diff --git a/includes/admin/assets/css/um-admin-settings.css b/includes/admin/assets/css/um-admin-settings.css index 1e159673..8dab9844 100644 --- a/includes/admin/assets/css/um-admin-settings.css +++ b/includes/admin/assets/css/um-admin-settings.css @@ -46,17 +46,17 @@ text-align: center; } -.column-core_version { +.wp-list-table.templates .column-core_version { width: 100px; text-align: center; } -.column-theme_version { +.wp-list-table.templates .column-theme_version { width: 100px; text-align: center; } -.column-status { +.wp-list-table.templates .column-status { width: 260px; } @@ -227,6 +227,16 @@ th.column-email.column-primary { .um-small-field { width:50%; } + + .wp-list-table.templates .column-core_version { + width: auto; + text-align: left; + } + + .wp-list-table.templates .column-theme_version { + width: auto; + text-align: left; + } } /* diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 5db21566..0e59a9fb 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -80,7 +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__check_templates_version', array( &$this, 'check_templates_version' ) ); add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) ); @@ -1869,13 +1869,12 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } - /** * Manual check templates versions * * @param $action */ - public function check_version( $action ) { + public function check_templates_version( $action ) { $templates = UM()->admin_settings()->get_override_templates( true ); $out_date = false; @@ -1887,7 +1886,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } if ( false === $out_date ) { - delete_option( 'um_template_version' ); + delete_option( 'um_override_templates_outdated' ); } $url = add_query_arg( @@ -1901,7 +1900,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 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 dd4277d3..fa68e9f1 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -720,22 +720,22 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { * Check Templates Versions notice */ 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' ); + if ( true === get_option( 'um_override_templates_outdated' ) ) { + $link = admin_url( 'admin.php?page=um_options&tab=override_templates' ); ob_start(); ?>
override templates status page and update templates', 'ultimate-member' ), $link ), UM()->get_allowed_html( 'admin_notice' ) ); + echo wp_kses( sprintf( __( 'Your templates are out of date. Please visit override templates status page and update templates.', 'ultimate-member' ), $link ), UM()->get_allowed_html( 'admin_notice' ) ); ?>
admin()->notices()->add_notice( - 'um_private_content_notice', + 'um_override_templates_notice', array( 'class' => 'error', 'message' => $message, diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 0854577c..a12d75a8 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -68,10 +68,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 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 ); - add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 ); - //save handlers add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 ); @@ -79,10 +77,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) ); add_action( 'um_settings_save', array( $this, 'on_settings_save' ) ); - add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) ); - //save licenses options add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) ); add_action( 'um_settings_save', array( $this, 'licenses_save' ) ); @@ -1978,7 +1974,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" ); - if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) { + if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info', 'override_templates' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) { /** * UM hook @@ -3019,7 +3015,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $section; } - + /** + * Periodically checking the versions of templates. + * + * @since 2.6.1 + * + * @return void + */ public function um_check_template_version() { $um_check_version = get_transient( 'um_check_template_versions' ); if ( false === $um_check_version ) { @@ -3027,35 +3029,35 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } - /** - * @param $html - * @param $section_fields - * - * @return string + * HTML for Settings > Override Templates tab. + * @return void */ - public function settings_override_templates_tab( $html, $section_fields ) { + public function settings_override_templates_tab() { $um_check_version = get_transient( 'um_check_template_versions' ); ?> -- '; - echo esc_html__('You could re-checked changes manually', 'ultimate-member'); - } - ?> -
-- - - -
-- - - -
+ ++ + + + +
++ here.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1516-templates-map' ), UM()->get_allowed_html( 'admin_notice' ) ); + ?> +
+ scan_template_files( um_path . '/templates/' ); - $scan_files = apply_filters( 'um_extend_scan_files', $scan_files ); + $scan_files = apply_filters( 'um_override_templates_scan_files', $scan_files ); $out_date = false; - set_transient( 'um_check_template_versions', current_time( 'd/m/Y H:i' ), 12 * HOUR_IN_SECONDS ); + + set_transient( 'um_check_template_versions', time(), 12 * HOUR_IN_SECONDS ); + foreach ( $scan_files as $key => $file ) { if ( ! str_contains( $file, 'email/' ) ) { - $located = apply_filters( 'um_get_path_template', array(), $file ); + $located = apply_filters( 'um_override_templates_get_template_path', array(), $file ); if ( ! empty( $located ) ) { $theme_file = $located['theme']; @@ -3106,7 +3110,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } if ( 0 === $status_code ) { $out_date = true; - update_option( 'um_template_version', 1 ); + update_option( 'um_override_templates_outdated', true ); } $outdated_files[] = array( 'core_version' => $core_version, @@ -3119,9 +3123,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } } -// exit(); + if ( false === $out_date ) { - delete_option( 'um_template_version' ); + delete_option( 'um_override_templates_outdated' ); } update_option( 'um_template_statuses', $outdated_files ); if ( true === $get_list ) { @@ -3142,7 +3146,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { if ( ! empty( $files ) ) { - foreach ( $files as $key => $value ) { + foreach ( $files as $value ) { if ( ! in_array( $value, array( '.', '..' ), true ) ) { @@ -3160,14 +3164,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $result; } - /** * @param $file string * * @return string */ public static function get_file_version( $file ) { - // Avoid notices if file does not exist. if ( ! file_exists( $file ) ) { return ''; 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 dda0f3e8..940ba523 100644 --- a/includes/admin/core/list-tables/version-template-list-table.php +++ b/includes/admin/core/list-tables/version-template-list-table.php @@ -1,50 +1,23 @@ -get_columns(); - $hidden = array(); - $sortable = $this->get_sortable_columns(); - $this->_column_headers = array( $columns, $hidden, $sortable ); - } + $screen = $this->screen; + $columns = $this->get_columns(); + $sortable = $this->get_sortable_columns(); + $this->_column_headers = array( $columns, array(), $sortable ); + + $templates = get_option( 'um_template_statuses', array() ); + $templates = is_array( $templates ) ? $templates : array(); + + @uasort( + $templates, + function ( $a, $b ) { + if ( strtolower( $a['status_code'] ) === strtolower( $b['status_code'] ) ) { + return 0; + } + return ( strtolower( $a['status_code'] ) < strtolower( $b['status_code'] ) ) ? -1 : 1; + } + ); + + $per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 ); + $paged = $this->get_pagenum(); + + $this->items = array_slice( $templates, ( $paged - 1 ) * $per_page, $per_page ); + + $this->set_pagination_args( + array( + 'total_items' => count( $templates ), + 'per_page' => $per_page, + ) + ); + } /** * @param object $item @@ -102,7 +98,6 @@ class UM_Versions_List_Table extends WP_List_Table { } } - /** * */ @@ -110,51 +105,16 @@ class UM_Versions_List_Table extends WP_List_Table { echo $this->no_items_message; } - - /** - * @param array $args - * - * @return $this - */ - public function set_sortable_columns( $args = array() ) { - $return_args = array(); - foreach ( $args as $k=>$val ) { - if ( is_numeric( $k ) ) { - $return_args[ $val ] = array( $val, $val == $this->default_sorting_field ); - } elseif( is_string( $k ) ) { - $return_args[ $k ] = array( $val, $k == $this->default_sorting_field ); - } else { - continue; - } - } - $this->sortable_columns = $return_args; - return $this; - } - - - /** - * @return array - */ - public function get_sortable_columns() { - return $this->sortable_columns; - } - - /** * @param array $args * * @return $this */ public function set_columns( $args = array() ) { - if ( count( $this->bulk_actions ) ) { - $args = array_merge( array( 'cb' => '' ), $args ); - } $this->columns = $args; - return $this; } - /** * @return array */ @@ -162,45 +122,6 @@ class UM_Versions_List_Table extends WP_List_Table { return $this->columns; } - - /** - * @param array $args - * - * @return $this - */ - public function set_actions( $args = array() ) { - $this->actions = $args; - return $this; - } - - - /** - * @return array - */ - public function get_actions() { - return $this->actions; - } - - - /** - * @param array $args - * - * @return $this - */ - public function set_bulk_actions( $args = array() ) { - $this->bulk_actions = $args; - return $this; - } - - - /** - * @return array - */ - public function get_bulk_actions() { - return $this->bulk_actions; - } - - /** * @param $item * @@ -215,7 +136,6 @@ class UM_Versions_List_Table extends WP_List_Table { return $output; } - /** * @param $item * @@ -225,19 +145,15 @@ class UM_Versions_List_Table extends WP_List_Table { return $item['core_version']; } - /** * @param $item * * @return string */ public function column_theme_version( $item ) { - $theme_version = $item['theme_version'] ? $item['theme_version'] : '-'; - - return $theme_version; + return $item['theme_version'] ? $item['theme_version'] : '-'; } - /** * @param $item * @@ -245,21 +161,11 @@ class UM_Versions_List_Table extends WP_List_Table { */ public function column_status( $item ) { $icon = 1 === $item['status_code'] ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt'; - $text = $item['status'] . ' '; - - return $text; - } - - - /** - * @param array $attr - */ - public function wpc_set_pagination_args( $attr = array() ) { - $this->set_pagination_args( $attr ); + return $item['status'] . ' '; } } -$ListTable = new UM_Versions_List_Table( +$list_table = new UM_Versions_List_Table( array( 'singular' => __( 'Template', 'ultimate-member' ), 'plural' => __( 'Templates', 'ultimate-member' ), @@ -267,9 +173,6 @@ $ListTable = new UM_Versions_List_Table( ) ); -$per_page = 999; -$paged = $ListTable->get_pagenum(); - /** * UM hook * @@ -301,22 +204,12 @@ $columns = apply_filters( ) ); -$ListTable->set_columns( $columns ); - -$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 ); -$ListTable->wpc_set_pagination_args( - array( - 'total_items' => count( $templates ), - 'per_page' => $per_page, - ) -); ?> +$list_table->set_columns( $columns ); +$list_table->prepare_items(); +?> diff --git a/includes/class-config.php b/includes/class-config.php index c0b812f1..1892d6fe 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -449,7 +449,7 @@ if ( ! class_exists( 'um\Config' ) ) { 'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}