Admin notice to configure sport
This commit is contained in:
30
assets/css/activation.css
Normal file
30
assets/css/activation.css
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/* Messages */
|
||||||
|
.sportspress-message {
|
||||||
|
border-left-color: #6bc2a5 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sportspress-message a.button-primary,
|
||||||
|
.sportspress-message a.button-secondary {
|
||||||
|
background: #6bc2a5;
|
||||||
|
border-color: #409e7f;
|
||||||
|
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sportspress-message a.button-primary:hover,
|
||||||
|
.sportspress-message a.button-secondary:hover {
|
||||||
|
background: #3bad87;
|
||||||
|
border-color: #338a6d;
|
||||||
|
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sportspress-message a.button-secondary {
|
||||||
|
-moz-opacity: 0.7;
|
||||||
|
opacity: 0.7;
|
||||||
|
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||||
|
}
|
||||||
@@ -122,37 +122,6 @@
|
|||||||
margin: 15px 0 0 -7px;
|
margin: 15px 0 0 -7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Messages */
|
|
||||||
.sportspress-message {
|
|
||||||
border-left-color: #6bc2a5 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sportspress-message a.button-primary,
|
|
||||||
.sportspress-message a.button-secondary {
|
|
||||||
background: #6bc2a5;
|
|
||||||
border-color: #409e7f;
|
|
||||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
|
||||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
|
||||||
color: #fff;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sportspress-message a.button-primary:hover,
|
|
||||||
.sportspress-message a.button-secondary:hover {
|
|
||||||
background: #3bad87;
|
|
||||||
border-color: #338a6d;
|
|
||||||
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
|
||||||
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
|
|
||||||
color: #fff;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sportspress-message a.button-secondary {
|
|
||||||
-moz-opacity: 0.7;
|
|
||||||
opacity: 0.7;
|
|
||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
|
||||||
}
|
|
||||||
|
|
||||||
.wp-media-buttons .button.sp-insert {
|
.wp-media-buttons .button.sp-insert {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
138
includes/admin/class-sp-admin-notices.php
Normal file
138
includes/admin/class-sp-admin-notices.php
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Display notices in admin.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Admin
|
||||||
|
* @package SportsPress/Admin
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SP_Admin_Notices' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SP_Admin_Notices Class
|
||||||
|
*/
|
||||||
|
class SP_Admin_Notices {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook in tabs.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'switch_theme', array( $this, 'reset_admin_notices' ) );
|
||||||
|
add_action( 'sportspress_updated', array( $this, 'reset_admin_notices' ) );
|
||||||
|
add_action( 'admin_print_styles', array( $this, 'add_notices' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset notices for themes when switched or a new version of SP is installed
|
||||||
|
*/
|
||||||
|
public function reset_admin_notices() {
|
||||||
|
update_option( 'sportspress_admin_notices', array( 'template_files', 'theme_support' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add notices + styles if needed.
|
||||||
|
*/
|
||||||
|
public function add_notices() {
|
||||||
|
if ( get_option( '_sp_needs_config' ) == 1 ) {
|
||||||
|
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||||
|
add_action( 'admin_notices', array( $this, 'install_notice' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$notices = get_option( 'sportspress_admin_notices', array() );
|
||||||
|
|
||||||
|
if ( isset( $_GET['skip_install_sportspress'] ) ):
|
||||||
|
update_option( '_sp_needs_config', $_GET['_sp_needs_config'] ? 0 : 1 );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
|
||||||
|
$notices = array_diff( $notices, array( 'theme_support' ) );
|
||||||
|
update_option( 'sportspress_admin_notices', $notices );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $_GET['hide_template_files_notice'] ) ) {
|
||||||
|
$notices = array_diff( $notices, array( 'template_files' ) );
|
||||||
|
update_option( 'sportspress_admin_notices', $notices );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( in_array( 'theme_support', $notices ) && ! current_theme_supports( 'sportspress' ) ) {
|
||||||
|
$template = get_option( 'template' );
|
||||||
|
|
||||||
|
if ( ! in_array( $template, array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
|
||||||
|
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||||
|
add_action( 'admin_notices', array( $this, 'theme_check_notice' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( in_array( 'template_files', $notices ) ) {
|
||||||
|
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||||
|
// add_action( 'admin_notices', array( $this, 'template_file_check_notice' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the install notices
|
||||||
|
*/
|
||||||
|
public function install_notice() {
|
||||||
|
$screen = get_current_screen();
|
||||||
|
|
||||||
|
// If we have just installed, show a message with the install pages button
|
||||||
|
if ( get_option( '_sp_needs_config' ) == 1 && $screen->id != 'settings_page_sportspress' ) {
|
||||||
|
include( 'views/html-notice-install.php' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the Theme Check notice
|
||||||
|
*/
|
||||||
|
public function theme_check_notice() {
|
||||||
|
// include( 'views/html-notice-theme-support.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a notice highlighting bad template files
|
||||||
|
*/
|
||||||
|
public function template_file_check_notice() {
|
||||||
|
if ( isset( $_GET['page'] ) && 'sp-status' == $_GET['page'] ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = include( 'class-sp-admin-status.php' );
|
||||||
|
$core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
|
||||||
|
$outdated = false;
|
||||||
|
|
||||||
|
foreach ( $core_templates as $file ) {
|
||||||
|
$theme_file = false;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
|
||||||
|
$outdated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $outdated ) {
|
||||||
|
include( 'views/html-notice-template-check.php' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return new SP_Admin_Notices();
|
||||||
@@ -39,7 +39,7 @@ class SP_Admin {
|
|||||||
if ( ! is_ajax() ) {
|
if ( ! is_ajax() ) {
|
||||||
include( 'class-sp-admin-menus.php' );
|
include( 'class-sp-admin-menus.php' );
|
||||||
// include( 'class-sp-admin-welcome.php' );
|
// include( 'class-sp-admin-welcome.php' );
|
||||||
// include( 'class-sp-admin-notices.php' );
|
include( 'class-sp-admin-notices.php' );
|
||||||
include( 'class-sp-admin-assets.php' );
|
include( 'class-sp-admin-assets.php' );
|
||||||
include( 'class-sp-admin-permalink-settings.php' );
|
include( 'class-sp-admin-permalink-settings.php' );
|
||||||
// include( 'class-sp-admin-editor.php' );
|
// include( 'class-sp-admin-editor.php' );
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
$sport_options[ $slug ] = $data['name'];
|
$sport_options[ $slug ] = $data['name'];
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
if ( ! get_option( 'sportspress_sport' ) )
|
||||||
|
$sport_options = array_merge( array( 0 => __( '— Select —', 'sportspress' ) ), $sport_options );
|
||||||
|
|
||||||
return apply_filters('sportspress_event_settings', array(
|
return apply_filters('sportspress_event_settings', array(
|
||||||
|
|
||||||
array( 'title' => __( 'Configure SportsPress', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'config_options' ),
|
array( 'title' => __( 'Configure SportsPress', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'config_options' ),
|
||||||
@@ -163,6 +166,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
endforeach;
|
endforeach;
|
||||||
endforeach;
|
endforeach;
|
||||||
update_option( 'sportspress_primary_result', 0 );
|
update_option( 'sportspress_primary_result', 0 );
|
||||||
|
update_option( '_sp_needs_config', 0 );
|
||||||
elseif ( isset( $_POST['sportspress_primary_result'] ) ):
|
elseif ( isset( $_POST['sportspress_primary_result'] ) ):
|
||||||
update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] );
|
update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] );
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
array( 'type' => 'frontend_styles' ),
|
array( 'type' => 'frontend_styles' ),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Custom CSS', 'woocommerce' ),
|
'title' => __( 'Custom CSS', 'sportspress' ),
|
||||||
'id' => 'sportspress_custom_css',
|
'id' => 'sportspress_custom_css',
|
||||||
'css' => 'width:100%; height: 130px;',
|
'css' => 'width:100%; height: 130px;',
|
||||||
'type' => 'textarea',
|
'type' => 'textarea',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||||||
<div id="message" class="updated sportspress-message">
|
<div id="message" class="updated sportspress-message">
|
||||||
<p><?php _e( '<strong>Welcome to SportsPress</strong> – Get Started', 'sportspress' ); ?></p>
|
<p><?php _e( '<strong>Welcome to SportsPress</strong> – Get Started', 'sportspress' ); ?></p>
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<a class="button-primary" href="<?php echo admin_url('options-general.php?page=sportspress'); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
|
<a class="button-primary" href="<?php echo admin_url('options-general.php?page=sportspress&tab=config'); ?>"><?php _e( 'Configure SportsPress', 'sportspress' ); ?></a>
|
||||||
<a class="button-secondary" href="<?php echo add_query_arg('sportspress_installed', '1' ); ?>"><?php _e( 'Skip setup', 'sportspress' ); ?></a>
|
<a class="button-secondary" href="<?php echo add_query_arg('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Skip setup', 'sportspress' ); ?></a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -99,6 +99,11 @@ class SP_Install {
|
|||||||
// Update version
|
// Update version
|
||||||
update_option( 'sportspress_version', SP()->version );
|
update_option( 'sportspress_version', SP()->version );
|
||||||
|
|
||||||
|
// Check if pages are needed
|
||||||
|
if ( ! get_option( 'sportspress_sport' ) ) {
|
||||||
|
update_option( '_sp_needs_config', 1 );
|
||||||
|
}
|
||||||
|
|
||||||
// Flush rules after install
|
// Flush rules after install
|
||||||
flush_rewrite_rules();
|
flush_rewrite_rules();
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ function sportspress_admin_notices_styles() {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
if ( $screen->id != 'settings_page_sportspress' ):
|
if ( $screen->id != 'settings_page_sportspress' ):
|
||||||
if ( isset( $_REQUEST['sportspress_installed'] ) ):
|
if ( isset( $_REQUEST['skip_install_sportspress'] ) ):
|
||||||
update_option( 'sportspress_installed', $_REQUEST['sportspress_installed'] );
|
update_option( '_sp_needs_config', $_REQUEST['_sp_needs_config'] );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( ! get_option( 'sportspress_installed' ) ):
|
if ( ! get_option( 'sportspress_installed' ) ):
|
||||||
@@ -70,7 +70,7 @@ function sportspress_admin_notices_styles() {
|
|||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
//add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sportspress_admin_install_notices function.
|
* sportspress_admin_install_notices function.
|
||||||
@@ -79,7 +79,7 @@ add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function sportspress_admin_install_notices() {
|
function sportspress_admin_install_notices() {
|
||||||
// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' );
|
include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,8 +290,7 @@ add_filter( 'the_content', 'sportspress_default_table_content' );
|
|||||||
|
|
||||||
function sportspress_default_player_content( $content ) {
|
function sportspress_default_player_content( $content ) {
|
||||||
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
||||||
sp_get_template( 'player-metrics.php' );
|
sp_get_template( 'player.php' );
|
||||||
sp_get_template( 'player-performance.php' );
|
|
||||||
endif;
|
endif;
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|||||||
6
templates/player.php
Normal file
6
templates/player.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
if ( ! isset( $id ) )
|
||||||
|
$id = get_the_ID();
|
||||||
|
|
||||||
|
sp_get_template( 'player-metrics.php', array( 'id' => $id ) );
|
||||||
|
sp_get_template( 'player-performance.php', array( 'id' => $id ) );
|
||||||
Reference in New Issue
Block a user