PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.5
ShopBuilder – WooCommerce Builder For Elementor v2.6.5
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/Builder/BuilderCpt.php +62 -18 2.2.02.6.5 View file →
@@ -35,17 +35,51 @@
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 - // add filter for search.
42 + // Add filter for search.
42 43 add_action( 'restrict_manage_posts', [ $this, 'add_filter' ] );
44 + // Post Content Remove For Elementor Builder.
45 + add_action( 'save_post_' . BuilderFns::$post_type_tb, [ $this, 'on_save_post' ], 10, 2 );
46 + }
43 47
44 - add_action( 'in_admin_header', [ $this, 'remove_all_notices' ], 1000 );
48 + /**
49 + * Hook into post save to clear post content for specific post type and editor.
50 + *
51 + * This method checks if the post is being updated (not newly created),
52 + * and if the post type matches the target type defined in BuilderFns::$post_type_tb.
53 + * If the post is edited with Elementor, it clears the post_content directly
54 + * from the database and clears the post cache.
55 + *
56 + * @param int $post_ID ID of the post being saved.
57 + * @param WP_Post $post Post object.
58 + * @param bool $update Whether this is an existing post being updated.
59 + *
60 + * @return void
61 + */
62 + public function on_save_post( $post_ID, $post ) {
63 + // Only proceed on update and specific post type.
64 + if ( BuilderFns::$post_type_tb !== $post->post_type ) {
65 + return;
66 + }
67 + if ( 'elementor' !== Fns::page_edit_with( $post_ID ) ) {
68 + return;
69 + }
70 + global $wpdb;
71 + // Directly update the post_content to empty.
72 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
73 + $wpdb->update(
74 + $wpdb->posts,
75 + [ 'post_content' => '' ],
76 + [ 'ID' => $post_ID ]
77 + );
78 + // Clear cache so changes reflect properly.
79 + clean_post_cache( $post_ID );
45 80 }
46 81
47 -
48 82 /**
49 83 * Public function add_filter.
50 84 * Added search filter for type of template
51 85 *
@@ -129,10 +163,10 @@
129 163 'with_front' => true,
130 164 'feeds' => false,
131 165 ],
132 166 'query_var' => true,
133 - 'publicly_queryable' => apply_filters( 'rtsb/builder/args/publicly_queryable', true ),
134 - 'capability_type' => 'product',
167 + 'publicly_queryable' => true,
168 + // 'capability_type' => 'product', Will Remove this line in the future.
135 169 'show_in_rest' => true,
136 170 'rest_base' => BuilderFns::$post_type_tb,
137 171 ];
138 172
@@ -231,9 +265,9 @@
231 265 $is_set_default = $post_id;
232 266 }
233 267 break;
234 268 default:
235 - break;
269 + break;
236 270 }
237 271 } elseif ( 'archive' === $template_type ) {
238 272 $categories_name = apply_filters( 'rtsb/template/builder/selected/categories', [], $post_id, $template_type );
239 273 $set_default = BuilderFns::get_specific_category_as_default( $post_id );
@@ -330,9 +364,9 @@
330 364 * @return string
331 365 */
332 366 public function builder_template( $template ) {
333 367 $builder_page_id = BuilderFns::is_builder_preview() ? get_the_ID() : BuilderFns::builder_page_id_by_page();
334 - if ( $builder_page_id ) {
368 + if ( defined( 'ELEMENTOR_VERSION' ) && $builder_page_id ) { // Elementor Check.
335 369 $page_template = get_post_meta( $builder_page_id, '_wp_page_template', true );
336 370 $new_template = RTSB_ABSPATH . 'page-templates/builder-template.php';
337 371 if ( 'elementor_canvas' === $page_template ) {
338 372 $new_template = RTSB_ABSPATH . 'page-templates/elementor-canvas.php';
@@ -347,8 +381,25 @@
347 381 return $template;
348 382 }
349 383
350 384 /**
385 + * Restrict the preview access.
386 + *
387 + * @return void
388 + */
389 + public function restrict_preview_access() {
390 + if ( ! apply_filters( 'rtsb/builder/preview/access', true ) ) {
391 + return;
392 + }
393 +
394 + if ( is_singular( 'rtsb_builder' ) ) {
395 + if ( ! is_user_logged_in() ) {
396 + wp_safe_redirect( home_url() );
397 + }
398 + }
399 + }
400 +
401 + /**
351 402 * Add/Remove edit link in dashboard.
352 403 *
353 404 * Add or remove an edit link to the post/page action links on the post/pages list table.
354 405 *
@@ -363,20 +414,13 @@
363 414 public function filter_post_row_actions( $actions ) {
364 415 if ( $this->is_current_screen() ) {
365 416 // unset( $actions['view'] );
366 417 unset( $actions['inline hide-if-no-js'] );
418 +
419 + if ( isset( $actions['view'] ) ) {
420 + $actions['view'] = str_replace( __( 'View', 'shopbuilder' ), __( 'Preview', 'shopbuilder' ), $actions['view'] );
421 + }
367 422 }
368 423
369 424 return $actions;
370 - }
371 -
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 425 }
382 426 }