Clean up spaces, tabs, indentation, and bracket formatting

This commit is contained in:
Brian Miyaji
2021-11-10 15:41:40 +09:00
parent e58beb1201
commit 3dff686a00
285 changed files with 29638 additions and 24147 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,360 +2,400 @@
/**
* SportsPress General Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_General' ) ) :
/**
* SP_Settings_General
*/
class SP_Settings_General extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_General
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'sportspress' );
class SP_Settings_General extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
add_action( 'sportspress_admin_field_colors', array( $this, 'colors_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Constructor
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'sportspress' );
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$presets = SP_Admin_Sports::get_preset_options();
$leagues = array( '' => __( '— Select —', 'sportspress' ) );
$terms = get_terms( array(
'taxonomy' => 'sp_league',
'hide_empty' => false,
) );
if ( $terms ) {
foreach ( $terms as $term ) {
$leagues[ $term->term_id ] = $term->name;
}
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
add_action( 'sportspress_admin_field_colors', array( $this, 'colors_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$seasons = array( '' => __( '— Select —', 'sportspress' ) );
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$terms = get_terms( array(
'taxonomy' => 'sp_season',
'hide_empty' => false,
) );
$presets = SP_Admin_Sports::get_preset_options();
if ( $terms ) {
foreach ( $terms as $term ) {
$seasons[ $term->term_id ] = $term->name;
$leagues = array( '' => __( '— Select —', 'sportspress' ) );
$terms = get_terms(
array(
'taxonomy' => 'sp_league',
'hide_empty' => false,
)
);
if ( $terms ) {
foreach ( $terms as $term ) {
$leagues[ $term->term_id ] = $term->name;
}
}
}
$settings = array_merge(
array(
array( 'title' => __( 'General Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
),
apply_filters( 'sportspress_general_options', array(
array( 'type' => 'timezone' ),
$seasons = array( '' => __( '— Select —', 'sportspress' ) );
$terms = get_terms(
array(
'title' => __( 'Sport', 'sportspress' ),
'id' => 'sportspress_sport',
'default' => 'none',
'type' => 'sport',
'options' => $presets,
),
'taxonomy' => 'sp_season',
'hide_empty' => false,
)
);
if ( $terms ) {
foreach ( $terms as $term ) {
$seasons[ $term->term_id ] = $term->name;
}
}
$settings = array_merge(
array(
'title' => __( 'Main League', 'sportspress' ),
'id' => 'sportspress_league',
'default' => null,
'type' => 'select',
'options' => $leagues,
),
array(
'title' => __( 'Current Season', 'sportspress' ),
'id' => 'sportspress_season',
'default' => null,
'type' => 'select',
'options' => $seasons,
),
)),
array(
array( 'type' => 'sectionend', 'id' => 'general_options' ),
array( 'title' => __( 'Styles and Scripts', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'script_styling_options' ),
)
);
$options = array(
array( 'type' => 'colors' ),
);
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ):
$options = array_merge( $options, array(
array(
'title' => __( 'Align', 'sportspress' ),
'id' => 'sportspress_table_text_align',
'default' => 'default',
'type' => 'radio',
'options' => array(
'default' => __( 'Default', 'sportspress' ),
'left' => __( 'Left', 'sportspress' ),
'center' => __( 'Center', 'sportspress' ),
'right' => __( 'Right', 'sportspress' ),
array(
'title' => __( 'General Options', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'general_options',
),
),
apply_filters(
'sportspress_general_options',
array(
array( 'type' => 'timezone' ),
array(
'title' => __( 'Sport', 'sportspress' ),
'id' => 'sportspress_sport',
'default' => 'none',
'type' => 'sport',
'options' => $presets,
),
array(
'title' => __( 'Main League', 'sportspress' ),
'id' => 'sportspress_league',
'default' => null,
'type' => 'select',
'options' => $leagues,
),
array(
'title' => __( 'Current Season', 'sportspress' ),
'id' => 'sportspress_season',
'default' => null,
'type' => 'select',
'options' => $seasons,
),
)
),
array(
'title' => __( 'Padding', 'sportspress' ),
'id' => 'sportspress_table_padding',
'class' => 'small-text',
'default' => null,
'placeholder' => __( 'Auto', 'sportspress' ),
'desc' => 'px',
'type' => 'number',
array(
'type' => 'sectionend',
'id' => 'general_options',
),
array(
'title' => __( 'Styles and Scripts', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'script_styling_options',
),
)
);
$options = array(
array( 'type' => 'colors' ),
);
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ) :
$options = array_merge(
$options,
array(
array(
'title' => __( 'Align', 'sportspress' ),
'id' => 'sportspress_table_text_align',
'default' => 'default',
'type' => 'radio',
'options' => array(
'default' => __( 'Default', 'sportspress' ),
'left' => __( 'Left', 'sportspress' ),
'center' => __( 'Center', 'sportspress' ),
'right' => __( 'Right', 'sportspress' ),
),
),
array(
'title' => __( 'Padding', 'sportspress' ),
'id' => 'sportspress_table_padding',
'class' => 'small-text',
'default' => null,
'placeholder' => __( 'Auto', 'sportspress' ),
'desc' => 'px',
'type' => 'number',
'custom_attributes' => array(
'step' => 1,
),
),
)
);
endif;
$options = array_merge(
$options,
array(
array(
'title' => __( 'Custom CSS', 'sportspress' ),
'id' => 'sportspress_custom_css',
'css' => 'width:100%; height: 130px;',
'type' => 'textarea',
),
),
apply_filters(
'sportspress_general_script_options',
array(
array(
'title' => __( 'Scripts', 'sportspress' ),
'desc' => __( 'Live countdowns', 'sportspress' ),
'id' => 'sportspress_enable_live_countdowns',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
),
array(
'desc' => __( 'Shortcode menu', 'sportspress' ),
'id' => 'sportspress_rich_editing',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ),
),
)
),
array(
array(
'title' => __( 'Tables', 'sportspress' ),
'desc' => __( 'Responsive', 'sportspress' ),
'id' => 'sportspress_enable_responsive_tables',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Scrollable', 'sportspress' ),
'id' => 'sportspress_enable_scrollable_tables',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Sortable', 'sportspress' ),
'id' => 'sportspress_enable_sortable_tables',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Widgets', 'sportspress' ),
'desc' => __( 'Unique', 'sportspress' ),
'id' => 'sportspress_widget_unique',
'default' => 'no',
'type' => 'checkbox',
'desc_tip' => __( 'Hide widget when same as content.', 'sportspress' ),
),
)
);
if ( apply_filters( 'sportspress_enable_header', false ) ) {
$options[] = array(
'title' => __( 'Header Offset', 'sportspress' ),
'id' => 'sportspress_header_offset',
'class' => 'small-text',
'default' => null,
'placeholder' => __( 'Auto', 'sportspress' ),
'desc' => 'px',
'type' => 'number',
'custom_attributes' => array(
'step' => 1
'step' => 1,
),
),
));
endif;
$options = array_merge( $options,
array(
array(
'title' => __( 'Custom CSS', 'sportspress' ),
'id' => 'sportspress_custom_css',
'css' => 'width:100%; height: 130px;',
'type' => 'textarea',
),
),
apply_filters( 'sportspress_general_script_options', array(
array(
'title' => __( 'Scripts', 'sportspress' ),
'desc' => __( 'Live countdowns', 'sportspress' ),
'id' => 'sportspress_enable_live_countdowns',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
),
array(
'desc' => __( 'Shortcode menu', 'sportspress' ),
'id' => 'sportspress_rich_editing',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ),
),
) ),
array(
array(
'title' => __( 'Tables', 'sportspress' ),
'desc' => __( 'Responsive', 'sportspress' ),
'id' => 'sportspress_enable_responsive_tables',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Scrollable', 'sportspress' ),
'id' => 'sportspress_enable_scrollable_tables',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Sortable', 'sportspress' ),
'id' => 'sportspress_enable_sortable_tables',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Widgets', 'sportspress' ),
'desc' => __( 'Unique', 'sportspress' ),
'id' => 'sportspress_widget_unique',
'default' => 'no',
'type' => 'checkbox',
'desc_tip' => __( 'Hide widget when same as content.', 'sportspress' ),
),
) );
if ( apply_filters( 'sportspress_enable_header', false ) ) {
$options[] = array(
'title' => __( 'Header Offset', 'sportspress' ),
'id' => 'sportspress_header_offset',
'class' => 'small-text',
'default' => null,
'placeholder' => __( 'Auto', 'sportspress' ),
'desc' => 'px',
'type' => 'number',
'custom_attributes' => array(
'step' => 1
),
);
}
$settings = array_merge( $settings, apply_filters( 'sportspress_script_styling_options', $options ), array(
array( 'type' => 'sectionend', 'id' => 'script_styling_options' ),
));
return apply_filters( 'sportspress_general_settings', $settings ); // End general settings
}
/**
* Save settings
*/
public function save() {
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) !== $_POST['sportspress_sport'] ):
$sport = sanitize_key( $_POST['sportspress_sport'] );
SP_Admin_Sports::apply_preset( $sport );
delete_option( '_sp_needs_welcome' );
update_option( 'sportspress_installed', 1 );
endif;
if ( isset( $_POST['add_sample_data'] ) ):
SP_Admin_Sample_Data::delete_posts();
SP_Admin_Sample_Data::insert_posts();
endif;
$settings = $this->get_settings();
SP_Admin_Settings::save_fields( $settings );
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
$_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', sanitize_text_field( $_POST['timezone_string'] ) );
$_POST['timezone_string'] = '';
}
if ( isset( $_POST['timezone_string'] ) )
update_option( 'timezone_string', sanitize_option( 'timezone_string', $_POST['timezone_string'] ) );
if ( isset( $_POST['gmt_offset'] ) )
update_option( 'gmt_offset', sanitize_option( 'gmt_offset', $_POST['gmt_offset'] ) );
if ( isset( $_POST['sportspress_frontend_css_primary'] ) ) {
// Save settings
$primary = ( ! empty( $_POST['sportspress_frontend_css_primary'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_primary'] ) : '';
$background = ( ! empty( $_POST['sportspress_frontend_css_background'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_background'] ) : '';
$text = ( ! empty( $_POST['sportspress_frontend_css_text'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_text'] ) : '';
$heading = ( ! empty( $_POST['sportspress_frontend_css_heading'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_heading'] ) : '';
$link = ( ! empty( $_POST['sportspress_frontend_css_link'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_link'] ) : '';
$customize = ( ! empty( $_POST['sportspress_frontend_css_customize'] ) ) ? 1 : '';
$colors = array(
'primary' => $primary,
'background' => $background,
'text' => $text,
'heading' => $heading,
'link' => $link,
'customize' => $customize,
);
// Merge with existing options if available
$options = get_option( 'themeboy' );
if ( is_array( $options ) ) {
$colors = array_merge( $options, $colors );
);
}
update_option( 'themeboy', $colors );
$settings = array_merge(
$settings,
apply_filters( 'sportspress_script_styling_options', $options ),
array(
array(
'type' => 'sectionend',
'id' => 'script_styling_options',
),
)
);
return apply_filters( 'sportspress_general_settings', $settings ); // End general settings
}
}
/**
* Timezone settings
*
* @access public
* @return void
*/
public function timezone_setting() {
$current_offset = get_option( 'gmt_offset' );
$tzstring = get_option( 'timezone_string' );
/**
* Save settings
*/
public function save() {
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) !== $_POST['sportspress_sport'] ) :
$sport = sanitize_key( $_POST['sportspress_sport'] );
SP_Admin_Sports::apply_preset( $sport );
delete_option( '_sp_needs_welcome' );
update_option( 'sportspress_installed', 1 );
endif;
$check_zone_info = true;
if ( isset( $_POST['add_sample_data'] ) ) :
SP_Admin_Sample_Data::delete_posts();
SP_Admin_Sample_Data::insert_posts();
endif;
// Remove old Etc mappings. Fallback to gmt_offset.
if ( false !== strpos( $tzstring,'Etc/GMT' ) )
$tzstring = '';
$settings = $this->get_settings();
SP_Admin_Settings::save_fields( $settings );
if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
$check_zone_info = false;
if ( 0 == $current_offset )
$tzstring = 'UTC+0';
elseif ($current_offset < 0)
$tzstring = 'UTC' . $current_offset;
else
$tzstring = 'UTC+' . $current_offset;
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
$_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', sanitize_text_field( $_POST['timezone_string'] ) );
$_POST['timezone_string'] = '';
}
if ( isset( $_POST['timezone_string'] ) ) {
update_option( 'timezone_string', sanitize_option( 'timezone_string', $_POST['timezone_string'] ) );
}
if ( isset( $_POST['gmt_offset'] ) ) {
update_option( 'gmt_offset', sanitize_option( 'gmt_offset', $_POST['gmt_offset'] ) );
}
if ( isset( $_POST['sportspress_frontend_css_primary'] ) ) {
// Save settings
$primary = ( ! empty( $_POST['sportspress_frontend_css_primary'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_primary'] ) : '';
$background = ( ! empty( $_POST['sportspress_frontend_css_background'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_background'] ) : '';
$text = ( ! empty( $_POST['sportspress_frontend_css_text'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_text'] ) : '';
$heading = ( ! empty( $_POST['sportspress_frontend_css_heading'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_heading'] ) : '';
$link = ( ! empty( $_POST['sportspress_frontend_css_link'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_link'] ) : '';
$customize = ( ! empty( $_POST['sportspress_frontend_css_customize'] ) ) ? 1 : '';
$colors = array(
'primary' => $primary,
'background' => $background,
'text' => $text,
'heading' => $heading,
'link' => $link,
'customize' => $customize,
);
// Merge with existing options if available
$options = get_option( 'themeboy' );
if ( is_array( $options ) ) {
$colors = array_merge( $options, $colors );
}
update_option( 'themeboy', $colors );
}
}
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
?>
/**
* Timezone settings
*
* @access public
* @return void
*/
public function timezone_setting() {
$current_offset = get_option( 'gmt_offset' );
$tzstring = get_option( 'timezone_string' );
$check_zone_info = true;
// Remove old Etc mappings. Fallback to gmt_offset.
if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
$tzstring = '';
}
if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
$check_zone_info = false;
if ( 0 == $current_offset ) {
$tzstring = 'UTC+0';
} elseif ( $current_offset < 0 ) {
$tzstring = 'UTC' . $current_offset;
} else {
$tzstring = 'UTC+' . $current_offset;
}
}
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="timezone_string"><?php _e( 'Timezone', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Choose a city in the same timezone as you.', 'sportspress' ); ?>"></i></label>
</th>
<td class="forminp">
<td class="forminp">
<legend class="screen-reader-text"><span><?php _e( 'Timezone', 'sportspress' ); ?></span></legend>
<select id="timezone_string" name="timezone_string" class="<?php echo $class; ?>">
<?php echo wp_timezone_choice($tzstring); ?>
<?php echo wp_timezone_choice( $tzstring ); ?>
</select>
</td>
</tr>
<?php
}
</td>
</tr>
<?php
}
/**
* Output the frontend styles settings.
*
* @access public
* @return void
*/
public function colors_setting() {
// Define color schemes each with 5 colors: Primary, Background, Text, Heading, Link
$color_schemes = apply_filters( 'sportspress_color_schemes', array(
'ThemeBoy' => array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ),
'Gold' => array( '333333', 'f7f7f7', '333333', 'd8bf94', '9f8958' ),
'Denim' => array( '0e2440', 'eae5e0', '0e2440', 'ffffff', '2b6291' ),
'Patriot' => array( '0d4785', 'ecedee', '333333', 'ffffff', 'c51d27' ),
'Metro' => array( '3a7895', '223344', 'ffffff', 'ffffff', 'ffa800' ),
'Stellar' => array( '313150', '050528', 'ffffff', 'ffffff', 'e00034' ),
'Carbon' => array( '353535', '191919', 'ededed', 'ffffff', 'f67f17' ),
'Avocado' => array( '00241e', '013832', 'ffffff', 'ffffff', 'efb11e' ),
) );
?><tr valign="top" class="themeboy">
/**
* Output the frontend styles settings.
*
* @access public
* @return void
*/
public function colors_setting() {
// Define color schemes each with 5 colors: Primary, Background, Text, Heading, Link
$color_schemes = apply_filters(
'sportspress_color_schemes',
array(
'ThemeBoy' => array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ),
'Gold' => array( '333333', 'f7f7f7', '333333', 'd8bf94', '9f8958' ),
'Denim' => array( '0e2440', 'eae5e0', '0e2440', 'ffffff', '2b6291' ),
'Patriot' => array( '0d4785', 'ecedee', '333333', 'ffffff', 'c51d27' ),
'Metro' => array( '3a7895', '223344', 'ffffff', 'ffffff', 'ffa800' ),
'Stellar' => array( '313150', '050528', 'ffffff', 'ffffff', 'e00034' ),
'Carbon' => array( '353535', '191919', 'ededed', 'ffffff', 'f67f17' ),
'Avocado' => array( '00241e', '013832', 'ffffff', 'ffffff', 'efb11e' ),
)
);
?>
<tr valign="top" class="themeboy">
<th scope="row" class="titledesc">
<?php _e( 'Color Scheme', 'sportspress' ); ?>
</th>
<td class="forminp">
<fieldset>
<?php foreach ( $color_schemes as $name => $colors ) { ?>
<div class="color-option sp-color-option">
<td class="forminp">
<fieldset>
<?php foreach ( $color_schemes as $name => $colors ) { ?>
<div class="color-option sp-color-option">
<label data-sp-colors="<?php echo implode( ',', $colors ); ?>"><?php echo esc_html( $name ); ?></label>
<table class="color-palette">
<tbody>
@@ -368,14 +408,16 @@ class SP_Settings_General extends SP_Settings_Page {
</table>
</div>
<?php } ?>
</fieldset>
<fieldset>
<div class="sp-custom-colors">
</fieldset>
<fieldset>
<div class="sp-custom-colors">
<label data-sp-colors="<?php echo implode( ',', $colors ); ?>"><?php _e( 'Customize', 'sportspress' ); ?></label><br>
<?php
<?php
// Get settings
$colors = array_map( 'esc_attr', (array) get_option( 'themeboy', array() ) );
if ( empty( $colors ) ) $colors = array_map( 'esc_attr', (array) get_option( 'sportspress_frontend_css_colors', array() ) );
if ( empty( $colors ) ) {
$colors = array_map( 'esc_attr', (array) get_option( 'sportspress_frontend_css_colors', array() ) );
}
// Fallback
if ( ! isset( $colors['customize'] ) ) {
@@ -383,47 +425,59 @@ class SP_Settings_General extends SP_Settings_Page {
}
// Defaults
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#2b353e';
if ( empty( $colors['background'] ) ) $colors['background'] = '#f4f4f4';
if ( empty( $colors['text'] ) ) $colors['text'] = '#222222';
if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff';
if ( empty( $colors['link'] ) ) $colors['link'] = '#00a69c';
if ( empty( $colors['primary'] ) ) {
$colors['primary'] = '#2b353e';
}
if ( empty( $colors['background'] ) ) {
$colors['background'] = '#f4f4f4';
}
if ( empty( $colors['text'] ) ) {
$colors['text'] = '#222222';
}
if ( empty( $colors['heading'] ) ) {
$colors['heading'] = '#ffffff';
}
if ( empty( $colors['link'] ) ) {
$colors['link'] = '#00a69c';
}
// Show inputs
$this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
$this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
$this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
$this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
$this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
$this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
$this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
$this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
$this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
$this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ):
?><br>
<label for="sportspress_frontend_css_customize">
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ) :
?>
<br>
<label for="sportspress_frontend_css_customize">
<input name="sportspress_frontend_css_customize" id="sportspress_frontend_css_customize" type="checkbox" value="1" <?php checked( $colors['customize'] ); ?>>
<?php _e( 'Enable', 'sportspress' ); ?>
</label>
<?php endif; ?>
</div>
</fieldset>
</fieldset>
</td>
</tr><?php
}
</tr>
<?php
}
/**
* Output a colour picker input box.
*
* @access public
* @param mixed $name
* @param mixed $id
* @param mixed $value
* @return void
*/
function color_picker( $name, $id, $value ) {
echo '<div class="sp-color-box"><strong>' . esc_html( $name ) . '</strong>
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
/**
* Output a colour picker input box.
*
* @access public
* @param mixed $name
* @param mixed $id
* @param mixed $value
* @return void
*/
function color_picker( $name, $id, $value ) {
echo '<div class="sp-color-box"><strong>' . esc_html( $name ) . '</strong>
<input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
</div>';
}
}
}
endif;

View File

@@ -2,63 +2,69 @@
/**
* SportsPress License Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Licenses' ) ) :
/**
* SP_Settings_Licenses
*/
class SP_Settings_Licenses extends SP_Settings_Page {
/**
* @var array
* SP_Settings_Licenses
*/
public $licenses = array();
class SP_Settings_Licenses extends SP_Settings_Page {
/**
* Constructor
*/
public function __construct() {
$this->id = 'licenses';
$this->label = __( 'Licenses', 'sportspress' );
/**
* @var array
*/
public $licenses = array();
$this->licenses = apply_filters( 'sportspress_licenses', array(
'pro' => array(
'name' => 'SportsPress Pro',
'url' => 'https://account.themeboy.com',
),
));
if ( sizeof ( $this->licenses ) <= 1 )
return;
/**
* Constructor
*/
public function __construct() {
$this->id = 'licenses';
$this->label = __( 'Licenses', 'sportspress' );
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$this->licenses = apply_filters(
'sportspress_licenses',
array(
'pro' => array(
'name' => 'SportsPress Pro',
'url' => 'https://account.themeboy.com',
),
)
);
/**
* Output licenses
*
* @access public
* @return void
*/
public function output() {
?>
<?php wp_nonce_field( 'sp_license_nonce', 'sp_license_nonce' ); ?>
if ( sizeof( $this->licenses ) <= 1 ) {
return;
}
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Output licenses
*
* @access public
* @return void
*/
public function output() {
?>
<?php wp_nonce_field( 'sp_license_nonce', 'sp_license_nonce' ); ?>
<div class="sp-modules-wrapper">
<div class="sp-modules-main">
<?php
foreach ( $this->licenses as $id => $license ) {
$key = get_site_option( 'sportspress_' . $id . '_license_key' );
$key = trim( $key );
$key = get_site_option( 'sportspress_' . $id . '_license_key' );
$key = trim( $key );
$status = get_site_option( 'sportspress_' . $id . '_license_status', false );
?>
<div class="sp-settings-section sp-settings-section-license_options">
@@ -94,121 +100,137 @@ class SP_Settings_Licenses extends SP_Settings_Page {
<?php } ?>
</div>
</div>
<?php
<?php
$GLOBALS['hide_save_button'] = true;
}
/**
* Save license
*/
public function save() {
// run a quick security check
if ( ! check_admin_referer( 'sp_license_nonce', 'sp_license_nonce' ) ) {
return;
$GLOBALS['hide_save_button'] = true;
}
foreach ( $_POST as $name => $value ) {
if ( 'sp_license_activate_' === substr( $name, 0, 20 ) ) {
$this->activate( substr( $name, 20 ) );
} elseif ( 'sp_license_deactivate_' === substr( $name, 0, 22 ) ) {
$this->deactivate( substr( $name, 22 ) );
/**
* Save license
*/
public function save() {
// run a quick security check
if ( ! check_admin_referer( 'sp_license_nonce', 'sp_license_nonce' ) ) {
return;
}
foreach ( $_POST as $name => $value ) {
if ( 'sp_license_activate_' === substr( $name, 0, 20 ) ) {
$this->activate( substr( $name, 20 ) );
} elseif ( 'sp_license_deactivate_' === substr( $name, 0, 22 ) ) {
$this->deactivate( substr( $name, 22 ) );
}
}
}
/**
* Activate license
*/
public function activate( $id ) {
// return if a license key isn't set
if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) ) {
return;
}
// retrieve the license key
$license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
// get the name of the product
$name = $this->licenses[ $id ]['name'];
// data to send in our API request
$api_params = array(
'edd_action' => 'activate_license',
'license' => $license,
'item_name' => urlencode( $name ), // the name of our product in EDD
'url' => home_url(),
);
// Call the custom API.
$response = wp_remote_post(
$this->licenses[ $id ]['url'],
array(
'timeout' => 15,
'sslverify' => false,
'body' => $api_params,
)
);
// Make sure the response came back okay
if ( is_wp_error( $response ) ) {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
return false;
}
// Decode the license data
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
// Update license status
update_site_option( 'sportspress_' . $id . '_license_status', $license_data->license );
// Update License or display error
if ( 'valid' == $license_data->license ) {
update_site_option( 'sportspress_' . $id . '_license_key', $license );
SP_Admin_Settings::add_override( __( 'License activated.', 'sportspress' ) );
} else {
SP_Admin_Settings::add_error( __( 'License invalid.', 'sportspress' ) );
}
}
/**
* Deactivate license
*/
public function deactivate( $id ) {
// return if a license key isn't set
if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) ) {
return;
}
// retrieve the license key
$license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
// get the name of the product
$name = $this->licenses[ $id ]['name'];
// data to send in our API request
$api_params = array(
'edd_action' => 'deactivate_license',
'license' => $license,
'item_name' => urlencode( $name ), // the name of our product in EDD
'url' => home_url(),
);
// Call the custom API.
$response = wp_remote_post(
$this->licenses[ $id ]['url'],
array(
'timeout' => 15,
'sslverify' => false,
'body' => $api_params,
)
);
// make sure the response came back okay
if ( is_wp_error( $response ) ) {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
return false;
}
// decode the license data
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
// $license_data->license will be either "deactivated" or "failed"
if ( $license_data->license == 'deactivated' ) {
delete_site_option( 'sportspress_' . $id . '_license_status' );
SP_Admin_Settings::add_override( __( 'License deactivated.', 'sportspress' ) );
} else {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
}
}
}
/**
* Activate license
*/
public function activate( $id ) {
// return if a license key isn't set
if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) )
return;
// retrieve the license key
$license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
// get the name of the product
$name = $this->licenses[ $id ]['name'];
// data to send in our API request
$api_params = array(
'edd_action'=> 'activate_license',
'license' => $license,
'item_name' => urlencode( $name ), // the name of our product in EDD
'url' => home_url()
);
// Call the custom API.
$response = wp_remote_post( $this->licenses[ $id ]['url'], array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
// Make sure the response came back okay
if ( is_wp_error( $response ) ) {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
return false;
}
// Decode the license data
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
// Update license status
update_site_option( 'sportspress_' . $id . '_license_status', $license_data->license );
// Update License or display error
if ( 'valid' == $license_data->license ) {
update_site_option( 'sportspress_' . $id . '_license_key', $license );
SP_Admin_Settings::add_override( __( 'License activated.', 'sportspress' ) );
} else {
SP_Admin_Settings::add_error( __( 'License invalid.', 'sportspress' ) );
}
}
/**
* Deactivate license
*/
public function deactivate( $id ) {
// return if a license key isn't set
if ( ! isset( $_POST[ 'sp_license_key_' . $id ] ) )
return;
// retrieve the license key
$license = trim( sanitize_text_field( $_POST[ 'sp_license_key_' . $id ] ) );
// get the name of the product
$name = $this->licenses[ $id ]['name'];
// data to send in our API request
$api_params = array(
'edd_action'=> 'deactivate_license',
'license' => $license,
'item_name' => urlencode( $name ), // the name of our product in EDD
'url' => home_url()
);
// Call the custom API.
$response = wp_remote_post( $this->licenses[ $id ]['url'], array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
// make sure the response came back okay
if ( is_wp_error( $response ) ) {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
return false;
}
// decode the license data
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
// $license_data->license will be either "deactivated" or "failed"
if ( $license_data->license == 'deactivated' ) {
delete_site_option( 'sportspress_' . $id . '_license_status' );
SP_Admin_Settings::add_override( __( 'License deactivated.', 'sportspress' ) );
} else {
SP_Admin_Settings::add_error( __( 'Sorry, there has been an error.', 'sportspress' ) );
}
}
}
endif;
return new SP_Settings_Licenses();

View File

@@ -2,55 +2,60 @@
/**
* SportsPress Module Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Modules' ) ) :
/**
* SP_Settings_Modules
*/
class SP_Settings_Modules extends SP_Settings_Page {
/**
* @var array
* SP_Settings_Modules
*/
public $sections = array();
class SP_Settings_Modules extends SP_Settings_Page {
/**
* Constructor
*/
public function __construct() {
$this->id = 'modules';
$this->label = __( 'Modules', 'sportspress' );
/**
* @var array
*/
public $sections = array();
$this->sections = apply_filters( 'sportspress_module_sections', array(
'general' => __( 'General', 'sportspress' ),
'event' => __( 'Events', 'sportspress' ),
'team' => __( 'Teams', 'sportspress' ),
'player_staff' => __( 'Players', 'sportspress' ) . ' &amp; ' . __( 'Staff', 'sportspress' ),
'admin' => __( 'Dashboard', 'sportspress' ),
'other' => __( 'Other', 'sportspress' ),
));
/**
* Constructor
*/
public function __construct() {
$this->id = 'modules';
$this->label = __( 'Modules', 'sportspress' );
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$this->sections = apply_filters(
'sportspress_module_sections',
array(
'general' => __( 'General', 'sportspress' ),
'event' => __( 'Events', 'sportspress' ),
'team' => __( 'Teams', 'sportspress' ),
'player_staff' => __( 'Players', 'sportspress' ) . ' &amp; ' . __( 'Staff', 'sportspress' ),
'admin' => __( 'Dashboard', 'sportspress' ),
'other' => __( 'Other', 'sportspress' ),
)
);
/**
* Output modules
*
* @access public
* @return void
*/
public function output() {
?>
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Output modules
*
* @access public
* @return void
*/
public function output() {
?>
<div class="sp-modules-wrapper">
<div class="sp-modules-sidebar">
<?php do_action( 'sportspress_modules_sidebar' ); ?>
@@ -64,7 +69,7 @@ class SP_Settings_Modules extends SP_Settings_Page {
</thead>
<tbody>
<tr><td>
<p><?php _e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.','sportspress' ); ?></p>
<p><?php _e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ); ?></p>
<p class="sp-module-actions">
<span><?php _e( 'Premium', 'sportspress' ); ?></span>
<a class="button button-primary" href="<?php echo apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ); ?>" target="_blank"><?php _e( 'Upgrade Now', 'sportspress' ); ?></a>
@@ -137,51 +142,51 @@ class SP_Settings_Modules extends SP_Settings_Page {
<?php
$categories = array(
'documentation' => array(
'icon' => 'sp-icon-book',
'icon' => 'sp-icon-book',
'label' => __( 'Documentation', 'sportspress' ),
'links' => array(
'http://tboy.co/installation' => __( 'Getting Started', 'sportspress' ),
'http://tboy.co/manuals' => __( 'Manuals', 'sportspress' ),
'http://tboy.co/videos' => __( 'Videos', 'sportspress' ),
'http://tboy.co/manuals' => __( 'Manuals', 'sportspress' ),
'http://tboy.co/videos' => __( 'Videos', 'sportspress' ),
),
),
'help' => array(
'icon' => 'dashicons dashicons-heart',
'help' => array(
'icon' => 'dashicons dashicons-heart',
'label' => __( 'Help', 'sportspress' ),
'links' => array(
'http://tboy.co/forums' => __( 'Support Forums', 'sportspress' ),
'http://tboy.co/ideas' => __( 'Feature Requests', 'sportspress' ),
'http://tboy.co/ideas' => __( 'Feature Requests', 'sportspress' ),
),
),
'social' => array(
'icon' => 'dashicons dashicons-share',
'social' => array(
'icon' => 'dashicons dashicons-share',
'label' => __( 'Connect', 'sportspress' ),
'links' => array(
'http://tboy.co/twitter' => __( 'Twitter', 'sportspress' ),
'http://tboy.co/twitter' => __( 'Twitter', 'sportspress' ),
'http://tboy.co/facebook' => __( 'Facebook', 'sportspress' ),
'http://tboy.co/youtube' => __( 'YouTube', 'sportspress' ),
'http://tboy.co/gplus' => __( 'Google+', 'sportspress' ),
'http://tboy.co/youtube' => __( 'YouTube', 'sportspress' ),
'http://tboy.co/gplus' => __( 'Google+', 'sportspress' ),
),
),
'developers' => array(
'icon' => 'dashicons dashicons-editor-code',
'developers' => array(
'icon' => 'dashicons dashicons-editor-code',
'label' => __( 'Developers', 'sportspress' ),
'links' => array(
'http://tboy.co/developers' => __( 'Reference', 'sportspress' ),
'http://tboy.co/slack' => __( 'Slack', 'sportspress' ),
'http://tboy.co/github' => __( 'GitHub', 'sportspress' ),
'http://tboy.co/slack' => __( 'Slack', 'sportspress' ),
'http://tboy.co/github' => __( 'GitHub', 'sportspress' ),
),
),
);
if ( class_exists( 'SportsPress_Pro' ) ) {
$categories['help']['links']['http://support.themeboy.com/'] = __( 'Premium Support', 'sportspress' );
} else {
$categories['help']['links'][ apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ] = '<span class="sp-desc-tip" title="' . __( 'Upgrade to Pro', 'sportspress' ) . '">' . __( 'Premium Support', 'sportspress' ) . '</span>';
}
$categories = apply_filters( 'sportspress_modules_welcome_links', $categories );
if ( sizeof( $categories ) ) {
?>
<table class="widefat" cellspacing="0">
@@ -192,7 +197,7 @@ class SP_Settings_Modules extends SP_Settings_Page {
</thead>
<tbody>
<tr><td>
<?php foreach ( $categories as $slug => $category ) { ?>
<?php foreach ( $categories as $slug => $category ) { ?>
<p><strong><i class="<?php echo esc_attr( $category['icon'] ); ?>"></i> <?php echo esc_html( $category['label'] ); ?></strong></p>
<ul class="sp-<?php echo esc_attr( $slug ); ?>-links">
<?php foreach ( $category['links'] as $url => $text ) { ?>
@@ -205,11 +210,11 @@ class SP_Settings_Modules extends SP_Settings_Page {
</table>
<?php } ?>
<?php do_action( 'sportspress_modules_after_sidebar' ); ?>
<?php do_action( 'sportspress_modules_after_sidebar' ); ?>
</div>
<div class="sp-modules-main">
<?php foreach ( SP()->modules->data as $section => $modules ) { ?>
<?php foreach ( SP()->modules->data as $section => $modules ) { ?>
<table class="sp-modules-table widefat" cellspacing="0">
<thead>
<tr><th>
@@ -252,38 +257,38 @@ class SP_Settings_Modules extends SP_Settings_Page {
<?php } ?>
<p class="submit">
<input name="save" class="button button-primary" type="submit" value="<?php _e( 'Save Changes', 'sportspress' ); ?>" />
<?php $GLOBALS['hide_save_button'] = true; ?>
</p>
<input name="save" class="button button-primary" type="submit" value="<?php _e( 'Save Changes', 'sportspress' ); ?>" />
<?php $GLOBALS['hide_save_button'] = true; ?>
</p>
</div>
</div>
<input type="hidden" name="sportspress_update_modules" value="1">
<?php if ( isset( $_POST[ 'sportspress_update_modules' ] ) ) { ?>
<?php if ( isset( $_POST['sportspress_update_modules'] ) ) { ?>
<script type="text/javascript">
window.onload = function() {
window.location = window.location.href;
}
</script>
<?php
}
flush_rewrite_rules();
}
/**
* Save settings
*/
public function save() {
foreach ( SP()->modules->data as $sections => $modules ) {
foreach ( $modules as $id => $module ) {
$name = 'sportspress_load_' . $id . '_module';
update_option( $name, isset( $_POST[ $name ] ) ? 'yes' : 'no' );
<?php
}
flush_rewrite_rules();
}
/**
* Save settings
*/
public function save() {
foreach ( SP()->modules->data as $sections => $modules ) {
foreach ( $modules as $id => $module ) {
$name = 'sportspress_load_' . $id . '_module';
update_option( $name, isset( $_POST[ $name ] ) ? 'yes' : 'no' );
}
}
flush_rewrite_rules();
}
flush_rewrite_rules();
}
}
endif;

View File

@@ -2,126 +2,135 @@
/**
* SportsPress Settings Page/Tab
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Page' ) ) :
/**
* SP_Settings_Page
*/
class SP_Settings_Page {
protected $id = '';
protected $label = '';
protected $template = '';
/**
* Add this page to settings
* SP_Settings_Page
*/
public function add_settings_page( $pages ) {
$pages[ $this->id ] = $this->label;
class SP_Settings_Page {
return $pages;
}
protected $id = '';
protected $label = '';
protected $template = '';
/**
* Add this page to settings
*/
public function add_settings_page( $pages ) {
$pages[ $this->id ] = $this->label;
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
return array();
}
return $pages;
}
/**
* Templates
*
* @return array
*/
public function templates() {
if ( ! isset( $this->template ) ) return array();
$template = $this->template;
return SP()->templates->$template;
}
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
return array();
}
/**
* Output the settings
*/
public function output() {
$settings = $this->get_settings();
/**
* Templates
*
* @return array
*/
public function templates() {
if ( ! isset( $this->template ) ) {
return array();
}
$template = $this->template;
return SP()->templates->$template;
}
SP_Admin_Settings::output_fields( $settings );
}
/**
* Output the settings
*/
public function output() {
$settings = $this->get_settings();
/**
* Save settings
*/
public function save() {
global $current_section;
SP_Admin_Settings::output_fields( $settings );
}
$settings = $this->get_settings();
SP_Admin_Settings::save_fields( $settings );
/**
* Save settings
*/
public function save() {
global $current_section;
if ( $current_section )
do_action( 'sportspress_update_options_' . $this->template . '_' . $current_section );
$settings = $this->get_settings();
SP_Admin_Settings::save_fields( $settings );
$templates = $this->templates();
if ( ! empty( $templates ) )
update_option( 'sportspress_' . $this->template . '_template_order', sp_array_value( $_POST, 'sportspress_' . $this->template . '_template_order', false, 'key' ) );
if ( $current_section ) {
do_action( 'sportspress_update_options_' . $this->template . '_' . $current_section );
}
if ( isset( $_POST['sportspress_template_visibility'] ) && is_array( $_POST['sportspress_template_visibility'] ) ) {
foreach ( $_POST['sportspress_template_visibility'] as $option => $toggled ) {
if ( $toggled ) {
update_option( $option, 'yes' );
} else {
update_option( $option, 'no' );
$templates = $this->templates();
if ( ! empty( $templates ) ) {
update_option( 'sportspress_' . $this->template . '_template_order', sp_array_value( $_POST, 'sportspress_' . $this->template . '_template_order', false, 'key' ) );
}
if ( isset( $_POST['sportspress_template_visibility'] ) && is_array( $_POST['sportspress_template_visibility'] ) ) {
foreach ( $_POST['sportspress_template_visibility'] as $option => $toggled ) {
if ( $toggled ) {
update_option( $option, 'yes' );
} else {
update_option( $option, 'no' );
}
}
}
}
}
/**
* Layout settings
*
* @access public
* @return void
*/
public function layout_setting() {
$templates = $this->templates();
$templates = apply_filters( 'sportspress_' . $this->template . '_templates', $templates );
$layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) {
$layout = array_keys( $templates );
}
$templates = array_merge( array_flip( (array) $layout ), $templates );
$slice = array_search( 'tabs', array_keys( $templates ) );
if ( $slice ) {
$templates = array_slice( $templates, 0, $slice );
}
?>
/**
* Layout settings
*
* @access public
* @return void
*/
public function layout_setting() {
$templates = $this->templates();
$templates = apply_filters( 'sportspress_' . $this->template . '_templates', $templates );
$layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) {
$layout = array_keys( $templates );
}
$templates = array_merge( array_flip( (array) $layout ), $templates );
$slice = array_search( 'tabs', array_keys( $templates ) );
if ( $slice ) {
$templates = array_slice( $templates, 0, $slice );
}
?>
<tr valign="top">
<th>
<?php _e( 'Layout', 'sportspress' ); ?>
</th>
<td class="sp-sortable-list-container">
<p class="description"><?php _e( 'Drag each item into the order you prefer.', 'sportspress' ); ?></p>
<td class="sp-sortable-list-container">
<p class="description"><?php _e( 'Drag each item into the order you prefer.', 'sportspress' ); ?></p>
<ul class="sp-layout sp-sortable-list sp-connected-list ui-sortable">
<?php foreach ( $templates as $template => $details ) {
if ( ! is_array( $details ) ) continue;
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
?>
<li>
<ul class="sp-layout sp-sortable-list sp-connected-list ui-sortable">
<?php
foreach ( $templates as $template => $details ) {
if ( ! is_array( $details ) ) {
continue;
}
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
?>
<li>
<div class="sp-item-bar sp-layout-item-bar">
<div class="sp-item-handle sp-layout-item-handle ui-sortable-handle">
<span class="sp-item-title item-title"><?php echo esc_html( sp_array_value( $details, 'title', ucfirst( $template ) ) ); ?></span>
@@ -134,51 +143,54 @@ class SP_Settings_Page {
</div>
</li>
<?php } ?>
</ul>
</ul>
</td>
</tr>
<?php
}
/**
* Tabs settings
*
* @access public
* @return void
*/
public function tabs_setting() {
$templates = $this->templates();
$templates = apply_filters( 'sportspress_' . $this->template . '_templates', $templates );
$layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) {
$layout = array_keys( $templates );
<?php
}
$templates = array_merge( array_flip( (array) $layout ), $templates );
$slice = array_search( 'tabs', array_keys( $templates ) );
if ( $slice ) {
$templates = array_slice( $templates, $slice );
} else {
$templates = array();
}
?>
/**
* Tabs settings
*
* @access public
* @return void
*/
public function tabs_setting() {
$templates = $this->templates();
$templates = apply_filters( 'sportspress_' . $this->template . '_templates', $templates );
$layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) {
$layout = array_keys( $templates );
}
$templates = array_merge( array_flip( (array) $layout ), $templates );
$slice = array_search( 'tabs', array_keys( $templates ) );
if ( $slice ) {
$templates = array_slice( $templates, $slice );
} else {
$templates = array();
}
?>
<tr valign="top">
<th>
<?php _e( 'Tabs', 'sportspress' ); ?>
</th>
<td class="sp-sortable-list-container">
<p class="description"><?php _e( 'Drag items here to display them as tabs.', 'sportspress' ); ?></p>
<td class="sp-sortable-list-container">
<p class="description"><?php _e( 'Drag items here to display them as tabs.', 'sportspress' ); ?></p>
<input type="hidden" name="sportspress_<?php echo esc_attr( $this->template ); ?>_template_order[]" value="tabs">
<ul class="sp-layout sp-sortable-list sp-connected-list ui-sortable">
<?php foreach ( $templates as $template => $details ) {
if ( ! is_array( $details ) ) continue;
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
?>
<li>
<ul class="sp-layout sp-sortable-list sp-connected-list ui-sortable">
<?php
foreach ( $templates as $template => $details ) {
if ( ! is_array( $details ) ) {
continue;
}
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
?>
<li>
<div class="sp-item-bar sp-layout-item-bar">
<div class="sp-item-handle sp-layout-item-handle ui-sortable-handle">
<span class="sp-item-title item-title"><?php echo esc_html( sp_array_value( $details, 'title', ucfirst( $template ) ) ); ?></span>
@@ -191,11 +203,11 @@ class SP_Settings_Page {
</div>
</li>
<?php } ?>
</ul>
</ul>
</td>
</tr>
<?php
<?php
}
}
}
endif;

View File

@@ -2,206 +2,223 @@
/**
* SportsPress Player Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6.8
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.6.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Players' ) ) :
/**
* SP_Settings_Players
*/
class SP_Settings_Players extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_Players
*/
public function __construct() {
$this->id = 'players';
$this->label = __( 'Players', 'sportspress' );
$this->template = 'player';
class SP_Settings_Players extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_player_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_player_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Constructor
*/
public function __construct() {
$this->id = 'players';
$this->label = __( 'Players', 'sportspress' );
$this->template = 'player';
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_player_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_player_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$settings = array_merge(
array(
array( 'title' => __( 'Player Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'player_options' ),
),
apply_filters( 'sportspress_player_options', array(
array( 'type' => 'player_layout' ),
array( 'type' => 'player_tabs' ),
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$settings = array_merge(
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link players', 'sportspress' ),
'id' => 'sportspress_link_players',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Details', 'sportspress' ),
'desc' => __( 'Squad Number', 'sportspress' ),
'id' => 'sportspress_player_show_number',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Name', 'sportspress' ),
'id' => 'sportspress_player_show_name',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Nationality', 'sportspress' ),
'id' => 'sportspress_player_show_nationality',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Position', 'sportspress' ),
'id' => 'sportspress_player_show_positions',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Current Team', 'sportspress' ),
'id' => 'sportspress_player_show_current_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Past Teams', 'sportspress' ),
'id' => 'sportspress_player_show_past_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Leagues', 'sportspress' ),
'id' => 'sportspress_player_show_leagues',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Seasons', 'sportspress' ),
'id' => 'sportspress_player_show_seasons',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_player_show_flags',
'default' => 'yes',
'type' => 'checkbox',
),
) ),
array(
array( 'type' => 'sectionend', 'id' => 'player_options' ),
),
array(
array( 'title' => __( 'Statistics', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'player_statistic_options' ),
array(
'title' => __( 'Columns', 'sportspress' ),
'id' => 'sportspress_player_columns',
'default' => 'auto',
'type' => 'radio',
'options' => array(
'auto' => __( 'Auto', 'sportspress' ),
'manual' => __( 'Manual', 'sportspress' ),
array(
'title' => __( 'Player Options', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'player_options',
),
),
apply_filters(
'sportspress_player_options',
array(
array( 'type' => 'player_layout' ),
array( 'type' => 'player_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link players', 'sportspress' ),
'id' => 'sportspress_link_players',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Details', 'sportspress' ),
'desc' => __( 'Squad Number', 'sportspress' ),
'id' => 'sportspress_player_show_number',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Name', 'sportspress' ),
'id' => 'sportspress_player_show_name',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Nationality', 'sportspress' ),
'id' => 'sportspress_player_show_nationality',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Position', 'sportspress' ),
'id' => 'sportspress_player_show_positions',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Current Team', 'sportspress' ),
'id' => 'sportspress_player_show_current_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Past Teams', 'sportspress' ),
'id' => 'sportspress_player_show_past_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Leagues', 'sportspress' ),
'id' => 'sportspress_player_show_leagues',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Seasons', 'sportspress' ),
'id' => 'sportspress_player_show_seasons',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_player_show_flags',
'default' => 'yes',
'type' => 'checkbox',
),
)
),
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_player_statistics_mode',
'default' => 'values',
'type' => 'radio',
array(
'type' => 'sectionend',
'id' => 'player_options',
),
),
array(
array(
'title' => __( 'Statistics', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'player_statistic_options',
),
array(
'title' => __( 'Columns', 'sportspress' ),
'id' => 'sportspress_player_columns',
'default' => 'auto',
'type' => 'radio',
'options' => array(
'values' => __( 'Values', 'sportspress' ),
'icons' => __( 'Icons', 'sportspress' ),
'auto' => __( 'Auto', 'sportspress' ),
'manual' => __( 'Manual', 'sportspress' ),
),
),
array(
'title' => __( 'Categories', 'sportspress' ),
'id' => 'sportspress_player_performance_sections',
'default' => -1,
'type' => 'radio',
'options' => array(
-1 => __( 'Combined', 'sportspress' ),
0 => __( 'Offense', 'sportspress' ) . ' &rarr; ' . __( 'Defense', 'sportspress' ),
1 => __( 'Defense', 'sportspress' ) . ' &rarr; ' . __( 'Offense', 'sportspress' ),
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_player_statistics_mode',
'default' => 'values',
'type' => 'radio',
'options' => array(
'values' => __( 'Values', 'sportspress' ),
'icons' => __( 'Icons', 'sportspress' ),
),
),
array(
'title' => __( 'Categories', 'sportspress' ),
'id' => 'sportspress_player_performance_sections',
'default' => -1,
'type' => 'radio',
'options' => array(
-1 => __( 'Combined', 'sportspress' ),
0 => __( 'Offense', 'sportspress' ) . ' &rarr; ' . __( 'Defense', 'sportspress' ),
1 => __( 'Defense', 'sportspress' ) . ' &rarr; ' . __( 'Offense', 'sportspress' ),
),
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Total', 'sportspress' ),
'id' => 'sportspress_player_show_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Career Total', 'sportspress' ),
'id' => 'sportspress_player_show_career_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Total', 'sportspress' ),
'id' => 'sportspress_player_show_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
apply_filters(
'sportspress_player_statistic_options',
array()
),
array(
'desc' => __( 'Career Total', 'sportspress' ),
'id' => 'sportspress_player_show_career_total',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
),
array(
'type' => 'sectionend',
'id' => 'player_statistic_options',
),
)
);
apply_filters( 'sportspress_player_statistic_options', array(
) ),
array(
array( 'type' => 'sectionend', 'id' => 'player_statistic_options' ),
)
);
return apply_filters( 'sportspress_player_settings', $settings );
return apply_filters( 'sportspress_player_settings', $settings );
}
}
}
endif;

View File

@@ -2,102 +2,116 @@
/**
* SportsPress Staff Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.1.6
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Staff' ) ) :
/**
* SP_Settings_Staff
*/
class SP_Settings_Staff extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_Staff
*/
public function __construct() {
$this->id = 'staff';
$this->label = __( 'Staff', 'sportspress' );
$this->template = 'staff';
class SP_Settings_Staff extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_staff_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_staff_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
/**
* Constructor
*/
public function __construct() {
$this->id = 'staff';
$this->label = __( 'Staff', 'sportspress' );
$this->template = 'staff';
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_staff_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_staff_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
return apply_filters(
'sportspress_staff_settings',
array_merge(
array(
array(
'title' => __( 'Staff Options', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'staff_options',
),
),
apply_filters(
'sportspress_staff_options',
array(
array( 'type' => 'staff_layout' ),
array( 'type' => 'staff_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link staff', 'sportspress' ),
'id' => 'sportspress_link_staff',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Details', 'sportspress' ),
'desc' => __( 'Nationality', 'sportspress' ),
'id' => 'sportspress_staff_show_nationality',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Current Team', 'sportspress' ),
'id' => 'sportspress_staff_show_current_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Past Teams', 'sportspress' ),
'id' => 'sportspress_staff_show_past_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_staff_show_flags',
'default' => 'yes',
'type' => 'checkbox',
),
)
),
array(
array(
'type' => 'sectionend',
'id' => 'staff_options',
),
)
)
); // End staff settings
}
}
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
return apply_filters( 'sportspress_staff_settings', array_merge(
array(
array( 'title' => __( 'Staff Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'staff_options' ),
),
apply_filters( 'sportspress_staff_options', array(
array( 'type' => 'staff_layout' ),
array( 'type' => 'staff_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link staff', 'sportspress' ),
'id' => 'sportspress_link_staff',
'default' => 'yes',
'type' => 'checkbox',
),
array(
'title' => __( 'Details', 'sportspress' ),
'desc' => __( 'Nationality', 'sportspress' ),
'id' => 'sportspress_staff_show_nationality',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Current Team', 'sportspress' ),
'id' => 'sportspress_staff_show_current_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Past Teams', 'sportspress' ),
'id' => 'sportspress_staff_show_past_teams',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Nationality', 'sportspress' ),
'desc' => __( 'Display national flags', 'sportspress' ),
'id' => 'sportspress_staff_show_flags',
'default' => 'yes',
'type' => 'checkbox',
),
) ),
array(
array( 'type' => 'sectionend', 'id' => 'staff_options' ),
)
) ); // End staff settings
}
}
endif;
return new SP_Settings_Staff();

View File

@@ -2,43 +2,45 @@
/**
* SportsPress System Status
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Status' ) ) :
/**
* SP_Settings_Status
*/
class SP_Settings_Status extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_Status
*/
public function __construct() {
$this->id = 'status';
$this->label = __( 'System Status', 'sportspress' );
class SP_Settings_Status extends SP_Settings_Page {
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG && current_user_can( 'manage_options' ) ) {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 99 );
/**
* Constructor
*/
public function __construct() {
$this->id = 'status';
$this->label = __( 'System Status', 'sportspress' );
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG && current_user_can( 'manage_options' ) ) {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 99 );
}
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
}
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
}
/**
* Output system status
*
* @access public
* @return void
*/
public function output() {
?>
/**
* Output system status
*
* @access public
* @return void
*/
public function output() {
?>
<h3><?php _e( 'System Status', 'sportspress' ); ?></h3>
<div class="updated sportspress-message">
<p><?php _e( 'Please include this information when requesting support:', 'sportspress' ); ?> </p>
@@ -56,130 +58,164 @@ class SP_Settings_Status extends SP_Settings_Page {
<tbody>
<tr>
<td><?php _e( 'Home URL','sportspress' ); ?>:</td>
<td><?php _e( 'Home URL', 'sportspress' ); ?>:</td>
<td><?php echo home_url(); ?></td>
</tr>
<tr>
<td><?php _e( 'Site URL','sportspress' ); ?>:</td>
<td><?php _e( 'Site URL', 'sportspress' ); ?>:</td>
<td><?php echo site_url(); ?></td>
</tr>
<tr>
<td><?php _e( 'SP Version','sportspress' ); ?>:</td>
<td><?php _e( 'SP Version', 'sportspress' ); ?>:</td>
<td><?php echo esc_html( SP()->version ); ?></td>
</tr>
<tr>
<td><?php _e( 'WP Version','sportspress' ); ?>:</td>
<td><?php bloginfo('version'); ?></td>
<td><?php _e( 'WP Version', 'sportspress' ); ?>:</td>
<td><?php bloginfo( 'version' ); ?></td>
</tr>
<tr>
<td><?php _e( 'WP Multisite Enabled','sportspress' ); ?>:</td>
<td><?php if ( is_multisite() ) _e( 'Yes', 'sportspress' ); else _e( 'No', 'sportspress' ); ?></td>
<td><?php _e( 'WP Multisite Enabled', 'sportspress' ); ?>:</td>
<td>
<?php
if ( is_multisite() ) {
_e( 'Yes', 'sportspress' );
} else {
_e( 'No', 'sportspress' );
}
?>
</td>
</tr>
<tr>
<td><?php _e( 'Web Server Info','sportspress' ); ?>:</td>
<td><?php _e( 'Web Server Info', 'sportspress' ); ?>:</td>
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
</tr>
<tr>
<td><?php _e( 'PHP Version','sportspress' ); ?>:</td>
<td><?php if ( function_exists( 'phpversion' ) ) echo esc_html( phpversion() ); ?></td>
<td><?php _e( 'PHP Version', 'sportspress' ); ?>:</td>
<td>
<?php
if ( function_exists( 'phpversion' ) ) {
echo esc_html( phpversion() );}
?>
</td>
</tr>
<tr>
<td><?php _e( 'WP Memory Limit','sportspress' ); ?>:</td>
<td><?php
<td><?php _e( 'WP Memory Limit', 'sportspress' ); ?>:</td>
<td>
<?php
$memory = sp_let_to_num( WP_MEMORY_LIMIT );
if ( $memory < 67108864 ) {
echo '<mark class="error">' . sprintf( __( '%s - We recommend setting memory to at least 64MB. See: <a href="%s">Increasing memory allocated to PHP</a>', 'sportspress' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>';
} else {
echo '<mark class="yes">' . size_format( $memory ) . '</mark>';
}
?></td>
if ( $memory < 67108864 ) {
echo '<mark class="error">' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: <a href="%2$s">Increasing memory allocated to PHP</a>', 'sportspress' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>';
} else {
echo '<mark class="yes">' . size_format( $memory ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td><?php _e( 'WP Debug Mode', 'sportspress' ); ?>:</td>
<td><?php if ( defined('WP_DEBUG') && WP_DEBUG ) echo '<mark class="yes">' . __( 'Yes', 'sportspress' ) . '</mark>'; else echo '<mark class="no">' . __( 'No', 'sportspress' ) . '</mark>'; ?></td>
<td>
<?php
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
echo '<mark class="yes">' . __( 'Yes', 'sportspress' ) . '</mark>';
} else {
echo '<mark class="no">' . __( 'No', 'sportspress' ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td><?php _e( 'WP Language', 'sportspress' ); ?>:</td>
<td><?php if ( defined( 'WPLANG' ) && WPLANG ) echo WPLANG; else _e( 'Default', 'sportspress' ); ?></td>
<td>
<?php
if ( defined( 'WPLANG' ) && WPLANG ) {
echo WPLANG;
} else {
_e( 'Default', 'sportspress' );
}
?>
</td>
</tr>
<tr>
<td><?php _e( 'WP Max Upload Size','sportspress' ); ?>:</td>
<td><?php _e( 'WP Max Upload Size', 'sportspress' ); ?>:</td>
<td><?php echo size_format( wp_max_upload_size() ); ?></td>
</tr>
<?php if ( function_exists( 'ini_get' ) ) : ?>
<?php if ( function_exists( 'ini_get' ) ) : ?>
<tr>
<td><?php _e('PHP Post Max Size','sportspress' ); ?>:</td>
<td><?php echo size_format( sp_let_to_num( ini_get('post_max_size') ) ); ?></td>
<td><?php _e( 'PHP Post Max Size', 'sportspress' ); ?>:</td>
<td><?php echo size_format( sp_let_to_num( ini_get( 'post_max_size' ) ) ); ?></td>
</tr>
<tr>
<td><?php _e('PHP Time Limit','sportspress' ); ?>:</td>
<td><?php echo ini_get('max_execution_time'); ?></td>
<td><?php _e( 'PHP Time Limit', 'sportspress' ); ?>:</td>
<td><?php echo ini_get( 'max_execution_time' ); ?></td>
</tr>
<tr>
<td><?php _e( 'PHP Max Input Vars','sportspress' ); ?>:</td>
<td><?php echo ini_get('max_input_vars'); ?></td>
<td><?php _e( 'PHP Max Input Vars', 'sportspress' ); ?>:</td>
<td><?php echo ini_get( 'max_input_vars' ); ?></td>
</tr>
<tr>
<td><?php _e( 'SUHOSIN Installed','sportspress' ); ?>:</td>
<td><?php _e( 'SUHOSIN Installed', 'sportspress' ); ?>:</td>
<td><?php echo extension_loaded( 'suhosin' ) ? __( 'Yes', 'sportspress' ) : __( 'No', 'sportspress' ); ?></td>
</tr>
<?php endif; ?>
<tr>
<td><?php _e( 'Default Timezone','sportspress' ); ?>:</td>
<td><?php
<td><?php _e( 'Default Timezone', 'sportspress' ); ?>:</td>
<td>
<?php
$default_timezone = date_default_timezone_get();
if ( 'UTC' !== $default_timezone ) {
echo '<mark class="error">' . sprintf( __( 'Default timezone is %s - it should be UTC', 'sportspress' ), $default_timezone ) . '</mark>';
} else {
echo '<mark class="yes">' . sprintf( __( 'Default timezone is %s', 'sportspress' ), $default_timezone ) . '</mark>';
} ?>
if ( 'UTC' !== $default_timezone ) {
echo '<mark class="error">' . sprintf( __( 'Default timezone is %s - it should be UTC', 'sportspress' ), $default_timezone ) . '</mark>';
} else {
echo '<mark class="yes">' . sprintf( __( 'Default timezone is %s', 'sportspress' ), $default_timezone ) . '</mark>';
}
?>
</td>
</tr>
<?php
<?php
$posting = array();
// fsockopen/cURL
$posting['fsockopen_curl']['name'] = __( 'fsockopen/cURL','sportspress');
$posting['fsockopen_curl']['name'] = __( 'fsockopen/cURL', 'sportspress' );
if ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ) {
if ( function_exists( 'fsockopen' ) && function_exists( 'curl_init' )) {
$posting['fsockopen_curl']['note'] = __('Your server has fsockopen and cURL enabled.', 'sportspress' );
} elseif ( function_exists( 'fsockopen' )) {
if ( function_exists( 'fsockopen' ) && function_exists( 'curl_init' ) ) {
$posting['fsockopen_curl']['note'] = __( 'Your server has fsockopen and cURL enabled.', 'sportspress' );
} elseif ( function_exists( 'fsockopen' ) ) {
$posting['fsockopen_curl']['note'] = __( 'Your server has fsockopen enabled, cURL is disabled.', 'sportspress' );
} else {
$posting['fsockopen_curl']['note'] = __( 'Your server has cURL enabled, fsockopen is disabled.', 'sportspress' );
}
$posting['fsockopen_curl']['success'] = true;
} else {
$posting['fsockopen_curl']['note'] = __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'sportspress' ). '</mark>';
$posting['fsockopen_curl']['note'] = __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'sportspress' ) . '</mark>';
$posting['fsockopen_curl']['success'] = false;
}
// SOAP
$posting['soap_client']['name'] = __( 'SOAP Client','sportspress' );
$posting['soap_client']['name'] = __( 'SOAP Client', 'sportspress' );
if ( class_exists( 'SoapClient' ) ) {
$posting['soap_client']['note'] = __('Your server has the SOAP Client class enabled.', 'sportspress' );
$posting['soap_client']['note'] = __( 'Your server has the SOAP Client class enabled.', 'sportspress' );
$posting['soap_client']['success'] = true;
} else {
$posting['soap_client']['note'] = sprintf( __( 'Your server does not have the <a href="%s">SOAP Client</a> class enabled - some gateway plugins which use SOAP may not work as expected.', 'sportspress' ), 'http://php.net/manual/en/class.soapclient.php' ) . '</mark>';
$posting['soap_client']['note'] = sprintf( __( 'Your server does not have the <a href="%s">SOAP Client</a> class enabled - some gateway plugins which use SOAP may not work as expected.', 'sportspress' ), 'http://php.net/manual/en/class.soapclient.php' ) . '</mark>';
$posting['soap_client']['success'] = false;
}
$posting = apply_filters( 'sportspress_debug_posting', $posting );
foreach( $posting as $post ) { $mark = ( isset( $post['success'] ) && $post['success'] == true ) ? 'yes' : 'error';
foreach ( $posting as $post ) {
$mark = ( isset( $post['success'] ) && $post['success'] == true ) ? 'yes' : 'error';
?>
<tr>
<td><?php echo esc_html( $post['name'] ); ?>:</td>
<td>
<mark class="<?php echo $mark; ?>">
<?php echo wp_kses_data( $post['note'] ); ?>
<?php echo wp_kses_data( $post['note'] ); ?>
</mark>
</td>
</tr>
<?php
}
?>
?>
</tbody>
<thead>
@@ -190,64 +226,74 @@ class SP_Settings_Status extends SP_Settings_Page {
<tbody>
<tr>
<td><?php _e( 'Installed Plugins','sportspress' ); ?>:</td>
<td><?php
<td><?php _e( 'Installed Plugins', 'sportspress' ); ?>:</td>
<td>
<?php
$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() )
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
if ( is_multisite() ) {
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
}
$sp_plugins = array();
foreach ( $active_plugins as $plugin ) {
foreach ( $active_plugins as $plugin ) {
$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$dirname = dirname( $plugin );
$version_string = '';
$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
$dirname = dirname( $plugin );
$version_string = '';
if ( ! empty( $plugin_data['Name'] ) ) {
if ( ! empty( $plugin_data['Name'] ) ) {
// link the plugin name to the plugin url if available
$plugin_name = $plugin_data['Name'];
if ( ! empty( $plugin_data['PluginURI'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . __( 'Visit plugin homepage' , 'sportspress' ) . '">' . $plugin_name . '</a>';
}
// link the plugin name to the plugin url if available
$plugin_name = $plugin_data['Name'];
if ( ! empty( $plugin_data['PluginURI'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . __( 'Visit plugin homepage', 'sportspress' ) . '">' . $plugin_name . '</a>';
}
if ( strstr( $dirname, 'sportspress' ) ) {
if ( strstr( $dirname, 'sportspress' ) ) {
if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
$changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) );
if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) {
if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
$changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) );
if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) {
$date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
$version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
$update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
set_transient( md5( $plugin ) . '_version_data', $version_data, 60*60*12 );
break;
}
$date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) );
$version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) );
$update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) );
$version_data = array(
'date' => $date,
'version' => $version,
'update' => $update,
'changelog' => $changelog,
);
set_transient( md5( $plugin ) . '_version_data', $version_data, 60 * 60 * 12 );
break;
}
}
}
if ( ! empty( $version_data['version'] ) && version_compare( $version_data['version'], $plugin_data['Version'], '>' ) )
$version_string = ' &ndash; <strong style="color:red;">' . $version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . '</strong>';
}
$sp_plugins[] = $plugin_name . ' ' . __( 'by', 'sportspress' ) . ' ' . $plugin_data['Author'] . ' ' . __( 'version', 'sportspress' ) . ' ' . $plugin_data['Version'] . $version_string;
if ( ! empty( $version_data['version'] ) && version_compare( $version_data['version'], $plugin_data['Version'], '>' ) ) {
$version_string = ' &ndash; <strong style="color:red;">' . $version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . '</strong>';
}
}
$sp_plugins[] = $plugin_name . ' ' . __( 'by', 'sportspress' ) . ' ' . $plugin_data['Author'] . ' ' . __( 'version', 'sportspress' ) . ' ' . $plugin_data['Version'] . $version_string;
}
}
if ( sizeof( $sp_plugins ) == 0 )
echo '-';
else
echo implode( ', <br/>', array_map( 'wp_kses_post', $sp_plugins ) );
if ( sizeof( $sp_plugins ) == 0 ) {
echo '-';
} else {
echo implode( ', <br/>', array_map( 'wp_kses_post', $sp_plugins ) );
}
?></td>
?>
</td>
</tr>
</tbody>
@@ -264,65 +310,130 @@ class SP_Settings_Status extends SP_Settings_Page {
</tr>
<tr>
<td><?php _e( 'Event Outcomes', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_outcome', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post )
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
$posts = get_posts(
array(
'post_type' => 'sp_outcome',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Event Results', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_result', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post )
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
$posts = get_posts(
array(
'post_type' => 'sp_result',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Player Performance', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_performance', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post )
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
$posts = get_posts(
array(
'post_type' => 'sp_performance',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Table Columns', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_column', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post ) {
$sort_order = sp_get_post_order( $post->ID );
$display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']' . ( '&mdash;' == $sort_order ? '' : ' {' . $sort_order . '}' );
}
$posts = get_posts(
array(
'post_type' => 'sp_column',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$sort_order = sp_get_post_order( $post->ID );
$display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']' . ( '&mdash;' == $sort_order ? '' : ' {' . $sort_order . '}' );
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Player Metrics', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_metric', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post )
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
$posts = get_posts(
array(
'post_type' => 'sp_metric',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$display_posts[] = $post->post_title . ' (' . $post->post_name . ') [' . $post->menu_order . ']';
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Player Statistics', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_posts = array();
$posts = get_posts( array( 'post_type' => 'sp_statistic', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'any' ) );
foreach ( $posts as $post )
$display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']';
$posts = get_posts(
array(
'post_type' => 'sp_statistic',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'any',
)
);
foreach ( $posts as $post ) {
$display_posts[] = $post->post_title . ' (' . $post->post_name . ' = ' . get_post_meta( $post->ID, 'sp_equation', true ) . ') [' . $post->menu_order . ']';
}
echo implode( ', ', array_map( 'esc_html', $display_posts ) );
?></td>
?>
</td>
</tr>
</tbody>
@@ -335,43 +446,55 @@ class SP_Settings_Status extends SP_Settings_Page {
<tbody>
<tr>
<td><?php _e( 'Leagues', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_terms = array();
$terms = get_terms( 'sp_league', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term )
$display_terms[] = $term->name . ' (' . $term->slug . ')';
$terms = get_terms( 'sp_league', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$display_terms[] = $term->name . ' (' . $term->slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Seasons', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_terms = array();
$terms = get_terms( 'sp_season', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term )
$display_terms[] = $term->name . ' (' . $term->slug . ')';
$terms = get_terms( 'sp_season', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$display_terms[] = $term->name . ' (' . $term->slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Venues', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_terms = array();
$terms = get_terms( 'sp_venue', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term )
$display_terms[] = $term->name . ' (' . $term->slug . ')';
$terms = get_terms( 'sp_venue', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$display_terms[] = $term->name . ' (' . $term->slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
?>
</td>
</tr>
<tr>
<td><?php _e( 'Positions', 'sportspress' ); ?>:</td>
<td><?php
<td>
<?php
$display_terms = array();
$terms = get_terms( 'sp_position', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term )
$display_terms[] = $term->name . ' (' . $term->slug . ')';
$terms = get_terms( 'sp_position', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
$display_terms[] = $term->name . ' (' . $term->slug . ')';
}
echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td>
?>
</td>
</tr>
</tbody>
@@ -382,23 +505,24 @@ class SP_Settings_Status extends SP_Settings_Page {
</thead>
<tbody>
<?php
$post_types = sp_post_types();
foreach ( $post_types as $post_type ):
?>
<?php
$post_types = sp_post_types();
foreach ( $post_types as $post_type ) :
?>
<tr>
<td>
<?php
$object = get_post_type_object( $post_type );
echo esc_html( $object->labels->name );
?>:
?>
:
</td>
<td>
<?php $count = wp_count_posts( $post_type ); ?>
<?php echo $count->publish; ?> publish, <?php echo $count->future; ?> future, <?php echo $count->draft; ?> draft, <?php echo $count->private; ?> private, <?php echo $count->trash; ?> trash, <?php echo $count->{'auto-draft'}; ?> auto-draft, <?php echo $count->inherit; ?> inherit
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
<thead>
@@ -407,59 +531,71 @@ class SP_Settings_Status extends SP_Settings_Page {
</tr>
</thead>
<?php
$active_theme = wp_get_theme();
if ( $active_theme->{'Author URI'} == 'http://themeboy.com' ) :
<?php
$active_theme = wp_get_theme();
if ( $active_theme->{'Author URI'} == 'http://themeboy.com' ) :
$theme_dir = substr( strtolower( str_replace( ' ','', $active_theme->Name ) ), 0, 45 );
$theme_dir = substr( strtolower( str_replace( ' ', '', $active_theme->Name ) ), 0, 45 );
if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) :
if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) :
$theme_changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
if ( ! empty( $cl_lines ) ) :
$theme_changelog = wp_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
$cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
if ( ! empty( $cl_lines ) ) :
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) :
foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) :
$theme_date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
$theme_version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
$theme_update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
$theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog );
set_transient( $theme_dir . '_version_data', $theme_version_data , 60*60*12 );
break;
$theme_date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) );
$theme_version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) );
$theme_update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) );
$theme_version_data = array(
'date' => $theme_date,
'version' => $theme_version,
'update' => $theme_update,
'changelog' => $theme_changelog,
);
set_transient( $theme_dir . '_version_data', $theme_version_data, 60 * 60 * 12 );
break;
endif;
}
endif;
}
endif;
endif;
endif;
endif;
?>
?>
<tbody>
<tr>
<td><?php _e( 'Theme Name', 'sportspress' ); ?>:</td>
<td><?php
<tr>
<td><?php _e( 'Theme Name', 'sportspress' ); ?>:</td>
<td>
<?php
echo esc_html( $active_theme->Name );
?></td>
</tr>
<tr>
<td><?php _e( 'Theme Version', 'sportspress' ); ?>:</td>
<td><?php
?>
</td>
</tr>
<tr>
<td><?php _e( 'Theme Version', 'sportspress' ); ?>:</td>
<td>
<?php
echo esc_html( $active_theme->Version );
if ( ! empty( $theme_version_data['version'] ) && version_compare( $theme_version_data['version'], $active_theme->Version, '!=' ) )
echo ' &ndash; <strong style="color:red;">' . $theme_version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . '</strong>';
?></td>
</tr>
<tr>
<td><?php _e( 'Author URL', 'sportspress' ); ?>:</td>
<td><?php
if ( ! empty( $theme_version_data['version'] ) && version_compare( $theme_version_data['version'], $active_theme->Version, '!=' ) ) {
echo ' &ndash; <strong style="color:red;">' . $theme_version_data['version'] . ' ' . __( 'is available', 'sportspress' ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td><?php _e( 'Author URL', 'sportspress' ); ?>:</td>
<td>
<?php
echo esc_url( $active_theme->{'Author URI'} );
?></td>
</tr>
?>
</td>
</tr>
</tbody>
<thead>
@@ -470,15 +606,16 @@ class SP_Settings_Status extends SP_Settings_Page {
<tbody>
<tr>
<?php
<?php
$status = include( SP()->plugin_path() . '/includes/admin/class-sp-admin-status.php' );
$status = include SP()->plugin_path() . '/includes/admin/class-sp-admin-status.php';
$template_paths = apply_filters( 'sportspress_template_overrides_scan_paths', array( 'SportsPress' => SP()->plugin_path() . '/templates/' ) );
$found_files = array();
foreach ( $template_paths as $plugin_name => $template_path )
foreach ( $template_paths as $plugin_name => $template_path ) {
$scanned_files[ $plugin_name ] = $status->scan_template_files( $template_path );
}
foreach ( $scanned_files as $plugin_name => $files ) {
foreach ( $files as $file ) {
@@ -488,7 +625,7 @@ class SP_Settings_Status extends SP_Settings_Page {
$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 ) ) {
} elseif ( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
$theme_file = get_template_directory() . '/sportspress/' . $file;
} else {
$theme_file = false;
@@ -499,7 +636,7 @@ class SP_Settings_Status extends SP_Settings_Page {
$theme_version = $status->get_file_version( $theme_file );
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
$found_files[ $plugin_name ][] = sprintf( __( '<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'sportspress' ), basename( $theme_file ), $theme_version ? $theme_version : '-', $core_version );
$found_files[ $plugin_name ][] = sprintf( __( '<code>%1$s</code> version <strong style="color:red">%2$s</strong> is out of date. The core version is %3$s', 'sportspress' ), basename( $theme_file ), $theme_version ? $theme_version : '-', $core_version );
} else {
$found_files[ $plugin_name ][] = sprintf( '<code>%s</code>', basename( $theme_file ) );
}
@@ -520,7 +657,7 @@ class SP_Settings_Status extends SP_Settings_Page {
<td><?php _e( 'No overrides present in theme.', 'sportspress' ); ?></td>
<?php
}
?>
?>
</tr>
</tbody>
@@ -596,9 +733,9 @@ class SP_Settings_Status extends SP_Settings_Page {
return false;
});
</script>
<?php
<?php
}
}
}
endif;

View File

@@ -2,104 +2,113 @@
/**
* SportsPress Team Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Teams' ) ) :
/**
* SP_Settings_Teams
*/
class SP_Settings_Teams extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_Teams
*/
public function __construct() {
$this->id = 'teams';
$this->label = __( 'Teams', 'sportspress' );
$this->template = 'team';
class SP_Settings_Teams extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_team_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_team_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Constructor
*/
public function __construct() {
$this->id = 'teams';
$this->label = __( 'Teams', 'sportspress' );
$this->template = 'team';
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_team_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_team_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$settings = array_merge(
array(
array( 'title' => __( 'Team Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'team_options' ),
),
apply_filters( 'sportspress_team_options', array(
array( 'type' => 'team_layout' ),
array( 'type' => 'team_tabs' ),
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$settings = array_merge(
array(
'title' => __( 'Staff', 'sportspress' ),
'desc' => __( 'Link staff', 'sportspress' ),
'id' => 'sportspress_team_link_staff',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link teams', 'sportspress' ),
'id' => 'sportspress_link_teams',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Venue', 'sportspress' ),
'desc' => __( 'Link venues', 'sportspress' ),
'id' => 'sportspress_team_link_venues',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Visit Site', 'sportspress' ),
'desc' => __( 'Open link in a new window/tab', 'sportspress' ),
'id' => 'sportspress_team_site_target_blank',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Comments', 'sportspress' ),
'desc' => __( 'Allow people to post comments on Team page', 'sportspress' ),
'id' => 'sportspress_team_comment_status',
'default' => 'no',
'type' => 'checkbox',
array(
'title' => __( 'Team Options', 'sportspress' ),
'type' => 'title',
'desc' => '',
'id' => 'team_options',
),
)),
),
apply_filters(
'sportspress_team_options',
array(
array( 'type' => 'team_layout' ),
array(
array( 'type' => 'sectionend', 'id' => 'team_options' ),
)
array( 'type' => 'team_tabs' ),
);
array(
'title' => __( 'Staff', 'sportspress' ),
'desc' => __( 'Link staff', 'sportspress' ),
'id' => 'sportspress_team_link_staff',
'default' => 'no',
'type' => 'checkbox',
),
return apply_filters( 'sportspress_team_settings', $settings );
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link teams', 'sportspress' ),
'id' => 'sportspress_link_teams',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Venue', 'sportspress' ),
'desc' => __( 'Link venues', 'sportspress' ),
'id' => 'sportspress_team_link_venues',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Visit Site', 'sportspress' ),
'desc' => __( 'Open link in a new window/tab', 'sportspress' ),
'id' => 'sportspress_team_site_target_blank',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Comments', 'sportspress' ),
'desc' => __( 'Allow people to post comments on Team page', 'sportspress' ),
'id' => 'sportspress_team_comment_status',
'default' => 'no',
'type' => 'checkbox',
),
)
),
array(
array(
'type' => 'sectionend',
'id' => 'team_options',
),
)
);
return apply_filters( 'sportspress_team_settings', $settings );
}
}
}
endif;

View File

@@ -2,75 +2,90 @@
/**
* SportsPress Text Settings
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.6
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'SP_Settings_Text' ) ) :
/**
* SP_Settings_Text
*/
class SP_Settings_Text extends SP_Settings_Page {
/**
* Constructor
* SP_Settings_Text
*/
public function __construct() {
$this->id = 'text';
$this->label = __( 'Text', 'sportspress' );
class SP_Settings_Text extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Constructor
*/
public function __construct() {
$this->id = 'text';
$this->label = __( 'Text', 'sportspress' );
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
$settings = array(
array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ),
);
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$strings = sp_get_text_options();
$options = get_option( 'sportspress_text' );
$options = array();
foreach ( $strings as $string ):
$options[] = array(
'title' => $string,
'id' => 'sportspress_text[' . $string . ']',
'default' => '',
'placeholder' => $string,
'value' => sp_array_value( $options, $string, null ),
'type' => 'text',
$settings = array(
array(
'title' => __( 'Text', 'sportspress' ),
'type' => 'title',
'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ),
'id' => 'text_options',
),
);
endforeach;
$settings = array_merge( $settings, apply_filters( 'sportspress_text_options', $options ), array(
array( 'type' => 'sectionend', 'id' => 'text_options' )
));
$strings = sp_get_text_options();
$options = get_option( 'sportspress_text' );
return apply_filters( 'sportspress_text_settings', $settings ); // End event settings
$options = array();
foreach ( $strings as $string ) :
$options[] = array(
'title' => $string,
'id' => 'sportspress_text[' . $string . ']',
'default' => '',
'placeholder' => $string,
'value' => sp_array_value( $options, $string, null ),
'type' => 'text',
);
endforeach;
$settings = array_merge(
$settings,
apply_filters( 'sportspress_text_options', $options ),
array(
array(
'type' => 'sectionend',
'id' => 'text_options',
),
)
);
return apply_filters( 'sportspress_text_settings', $settings ); // End event settings
}
/**
* Save settings
*/
public function save() {
if ( isset( $_POST['sportspress_text'] ) ) {
update_option( 'sportspress_text', array_map( 'sanitize_text_field', $_POST['sportspress_text'] ) );
}
}
}
/**
* Save settings
*/
public function save() {
if ( isset( $_POST['sportspress_text'] ) )
update_option( 'sportspress_text', array_map( 'sanitize_text_field', $_POST['sportspress_text'] ) );
}
}
endif;
return new SP_Settings_Text();