'', 'title' => __( 'Title', 'neuf_event' ), 'starttime' => __( 'Date & Time', 'neuf_event' ), 'endtime' => __( 'Ending Date & Time', 'neuf_event'), 'venue' => __( 'Venue', 'neuf_event' ), 'type' => __( 'Type', 'neuf_event' ), 'promoperiod' => __( 'Promo Period', 'neuf_event' ), 'date' => __( 'Date Published', 'neuf_event' ), 'author' => __( 'Author', 'neuf_event' ), ); return $custom_cols; } add_filter( "manage_event_posts_columns", "change_columns" ); // Add values to the custom columns function custom_columns( $column, $post_id ) { switch ( $column ) { case "starttime": $starttime = intval(get_post_meta( $post_id, '_neuf_events_starttime', true)); echo format_datetime($starttime); break; case "endtime": $endtime = intval(get_post_meta( $post_id, '_neuf_events_endtime', true)); echo $endtime ? format_datetime($endtime) : __("None", 'neuf_event'); break; case "type": echo the_terms( $post_id , 'event_type', '', ', ', '' ); break; case "venue": echo get_post_meta( $post_id , '_neuf_events_venue', true); break; case "promoperiod": echo get_post_meta( $post_id, '_neuf_events_promo_period', true); break; } } add_action( "manage_posts_custom_column" , "custom_columns", 10, 2 ); // Make these columns sortable function sortable_columns( $cols ) { $custom_cols = array( 'starttime' => 'starttime', 'endtime' => 'endtime', 'type' => 'type', 'venue' => 'venue', 'promoperiod' => 'promoperiod', ); return array_merge($cols, $custom_cols); } add_filter( "manage_edit-event_sortable_columns", "sortable_columns" ); /* * http://scribu.net/wordpress/custom-sortable-columns.html#comment-4732 */ function starttime_column_orderby( $vars ) { if ( isset( $vars['orderby']) ) { if('starttime' == $vars['orderby'] ) { $vars = array_merge( $vars, array( 'meta_key' => '_neuf_events_starttime', 'orderby' => 'meta_value' ) ); } if ( 'endtime' == $vars['orderby'] ) { $vars = array_merge( $vars, array( 'meta_key' => '_neuf_events_endtime', 'orderby' => 'meta_value' ) ); } } return $vars; } add_filter( 'request', 'starttime_column_orderby' ); function add_admin_script_and_styles() { // Datetime selection and form validation // Ref: http://trentrichardson.com/examples/timepicker/ // Ref: http://docs.jquery.com/Plugins/Validation#API_Documentation wp_register_style('jquery-ui-css', plugins_url("neuf-events/style/jquery-ui.min.css")); wp_register_style('jquery-ui-timepicker-css', plugins_url("neuf-events/style/jquery-ui-timepicker-addon.css"), array('jquery-ui-css')); wp_register_script('jquery-ui-timepicker-addon', plugins_url("neuf-events/script/jquery-ui-timepicker-addon.js"), array('jquery-ui-slider', 'jquery-ui-datepicker') ); wp_register_script('jquery-validate', plugins_url("neuf-events/script/jquery.validate.min.js"), array('jquery')); wp_register_script('neuf-events', plugins_url("neuf-events/script/neuf_events.js"), array('jquery-ui-timepicker-addon', 'jquery-validate')); wp_enqueue_style('jquery-ui-timepicker-css'); wp_enqueue_script('neuf-events'); } add_action('admin_enqueue_scripts', 'add_admin_script_and_styles'); /* Add metaboxes (with styles) */ function add_events_metaboxes() { add_meta_box( 'neuf_events_details', __('Event Details', 'neuf_event'), 'neuf_event_details', 'event', 'side', 'high' ); } function neuf_event_details() { ?>