| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | -if (!defined('WPO_VERSION')) die('No direct access allowed'); | |
| 2 | +if (!defined('ABSPATH')) die('No direct access allowed'); | |
| 3 | 3 | |
| 4 | 4 | ?> |
| 5 | 5 | <div class="wpo_shade hidden"> |
| 6 | 6 | <div class="wpo_shade_inner"> |
| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | echo '<div id="message" class="updated below-h2"><strong>'; |
| 17 | 17 | foreach ($optimization_results as $optimization_result) { |
| 18 | 18 | if (!empty($optimization_result->output)) { |
| 19 | 19 | foreach ($optimization_result->output as $line) { |
| 20 | - echo $line."<br>"; | |
| 20 | + echo wp_kses_post($line)."<br>"; | |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | echo '</strong></div>'; |
| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | echo '</strong></div>'; |
| 25 | 25 | } |
| 26 | 26 | ?> |
| 27 | 27 | |
| 28 | - <?php WP_Optimize()->include_template('database/status-box-contents.php', false, array('optimize_db' => false)); ?> | |
| 28 | + <?php WP_Optimize()->include_template('database/status-box-contents.php', false, $status_data); ?> | |
| 29 | 29 | <?php |
| 30 | 30 | $message = __('Warning: This operation is permanent.', 'wp-optimize'); |
| 31 | 31 | $message .= ' '; |
| 32 | 32 | $message .= __('Continue?', 'wp-optimize'); |
| @@ -36,10 +36,12 @@ | ||
| 36 | 36 | <?php wp_nonce_field('wpo_optimization'); ?> |
| 37 | 37 | |
| 38 | 38 | <h3><?php esc_html_e('Optimizations', 'wp-optimize'); ?></h3> |
| 39 | 39 | |
| 40 | - | |
| 41 | 40 | <div class="wpo-run-optimizations__container"> |
| 41 | + <?php if ($should_show_load_in_batches_button) : ?> | |
| 42 | + <button type="button" id="wpo-load-tables-in-batches" class="button button-primary button-large"><?php echo esc_html__('Reload database tables in batches', 'wp-optimize'); ?></button> | |
| 43 | + <?php endif; ?> | |
| 42 | 44 | <?php $button_caption = apply_filters('wpo_run_button_caption', __('Run all selected optimizations', 'wp-optimize')); ?> |
| 43 | 45 | <input class="button button-primary button-large" type="submit" id="wp-optimize" name="wp-optimize" value="<?php echo esc_attr($button_caption); ?>"><?php WP_Optimize()->include_template('take-a-backup.php', false, array('checkbox_name' => 'enable-auto-backup')); ?> |
| 44 | 46 | </div> |
| 45 | 47 | |
| @@ -46,9 +48,9 @@ | ||
| 46 | 48 | <?php do_action('wpo_additional_options'); ?> |
| 47 | 49 | |
| 48 | 50 | <?php |
| 49 | 51 | if ($load_data) { |
| 50 | - WP_Optimize()->include_template('database/optimizations-table.php', false, array('does_server_allows_table_optimization' => $does_server_allows_table_optimization)); | |
| 52 | + WP_Optimize()->include_template('database/optimizations-table.php', false, $optimizations_table_data); | |
| 51 | 53 | } else { |
| 52 | 54 | ?> |
| 53 | 55 | <div class="wp-optimize-optimizations-table-placeholder"> |
| 54 | 56 | </div> |
| @@ -69,4 +71,56 @@ | ||
| 69 | 71 | ?> |
| 70 | 72 | </p> |
| 71 | 73 | </form> |
| 72 | 74 | </div> |
| 75 | +<?php if ($should_show_load_in_batches_button) : ?> | |
| 76 | +<?php | |
| 77 | +// Determine scan offset | |
| 78 | +$scan_job_offset = ($total_table_count === $done_table_count) ? 0 : $done_table_count; | |
| 79 | + | |
| 80 | +// Escape values once for reuse | |
| 81 | +$total_table_count_esc = esc_html($total_table_count); | |
| 82 | +$scan_job_offset_esc = esc_js($scan_job_offset); | |
| 83 | +?> | |
| 84 | +<div id="wpo-too-many-tables-popup" class="wpo-modal--container wpo-too-many-tables" style="display:none;"> | |
| 85 | + <div class="wpo-modal--bg"></div> | |
| 86 | + <div class="wpo-modal" style="text-align:center; max-width:600px;"> | |
| 87 | + <button type="button" class="wpo-modal--close wpo-too-many-tables-close"> | |
| 88 | + <span class="dashicons dashicons-no"></span> | |
| 89 | + <span class="screen-reader-text"><?php esc_html_e('Close', 'wp-optimize'); ?></span> | |
| 90 | + </button> | |
| 91 | + <div class="wpo-modal--content"> | |
| 92 | + <p> | |
| 93 | + <?php | |
| 94 | + printf( | |
| 95 | + /* translators: %s = total number of tables */ | |
| 96 | + esc_html__( | |
| 97 | + 'You have a total of %s tables which will take some time to load.', | |
| 98 | + 'wp-optimize' | |
| 99 | + ) . ' ' . esc_html__( | |
| 100 | + 'Click the button below and please wait while it loads all the tables.', | |
| 101 | + 'wp-optimize' | |
| 102 | + ), | |
| 103 | + $total_table_count_esc // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output already escaped | |
| 104 | + ); | |
| 105 | + ?> | |
| 106 | + </p> | |
| 107 | + <p> | |
| 108 | + <button id="wpo-load-tables-in-batches-button" class="button button-primary button-large"> | |
| 109 | + <?php | |
| 110 | + echo (0 === $scan_job_offset) ? esc_html__('Load Tables', 'wp-optimize') : esc_html__('Continue Loading Tables', 'wp-optimize'); | |
| 111 | + ?> | |
| 112 | + </button> | |
| 113 | + </p> | |
| 114 | + <div id="wpo-load-tables-in-batches-progress"></div> | |
| 115 | + <div id="wpo-load-tables-eta"></div> | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | +</div> | |
| 119 | +<script> | |
| 120 | + var wpo_table_scan_offset = <?php echo $scan_job_offset_esc; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output already escaped ?>; | |
| 121 | +</script> | |
| 122 | +<?php endif; ?> | |
| 123 | +<script> | |
| 124 | + var wpo_too_many_tables = <?php echo $too_many_tables ? 'true' : 'false'; ?>; | |
| 125 | + var wpo_onboarding_active = <?php echo $onboarding_active ? 'true' : 'false'; ?>; | |
| 126 | +</script> | |