Add admin notices
This commit is contained in:
54
admin/hooks/admin-print-styles.php
Normal file
54
admin/hooks/admin-print-styles.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
function sportspress_admin_notices_styles() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( $screen->id != 'settings_page_sportspress' ):
|
||||
|
||||
if ( isset( $_GET['sportspress_installed'] ) ):
|
||||
update_option( 'sportspress_installed', $_GET['sportspress_installed'] );
|
||||
endif;
|
||||
|
||||
if ( ! get_option( 'sportspress_installed' ) ):
|
||||
add_action( 'admin_notices', 'sportspress_admin_install_notices' );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
$template = get_option( 'template' );
|
||||
|
||||
if ( ! current_theme_supports( 'sportspress' ) && ! in_array( $template, array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ):
|
||||
|
||||
if ( ! empty( $_GET['hide_sportspress_theme_support_check'] ) ):
|
||||
update_option( 'sportspress_theme_support_check', $template );
|
||||
return;
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_theme_support_check' ) !== $template ):
|
||||
add_action( 'admin_notices', 'sportspress_theme_check_notice' );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
}
|
||||
add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
||||
|
||||
/**
|
||||
* sportspress_admin_install_notices function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_admin_install_notices() {
|
||||
include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-install.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* sportspress_theme_check_notice function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_theme_check_notice() {
|
||||
include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' );
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
function sportspress_plugin_action_links( $links ) {
|
||||
$settings_link = '<a href="options-general.php?page=sportspress">' . __( 'Settings', 'sportspress' ) . '</a>';
|
||||
$themes_link = '<a href="http://themeboy.com/themes/?ref=sportspress" target="_blank">' . __( 'Themes', 'sportspress' ) . '</a>';
|
||||
$docs_link = '<a href="http://docs.themeboy.com/sportspress" target="_blank">' . __( 'Docs', 'sportspress' ) . '</a>';
|
||||
$themes_link = '<a href="http://themeboy.com/themes?plugin=sportspress" target="_blank">' . __( 'Themes', 'sportspress' ) . '</a>';
|
||||
|
||||
array_unshift( $links, $settings_link, $themes_link );
|
||||
array_unshift( $links, $settings_link, $docs_link, $themes_link );
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
10
admin/includes/notice-install.php
Normal file
10
admin/includes/notice-install.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated sportspress-message">
|
||||
<h3><?php _e( 'Welcome to SportsPress!', 'sportspress' ); ?></h3>
|
||||
<p class="submit">
|
||||
<a class="button button-primary button-hero" href="<?php echo admin_url('options-general.php?page=sportspress'); ?>"><?php _e( 'Settings', 'sportspress' ); ?></a>
|
||||
<a class="button button-secondary button-hero" href="<?php echo add_query_arg('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Skip setup', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
10
admin/includes/notice-theme-support.php
Normal file
10
admin/includes/notice-theme-support.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="error sportspress-message">
|
||||
<h4><?php _e( '<strong>Your theme does not declare SportsPress support</strong> – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?></h4>
|
||||
<p class="submit">
|
||||
<a class="button-primary" href="http://docs.themeboy.com/sportspress/compatibility/"><?php _e( 'Theme Integration Guide', 'sportspress' ); ?></a>
|
||||
<a class="button-secondary" href="<?php echo add_query_arg( 'hide_sportspress_theme_support_check', 'true' ); ?>"><?php _e( 'Hide this notice', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -81,6 +81,7 @@ require_once dirname( __FILE__ ) . '/admin/hooks/wp-enqueue-scripts.php';
|
||||
// Admin request actions
|
||||
require_once dirname( __FILE__ ) . '/admin/hooks/admin-menu.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/hooks/admin-enqueue-scripts.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/hooks/admin-print-styles.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php';
|
||||
|
||||
// Administrative actions
|
||||
|
||||
Reference in New Issue
Block a user