Add single performance name option

This commit is contained in:
Brian Miyaji
2017-01-08 11:02:32 +11:00
parent e468ef8ac7
commit 0960bd7c3c
5 changed files with 19 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
}
// Post Meta
$single = get_post_meta( $post->ID, 'sp_single', true );
$section = get_post_meta( $post->ID, 'sp_section', true );
if ( '' === $section ) {
$section = -1;
@@ -53,6 +54,10 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo $post->post_name; ?>">
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>"<?php if ( $readonly ) { ?> readonly="readonly"<?php } ?>>
</p>
<p><strong><?php _e( 'Single', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_single" type="text" id="sp_single" placeholder="<?php echo $post->post_title; ?>" value="<?php echo $single; ?>">
</p>
<p><strong><?php _e( 'Category', 'sportspress' ); ?></strong></p>
<p class="sp-section-selector">
<select name="sp_section">
@@ -135,6 +140,7 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
*/
public static function save( $post_id, $post ) {
self::delete_duplicate( $_POST );
update_post_meta( $post_id, 'sp_single', sp_array_value( $_POST, 'sp_single', '' ) );
update_post_meta( $post_id, 'sp_section', (int) sp_array_value( $_POST, 'sp_section', -1 ) );
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'number' ) );
update_post_meta( $post_id, 'sp_precision', sp_array_value( $_POST, 'sp_precision', 0 ) );

View File

@@ -163,6 +163,15 @@ function sp_get_performance( $post = 0 ) {
return $event->performance();
}
function sp_get_single_name( $post = 0 ) {
$single = get_post_meta( $post, 'sp_single', true );
if ( '' !== $single ) {
return $single;
} else {
return get_the_title( $post );
}
}
function sp_event_logos( $post = 0 ) {
sp_get_template( 'event-logos.php', array( 'id' => $post ) );
}

View File

@@ -104,7 +104,7 @@ class SportsPress_Icons {
if ( ! $id || ! $value ) return $icons;
$icon = get_post_meta( $id, 'sp_icon', true );
if ( null !== $icon && in_array( $icon, $this->icons ) ) {
$title = get_the_title( $id );
$title = sp_get_single_name( $id );
$color = get_post_meta( $id, 'sp_color', true );
preg_match( '#\((.*?)\)#', $value, $match );
if ( ! empty( $match ) && isset( $match[1] ) ) {

View File

@@ -110,7 +110,7 @@ if ( ! isset( $class ) ) $class = null;
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_single_name( $performance_id ) ) ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;

View File

@@ -162,7 +162,7 @@ if ( ! isset( $subs ) ) $subs = array();
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_single_name( $performance_id ) ) ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;
@@ -218,7 +218,7 @@ if ( ! isset( $subs ) ) $subs = array();
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini', array( 'title' => sp_get_single_name( $performance_id ) ) ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;