@@ -13,241 +13,241 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class geodir_cpt_categories_widget extends WP_Widget { |
15 | 15 | |
16 | - /** |
|
17 | - * Register the cpt categories with WordPress. |
|
18 | - * |
|
19 | - * @since 1.5.4 |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - $widget_ops = array('classname' => 'geodir_cpt_categories_widget', 'description' => __('A list of GeoDirectory CPT categories.', 'geodirectory')); |
|
23 | - parent::__construct('geodir_cpt_categories_widget', __('GD > CPT Categories', 'geodirectory'), $widget_ops); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * Front-end display content for cpt categories widget. |
|
28 | - * |
|
29 | - * @since 1.5.4 |
|
30 | - * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
31 | - * |
|
32 | - * @param array $args Widget arguments. |
|
33 | - * @param array $instance Saved values from database. |
|
34 | - */ |
|
35 | - public function widget($args, $instance) { |
|
36 | - $params = array(); |
|
37 | - /** |
|
38 | - * Filter the widget title. |
|
39 | - * |
|
40 | - * @since 1.5.4 |
|
41 | - * |
|
42 | - * @param string $title The widget title. Default empty. |
|
43 | - * @param array $instance An array of the widget's settings. |
|
44 | - * @param mixed $id_base The widget ID. |
|
45 | - */ |
|
46 | - $params['title'] = apply_filters('geodir_cpt_categories_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
|
47 | - |
|
48 | - /** |
|
49 | - * Filter the widget setting post type. |
|
50 | - * |
|
51 | - * @since 1.5.4 |
|
52 | - * |
|
53 | - * @param array $post_type The post types to display categories. |
|
54 | - * @param array $instance An array of the widget's settings. |
|
55 | - * @param mixed $id_base The widget ID. |
|
56 | - */ |
|
57 | - $params['post_type'] = apply_filters('geodir_cpt_categories_widget_post_type', empty($instance['post_type']) ? array() : $instance['post_type'], $instance, $this->id_base); |
|
58 | - |
|
59 | - /** |
|
60 | - * Filter the widget setting to hide empty categories. |
|
61 | - * |
|
62 | - * @since 1.5.4 |
|
63 | - * |
|
64 | - * @param bool $hide_empty If true then empty category will be not displayed. |
|
65 | - * @param array $instance An array of the widget's settings. |
|
66 | - * @param mixed $id_base The widget ID. |
|
67 | - */ |
|
68 | - $params['hide_empty'] = apply_filters('geodir_cpt_categories_widget_hide_empty', empty($instance['hide_empty']) ? 0 : 1, $instance, $this->id_base); |
|
69 | - |
|
70 | - /** |
|
71 | - * Filter the widget setting to show/hide category count. |
|
72 | - * |
|
73 | - * @since 1.5.4 |
|
74 | - * |
|
75 | - * @param bool $show_count If true then category count will be displayed. |
|
76 | - * @param array $instance An array of the widget's settings. |
|
77 | - * @param mixed $id_base The widget ID. |
|
78 | - */ |
|
79 | - $params['show_count'] = apply_filters('geodir_cpt_categories_widget_show_count', empty($instance['show_count']) ? 0 : 1, $instance, $this->id_base); |
|
80 | - |
|
81 | - /** |
|
82 | - * Filter the widget setting to show/hide category icon. |
|
83 | - * |
|
84 | - * @since 1.5.4 |
|
85 | - * |
|
86 | - * @param bool $hide_icon If true then category icon will be not displayed. |
|
87 | - * @param array $instance An array of the widget's settings. |
|
88 | - * @param mixed $id_base The widget ID. |
|
89 | - */ |
|
90 | - $params['hide_icon'] = apply_filters('geodir_cpt_categories_widget_hide_icon', empty($instance['hide_icon']) ? 0 : 1, $instance, $this->id_base); |
|
91 | - |
|
92 | - /** |
|
93 | - * Filter the widget setting to show CPT inline or not. |
|
94 | - * |
|
95 | - * @since 1.5.4 |
|
96 | - * |
|
97 | - * @param bool $cpt_left If true then CPT will be displayed inline. |
|
98 | - * @param array $instance An array of the widget's settings. |
|
99 | - * @param mixed $id_base The widget ID. |
|
100 | - */ |
|
101 | - $params['cpt_left'] = apply_filters('geodir_cpt_categories_widget_cpt_left', empty($instance['cpt_left']) ? 0 : 1, $instance, $this->id_base); |
|
102 | - |
|
103 | - /** |
|
104 | - * Filter the widget categories sorting order settings. |
|
105 | - * |
|
106 | - * @since 1.5.4 |
|
107 | - * |
|
108 | - * @param string $max_count Widget max no of sub-categories count. Default 'count'. |
|
109 | - * @param array $instance An array of the widget's settings. |
|
110 | - * @param mixed $id_base The widget ID. |
|
111 | - */ |
|
112 | - $params['sort_by'] = apply_filters('geodir_cpt_categories_widget_sort_by', isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count', $instance, $this->id_base); |
|
113 | - |
|
114 | - /** |
|
115 | - * Filter the widget max no of sub-categories count. |
|
116 | - * |
|
117 | - * @since 1.5.4 |
|
118 | - * |
|
119 | - * @param bool|string $max_count Widget max no of sub-categories count. |
|
120 | - * @param array $instance An array of the widget's settings. |
|
121 | - * @param mixed $id_base The widget ID. |
|
122 | - */ |
|
123 | - $params['max_count'] = apply_filters('geodir_cpt_categories_widget_max_count', !isset($instance['max_count']) ? 'all' : strip_tags($instance['max_count']), $instance, $this->id_base); |
|
124 | - |
|
125 | - /** |
|
126 | - * Filter the widget max sub-categories depth. |
|
127 | - * |
|
128 | - * @since 1.5.4 |
|
129 | - * |
|
130 | - * @param bool|string $max_level Widget max sub-categories depth. |
|
131 | - * @param array $instance An array of the widget's settings. |
|
132 | - * @param mixed $id_base The widget ID. |
|
133 | - */ |
|
134 | - $params['max_level'] = apply_filters('geodir_cpt_categories_widget_max_level', !isset($instance['max_level']) ? 'all' : strip_tags($instance['max_level']), $instance, $this->id_base); |
|
16 | + /** |
|
17 | + * Register the cpt categories with WordPress. |
|
18 | + * |
|
19 | + * @since 1.5.4 |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + $widget_ops = array('classname' => 'geodir_cpt_categories_widget', 'description' => __('A list of GeoDirectory CPT categories.', 'geodirectory')); |
|
23 | + parent::__construct('geodir_cpt_categories_widget', __('GD > CPT Categories', 'geodirectory'), $widget_ops); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * Front-end display content for cpt categories widget. |
|
28 | + * |
|
29 | + * @since 1.5.4 |
|
30 | + * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
31 | + * |
|
32 | + * @param array $args Widget arguments. |
|
33 | + * @param array $instance Saved values from database. |
|
34 | + */ |
|
35 | + public function widget($args, $instance) { |
|
36 | + $params = array(); |
|
37 | + /** |
|
38 | + * Filter the widget title. |
|
39 | + * |
|
40 | + * @since 1.5.4 |
|
41 | + * |
|
42 | + * @param string $title The widget title. Default empty. |
|
43 | + * @param array $instance An array of the widget's settings. |
|
44 | + * @param mixed $id_base The widget ID. |
|
45 | + */ |
|
46 | + $params['title'] = apply_filters('geodir_cpt_categories_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); |
|
47 | + |
|
48 | + /** |
|
49 | + * Filter the widget setting post type. |
|
50 | + * |
|
51 | + * @since 1.5.4 |
|
52 | + * |
|
53 | + * @param array $post_type The post types to display categories. |
|
54 | + * @param array $instance An array of the widget's settings. |
|
55 | + * @param mixed $id_base The widget ID. |
|
56 | + */ |
|
57 | + $params['post_type'] = apply_filters('geodir_cpt_categories_widget_post_type', empty($instance['post_type']) ? array() : $instance['post_type'], $instance, $this->id_base); |
|
58 | + |
|
59 | + /** |
|
60 | + * Filter the widget setting to hide empty categories. |
|
61 | + * |
|
62 | + * @since 1.5.4 |
|
63 | + * |
|
64 | + * @param bool $hide_empty If true then empty category will be not displayed. |
|
65 | + * @param array $instance An array of the widget's settings. |
|
66 | + * @param mixed $id_base The widget ID. |
|
67 | + */ |
|
68 | + $params['hide_empty'] = apply_filters('geodir_cpt_categories_widget_hide_empty', empty($instance['hide_empty']) ? 0 : 1, $instance, $this->id_base); |
|
69 | + |
|
70 | + /** |
|
71 | + * Filter the widget setting to show/hide category count. |
|
72 | + * |
|
73 | + * @since 1.5.4 |
|
74 | + * |
|
75 | + * @param bool $show_count If true then category count will be displayed. |
|
76 | + * @param array $instance An array of the widget's settings. |
|
77 | + * @param mixed $id_base The widget ID. |
|
78 | + */ |
|
79 | + $params['show_count'] = apply_filters('geodir_cpt_categories_widget_show_count', empty($instance['show_count']) ? 0 : 1, $instance, $this->id_base); |
|
80 | + |
|
81 | + /** |
|
82 | + * Filter the widget setting to show/hide category icon. |
|
83 | + * |
|
84 | + * @since 1.5.4 |
|
85 | + * |
|
86 | + * @param bool $hide_icon If true then category icon will be not displayed. |
|
87 | + * @param array $instance An array of the widget's settings. |
|
88 | + * @param mixed $id_base The widget ID. |
|
89 | + */ |
|
90 | + $params['hide_icon'] = apply_filters('geodir_cpt_categories_widget_hide_icon', empty($instance['hide_icon']) ? 0 : 1, $instance, $this->id_base); |
|
91 | + |
|
92 | + /** |
|
93 | + * Filter the widget setting to show CPT inline or not. |
|
94 | + * |
|
95 | + * @since 1.5.4 |
|
96 | + * |
|
97 | + * @param bool $cpt_left If true then CPT will be displayed inline. |
|
98 | + * @param array $instance An array of the widget's settings. |
|
99 | + * @param mixed $id_base The widget ID. |
|
100 | + */ |
|
101 | + $params['cpt_left'] = apply_filters('geodir_cpt_categories_widget_cpt_left', empty($instance['cpt_left']) ? 0 : 1, $instance, $this->id_base); |
|
102 | + |
|
103 | + /** |
|
104 | + * Filter the widget categories sorting order settings. |
|
105 | + * |
|
106 | + * @since 1.5.4 |
|
107 | + * |
|
108 | + * @param string $max_count Widget max no of sub-categories count. Default 'count'. |
|
109 | + * @param array $instance An array of the widget's settings. |
|
110 | + * @param mixed $id_base The widget ID. |
|
111 | + */ |
|
112 | + $params['sort_by'] = apply_filters('geodir_cpt_categories_widget_sort_by', isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count', $instance, $this->id_base); |
|
113 | + |
|
114 | + /** |
|
115 | + * Filter the widget max no of sub-categories count. |
|
116 | + * |
|
117 | + * @since 1.5.4 |
|
118 | + * |
|
119 | + * @param bool|string $max_count Widget max no of sub-categories count. |
|
120 | + * @param array $instance An array of the widget's settings. |
|
121 | + * @param mixed $id_base The widget ID. |
|
122 | + */ |
|
123 | + $params['max_count'] = apply_filters('geodir_cpt_categories_widget_max_count', !isset($instance['max_count']) ? 'all' : strip_tags($instance['max_count']), $instance, $this->id_base); |
|
124 | + |
|
125 | + /** |
|
126 | + * Filter the widget max sub-categories depth. |
|
127 | + * |
|
128 | + * @since 1.5.4 |
|
129 | + * |
|
130 | + * @param bool|string $max_level Widget max sub-categories depth. |
|
131 | + * @param array $instance An array of the widget's settings. |
|
132 | + * @param mixed $id_base The widget ID. |
|
133 | + */ |
|
134 | + $params['max_level'] = apply_filters('geodir_cpt_categories_widget_max_level', !isset($instance['max_level']) ? 'all' : strip_tags($instance['max_level']), $instance, $this->id_base); |
|
135 | 135 | |
136 | - /** |
|
137 | - * Filter the widget setting to disable filter current viewing post type. |
|
138 | - * |
|
139 | - * @since 1.6.6 |
|
140 | - * |
|
141 | - * @param bool $no_cpt_filter If true then it doesn't filter current viewing post type. |
|
142 | - * @param array $instance An array of the widget's settings. |
|
143 | - * @param mixed $id_base The widget ID. |
|
144 | - */ |
|
145 | - $params['no_cpt_filter'] = apply_filters('geodir_cpt_categories_widget_no_cpt_filter', empty($instance['no_cpt_filter']) ? 0 : 1, $instance, $this->id_base); |
|
136 | + /** |
|
137 | + * Filter the widget setting to disable filter current viewing post type. |
|
138 | + * |
|
139 | + * @since 1.6.6 |
|
140 | + * |
|
141 | + * @param bool $no_cpt_filter If true then it doesn't filter current viewing post type. |
|
142 | + * @param array $instance An array of the widget's settings. |
|
143 | + * @param mixed $id_base The widget ID. |
|
144 | + */ |
|
145 | + $params['no_cpt_filter'] = apply_filters('geodir_cpt_categories_widget_no_cpt_filter', empty($instance['no_cpt_filter']) ? 0 : 1, $instance, $this->id_base); |
|
146 | 146 | |
147 | - /** |
|
148 | - * Filter the widget setting to disable current viewing category. |
|
149 | - * |
|
150 | - * @since 1.6.6 |
|
151 | - * |
|
152 | - * @param bool $no_cat_filter If true then it doesn't filter current viewing category. |
|
153 | - * @param array $instance An array of the widget's settings. |
|
154 | - * @param mixed $id_base The widget ID. |
|
155 | - */ |
|
156 | - $params['no_cat_filter'] = apply_filters('geodir_cpt_categories_widget_no_cat_filter', empty($instance['no_cat_filter']) ? 0 : 1, $instance, $this->id_base); |
|
157 | - |
|
158 | - /** |
|
159 | - * Filter the widget parameters. |
|
160 | - * |
|
161 | - * @since 1.5.4 |
|
162 | - * |
|
163 | - * @param array $params The widget parameters. |
|
164 | - * @param array $instance An array of the widget's settings. |
|
165 | - * @param mixed $id_base The widget ID. |
|
166 | - */ |
|
167 | - $params = apply_filters('geodir_cpt_categories_widget_params', $params, $instance, $this->id_base); |
|
168 | - |
|
169 | - $output = geodir_cpt_categories_output($params); |
|
170 | - |
|
171 | - echo $args['before_widget']; |
|
172 | - if ( $params['title'] ) { |
|
173 | - echo '<div class="geodir_list_heading clearfix">'; |
|
174 | - echo $args['before_title'] . $params['title'] . $args['after_title']; |
|
175 | - echo '</div>'; |
|
176 | - } |
|
177 | - echo '<div class="gd-cptcats-widget">'; |
|
178 | - echo $output; |
|
179 | - echo '</div>'; |
|
180 | - echo $args['after_widget']; |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Sanitize cpt categories widget values as they are saved. |
|
185 | - * |
|
186 | - * @since 1.5.4 |
|
187 | - * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
188 | - * |
|
189 | - * @param array $new_instance Values just sent to be saved. |
|
190 | - * @param array $old_instance Previously saved values from database. |
|
191 | - * |
|
192 | - * @return array Updated safe values to be saved. |
|
193 | - */ |
|
194 | - public function update($new_instance, $old_instance) { |
|
195 | - $new_instance['post_type'] = is_array($new_instance['post_type']) && in_array('0', $new_instance['post_type']) ? array('0') : $new_instance['post_type']; |
|
196 | - $instance = $old_instance; |
|
197 | - $instance['title'] = strip_tags($new_instance['title']); |
|
198 | - $instance['post_type'] = isset($new_instance['post_type']) ? $new_instance['post_type'] : array('0'); |
|
199 | - $instance['hide_empty'] = !empty($new_instance['hide_empty']) ? 1 : 0; |
|
200 | - $instance['show_count'] = !empty($new_instance['show_count']) ? 1 : 0; |
|
201 | - $instance['hide_icon'] = !empty($new_instance['hide_icon']) ? 1 : 0; |
|
202 | - $instance['cpt_left'] = !empty($new_instance['cpt_left']) ? 1 : 0; |
|
203 | - $instance['sort_by'] = isset($new_instance['sort_by']) && in_array($new_instance['sort_by'], array('az', 'count')) ? $new_instance['sort_by'] : 'count'; |
|
204 | - $instance['max_count'] = strip_tags($new_instance['max_count']); |
|
205 | - $instance['max_level'] = strip_tags($new_instance['max_level']); |
|
206 | - $instance['no_cpt_filter'] = !empty($new_instance['no_cpt_filter']) ? 1 : 0; |
|
207 | - $instance['no_cat_filter'] = !empty($new_instance['no_cat_filter']) ? 1 : 0; |
|
208 | - |
|
209 | - return $instance; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Back-end cpt categories settings form. |
|
214 | - * |
|
215 | - * @since 1.5.4 |
|
216 | - * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
217 | - * |
|
218 | - * @param array $instance Previously saved values from database. |
|
219 | - */ |
|
220 | - public function form($instance) { |
|
221 | - $instance = wp_parse_args( (array)$instance, |
|
222 | - array( |
|
223 | - 'title' => '', |
|
224 | - 'post_type' => array(), // NULL for all |
|
225 | - 'hide_empty' => '', |
|
226 | - 'show_count' => '', |
|
227 | - 'hide_icon' => '', |
|
228 | - 'cpt_left' => '', |
|
229 | - 'sort_by' => 'count', |
|
230 | - 'max_count' => 'all', |
|
231 | - 'max_level' => '1', |
|
232 | - 'no_cpt_filter' => '', |
|
233 | - 'no_cat_filter' => '', |
|
234 | - ) |
|
235 | - ); |
|
236 | - |
|
237 | - $title = strip_tags($instance['title']); |
|
238 | - $post_type = $instance['post_type']; |
|
239 | - $hide_empty = !empty($instance['hide_empty']) ? true : false; |
|
240 | - $show_count = !empty($instance['show_count']) ? true : false; |
|
241 | - $hide_icon = !empty($instance['hide_icon']) ? true : false; |
|
242 | - $cpt_left = !empty($instance['cpt_left']) ? true : false; |
|
243 | - $max_count = strip_tags($instance['max_count']); |
|
244 | - $max_level = strip_tags($instance['max_level']); |
|
245 | - $sort_by = isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count'; |
|
246 | - $no_cpt_filter = !empty($instance['no_cpt_filter']) ? true : false; |
|
247 | - $no_cat_filter = !empty($instance['no_cat_filter']) ? true : false; |
|
248 | - |
|
249 | - $post_type_options = geodir_get_posttypes('options'); |
|
250 | - ?> |
|
147 | + /** |
|
148 | + * Filter the widget setting to disable current viewing category. |
|
149 | + * |
|
150 | + * @since 1.6.6 |
|
151 | + * |
|
152 | + * @param bool $no_cat_filter If true then it doesn't filter current viewing category. |
|
153 | + * @param array $instance An array of the widget's settings. |
|
154 | + * @param mixed $id_base The widget ID. |
|
155 | + */ |
|
156 | + $params['no_cat_filter'] = apply_filters('geodir_cpt_categories_widget_no_cat_filter', empty($instance['no_cat_filter']) ? 0 : 1, $instance, $this->id_base); |
|
157 | + |
|
158 | + /** |
|
159 | + * Filter the widget parameters. |
|
160 | + * |
|
161 | + * @since 1.5.4 |
|
162 | + * |
|
163 | + * @param array $params The widget parameters. |
|
164 | + * @param array $instance An array of the widget's settings. |
|
165 | + * @param mixed $id_base The widget ID. |
|
166 | + */ |
|
167 | + $params = apply_filters('geodir_cpt_categories_widget_params', $params, $instance, $this->id_base); |
|
168 | + |
|
169 | + $output = geodir_cpt_categories_output($params); |
|
170 | + |
|
171 | + echo $args['before_widget']; |
|
172 | + if ( $params['title'] ) { |
|
173 | + echo '<div class="geodir_list_heading clearfix">'; |
|
174 | + echo $args['before_title'] . $params['title'] . $args['after_title']; |
|
175 | + echo '</div>'; |
|
176 | + } |
|
177 | + echo '<div class="gd-cptcats-widget">'; |
|
178 | + echo $output; |
|
179 | + echo '</div>'; |
|
180 | + echo $args['after_widget']; |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Sanitize cpt categories widget values as they are saved. |
|
185 | + * |
|
186 | + * @since 1.5.4 |
|
187 | + * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
188 | + * |
|
189 | + * @param array $new_instance Values just sent to be saved. |
|
190 | + * @param array $old_instance Previously saved values from database. |
|
191 | + * |
|
192 | + * @return array Updated safe values to be saved. |
|
193 | + */ |
|
194 | + public function update($new_instance, $old_instance) { |
|
195 | + $new_instance['post_type'] = is_array($new_instance['post_type']) && in_array('0', $new_instance['post_type']) ? array('0') : $new_instance['post_type']; |
|
196 | + $instance = $old_instance; |
|
197 | + $instance['title'] = strip_tags($new_instance['title']); |
|
198 | + $instance['post_type'] = isset($new_instance['post_type']) ? $new_instance['post_type'] : array('0'); |
|
199 | + $instance['hide_empty'] = !empty($new_instance['hide_empty']) ? 1 : 0; |
|
200 | + $instance['show_count'] = !empty($new_instance['show_count']) ? 1 : 0; |
|
201 | + $instance['hide_icon'] = !empty($new_instance['hide_icon']) ? 1 : 0; |
|
202 | + $instance['cpt_left'] = !empty($new_instance['cpt_left']) ? 1 : 0; |
|
203 | + $instance['sort_by'] = isset($new_instance['sort_by']) && in_array($new_instance['sort_by'], array('az', 'count')) ? $new_instance['sort_by'] : 'count'; |
|
204 | + $instance['max_count'] = strip_tags($new_instance['max_count']); |
|
205 | + $instance['max_level'] = strip_tags($new_instance['max_level']); |
|
206 | + $instance['no_cpt_filter'] = !empty($new_instance['no_cpt_filter']) ? 1 : 0; |
|
207 | + $instance['no_cat_filter'] = !empty($new_instance['no_cat_filter']) ? 1 : 0; |
|
208 | + |
|
209 | + return $instance; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Back-end cpt categories settings form. |
|
214 | + * |
|
215 | + * @since 1.5.4 |
|
216 | + * @since 1.6.6 New parameters $no_cpt_filter &no_cat_filter added. |
|
217 | + * |
|
218 | + * @param array $instance Previously saved values from database. |
|
219 | + */ |
|
220 | + public function form($instance) { |
|
221 | + $instance = wp_parse_args( (array)$instance, |
|
222 | + array( |
|
223 | + 'title' => '', |
|
224 | + 'post_type' => array(), // NULL for all |
|
225 | + 'hide_empty' => '', |
|
226 | + 'show_count' => '', |
|
227 | + 'hide_icon' => '', |
|
228 | + 'cpt_left' => '', |
|
229 | + 'sort_by' => 'count', |
|
230 | + 'max_count' => 'all', |
|
231 | + 'max_level' => '1', |
|
232 | + 'no_cpt_filter' => '', |
|
233 | + 'no_cat_filter' => '', |
|
234 | + ) |
|
235 | + ); |
|
236 | + |
|
237 | + $title = strip_tags($instance['title']); |
|
238 | + $post_type = $instance['post_type']; |
|
239 | + $hide_empty = !empty($instance['hide_empty']) ? true : false; |
|
240 | + $show_count = !empty($instance['show_count']) ? true : false; |
|
241 | + $hide_icon = !empty($instance['hide_icon']) ? true : false; |
|
242 | + $cpt_left = !empty($instance['cpt_left']) ? true : false; |
|
243 | + $max_count = strip_tags($instance['max_count']); |
|
244 | + $max_level = strip_tags($instance['max_level']); |
|
245 | + $sort_by = isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count'; |
|
246 | + $no_cpt_filter = !empty($instance['no_cpt_filter']) ? true : false; |
|
247 | + $no_cat_filter = !empty($instance['no_cat_filter']) ? true : false; |
|
248 | + |
|
249 | + $post_type_options = geodir_get_posttypes('options'); |
|
250 | + ?> |
|
251 | 251 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> |
252 | 252 | <p> |
253 | 253 | <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Select CPT:', 'geodirectory'); ?></label> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | <label for="<?php echo $this->get_field_id('no_cat_filter'); ?>"><?php _e( 'Don\'t filter for current viewing category', 'geodirectory' ); ?></label> |
299 | 299 | </p> |
300 | 300 | <?php |
301 | - } |
|
301 | + } |
|
302 | 302 | } // class geodir_cpt_categories_widget |
303 | 303 | |
304 | 304 | register_widget('geodir_cpt_categories_widget'); |
@@ -313,153 +313,153 @@ discard block |
||
313 | 313 | * @return string CPT categories content. |
314 | 314 | */ |
315 | 315 | function geodir_cpt_categories_output($params) { |
316 | - $args = wp_parse_args((array)$params, |
|
317 | - array( |
|
318 | - 'title' => '', |
|
319 | - 'post_type' => array(), // NULL for all |
|
320 | - 'hide_empty' => '', |
|
321 | - 'show_count' => '', |
|
322 | - 'hide_icon' => '', |
|
323 | - 'cpt_left' => '', |
|
324 | - 'sort_by' => 'count', |
|
325 | - 'max_count' => 'all', |
|
326 | - 'max_level' => '1', |
|
327 | - 'no_cpt_filter' => '', |
|
328 | - 'no_cat_filter' => '', |
|
329 | - ) |
|
330 | - ); |
|
331 | - |
|
332 | - $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count'; |
|
333 | - $cpt_filter = empty($args['no_cpt_filter']) ? true : false; |
|
334 | - $cat_filter = empty($args['no_cat_filter']) ? true : false; |
|
335 | - |
|
336 | - $gd_post_types = geodir_get_posttypes('array'); |
|
337 | - |
|
338 | - $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type']; |
|
339 | - $current_posttype = geodir_get_current_posttype(); |
|
340 | - |
|
341 | - $is_listing = false; |
|
342 | - $is_category = false; |
|
343 | - if (geodir_is_page('listing')) { |
|
344 | - $current_posttype = geodir_get_current_posttype(); |
|
345 | - |
|
346 | - if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { |
|
347 | - $is_listing = true; |
|
348 | - |
|
349 | - if (is_tax()) { // category page |
|
350 | - $current_term_id = get_queried_object_id(); |
|
351 | - $current_taxonomy = get_query_var('taxonomy'); |
|
352 | - $current_posttype = geodir_get_current_posttype(); |
|
353 | - |
|
354 | - if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
355 | - $is_category = true; |
|
356 | - } |
|
357 | - } |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - $parent_category = 0; |
|
362 | - if ($is_listing && $cpt_filter) { |
|
363 | - $post_type_arr = array($current_posttype); |
|
364 | - } |
|
365 | - |
|
366 | - $post_types = array(); |
|
367 | - if (!empty($post_type_arr)) { |
|
368 | - if (in_array('0', $post_type_arr)) { |
|
369 | - $post_types = $gd_post_types; |
|
370 | - } else { |
|
371 | - foreach ($post_type_arr as $cpt) { |
|
372 | - if (isset($gd_post_types[$cpt])) { |
|
373 | - $post_types[$cpt] = $gd_post_types[$cpt]; |
|
374 | - } |
|
375 | - } |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - if (empty($post_type_arr)) { |
|
380 | - $post_types = $gd_post_types; |
|
381 | - } |
|
382 | - |
|
383 | - $hide_empty = !empty($args['hide_empty']) ? true : false; |
|
384 | - $max_count = strip_tags($args['max_count']); |
|
385 | - $all_childs = $max_count == 'all' ? true : false; |
|
386 | - $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
387 | - $max_level = strip_tags($args['max_level']); |
|
388 | - $show_count = !empty($args['show_count']) ? true : false; |
|
389 | - $hide_icon = !empty($args['hide_icon']) ? true : false; |
|
390 | - $cpt_left = !empty($args['cpt_left']) ? true : false; |
|
391 | - |
|
392 | - if(!$cpt_left){ |
|
393 | - $cpt_left = "gd-cpt-flat"; |
|
394 | - }else{ |
|
395 | - $cpt_left = ''; |
|
396 | - } |
|
397 | - |
|
398 | - $orderby = 'count'; |
|
399 | - $order = 'DESC'; |
|
400 | - if ($sort_by == 'az') { |
|
401 | - $orderby = 'name'; |
|
402 | - $order = 'ASC'; |
|
403 | - } |
|
404 | - |
|
405 | - $output = ''; |
|
406 | - if (!empty($post_types)) { |
|
407 | - foreach ($post_types as $cpt => $cpt_info) { |
|
408 | - $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
|
409 | - $cat_taxonomy = $cpt . 'category'; |
|
410 | - $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); |
|
411 | - if ($hide_empty) { |
|
412 | - $categories = geodir_filter_empty_terms($categories); |
|
413 | - } |
|
414 | - if ($sort_by == 'count') { |
|
415 | - $categories = geodir_sort_terms($categories, 'count'); |
|
416 | - } |
|
417 | - |
|
418 | - if (!empty($categories)) { |
|
419 | - $term_icons = !$hide_icon ? geodir_get_term_icon() : array(); |
|
420 | - $row_class = ''; |
|
421 | - |
|
422 | - if ($is_listing) { |
|
423 | - $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
|
424 | - } |
|
425 | - $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
426 | - |
|
427 | - if ($is_category && $cat_filter && $cpt == $current_posttype) { |
|
428 | - $term_info = get_term($current_term_id, $cat_taxonomy); |
|
429 | - |
|
430 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
|
431 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
432 | - |
|
433 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
434 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
435 | - } else { |
|
436 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
437 | - } |
|
438 | - foreach ($categories as $category) { |
|
439 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
440 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
441 | - |
|
442 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
443 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
444 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
445 | - |
|
446 | - $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
|
447 | - $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
|
448 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
449 | - $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' .$term_icon_url . $category->name . $count . '</a></h3>'; |
|
450 | - if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
451 | - $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
|
452 | - } |
|
453 | - $cpt_row .= '</li>'; |
|
454 | - $cpt_row .= '</ul>'; |
|
455 | - } |
|
456 | - $cpt_row .= '</ul></div>'; |
|
457 | - |
|
458 | - $output .= $cpt_row; |
|
459 | - } |
|
460 | - } |
|
461 | - } |
|
462 | - return $output; |
|
316 | + $args = wp_parse_args((array)$params, |
|
317 | + array( |
|
318 | + 'title' => '', |
|
319 | + 'post_type' => array(), // NULL for all |
|
320 | + 'hide_empty' => '', |
|
321 | + 'show_count' => '', |
|
322 | + 'hide_icon' => '', |
|
323 | + 'cpt_left' => '', |
|
324 | + 'sort_by' => 'count', |
|
325 | + 'max_count' => 'all', |
|
326 | + 'max_level' => '1', |
|
327 | + 'no_cpt_filter' => '', |
|
328 | + 'no_cat_filter' => '', |
|
329 | + ) |
|
330 | + ); |
|
331 | + |
|
332 | + $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count'; |
|
333 | + $cpt_filter = empty($args['no_cpt_filter']) ? true : false; |
|
334 | + $cat_filter = empty($args['no_cat_filter']) ? true : false; |
|
335 | + |
|
336 | + $gd_post_types = geodir_get_posttypes('array'); |
|
337 | + |
|
338 | + $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type']; |
|
339 | + $current_posttype = geodir_get_current_posttype(); |
|
340 | + |
|
341 | + $is_listing = false; |
|
342 | + $is_category = false; |
|
343 | + if (geodir_is_page('listing')) { |
|
344 | + $current_posttype = geodir_get_current_posttype(); |
|
345 | + |
|
346 | + if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { |
|
347 | + $is_listing = true; |
|
348 | + |
|
349 | + if (is_tax()) { // category page |
|
350 | + $current_term_id = get_queried_object_id(); |
|
351 | + $current_taxonomy = get_query_var('taxonomy'); |
|
352 | + $current_posttype = geodir_get_current_posttype(); |
|
353 | + |
|
354 | + if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
355 | + $is_category = true; |
|
356 | + } |
|
357 | + } |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + $parent_category = 0; |
|
362 | + if ($is_listing && $cpt_filter) { |
|
363 | + $post_type_arr = array($current_posttype); |
|
364 | + } |
|
365 | + |
|
366 | + $post_types = array(); |
|
367 | + if (!empty($post_type_arr)) { |
|
368 | + if (in_array('0', $post_type_arr)) { |
|
369 | + $post_types = $gd_post_types; |
|
370 | + } else { |
|
371 | + foreach ($post_type_arr as $cpt) { |
|
372 | + if (isset($gd_post_types[$cpt])) { |
|
373 | + $post_types[$cpt] = $gd_post_types[$cpt]; |
|
374 | + } |
|
375 | + } |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + if (empty($post_type_arr)) { |
|
380 | + $post_types = $gd_post_types; |
|
381 | + } |
|
382 | + |
|
383 | + $hide_empty = !empty($args['hide_empty']) ? true : false; |
|
384 | + $max_count = strip_tags($args['max_count']); |
|
385 | + $all_childs = $max_count == 'all' ? true : false; |
|
386 | + $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
387 | + $max_level = strip_tags($args['max_level']); |
|
388 | + $show_count = !empty($args['show_count']) ? true : false; |
|
389 | + $hide_icon = !empty($args['hide_icon']) ? true : false; |
|
390 | + $cpt_left = !empty($args['cpt_left']) ? true : false; |
|
391 | + |
|
392 | + if(!$cpt_left){ |
|
393 | + $cpt_left = "gd-cpt-flat"; |
|
394 | + }else{ |
|
395 | + $cpt_left = ''; |
|
396 | + } |
|
397 | + |
|
398 | + $orderby = 'count'; |
|
399 | + $order = 'DESC'; |
|
400 | + if ($sort_by == 'az') { |
|
401 | + $orderby = 'name'; |
|
402 | + $order = 'ASC'; |
|
403 | + } |
|
404 | + |
|
405 | + $output = ''; |
|
406 | + if (!empty($post_types)) { |
|
407 | + foreach ($post_types as $cpt => $cpt_info) { |
|
408 | + $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
|
409 | + $cat_taxonomy = $cpt . 'category'; |
|
410 | + $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); |
|
411 | + if ($hide_empty) { |
|
412 | + $categories = geodir_filter_empty_terms($categories); |
|
413 | + } |
|
414 | + if ($sort_by == 'count') { |
|
415 | + $categories = geodir_sort_terms($categories, 'count'); |
|
416 | + } |
|
417 | + |
|
418 | + if (!empty($categories)) { |
|
419 | + $term_icons = !$hide_icon ? geodir_get_term_icon() : array(); |
|
420 | + $row_class = ''; |
|
421 | + |
|
422 | + if ($is_listing) { |
|
423 | + $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
|
424 | + } |
|
425 | + $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
426 | + |
|
427 | + if ($is_category && $cat_filter && $cpt == $current_posttype) { |
|
428 | + $term_info = get_term($current_term_id, $cat_taxonomy); |
|
429 | + |
|
430 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
|
431 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
432 | + |
|
433 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
434 | + $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
435 | + } else { |
|
436 | + $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
437 | + } |
|
438 | + foreach ($categories as $category) { |
|
439 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
440 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
441 | + |
|
442 | + $term_link = get_term_link( $category, $category->taxonomy ); |
|
443 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
444 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
445 | + |
|
446 | + $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
|
447 | + $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
|
448 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
449 | + $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' .$term_icon_url . $category->name . $count . '</a></h3>'; |
|
450 | + if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
451 | + $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
|
452 | + } |
|
453 | + $cpt_row .= '</li>'; |
|
454 | + $cpt_row .= '</ul>'; |
|
455 | + } |
|
456 | + $cpt_row .= '</ul></div>'; |
|
457 | + |
|
458 | + $output .= $cpt_row; |
|
459 | + } |
|
460 | + } |
|
461 | + } |
|
462 | + return $output; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -479,48 +479,48 @@ discard block |
||
479 | 479 | * @return string Html content. |
480 | 480 | */ |
481 | 481 | function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) { |
482 | - $cat_taxonomy = $cpt . 'category'; |
|
483 | - |
|
484 | - $orderby = 'count'; |
|
485 | - $order = 'DESC'; |
|
486 | - if ($sort_by == 'az') { |
|
487 | - $orderby = 'name'; |
|
488 | - $order = 'ASC'; |
|
489 | - } |
|
490 | - |
|
491 | - if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
492 | - return ''; |
|
493 | - } |
|
494 | - |
|
495 | - $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count)); |
|
496 | - if ($hide_empty) { |
|
497 | - $child_cats = geodir_filter_empty_terms($child_cats); |
|
498 | - } |
|
499 | - |
|
500 | - if (empty($child_cats)) { |
|
501 | - return ''; |
|
502 | - } |
|
503 | - |
|
504 | - if ($sort_by == 'count') { |
|
505 | - $child_cats = geodir_sort_terms($child_cats, 'count'); |
|
506 | - } |
|
507 | - |
|
508 | - $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
509 | - $depth++; |
|
510 | - foreach ($child_cats as $category) { |
|
511 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
512 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
513 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
514 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
515 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
516 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
517 | - |
|
518 | - $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
|
519 | - $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
520 | - $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
|
521 | - } |
|
522 | - $content .= '</li></ul>'; |
|
523 | - |
|
524 | - return $content; |
|
482 | + $cat_taxonomy = $cpt . 'category'; |
|
483 | + |
|
484 | + $orderby = 'count'; |
|
485 | + $order = 'DESC'; |
|
486 | + if ($sort_by == 'az') { |
|
487 | + $orderby = 'name'; |
|
488 | + $order = 'ASC'; |
|
489 | + } |
|
490 | + |
|
491 | + if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
492 | + return ''; |
|
493 | + } |
|
494 | + |
|
495 | + $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count)); |
|
496 | + if ($hide_empty) { |
|
497 | + $child_cats = geodir_filter_empty_terms($child_cats); |
|
498 | + } |
|
499 | + |
|
500 | + if (empty($child_cats)) { |
|
501 | + return ''; |
|
502 | + } |
|
503 | + |
|
504 | + if ($sort_by == 'count') { |
|
505 | + $child_cats = geodir_sort_terms($child_cats, 'count'); |
|
506 | + } |
|
507 | + |
|
508 | + $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
509 | + $depth++; |
|
510 | + foreach ($child_cats as $category) { |
|
511 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
512 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
513 | + $term_link = get_term_link( $category, $category->taxonomy ); |
|
514 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
515 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
516 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
517 | + |
|
518 | + $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
|
519 | + $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
520 | + $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
|
521 | + } |
|
522 | + $content .= '</li></ul>'; |
|
523 | + |
|
524 | + return $content; |
|
525 | 525 | } |
526 | 526 | ?> |
527 | 527 | \ No newline at end of file |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | $output = geodir_cpt_categories_output($params); |
170 | 170 | |
171 | 171 | echo $args['before_widget']; |
172 | - if ( $params['title'] ) { |
|
172 | + if ($params['title']) { |
|
173 | 173 | echo '<div class="geodir_list_heading clearfix">'; |
174 | - echo $args['before_title'] . $params['title'] . $args['after_title']; |
|
174 | + echo $args['before_title'].$params['title'].$args['after_title']; |
|
175 | 175 | echo '</div>'; |
176 | 176 | } |
177 | 177 | echo '<div class="gd-cptcats-widget">'; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param array $instance Previously saved values from database. |
219 | 219 | */ |
220 | 220 | public function form($instance) { |
221 | - $instance = wp_parse_args( (array)$instance, |
|
221 | + $instance = wp_parse_args((array) $instance, |
|
222 | 222 | array( |
223 | 223 | 'title' => '', |
224 | 224 | 'post_type' => array(), // NULL for all |
@@ -252,50 +252,50 @@ discard block |
||
252 | 252 | <p> |
253 | 253 | <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Select CPT:', 'geodirectory'); ?></label> |
254 | 254 | <select name="<?php echo $this->get_field_name('post_type'); ?>[]" id="<?php echo $this->get_field_id('post_type'); ?>" class="widefat" multiple="multiple"> |
255 | - <option value="0" <?php selected( (empty($post_type) || (is_array($post_type) && in_array('0', $post_type))), true ); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
255 | + <option value="0" <?php selected((empty($post_type) || (is_array($post_type) && in_array('0', $post_type))), true); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
256 | 256 | <?php foreach ($post_type_options as $name => $title) { ?> |
257 | - <option value="<?php echo $name;?>" <?php selected( is_array($post_type) && in_array($name, $post_type), true ); ?>><?php echo $title; ?></option> |
|
257 | + <option value="<?php echo $name; ?>" <?php selected(is_array($post_type) && in_array($name, $post_type), true); ?>><?php echo $title; ?></option> |
|
258 | 258 | <?php } ?> |
259 | 259 | </select> |
260 | 260 | </p> |
261 | - <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_empty'); ?>" name="<?php echo $this->get_field_name('hide_empty'); ?>"<?php checked( $hide_empty ); ?> value="1" /> |
|
262 | - <label for="<?php echo $this->get_field_id('hide_empty'); ?>"><?php _e( 'Hide empty categories', 'geodirectory' ); ?></label><br /> |
|
263 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_count'); ?>" name="<?php echo $this->get_field_name('show_count'); ?>"<?php checked( $show_count ); ?> value="1" /> |
|
264 | - <label for="<?php echo $this->get_field_id('show_count'); ?>"><?php _e( 'Show category count' ); ?></label> <small><?php _e( '( Enabling will slow down page loading for big directories. )', 'geodirectory' ); ?></small><br /> |
|
265 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_icon'); ?>" name="<?php echo $this->get_field_name('hide_icon'); ?>"<?php checked( $hide_icon ); ?> value="1" /> |
|
266 | - <label for="<?php echo $this->get_field_id('hide_icon'); ?>"><?php _e( 'Hide category icon', 'geodirectory' ); ?></label><br /> |
|
267 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('cpt_left'); ?>" name="<?php echo $this->get_field_name('cpt_left'); ?>"<?php checked( $cpt_left ); ?> value="1" /> |
|
268 | - <label for="<?php echo $this->get_field_id('cpt_left'); ?>"><?php _e( 'Show CPT on same line', 'geodirectory' ); ?></label> |
|
261 | + <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_empty'); ?>" name="<?php echo $this->get_field_name('hide_empty'); ?>"<?php checked($hide_empty); ?> value="1" /> |
|
262 | + <label for="<?php echo $this->get_field_id('hide_empty'); ?>"><?php _e('Hide empty categories', 'geodirectory'); ?></label><br /> |
|
263 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_count'); ?>" name="<?php echo $this->get_field_name('show_count'); ?>"<?php checked($show_count); ?> value="1" /> |
|
264 | + <label for="<?php echo $this->get_field_id('show_count'); ?>"><?php _e('Show category count'); ?></label> <small><?php _e('( Enabling will slow down page loading for big directories. )', 'geodirectory'); ?></small><br /> |
|
265 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hide_icon'); ?>" name="<?php echo $this->get_field_name('hide_icon'); ?>"<?php checked($hide_icon); ?> value="1" /> |
|
266 | + <label for="<?php echo $this->get_field_id('hide_icon'); ?>"><?php _e('Hide category icon', 'geodirectory'); ?></label><br /> |
|
267 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('cpt_left'); ?>" name="<?php echo $this->get_field_name('cpt_left'); ?>"<?php checked($cpt_left); ?> value="1" /> |
|
268 | + <label for="<?php echo $this->get_field_id('cpt_left'); ?>"><?php _e('Show CPT on same line', 'geodirectory'); ?></label> |
|
269 | 269 | <p> |
270 | 270 | <label for="<?php echo $this->get_field_id('sort_by'); ?>"><?php _e('Sort by:', 'geodirectory'); ?></label> |
271 | 271 | <select name="<?php echo $this->get_field_name('sort_by'); ?>" id="<?php echo $this->get_field_id('sort_by'); ?>" class="widefat"> |
272 | - <option value="az" <?php selected( $sort_by, 'az' ); ?>><?php _e('A-Z', 'geodirectory'); ?></option> |
|
273 | - <option value="count" <?php selected( $sort_by, 'count' ); ?>><?php _e('Count', 'geodirectory'); ?></option> |
|
272 | + <option value="az" <?php selected($sort_by, 'az'); ?>><?php _e('A-Z', 'geodirectory'); ?></option> |
|
273 | + <option value="count" <?php selected($sort_by, 'count'); ?>><?php _e('Count', 'geodirectory'); ?></option> |
|
274 | 274 | </select> |
275 | 275 | </p> |
276 | 276 | <p> |
277 | 277 | <label for="<?php echo $this->get_field_id('max_count'); ?>"><?php _e('Max no of sub-categories:', 'geodirectory'); ?></label> |
278 | 278 | <select name="<?php echo $this->get_field_name('max_count'); ?>" id="<?php echo $this->get_field_id('max_count'); ?>" class="widefat"> |
279 | - <option value="all" <?php selected( $max_count, 'all' ); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
279 | + <option value="all" <?php selected($max_count, 'all'); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
280 | 280 | <?php for ($n = 10; $n >= 0; $n--) { ?> |
281 | - <option value="<?php echo $n;?>" <?php selected( $max_count, $n ); ?>><?php echo $n; ?></option> |
|
281 | + <option value="<?php echo $n; ?>" <?php selected($max_count, $n); ?>><?php echo $n; ?></option> |
|
282 | 282 | <?php } ?> |
283 | 283 | </select> |
284 | 284 | </p> |
285 | 285 | <p> |
286 | 286 | <label for="<?php echo $this->get_field_id('max_level'); ?>"><?php _e('Show max sub-categories depth:', 'geodirectory'); ?></label> |
287 | 287 | <select name="<?php echo $this->get_field_name('max_level'); ?>" id="<?php echo $this->get_field_id('max_level'); ?>" class="widefat"> |
288 | - <option value="all" <?php selected( $max_level, 'all' ); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
288 | + <option value="all" <?php selected($max_level, 'all'); ?>><?php _e('All', 'geodirectory'); ?></option> |
|
289 | 289 | <?php for ($n = 0; $n <= 10; $n++) { ?> |
290 | - <option value="<?php echo $n;?>" <?php selected( $max_level, $n ); ?>><?php echo $n; ?></option> |
|
290 | + <option value="<?php echo $n; ?>" <?php selected($max_level, $n); ?>><?php echo $n; ?></option> |
|
291 | 291 | <?php } ?> |
292 | 292 | </select> |
293 | 293 | </p> |
294 | 294 | <p> |
295 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('no_cpt_filter'); ?>" name="<?php echo $this->get_field_name('no_cpt_filter'); ?>"<?php checked( $no_cpt_filter ); ?> value="1" /> |
|
296 | - <label for="<?php echo $this->get_field_id('no_cpt_filter'); ?>"><?php _e( 'Don\'t filter for current viewing post type', 'geodirectory' ); ?></label> |
|
297 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('no_cat_filter'); ?>" name="<?php echo $this->get_field_name('no_cat_filter'); ?>"<?php checked( $no_cat_filter ); ?> value="1" /> |
|
298 | - <label for="<?php echo $this->get_field_id('no_cat_filter'); ?>"><?php _e( 'Don\'t filter for current viewing category', 'geodirectory' ); ?></label> |
|
295 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('no_cpt_filter'); ?>" name="<?php echo $this->get_field_name('no_cpt_filter'); ?>"<?php checked($no_cpt_filter); ?> value="1" /> |
|
296 | + <label for="<?php echo $this->get_field_id('no_cpt_filter'); ?>"><?php _e('Don\'t filter for current viewing post type', 'geodirectory'); ?></label> |
|
297 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('no_cat_filter'); ?>" name="<?php echo $this->get_field_name('no_cat_filter'); ?>"<?php checked($no_cat_filter); ?> value="1" /> |
|
298 | + <label for="<?php echo $this->get_field_id('no_cat_filter'); ?>"><?php _e('Don\'t filter for current viewing category', 'geodirectory'); ?></label> |
|
299 | 299 | </p> |
300 | 300 | <?php |
301 | 301 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * @return string CPT categories content. |
314 | 314 | */ |
315 | 315 | function geodir_cpt_categories_output($params) { |
316 | - $args = wp_parse_args((array)$params, |
|
316 | + $args = wp_parse_args((array) $params, |
|
317 | 317 | array( |
318 | 318 | 'title' => '', |
319 | 319 | 'post_type' => array(), // NULL for all |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $current_taxonomy = get_query_var('taxonomy'); |
352 | 352 | $current_posttype = geodir_get_current_posttype(); |
353 | 353 | |
354 | - if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
354 | + if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype.'category') { |
|
355 | 355 | $is_category = true; |
356 | 356 | } |
357 | 357 | } |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | $hide_empty = !empty($args['hide_empty']) ? true : false; |
384 | 384 | $max_count = strip_tags($args['max_count']); |
385 | 385 | $all_childs = $max_count == 'all' ? true : false; |
386 | - $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
386 | + $max_count = $max_count > 0 ? (int) $max_count : 0; |
|
387 | 387 | $max_level = strip_tags($args['max_level']); |
388 | 388 | $show_count = !empty($args['show_count']) ? true : false; |
389 | 389 | $hide_icon = !empty($args['hide_icon']) ? true : false; |
390 | 390 | $cpt_left = !empty($args['cpt_left']) ? true : false; |
391 | 391 | |
392 | - if(!$cpt_left){ |
|
392 | + if (!$cpt_left) { |
|
393 | 393 | $cpt_left = "gd-cpt-flat"; |
394 | - }else{ |
|
394 | + } else { |
|
395 | 395 | $cpt_left = ''; |
396 | 396 | } |
397 | 397 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | if (!empty($post_types)) { |
407 | 407 | foreach ($post_types as $cpt => $cpt_info) { |
408 | 408 | $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
409 | - $cat_taxonomy = $cpt . 'category'; |
|
409 | + $cat_taxonomy = $cpt.'category'; |
|
410 | 410 | $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); |
411 | 411 | if ($hide_empty) { |
412 | 412 | $categories = geodir_filter_empty_terms($categories); |
@@ -422,32 +422,32 @@ discard block |
||
422 | 422 | if ($is_listing) { |
423 | 423 | $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
424 | 424 | } |
425 | - $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
425 | + $cpt_row = '<div class="gd-cptcat-row gd-cptcat-'.$cpt.$row_class.' '.$cpt_left.'">'; |
|
426 | 426 | |
427 | 427 | if ($is_category && $cat_filter && $cpt == $current_posttype) { |
428 | 428 | $term_info = get_term($current_term_id, $cat_taxonomy); |
429 | 429 | |
430 | 430 | $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
431 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
431 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($term_info->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
432 | 432 | |
433 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
434 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
433 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$term_info->count.')</span>' : ''; |
|
434 | + $cpt_row .= '<h2 class="gd-cptcat-title">'.$term_icon_url.$term_info->name.$count.'</h2>'; |
|
435 | 435 | } else { |
436 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
436 | + $cpt_row .= '<h2 class="gd-cptcat-title">'.__($cpt_info['labels']['name'], 'geodirectory').'</h2>'; |
|
437 | 437 | } |
438 | 438 | foreach ($categories as $category) { |
439 | 439 | $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
440 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
440 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($category->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
441 | 441 | |
442 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
442 | + $term_link = get_term_link($category, $category->taxonomy); |
|
443 | 443 | /** Filter documented in geodirectory-functions/general_functions.php **/ |
444 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
444 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $category->term_id, $cpt); |
|
445 | 445 | |
446 | 446 | $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
447 | 447 | $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
448 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
449 | - $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' .$term_icon_url . $category->name . $count . '</a></h3>'; |
|
450 | - if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
448 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$category->count.')</span>' : ''; |
|
449 | + $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="'.esc_url($term_link).'" title="'.esc_attr($category->name).'">'.$term_icon_url.$category->name.$count.'</a></h3>'; |
|
450 | + if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int) $max_level > 0)) { |
|
451 | 451 | $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
452 | 452 | } |
453 | 453 | $cpt_row .= '</li>'; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @return string Html content. |
480 | 480 | */ |
481 | 481 | function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) { |
482 | - $cat_taxonomy = $cpt . 'category'; |
|
482 | + $cat_taxonomy = $cpt.'category'; |
|
483 | 483 | |
484 | 484 | $orderby = 'count'; |
485 | 485 | $order = 'DESC'; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $order = 'ASC'; |
489 | 489 | } |
490 | 490 | |
491 | - if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
491 | + if ($max_level != 'all' && $depth > (int) $max_level) { |
|
492 | 492 | return ''; |
493 | 493 | } |
494 | 494 | |
@@ -505,18 +505,18 @@ discard block |
||
505 | 505 | $child_cats = geodir_sort_terms($child_cats, 'count'); |
506 | 506 | } |
507 | 507 | |
508 | - $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
508 | + $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-'.$depth.'">'; |
|
509 | 509 | $depth++; |
510 | 510 | foreach ($child_cats as $category) { |
511 | 511 | $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
512 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
513 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
512 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($category->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
513 | + $term_link = get_term_link($category, $category->taxonomy); |
|
514 | 514 | /** Filter documented in geodirectory-functions/general_functions.php **/ |
515 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
516 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
515 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $category->term_id, $cpt); |
|
516 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$category->count.')</span>' : ''; |
|
517 | 517 | |
518 | 518 | $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
519 | - $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
519 | + $content .= '<a href="'.esc_url($term_link).'" title="'.esc_attr($category->name).'">'.$term_icon_url.$category->name.$count.'</a></li>'; |
|
520 | 520 | $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
521 | 521 | } |
522 | 522 | $content .= '</li></ul>'; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | // If this file is called directly, abort. |
9 | 9 | if (!defined('WPINC')) { |
10 | - die; |
|
10 | + die; |
|
11 | 11 | } |
12 | 12 | require_once('geodirectory-functions/shortcode_functions.php'); |
13 | 13 | |
@@ -32,43 +32,43 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function geodir_sc_add_listing($atts) |
34 | 34 | { |
35 | - ob_start(); |
|
36 | - $defaults = array( |
|
37 | - 'pid' => '', |
|
38 | - 'listing_type' => 'gd_place', |
|
39 | - 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
40 | - 'show_login' => false, |
|
41 | - ); |
|
42 | - $params = shortcode_atts($defaults, $atts); |
|
43 | - |
|
44 | - foreach ($params as $key => $value) { |
|
45 | - $_REQUEST[$key] = $value; |
|
46 | - } |
|
47 | - |
|
48 | - $user_id = get_current_user_id(); |
|
49 | - if (!$user_id) { |
|
50 | - echo $params['login_msg']; |
|
51 | - if ($params['show_login']) { |
|
52 | - echo "<br />"; |
|
53 | - $defaults = array( |
|
54 | - 'before_widget' => '', |
|
55 | - 'after_widget' => '', |
|
56 | - 'before_title' => '', |
|
57 | - 'after_title' => '', |
|
58 | - ); |
|
59 | - |
|
60 | - geodir_loginwidget_output($defaults, $defaults); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - } else { |
|
65 | - // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
66 | - } |
|
67 | - $output = ob_get_contents(); |
|
68 | - |
|
69 | - ob_end_clean(); |
|
70 | - |
|
71 | - return $output; |
|
35 | + ob_start(); |
|
36 | + $defaults = array( |
|
37 | + 'pid' => '', |
|
38 | + 'listing_type' => 'gd_place', |
|
39 | + 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
40 | + 'show_login' => false, |
|
41 | + ); |
|
42 | + $params = shortcode_atts($defaults, $atts); |
|
43 | + |
|
44 | + foreach ($params as $key => $value) { |
|
45 | + $_REQUEST[$key] = $value; |
|
46 | + } |
|
47 | + |
|
48 | + $user_id = get_current_user_id(); |
|
49 | + if (!$user_id) { |
|
50 | + echo $params['login_msg']; |
|
51 | + if ($params['show_login']) { |
|
52 | + echo "<br />"; |
|
53 | + $defaults = array( |
|
54 | + 'before_widget' => '', |
|
55 | + 'after_widget' => '', |
|
56 | + 'before_title' => '', |
|
57 | + 'after_title' => '', |
|
58 | + ); |
|
59 | + |
|
60 | + geodir_loginwidget_output($defaults, $defaults); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + } else { |
|
65 | + // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
66 | + } |
|
67 | + $output = ob_get_contents(); |
|
68 | + |
|
69 | + ob_end_clean(); |
|
70 | + |
|
71 | + return $output; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -96,136 +96,136 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function geodir_sc_home_map($atts) |
98 | 98 | { |
99 | - ob_start(); |
|
100 | - $defaults = array( |
|
101 | - 'width' => '960', |
|
102 | - 'height' => '425', |
|
103 | - 'maptype' => 'ROADMAP', |
|
104 | - 'zoom' => '13', |
|
105 | - 'autozoom' => '', |
|
106 | - 'child_collapse' => '0', |
|
107 | - 'scrollwheel' => '0', |
|
99 | + ob_start(); |
|
100 | + $defaults = array( |
|
101 | + 'width' => '960', |
|
102 | + 'height' => '425', |
|
103 | + 'maptype' => 'ROADMAP', |
|
104 | + 'zoom' => '13', |
|
105 | + 'autozoom' => '', |
|
106 | + 'child_collapse' => '0', |
|
107 | + 'scrollwheel' => '0', |
|
108 | 108 | 'marker_cluster' => false, |
109 | - 'latitude' => '', |
|
110 | - 'longitude' => '' |
|
111 | - ); |
|
112 | - |
|
113 | - $params = shortcode_atts($defaults, $atts); |
|
114 | - |
|
115 | - $params = gdsc_validate_map_args($params); |
|
116 | - |
|
117 | - $map_args = array( |
|
118 | - 'map_canvas_name' => 'gd_home_map', |
|
119 | - 'latitude' => $params['latitude'], |
|
120 | - 'longitude' => $params['longitude'], |
|
121 | - |
|
122 | - /** |
|
123 | - * Filter the widget width of the map on home/listings page. |
|
124 | - * |
|
125 | - * @since 1.0.0 |
|
126 | - * @param mixed(string|int|float) $params['width'] The map width. |
|
127 | - */ |
|
128 | - 'width' => apply_filters('widget_width', $params['width']), |
|
129 | - /** |
|
130 | - * Filter the widget height of the map on home/listings page. |
|
131 | - * |
|
132 | - * @since 1.0.0 |
|
133 | - * @param mixed(string|int|float) $params['height'] The map height. |
|
134 | - */ |
|
135 | - 'height' => apply_filters('widget_heigh', $params['height']), |
|
136 | - /** |
|
137 | - * Filter the widget maptype of the map on home/listings page. |
|
138 | - * |
|
139 | - * @since 1.0.0 |
|
109 | + 'latitude' => '', |
|
110 | + 'longitude' => '' |
|
111 | + ); |
|
112 | + |
|
113 | + $params = shortcode_atts($defaults, $atts); |
|
114 | + |
|
115 | + $params = gdsc_validate_map_args($params); |
|
116 | + |
|
117 | + $map_args = array( |
|
118 | + 'map_canvas_name' => 'gd_home_map', |
|
119 | + 'latitude' => $params['latitude'], |
|
120 | + 'longitude' => $params['longitude'], |
|
121 | + |
|
122 | + /** |
|
123 | + * Filter the widget width of the map on home/listings page. |
|
124 | + * |
|
125 | + * @since 1.0.0 |
|
126 | + * @param mixed(string|int|float) $params['width'] The map width. |
|
127 | + */ |
|
128 | + 'width' => apply_filters('widget_width', $params['width']), |
|
129 | + /** |
|
130 | + * Filter the widget height of the map on home/listings page. |
|
131 | + * |
|
132 | + * @since 1.0.0 |
|
133 | + * @param mixed(string|int|float) $params['height'] The map height. |
|
134 | + */ |
|
135 | + 'height' => apply_filters('widget_heigh', $params['height']), |
|
136 | + /** |
|
137 | + * Filter the widget maptype of the map on home/listings page. |
|
138 | + * |
|
139 | + * @since 1.0.0 |
|
140 | 140 | * @since 1.5.2 Added TERRAIN map type. |
141 | - * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
142 | - */ |
|
143 | - 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
144 | - /** |
|
145 | - * Filter the widget scrollwheel value of the map on home/listings page. |
|
146 | - * |
|
147 | - * Should the scrollwheel zoom the map or not. |
|
148 | - * |
|
149 | - * @since 1.0.0 |
|
150 | - * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
151 | - */ |
|
152 | - 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
153 | - /** |
|
154 | - * Filter the widget zoom level of the map on home/listings page. |
|
155 | - * |
|
156 | - * @since 1.0.0 |
|
157 | - * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
158 | - */ |
|
159 | - 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
160 | - /** |
|
161 | - * Filter the widget auto zoom value of the map on home/listings page. |
|
162 | - * |
|
163 | - * If the map should autozoom to fit the markers shown. |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
167 | - */ |
|
168 | - 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
169 | - /** |
|
170 | - * Filter the widget child_collapse value of the map on home/listings page. |
|
171 | - * |
|
172 | - * If the map should auto collapse the child categories if the category bar is present. |
|
173 | - * |
|
174 | - * @since 1.0.0 |
|
175 | - * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
176 | - */ |
|
177 | - 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
178 | - 'enable_cat_filters' => true, |
|
179 | - 'enable_text_search' => true, |
|
180 | - 'enable_post_type_filters' => true, |
|
181 | - /** |
|
182 | - * Filter the widget enable_location_filters value of the map on home/listings page. |
|
183 | - * |
|
184 | - * This is used when the location addon is used. |
|
185 | - * |
|
186 | - * @since 1.0.0 |
|
187 | - * @param bool $val True if location filters should be used, false if not. |
|
188 | - */ |
|
189 | - 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
190 | - 'enable_jason_on_load' => false, |
|
191 | - 'enable_marker_cluster' => false, |
|
192 | - 'enable_map_resize_button' => true, |
|
193 | - 'map_class_name' => 'geodir-map-home-page', |
|
194 | - 'is_geodir_home_map_widget' => true, |
|
195 | - ); |
|
141 | + * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
142 | + */ |
|
143 | + 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
144 | + /** |
|
145 | + * Filter the widget scrollwheel value of the map on home/listings page. |
|
146 | + * |
|
147 | + * Should the scrollwheel zoom the map or not. |
|
148 | + * |
|
149 | + * @since 1.0.0 |
|
150 | + * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
151 | + */ |
|
152 | + 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
153 | + /** |
|
154 | + * Filter the widget zoom level of the map on home/listings page. |
|
155 | + * |
|
156 | + * @since 1.0.0 |
|
157 | + * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
158 | + */ |
|
159 | + 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
160 | + /** |
|
161 | + * Filter the widget auto zoom value of the map on home/listings page. |
|
162 | + * |
|
163 | + * If the map should autozoom to fit the markers shown. |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
167 | + */ |
|
168 | + 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
169 | + /** |
|
170 | + * Filter the widget child_collapse value of the map on home/listings page. |
|
171 | + * |
|
172 | + * If the map should auto collapse the child categories if the category bar is present. |
|
173 | + * |
|
174 | + * @since 1.0.0 |
|
175 | + * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
176 | + */ |
|
177 | + 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
178 | + 'enable_cat_filters' => true, |
|
179 | + 'enable_text_search' => true, |
|
180 | + 'enable_post_type_filters' => true, |
|
181 | + /** |
|
182 | + * Filter the widget enable_location_filters value of the map on home/listings page. |
|
183 | + * |
|
184 | + * This is used when the location addon is used. |
|
185 | + * |
|
186 | + * @since 1.0.0 |
|
187 | + * @param bool $val True if location filters should be used, false if not. |
|
188 | + */ |
|
189 | + 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
190 | + 'enable_jason_on_load' => false, |
|
191 | + 'enable_marker_cluster' => false, |
|
192 | + 'enable_map_resize_button' => true, |
|
193 | + 'map_class_name' => 'geodir-map-home-page', |
|
194 | + 'is_geodir_home_map_widget' => true, |
|
195 | + ); |
|
196 | 196 | |
197 | 197 | // Add marker cluster |
198 | 198 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
199 | - $map_args['enable_marker_cluster'] = true; |
|
200 | - if(get_option('geodir_marker_cluster_type')) { |
|
201 | - if ($map_args['autozoom']) { |
|
202 | - $map_args['enable_marker_cluster_no_reposition'] = false; |
|
203 | - } else { |
|
204 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
205 | - } |
|
199 | + $map_args['enable_marker_cluster'] = true; |
|
200 | + if(get_option('geodir_marker_cluster_type')) { |
|
201 | + if ($map_args['autozoom']) { |
|
202 | + $map_args['enable_marker_cluster_no_reposition'] = false; |
|
203 | + } else { |
|
204 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
205 | + } |
|
206 | 206 | |
207 | - $map_args['enable_marker_cluster_server'] = true ; |
|
207 | + $map_args['enable_marker_cluster_server'] = true ; |
|
208 | 208 | |
209 | - } |
|
209 | + } |
|
210 | 210 | } else { |
211 | 211 | $map_args['enable_marker_cluster'] = false; |
212 | 212 | } |
213 | 213 | |
214 | - // if lat and long set in shortcode, hack it so the map is not repositioned |
|
215 | - if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
216 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
217 | - } |
|
214 | + // if lat and long set in shortcode, hack it so the map is not repositioned |
|
215 | + if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
216 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | - geodir_draw_map($map_args); |
|
220 | + geodir_draw_map($map_args); |
|
221 | 221 | |
222 | - add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
222 | + add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
223 | 223 | |
224 | - $output = ob_get_contents(); |
|
224 | + $output = ob_get_contents(); |
|
225 | 225 | |
226 | - ob_end_clean(); |
|
226 | + ob_end_clean(); |
|
227 | 227 | |
228 | - return $output; |
|
228 | + return $output; |
|
229 | 229 | } |
230 | 230 | add_shortcode('gd_homepage_map', 'geodir_sc_home_map'); |
231 | 231 | |
@@ -259,77 +259,77 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function geodir_sc_listing_map($atts) |
261 | 261 | { |
262 | - ob_start(); |
|
263 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
264 | - |
|
265 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
266 | - |
|
267 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
268 | - |
|
269 | - $defaults = array( |
|
270 | - 'width' => '294', |
|
271 | - 'height' => '370', |
|
272 | - 'zoom' => '13', |
|
273 | - 'autozoom' => '', |
|
274 | - 'sticky' => '', |
|
275 | - 'showall' => '0', |
|
276 | - 'scrollwheel' => '0', |
|
277 | - 'maptype' => 'ROADMAP', |
|
278 | - 'child_collapse' => 0, |
|
262 | + ob_start(); |
|
263 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
264 | + |
|
265 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
266 | + |
|
267 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
268 | + |
|
269 | + $defaults = array( |
|
270 | + 'width' => '294', |
|
271 | + 'height' => '370', |
|
272 | + 'zoom' => '13', |
|
273 | + 'autozoom' => '', |
|
274 | + 'sticky' => '', |
|
275 | + 'showall' => '0', |
|
276 | + 'scrollwheel' => '0', |
|
277 | + 'maptype' => 'ROADMAP', |
|
278 | + 'child_collapse' => 0, |
|
279 | 279 | 'marker_cluster' => false |
280 | - ); |
|
281 | - |
|
282 | - $params = shortcode_atts($defaults, $atts); |
|
283 | - |
|
284 | - $params = gdsc_validate_map_args($params); |
|
285 | - |
|
286 | - $map_args = array( |
|
287 | - 'map_canvas_name' => 'gd_listing_map', |
|
288 | - 'width' => $params['width'], |
|
289 | - 'height' => $params['height'], |
|
290 | - 'zoom' => $params['zoom'], |
|
291 | - 'autozoom' => $params['autozoom'], |
|
292 | - 'sticky' => $params['sticky'], |
|
293 | - 'showall' => $params['showall'], |
|
294 | - 'scrollwheel' => $params['scrollwheel'], |
|
295 | - 'child_collapse' => 0, |
|
296 | - 'enable_cat_filters' => false, |
|
297 | - 'enable_text_search' => false, |
|
298 | - 'enable_post_type_filters' => false, |
|
299 | - 'enable_location_filters' => false, |
|
300 | - 'enable_jason_on_load' => true, |
|
301 | - ); |
|
302 | - |
|
303 | - if (is_single()) { |
|
304 | - |
|
305 | - global $post; |
|
306 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
307 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
308 | - $mapview = $post->post_mapview; |
|
309 | - $map_args['zoom'] = $post->post_mapzoom; |
|
310 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
311 | - |
|
312 | - } else { |
|
313 | - $default_location = geodir_get_default_location(); |
|
314 | - |
|
315 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
316 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
317 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
318 | - } |
|
319 | - |
|
320 | - if (empty($mapview)) { |
|
321 | - $mapview = 'ROADMAP'; |
|
322 | - } |
|
323 | - |
|
324 | - // Set default map options |
|
325 | - $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
326 | - $map_args['latitude'] = $map_default_lat; |
|
327 | - $map_args['longitude'] = $map_default_lng; |
|
328 | - $map_args['streetViewControl'] = true; |
|
329 | - $map_args['maptype'] = $mapview; |
|
330 | - $map_args['showPreview'] = '0'; |
|
331 | - $map_args['maxZoom'] = 21; |
|
332 | - $map_args['bubble_size'] = 'small'; |
|
280 | + ); |
|
281 | + |
|
282 | + $params = shortcode_atts($defaults, $atts); |
|
283 | + |
|
284 | + $params = gdsc_validate_map_args($params); |
|
285 | + |
|
286 | + $map_args = array( |
|
287 | + 'map_canvas_name' => 'gd_listing_map', |
|
288 | + 'width' => $params['width'], |
|
289 | + 'height' => $params['height'], |
|
290 | + 'zoom' => $params['zoom'], |
|
291 | + 'autozoom' => $params['autozoom'], |
|
292 | + 'sticky' => $params['sticky'], |
|
293 | + 'showall' => $params['showall'], |
|
294 | + 'scrollwheel' => $params['scrollwheel'], |
|
295 | + 'child_collapse' => 0, |
|
296 | + 'enable_cat_filters' => false, |
|
297 | + 'enable_text_search' => false, |
|
298 | + 'enable_post_type_filters' => false, |
|
299 | + 'enable_location_filters' => false, |
|
300 | + 'enable_jason_on_load' => true, |
|
301 | + ); |
|
302 | + |
|
303 | + if (is_single()) { |
|
304 | + |
|
305 | + global $post; |
|
306 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
307 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
308 | + $mapview = $post->post_mapview; |
|
309 | + $map_args['zoom'] = $post->post_mapzoom; |
|
310 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
311 | + |
|
312 | + } else { |
|
313 | + $default_location = geodir_get_default_location(); |
|
314 | + |
|
315 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
316 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
317 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
318 | + } |
|
319 | + |
|
320 | + if (empty($mapview)) { |
|
321 | + $mapview = 'ROADMAP'; |
|
322 | + } |
|
323 | + |
|
324 | + // Set default map options |
|
325 | + $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
326 | + $map_args['latitude'] = $map_default_lat; |
|
327 | + $map_args['longitude'] = $map_default_lng; |
|
328 | + $map_args['streetViewControl'] = true; |
|
329 | + $map_args['maptype'] = $mapview; |
|
330 | + $map_args['showPreview'] = '0'; |
|
331 | + $map_args['maxZoom'] = 21; |
|
332 | + $map_args['bubble_size'] = 'small'; |
|
333 | 333 | |
334 | 334 | // Add marker cluster |
335 | 335 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | $map_args['enable_marker_cluster'] = false; |
339 | 339 | } |
340 | 340 | |
341 | - geodir_draw_map($map_args); |
|
341 | + geodir_draw_map($map_args); |
|
342 | 342 | |
343 | - $output = ob_get_contents(); |
|
343 | + $output = ob_get_contents(); |
|
344 | 344 | |
345 | - ob_end_clean(); |
|
345 | + ob_end_clean(); |
|
346 | 346 | |
347 | - return $output; |
|
347 | + return $output; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider'); |
@@ -377,120 +377,120 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function geodir_sc_listing_slider($atts) |
379 | 379 | { |
380 | - ob_start(); |
|
381 | - $defaults = array( |
|
382 | - 'post_type' => 'gd_place', |
|
383 | - 'category' => '0', |
|
384 | - 'post_number' => '5', |
|
385 | - 'slideshow' => '0', |
|
386 | - 'animation_loop' => 0, |
|
387 | - 'direction_nav' => 0, |
|
388 | - 'slideshow_speed' => 5000, |
|
389 | - 'animation_speed' => 600, |
|
390 | - 'animation' => 'slide', |
|
391 | - 'order_by' => 'latest', |
|
392 | - 'show_title' => '', |
|
393 | - 'show_featured_only' => '', |
|
394 | - 'title' => '', |
|
395 | - ); |
|
396 | - |
|
397 | - $params = shortcode_atts($defaults, $atts); |
|
398 | - |
|
399 | - |
|
400 | - /* |
|
380 | + ob_start(); |
|
381 | + $defaults = array( |
|
382 | + 'post_type' => 'gd_place', |
|
383 | + 'category' => '0', |
|
384 | + 'post_number' => '5', |
|
385 | + 'slideshow' => '0', |
|
386 | + 'animation_loop' => 0, |
|
387 | + 'direction_nav' => 0, |
|
388 | + 'slideshow_speed' => 5000, |
|
389 | + 'animation_speed' => 600, |
|
390 | + 'animation' => 'slide', |
|
391 | + 'order_by' => 'latest', |
|
392 | + 'show_title' => '', |
|
393 | + 'show_featured_only' => '', |
|
394 | + 'title' => '', |
|
395 | + ); |
|
396 | + |
|
397 | + $params = shortcode_atts($defaults, $atts); |
|
398 | + |
|
399 | + |
|
400 | + /* |
|
401 | 401 | * |
402 | 402 | * Now we begin the validation of the attributes. |
403 | 403 | */ |
404 | - // Check we have a valid post_type |
|
405 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
406 | - $params['post_type'] = 'gd_place'; |
|
407 | - } |
|
408 | - |
|
409 | - // Check we have a valid sort_order |
|
410 | - $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
411 | - |
|
412 | - // Match the chosen animation to our options |
|
413 | - $animation_list = array('slide', 'fade'); |
|
414 | - if (!(in_array($params['animation'], $animation_list))) { |
|
415 | - $params['animation'] = 'slide'; |
|
416 | - } |
|
417 | - |
|
418 | - // Post_number needs to be a positive integer |
|
419 | - $params['post_number'] = absint($params['post_number']); |
|
420 | - if (0 == $params['post_number']) { |
|
421 | - $params['post_number'] = 1; |
|
422 | - } |
|
423 | - |
|
424 | - // Manage the entered categories |
|
425 | - if (0 != $params['category'] || '' != $params['category']) { |
|
426 | - $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
427 | - } |
|
428 | - // Convert show_title to a bool |
|
429 | - $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
430 | - |
|
431 | - // Convert show_featured_only to a bool |
|
432 | - $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
433 | - |
|
434 | - /* |
|
404 | + // Check we have a valid post_type |
|
405 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
406 | + $params['post_type'] = 'gd_place'; |
|
407 | + } |
|
408 | + |
|
409 | + // Check we have a valid sort_order |
|
410 | + $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
411 | + |
|
412 | + // Match the chosen animation to our options |
|
413 | + $animation_list = array('slide', 'fade'); |
|
414 | + if (!(in_array($params['animation'], $animation_list))) { |
|
415 | + $params['animation'] = 'slide'; |
|
416 | + } |
|
417 | + |
|
418 | + // Post_number needs to be a positive integer |
|
419 | + $params['post_number'] = absint($params['post_number']); |
|
420 | + if (0 == $params['post_number']) { |
|
421 | + $params['post_number'] = 1; |
|
422 | + } |
|
423 | + |
|
424 | + // Manage the entered categories |
|
425 | + if (0 != $params['category'] || '' != $params['category']) { |
|
426 | + $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
427 | + } |
|
428 | + // Convert show_title to a bool |
|
429 | + $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
430 | + |
|
431 | + // Convert show_featured_only to a bool |
|
432 | + $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
433 | + |
|
434 | + /* |
|
435 | 435 | * Hopefully all attributes are now valid, and safe to pass forward |
436 | 436 | */ |
437 | 437 | |
438 | - // redeclare vars after validation |
|
439 | - |
|
440 | - if (isset($params['direction_nav'])) { |
|
441 | - $params['directionNav'] = $params['direction_nav']; |
|
442 | - } |
|
443 | - if (isset($params['animation_loop'])) { |
|
444 | - $params['animationLoop'] = $params['animation_loop']; |
|
445 | - } |
|
446 | - if (isset($params['slideshow_speed'])) { |
|
447 | - $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
448 | - } |
|
449 | - if (isset($params['animation_speed'])) { |
|
450 | - $params['animationSpeed'] = $params['animation_speed']; |
|
451 | - } |
|
452 | - if (isset($params['order_by'])) { |
|
453 | - $params['list_sort'] = $params['order_by']; |
|
454 | - } |
|
455 | - |
|
456 | - $query_args = array( |
|
457 | - 'post_number' => $params['post_number'], |
|
458 | - 'is_geodir_loop' => true, |
|
459 | - 'post_type' => $params['post_type'], |
|
460 | - 'order_by' => $params['order_by'] |
|
461 | - ); |
|
462 | - |
|
463 | - if (1 == $params['show_featured_only']) { |
|
464 | - $query_args['show_featured_only'] = 1; |
|
465 | - } |
|
466 | - |
|
467 | - if (0 != $params['category'] && '' != $params['category']) { |
|
468 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
469 | - $tax_query = array( |
|
470 | - 'taxonomy' => $category_taxonomy[0], |
|
471 | - 'field' => 'id', |
|
472 | - 'terms' => $params['category'], |
|
473 | - ); |
|
474 | - |
|
475 | - $query_args['tax_query'] = array($tax_query); |
|
476 | - } |
|
477 | - |
|
478 | - $defaults = array( |
|
479 | - 'before_widget' => '', |
|
480 | - 'after_widget' => '', |
|
481 | - 'before_title' => '', |
|
482 | - 'after_title' => '', |
|
483 | - ); |
|
484 | - |
|
485 | - $query_args = array_merge($query_args, $params); |
|
486 | - |
|
487 | - geodir_listing_slider_widget_output($defaults, $query_args); |
|
488 | - |
|
489 | - $output = ob_get_contents(); |
|
490 | - |
|
491 | - ob_end_clean(); |
|
492 | - |
|
493 | - return $output; |
|
438 | + // redeclare vars after validation |
|
439 | + |
|
440 | + if (isset($params['direction_nav'])) { |
|
441 | + $params['directionNav'] = $params['direction_nav']; |
|
442 | + } |
|
443 | + if (isset($params['animation_loop'])) { |
|
444 | + $params['animationLoop'] = $params['animation_loop']; |
|
445 | + } |
|
446 | + if (isset($params['slideshow_speed'])) { |
|
447 | + $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
448 | + } |
|
449 | + if (isset($params['animation_speed'])) { |
|
450 | + $params['animationSpeed'] = $params['animation_speed']; |
|
451 | + } |
|
452 | + if (isset($params['order_by'])) { |
|
453 | + $params['list_sort'] = $params['order_by']; |
|
454 | + } |
|
455 | + |
|
456 | + $query_args = array( |
|
457 | + 'post_number' => $params['post_number'], |
|
458 | + 'is_geodir_loop' => true, |
|
459 | + 'post_type' => $params['post_type'], |
|
460 | + 'order_by' => $params['order_by'] |
|
461 | + ); |
|
462 | + |
|
463 | + if (1 == $params['show_featured_only']) { |
|
464 | + $query_args['show_featured_only'] = 1; |
|
465 | + } |
|
466 | + |
|
467 | + if (0 != $params['category'] && '' != $params['category']) { |
|
468 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
469 | + $tax_query = array( |
|
470 | + 'taxonomy' => $category_taxonomy[0], |
|
471 | + 'field' => 'id', |
|
472 | + 'terms' => $params['category'], |
|
473 | + ); |
|
474 | + |
|
475 | + $query_args['tax_query'] = array($tax_query); |
|
476 | + } |
|
477 | + |
|
478 | + $defaults = array( |
|
479 | + 'before_widget' => '', |
|
480 | + 'after_widget' => '', |
|
481 | + 'before_title' => '', |
|
482 | + 'after_title' => '', |
|
483 | + ); |
|
484 | + |
|
485 | + $query_args = array_merge($query_args, $params); |
|
486 | + |
|
487 | + geodir_listing_slider_widget_output($defaults, $query_args); |
|
488 | + |
|
489 | + $output = ob_get_contents(); |
|
490 | + |
|
491 | + ob_end_clean(); |
|
492 | + |
|
493 | + return $output; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | add_shortcode('gd_login_box', 'geodir_sc_login_box'); |
@@ -514,22 +514,22 @@ discard block |
||
514 | 514 | */ |
515 | 515 | function geodir_sc_login_box($atts) |
516 | 516 | { |
517 | - ob_start(); |
|
517 | + ob_start(); |
|
518 | 518 | |
519 | - $defaults = array( |
|
520 | - 'before_widget' => '', |
|
521 | - 'after_widget' => '', |
|
522 | - 'before_title' => '', |
|
523 | - 'after_title' => '', |
|
524 | - ); |
|
519 | + $defaults = array( |
|
520 | + 'before_widget' => '', |
|
521 | + 'after_widget' => '', |
|
522 | + 'before_title' => '', |
|
523 | + 'after_title' => '', |
|
524 | + ); |
|
525 | 525 | |
526 | - geodir_loginwidget_output($defaults, $defaults); |
|
526 | + geodir_loginwidget_output($defaults, $defaults); |
|
527 | 527 | |
528 | - $output = ob_get_contents(); |
|
528 | + $output = ob_get_contents(); |
|
529 | 529 | |
530 | - ob_end_clean(); |
|
530 | + ob_end_clean(); |
|
531 | 531 | |
532 | - return $output; |
|
532 | + return $output; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category'); |
@@ -558,28 +558,28 @@ discard block |
||
558 | 558 | */ |
559 | 559 | function geodir_sc_popular_post_category($atts) |
560 | 560 | { |
561 | - ob_start(); |
|
562 | - global $geodir_post_category_str; |
|
563 | - $defaults = array( |
|
564 | - 'category_limit' => 15, |
|
565 | - 'before_widget' => '', |
|
566 | - 'after_widget' => '', |
|
567 | - 'before_title' => '', |
|
568 | - 'after_title' => '', |
|
569 | - 'title' => '', |
|
561 | + ob_start(); |
|
562 | + global $geodir_post_category_str; |
|
563 | + $defaults = array( |
|
564 | + 'category_limit' => 15, |
|
565 | + 'before_widget' => '', |
|
566 | + 'after_widget' => '', |
|
567 | + 'before_title' => '', |
|
568 | + 'after_title' => '', |
|
569 | + 'title' => '', |
|
570 | 570 | 'default_post_type' => '', |
571 | - ); |
|
571 | + ); |
|
572 | 572 | |
573 | - $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
574 | - $params['category_limit'] = absint($params['category_limit']); |
|
573 | + $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
574 | + $params['category_limit'] = absint($params['category_limit']); |
|
575 | 575 | $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
576 | - geodir_popular_post_category_output($params, $params); |
|
576 | + geodir_popular_post_category_output($params, $params); |
|
577 | 577 | |
578 | - $output = ob_get_contents(); |
|
578 | + $output = ob_get_contents(); |
|
579 | 579 | |
580 | - ob_end_clean(); |
|
580 | + ob_end_clean(); |
|
581 | 581 | |
582 | - return $output; |
|
582 | + return $output; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view'); |
@@ -619,97 +619,97 @@ discard block |
||
619 | 619 | */ |
620 | 620 | function geodir_sc_popular_post_view($atts) |
621 | 621 | { |
622 | - ob_start(); |
|
623 | - $defaults = array( |
|
624 | - 'post_type' => 'gd_place', |
|
625 | - 'category' => '0', |
|
626 | - 'post_number' => '5', |
|
627 | - 'layout' => 'gridview_onehalf', |
|
628 | - 'add_location_filter' => '0', |
|
629 | - 'list_sort' => 'latest', |
|
630 | - 'use_viewing_post_type' => '1', |
|
631 | - 'character_count' => '20', |
|
632 | - 'listing_width' => '', |
|
633 | - 'show_featured_only' => '0', |
|
634 | - 'show_special_only' => '0', |
|
635 | - 'with_pics_only' => '0', |
|
636 | - 'with_videos_only' => '0', |
|
637 | - 'before_widget' => '', |
|
638 | - 'after_widget' => '', |
|
639 | - 'before_title' => '<h3 class="widget-title">', |
|
640 | - 'after_title' => '</h3>', |
|
641 | - 'title' => '', |
|
642 | - 'category_title' => '', |
|
643 | - ); |
|
644 | - |
|
645 | - $params = shortcode_atts($defaults, $atts); |
|
646 | - |
|
647 | - /** |
|
648 | - * Validate our incoming params |
|
649 | - */ |
|
622 | + ob_start(); |
|
623 | + $defaults = array( |
|
624 | + 'post_type' => 'gd_place', |
|
625 | + 'category' => '0', |
|
626 | + 'post_number' => '5', |
|
627 | + 'layout' => 'gridview_onehalf', |
|
628 | + 'add_location_filter' => '0', |
|
629 | + 'list_sort' => 'latest', |
|
630 | + 'use_viewing_post_type' => '1', |
|
631 | + 'character_count' => '20', |
|
632 | + 'listing_width' => '', |
|
633 | + 'show_featured_only' => '0', |
|
634 | + 'show_special_only' => '0', |
|
635 | + 'with_pics_only' => '0', |
|
636 | + 'with_videos_only' => '0', |
|
637 | + 'before_widget' => '', |
|
638 | + 'after_widget' => '', |
|
639 | + 'before_title' => '<h3 class="widget-title">', |
|
640 | + 'after_title' => '</h3>', |
|
641 | + 'title' => '', |
|
642 | + 'category_title' => '', |
|
643 | + ); |
|
650 | 644 | |
651 | - // Validate the selected post type, default to gd_place on fail |
|
652 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
653 | - $params['post_type'] = 'gd_place'; |
|
654 | - } |
|
655 | - |
|
656 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
657 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
658 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
659 | - |
|
660 | - // Make sure we have an array |
|
661 | - if (!(is_array($params['category']))) { |
|
662 | - $params['category'] = explode(',', $params['category']); |
|
663 | - } |
|
664 | - |
|
665 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
666 | - // Otherwise it becomes empty and later on that will mean "All" |
|
667 | - $params['category'] = array_intersect($params['category'], $categories); |
|
668 | - |
|
669 | - // Post_number needs to be a positive integer |
|
670 | - $params['post_number'] = absint($params['post_number']); |
|
671 | - if (0 == $params['post_number']) { |
|
672 | - $params['post_number'] = 1; |
|
673 | - } |
|
674 | - |
|
675 | - // Validate our layout choice |
|
676 | - // Outside of the norm, I added some more simple terms to match the existing |
|
677 | - // So now I just run the switch to set it properly. |
|
678 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
679 | - |
|
680 | - // Validate our sorting choice |
|
681 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
682 | - |
|
683 | - // Validate character_count |
|
684 | - $params['character_count'] = absint($params['character_count']); |
|
685 | - if (20 > $params['character_count']) { |
|
686 | - $params['character_count'] = 20; |
|
687 | - } |
|
688 | - |
|
689 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
690 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
691 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
692 | - |
|
693 | - // Validate the checkboxes used on the widget |
|
694 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
695 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
696 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
697 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
698 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
699 | - $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
700 | - |
|
701 | - /** |
|
702 | - * End of validation |
|
703 | - */ |
|
645 | + $params = shortcode_atts($defaults, $atts); |
|
646 | + |
|
647 | + /** |
|
648 | + * Validate our incoming params |
|
649 | + */ |
|
650 | + |
|
651 | + // Validate the selected post type, default to gd_place on fail |
|
652 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
653 | + $params['post_type'] = 'gd_place'; |
|
654 | + } |
|
655 | + |
|
656 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
657 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
658 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
659 | + |
|
660 | + // Make sure we have an array |
|
661 | + if (!(is_array($params['category']))) { |
|
662 | + $params['category'] = explode(',', $params['category']); |
|
663 | + } |
|
664 | + |
|
665 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
666 | + // Otherwise it becomes empty and later on that will mean "All" |
|
667 | + $params['category'] = array_intersect($params['category'], $categories); |
|
668 | + |
|
669 | + // Post_number needs to be a positive integer |
|
670 | + $params['post_number'] = absint($params['post_number']); |
|
671 | + if (0 == $params['post_number']) { |
|
672 | + $params['post_number'] = 1; |
|
673 | + } |
|
674 | + |
|
675 | + // Validate our layout choice |
|
676 | + // Outside of the norm, I added some more simple terms to match the existing |
|
677 | + // So now I just run the switch to set it properly. |
|
678 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
679 | + |
|
680 | + // Validate our sorting choice |
|
681 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
704 | 682 | |
705 | - geodir_popular_postview_output($params, $params); |
|
683 | + // Validate character_count |
|
684 | + $params['character_count'] = absint($params['character_count']); |
|
685 | + if (20 > $params['character_count']) { |
|
686 | + $params['character_count'] = 20; |
|
687 | + } |
|
688 | + |
|
689 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
690 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
691 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
692 | + |
|
693 | + // Validate the checkboxes used on the widget |
|
694 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
695 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
696 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
697 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
698 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
699 | + $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
700 | + |
|
701 | + /** |
|
702 | + * End of validation |
|
703 | + */ |
|
704 | + |
|
705 | + geodir_popular_postview_output($params, $params); |
|
706 | 706 | |
707 | 707 | |
708 | - $output = ob_get_contents(); |
|
708 | + $output = ob_get_contents(); |
|
709 | 709 | |
710 | - ob_end_clean(); |
|
710 | + ob_end_clean(); |
|
711 | 711 | |
712 | - return $output; |
|
712 | + return $output; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews'); |
@@ -731,37 +731,37 @@ discard block |
||
731 | 731 | * @return string Recent reviews HTML. |
732 | 732 | */ |
733 | 733 | function geodir_sc_recent_reviews($atts) { |
734 | - ob_start(); |
|
735 | - $defaults = array( |
|
734 | + ob_start(); |
|
735 | + $defaults = array( |
|
736 | 736 | 'title' => '', |
737 | 737 | 'count' => 5, |
738 | - ); |
|
738 | + ); |
|
739 | 739 | |
740 | - $params = shortcode_atts($defaults, $atts); |
|
740 | + $params = shortcode_atts($defaults, $atts); |
|
741 | 741 | |
742 | - $count = absint($params['count']); |
|
743 | - if (0 == $count) { |
|
744 | - $count = 1; |
|
745 | - } |
|
742 | + $count = absint($params['count']); |
|
743 | + if (0 == $count) { |
|
744 | + $count = 1; |
|
745 | + } |
|
746 | 746 | |
747 | 747 | $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; |
748 | 748 | |
749 | - $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
749 | + $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
750 | 750 | |
751 | - if ($comments_li) { |
|
752 | - if ($title != '') { ?> |
|
751 | + if ($comments_li) { |
|
752 | + if ($title != '') { ?> |
|
753 | 753 | <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3> |
754 | 754 | <?php } ?> |
755 | 755 | <div class="geodir_sc_recent_reviews_section"> |
756 | 756 | <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul> |
757 | 757 | </div> |
758 | 758 | <?php |
759 | - } |
|
760 | - $output = ob_get_contents(); |
|
759 | + } |
|
760 | + $output = ob_get_contents(); |
|
761 | 761 | |
762 | - ob_end_clean(); |
|
762 | + ob_end_clean(); |
|
763 | 763 | |
764 | - return $output; |
|
764 | + return $output; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | add_shortcode('gd_related_listings', 'geodir_sc_related_listings'); |
@@ -791,64 +791,64 @@ discard block |
||
791 | 791 | */ |
792 | 792 | function geodir_sc_related_listings($atts) |
793 | 793 | { |
794 | - ob_start(); |
|
795 | - $defaults = array( |
|
796 | - 'post_number' => 5, |
|
797 | - 'relate_to' => 'category', |
|
798 | - 'layout' => 'gridview_onehalf', |
|
799 | - 'add_location_filter' => 0, |
|
800 | - 'listing_width' => '', |
|
801 | - 'list_sort' => 'latest', |
|
802 | - 'character_count' => 20, |
|
803 | - 'is_widget' => 1, |
|
804 | - 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
805 | - ); |
|
806 | - // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
807 | - |
|
808 | - $params = shortcode_atts($defaults, $atts); |
|
809 | - |
|
810 | - /** |
|
811 | - * Begin validating parameters |
|
812 | - */ |
|
794 | + ob_start(); |
|
795 | + $defaults = array( |
|
796 | + 'post_number' => 5, |
|
797 | + 'relate_to' => 'category', |
|
798 | + 'layout' => 'gridview_onehalf', |
|
799 | + 'add_location_filter' => 0, |
|
800 | + 'listing_width' => '', |
|
801 | + 'list_sort' => 'latest', |
|
802 | + 'character_count' => 20, |
|
803 | + 'is_widget' => 1, |
|
804 | + 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
805 | + ); |
|
806 | + // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
807 | + |
|
808 | + $params = shortcode_atts($defaults, $atts); |
|
813 | 809 | |
814 | - // Validate that post_number is a number and is 1 or higher |
|
815 | - $params['post_number'] = absint($params['post_number']); |
|
816 | - if (0 === $params['post_number']) { |
|
817 | - $params['post_number'] = 1; |
|
818 | - } |
|
810 | + /** |
|
811 | + * Begin validating parameters |
|
812 | + */ |
|
813 | + |
|
814 | + // Validate that post_number is a number and is 1 or higher |
|
815 | + $params['post_number'] = absint($params['post_number']); |
|
816 | + if (0 === $params['post_number']) { |
|
817 | + $params['post_number'] = 1; |
|
818 | + } |
|
819 | 819 | |
820 | - // Validate relate_to - only category or tags |
|
821 | - $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
822 | - if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
823 | - $params['relate_to'] = 'category'; |
|
824 | - } |
|
820 | + // Validate relate_to - only category or tags |
|
821 | + $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
822 | + if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
823 | + $params['relate_to'] = 'category'; |
|
824 | + } |
|
825 | 825 | |
826 | - // Validate layout selection |
|
827 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
826 | + // Validate layout selection |
|
827 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
828 | 828 | |
829 | - // Validate sorting option |
|
830 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
829 | + // Validate sorting option |
|
830 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
831 | 831 | |
832 | - // Validate add_location_filter |
|
833 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
832 | + // Validate add_location_filter |
|
833 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
834 | 834 | |
835 | - // Validate listing_width |
|
836 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
835 | + // Validate listing_width |
|
836 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
837 | 837 | |
838 | - // Validate character_count |
|
839 | - $params['character_count'] = absint($params['character_count']); |
|
840 | - if (20 > $params['character_count']) { |
|
841 | - $params['character_count'] = 20; |
|
842 | - } |
|
838 | + // Validate character_count |
|
839 | + $params['character_count'] = absint($params['character_count']); |
|
840 | + if (20 > $params['character_count']) { |
|
841 | + $params['character_count'] = 20; |
|
842 | + } |
|
843 | 843 | |
844 | - if ($related_display = geodir_related_posts_display($params)) { |
|
845 | - echo $related_display; |
|
846 | - } |
|
847 | - $output = ob_get_contents(); |
|
844 | + if ($related_display = geodir_related_posts_display($params)) { |
|
845 | + echo $related_display; |
|
846 | + } |
|
847 | + $output = ob_get_contents(); |
|
848 | 848 | |
849 | - ob_end_clean(); |
|
849 | + ob_end_clean(); |
|
850 | 850 | |
851 | - return $output; |
|
851 | + return $output; |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | * @return string Advanced search widget HTML. |
873 | 873 | */ |
874 | 874 | function geodir_sc_advanced_search($atts) { |
875 | - $defaults = array( |
|
875 | + $defaults = array( |
|
876 | 876 | 'title' => '', |
877 | 877 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
878 | - 'after_widget' => '</section>', |
|
879 | - 'before_title' => '<h3 class="widget-title">', |
|
880 | - 'after_title' => '</h3>', |
|
878 | + 'after_widget' => '</section>', |
|
879 | + 'before_title' => '<h3 class="widget-title">', |
|
880 | + 'after_title' => '</h3>', |
|
881 | 881 | 'show_adv_search' => 'default' |
882 | 882 | ); |
883 | 883 | |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | the_widget('geodir_advance_search_widget', $params, $params ); |
902 | 902 | |
903 | 903 | $output = ob_get_contents(); |
904 | - ob_end_clean(); |
|
904 | + ob_end_clean(); |
|
905 | 905 | |
906 | - return $output; |
|
906 | + return $output; |
|
907 | 907 | } |
908 | 908 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
909 | 909 | |
@@ -949,48 +949,48 @@ discard block |
||
949 | 949 | 'add_location_filter' => '1', |
950 | 950 | 'tab_layout' => 'bestof-tabs-on-top', |
951 | 951 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
952 | - 'after_widget' => '</section>', |
|
953 | - 'before_title' => '<h3 class="widget-title">', |
|
954 | - 'after_title' => '</h3>', |
|
952 | + 'after_widget' => '</section>', |
|
953 | + 'before_title' => '<h3 class="widget-title">', |
|
954 | + 'after_title' => '</h3>', |
|
955 | 955 | ); |
956 | 956 | $params = shortcode_atts($defaults, $atts); |
957 | 957 | |
958 | - /** |
|
959 | - * Validate our incoming params |
|
960 | - */ |
|
958 | + /** |
|
959 | + * Validate our incoming params |
|
960 | + */ |
|
961 | 961 | |
962 | - // Validate the selected post type, default to gd_place on fail |
|
963 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
964 | - $params['post_type'] = 'gd_place'; |
|
965 | - } |
|
962 | + // Validate the selected post type, default to gd_place on fail |
|
963 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
964 | + $params['post_type'] = 'gd_place'; |
|
965 | + } |
|
966 | 966 | |
967 | 967 | // Post limit needs to be a positive integer |
968 | - $params['post_limit'] = absint($params['post_limit']); |
|
969 | - if (0 == $params['post_limit']) { |
|
970 | - $params['post_limit'] = 5; |
|
971 | - } |
|
968 | + $params['post_limit'] = absint($params['post_limit']); |
|
969 | + if (0 == $params['post_limit']) { |
|
970 | + $params['post_limit'] = 5; |
|
971 | + } |
|
972 | 972 | |
973 | 973 | // Category limit needs to be a positive integer |
974 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
975 | - if (0 == $params['categ_limit']) { |
|
976 | - $params['categ_limit'] = 3; |
|
977 | - } |
|
974 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
975 | + if (0 == $params['categ_limit']) { |
|
976 | + $params['categ_limit'] = 3; |
|
977 | + } |
|
978 | 978 | |
979 | 979 | // Tab layout validation |
980 | - $params['tab_layout'] = $params['tab_layout']; |
|
981 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
982 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
983 | - } |
|
980 | + $params['tab_layout'] = $params['tab_layout']; |
|
981 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
982 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
983 | + } |
|
984 | 984 | |
985 | 985 | // Validate character_count |
986 | - $params['character_count'] = $params['character_count']; |
|
986 | + $params['character_count'] = $params['character_count']; |
|
987 | 987 | |
988 | 988 | ob_start(); |
989 | 989 | the_widget('geodir_bestof_widget', $params, $params); |
990 | - $output = ob_get_contents(); |
|
991 | - ob_end_clean(); |
|
990 | + $output = ob_get_contents(); |
|
991 | + ob_end_clean(); |
|
992 | 992 | |
993 | - return $output; |
|
993 | + return $output; |
|
994 | 994 | } |
995 | 995 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
996 | 996 | |
@@ -1038,127 +1038,127 @@ discard block |
||
1038 | 1038 | * @return string HTML content to display geodirectory listings. |
1039 | 1039 | */ |
1040 | 1040 | function geodir_sc_gd_listings($atts, $content = '') { |
1041 | - global $post; |
|
1042 | - $defaults = array( |
|
1043 | - 'title' => '', |
|
1044 | - 'post_type' => 'gd_place', |
|
1045 | - 'category' => 0, |
|
1046 | - 'list_sort' => 'latest', |
|
1047 | - 'event_type' => '', |
|
1048 | - 'post_number' => 10, |
|
1049 | - 'post_author' => '', |
|
1050 | - 'layout' => 'gridview_onehalf', |
|
1051 | - 'listing_width' => '', |
|
1052 | - 'character_count' => 20, |
|
1053 | - 'add_location_filter' => 1, |
|
1054 | - 'show_featured_only' => '', |
|
1055 | - 'show_special_only' => '', |
|
1056 | - 'with_pics_only' => '', |
|
1057 | - 'with_videos_only' => '', |
|
1058 | - 'with_pagination' => '1', |
|
1059 | - 'top_pagination' => '0', |
|
1060 | - 'bottom_pagination' => '1', |
|
1061 | - 'without_no_results' => 0, |
|
1062 | - 'tags' => '' |
|
1063 | - ); |
|
1064 | - $params = shortcode_atts($defaults, $atts); |
|
1065 | - |
|
1066 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
1067 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1068 | - |
|
1069 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
1070 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1071 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1072 | - |
|
1073 | - // Make sure we have an array |
|
1074 | - if (!(is_array($params['category']))) { |
|
1075 | - $params['category'] = explode(',', $params['category']); |
|
1076 | - } |
|
1077 | - |
|
1078 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1079 | - // Otherwise it becomes empty and later on that will mean "All" |
|
1080 | - $params['category'] = array_intersect($params['category'], $categories); |
|
1081 | - |
|
1082 | - // Post_number needs to be a positive integer |
|
1083 | - $params['post_number'] = absint($params['post_number']); |
|
1084 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1041 | + global $post; |
|
1042 | + $defaults = array( |
|
1043 | + 'title' => '', |
|
1044 | + 'post_type' => 'gd_place', |
|
1045 | + 'category' => 0, |
|
1046 | + 'list_sort' => 'latest', |
|
1047 | + 'event_type' => '', |
|
1048 | + 'post_number' => 10, |
|
1049 | + 'post_author' => '', |
|
1050 | + 'layout' => 'gridview_onehalf', |
|
1051 | + 'listing_width' => '', |
|
1052 | + 'character_count' => 20, |
|
1053 | + 'add_location_filter' => 1, |
|
1054 | + 'show_featured_only' => '', |
|
1055 | + 'show_special_only' => '', |
|
1056 | + 'with_pics_only' => '', |
|
1057 | + 'with_videos_only' => '', |
|
1058 | + 'with_pagination' => '1', |
|
1059 | + 'top_pagination' => '0', |
|
1060 | + 'bottom_pagination' => '1', |
|
1061 | + 'without_no_results' => 0, |
|
1062 | + 'tags' => '' |
|
1063 | + ); |
|
1064 | + $params = shortcode_atts($defaults, $atts); |
|
1065 | + |
|
1066 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
1067 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1068 | + |
|
1069 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
1070 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1071 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1072 | + |
|
1073 | + // Make sure we have an array |
|
1074 | + if (!(is_array($params['category']))) { |
|
1075 | + $params['category'] = explode(',', $params['category']); |
|
1076 | + } |
|
1077 | + |
|
1078 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1079 | + // Otherwise it becomes empty and later on that will mean "All" |
|
1080 | + $params['category'] = array_intersect($params['category'], $categories); |
|
1081 | + |
|
1082 | + // Post_number needs to be a positive integer |
|
1083 | + $params['post_number'] = absint($params['post_number']); |
|
1084 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1085 | 1085 | |
1086 | - // Post_number needs to be a positive integer |
|
1087 | - if (!empty($atts['post_author'])) { |
|
1088 | - if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1089 | - $params['post_author'] = $post->post_author; |
|
1090 | - } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1091 | - $params['post_author'] = absint($atts['post_author']); |
|
1092 | - } else { |
|
1093 | - unset($params['post_author']); |
|
1094 | - } |
|
1095 | - } else { |
|
1096 | - unset($params['post_author']); |
|
1097 | - } |
|
1098 | - |
|
1099 | - // Validate character_count |
|
1100 | - //todo: is this necessary? |
|
1101 | - $params['character_count'] = $params['character_count']; |
|
1102 | - |
|
1103 | - // Validate our layout choice |
|
1104 | - // Outside of the norm, I added some more simple terms to match the existing |
|
1105 | - // So now I just run the switch to set it properly. |
|
1106 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1107 | - |
|
1108 | - // Validate our sorting choice |
|
1109 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1110 | - |
|
1111 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
1112 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1113 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1114 | - |
|
1115 | - // Validate the checkboxes used on the widget |
|
1116 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1117 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1118 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1119 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1120 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1121 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1122 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1123 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1124 | - |
|
1125 | - // Clean tags |
|
1126 | - if (!empty($params['tags'])) { |
|
1127 | - if (!is_array($params['tags'])) { |
|
1128 | - $comma = _x(',', 'tag delimiter'); |
|
1129 | - if ( ',' !== $comma ) { |
|
1130 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1131 | - } |
|
1132 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1133 | - $params['tags'] = array_map('trim', $params['tags']); |
|
1134 | - } |
|
1135 | - } else { |
|
1136 | - $params['tags'] = array(); |
|
1137 | - } |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * End of validation |
|
1141 | - */ |
|
1142 | - if (isset($atts['geodir_ajax'])) { |
|
1143 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1144 | - unset($atts['geodir_ajax']); |
|
1145 | - } |
|
1146 | - if (isset($atts['pageno'])) { |
|
1147 | - $params['pageno'] = $atts['pageno']; |
|
1148 | - unset($atts['pageno']); |
|
1149 | - } |
|
1150 | - |
|
1151 | - if ( !empty($atts['shortcode_content']) ) { |
|
1152 | - $content = $atts['shortcode_content']; |
|
1153 | - } |
|
1154 | - $params['shortcode_content'] = trim($content); |
|
1155 | - $atts['shortcode_content'] = trim($content); |
|
1086 | + // Post_number needs to be a positive integer |
|
1087 | + if (!empty($atts['post_author'])) { |
|
1088 | + if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1089 | + $params['post_author'] = $post->post_author; |
|
1090 | + } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1091 | + $params['post_author'] = absint($atts['post_author']); |
|
1092 | + } else { |
|
1093 | + unset($params['post_author']); |
|
1094 | + } |
|
1095 | + } else { |
|
1096 | + unset($params['post_author']); |
|
1097 | + } |
|
1098 | + |
|
1099 | + // Validate character_count |
|
1100 | + //todo: is this necessary? |
|
1101 | + $params['character_count'] = $params['character_count']; |
|
1102 | + |
|
1103 | + // Validate our layout choice |
|
1104 | + // Outside of the norm, I added some more simple terms to match the existing |
|
1105 | + // So now I just run the switch to set it properly. |
|
1106 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1107 | + |
|
1108 | + // Validate our sorting choice |
|
1109 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1110 | + |
|
1111 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
1112 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1113 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1114 | + |
|
1115 | + // Validate the checkboxes used on the widget |
|
1116 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1117 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1118 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1119 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1120 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1121 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1122 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1123 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1124 | + |
|
1125 | + // Clean tags |
|
1126 | + if (!empty($params['tags'])) { |
|
1127 | + if (!is_array($params['tags'])) { |
|
1128 | + $comma = _x(',', 'tag delimiter'); |
|
1129 | + if ( ',' !== $comma ) { |
|
1130 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1131 | + } |
|
1132 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1133 | + $params['tags'] = array_map('trim', $params['tags']); |
|
1134 | + } |
|
1135 | + } else { |
|
1136 | + $params['tags'] = array(); |
|
1137 | + } |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * End of validation |
|
1141 | + */ |
|
1142 | + if (isset($atts['geodir_ajax'])) { |
|
1143 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1144 | + unset($atts['geodir_ajax']); |
|
1145 | + } |
|
1146 | + if (isset($atts['pageno'])) { |
|
1147 | + $params['pageno'] = $atts['pageno']; |
|
1148 | + unset($atts['pageno']); |
|
1149 | + } |
|
1150 | + |
|
1151 | + if ( !empty($atts['shortcode_content']) ) { |
|
1152 | + $content = $atts['shortcode_content']; |
|
1153 | + } |
|
1154 | + $params['shortcode_content'] = trim($content); |
|
1155 | + $atts['shortcode_content'] = trim($content); |
|
1156 | 1156 | |
1157 | - $params['shortcode_atts'] = $atts; |
|
1157 | + $params['shortcode_atts'] = $atts; |
|
1158 | 1158 | |
1159 | - $output = geodir_sc_gd_listings_output($params); |
|
1159 | + $output = geodir_sc_gd_listings_output($params); |
|
1160 | 1160 | |
1161 | - return $output; |
|
1161 | + return $output; |
|
1162 | 1162 | } |
1163 | 1163 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
1164 | 1164 | |
@@ -1198,56 +1198,56 @@ discard block |
||
1198 | 1198 | * @return string HTML content to display CPT categories. |
1199 | 1199 | */ |
1200 | 1200 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
1201 | - $defaults = array( |
|
1202 | - 'title' => '', |
|
1203 | - 'post_type' => '', // NULL for all |
|
1204 | - 'hide_empty' => '', |
|
1205 | - 'show_count' => '', |
|
1206 | - 'hide_icon' => '', |
|
1207 | - 'cpt_left' => '', |
|
1208 | - 'sort_by' => 'count', |
|
1209 | - 'max_count' => 'all', |
|
1210 | - 'max_level' => '1', |
|
1211 | - 'no_cpt_filter' => '', |
|
1212 | - 'no_cat_filter' => '', |
|
1213 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1214 | - 'after_widget' => '</section>', |
|
1215 | - 'before_title' => '<h3 class="widget-title">', |
|
1216 | - 'after_title' => '</h3>', |
|
1217 | - ); |
|
1218 | - $params = shortcode_atts($defaults, $atts); |
|
1219 | - |
|
1220 | - /** |
|
1221 | - * Validate our incoming params |
|
1222 | - */ |
|
1223 | - // Make sure we have an array |
|
1224 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1225 | - |
|
1226 | - // Validate the checkboxes used on the widget |
|
1227 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1228 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1229 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1230 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1201 | + $defaults = array( |
|
1202 | + 'title' => '', |
|
1203 | + 'post_type' => '', // NULL for all |
|
1204 | + 'hide_empty' => '', |
|
1205 | + 'show_count' => '', |
|
1206 | + 'hide_icon' => '', |
|
1207 | + 'cpt_left' => '', |
|
1208 | + 'sort_by' => 'count', |
|
1209 | + 'max_count' => 'all', |
|
1210 | + 'max_level' => '1', |
|
1211 | + 'no_cpt_filter' => '', |
|
1212 | + 'no_cat_filter' => '', |
|
1213 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1214 | + 'after_widget' => '</section>', |
|
1215 | + 'before_title' => '<h3 class="widget-title">', |
|
1216 | + 'after_title' => '</h3>', |
|
1217 | + ); |
|
1218 | + $params = shortcode_atts($defaults, $atts); |
|
1231 | 1219 | |
1232 | - if ($params['max_count'] != 'all') { |
|
1233 | - $params['max_count'] = absint($params['max_count']); |
|
1234 | - } |
|
1220 | + /** |
|
1221 | + * Validate our incoming params |
|
1222 | + */ |
|
1223 | + // Make sure we have an array |
|
1224 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1225 | + |
|
1226 | + // Validate the checkboxes used on the widget |
|
1227 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1228 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1229 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1230 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1231 | + |
|
1232 | + if ($params['max_count'] != 'all') { |
|
1233 | + $params['max_count'] = absint($params['max_count']); |
|
1234 | + } |
|
1235 | 1235 | |
1236 | - if ($params['max_level'] != 'all') { |
|
1237 | - $params['max_level'] = absint($params['max_level']); |
|
1238 | - } |
|
1236 | + if ($params['max_level'] != 'all') { |
|
1237 | + $params['max_level'] = absint($params['max_level']); |
|
1238 | + } |
|
1239 | 1239 | |
1240 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1241 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1240 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1241 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1242 | 1242 | |
1243 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1243 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1244 | 1244 | |
1245 | - ob_start(); |
|
1246 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1247 | - $output = ob_get_contents(); |
|
1248 | - ob_end_clean(); |
|
1245 | + ob_start(); |
|
1246 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1247 | + $output = ob_get_contents(); |
|
1248 | + ob_end_clean(); |
|
1249 | 1249 | |
1250 | - return $output; |
|
1250 | + return $output; |
|
1251 | 1251 | } |
1252 | 1252 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
1253 | 1253 | |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | * @return string HTML code. |
1263 | 1263 | */ |
1264 | 1264 | function geodir_sc_responsive_videos($atts, $content) { |
1265 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1265 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1266 | 1266 | } |
1267 | 1267 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
1268 | 1268 | ?> |
1269 | 1269 | \ No newline at end of file |