hook = 'edit.php?post_type=event'; $this->title = __( 'Calendar View', 'eventorganiser' ); $this->menu = __( 'Calendar View', 'eventorganiser' ); $this->permissions = 'edit_events'; $this->slug = 'calendar'; } /** * Enqueues the page's scripts and styles, and localises them. */ function page_scripts(){ global $wp_locale; wp_enqueue_script( 'eo_calendar' ); //wp_enqueue_script( 'eo_event' ); wp_localize_script( 'eo_event', 'EO_Ajax_Event', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'startday' => intval( get_option( 'start_of_week' ) ), 'format' => eventorganiser_php2jquerydate( eventorganiser_get_option('dateformat') ), )); wp_localize_script( 'eo_calendar', 'EO_Ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'startday' => intval( get_option( 'start_of_week' ) ), 'format' => eventorganiser_php2jquerydate( eventorganiser_get_option('dateformat') ), 'timeFormat' => ( get_current_screen()->get_option( 'eofc_time_format', 'value' ) ? 'h:mmtt' : 'HH:mm' ), 'perm_edit' => current_user_can( 'edit_events' ), 'categories' => get_terms( 'event-category', array( 'hide_empty' => 0 ) ), 'venues' => get_terms( 'event-venue', array( 'hide_empty' => 0 ) ), 'locale' => array( 'monthNames' => array_values( $wp_locale->month ), 'monthAbbrev' => array_values( $wp_locale->month_abbrev ), 'dayNames' => array_values( $wp_locale->weekday ), 'dayAbbrev' => array_values( $wp_locale->weekday_abbrev ), 'today' => __( 'today', 'eventorganiser' ), 'day' => __( 'day', 'eventorganiser' ), 'week' => __( 'week', 'eventorganiser' ), 'month' => __( 'month', 'eventorganiser' ), 'gotodate' => __( 'go to date', 'eventorganiser' ), 'cat' => __( 'View all categories', 'eventorganiser' ), 'venue' => __( 'View all venues', 'eventorganiser' ), ) )); wp_enqueue_style( 'eo_calendar-style' ); wp_enqueue_style( 'eventorganiser-style' ); } /** * Prints page styles */ function page_styles(){ if ( $terms = get_terms( 'event-category', array( 'hide_empty' => 0 ) ) ): $css = ''; foreach ( $terms as $term ): $css .= ".cat-slug-{$term->slug} span.ui-selectmenu-item-icon{ background: ".eo_get_category_color( $term ).";}\n"; endforeach; wp_add_inline_style( 'eo_calendar-style', $css ); endif; } function page_actions(){ //Add screen option $user = wp_get_current_user(); $is12hour = get_user_meta( $user->ID, 'eofc_time_format', true ); if( '' === $is12hour ) $is12hour = eventorganiser_blog_is_24() ? 0 : 1; add_screen_option( 'eofc_time_format', array( 'value' => $is12hour ) ); add_filter( 'screen_settings', array( $this, 'screen_options' ), 10, 2 ); //Check action if ( !empty( $_REQUEST['save'] ) || !empty( $_REQUEST['publish'] ) ){ //Check nonce check_admin_referer( 'eventorganiser_calendar_save' ); //authentication checks if ( !current_user_can( 'edit_events' ) ) wp_die( __( 'You do not have sufficient permissions to create events', 'eventorganiser' ) ); $input = $_REQUEST['eo_event']; //Retrieve input from posted data //Set the status of the new event if ( !empty( $_REQUEST['save'] ) ): $status = 'draft'; else: $status = ( current_user_can( 'publish_events' ) ? 'publish' : 'pending' ); endif; //Set post and event details $venue = (int) $input['venue_id']; $post_input = array( 'post_title' => $input['event_title'], 'post_status' => $status, 'post_content' => $input['event_content'], 'post_type' => 'event', 'tax_input' => array( 'event-venue' => array( $venue ) ), ); $tz = eo_get_blog_timezone(); $event_data = array( 'schedule' => 'once', 'all_day' => $input['allday'], 'start' => new DateTime( $input['StartDate'].' '.$input['StartTime'], $tz ), 'end' => new DateTime( $input['EndDate'].' '.$input['FinishTime'], $tz ), ); //Insert event $post_id = eo_insert_event( $post_input, $event_data ); if ( $post_id ){ //If event was successfully inserted, redirect and display appropriate message $redirect = get_edit_post_link( $post_id, '' ); if( $status == 'publish' ) $redirect = add_query_arg( 'message', 6, $redirect ); else $redirect = add_query_arg( 'message', 7, $redirect ); //Redirect to event admin page & exit wp_redirect( $redirect ); exit; } }elseif ( isset( $_REQUEST['action'] ) && ( $_REQUEST['action'] == 'delete_occurrence' || $_REQUEST['action'] == 'break_series') && isset( $_REQUEST['series'] ) && isset( $_REQUEST['event'] ) ){ $post_id = intval( $_REQUEST['series'] ); $event_id = intval( $_REQUEST['event'] ); $action = $_REQUEST['action']; if ( $action == 'break_series' ): //Check nonce check_admin_referer( 'eventorganiser_break_series_'.$event_id ); //Check permissions if ( !current_user_can( 'edit_event', $post_id ) || !current_user_can( 'delete_event', $post_id ) ) wp_die( __( 'You do not have sufficient permissions to edit this event', 'eventorganiser' ) ); $new_event_id = eo_break_occurrence( $post_id, $event_id ); //Redirect to prevent resubmisson $redirect = get_edit_post_link( $new_event_id, '' ); $redirect = add_query_arg( 'message', 20, $redirect ); wp_redirect( $redirect ); exit; elseif( $action == 'delete_occurrence' ): global $EO_Errors; //Check nonce check_admin_referer( 'eventorganiser_delete_occurrence_'.$event_id ); //Check permissions if ( ! current_user_can( 'delete_event', $post_id ) ) wp_die( __( 'You do not have sufficient permissions to delete this event', 'eventorganiser' ) ); $response = _eventorganiser_remove_occurrence( $post_id, $event_id ); //Break Cache! _eventorganiser_delete_calendar_cache(); if ( is_wp_error( $response ) ){ $EO_Errors = $response; } else { $EO_Errors = new WP_Error( 'eo_notice', ''.__( 'Occurrence deleted.', 'eventorganiser' ).'' ); } endif; } } function screen_options( $options, $screen ){ $options .= '