| @@ -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 | |
| @@ -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> | |