diff --git a/assets/css/admin.css b/assets/css/admin.css index 32d4fe7f..bf7d1093 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -381,6 +381,36 @@ table.widefat select.sp-outcome { border-left-color: #464646; } +#debug-report { + display: none; + margin: 10px 0; + padding: 0; + position: relative; +} + +#debug-report textarea { + font-family: monospace; + width: 100%; + margin: 0; + height: 300px; + padding: 20px; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; + resize: none; + font-size: 12px; + line-height: 20px; + outline: 0; +} + +table.sp_status_table td mark { + background: transparent none; +} + +table.sp_status_table td mark.yes { + color: #7ad03a; +} + /* Media Queries */ @media only screen and (max-width: 782px) { diff --git a/includes/admin/class-sp-admin-addons.php b/includes/admin/class-sp-admin-addons.php new file mode 100644 index 00000000..40cff639 --- /dev/null +++ b/includes/admin/class-sp-admin-addons.php @@ -0,0 +1,62 @@ + 'sportspress-addons-page', + 'timeout' => 3 + ) ); + + if ( ! is_wp_error( $raw_addons ) ) { + + $raw_addons = wp_remote_retrieve_body( $raw_addons ); + + // Get Products + $dom = new DOMDocument(); + libxml_use_internal_errors(true); + $dom->loadHTML( $raw_addons ); + + $addons = ''; + $xpath = new DOMXPath( $dom ); + $tags = $xpath->query('//ul[@class="products"]'); + foreach ( $tags as $tag ) { + $addons = $tag->ownerDocument->saveXML( $tag ); + break; + } + + if ( $addons ) + set_transient( 'sportspress_addons_html_' . $view, wp_kses_post( $addons ), 60*60*24*7 ); // Cached for a week + } + } + + include_once( 'views/html-admin-page-addons.php' ); + } +} + +endif; + +return new SP_Admin_Addons(); \ No newline at end of file diff --git a/includes/admin/class-sp-admin-menus.php b/includes/admin/class-sp-admin-menus.php index 371cf007..a12ae47a 100644 --- a/includes/admin/class-sp-admin-menus.php +++ b/includes/admin/class-sp-admin-menus.php @@ -22,6 +22,11 @@ class SP_Admin_Menus { */ public function __construct() { add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); + add_action( 'admin_menu', array( $this, 'status_menu' ), 60 ); + + if ( apply_filters( 'sportspress_show_addons_page', false ) ) // Make true to display by default + add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 ); + add_action( 'admin_head', array( $this, 'menu_highlight' ) ); add_filter( 'menu_order', array( $this, 'menu_order' ) ); add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) ); @@ -39,6 +44,21 @@ class SP_Admin_Menus { $main_page = add_menu_page( __( 'SportsPress Settings', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), null, '51.5' ); } + /** + * Add menu item + */ + public function status_menu() { + add_submenu_page( 'sportspress', __( 'SportsPress Status', 'sportspress' ), __( 'System Status', 'sportspress' ) , 'manage_sportspress', 'sp-status', array( $this, 'status_page' ) ); + register_setting( 'sportspress_status_settings_fields', 'sportspress_status_options' ); + } + + /** + * Addons menu item + */ + public function addons_menu() { + add_submenu_page( 'sportspress', __( 'SportsPress Add-ons/Extensions', 'sportspress' ), __( 'Add-ons', 'sportspress' ) , 'manage_sportspress', 'sp-addons', array( $this, 'addons_page' ) ); + } + /** * Highlights the correct top level admin menu item for post type add screens. * @@ -117,6 +137,22 @@ class SP_Admin_Menus { return true; } + /** + * Init the status page + */ + public function status_page() { + $page = include( 'class-sp-admin-status.php' ); + $page->output(); + } + + /** + * Init the addons page + */ + public function addons_page() { + $page = include( 'class-sp-admin-addons.php' ); + $page->output(); + } + /** * Clean the SP menu items in admin. */ diff --git a/includes/admin/class-sp-admin-status.php b/includes/admin/class-sp-admin-status.php new file mode 100644 index 00000000..658b6069 --- /dev/null +++ b/includes/admin/class-sp-admin-status.php @@ -0,0 +1,86 @@ + 'Header Name') + */ + public function get_file_version( $file ) { + // We don't need to write to the file, so just open for reading. + $fp = fopen( $file, 'r' ); + + // Pull only the first 8kiB of the file in. + $file_data = fread( $fp, 8192 ); + + // PHP will close file handle, but we are good citizens. + fclose( $fp ); + + // Make sure we catch CR-only line endings. + $file_data = str_replace( "\r", "\n", $file_data ); + $version = ''; + + if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) + $version = _cleanup_header_comment( $match[1] ); + + return $version ; + } + + /** + * Scan the template files + * + * @access public + * @param string $template_path + * @return array + */ + public function scan_template_files( $template_path ) { + $files = scandir( $template_path ); + $result = array(); + if ( $files ) { + foreach ( $files as $key => $value ) { + if ( ! in_array( $value, array( ".",".." ) ) ) { + if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { + $sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); + foreach ( $sub_files as $sub_file ) { + $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; + } + } else { + $result[] = $value; + } + } + } + } + return $result; + } +} + +endif; + +return new SP_Admin_Status(); diff --git a/includes/admin/sp-admin-functions.php b/includes/admin/sp-admin-functions.php index dcc607a4..b33a2377 100644 --- a/includes/admin/sp-admin-functions.php +++ b/includes/admin/sp-admin-functions.php @@ -19,6 +19,7 @@ function sp_get_screen_ids() { return apply_filters( 'sportspress_screen_ids', array( 'dashboard_page_sp-about', 'toplevel_page_sportspress', + 'sportspress_page_sp-status', 'edit-sp_result', 'sp_result', 'edit-sp_outcome', diff --git a/includes/admin/views/html-admin-page-addons.php b/includes/admin/views/html-admin-page-addons.php new file mode 100644 index 00000000..8653939c --- /dev/null +++ b/includes/admin/views/html-admin-page-addons.php @@ -0,0 +1,35 @@ +
SportsPress Extensions Catalog', 'sportspress' ), 'http://themeboy.com/sportspress/extensions/' ); ?>
+ + +| + | |||
|---|---|---|---|
| : | ++ | ||
| : | ++ | ||
| : | +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_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_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_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 . ') [' . $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_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 ) ); + ?> | +||
| + | |||
| : | +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 ) ); + ?> | +||
| + | |||
| : | +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 ); ?> | + +: | ++ + |