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 -5 2.8.9trunk 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 }
@@ -359,11 +362,8 @@
359 362 * @param WP_Post $post Post object of current post in listing.
360 363 * @return bool True if the post type is in a list of supported psot types; false otherwise.
361 364 */
362 365 protected function validate_post_type( $post_type, $post = null ) {
363 - // Get all public post types.
364 - $public_types = array_keys( get_post_types( [ 'public' => true ] ) );
365 -
366 366 /**
367 367 * Fires when determining if the "Copy" row action should be made available.
368 368 * Allows overriding supported post types.
369 369 *
@@ -370,13 +370,35 @@
370 370 * @param array Post types supported by default.
371 371 * @param WP_Post $post Post object of current post in listing.
372 372 */
373 373 $valid_post_types = apply_filters(
374 - 'cbb_copy_item_post_types',
375 - $public_types,
374 + 'cbb_copy_item_validate_post_types',
375 + $this->get_supported_post_types(),
376 376 $post
377 377 );
378 378
379 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 + );
380 402 }
381 403 }
382 404 endif;