Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Avoid unnamed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Dec 23, 2022
1 parent 7656707 commit 94f594f
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions wp-directives.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<meta itemprop="wp-client-side-transitions" content="active">';
}
function wp_directives_add_client_side_transitions_meta_tag() {
if ( wp_directives_get_client_side_transitions() ) {
echo '<meta itemprop="wp-client-side-transitions" content="active">';
}
);
}
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' );
Expand All @@ -155,36 +153,32 @@ 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 );
$w->next_tag();
$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.
Expand Down

0 comments on commit 94f594f

Please sign in to comment.