Test Failed
Push — master ( 501953...9a1c33 )
by
unknown
14:42
created
geodirectory-widgets/geodirectory_cpt_categories_widget.php 1 patch
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -13,241 +13,241 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 .= '</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 .= '</div>';
457
+
458
+				$output .= $cpt_row;
459
+			}
460
+		}
461
+	}
462
+	return $output;
463 463
 }
464 464
 
465 465
 /**
@@ -479,48 +479,48 @@  discard block
 block discarded – undo
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
Please login to merge, or discard this patch.