PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / 2.8.15
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts v2.8.15
2.8.15 2.8.14 2.8.13 2.8.12 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.11 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 trunk 1.0.1 1.0.2 1.1.0 All 148 releases
← All changes | includes/copy-post.php +31 -10 2.7.7 → 2.8.15 View file →
@@ -127,9 +127,9 @@
127 127 $new_post = $this->copy_item( $post_id );
128 128
129 129 // On error.
130 130 if ( ! $new_post || ! $new_post instanceof \WP_Post ) {
131 - die( is_string( $new_post ) ? $new_post : '' );
131 + die( is_string( $new_post ) ? esc_html( $new_post ) : '' );
132 132 }
133 133
134 134 // Redirect to the post list screen.
135 135 wp_safe_redirect(
@@ -174,8 +174,9 @@
174 174 'post_author' => $new_author_id,
175 175 'post_status' => 'draft',
176 176 'post_type' => $post->post_type,
177 177 'menu_order' => $post->menu_order,
178 + 'post_parent' => $post->post_parent,
178 179 );
179 180
180 181 // Insert the post.
181 182 $new_post_id = wp_insert_post( $args );
@@ -310,11 +311,12 @@
310 311 admin_url( 'post.php' )
311 312 );
312 313
313 314 return [
315 + // translators: %s: the label of the post type.
314 316 'message' => sprintf( __( 'A new copied %s is created.', 'content-blocks-builder' ), strtolower( $post_type_label ) ),
315 317 'edit_url' => $edit_url,
316 - 'edit_label' => esc_attr__( 'Edit' ),
318 + 'edit_label' => esc_attr__( 'Edit', 'content-blocks-builder' ),
317 319 ];
318 320 }
319 321
320 322 /**
@@ -336,8 +338,11 @@
336 338 $this->the_plugin_instance->get_script_version( $copy_post_asset ),
337 339 [ 'in_footer' => true ]
338 340 );
339 341
342 + // Load supported post types to JS.
343 + wp_add_inline_script( 'cbb-copy-post', sprintf( 'const CBB_COPY_POST = %s;', wp_json_encode( [ 'postTypes' => $this->get_supported_post_types() ] ) ), 'before' );
344 +
340 345 // Add translation.
341 346 wp_set_script_translations( 'cbb-copy-post', 'content-blocks-builder' );
342 347 }
343 348 }
@@ -366,19 +371,35 @@
366 371 * @param array Post types supported by default.
367 372 * @param WP_Post $post Post object of current post in listing.
368 373 */
369 374 $valid_post_types = apply_filters(
370 - 'cbb_copy_item_post_types',
371 - [
372 - 'boldblocks_block',
373 - 'boldblocks_variation',
374 - 'boldblocks_pattern',
375 - 'post',
376 - 'page',
377 - ],
375 + 'cbb_copy_item_validate_post_types',
376 + $this->get_supported_post_types(),
378 377 $post
379 378 );
380 379
381 380 return in_array( $post_type, $valid_post_types, true );
381 + }
382 +
383 + /**
384 + * Get the list of supported post types.
385 + *
386 + * @return array
387 + */
388 + private function get_supported_post_types() {
389 + // Get all public post types.
390 + $public_types = array_keys( get_post_types( [ 'public' => true ] ) );
391 +
392 + /**
393 + * Fires when determining if the "Copy" row action should be made available.
394 + * Allows overriding supported post types.
395 + *
396 + * @param array Post types supported by default.
397 + * @param WP_Post $post Post object of current post in listing.
398 + */
399 + return apply_filters(
400 + 'cbb_copy_item_supported_post_types',
401 + $public_types,
402 + );
382 403 }
383 404 }
384 405 endif;