PluginProbe
SweepPress: Website Cleanup and Optimization / 2.4
SweepPress: Website Cleanup and Optimization v2.4
trunk 1.1 1.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.8 2.0 2.1 2.1.1 2.2 2.3 2.3.1 2.4 2.4.1 2.4.2 2.5 2.6 3.0 3.1 3.1.1 3.2 All 39 releases
sweeppress / forms / content-sweep.php

content-sweep.php in SweepPress: Website Cleanup and Optimization 2.4, at forms/content-sweep.php

214 lines 8.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Dev4Press\Plugin\SweepPress\Basic\Database;
4 use Dev4Press\v43\Core\Quick\Sanitize;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 $method = sweeppress_settings()->get_method();
11 $list = sweeppress_core()->available();
12
13 $total = 0;
14 $active = 0;
15 $items = array();
16 $categories = array();
17 $status = array();
18
19 foreach ( $list as $category => $sweepers ) {
20 $active_for_category = 0;
21
22 foreach ( $sweepers as $sweeper ) {
23 $status[ $sweeper->get_code() ] = $method == 'normal' || ( $method == 'partial' && ! $sweeper->has_high_system_requirements() );
24
25 if ( ! $status[ $sweeper->get_code() ] && $sweeper->has_cached_data() ) {
26 $status[ $sweeper->get_code() ] = true;
27 }
28
29 $total ++;
30
31 if ( $status[ $sweeper->get_code() ] && $sweeper->is_sweepable() ) {
32 $active ++;
33 $active_for_category ++;
34 }
35 }
36
37 $categories[ $category ] = $active_for_category;
38 }
39
40 Database::instance();
41
42 ?>
43 <div class="d4p-content d4p-sweeper-content">
44 <?php require( SWEEPPRESS_PATH . 'forms/misc-notices-backup.php' ); ?>
45
46 <div id="sweeppress-results-wrapper" class="d4p-group" style="max-width: 1000px" hidden>
47 <h3><?php esc_html_e( 'Sweep Progress Report', 'sweeppress' ); ?></h3>
48 <div class="d4p-group-inner">
49 <div id="sweeppress-results-sweeper">
50 <div class="sweeppress-results-loader">
51 <i class="d4p-icon d4p-ui-spinner d4p-icon-spin"></i>
52 <span><?php esc_html_e( 'Please wait for the sweeping to finish...', 'sweeppress' ); ?></span>
53 </div>
54 </div>
55 </div>
56 </div>
57 <div class="sweeppress-sweepers-wrapper">
58 <div class="sweeppress-sweepers-controls">
59 <dl>
60 <dt><?php esc_html_e( 'Sweepers Available', 'sweeppress' ); ?></dt>
61 <dd>
62 <?php
63
64 echo sprintf( esc_html__( 'Active: %s / Total: %s', 'sweeppress' ), '<strong>' . esc_html( $active ) . '</strong>', '<strong>' . esc_html( $total ) . '</strong>' );
65
66 if ( $active < $total ) {
67 echo '<button class="toggle-empty-tasks" type="button" title="' . esc_attr__( 'Toggle Empty Sweepers', 'sweeppress' ) . '" aria-expanded="false"><i aria-hidden="true" class="d4p-icon d4p-ui-eye"></i></button>';
68 }
69
70 ?>
71 </dd>
72 </dl>
73 </div>
74
75 <?php
76
77 foreach ( $list as $category => $sweepers ) {
78 echo '<h4 data-cat="' . esc_attr( $category ) . '" id="sweeper-category-' . esc_attr( $category ) . '" class="sweeper-category-label ' . ( $categories[ $category ] == 0 ? 'empty-sweeper-category' : '' ) . '">' . esc_html( sweeppress_core()->get_category_label( $category ) ) . '</h4>';
79
80 foreach ( $sweepers as $sweeper ) {
81 $run = $status[ $sweeper->get_code() ];
82 $is = $run && $sweeper->is_sweepable();
83
84 $classes = array(
85 'sweeppress-item-wrapper',
86 'sweeppress-item-cat-' . $sweeper->get_category(),
87 );
88
89 if ( $run && ! $is ) {
90 $classes[] = 'empty-sweeper';
91 }
92
93 $affected_tables = $sweeper->affected_tables();
94
95 ?>
96
97 <div class="<?php echo Sanitize::html_classes( $classes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>">
98 <h5>
99 <?php
100
101 $_toggle = $is && $sweeper->has_empty_tasks() && ! $sweeper->is_no_size();
102
103 echo esc_html( $sweeper->title() );
104 echo '<button class="toggle-section toggle-help" type="button" title="' . esc_attr__( 'Toggle Help', 'sweeppress' ) . '" aria-expanded="false" aria-controls="sweeper-info-' . esc_attr( $sweeper->get_unique_id() ) . '"><i aria-hidden="true" class="d4p-icon d4p-ui-question-sqaure"></i></button>';
105
106 if ( ! empty( $sweeper->limitations() ) ) {
107 echo '<button class="toggle-section toggle-limits" type="button" title="' . esc_attr__( 'Toggle Limitations', 'sweeppress' ) . '" aria-expanded="false" aria-controls="sweeper-limit-' . esc_attr( $sweeper->get_unique_id() ) . '"><i aria-hidden="true" class="d4p-icon d4p-ui-exclamation-square"></i></button>';
108 }
109
110 if ( ! empty( $affected_tables ) ) {
111 echo '<button class="toggle-section toggle-tables" type="button" title="' . esc_attr__( 'Toggle Affected Tables', 'sweeppress' ) . '" aria-expanded="false" aria-controls="sweeper-tables-' . esc_attr( $sweeper->get_unique_id() ) . '"><i aria-hidden="true" class="d4p-icon d4p-ui-database"></i></button>';
112 }
113
114 echo '<button style="display: ' . ( $_toggle ? 'inline' : 'none' ) . '" class="toggle-empty" type="button" title="' . esc_attr__( 'Toggle Empty Tasks', 'sweeppress' ) . '" aria-expanded="false"><i aria-hidden="true" class="d4p-icon d4p-ui-eye"></i></button>';
115
116 if ( $sweeper->has_high_system_requirements() ) {
117 echo '<span class="flat-system" title="' . esc_attr__( 'This sweeper estimation process has high system requirements and it can be slow to estimate.', 'sweeppress' ) . '"><i class="d4p-icon d4p-ui-gauge-bolt"></i></span>';
118 }
119
120 echo '<input style="display: ' . ( $is ? 'block' : 'none' ) . '" class="sweeppress-sweeper-check" type="checkbox" />';
121
122 ?>
123 </h5>
124 <div class="sweeppress-item-help" hidden id="sweeper-info-<?php echo esc_attr( $sweeper->get_unique_id() ); ?>">
125 <p>
126 <?php echo esc_html( $sweeper->description() ); ?>
127 </p>
128 <?php
129
130 if ( ! empty( $sweeper->help() ) ) {
131 echo wp_kses_post( sweeppress_strings_array_to_list( $sweeper->help() ) );
132
133 $_last_used = sweeppress_settings()->get_sweeper_last_used_timestamp( $sweeper->get_code() );
134
135 if ( $_last_used > 0 ) {
136 echo '<div class="sweeppress-item-last-used">' . sprintf( esc_html__( 'This sweeper was last used: %s ago.', 'sweeppress' ), '<strong>' . human_time_diff( time(), $_last_used ) . '</strong>' ) . '</div>';
137 }
138 }
139
140 ?>
141 </div>
142 <?php
143
144 if ( ! empty( $affected_tables ) ) {
145 ?>
146
147 <div class="sweeppress-item-tables" hidden id="sweeper-tables-<?php echo esc_attr( $sweeper->get_unique_id() ); ?>">
148 <p><?php esc_html_e( 'This sweeper affects database tables listed below.', 'sweeppress' ); ?></p>
149 <ul>
150 <li><?php echo join( '</li><li>', $affected_tables ); ?></li>
151 </ul>
152 </div>
153
154 <?php
155 }
156
157 if ( ! empty( $sweeper->limitations() ) ) {
158 ?>
159
160 <div class="sweeppress-item-limit" hidden id="sweeper-limit-<?php echo esc_attr( $sweeper->get_unique_id() ); ?>">
161 <p><?php esc_html_e( 'This sweeper has few limitations listed below.', 'sweeppress' ); ?></p>
162 <?php echo wp_kses_post( sweeppress_strings_array_to_list( $sweeper->limitations() ) ); ?>
163 </div>
164
165 <?php
166 }
167
168 ?>
169 <div class="sweeppress-item-inside">
170 <?php
171
172 if ( $run ) {
173 include 'misc-sweep-single.php';
174 } else {
175 ?>
176
177 <div class="notice inline notice-info sweeppress-item-run">
178 <p><strong><?php
179
180 if ( $sweeper->has_high_system_requirements() ) {
181 esc_html_e( 'This sweeper estimation query can be slow, and based on your plugin performance settings and database size, it is not run automatically.', 'sweeppress' );
182 } else {
183 esc_html_e( 'Based on your plugin performance settings and database size, this sweeper estimate has not been run.', 'sweeppress' );
184 }
185
186 ?></strong></p>
187 <p>
188 <?php esc_html_e( 'Click the button to run this sweeper in the background.', 'sweeppress' ); ?>
189 </p>
190 <p>
191 <button data-sweeper="<?php echo esc_attr( $sweeper->get_code() ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'sweeppress-run-estimate-' . $sweeper->get_code() ) ); ?>" type="button" class="button-secondary"><?php esc_html_e( 'Estimate This Sweeper', 'sweeppress' ); ?></button>
192 </p>
193 </div>
194 <div class="sweeppress-item-run-loader">
195 <i class="d4p-icon d4p-ui-spinner d4p-icon-spin d4p-icon-fw"></i>
196 <span><?php esc_html_e( 'Please wait...', 'sweeppress' ); ?></span>
197 </div>
198
199 <?php
200 }
201
202 ?>
203 </div>
204 </div>
205
206 <?php
207 }
208 }
209
210 ?>
211 </div>
212 <input type="hidden" value="<?php echo wp_create_nonce( 'sweeppress-sweep-panel-sweeper' ); ?>" name="sweeppress[nonce]"/>
213 </div>
214