Add heading option to calendars, league tables, and player lists

This commit is contained in:
Brian Miyaji
2015-10-04 21:52:26 +11:00
parent 801c52420e
commit 71aa3cdc22
8 changed files with 44 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ class SP_Meta_Box_Calendar_Details {
*/
public static function output( $post ) {
$taxonomies = get_object_taxonomies( 'sp_calendar' );
$caption = get_post_meta( $post->ID, 'sp_caption', true );
$status = get_post_meta( $post->ID, 'sp_status', true );
$date = get_post_meta( $post->ID, 'sp_date', true );
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
@@ -29,6 +30,9 @@ class SP_Meta_Box_Calendar_Details {
$order = get_post_meta( $post->ID, 'sp_order', true );
?>
<div>
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
<p><strong><?php _e( 'Status', 'sportspress' ); ?></strong></p>
<p>
<?php
@@ -96,6 +100,7 @@ class SP_Meta_Box_Calendar_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );

View File

@@ -20,6 +20,7 @@ class SP_Meta_Box_List_Details {
*/
public static function output( $post ) {
$taxonomies = get_object_taxonomies( 'sp_list' );
$caption = get_post_meta( $post->ID, 'sp_caption', true );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$grouping = get_post_meta( $post->ID, 'sp_grouping', true );
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
@@ -31,6 +32,9 @@ class SP_Meta_Box_List_Details {
}
?>
<div>
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
<?php
foreach ( $taxonomies as $taxonomy ) {
sp_taxonomy_field( $taxonomy, $post, true );
@@ -104,6 +108,7 @@ class SP_Meta_Box_List_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) );

View File

@@ -21,6 +21,7 @@ class SP_Meta_Box_Table_Details {
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$taxonomies = get_object_taxonomies( 'sp_table' );
$caption = get_post_meta( $post->ID, 'sp_caption', true );
$select = get_post_meta( $post->ID, 'sp_select', true );
if ( ! $select ) {
global $pagenow;
@@ -28,6 +29,9 @@ class SP_Meta_Box_Table_Details {
}
?>
<div>
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
<p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
<?php
foreach ( $taxonomies as $taxonomy ) {
sp_taxonomy_field( $taxonomy, $post, true );
@@ -56,6 +60,7 @@ class SP_Meta_Box_Table_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
update_post_meta( $post_id, 'sp_select', sp_array_value( $_POST, 'sp_select', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
}

View File

@@ -298,7 +298,7 @@ if ( ! function_exists( 'sportspress_output_league_table' ) ) {
* @return void
*/
function sportspress_output_league_table() {
sp_get_template( 'league-table.php', array( 'title' => __( 'League Table', 'sportspress' ) ) );
sp_get_template( 'league-table.php' );
}
}

View File

@@ -53,8 +53,13 @@ if ( $order != 'default' )
$data = $calendar->data();
$usecolumns = $calendar->columns;
if ( $show_title && false === $title && $id )
if ( $show_title && false === $title && $id ):
$caption = $calendar->caption;
if ( $caption )
$title = $caption;
else
$title = get_the_title( $id );
endif;
if ( isset( $columns ) ) {
$usecolumns = $columns;

View File

@@ -62,8 +62,13 @@ if ( isset( $columns ) ):
$usecolumns = explode( ',', $columns );
endif;
if ( $show_title && false === $title && $id )
if ( $show_title && false === $title && $id ):
$caption = $calendar->caption;
if ( $caption )
$title = $caption;
else
$title = get_the_title( $id );
endif;
?>
<div class="sp-template sp-template-event-list">
<?php if ( $title ) { ?>

View File

@@ -31,8 +31,13 @@ if ( ! isset( $highlight ) ) $highlight = get_post_meta( $id, 'sp_highlight', tr
$table = new SP_League_Table( $id );
if ( $show_title && false === $title && $id )
if ( $show_title && false === $title && $id ):
$caption = $table->caption;
if ( $caption )
$title = $caption;
else
$title = get_the_title( $id );
endif;
$output = '';

View File

@@ -74,8 +74,13 @@ $output = '';
if ( $grouping === 'position' ):
$groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
else:
if ( $show_title && false === $title && $id )
get_the_title( $id );
if ( $show_title && false === $title && $id ):
$caption = $list->caption;
if ( $caption )
$title = $caption;
else
$title = get_the_title( $id );
endif;
if ( $title )
$output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '</' . $grouptag . '>';
$group = new stdClass();