• Resolved WanDal

    (@dawasi)


    Hi

    I need to remove the_content filter. Up to version 5.6 I used the following code:

    add_action( 'wp_loaded', function() {
      remove_filter( 'the_content', array( WP_Typography::get_instance(), 'process' ), 9999 );
    } );

    However, since version 5.7 this no longer works. How can I remove the filter in the latest version?

    Many thanks

    • This topic was modified 4 years, 9 months ago by WanDal.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author pepe

    (@pputzer)

    Hi @dawasi, that’s weird. This mechanism should not have changed with the update. You don’t have NextGEN Gallery installed? That would change the priority used to PHP_INT_MAX.

    As a workaround, you can use the typo_disable_filtering hook like this to disable all “content”-type filters:

    
    add_filter( 'typo_disable_filtering', function( $disable, $filter_group ) {
        return 'content' !== $filter_group;
    }, 10, 2 );
    
    Thread Starter WanDal

    (@dawasi)

    Hi @pputzer

    No, NextGEN Gallery is not installed.

    Disabling the whole content filter group is not an option, because I need the rest of the filters.

    In version 5.6.1 we used before, the_content filter was added in \wp-typography\includes\wp-typography\components\class-public-interface.php using:

    \add_filter( 'the_content', [ $this->plugin, 'process' ], $priority );

    where $this->plugin was an object of class WP_Typography.

    In version 5.7.0, the_content filter is added using:

    \add_filter( 'the_content', [ $this->api, 'process' ], $priority );

    where $this->api is an object of class Implementation.

    Couldn’t my problem be related to this adjustment?

    Plugin Author pepe

    (@pputzer)

    It should not matter, because WP_Typography\Implementation is a subclass of WP_Typography and the actual object returned by WP_Typography::get_instance(). In 5.7, I just renamed the property and updated the annotation to document we are actually using WP_Typography\Implementation internally. I’ll investigate, but right now I don’t see how it could change things (it ultimately boils down to spl_object_hash()).

    Plugin Author pepe

    (@pputzer)

    Sorry for the delay. I found the bug (incorrect dependency injection due to the type hint change, so there where actually two instances of the supposed singleton).

    Plugin Author pepe

    (@pputzer)

    Fixed in 5.7.1.

    Thread Starter WanDal

    (@dawasi)

    Great! Thanks a lot.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove the_content filter’ is closed to new replies.