Add activation welcome and notices close #21
This commit is contained in:
@@ -37,17 +37,13 @@ class SP_Admin_Notices {
|
||||
* Add notices + styles if needed.
|
||||
*/
|
||||
public function add_notices() {
|
||||
if ( get_option( '_sp_needs_config' ) == 1 ) {
|
||||
if ( get_option( '_sp_needs_welcome' ) == 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 );
|
||||
@@ -80,7 +76,7 @@ class SP_Admin_Notices {
|
||||
$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' ) {
|
||||
if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'settings_page_sportspress' ) {
|
||||
include( 'views/html-notice-install.php' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,6 +597,95 @@ class SP_Admin_Settings {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure sport
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function configure_sport( $sport ) {
|
||||
// Get array of taxonomies to insert
|
||||
$term_groups = sp_array_value( $sport, 'term', array() );
|
||||
|
||||
foreach( $term_groups as $taxonomy => $terms ):
|
||||
// Find empty terms and destroy
|
||||
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
|
||||
|
||||
foreach( $allterms as $term ):
|
||||
if ( $term->count == 0 )
|
||||
wp_delete_term( $term->term_id, $taxonomy );
|
||||
endforeach;
|
||||
|
||||
// Insert terms
|
||||
foreach( $terms as $term ):
|
||||
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
// Get array of post types to insert
|
||||
$post_groups = sp_array_value( $sport, 'posts', array() );
|
||||
|
||||
// Loop through each post type
|
||||
foreach( $post_groups as $post_type => $posts ):
|
||||
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_preset',
|
||||
'value' => 1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Delete posts
|
||||
$old_posts = get_posts( $args );
|
||||
|
||||
foreach( $old_posts as $post ):
|
||||
wp_delete_post( $post->ID, true);
|
||||
endforeach;
|
||||
|
||||
// Add posts
|
||||
foreach( $posts as $index => $post ):
|
||||
|
||||
// Make sure post doesn't overlap
|
||||
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
||||
|
||||
// Translate post title
|
||||
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
||||
|
||||
// Set post type
|
||||
$post['post_type'] = $post_type;
|
||||
|
||||
// Increment menu order by 2 and publish post
|
||||
$post['menu_order'] = $index * 2 + 2;
|
||||
$post['post_status'] = 'publish';
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Flag as preset
|
||||
update_post_meta( $id, '_sp_preset', 1 );
|
||||
|
||||
// Update meta
|
||||
if ( array_key_exists( 'meta', $post ) ):
|
||||
foreach ( $post['meta'] as $key => $value ):
|
||||
update_post_meta( $id, $key, $value );
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
// Update terms
|
||||
if ( array_key_exists( 'tax_input', $post ) ):
|
||||
foreach ( $post['tax_input'] as $taxonomy => $terms ):
|
||||
wp_set_object_terms( $id, $terms, $taxonomy, false );
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;
|
||||
update_option( 'sportspress_primary_result', 0 );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
303
includes/admin/class-sp-admin-welcome.php
Normal file
303
includes/admin/class-sp-admin-welcome.php
Normal file
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
/**
|
||||
* Welcome Page Class
|
||||
*
|
||||
* Shows a feature overview for the new version (major) and credits.
|
||||
*
|
||||
* Adapted from code in EDD (Copyright (c) 2012, Pippin Williamson) and WP.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* SP_Admin_Welcome class.
|
||||
*/
|
||||
class SP_Admin_Welcome {
|
||||
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->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() {
|
||||
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
|
||||
|
||||
// About
|
||||
$about = add_dashboard_page( $welcome_page_title, $welcome_page_title, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
|
||||
|
||||
add_action( 'admin_print_styles-'. $about, array( $this, 'admin_css' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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-translators' );
|
||||
|
||||
// Badge for welcome page
|
||||
$badge_url = SP()->plugin_url() . '/assets/images/welcome/sp-badge.png';
|
||||
?>
|
||||
<style type="text/css">
|
||||
/*<![CDATA[*/
|
||||
.sp-badge {
|
||||
position: relative;;
|
||||
background: #2f4265 url(<?php echo $badge_url; ?>) no-repeat center top;
|
||||
text-rendering: optimizeLegibility;
|
||||
padding-top: 160px;
|
||||
height: 42px;
|
||||
width: 165px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
color: #e6e7e8;
|
||||
margin: 5px 0 0 0;
|
||||
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,.2);
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,.2);
|
||||
}
|
||||
.about-wrap .sp-badge {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
.about-wrap .sp-feature {
|
||||
overflow: visible !important;
|
||||
*zoom:1;
|
||||
}
|
||||
.about-wrap .sp-feature:before,
|
||||
.about-wrap .sp-feature:after {
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
.about-wrap .sp-feature:after {
|
||||
clear: both;
|
||||
}
|
||||
.about-wrap .feature-rest div {
|
||||
width: 50% !important;
|
||||
padding-right: 100px;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.about-wrap .feature-rest div.last-feature {
|
||||
padding-left: 100px;
|
||||
padding-right: 0;
|
||||
}
|
||||
.about-integrations {
|
||||
background: #fff;
|
||||
margin: 20px 0;
|
||||
padding: 1px 20px 10px;
|
||||
}
|
||||
/*]]>*/
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
?>
|
||||
<h1><?php printf( __( 'Welcome to SportsPress!', 'sportspress' ), $major_version ); ?></h1>
|
||||
|
||||
<div class="about-text sportspress-about-text">
|
||||
<?php
|
||||
if ( ! empty( $_GET['sp-installed'] ) )
|
||||
$message = __( 'Thanks, all done!', 'sportspress' );
|
||||
elseif ( ! empty( $_GET['sp-updated'] ) )
|
||||
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
|
||||
else
|
||||
$message = __( 'Thanks for installing!', 'sportspress' );
|
||||
|
||||
printf( __( '%s SportsPress %s is more powerful, stable, and secure than ever before. We hope you enjoy it.', 'sportspress' ), $message, $major_version );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
|
||||
|
||||
<p class="sportspress-actions">
|
||||
<?php if ( false ): ?><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ); ?>" class="button button-primary"><?php _e( 'Settings', 'sportspress' ); ?></a><?php endif; ?>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://ow.ly/vaGUv" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites." data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||
</p>
|
||||
|
||||
<?php if ( false ): ?>
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<a class="nav-tab <?php if ( $_GET['page'] == 'sp-about' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-about' ), 'index.php' ) ) ); ?>">
|
||||
<?php _e( 'Get Started', 'sportspress' ); ?>
|
||||
</a><a class="nav-tab <?php if ( $_GET['page'] == 'sp-translators' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-translators' ), 'index.php' ) ) ); ?>">
|
||||
<?php _e( 'Translators', 'sportspress' ); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the about screen.
|
||||
*/
|
||||
public function about_screen() {
|
||||
include_once( 'class-sp-admin-settings.php' );
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
|
||||
<?php $this->intro(); ?>
|
||||
|
||||
<!--<div class="changelog point-releases"></div>-->
|
||||
|
||||
<div class="changelog">
|
||||
<h3><?php _e( 'Get Started', 'sportspress' ); ?></h3>
|
||||
|
||||
<?php
|
||||
// Save settings
|
||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||
$sport = SP()->sports->$_POST['sportspress_sport'];
|
||||
SP_Admin_Settings::configure_sport( $sport );
|
||||
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
|
||||
endif;
|
||||
if ( isset( $_POST['sportspress_default_country'] ) ):
|
||||
update_option( 'sportspress_default_country', $_POST['sportspress_default_country'] );
|
||||
update_option( '_sportspress_needs_welcome', 1 );
|
||||
?>
|
||||
<div id="message" class="updated sportspress-message">
|
||||
<p><strong><?php _e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="sp-feature feature-section col three-col">
|
||||
<div>
|
||||
<form method="post" id="mainform" action="" enctype="multipart/form-data">
|
||||
<h4><?php _e( 'Base Location', 'sportspress' ); ?></h4>
|
||||
<?php
|
||||
$selected = (string) get_option( 'sportspress_default_country', 'AU' );
|
||||
$continents = SP()->countries->continents;
|
||||
?>
|
||||
<p>
|
||||
<select name="sportspress_default_country" data-placeholder="<?php _e( 'Choose a country…', 'sportspress' ); ?>" title="Country" class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>">
|
||||
<?php SP()->countries->country_dropdown_options( $selected ); ?>
|
||||
</select>
|
||||
</p>
|
||||
<h4><?php printf( __( 'Select %s', 'sportspress' ), __( 'Sport', 'sportspress' ) ); ?></h4>
|
||||
<?php
|
||||
$sport_options = sp_get_sport_options();
|
||||
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||
$settings = array( array(
|
||||
'id' => 'sportspress_sport',
|
||||
'default' => 'soccer',
|
||||
'type' => 'select',
|
||||
'class' => $class,
|
||||
'options' => $sport_options,
|
||||
));
|
||||
SP_Admin_Settings::output_fields( $settings );
|
||||
?>
|
||||
<p class="submit sportspress-actions">
|
||||
<input name="save" class="button-primary" type="submit" value="<?php _e( 'Save changes', 'sportspress' ); ?>" />
|
||||
<input type="hidden" name="subtab" id="last_tab" />
|
||||
<?php wp_nonce_field( 'sportspress-settings' ); ?>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
|
||||
<ul class="sportspress-steps">
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-team"><?php _e( 'Add New Team', 'sportspress' ); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-player"><?php _e( 'Add New Player', 'sportspress' ); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-event"><?php _e( 'Add New Event', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="last-feature">
|
||||
<h4><?php _e( 'Translators', 'sportspress' ); ?></h4>
|
||||
<p><?php _e( 'SportsPress has been kindly translated into several other languages thanks to our translation team. Want to see your name? <a href="https://www.transifex.com/projects/p/sportspress/">Translate SportsPress</a>.', 'sportspress' ); ?></p>
|
||||
<?php
|
||||
$translator_handles = array( 'Abdulelah', 'aylaview', 'Bhelpful2', 'JensZ', 'karimjarro', 'Spirossmil', 'ThemeBoy' );
|
||||
$translator_links = array();
|
||||
foreach ( $translator_handles as $handle ):
|
||||
$translator_links[] = '<a href="https://www.transifex.com/accounts/profile/' . $handle . '">' . $handle . '</a>';
|
||||
endforeach;
|
||||
?>
|
||||
<p class="wp-credits-list">
|
||||
<?php echo implode( ', ', $translator_links ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="return-to-dashboard">
|
||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
@@ -38,7 +38,7 @@ class SP_Admin {
|
||||
// Classes we only need if the ajax is not-ajax
|
||||
if ( ! is_ajax() ) {
|
||||
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-assets.php' );
|
||||
include( 'class-sp-admin-permalink-settings.php' );
|
||||
|
||||
@@ -41,13 +41,6 @@ class SP_Settings_Config extends SP_Settings_Page {
|
||||
*/
|
||||
public function get_settings() {
|
||||
$sports = sp_get_sport_options();
|
||||
$sport_options = array();
|
||||
foreach ( $sports as $slug => $data ):
|
||||
$sport_options[ $slug ] = $data['name'];
|
||||
endforeach;
|
||||
|
||||
if ( ! get_option( 'sportspress_sport' ) )
|
||||
$sport_options = array_merge( array( 0 => __( '— Select —', 'sportspress' ) ), $sport_options );
|
||||
|
||||
return apply_filters('sportspress_event_settings', array(
|
||||
|
||||
@@ -58,7 +51,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
||||
'id' => 'sportspress_sport',
|
||||
'default' => 'soccer',
|
||||
'type' => 'select',
|
||||
'options' => $sport_options,
|
||||
'options' => $sports,
|
||||
),
|
||||
|
||||
array( 'type' => 'results' ),
|
||||
@@ -83,90 +76,9 @@ class SP_Settings_Config extends SP_Settings_Page {
|
||||
*/
|
||||
public function save() {
|
||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||
|
||||
$sport = SP()->sports->$_POST['sportspress_sport'];
|
||||
|
||||
// Get array of taxonomies to insert
|
||||
$term_groups = sp_array_value( $sport, 'term', array() );
|
||||
|
||||
foreach( $term_groups as $taxonomy => $terms ):
|
||||
// Find empty terms and destroy
|
||||
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
|
||||
|
||||
foreach( $allterms as $term ):
|
||||
if ( $term->count == 0 )
|
||||
wp_delete_term( $term->term_id, $taxonomy );
|
||||
endforeach;
|
||||
|
||||
// Insert terms
|
||||
foreach( $terms as $term ):
|
||||
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
// Get array of post types to insert
|
||||
$post_groups = sp_array_value( $sport, 'posts', array() );
|
||||
|
||||
// Loop through each post type
|
||||
foreach( $post_groups as $post_type => $posts ):
|
||||
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_preset',
|
||||
'value' => 1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Delete posts
|
||||
$old_posts = get_posts( $args );
|
||||
|
||||
foreach( $old_posts as $post ):
|
||||
wp_delete_post( $post->ID, true);
|
||||
endforeach;
|
||||
|
||||
// Add posts
|
||||
foreach( $posts as $index => $post ):
|
||||
|
||||
// Make sure post doesn't overlap
|
||||
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
||||
|
||||
// Translate post title
|
||||
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
||||
|
||||
// Set post type
|
||||
$post['post_type'] = $post_type;
|
||||
|
||||
// Increment menu order by 2 and publish post
|
||||
$post['menu_order'] = $index * 2 + 2;
|
||||
$post['post_status'] = 'publish';
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Flag as preset
|
||||
update_post_meta( $id, '_sp_preset', 1 );
|
||||
|
||||
// Update meta
|
||||
if ( array_key_exists( 'meta', $post ) ):
|
||||
foreach ( $post['meta'] as $key => $value ):
|
||||
update_post_meta( $id, $key, $value );
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
// Update terms
|
||||
if ( array_key_exists( 'tax_input', $post ) ):
|
||||
foreach ( $post['tax_input'] as $taxonomy => $terms ):
|
||||
wp_set_object_terms( $id, $terms, $taxonomy, false );
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;
|
||||
update_option( 'sportspress_primary_result', 0 );
|
||||
update_option( '_sp_needs_config', 0 );
|
||||
SP_Admin_Settings::configure_sport( $sport );
|
||||
update_option( '_sp_needs_welcome', 0 );
|
||||
elseif ( isset( $_POST['sportspress_primary_result'] ) ):
|
||||
update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] );
|
||||
endif;
|
||||
|
||||
@@ -40,18 +40,6 @@ class SP_Settings_Events extends SP_Settings_Page {
|
||||
$settings = array(
|
||||
|
||||
array( 'title' => __( 'Event Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'event_options' ),
|
||||
|
||||
array(
|
||||
'title' => __( 'Number of Teams', 'sportspress' ),
|
||||
'id' => 'sportspress_event_num_teams',
|
||||
'class' => 'small-text',
|
||||
'default' => '2',
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 0,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
|
||||
array( 'type' => 'delimiter' ),
|
||||
|
||||
|
||||
@@ -112,6 +112,13 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
* Save settings
|
||||
*/
|
||||
public function save() {
|
||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||
$sport = SP()->sports->$_POST['sportspress_sport'];
|
||||
SP_Admin_Settings::configure_sport( $sport );
|
||||
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
|
||||
update_option( '_sp_needs_welcome', 0 );
|
||||
endif;
|
||||
|
||||
$settings = $this->get_settings();
|
||||
SP_Admin_Settings::save_fields( $settings );
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
*/
|
||||
function sp_get_screen_ids() {
|
||||
return apply_filters( 'sportspress_screen_ids', array(
|
||||
'dashboard_page_sp-about',
|
||||
'settings_page_sportspress',
|
||||
'edit-sp_result',
|
||||
'sp_result',
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<div id="message" class="updated sportspress-message">
|
||||
<p><?php _e( '<strong>Welcome to SportsPress</strong> – Get Started', 'sportspress' ); ?></p>
|
||||
<p><strong><?php printf( __( 'Welcome to SportsPress %s', 'sportspress' ), SP()->version ); ?></strong></p>
|
||||
<p class="submit">
|
||||
<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('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Skip setup', 'sportspress' ); ?></a>
|
||||
<a class="button-primary" href="<?php echo admin_url( add_query_arg( array( 'page' => 'sp-about', 'install_sportspress' => 'true' ), 'index.php' ) ); ?>"><?php _e( "Get Started", 'sportspress' ); ?></a>
|
||||
<a class="button-secondary" href="<?php echo add_query_arg('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Hide this notice', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user