Add admin notices

This commit is contained in:
Brian Miyaji
2014-01-13 13:51:41 +11:00
parent baea137df4
commit 559b5aaecd
5 changed files with 78 additions and 2 deletions

View 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' );
}

View File

@@ -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;
}

View 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>

View 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> &#8211; 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>

View File

@@ -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