In this code, we create a new PHP class called DisableJetpackPromotions
. In the constructor function of this class, we add several WordPress filters that disable Jetpack promotions and announcement notices.
The jetpack_just_in_time_msgs
filter disables all Just-in-Time messages that Jetpack might display in the WordPress dashboard. (I think that should catch them all, but if not…) The jetpack_just_in_time_msgs_allowed
and jetpack_just_in_time_msgs_allowed_list
filters prevent Jetpack from showing any allowed messages or messages in a specific list. Finally, the jetpack_just_in_time_highlight_reel
filter disables the Jetpack Highlight Reel feature.
We’re also adding the basic promotion blocker using the jetpack_show_promotions
and blocking Jetpack’s analytics data collection using jetpack_blaze_enabled
.
We then create a new instance of the DisableJetpackPromotions
class to ensure that these filters are applied when the WordPress site is loaded. The Snippet is set to run only in the WP admin backend. But in the event you don’t use it inside of Code Snippets Pro ❤️, it also checks for is_admin
so that it’s only running when necessary.
See the code…
<?php
// Disable Jetpack Promotions and Notices in WP Admin [SnipSnip.pro]
// https://snipsnip.pro/s/629
if ( \is_admin() && !class_exists( 'DisableJetpackPromotions' ) ) {
class DisableJetpackPromotions {
public function __construct() {
// Disable all Just-in-Time messages
add_filter( 'jetpack_just_in_time_msgs', '__return_false' );
add_filter( 'jetpack_just_in_time_msgs_allowed', '__return_false' );
add_filter( 'jetpack_just_in_time_msgs_allowed_list', '__return_empty_array' );
// Disable the Jetpack Highlight Reel feature
add_filter( 'jetpack_just_in_time_highlight_reel', '__return_false' );
// Use the basic promotion blockers
add_filter( 'jetpack_show_promotions', '__return_false', 20 );
add_filter( 'jetpack_blaze_enabled', '__return_false' );
}
}
new DisableJetpackPromotions();
}
👆 This shortcode was added to the Post using Block Editor
👇 This Shortcode was added to the Single Template using FSE