Skip to content

Commit

Permalink
Cleaned up ACF Block load script
Browse files Browse the repository at this point in the history
  • Loading branch information
raikasdev authored and ronilaukkarinen committed Dec 8, 2023
1 parent 5e9d91c commit 231e831
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inc/template-tags/acf-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ function load_acf_block( $block_path, $cache = false, $block = [], $is_preview =
*/
if ( ! $is_preview ) {
$post_type = get_post_type();
if ( $post_type && 'wp_block' !== $post_type && is_array( $block['post_types'] ) && ! in_array( $post_type, $block['post_types'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict

$is_not_wp_block = $post_type && 'wp_block' !== $post_type;
$is_disallowed_in_post_type = is_array( $block['post_types'] ) && ! in_array( $post_type, $block['post_types'] );

if ( $is_not_wp_block && $is_disallowed_in_post_type ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
return '';
}
}
Expand Down

0 comments on commit 231e831

Please sign in to comment.