From e646d2c7527bd56f27877cf174d90a8f7ca871c6 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 19 Oct 2014 15:51:00 +1100 Subject: [PATCH] Move system status to settings tab --- includes/admin/class-sp-admin-assets.php | 2 +- includes/admin/class-sp-admin-menus.php | 19 - includes/admin/class-sp-admin-notices.php | 2 +- includes/admin/class-sp-admin-settings.php | 5 +- includes/admin/class-sp-admin-status.php | 9 +- .../settings/class-sp-settings-general.php | 2 +- .../settings/class-sp-settings-status.php | 600 ++++++++++++++++++ .../views/html-notice-template-check.php | 2 +- 8 files changed, 608 insertions(+), 33 deletions(-) create mode 100644 includes/admin/settings/class-sp-settings-status.php diff --git a/includes/admin/class-sp-admin-assets.php b/includes/admin/class-sp-admin-assets.php index fc2ec0bc..bccbe671 100755 --- a/includes/admin/class-sp-admin-assets.php +++ b/includes/admin/class-sp-admin-assets.php @@ -39,7 +39,7 @@ class SP_Admin_Assets { wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION ); - } elseif ( strpos( $screen->id, 'sp-config' ) !== false || strpos( $screen->id, 'sp-status' ) !== false ) { + } elseif ( strpos( $screen->id, 'sp-config' ) !== false ) { wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION ); } diff --git a/includes/admin/class-sp-admin-menus.php b/includes/admin/class-sp-admin-menus.php index 74b066d3..a285f21e 100755 --- a/includes/admin/class-sp-admin-menus.php +++ b/includes/admin/class-sp-admin-menus.php @@ -29,9 +29,6 @@ class SP_Admin_Menus { add_action( 'admin_menu', array( $this, 'seasons_menu' ), 10 ); add_filter( 'admin_menu', array( $this, 'menu_add' ), 20 ); - if ( current_user_can( 'manage_options' ) ) - add_action( 'admin_menu', array( $this, 'status_menu' ), 20 ); - add_action( 'admin_head', array( $this, 'menu_highlight' ) ); add_action( 'admin_head', array( $this, 'menu_rename' ) ); add_action( 'parent_file', array( $this, 'parent_file' ) ); @@ -80,14 +77,6 @@ class SP_Admin_Menus { add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season'); } - /** - * Add menu item - */ - public function status_menu() { - add_submenu_page( 'sportspress', __( 'System Status', 'sportspress' ), __( 'System Status', 'sportspress' ) , 'manage_sportspress', 'sp-status', array( $this, 'status_page' ) ); - register_setting( 'sportspress_status_settings_fields', 'sportspress_status_options' ); - } - /** * Highlights the correct top level admin menu item for post type add screens. * @@ -197,14 +186,6 @@ class SP_Admin_Menus { return true; } - /** - * Init the status page - */ - public function status_page() { - $page = include( 'class-sp-admin-status.php' ); - $page->output(); - } - /** * Clean the SP menu items in admin. */ diff --git a/includes/admin/class-sp-admin-notices.php b/includes/admin/class-sp-admin-notices.php index d6afa7d4..1d4f2502 100644 --- a/includes/admin/class-sp-admin-notices.php +++ b/includes/admin/class-sp-admin-notices.php @@ -88,7 +88,7 @@ class SP_Admin_Notices { * Show a notice highlighting bad template files */ public function template_file_check_notice() { - if ( isset( $_GET['page'] ) && 'sp-status' == $_GET['page'] ) { + if ( isset( $_GET['page'] ) && 'sportspress' == $_GET['page'] && isset( $_GET['tab'] ) && 'status' == $_GET['tab'] ) { return; } diff --git a/includes/admin/class-sp-admin-settings.php b/includes/admin/class-sp-admin-settings.php index fae8eac1..f3a2c145 100644 --- a/includes/admin/class-sp-admin-settings.php +++ b/includes/admin/class-sp-admin-settings.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin - * @version 1.3 + * @version 1.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -40,7 +40,8 @@ class SP_Admin_Settings { $settings = apply_filters( 'sportspress_get_settings_pages', $settings ); $settings[] = include( 'settings/class-sp-settings-text.php' ); - //$settings[] = include( 'settings/class-sp-settings-config.php' ); + + if ( current_user_can( 'manage_options' ) ) $settings[] = include( 'settings/class-sp-settings-status.php' ); self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings ); } diff --git a/includes/admin/class-sp-admin-status.php b/includes/admin/class-sp-admin-status.php index 5a2fe78d..268c101c 100644 --- a/includes/admin/class-sp-admin-status.php +++ b/includes/admin/class-sp-admin-status.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin - * @version 0.8 + * @version 1.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -17,13 +17,6 @@ if ( ! class_exists( 'SP_Admin_Status' ) ) : */ class SP_Admin_Status { - /** - * Handles output of the reports page in admin. - */ - public function output() { - include_once( 'views/html-admin-page-status.php' ); - } - /** * Retrieve metadata from a file. Based on WP Core's get_file_data function * diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index 3343cb0a..553f6792 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! class_exists( 'SP_Settings_General' ) ) : /** - * SP_Admin_Settings_General + * SP_Settings_General */ class SP_Settings_General extends SP_Settings_Page { diff --git a/includes/admin/settings/class-sp-settings-status.php b/includes/admin/settings/class-sp-settings-status.php new file mode 100644 index 00000000..04b40a8e --- /dev/null +++ b/includes/admin/settings/class-sp-settings-status.php @@ -0,0 +1,600 @@ +id = 'status'; + $this->label = __( 'System Status', 'sportspress' ); + + add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); + add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); + } + + /** + * Output system status + * + * @access public + * @return void + */ + public function output() { + ?> +

+
+

+

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + $posting['fsockopen_curl']['success'] = false; + } + + // SOAP + $posting['soap_client']['name'] = __( 'SOAP Client','sportspress' ); + if ( class_exists( 'SoapClient' ) ) { + $posting['soap_client']['note'] = __('Your server has the SOAP Client class enabled.', 'sportspress' ); + $posting['soap_client']['success'] = true; + } else { + $posting['soap_client']['note'] = sprintf( __( 'Your server does not have the SOAP Client class enabled - some gateway plugins which use SOAP may not work as expected.', 'sportspress' ), 'http://php.net/manual/en/class.soapclient.php' ) . ''; + $posting['soap_client']['success'] = false; + } + + $posting = apply_filters( 'sportspress_debug_posting', $posting ); + + foreach( $posting as $post ) { $mark = ( isset( $post['success'] ) && $post['success'] == true ) ? 'yes' : 'error'; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {'Author URI'} == 'http://themeboy.com' ) : + + $theme_dir = substr( strtolower( str_replace( ' ','', $active_theme->Name ) ), 0, 45 ); + + if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) : + + $theme_changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' ); + $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); + if ( ! empty( $cl_lines ) ) : + + foreach ( $cl_lines as $line_num => $cl_line ) { + if ( preg_match( '/^[0-9]/', $cl_line ) ) : + + $theme_date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) ); + $theme_version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) ); + $theme_update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) ); + $theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog ); + set_transient( $theme_dir . '_version_data', $theme_version_data , 60*60*12 ); + break; + + endif; + } + + endif; + + endif; + + endif; + ?> + + + + + + + + + + + + + + + + + + + + + + + + plugin_path() . '/includes/admin/class-sp-admin-status.php' ); + + $template_paths = apply_filters( 'sportspress_template_overrides_scan_paths', array( 'SportsPress' => SP()->plugin_path() . '/templates/' ) ); + $found_files = array(); + + foreach ( $template_paths as $plugin_name => $template_path ) + $scanned_files[ $plugin_name ] = $status->scan_template_files( $template_path ); + + foreach ( $scanned_files as $plugin_name => $files ) { + foreach ( $files as $file ) { + if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . $file; + } elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/sportspress/' . $file; + } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { + $theme_file = get_template_directory() . '/' . $file; + } elseif( file_exists( get_template_directory() . '/sportspress/' . $file ) ) { + $theme_file = get_template_directory() . '/sportspress/' . $file; + } else { + $theme_file = false; + } + + if ( $theme_file ) { + $core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file ); + $theme_version = $status->get_file_version( $theme_file ); + + if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { + $found_files[ $plugin_name ][] = sprintf( __( '%s version %s is out of date. The core version is %s', 'sportspress' ), basename( $theme_file ), $theme_version ? $theme_version : '-', $core_version ); + } else { + $found_files[ $plugin_name ][] = sprintf( '%s', basename( $theme_file ) ); + } + } + } + } + + if ( $found_files ) { + foreach ( $found_files as $plugin_name => $found_plugin_files ) { + ?> + + + + + + + + + +
:
:
:version ); ?>
:
:
:
:
:' . sprintf( __( '%s - We recommend setting memory to at least 64MB. See: Increasing memory allocated to PHP', 'sportspress' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . ''; + } else { + echo '' . size_format( $memory ) . ''; + } + ?>
:' . __( 'Yes', 'sportspress' ) . ''; else echo '' . __( 'No', 'sportspress' ) . ''; ?>
:
:
:
:
:
:
:' . sprintf( __( 'Default timezone is %s - it should be UTC', 'sportspress' ), $default_timezone ) . ''; + } else { + echo '' . sprintf( __( 'Default timezone is %s', 'sportspress' ), $default_timezone ) . ''; + } ?> +
: + + + +
:' . $plugin_name . ''; + } + + if ( strstr( $dirname, 'sportspress' ) ) { + + if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) { + $changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' ); + $cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) ); + if ( ! empty( $cl_lines ) ) { + foreach ( $cl_lines as $line_num => $cl_line ) { + if ( preg_match( '/^[0-9]/', $cl_line ) ) { + + $date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) ); + $version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) ); + $update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) ); + $version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog ); + set_transient( md5( $plugin ) . '_version_data', $version_data, 60*60*12 ); + break; + } + } + } + } + + if ( ! empty( $version_data['version'] ) && version_compare( $version_data['version'], $plugin_data['Version'], '>' ) ) + $version_string = ' – ' . $version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . ''; + } + + $sp_plugins[] = $plugin_name . ' ' . __( 'by', 'sportspress' ) . ' ' . $plugin_data['Author'] . ' ' . __( 'version', 'sportspress' ) . ' ' . $plugin_data['Version'] . $version_string; + + } + } + + if ( sizeof( $sp_plugins ) == 0 ) + echo '-'; + else + echo implode( ',
', $sp_plugins ); + + ?>
:
: 'sp_outcome', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 'sp_result', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 'sp_performance', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 'sp_column', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 'sp_metric', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 'sp_statistic', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) ); + foreach ( $posts as $post ) + $display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']'; + echo implode( ', ', array_map( 'esc_html', $display_posts ) ); + ?>
: 0 ) ); + foreach ( $terms as $term ) + $display_terms[] = $term->name . ' (' . $term->slug . ')'; + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?>
: 0 ) ); + foreach ( $terms as $term ) + $display_terms[] = $term->name . ' (' . $term->slug . ')'; + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?>
: 0 ) ); + foreach ( $terms as $term ) + $display_terms[] = $term->name . ' (' . $term->slug . ')'; + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?>
: 0 ) ); + foreach ( $terms as $term ) + $display_terms[] = $term->name . ' (' . $term->slug . ')'; + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?>
+ labels->name; + ?>: + + + publish; ?> publish, future; ?> future, draft; ?> draft, private; ?> private, trash; ?> trash, {'auto-draft'}; ?> auto-draft, inherit; ?> inherit +
:Name; + ?>
:Version; + + if ( ! empty( $theme_version_data['version'] ) && version_compare( $theme_version_data['version'], $active_theme->Version, '!=' ) ) + echo ' – ' . $theme_version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . ''; + ?>
:{'Author URI'}; + ?>
():', $found_plugin_files ); ?>:
+ + +

Your theme has bundled outdated copies of SportsPress template files – if you encounter functionality issues on the frontend this could the reason. Ensure you update or remove them (in general we recommend only bundling the template files you actually need to customize). See the system report for full details.', 'sportspress' ); ?>

-

+

\ No newline at end of file