Add match days via fixtures importer

This commit is contained in:
Brian Miyaji
2016-09-01 22:42:26 +10:00
parent bf76ed7c97
commit b9d97c0677
2 changed files with 11 additions and 2 deletions

View File

@@ -28,7 +28,9 @@ if ( class_exists( 'WP_Importer' ) ) {
'sp_venue' => __( 'Venue', 'sportspress' ), 'sp_venue' => __( 'Venue', 'sportspress' ),
'sp_home' => __( 'Home', 'sportspress' ), 'sp_home' => __( 'Home', 'sportspress' ),
'sp_away' => __( 'Away', 'sportspress' ), 'sp_away' => __( 'Away', 'sportspress' ),
'sp_day' => __( 'Match Day', 'sportspress' ),
); );
$this->optionals = array( 'sp_day' );
} }
/** /**
@@ -72,6 +74,7 @@ if ( class_exists( 'WP_Importer' ) ) {
sp_array_value( $meta, 'post_date' ), sp_array_value( $meta, 'post_date' ),
sp_array_value( $meta, 'post_time' ), sp_array_value( $meta, 'post_time' ),
sp_array_value( $meta, 'sp_venue' ), sp_array_value( $meta, 'sp_venue' ),
sp_array_value( $meta, 'sp_day' ),
); );
$teams = array( $teams = array(
@@ -83,7 +86,7 @@ if ( class_exists( 'WP_Importer' ) ) {
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ): if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
// List event columns // List event columns
list( $date, $time, $venue ) = $event; list( $date, $time, $venue, $day ) = $event;
// Format date // Format date
$date = str_replace( '/', '-', trim( $date ) ); $date = str_replace( '/', '-', trim( $date ) );
@@ -137,6 +140,11 @@ if ( class_exists( 'WP_Importer' ) ) {
// Update venue // Update venue
wp_set_object_terms( $id, $venue, 'sp_venue', false ); wp_set_object_terms( $id, $venue, 'sp_venue', false );
// Update match day
if ( '' !== $day ) {
update_post_meta( $id, 'sp_day', $day );
}
// Increment // Increment
$this->imported ++; $this->imported ++;

View File

@@ -22,6 +22,7 @@ if ( class_exists( 'WP_Importer' ) ) {
var $skipped; var $skipped;
var $import_label; var $import_label;
var $columns = array(); var $columns = array();
var $optionals = array();
/** /**
* Constructor. * Constructor.
@@ -152,7 +153,7 @@ if ( class_exists( 'WP_Importer' ) ) {
<tr> <tr>
<?php $index = 0; foreach ( $this->columns as $key => $label ): $value = sp_array_value( $row, $index ); ?> <?php $index = 0; foreach ( $this->columns as $key => $label ): $value = sp_array_value( $row, $index ); ?>
<td> <td>
<input type="text" class="widefat" value="<?php echo esc_attr( $value ); ?>" name="sp_import[]"> <input type="text" class="widefat" value="<?php echo esc_attr( $value ); ?>" name="sp_import[]"<?php if ( in_array( $key, $this->optionals ) ) { ?> placeholder="<?php _e( 'Default', 'sportspress' ); ?>"<?php } ?>>
</td> </td>
<?php $index ++; endforeach; ?> <?php $index ++; endforeach; ?>
<td class="sp-actions-column"> <td class="sp-actions-column">