@@ -40,8 +40,6 @@ public function init() {
4040 add_action ( 'switch_theme ' , [ $ this , 'switch_theme_material ' ], 10 , 2 );
4141 add_action ( 'admin_notices ' , [ $ this , 'theme_not_installed_notice ' ], 10 , 2 );
4242 add_action ( 'admin_notices ' , [ $ this , 'plugin_activated_notice ' ], 9 , 2 );
43- add_filter ( 'auto_update_plugin ' , [ $ this , 'enable_plugin_auto_update ' ], 10 , 2 );
44- add_filter ( 'auto_update_theme ' , [ $ this , 'enable_theme_auto_update ' ], 10 , 2 );
4543 }
4644
4745 /**
@@ -291,22 +289,30 @@ public function enqueue_assets() {
291289 true
292290 );
293291
292+ $ plugin_file = 'material-design/material-design.php ' ;
293+ $ plugin_updates = get_site_transient ( 'update_plugins ' );
294+ $ theme_updates = get_site_transient ( 'update_themes ' );
295+
294296 wp_localize_script (
295297 'material-settings ' ,
296298 'materialDesignWizard ' ,
297299 [
298- 'restPath ' => esc_url ( $ this ->plugin ->onboarding_rest_controller ->get_base_path () ),
299- 'redirect ' => esc_url ( admin_url ( 'themes.php ' ) ),
300- 'nonce ' => wp_create_nonce ( 'wp_rest ' ),
301- 'themeStatus ' => esc_html ( $ this ->plugin ->theme_status () ),
302- 'assetsRestPath ' => esc_url ( $ this ->plugin ->assets_rest_controller ->get_base_path () ),
303- 'apiStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_api_status () ),
304- 'fontsLastUpdated ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_last_updated () ),
305- 'iconsLastUpdated ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_last_updated () ),
306- 'fontsAutoUpdate ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_auto_update () ),
307- 'iconsAutoUpdate ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_auto_update () ),
308- 'fontsUpdateStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_update_status () ),
309- 'iconsUpdateStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_update_status () ),
300+ 'restPath ' => esc_url ( $ this ->plugin ->onboarding_rest_controller ->get_base_path () ),
301+ 'redirect ' => esc_url ( admin_url ( 'themes.php ' ) ),
302+ 'nonce ' => wp_create_nonce ( 'wp_rest ' ),
303+ 'themeStatus ' => esc_html ( $ this ->plugin ->theme_status () ),
304+ 'assetsRestPath ' => esc_url ( $ this ->plugin ->assets_rest_controller ->get_base_path () ),
305+ 'apiStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_api_status () ),
306+ 'fontsLastUpdated ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_last_updated () ),
307+ 'iconsLastUpdated ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_last_updated () ),
308+ 'fontsAutoUpdate ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_auto_update () ),
309+ 'iconsAutoUpdate ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_auto_update () ),
310+ 'fontsUpdateStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_fonts_update_status () ),
311+ 'iconsUpdateStatus ' => esc_html ( $ this ->plugin ->assets_rest_controller ->get_icons_update_status () ),
312+ 'pluginAutoUpdate ' => in_array ( 'material-design/material-design.php ' , get_site_option ( 'auto_update_plugins ' , [] ), true ),
313+ 'themeAutoUpdate ' => in_array ( Plugin::THEME_SLUG , get_site_option ( 'auto_update_themes ' , [] ), true ),
314+ 'pluginUpdateStatus ' => isset ( $ plugin_updates ->response [ $ plugin_file ] ) ? 1 : 0 ,
315+ 'pluginUpdateStatus ' => isset ( $ theme_updates ->response [ Plugin::THEME_SLUG ] ) ? 1 : 0 ,
310316 ]
311317 );
312318 }
@@ -462,36 +468,4 @@ public function plugin_activated_notice() {
462468 )
463469 );
464470 }
465-
466- /**
467- * Enable auto updates for the plugin.
468- *
469- * @param bool|null $update Whether to update.
470- * @param object $item The update offer.
471- *
472- * @return bool
473- */
474- public function enable_plugin_auto_update ( $ update , $ item ) {
475- if ( 'material-design ' === $ item ->slug ) {
476- return true ;
477- }
478-
479- return $ update ;
480- }
481-
482- /**
483- * Enable auto updates for the theme.
484- *
485- * @param bool|null $update Whether to update.
486- * @param object $item The update offer.
487- *
488- * @return bool
489- */
490- public function enable_theme_auto_update ( $ update , $ item ) {
491- if ( Plugin::THEME_SLUG === $ item ->slug ) {
492- return true ;
493- }
494-
495- return $ update ;
496- }
497471}
0 commit comments