| @@ -8,11 +8,12 @@ | ||
| 8 | 8 | namespace RadiusTheme\SB\Controllers\Builder; |
| 9 | 9 | |
| 10 | 10 | defined( 'ABSPATH' ) || exit(); |
| 11 | 11 | |
| 12 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 12 | +use WP_Query; | |
| 13 | 13 | use RadiusTheme\SB\Helpers\Fns; |
| 14 | 14 | use RadiusTheme\SB\Helpers\BuilderFns; |
| 15 | +use RadiusTheme\SB\Traits\SingletonTrait; | |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Builder Custom post type |
| 18 | 19 | */ |
| @@ -35,9 +36,9 @@ | ||
| 35 | 36 | add_action( 'pre_get_posts', [ $this, 'sortable_columns_query' ] ); |
| 36 | 37 | add_filter( 'template_include', [ $this, 'builder_template' ], 99 ); |
| 37 | 38 | |
| 38 | 39 | add_filter( 'parse_query', [ $this, 'query_filter' ] ); |
| 39 | - // add filter for search | |
| 40 | + // add filter for search. | |
| 40 | 41 | add_action( 'restrict_manage_posts', [ $this, 'add_filter' ] ); |
| 41 | 42 | |
| 42 | 43 | add_action( 'in_admin_header', [ $this, 'remove_all_notices' ], 1000 ); |
| 43 | 44 | |
| @@ -53,12 +54,12 @@ | ||
| 53 | 54 | public function add_filter() { |
| 54 | 55 | |
| 55 | 56 | global $typenow; |
| 56 | 57 | |
| 57 | - if ( $typenow != BuilderFns::$post_type_tb ) { | |
| 58 | + if ( BuilderFns::$post_type_tb != $typenow ) { | |
| 58 | 59 | return; |
| 59 | 60 | } |
| 60 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended. No need nonce. | |
| 61 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 61 | 62 | $selected = isset( $_GET['type'] ) ? sanitize_key( $_GET['type'] ) : ''; |
| 62 | 63 | $builder_page_types = BuilderFns::builder_page_types(); |
| 63 | 64 | ?> |
| 64 | 65 | <select name="template_type" id="type"> |
| @@ -129,15 +130,15 @@ | ||
| 129 | 130 | 'with_front' => true, |
| 130 | 131 | 'feeds' => false, |
| 131 | 132 | ], |
| 132 | 133 | 'query_var' => true, |
| 133 | - 'publicly_queryable' => true, | |
| 134 | + 'publicly_queryable' => apply_filters( 'rtsb/builder/args/publicly_queryable', true ), | |
| 134 | 135 | 'capability_type' => 'product', |
| 135 | 136 | 'show_in_rest' => true, |
| 136 | 137 | 'rest_base' => BuilderFns::$post_type_tb, |
| 137 | 138 | ]; |
| 138 | 139 | |
| 139 | - $tb_args = apply_filters( 'rtsb_register_template_builder_args', $tb_args ); | |
| 140 | + $tb_args = apply_filters( 'rtsb/builder/template_args', $tb_args ); | |
| 140 | 141 | |
| 141 | 142 | register_post_type( BuilderFns::$post_type_tb, $tb_args ); |
| 142 | 143 | |
| 143 | 144 | // Flash rewrite rules. |
| @@ -195,9 +196,9 @@ | ||
| 195 | 196 | |
| 196 | 197 | switch ( $column ) { |
| 197 | 198 | case 'type': |
| 198 | 199 | $the_type = ! empty( $types[ $type ] ) ? esc_html( ucwords( $types[ $type ] ) ) : ''; |
| 199 | - echo apply_filters( 'rtsb/columns/template/types/text', $the_type, $type, $post_id ); | |
| 200 | + Fns::print_html( apply_filters( 'rtsb/columns/template/types/text', $the_type, $type, $post_id ) ); | |
| 200 | 201 | break; |
| 201 | 202 | case 'edit_with': |
| 202 | 203 | $edit_by = Fns::page_edit_with( $post_id ); |
| 203 | 204 | echo esc_html( ucfirst( $edit_by ) ); |
| @@ -281,22 +282,23 @@ | ||
| 281 | 282 | |
| 282 | 283 | /** |
| 283 | 284 | * Manage Template filter by template type |
| 284 | 285 | * |
| 285 | - * @param \WP_Query $query WordPress main query. | |
| 286 | + * @param WP_Query $query WordPress main query. | |
| 286 | 287 | * |
| 287 | 288 | * @return void |
| 288 | 289 | */ |
| 289 | - public function query_filter( \WP_Query $query ) { | |
| 290 | + public function query_filter( WP_Query $query ) { | |
| 290 | 291 | |
| 291 | 292 | if ( ! is_admin() || ! $this->is_current_screen() || ! empty( $query->query_vars['meta_key'] ) ) { |
| 292 | 293 | return; |
| 293 | 294 | } |
| 295 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 294 | 296 | $type = isset( $_GET['template_type'] ) ? sanitize_key( $_GET['template_type'] ) : ''; |
| 295 | 297 | |
| 296 | 298 | if ( '' != $type && 'all' != $type ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 297 | 299 | $query->query_vars['meta_key'] = BuilderFns::template_type_meta_key(); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key |
| 298 | - $query->query_vars['meta_value'] = $type; | |
| 300 | + $query->query_vars['meta_value'] = $type; // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value | |
| 299 | 301 | $query->query_vars['meta_compare'] = '='; |
| 300 | 302 | } |
| 301 | 303 | } |
| 302 | 304 | |