Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user