From 5673f1c4509f7f8335846d36d0aa2faf17eb8a64 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Wed, 14 Feb 2024 14:35:16 +0200 Subject: [PATCH] - fixed displaying outdated templates admin notice between theme switching; --- includes/admin/class-admin.php | 14 +----------- includes/common/class-init.php | 13 +++++++++++ includes/common/class-screen.php | 2 +- includes/common/class-theme.php | 38 ++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 includes/common/class-theme.php diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 0abab767..6512115c 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -1904,19 +1904,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * Manual check templates versions. */ public function check_templates_version() { - $templates = UM()->admin_settings()->get_override_templates( true ); - $out_date = false; - - foreach ( $templates as $template ) { - if ( 0 === $template['status_code'] ) { - $out_date = true; - break; - } - } - - if ( false === $out_date ) { - delete_option( 'um_override_templates_outdated' ); - } + UM()->common()->theme()->check_outdated_templates(); $url = add_query_arg( array( diff --git a/includes/common/class-init.php b/includes/common/class-init.php index aa777765..1e9e74cd 100644 --- a/includes/common/class-init.php +++ b/includes/common/class-init.php @@ -24,6 +24,7 @@ if ( ! class_exists( 'um\common\Init' ) ) { $this->screen(); $this->secure()->hooks(); $this->site_health(); + $this->theme()->hooks(); } /** @@ -73,5 +74,17 @@ if ( ! class_exists( 'um\common\Init' ) ) { } return UM()->classes['um\common\site_health']; } + + /** + * @since 2.8.3 + * + * @return Theme + */ + public function theme() { + if ( empty( UM()->classes['um\common\theme'] ) ) { + UM()->classes['um\common\theme'] = new Theme(); + } + return UM()->classes['um\common\theme']; + } } } diff --git a/includes/common/class-screen.php b/includes/common/class-screen.php index 494cdae8..e9328e74 100644 --- a/includes/common/class-screen.php +++ b/includes/common/class-screen.php @@ -18,7 +18,7 @@ if ( ! class_exists( 'um\common\Screen' ) ) { * Screen constructor. */ public function __construct() { - add_filter( 'body_class', array( &$this, 'remove_admin_bar' ), 1000, 1 ); + add_filter( 'body_class', array( &$this, 'remove_admin_bar' ), 1000 ); } /** diff --git a/includes/common/class-theme.php b/includes/common/class-theme.php new file mode 100644 index 00000000..c667646a --- /dev/null +++ b/includes/common/class-theme.php @@ -0,0 +1,38 @@ +admin_settings()->get_override_templates( true ); + $out_date = false; + + foreach ( $templates as $template ) { + if ( 0 === $template['status_code'] ) { + $out_date = true; + break; + } + } + + if ( false === $out_date ) { + delete_option( 'um_override_templates_outdated' ); + } + } +}