diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index c6cf0c80..626d35d4 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -80,6 +80,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) ); add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) ); add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) ); + add_action( 'um_admin_do_action__check_version', array( &$this, 'check_version' ) ); add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) ); @@ -1869,6 +1870,33 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } + public function check_version( $action ) { + $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_template_version' ); + } + + $url = add_query_arg( + array( + 'page' => 'um_options', + 'tab' => 'override_templates', + ), + admin_url( 'admin.php' ) + ); + wp_safe_redirect( $url ); + exit; + } + + /** * Add any custom links to plugin page * diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 7b335fc5..34745cd8 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -52,6 +52,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { $this->extensions_page(); + $this->template_version(); + // removed for now to avoid the bad reviews //$this->reviews_notice(); @@ -714,6 +716,31 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { } + public function template_version() { + if ( true === (bool) get_option( 'um_template_version' ) ) { + $link = get_admin_url( null, 'admin.php?page=um_options&tab=override_templates' ); + ob_start(); + ?> + +

+ override templates status page and update templates', 'ultimate-member' ), $link ); ?> +

+ + admin()->notices()->add_notice( + 'um_private_content_notice', + array( + 'class' => 'error', + 'message' => $message, + 'dismissible' => false, + ), + 10 + ); + } + } + + function dismiss_notice() { UM()->admin()->check_ajax_nonce(); diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 441bdbcd..e72982e2 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -64,7 +64,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 ); - //custom content for licenses tab + //custom content for override templates tab + add_action( 'plugins_loaded', array( $this, 'um_check_template_version' ), 10 ); add_filter( 'um_settings_section_override_templates__content', array( $this, 'settings_override_templates_tab' ), 10, 2 ); @@ -3019,11 +3020,34 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } + public function um_check_template_version() { + $um_check_version = get_transient( 'um_check_template_versions' ); + if ( false === $um_check_version ) { + $this->get_override_templates(); + } + } + + public function settings_override_templates_tab( $html, $section_fields ) { + $um_check_version = get_transient( 'um_check_template_versions' ); ?> +

+ '; + echo esc_html__('You could re-checked changes manually', 'ultimate-member'); + } + ?> +

- + + +

+

+ +

scan_template_files( um_path . '/templates/' ); + $out_date = false; + set_transient( 'um_check_template_versions', current_time('d/m/Y H:i' ), 12 * HOUR_IN_SECONDS ); foreach ( $scan_files as $key => $file ) { if ( ! str_contains( $file, 'email/' ) ) { if ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/' . $file ) ) { @@ -3057,6 +3083,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $status = esc_html__( 'Theme version is empty', 'ultimate-member' ); $status_code = 0; } + if ( 0 === $status_code ) { + $out_date = true; + update_option( 'um_template_version', 1 ); + } $outdated_files[] = array( 'core_version' => $core_version, 'theme_version' => $theme_version, @@ -3068,8 +3098,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } } - - return $outdated_files; + if ( false === $out_date ) { + delete_option( 'um_template_version' ); + } + update_option( 'um_template_statuses', $outdated_files ); + if ( true === $get_list ) { + return $outdated_files; + } } diff --git a/includes/admin/core/list-tables/version-template-list-table.php b/includes/admin/core/list-tables/version-template-list-table.php index 1eb41c65..dda0f3e8 100644 --- a/includes/admin/core/list-tables/version-template-list-table.php +++ b/includes/admin/core/list-tables/version-template-list-table.php @@ -303,7 +303,7 @@ $columns = apply_filters( $ListTable->set_columns( $columns ); -$templates = UM()->admin_settings()->get_override_templates(); +$templates = get_option( 'um_template_statuses' ) ? get_option( 'um_template_statuses' ) : array(); $ListTable->prepare_items(); $ListTable->items = array_slice( $templates, ( $paged - 1 ) * $per_page, $per_page );