PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.3
WP Coder – Insert & Manage Code Snippets v4.3
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
← All changes | classes/Dashboard/ListTable.php +82 -63 3.24.3 View file →
@@ -32,25 +32,34 @@
32 32 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
33 33 }
34 34 ?>
35 35 <p class="search-box">
36 - <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ) ?>"><?php echo esc_attr( $text ); ?>
36 + <label class="screen-reader-text" for="<?php
37 + echo esc_attr( $input_id ) ?>"><?php
38 + echo esc_attr( $text ); ?>
37 39 :</label>
38 - <input type="search" id="<?php echo esc_attr( $input_id ) ?>" name="s"
39 - value="<?php _admin_search_query(); ?>"/>
40 - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
40 + <input type="search" id="<?php
41 + echo esc_attr( $input_id ) ?>" name="s" value="<?php
42 + _admin_search_query(); ?>"/>
43 + <?php
44 + submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
41 45 </p>
42 46 <?php
43 47 }
44 48
45 49 public function column_title( $item ): string {
46 - $title = ! empty( $item['title'] ) ? $item['title'] : __( 'Untitled', 'side-menu' );
50 + $title = ! empty( $item['title'] ) ? $item['title'] : __( 'Untitled', 'wp-coder' );
51 +
47 52 $actions = [
48 53 'id' => 'ID: ' . $item['ID'],
49 - 'edit' => '<a href="' . esc_url( Link::edit( $item['ID'] ) ) . '">' . esc_attr__( 'Edit', 'wpcoder' ) . '</a>',
50 - 'duplicate' => '<a href="' . esc_url( Link::duplicate( $item['ID'] ) ) . '">' . esc_attr__( 'Duplicate', 'wpcoder' ) . '</a>',
51 - 'delete' => '<a href="' . esc_url( Link::remove( $item['ID'] ) ) . '" >' . esc_attr__( 'Delete', 'wpcoder' ) . '</a>',
52 - 'export' => '<a href="' . esc_url( Link::export( $item['ID'] ) ) . '" >' . esc_attr__( 'Export', 'wpcoder' ) . '</a>',
54 + 'edit' => '<a href="' . esc_url( Link::edit( $item['ID'] ) ) . '">' . esc_attr__( 'Edit',
55 + 'wp-coder' ) . '</a>',
56 + 'duplicate' => '<a href="' . esc_url( Link::duplicate( $item['ID'] ) ) . '">' . esc_attr__( 'Duplicate',
57 + 'wp-coder' ) . '</a>',
58 + 'delete' => '<a href="' . esc_url( Link::remove( $item['ID'] ) ) . '" >' . esc_attr__( 'Delete',
59 + 'wp-coder' ) . '</a>',
60 + 'export' => '<a href="' . esc_url( Link::export( $item['ID'] ) ) . '" >' . esc_attr__( 'Export',
61 + 'wp-coder' ) . '</a>',
53 62 ];
54 63
55 64
56 65 return $title . $this->row_actions( $actions );
@@ -79,16 +88,19 @@
79 88
80 89 public function get_columns(): array {
81 90 return [
82 91 'cb' => '<input type="checkbox" />',
83 - 'title' => __( 'Title', 'wpcoder' ),
84 - 'code' => __( 'Shortcode', 'wpcoder' ),
85 - 'code-alt' => __( 'Alternative Shortcode', 'wpcoder' ),
86 - 'tag' => __( 'Tag', 'wpcoder' ),
87 - 'mode' => __( 'Test mode', 'wpcoder' ) . '<sup class="has-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', 'wpcoder' ) . '">ℹ</sup>',
88 - 'status' => __( 'Status', 'wpcoder' ) . '<sup class="has-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', 'wpcoder' ) . '">ℹ</sup>',
92 + 'title' => __( 'Title', 'wp-coder' ),
93 + 'code' => __( 'Shortcode', 'wp-coder' ),
94 + 'code-alt' => __( 'Alternative Shortcode', 'wp-coder' ),
95 + 'tag' => __( 'Tag', 'wp-coder' ),
96 + 'mode' => __( 'Test mode',
97 + 'wp-coder' ) . '<sup class="wowp-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.',
98 + 'wp-coder' ) . '">ℹ</sup>',
99 + 'status' => __( 'Status',
100 + 'wp-coder' ) . '<sup class="wowp-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.',
101 + 'wp-coder' ) . '">ℹ</sup>',
89 102 ];
90 -
91 103 }
92 104
93 105 public function get_hidden_columns(): array {
94 106 return [];
@@ -112,27 +124,39 @@
112 124
113 125 if ( empty( $result ) ) {
114 126 return $data;
115 127 }
128 + $paged = $_GET['paged'] ?? '';
116 129
117 - $main_link = add_query_arg( [
130 + $main_link_arg = [
118 131 'page' => $slug . '-settings',
119 132 'action' => 'update'
120 - ], admin_url( 'admin.php' ) );
133 + ];
134 +
135 + if ( ! empty( $paged ) ) {
136 + $main_link_arg['wpcoder-page'] = absint( $paged );
137 + }
138 +
139 + $main_link = add_query_arg( $main_link_arg, admin_url( 'admin.php' ) );
140 +
141 +
121 142 foreach ( $result as $key => $value ) {
122 -
123 - $title = ! empty( $value->title ) ? $value->title : __( 'UnTitle', 'wpcoder' );
124 - $tooltip_off = esc_attr__( 'Click for Deactivate.', 'wpcoder' );
125 - $tooltip_on = esc_attr__( 'Click for Activate.', 'wpcoder' );
126 - $status_off = '<a href="' . esc_url( Link::activate_url( $value->id ) ) . '" class="wowp-toogle is-off" data-tooltip="' . esc_attr( $tooltip_on ) . '"><span>' . esc_attr__( 'OFF', 'wpcoder' ) . '</span></a>';
127 - $status_on = '<a href="' . esc_url( Link::deactivate_url( $value->id ) ) . '" class="wowp-toogle is-on" data-tooltip="' . esc_attr( $tooltip_off ) . '"><span>' . esc_attr__( 'ON', 'wpcoder' ) . '</span></a>';
143 + $title = ! empty( $value->title ) ? $value->title : __( 'Untitled', 'wp-coder' );
144 + $tooltip_off = esc_attr__( 'Click for Deactivate.', 'wp-coder' );
145 + $tooltip_on = esc_attr__( 'Click for Activate.', 'wp-coder' );
146 + $status_off = '<a href="' . esc_url( Link::activate_url( $value->id ) ) . '" class="wowp-toogle is-off" data-tooltip="' . esc_attr( $tooltip_on ) . '"><span>' . esc_attr__( 'OFF',
147 + 'wp-coder' ) . '</span></a>';
148 + $status_on = '<a href="' . esc_url( Link::deactivate_url( $value->id ) ) . '" class="wowp-toogle is-on" data-tooltip="' . esc_attr( $tooltip_off ) . '"><span>' . esc_attr__( 'ON',
149 + 'wp-coder' ) . '</span></a>';
128 150 $status = ! empty( $value->status ) ? $status_off : $status_on;
129 151
130 - $mode_tooltip_off = esc_attr__( 'Click for OFF.', 'wpcoder' );
131 - $mode_tooltip_on = esc_attr__( 'Click for ON.', 'wpcoder' );
152 + $mode_tooltip_off = esc_attr__( 'Click for OFF.', 'wp-coder' );
153 + $mode_tooltip_on = esc_attr__( 'Click for ON.', 'wp-coder' );
132 154
133 - $mode_off = '<a href="' . esc_url( Link::activate_mode( $value->id ) ) . '" class="wowp-toogle is-off" data-tooltip="' . esc_attr( $mode_tooltip_on ) . '"><span>' . esc_attr__( 'OFF', 'wpcoder' ) . '</span></a>';
134 - $mode_on = '<a href="' . esc_url( Link::deactivate_mode( $value->id ) ) . '" class="wowp-toogle is-on" data-tooltip="' . esc_attr( $mode_tooltip_off ) . '"><span>' . esc_attr__( 'ON', 'wpcoder' ) . '</span></a>';
155 + $mode_off = '<a href="' . esc_url( Link::activate_mode( $value->id ) ) . '" class="wowp-toogle is-off" data-tooltip="' . esc_attr( $mode_tooltip_on ) . '"><span>' . esc_attr__( 'OFF',
156 + 'wp-coder' ) . '</span></a>';
157 + $mode_on = '<a href="' . esc_url( Link::deactivate_mode( $value->id ) ) . '" class="wowp-toogle is-on" data-tooltip="' . esc_attr( $mode_tooltip_off ) . '"><span>' . esc_attr__( 'ON',
158 + 'wp-coder' ) . '</span></a>';
135 159
136 160 $mode = empty( $value->mode ) ? $mode_off : $mode_on;
137 161
138 162 $tag = '';
@@ -147,10 +171,10 @@
147 171 $link = add_query_arg( [ 'id' => $value->id ], $main_link );
148 172 $data[] = array(
149 173 'ID' => $value->id,
150 174 'title' => '<a href="' . esc_url( $link ) . '">' . esc_attr( $title ) . '</a>',
151 - 'code' => '<div class="wowp-input-group"><input type="text" value="[' . esc_attr( $shortcode ) . ' id=&quot;' . absint( $value->id ) . '&quot;]" readonly="readonly"><span class="wowp-copy codericon codericon-copy"></span></div>',
152 - 'code-alt' => '<div class="wowp-input-group"><input type="text" value="[' . esc_attr( $shortcode ) . ' title=&quot;' . esc_attr( $title ) . '&quot;]" readonly="readonly"><span class="wowp-copy codericon codericon-copy"></span></div>',
175 + 'code' => '<div class="wowp-field has-addon"><label for="shortcode" class="label is-addon"><span class="wowp-tooltip on-right is-pointer can-copy" data-tooltip="Copy"><span class="wowp-copy icon icon-copy"></span></span></label><input type="text" value="[' . esc_attr( $shortcode ) . ' id=&quot;' . absint( $value->id ) . '&quot;]" readonly="readonly"></div>',
176 + 'code-alt' => '<div class="wowp-field has-addon"><label for="shortcode" class="label is-addon"><span class="wowp-tooltip on-right is-pointer can-copy" data-tooltip="Copy"><span class="wowp-copy icon icon-copy"></span></span></label><input type="text" value="[' . esc_attr( $shortcode ) . ' title=&quot;' . esc_attr( $title ) . '&quot;]" readonly="readonly"></div>',
153 177 'tag' => $tag,
154 178 'mode' => $mode,
155 179 'status' => $status,
156 180 );
@@ -156,10 +180,8 @@
156 180 );
157 181 }
158 182
159 183 return $data;
160 -
161 -
162 184 }
163 185
164 186 public function column_cb( $item ) {
165 187 return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'ID', $item['ID'] );
@@ -196,38 +218,36 @@
196 218
197 219 $result = '';
198 220
199 221 $table = $wpdb->prefix . WPCoder::PREFIX;
200 -
222 +// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
201 223 if ( empty( $search ) ) {
202 224 $result = $wpdb->get_results( "SELECT * FROM $table order by id desc" );
203 225 if ( ! empty( $tag_search ) ) {
204 - $result = $wpdb->get_results( "SELECT * FROM $table WHERE tag='$tag_search' order by id desc" );
226 + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $table WHERE tag=%s order by id desc", $tag_search ));
205 227 }
206 - } elseif ( trim( $search ) === 'UnTitle' ) {
228 + } elseif ( trim( $search ) === 'Untitled' ) {
207 229 $result = $wpdb->get_results( "SELECT * FROM $table WHERE title='' order by id desc" );
208 230 if ( ! empty( $tag_search ) ) {
209 - $result = $wpdb->get_results( "SELECT * FROM $table WHERE title='' AND tag='$tag_search' order by id desc" );
231 + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $table WHERE title='' AND tag=%s order by id desc", $tag_search));
210 232 }
211 233 } elseif ( is_numeric( $search ) ) {
212 - $query = $wpdb->prepare( "SELECT * FROM $table WHERE id=%d", absint( $search ) );
234 + $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table WHERE id=%d", absint( $search ) ) );
213 235 if ( ! empty( $tag_search ) ) {
214 - $query = $wpdb->prepare( "SELECT * FROM $table WHERE id=%d AND tag='%s'", absint( $search ),
215 - $tag_search );
236 + $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table WHERE id=%d AND tag=%s", absint( $search ),
237 + $tag_search ) );
216 238 }
217 - $result = $wpdb->get_results( $query );
218 239 } else {
219 - $wild = '%';
220 - $find = sanitize_text_field( $search );
221 - $like = $wild . $wpdb->esc_like( $find ) . $wild;
222 - $query = $wpdb->prepare( "SELECT * FROM $table WHERE title LIKE %s order by id desc", $like );
240 + $wild = '%';
241 + $find = sanitize_text_field( $search );
242 + $like = $wild . $wpdb->esc_like( $find ) . $wild;
243 + $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table WHERE title LIKE %s order by id desc", $like ) );
223 244 if ( ! empty( $tag_search ) ) {
224 - $query = $wpdb->prepare( "SELECT * FROM $table WHERE title LIKE %s AND tag='%s' order by id desc",
225 - $like, $tag_search );
245 + $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table WHERE title LIKE %s AND tag=%s order by id desc", $like, $tag_search ) );
226 246 }
227 - $result = $wpdb->get_results( $query );
228 247 }
229 248
249 +// phpcs:enable
230 250 return $result;
231 251 }
232 252
233 253
@@ -232,13 +252,14 @@
232 252
233 253
234 254 public function get_bulk_actions() {
235 255 $actions = [
236 - 'delete' => __( 'Delate', 'wpcoder' ),
237 - 'activate' => __( 'Activate', 'wpcoder' ),
238 - 'deactivate' => __( 'Deactivate', 'wpcoder' ),
239 - 'test_on' => __( 'Test mode ON', 'wpcoder' ),
240 - 'test_off' => __( 'Test mode OFF', 'wpcoder' ),
256 + 'delete' => __( 'Delate', 'wp-coder' ),
257 + 'activate' => __( 'Activate', 'wp-coder' ),
258 + 'deactivate' => __( 'Deactivate', 'wp-coder' ),
259 + 'test_on' => __( 'Test mode ON', 'wp-coder' ),
260 + 'test_off' => __( 'Test mode OFF', 'wp-coder' ),
261 + 'export' => __( 'Export', 'wp-coder' ),
241 262 ];
242 263
243 264 return $actions;
244 265 }
@@ -275,24 +296,22 @@
275 296 if ( 'test_off' === $this->current_action() ) {
276 297 Settings::deactivate_mode( $id );
277 298 }
278 299 }
279 -
280 300 }
281 301
282 302 protected function extra_tablenav( $which ) {
283 303 if ( 'top' === $which ) {
284 -
285 304 $tags = DBManager::get_tags_from_table();
286 305
287 306 $tag_search = ( ! empty( $_REQUEST['tag'] ) ) ? sanitize_text_field( $_REQUEST ['tag'] ) : '';
288 307 $tag_search = ( $tag_search === 'all' ) ? '' : $tag_search;
289 308
290 - echo '<div class="alignleft actions"><label for="filter-by-tag" class="screen-reader-text">' . __( 'Filter by tag',
291 - 'wpcoder' ) . '</label>';
309 + echo '<div class="alignleft actions"><label for="filter-by-tag" class="screen-reader-text">' . esc_attr__( 'Filter by tag',
310 + 'wp-coder' ) . '</label>';
292 311 echo '<select name="tag" id="filter-by-tag">';
293 - echo '<option value="all"' . selected( 'all', $tag_search, false ) . '>' . __( 'All',
294 - 'wpcoder' ) . '</option>';
312 + echo '<option value="all"' . selected( 'all', $tag_search, false ) . '>' . esc_attr__( 'All',
313 + 'wp-coder' ) . '</option>';
295 314
296 315 if ( ! empty( $tags ) ) {
297 316 foreach ( $tags as $tag ) {
298 317 if ( empty( $tag['tag'] ) ) {
@@ -297,14 +316,14 @@
297 316 foreach ( $tags as $tag ) {
298 317 if ( empty( $tag['tag'] ) ) {
299 318 continue;
300 319 }
301 - echo '<option value="' . trim( esc_attr( $tag['tag'] ) ) . '"' . selected( $tag['tag'], $tag_search,
302 - false ) . '>' . esc_attr( $tag['tag'] ) . '</option>';
320 + echo '<option value="' . esc_attr( trim( $tag['tag'] ) ) . '"' . selected( $tag['tag'], $tag_search,
321 + false ) . '>' . esc_html( $tag['tag'] ) . '</option>';
303 322 }
304 323 }
305 324 echo '</select>';
306 - submit_button( __( 'Filter', 'wpcoder' ), 'secondary', 'action', false );
325 + submit_button( __( 'Filter', 'wp-coder' ), 'secondary', 'action', false );
307 326 echo '</div>';
308 327 }
309 328 }
310 329
@@ -317,9 +336,8 @@
317 336 $result = strnatcmp( $a[ $orderby ], $b[ $orderby ] );
318 337
319 338 // Send final sort direction to usort
320 339 return ( $order === 'asc' ) ? $result : - $result;
321 -
322 340 }
323 341
324 342 private function verify() {
325 343 $name = WPCoder::PREFIX . '_list_action';
@@ -324,8 +342,9 @@
324 342 private function verify() {
325 343 $name = WPCoder::PREFIX . '_list_action';
326 344 $nonce_action = WPCoder::PREFIX . '_nonce';
327 345
328 - return ! ( ! isset( $_POST[ $name ] ) || ! wp_verify_nonce( $_POST[ $name ], $nonce_action ) || ! current_user_can( 'unfiltered_html' ) );
346 + return ! ( ! isset( $_POST[ $name ] ) || ! wp_verify_nonce( $_POST[ $name ],
347 + $nonce_action ) || ! current_user_can( 'unfiltered_html' ) );
329 348 }
330 349
331 350 }