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', dirname( __FILE__ ) ), array(), '1.10', 'all' ); } else { wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.11', 'all' ); } } /** * Render Clone page. */ public static function render() { $uploadError = false; $uploadFile = false; if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_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 = __( 'File could not be uploaded.', 'mainwp-child' ); } } else { $uploadError = __( '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 $wp_filesystem; if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! 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 = __( 'File could not be uploaded.', 'mainwp-child' ); } } else { $uploadError = __( '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(); ?>

is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! 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; } ?>

)

get_branding_title(); if ( '' != $branding_title ) { $branding_msg = 'If you have a FULL backup created by basic ' . esc_html( 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. */ private static function render_clone_from_server() { $page = $_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 = stripslashes( rawurldecode( $_REQUEST['dir'] ) ); $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; } } 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 = esc_url( add_query_arg( array( 'dir' => rawurlencode( $adir ) ), $url ) ); $dirparts = '' . $part . DIRECTORY_SEPARATOR . '' . $dirparts; } echo '
' . __( 'Current Directory: ' . $dirparts . '', 'mainwp-child' ) . '
'; $quick_dirs = array(); $quick_dirs[] = array( __( 'Site Root', 'mainwp-child' ), ABSPATH ); $quick_dirs[] = array( __( 'Backup', 'mainwp-child' ), $backup_dir ); $uploads = wp_upload_dir(); if ( $uploads && false === $uploads['error'] ) { $quick_dirs[] = array( __( 'Uploads Folder', 'mainwp-child' ), $uploads['path'] ); } $quick_dirs[] = array( __( '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 = esc_url( add_query_arg( array( 'dir' => rawurlencode( $adir ) ), $url ) ); $quick_links[] = "$text"; } if ( ! empty( $quick_links ) ) { echo '
' . esc_html__( 'Quick Jump:', 'mainwp-child' ) . ' ' . __( implode( ' | ', $quick_links ) ) . '
'; } 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. */ 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; } else { if ( ! MainWP_Clone::is_archive( $file ) ) { $rejected_files[] = $file; } else { $files[] = $file; } } } sort( $directories ); sort( $files ); $parent = dirname( $current_dir ); ?>

rawurlencode( $filename ) ), $url ) ); ?>
.
' ); } self::render_style(); ?>