Skip to content

Commit

Permalink
Only disable o2 filters if the class exists
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Oct 22, 2024
1 parent 07528f4 commit 1cff8c8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mu-plugins/blocks/notice/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ function render_callout_as_notice( $attr, $content, $tag ) {

// Sanitize message content.
$content = wp_kses_post( $content );
// Temporarily disable o2 processing while formatting content.
add_filter( 'o2_process_the_content', '__return_false', 1 );
remove_filter( 'the_content', array( 'o2', 'add_json_data' ), 999999 );
// Temporarily disable o2 processing while formatting content, if the class exists.
$o2_exists = class_exists( 'o2' );
if ( $o2_exists ) {
add_filter( 'o2_process_the_content', '__return_false', 1 );
remove_filter( 'the_content', array( 'o2', 'add_json_data' ), 999999 );
}

$content = apply_filters( 'the_content', $content );
remove_filter( 'o2_process_the_content', '__return_false', 1 );
add_filter( 'the_content', array( 'o2', 'add_json_data' ), 999999 );

if ( $o2_exists ) {
remove_filter( 'o2_process_the_content', '__return_false', 1 );
add_filter( 'the_content', array( 'o2', 'add_json_data' ), 999999 );
}

// Create a unique placeholder for the content.
// Directly processing `$content` with `do_blocks` can lead to buggy layouts on make.wp.org.
Expand Down

0 comments on commit 1cff8c8

Please sign in to comment.