@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | // If this file is called directly, abort. |
| 9 | 9 | if (!defined('WPINC')) { |
| 10 | - die; |
|
| 10 | + die; |
|
| 11 | 11 | } |
| 12 | 12 | require_once('geodirectory-functions/shortcode_functions.php'); |
| 13 | 13 | |
@@ -32,43 +32,43 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function geodir_sc_add_listing($atts) |
| 34 | 34 | { |
| 35 | - ob_start(); |
|
| 36 | - $defaults = array( |
|
| 37 | - 'pid' => '', |
|
| 38 | - 'listing_type' => 'gd_place', |
|
| 39 | - 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
| 40 | - 'show_login' => false, |
|
| 41 | - ); |
|
| 42 | - $params = shortcode_atts($defaults, $atts); |
|
| 43 | - |
|
| 44 | - foreach ($params as $key => $value) { |
|
| 45 | - $_REQUEST[$key] = $value; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - $user_id = get_current_user_id(); |
|
| 49 | - if (!$user_id) { |
|
| 50 | - echo $params['login_msg']; |
|
| 51 | - if ($params['show_login']) { |
|
| 52 | - echo "<br />"; |
|
| 53 | - $defaults = array( |
|
| 54 | - 'before_widget' => '', |
|
| 55 | - 'after_widget' => '', |
|
| 56 | - 'before_title' => '', |
|
| 57 | - 'after_title' => '', |
|
| 58 | - ); |
|
| 59 | - |
|
| 60 | - geodir_loginwidget_output($defaults, $defaults); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - } else { |
|
| 65 | - // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
| 66 | - } |
|
| 67 | - $output = ob_get_contents(); |
|
| 68 | - |
|
| 69 | - ob_end_clean(); |
|
| 70 | - |
|
| 71 | - return $output; |
|
| 35 | + ob_start(); |
|
| 36 | + $defaults = array( |
|
| 37 | + 'pid' => '', |
|
| 38 | + 'listing_type' => 'gd_place', |
|
| 39 | + 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
| 40 | + 'show_login' => false, |
|
| 41 | + ); |
|
| 42 | + $params = shortcode_atts($defaults, $atts); |
|
| 43 | + |
|
| 44 | + foreach ($params as $key => $value) { |
|
| 45 | + $_REQUEST[$key] = $value; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + $user_id = get_current_user_id(); |
|
| 49 | + if (!$user_id) { |
|
| 50 | + echo $params['login_msg']; |
|
| 51 | + if ($params['show_login']) { |
|
| 52 | + echo "<br />"; |
|
| 53 | + $defaults = array( |
|
| 54 | + 'before_widget' => '', |
|
| 55 | + 'after_widget' => '', |
|
| 56 | + 'before_title' => '', |
|
| 57 | + 'after_title' => '', |
|
| 58 | + ); |
|
| 59 | + |
|
| 60 | + geodir_loginwidget_output($defaults, $defaults); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + } else { |
|
| 65 | + // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
| 66 | + } |
|
| 67 | + $output = ob_get_contents(); |
|
| 68 | + |
|
| 69 | + ob_end_clean(); |
|
| 70 | + |
|
| 71 | + return $output; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -96,136 +96,136 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | function geodir_sc_home_map($atts) |
| 98 | 98 | { |
| 99 | - ob_start(); |
|
| 100 | - $defaults = array( |
|
| 101 | - 'width' => '960', |
|
| 102 | - 'height' => '425', |
|
| 103 | - 'maptype' => 'ROADMAP', |
|
| 104 | - 'zoom' => '13', |
|
| 105 | - 'autozoom' => '', |
|
| 106 | - 'child_collapse' => '0', |
|
| 107 | - 'scrollwheel' => '0', |
|
| 99 | + ob_start(); |
|
| 100 | + $defaults = array( |
|
| 101 | + 'width' => '960', |
|
| 102 | + 'height' => '425', |
|
| 103 | + 'maptype' => 'ROADMAP', |
|
| 104 | + 'zoom' => '13', |
|
| 105 | + 'autozoom' => '', |
|
| 106 | + 'child_collapse' => '0', |
|
| 107 | + 'scrollwheel' => '0', |
|
| 108 | 108 | 'marker_cluster' => false, |
| 109 | - 'latitude' => '', |
|
| 110 | - 'longitude' => '' |
|
| 111 | - ); |
|
| 112 | - |
|
| 113 | - $params = shortcode_atts($defaults, $atts); |
|
| 114 | - |
|
| 115 | - $params = gdsc_validate_map_args($params); |
|
| 116 | - |
|
| 117 | - $map_args = array( |
|
| 118 | - 'map_canvas_name' => 'gd_home_map', |
|
| 119 | - 'latitude' => $params['latitude'], |
|
| 120 | - 'longitude' => $params['longitude'], |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Filter the widget width of the map on home/listings page. |
|
| 124 | - * |
|
| 125 | - * @since 1.0.0 |
|
| 126 | - * @param mixed(string|int|float) $params['width'] The map width. |
|
| 127 | - */ |
|
| 128 | - 'width' => apply_filters('widget_width', $params['width']), |
|
| 129 | - /** |
|
| 130 | - * Filter the widget height of the map on home/listings page. |
|
| 131 | - * |
|
| 132 | - * @since 1.0.0 |
|
| 133 | - * @param mixed(string|int|float) $params['height'] The map height. |
|
| 134 | - */ |
|
| 135 | - 'height' => apply_filters('widget_heigh', $params['height']), |
|
| 136 | - /** |
|
| 137 | - * Filter the widget maptype of the map on home/listings page. |
|
| 138 | - * |
|
| 139 | - * @since 1.0.0 |
|
| 109 | + 'latitude' => '', |
|
| 110 | + 'longitude' => '' |
|
| 111 | + ); |
|
| 112 | + |
|
| 113 | + $params = shortcode_atts($defaults, $atts); |
|
| 114 | + |
|
| 115 | + $params = gdsc_validate_map_args($params); |
|
| 116 | + |
|
| 117 | + $map_args = array( |
|
| 118 | + 'map_canvas_name' => 'gd_home_map', |
|
| 119 | + 'latitude' => $params['latitude'], |
|
| 120 | + 'longitude' => $params['longitude'], |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Filter the widget width of the map on home/listings page. |
|
| 124 | + * |
|
| 125 | + * @since 1.0.0 |
|
| 126 | + * @param mixed(string|int|float) $params['width'] The map width. |
|
| 127 | + */ |
|
| 128 | + 'width' => apply_filters('widget_width', $params['width']), |
|
| 129 | + /** |
|
| 130 | + * Filter the widget height of the map on home/listings page. |
|
| 131 | + * |
|
| 132 | + * @since 1.0.0 |
|
| 133 | + * @param mixed(string|int|float) $params['height'] The map height. |
|
| 134 | + */ |
|
| 135 | + 'height' => apply_filters('widget_heigh', $params['height']), |
|
| 136 | + /** |
|
| 137 | + * Filter the widget maptype of the map on home/listings page. |
|
| 138 | + * |
|
| 139 | + * @since 1.0.0 |
|
| 140 | 140 | * @since 1.5.2 Added TERRAIN map type. |
| 141 | - * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
| 142 | - */ |
|
| 143 | - 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
| 144 | - /** |
|
| 145 | - * Filter the widget scrollwheel value of the map on home/listings page. |
|
| 146 | - * |
|
| 147 | - * Should the scrollwheel zoom the map or not. |
|
| 148 | - * |
|
| 149 | - * @since 1.0.0 |
|
| 150 | - * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
| 151 | - */ |
|
| 152 | - 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
| 153 | - /** |
|
| 154 | - * Filter the widget zoom level of the map on home/listings page. |
|
| 155 | - * |
|
| 156 | - * @since 1.0.0 |
|
| 157 | - * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
| 158 | - */ |
|
| 159 | - 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
| 160 | - /** |
|
| 161 | - * Filter the widget auto zoom value of the map on home/listings page. |
|
| 162 | - * |
|
| 163 | - * If the map should autozoom to fit the markers shown. |
|
| 164 | - * |
|
| 165 | - * @since 1.0.0 |
|
| 166 | - * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
| 167 | - */ |
|
| 168 | - 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
| 169 | - /** |
|
| 170 | - * Filter the widget child_collapse value of the map on home/listings page. |
|
| 171 | - * |
|
| 172 | - * If the map should auto collapse the child categories if the category bar is present. |
|
| 173 | - * |
|
| 174 | - * @since 1.0.0 |
|
| 175 | - * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
| 176 | - */ |
|
| 177 | - 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
| 178 | - 'enable_cat_filters' => true, |
|
| 179 | - 'enable_text_search' => true, |
|
| 180 | - 'enable_post_type_filters' => true, |
|
| 181 | - /** |
|
| 182 | - * Filter the widget enable_location_filters value of the map on home/listings page. |
|
| 183 | - * |
|
| 184 | - * This is used when the location addon is used. |
|
| 185 | - * |
|
| 186 | - * @since 1.0.0 |
|
| 187 | - * @param bool $val True if location filters should be used, false if not. |
|
| 188 | - */ |
|
| 189 | - 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
| 190 | - 'enable_jason_on_load' => false, |
|
| 191 | - 'enable_marker_cluster' => false, |
|
| 192 | - 'enable_map_resize_button' => true, |
|
| 193 | - 'map_class_name' => 'geodir-map-home-page', |
|
| 194 | - 'is_geodir_home_map_widget' => true, |
|
| 195 | - ); |
|
| 141 | + * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
| 142 | + */ |
|
| 143 | + 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
| 144 | + /** |
|
| 145 | + * Filter the widget scrollwheel value of the map on home/listings page. |
|
| 146 | + * |
|
| 147 | + * Should the scrollwheel zoom the map or not. |
|
| 148 | + * |
|
| 149 | + * @since 1.0.0 |
|
| 150 | + * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
| 151 | + */ |
|
| 152 | + 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
| 153 | + /** |
|
| 154 | + * Filter the widget zoom level of the map on home/listings page. |
|
| 155 | + * |
|
| 156 | + * @since 1.0.0 |
|
| 157 | + * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
| 158 | + */ |
|
| 159 | + 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
| 160 | + /** |
|
| 161 | + * Filter the widget auto zoom value of the map on home/listings page. |
|
| 162 | + * |
|
| 163 | + * If the map should autozoom to fit the markers shown. |
|
| 164 | + * |
|
| 165 | + * @since 1.0.0 |
|
| 166 | + * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
| 167 | + */ |
|
| 168 | + 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
| 169 | + /** |
|
| 170 | + * Filter the widget child_collapse value of the map on home/listings page. |
|
| 171 | + * |
|
| 172 | + * If the map should auto collapse the child categories if the category bar is present. |
|
| 173 | + * |
|
| 174 | + * @since 1.0.0 |
|
| 175 | + * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
| 176 | + */ |
|
| 177 | + 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
| 178 | + 'enable_cat_filters' => true, |
|
| 179 | + 'enable_text_search' => true, |
|
| 180 | + 'enable_post_type_filters' => true, |
|
| 181 | + /** |
|
| 182 | + * Filter the widget enable_location_filters value of the map on home/listings page. |
|
| 183 | + * |
|
| 184 | + * This is used when the location addon is used. |
|
| 185 | + * |
|
| 186 | + * @since 1.0.0 |
|
| 187 | + * @param bool $val True if location filters should be used, false if not. |
|
| 188 | + */ |
|
| 189 | + 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
| 190 | + 'enable_jason_on_load' => false, |
|
| 191 | + 'enable_marker_cluster' => false, |
|
| 192 | + 'enable_map_resize_button' => true, |
|
| 193 | + 'map_class_name' => 'geodir-map-home-page', |
|
| 194 | + 'is_geodir_home_map_widget' => true, |
|
| 195 | + ); |
|
| 196 | 196 | |
| 197 | 197 | // Add marker cluster |
| 198 | 198 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
| 199 | - $map_args['enable_marker_cluster'] = true; |
|
| 200 | - if(get_option('geodir_marker_cluster_type')) { |
|
| 201 | - if ($map_args['autozoom']) { |
|
| 202 | - $map_args['enable_marker_cluster_no_reposition'] = false; |
|
| 203 | - } else { |
|
| 204 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
| 205 | - } |
|
| 199 | + $map_args['enable_marker_cluster'] = true; |
|
| 200 | + if(get_option('geodir_marker_cluster_type')) { |
|
| 201 | + if ($map_args['autozoom']) { |
|
| 202 | + $map_args['enable_marker_cluster_no_reposition'] = false; |
|
| 203 | + } else { |
|
| 204 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $map_args['enable_marker_cluster_server'] = true ; |
|
| 207 | + $map_args['enable_marker_cluster_server'] = true ; |
|
| 208 | 208 | |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | } else { |
| 211 | 211 | $map_args['enable_marker_cluster'] = false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - // if lat and long set in shortcode, hack it so the map is not repositioned |
|
| 215 | - if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
| 216 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
| 217 | - } |
|
| 214 | + // if lat and long set in shortcode, hack it so the map is not repositioned |
|
| 215 | + if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
| 216 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - geodir_draw_map($map_args); |
|
| 220 | + geodir_draw_map($map_args); |
|
| 221 | 221 | |
| 222 | - add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
| 222 | + add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
| 223 | 223 | |
| 224 | - $output = ob_get_contents(); |
|
| 224 | + $output = ob_get_contents(); |
|
| 225 | 225 | |
| 226 | - ob_end_clean(); |
|
| 226 | + ob_end_clean(); |
|
| 227 | 227 | |
| 228 | - return $output; |
|
| 228 | + return $output; |
|
| 229 | 229 | } |
| 230 | 230 | add_shortcode('gd_homepage_map', 'geodir_sc_home_map'); |
| 231 | 231 | |
@@ -264,243 +264,243 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | function geodir_sc_listing_map($atts) { |
| 266 | 266 | |
| 267 | - // if some params are set then we need a new query, if not then we can use the main query |
|
| 268 | - if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
| 269 | - |
|
| 270 | - global $add_post_in_marker_array, $gd_sc_map_params; |
|
| 271 | - $backup_globals = array(); |
|
| 272 | - $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
| 273 | - $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
| 274 | - |
|
| 275 | - $defaults = array( |
|
| 276 | - 'width' => '294', |
|
| 277 | - 'height' => '370', |
|
| 278 | - 'zoom' => '13', |
|
| 279 | - 'autozoom' => '', |
|
| 280 | - 'sticky' => '', |
|
| 281 | - 'showall' => '0', |
|
| 282 | - 'scrollwheel' => '0', |
|
| 283 | - 'maptype' => 'ROADMAP', |
|
| 284 | - 'child_collapse' => 0, |
|
| 285 | - 'marker_cluster' => false, |
|
| 286 | - 'post_type' => 'gd_place', |
|
| 287 | - 'category' => '0', |
|
| 288 | - 'event_type' => 'all' |
|
| 289 | - ); |
|
| 290 | - |
|
| 291 | - $params = shortcode_atts( $defaults, $atts ); |
|
| 292 | - |
|
| 293 | - if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
| 294 | - $params['post_type'] = 'gd_place'; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
| 298 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
| 299 | - $categories = get_terms( $category_taxonomy, array( |
|
| 300 | - 'orderby' => 'count', |
|
| 301 | - 'order' => 'DESC', |
|
| 302 | - 'fields' => 'ids' |
|
| 303 | - ) ); |
|
| 304 | - |
|
| 305 | - // Make sure we have an array |
|
| 306 | - if ( ! ( is_array( $params['category'] ) ) ) { |
|
| 307 | - $params['category'] = explode( ',', $params['category'] ); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 311 | - // Otherwise it becomes empty and later on that will mean "All" |
|
| 312 | - $params['category'] = array_intersect( $params['category'], $categories ); |
|
| 313 | - |
|
| 314 | - if ( $params['post_type'] == 'gd_event' ) { |
|
| 315 | - $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $params = gdsc_validate_map_args( $params ); |
|
| 319 | - |
|
| 320 | - $gd_sc_map_params = $params; |
|
| 321 | - |
|
| 322 | - $query_args = array( |
|
| 323 | - 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
| 324 | - 'is_geodir_loop' => true, |
|
| 325 | - 'gd_location' => false, |
|
| 326 | - 'post_type' => $params['post_type'], |
|
| 327 | - ); |
|
| 328 | - |
|
| 329 | - if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
| 330 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
| 331 | - |
|
| 332 | - ######### WPML ######### |
|
| 333 | - if ( function_exists( 'icl_object_id' ) ) { |
|
| 334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
| 335 | - } |
|
| 336 | - ######### WPML ######### |
|
| 337 | - |
|
| 338 | - $tax_query = array( |
|
| 339 | - 'taxonomy' => $category_taxonomy[0], |
|
| 340 | - 'field' => 'id', |
|
| 341 | - 'terms' => $params['category'] |
|
| 342 | - ); |
|
| 343 | - |
|
| 344 | - $query_args['tax_query'] = array( $tax_query ); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - $add_post_in_marker_array = true; |
|
| 348 | - |
|
| 349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
| 350 | - global $geodir_event_widget_listview; |
|
| 351 | - $geodir_event_widget_listview = true; |
|
| 352 | - |
|
| 353 | - $query_args['geodir_event_type'] = $params['event_type']; |
|
| 354 | - |
|
| 355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
| 356 | - |
|
| 357 | - $geodir_event_widget_listview = false; |
|
| 358 | - } else { |
|
| 359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - if ( ! empty( $listings ) ) { |
|
| 363 | - foreach ( $listings as $listing ) { |
|
| 364 | - create_marker_jason_of_posts( $listing ); |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - ob_start(); |
|
| 369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
| 370 | - |
|
| 371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
| 372 | - |
|
| 373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
| 374 | - |
|
| 375 | - $default_location = geodir_get_default_location(); |
|
| 376 | - |
|
| 377 | - $map_args = array( |
|
| 378 | - 'map_canvas_name' => 'gd_listing_map', |
|
| 379 | - 'width' => $params['width'], |
|
| 380 | - 'height' => $params['height'], |
|
| 381 | - 'zoom' => $params['zoom'], |
|
| 382 | - 'autozoom' => $params['autozoom'], |
|
| 383 | - 'sticky' => $params['sticky'], |
|
| 384 | - 'showall' => $params['showall'], |
|
| 385 | - 'scrollwheel' => $params['scrollwheel'], |
|
| 386 | - 'maptype' => $params['maptype'], |
|
| 387 | - 'child_collapse' => 0, |
|
| 388 | - 'enable_cat_filters' => false, |
|
| 389 | - 'enable_text_search' => false, |
|
| 390 | - 'enable_post_type_filters' => false, |
|
| 391 | - 'enable_location_filters' => false, |
|
| 392 | - 'enable_jason_on_load' => true, |
|
| 393 | - 'ajax_url' => geodir_get_ajax_url(), |
|
| 394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
| 395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
| 396 | - 'streetViewControl' => true, |
|
| 397 | - 'showPreview' => '0', |
|
| 398 | - 'maxZoom' => 21, |
|
| 399 | - 'bubble_size' => 'small', |
|
| 400 | - ); |
|
| 401 | - |
|
| 402 | - if ( is_single() ) { |
|
| 403 | - global $post; |
|
| 404 | - if ( isset( $post->post_latitude ) ) { |
|
| 405 | - $map_args['latitude'] = $post->post_latitude; |
|
| 406 | - $map_args['longitude'] = $post->post_longitude; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
| 410 | - } else { |
|
| 411 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - // Add marker cluster |
|
| 415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
| 416 | - $map_args['enable_marker_cluster'] = true; |
|
| 417 | - } else { |
|
| 418 | - $map_args['enable_marker_cluster'] = false; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - geodir_draw_map( $map_args ); |
|
| 422 | - |
|
| 423 | - $output = ob_get_contents(); |
|
| 424 | - |
|
| 425 | - ob_end_clean(); |
|
| 426 | - |
|
| 427 | - foreach ( $backup_globals as $global => $value ) { |
|
| 428 | - ${$global} = $value; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - return $output; |
|
| 432 | - }else{ |
|
| 433 | - ob_start(); |
|
| 434 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
| 435 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
| 436 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
| 437 | - $defaults = array( |
|
| 438 | - 'width' => '294', |
|
| 439 | - 'height' => '370', |
|
| 440 | - 'zoom' => '13', |
|
| 441 | - 'autozoom' => '', |
|
| 442 | - 'sticky' => '', |
|
| 443 | - 'showall' => '0', |
|
| 444 | - 'scrollwheel' => '0', |
|
| 445 | - 'maptype' => 'ROADMAP', |
|
| 446 | - 'child_collapse' => 0, |
|
| 447 | - 'marker_cluster' => false |
|
| 448 | - ); |
|
| 449 | - $params = shortcode_atts($defaults, $atts); |
|
| 450 | - $params = gdsc_validate_map_args($params); |
|
| 451 | - $map_args = array( |
|
| 452 | - 'map_canvas_name' => 'gd_listing_map', |
|
| 453 | - 'width' => $params['width'], |
|
| 454 | - 'height' => $params['height'], |
|
| 455 | - 'zoom' => $params['zoom'], |
|
| 456 | - 'autozoom' => $params['autozoom'], |
|
| 457 | - 'sticky' => $params['sticky'], |
|
| 458 | - 'showall' => $params['showall'], |
|
| 459 | - 'scrollwheel' => $params['scrollwheel'], |
|
| 460 | - 'child_collapse' => 0, |
|
| 461 | - 'enable_cat_filters' => false, |
|
| 462 | - 'enable_text_search' => false, |
|
| 463 | - 'enable_post_type_filters' => false, |
|
| 464 | - 'enable_location_filters' => false, |
|
| 465 | - 'enable_jason_on_load' => true, |
|
| 466 | - ); |
|
| 467 | - if (is_single()) { |
|
| 468 | - global $post; |
|
| 469 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
| 470 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
| 471 | - $mapview = $post->post_mapview; |
|
| 472 | - $map_args['zoom'] = $post->post_mapzoom; |
|
| 473 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
| 474 | - } else { |
|
| 475 | - $default_location = geodir_get_default_location(); |
|
| 476 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 477 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 478 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
| 479 | - } |
|
| 480 | - if (empty($mapview)) { |
|
| 481 | - $mapview = 'ROADMAP'; |
|
| 482 | - } |
|
| 483 | - // Set default map options |
|
| 484 | - $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
| 485 | - $map_args['latitude'] = $map_default_lat; |
|
| 486 | - $map_args['longitude'] = $map_default_lng; |
|
| 487 | - $map_args['streetViewControl'] = true; |
|
| 488 | - $map_args['maptype'] = $mapview; |
|
| 489 | - $map_args['showPreview'] = '0'; |
|
| 490 | - $map_args['maxZoom'] = 21; |
|
| 491 | - $map_args['bubble_size'] = 'small'; |
|
| 492 | - |
|
| 493 | - // Add marker cluster |
|
| 494 | - if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
| 495 | - $map_args['enable_marker_cluster'] = true; |
|
| 496 | - } else { |
|
| 497 | - $map_args['enable_marker_cluster'] = false; |
|
| 498 | - } |
|
| 499 | - geodir_draw_map($map_args); |
|
| 500 | - $output = ob_get_contents(); |
|
| 501 | - ob_end_clean(); |
|
| 502 | - return $output; |
|
| 503 | - } |
|
| 267 | + // if some params are set then we need a new query, if not then we can use the main query |
|
| 268 | + if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
| 269 | + |
|
| 270 | + global $add_post_in_marker_array, $gd_sc_map_params; |
|
| 271 | + $backup_globals = array(); |
|
| 272 | + $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
| 273 | + $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
| 274 | + |
|
| 275 | + $defaults = array( |
|
| 276 | + 'width' => '294', |
|
| 277 | + 'height' => '370', |
|
| 278 | + 'zoom' => '13', |
|
| 279 | + 'autozoom' => '', |
|
| 280 | + 'sticky' => '', |
|
| 281 | + 'showall' => '0', |
|
| 282 | + 'scrollwheel' => '0', |
|
| 283 | + 'maptype' => 'ROADMAP', |
|
| 284 | + 'child_collapse' => 0, |
|
| 285 | + 'marker_cluster' => false, |
|
| 286 | + 'post_type' => 'gd_place', |
|
| 287 | + 'category' => '0', |
|
| 288 | + 'event_type' => 'all' |
|
| 289 | + ); |
|
| 290 | + |
|
| 291 | + $params = shortcode_atts( $defaults, $atts ); |
|
| 292 | + |
|
| 293 | + if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
| 294 | + $params['post_type'] = 'gd_place'; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
| 298 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
| 299 | + $categories = get_terms( $category_taxonomy, array( |
|
| 300 | + 'orderby' => 'count', |
|
| 301 | + 'order' => 'DESC', |
|
| 302 | + 'fields' => 'ids' |
|
| 303 | + ) ); |
|
| 304 | + |
|
| 305 | + // Make sure we have an array |
|
| 306 | + if ( ! ( is_array( $params['category'] ) ) ) { |
|
| 307 | + $params['category'] = explode( ',', $params['category'] ); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 311 | + // Otherwise it becomes empty and later on that will mean "All" |
|
| 312 | + $params['category'] = array_intersect( $params['category'], $categories ); |
|
| 313 | + |
|
| 314 | + if ( $params['post_type'] == 'gd_event' ) { |
|
| 315 | + $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $params = gdsc_validate_map_args( $params ); |
|
| 319 | + |
|
| 320 | + $gd_sc_map_params = $params; |
|
| 321 | + |
|
| 322 | + $query_args = array( |
|
| 323 | + 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
| 324 | + 'is_geodir_loop' => true, |
|
| 325 | + 'gd_location' => false, |
|
| 326 | + 'post_type' => $params['post_type'], |
|
| 327 | + ); |
|
| 328 | + |
|
| 329 | + if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
| 330 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
| 331 | + |
|
| 332 | + ######### WPML ######### |
|
| 333 | + if ( function_exists( 'icl_object_id' ) ) { |
|
| 334 | + $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
| 335 | + } |
|
| 336 | + ######### WPML ######### |
|
| 337 | + |
|
| 338 | + $tax_query = array( |
|
| 339 | + 'taxonomy' => $category_taxonomy[0], |
|
| 340 | + 'field' => 'id', |
|
| 341 | + 'terms' => $params['category'] |
|
| 342 | + ); |
|
| 343 | + |
|
| 344 | + $query_args['tax_query'] = array( $tax_query ); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + $add_post_in_marker_array = true; |
|
| 348 | + |
|
| 349 | + if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
| 350 | + global $geodir_event_widget_listview; |
|
| 351 | + $geodir_event_widget_listview = true; |
|
| 352 | + |
|
| 353 | + $query_args['geodir_event_type'] = $params['event_type']; |
|
| 354 | + |
|
| 355 | + $listings = geodir_event_get_widget_events( $query_args ); |
|
| 356 | + |
|
| 357 | + $geodir_event_widget_listview = false; |
|
| 358 | + } else { |
|
| 359 | + $listings = geodir_get_widget_listings( $query_args ); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + if ( ! empty( $listings ) ) { |
|
| 363 | + foreach ( $listings as $listing ) { |
|
| 364 | + create_marker_jason_of_posts( $listing ); |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + ob_start(); |
|
| 369 | + add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
| 370 | + |
|
| 371 | + add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
| 372 | + |
|
| 373 | + add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
| 374 | + |
|
| 375 | + $default_location = geodir_get_default_location(); |
|
| 376 | + |
|
| 377 | + $map_args = array( |
|
| 378 | + 'map_canvas_name' => 'gd_listing_map', |
|
| 379 | + 'width' => $params['width'], |
|
| 380 | + 'height' => $params['height'], |
|
| 381 | + 'zoom' => $params['zoom'], |
|
| 382 | + 'autozoom' => $params['autozoom'], |
|
| 383 | + 'sticky' => $params['sticky'], |
|
| 384 | + 'showall' => $params['showall'], |
|
| 385 | + 'scrollwheel' => $params['scrollwheel'], |
|
| 386 | + 'maptype' => $params['maptype'], |
|
| 387 | + 'child_collapse' => 0, |
|
| 388 | + 'enable_cat_filters' => false, |
|
| 389 | + 'enable_text_search' => false, |
|
| 390 | + 'enable_post_type_filters' => false, |
|
| 391 | + 'enable_location_filters' => false, |
|
| 392 | + 'enable_jason_on_load' => true, |
|
| 393 | + 'ajax_url' => geodir_get_ajax_url(), |
|
| 394 | + 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
| 395 | + 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
| 396 | + 'streetViewControl' => true, |
|
| 397 | + 'showPreview' => '0', |
|
| 398 | + 'maxZoom' => 21, |
|
| 399 | + 'bubble_size' => 'small', |
|
| 400 | + ); |
|
| 401 | + |
|
| 402 | + if ( is_single() ) { |
|
| 403 | + global $post; |
|
| 404 | + if ( isset( $post->post_latitude ) ) { |
|
| 405 | + $map_args['latitude'] = $post->post_latitude; |
|
| 406 | + $map_args['longitude'] = $post->post_longitude; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
| 410 | + } else { |
|
| 411 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + // Add marker cluster |
|
| 415 | + if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
| 416 | + $map_args['enable_marker_cluster'] = true; |
|
| 417 | + } else { |
|
| 418 | + $map_args['enable_marker_cluster'] = false; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + geodir_draw_map( $map_args ); |
|
| 422 | + |
|
| 423 | + $output = ob_get_contents(); |
|
| 424 | + |
|
| 425 | + ob_end_clean(); |
|
| 426 | + |
|
| 427 | + foreach ( $backup_globals as $global => $value ) { |
|
| 428 | + ${$global} = $value; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + return $output; |
|
| 432 | + }else{ |
|
| 433 | + ob_start(); |
|
| 434 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
| 435 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
| 436 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
| 437 | + $defaults = array( |
|
| 438 | + 'width' => '294', |
|
| 439 | + 'height' => '370', |
|
| 440 | + 'zoom' => '13', |
|
| 441 | + 'autozoom' => '', |
|
| 442 | + 'sticky' => '', |
|
| 443 | + 'showall' => '0', |
|
| 444 | + 'scrollwheel' => '0', |
|
| 445 | + 'maptype' => 'ROADMAP', |
|
| 446 | + 'child_collapse' => 0, |
|
| 447 | + 'marker_cluster' => false |
|
| 448 | + ); |
|
| 449 | + $params = shortcode_atts($defaults, $atts); |
|
| 450 | + $params = gdsc_validate_map_args($params); |
|
| 451 | + $map_args = array( |
|
| 452 | + 'map_canvas_name' => 'gd_listing_map', |
|
| 453 | + 'width' => $params['width'], |
|
| 454 | + 'height' => $params['height'], |
|
| 455 | + 'zoom' => $params['zoom'], |
|
| 456 | + 'autozoom' => $params['autozoom'], |
|
| 457 | + 'sticky' => $params['sticky'], |
|
| 458 | + 'showall' => $params['showall'], |
|
| 459 | + 'scrollwheel' => $params['scrollwheel'], |
|
| 460 | + 'child_collapse' => 0, |
|
| 461 | + 'enable_cat_filters' => false, |
|
| 462 | + 'enable_text_search' => false, |
|
| 463 | + 'enable_post_type_filters' => false, |
|
| 464 | + 'enable_location_filters' => false, |
|
| 465 | + 'enable_jason_on_load' => true, |
|
| 466 | + ); |
|
| 467 | + if (is_single()) { |
|
| 468 | + global $post; |
|
| 469 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
| 470 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
| 471 | + $mapview = $post->post_mapview; |
|
| 472 | + $map_args['zoom'] = $post->post_mapzoom; |
|
| 473 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
| 474 | + } else { |
|
| 475 | + $default_location = geodir_get_default_location(); |
|
| 476 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 477 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 478 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
| 479 | + } |
|
| 480 | + if (empty($mapview)) { |
|
| 481 | + $mapview = 'ROADMAP'; |
|
| 482 | + } |
|
| 483 | + // Set default map options |
|
| 484 | + $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
| 485 | + $map_args['latitude'] = $map_default_lat; |
|
| 486 | + $map_args['longitude'] = $map_default_lng; |
|
| 487 | + $map_args['streetViewControl'] = true; |
|
| 488 | + $map_args['maptype'] = $mapview; |
|
| 489 | + $map_args['showPreview'] = '0'; |
|
| 490 | + $map_args['maxZoom'] = 21; |
|
| 491 | + $map_args['bubble_size'] = 'small'; |
|
| 492 | + |
|
| 493 | + // Add marker cluster |
|
| 494 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
| 495 | + $map_args['enable_marker_cluster'] = true; |
|
| 496 | + } else { |
|
| 497 | + $map_args['enable_marker_cluster'] = false; |
|
| 498 | + } |
|
| 499 | + geodir_draw_map($map_args); |
|
| 500 | + $output = ob_get_contents(); |
|
| 501 | + ob_end_clean(); |
|
| 502 | + return $output; |
|
| 503 | + } |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider'); |
@@ -533,120 +533,120 @@ discard block |
||
| 533 | 533 | */ |
| 534 | 534 | function geodir_sc_listing_slider($atts) |
| 535 | 535 | { |
| 536 | - ob_start(); |
|
| 537 | - $defaults = array( |
|
| 538 | - 'post_type' => 'gd_place', |
|
| 539 | - 'category' => '0', |
|
| 540 | - 'post_number' => '5', |
|
| 541 | - 'slideshow' => '0', |
|
| 542 | - 'animation_loop' => 0, |
|
| 543 | - 'direction_nav' => 0, |
|
| 544 | - 'slideshow_speed' => 5000, |
|
| 545 | - 'animation_speed' => 600, |
|
| 546 | - 'animation' => 'slide', |
|
| 547 | - 'order_by' => 'latest', |
|
| 548 | - 'show_title' => '', |
|
| 549 | - 'show_featured_only' => '', |
|
| 550 | - 'title' => '', |
|
| 551 | - ); |
|
| 552 | - |
|
| 553 | - $params = shortcode_atts($defaults, $atts); |
|
| 554 | - |
|
| 555 | - |
|
| 556 | - /* |
|
| 536 | + ob_start(); |
|
| 537 | + $defaults = array( |
|
| 538 | + 'post_type' => 'gd_place', |
|
| 539 | + 'category' => '0', |
|
| 540 | + 'post_number' => '5', |
|
| 541 | + 'slideshow' => '0', |
|
| 542 | + 'animation_loop' => 0, |
|
| 543 | + 'direction_nav' => 0, |
|
| 544 | + 'slideshow_speed' => 5000, |
|
| 545 | + 'animation_speed' => 600, |
|
| 546 | + 'animation' => 'slide', |
|
| 547 | + 'order_by' => 'latest', |
|
| 548 | + 'show_title' => '', |
|
| 549 | + 'show_featured_only' => '', |
|
| 550 | + 'title' => '', |
|
| 551 | + ); |
|
| 552 | + |
|
| 553 | + $params = shortcode_atts($defaults, $atts); |
|
| 554 | + |
|
| 555 | + |
|
| 556 | + /* |
|
| 557 | 557 | * |
| 558 | 558 | * Now we begin the validation of the attributes. |
| 559 | 559 | */ |
| 560 | - // Check we have a valid post_type |
|
| 561 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 562 | - $params['post_type'] = 'gd_place'; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - // Check we have a valid sort_order |
|
| 566 | - $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
| 567 | - |
|
| 568 | - // Match the chosen animation to our options |
|
| 569 | - $animation_list = array('slide', 'fade'); |
|
| 570 | - if (!(in_array($params['animation'], $animation_list))) { |
|
| 571 | - $params['animation'] = 'slide'; |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - // Post_number needs to be a positive integer |
|
| 575 | - $params['post_number'] = absint($params['post_number']); |
|
| 576 | - if (0 == $params['post_number']) { |
|
| 577 | - $params['post_number'] = 1; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - // Manage the entered categories |
|
| 581 | - if (0 != $params['category'] || '' != $params['category']) { |
|
| 582 | - $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
| 583 | - } |
|
| 584 | - // Convert show_title to a bool |
|
| 585 | - $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
| 586 | - |
|
| 587 | - // Convert show_featured_only to a bool |
|
| 588 | - $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
| 589 | - |
|
| 590 | - /* |
|
| 560 | + // Check we have a valid post_type |
|
| 561 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 562 | + $params['post_type'] = 'gd_place'; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + // Check we have a valid sort_order |
|
| 566 | + $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
| 567 | + |
|
| 568 | + // Match the chosen animation to our options |
|
| 569 | + $animation_list = array('slide', 'fade'); |
|
| 570 | + if (!(in_array($params['animation'], $animation_list))) { |
|
| 571 | + $params['animation'] = 'slide'; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + // Post_number needs to be a positive integer |
|
| 575 | + $params['post_number'] = absint($params['post_number']); |
|
| 576 | + if (0 == $params['post_number']) { |
|
| 577 | + $params['post_number'] = 1; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + // Manage the entered categories |
|
| 581 | + if (0 != $params['category'] || '' != $params['category']) { |
|
| 582 | + $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
| 583 | + } |
|
| 584 | + // Convert show_title to a bool |
|
| 585 | + $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
| 586 | + |
|
| 587 | + // Convert show_featured_only to a bool |
|
| 588 | + $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
| 589 | + |
|
| 590 | + /* |
|
| 591 | 591 | * Hopefully all attributes are now valid, and safe to pass forward |
| 592 | 592 | */ |
| 593 | 593 | |
| 594 | - // redeclare vars after validation |
|
| 595 | - |
|
| 596 | - if (isset($params['direction_nav'])) { |
|
| 597 | - $params['directionNav'] = $params['direction_nav']; |
|
| 598 | - } |
|
| 599 | - if (isset($params['animation_loop'])) { |
|
| 600 | - $params['animationLoop'] = $params['animation_loop']; |
|
| 601 | - } |
|
| 602 | - if (isset($params['slideshow_speed'])) { |
|
| 603 | - $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
| 604 | - } |
|
| 605 | - if (isset($params['animation_speed'])) { |
|
| 606 | - $params['animationSpeed'] = $params['animation_speed']; |
|
| 607 | - } |
|
| 608 | - if (isset($params['order_by'])) { |
|
| 609 | - $params['list_sort'] = $params['order_by']; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - $query_args = array( |
|
| 613 | - 'post_number' => $params['post_number'], |
|
| 614 | - 'is_geodir_loop' => true, |
|
| 615 | - 'post_type' => $params['post_type'], |
|
| 616 | - 'order_by' => $params['order_by'] |
|
| 617 | - ); |
|
| 618 | - |
|
| 619 | - if (1 == $params['show_featured_only']) { |
|
| 620 | - $query_args['show_featured_only'] = 1; |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - if (0 != $params['category'] && '' != $params['category']) { |
|
| 624 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 625 | - $tax_query = array( |
|
| 626 | - 'taxonomy' => $category_taxonomy[0], |
|
| 627 | - 'field' => 'id', |
|
| 628 | - 'terms' => $params['category'], |
|
| 629 | - ); |
|
| 630 | - |
|
| 631 | - $query_args['tax_query'] = array($tax_query); |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - $defaults = array( |
|
| 635 | - 'before_widget' => '', |
|
| 636 | - 'after_widget' => '', |
|
| 637 | - 'before_title' => '', |
|
| 638 | - 'after_title' => '', |
|
| 639 | - ); |
|
| 640 | - |
|
| 641 | - $query_args = array_merge($query_args, $params); |
|
| 642 | - |
|
| 643 | - geodir_listing_slider_widget_output($defaults, $query_args); |
|
| 644 | - |
|
| 645 | - $output = ob_get_contents(); |
|
| 646 | - |
|
| 647 | - ob_end_clean(); |
|
| 648 | - |
|
| 649 | - return $output; |
|
| 594 | + // redeclare vars after validation |
|
| 595 | + |
|
| 596 | + if (isset($params['direction_nav'])) { |
|
| 597 | + $params['directionNav'] = $params['direction_nav']; |
|
| 598 | + } |
|
| 599 | + if (isset($params['animation_loop'])) { |
|
| 600 | + $params['animationLoop'] = $params['animation_loop']; |
|
| 601 | + } |
|
| 602 | + if (isset($params['slideshow_speed'])) { |
|
| 603 | + $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
| 604 | + } |
|
| 605 | + if (isset($params['animation_speed'])) { |
|
| 606 | + $params['animationSpeed'] = $params['animation_speed']; |
|
| 607 | + } |
|
| 608 | + if (isset($params['order_by'])) { |
|
| 609 | + $params['list_sort'] = $params['order_by']; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + $query_args = array( |
|
| 613 | + 'post_number' => $params['post_number'], |
|
| 614 | + 'is_geodir_loop' => true, |
|
| 615 | + 'post_type' => $params['post_type'], |
|
| 616 | + 'order_by' => $params['order_by'] |
|
| 617 | + ); |
|
| 618 | + |
|
| 619 | + if (1 == $params['show_featured_only']) { |
|
| 620 | + $query_args['show_featured_only'] = 1; |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + if (0 != $params['category'] && '' != $params['category']) { |
|
| 624 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 625 | + $tax_query = array( |
|
| 626 | + 'taxonomy' => $category_taxonomy[0], |
|
| 627 | + 'field' => 'id', |
|
| 628 | + 'terms' => $params['category'], |
|
| 629 | + ); |
|
| 630 | + |
|
| 631 | + $query_args['tax_query'] = array($tax_query); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + $defaults = array( |
|
| 635 | + 'before_widget' => '', |
|
| 636 | + 'after_widget' => '', |
|
| 637 | + 'before_title' => '', |
|
| 638 | + 'after_title' => '', |
|
| 639 | + ); |
|
| 640 | + |
|
| 641 | + $query_args = array_merge($query_args, $params); |
|
| 642 | + |
|
| 643 | + geodir_listing_slider_widget_output($defaults, $query_args); |
|
| 644 | + |
|
| 645 | + $output = ob_get_contents(); |
|
| 646 | + |
|
| 647 | + ob_end_clean(); |
|
| 648 | + |
|
| 649 | + return $output; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | add_shortcode('gd_login_box', 'geodir_sc_login_box'); |
@@ -670,22 +670,22 @@ discard block |
||
| 670 | 670 | */ |
| 671 | 671 | function geodir_sc_login_box($atts) |
| 672 | 672 | { |
| 673 | - ob_start(); |
|
| 673 | + ob_start(); |
|
| 674 | 674 | |
| 675 | - $defaults = array( |
|
| 676 | - 'before_widget' => '', |
|
| 677 | - 'after_widget' => '', |
|
| 678 | - 'before_title' => '', |
|
| 679 | - 'after_title' => '', |
|
| 680 | - ); |
|
| 675 | + $defaults = array( |
|
| 676 | + 'before_widget' => '', |
|
| 677 | + 'after_widget' => '', |
|
| 678 | + 'before_title' => '', |
|
| 679 | + 'after_title' => '', |
|
| 680 | + ); |
|
| 681 | 681 | |
| 682 | - geodir_loginwidget_output($defaults, $defaults); |
|
| 682 | + geodir_loginwidget_output($defaults, $defaults); |
|
| 683 | 683 | |
| 684 | - $output = ob_get_contents(); |
|
| 684 | + $output = ob_get_contents(); |
|
| 685 | 685 | |
| 686 | - ob_end_clean(); |
|
| 686 | + ob_end_clean(); |
|
| 687 | 687 | |
| 688 | - return $output; |
|
| 688 | + return $output; |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category'); |
@@ -716,31 +716,31 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | function geodir_sc_popular_post_category($atts) |
| 718 | 718 | { |
| 719 | - ob_start(); |
|
| 720 | - global $geodir_post_category_str; |
|
| 721 | - $defaults = array( |
|
| 722 | - 'category_limit' => 15, |
|
| 723 | - 'category_restrict' => false, |
|
| 724 | - 'before_widget' => '', |
|
| 725 | - 'after_widget' => '', |
|
| 726 | - 'before_title' => '', |
|
| 727 | - 'after_title' => '', |
|
| 728 | - 'title' => '', |
|
| 729 | - 'default_post_type' => '', |
|
| 730 | - 'parent_only' => false, |
|
| 731 | - ); |
|
| 732 | - |
|
| 733 | - $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
| 734 | - $params['category_limit'] = absint($params['category_limit']); |
|
| 735 | - $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
| 736 | - $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
| 737 | - geodir_popular_post_category_output($params, $params); |
|
| 738 | - |
|
| 739 | - $output = ob_get_contents(); |
|
| 740 | - |
|
| 741 | - ob_end_clean(); |
|
| 742 | - |
|
| 743 | - return $output; |
|
| 719 | + ob_start(); |
|
| 720 | + global $geodir_post_category_str; |
|
| 721 | + $defaults = array( |
|
| 722 | + 'category_limit' => 15, |
|
| 723 | + 'category_restrict' => false, |
|
| 724 | + 'before_widget' => '', |
|
| 725 | + 'after_widget' => '', |
|
| 726 | + 'before_title' => '', |
|
| 727 | + 'after_title' => '', |
|
| 728 | + 'title' => '', |
|
| 729 | + 'default_post_type' => '', |
|
| 730 | + 'parent_only' => false, |
|
| 731 | + ); |
|
| 732 | + |
|
| 733 | + $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
| 734 | + $params['category_limit'] = absint($params['category_limit']); |
|
| 735 | + $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
| 736 | + $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
| 737 | + geodir_popular_post_category_output($params, $params); |
|
| 738 | + |
|
| 739 | + $output = ob_get_contents(); |
|
| 740 | + |
|
| 741 | + ob_end_clean(); |
|
| 742 | + |
|
| 743 | + return $output; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view'); |
@@ -781,96 +781,96 @@ discard block |
||
| 781 | 781 | */ |
| 782 | 782 | function geodir_sc_popular_post_view($atts) |
| 783 | 783 | { |
| 784 | - ob_start(); |
|
| 785 | - $defaults = array( |
|
| 786 | - 'post_type' => 'gd_place', |
|
| 787 | - 'category' => '0', |
|
| 788 | - 'post_number' => '5', |
|
| 789 | - 'layout' => 'gridview_onehalf', |
|
| 790 | - 'add_location_filter' => '0', |
|
| 791 | - 'list_sort' => 'latest', |
|
| 792 | - 'use_viewing_post_type' => '1', |
|
| 793 | - 'character_count' => '20', |
|
| 794 | - 'listing_width' => '', |
|
| 795 | - 'show_featured_only' => '0', |
|
| 796 | - 'show_special_only' => '0', |
|
| 797 | - 'with_pics_only' => '0', |
|
| 798 | - 'with_videos_only' => '0', |
|
| 799 | - 'before_widget' => '', |
|
| 800 | - 'after_widget' => '', |
|
| 801 | - 'before_title' => '<h3 class="widget-title">', |
|
| 802 | - 'after_title' => '</h3>', |
|
| 803 | - 'title' => '', |
|
| 804 | - 'category_title' => '', |
|
| 805 | - ); |
|
| 806 | - |
|
| 807 | - $params = shortcode_atts($defaults, $atts); |
|
| 808 | - |
|
| 809 | - /** |
|
| 810 | - * Validate our incoming params |
|
| 811 | - */ |
|
| 784 | + ob_start(); |
|
| 785 | + $defaults = array( |
|
| 786 | + 'post_type' => 'gd_place', |
|
| 787 | + 'category' => '0', |
|
| 788 | + 'post_number' => '5', |
|
| 789 | + 'layout' => 'gridview_onehalf', |
|
| 790 | + 'add_location_filter' => '0', |
|
| 791 | + 'list_sort' => 'latest', |
|
| 792 | + 'use_viewing_post_type' => '1', |
|
| 793 | + 'character_count' => '20', |
|
| 794 | + 'listing_width' => '', |
|
| 795 | + 'show_featured_only' => '0', |
|
| 796 | + 'show_special_only' => '0', |
|
| 797 | + 'with_pics_only' => '0', |
|
| 798 | + 'with_videos_only' => '0', |
|
| 799 | + 'before_widget' => '', |
|
| 800 | + 'after_widget' => '', |
|
| 801 | + 'before_title' => '<h3 class="widget-title">', |
|
| 802 | + 'after_title' => '</h3>', |
|
| 803 | + 'title' => '', |
|
| 804 | + 'category_title' => '', |
|
| 805 | + ); |
|
| 812 | 806 | |
| 813 | - // Validate the selected post type, default to gd_place on fail |
|
| 814 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 815 | - $params['post_type'] = 'gd_place'; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
| 819 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 820 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
| 821 | - |
|
| 822 | - // Make sure we have an array |
|
| 823 | - if (!(is_array($params['category']))) { |
|
| 824 | - $params['category'] = explode(',', $params['category']); |
|
| 825 | - } |
|
| 826 | - |
|
| 827 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 828 | - // Otherwise it becomes empty and later on that will mean "All" |
|
| 829 | - $params['category'] = array_intersect($params['category'], $categories); |
|
| 830 | - |
|
| 831 | - // Post_number needs to be a positive integer |
|
| 832 | - $params['post_number'] = absint($params['post_number']); |
|
| 833 | - if (0 == $params['post_number']) { |
|
| 834 | - $params['post_number'] = 1; |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - // Validate our layout choice |
|
| 838 | - // Outside of the norm, I added some more simple terms to match the existing |
|
| 839 | - // So now I just run the switch to set it properly. |
|
| 840 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 841 | - |
|
| 842 | - // Validate our sorting choice |
|
| 843 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 844 | - |
|
| 845 | - // Validate character_count |
|
| 846 | - if ($params['character_count'] !== '') { |
|
| 847 | - $params['character_count'] = absint($params['character_count']); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
| 851 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 852 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 853 | - |
|
| 854 | - // Validate the checkboxes used on the widget |
|
| 855 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 856 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 857 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 858 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 859 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 860 | - $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * End of validation |
|
| 864 | - */ |
|
| 807 | + $params = shortcode_atts($defaults, $atts); |
|
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * Validate our incoming params |
|
| 811 | + */ |
|
| 812 | + |
|
| 813 | + // Validate the selected post type, default to gd_place on fail |
|
| 814 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 815 | + $params['post_type'] = 'gd_place'; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
| 819 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 820 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
| 821 | + |
|
| 822 | + // Make sure we have an array |
|
| 823 | + if (!(is_array($params['category']))) { |
|
| 824 | + $params['category'] = explode(',', $params['category']); |
|
| 825 | + } |
|
| 865 | 826 | |
| 866 | - geodir_popular_postview_output($params, $params); |
|
| 827 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 828 | + // Otherwise it becomes empty and later on that will mean "All" |
|
| 829 | + $params['category'] = array_intersect($params['category'], $categories); |
|
| 867 | 830 | |
| 831 | + // Post_number needs to be a positive integer |
|
| 832 | + $params['post_number'] = absint($params['post_number']); |
|
| 833 | + if (0 == $params['post_number']) { |
|
| 834 | + $params['post_number'] = 1; |
|
| 835 | + } |
|
| 836 | + |
|
| 837 | + // Validate our layout choice |
|
| 838 | + // Outside of the norm, I added some more simple terms to match the existing |
|
| 839 | + // So now I just run the switch to set it properly. |
|
| 840 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 841 | + |
|
| 842 | + // Validate our sorting choice |
|
| 843 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 844 | + |
|
| 845 | + // Validate character_count |
|
| 846 | + if ($params['character_count'] !== '') { |
|
| 847 | + $params['character_count'] = absint($params['character_count']); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
| 851 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 852 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 868 | 853 | |
| 869 | - $output = ob_get_contents(); |
|
| 854 | + // Validate the checkboxes used on the widget |
|
| 855 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 856 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 857 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 858 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 859 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 860 | + $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
| 870 | 861 | |
| 871 | - ob_end_clean(); |
|
| 862 | + /** |
|
| 863 | + * End of validation |
|
| 864 | + */ |
|
| 872 | 865 | |
| 873 | - return $output; |
|
| 866 | + geodir_popular_postview_output($params, $params); |
|
| 867 | + |
|
| 868 | + |
|
| 869 | + $output = ob_get_contents(); |
|
| 870 | + |
|
| 871 | + ob_end_clean(); |
|
| 872 | + |
|
| 873 | + return $output; |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews'); |
@@ -892,37 +892,37 @@ discard block |
||
| 892 | 892 | * @return string Recent reviews HTML. |
| 893 | 893 | */ |
| 894 | 894 | function geodir_sc_recent_reviews($atts) { |
| 895 | - ob_start(); |
|
| 896 | - $defaults = array( |
|
| 895 | + ob_start(); |
|
| 896 | + $defaults = array( |
|
| 897 | 897 | 'title' => '', |
| 898 | 898 | 'count' => 5, |
| 899 | - ); |
|
| 899 | + ); |
|
| 900 | 900 | |
| 901 | - $params = shortcode_atts($defaults, $atts); |
|
| 901 | + $params = shortcode_atts($defaults, $atts); |
|
| 902 | 902 | |
| 903 | - $count = absint($params['count']); |
|
| 904 | - if (0 == $count) { |
|
| 905 | - $count = 1; |
|
| 906 | - } |
|
| 903 | + $count = absint($params['count']); |
|
| 904 | + if (0 == $count) { |
|
| 905 | + $count = 1; |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | 908 | $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; |
| 909 | 909 | |
| 910 | - $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
| 910 | + $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
| 911 | 911 | |
| 912 | - if ($comments_li) { |
|
| 913 | - if ($title != '') { ?> |
|
| 912 | + if ($comments_li) { |
|
| 913 | + if ($title != '') { ?> |
|
| 914 | 914 | <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3> |
| 915 | 915 | <?php } ?> |
| 916 | 916 | <div class="geodir_sc_recent_reviews_section"> |
| 917 | 917 | <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul> |
| 918 | 918 | </div> |
| 919 | 919 | <?php |
| 920 | - } |
|
| 921 | - $output = ob_get_contents(); |
|
| 920 | + } |
|
| 921 | + $output = ob_get_contents(); |
|
| 922 | 922 | |
| 923 | - ob_end_clean(); |
|
| 923 | + ob_end_clean(); |
|
| 924 | 924 | |
| 925 | - return $output; |
|
| 925 | + return $output; |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | add_shortcode('gd_related_listings', 'geodir_sc_related_listings'); |
@@ -952,63 +952,63 @@ discard block |
||
| 952 | 952 | */ |
| 953 | 953 | function geodir_sc_related_listings($atts) |
| 954 | 954 | { |
| 955 | - ob_start(); |
|
| 956 | - $defaults = array( |
|
| 957 | - 'post_number' => 5, |
|
| 958 | - 'relate_to' => 'category', |
|
| 959 | - 'layout' => 'gridview_onehalf', |
|
| 960 | - 'add_location_filter' => 0, |
|
| 961 | - 'listing_width' => '', |
|
| 962 | - 'list_sort' => 'latest', |
|
| 963 | - 'character_count' => 20, |
|
| 964 | - 'is_widget' => 1, |
|
| 965 | - 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
| 966 | - ); |
|
| 967 | - // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
| 968 | - |
|
| 969 | - $params = shortcode_atts($defaults, $atts); |
|
| 970 | - |
|
| 971 | - /** |
|
| 972 | - * Begin validating parameters |
|
| 973 | - */ |
|
| 955 | + ob_start(); |
|
| 956 | + $defaults = array( |
|
| 957 | + 'post_number' => 5, |
|
| 958 | + 'relate_to' => 'category', |
|
| 959 | + 'layout' => 'gridview_onehalf', |
|
| 960 | + 'add_location_filter' => 0, |
|
| 961 | + 'listing_width' => '', |
|
| 962 | + 'list_sort' => 'latest', |
|
| 963 | + 'character_count' => 20, |
|
| 964 | + 'is_widget' => 1, |
|
| 965 | + 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
| 966 | + ); |
|
| 967 | + // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
| 974 | 968 | |
| 975 | - // Validate that post_number is a number and is 1 or higher |
|
| 976 | - $params['post_number'] = absint($params['post_number']); |
|
| 977 | - if (0 === $params['post_number']) { |
|
| 978 | - $params['post_number'] = 1; |
|
| 979 | - } |
|
| 969 | + $params = shortcode_atts($defaults, $atts); |
|
| 980 | 970 | |
| 981 | - // Validate relate_to - only category or tags |
|
| 982 | - $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
| 983 | - if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
| 984 | - $params['relate_to'] = 'category'; |
|
| 985 | - } |
|
| 971 | + /** |
|
| 972 | + * Begin validating parameters |
|
| 973 | + */ |
|
| 986 | 974 | |
| 987 | - // Validate layout selection |
|
| 988 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 975 | + // Validate that post_number is a number and is 1 or higher |
|
| 976 | + $params['post_number'] = absint($params['post_number']); |
|
| 977 | + if (0 === $params['post_number']) { |
|
| 978 | + $params['post_number'] = 1; |
|
| 979 | + } |
|
| 989 | 980 | |
| 990 | - // Validate sorting option |
|
| 991 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 981 | + // Validate relate_to - only category or tags |
|
| 982 | + $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
| 983 | + if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
| 984 | + $params['relate_to'] = 'category'; |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + // Validate layout selection |
|
| 988 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 992 | 989 | |
| 993 | - // Validate add_location_filter |
|
| 994 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 990 | + // Validate sorting option |
|
| 991 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 995 | 992 | |
| 996 | - // Validate listing_width |
|
| 997 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 993 | + // Validate add_location_filter |
|
| 994 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 998 | 995 | |
| 999 | - // Validate character_count |
|
| 1000 | - if ($params['character_count'] !== '') { |
|
| 1001 | - $params['character_count'] = absint($params['character_count']); |
|
| 1002 | - } |
|
| 996 | + // Validate listing_width |
|
| 997 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1003 | 998 | |
| 1004 | - if ($related_display = geodir_related_posts_display($params)) { |
|
| 1005 | - echo $related_display; |
|
| 1006 | - } |
|
| 1007 | - $output = ob_get_contents(); |
|
| 999 | + // Validate character_count |
|
| 1000 | + if ($params['character_count'] !== '') { |
|
| 1001 | + $params['character_count'] = absint($params['character_count']); |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + if ($related_display = geodir_related_posts_display($params)) { |
|
| 1005 | + echo $related_display; |
|
| 1006 | + } |
|
| 1007 | + $output = ob_get_contents(); |
|
| 1008 | 1008 | |
| 1009 | - ob_end_clean(); |
|
| 1009 | + ob_end_clean(); |
|
| 1010 | 1010 | |
| 1011 | - return $output; |
|
| 1011 | + return $output; |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /** |
@@ -1032,13 +1032,13 @@ discard block |
||
| 1032 | 1032 | * @return string Advanced search widget HTML. |
| 1033 | 1033 | */ |
| 1034 | 1034 | function geodir_sc_advanced_search($atts) { |
| 1035 | - $defaults = array( |
|
| 1035 | + $defaults = array( |
|
| 1036 | 1036 | 'title' => '', |
| 1037 | 1037 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
| 1038 | - 'after_widget' => '</section>', |
|
| 1039 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1040 | - 'after_title' => '</h3>', |
|
| 1041 | - 'show_adv_search' => 'default', |
|
| 1038 | + 'after_widget' => '</section>', |
|
| 1039 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1040 | + 'after_title' => '</h3>', |
|
| 1041 | + 'show_adv_search' => 'default', |
|
| 1042 | 1042 | 'post_type' => '' |
| 1043 | 1043 | ); |
| 1044 | 1044 | |
@@ -1062,9 +1062,9 @@ discard block |
||
| 1062 | 1062 | the_widget('geodir_advance_search_widget', $params, $params ); |
| 1063 | 1063 | |
| 1064 | 1064 | $output = ob_get_contents(); |
| 1065 | - ob_end_clean(); |
|
| 1065 | + ob_end_clean(); |
|
| 1066 | 1066 | |
| 1067 | - return $output; |
|
| 1067 | + return $output; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
| 1070 | 1070 | |
@@ -1110,48 +1110,48 @@ discard block |
||
| 1110 | 1110 | 'add_location_filter' => '1', |
| 1111 | 1111 | 'tab_layout' => 'bestof-tabs-on-top', |
| 1112 | 1112 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
| 1113 | - 'after_widget' => '</section>', |
|
| 1114 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1115 | - 'after_title' => '</h3>', |
|
| 1113 | + 'after_widget' => '</section>', |
|
| 1114 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1115 | + 'after_title' => '</h3>', |
|
| 1116 | 1116 | ); |
| 1117 | 1117 | $params = shortcode_atts($defaults, $atts); |
| 1118 | 1118 | |
| 1119 | - /** |
|
| 1120 | - * Validate our incoming params |
|
| 1121 | - */ |
|
| 1119 | + /** |
|
| 1120 | + * Validate our incoming params |
|
| 1121 | + */ |
|
| 1122 | 1122 | |
| 1123 | - // Validate the selected post type, default to gd_place on fail |
|
| 1124 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 1125 | - $params['post_type'] = 'gd_place'; |
|
| 1126 | - } |
|
| 1123 | + // Validate the selected post type, default to gd_place on fail |
|
| 1124 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 1125 | + $params['post_type'] = 'gd_place'; |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | 1128 | // Post limit needs to be a positive integer |
| 1129 | - $params['post_limit'] = absint($params['post_limit']); |
|
| 1130 | - if (0 == $params['post_limit']) { |
|
| 1131 | - $params['post_limit'] = 5; |
|
| 1132 | - } |
|
| 1129 | + $params['post_limit'] = absint($params['post_limit']); |
|
| 1130 | + if (0 == $params['post_limit']) { |
|
| 1131 | + $params['post_limit'] = 5; |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | 1134 | // Category limit needs to be a positive integer |
| 1135 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
| 1136 | - if (0 == $params['categ_limit']) { |
|
| 1137 | - $params['categ_limit'] = 3; |
|
| 1138 | - } |
|
| 1135 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
| 1136 | + if (0 == $params['categ_limit']) { |
|
| 1137 | + $params['categ_limit'] = 3; |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | 1140 | // Tab layout validation |
| 1141 | - $params['tab_layout'] = $params['tab_layout']; |
|
| 1142 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
| 1143 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
| 1144 | - } |
|
| 1141 | + $params['tab_layout'] = $params['tab_layout']; |
|
| 1142 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
| 1143 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | 1146 | // Validate character_count |
| 1147 | - $params['character_count'] = $params['character_count']; |
|
| 1147 | + $params['character_count'] = $params['character_count']; |
|
| 1148 | 1148 | |
| 1149 | 1149 | ob_start(); |
| 1150 | 1150 | the_widget('geodir_bestof_widget', $params, $params); |
| 1151 | - $output = ob_get_contents(); |
|
| 1152 | - ob_end_clean(); |
|
| 1151 | + $output = ob_get_contents(); |
|
| 1152 | + ob_end_clean(); |
|
| 1153 | 1153 | |
| 1154 | - return $output; |
|
| 1154 | + return $output; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
| 1157 | 1157 | |
@@ -1204,143 +1204,143 @@ discard block |
||
| 1204 | 1204 | * @return string HTML content to display geodirectory listings. |
| 1205 | 1205 | */ |
| 1206 | 1206 | function geodir_sc_gd_listings($atts, $content = '') { |
| 1207 | - global $post; |
|
| 1208 | - $defaults = array( |
|
| 1209 | - 'title' => '', |
|
| 1210 | - 'post_type' => 'gd_place', |
|
| 1211 | - 'category' => 0, |
|
| 1212 | - 'list_sort' => 'latest', |
|
| 1213 | - 'event_type' => '', |
|
| 1214 | - 'post_number' => 10, |
|
| 1215 | - 'post_author' => '', |
|
| 1216 | - 'layout' => 'gridview_onehalf', |
|
| 1217 | - 'listing_width' => '', |
|
| 1218 | - 'character_count' => 20, |
|
| 1219 | - 'add_location_filter' => 1, |
|
| 1220 | - 'show_featured_only' => '', |
|
| 1221 | - 'show_special_only' => '', |
|
| 1222 | - 'with_pics_only' => '', |
|
| 1223 | - 'with_videos_only' => '', |
|
| 1224 | - 'with_pagination' => '1', |
|
| 1225 | - 'top_pagination' => '0', |
|
| 1226 | - 'bottom_pagination' => '1', |
|
| 1227 | - 'without_no_results' => 0, |
|
| 1228 | - 'tags' => '', |
|
| 1229 | - 'show_favorites_only' => '', |
|
| 1230 | - 'favorites_by_user' => '', |
|
| 1231 | - ); |
|
| 1232 | - $params = shortcode_atts($defaults, $atts); |
|
| 1233 | - |
|
| 1234 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
| 1235 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
| 1236 | - |
|
| 1237 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
| 1238 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 1239 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
| 1240 | - |
|
| 1241 | - // Make sure we have an array |
|
| 1242 | - if (!(is_array($params['category']))) { |
|
| 1243 | - $params['category'] = explode(',', $params['category']); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 1247 | - // Otherwise it becomes empty and later on that will mean "All" |
|
| 1248 | - $params['category'] = array_intersect($params['category'], $categories); |
|
| 1249 | - |
|
| 1250 | - // Post_number needs to be a positive integer |
|
| 1251 | - $params['post_number'] = absint($params['post_number']); |
|
| 1252 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
| 1207 | + global $post; |
|
| 1208 | + $defaults = array( |
|
| 1209 | + 'title' => '', |
|
| 1210 | + 'post_type' => 'gd_place', |
|
| 1211 | + 'category' => 0, |
|
| 1212 | + 'list_sort' => 'latest', |
|
| 1213 | + 'event_type' => '', |
|
| 1214 | + 'post_number' => 10, |
|
| 1215 | + 'post_author' => '', |
|
| 1216 | + 'layout' => 'gridview_onehalf', |
|
| 1217 | + 'listing_width' => '', |
|
| 1218 | + 'character_count' => 20, |
|
| 1219 | + 'add_location_filter' => 1, |
|
| 1220 | + 'show_featured_only' => '', |
|
| 1221 | + 'show_special_only' => '', |
|
| 1222 | + 'with_pics_only' => '', |
|
| 1223 | + 'with_videos_only' => '', |
|
| 1224 | + 'with_pagination' => '1', |
|
| 1225 | + 'top_pagination' => '0', |
|
| 1226 | + 'bottom_pagination' => '1', |
|
| 1227 | + 'without_no_results' => 0, |
|
| 1228 | + 'tags' => '', |
|
| 1229 | + 'show_favorites_only' => '', |
|
| 1230 | + 'favorites_by_user' => '', |
|
| 1231 | + ); |
|
| 1232 | + $params = shortcode_atts($defaults, $atts); |
|
| 1233 | + |
|
| 1234 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
| 1235 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
| 1236 | + |
|
| 1237 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
| 1238 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 1239 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
| 1240 | + |
|
| 1241 | + // Make sure we have an array |
|
| 1242 | + if (!(is_array($params['category']))) { |
|
| 1243 | + $params['category'] = explode(',', $params['category']); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 1247 | + // Otherwise it becomes empty and later on that will mean "All" |
|
| 1248 | + $params['category'] = array_intersect($params['category'], $categories); |
|
| 1249 | + |
|
| 1250 | + // Post_number needs to be a positive integer |
|
| 1251 | + $params['post_number'] = absint($params['post_number']); |
|
| 1252 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
| 1253 | 1253 | |
| 1254 | - // Post_number needs to be a positive integer |
|
| 1255 | - if (!empty($atts['post_author'])) { |
|
| 1256 | - if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1257 | - $params['post_author'] = $post->post_author; |
|
| 1258 | - } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
| 1259 | - $params['post_author'] = absint($atts['post_author']); |
|
| 1260 | - } else { |
|
| 1261 | - unset($params['post_author']); |
|
| 1262 | - } |
|
| 1263 | - } else { |
|
| 1264 | - unset($params['post_author']); |
|
| 1265 | - } |
|
| 1266 | - |
|
| 1267 | - // Validate character_count |
|
| 1268 | - //todo: is this necessary? |
|
| 1269 | - $params['character_count'] = $params['character_count']; |
|
| 1270 | - |
|
| 1271 | - // Validate our layout choice |
|
| 1272 | - // Outside of the norm, I added some more simple terms to match the existing |
|
| 1273 | - // So now I just run the switch to set it properly. |
|
| 1274 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 1275 | - |
|
| 1276 | - // Validate our sorting choice |
|
| 1277 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 1278 | - |
|
| 1279 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
| 1280 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 1281 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1282 | - |
|
| 1283 | - // Validate the checkboxes used on the widget |
|
| 1284 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 1285 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 1286 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 1287 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 1288 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 1289 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
| 1290 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
| 1291 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
| 1254 | + // Post_number needs to be a positive integer |
|
| 1255 | + if (!empty($atts['post_author'])) { |
|
| 1256 | + if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1257 | + $params['post_author'] = $post->post_author; |
|
| 1258 | + } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
| 1259 | + $params['post_author'] = absint($atts['post_author']); |
|
| 1260 | + } else { |
|
| 1261 | + unset($params['post_author']); |
|
| 1262 | + } |
|
| 1263 | + } else { |
|
| 1264 | + unset($params['post_author']); |
|
| 1265 | + } |
|
| 1266 | + |
|
| 1267 | + // Validate character_count |
|
| 1268 | + //todo: is this necessary? |
|
| 1269 | + $params['character_count'] = $params['character_count']; |
|
| 1270 | + |
|
| 1271 | + // Validate our layout choice |
|
| 1272 | + // Outside of the norm, I added some more simple terms to match the existing |
|
| 1273 | + // So now I just run the switch to set it properly. |
|
| 1274 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 1275 | + |
|
| 1276 | + // Validate our sorting choice |
|
| 1277 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 1278 | + |
|
| 1279 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
| 1280 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 1281 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1282 | + |
|
| 1283 | + // Validate the checkboxes used on the widget |
|
| 1284 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 1285 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 1286 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 1287 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 1288 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 1289 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
| 1290 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
| 1291 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
| 1292 | 1292 | |
| 1293 | - // User favorites |
|
| 1294 | - $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
| 1295 | - if (!empty($params['show_favorites_only'])) { |
|
| 1296 | - if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1297 | - $params['favorites_by_user'] = $post->post_author; |
|
| 1298 | - } else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) { |
|
| 1299 | - $params['favorites_by_user'] = absint($atts['favorites_by_user']); |
|
| 1300 | - } else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) { |
|
| 1301 | - $params['favorites_by_user'] = $current_user_id; |
|
| 1302 | - } else { |
|
| 1303 | - $params['favorites_by_user'] = 0; |
|
| 1304 | - } |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - // Clean tags |
|
| 1308 | - if (!empty($params['tags'])) { |
|
| 1309 | - if (!is_array($params['tags'])) { |
|
| 1310 | - $comma = _x(',', 'tag delimiter'); |
|
| 1311 | - if ( ',' !== $comma ) { |
|
| 1312 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
| 1313 | - } |
|
| 1314 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
| 1315 | - $params['tags'] = array_map('trim', $params['tags']); |
|
| 1316 | - } |
|
| 1317 | - } else { |
|
| 1318 | - $params['tags'] = array(); |
|
| 1319 | - } |
|
| 1320 | - |
|
| 1321 | - /** |
|
| 1322 | - * End of validation |
|
| 1323 | - */ |
|
| 1324 | - if (isset($atts['geodir_ajax'])) { |
|
| 1325 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
| 1326 | - unset($atts['geodir_ajax']); |
|
| 1327 | - } |
|
| 1328 | - if (isset($atts['pageno'])) { |
|
| 1329 | - $params['pageno'] = $atts['pageno']; |
|
| 1330 | - unset($atts['pageno']); |
|
| 1331 | - } |
|
| 1332 | - |
|
| 1333 | - if ( !empty($atts['shortcode_content']) ) { |
|
| 1334 | - $content = $atts['shortcode_content']; |
|
| 1335 | - } |
|
| 1336 | - $params['shortcode_content'] = trim($content); |
|
| 1337 | - $atts['shortcode_content'] = trim($content); |
|
| 1293 | + // User favorites |
|
| 1294 | + $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
| 1295 | + if (!empty($params['show_favorites_only'])) { |
|
| 1296 | + if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1297 | + $params['favorites_by_user'] = $post->post_author; |
|
| 1298 | + } else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) { |
|
| 1299 | + $params['favorites_by_user'] = absint($atts['favorites_by_user']); |
|
| 1300 | + } else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) { |
|
| 1301 | + $params['favorites_by_user'] = $current_user_id; |
|
| 1302 | + } else { |
|
| 1303 | + $params['favorites_by_user'] = 0; |
|
| 1304 | + } |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + // Clean tags |
|
| 1308 | + if (!empty($params['tags'])) { |
|
| 1309 | + if (!is_array($params['tags'])) { |
|
| 1310 | + $comma = _x(',', 'tag delimiter'); |
|
| 1311 | + if ( ',' !== $comma ) { |
|
| 1312 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
| 1313 | + } |
|
| 1314 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
| 1315 | + $params['tags'] = array_map('trim', $params['tags']); |
|
| 1316 | + } |
|
| 1317 | + } else { |
|
| 1318 | + $params['tags'] = array(); |
|
| 1319 | + } |
|
| 1320 | + |
|
| 1321 | + /** |
|
| 1322 | + * End of validation |
|
| 1323 | + */ |
|
| 1324 | + if (isset($atts['geodir_ajax'])) { |
|
| 1325 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
| 1326 | + unset($atts['geodir_ajax']); |
|
| 1327 | + } |
|
| 1328 | + if (isset($atts['pageno'])) { |
|
| 1329 | + $params['pageno'] = $atts['pageno']; |
|
| 1330 | + unset($atts['pageno']); |
|
| 1331 | + } |
|
| 1332 | + |
|
| 1333 | + if ( !empty($atts['shortcode_content']) ) { |
|
| 1334 | + $content = $atts['shortcode_content']; |
|
| 1335 | + } |
|
| 1336 | + $params['shortcode_content'] = trim($content); |
|
| 1337 | + $atts['shortcode_content'] = trim($content); |
|
| 1338 | 1338 | |
| 1339 | - $params['shortcode_atts'] = $atts; |
|
| 1339 | + $params['shortcode_atts'] = $atts; |
|
| 1340 | 1340 | |
| 1341 | - $output = geodir_sc_gd_listings_output($params); |
|
| 1341 | + $output = geodir_sc_gd_listings_output($params); |
|
| 1342 | 1342 | |
| 1343 | - return $output; |
|
| 1343 | + return $output; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
| 1346 | 1346 | |
@@ -1380,56 +1380,56 @@ discard block |
||
| 1380 | 1380 | * @return string HTML content to display CPT categories. |
| 1381 | 1381 | */ |
| 1382 | 1382 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
| 1383 | - $defaults = array( |
|
| 1384 | - 'title' => '', |
|
| 1385 | - 'post_type' => '', // NULL for all |
|
| 1386 | - 'hide_empty' => '', |
|
| 1387 | - 'show_count' => '', |
|
| 1388 | - 'hide_icon' => '', |
|
| 1389 | - 'cpt_left' => '', |
|
| 1390 | - 'sort_by' => 'count', |
|
| 1391 | - 'max_count' => 'all', |
|
| 1392 | - 'max_level' => '1', |
|
| 1393 | - 'no_cpt_filter' => '', |
|
| 1394 | - 'no_cat_filter' => '', |
|
| 1395 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
| 1396 | - 'after_widget' => '</section>', |
|
| 1397 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1398 | - 'after_title' => '</h3>', |
|
| 1399 | - ); |
|
| 1400 | - $params = shortcode_atts($defaults, $atts); |
|
| 1401 | - |
|
| 1402 | - /** |
|
| 1403 | - * Validate our incoming params |
|
| 1404 | - */ |
|
| 1405 | - // Make sure we have an array |
|
| 1406 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
| 1407 | - |
|
| 1408 | - // Validate the checkboxes used on the widget |
|
| 1409 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
| 1410 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
| 1411 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
| 1412 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
| 1383 | + $defaults = array( |
|
| 1384 | + 'title' => '', |
|
| 1385 | + 'post_type' => '', // NULL for all |
|
| 1386 | + 'hide_empty' => '', |
|
| 1387 | + 'show_count' => '', |
|
| 1388 | + 'hide_icon' => '', |
|
| 1389 | + 'cpt_left' => '', |
|
| 1390 | + 'sort_by' => 'count', |
|
| 1391 | + 'max_count' => 'all', |
|
| 1392 | + 'max_level' => '1', |
|
| 1393 | + 'no_cpt_filter' => '', |
|
| 1394 | + 'no_cat_filter' => '', |
|
| 1395 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
| 1396 | + 'after_widget' => '</section>', |
|
| 1397 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1398 | + 'after_title' => '</h3>', |
|
| 1399 | + ); |
|
| 1400 | + $params = shortcode_atts($defaults, $atts); |
|
| 1413 | 1401 | |
| 1414 | - if ($params['max_count'] != 'all') { |
|
| 1415 | - $params['max_count'] = absint($params['max_count']); |
|
| 1416 | - } |
|
| 1402 | + /** |
|
| 1403 | + * Validate our incoming params |
|
| 1404 | + */ |
|
| 1405 | + // Make sure we have an array |
|
| 1406 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
| 1407 | + |
|
| 1408 | + // Validate the checkboxes used on the widget |
|
| 1409 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
| 1410 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
| 1411 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
| 1412 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
| 1413 | + |
|
| 1414 | + if ($params['max_count'] != 'all') { |
|
| 1415 | + $params['max_count'] = absint($params['max_count']); |
|
| 1416 | + } |
|
| 1417 | 1417 | |
| 1418 | - if ($params['max_level'] != 'all') { |
|
| 1419 | - $params['max_level'] = absint($params['max_level']); |
|
| 1420 | - } |
|
| 1418 | + if ($params['max_level'] != 'all') { |
|
| 1419 | + $params['max_level'] = absint($params['max_level']); |
|
| 1420 | + } |
|
| 1421 | 1421 | |
| 1422 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
| 1423 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
| 1422 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
| 1423 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
| 1424 | 1424 | |
| 1425 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
| 1425 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
| 1426 | 1426 | |
| 1427 | - ob_start(); |
|
| 1428 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
| 1429 | - $output = ob_get_contents(); |
|
| 1430 | - ob_end_clean(); |
|
| 1427 | + ob_start(); |
|
| 1428 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
| 1429 | + $output = ob_get_contents(); |
|
| 1430 | + ob_end_clean(); |
|
| 1431 | 1431 | |
| 1432 | - return $output; |
|
| 1432 | + return $output; |
|
| 1433 | 1433 | } |
| 1434 | 1434 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
| 1435 | 1435 | |
@@ -1444,6 +1444,6 @@ discard block |
||
| 1444 | 1444 | * @return string HTML code. |
| 1445 | 1445 | */ |
| 1446 | 1446 | function geodir_sc_responsive_videos($atts, $content) { |
| 1447 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
| 1447 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
| 1450 | 1450 | \ No newline at end of file |