Advertisement
Guest User

How to shortcode ai1ec step 4

a guest
Dec 20th, 2011
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. /**
  2.      * view shortcode function
  3.      *
  4.      * Display requested calendar page.
  5.      *
  6.      * @return void
  7.      **/
  8.     function view_shortcode($atts)
  9.     {
  10.  
  11.         global $ai1ec_view_helper,
  12.                $ai1ec_settings,
  13.                $ai1ec_events_helper;
  14.  
  15.         If($atts){
  16.             extract( $atts );   }
  17.         $this->process_request();
  18.  
  19.         // Set body class
  20.         add_filter( 'body_class', array( &$this, 'body_class' ) );
  21.         // Queue any styles, scripts
  22.         $this->load_css();
  23.         $this->load_js();
  24.  
  25.       $post_ids = array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' );
  26.         // Define arguments for specific calendar sub-view (month, agenda, etc.)
  27.         $args = array(
  28.             'active_event' => $this->request['ai1ec_active_event'],
  29.           'post_ids'     => $post_ids,
  30.         );
  31.  
  32.         // Find out which view of the calendar page was requested
  33.         switch( $this->request['action'] )
  34.         {
  35.             case 'ai1ec_month':
  36.                 $args['month_offset'] = $this->request['ai1ec_month_offset'];
  37.                 $view = $this->get_month_view( $args );
  38.                 break;
  39.  
  40.             case 'ai1ec_week':
  41.                 $args['week_offset'] = $this->request['ai1ec_week_offset'];
  42.                 $view = $this->get_week_view( $args );
  43.                 break;
  44.  
  45.             case 'ai1ec_agenda':
  46.                 $args['page_offset'] = $this->request['ai1ec_page_offset'];
  47.                 $view = $this->get_agenda_view( $args );
  48.                 break;
  49.         }
  50.  
  51.       if( $ai1ec_settings->show_create_event_button && current_user_can( 'edit_ai1ec_events' ) )
  52.         $create_event_url = admin_url( 'post-new.php?post_type=' . AI1EC_POST_TYPE );
  53.       else
  54.         $create_event_url = false;
  55.  
  56.       // Validate preselected category/tag/post IDs
  57.       $cat_ids  = join( ',', array_filter( explode( ',', $this->request['ai1ec_cat_ids'] ), 'is_numeric' ) );
  58.       $tag_ids  = join( ',', array_filter( explode( ',', $this->request['ai1ec_tag_ids'] ), 'is_numeric' ) );
  59.       $post_ids = join( ',', $post_ids );
  60.  
  61.         If($cat_ids){
  62.                 $cat_ids  = cat_ids . join( ',', array_filter( explode( ',', $cat ), 'is_numeric' ) );
  63.             }
  64.             else
  65.             {
  66.                 $cat_ids  = join( ',', array_filter( explode( ',', $cat ), 'is_numeric' ) );
  67.             }
  68.  
  69.         If($tag_ids){
  70.                 $tag_ids  = tag_ids . join( ',', array_filter( explode( ',', $tag ), 'is_numeric' ) );
  71.             }
  72.             else
  73.             {
  74.                 $tag_ids  = join( ',', array_filter( explode( ',', $tag ), 'is_numeric' ) );
  75.             }
  76.  
  77.       $categories = get_terms( 'events_categories', array( 'orderby' => 'name' ) );
  78.     foreach( $categories as &$cat ) {
  79.       $cat->color = $ai1ec_events_helper->get_category_color_square( $cat->term_id );
  80.     }
  81.         // Define new arguments for overall calendar view
  82.         $args = array(
  83.             'view'                    => $view,
  84.             'create_event_url'        => $create_event_url,
  85.             'categories'              => $categories,
  86.             'tags'                    => get_terms( 'events_tags', array( 'orderby' => 'name' ) ),
  87.             'selected_cat_ids'        => $cat_ids,
  88.             'selected_tag_ids'        => $tag_ids,
  89.             'selected_post_ids'       => $post_ids,
  90.             'show_subscribe_buttons'  => ! $ai1ec_settings->turn_off_subscription_buttons
  91.         );
  92.         // Feed month view into generic calendar view
  93.         echo apply_filters( 'ai1ec_view', $ai1ec_view_helper->get_view( 'calendar.php', $args ), $args );
  94.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement