Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * view shortcode function
- *
- * Display requested calendar page.
- *
- * @return void
- **/
- function view_shortcode($atts)
- {
- global $ai1ec_view_helper,
- $ai1ec_settings,
- $ai1ec_events_helper;
- If($atts){
- extract( $atts ); }
- $this->process_request();
- // Set body class
- add_filter( 'body_class', array( &$this, 'body_class' ) );
- // Queue any styles, scripts
- $this->load_css();
- $this->load_js();
- $post_ids = array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' );
- // Define arguments for specific calendar sub-view (month, agenda, etc.)
- $args = array(
- 'active_event' => $this->request['ai1ec_active_event'],
- 'post_ids' => $post_ids,
- );
- // Find out which view of the calendar page was requested
- switch( $this->request['action'] )
- {
- case 'ai1ec_month':
- $args['month_offset'] = $this->request['ai1ec_month_offset'];
- $view = $this->get_month_view( $args );
- break;
- case 'ai1ec_week':
- $args['week_offset'] = $this->request['ai1ec_week_offset'];
- $view = $this->get_week_view( $args );
- break;
- case 'ai1ec_agenda':
- $args['page_offset'] = $this->request['ai1ec_page_offset'];
- $view = $this->get_agenda_view( $args );
- break;
- }
- if( $ai1ec_settings->show_create_event_button && current_user_can( 'edit_ai1ec_events' ) )
- $create_event_url = admin_url( 'post-new.php?post_type=' . AI1EC_POST_TYPE );
- else
- $create_event_url = false;
- // Validate preselected category/tag/post IDs
- $cat_ids = join( ',', array_filter( explode( ',', $this->request['ai1ec_cat_ids'] ), 'is_numeric' ) );
- $tag_ids = join( ',', array_filter( explode( ',', $this->request['ai1ec_tag_ids'] ), 'is_numeric' ) );
- $post_ids = join( ',', $post_ids );
- If($cat_ids){
- $cat_ids = cat_ids . join( ',', array_filter( explode( ',', $cat ), 'is_numeric' ) );
- }
- else
- {
- $cat_ids = join( ',', array_filter( explode( ',', $cat ), 'is_numeric' ) );
- }
- If($tag_ids){
- $tag_ids = tag_ids . join( ',', array_filter( explode( ',', $tag ), 'is_numeric' ) );
- }
- else
- {
- $tag_ids = join( ',', array_filter( explode( ',', $tag ), 'is_numeric' ) );
- }
- $categories = get_terms( 'events_categories', array( 'orderby' => 'name' ) );
- foreach( $categories as &$cat ) {
- $cat->color = $ai1ec_events_helper->get_category_color_square( $cat->term_id );
- }
- // Define new arguments for overall calendar view
- $args = array(
- 'view' => $view,
- 'create_event_url' => $create_event_url,
- 'categories' => $categories,
- 'tags' => get_terms( 'events_tags', array( 'orderby' => 'name' ) ),
- 'selected_cat_ids' => $cat_ids,
- 'selected_tag_ids' => $tag_ids,
- 'selected_post_ids' => $post_ids,
- 'show_subscribe_buttons' => ! $ai1ec_settings->turn_off_subscription_buttons
- );
- // Feed month view into generic calendar view
- echo apply_filters( 'ai1ec_view', $ai1ec_view_helper->get_view( 'calendar.php', $args ), $args );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement