From 578c1d8c2db07af586dbf2bf7a7e17d406fcb081 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 21 Oct 2016 18:49:44 +1100 Subject: [PATCH] Add tab labels to templates --- includes/class-sp-template-loader.php | 10 ++++++++-- includes/class-sp-templates.php | 3 +++ modules/sportspress-league-tables.php | 1 + modules/sportspress-player-lists.php | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/class-sp-template-loader.php b/includes/class-sp-template-loader.php index 8786e47c..86d15751 100644 --- a/includes/class-sp-template-loader.php +++ b/includes/class-sp-template-loader.php @@ -69,8 +69,11 @@ class SP_Template_Loader { // Get layout setting $layout = (array) get_option( 'sportspress_' . $type . '_template_order', array() ); + // Get templates + $templates = SP()->templates->$type; + // Combine layout setting with available templates - $templates = array_merge( array_flip( $layout ), SP()->templates->$type ); + $templates = array_merge( array_flip( $layout ), $templates ); $templates = apply_filters( 'sportspress_' . $type . '_templates', $templates ); @@ -134,8 +137,11 @@ class SP_Template_Loader { // Continue if tab content is empty if ( empty( $buffer ) ) continue; + // Get template label + $label = sp_array_value( $template, 'label', $template['title'] ); + // Add to tabs - $tabs .= '
  • ' . apply_filters( 'gettext', $template['title'], $template['title'], 'sportspress' ) . '
  • '; + $tabs .= '
  • ' . apply_filters( 'gettext', $label, $label, 'sportspress' ) . '
  • '; // Render the template $tab_content .= '
    ' . $buffer . '
    '; diff --git a/includes/class-sp-templates.php b/includes/class-sp-templates.php index 1c7a6db7..14db6125 100644 --- a/includes/class-sp-templates.php +++ b/includes/class-sp-templates.php @@ -130,6 +130,7 @@ class SP_Templates { apply_filters( 'sportspress_after_team_template', array( 'link' => array( 'title' => __( 'Visit Site', 'sportspress' ), + 'label' => __( 'Link', 'sportspress' ), 'option' => 'sportspress_team_show_link', 'action' => 'sportspress_output_team_link', 'default' => 'no', @@ -173,6 +174,7 @@ class SP_Templates { apply_filters( 'sportspress_before_player_template', array( 'selector' => array( 'title' => __( 'Dropdown', 'sportspress' ), + 'label' => __( 'Players', 'sportspress' ), 'option' => 'sportspress_player_show_selector', 'action' => 'sportspress_output_player_selector', 'default' => 'yes', @@ -240,6 +242,7 @@ class SP_Templates { apply_filters( 'sportspress_before_staff_template', array( 'selector' => array( 'title' => __( 'Dropdown', 'sportspress' ), + 'label' => __( 'Staff', 'sportspress' ), 'option' => 'sportspress_staff_show_selector', 'action' => 'sportspress_output_staff_selector', 'default' => 'yes', diff --git a/modules/sportspress-league-tables.php b/modules/sportspress-league-tables.php index 1590e9eb..b7fc6dba 100644 --- a/modules/sportspress-league-tables.php +++ b/modules/sportspress-league-tables.php @@ -299,6 +299,7 @@ class SportsPress_League_Tables { return array_merge( $templates, array( 'tables' => array( 'title' => __( 'League Tables', 'sportspress' ), + 'label' => __( 'League Table', 'sportspress' ), 'option' => 'sportspress_team_show_tables', 'action' => 'sportspress_output_team_tables', 'default' => 'yes', diff --git a/modules/sportspress-player-lists.php b/modules/sportspress-player-lists.php index d2b7be2d..295f557f 100644 --- a/modules/sportspress-player-lists.php +++ b/modules/sportspress-player-lists.php @@ -304,6 +304,7 @@ class SportsPress_Player_Lists { return array_merge( $templates, array( 'lists' => array( 'title' => __( 'Player Lists', 'sportspress' ), + 'label' => __( 'Players', 'sportspress' ), 'option' => 'sportspress_team_show_lists', 'action' => 'sportspress_output_team_lists', 'default' => 'yes',