| @@ -35,14 +35,13 @@ | ||
| 35 | 35 | add_action( 'manage_' . BuilderFns::$post_type_tb . '_posts_custom_column', [ $this, 'custom_columns' ], 10, 2 ); |
| 36 | 36 | add_filter( 'manage_edit-' . BuilderFns::$post_type_tb . '_sortable_columns', [ $this, 'register_sortable_columns' ] ); |
| 37 | 37 | add_action( 'pre_get_posts', [ $this, 'sortable_columns_query' ] ); |
| 38 | 38 | add_filter( 'template_include', [ $this, 'builder_template' ], 99 ); |
| 39 | + add_filter( 'template_redirect', [ $this, 'restrict_preview_access' ], 99 ); | |
| 39 | 40 | |
| 40 | 41 | add_filter( 'parse_query', [ $this, 'query_filter' ] ); |
| 41 | 42 | // add filter for search. |
| 42 | 43 | add_action( 'restrict_manage_posts', [ $this, 'add_filter' ] ); |
| 43 | - | |
| 44 | - add_action( 'in_admin_header', [ $this, 'remove_all_notices' ], 1000 ); | |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | |
| 48 | 47 | /** |
| @@ -129,10 +128,10 @@ | ||
| 129 | 128 | 'with_front' => true, |
| 130 | 129 | 'feeds' => false, |
| 131 | 130 | ], |
| 132 | 131 | 'query_var' => true, |
| 133 | - 'publicly_queryable' => apply_filters( 'rtsb/builder/args/publicly_queryable', true ), | |
| 134 | - 'capability_type' => 'product', | |
| 132 | + 'publicly_queryable' => true, | |
| 133 | + // 'capability_type' => 'product', Will Remove this line in the future. | |
| 135 | 134 | 'show_in_rest' => true, |
| 136 | 135 | 'rest_base' => BuilderFns::$post_type_tb, |
| 137 | 136 | ]; |
| 138 | 137 | |
| @@ -231,9 +230,9 @@ | ||
| 231 | 230 | $is_set_default = $post_id; |
| 232 | 231 | } |
| 233 | 232 | break; |
| 234 | 233 | default: |
| 235 | - break; | |
| 234 | + break; | |
| 236 | 235 | } |
| 237 | 236 | } elseif ( 'archive' === $template_type ) { |
| 238 | 237 | $categories_name = apply_filters( 'rtsb/template/builder/selected/categories', [], $post_id, $template_type ); |
| 239 | 238 | $set_default = BuilderFns::get_specific_category_as_default( $post_id ); |
| @@ -330,9 +329,9 @@ | ||
| 330 | 329 | * @return string |
| 331 | 330 | */ |
| 332 | 331 | public function builder_template( $template ) { |
| 333 | 332 | $builder_page_id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_page(); |
| 334 | - if ( $builder_page_id ) { | |
| 333 | + if ( defined( 'ELEMENTOR_VERSION' ) && $builder_page_id ) { // Elementor Check. | |
| 335 | 334 | $page_template = get_post_meta( $builder_page_id, '_wp_page_template', true ); |
| 336 | 335 | $new_template = RTSB_ABSPATH . 'page-templates/builder-template.php'; |
| 337 | 336 | if ( 'elementor_canvas' === $page_template ) { |
| 338 | 337 | $new_template = RTSB_ABSPATH . 'page-templates/elementor-canvas.php'; |
| @@ -347,8 +346,25 @@ | ||
| 347 | 346 | return $template; |
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | /** |
| 350 | + * Restrict the preview access. | |
| 351 | + * | |
| 352 | + * @return void | |
| 353 | + */ | |
| 354 | + public function restrict_preview_access() { | |
| 355 | + if ( ! apply_filters( 'rtsb/builder/preview/access', true ) ) { | |
| 356 | + return; | |
| 357 | + } | |
| 358 | + | |
| 359 | + if ( is_singular( 'rtsb_builder' ) ) { | |
| 360 | + if ( ! is_user_logged_in() ) { | |
| 361 | + wp_safe_redirect( home_url() ); | |
| 362 | + } | |
| 363 | + } | |
| 364 | + } | |
| 365 | + | |
| 366 | + /** | |
| 351 | 367 | * Add/Remove edit link in dashboard. |
| 352 | 368 | * |
| 353 | 369 | * Add or remove an edit link to the post/page action links on the post/pages list table. |
| 354 | 370 | * |
| @@ -363,20 +379,14 @@ | ||
| 363 | 379 | public function filter_post_row_actions( $actions ) { |
| 364 | 380 | if ( $this->is_current_screen() ) { |
| 365 | 381 | // unset( $actions['view'] ); |
| 366 | 382 | unset( $actions['inline hide-if-no-js'] ); |
| 383 | + | |
| 384 | + if ( isset( $actions['view'] ) ) { | |
| 385 | + $actions['view'] = str_replace( __( 'View', 'shopbuilder' ), __( 'Preview', 'shopbuilder' ), $actions['view'] ); | |
| 386 | + } | |
| 367 | 387 | } |
| 368 | 388 | |
| 369 | 389 | return $actions; |
| 370 | 390 | } |
| 371 | 391 | |
| 372 | - /** | |
| 373 | - * Remove admin notices | |
| 374 | - */ | |
| 375 | - public function remove_all_notices() { | |
| 376 | - $screen = get_current_screen(); | |
| 377 | - if ( 'edit-rtsb_builder' === $screen->id ) { | |
| 378 | - remove_all_actions( 'admin_notices' ); | |
| 379 | - remove_all_actions( 'all_admin_notices' ); | |
| 380 | - } | |
| 381 | - } | |
| 382 | 392 | } |