| @@ -46,20 +46,20 @@ | ||
| 46 | 46 | <?php |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function column_title( $item ): string { |
| 50 | - $title = ! empty( $item['title'] ) ? $item['title'] : __( 'Untitled', 'wpcoder' ); | |
| 50 | + $title = ! empty( $item['title'] ) ? $item['title'] : __( 'Untitled', 'wp-coder' ); | |
| 51 | 51 | |
| 52 | 52 | $actions = [ |
| 53 | 53 | 'id' => 'ID: ' . $item['ID'], |
| 54 | 54 | 'edit' => '<a href="' . esc_url( Link::edit( $item['ID'] ) ) . '">' . esc_attr__( 'Edit', |
| 55 | - 'wpcoder' ) . '</a>', | |
| 55 | + 'wp-coder' ) . '</a>', | |
| 56 | 56 | 'duplicate' => '<a href="' . esc_url( Link::duplicate( $item['ID'] ) ) . '">' . esc_attr__( 'Duplicate', |
| 57 | - 'wpcoder' ) . '</a>', | |
| 57 | + 'wp-coder' ) . '</a>', | |
| 58 | 58 | 'delete' => '<a href="' . esc_url( Link::remove( $item['ID'] ) ) . '" >' . esc_attr__( 'Delete', |
| 59 | - 'wpcoder' ) . '</a>', | |
| 59 | + 'wp-coder' ) . '</a>', | |
| 60 | 60 | 'export' => '<a href="' . esc_url( Link::export( $item['ID'] ) ) . '" >' . esc_attr__( 'Export', |
| 61 | - 'wpcoder' ) . '</a>', | |
| 61 | + 'wp-coder' ) . '</a>', | |
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | return $title . $this->row_actions( $actions ); |
| @@ -88,18 +88,18 @@ | ||
| 88 | 88 | |
| 89 | 89 | public function get_columns(): array { |
| 90 | 90 | return [ |
| 91 | 91 | 'cb' => '<input type="checkbox" />', |
| 92 | - 'title' => __( 'Title', 'wpcoder' ), | |
| 93 | - 'code' => __( 'Shortcode', 'wpcoder' ), | |
| 94 | - 'code-alt' => __( 'Alternative Shortcode', 'wpcoder' ), | |
| 95 | - 'tag' => __( 'Tag', 'wpcoder' ), | |
| 92 | + 'title' => __( 'Title', 'wp-coder' ), | |
| 93 | + 'code' => __( 'Shortcode', 'wp-coder' ), | |
| 94 | + 'code-alt' => __( 'Alternative Shortcode', 'wp-coder' ), | |
| 95 | + 'tag' => __( 'Tag', 'wp-coder' ), | |
| 96 | 96 | 'mode' => __( 'Test mode', |
| 97 | - 'wpcoder' ) . '<sup class="has-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', | |
| 98 | - 'wpcoder' ) . '">ℹ</sup>', | |
| 97 | + 'wp-coder' ) . '<sup class="wowp-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', | |
| 98 | + 'wp-coder' ) . '">ℹ</sup>', | |
| 99 | 99 | 'status' => __( 'Status', |
| 100 | - 'wpcoder' ) . '<sup class="has-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', | |
| 101 | - 'wpcoder' ) . '">ℹ</sup>', | |
| 100 | + 'wp-coder' ) . '<sup class="wowp-tooltip" data-tooltip="' . __( 'The item will only be displayed for administrators.', | |
| 101 | + 'wp-coder' ) . '">ℹ</sup>', | |
| 102 | 102 | ]; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function get_hidden_columns(): array { |
| @@ -139,24 +139,24 @@ | ||
| 139 | 139 | $main_link = add_query_arg( $main_link_arg, admin_url( 'admin.php' ) ); |
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | foreach ( $result as $key => $value ) { |
| 143 | - $title = ! empty( $value->title ) ? $value->title : __( 'UnTitle', 'wpcoder' ); | |
| 144 | - $tooltip_off = esc_attr__( 'Click for Deactivate.', 'wpcoder' ); | |
| 145 | - $tooltip_on = esc_attr__( 'Click for Activate.', 'wpcoder' ); | |
| 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 | 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 | - 'wpcoder' ) . '</span></a>'; | |
| 147 | + 'wp-coder' ) . '</span></a>'; | |
| 148 | 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 | - 'wpcoder' ) . '</span></a>'; | |
| 149 | + 'wp-coder' ) . '</span></a>'; | |
| 150 | 150 | $status = ! empty( $value->status ) ? $status_off : $status_on; |
| 151 | 151 | |
| 152 | - $mode_tooltip_off = esc_attr__( 'Click for OFF.', 'wpcoder' ); | |
| 153 | - $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' ); | |
| 154 | 154 | |
| 155 | 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 | - 'wpcoder' ) . '</span></a>'; | |
| 156 | + 'wp-coder' ) . '</span></a>'; | |
| 157 | 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 | - 'wpcoder' ) . '</span></a>'; | |
| 158 | + 'wp-coder' ) . '</span></a>'; | |
| 159 | 159 | |
| 160 | 160 | $mode = empty( $value->mode ) ? $mode_off : $mode_on; |
| 161 | 161 | |
| 162 | 162 | $tag = ''; |
| @@ -171,10 +171,10 @@ | ||
| 171 | 171 | $link = add_query_arg( [ 'id' => $value->id ], $main_link ); |
| 172 | 172 | $data[] = array( |
| 173 | 173 | 'ID' => $value->id, |
| 174 | 174 | 'title' => '<a href="' . esc_url( $link ) . '">' . esc_attr( $title ) . '</a>', |
| 175 | - 'code' => '<div class="wowp-input-group"><input type="text" value="[' . esc_attr( $shortcode ) . ' id="' . absint( $value->id ) . '"]" readonly="readonly"><span class="wowp-copy codericon codericon-copy"></span></div>', | |
| 176 | - 'code-alt' => '<div class="wowp-input-group"><input type="text" value="[' . esc_attr( $shortcode ) . ' title="' . esc_attr( $title ) . '"]" 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="' . absint( $value->id ) . '"]" 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="' . esc_attr( $title ) . '"]" readonly="readonly"></div>', | |
| 177 | 177 | 'tag' => $tag, |
| 178 | 178 | 'mode' => $mode, |
| 179 | 179 | 'status' => $status, |
| 180 | 180 | ); |
| @@ -218,38 +218,36 @@ | ||
| 218 | 218 | |
| 219 | 219 | $result = ''; |
| 220 | 220 | |
| 221 | 221 | $table = $wpdb->prefix . WPCoder::PREFIX; |
| 222 | - | |
| 222 | +// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 223 | 223 | if ( empty( $search ) ) { |
| 224 | 224 | $result = $wpdb->get_results( "SELECT * FROM $table order by id desc" ); |
| 225 | 225 | if ( ! empty( $tag_search ) ) { |
| 226 | - $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 )); | |
| 227 | 227 | } |
| 228 | - } elseif ( trim( $search ) === 'UnTitle' ) { | |
| 228 | + } elseif ( trim( $search ) === 'Untitled' ) { | |
| 229 | 229 | $result = $wpdb->get_results( "SELECT * FROM $table WHERE title='' order by id desc" ); |
| 230 | 230 | if ( ! empty( $tag_search ) ) { |
| 231 | - $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)); | |
| 232 | 232 | } |
| 233 | 233 | } elseif ( is_numeric( $search ) ) { |
| 234 | - $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 ) ) ); | |
| 235 | 235 | if ( ! empty( $tag_search ) ) { |
| 236 | - $query = $wpdb->prepare( "SELECT * FROM $table WHERE id=%d AND tag='%s'", absint( $search ), | |
| 237 | - $tag_search ); | |
| 236 | + $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table WHERE id=%d AND tag=%s", absint( $search ), | |
| 237 | + $tag_search ) ); | |
| 238 | 238 | } |
| 239 | - $result = $wpdb->get_results( $query ); | |
| 240 | 239 | } else { |
| 241 | - $wild = '%'; | |
| 242 | - $find = sanitize_text_field( $search ); | |
| 243 | - $like = $wild . $wpdb->esc_like( $find ) . $wild; | |
| 244 | - $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 ) ); | |
| 245 | 244 | if ( ! empty( $tag_search ) ) { |
| 246 | - $query = $wpdb->prepare( "SELECT * FROM $table WHERE title LIKE %s AND tag='%s' order by id desc", | |
| 247 | - $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 ) ); | |
| 248 | 246 | } |
| 249 | - $result = $wpdb->get_results( $query ); | |
| 250 | 247 | } |
| 251 | 248 | |
| 249 | +// phpcs:enable | |
| 252 | 250 | return $result; |
| 253 | 251 | } |
| 254 | 252 | |
| 255 | 253 | |
| @@ -254,13 +252,14 @@ | ||
| 254 | 252 | |
| 255 | 253 | |
| 256 | 254 | public function get_bulk_actions() { |
| 257 | 255 | $actions = [ |
| 258 | - 'delete' => __( 'Delate', 'wpcoder' ), | |
| 259 | - 'activate' => __( 'Activate', 'wpcoder' ), | |
| 260 | - 'deactivate' => __( 'Deactivate', 'wpcoder' ), | |
| 261 | - 'test_on' => __( 'Test mode ON', 'wpcoder' ), | |
| 262 | - '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' ), | |
| 263 | 262 | ]; |
| 264 | 263 | |
| 265 | 264 | return $actions; |
| 266 | 265 | } |
| @@ -306,13 +305,13 @@ | ||
| 306 | 305 | |
| 307 | 306 | $tag_search = ( ! empty( $_REQUEST['tag'] ) ) ? sanitize_text_field( $_REQUEST ['tag'] ) : ''; |
| 308 | 307 | $tag_search = ( $tag_search === 'all' ) ? '' : $tag_search; |
| 309 | 308 | |
| 310 | - echo '<div class="alignleft actions"><label for="filter-by-tag" class="screen-reader-text">' . __( 'Filter by tag', | |
| 311 | - '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>'; | |
| 312 | 311 | echo '<select name="tag" id="filter-by-tag">'; |
| 313 | - echo '<option value="all"' . selected( 'all', $tag_search, false ) . '>' . __( 'All', | |
| 314 | - 'wpcoder' ) . '</option>'; | |
| 312 | + echo '<option value="all"' . selected( 'all', $tag_search, false ) . '>' . esc_attr__( 'All', | |
| 313 | + 'wp-coder' ) . '</option>'; | |
| 315 | 314 | |
| 316 | 315 | if ( ! empty( $tags ) ) { |
| 317 | 316 | foreach ( $tags as $tag ) { |
| 318 | 317 | if ( empty( $tag['tag'] ) ) { |
| @@ -317,14 +316,14 @@ | ||
| 317 | 316 | foreach ( $tags as $tag ) { |
| 318 | 317 | if ( empty( $tag['tag'] ) ) { |
| 319 | 318 | continue; |
| 320 | 319 | } |
| 321 | - echo '<option value="' . trim( esc_attr( $tag['tag'] ) ) . '"' . selected( $tag['tag'], $tag_search, | |
| 322 | - 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>'; | |
| 323 | 322 | } |
| 324 | 323 | } |
| 325 | 324 | echo '</select>'; |
| 326 | - submit_button( __( 'Filter', 'wpcoder' ), 'secondary', 'action', false ); | |
| 325 | + submit_button( __( 'Filter', 'wp-coder' ), 'secondary', 'action', false ); | |
| 327 | 326 | echo '</div>'; |
| 328 | 327 | } |
| 329 | 328 | } |
| 330 | 329 | |
| @@ -344,8 +343,8 @@ | ||
| 344 | 343 | $name = WPCoder::PREFIX . '_list_action'; |
| 345 | 344 | $nonce_action = WPCoder::PREFIX . '_nonce'; |
| 346 | 345 | |
| 347 | 346 | return ! ( ! isset( $_POST[ $name ] ) || ! wp_verify_nonce( $_POST[ $name ], |
| 348 | - $nonce_action ) || ! current_user_can( 'manage_options' ) ); | |
| 347 | + $nonce_action ) || ! current_user_can( 'unfiltered_html' ) ); | |
| 349 | 348 | } |
| 350 | 349 | |
| 351 | 350 | } |