Add tab options to layout designer

This commit is contained in:
Brian Miyaji
2016-08-20 23:08:41 +10:00
parent ac0f742bea
commit 7f97fc9ba0
10 changed files with 195 additions and 19 deletions

View File

@@ -32,6 +32,7 @@ class SP_Settings_Events extends SP_Settings_Page {
add_action( 'sportspress_admin_field_current_mode', array( $this, 'current_mode_setting' ) );
add_action( 'sportspress_admin_field_delimiter', array( $this, 'delimiter_setting' ) );
add_action( 'sportspress_admin_field_event_layout', array( $this, 'layout_setting' ) );
add_action( 'sportspress_admin_field_event_tabs', array( $this, 'tabs_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
@@ -61,6 +62,8 @@ class SP_Settings_Events extends SP_Settings_Page {
apply_filters( 'sportspress_event_template_options', array(
array( 'type' => 'event_layout' ),
array( 'type' => 'event_tabs' ),
array(
'title' => __( 'Display', 'sportspress' ),
'desc' => __( 'Date', 'sportspress' ),

View File

@@ -90,6 +90,11 @@ class SP_Settings_Page {
}
$templates = array_merge( array_flip( $layout ), $templates );
$slice = array_search( 'tabs', array_flip( $templates ) );
if ( $slice ) {
$templates = array_slice( $templates, 0, $slice );
}
?>
<tr valign="top">
<th>
@@ -97,8 +102,64 @@ class SP_Settings_Page {
</th>
<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 ui-sortable">
<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 sp_array_value( $details, 'title', ucfirst( $template ) ); ?></span>
<input type="hidden" name="sportspress_<?php echo $this->template; ?>_template_order[]" value="<?php echo $template; ?>">
</div>
<input type="hidden" name="sportspress_template_visibility[<?php echo $option; ?>]" value="0">
<input class="sp-toggle-switch" type="checkbox" name="sportspress_template_visibility[<?php echo $option; ?>]" id="<?php echo $option; ?>" value="1" <?php checked( $visibility, 'yes' ); ?>>
<label for="sportspress_<?php echo $this->template; ?>_show_<?php echo $template; ?>"></label>
</div>
</li>
<?php } ?>
</ul>
</td>
</tr>
<?php
}
/**
* Tabs settings
*
* @access public
* @return void
*/
public function tabs_setting() {
$templates = apply_filters( 'sportspress_' . $this->template . '_templates', $this->templates );
$layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) {
$layout = array_keys( $templates );
}
$templates = array_merge( array_flip( $layout ), $templates );
$slice = array_search( 'tabs', array_flip( $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>
<input type="hidden" name="sportspress_<?php echo $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 );

View File

@@ -30,6 +30,7 @@ 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' ) );
}
@@ -48,6 +49,8 @@ class SP_Settings_Players extends SP_Settings_Page {
apply_filters( 'sportspress_player_options', array(
array( 'type' => 'player_layout' ),
array( 'type' => 'player_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link players', 'sportspress' ),

View File

@@ -30,6 +30,7 @@ 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' ) );
}
@@ -48,6 +49,8 @@ class SP_Settings_Staff extends SP_Settings_Page {
apply_filters( 'sportspress_staff_options', array(
array( 'type' => 'staff_layout' ),
array( 'type' => 'staff_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link staff', 'sportspress' ),

View File

@@ -30,6 +30,7 @@ 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' ) );
}
@@ -49,6 +50,8 @@ class SP_Settings_Teams extends SP_Settings_Page {
apply_filters( 'sportspress_team_options', array(
array( 'type' => 'team_layout' ),
array( 'type' => 'team_tabs' ),
array(
'title' => __( 'Link', 'sportspress' ),
'desc' => __( 'Link teams', 'sportspress' ),