PluginProbe
Themify Event Post / trunk
Themify Event Post vtrunk
1.3.7 trunk 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6
themify-event-post / templates / shortcode.php

shortcode.php in Themify Event Post trunk, at templates/shortcode.php

106 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 static $instance = 0;
4 $instance++;
5
6 $defaults = array(
7 'post_type' => 'event',
8 'taxonomy' => 'event-category',
9 'taxonomy_relation' => 'AND',
10 'limit' => 3,
11 'offset' => 0,
12 'category' => '0', // integer category ID
13 'orderby' => 'event_date', // date, title, rand, event_date
14 'order' => 'DESC', // ASC
15 'show' => 'upcoming',
16 'display' => 'excerpt', // excerpt, none
17 'more_link' => false, // true goes to post type archive, and admits custom link
18 'more_text' => __( 'More &rarr;', 'themify-event-post' ),
19 'style' => 'grid3', // grid4, grid2, list-post
20 'image_w' => '',
21 'image_h' => '',
22 'image_size' => 'medium',
23 'title' => 'yes', // no
24 'title_tag' => 'h2',
25 'unlink_title' => 'no',
26 'image' => 'yes', // no
27 'unlink_image' => 'no',
28 'hide_event_location' => 'no',
29 'hide_event_date' => 'no',
30 'hide_event_organizer' => 'no',
31 'hide_event_performer' => 'no',
32 'hide_event_meta' => 'no',
33 'hide_page_nav' => 'no',
34 'id' => '', /* show a single event post */
35 // templating
36 'template' => 'content',
37 'template_before' => '',
38 'template_after' => '',
39 );
40 $args = shortcode_atts( $defaults, $atts, 'themify_event_post' );
41
42 if ( ! empty( $args['id'] ) ) {
43 $args['style'] = 'list-post';
44 }
45
46 if ( empty( $args['template_before'] ) )
47 $args['template_before'] = '<div class="themify_event_post_loop ' . esc_attr( $args['style'] ) . '">';
48 if ( empty( $args['template_after'] ) )
49 $args['template_after'] = '</div>';
50
51 // Prevent XSS via user-supplied wrapper templates.
52 $args['template_before'] = themify_event_post_sanitize_template_wrapper( $args['template_before'] );
53 $args['template_after'] = themify_event_post_sanitize_template_wrapper( $args['template_after'] );
54
55 // Event Query Setup
56 $events = array();
57
58 if ( $args['show'] === 'upcoming' || $args['show'] === 'tabbed' ) { // show only future events
59 $query = new WP_Query();
60 $args['show'] = 'upcoming';
61 $events[] = $query->query( apply_filters( 'themify_event_shortcode_args', themify_event_post_parse_query( $args ) ) );
62 }
63 if ( 'past' === $args['show'] || 'tabbed' === $args['show'] ) {
64 $query = new WP_Query();
65 $args['show'] = 'past';
66 $events[] = $query->query( apply_filters( 'themify_event_shortcode_args', themify_event_post_parse_query( $args ) ) );
67 }
68 if ( 'mix' === $args['show'] ) {
69 $query = new WP_Query();
70 $events[] = $query->query( apply_filters( 'themify_event_shortcode_args', themify_event_post_parse_query( $args ) ) );
71 }
72
73 ob_start();
74 if ( $args['show'] === 'tabbed' ) {
75 ?>
76 <div class="themify-events-tabs">
77 <ul>
78 <li><a href="#themify-events-upcoming-<?php echo $instance; ?>"><?php _e( 'Upcoming', 'themify-event-post' ); ?></a></li>
79 <li><a href="#themify-events-past-<?php echo $instance; ?>"><?php _e( 'Past', 'themify-event-post' ); ?></a></li>
80 </ul>
81 <div id="themify-events-upcoming-<?php echo $instance; ?>">
82 <?php echo $args['template_before'] . $this->get_shortcode_template( $events[0], $args['template'], $args ) . $args['template_after']; ?>
83 </div>
84 <div id="themify-events-past-<?php echo $instance; ?>">
85 <?php echo $args['template_before'] . $this->get_shortcode_template( $events[1], $args['template'], $args ) . $args['template_after']; ?>
86 </div>
87 </div>
88 <?php
89 } else {
90
91 $output = $this->get_shortcode_template( $events[0], $args['template'], $args );
92 if ( $output !== '' ) {
93 echo $args['template_before'] . $output . $args['template_after'];
94 if ( $args['hide_page_nav'] === 'no' ) {
95 echo themify_event_post_pagenav( array(
96 'total_posts' => $query->found_posts,
97 'paged' => themify_event_post_get_paged_query(),
98 'offset' => (int) $args['offset'],
99 'posts_per_page' => (int) $args['limit'],
100 ) );
101 }
102 }
103
104 }
105 return ob_get_clean();
106