PluginProbe
WP Ultimate Post Grid / 2.4.0
WP Ultimate Post Grid v2.4.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 +29 -115 2.8.02.4.0 View file →
@@ -16,142 +16,56 @@
16 16 $slug = strtolower( trim( $options['id'] ) );
17 17
18 18 if( $slug ) {
19 19 unset( $options['id'] );
20 - $no_output_mode = isset( $options['wpupg_no_output'] ) && $options['wpupg_no_output'] ? true : false;
21 - unset( $options['wpupg_no_output'] );
22 -
23 20 $post = get_page_by_path( $slug, OBJECT, WPUPG_POST_TYPE );
24 21
25 22 if( !is_null( $post ) ) {
26 - $grid = WPUPG_Grid_Manager::get( $post );
23 + $grid = new WPUPG_Grid( $post );
27 24
28 25 // Check if we need to filter the grid dynamically
29 26 $dynamic_rules = array();
30 27 if( count( $options ) > 0 && WPUltimatePostGrid::is_premium_active() ) {
31 28
32 - // Term Grid.
33 - if ( $grid->type() == 'terms' ) {
34 - if( isset( $options['term_id'] ) ) {
35 - $term_ids = str_replace( ',', ';', $options['term_id'] );
36 - $term_ids = str_replace( 'current_term', get_queried_object_id(), $term_ids );
29 + if( isset( $options['post_id'] ) ) {
30 + $post_ids = str_replace( ',', ';', $options['post_id'] );
31 + $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
37 32
38 - $dynamic_rules = array(
39 - 'values' => explode( ';', $term_ids ),
40 - 'type' => 'restrict',
41 - );
42 - unset( $options['term_id'] );
43 - }
33 + $dynamic_rules[] = array(
34 + 'post_type' => 'wpupg_general',
35 + 'taxonomy' => 'id',
36 + 'values' => explode( ';', $post_ids ),
37 + 'type' => 'restrict',
38 + );
39 + unset( $options['post_id'] );
40 + }
44 41
45 - if( isset( $options['exclude_term_id'] ) ) {
46 - $term_ids = str_replace( ',', ';', $options['exclude_term_id'] );
47 - $term_ids = str_replace( 'current_term', get_queried_object_id(), $term_ids );
42 + if( isset( $options['exclude_post_id'] ) ) {
43 + $post_ids = str_replace( ',', ';', $options['exclude_post_id'] );
44 + $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
48 45
49 - $dynamic_rules = array(
50 - 'values' => explode( ';', $term_ids ),
51 - 'type' => 'exclude',
52 - );
53 - unset( $options['exclude_term_id'] );
54 - }
55 - } else {
56 - // Post Grid.
57 - if( isset( $options['post_id'] ) ) {
58 - $post_ids = str_replace( ',', ';', $options['post_id'] );
59 - $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
46 + $dynamic_rules[] = array(
47 + 'post_type' => 'wpupg_general',
48 + 'taxonomy' => 'id',
49 + 'values' => explode( ';', $post_ids ),
50 + 'type' => 'exclude',
51 + );
52 + unset( $options['exclude_post_id'] );
53 + }
60 54
55 + foreach( $options as $taxonomy => $terms ) {
56 + if( taxonomy_exists( $taxonomy ) ) {
61 57 $dynamic_rules[] = array(
62 - 'post_type' => 'wpupg_general',
63 - 'taxonomy' => 'id',
64 - 'values' => explode( ';', $post_ids ),
58 + 'post_type' => 'wpupg_dynamic',
59 + 'taxonomy' => $taxonomy,
60 + 'values' => explode( ';', str_replace( ',', ';', $terms ) ),
65 61 'type' => 'restrict',
66 62 );
67 - unset( $options['post_id'] );
68 63 }
69 -
70 - if( isset( $options['exclude_post_id'] ) ) {
71 - $post_ids = str_replace( ',', ';', $options['exclude_post_id'] );
72 - $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids );
73 -
74 - $dynamic_rules[] = array(
75 - 'post_type' => 'wpupg_general',
76 - 'taxonomy' => 'id',
77 - 'values' => explode( ';', $post_ids ),
78 - 'type' => 'exclude',
79 - );
80 - unset( $options['exclude_post_id'] );
81 - }
82 -
83 - if( isset( $options['author'] ) ) {
84 - $author_ids = str_replace( ',', ';', $options['author'] );
85 - $author_ids = str_replace( 'current_user', get_current_user_id(), $author_ids );
86 -
87 - $dynamic_rules[] = array(
88 - 'post_type' => 'wpupg_general',
89 - 'taxonomy' => 'author',
90 - 'values' => explode( ';', $author_ids ),
91 - 'type' => 'restrict',
92 - );
93 - unset( $options['author'] );
94 - }
95 -
96 - if( isset( $options['exclude_author'] ) ) {
97 - $author_ids = str_replace( ',', ';', $options['exclude_author'] );
98 - $author_ids = str_replace( 'current_user', get_current_user_id(), $author_ids );
99 -
100 - $dynamic_rules[] = array(
101 - 'post_type' => 'wpupg_general',
102 - 'taxonomy' => 'author',
103 - 'values' => explode( ';', $author_ids ),
104 - 'type' => 'exclude',
105 - );
106 - unset( $options['exclude_author'] );
107 - }
108 -
109 - if( isset( $options['date'] ) ) {
110 - $date_condition = str_replace( '_today', '', $options['date'] );
111 - $date_condition = in_array( $date_condition, array( 'before', 'after' ) ) ? $date_condition : 'is';
112 -
113 - $dynamic_rules[] = array(
114 - 'post_type' => 'wpupg_general',
115 - 'taxonomy' => 'date',
116 - 'values' => array( $date_condition, date( 'Y-m-d' ) ),
117 - 'type' => 'restrict',
118 - );
119 - unset( $options['date'] );
120 - }
121 -
122 - foreach( $options as $taxonomy => $terms ) {
123 - if( taxonomy_exists( $taxonomy ) ) {
124 - $dynamic_rules[] = array(
125 - 'post_type' => 'wpupg_dynamic',
126 - 'taxonomy' => $taxonomy,
127 - 'values' => explode( ';', str_replace( ',', ';', $terms ) ),
128 - 'type' => 'restrict',
129 - );
130 - } elseif( 'exclude_' === substr( $taxonomy, 0, 8 ) ) {
131 - $dynamic_rules[] = array(
132 - 'post_type' => 'wpupg_dynamic',
133 - 'taxonomy' => substr( $taxonomy, 8 ),
134 - 'values' => explode( ';', str_replace( ',', ';', $terms ) ),
135 - 'type' => 'exclude',
136 - );
137 - }
138 - }
139 64 }
140 65 }
141 - if( count( $dynamic_rules ) > 0 || 'rand' === $grid->order_by() ) {
66 + if( count( $dynamic_rules ) > 0 ) {
142 67 $grid->set_dynamic_rules( $dynamic_rules );
143 - } else if ( WPUltimatePostGrid::option( 'cache_reset_front_end', '1' ) == '1' ) {
144 - // Make sure latest version of grid is shown.
145 - $grid_ids = get_option( 'wpupg_regenerate_grids_check', false );
146 -
147 - if( $grid_ids && in_array( $grid->ID(), $grid_ids ) ) {
148 - WPUltimatePostGrid::get()->helper( 'grid_cache' )->generate( $grid->ID() );
149 - }
150 - }
151 -
152 - if ( $no_output_mode ) {
153 - return '';
154 68 }
155 69
156 70 $link_type = $grid->link_type();
157 71 $link_target = $grid->link_target();