query( 'jquery-ui-core' ); $version = $ui->ver; if ( MainWP_Helper::starts_with( $version, '1.10' ) ) { wp_enqueue_style( 'jquery-ui-style', plugins_url( 'css/1.10.4/jquery-ui.min.css', __DIR__ ), array(), '1.10', 'all' ); } else { wp_enqueue_style( 'jquery-ui-style', plugins_url( 'css/1.11.1/jquery-ui.min.css', __DIR__ ), array(), '1.11', 'all' ); } } /** * Render Clone page. * * @uses \MainWP\Child\MainWP_Clone::get_class_name() * @uses \MainWP\Child\MainWP_Helper::return_bytes() * @uses \MainWP\Child\MainWP_Helper::human_filesize() * @uses \MainWP\Child\MainWP_Helper::get_wp_filesystem() */ public static function render() { $uploadError = false; $uploadFile = false; if ( isset( $_REQUEST['_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_nonce'] ) ), 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = isset( $_FILES['file'] ) ? sanitize_text_field( wp_unslash( $_FILES['file'] ) ) : ''; $upload_overrides = array( 'test_form' => false ); add_filter( 'upload_mimes', array( MainWP_Clone::get_class_name(), 'upload_mimes' ) ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile ) { $uploadFile = str_replace( ABSPATH, '', $movefile['file'] ); } else { $uploadError = esc_html__( 'File could not be uploaded.', 'mainwp-child' ); } } else { $uploadError = esc_html__( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'mainwp-child' ); } } $sitesToClone = get_option( 'mainwp_child_clone_sites' ); $uploadSizeInBytes = min( MainWP_Helper::return_bytes( ini_get( 'upload_max_filesize' ) ), MainWP_Helper::return_bytes( ini_get( 'post_max_size' ) ) ); $uploadSize = MainWP_Helper::human_filesize( $uploadSizeInBytes ); self::render_style(); if ( '0' === $sitesToClone ) { echo '
' . esc_html__( 'Cloning is currently off - To turn on return to your main dashboard and turn cloning on on the Clone page.', 'mainwp-child' ) . '
'; return; } $error = false; MainWP_Helper::get_wp_filesystem(); /** * Global variable containing the instance of the (auto-)configured filesystem object after the filesystem "factory" has been run. * * @global object $wp_filesystem Filesystem object. */ global $wp_filesystem; if ( ! MainWP_Helper::is_writable( WP_CONTENT_DIR ) ) { echo '
' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')
'; $error = true; } ?>
' . esc_html__( 'Cloning is currently on but no sites have been allowed, to allow sites return to your main dashboard and turn cloning on on the Clone page.', 'mainwp-child' ) . ''; } else { ?>

$siteToClone ) { ?>
MB


)




false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile ) { $uploadFile = str_replace( ABSPATH, '', $movefile['file'] ); } else { $uploadError = esc_html__( 'File could not be uploaded.', 'mainwp-child' ); } } else { $uploadError = esc_html__( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'mainwp-child' ); } } $uploadSizeInBytes = min( MainWP_Helper::return_bytes( ini_get( 'upload_max_filesize' ) ), MainWP_Helper::return_bytes( ini_get( 'post_max_size' ) ) ); $uploadSize = MainWP_Helper::human_filesize( $uploadSizeInBytes ); self::render_style(); ?>

' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')
'; $error = true; } ?>

)

get_branding_title(); if ( '' !== $branding_title ) { $branding_msg = 'If you have a FULL backup created by basic ' . stripslashes( $branding_title ) . ' Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.'; } else { $branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' ); } ?>


Note: All files are copied to the uploads directory. * Author: Dion Hulse * Author URI: http://dd32.id.au/ */ /** * Render Clone from server * Allows the Media Manager to add files from the webservers filesystem. Note: All files are copied to the uploads directory. * * @uses \MainWP\Child\MainWP_Helper::get_mainwp_dir() * @uses \MainWP\Child\MainWP_Helper::update_option() */ private static function render_clone_from_server() { // phpcs:disable WordPress.Security.NonceVerification $page = isset( $_REQUEST['page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : ''; $sitesToClone = get_option( 'mainwp_child_clone_sites' ); $url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup', false ); $current_dir = $dirs[0]; $backup_dir = $current_dir; if ( isset( $_REQUEST['dir'] ) ) { $current_dir = isset( $_REQUEST['dir'] ) ? stripslashes( rawurldecode( wp_unslash( $_REQUEST['dir'] ) ) ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $current_dir = '/' . ltrim( $current_dir, '/' ); if ( ! is_readable( $current_dir ) && get_option( 'mainwp_child_clone_from_server_last_folder' ) ) { $current_dir = get_option( 'mainwp_child_clone_from_server_last_folder' ) . $current_dir; } } // phpcs:enable if ( ! is_readable( $current_dir ) ) { $current_dir = WP_CONTENT_DIR; } $current_dir = str_replace( '\\', '/', $current_dir ); if ( strlen( $current_dir ) > 1 ) { $current_dir = untrailingslashit( $current_dir ); } echo '
'; echo '

' . esc_html__( 'Option 2:', 'mainwp-child' ) . ' ' . esc_html__( 'Restore/Clone From Server', 'mainwp-child' ) . '

'; echo '
'; echo '' . esc_html__( 'If you have uploaded a FULL backup to your server (via FTP or other means) you can use this section to locate the zip file and select it. A database only backup will not work.', 'mainwp-child' ) . ''; if ( ! is_readable( $current_dir ) ) { echo '
' . esc_html__( 'Root directory is not readable. Please contact with site administrator to correct.', 'mainwp-child' ) . '
'; return; } MainWP_Helper::update_option( 'mainwp_child_clone_from_server_last_folder', rtrim( $current_dir, '/' ) ); $parts = explode( '/', ltrim( $current_dir, '/' ) ); $dirparts = ''; $count_parts = count( $parts ); for ( $i = $count_parts - 1; $i >= 0; $i-- ) { $part = $parts[ $i ]; $adir = implode( '/', array_slice( $parts, 0, $i + 1 ) ); if ( strlen( $adir ) > 1 ) { $adir = ltrim( $adir, '/' ); } $durl = add_query_arg( array( 'dir' => rawurlencode( $adir ) ), $url ); $dirparts = '' . $part . DIRECTORY_SEPARATOR . '' . $dirparts; } echo '
' . sprintf( esc_html__( '%1$sCurrent Directory:%2$s %3$s', 'mainwp-child' ), '', '', '' . $dirparts . '' ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput $quick_dirs = array(); $quick_dirs[] = array( esc_html__( 'Site Root', 'mainwp-child' ), ABSPATH ); $quick_dirs[] = array( esc_html__( 'Backup', 'mainwp-child' ), $backup_dir ); $uploads = wp_upload_dir(); if ( $uploads && false === $uploads['error'] ) { $quick_dirs[] = array( esc_html__( 'Uploads Folder', 'mainwp-child' ), $uploads['path'] ); } $quick_dirs[] = array( esc_html__( 'Content Folder', 'mainwp-child' ), WP_CONTENT_DIR ); $quick_links = array(); foreach ( $quick_dirs as $dir ) { list( $text, $adir ) = $dir; $adir = str_replace( '\\', '/', strtolower( $adir ) ); if ( strlen( $adir ) > 1 ) { $adir = ltrim( $adir, '/' ); } $durl = add_query_arg( array( 'dir' => rawurlencode( $adir ) ), $url ); $quick_links[] = "" . esc_html( $text ) . ''; } if ( ! empty( $quick_links ) ) { echo '
' . esc_html__( 'Quick Jump:', 'mainwp-child' ) . ' ' . implode( ' | ', $quick_links ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput } self::render_clone_from_server_form( $current_dir, $url ); } /** * Render clone from server form. * * @param string $current_dir Current parent directory. * @param string $url URL of file to upload. * * @uses MainWP_Clone::is_archive() */ private static function render_clone_from_server_form( $current_dir, $url ) { $dir_files = scandir( $current_dir ); $directories = array(); $files = array(); $rejected_files = array(); foreach ( (array) $dir_files as $file ) { if ( in_array( $file, array( '.', '..' ) ) ) { continue; } if ( is_dir( $current_dir . '/' . $file ) ) { $directories[] = $file; } elseif ( ! MainWP_Clone::is_archive( $file ) ) { $rejected_files[] = $file; } else { $files[] = $file; } } sort( $directories ); sort( $files ); $parent = dirname( $current_dir ); ?>

rawurlencode( $filename ) ), $url ) ); ?>
.