| @@ -1,5 +1,5 @@ | ||
| 1 | -<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?> | |
| 1 | +<?php if (!defined('ABSPATH')) die('No direct access allowed'); ?> | |
| 2 | 2 | |
| 3 | 3 | <table id="optimizations_list" class="wp-list-table widefat striped"> |
| 4 | 4 | <thead> |
| 5 | 5 | <tr> |
| @@ -10,30 +10,11 @@ | ||
| 10 | 10 | </tr> |
| 11 | 11 | </thead> |
| 12 | 12 | <tbody> |
| 13 | 13 | <?php |
| 14 | - $optimizations = $optimizer->sort_optimizations($optimizer->get_optimizations()); | |
| 15 | 14 | |
| 16 | - foreach ($optimizations as $id => $optimization) { | |
| 17 | - if ('optimizetables' == $id && false === $does_server_allows_table_optimization) continue; | |
| 18 | - // If we don't want to show optimization on the first tab. | |
| 19 | - if (false === $optimization->display_in_optimizations_list()) continue; | |
| 20 | - // This is an array, with attributes dom_id, activated, settings_label, info; all values are strings. | |
| 21 | - $use_ajax = defined('WP_OPTIMIZE_DEBUG_OPTIMIZATIONS') && WP_OPTIMIZE_DEBUG_OPTIMIZATIONS ? false : true; | |
| 22 | - $html = $optimization->get_settings_html($use_ajax); | |
| 23 | - $disable_optimization_button = false; | |
| 15 | + foreach ($items as $optimization) { | |
| 24 | 16 | |
| 25 | - // Check if the DOM is optimize-db to generate a list of tables. | |
| 26 | - if ('optimize-db' == $html['dom_id']) { | |
| 27 | - $table_list = $optimizer->get_table_information(); | |
| 28 | - | |
| 29 | - // Make sure that optimization_table_inno_db is set. | |
| 30 | - if ($table_list['inno_db_tables'] > 0 && 0 == $table_list['is_optimizable'] && 0 == $table_list['non_inno_db_tables']) { | |
| 31 | - $disable_optimization_button = true; | |
| 32 | - $html['activated'] = ''; | |
| 33 | - } | |
| 34 | - } | |
| 35 | - | |
| 36 | 17 | $sensitive_items = array( |
| 37 | 18 | 'clean-transient', |
| 38 | 19 | 'clean-pingbacks', |
| 39 | 20 | 'clean-trackbacks', |
| @@ -43,42 +24,31 @@ | ||
| 43 | 24 | 'clean-usermeta', |
| 44 | 25 | ); |
| 45 | 26 | |
| 46 | 27 | ?> |
| 47 | - <tr class="wp-optimize-settings wp-optimize-settings-<?php echo esc_attr($html['dom_id']); ?><?php echo (in_array($html['dom_id'], $sensitive_items)) ? ' wp-optimize-setting-is-sensitive' : ''; ?>" id="wp-optimize-settings-<?php echo esc_attr($html['dom_id']); ?>" data-optimization_id="<?php echo esc_attr($id); ?>" data-optimization_run_sort_order="<?php echo esc_attr($optimization->get_run_sort_order()); ?>" > | |
| 28 | + <tr class="wp-optimize-settings wp-optimize-settings-<?php echo esc_attr($optimization['dom_id']); ?><?php echo (in_array($optimization['dom_id'], $sensitive_items)) ? ' wp-optimize-setting-is-sensitive' : ''; ?>" id="wp-optimize-settings-<?php echo esc_attr($optimization['dom_id']); ?>" data-optimization_id="<?php echo esc_attr($optimization['id']); ?>" data-optimization_run_sort_order="<?php echo esc_attr($optimization['run_sort_order']); ?>" > | |
| 48 | 29 | <?php |
| 49 | - if (!empty($html['settings_label'])) { | |
| 30 | + if (!empty($optimization['settings_label'])) { | |
| 50 | 31 | ?> |
| 51 | 32 | |
| 52 | 33 | <th class="wp-optimize-settings-optimization-checkbox check-column"> |
| 53 | - <input name="<?php echo esc_attr($html['dom_id']); ?>" id="optimization_checkbox_<?php echo esc_attr($id); ?>" class="optimization_checkbox" type="checkbox" value="true" <?php echo ($html['activated']) ? 'checked="checked"' : ''; ?> <?php echo $disable_optimization_button ? 'data-disabled="1" disabled' : ''; ?> > | |
| 34 | + <input name="<?php echo esc_attr($optimization['dom_id']); ?>" id="optimization_checkbox_<?php echo esc_attr($optimization['id']); ?>" class="optimization_checkbox" type="checkbox" value="true" <?php echo ($optimization['activated']) ? 'checked="checked"' : ''; ?> <?php echo $optimization['disable_optimization_button'] ? 'data-disabled="1" disabled' : ''; ?> > | |
| 54 | 35 | |
| 55 | - <img id="optimization_spinner_<?php echo esc_attr($id); ?>" class="optimization_spinner display-none" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" alt="..."> | |
| 36 | + <img id="optimization_spinner_<?php echo esc_attr($optimization['id']); ?>" class="optimization_spinner display-none" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" alt="..."> | |
| 56 | 37 | </th> |
| 57 | 38 | |
| 58 | 39 | |
| 59 | 40 | <td> |
| 60 | - <label for="optimization_checkbox_<?php echo esc_attr($id); ?>"><?php echo esc_html($html['settings_label']); ?></label> | |
| 61 | - <div class="wp-optimize-settings-optimization-info" id="optimization_info_<?php echo esc_attr($id); ?>"> | |
| 62 | - <?php | |
| 63 | - if ($use_ajax && array_key_exists('support_ajax_get_info', $html) && $html['support_ajax_get_info']) { | |
| 64 | - $last_output = $optimization->get_last_output(); | |
| 65 | - if ($last_output) { | |
| 66 | - echo join('<br>', $last_output); | |
| 67 | - } else { | |
| 68 | - echo '<span class="wp-optimize-optimization-info-ajax" data-id="'.esc_attr($id).'">...</span>'; | |
| 69 | - } | |
| 70 | - } else { | |
| 71 | - echo join('<br>', $html['info']); | |
| 72 | - } | |
| 73 | - ?> | |
| 41 | + <label for="optimization_checkbox_<?php echo esc_attr($optimization['id']); ?>"><?php echo esc_html($optimization['settings_label']); ?></label> | |
| 42 | + <div class="wp-optimize-settings-optimization-info" id="optimization_info_<?php echo esc_attr($optimization['id']); ?>"> | |
| 43 | + <?php echo $optimization['info_raw']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output already escaped ?> | |
| 74 | 44 | </div> |
| 75 | 45 | </td> |
| 76 | 46 | |
| 77 | 47 | <td class="wp-optimize-settings-optimization-run"> |
| 78 | - <button id="optimization_button_<?php echo esc_attr($id); ?>_big" class="button button-secondary wp-optimize-settings-optimization-run-button show_on_default_sizes optimization_button_<?php echo esc_attr($id); ?>" type="button" <?php echo $disable_optimization_button ? 'data-disabled="1" disabled' : ''; ?> ><?php esc_html_e('Run optimization', 'wp-optimize'); ?></button> | |
| 48 | + <button id="optimization_button_<?php echo esc_attr($optimization['id']); ?>_big" class="button button-secondary wp-optimize-settings-optimization-run-button show_on_default_sizes optimization_button_<?php echo esc_attr($optimization['id']); ?>" type="button" <?php echo $optimization['disable_optimization_button'] ? 'data-disabled="1" disabled' : ''; ?> ><?php esc_html_e('Run optimization', 'wp-optimize'); ?></button> | |
| 79 | 49 | |
| 80 | - <button id="optimization_button_<?php echo esc_attr($id); ?>_small" class="button button-secondary wp-optimize-settings-optimization-run-button show_on_mobile_sizes optimization_button_<?php echo esc_attr($id); ?>" type="button" <?php echo $disable_optimization_button ? 'data-disabled="1" disabled' : ''; ?> ><?php esc_html_e('Go', 'wp-optimize'); ?></button> | |
| 50 | + <button id="optimization_button_<?php echo esc_attr($optimization['id']); ?>_small" class="button button-secondary wp-optimize-settings-optimization-run-button show_on_mobile_sizes optimization_button_<?php echo esc_attr($optimization['id']); ?>" type="button" <?php echo $optimization['disable_optimization_button'] ? 'data-disabled="1" disabled' : ''; ?> ><?php esc_html_e('Go', 'wp-optimize'); ?></button> | |
| 81 | 51 | </td> |
| 82 | 52 | |
| 83 | 53 | <?php } ?> |
| 84 | 54 | </tr> |
| @@ -83,5 +53,50 @@ | ||
| 83 | 53 | <?php } ?> |
| 84 | 54 | </tr> |
| 85 | 55 | <?php } ?> |
| 86 | 56 | </tbody> |
| 87 | -</table> | |
| 57 | +</table> | |
| 58 | + | |
| 59 | +<script type="text/html" id="tmpl-wpo-postmeta"> | |
| 60 | + <h3><span class="dashicons dashicons-warning"></span> <?php esc_html_e('Are you sure you want to clean post metadata?', 'wp-optimize'); ?></h3> | |
| 61 | + <div class="notice notice-warning"> | |
| 62 | + <p><?php echo esc_html__('WARNING', 'wp-optimize') . ' - ' . esc_html__('Only clean post metadata if you are sure of what you are doing, and after taking a backup with UpdraftPlus plugin', 'wp-optimize'); ?></p> | |
| 63 | + </div> | |
| 64 | + <h4><?php echo esc_html__('You are about to remove posts metadata.', 'wp-optimize'); ?></h4> | |
| 65 | + <p> | |
| 66 | + <input type="checkbox" id="confirm_post_meta_deletion"> <label for="confirm_post_meta_deletion"><?php esc_html_e('I have taken a backup and I want to continue with this optimization.', 'wp-optimize'); ?></label> | |
| 67 | + </p> | |
| 68 | + <p> | |
| 69 | + <input type="checkbox" id="ignores_post_meta_deletion_warning"> <label for="ignores_post_meta_deletion_warning"><?php esc_html_e('Do not show this warning again.', 'wp-optimize'); ?></label> | |
| 70 | + </p> | |
| 71 | + <button type="button" id="confirm-post-meta-delete-action" class="button button-primary delete-post-meta" disabled><?php esc_html_e('Remove posts metadata', 'wp-optimize'); ?></button> | |
| 72 | + <button type="button" class="button cancel wpo-modal--close"><?php esc_html_e('Cancel', 'wp-optimize'); ?></button> | |
| 73 | +</script> | |
| 74 | + | |
| 75 | +<script type="text/html" id="tmpl-wpo-orphandata"> | |
| 76 | + <h3><span class="dashicons dashicons-warning"></span> <?php esc_html_e('Are you sure you want to clean orphaned relationship data?', 'wp-optimize'); ?></h3> | |
| 77 | + <div class="notice notice-warning"> | |
| 78 | + <p><?php echo esc_html__('WARNING', 'wp-optimize') . ' - ' . esc_html__('Only clean orphaned relationship data if you are sure of what you are doing, and after taking a backup with UpdraftPlus plugin', 'wp-optimize'); ?></p> | |
| 79 | + </div> | |
| 80 | + <h4><?php echo esc_html__('You are about to remove orphaned relationship data.', 'wp-optimize'); ?></h4> | |
| 81 | + <p> | |
| 82 | + <input type="checkbox" id="confirm_orphaned_relationship_data_deletion"> <label for="confirm_orphaned_relationship_data_deletion"><?php esc_html_e('I want to continue with this optimization.', 'wp-optimize'); ?></label> | |
| 83 | + </p> | |
| 84 | + <p> | |
| 85 | + <input type="checkbox" id="ignores_orphaned_relationship_data_deletion_warning"> <label for="ignores_orphaned_relationship_data_deletion_warning"><?php esc_html_e('Do not show this warning again.', 'wp-optimize'); ?></label> | |
| 86 | + </p> | |
| 87 | + <button type="button" id="confirm-orphaned-relationship-data-delete-action" class="button button-primary delete-orphaned-relationship-data" disabled><?php esc_html_e('Remove orphaned relationship data', 'wp-optimize'); ?></button> | |
| 88 | + <button type="button" class="button cancel wpo-modal--close"><?php esc_html_e('Cancel', 'wp-optimize'); ?></button> | |
| 89 | +</script> | |
| 90 | + | |
| 91 | +<script type="text/html" id="tmpl-wpo-grouped-warnings"> | |
| 92 | + <h3><span class="dashicons dashicons-warning"></span> <?php esc_html_e('Please review these actions that are about to run', 'wp-optimize'); ?></h3> | |
| 93 | + <div class="notice notice-warning"> | |
| 94 | + [[warning_messages]] | |
| 95 | + </div> | |
| 96 | + <h4><?php echo esc_html__('You are about to remove sensible data.', 'wp-optimize'); ?></h4> | |
| 97 | + <p> | |
| 98 | + <input type="checkbox" id="confirm_grouped_warnings_data_deletion"> <label for="confirm_grouped_warnings_data_deletion"><?php esc_html_e('I want to continue with these optimizations.', 'wp-optimize'); ?></label> | |
| 99 | + </p> | |
| 100 | + <button type="button" id="confirm-grouped-warnings-data-delete-action" class="button button-primary delete-grouped-warnings-data" disabled><?php esc_html_e('Apply optimization', 'wp-optimize'); ?></button> | |
| 101 | + <button type="button" class="button cancel wpo-modal--close"><?php esc_html_e('Cancel', 'wp-optimize'); ?></button> | |
| 102 | +</script> | |