Ejemplo n.º 1
0
        /**
         * Callback function for the Migration Files to Transfer meta box.
         *
         * @param $wpmove_options Plugin settings array
         * @return void
         */
        function metabox_ma_migrate_filetree()
        {
            ?>
			<p id="wpmove_file_tree_buttons" style="display: none;">
				<input type="button" name="wpmove_file_tree_check_all" id="wpmove_file_tree_check_all" class="button-secondary" value="<?php 
            _e('Select All', 'WPMove');
            ?>
" />
				<input type="button" name="wpmove_file_tree_uncheck_all" id="wpmove_file_tree_uncheck_all" class="button-secondary" value="<?php 
            _e('Unselect All', 'WPMove');
            ?>
" />
				<input type="button" name="wpmove_toggle_change_domain_name" id="wpmove_toggle_change_domain_name" class="button-secondary" value="<?php 
            _e('Change Domain Name', 'WPMove');
            ?>
" style="display:none;" />
			</p>
			<blockquote>
				<?php 
            // To use as a file ID
            $i = 0;
            // List all of the files inside the main directory
            $abspath = substr(ABSPATH, 0, strlen(ABSPATH) - 1);
            $files = wpmove_generate_file_tree($abspath, FALSE, array(WPMOVE_DIR, WPMOVE_BACKUP_DIR, WPMOVE_OLD_BACKUP_DIR));
            ?>
				<div id="wpmove_file_tree" style="display:none;">
					<ul>
						<?php 
            wpmove_display_file_tree($files);
            ?>
					</ul>
				</div>
				<div id="wpmove_file_tree_loading" style="display:none;">
					<?php 
            echo '<img src="' . WPMOVE_URL . '/libs/js/themes/default/throbber.gif" alt="' . __('Loading...', 'WPMove') . '" style="vertical-align:middle;" /> <strong>' . __('Loading...', 'WPMove') . '</strong>';
            ?>
				</div>
				<noscript>
					<?php 
            // Prepare the file list
            $files = wpmove_list_all_files($abspath, FALSE, array(WPMOVE_DIR, WPMOVE_BACKUP_DIR, WPMOVE_OLD_BACKUP_DIR));
            // Display each file with a checked checkbox
            foreach ($files as $file) {
                if (is_file($file)) {
                    $short_path = str_replace(ABSPATH, '', $file);
                    echo '<input id="file-' . $i . '" name="files[]" type="checkbox" value="' . $file . '" checked> <label for="file-' . $i++ . '"><span class="code">' . $short_path . '</span></label><br>';
                }
            }
            ?>
				</noscript>
			</blockquote>
			<?php 
        }
/**
 * Generates a classic file tree.
 *
 * @param	string	$directory			Directory to list the files of
 * @param	bool	$ignore_directories	Ignores sub directories if set to TRUE
 * @return	array	$tree				Generated tree
 */
function wpmove_generate_file_tree($directory, $ignore_directories = FALSE, $ommit = array())
{
    $files = array();
    $directories = array();
    if (is_array($fileList = glob($directory . "/*"))) {
        foreach ($fileList as $file) {
            if (is_file($file)) {
                array_push($files, $file);
            } elseif (!$ignore_directories) {
                $skip = FALSE;
                foreach ($ommit as $dir) {
                    if ($file == $dir) {
                        $skip = TRUE;
                    }
                }
                if (!$skip) {
                    array_push($directories, $file);
                    array_push($directories, wpmove_generate_file_tree($file, FALSE, $ommit));
                }
            }
        }
    }
    $tree = array_merge($directories, $files);
    return $tree;
}