plugin = 'sportspress/sportspress.php';
add_action( 'admin_menu', array( $this, 'admin_menus') );
add_action( 'admin_head', array( $this, 'admin_head' ) );
add_action( 'admin_init', array( $this, 'welcome' ) );
}
/**
* Add admin menus/screens
*
* @access public
* @return void
*/
public function admin_menus() {
if ( empty( $_GET['page'] ) ) {
return;
}
$welcome_page_name = __( 'About SportsPress', 'sportspress' );
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
switch ( $_GET['page'] ) {
case 'sp-about' :
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
break;
case 'sp-credits' :
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
break;
case 'sp-translators' :
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
break;
}
}
/**
* admin_css function.
*
* @access public
* @return void
*/
public function admin_css() {
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
}
/**
* Add styles just for this page, and remove dashboard page links.
*
* @access public
* @return void
*/
public function admin_head() {
remove_submenu_page( 'index.php', 'sp-about' );
remove_submenu_page( 'index.php', 'sp-credits' );
remove_submenu_page( 'index.php', 'sp-translators' );
}
/**
* Into text/links shown on all about pages.
*
* @access private
* @return void
*/
private function intro() {
// Flush after upgrades
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
flush_rewrite_rules();
// Drop minor version if 0
$major_version = substr( SP()->version, 0, 3 );
?>
' ); ?>
version ); ?>
intro(); ?>
$name ):
if ( $sport === $slug ):
$sport = $name;
break;
endif;
endforeach;
endforeach;
echo $sport;
?>
array(
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'edit.php' ) ),
'icon' => 'dashicons-shield-alt',
'label' => __( 'Add New Team', 'sportspress' ),
),
'players' => array(
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'edit.php' ) ),
'icon' => 'dashicons-groups',
'label' => __( 'Add New Player', 'sportspress' ),
),
'events' => array(
'link' => admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ),
'icon' => 'dashicons-calendar',
'label' => __( 'Add New Event', 'sportspress' ),
),
) );
?>
intro(); ?>
Contribute to SportsPress.', 'sportspress' ), 'https://github.com/ThemeBoy/SportsPress/blob/master/CONTRIBUTING.md' ); ?>
contributors(); ?>
intro(); ?>
Translate SportsPress.', 'sportspress' ), 'https://www.transifex.com/projects/p/sportspress/' ); ?>
' . $handle . '';
endforeach;
?>
get_contributors();
if ( empty( $contributors ) ) {
return '';
}
$contributor_list = '';
return $contributor_list;
}
/**
* Retrieve list of contributors from GitHub.
*
* @access public
* @return mixed
*/
public function get_contributors() {
$contributors = get_transient( 'sportspress_contributors' );
if ( false !== $contributors ) {
return $contributors;
}
$response = wp_remote_get( 'https://api.github.com/repos/ThemeBoy/SportsPress/contributors', array( 'sslverify' => false ) );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return array();
}
$contributors = json_decode( wp_remote_retrieve_body( $response ) );
if ( ! is_array( $contributors ) ) {
return array();
}
set_transient( 'sportspress_contributors', $contributors, HOUR_IN_SECONDS );
return $contributors;
}
/**
* Sends user to the welcome page on first activation
*/
public function welcome() {
// Bail if no activation redirect transient is set
if ( ! get_transient( '_sp_activation_redirect' ) )
return;
// Delete the redirect transient
delete_transient( '_sp_activation_redirect' );
// Bail if we are waiting to install or update via the interface update/install links
if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 )
return;
// Bail if activating from network, or bulk, or within an iFrame
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
return;
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) )
return;
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
exit;
}
}
new SP_Admin_Welcome();