PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.4
WP Coder – Insert & Manage Code Snippets v3.4
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 +34 -22 3.0.33.4 View file →
@@ -4,9 +4,9 @@
4 4
5 5 defined( 'ABSPATH' ) || exit;
6 6
7 7 use WP_List_Table;
8 -use WPCoder\WOW_Plugin;
8 +use WPCoder\WPCoder;
9 9
10 10 class ListTable extends WP_List_Table {
11 11
12 12 public $per_page = 30;
@@ -78,15 +78,15 @@
78 78 }
79 79
80 80 public function get_columns(): array {
81 81 return [
82 - '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>',
82 + '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>',
89 89 ];
90 90
91 91 }
92 92
@@ -106,10 +106,10 @@
106 106 $offset = $this->per_page * ( $paged - 1 );
107 107
108 108 $result = $this->get_results();
109 109
110 - $slug = WOW_Plugin::SLUG;
111 - $shortcode = WOW_Plugin::SHORTCODE;
110 + $slug = WPCoder::SLUG;
111 + $shortcode = WPCoder::SHORTCODE;
112 112
113 113 if ( empty( $result ) ) {
114 114 return $data;
115 115 }
@@ -114,10 +114,9 @@
114 114 return $data;
115 115 }
116 116
117 117 $main_link = add_query_arg( [
118 - 'page' => $slug,
119 - 'tab' => 'settings',
118 + 'page' => $slug . '-settings',
120 119 'action' => 'update'
121 120 ], admin_url( 'admin.php' ) );
122 121 foreach ( $result as $key => $value ) {
123 122
@@ -138,9 +137,9 @@
138 137
139 138 $tag = '';
140 139 if ( isset( $value->tag ) ) {
141 140 $tag_url = add_query_arg( [
142 - 'page' => WOW_Plugin::SLUG,
141 + 'page' => WPCoder::SLUG,
143 142 'tag' => $value->tag
144 143 ], admin_url( 'admin.php' ) );
145 144 $tag = '<a href="' . esc_url( $tag_url ) . '">' . esc_attr( $value->tag ) . '</a>';
146 145 }
@@ -146,15 +145,15 @@
146 145 }
147 146
148 147 $link = add_query_arg( [ 'id' => $value->id ], $main_link );
149 148 $data[] = array(
150 - 'ID' => $value->id,
151 - 'title' => '<a href="' . esc_url( $link ) . '">' . esc_attr( $title ) . '</a>',
152 - 'code' => '[' . esc_attr( $shortcode ) . ' id="' . absint( $value->id ) . '"]',
153 - 'code-alt' => '[' . esc_attr($shortcode) . ' title="' . esc_attr($title) . '"]',
154 - 'tag' => $tag,
155 - 'mode' => $mode,
156 - 'status' => $status,
149 + 'ID' => $value->id,
150 + '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>',
153 + 'tag' => $tag,
154 + 'mode' => $mode,
155 + 'status' => $status,
157 156 );
158 157 }
159 158
160 159 return $data;
@@ -196,9 +195,9 @@
196 195
197 196
198 197 $result = '';
199 198
200 - $table = $wpdb->prefix . WOW_Plugin::PREFIX;
199 + $table = $wpdb->prefix . WPCoder::PREFIX;
201 200
202 201 if ( empty( $search ) ) {
203 202 $result = $wpdb->get_results( "SELECT * FROM $table order by id desc" );
204 203 if ( ! empty( $tag_search ) ) {
@@ -250,11 +249,17 @@
250 249 if ( ! is_array( $ids ) ) {
251 250 $ids = [ $ids ];
252 251 }
253 252 if ( empty( $action ) ) {
254 - return;
253 + return false;
255 254 }
256 255
256 + $verify = $this->verify();
257 +
258 + if ( ! $verify ) {
259 + return false;
260 + }
261 +
257 262 foreach ( $ids as $id ) {
258 263 if ( 'delete' === $this->current_action() ) {
259 264 DBManager::delete( $id );
260 265 }
@@ -313,7 +318,14 @@
313 318
314 319 // Send final sort direction to usort
315 320 return ( $order === 'asc' ) ? $result : - $result;
316 321
322 + }
323 +
324 + private function verify() {
325 + $name = WPCoder::PREFIX . '_list_action';
326 + $nonce_action = WPCoder::PREFIX . '_nonce';
327 +
328 + return ! ( ! isset( $_POST[ $name ] ) || ! wp_verify_nonce( $_POST[ $name ], $nonce_action ) || ! current_user_can( 'unfiltered_html' ) );
317 329 }
318 330
319 331 }