Add date range selector to calendar events

This commit is contained in:
Brian Miyaji
2014-10-23 00:13:40 +11:00
parent 640d896649
commit 12064bd8c3
13 changed files with 413 additions and 44 deletions

View File

@@ -59,6 +59,11 @@ class SP_Admin_Assets {
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
}
if ( in_array( $screen->id, array( 'sp_calendar', 'widgets' ) ) ) {
wp_enqueue_style( 'jquery-ui-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
}
do_action( 'sportspress_admin_css' );
}
@@ -103,7 +108,7 @@ class SP_Admin_Assets {
wp_enqueue_script( 'jquery-caret' );
wp_enqueue_script( 'jquery-countdown' );
wp_enqueue_script( 'jquery-fitvids' );
wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown', 'jquery-fitvids' ), SP_VERSION, true );
wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown', 'jquery-fitvids' ), SP_VERSION, true );
$strings = array(
'none' => __( 'None', 'sportspress' ),

View File

@@ -21,6 +21,8 @@ class SP_Meta_Box_Calendar_Details {
public static function output( $post ) {
$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 );
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
@@ -39,17 +41,24 @@ class SP_Meta_Box_Calendar_Details {
sp_dropdown_statuses( $args );
?>
</p>
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'name' => 'sp_date',
'id' => 'sp_date',
'selected' => $date,
);
sp_dropdown_dates( $args );
?>
</p>
<div class="sp-date-selector">
<p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
<p>
<?php
$args = array(
'name' => 'sp_date',
'id' => 'sp_date',
'selected' => $date,
);
sp_dropdown_dates( $args );
?>
</p>
<p class="sp-date-range">
<input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? $date_from : date_i18n( 'Y-m-d' ); ?>" size="10">
:
<input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n( 'Y-m-d' ); ?>" size="10">
</p>
</div>
<p><strong><?php _e( 'Competition', 'sportspress' ); ?></strong></p>
<p>
<?php
@@ -130,6 +139,8 @@ class SP_Meta_Box_Calendar_Details {
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
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 ) );
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
}