@@ -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'); |
@@ -316,177 +316,177 @@ discard block |
||
| 316 | 316 | * @return string CPT categories content. |
| 317 | 317 | */ |
| 318 | 318 | function geodir_cpt_categories_output($params) { |
| 319 | - global $post, $gd_use_query_vars; |
|
| 319 | + global $post, $gd_use_query_vars; |
|
| 320 | 320 | |
| 321 | - $old_gd_use_query_vars = $gd_use_query_vars; |
|
| 321 | + $old_gd_use_query_vars = $gd_use_query_vars; |
|
| 322 | 322 | |
| 323 | - $gd_use_query_vars = geodir_is_page('detail') ? true : false; |
|
| 323 | + $gd_use_query_vars = geodir_is_page('detail') ? true : false; |
|
| 324 | 324 | |
| 325 | - $args = wp_parse_args((array)$params, |
|
| 326 | - array( |
|
| 327 | - 'title' => '', |
|
| 328 | - 'post_type' => array(), // NULL for all |
|
| 329 | - 'hide_empty' => '', |
|
| 330 | - 'show_count' => '', |
|
| 331 | - 'hide_icon' => '', |
|
| 332 | - 'cpt_left' => '', |
|
| 333 | - 'sort_by' => 'count', |
|
| 334 | - 'max_count' => 'all', |
|
| 335 | - 'max_level' => '1', |
|
| 336 | - 'no_cpt_filter' => '', |
|
| 337 | - 'no_cat_filter' => '', |
|
| 338 | - ) |
|
| 339 | - ); |
|
| 340 | - |
|
| 341 | - $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count'; |
|
| 342 | - $cpt_filter = empty($args['no_cpt_filter']) ? true : false; |
|
| 343 | - $cat_filter = empty($args['no_cat_filter']) ? true : false; |
|
| 344 | - |
|
| 345 | - $gd_post_types = geodir_get_posttypes('array'); |
|
| 346 | - |
|
| 347 | - $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type']; |
|
| 348 | - $current_posttype = geodir_get_current_posttype(); |
|
| 349 | - |
|
| 350 | - $is_listing = false; |
|
| 351 | - $is_detail = false; |
|
| 352 | - $is_category = false; |
|
| 353 | - $post_ID = 0; |
|
| 354 | - $is_listing_page = geodir_is_page('listing'); |
|
| 355 | - $is_detail_page = geodir_is_page('detail'); |
|
| 356 | - if ($is_listing_page || $is_detail_page) { |
|
| 357 | - $current_posttype = geodir_get_current_posttype(); |
|
| 358 | - |
|
| 359 | - if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { |
|
| 360 | - if ($is_detail_page) { |
|
| 361 | - $is_detail = true; |
|
| 362 | - $post_ID = is_object($post) && !empty($post->ID) ? (int)$post->ID : 0; |
|
| 363 | - } else { |
|
| 364 | - $is_listing = true; |
|
| 365 | - if (is_tax()) { // category page |
|
| 366 | - $current_term_id = get_queried_object_id(); |
|
| 367 | - $current_taxonomy = get_query_var('taxonomy'); |
|
| 368 | - $current_posttype = geodir_get_current_posttype(); |
|
| 369 | - |
|
| 370 | - if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
| 371 | - $is_category = true; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - $parent_category = 0; |
|
| 379 | - if (($is_listing || $is_detail) && $cpt_filter) { |
|
| 380 | - $post_type_arr = array($current_posttype); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - $post_types = array(); |
|
| 384 | - if (!empty($post_type_arr)) { |
|
| 385 | - if (in_array('0', $post_type_arr)) { |
|
| 386 | - $post_types = $gd_post_types; |
|
| 387 | - } else { |
|
| 388 | - foreach ($post_type_arr as $cpt) { |
|
| 389 | - if (isset($gd_post_types[$cpt])) { |
|
| 390 | - $post_types[$cpt] = $gd_post_types[$cpt]; |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - if (empty($post_type_arr)) { |
|
| 397 | - $post_types = $gd_post_types; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - $hide_empty = !empty($args['hide_empty']) ? true : false; |
|
| 401 | - $max_count = strip_tags($args['max_count']); |
|
| 402 | - $all_childs = $max_count == 'all' ? true : false; |
|
| 403 | - $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
| 404 | - $max_level = strip_tags($args['max_level']); |
|
| 405 | - $show_count = !empty($args['show_count']) ? true : false; |
|
| 406 | - $hide_icon = !empty($args['hide_icon']) ? true : false; |
|
| 407 | - $cpt_left = !empty($args['cpt_left']) ? true : false; |
|
| 408 | - |
|
| 409 | - if(!$cpt_left){ |
|
| 410 | - $cpt_left = "gd-cpt-flat"; |
|
| 411 | - }else{ |
|
| 412 | - $cpt_left = ''; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - $orderby = 'count'; |
|
| 416 | - $order = 'DESC'; |
|
| 417 | - if ($sort_by == 'az') { |
|
| 418 | - $orderby = 'name'; |
|
| 419 | - $order = 'ASC'; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - $output = ''; |
|
| 423 | - if (!empty($post_types)) { |
|
| 424 | - foreach ($post_types as $cpt => $cpt_info) { |
|
| 425 | - $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
|
| 426 | - $cat_taxonomy = $cpt . 'category'; |
|
| 427 | - $skip_childs = false; |
|
| 428 | - if ($cat_filter && $cpt == $current_posttype && $is_detail && $post_ID) { |
|
| 429 | - $skip_childs = true; |
|
| 430 | - $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'object_ids' => $post_ID)); |
|
| 431 | - } else { |
|
| 432 | - $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - if ($hide_empty) { |
|
| 436 | - $categories = geodir_filter_empty_terms($categories); |
|
| 437 | - } |
|
| 438 | - if ($sort_by == 'count') { |
|
| 439 | - $categories = geodir_sort_terms($categories, 'count'); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - if (!empty($categories)) { |
|
| 443 | - $term_icons = !$hide_icon ? geodir_get_term_icon() : array(); |
|
| 444 | - $row_class = ''; |
|
| 445 | - |
|
| 446 | - if ($is_listing) { |
|
| 447 | - $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
|
| 448 | - } |
|
| 449 | - $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
| 450 | - |
|
| 451 | - if ($is_category && $cat_filter && $cpt == $current_posttype) { |
|
| 452 | - $term_info = get_term($current_term_id, $cat_taxonomy); |
|
| 453 | - |
|
| 454 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
|
| 455 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 456 | - |
|
| 457 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
| 458 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
| 459 | - } else { |
|
| 460 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
| 461 | - } |
|
| 462 | - foreach ($categories as $category) { |
|
| 463 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
| 464 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 465 | - |
|
| 466 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 467 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 468 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 469 | - |
|
| 470 | - $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
|
| 471 | - $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
|
| 472 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 473 | - $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>'; |
|
| 474 | - if (!$skip_childs && ($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
| 475 | - $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
|
| 476 | - } |
|
| 477 | - $cpt_row .= '</li>'; |
|
| 478 | - $cpt_row .= '</ul>'; |
|
| 479 | - } |
|
| 480 | - $cpt_row .= '</div>'; |
|
| 481 | - |
|
| 482 | - $output .= $cpt_row; |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - } |
|
| 325 | + $args = wp_parse_args((array)$params, |
|
| 326 | + array( |
|
| 327 | + 'title' => '', |
|
| 328 | + 'post_type' => array(), // NULL for all |
|
| 329 | + 'hide_empty' => '', |
|
| 330 | + 'show_count' => '', |
|
| 331 | + 'hide_icon' => '', |
|
| 332 | + 'cpt_left' => '', |
|
| 333 | + 'sort_by' => 'count', |
|
| 334 | + 'max_count' => 'all', |
|
| 335 | + 'max_level' => '1', |
|
| 336 | + 'no_cpt_filter' => '', |
|
| 337 | + 'no_cat_filter' => '', |
|
| 338 | + ) |
|
| 339 | + ); |
|
| 340 | + |
|
| 341 | + $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count'; |
|
| 342 | + $cpt_filter = empty($args['no_cpt_filter']) ? true : false; |
|
| 343 | + $cat_filter = empty($args['no_cat_filter']) ? true : false; |
|
| 344 | + |
|
| 345 | + $gd_post_types = geodir_get_posttypes('array'); |
|
| 346 | + |
|
| 347 | + $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type']; |
|
| 348 | + $current_posttype = geodir_get_current_posttype(); |
|
| 349 | + |
|
| 350 | + $is_listing = false; |
|
| 351 | + $is_detail = false; |
|
| 352 | + $is_category = false; |
|
| 353 | + $post_ID = 0; |
|
| 354 | + $is_listing_page = geodir_is_page('listing'); |
|
| 355 | + $is_detail_page = geodir_is_page('detail'); |
|
| 356 | + if ($is_listing_page || $is_detail_page) { |
|
| 357 | + $current_posttype = geodir_get_current_posttype(); |
|
| 358 | + |
|
| 359 | + if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { |
|
| 360 | + if ($is_detail_page) { |
|
| 361 | + $is_detail = true; |
|
| 362 | + $post_ID = is_object($post) && !empty($post->ID) ? (int)$post->ID : 0; |
|
| 363 | + } else { |
|
| 364 | + $is_listing = true; |
|
| 365 | + if (is_tax()) { // category page |
|
| 366 | + $current_term_id = get_queried_object_id(); |
|
| 367 | + $current_taxonomy = get_query_var('taxonomy'); |
|
| 368 | + $current_posttype = geodir_get_current_posttype(); |
|
| 369 | + |
|
| 370 | + if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
| 371 | + $is_category = true; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + $parent_category = 0; |
|
| 379 | + if (($is_listing || $is_detail) && $cpt_filter) { |
|
| 380 | + $post_type_arr = array($current_posttype); |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + $post_types = array(); |
|
| 384 | + if (!empty($post_type_arr)) { |
|
| 385 | + if (in_array('0', $post_type_arr)) { |
|
| 386 | + $post_types = $gd_post_types; |
|
| 387 | + } else { |
|
| 388 | + foreach ($post_type_arr as $cpt) { |
|
| 389 | + if (isset($gd_post_types[$cpt])) { |
|
| 390 | + $post_types[$cpt] = $gd_post_types[$cpt]; |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + if (empty($post_type_arr)) { |
|
| 397 | + $post_types = $gd_post_types; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + $hide_empty = !empty($args['hide_empty']) ? true : false; |
|
| 401 | + $max_count = strip_tags($args['max_count']); |
|
| 402 | + $all_childs = $max_count == 'all' ? true : false; |
|
| 403 | + $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
| 404 | + $max_level = strip_tags($args['max_level']); |
|
| 405 | + $show_count = !empty($args['show_count']) ? true : false; |
|
| 406 | + $hide_icon = !empty($args['hide_icon']) ? true : false; |
|
| 407 | + $cpt_left = !empty($args['cpt_left']) ? true : false; |
|
| 408 | + |
|
| 409 | + if(!$cpt_left){ |
|
| 410 | + $cpt_left = "gd-cpt-flat"; |
|
| 411 | + }else{ |
|
| 412 | + $cpt_left = ''; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + $orderby = 'count'; |
|
| 416 | + $order = 'DESC'; |
|
| 417 | + if ($sort_by == 'az') { |
|
| 418 | + $orderby = 'name'; |
|
| 419 | + $order = 'ASC'; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + $output = ''; |
|
| 423 | + if (!empty($post_types)) { |
|
| 424 | + foreach ($post_types as $cpt => $cpt_info) { |
|
| 425 | + $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
|
| 426 | + $cat_taxonomy = $cpt . 'category'; |
|
| 427 | + $skip_childs = false; |
|
| 428 | + if ($cat_filter && $cpt == $current_posttype && $is_detail && $post_ID) { |
|
| 429 | + $skip_childs = true; |
|
| 430 | + $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'object_ids' => $post_ID)); |
|
| 431 | + } else { |
|
| 432 | + $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + if ($hide_empty) { |
|
| 436 | + $categories = geodir_filter_empty_terms($categories); |
|
| 437 | + } |
|
| 438 | + if ($sort_by == 'count') { |
|
| 439 | + $categories = geodir_sort_terms($categories, 'count'); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + if (!empty($categories)) { |
|
| 443 | + $term_icons = !$hide_icon ? geodir_get_term_icon() : array(); |
|
| 444 | + $row_class = ''; |
|
| 445 | + |
|
| 446 | + if ($is_listing) { |
|
| 447 | + $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
|
| 448 | + } |
|
| 449 | + $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
| 450 | + |
|
| 451 | + if ($is_category && $cat_filter && $cpt == $current_posttype) { |
|
| 452 | + $term_info = get_term($current_term_id, $cat_taxonomy); |
|
| 453 | + |
|
| 454 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
|
| 455 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 456 | + |
|
| 457 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
| 458 | + $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
| 459 | + } else { |
|
| 460 | + $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
| 461 | + } |
|
| 462 | + foreach ($categories as $category) { |
|
| 463 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
| 464 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 465 | + |
|
| 466 | + $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 467 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 468 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 469 | + |
|
| 470 | + $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
|
| 471 | + $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
|
| 472 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 473 | + $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>'; |
|
| 474 | + if (!$skip_childs && ($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
| 475 | + $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
|
| 476 | + } |
|
| 477 | + $cpt_row .= '</li>'; |
|
| 478 | + $cpt_row .= '</ul>'; |
|
| 479 | + } |
|
| 480 | + $cpt_row .= '</div>'; |
|
| 481 | + |
|
| 482 | + $output .= $cpt_row; |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - $gd_use_query_vars = $old_gd_use_query_vars; |
|
| 487 | + $gd_use_query_vars = $old_gd_use_query_vars; |
|
| 488 | 488 | |
| 489 | - return $output; |
|
| 489 | + return $output; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -506,48 +506,48 @@ discard block |
||
| 506 | 506 | * @return string Html content. |
| 507 | 507 | */ |
| 508 | 508 | function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) { |
| 509 | - $cat_taxonomy = $cpt . 'category'; |
|
| 510 | - |
|
| 511 | - $orderby = 'count'; |
|
| 512 | - $order = 'DESC'; |
|
| 513 | - if ($sort_by == 'az') { |
|
| 514 | - $orderby = 'name'; |
|
| 515 | - $order = 'ASC'; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
| 519 | - return ''; |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count)); |
|
| 523 | - if ($hide_empty) { |
|
| 524 | - $child_cats = geodir_filter_empty_terms($child_cats); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - if (empty($child_cats)) { |
|
| 528 | - return ''; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - if ($sort_by == 'count') { |
|
| 532 | - $child_cats = geodir_sort_terms($child_cats, 'count'); |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
| 536 | - $depth++; |
|
| 537 | - foreach ($child_cats as $category) { |
|
| 538 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
| 539 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 540 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 541 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 542 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 543 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 544 | - |
|
| 545 | - $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
|
| 546 | - $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
| 547 | - $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
|
| 548 | - } |
|
| 549 | - $content .= '</li></ul>'; |
|
| 550 | - |
|
| 551 | - return $content; |
|
| 509 | + $cat_taxonomy = $cpt . 'category'; |
|
| 510 | + |
|
| 511 | + $orderby = 'count'; |
|
| 512 | + $order = 'DESC'; |
|
| 513 | + if ($sort_by == 'az') { |
|
| 514 | + $orderby = 'name'; |
|
| 515 | + $order = 'ASC'; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
| 519 | + return ''; |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count)); |
|
| 523 | + if ($hide_empty) { |
|
| 524 | + $child_cats = geodir_filter_empty_terms($child_cats); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + if (empty($child_cats)) { |
|
| 528 | + return ''; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + if ($sort_by == 'count') { |
|
| 532 | + $child_cats = geodir_sort_terms($child_cats, 'count'); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
| 536 | + $depth++; |
|
| 537 | + foreach ($child_cats as $category) { |
|
| 538 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
|
| 539 | + $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 540 | + $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 541 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 542 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 543 | + $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 544 | + |
|
| 545 | + $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
|
| 546 | + $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
| 547 | + $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
|
| 548 | + } |
|
| 549 | + $content .= '</li></ul>'; |
|
| 550 | + |
|
| 551 | + return $content; |
|
| 552 | 552 | } |
| 553 | 553 | ?> |
| 554 | 554 | \ 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 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | $gd_use_query_vars = geodir_is_page('detail') ? true : false; |
| 324 | 324 | |
| 325 | - $args = wp_parse_args((array)$params, |
|
| 325 | + $args = wp_parse_args((array) $params, |
|
| 326 | 326 | array( |
| 327 | 327 | 'title' => '', |
| 328 | 328 | 'post_type' => array(), // NULL for all |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { |
| 360 | 360 | if ($is_detail_page) { |
| 361 | 361 | $is_detail = true; |
| 362 | - $post_ID = is_object($post) && !empty($post->ID) ? (int)$post->ID : 0; |
|
| 362 | + $post_ID = is_object($post) && !empty($post->ID) ? (int) $post->ID : 0; |
|
| 363 | 363 | } else { |
| 364 | 364 | $is_listing = true; |
| 365 | 365 | if (is_tax()) { // category page |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $current_taxonomy = get_query_var('taxonomy'); |
| 368 | 368 | $current_posttype = geodir_get_current_posttype(); |
| 369 | 369 | |
| 370 | - if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { |
|
| 370 | + if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype.'category') { |
|
| 371 | 371 | $is_category = true; |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -400,15 +400,15 @@ discard block |
||
| 400 | 400 | $hide_empty = !empty($args['hide_empty']) ? true : false; |
| 401 | 401 | $max_count = strip_tags($args['max_count']); |
| 402 | 402 | $all_childs = $max_count == 'all' ? true : false; |
| 403 | - $max_count = $max_count > 0 ? (int)$max_count : 0; |
|
| 403 | + $max_count = $max_count > 0 ? (int) $max_count : 0; |
|
| 404 | 404 | $max_level = strip_tags($args['max_level']); |
| 405 | 405 | $show_count = !empty($args['show_count']) ? true : false; |
| 406 | 406 | $hide_icon = !empty($args['hide_icon']) ? true : false; |
| 407 | 407 | $cpt_left = !empty($args['cpt_left']) ? true : false; |
| 408 | 408 | |
| 409 | - if(!$cpt_left){ |
|
| 409 | + if (!$cpt_left) { |
|
| 410 | 410 | $cpt_left = "gd-cpt-flat"; |
| 411 | - }else{ |
|
| 411 | + } else { |
|
| 412 | 412 | $cpt_left = ''; |
| 413 | 413 | } |
| 414 | 414 | |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | if (!empty($post_types)) { |
| 424 | 424 | foreach ($post_types as $cpt => $cpt_info) { |
| 425 | 425 | $parent_category = ($is_category && $cat_filter && $cpt == $current_posttype) ? $current_term_id : 0; |
| 426 | - $cat_taxonomy = $cpt . 'category'; |
|
| 426 | + $cat_taxonomy = $cpt.'category'; |
|
| 427 | 427 | $skip_childs = false; |
| 428 | 428 | if ($cat_filter && $cpt == $current_posttype && $is_detail && $post_ID) { |
| 429 | 429 | $skip_childs = true; |
@@ -446,32 +446,32 @@ discard block |
||
| 446 | 446 | if ($is_listing) { |
| 447 | 447 | $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; |
| 448 | 448 | } |
| 449 | - $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">'; |
|
| 449 | + $cpt_row = '<div class="gd-cptcat-row gd-cptcat-'.$cpt.$row_class.' '.$cpt_left.'">'; |
|
| 450 | 450 | |
| 451 | 451 | if ($is_category && $cat_filter && $cpt == $current_posttype) { |
| 452 | 452 | $term_info = get_term($current_term_id, $cat_taxonomy); |
| 453 | 453 | |
| 454 | 454 | $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; |
| 455 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 455 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($term_info->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
| 456 | 456 | |
| 457 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; |
|
| 458 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; |
|
| 457 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$term_info->count.')</span>' : ''; |
|
| 458 | + $cpt_row .= '<h2 class="gd-cptcat-title">'.$term_icon_url.$term_info->name.$count.'</h2>'; |
|
| 459 | 459 | } else { |
| 460 | - $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; |
|
| 460 | + $cpt_row .= '<h2 class="gd-cptcat-title">'.__($cpt_info['labels']['name'], 'geodirectory').'</h2>'; |
|
| 461 | 461 | } |
| 462 | 462 | foreach ($categories as $category) { |
| 463 | 463 | $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
| 464 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 464 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($category->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
| 465 | 465 | |
| 466 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 466 | + $term_link = get_term_link($category, $category->taxonomy); |
|
| 467 | 467 | /** Filter documented in geodirectory-functions/general_functions.php **/ |
| 468 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 468 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $category->term_id, $cpt); |
|
| 469 | 469 | |
| 470 | 470 | $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent '.$cpt_left.'">'; |
| 471 | 471 | $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; |
| 472 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 473 | - $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>'; |
|
| 474 | - if (!$skip_childs && ($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) { |
|
| 472 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$category->count.')</span>' : ''; |
|
| 473 | + $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>'; |
|
| 474 | + if (!$skip_childs && ($all_childs || $max_count > 0) && ($max_level == 'all' || (int) $max_level > 0)) { |
|
| 475 | 475 | $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); |
| 476 | 476 | } |
| 477 | 477 | $cpt_row .= '</li>'; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @return string Html content. |
| 507 | 507 | */ |
| 508 | 508 | function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) { |
| 509 | - $cat_taxonomy = $cpt . 'category'; |
|
| 509 | + $cat_taxonomy = $cpt.'category'; |
|
| 510 | 510 | |
| 511 | 511 | $orderby = 'count'; |
| 512 | 512 | $order = 'DESC'; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $order = 'ASC'; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - if ($max_level != 'all' && $depth > (int)$max_level ) { |
|
| 518 | + if ($max_level != 'all' && $depth > (int) $max_level) { |
|
| 519 | 519 | return ''; |
| 520 | 520 | } |
| 521 | 521 | |
@@ -532,18 +532,18 @@ discard block |
||
| 532 | 532 | $child_cats = geodir_sort_terms($child_cats, 'count'); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">'; |
|
| 535 | + $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-'.$depth.'">'; |
|
| 536 | 536 | $depth++; |
| 537 | 537 | foreach ($child_cats as $category) { |
| 538 | 538 | $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; |
| 539 | - $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; |
|
| 540 | - $term_link = get_term_link( $category, $category->taxonomy ); |
|
| 539 | + $term_icon_url = $term_icon_url != '' ? '<img alt="'.esc_attr($category->name).' icon" src="'.$term_icon_url.'" /> ' : ''; |
|
| 540 | + $term_link = get_term_link($category, $category->taxonomy); |
|
| 541 | 541 | /** Filter documented in geodirectory-functions/general_functions.php **/ |
| 542 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt ); |
|
| 543 | - $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; |
|
| 542 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $category->term_id, $cpt); |
|
| 543 | + $count = $show_count ? ' <span class="gd-cptcat-count">('.$category->count.')</span>' : ''; |
|
| 544 | 544 | |
| 545 | 545 | $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">'; |
| 546 | - $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>'; |
|
| 546 | + $content .= '<a href="'.esc_url($term_link).'" title="'.esc_attr($category->name).'">'.$term_icon_url.$category->name.$count.'</a></li>'; |
|
| 547 | 547 | $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); |
| 548 | 548 | } |
| 549 | 549 | $content .= '</li></ul>'; |