@@ -42,6 +42,7 @@ public static function init() {
4242 'admin_bar_color ' => null ,
4343 'disable_emojis ' => false ,
4444 'disable_search ' => false ,
45+ 'disable_updates ' => [],
4546 'disable_xmlrpc ' => false ,
4647 'feed_links ' => true ,
4748 'heartbeat ' => null ,
@@ -70,6 +71,15 @@ public static function init() {
7071 'is_production ' => defined ( self ::get_config ( 'common_toolkit/environment_constant ' ) ) ? self ::get_config ( 'common_toolkit/environment_production ' ) == getenv ( self ::get_config ( 'common_toolkit/environment_constant ' ) ) : true
7172 ];
7273
74+ // Remove WordPress core, plugin and/or theme update notices
75+ $ disable_updates = self ::get_config ( 'common_toolkit/disable_updates ' );
76+ if ( in_array ( 'core ' , $ disable_updates ) )
77+ add_filter ( 'pre_site_transient_update_core ' , array ( self ::$ instance , 'disable_updates ' ) );
78+ if ( in_array ( 'plugin ' , $ disable_updates ) )
79+ add_filter ( 'pre_site_transient_update_plugins ' , array ( self ::$ instance , 'disable_updates ' ) );
80+ if ( in_array ( 'theme ' , $ disable_updates ) )
81+ add_filter ( 'pre_site_transient_update_themes ' , array ( self ::$ instance , 'disable_updates ' ) );
82+
7383 // Modify or disable WordPress heartbeat
7484 if ( self ::get_config ( 'common_toolkit/heartbeat ' ) === false ) { // Disable heartbeat
7585 add_action ( 'init ' , function () { wp_deregister_script ( 'heartbeat ' ); }, 1 );
@@ -194,7 +204,7 @@ public static function ctk_config_filter( $key = null ) {
194204 * Usage: echo apply_filters( 'ctk_environment', null ); // Echos current environment string
195205 * var_dump( apply_filters( 'ctk_environment', 'is_production' ) ); // Returns true if in production mode
196206 *
197- * @since 0.8.1
207+ * @since 0.8.0
198208 */
199209 public static function ctk_environment_filter ( $ key = null ) {
200210
@@ -230,10 +240,23 @@ public function disable_emojis() {
230240
231241 }
232242
243+ /*
244+ * Remove WordPress core, plugin and/or theme update notices
245+ * Usage: define( 'CTK_CONFIG', [ 'disable_updates' => [ 'core', 'plugin', 'theme' ] ] );
246+ *
247+ * @since 0.8.0
248+ */
249+ public function disable_updates () {
250+
251+ global $ wp_version ;
252+ return (object ) array ( 'last_checked ' => time (), 'version_checked ' => $ wp_version );
253+
254+ }
255+
233256 /*
234257 * Disables WordPress site search and return 404
235258 *
236- * @since 0.8.1
259+ * @since 0.8.0
237260 */
238261 public function disable_search ( $ query , $ error = true ) {
239262
0 commit comments