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 / misc-sweep-single.php

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

133 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Dev4Press\v43\Core\Quick\Sanitize;
4 use Dev4Press\v43\Core\Quick\File;
5
6 $tasks = $sweeper->is_no_size();
7 $total = array(
8 'tasks' => 0,
9 'items' => 0,
10 'records' => 0,
11 'size' => 0,
12 );
13
14 foreach ( $sweeper->get_tasks() as $task => $data ) {
15 if ( $tasks ) {
16 $total['tasks'] ++;
17 }
18
19 $info = array();
20 $is_cpt = isset( $data['type'] ) && $data['type'] == 'post_type';
21 $data['items'] = $data['items'] ?? 0;
22
23 if ( $tasks || ( $data['items'] > 0 || $data['records'] > 0 || $data['size'] > 0 ) ) {
24 $item_class = array( 'sweeppress-item-task' );
25 $item_name = 'sweeppress[sweeper][' . $sweeper->get_category() . '][' . $sweeper->get_code() . '][' . $task . ']';
26
27 if ( $is_cpt ) {
28 $item_class[] = $data['registered'] ? 'task-is-registered' : 'task-is-missing';
29 }
30
31 echo '<div class="' . Sanitize::html_classes( $item_class ) . '">';
32
33 if ( $is_cpt && ! $data['registered'] ) {
34 echo '<i title="' . esc_attr__( 'Not currently registered.', 'sweeppress' ) . '" class="d4p-icon d4p-ui-warning"></i> ';
35 }
36
37 echo esc_html( $data['title'] );
38
39 if ( isset( $data['real_title'] ) ) {
40 echo ' [<span>' . esc_html( $data['real_title'] ) . '</span>]';
41 }
42
43 if ( $data['items'] > 0 || $data['records'] > 0 || $data['size'] > 0 ) {
44 echo ' (<span class="sweeppress-item-task-stats">';
45
46 if ( $data['items'] > 0 ) {
47 $total['items'] += absint( $data['items'] );
48 echo '<span>' . sprintf( esc_html( $sweeper->items_count_n( absint( $data['items'] ) ) ), '<strong>' . absint( $data['items'] ) . '</strong>' ) . '</span>';
49 }
50
51 if ( $data['records'] > 0 ) {
52 $_records = absint( $data['records'] );
53 $total['records'] += $_records;
54 echo '<span>' . sprintf( esc_html( _n( '%s record', '%s records', $_records, 'sweeppress' ) ), '<strong>' . $_records . '</strong>' ) . '</span>';
55 }
56
57 if ( $data['size'] > 0 ) {
58 $total['size'] += absint( $data['size'] );
59 echo '<span>' . File::size_format( absint( $data['size'] ) ) . '</span>';
60 }
61
62 echo '</span>)';
63 }
64
65 echo '<input data-size="' . esc_attr( $data['size'] ) . '" data-records="' . esc_attr( $data['records'] ) . '" class="sweeppress-task-check" type="checkbox" value="sweep" name="' . esc_attr( $item_name ) . '" />';
66
67 echo '</div>';
68 } else {
69 echo '<div class="sweeppress-item-task empty-task">';
70 echo esc_html( $data['title'] );
71
72 if ( isset( $data['real_title'] ) ) {
73 echo ' [<span>' . esc_html( $data['real_title'] ) . '</span>]';
74 }
75
76 echo '</div>';
77 }
78 }
79
80 ?>
81 <div class="sweeppress-item-total">
82 <?php
83
84 if ( $total['size'] > 0 ) {
85 $percentage = $sweeper->calculate_percentage( $total['size'] );
86 $total_size = File::size_format( $sweeper->affected_tables_size(), 2, ' ', false );
87
88 if ( $percentage < 0.5 ) {
89 $percentage = '< 0.5';
90 }
91
92 echo '<span title="' . esc_attr( sprintf( __( 'Estimated from the total size of affected tables (%s).', 'sweeppress' ), $total_size ) ) . '" class="sweeppress-affected-percentage">' . esc_html( $percentage ) . '%</span>';
93 }
94
95 ?>
96 <p>
97 <?php
98
99 if ( $total['tasks'] > 0 || $total['items'] > 0 || $total['records'] > 0 || $total['size'] > 0 ) {
100 echo '<strong>' . esc_html__( 'Totals', 'sweeppress' ) . ':</strong>';
101
102 echo ' <span class="sweeppress-item-task-stats">';
103
104 if ( $total['tasks'] > 0 ) {
105 echo '<span>' . sprintf( esc_html( $sweeper->tasks_count_n( absint( $total['tasks'] ) ) ), '<strong>' . absint( $total['tasks'] ) . '</strong>' ) . '</span>';
106 }
107
108 if ( $total['items'] > 0 ) {
109 echo '<span>' . sprintf( esc_html( $sweeper->items_count_n( absint( $total['items'] ) ) ), '<strong>' . absint( $total['items'] ) . '</strong>' ) . '</span>';
110 }
111
112 if ( $total['records'] > 0 ) {
113 $_records = absint( $total['records'] );
114 echo '<span>' . sprintf( esc_html( _n( '%s record', '%s records', $_records, 'sweeppress' ) ), '<strong>' . $_records . '</strong>' ) . '</span>';
115 }
116
117 if ( $total['size'] > 0 ) {
118 echo '<span>' . File::size_format( absint( $total['size'] ) ) . '</span>';
119 }
120
121 if ( $sweeper->is_cached() ) {
122 echo '<span><strong>' . esc_html__( 'From Cache', 'sweeppress' ) . '</strong></span>';
123 }
124
125 echo '</span>';
126 } else {
127 esc_html_e( 'Nothing to sweep.', 'sweeppress' );
128 }
129
130 ?>
131 </p>
132 </div>
133