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 +27 -8 2.7.8trunk View file →
@@ -337,8 +337,11 @@
337 337 $this->the_plugin_instance->get_script_version( $copy_post_asset ),
338 338 [ 'in_footer' => true ]
339 339 );
340 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 +
341 344 // Add translation.
342 345 wp_set_script_translations( 'cbb-copy-post', 'content-blocks-builder' );
343 346 }
344 347 }
@@ -367,19 +370,35 @@
367 370 * @param array Post types supported by default.
368 371 * @param WP_Post $post Post object of current post in listing.
369 372 */
370 373 $valid_post_types = apply_filters(
371 - 'cbb_copy_item_post_types',
372 - [
373 - 'boldblocks_block',
374 - 'boldblocks_variation',
375 - 'boldblocks_pattern',
376 - 'post',
377 - 'page',
378 - ],
374 + 'cbb_copy_item_validate_post_types',
375 + $this->get_supported_post_types(),
379 376 $post
380 377 );
381 378
382 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 + );
383 402 }
384 403 }
385 404 endif;