Add abbreviation to event outcomes

This commit is contained in:
Brian Miyaji
2014-06-25 12:49:43 +10:00
parent 743d60c6ec
commit e0852ae9aa
8 changed files with 66 additions and 18 deletions

View File

@@ -77,6 +77,7 @@ class SP_Admin_Sports {
$post = self::get_post_array( $outcome, $post_type );
if ( empty( $post ) ) continue;
$id = self::insert_preset_post( $post, $index );
update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
}
// Results

View File

@@ -42,6 +42,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Variable', 'sportspress' ),
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
'sp_description' => __( 'Description', 'sportspress' ),
);
return apply_filters( 'sportspress_outcome_admin_columns', $columns );
@@ -57,6 +58,10 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
global $post;
echo $post->post_name;
break;
case 'sp_abbreviation':
global $post;
echo sp_get_post_abbreviation( $post->ID );
break;
case 'sp_description':
global $post;
echo '<span class="description">' . $post->post_excerpt . '</span>';

View File

@@ -23,12 +23,24 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
?>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<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; ?>">
</p>
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_abbreviation" type="text" id="sp_abbreviation" value="<?php echo $abbreviation; ?>" placeholder="<?php echo substr( $post->post_title, 0, 1 ); ?>">
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', array() ) );
}
}

View File

@@ -106,6 +106,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Abbreviation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
@@ -114,6 +115,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td><?php echo sp_get_post_abbreviation( $row->ID ); ?></td>
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
</tr>