PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / trunk
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts vtrunk
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 1.1.1 All 147 releases
← All changes | includes/copy-post.php +30 -10 2.7.5trunk 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(
@@ -310,11 +310,12 @@
310 310 admin_url( 'post.php' )
311 311 );
312 312
313 313 return [
314 + // translators: %s: the label of the post type.
314 315 'message' => sprintf( __( 'A new copied %s is created.', 'content-blocks-builder' ), strtolower( $post_type_label ) ),
315 316 'edit_url' => $edit_url,
316 - 'edit_label' => esc_attr__( 'Edit' ),
317 + 'edit_label' => esc_attr__( 'Edit', 'content-blocks-builder' ),
317 318 ];
318 319 }
319 320
320 321 /**
@@ -336,8 +337,11 @@
336 337 $this->the_plugin_instance->get_script_version( $copy_post_asset ),
337 338 [ 'in_footer' => true ]
338 339 );
339 340
341 + // Load supported post types to JS.
342 + wp_add_inline_script( 'cbb-copy-post', sprintf( 'const CBB_COPY_POST = %s;', wp_json_encode( [ 'postTypes' => $this->get_supported_post_types() ] ) ), 'before' );
343 +
340 344 // Add translation.
341 345 wp_set_script_translations( 'cbb-copy-post', 'content-blocks-builder' );
342 346 }
343 347 }
@@ -366,19 +370,35 @@
366 370 * @param array Post types supported by default.
367 371 * @param WP_Post $post Post object of current post in listing.
368 372 */
369 373 $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 - ],
374 + 'cbb_copy_item_validate_post_types',
375 + $this->get_supported_post_types(),
378 376 $post
379 377 );
380 378
381 379 return in_array( $post_type, $valid_post_types, true );
380 + }
381 +
382 + /**
383 + * Get the list of supported post types.
384 + *
385 + * @return array
386 + */
387 + private function get_supported_post_types() {
388 + /// Get all public post types.
389 + $public_types = array_keys( get_post_types( [ 'public' => true ] ) );
390 +
391 + /**
392 + * Fires when determining if the "Copy" row action should be made available.
393 + * Allows overriding supported post types.
394 + *
395 + * @param array Post types supported by default.
396 + * @param WP_Post $post Post object of current post in listing.
397 + */
398 + return apply_filters(
399 + 'cbb_copy_item_supported_post_types',
400 + $public_types,
401 + );
382 402 }
383 403 }
384 404 endif;