From 94f594fdb2dd25f047e138bfd5a6c3ff65825ea8 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Fri, 23 Dec 2022 11:10:11 +0100 Subject: [PATCH] Avoid unnamed functions --- wp-directives.php | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/wp-directives.php b/wp-directives.php index 010e2e38..64e13ac3 100644 --- a/wp-directives.php +++ b/wp-directives.php @@ -136,14 +136,12 @@ function wp_directives_get_client_side_transitions() { return $client_side_transitions; } -add_action( - 'wp_head', - function () { - if ( wp_directives_get_client_side_transitions() ) { - echo ''; - } +function wp_directives_add_client_side_transitions_meta_tag() { + if ( wp_directives_get_client_side_transitions() ) { + echo ''; } -); +} +add_action( 'wp_head', 'wp_directives_add_client_side_transitions_meta_tag' ); function wp_directives_client_site_transitions_option() { $options = get_option( 'wp_directives_plugin_settings' ); @@ -155,25 +153,23 @@ function wp_directives_client_site_transitions_option() { 9 ); -add_filter( - 'render_block', - function ( $block_content, $block, $instance ) { - if ( wp_directives_get_client_side_transitions() ) { - return $block_content; - } +function wp_directives_mark_interactive_blocks( $block_content, $block, $instance ) { + if ( wp_directives_get_client_side_transitions() ) { + return $block_content; + } // Append the `wp-ignore` attribute for inner blocks of interactive blocks. - if ( isset( $instance->parsed_block['isolated'] ) ) { - $w = new WP_HTML_Tag_Processor( $block_content ); - $w->next_tag(); - $w->set_attribute( 'wp-ignore', '' ); - $block_content = (string) $w; - } + if ( isset( $instance->parsed_block['isolated'] ) ) { + $w = new WP_HTML_Tag_Processor( $block_content ); + $w->next_tag(); + $w->set_attribute( 'wp-ignore', '' ); + $block_content = (string) $w; + } // Return if it's not interactive. - if ( ! block_has_support( $instance->block_type, array( 'interactivity' ) ) ) { - return $block_content; - } + if ( ! block_has_support( $instance->block_type, array( 'interactivity' ) ) ) { + return $block_content; + } // Add the `wp-island` attribute if it's interactive. $w = new WP_HTML_Tag_Processor( $block_content ); @@ -181,10 +177,8 @@ function ( $block_content, $block, $instance ) { $w->set_attribute( 'wp-island', '' ); return (string) $w; - }, - 10, - 3 -); +} +add_filter( 'render_block', 'wp_directives_mark_interactive_blocks', 10, 3 ); /** * Add a flag to mark inner blocks of isolated interactive blocks.