PluginProbe
WP Ultimate Post Grid / 2.0
WP Ultimate Post Grid v2.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | helpers/shortcodes/grid_shortcode.php +24 -94 2.7.02.0 View file →
@@ -25,106 +25,41 @@
25 25 // Check if we need to filter the grid dynamically
26 26 $dynamic_rules = array();
27 27 if( count( $options ) > 0 && WPUltimatePostGrid::is_premium_active() ) {
28 28
29 - // Term Grid.
30 - if ( $grid->type() == 'terms' ) {
31 - if( isset( $options['term_id'] ) ) {
32 - $term_ids = str_replace( ',', ';', $options['term_id'] );
33 - $term_ids = str_replace( 'current_term', get_queried_object_id(), $term_ids );
29 + if( isset( $options['post_id'] ) ) {
30 + $dynamic_rules[] = array(
31 + 'post_type' => 'wpupg_general',
32 + 'taxonomy' => 'id',
33 + 'values' => explode( ';', str_replace( ',', ';', $options['post_id'] ) ),
34 + 'type' => 'restrict',
35 + );
36 + unset( $options['post_id'] );
37 + }
34 38
35 - $dynamic_rules = array(
36 - 'values' => explode( ';', $term_ids ),
37 - 'type' => 'restrict',
38 - );
39 - unset( $options['term_id'] );
40 - }
39 + if( isset( $options['exclude_post_id'] ) ) {
40 + $dynamic_rules[] = array(
41 + 'post_type' => 'wpupg_general',
42 + 'taxonomy' => 'id',
43 + 'values' => explode( ';', str_replace( ',', ';', $options['exclude_post_id'] ) ),
44 + 'type' => 'exclude',
45 + );
46 + unset( $options['exclude_post_id'] );
47 + }
41 48
42 - if( isset( $options['exclude_term_id'] ) ) {
43 - $term_ids = str_replace( ',', ';', $options['exclude_term_id'] );
44 - $term_ids = str_replace( 'current_term', get_queried_object_id(), $term_ids );
45 -
46 - $dynamic_rules = array(
47 - 'values' => explode( ';', $term_ids ),
48 - 'type' => 'exclude',
49 - );
50 - unset( $options['exclude_term_id'] );
51 - }
52 - } else {
53 - // Post Grid.
54 - if( isset( $options['post_id'] ) ) {
55 - $post_ids = str_replace( ',', ';', $options['post_id'] );
56 - $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
57 -
49 + foreach( $options as $taxonomy => $terms ) {
50 + if( taxonomy_exists( $taxonomy ) ) {
58 51 $dynamic_rules[] = array(
59 - 'post_type' => 'wpupg_general',
60 - 'taxonomy' => 'id',
61 - 'values' => explode( ';', $post_ids ),
52 + 'post_type' => 'wpupg_dynamic',
53 + 'taxonomy' => $taxonomy,
54 + 'values' => explode( ';', str_replace( ',', ';', $terms ) ),
62 55 'type' => 'restrict',
63 56 );
64 - unset( $options['post_id'] );
65 57 }
66 -
67 - if( isset( $options['exclude_post_id'] ) ) {
68 - $post_ids = str_replace( ',', ';', $options['exclude_post_id'] );
69 - $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
70 -
71 - $dynamic_rules[] = array(
72 - 'post_type' => 'wpupg_general',
73 - 'taxonomy' => 'id',
74 - 'values' => explode( ';', $post_ids ),
75 - 'type' => 'exclude',
76 - );
77 - unset( $options['exclude_post_id'] );
78 - }
79 -
80 - if( isset( $options['author'] ) ) {
81 - $author_ids = str_replace( ',', ';', $options['author'] );
82 - $author_ids = str_replace( 'current_user', get_current_user_id(), $author_ids );
83 -
84 - $dynamic_rules[] = array(
85 - 'post_type' => 'wpupg_general',
86 - 'taxonomy' => 'author',
87 - 'values' => explode( ';', $author_ids ),
88 - 'type' => 'restrict',
89 - );
90 - unset( $options['author'] );
91 - }
92 -
93 - if( isset( $options['exclude_author'] ) ) {
94 - $author_ids = str_replace( ',', ';', $options['exclude_author'] );
95 - $author_ids = str_replace( 'current_user', get_current_user_id(), $author_ids );
96 -
97 - $dynamic_rules[] = array(
98 - 'post_type' => 'wpupg_general',
99 - 'taxonomy' => 'author',
100 - 'values' => explode( ';', $author_ids ),
101 - 'type' => 'exclude',
102 - );
103 - unset( $options['exclude_author'] );
104 - }
105 -
106 - foreach( $options as $taxonomy => $terms ) {
107 - if( taxonomy_exists( $taxonomy ) ) {
108 - $dynamic_rules[] = array(
109 - 'post_type' => 'wpupg_dynamic',
110 - 'taxonomy' => $taxonomy,
111 - 'values' => explode( ';', str_replace( ',', ';', $terms ) ),
112 - 'type' => 'restrict',
113 - );
114 - }
115 - }
116 58 }
117 59 }
118 - if( count( $dynamic_rules ) > 0 || 'rand' === $grid->order_by() ) {
60 + if( count( $dynamic_rules ) > 0 ) {
119 61 $grid->set_dynamic_rules( $dynamic_rules );
120 - } else if ( WPUltimatePostGrid::option( 'cache_reset_front_end', '1' ) == '1' ) {
121 - // Make sure latest version of grid is shown.
122 - $grid_ids = get_option( 'wpupg_regenerate_grids_check', false );
123 -
124 - if( $grid_ids && in_array( $grid->ID(), $grid_ids ) ) {
125 - WPUltimatePostGrid::get()->helper( 'grid_cache' )->generate( $grid->ID() );
126 - }
127 62 }
128 63
129 64 $link_type = $grid->link_type();
130 65 $link_target = $grid->link_target();
@@ -135,13 +70,8 @@
135 70 $posts .= $grid->draw_posts();
136 71 $posts .= '</div>';
137 72
138 73 $output = apply_filters( 'wpupg_posts_shortcode', $posts, $grid );
139 -
140 - // Message when no items match filter
141 - if( $grid->empty_message() ) {
142 - $output .= '<div id="wpupg-grid-' . esc_attr( $slug ) . '-empty" class="wpupg-grid-empty">' . $grid->empty_message() . '</div>';
143 - }
144 74
145 75 $pagination = '';
146 76 if( $grid->pagination_type() == 'pages' ) {
147 77 $pagination_type = $grid->pagination_type();