/** * 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 }
/** * Displays the file tree using the given array of files * * @param array $files Array of files in a tree form * @return integer $i Updates counter to make sure every item has a unique ID */ function wpmove_display_file_tree($files, $i = 0) { foreach ($files as $file) { if (!is_array($file)) { if (is_file($file)) { echo '<li id="file-' . $i++ . '" rel="file"><a href="#" title="' . $file . '">' . basename($file) . '</a></li>'; } elseif (count(@scandir($file)) > 2) { echo '<li id="dir-' . $i++ . '" rel="directory"><a href="#" title="">' . basename($file) . '</a><ul>'; } else { echo '<li id="dir-' . $i++ . '" rel="directory"><a href="#" title="' . $file . '">' . basename($file) . '</a><ul>'; } } else { $i = wpmove_display_file_tree($file, $i); } } echo '</ul></li>'; return $i; }