• I do not use JetPack’s payment module. I have switched it off in the UI. But the filter still remains attached to the the_content hook.

    I can see Jetpack_Simple_Payments::remove_auto_paragraph_from_product_description as a priority 0 callback.

    How do I disable it completely?

    Similarly, I can also see crowdsignal_link and jetpack_videopress_flash_embed_filter and Jetpack_Geo_Location::the_content_microformat – I don’t use any of these services. They’re switched off in the admin panel. But their hooks remain.

    Please can you let me know how I remove them – either in the UI or via functions.php

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • You should be able to remove it via this code:

    if ( \function_exists( 'crowdsignal_link' ) ) {
    \remove_filter( 'the_content', 'crowdsignal_link', 1 );
    }
    Thread Starter Terence Eden

    (@edent)

    @kittmedia Thanks! That appears to work. The only one I can’t get removed now is Jetpack_Geo_Location::the_content_microformat

    The rest I’ve destroyed with

    remove_filter(
    'the_content',
    [Jetpack_Simple_Payments::get_instance(), 'remove_auto_paragraph_from_product_description'],
    0
    );
    remove_filter( 'the_content', 'jetpack_videopress_flash_embed_filter', 7 );
    remove_filter( 'the_content', 'jetpack_spotify_embed_ids', 7 );
    remove_filter( 'the_content', 'jetpack_fix_youtube_shortcode_display_filter', 7 );

    Hi @edent,

    Could you share your site URL so we can take a closer look?

    Thanks!

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi @edent,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    The only one I can’t get removed now is Jetpack_Geo_Location::the_content_microformat

    If you do not use Jetpack’s Geolocation feature, you could stop it from loading altogether using the jetpack_tools_to_include filter, like so:

    add_filter( 'jetpack_tools_to_include', function( $tools ) {
    $index = array_search( 'geo-location.php', $tools, true );
    if ( $index ) {
    unset( $tools[$index] );
    }
    return $tools;
    } );

    If you do not use specific embeds on your site, you could remove support for said embed using the jetpack_shortcodes_to_include filter. In your messages above, you mention Crowdsignal, YouTube, Spotify for example. You could remove all three like so:

    /**
    * Remove support for specific Jetpack shortcodes.
    * Crowdsignal, Spotify, YouTube.
    *
    * @param array $shortcodes The list of shortcodes to include.
    *
    * @return array The list of shortcodes to include.
    */
    function jeherve_remove_some_jetpack_shortcodes( $shortcodes ) {
    $shortcodes_to_remove = array(
    'crowdsignal',
    'spotify',
    'youtube',
    );

    foreach ( $shortcodes as $key => $shortcode_path ) {
    if ( in_array( $key, $shortcodes_to_remove, true ) ) {
    unset( $shortcodes[ $key ] );
    }
    }

    return $shortcodes;
    }
    add_filter( 'jetpack_shortcodes_to_include', 'jeherve_remove_some_jetpack_shortcodes' );

    Alternatively, if you do not use any of the shortcode embeds provided by the Jetpack plugin, you could deactivate the Shortcode embeds feature by going to Jetpack > Settings > Writing in your dashboard and toggling it off.

    I do not use JetPack’s payment module. I have switched it off in the UI. But the filter still remains attached to the the_content hook.

    One way to remove any checks for Payment tools would be to remove it via code, like this. This will allow you to remove all checks, not just the one you just spotted:

    // Do not register the Payments block.
    add_filter(
    'jetpack_set_available_extensions',
    function ( $extensions ) {
    return array_diff(
    $extensions,
    array(
    'simple-payments',
    )
    );
    }
    );

    // Do not load Simple Payments utilities.
    add_filter(
    'jetpack_tools_to_include',
    function ( $tools ) {
    $index = array_search( 'simple-payments/simple-payments.php', $tools, true );
    if ( $index ) {
    unset( $tools[ $index ] );
    }
    return $tools;
    }
    );
    Thread Starter Terence Eden

    (@edent)

    Thanks @jeherve – sadly the jetpack_tools_to_include filter doesn’t seem to be firing. But it gives me something to look for.

    Could I please encourage you to make these switches visible in the JetPack UI? I don’t think it is fair to ask users to add custom functions to toggle this functionality. If someone hasn’t switched on Payments, for example, there’s no need to load it up by default.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    sadly the jetpack_tools_to_include filter doesn’t seem to be firing.

    It seems to work in my tests. Can you tell me more about what you tried, and how you’re still experiencing issues?

    Could I please encourage you to make these switches visible in the JetPack UI?

    While we can, and do make some of those settings available in the settings UI, we cannot add each one of those options to the UI. Doing so would add hundreds of toggles, that would make things too confusing for just about any site admin. At some point, we must make a choice of the toggles we want to display, so they’re useful to site admins without being overwhelming. This is an approach we all try to follow in the WordPress ecosystem. It’s also known as “Decisions, not options”.

    Every time you give a user an option, you are asking them to make a decision. When a user doesn’t care or understand the option this ultimately leads to frustration.

    WordPress Philosophy

    That doesn’t mean we do not consider the impact of each function that we add to the plugin, though. If something must run on your site, as soon as you’ve connected your site to WordPress.com, and even if you haven’t turned on a toggle, we look at it and try hard to make sure it doesn’t have an negative impact on your site’s performance.

    Looking at the remove_auto_paragraph_from_product_description method you mentioned in your first post for example, this isn’t something that will have a noticeable impact on your site, as the method doesn’t do anything when you haven’t actually created a product you want to sell via the Payment button.

    Thread Starter Terence Eden

    (@edent)

    It seems to work in my tests. Can you tell me more about what you tried, and how you’re still experiencing issues?

    I’ve added this code to functions.php

    add_filter( 'jetpack_tools_to_include', function( $tools ) {
    var_dump($tools);die();
    $index = array_search( 'geo-location.php', $tools, true );
    if ( $index ) {
    unset( $tools[$index] );
    }
    return $tools;
    } );

    I’m then looping through $wp_filter["the_content"]->callbacks as per https://shkspr.mobi/blog/2024/08/wordpress-display-hook-action-priority-in-the-dashboard/

    Doing so would add hundreds of toggles

    I think you misunderstand me. There are already toggles like this for all sorts of JetPack options:

    If I’ve turned off something, there shouldn’t be any filter loaded.

    For example, I don’t have Monetize switched on – but the filter is still active. You say it doesn’t have a noticeable impact – but that could change in the future. I want JetPack to respect my choices.

    Additionally, I can’t find a setting for Geotagged posts. Again, I don’t want something loaded if I’m not using it. These things shouldn’t be forced onto users; we should have a choice.

    • This reply was modified 2 months, 1 week ago by Terence Eden.
    Plugin Contributor sermitr

    (@sermitr)

    Hello @edent.

    Thanks for bringing it up. We’ll give it a closer look and see if this is something we could optimize.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I’ve added this code to functions.php

    add_filter( 'jetpack_tools_to_include', function( $tools ) {	var_dump($tools);die();	$index = array_search( 'geo-location.php', $tools, true );	if ( $index ) {		unset( $tools[$index] );	}	return $tools;} );

    I’m then looping through $wp_filter["the_content"]->callbacks as per https://shkspr.mobi/blog/2024/08/wordpress-display-hook-action-priority-in-the-dashboard/

    Coming back to this thread, could you remove the die(); from your code snippet above? You will see the call from the geo-location.php file disappear from your dashboard widget when you do that. The jetpack_tools_to_include filter is a sure way to ensure that geo location file is not required in the plugin.

    It’s a mechanism we’ve chosen for some of the features included in the Jetpack plugin, whenever we decided that adding a toggle in the UI wasn’t necessary. The Payments feature can also be disabled using the same filter, for example:

    add_filter( 'jetpack_tools_to_include', function( $tools ) {
    $index = array_search( 'simple-payments/simple-payments.php', $tools, true );
    if ( $index ) {
    unset( $tools[$index] );
    }
    return $tools;
    } );

    You could even take a nuclear approach with that filter, and stop loading all the things that are currently loaded that way in the plugin:

    add_filter( 'jetpack_tools_to_include', '__return_empty_array' );

    All that said, I know it can cause some confusion at times. Like you said, Jetpack should respect your choices. With that in mind, in the past year we’ve started to move away from this approach: we’ve removed some features entirely, or started loading them differently, or moved them to a toggle in the UI. A colleague of mine recently published a post with some examples of recent changes we’ve made with that performance approach in mind.

    Thread Starter Terence Eden

    (@edent)

    Sadly, this doesn’t work.

    add_filter( 'jetpack_tools_to_include', '__return_empty_array' );

    If I *just* have that in my functions.php, it loads up all sort of irrelevant JP stuff like jetpack_videopress_flash_embed_filter and jetpack_spotify_embed_ids

    The only thing I need from JetPack is stats. So I’ve ended up with this unwieldy monster function:

    add_action('init', function() {
    if ( class_exists( 'Jetpack_Simple_Payments' ) ) {
    remove_filter(
    'the_content',
    [Jetpack_Simple_Payments::get_instance(), 'remove_auto_paragraph_from_product_description'],
    0
    );
    }
    remove_filter( 'the_content', 'jetpack_videopress_flash_embed_filter', 7 );
    remove_filter( 'the_content', 'jetpack_spotify_embed_ids', 7 );
    remove_filter( 'the_content', 'jetpack_fix_youtube_shortcode_display_filter', 7 );
    remove_filter( 'the_content', 'convert_smilies', 20 );
    foreach ( array( 'the_content', 'the_title', 'wp_title', 'document_title' ) as $filter ) {
    remove_filter( $filter, 'capital_P_dangit', 11 );
    }
    remove_filter( 'comment_text', 'capital_P_dangit', 31 ); // No idea why this is separate
    remove_filter( 'the_content', 'do_blocks', 9 );

    if ( \function_exists( 'crowdsignal_link' ) ) {
    \remove_filter( 'the_content', 'crowdsignal_link', 1 );
    }
    // Remove Open Graph
    add_filter( "jetpack_enable_open_graph", "__return_false" );

    // Remove JetPack CSS
    // https://css-tricks.com/snippets/wordpress/removing-jetpack-css/
    add_filter( 'jetpack_sharing_counts', '__return_false', 99 );
    add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 );

    // Remove the forced Blaze
    // https://developer.jetpack.com/hooks/jetpack_blaze_enabled/
    add_filter( 'jetpack_blaze_enabled', '__return_false' );
    add_filter( 'jetpack_tools_to_include', '__return_empty_array' );
    }, 11);

    // Remove Sharing Icons
    // https://jetpack.com/2013/06/10/moving-sharing-icons/
    function jptweak_remove_share() {
    remove_filter( 'the_content', 'sharing_display', 19 );
    remove_filter( 'the_excerpt', 'sharing_display', 19 );
    if ( class_exists( 'Jetpack_Likes' ) ) {
    remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
    }
    }
    add_action( 'loop_start', 'jptweak_remove_share' );

    Like, this is clearly bonkers, right? I want one function from your plugin. There’s no sensible way to disable all the other extraneous stuff.

    I do appreciate all the work you do. But JetPack just doesn’t work for me any more. I want something modular rather than running dozens of irrelevant functions.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    If I just have that in my functions.php, it loads up all sort of irrelevant JP stuff like jetpack_videopress_flash_embed_filter and jetpack_spotify_embed_ids

    That’s expected I’m afraid. Since you use the shortcode embeds feature on your site (as we can see in the screenshot you posted earlier), you will see things related to different shortcodes. If you want to continue using the shortcode embeds feature, but are not interested in some of the embeds like Spotify, you can use the jetpack_shortcodes_to_include filter I mentioned in one of my earlier posts.

    So I’ve ended up with this unwieldy monster function:

    It is indeed an interesting mix of things. The good news is, you can get rid of a lot of those things if you actually disable the features you’re not interested in. For example, if you’ve disabled the Sharing, Like, and Blaze features, you do not need to add any sharing / Like / Blaze code snippets. That code will not be loaded on your site at all, there is no need for additional snippets.

    Thread Starter Terence Eden

    (@edent)

    I’ve solved the problem by uninstalling JetPack.

    Due to Matt Mullenweg’s recent behaviour, I simply can’t trust my data and my site to someone who makes capricious decisions without regard to the WordPress community.

    I’m sad that I can’t continue using JetPack. But Matt Mullenweg has destroyed my faith in JetPack and WordPress.

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.