@@ -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'); |
@@ -780,97 +780,97 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | function geodir_sc_popular_post_view($atts) |
| 782 | 782 | { |
| 783 | - ob_start(); |
|
| 784 | - $defaults = array( |
|
| 785 | - 'post_type' => 'gd_place', |
|
| 786 | - 'category' => '0', |
|
| 787 | - 'post_number' => '5', |
|
| 788 | - 'layout' => 'gridview_onehalf', |
|
| 789 | - 'add_location_filter' => '0', |
|
| 790 | - 'list_sort' => 'latest', |
|
| 791 | - 'use_viewing_post_type' => '1', |
|
| 792 | - 'character_count' => '20', |
|
| 793 | - 'listing_width' => '', |
|
| 794 | - 'show_featured_only' => '0', |
|
| 795 | - 'show_special_only' => '0', |
|
| 796 | - 'with_pics_only' => '0', |
|
| 797 | - 'with_videos_only' => '0', |
|
| 798 | - 'before_widget' => '', |
|
| 799 | - 'after_widget' => '', |
|
| 800 | - 'before_title' => '<h3 class="widget-title">', |
|
| 801 | - 'after_title' => '</h3>', |
|
| 802 | - 'title' => '', |
|
| 803 | - 'category_title' => '', |
|
| 804 | - ); |
|
| 805 | - |
|
| 806 | - $params = shortcode_atts($defaults, $atts); |
|
| 807 | - |
|
| 808 | - /** |
|
| 809 | - * Validate our incoming params |
|
| 810 | - */ |
|
| 783 | + ob_start(); |
|
| 784 | + $defaults = array( |
|
| 785 | + 'post_type' => 'gd_place', |
|
| 786 | + 'category' => '0', |
|
| 787 | + 'post_number' => '5', |
|
| 788 | + 'layout' => 'gridview_onehalf', |
|
| 789 | + 'add_location_filter' => '0', |
|
| 790 | + 'list_sort' => 'latest', |
|
| 791 | + 'use_viewing_post_type' => '1', |
|
| 792 | + 'character_count' => '20', |
|
| 793 | + 'listing_width' => '', |
|
| 794 | + 'show_featured_only' => '0', |
|
| 795 | + 'show_special_only' => '0', |
|
| 796 | + 'with_pics_only' => '0', |
|
| 797 | + 'with_videos_only' => '0', |
|
| 798 | + 'before_widget' => '', |
|
| 799 | + 'after_widget' => '', |
|
| 800 | + 'before_title' => '<h3 class="widget-title">', |
|
| 801 | + 'after_title' => '</h3>', |
|
| 802 | + 'title' => '', |
|
| 803 | + 'category_title' => '', |
|
| 804 | + ); |
|
| 811 | 805 | |
| 812 | - // Validate the selected post type, default to gd_place on fail |
|
| 813 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 814 | - $params['post_type'] = 'gd_place'; |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
| 818 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 819 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
| 820 | - |
|
| 821 | - // Make sure we have an array |
|
| 822 | - if (!(is_array($params['category']))) { |
|
| 823 | - $params['category'] = explode(',', $params['category']); |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 827 | - // Otherwise it becomes empty and later on that will mean "All" |
|
| 828 | - $params['category'] = array_intersect($params['category'], $categories); |
|
| 829 | - |
|
| 830 | - // Post_number needs to be a positive integer |
|
| 831 | - $params['post_number'] = absint($params['post_number']); |
|
| 832 | - if (0 == $params['post_number']) { |
|
| 833 | - $params['post_number'] = 1; |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - // Validate our layout choice |
|
| 837 | - // Outside of the norm, I added some more simple terms to match the existing |
|
| 838 | - // So now I just run the switch to set it properly. |
|
| 839 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 840 | - |
|
| 841 | - // Validate our sorting choice |
|
| 842 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 843 | - |
|
| 844 | - // Validate character_count |
|
| 845 | - $params['character_count'] = absint($params['character_count']); |
|
| 846 | - if (20 > $params['character_count']) { |
|
| 847 | - $params['character_count'] = 20; |
|
| 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 | - */ |
|
| 806 | + $params = shortcode_atts($defaults, $atts); |
|
| 807 | + |
|
| 808 | + /** |
|
| 809 | + * Validate our incoming params |
|
| 810 | + */ |
|
| 811 | + |
|
| 812 | + // Validate the selected post type, default to gd_place on fail |
|
| 813 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 814 | + $params['post_type'] = 'gd_place'; |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
| 818 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 819 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
| 820 | + |
|
| 821 | + // Make sure we have an array |
|
| 822 | + if (!(is_array($params['category']))) { |
|
| 823 | + $params['category'] = explode(',', $params['category']); |
|
| 824 | + } |
|
| 865 | 825 | |
| 866 | - geodir_popular_postview_output($params, $params); |
|
| 826 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 827 | + // Otherwise it becomes empty and later on that will mean "All" |
|
| 828 | + $params['category'] = array_intersect($params['category'], $categories); |
|
| 867 | 829 | |
| 830 | + // Post_number needs to be a positive integer |
|
| 831 | + $params['post_number'] = absint($params['post_number']); |
|
| 832 | + if (0 == $params['post_number']) { |
|
| 833 | + $params['post_number'] = 1; |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + // Validate our layout choice |
|
| 837 | + // Outside of the norm, I added some more simple terms to match the existing |
|
| 838 | + // So now I just run the switch to set it properly. |
|
| 839 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 840 | + |
|
| 841 | + // Validate our sorting choice |
|
| 842 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 843 | + |
|
| 844 | + // Validate character_count |
|
| 845 | + $params['character_count'] = absint($params['character_count']); |
|
| 846 | + if (20 > $params['character_count']) { |
|
| 847 | + $params['character_count'] = 20; |
|
| 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,64 +952,64 @@ 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 | - $params['character_count'] = absint($params['character_count']); |
|
| 1001 | - if (20 > $params['character_count']) { |
|
| 1002 | - $params['character_count'] = 20; |
|
| 1003 | - } |
|
| 996 | + // Validate listing_width |
|
| 997 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1004 | 998 | |
| 1005 | - if ($related_display = geodir_related_posts_display($params)) { |
|
| 1006 | - echo $related_display; |
|
| 1007 | - } |
|
| 1008 | - $output = ob_get_contents(); |
|
| 999 | + // Validate character_count |
|
| 1000 | + $params['character_count'] = absint($params['character_count']); |
|
| 1001 | + if (20 > $params['character_count']) { |
|
| 1002 | + $params['character_count'] = 20; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + if ($related_display = geodir_related_posts_display($params)) { |
|
| 1006 | + echo $related_display; |
|
| 1007 | + } |
|
| 1008 | + $output = ob_get_contents(); |
|
| 1009 | 1009 | |
| 1010 | - ob_end_clean(); |
|
| 1010 | + ob_end_clean(); |
|
| 1011 | 1011 | |
| 1012 | - return $output; |
|
| 1012 | + return $output; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
@@ -1033,13 +1033,13 @@ discard block |
||
| 1033 | 1033 | * @return string Advanced search widget HTML. |
| 1034 | 1034 | */ |
| 1035 | 1035 | function geodir_sc_advanced_search($atts) { |
| 1036 | - $defaults = array( |
|
| 1036 | + $defaults = array( |
|
| 1037 | 1037 | 'title' => '', |
| 1038 | 1038 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
| 1039 | - 'after_widget' => '</section>', |
|
| 1040 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1041 | - 'after_title' => '</h3>', |
|
| 1042 | - 'show_adv_search' => 'default', |
|
| 1039 | + 'after_widget' => '</section>', |
|
| 1040 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1041 | + 'after_title' => '</h3>', |
|
| 1042 | + 'show_adv_search' => 'default', |
|
| 1043 | 1043 | 'post_type' => '' |
| 1044 | 1044 | ); |
| 1045 | 1045 | |
@@ -1063,9 +1063,9 @@ discard block |
||
| 1063 | 1063 | the_widget('geodir_advance_search_widget', $params, $params ); |
| 1064 | 1064 | |
| 1065 | 1065 | $output = ob_get_contents(); |
| 1066 | - ob_end_clean(); |
|
| 1066 | + ob_end_clean(); |
|
| 1067 | 1067 | |
| 1068 | - return $output; |
|
| 1068 | + return $output; |
|
| 1069 | 1069 | } |
| 1070 | 1070 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
| 1071 | 1071 | |
@@ -1111,48 +1111,48 @@ discard block |
||
| 1111 | 1111 | 'add_location_filter' => '1', |
| 1112 | 1112 | 'tab_layout' => 'bestof-tabs-on-top', |
| 1113 | 1113 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
| 1114 | - 'after_widget' => '</section>', |
|
| 1115 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1116 | - 'after_title' => '</h3>', |
|
| 1114 | + 'after_widget' => '</section>', |
|
| 1115 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1116 | + 'after_title' => '</h3>', |
|
| 1117 | 1117 | ); |
| 1118 | 1118 | $params = shortcode_atts($defaults, $atts); |
| 1119 | 1119 | |
| 1120 | - /** |
|
| 1121 | - * Validate our incoming params |
|
| 1122 | - */ |
|
| 1120 | + /** |
|
| 1121 | + * Validate our incoming params |
|
| 1122 | + */ |
|
| 1123 | 1123 | |
| 1124 | - // Validate the selected post type, default to gd_place on fail |
|
| 1125 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 1126 | - $params['post_type'] = 'gd_place'; |
|
| 1127 | - } |
|
| 1124 | + // Validate the selected post type, default to gd_place on fail |
|
| 1125 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
| 1126 | + $params['post_type'] = 'gd_place'; |
|
| 1127 | + } |
|
| 1128 | 1128 | |
| 1129 | 1129 | // Post limit needs to be a positive integer |
| 1130 | - $params['post_limit'] = absint($params['post_limit']); |
|
| 1131 | - if (0 == $params['post_limit']) { |
|
| 1132 | - $params['post_limit'] = 5; |
|
| 1133 | - } |
|
| 1130 | + $params['post_limit'] = absint($params['post_limit']); |
|
| 1131 | + if (0 == $params['post_limit']) { |
|
| 1132 | + $params['post_limit'] = 5; |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | 1135 | // Category limit needs to be a positive integer |
| 1136 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
| 1137 | - if (0 == $params['categ_limit']) { |
|
| 1138 | - $params['categ_limit'] = 3; |
|
| 1139 | - } |
|
| 1136 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
| 1137 | + if (0 == $params['categ_limit']) { |
|
| 1138 | + $params['categ_limit'] = 3; |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | 1141 | // Tab layout validation |
| 1142 | - $params['tab_layout'] = $params['tab_layout']; |
|
| 1143 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
| 1144 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
| 1145 | - } |
|
| 1142 | + $params['tab_layout'] = $params['tab_layout']; |
|
| 1143 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
| 1144 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
| 1145 | + } |
|
| 1146 | 1146 | |
| 1147 | 1147 | // Validate character_count |
| 1148 | - $params['character_count'] = $params['character_count']; |
|
| 1148 | + $params['character_count'] = $params['character_count']; |
|
| 1149 | 1149 | |
| 1150 | 1150 | ob_start(); |
| 1151 | 1151 | the_widget('geodir_bestof_widget', $params, $params); |
| 1152 | - $output = ob_get_contents(); |
|
| 1153 | - ob_end_clean(); |
|
| 1152 | + $output = ob_get_contents(); |
|
| 1153 | + ob_end_clean(); |
|
| 1154 | 1154 | |
| 1155 | - return $output; |
|
| 1155 | + return $output; |
|
| 1156 | 1156 | } |
| 1157 | 1157 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
| 1158 | 1158 | |
@@ -1205,143 +1205,143 @@ discard block |
||
| 1205 | 1205 | * @return string HTML content to display geodirectory listings. |
| 1206 | 1206 | */ |
| 1207 | 1207 | function geodir_sc_gd_listings($atts, $content = '') { |
| 1208 | - global $post; |
|
| 1209 | - $defaults = array( |
|
| 1210 | - 'title' => '', |
|
| 1211 | - 'post_type' => 'gd_place', |
|
| 1212 | - 'category' => 0, |
|
| 1213 | - 'list_sort' => 'latest', |
|
| 1214 | - 'event_type' => '', |
|
| 1215 | - 'post_number' => 10, |
|
| 1216 | - 'post_author' => '', |
|
| 1217 | - 'layout' => 'gridview_onehalf', |
|
| 1218 | - 'listing_width' => '', |
|
| 1219 | - 'character_count' => 20, |
|
| 1220 | - 'add_location_filter' => 1, |
|
| 1221 | - 'show_featured_only' => '', |
|
| 1222 | - 'show_special_only' => '', |
|
| 1223 | - 'with_pics_only' => '', |
|
| 1224 | - 'with_videos_only' => '', |
|
| 1225 | - 'with_pagination' => '1', |
|
| 1226 | - 'top_pagination' => '0', |
|
| 1227 | - 'bottom_pagination' => '1', |
|
| 1228 | - 'without_no_results' => 0, |
|
| 1229 | - 'tags' => '', |
|
| 1230 | - 'show_favorites_only' => '', |
|
| 1231 | - 'favorites_by_user' => '', |
|
| 1232 | - ); |
|
| 1233 | - $params = shortcode_atts($defaults, $atts); |
|
| 1234 | - |
|
| 1235 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
| 1236 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
| 1237 | - |
|
| 1238 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
| 1239 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 1240 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
| 1241 | - |
|
| 1242 | - // Make sure we have an array |
|
| 1243 | - if (!(is_array($params['category']))) { |
|
| 1244 | - $params['category'] = explode(',', $params['category']); |
|
| 1245 | - } |
|
| 1246 | - |
|
| 1247 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 1248 | - // Otherwise it becomes empty and later on that will mean "All" |
|
| 1249 | - $params['category'] = array_intersect($params['category'], $categories); |
|
| 1250 | - |
|
| 1251 | - // Post_number needs to be a positive integer |
|
| 1252 | - $params['post_number'] = absint($params['post_number']); |
|
| 1253 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
| 1208 | + global $post; |
|
| 1209 | + $defaults = array( |
|
| 1210 | + 'title' => '', |
|
| 1211 | + 'post_type' => 'gd_place', |
|
| 1212 | + 'category' => 0, |
|
| 1213 | + 'list_sort' => 'latest', |
|
| 1214 | + 'event_type' => '', |
|
| 1215 | + 'post_number' => 10, |
|
| 1216 | + 'post_author' => '', |
|
| 1217 | + 'layout' => 'gridview_onehalf', |
|
| 1218 | + 'listing_width' => '', |
|
| 1219 | + 'character_count' => 20, |
|
| 1220 | + 'add_location_filter' => 1, |
|
| 1221 | + 'show_featured_only' => '', |
|
| 1222 | + 'show_special_only' => '', |
|
| 1223 | + 'with_pics_only' => '', |
|
| 1224 | + 'with_videos_only' => '', |
|
| 1225 | + 'with_pagination' => '1', |
|
| 1226 | + 'top_pagination' => '0', |
|
| 1227 | + 'bottom_pagination' => '1', |
|
| 1228 | + 'without_no_results' => 0, |
|
| 1229 | + 'tags' => '', |
|
| 1230 | + 'show_favorites_only' => '', |
|
| 1231 | + 'favorites_by_user' => '', |
|
| 1232 | + ); |
|
| 1233 | + $params = shortcode_atts($defaults, $atts); |
|
| 1234 | + |
|
| 1235 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
| 1236 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
| 1237 | + |
|
| 1238 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
| 1239 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
| 1240 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
| 1241 | + |
|
| 1242 | + // Make sure we have an array |
|
| 1243 | + if (!(is_array($params['category']))) { |
|
| 1244 | + $params['category'] = explode(',', $params['category']); |
|
| 1245 | + } |
|
| 1246 | + |
|
| 1247 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
| 1248 | + // Otherwise it becomes empty and later on that will mean "All" |
|
| 1249 | + $params['category'] = array_intersect($params['category'], $categories); |
|
| 1250 | + |
|
| 1251 | + // Post_number needs to be a positive integer |
|
| 1252 | + $params['post_number'] = absint($params['post_number']); |
|
| 1253 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
| 1254 | 1254 | |
| 1255 | - // Post_number needs to be a positive integer |
|
| 1256 | - if (!empty($atts['post_author'])) { |
|
| 1257 | - if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1258 | - $params['post_author'] = $post->post_author; |
|
| 1259 | - } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
| 1260 | - $params['post_author'] = absint($atts['post_author']); |
|
| 1261 | - } else { |
|
| 1262 | - unset($params['post_author']); |
|
| 1263 | - } |
|
| 1264 | - } else { |
|
| 1265 | - unset($params['post_author']); |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - // Validate character_count |
|
| 1269 | - //todo: is this necessary? |
|
| 1270 | - $params['character_count'] = $params['character_count']; |
|
| 1271 | - |
|
| 1272 | - // Validate our layout choice |
|
| 1273 | - // Outside of the norm, I added some more simple terms to match the existing |
|
| 1274 | - // So now I just run the switch to set it properly. |
|
| 1275 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 1276 | - |
|
| 1277 | - // Validate our sorting choice |
|
| 1278 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 1279 | - |
|
| 1280 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
| 1281 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 1282 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1283 | - |
|
| 1284 | - // Validate the checkboxes used on the widget |
|
| 1285 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 1286 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 1287 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 1288 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 1289 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 1290 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
| 1291 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
| 1292 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
| 1255 | + // Post_number needs to be a positive integer |
|
| 1256 | + if (!empty($atts['post_author'])) { |
|
| 1257 | + if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1258 | + $params['post_author'] = $post->post_author; |
|
| 1259 | + } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
| 1260 | + $params['post_author'] = absint($atts['post_author']); |
|
| 1261 | + } else { |
|
| 1262 | + unset($params['post_author']); |
|
| 1263 | + } |
|
| 1264 | + } else { |
|
| 1265 | + unset($params['post_author']); |
|
| 1266 | + } |
|
| 1267 | + |
|
| 1268 | + // Validate character_count |
|
| 1269 | + //todo: is this necessary? |
|
| 1270 | + $params['character_count'] = $params['character_count']; |
|
| 1271 | + |
|
| 1272 | + // Validate our layout choice |
|
| 1273 | + // Outside of the norm, I added some more simple terms to match the existing |
|
| 1274 | + // So now I just run the switch to set it properly. |
|
| 1275 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
| 1276 | + |
|
| 1277 | + // Validate our sorting choice |
|
| 1278 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
| 1279 | + |
|
| 1280 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
| 1281 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
| 1282 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
| 1283 | + |
|
| 1284 | + // Validate the checkboxes used on the widget |
|
| 1285 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
| 1286 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
| 1287 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
| 1288 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
| 1289 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
| 1290 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
| 1291 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
| 1292 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
| 1293 | 1293 | |
| 1294 | - // User favorites |
|
| 1295 | - $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
| 1296 | - if (!empty($params['show_favorites_only'])) { |
|
| 1297 | - if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1298 | - $params['favorites_by_user'] = $post->post_author; |
|
| 1299 | - } else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) { |
|
| 1300 | - $params['favorites_by_user'] = absint($atts['favorites_by_user']); |
|
| 1301 | - } else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) { |
|
| 1302 | - $params['favorites_by_user'] = $current_user_id; |
|
| 1303 | - } else { |
|
| 1304 | - $params['favorites_by_user'] = 0; |
|
| 1305 | - } |
|
| 1306 | - } |
|
| 1307 | - |
|
| 1308 | - // Clean tags |
|
| 1309 | - if (!empty($params['tags'])) { |
|
| 1310 | - if (!is_array($params['tags'])) { |
|
| 1311 | - $comma = _x(',', 'tag delimiter'); |
|
| 1312 | - if ( ',' !== $comma ) { |
|
| 1313 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
| 1314 | - } |
|
| 1315 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
| 1316 | - $params['tags'] = array_map('trim', $params['tags']); |
|
| 1317 | - } |
|
| 1318 | - } else { |
|
| 1319 | - $params['tags'] = array(); |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - /** |
|
| 1323 | - * End of validation |
|
| 1324 | - */ |
|
| 1325 | - if (isset($atts['geodir_ajax'])) { |
|
| 1326 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
| 1327 | - unset($atts['geodir_ajax']); |
|
| 1328 | - } |
|
| 1329 | - if (isset($atts['pageno'])) { |
|
| 1330 | - $params['pageno'] = $atts['pageno']; |
|
| 1331 | - unset($atts['pageno']); |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - if ( !empty($atts['shortcode_content']) ) { |
|
| 1335 | - $content = $atts['shortcode_content']; |
|
| 1336 | - } |
|
| 1337 | - $params['shortcode_content'] = trim($content); |
|
| 1338 | - $atts['shortcode_content'] = trim($content); |
|
| 1294 | + // User favorites |
|
| 1295 | + $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
| 1296 | + if (!empty($params['show_favorites_only'])) { |
|
| 1297 | + if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
| 1298 | + $params['favorites_by_user'] = $post->post_author; |
|
| 1299 | + } else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) { |
|
| 1300 | + $params['favorites_by_user'] = absint($atts['favorites_by_user']); |
|
| 1301 | + } else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) { |
|
| 1302 | + $params['favorites_by_user'] = $current_user_id; |
|
| 1303 | + } else { |
|
| 1304 | + $params['favorites_by_user'] = 0; |
|
| 1305 | + } |
|
| 1306 | + } |
|
| 1307 | + |
|
| 1308 | + // Clean tags |
|
| 1309 | + if (!empty($params['tags'])) { |
|
| 1310 | + if (!is_array($params['tags'])) { |
|
| 1311 | + $comma = _x(',', 'tag delimiter'); |
|
| 1312 | + if ( ',' !== $comma ) { |
|
| 1313 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
| 1314 | + } |
|
| 1315 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
| 1316 | + $params['tags'] = array_map('trim', $params['tags']); |
|
| 1317 | + } |
|
| 1318 | + } else { |
|
| 1319 | + $params['tags'] = array(); |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + /** |
|
| 1323 | + * End of validation |
|
| 1324 | + */ |
|
| 1325 | + if (isset($atts['geodir_ajax'])) { |
|
| 1326 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
| 1327 | + unset($atts['geodir_ajax']); |
|
| 1328 | + } |
|
| 1329 | + if (isset($atts['pageno'])) { |
|
| 1330 | + $params['pageno'] = $atts['pageno']; |
|
| 1331 | + unset($atts['pageno']); |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + if ( !empty($atts['shortcode_content']) ) { |
|
| 1335 | + $content = $atts['shortcode_content']; |
|
| 1336 | + } |
|
| 1337 | + $params['shortcode_content'] = trim($content); |
|
| 1338 | + $atts['shortcode_content'] = trim($content); |
|
| 1339 | 1339 | |
| 1340 | - $params['shortcode_atts'] = $atts; |
|
| 1340 | + $params['shortcode_atts'] = $atts; |
|
| 1341 | 1341 | |
| 1342 | - $output = geodir_sc_gd_listings_output($params); |
|
| 1342 | + $output = geodir_sc_gd_listings_output($params); |
|
| 1343 | 1343 | |
| 1344 | - return $output; |
|
| 1344 | + return $output; |
|
| 1345 | 1345 | } |
| 1346 | 1346 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
| 1347 | 1347 | |
@@ -1381,56 +1381,56 @@ discard block |
||
| 1381 | 1381 | * @return string HTML content to display CPT categories. |
| 1382 | 1382 | */ |
| 1383 | 1383 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
| 1384 | - $defaults = array( |
|
| 1385 | - 'title' => '', |
|
| 1386 | - 'post_type' => '', // NULL for all |
|
| 1387 | - 'hide_empty' => '', |
|
| 1388 | - 'show_count' => '', |
|
| 1389 | - 'hide_icon' => '', |
|
| 1390 | - 'cpt_left' => '', |
|
| 1391 | - 'sort_by' => 'count', |
|
| 1392 | - 'max_count' => 'all', |
|
| 1393 | - 'max_level' => '1', |
|
| 1394 | - 'no_cpt_filter' => '', |
|
| 1395 | - 'no_cat_filter' => '', |
|
| 1396 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
| 1397 | - 'after_widget' => '</section>', |
|
| 1398 | - 'before_title' => '<h3 class="widget-title">', |
|
| 1399 | - 'after_title' => '</h3>', |
|
| 1400 | - ); |
|
| 1401 | - $params = shortcode_atts($defaults, $atts); |
|
| 1402 | - |
|
| 1403 | - /** |
|
| 1404 | - * Validate our incoming params |
|
| 1405 | - */ |
|
| 1406 | - // Make sure we have an array |
|
| 1407 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
| 1408 | - |
|
| 1409 | - // Validate the checkboxes used on the widget |
|
| 1410 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
| 1411 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
| 1412 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
| 1413 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
| 1384 | + $defaults = array( |
|
| 1385 | + 'title' => '', |
|
| 1386 | + 'post_type' => '', // NULL for all |
|
| 1387 | + 'hide_empty' => '', |
|
| 1388 | + 'show_count' => '', |
|
| 1389 | + 'hide_icon' => '', |
|
| 1390 | + 'cpt_left' => '', |
|
| 1391 | + 'sort_by' => 'count', |
|
| 1392 | + 'max_count' => 'all', |
|
| 1393 | + 'max_level' => '1', |
|
| 1394 | + 'no_cpt_filter' => '', |
|
| 1395 | + 'no_cat_filter' => '', |
|
| 1396 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
| 1397 | + 'after_widget' => '</section>', |
|
| 1398 | + 'before_title' => '<h3 class="widget-title">', |
|
| 1399 | + 'after_title' => '</h3>', |
|
| 1400 | + ); |
|
| 1401 | + $params = shortcode_atts($defaults, $atts); |
|
| 1414 | 1402 | |
| 1415 | - if ($params['max_count'] != 'all') { |
|
| 1416 | - $params['max_count'] = absint($params['max_count']); |
|
| 1417 | - } |
|
| 1403 | + /** |
|
| 1404 | + * Validate our incoming params |
|
| 1405 | + */ |
|
| 1406 | + // Make sure we have an array |
|
| 1407 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
| 1408 | + |
|
| 1409 | + // Validate the checkboxes used on the widget |
|
| 1410 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
| 1411 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
| 1412 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
| 1413 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
| 1414 | + |
|
| 1415 | + if ($params['max_count'] != 'all') { |
|
| 1416 | + $params['max_count'] = absint($params['max_count']); |
|
| 1417 | + } |
|
| 1418 | 1418 | |
| 1419 | - if ($params['max_level'] != 'all') { |
|
| 1420 | - $params['max_level'] = absint($params['max_level']); |
|
| 1421 | - } |
|
| 1419 | + if ($params['max_level'] != 'all') { |
|
| 1420 | + $params['max_level'] = absint($params['max_level']); |
|
| 1421 | + } |
|
| 1422 | 1422 | |
| 1423 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
| 1424 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
| 1423 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
| 1424 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
| 1425 | 1425 | |
| 1426 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
| 1426 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
| 1427 | 1427 | |
| 1428 | - ob_start(); |
|
| 1429 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
| 1430 | - $output = ob_get_contents(); |
|
| 1431 | - ob_end_clean(); |
|
| 1428 | + ob_start(); |
|
| 1429 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
| 1430 | + $output = ob_get_contents(); |
|
| 1431 | + ob_end_clean(); |
|
| 1432 | 1432 | |
| 1433 | - return $output; |
|
| 1433 | + return $output; |
|
| 1434 | 1434 | } |
| 1435 | 1435 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
| 1436 | 1436 | |
@@ -1445,6 +1445,6 @@ discard block |
||
| 1445 | 1445 | * @return string HTML code. |
| 1446 | 1446 | */ |
| 1447 | 1447 | function geodir_sc_responsive_videos($atts, $content) { |
| 1448 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
| 1448 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
| 1449 | 1449 | } |
| 1450 | 1450 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
| 1451 | 1451 | \ No newline at end of file |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function gd_compat_styles() |
| 19 | 19 | {
|
| 20 | - $tc = get_option('theme_compatibility_setting');
|
|
| 21 | - echo "<style id='gd-compat-styles' type='text/css'>"; |
|
| 22 | - echo $tc['geodir_theme_compat_css']; |
|
| 23 | - echo "</style>"; |
|
| 20 | + $tc = get_option('theme_compatibility_setting');
|
|
| 21 | + echo "<style id='gd-compat-styles' type='text/css'>"; |
|
| 22 | + echo $tc['geodir_theme_compat_css']; |
|
| 23 | + echo "</style>"; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function gd_compat_script() |
| 33 | 33 | {
|
| 34 | - $tc = get_option('theme_compatibility_setting');
|
|
| 35 | - echo "<script>"; |
|
| 36 | - echo $tc['geodir_theme_compat_js']; |
|
| 37 | - echo " </script>"; |
|
| 34 | + $tc = get_option('theme_compatibility_setting');
|
|
| 35 | + echo "<script>"; |
|
| 36 | + echo $tc['geodir_theme_compat_js']; |
|
| 37 | + echo " </script>"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function geodir_top_content_add_dynamic() |
| 49 | 49 | {
|
| 50 | - $tc = get_option('theme_compatibility_setting');
|
|
| 51 | - echo $tc['geodir_top_content_add']; |
|
| 50 | + $tc = get_option('theme_compatibility_setting');
|
|
| 51 | + echo $tc['geodir_top_content_add']; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function geodir_before_main_content_add_dynamic() |
| 63 | 63 | {
|
| 64 | - $tc = get_option('theme_compatibility_setting');
|
|
| 65 | - echo $tc['geodir_before_main_content_add']; |
|
| 64 | + $tc = get_option('theme_compatibility_setting');
|
|
| 65 | + echo $tc['geodir_before_main_content_add']; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function geodir_full_page_class_dynamic() |
| 77 | 77 | {
|
| 78 | - $tc = get_option('theme_compatibility_setting');
|
|
| 79 | - return $tc['geodir_full_page_class_filter']; |
|
| 78 | + $tc = get_option('theme_compatibility_setting');
|
|
| 79 | + return $tc['geodir_full_page_class_filter']; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function geodir_before_widget_dynamic() |
| 91 | 91 | {
|
| 92 | - $tc = get_option('theme_compatibility_setting');
|
|
| 93 | - return $tc['geodir_before_widget_filter']; |
|
| 92 | + $tc = get_option('theme_compatibility_setting');
|
|
| 93 | + return $tc['geodir_before_widget_filter']; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function geodir_after_widget_dynamic() |
| 105 | 105 | {
|
| 106 | - $tc = get_option('theme_compatibility_setting');
|
|
| 107 | - return $tc['geodir_after_widget_filter']; |
|
| 106 | + $tc = get_option('theme_compatibility_setting');
|
|
| 107 | + return $tc['geodir_after_widget_filter']; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function geodir_before_title_dynamic() |
| 119 | 119 | {
|
| 120 | - $tc = get_option('theme_compatibility_setting');
|
|
| 121 | - return $tc['geodir_before_title_filter']; |
|
| 120 | + $tc = get_option('theme_compatibility_setting');
|
|
| 121 | + return $tc['geodir_before_title_filter']; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function geodir_after_title_dynamic() |
| 133 | 133 | {
|
| 134 | - $tc = get_option('theme_compatibility_setting');
|
|
| 135 | - return $tc['geodir_after_title_filter']; |
|
| 134 | + $tc = get_option('theme_compatibility_setting');
|
|
| 135 | + return $tc['geodir_after_title_filter']; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | function geodir_menu_li_class_dynamic() |
| 147 | 147 | {
|
| 148 | - $tc = get_option('theme_compatibility_setting');
|
|
| 149 | - return $tc['geodir_menu_li_class_filter']; |
|
| 148 | + $tc = get_option('theme_compatibility_setting');
|
|
| 149 | + return $tc['geodir_menu_li_class_filter']; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function geodir_sub_menu_ul_class_dynamic() |
| 161 | 161 | {
|
| 162 | - $tc = get_option('theme_compatibility_setting');
|
|
| 163 | - return $tc['geodir_sub_menu_ul_class_filter']; |
|
| 162 | + $tc = get_option('theme_compatibility_setting');
|
|
| 163 | + return $tc['geodir_sub_menu_ul_class_filter']; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function geodir_sub_menu_li_class_dynamic() |
| 175 | 175 | {
|
| 176 | - $tc = get_option('theme_compatibility_setting');
|
|
| 177 | - return $tc['geodir_sub_menu_li_class_filter']; |
|
| 176 | + $tc = get_option('theme_compatibility_setting');
|
|
| 177 | + return $tc['geodir_sub_menu_li_class_filter']; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function geodir_menu_a_class_dynamic() |
| 189 | 189 | {
|
| 190 | - $tc = get_option('theme_compatibility_setting');
|
|
| 191 | - return $tc['geodir_menu_a_class_filter']; |
|
| 190 | + $tc = get_option('theme_compatibility_setting');
|
|
| 191 | + return $tc['geodir_menu_a_class_filter']; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | function geodir_sub_menu_a_class_dynamic() |
| 203 | 203 | {
|
| 204 | - $tc = get_option('theme_compatibility_setting');
|
|
| 205 | - return $tc['geodir_sub_menu_a_class_filter']; |
|
| 204 | + $tc = get_option('theme_compatibility_setting');
|
|
| 205 | + return $tc['geodir_sub_menu_a_class_filter']; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function geodir_location_switcher_menu_li_class_dynamic() |
| 217 | 217 | {
|
| 218 | - $tc = get_option('theme_compatibility_setting');
|
|
| 219 | - return $tc['geodir_location_switcher_menu_li_class_filter']; |
|
| 218 | + $tc = get_option('theme_compatibility_setting');
|
|
| 219 | + return $tc['geodir_location_switcher_menu_li_class_filter']; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function geodir_location_switcher_menu_a_class_dynamic() |
| 231 | 231 | {
|
| 232 | - $tc = get_option('theme_compatibility_setting');
|
|
| 233 | - return $tc['geodir_location_switcher_menu_a_class_filter']; |
|
| 232 | + $tc = get_option('theme_compatibility_setting');
|
|
| 233 | + return $tc['geodir_location_switcher_menu_a_class_filter']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function geodir_location_switcher_menu_sub_ul_class_dynamic() |
| 245 | 245 | {
|
| 246 | - $tc = get_option('theme_compatibility_setting');
|
|
| 247 | - return $tc['geodir_location_switcher_menu_sub_ul_class_filter']; |
|
| 246 | + $tc = get_option('theme_compatibility_setting');
|
|
| 247 | + return $tc['geodir_location_switcher_menu_sub_ul_class_filter']; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | function geodir_location_switcher_menu_sub_li_class_dynamic() |
| 259 | 259 | {
|
| 260 | - $tc = get_option('theme_compatibility_setting');
|
|
| 261 | - return $tc['geodir_location_switcher_menu_sub_li_class_filter']; |
|
| 260 | + $tc = get_option('theme_compatibility_setting');
|
|
| 261 | + return $tc['geodir_location_switcher_menu_sub_li_class_filter']; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
@@ -275,107 +275,107 @@ discard block |
||
| 275 | 275 | function geodir_content_actions_dynamic() |
| 276 | 276 | {
|
| 277 | 277 | |
| 278 | - $tc = get_option('theme_compatibility_setting');
|
|
| 278 | + $tc = get_option('theme_compatibility_setting');
|
|
| 279 | 279 | //print_r($tc); |
| 280 | - if (empty($tc)) {
|
|
| 281 | - return; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - //php |
|
| 285 | - if (!empty($tc['geodir_theme_compat_code'])) {
|
|
| 286 | - include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
|
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - //geodir_full_page_class |
|
| 290 | - if (!empty($tc['geodir_full_page_class_filter'])) {
|
|
| 291 | - add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
|
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - //widget before filter |
|
| 295 | - if (!empty($tc['geodir_before_widget_filter'])) {
|
|
| 296 | - add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
|
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - //widget after filter |
|
| 300 | - if (!empty($tc['geodir_after_widget_filter'])) {
|
|
| 301 | - add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
|
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - //widget before title filter |
|
| 305 | - if (!empty($tc['geodir_before_title_filter'])) {
|
|
| 306 | - add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
|
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - //widget before title filter |
|
| 310 | - if (!empty($tc['geodir_after_title_filter'])) {
|
|
| 311 | - add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
|
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - //menu li class |
|
| 315 | - if (!empty($tc['geodir_menu_li_class_filter'])) {
|
|
| 316 | - add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
|
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - //menu ul class |
|
| 320 | - if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
|
|
| 321 | - add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
|
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - //menu sub li class |
|
| 325 | - if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
|
|
| 326 | - add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
|
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - //menu a class |
|
| 330 | - if (!empty($tc['geodir_menu_a_class_filter'])) {
|
|
| 331 | - add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
|
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - //menu sub a class |
|
| 335 | - if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
|
|
| 336 | - add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
|
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - //location menu li class |
|
| 340 | - if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
|
|
| 341 | - add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
|
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - //location menu sub ul class |
|
| 345 | - if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
|
|
| 346 | - add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
|
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - //location menu sub li class |
|
| 350 | - if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
|
|
| 351 | - add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
|
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - //location menu a class |
|
| 355 | - if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
|
|
| 356 | - add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
|
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - // compat styles |
|
| 360 | - if (!empty($tc['geodir_theme_compat_css'])) {
|
|
| 361 | - add_action('wp_head', 'gd_compat_styles');
|
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // compat js |
|
| 365 | - if (!empty($tc['geodir_theme_compat_js'])) {
|
|
| 366 | - add_action('wp_footer', 'gd_compat_script');
|
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - |
|
| 370 | - // geodir_top_content_add |
|
| 371 | - if (!empty($tc['geodir_top_content_add'])) {
|
|
| 372 | - add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
|
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - // geodir_before_main_content_add |
|
| 376 | - if (!empty($tc['geodir_before_main_content_add'])) {
|
|
| 377 | - add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
|
|
| 378 | - } |
|
| 280 | + if (empty($tc)) {
|
|
| 281 | + return; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + //php |
|
| 285 | + if (!empty($tc['geodir_theme_compat_code'])) {
|
|
| 286 | + include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
|
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + //geodir_full_page_class |
|
| 290 | + if (!empty($tc['geodir_full_page_class_filter'])) {
|
|
| 291 | + add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
|
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + //widget before filter |
|
| 295 | + if (!empty($tc['geodir_before_widget_filter'])) {
|
|
| 296 | + add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
|
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + //widget after filter |
|
| 300 | + if (!empty($tc['geodir_after_widget_filter'])) {
|
|
| 301 | + add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
|
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + //widget before title filter |
|
| 305 | + if (!empty($tc['geodir_before_title_filter'])) {
|
|
| 306 | + add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
|
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + //widget before title filter |
|
| 310 | + if (!empty($tc['geodir_after_title_filter'])) {
|
|
| 311 | + add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
|
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + //menu li class |
|
| 315 | + if (!empty($tc['geodir_menu_li_class_filter'])) {
|
|
| 316 | + add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
|
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + //menu ul class |
|
| 320 | + if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
|
|
| 321 | + add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
|
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + //menu sub li class |
|
| 325 | + if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
|
|
| 326 | + add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
|
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + //menu a class |
|
| 330 | + if (!empty($tc['geodir_menu_a_class_filter'])) {
|
|
| 331 | + add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
|
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + //menu sub a class |
|
| 335 | + if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
|
|
| 336 | + add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
|
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + //location menu li class |
|
| 340 | + if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
|
|
| 341 | + add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
|
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + //location menu sub ul class |
|
| 345 | + if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
|
|
| 346 | + add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
|
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + //location menu sub li class |
|
| 350 | + if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
|
|
| 351 | + add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
|
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + //location menu a class |
|
| 355 | + if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
|
|
| 356 | + add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
|
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + // compat styles |
|
| 360 | + if (!empty($tc['geodir_theme_compat_css'])) {
|
|
| 361 | + add_action('wp_head', 'gd_compat_styles');
|
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // compat js |
|
| 365 | + if (!empty($tc['geodir_theme_compat_js'])) {
|
|
| 366 | + add_action('wp_footer', 'gd_compat_script');
|
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + |
|
| 370 | + // geodir_top_content_add |
|
| 371 | + if (!empty($tc['geodir_top_content_add'])) {
|
|
| 372 | + add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
|
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + // geodir_before_main_content_add |
|
| 376 | + if (!empty($tc['geodir_before_main_content_add'])) {
|
|
| 377 | + add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
|
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | 380 | |
| 381 | 381 | } |
@@ -398,23 +398,23 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function geodir_action_wrapper_open($type = '', $id = '', $class = '') |
| 400 | 400 | {
|
| 401 | - $tc = get_option('theme_compatibility_setting');
|
|
| 402 | - if (!empty($tc['geodir_wrapper_open_replace'])) {
|
|
| 403 | - $text = $tc['geodir_wrapper_open_replace']; |
|
| 404 | - } else {
|
|
| 405 | - $text = '<div id="[id]" class="[class]">'; |
|
| 406 | - } |
|
| 401 | + $tc = get_option('theme_compatibility_setting');
|
|
| 402 | + if (!empty($tc['geodir_wrapper_open_replace'])) {
|
|
| 403 | + $text = $tc['geodir_wrapper_open_replace']; |
|
| 404 | + } else {
|
|
| 405 | + $text = '<div id="[id]" class="[class]">'; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - if (!empty($tc['geodir_wrapper_open_id'])) {
|
|
| 409 | - $id = $tc['geodir_wrapper_open_id']; |
|
| 410 | - } |
|
| 411 | - if (!empty($tc['geodir_wrapper_open_class'])) {
|
|
| 412 | - $class = $tc['geodir_wrapper_open_class']; |
|
| 413 | - } |
|
| 408 | + if (!empty($tc['geodir_wrapper_open_id'])) {
|
|
| 409 | + $id = $tc['geodir_wrapper_open_id']; |
|
| 410 | + } |
|
| 411 | + if (!empty($tc['geodir_wrapper_open_class'])) {
|
|
| 412 | + $class = $tc['geodir_wrapper_open_class']; |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
|
|
| 415 | + $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
|
|
| 416 | 416 | |
| 417 | - echo $text; |
|
| 417 | + echo $text; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | // action for adding the wrapperdiv closing tag |
@@ -429,14 +429,14 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | function geodir_action_wrapper_close($type = '') |
| 431 | 431 | {
|
| 432 | - $tc = get_option('theme_compatibility_setting');
|
|
| 433 | - if (!empty($tc['geodir_wrapper_close_replace'])) {
|
|
| 434 | - $text = $tc['geodir_wrapper_close_replace']; |
|
| 435 | - } else {
|
|
| 436 | - $text = '</div><!-- wrapper ends here-->'; |
|
| 437 | - } |
|
| 432 | + $tc = get_option('theme_compatibility_setting');
|
|
| 433 | + if (!empty($tc['geodir_wrapper_close_replace'])) {
|
|
| 434 | + $text = $tc['geodir_wrapper_close_replace']; |
|
| 435 | + } else {
|
|
| 436 | + $text = '</div><!-- wrapper ends here-->'; |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | - echo $text; |
|
| 439 | + echo $text; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // action for adding the content div opening tag |
@@ -452,35 +452,35 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | function geodir_action_wrapper_content_open($type = '', $id = '', $class = '') |
| 454 | 454 | {
|
| 455 | - if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
|
|
| 456 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 457 | - } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
|
|
| 458 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 459 | - } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
|
|
| 460 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 461 | - } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
|
|
| 462 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 463 | - } else {
|
|
| 464 | - $width_css = ''; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - $tc = get_option('theme_compatibility_setting');
|
|
| 468 | - if (!empty($tc['geodir_wrapper_content_open_replace'])) {
|
|
| 469 | - $text = $tc['geodir_wrapper_content_open_replace']; |
|
| 470 | - } else {
|
|
| 471 | - $text = '<div id="[id]" class="[class]" role="main" [width_css]>'; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - if (!empty($tc['geodir_wrapper_content_open_id'])) {
|
|
| 475 | - $id = $tc['geodir_wrapper_content_open_id']; |
|
| 476 | - } |
|
| 477 | - if (!empty($tc['geodir_wrapper_content_open_class'])) {
|
|
| 478 | - $class = $tc['geodir_wrapper_content_open_class']; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - $text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
|
|
| 482 | - |
|
| 483 | - echo $text; |
|
| 455 | + if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
|
|
| 456 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 457 | + } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
|
|
| 458 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 459 | + } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
|
|
| 460 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 461 | + } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
|
|
| 462 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 463 | + } else {
|
|
| 464 | + $width_css = ''; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + $tc = get_option('theme_compatibility_setting');
|
|
| 468 | + if (!empty($tc['geodir_wrapper_content_open_replace'])) {
|
|
| 469 | + $text = $tc['geodir_wrapper_content_open_replace']; |
|
| 470 | + } else {
|
|
| 471 | + $text = '<div id="[id]" class="[class]" role="main" [width_css]>'; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + if (!empty($tc['geodir_wrapper_content_open_id'])) {
|
|
| 475 | + $id = $tc['geodir_wrapper_content_open_id']; |
|
| 476 | + } |
|
| 477 | + if (!empty($tc['geodir_wrapper_content_open_class'])) {
|
|
| 478 | + $class = $tc['geodir_wrapper_content_open_class']; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + $text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
|
|
| 482 | + |
|
| 483 | + echo $text; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // action for adding the primary div closing tag |
@@ -494,13 +494,13 @@ discard block |
||
| 494 | 494 | */ |
| 495 | 495 | function geodir_action_wrapper_content_close($type = '') |
| 496 | 496 | {
|
| 497 | - $tc = get_option('theme_compatibility_setting');
|
|
| 498 | - if (!empty($tc['geodir_wrapper_content_close_replace'])) {
|
|
| 499 | - $text = $tc['geodir_wrapper_content_close_replace']; |
|
| 500 | - } else {
|
|
| 501 | - $text = '</div><!-- content ends here-->'; |
|
| 502 | - } |
|
| 503 | - echo $text; |
|
| 497 | + $tc = get_option('theme_compatibility_setting');
|
|
| 498 | + if (!empty($tc['geodir_wrapper_content_close_replace'])) {
|
|
| 499 | + $text = $tc['geodir_wrapper_content_close_replace']; |
|
| 500 | + } else {
|
|
| 501 | + $text = '</div><!-- content ends here-->'; |
|
| 502 | + } |
|
| 503 | + echo $text; |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // action for adding the <article> opening tag |
@@ -518,24 +518,24 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | function geodir_action_article_open($type = '', $id = '', $class = '', $itemtype = '') |
| 520 | 520 | {
|
| 521 | - $class = implode(" ", $class);
|
|
| 522 | - $tc = get_option('theme_compatibility_setting');
|
|
| 523 | - if (!empty($tc['geodir_article_open_replace'])) {
|
|
| 524 | - $text = $tc['geodir_article_open_replace']; |
|
| 525 | - } else {
|
|
| 526 | - $text = '<article id="[id]" class="[class]" >'; |
|
| 527 | - } |
|
| 521 | + $class = implode(" ", $class);
|
|
| 522 | + $tc = get_option('theme_compatibility_setting');
|
|
| 523 | + if (!empty($tc['geodir_article_open_replace'])) {
|
|
| 524 | + $text = $tc['geodir_article_open_replace']; |
|
| 525 | + } else {
|
|
| 526 | + $text = '<article id="[id]" class="[class]" >'; |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - if (!empty($tc['geodir_article_open_id'])) {
|
|
| 530 | - $id = $tc['geodir_article_open_id']; |
|
| 531 | - } |
|
| 532 | - if (!empty($tc['geodir_article_open_class'])) {
|
|
| 533 | - $class = $tc['geodir_article_open_class']; |
|
| 534 | - } |
|
| 529 | + if (!empty($tc['geodir_article_open_id'])) {
|
|
| 530 | + $id = $tc['geodir_article_open_id']; |
|
| 531 | + } |
|
| 532 | + if (!empty($tc['geodir_article_open_class'])) {
|
|
| 533 | + $class = $tc['geodir_article_open_class']; |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | - $text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
|
|
| 536 | + $text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
|
|
| 537 | 537 | |
| 538 | - echo $text; |
|
| 538 | + echo $text; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // action for adding the primary div closing tag |
@@ -549,13 +549,13 @@ discard block |
||
| 549 | 549 | */ |
| 550 | 550 | function geodir_action_article_close($type = '') |
| 551 | 551 | {
|
| 552 | - $tc = get_option('theme_compatibility_setting');
|
|
| 553 | - if (!empty($tc['geodir_article_close_replace'])) {
|
|
| 554 | - $text = $tc['geodir_article_close_replace']; |
|
| 555 | - } else {
|
|
| 556 | - $text = '</article><!-- article ends here-->'; |
|
| 557 | - } |
|
| 558 | - echo $text; |
|
| 552 | + $tc = get_option('theme_compatibility_setting');
|
|
| 553 | + if (!empty($tc['geodir_article_close_replace'])) {
|
|
| 554 | + $text = $tc['geodir_article_close_replace']; |
|
| 555 | + } else {
|
|
| 556 | + $text = '</article><!-- article ends here-->'; |
|
| 557 | + } |
|
| 558 | + echo $text; |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | // action for adding the sidebar opening tag |
@@ -572,35 +572,35 @@ discard block |
||
| 572 | 572 | */ |
| 573 | 573 | function geodir_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') |
| 574 | 574 | {
|
| 575 | - if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
|
|
| 576 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 577 | - } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
|
|
| 578 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 579 | - } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
|
|
| 580 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 581 | - } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
|
|
| 582 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 583 | - } else {
|
|
| 584 | - $width_css = ''; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - $tc = get_option('theme_compatibility_setting');
|
|
| 588 | - if (!empty($tc['geodir_sidebar_right_open_replace'])) {
|
|
| 589 | - $text = $tc['geodir_sidebar_right_open_replace']; |
|
| 590 | - } else {
|
|
| 591 | - $text = '<aside id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>'; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - if (!empty($tc['geodir_sidebar_right_open_id'])) {
|
|
| 595 | - $id = $tc['geodir_sidebar_right_open_id']; |
|
| 596 | - } |
|
| 597 | - if (!empty($tc['geodir_sidebar_right_open_class'])) {
|
|
| 598 | - $class = $tc['geodir_sidebar_right_open_class']; |
|
| 599 | - } |
|
| 600 | - |
|
| 601 | - $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
|
|
| 602 | - |
|
| 603 | - echo $text; |
|
| 575 | + if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
|
|
| 576 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 577 | + } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
|
|
| 578 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 579 | + } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
|
|
| 580 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 581 | + } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
|
|
| 582 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 583 | + } else {
|
|
| 584 | + $width_css = ''; |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + $tc = get_option('theme_compatibility_setting');
|
|
| 588 | + if (!empty($tc['geodir_sidebar_right_open_replace'])) {
|
|
| 589 | + $text = $tc['geodir_sidebar_right_open_replace']; |
|
| 590 | + } else {
|
|
| 591 | + $text = '<aside id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>'; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + if (!empty($tc['geodir_sidebar_right_open_id'])) {
|
|
| 595 | + $id = $tc['geodir_sidebar_right_open_id']; |
|
| 596 | + } |
|
| 597 | + if (!empty($tc['geodir_sidebar_right_open_class'])) {
|
|
| 598 | + $class = $tc['geodir_sidebar_right_open_class']; |
|
| 599 | + } |
|
| 600 | + |
|
| 601 | + $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
|
|
| 602 | + |
|
| 603 | + echo $text; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // action for adding the primary div closing tag |
@@ -614,13 +614,13 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | function geodir_action_sidebar_right_close($type = '') |
| 616 | 616 | {
|
| 617 | - $tc = get_option('theme_compatibility_setting');
|
|
| 618 | - if (!empty($tc['geodir_sidebar_right_close_replace'])) {
|
|
| 619 | - $text = $tc['geodir_sidebar_right_close_replace']; |
|
| 620 | - } else {
|
|
| 621 | - $text = '</aside><!-- sidebar ends here-->'; |
|
| 622 | - } |
|
| 623 | - echo $text; |
|
| 617 | + $tc = get_option('theme_compatibility_setting');
|
|
| 618 | + if (!empty($tc['geodir_sidebar_right_close_replace'])) {
|
|
| 619 | + $text = $tc['geodir_sidebar_right_close_replace']; |
|
| 620 | + } else {
|
|
| 621 | + $text = '</aside><!-- sidebar ends here-->'; |
|
| 622 | + } |
|
| 623 | + echo $text; |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | |
@@ -641,121 +641,121 @@ discard block |
||
| 641 | 641 | */ |
| 642 | 642 | function geodir_action_geodir_set_preview_post() |
| 643 | 643 | {
|
| 644 | - global $post, $preview, $gd_session; |
|
| 645 | - $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 646 | - if (!$preview || $is_backend_preview) {
|
|
| 647 | - return; |
|
| 648 | - }// bail if not previewing |
|
| 649 | - |
|
| 650 | - $listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : ''; |
|
| 651 | - |
|
| 652 | - $fields_info = geodir_get_custom_fields_type($listing_type); |
|
| 653 | - |
|
| 654 | - foreach ($_REQUEST as $pkey => $pval) {
|
|
| 655 | - if ($pkey == 'geodir_video') {
|
|
| 656 | - $tags = '<iframe>'; |
|
| 657 | - } else if ($pkey == 'post_desc') {
|
|
| 658 | - $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'; |
|
| 659 | - } else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
|
|
| 660 | - $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'; |
|
| 661 | - } else if (is_array($_REQUEST[$pkey])) {
|
|
| 662 | - $tags = 'skip_field'; |
|
| 663 | - } else {
|
|
| 664 | - $tags = ''; |
|
| 665 | - } |
|
| 666 | - /** |
|
| 667 | - * Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page. |
|
| 668 | - * |
|
| 669 | - * @since 1.0.0 |
|
| 670 | - * @param string $tags The allowed HTML tags for the field. Can be many things, for example the description allows these tags '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'. |
|
| 671 | - * @param string|array $pkey The field id/name. If array then value is set as "skip_field". |
|
| 672 | - */ |
|
| 673 | - $tags = apply_filters('geodir_save_post_key', $tags, $pkey);
|
|
| 674 | - |
|
| 675 | - if ($tags != 'skip_field') {
|
|
| 676 | - $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - $post = (object)$_REQUEST; |
|
| 681 | - |
|
| 682 | - |
|
| 683 | - if (isset($post->video)) {
|
|
| 684 | - $post->video = stripslashes($post->video); |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - if (isset($post->Video2)) {
|
|
| 688 | - $post->Video2 = stripslashes($post->Video2); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - $post_type = $post->listing_type; |
|
| 692 | - $post_type_info = get_post_type_object($post_type); |
|
| 693 | - |
|
| 694 | - $listing_label = $post_type_info->labels->singular_name; |
|
| 695 | - |
|
| 696 | - $term_icon = ''; |
|
| 697 | - |
|
| 698 | - if (!empty($post->post_category)) {
|
|
| 699 | - foreach ($post->post_category as $post_taxonomy => $post_term) {
|
|
| 700 | - |
|
| 701 | - if ($post_term != '' && !is_array($post_term)) {
|
|
| 702 | - $post_term = explode(',', trim($post_term, ','));
|
|
| 703 | - } |
|
| 644 | + global $post, $preview, $gd_session; |
|
| 645 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 646 | + if (!$preview || $is_backend_preview) {
|
|
| 647 | + return; |
|
| 648 | + }// bail if not previewing |
|
| 649 | + |
|
| 650 | + $listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : ''; |
|
| 651 | + |
|
| 652 | + $fields_info = geodir_get_custom_fields_type($listing_type); |
|
| 653 | + |
|
| 654 | + foreach ($_REQUEST as $pkey => $pval) {
|
|
| 655 | + if ($pkey == 'geodir_video') {
|
|
| 656 | + $tags = '<iframe>'; |
|
| 657 | + } else if ($pkey == 'post_desc') {
|
|
| 658 | + $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'; |
|
| 659 | + } else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
|
|
| 660 | + $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'; |
|
| 661 | + } else if (is_array($_REQUEST[$pkey])) {
|
|
| 662 | + $tags = 'skip_field'; |
|
| 663 | + } else {
|
|
| 664 | + $tags = ''; |
|
| 665 | + } |
|
| 666 | + /** |
|
| 667 | + * Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page. |
|
| 668 | + * |
|
| 669 | + * @since 1.0.0 |
|
| 670 | + * @param string $tags The allowed HTML tags for the field. Can be many things, for example the description allows these tags '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'. |
|
| 671 | + * @param string|array $pkey The field id/name. If array then value is set as "skip_field". |
|
| 672 | + */ |
|
| 673 | + $tags = apply_filters('geodir_save_post_key', $tags, $pkey);
|
|
| 674 | + |
|
| 675 | + if ($tags != 'skip_field') {
|
|
| 676 | + $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags); |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + $post = (object)$_REQUEST; |
|
| 681 | + |
|
| 682 | + |
|
| 683 | + if (isset($post->video)) {
|
|
| 684 | + $post->video = stripslashes($post->video); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + if (isset($post->Video2)) {
|
|
| 688 | + $post->Video2 = stripslashes($post->Video2); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + $post_type = $post->listing_type; |
|
| 692 | + $post_type_info = get_post_type_object($post_type); |
|
| 693 | + |
|
| 694 | + $listing_label = $post_type_info->labels->singular_name; |
|
| 695 | + |
|
| 696 | + $term_icon = ''; |
|
| 697 | + |
|
| 698 | + if (!empty($post->post_category)) {
|
|
| 699 | + foreach ($post->post_category as $post_taxonomy => $post_term) {
|
|
| 700 | + |
|
| 701 | + if ($post_term != '' && !is_array($post_term)) {
|
|
| 702 | + $post_term = explode(',', trim($post_term, ','));
|
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | - if (is_array($post_term)) {
|
|
| 706 | - $post_term = array_unique($post_term); |
|
| 707 | - } |
|
| 705 | + if (is_array($post_term)) {
|
|
| 706 | + $post_term = array_unique($post_term); |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - if (!empty($post_term)) {
|
|
| 710 | - foreach ($post_term as $cat_id) {
|
|
| 711 | - $cat_id = trim($cat_id); |
|
| 712 | - |
|
| 713 | - if ($cat_id != '') {
|
|
| 714 | - $term_icon = get_option('geodir_default_marker_icon');
|
|
| 715 | - |
|
| 716 | - if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
|
|
| 717 | - if ($term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
|
|
| 718 | - if (isset($term_icon_url['src']) && $term_icon_url['src'] != '') |
|
| 719 | - $term_icon = $term_icon_url['src']; |
|
| 720 | - break; |
|
| 721 | - } |
|
| 722 | - } |
|
| 723 | - } |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - } |
|
| 727 | - } |
|
| 709 | + if (!empty($post_term)) {
|
|
| 710 | + foreach ($post_term as $cat_id) {
|
|
| 711 | + $cat_id = trim($cat_id); |
|
| 712 | + |
|
| 713 | + if ($cat_id != '') {
|
|
| 714 | + $term_icon = get_option('geodir_default_marker_icon');
|
|
| 715 | + |
|
| 716 | + if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
|
|
| 717 | + if ($term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
|
|
| 718 | + if (isset($term_icon_url['src']) && $term_icon_url['src'] != '') |
|
| 719 | + $term_icon = $term_icon_url['src']; |
|
| 720 | + break; |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | - $post_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 730 | - $post_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 729 | + $post_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 730 | + $post_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 731 | 731 | |
| 732 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 733 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 732 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 733 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 734 | 734 | |
| 735 | - $json_title = str_replace($srcharr, $replarr, $post->post_title); |
|
| 735 | + $json_title = str_replace($srcharr, $replarr, $post->post_title); |
|
| 736 | 736 | |
| 737 | - $json = '{';
|
|
| 738 | - $json .= '"post_preview": "1",'; |
|
| 739 | - $json .= '"t": "' . $json_title . '",'; |
|
| 740 | - $json .= '"lt": "' . $post_latitude . '",'; |
|
| 741 | - $json .= '"ln": "' . $post_longitude . '",'; |
|
| 742 | - $json .= '"i":"' . $term_icon . '"'; |
|
| 743 | - $json .= '}'; |
|
| 737 | + $json = '{';
|
|
| 738 | + $json .= '"post_preview": "1",'; |
|
| 739 | + $json .= '"t": "' . $json_title . '",'; |
|
| 740 | + $json .= '"lt": "' . $post_latitude . '",'; |
|
| 741 | + $json .= '"ln": "' . $post_longitude . '",'; |
|
| 742 | + $json .= '"i":"' . $term_icon . '"'; |
|
| 743 | + $json .= '}'; |
|
| 744 | 744 | |
| 745 | - $post->marker_json = $json; |
|
| 745 | + $post->marker_json = $json; |
|
| 746 | 746 | |
| 747 | - $gd_session->set('listing', $_REQUEST);
|
|
| 747 | + $gd_session->set('listing', $_REQUEST);
|
|
| 748 | 748 | |
| 749 | - // we need to define a few things to trick the setup_postdata |
|
| 750 | - if (!isset($post->ID)) {
|
|
| 751 | - $post->ID = ''; |
|
| 752 | - $post->post_author = ''; |
|
| 753 | - $post->post_date = ''; |
|
| 754 | - $post->post_content = ''; |
|
| 755 | - $post->default_category = ''; |
|
| 756 | - $post->post_type = ''; |
|
| 757 | - } |
|
| 758 | - setup_postdata($post); |
|
| 749 | + // we need to define a few things to trick the setup_postdata |
|
| 750 | + if (!isset($post->ID)) {
|
|
| 751 | + $post->ID = ''; |
|
| 752 | + $post->post_author = ''; |
|
| 753 | + $post->post_date = ''; |
|
| 754 | + $post->post_content = ''; |
|
| 755 | + $post->default_category = ''; |
|
| 756 | + $post->post_type = ''; |
|
| 757 | + } |
|
| 758 | + setup_postdata($post); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /** |
@@ -767,15 +767,15 @@ discard block |
||
| 767 | 767 | */ |
| 768 | 768 | function geodir_action_geodir_preview_code() |
| 769 | 769 | {
|
| 770 | - global $preview; |
|
| 770 | + global $preview; |
|
| 771 | 771 | |
| 772 | - $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 772 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 773 | 773 | |
| 774 | - if (!$preview || $is_backend_preview) {
|
|
| 775 | - return; |
|
| 776 | - }// bail if not previewing |
|
| 774 | + if (!$preview || $is_backend_preview) {
|
|
| 775 | + return; |
|
| 776 | + }// bail if not previewing |
|
| 777 | 777 | |
| 778 | - geodir_get_template_part('preview', 'buttons');
|
|
| 778 | + geodir_get_template_part('preview', 'buttons');
|
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | // action for adding the details page top widget area |
@@ -791,20 +791,20 @@ discard block |
||
| 791 | 791 | */ |
| 792 | 792 | function geodir_action_geodir_sidebar_detail_top($class = '') |
| 793 | 793 | {
|
| 794 | - if (get_option('geodir_show_detail_top_section')) { ?>
|
|
| 794 | + if (get_option('geodir_show_detail_top_section')) { ?>
|
|
| 795 | 795 | <div |
| 796 | 796 | class="<?php |
| 797 | - /** |
|
| 798 | - * Filter the div class for the wrapper of the full width widget areas. |
|
| 799 | - * |
|
| 800 | - * Allows you to filter the class of the div for the HTML Container wrapper for the full width widget areas referred to as "Top Section" or "Bottom Section" in the widget areas. |
|
| 801 | - * |
|
| 802 | - * @since 1.0.0 |
|
| 803 | - * @param string $class The class of the div. |
|
| 804 | - * @param string $type The page type the widget area is being used on. Values can be 'geodir_detail_top', 'geodir_detail_bottom', 'geodir_listing_top', 'geodir_listing_bottom', 'Reg/Login Top Section', |
|
| 805 | - * 'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'. |
|
| 806 | - */ |
|
| 807 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
|
|
| 797 | + /** |
|
| 798 | + * Filter the div class for the wrapper of the full width widget areas. |
|
| 799 | + * |
|
| 800 | + * Allows you to filter the class of the div for the HTML Container wrapper for the full width widget areas referred to as "Top Section" or "Bottom Section" in the widget areas. |
|
| 801 | + * |
|
| 802 | + * @since 1.0.0 |
|
| 803 | + * @param string $class The class of the div. |
|
| 804 | + * @param string $type The page type the widget area is being used on. Values can be 'geodir_detail_top', 'geodir_detail_bottom', 'geodir_listing_top', 'geodir_listing_bottom', 'Reg/Login Top Section', |
|
| 805 | + * 'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'. |
|
| 806 | + */ |
|
| 807 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
|
|
| 808 | 808 | <?php dynamic_sidebar('geodir_detail_top'); ?>
|
| 809 | 809 | </div> |
| 810 | 810 | <?php } |
@@ -828,11 +828,11 @@ discard block |
||
| 828 | 828 | */ |
| 829 | 829 | function geodir_action_geodir_sidebar_detail_bottom_section($class = '') |
| 830 | 830 | {
|
| 831 | - if (get_option('geodir_show_detail_bottom_section')) { ?>
|
|
| 831 | + if (get_option('geodir_show_detail_bottom_section')) { ?>
|
|
| 832 | 832 | <div |
| 833 | 833 | class="<?php |
| 834 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 835 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
|
|
| 834 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 835 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
|
|
| 836 | 836 | <?php dynamic_sidebar('geodir_detail_bottom'); ?>
|
| 837 | 837 | </div><!-- clearfix ends here--> |
| 838 | 838 | <?php } |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | function geodir_details_sidebar_widget_area() |
| 848 | 848 | {
|
| 849 | - dynamic_sidebar('geodir_detail_sidebar');
|
|
| 849 | + dynamic_sidebar('geodir_detail_sidebar');
|
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -857,12 +857,12 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | function geodir_details_sidebar_place_details() |
| 859 | 859 | {
|
| 860 | - /** |
|
| 861 | - * Used to add items to the details page sidebar. |
|
| 862 | - * |
|
| 863 | - * @since 1.0.0 |
|
| 864 | - */ |
|
| 865 | - do_action('geodir_detail_page_sidebar');
|
|
| 860 | + /** |
|
| 861 | + * Used to add items to the details page sidebar. |
|
| 862 | + * |
|
| 863 | + * @since 1.0.0 |
|
| 864 | + */ |
|
| 865 | + do_action('geodir_detail_page_sidebar');
|
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_place_details', 10);
|
@@ -877,68 +877,68 @@ discard block |
||
| 877 | 877 | */ |
| 878 | 878 | function geodir_action_details_sidebar() |
| 879 | 879 | {
|
| 880 | - // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='') |
|
| 881 | - if (get_option('geodir_detail_sidebar_left_section')) {
|
|
| 882 | - /** |
|
| 883 | - * Called before the details page left sidebar is opened. |
|
| 884 | - * |
|
| 885 | - * This is used to add opening wrapper HTML to the details page left sidebar. |
|
| 886 | - * |
|
| 887 | - * @since 1.0.0 |
|
| 888 | - * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 889 | - * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'. |
|
| 890 | - * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'. |
|
| 891 | - * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'. |
|
| 892 | - */ |
|
| 893 | - do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
|
|
| 894 | - ?> |
|
| 880 | + // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='') |
|
| 881 | + if (get_option('geodir_detail_sidebar_left_section')) {
|
|
| 882 | + /** |
|
| 883 | + * Called before the details page left sidebar is opened. |
|
| 884 | + * |
|
| 885 | + * This is used to add opening wrapper HTML to the details page left sidebar. |
|
| 886 | + * |
|
| 887 | + * @since 1.0.0 |
|
| 888 | + * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 889 | + * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'. |
|
| 890 | + * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'. |
|
| 891 | + * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'. |
|
| 892 | + */ |
|
| 893 | + do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
|
|
| 894 | + ?> |
|
| 895 | 895 | <div class="geodir-content-left geodir-sidebar-wrap"><?php |
| 896 | - /** |
|
| 897 | - * Called inside the HTML wrapper of the details sidebar for either the left and right sidebar. |
|
| 898 | - * |
|
| 899 | - * This is used to add all info to the details page sidebars. |
|
| 900 | - * |
|
| 901 | - * @since 1.0.0 |
|
| 902 | - */ |
|
| 903 | - do_action('geodir_detail_sidebar_inside');
|
|
| 904 | - ?></div><!-- end geodir-content-left --><?php |
|
| 905 | - /** |
|
| 906 | - * Called after the details page left sidebar. |
|
| 907 | - * |
|
| 908 | - * This is used to add closing wrapper HTML to the details page left sidebar. |
|
| 909 | - * |
|
| 910 | - * @since 1.0.0 |
|
| 911 | - * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 912 | - */ |
|
| 913 | - do_action('geodir_sidebar_left_close', 'details-page');
|
|
| 914 | - } else {
|
|
| 915 | - /** |
|
| 916 | - * Called before the details page right sidebar is opened. |
|
| 917 | - * |
|
| 918 | - * This is used to add opening wrapper HTML to the details page right sidebar. |
|
| 919 | - * |
|
| 920 | - * @since 1.0.0 |
|
| 921 | - * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'. |
|
| 922 | - * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'. |
|
| 923 | - * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'. |
|
| 924 | - * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'. |
|
| 925 | - */ |
|
| 926 | - do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 927 | - ?> |
|
| 896 | + /** |
|
| 897 | + * Called inside the HTML wrapper of the details sidebar for either the left and right sidebar. |
|
| 898 | + * |
|
| 899 | + * This is used to add all info to the details page sidebars. |
|
| 900 | + * |
|
| 901 | + * @since 1.0.0 |
|
| 902 | + */ |
|
| 903 | + do_action('geodir_detail_sidebar_inside');
|
|
| 904 | + ?></div><!-- end geodir-content-left --><?php |
|
| 905 | + /** |
|
| 906 | + * Called after the details page left sidebar. |
|
| 907 | + * |
|
| 908 | + * This is used to add closing wrapper HTML to the details page left sidebar. |
|
| 909 | + * |
|
| 910 | + * @since 1.0.0 |
|
| 911 | + * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 912 | + */ |
|
| 913 | + do_action('geodir_sidebar_left_close', 'details-page');
|
|
| 914 | + } else {
|
|
| 915 | + /** |
|
| 916 | + * Called before the details page right sidebar is opened. |
|
| 917 | + * |
|
| 918 | + * This is used to add opening wrapper HTML to the details page right sidebar. |
|
| 919 | + * |
|
| 920 | + * @since 1.0.0 |
|
| 921 | + * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'. |
|
| 922 | + * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'. |
|
| 923 | + * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'. |
|
| 924 | + * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'. |
|
| 925 | + */ |
|
| 926 | + do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 927 | + ?> |
|
| 928 | 928 | <div class="geodir-content-right geodir-sidebar-wrap"><?php |
| 929 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 930 | - do_action('geodir_detail_sidebar_inside');
|
|
| 931 | - ?></div><!-- end geodir-content-right --><?php |
|
| 932 | - /** |
|
| 933 | - * Called after the details page right sidebar. |
|
| 934 | - * |
|
| 935 | - * This is used to add closing wrapper HTML to the details page right sidebar. |
|
| 936 | - * |
|
| 937 | - * @since 1.0.0 |
|
| 938 | - * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 939 | - */ |
|
| 940 | - do_action('geodir_sidebar_right_close', 'details-page');
|
|
| 941 | - } |
|
| 929 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 930 | + do_action('geodir_detail_sidebar_inside');
|
|
| 931 | + ?></div><!-- end geodir-content-right --><?php |
|
| 932 | + /** |
|
| 933 | + * Called after the details page right sidebar. |
|
| 934 | + * |
|
| 935 | + * This is used to add closing wrapper HTML to the details page right sidebar. |
|
| 936 | + * |
|
| 937 | + * @since 1.0.0 |
|
| 938 | + * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 939 | + */ |
|
| 940 | + do_action('geodir_sidebar_right_close', 'details-page');
|
|
| 941 | + } |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | add_action('geodir_page_title', 'geodir_action_page_title', 10);
|
@@ -952,21 +952,21 @@ discard block |
||
| 952 | 952 | */ |
| 953 | 953 | function geodir_action_page_title() |
| 954 | 954 | {
|
| 955 | - /** |
|
| 956 | - * Filter the page title HTML h1 class. |
|
| 957 | - * |
|
| 958 | - * @since 1.0.0 |
|
| 959 | - * @param string $class The class to use. Default is 'entry-title fn'. |
|
| 960 | - */ |
|
| 961 | - $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 962 | - /** |
|
| 963 | - * Filter the page title HTML header wrapper class. |
|
| 964 | - * |
|
| 965 | - * @since 1.0.0 |
|
| 966 | - * @param string $class The class to use. Default is 'entry-header'. |
|
| 967 | - */ |
|
| 968 | - $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 969 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>'; |
|
| 955 | + /** |
|
| 956 | + * Filter the page title HTML h1 class. |
|
| 957 | + * |
|
| 958 | + * @since 1.0.0 |
|
| 959 | + * @param string $class The class to use. Default is 'entry-title fn'. |
|
| 960 | + */ |
|
| 961 | + $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 962 | + /** |
|
| 963 | + * Filter the page title HTML header wrapper class. |
|
| 964 | + * |
|
| 965 | + * @since 1.0.0 |
|
| 966 | + * @param string $class The class to use. Default is 'entry-header'. |
|
| 967 | + */ |
|
| 968 | + $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 969 | + echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>'; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | |
@@ -983,94 +983,94 @@ discard block |
||
| 983 | 983 | */ |
| 984 | 984 | function geodir_action_details_slider() |
| 985 | 985 | {
|
| 986 | - global $preview, $post; |
|
| 986 | + global $preview, $post; |
|
| 987 | 987 | |
| 988 | - $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend |
|
| 988 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend |
|
| 989 | 989 | |
| 990 | - if ($is_backend_preview && !empty($post) && !empty($post->ID) && !isset($post->post_images)) {
|
|
| 991 | - $preview_get_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 990 | + if ($is_backend_preview && !empty($post) && !empty($post->ID) && !isset($post->post_images)) {
|
|
| 991 | + $preview_get_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 992 | 992 | |
| 993 | - $preview_post_images = array(); |
|
| 994 | - if ($preview_get_images) {
|
|
| 995 | - foreach ($preview_get_images as $row) {
|
|
| 996 | - $preview_post_images[] = $row->src; |
|
| 997 | - } |
|
| 998 | - } |
|
| 999 | - if (!empty($preview_post_images)) {
|
|
| 1000 | - $post->post_images = implode(',', $preview_post_images);
|
|
| 1001 | - } |
|
| 1002 | - } |
|
| 1003 | - |
|
| 1004 | - if ($preview) {
|
|
| 1005 | - $post_images = array(); |
|
| 1006 | - if (isset($post->post_images) && !empty($post->post_images)) {
|
|
| 1007 | - $post->post_images = trim($post->post_images, ","); |
|
| 1008 | - $post_images = explode(",", $post->post_images);
|
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - $main_slides = ''; |
|
| 1012 | - $nav_slides = ''; |
|
| 1013 | - $slides = 0; |
|
| 1014 | - |
|
| 1015 | - if (!empty($post_images)) {
|
|
| 1016 | - foreach ($post_images as $image) {
|
|
| 1017 | - if (!empty($image)) {
|
|
| 1018 | - $sizes = getimagesize(trim($image)); |
|
| 1019 | - $width = !empty($sizes) && isset($sizes[0]) ? $sizes[0] : 0; |
|
| 1020 | - $height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0; |
|
| 1021 | - |
|
| 1022 | - if ($image && $width && $height) {
|
|
| 1023 | - $image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
|
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - if (isset($image->src)) {
|
|
| 1027 | - if ($image->height >= 400) {
|
|
| 1028 | - $spacer_height = 0; |
|
| 1029 | - } else {
|
|
| 1030 | - $spacer_height = ((400 - $image->height) / 2); |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - $image_title = isset($image->title) ? $image->title : ''; |
|
| 1034 | - |
|
| 1035 | - $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1036 | - $main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>'; |
|
| 1037 | - $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1038 | - $slides++; |
|
| 1039 | - } |
|
| 1040 | - } |
|
| 1041 | - }// endfore |
|
| 1042 | - } //end if |
|
| 1043 | - } else {
|
|
| 1044 | - $main_slides = ''; |
|
| 1045 | - $nav_slides = ''; |
|
| 1046 | - /** |
|
| 1047 | - * Filter if default images should show on the details page. |
|
| 1048 | - * |
|
| 1049 | - * @param bool $use_default_image Default false. |
|
| 1050 | - * @since 1.6.16 |
|
| 1051 | - */ |
|
| 1052 | - $use_default_image = apply_filters('geodir_details_default_image_show', false);
|
|
| 1053 | - $post_images = geodir_get_images($post->ID, 'thumbnail', $use_default_image); // Hide default image on listing preview/detail page. |
|
| 1054 | - $slides = 0; |
|
| 1055 | - |
|
| 1056 | - if (!empty($post_images)) {
|
|
| 1057 | - foreach ($post_images as $image) {
|
|
| 1058 | - if ($image->height >= 400) {
|
|
| 1059 | - $spacer_height = 0; |
|
| 1060 | - } else {
|
|
| 1061 | - $spacer_height = ((400 - $image->height) / 2); |
|
| 1062 | - } |
|
| 1063 | - $caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : ''; |
|
| 1064 | - $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1065 | - $main_slides .= '<img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>'; |
|
| 1066 | - $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1067 | - $slides++; |
|
| 1068 | - } |
|
| 1069 | - }// endfore |
|
| 1070 | - } |
|
| 993 | + $preview_post_images = array(); |
|
| 994 | + if ($preview_get_images) {
|
|
| 995 | + foreach ($preview_get_images as $row) {
|
|
| 996 | + $preview_post_images[] = $row->src; |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | + if (!empty($preview_post_images)) {
|
|
| 1000 | + $post->post_images = implode(',', $preview_post_images);
|
|
| 1001 | + } |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + if ($preview) {
|
|
| 1005 | + $post_images = array(); |
|
| 1006 | + if (isset($post->post_images) && !empty($post->post_images)) {
|
|
| 1007 | + $post->post_images = trim($post->post_images, ","); |
|
| 1008 | + $post_images = explode(",", $post->post_images);
|
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + $main_slides = ''; |
|
| 1012 | + $nav_slides = ''; |
|
| 1013 | + $slides = 0; |
|
| 1014 | + |
|
| 1015 | + if (!empty($post_images)) {
|
|
| 1016 | + foreach ($post_images as $image) {
|
|
| 1017 | + if (!empty($image)) {
|
|
| 1018 | + $sizes = getimagesize(trim($image)); |
|
| 1019 | + $width = !empty($sizes) && isset($sizes[0]) ? $sizes[0] : 0; |
|
| 1020 | + $height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0; |
|
| 1021 | + |
|
| 1022 | + if ($image && $width && $height) {
|
|
| 1023 | + $image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
|
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + if (isset($image->src)) {
|
|
| 1027 | + if ($image->height >= 400) {
|
|
| 1028 | + $spacer_height = 0; |
|
| 1029 | + } else {
|
|
| 1030 | + $spacer_height = ((400 - $image->height) / 2); |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + $image_title = isset($image->title) ? $image->title : ''; |
|
| 1034 | + |
|
| 1035 | + $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1036 | + $main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>'; |
|
| 1037 | + $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1038 | + $slides++; |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + }// endfore |
|
| 1042 | + } //end if |
|
| 1043 | + } else {
|
|
| 1044 | + $main_slides = ''; |
|
| 1045 | + $nav_slides = ''; |
|
| 1046 | + /** |
|
| 1047 | + * Filter if default images should show on the details page. |
|
| 1048 | + * |
|
| 1049 | + * @param bool $use_default_image Default false. |
|
| 1050 | + * @since 1.6.16 |
|
| 1051 | + */ |
|
| 1052 | + $use_default_image = apply_filters('geodir_details_default_image_show', false);
|
|
| 1053 | + $post_images = geodir_get_images($post->ID, 'thumbnail', $use_default_image); // Hide default image on listing preview/detail page. |
|
| 1054 | + $slides = 0; |
|
| 1055 | + |
|
| 1056 | + if (!empty($post_images)) {
|
|
| 1057 | + foreach ($post_images as $image) {
|
|
| 1058 | + if ($image->height >= 400) {
|
|
| 1059 | + $spacer_height = 0; |
|
| 1060 | + } else {
|
|
| 1061 | + $spacer_height = ((400 - $image->height) / 2); |
|
| 1062 | + } |
|
| 1063 | + $caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : ''; |
|
| 1064 | + $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1065 | + $main_slides .= '<img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>'; |
|
| 1066 | + $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1067 | + $slides++; |
|
| 1068 | + } |
|
| 1069 | + }// endfore |
|
| 1070 | + } |
|
| 1071 | 1071 | |
| 1072 | - if (!empty($post_images)) {
|
|
| 1073 | - ?> |
|
| 1072 | + if (!empty($post_images)) {
|
|
| 1073 | + ?> |
|
| 1074 | 1074 | <div class="geodir_flex-container"> |
| 1075 | 1075 | <div class="geodir_flex-loader"><i class="fa fa-refresh fa-spin"></i></div> |
| 1076 | 1076 | <div id="geodir_slider" class="geodir_flexslider "> |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | <?php } ?> |
| 1084 | 1084 | </div> |
| 1085 | 1085 | <?php |
| 1086 | - } |
|
| 1086 | + } |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | add_action('geodir_details_taxonomies', 'geodir_action_details_taxonomies', 10);
|
@@ -1098,177 +1098,177 @@ discard block |
||
| 1098 | 1098 | */ |
| 1099 | 1099 | function geodir_action_details_taxonomies() |
| 1100 | 1100 | {
|
| 1101 | - global $preview, $post;?> |
|
| 1101 | + global $preview, $post;?> |
|
| 1102 | 1102 | <p class="geodir_post_taxomomies clearfix"> |
| 1103 | 1103 | <?php |
| 1104 | - $taxonomies = array(); |
|
| 1105 | - |
|
| 1106 | - $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1107 | - |
|
| 1108 | - if ($preview && !$is_backend_preview) {
|
|
| 1109 | - $post_type = $post->listing_type; |
|
| 1110 | - $post_taxonomy = $post_type . 'category'; |
|
| 1111 | - $post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
|
|
| 1112 | - } else {
|
|
| 1113 | - $post_type = $post->post_type; |
|
| 1114 | - $post_taxonomy = $post_type . 'category'; |
|
| 1115 | - } |
|
| 1104 | + $taxonomies = array(); |
|
| 1105 | + |
|
| 1106 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1107 | + |
|
| 1108 | + if ($preview && !$is_backend_preview) {
|
|
| 1109 | + $post_type = $post->listing_type; |
|
| 1110 | + $post_taxonomy = $post_type . 'category'; |
|
| 1111 | + $post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
|
|
| 1112 | + } else {
|
|
| 1113 | + $post_type = $post->post_type; |
|
| 1114 | + $post_taxonomy = $post_type . 'category'; |
|
| 1115 | + } |
|
| 1116 | 1116 | //{
|
| 1117 | - $post_type_info = get_post_type_object($post_type); |
|
| 1118 | - $listing_label = __($post_type_info->labels->singular_name, 'geodirectory'); |
|
| 1119 | - |
|
| 1120 | - if (!empty($post->post_tags)) {
|
|
| 1121 | - |
|
| 1122 | - if (taxonomy_exists($post_type . '_tags')): |
|
| 1123 | - $links = array(); |
|
| 1124 | - $terms = array(); |
|
| 1125 | - // to limit post tags |
|
| 1126 | - $post_tags = trim($post->post_tags, ","); |
|
| 1127 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 1128 | - /** |
|
| 1129 | - * Filter the post tags. |
|
| 1130 | - * |
|
| 1131 | - * Allows you to filter the post tags output on the details page of a post. |
|
| 1132 | - * |
|
| 1133 | - * @since 1.0.0 |
|
| 1134 | - * @param string $post_tags A comma seperated list of tags. |
|
| 1135 | - * @param int $post_id The current post id. |
|
| 1136 | - */ |
|
| 1137 | - $post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
|
|
| 1138 | - |
|
| 1139 | - $post->post_tags = $post_tags; |
|
| 1140 | - $post_tags = explode(",", trim($post->post_tags, ","));
|
|
| 1141 | - |
|
| 1142 | - |
|
| 1143 | - foreach ($post_tags as $post_term) {
|
|
| 1144 | - |
|
| 1145 | - // fix slug creation order for tags & location |
|
| 1146 | - $post_term = trim($post_term); |
|
| 1147 | - |
|
| 1148 | - $priority_location = false; |
|
| 1149 | - if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
|
|
| 1150 | - $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
|
|
| 1151 | - } else {
|
|
| 1152 | - $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL; |
|
| 1153 | - $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL; |
|
| 1154 | - $post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL; |
|
| 1155 | - $match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false; |
|
| 1156 | - $match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false; |
|
| 1157 | - $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false; |
|
| 1158 | - if ($match_country || $match_region || $match_city) {
|
|
| 1159 | - $priority_location = true; |
|
| 1160 | - $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1161 | - } else {
|
|
| 1162 | - $insert_term = wp_insert_term($post_term, $post_type . '_tags'); |
|
| 1163 | - $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1164 | - } |
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - if (!is_wp_error($term) && is_object($term)) {
|
|
| 1168 | - |
|
| 1169 | - // fix tag link on detail page |
|
| 1170 | - if ($priority_location) {
|
|
| 1171 | - |
|
| 1172 | - $tag_link = "<a href=''>$post_term</a>"; |
|
| 1173 | - /** |
|
| 1174 | - * Filter the tag name on the details page. |
|
| 1175 | - * |
|
| 1176 | - * @since 1.5.6 |
|
| 1177 | - * @param string $tag_link The tag link html. |
|
| 1178 | - * @param object $term The tag term object. |
|
| 1179 | - */ |
|
| 1180 | - $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1181 | - $links[] = $tag_link; |
|
| 1182 | - } else {
|
|
| 1183 | - $tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>"; |
|
| 1184 | - /** This action is documented in geodirectory-template_actions.php */ |
|
| 1185 | - $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1186 | - $links[] = $tag_link; |
|
| 1187 | - } |
|
| 1188 | - $terms[] = $term; |
|
| 1189 | - } |
|
| 1190 | - // |
|
| 1191 | - } |
|
| 1192 | - if (!isset($listing_label)) {
|
|
| 1193 | - $listing_label = ''; |
|
| 1194 | - } |
|
| 1195 | - $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1196 | - endif; |
|
| 1197 | - |
|
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - if (!empty($post->{$post_taxonomy})) {
|
|
| 1201 | - $links = array(); |
|
| 1202 | - $terms = array(); |
|
| 1203 | - $termsOrdered = array(); |
|
| 1204 | - if (!is_array($post->{$post_taxonomy})) {
|
|
| 1205 | - $post_term = explode(",", trim($post->{$post_taxonomy}, ","));
|
|
| 1206 | - } else {
|
|
| 1207 | - $post_term = $post->{$post_taxonomy};
|
|
| 1117 | + $post_type_info = get_post_type_object($post_type); |
|
| 1118 | + $listing_label = __($post_type_info->labels->singular_name, 'geodirectory'); |
|
| 1119 | + |
|
| 1120 | + if (!empty($post->post_tags)) {
|
|
| 1121 | + |
|
| 1122 | + if (taxonomy_exists($post_type . '_tags')): |
|
| 1123 | + $links = array(); |
|
| 1124 | + $terms = array(); |
|
| 1125 | + // to limit post tags |
|
| 1126 | + $post_tags = trim($post->post_tags, ","); |
|
| 1127 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 1128 | + /** |
|
| 1129 | + * Filter the post tags. |
|
| 1130 | + * |
|
| 1131 | + * Allows you to filter the post tags output on the details page of a post. |
|
| 1132 | + * |
|
| 1133 | + * @since 1.0.0 |
|
| 1134 | + * @param string $post_tags A comma seperated list of tags. |
|
| 1135 | + * @param int $post_id The current post id. |
|
| 1136 | + */ |
|
| 1137 | + $post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
|
|
| 1138 | + |
|
| 1139 | + $post->post_tags = $post_tags; |
|
| 1140 | + $post_tags = explode(",", trim($post->post_tags, ","));
|
|
| 1141 | + |
|
| 1142 | + |
|
| 1143 | + foreach ($post_tags as $post_term) {
|
|
| 1144 | + |
|
| 1145 | + // fix slug creation order for tags & location |
|
| 1146 | + $post_term = trim($post_term); |
|
| 1147 | + |
|
| 1148 | + $priority_location = false; |
|
| 1149 | + if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
|
|
| 1150 | + $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
|
|
| 1151 | + } else {
|
|
| 1152 | + $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL; |
|
| 1153 | + $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL; |
|
| 1154 | + $post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL; |
|
| 1155 | + $match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false; |
|
| 1156 | + $match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false; |
|
| 1157 | + $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false; |
|
| 1158 | + if ($match_country || $match_region || $match_city) {
|
|
| 1159 | + $priority_location = true; |
|
| 1160 | + $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1161 | + } else {
|
|
| 1162 | + $insert_term = wp_insert_term($post_term, $post_type . '_tags'); |
|
| 1163 | + $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + if (!is_wp_error($term) && is_object($term)) {
|
|
| 1168 | + |
|
| 1169 | + // fix tag link on detail page |
|
| 1170 | + if ($priority_location) {
|
|
| 1171 | + |
|
| 1172 | + $tag_link = "<a href=''>$post_term</a>"; |
|
| 1173 | + /** |
|
| 1174 | + * Filter the tag name on the details page. |
|
| 1175 | + * |
|
| 1176 | + * @since 1.5.6 |
|
| 1177 | + * @param string $tag_link The tag link html. |
|
| 1178 | + * @param object $term The tag term object. |
|
| 1179 | + */ |
|
| 1180 | + $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1181 | + $links[] = $tag_link; |
|
| 1182 | + } else {
|
|
| 1183 | + $tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>"; |
|
| 1184 | + /** This action is documented in geodirectory-template_actions.php */ |
|
| 1185 | + $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1186 | + $links[] = $tag_link; |
|
| 1187 | + } |
|
| 1188 | + $terms[] = $term; |
|
| 1189 | + } |
|
| 1190 | + // |
|
| 1191 | + } |
|
| 1192 | + if (!isset($listing_label)) {
|
|
| 1193 | + $listing_label = ''; |
|
| 1194 | + } |
|
| 1195 | + $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1196 | + endif; |
|
| 1197 | + |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + if (!empty($post->{$post_taxonomy})) {
|
|
| 1201 | + $links = array(); |
|
| 1202 | + $terms = array(); |
|
| 1203 | + $termsOrdered = array(); |
|
| 1204 | + if (!is_array($post->{$post_taxonomy})) {
|
|
| 1205 | + $post_term = explode(",", trim($post->{$post_taxonomy}, ","));
|
|
| 1206 | + } else {
|
|
| 1207 | + $post_term = $post->{$post_taxonomy};
|
|
| 1208 | 1208 | |
| 1209 | 1209 | if ($preview && !$is_backend_preview) {
|
| 1210 | 1210 | $post_term = geodir_add_parent_terms($post_term, $post_taxonomy); |
| 1211 | 1211 | } |
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - $post_term = array_unique($post_term); |
|
| 1215 | - if (!empty($post_term)) {
|
|
| 1216 | - foreach ($post_term as $post_term) {
|
|
| 1217 | - $post_term = trim($post_term); |
|
| 1218 | - |
|
| 1219 | - if ($post_term != ''): |
|
| 1220 | - $term = get_term_by('id', $post_term, $post_taxonomy);
|
|
| 1221 | - |
|
| 1222 | - if (is_object($term)) {
|
|
| 1223 | - $term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>"; |
|
| 1224 | - /** |
|
| 1225 | - * Filter the category name on the details page. |
|
| 1226 | - * |
|
| 1227 | - * @since 1.5.6 |
|
| 1228 | - * @param string $term_link The link html to the category. |
|
| 1229 | - * @param object $term The category term object. |
|
| 1230 | - */ |
|
| 1231 | - $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
|
|
| 1232 | - $links[] = $term_link; |
|
| 1233 | - $terms[] = $term; |
|
| 1234 | - } |
|
| 1235 | - endif; |
|
| 1236 | - } |
|
| 1237 | - // order alphabetically |
|
| 1238 | - asort($links); |
|
| 1239 | - foreach (array_keys($links) as $key) {
|
|
| 1240 | - $termsOrdered[$key] = $terms[$key]; |
|
| 1241 | - } |
|
| 1242 | - $terms = $termsOrdered; |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + $post_term = array_unique($post_term); |
|
| 1215 | + if (!empty($post_term)) {
|
|
| 1216 | + foreach ($post_term as $post_term) {
|
|
| 1217 | + $post_term = trim($post_term); |
|
| 1218 | + |
|
| 1219 | + if ($post_term != ''): |
|
| 1220 | + $term = get_term_by('id', $post_term, $post_taxonomy);
|
|
| 1221 | + |
|
| 1222 | + if (is_object($term)) {
|
|
| 1223 | + $term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>"; |
|
| 1224 | + /** |
|
| 1225 | + * Filter the category name on the details page. |
|
| 1226 | + * |
|
| 1227 | + * @since 1.5.6 |
|
| 1228 | + * @param string $term_link The link html to the category. |
|
| 1229 | + * @param object $term The category term object. |
|
| 1230 | + */ |
|
| 1231 | + $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
|
|
| 1232 | + $links[] = $term_link; |
|
| 1233 | + $terms[] = $term; |
|
| 1234 | + } |
|
| 1235 | + endif; |
|
| 1236 | + } |
|
| 1237 | + // order alphabetically |
|
| 1238 | + asort($links); |
|
| 1239 | + foreach (array_keys($links) as $key) {
|
|
| 1240 | + $termsOrdered[$key] = $terms[$key]; |
|
| 1241 | + } |
|
| 1242 | + $terms = $termsOrdered; |
|
| 1243 | 1243 | |
| 1244 | - } |
|
| 1244 | + } |
|
| 1245 | 1245 | |
| 1246 | - if (!isset($listing_label)) {
|
|
| 1247 | - $listing_label = ''; |
|
| 1248 | - } |
|
| 1249 | - $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1246 | + if (!isset($listing_label)) {
|
|
| 1247 | + $listing_label = ''; |
|
| 1248 | + } |
|
| 1249 | + $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1250 | 1250 | |
| 1251 | - } |
|
| 1251 | + } |
|
| 1252 | 1252 | |
| 1253 | - /** |
|
| 1254 | - * Filter the taxonomies array before output. |
|
| 1255 | - * |
|
| 1256 | - * @since 1.5.9 |
|
| 1257 | - * @param array $taxonomies The array of cats and tags. |
|
| 1258 | - * @param string $post_type The post type being output. |
|
| 1259 | - * @param string $listing_label The post type label. |
|
| 1260 | - * @param string $listing_label The post type label with ucwords function. |
|
| 1261 | - */ |
|
| 1262 | - $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
|
|
| 1253 | + /** |
|
| 1254 | + * Filter the taxonomies array before output. |
|
| 1255 | + * |
|
| 1256 | + * @since 1.5.9 |
|
| 1257 | + * @param array $taxonomies The array of cats and tags. |
|
| 1258 | + * @param string $post_type The post type being output. |
|
| 1259 | + * @param string $listing_label The post type label. |
|
| 1260 | + * @param string $listing_label The post type label with ucwords function. |
|
| 1261 | + */ |
|
| 1262 | + $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
|
|
| 1263 | 1263 | |
| 1264 | - if (isset($taxonomies[$post_taxonomy])) {
|
|
| 1265 | - echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>'; |
|
| 1266 | - } |
|
| 1264 | + if (isset($taxonomies[$post_taxonomy])) {
|
|
| 1265 | + echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>'; |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | - if (isset($taxonomies[$post_type . '_tags'])) |
|
| 1269 | - echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>'; |
|
| 1268 | + if (isset($taxonomies[$post_type . '_tags'])) |
|
| 1269 | + echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>'; |
|
| 1270 | 1270 | |
| 1271 | - ?> |
|
| 1271 | + ?> |
|
| 1272 | 1272 | </p><?php |
| 1273 | 1273 | } |
| 1274 | 1274 | |
@@ -1290,140 +1290,140 @@ discard block |
||
| 1290 | 1290 | function geodir_action_details_micordata($post='') |
| 1291 | 1291 | {
|
| 1292 | 1292 | |
| 1293 | - global $preview; |
|
| 1294 | - if(empty($post)){global $post;}
|
|
| 1295 | - if ($preview || !geodir_is_page('detail')) {
|
|
| 1296 | - return; |
|
| 1297 | - } |
|
| 1298 | - |
|
| 1299 | - // url |
|
| 1300 | - $c_url = geodir_curPageURL(); |
|
| 1301 | - |
|
| 1302 | - // post reviews |
|
| 1303 | - $post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve'));
|
|
| 1304 | - if (empty($post_reviews)) {
|
|
| 1305 | - $reviews = ''; |
|
| 1306 | - } else {
|
|
| 1307 | - foreach ($post_reviews as $review) {
|
|
| 1308 | - $reviews[] = array( |
|
| 1309 | - "@type" => "Review", |
|
| 1310 | - "author" => $review->comment_author, |
|
| 1311 | - "datePublished" => $review->comment_date, |
|
| 1312 | - "description" => $review->comment_content, |
|
| 1313 | - "reviewRating" => array( |
|
| 1314 | - "@type" => "Rating", |
|
| 1315 | - "bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score. |
|
| 1316 | - "ratingValue" => geodir_get_commentoverall($review->comment_ID), |
|
| 1317 | - "worstRating" => "1" |
|
| 1318 | - ) |
|
| 1319 | - ); |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - } |
|
| 1323 | - |
|
| 1324 | - // post images |
|
| 1325 | - $post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 1326 | - if (empty($post_images)) {
|
|
| 1327 | - $images = ''; |
|
| 1328 | - } else {
|
|
| 1329 | - $i_arr = array(); |
|
| 1330 | - foreach ($post_images as $img) {
|
|
| 1331 | - $i_arr[] = $img->src; |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - if (count($i_arr) == 1) {
|
|
| 1335 | - $images = $i_arr[0]; |
|
| 1336 | - } else {
|
|
| 1337 | - $images = $i_arr; |
|
| 1338 | - } |
|
| 1339 | - |
|
| 1340 | - } |
|
| 1341 | - //print_r($post); |
|
| 1342 | - // external links |
|
| 1343 | - $external_links = array(); |
|
| 1344 | - $external_links[] = $post->geodir_website; |
|
| 1345 | - $external_links[] = $post->geodir_twitter; |
|
| 1346 | - $external_links[] = $post->geodir_facebook; |
|
| 1347 | - $external_links = array_filter($external_links); |
|
| 1348 | - |
|
| 1349 | - if(!empty($external_links)){
|
|
| 1350 | - $external_links = array_values($external_links); |
|
| 1351 | - } |
|
| 1352 | - |
|
| 1353 | - // reviews |
|
| 1354 | - $comment_count = geodir_get_review_count_total($post->ID); |
|
| 1355 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 1356 | - |
|
| 1357 | - // schema type |
|
| 1358 | - $schema_type = 'LocalBusiness'; |
|
| 1359 | - if(isset($post->default_category) && $post->default_category){
|
|
| 1360 | - $cat_schema = get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type); |
|
| 1361 | - if($cat_schema){$schema_type = $cat_schema;}
|
|
| 1362 | - if(!$schema_type && $post->post_type=='gd_event'){$schema_type = 'Event';}
|
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - $schema = array(); |
|
| 1366 | - $schema['@context'] = "https://schema.org"; |
|
| 1367 | - $schema['@type'] = $schema_type; |
|
| 1368 | - $schema['name'] = $post->post_title; |
|
| 1369 | - $schema['description'] = wp_strip_all_tags( $post->post_content, true ); |
|
| 1370 | - $schema['telephone'] = $post->geodir_contact; |
|
| 1371 | - $schema['url'] = $c_url; |
|
| 1372 | - $schema['sameAs'] = $external_links; |
|
| 1373 | - $schema['image'] = $images; |
|
| 1374 | - $schema['address'] = array( |
|
| 1375 | - "@type" => "PostalAddress", |
|
| 1376 | - "streetAddress" => $post->post_address, |
|
| 1377 | - "addressLocality" => $post->post_city, |
|
| 1378 | - "addressRegion" => $post->post_region, |
|
| 1379 | - "addressCountry" => $post->post_country, |
|
| 1380 | - "postalCode" => $post->post_zip |
|
| 1381 | - ); |
|
| 1382 | - |
|
| 1383 | - if($post->post_latitude && $post->post_longitude) {
|
|
| 1384 | - $schema['geo'] = array( |
|
| 1385 | - "@type" => "GeoCoordinates", |
|
| 1386 | - "latitude" => $post->post_latitude, |
|
| 1387 | - "longitude" => $post->post_longitude |
|
| 1388 | - ); |
|
| 1389 | - } |
|
| 1390 | - |
|
| 1391 | - if($post_avgratings) {
|
|
| 1392 | - $schema['aggregateRating'] = array( |
|
| 1393 | - "@type" => "AggregateRating", |
|
| 1394 | - "ratingValue" => $post_avgratings, |
|
| 1395 | - "bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score. |
|
| 1396 | - "worstRating" => "1", |
|
| 1397 | - "ratingCount" => $comment_count |
|
| 1398 | - ); |
|
| 1399 | - } |
|
| 1400 | - $schema['review'] = $reviews; |
|
| 1401 | - |
|
| 1402 | - /** |
|
| 1403 | - * Allow the schema JSON-LD info to be filtered. |
|
| 1404 | - * |
|
| 1405 | - * @since 1.5.4 |
|
| 1406 | - * @since 1.5.7 Added $post variable. |
|
| 1407 | - * @param array $schema The array of schema data to be filtered. |
|
| 1408 | - * @param object $post The post object. |
|
| 1409 | - */ |
|
| 1410 | - $schema = apply_filters('geodir_details_schema', $schema,$post);
|
|
| 1411 | - |
|
| 1412 | - |
|
| 1413 | - echo '<script type="application/ld+json">' . json_encode($schema) . '</script>'; |
|
| 1414 | - |
|
| 1415 | - |
|
| 1416 | - $uploads = wp_upload_dir(); |
|
| 1417 | - $facebook_og = (isset($post->featured_image) && $post->featured_image) ? '<meta property="og:image" content="'.$uploads['baseurl'].$post->featured_image.'"/>' : ''; |
|
| 1418 | - |
|
| 1419 | - /** |
|
| 1420 | - * Show facebook open graph meta info |
|
| 1421 | - * |
|
| 1422 | - * @since 1.6.6 |
|
| 1423 | - * @param string $facebook_og The open graph html to be filtered. |
|
| 1424 | - * @param object $post The post object. |
|
| 1425 | - */ |
|
| 1426 | - echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
|
|
| 1293 | + global $preview; |
|
| 1294 | + if(empty($post)){global $post;}
|
|
| 1295 | + if ($preview || !geodir_is_page('detail')) {
|
|
| 1296 | + return; |
|
| 1297 | + } |
|
| 1298 | + |
|
| 1299 | + // url |
|
| 1300 | + $c_url = geodir_curPageURL(); |
|
| 1301 | + |
|
| 1302 | + // post reviews |
|
| 1303 | + $post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve'));
|
|
| 1304 | + if (empty($post_reviews)) {
|
|
| 1305 | + $reviews = ''; |
|
| 1306 | + } else {
|
|
| 1307 | + foreach ($post_reviews as $review) {
|
|
| 1308 | + $reviews[] = array( |
|
| 1309 | + "@type" => "Review", |
|
| 1310 | + "author" => $review->comment_author, |
|
| 1311 | + "datePublished" => $review->comment_date, |
|
| 1312 | + "description" => $review->comment_content, |
|
| 1313 | + "reviewRating" => array( |
|
| 1314 | + "@type" => "Rating", |
|
| 1315 | + "bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score. |
|
| 1316 | + "ratingValue" => geodir_get_commentoverall($review->comment_ID), |
|
| 1317 | + "worstRating" => "1" |
|
| 1318 | + ) |
|
| 1319 | + ); |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + // post images |
|
| 1325 | + $post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 1326 | + if (empty($post_images)) {
|
|
| 1327 | + $images = ''; |
|
| 1328 | + } else {
|
|
| 1329 | + $i_arr = array(); |
|
| 1330 | + foreach ($post_images as $img) {
|
|
| 1331 | + $i_arr[] = $img->src; |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + if (count($i_arr) == 1) {
|
|
| 1335 | + $images = $i_arr[0]; |
|
| 1336 | + } else {
|
|
| 1337 | + $images = $i_arr; |
|
| 1338 | + } |
|
| 1339 | + |
|
| 1340 | + } |
|
| 1341 | + //print_r($post); |
|
| 1342 | + // external links |
|
| 1343 | + $external_links = array(); |
|
| 1344 | + $external_links[] = $post->geodir_website; |
|
| 1345 | + $external_links[] = $post->geodir_twitter; |
|
| 1346 | + $external_links[] = $post->geodir_facebook; |
|
| 1347 | + $external_links = array_filter($external_links); |
|
| 1348 | + |
|
| 1349 | + if(!empty($external_links)){
|
|
| 1350 | + $external_links = array_values($external_links); |
|
| 1351 | + } |
|
| 1352 | + |
|
| 1353 | + // reviews |
|
| 1354 | + $comment_count = geodir_get_review_count_total($post->ID); |
|
| 1355 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 1356 | + |
|
| 1357 | + // schema type |
|
| 1358 | + $schema_type = 'LocalBusiness'; |
|
| 1359 | + if(isset($post->default_category) && $post->default_category){
|
|
| 1360 | + $cat_schema = get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type); |
|
| 1361 | + if($cat_schema){$schema_type = $cat_schema;}
|
|
| 1362 | + if(!$schema_type && $post->post_type=='gd_event'){$schema_type = 'Event';}
|
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + $schema = array(); |
|
| 1366 | + $schema['@context'] = "https://schema.org"; |
|
| 1367 | + $schema['@type'] = $schema_type; |
|
| 1368 | + $schema['name'] = $post->post_title; |
|
| 1369 | + $schema['description'] = wp_strip_all_tags( $post->post_content, true ); |
|
| 1370 | + $schema['telephone'] = $post->geodir_contact; |
|
| 1371 | + $schema['url'] = $c_url; |
|
| 1372 | + $schema['sameAs'] = $external_links; |
|
| 1373 | + $schema['image'] = $images; |
|
| 1374 | + $schema['address'] = array( |
|
| 1375 | + "@type" => "PostalAddress", |
|
| 1376 | + "streetAddress" => $post->post_address, |
|
| 1377 | + "addressLocality" => $post->post_city, |
|
| 1378 | + "addressRegion" => $post->post_region, |
|
| 1379 | + "addressCountry" => $post->post_country, |
|
| 1380 | + "postalCode" => $post->post_zip |
|
| 1381 | + ); |
|
| 1382 | + |
|
| 1383 | + if($post->post_latitude && $post->post_longitude) {
|
|
| 1384 | + $schema['geo'] = array( |
|
| 1385 | + "@type" => "GeoCoordinates", |
|
| 1386 | + "latitude" => $post->post_latitude, |
|
| 1387 | + "longitude" => $post->post_longitude |
|
| 1388 | + ); |
|
| 1389 | + } |
|
| 1390 | + |
|
| 1391 | + if($post_avgratings) {
|
|
| 1392 | + $schema['aggregateRating'] = array( |
|
| 1393 | + "@type" => "AggregateRating", |
|
| 1394 | + "ratingValue" => $post_avgratings, |
|
| 1395 | + "bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score. |
|
| 1396 | + "worstRating" => "1", |
|
| 1397 | + "ratingCount" => $comment_count |
|
| 1398 | + ); |
|
| 1399 | + } |
|
| 1400 | + $schema['review'] = $reviews; |
|
| 1401 | + |
|
| 1402 | + /** |
|
| 1403 | + * Allow the schema JSON-LD info to be filtered. |
|
| 1404 | + * |
|
| 1405 | + * @since 1.5.4 |
|
| 1406 | + * @since 1.5.7 Added $post variable. |
|
| 1407 | + * @param array $schema The array of schema data to be filtered. |
|
| 1408 | + * @param object $post The post object. |
|
| 1409 | + */ |
|
| 1410 | + $schema = apply_filters('geodir_details_schema', $schema,$post);
|
|
| 1411 | + |
|
| 1412 | + |
|
| 1413 | + echo '<script type="application/ld+json">' . json_encode($schema) . '</script>'; |
|
| 1414 | + |
|
| 1415 | + |
|
| 1416 | + $uploads = wp_upload_dir(); |
|
| 1417 | + $facebook_og = (isset($post->featured_image) && $post->featured_image) ? '<meta property="og:image" content="'.$uploads['baseurl'].$post->featured_image.'"/>' : ''; |
|
| 1418 | + |
|
| 1419 | + /** |
|
| 1420 | + * Show facebook open graph meta info |
|
| 1421 | + * |
|
| 1422 | + * @since 1.6.6 |
|
| 1423 | + * @param string $facebook_og The open graph html to be filtered. |
|
| 1424 | + * @param object $post The post object. |
|
| 1425 | + */ |
|
| 1426 | + echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
|
|
| 1427 | 1427 | |
| 1428 | 1428 | |
| 1429 | 1429 | |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | */ |
| 1444 | 1444 | function geodir_action_details_next_prev() |
| 1445 | 1445 | {
|
| 1446 | - ?> |
|
| 1446 | + ?> |
|
| 1447 | 1447 | <div class="geodir-pos_navigation clearfix"> |
| 1448 | 1448 | <div |
| 1449 | 1449 | class="geodir-post_left"><?php previous_post_link('%link', '' . __('Previous', 'geodirectory'), false) ?></div>
|
@@ -1461,15 +1461,15 @@ discard block |
||
| 1461 | 1461 | */ |
| 1462 | 1462 | function geodir_action_before_single_post() |
| 1463 | 1463 | {
|
| 1464 | - global $post; |
|
| 1465 | - /** |
|
| 1466 | - * Called at the very start of the details page output, before the title section. |
|
| 1467 | - * |
|
| 1468 | - * @since 1.0.0 |
|
| 1469 | - * @param object $post The current post object. |
|
| 1470 | - * @global WP_Post|null $post The current post, if available. |
|
| 1471 | - */ |
|
| 1472 | - do_action('geodir_before_single_post', $post); // extra action
|
|
| 1464 | + global $post; |
|
| 1465 | + /** |
|
| 1466 | + * Called at the very start of the details page output, before the title section. |
|
| 1467 | + * |
|
| 1468 | + * @since 1.0.0 |
|
| 1469 | + * @param object $post The current post object. |
|
| 1470 | + * @global WP_Post|null $post The current post, if available. |
|
| 1471 | + */ |
|
| 1472 | + do_action('geodir_before_single_post', $post); // extra action
|
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | /** |
@@ -1480,13 +1480,13 @@ discard block |
||
| 1480 | 1480 | */ |
| 1481 | 1481 | function geodir_action_after_single_post($post) |
| 1482 | 1482 | {
|
| 1483 | - /** |
|
| 1484 | - * Called on the details page after the details page tabs section and before the next/prev buttons. |
|
| 1485 | - * |
|
| 1486 | - * @since 1.0.0 |
|
| 1487 | - * @param object $post The current post object. |
|
| 1488 | - */ |
|
| 1489 | - do_action('geodir_after_single_post', $post); // extra action
|
|
| 1483 | + /** |
|
| 1484 | + * Called on the details page after the details page tabs section and before the next/prev buttons. |
|
| 1485 | + * |
|
| 1486 | + * @since 1.0.0 |
|
| 1487 | + * @param object $post The current post object. |
|
| 1488 | + */ |
|
| 1489 | + do_action('geodir_after_single_post', $post); // extra action
|
|
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | add_action('geodir_details_main_content', 'geodir_action_before_single_post', 10);
|
@@ -1512,168 +1512,168 @@ discard block |
||
| 1512 | 1512 | */ |
| 1513 | 1513 | function geodir_action_listings_title() |
| 1514 | 1514 | {
|
| 1515 | - global $wp, $term; |
|
| 1516 | - |
|
| 1517 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 1518 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 1519 | - |
|
| 1520 | - $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 1521 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 1522 | - $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - $list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory'); |
|
| 1526 | - $single_name = $post_type_info->labels->singular_name; |
|
| 1527 | - |
|
| 1528 | - $taxonomy = geodir_get_taxonomies($gd_post_type, true); |
|
| 1529 | - |
|
| 1530 | - $gd_country = get_query_var('gd_country');
|
|
| 1531 | - $gd_region = get_query_var('gd_region');
|
|
| 1532 | - $gd_city = get_query_var('gd_city');
|
|
| 1533 | - |
|
| 1534 | - if (!empty($term)) {
|
|
| 1535 | - $location_name = ''; |
|
| 1536 | - if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
|
|
| 1537 | - if ($gd_country != '') {
|
|
| 1538 | - $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
|
|
| 1539 | - } |
|
| 1540 | - |
|
| 1541 | - if ($gd_region != '') {
|
|
| 1542 | - $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
|
|
| 1543 | - } |
|
| 1544 | - |
|
| 1545 | - if ($gd_city != '') {
|
|
| 1546 | - $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
|
|
| 1547 | - } |
|
| 1548 | - } |
|
| 1549 | - |
|
| 1550 | - $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
|
| 1551 | - if (!empty($current_term)) {
|
|
| 1552 | - $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
|
| 1553 | - if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1554 | - $location_last_char = substr($location_name, -1); |
|
| 1555 | - $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
|
| 1556 | - $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1557 | - } else {
|
|
| 1558 | - $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1559 | - } |
|
| 1560 | - } else {
|
|
| 1561 | - if (count($taxonomy) > 1) {
|
|
| 1562 | - $current_term = get_term_by('slug', $term, $taxonomy[1]);
|
|
| 1563 | - |
|
| 1564 | - if (!empty($current_term)) {
|
|
| 1565 | - $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
|
| 1566 | - if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1567 | - $location_last_char = substr($location_name, -1); |
|
| 1568 | - $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
|
| 1569 | - $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1570 | - } else {
|
|
| 1571 | - $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1572 | - } |
|
| 1573 | - } |
|
| 1574 | - } |
|
| 1575 | - } |
|
| 1515 | + global $wp, $term; |
|
| 1576 | 1516 | |
| 1577 | - } else {
|
|
| 1578 | - $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 1579 | - $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 1580 | - $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 1517 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 1518 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 1581 | 1519 | |
| 1582 | - $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 1520 | + $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 1521 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 1522 | + $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 1523 | + } |
|
| 1583 | 1524 | |
| 1584 | - if (function_exists('get_actual_location_name')) {
|
|
| 1585 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 1586 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 1587 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 1588 | - } |
|
| 1525 | + $list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory'); |
|
| 1526 | + $single_name = $post_type_info->labels->singular_name; |
|
| 1589 | 1527 | |
| 1590 | - if ($gd_city != '') {
|
|
| 1591 | - if ($gd_city_actual != '') {
|
|
| 1592 | - $gd_city = $gd_city_actual; |
|
| 1593 | - } else {
|
|
| 1594 | - $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 1595 | - $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 1596 | - $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 1597 | - } |
|
| 1528 | + $taxonomy = geodir_get_taxonomies($gd_post_type, true); |
|
| 1598 | 1529 | |
| 1599 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
|
|
| 1600 | - } else if ($gd_region != '') {
|
|
| 1601 | - if ($gd_region_actual != '') {
|
|
| 1602 | - $gd_region = $gd_region_actual; |
|
| 1603 | - } else {
|
|
| 1604 | - $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 1605 | - $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 1606 | - $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 1607 | - } |
|
| 1530 | + $gd_country = get_query_var('gd_country');
|
|
| 1531 | + $gd_region = get_query_var('gd_region');
|
|
| 1532 | + $gd_city = get_query_var('gd_city');
|
|
| 1608 | 1533 | |
| 1609 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
|
|
| 1610 | - } else if ($gd_country != '') {
|
|
| 1611 | - if ($gd_country_actual != '') {
|
|
| 1612 | - $gd_country = $gd_country_actual; |
|
| 1613 | - } else {
|
|
| 1614 | - $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 1615 | - $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 1616 | - $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
|
|
| 1620 | - } |
|
| 1621 | - } |
|
| 1622 | - |
|
| 1623 | - if (is_search()) {
|
|
| 1624 | - $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 1625 | - } |
|
| 1626 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1627 | - $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 1628 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1629 | - $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 1630 | - |
|
| 1631 | - |
|
| 1632 | - $title = $list_title; |
|
| 1633 | - $gd_page = ''; |
|
| 1634 | - if(geodir_is_page('pt')){
|
|
| 1635 | - $gd_page = 'pt'; |
|
| 1636 | - $title = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
|
|
| 1637 | - } |
|
| 1638 | - elseif(geodir_is_page('listing')){
|
|
| 1639 | - $gd_page = 'listing'; |
|
| 1640 | - global $wp_query; |
|
| 1641 | - $current_term = $wp_query->get_queried_object(); |
|
| 1642 | - if (strpos($current_term->taxonomy,'_tags') !== false) {
|
|
| 1643 | - $title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
|
|
| 1644 | - }else{
|
|
| 1645 | - $title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
|
|
| 1646 | - } |
|
| 1534 | + if (!empty($term)) {
|
|
| 1535 | + $location_name = ''; |
|
| 1536 | + if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
|
|
| 1537 | + if ($gd_country != '') {
|
|
| 1538 | + $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
|
|
| 1539 | + } |
|
| 1647 | 1540 | |
| 1648 | - } |
|
| 1649 | - elseif(geodir_is_page('author')){
|
|
| 1650 | - $gd_page = 'author'; |
|
| 1651 | - if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 1652 | - $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
|
| 1653 | - }else{
|
|
| 1654 | - $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
|
| 1655 | - } |
|
| 1541 | + if ($gd_region != '') {
|
|
| 1542 | + $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
|
|
| 1543 | + } |
|
| 1656 | 1544 | |
| 1657 | - } |
|
| 1545 | + if ($gd_city != '') {
|
|
| 1546 | + $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
|
|
| 1547 | + } |
|
| 1548 | + } |
|
| 1549 | + |
|
| 1550 | + $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
|
| 1551 | + if (!empty($current_term)) {
|
|
| 1552 | + $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
|
| 1553 | + if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1554 | + $location_last_char = substr($location_name, -1); |
|
| 1555 | + $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
|
| 1556 | + $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1557 | + } else {
|
|
| 1558 | + $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1559 | + } |
|
| 1560 | + } else {
|
|
| 1561 | + if (count($taxonomy) > 1) {
|
|
| 1562 | + $current_term = get_term_by('slug', $term, $taxonomy[1]);
|
|
| 1563 | + |
|
| 1564 | + if (!empty($current_term)) {
|
|
| 1565 | + $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
|
| 1566 | + if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1567 | + $location_last_char = substr($location_name, -1); |
|
| 1568 | + $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
|
| 1569 | + $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1570 | + } else {
|
|
| 1571 | + $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1572 | + } |
|
| 1573 | + } |
|
| 1574 | + } |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + } else {
|
|
| 1578 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 1579 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 1580 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 1581 | + |
|
| 1582 | + $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 1583 | + |
|
| 1584 | + if (function_exists('get_actual_location_name')) {
|
|
| 1585 | + $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 1586 | + $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 1587 | + $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + if ($gd_city != '') {
|
|
| 1591 | + if ($gd_city_actual != '') {
|
|
| 1592 | + $gd_city = $gd_city_actual; |
|
| 1593 | + } else {
|
|
| 1594 | + $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 1595 | + $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 1596 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 1597 | + } |
|
| 1658 | 1598 | |
| 1599 | + $list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
|
|
| 1600 | + } else if ($gd_region != '') {
|
|
| 1601 | + if ($gd_region_actual != '') {
|
|
| 1602 | + $gd_region = $gd_region_actual; |
|
| 1603 | + } else {
|
|
| 1604 | + $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 1605 | + $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 1606 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 1607 | + } |
|
| 1659 | 1608 | |
| 1660 | - /** |
|
| 1661 | - * Filter page title to replace variables. |
|
| 1662 | - * |
|
| 1663 | - * @since 1.5.4 |
|
| 1664 | - * @param string $title The page title including variables. |
|
| 1665 | - * @param string $gd_page The GeoDirectory page type if any. |
|
| 1666 | - */ |
|
| 1667 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 1609 | + $list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
|
|
| 1610 | + } else if ($gd_country != '') {
|
|
| 1611 | + if ($gd_country_actual != '') {
|
|
| 1612 | + $gd_country = $gd_country_actual; |
|
| 1613 | + } else {
|
|
| 1614 | + $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 1615 | + $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 1616 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 1617 | + } |
|
| 1668 | 1618 | |
| 1669 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 1670 | - /** |
|
| 1671 | - * Filter the listing page title. |
|
| 1672 | - * |
|
| 1673 | - * @since 1.0.0 |
|
| 1674 | - * @param string $list_title The title for the category page. |
|
| 1675 | - */ |
|
| 1676 | - apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
|
|
| 1619 | + $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
|
|
| 1620 | + } |
|
| 1621 | + } |
|
| 1622 | + |
|
| 1623 | + if (is_search()) {
|
|
| 1624 | + $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 1625 | + } |
|
| 1626 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1627 | + $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 1628 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1629 | + $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 1630 | + |
|
| 1631 | + |
|
| 1632 | + $title = $list_title; |
|
| 1633 | + $gd_page = ''; |
|
| 1634 | + if(geodir_is_page('pt')){
|
|
| 1635 | + $gd_page = 'pt'; |
|
| 1636 | + $title = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
|
|
| 1637 | + } |
|
| 1638 | + elseif(geodir_is_page('listing')){
|
|
| 1639 | + $gd_page = 'listing'; |
|
| 1640 | + global $wp_query; |
|
| 1641 | + $current_term = $wp_query->get_queried_object(); |
|
| 1642 | + if (strpos($current_term->taxonomy,'_tags') !== false) {
|
|
| 1643 | + $title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
|
|
| 1644 | + }else{
|
|
| 1645 | + $title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
|
|
| 1646 | + } |
|
| 1647 | + |
|
| 1648 | + } |
|
| 1649 | + elseif(geodir_is_page('author')){
|
|
| 1650 | + $gd_page = 'author'; |
|
| 1651 | + if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 1652 | + $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
|
| 1653 | + }else{
|
|
| 1654 | + $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
|
| 1655 | + } |
|
| 1656 | + |
|
| 1657 | + } |
|
| 1658 | + |
|
| 1659 | + |
|
| 1660 | + /** |
|
| 1661 | + * Filter page title to replace variables. |
|
| 1662 | + * |
|
| 1663 | + * @since 1.5.4 |
|
| 1664 | + * @param string $title The page title including variables. |
|
| 1665 | + * @param string $gd_page The GeoDirectory page type if any. |
|
| 1666 | + */ |
|
| 1667 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 1668 | + |
|
| 1669 | + echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 1670 | + /** |
|
| 1671 | + * Filter the listing page title. |
|
| 1672 | + * |
|
| 1673 | + * @since 1.0.0 |
|
| 1674 | + * @param string $list_title The title for the category page. |
|
| 1675 | + */ |
|
| 1676 | + apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
|
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | add_action('geodir_listings_page_description', 'geodir_action_listings_description', 10);
|
@@ -1686,46 +1686,46 @@ discard block |
||
| 1686 | 1686 | */ |
| 1687 | 1687 | function geodir_action_listings_description() |
| 1688 | 1688 | {
|
| 1689 | - global $wp_query; |
|
| 1690 | - $current_term = $wp_query->get_queried_object(); |
|
| 1689 | + global $wp_query; |
|
| 1690 | + $current_term = $wp_query->get_queried_object(); |
|
| 1691 | 1691 | |
| 1692 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 1693 | - if (isset($current_term->term_id) && $current_term->term_id != '') {
|
|
| 1692 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 1693 | + if (isset($current_term->term_id) && $current_term->term_id != '') {
|
|
| 1694 | 1694 | |
| 1695 | - $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags'); |
|
| 1696 | - $saved_data = stripslashes(get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type)); |
|
| 1697 | - if ($term_desc && !$saved_data) {
|
|
| 1698 | - $saved_data = $term_desc; |
|
| 1699 | - } |
|
| 1695 | + $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags'); |
|
| 1696 | + $saved_data = stripslashes(get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type)); |
|
| 1697 | + if ($term_desc && !$saved_data) {
|
|
| 1698 | + $saved_data = $term_desc; |
|
| 1699 | + } |
|
| 1700 | 1700 | |
| 1701 | - // stop payment manager filtering content length |
|
| 1702 | - $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); |
|
| 1703 | - if ( false !== $filter_priority ) {
|
|
| 1704 | - remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1705 | - } |
|
| 1701 | + // stop payment manager filtering content length |
|
| 1702 | + $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); |
|
| 1703 | + if ( false !== $filter_priority ) {
|
|
| 1704 | + remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1705 | + } |
|
| 1706 | 1706 | |
| 1707 | - /** |
|
| 1708 | - * Apply the core filter `the_content` filter to the variable string. |
|
| 1709 | - * |
|
| 1710 | - * This is a WordPress core filter that does many things. |
|
| 1711 | - * |
|
| 1712 | - * @since 1.0.0 |
|
| 1713 | - * @param string $var The string to apply the filter to. |
|
| 1714 | - */ |
|
| 1715 | - $cat_description = apply_filters('the_content', $saved_data);
|
|
| 1707 | + /** |
|
| 1708 | + * Apply the core filter `the_content` filter to the variable string. |
|
| 1709 | + * |
|
| 1710 | + * This is a WordPress core filter that does many things. |
|
| 1711 | + * |
|
| 1712 | + * @since 1.0.0 |
|
| 1713 | + * @param string $var The string to apply the filter to. |
|
| 1714 | + */ |
|
| 1715 | + $cat_description = apply_filters('the_content', $saved_data);
|
|
| 1716 | 1716 | |
| 1717 | 1717 | |
| 1718 | - if ( false !== $filter_priority ) {
|
|
| 1719 | - add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1720 | - } |
|
| 1718 | + if ( false !== $filter_priority ) {
|
|
| 1719 | + add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1720 | + } |
|
| 1721 | 1721 | |
| 1722 | - if ($cat_description) {
|
|
| 1723 | - ?> |
|
| 1722 | + if ($cat_description) {
|
|
| 1723 | + ?> |
|
| 1724 | 1724 | |
| 1725 | 1725 | <div class="term_description"><?php echo $cat_description;?></div> <?php |
| 1726 | - } |
|
| 1726 | + } |
|
| 1727 | 1727 | |
| 1728 | - } |
|
| 1728 | + } |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | // action for adding the listings page top widget area |
@@ -1744,11 +1744,11 @@ discard block |
||
| 1744 | 1744 | */ |
| 1745 | 1745 | function geodir_action_geodir_sidebar_listings_top() |
| 1746 | 1746 | {
|
| 1747 | - if (get_option('geodir_show_listing_top_section')) { ?>
|
|
| 1747 | + if (get_option('geodir_show_listing_top_section')) { ?>
|
|
| 1748 | 1748 | <div |
| 1749 | 1749 | class="<?php |
| 1750 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1751 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_top'); ?>">
|
|
| 1750 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1751 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_top'); ?>">
|
|
| 1752 | 1752 | <?php dynamic_sidebar('geodir_listing_top'); ?>
|
| 1753 | 1753 | </div><!-- clearfix ends here--> |
| 1754 | 1754 | <?php } |
@@ -1771,35 +1771,35 @@ discard block |
||
| 1771 | 1771 | */ |
| 1772 | 1772 | function geodir_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '') |
| 1773 | 1773 | {
|
| 1774 | - if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
|
|
| 1775 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1776 | - } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
|
|
| 1777 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1778 | - } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
|
|
| 1779 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1780 | - } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
|
|
| 1781 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1782 | - } else {
|
|
| 1783 | - $width_css = ''; |
|
| 1784 | - } |
|
| 1785 | - |
|
| 1786 | - $tc = get_option('theme_compatibility_setting');
|
|
| 1787 | - if (!empty($tc['geodir_sidebar_left_open_replace'])) {
|
|
| 1788 | - $text = $tc['geodir_sidebar_left_open_replace']; |
|
| 1789 | - } else {
|
|
| 1790 | - $text = '<aside id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>'; |
|
| 1791 | - } |
|
| 1792 | - |
|
| 1793 | - if (!empty($tc['geodir_sidebar_left_open_id'])) {
|
|
| 1794 | - $id = $tc['geodir_sidebar_left_open_id']; |
|
| 1795 | - } |
|
| 1796 | - if (!empty($tc['geodir_sidebar_left_open_class'])) {
|
|
| 1797 | - $class = $tc['geodir_sidebar_left_open_class']; |
|
| 1798 | - } |
|
| 1799 | - |
|
| 1800 | - $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
|
|
| 1801 | - |
|
| 1802 | - echo $text; |
|
| 1774 | + if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
|
|
| 1775 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 1776 | + } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
|
|
| 1777 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 1778 | + } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
|
|
| 1779 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 1780 | + } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
|
|
| 1781 | + $width_css = 'style="width:' . $width . '%;"'; |
|
| 1782 | + } else {
|
|
| 1783 | + $width_css = ''; |
|
| 1784 | + } |
|
| 1785 | + |
|
| 1786 | + $tc = get_option('theme_compatibility_setting');
|
|
| 1787 | + if (!empty($tc['geodir_sidebar_left_open_replace'])) {
|
|
| 1788 | + $text = $tc['geodir_sidebar_left_open_replace']; |
|
| 1789 | + } else {
|
|
| 1790 | + $text = '<aside id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>'; |
|
| 1791 | + } |
|
| 1792 | + |
|
| 1793 | + if (!empty($tc['geodir_sidebar_left_open_id'])) {
|
|
| 1794 | + $id = $tc['geodir_sidebar_left_open_id']; |
|
| 1795 | + } |
|
| 1796 | + if (!empty($tc['geodir_sidebar_left_open_class'])) {
|
|
| 1797 | + $class = $tc['geodir_sidebar_left_open_class']; |
|
| 1798 | + } |
|
| 1799 | + |
|
| 1800 | + $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
|
|
| 1801 | + |
|
| 1802 | + echo $text; |
|
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | 1805 | // action for adding the primary div closing tag |
@@ -1815,13 +1815,13 @@ discard block |
||
| 1815 | 1815 | */ |
| 1816 | 1816 | function geodir_action_sidebar_left_close($type = '') |
| 1817 | 1817 | {
|
| 1818 | - $tc = get_option('theme_compatibility_setting');
|
|
| 1819 | - if (!empty($tc['geodir_sidebar_left_close_replace'])) {
|
|
| 1820 | - $text = $tc['geodir_sidebar_left_close_replace']; |
|
| 1821 | - } else {
|
|
| 1822 | - $text = '</aside><!-- sidebar ends here-->'; |
|
| 1823 | - } |
|
| 1824 | - echo $text; |
|
| 1818 | + $tc = get_option('theme_compatibility_setting');
|
|
| 1819 | + if (!empty($tc['geodir_sidebar_left_close_replace'])) {
|
|
| 1820 | + $text = $tc['geodir_sidebar_left_close_replace']; |
|
| 1821 | + } else {
|
|
| 1822 | + $text = '</aside><!-- sidebar ends here-->'; |
|
| 1823 | + } |
|
| 1824 | + echo $text; |
|
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | /** |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | */ |
| 1835 | 1835 | function geodir_listing_left_section() |
| 1836 | 1836 | {
|
| 1837 | - if (get_option('geodir_show_listing_left_section')) { ?>
|
|
| 1837 | + if (get_option('geodir_show_listing_left_section')) { ?>
|
|
| 1838 | 1838 | <div class="geodir-content-left geodir-sidebar-wrap"> |
| 1839 | 1839 | <?php dynamic_sidebar('geodir_listing_left_sidebar'); ?>
|
| 1840 | 1840 | </div><!-- end geodir-content-left --> |
@@ -1852,20 +1852,20 @@ discard block |
||
| 1852 | 1852 | */ |
| 1853 | 1853 | function geodir_action_listings_sidebar_left() |
| 1854 | 1854 | {
|
| 1855 | - if (get_option('geodir_show_listing_left_section')) {
|
|
| 1856 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1857 | - do_action('geodir_sidebar_left_open', 'listings-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'https://schema.org/WPSideBar');
|
|
| 1858 | - /** |
|
| 1859 | - * Calls the listings page (category) left sidebar content. |
|
| 1860 | - * |
|
| 1861 | - * All the content for the listings page left sidebar is added via this hook. |
|
| 1862 | - * |
|
| 1863 | - * @since 1.0.0 |
|
| 1864 | - */ |
|
| 1865 | - do_action('geodir_listings_sidebar_left_inside');
|
|
| 1866 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1867 | - do_action('geodir_sidebar_left_close', 'listings-page');
|
|
| 1868 | - } |
|
| 1855 | + if (get_option('geodir_show_listing_left_section')) {
|
|
| 1856 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1857 | + do_action('geodir_sidebar_left_open', 'listings-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'https://schema.org/WPSideBar');
|
|
| 1858 | + /** |
|
| 1859 | + * Calls the listings page (category) left sidebar content. |
|
| 1860 | + * |
|
| 1861 | + * All the content for the listings page left sidebar is added via this hook. |
|
| 1862 | + * |
|
| 1863 | + * @since 1.0.0 |
|
| 1864 | + */ |
|
| 1865 | + do_action('geodir_listings_sidebar_left_inside');
|
|
| 1866 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1867 | + do_action('geodir_sidebar_left_close', 'listings-page');
|
|
| 1868 | + } |
|
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
@@ -1878,7 +1878,7 @@ discard block |
||
| 1878 | 1878 | */ |
| 1879 | 1879 | function geodir_listing_right_section() |
| 1880 | 1880 | {
|
| 1881 | - if (get_option('geodir_show_listing_right_section')) { ?>
|
|
| 1881 | + if (get_option('geodir_show_listing_right_section')) { ?>
|
|
| 1882 | 1882 | <div class="geodir-content-right geodir-sidebar-wrap"> |
| 1883 | 1883 | <?php dynamic_sidebar('geodir_listing_right_sidebar'); ?>
|
| 1884 | 1884 | </div><!-- end geodir-content-right --> |
@@ -1896,20 +1896,20 @@ discard block |
||
| 1896 | 1896 | */ |
| 1897 | 1897 | function geodir_action_listings_sidebar_right() |
| 1898 | 1898 | {
|
| 1899 | - if (get_option('geodir_show_listing_right_section')) {
|
|
| 1900 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1901 | - do_action('geodir_sidebar_right_open', 'listings-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 1902 | - /** |
|
| 1903 | - * Calls the listings page (category) right sidebar content. |
|
| 1904 | - * |
|
| 1905 | - * All the content for the listings page right sidebar is added via this hook. |
|
| 1906 | - * |
|
| 1907 | - * @since 1.0.0 |
|
| 1908 | - */ |
|
| 1909 | - do_action('geodir_listings_sidebar_right_inside');
|
|
| 1910 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1911 | - do_action('geodir_sidebar_right_close', 'listings-page');
|
|
| 1912 | - } |
|
| 1899 | + if (get_option('geodir_show_listing_right_section')) {
|
|
| 1900 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1901 | + do_action('geodir_sidebar_right_open', 'listings-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 1902 | + /** |
|
| 1903 | + * Calls the listings page (category) right sidebar content. |
|
| 1904 | + * |
|
| 1905 | + * All the content for the listings page right sidebar is added via this hook. |
|
| 1906 | + * |
|
| 1907 | + * @since 1.0.0 |
|
| 1908 | + */ |
|
| 1909 | + do_action('geodir_listings_sidebar_right_inside');
|
|
| 1910 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1911 | + do_action('geodir_sidebar_right_close', 'listings-page');
|
|
| 1912 | + } |
|
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | 1915 | |
@@ -1926,23 +1926,23 @@ discard block |
||
| 1926 | 1926 | */ |
| 1927 | 1927 | function geodir_action_main_content_open($type = '', $id = '', $class = '') |
| 1928 | 1928 | {
|
| 1929 | - $tc = get_option('theme_compatibility_setting');
|
|
| 1930 | - if (!empty($tc['geodir_main_content_open_replace'])) {
|
|
| 1931 | - $text = $tc['geodir_main_content_open_replace']; |
|
| 1932 | - } else {
|
|
| 1933 | - $text = '<main id="[id]" class="[class]" role="main">'; |
|
| 1934 | - } |
|
| 1929 | + $tc = get_option('theme_compatibility_setting');
|
|
| 1930 | + if (!empty($tc['geodir_main_content_open_replace'])) {
|
|
| 1931 | + $text = $tc['geodir_main_content_open_replace']; |
|
| 1932 | + } else {
|
|
| 1933 | + $text = '<main id="[id]" class="[class]" role="main">'; |
|
| 1934 | + } |
|
| 1935 | 1935 | |
| 1936 | - if (!empty($tc['geodir_main_content_open_id'])) {
|
|
| 1937 | - $id = $tc['geodir_main_content_open_id']; |
|
| 1938 | - } |
|
| 1939 | - if (!empty($tc['geodir_main_content_open_class'])) {
|
|
| 1940 | - $class = $tc['geodir_main_content_open_class']; |
|
| 1941 | - } |
|
| 1936 | + if (!empty($tc['geodir_main_content_open_id'])) {
|
|
| 1937 | + $id = $tc['geodir_main_content_open_id']; |
|
| 1938 | + } |
|
| 1939 | + if (!empty($tc['geodir_main_content_open_class'])) {
|
|
| 1940 | + $class = $tc['geodir_main_content_open_class']; |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
|
|
| 1943 | + $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
|
|
| 1944 | 1944 | |
| 1945 | - echo $text; |
|
| 1945 | + echo $text; |
|
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | // action for adding the primary div closing tag |
@@ -1955,13 +1955,13 @@ discard block |
||
| 1955 | 1955 | */ |
| 1956 | 1956 | function geodir_action_main_content_close() |
| 1957 | 1957 | {
|
| 1958 | - $tc = get_option('theme_compatibility_setting');
|
|
| 1959 | - if (!empty($tc['geodir_main_content_close_replace'])) {
|
|
| 1960 | - $text = $tc['geodir_main_content_close_replace']; |
|
| 1961 | - } else {
|
|
| 1962 | - $text = '</main><!-- main ends here-->'; |
|
| 1963 | - } |
|
| 1964 | - echo $text; |
|
| 1958 | + $tc = get_option('theme_compatibility_setting');
|
|
| 1959 | + if (!empty($tc['geodir_main_content_close_replace'])) {
|
|
| 1960 | + $text = $tc['geodir_main_content_close_replace']; |
|
| 1961 | + } else {
|
|
| 1962 | + $text = '</main><!-- main ends here-->'; |
|
| 1963 | + } |
|
| 1964 | + echo $text; |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | /** |
@@ -1973,14 +1973,14 @@ discard block |
||
| 1973 | 1973 | */ |
| 1974 | 1974 | function geodir_action_listings_content_inside() |
| 1975 | 1975 | {
|
| 1976 | - global $gridview_columns; |
|
| 1977 | - $listing_view = get_option('geodir_listing_view');
|
|
| 1978 | - if (strstr($listing_view, 'gridview')) {
|
|
| 1979 | - $gridview_columns = $listing_view; |
|
| 1980 | - $listing_view_exp = explode('_', $listing_view);
|
|
| 1981 | - $listing_view = $listing_view_exp[0]; |
|
| 1982 | - } |
|
| 1983 | - geodir_get_template_part('listing', 'listview');
|
|
| 1976 | + global $gridview_columns; |
|
| 1977 | + $listing_view = get_option('geodir_listing_view');
|
|
| 1978 | + if (strstr($listing_view, 'gridview')) {
|
|
| 1979 | + $gridview_columns = $listing_view; |
|
| 1980 | + $listing_view_exp = explode('_', $listing_view);
|
|
| 1981 | + $listing_view = $listing_view_exp[0]; |
|
| 1982 | + } |
|
| 1983 | + geodir_get_template_part('listing', 'listview');
|
|
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | 1986 | add_action('geodir_listings_content_inside', 'geodir_action_listings_content_inside', 10);
|
@@ -1996,47 +1996,47 @@ discard block |
||
| 1996 | 1996 | */ |
| 1997 | 1997 | function geodir_action_listings_content() |
| 1998 | 1998 | {
|
| 1999 | - /** |
|
| 2000 | - * This is used to add HTML opening wrappers to the main content of most pages including listings, author, search, home etc. |
|
| 2001 | - * |
|
| 2002 | - * @since 1.0.0 |
|
| 2003 | - * @param string $type The page type. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 2004 | - * @param string $id The id for the div. Usually 'geodir-main-content'. |
|
| 2005 | - * @param string $class The class for the div. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 2006 | - * @see 'geodir_main_content_close' Where the oposing closing tag is added. |
|
| 2007 | - */ |
|
| 2008 | - do_action('geodir_main_content_open', 'listings-page', 'geodir-main-content', 'listings-page');
|
|
| 2009 | - $extra_class = apply_filters('geodir_before_listing_wrapper_extra_class', '', 'listings-page');
|
|
| 2010 | - echo '<div class="clearfix '.$extra_class.'">'; |
|
| 2011 | - /** |
|
| 2012 | - * Called before the listings page content, inside the outer wrapper. Used on listings pages and search and author pages. |
|
| 2013 | - * |
|
| 2014 | - * @since 1.0.0 |
|
| 2015 | - */ |
|
| 2016 | - do_action('geodir_before_listing');
|
|
| 2017 | - echo '</div>'; |
|
| 2018 | - |
|
| 2019 | - /** |
|
| 2020 | - * This actions calls the listings list content. Used on listings pages and search and author pages. |
|
| 2021 | - * |
|
| 2022 | - * @since 1.0.0 |
|
| 2023 | - */ |
|
| 2024 | - do_action('geodir_listings_content_inside');
|
|
| 2025 | - |
|
| 2026 | - /** |
|
| 2027 | - * Called after the listings content, inside the outer wrapper HTML. Used on listings pages and search and author pages. |
|
| 2028 | - * |
|
| 2029 | - * @since 1.0.0 |
|
| 2030 | - */ |
|
| 2031 | - do_action('geodir_after_listing');
|
|
| 2032 | - |
|
| 2033 | - /** |
|
| 2034 | - * This is used to add HTML closing wrappers to the main content of most pages including listings, author, search, home etc. |
|
| 2035 | - * |
|
| 2036 | - * @since 1.0.0 |
|
| 2037 | - * @see 'geodir_main_content_open' Where the oposing opening tag is added. |
|
| 2038 | - */ |
|
| 2039 | - do_action('geodir_main_content_close', 'listings-page');
|
|
| 1999 | + /** |
|
| 2000 | + * This is used to add HTML opening wrappers to the main content of most pages including listings, author, search, home etc. |
|
| 2001 | + * |
|
| 2002 | + * @since 1.0.0 |
|
| 2003 | + * @param string $type The page type. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 2004 | + * @param string $id The id for the div. Usually 'geodir-main-content'. |
|
| 2005 | + * @param string $class The class for the div. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'. |
|
| 2006 | + * @see 'geodir_main_content_close' Where the oposing closing tag is added. |
|
| 2007 | + */ |
|
| 2008 | + do_action('geodir_main_content_open', 'listings-page', 'geodir-main-content', 'listings-page');
|
|
| 2009 | + $extra_class = apply_filters('geodir_before_listing_wrapper_extra_class', '', 'listings-page');
|
|
| 2010 | + echo '<div class="clearfix '.$extra_class.'">'; |
|
| 2011 | + /** |
|
| 2012 | + * Called before the listings page content, inside the outer wrapper. Used on listings pages and search and author pages. |
|
| 2013 | + * |
|
| 2014 | + * @since 1.0.0 |
|
| 2015 | + */ |
|
| 2016 | + do_action('geodir_before_listing');
|
|
| 2017 | + echo '</div>'; |
|
| 2018 | + |
|
| 2019 | + /** |
|
| 2020 | + * This actions calls the listings list content. Used on listings pages and search and author pages. |
|
| 2021 | + * |
|
| 2022 | + * @since 1.0.0 |
|
| 2023 | + */ |
|
| 2024 | + do_action('geodir_listings_content_inside');
|
|
| 2025 | + |
|
| 2026 | + /** |
|
| 2027 | + * Called after the listings content, inside the outer wrapper HTML. Used on listings pages and search and author pages. |
|
| 2028 | + * |
|
| 2029 | + * @since 1.0.0 |
|
| 2030 | + */ |
|
| 2031 | + do_action('geodir_after_listing');
|
|
| 2032 | + |
|
| 2033 | + /** |
|
| 2034 | + * This is used to add HTML closing wrappers to the main content of most pages including listings, author, search, home etc. |
|
| 2035 | + * |
|
| 2036 | + * @since 1.0.0 |
|
| 2037 | + * @see 'geodir_main_content_open' Where the oposing opening tag is added. |
|
| 2038 | + */ |
|
| 2039 | + do_action('geodir_main_content_close', 'listings-page');
|
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | |
@@ -2051,10 +2051,10 @@ discard block |
||
| 2051 | 2051 | */ |
| 2052 | 2052 | function geodir_action_sidebar_listings_bottom_section() |
| 2053 | 2053 | {
|
| 2054 | - if (get_option('geodir_show_listing_bottom_section')) { ?>
|
|
| 2054 | + if (get_option('geodir_show_listing_bottom_section')) { ?>
|
|
| 2055 | 2055 | <div class="<?php |
| 2056 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2057 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_bottom'); ?>">
|
|
| 2056 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2057 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_bottom'); ?>">
|
|
| 2058 | 2058 | <?php dynamic_sidebar('geodir_listing_bottom'); ?>
|
| 2059 | 2059 | </div><!-- clearfix ends here--> |
| 2060 | 2060 | <?php } |
@@ -2074,38 +2074,38 @@ discard block |
||
| 2074 | 2074 | */ |
| 2075 | 2075 | function geodir_action_add_listing_page_title() |
| 2076 | 2076 | {
|
| 2077 | - if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '') |
|
| 2078 | - $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2079 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2080 | - $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 2081 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2082 | - $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 2083 | - |
|
| 2084 | - $title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
|
|
| 2085 | - |
|
| 2086 | - if(geodir_is_page('add-listing')){
|
|
| 2087 | - $gd_page = 'add-listing'; |
|
| 2088 | - if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
|
|
| 2089 | - $title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
|
|
| 2090 | - }elseif(isset($listing_type)){
|
|
| 2091 | - $title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
|
|
| 2092 | - } |
|
| 2077 | + if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '') |
|
| 2078 | + $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2079 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2080 | + $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 2081 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2082 | + $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 2083 | + |
|
| 2084 | + $title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
|
|
| 2085 | + |
|
| 2086 | + if(geodir_is_page('add-listing')){
|
|
| 2087 | + $gd_page = 'add-listing'; |
|
| 2088 | + if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
|
|
| 2089 | + $title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
|
|
| 2090 | + }elseif(isset($listing_type)){
|
|
| 2091 | + $title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
|
|
| 2092 | + } |
|
| 2093 | 2093 | |
| 2094 | - } |
|
| 2094 | + } |
|
| 2095 | 2095 | |
| 2096 | 2096 | |
| 2097 | - /** |
|
| 2098 | - * Filter page title to replace variables. |
|
| 2099 | - * |
|
| 2100 | - * @since 1.5.4 |
|
| 2101 | - * @param string $title The page title including variables. |
|
| 2102 | - * @param string $gd_page The GeoDirectory page type if any. |
|
| 2103 | - */ |
|
| 2104 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2097 | + /** |
|
| 2098 | + * Filter page title to replace variables. |
|
| 2099 | + * |
|
| 2100 | + * @since 1.5.4 |
|
| 2101 | + * @param string $title The page title including variables. |
|
| 2102 | + * @param string $gd_page The GeoDirectory page type if any. |
|
| 2103 | + */ |
|
| 2104 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2105 | 2105 | |
| 2106 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">'; |
|
| 2107 | - echo $title; |
|
| 2108 | - echo '</h1></header>'; |
|
| 2106 | + echo '<header class="' . $class_header . '"><h1 class="' . $class . '">'; |
|
| 2107 | + echo $title; |
|
| 2108 | + echo '</h1></header>'; |
|
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | add_action('geodir_add_listing_page_mandatory', 'geodir_action_add_listing_page_mandatory', 10);
|
@@ -2136,61 +2136,61 @@ discard block |
||
| 2136 | 2136 | */ |
| 2137 | 2137 | function geodir_action_add_listing_form() |
| 2138 | 2138 | {
|
| 2139 | - global $cat_display, $post_cat, $current_user, $gd_session; |
|
| 2140 | - $page_id = get_the_ID(); |
|
| 2141 | - $post = ''; |
|
| 2142 | - $title = ''; |
|
| 2143 | - $desc = ''; |
|
| 2144 | - $kw_tags = ''; |
|
| 2145 | - $required_msg = ''; |
|
| 2146 | - $submit_button = ''; |
|
| 2147 | - |
|
| 2148 | - $ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add'; |
|
| 2149 | - |
|
| 2150 | - $thumb_img_arr = array(); |
|
| 2151 | - $curImages = ''; |
|
| 2152 | - |
|
| 2153 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 2154 | - global $post; |
|
| 2155 | - $post = (object)$gd_session->get('listing');
|
|
| 2156 | - $listing_type = $post->listing_type; |
|
| 2157 | - $title = $post->post_title; |
|
| 2158 | - $desc = $post->post_desc; |
|
| 2159 | - $post_cat = $post->post_category; |
|
| 2160 | - |
|
| 2161 | - $kw_tags = $post->post_tags; |
|
| 2162 | - $curImages = isset($post->post_images) ? $post->post_images : ''; |
|
| 2163 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2164 | - global $post, $post_images; |
|
| 2165 | - |
|
| 2166 | - $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 2167 | - $thumb_img_arr = geodir_get_images($post->ID); |
|
| 2168 | - if ($thumb_img_arr) {
|
|
| 2169 | - foreach ($thumb_img_arr as $post_img) {
|
|
| 2170 | - $curImages .= $post_img->src . ','; |
|
| 2171 | - } |
|
| 2172 | - } |
|
| 2139 | + global $cat_display, $post_cat, $current_user, $gd_session; |
|
| 2140 | + $page_id = get_the_ID(); |
|
| 2141 | + $post = ''; |
|
| 2142 | + $title = ''; |
|
| 2143 | + $desc = ''; |
|
| 2144 | + $kw_tags = ''; |
|
| 2145 | + $required_msg = ''; |
|
| 2146 | + $submit_button = ''; |
|
| 2147 | + |
|
| 2148 | + $ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add'; |
|
| 2149 | + |
|
| 2150 | + $thumb_img_arr = array(); |
|
| 2151 | + $curImages = ''; |
|
| 2152 | + |
|
| 2153 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 2154 | + global $post; |
|
| 2155 | + $post = (object)$gd_session->get('listing');
|
|
| 2156 | + $listing_type = $post->listing_type; |
|
| 2157 | + $title = $post->post_title; |
|
| 2158 | + $desc = $post->post_desc; |
|
| 2159 | + $post_cat = $post->post_category; |
|
| 2160 | + |
|
| 2161 | + $kw_tags = $post->post_tags; |
|
| 2162 | + $curImages = isset($post->post_images) ? $post->post_images : ''; |
|
| 2163 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2164 | + global $post, $post_images; |
|
| 2165 | + |
|
| 2166 | + $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 2167 | + $thumb_img_arr = geodir_get_images($post->ID); |
|
| 2168 | + if ($thumb_img_arr) {
|
|
| 2169 | + foreach ($thumb_img_arr as $post_img) {
|
|
| 2170 | + $curImages .= $post_img->src . ','; |
|
| 2171 | + } |
|
| 2172 | + } |
|
| 2173 | 2173 | |
| 2174 | - $listing_type = $post->post_type; |
|
| 2175 | - $title = $post->post_title; |
|
| 2176 | - $desc = $post->post_content; |
|
| 2177 | - $kw_tags = $post->post_tags; |
|
| 2178 | - $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
|
|
| 2179 | - } else {
|
|
| 2180 | - $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2181 | - } |
|
| 2174 | + $listing_type = $post->post_type; |
|
| 2175 | + $title = $post->post_title; |
|
| 2176 | + $desc = $post->post_content; |
|
| 2177 | + $kw_tags = $post->post_tags; |
|
| 2178 | + $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
|
|
| 2179 | + } else {
|
|
| 2180 | + $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2181 | + } |
|
| 2182 | 2182 | |
| 2183 | - if ($current_user->ID != '0') {
|
|
| 2184 | - $user_login = true; |
|
| 2185 | - } |
|
| 2183 | + if ($current_user->ID != '0') {
|
|
| 2184 | + $user_login = true; |
|
| 2185 | + } |
|
| 2186 | 2186 | |
| 2187 | - $post_type_info = geodir_get_posttype_info($listing_type); |
|
| 2187 | + $post_type_info = geodir_get_posttype_info($listing_type); |
|
| 2188 | 2188 | |
| 2189 | - $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
|
|
| 2189 | + $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
|
|
| 2190 | 2190 | |
| 2191 | - $package_info = array(); |
|
| 2192 | - $package_info = geodir_post_package_info($package_info, $post); |
|
| 2193 | - ?> |
|
| 2191 | + $package_info = array(); |
|
| 2192 | + $package_info = geodir_post_package_info($package_info, $post); |
|
| 2193 | + ?> |
|
| 2194 | 2194 | <form name="propertyform" id="propertyform" action="<?php echo get_page_link(geodir_preview_page_id());?>" method="post" enctype="multipart/form-data"> |
| 2195 | 2195 | <input type="hidden" name="preview" value="<?php echo sanitize_text_field($listing_type);?>"/> |
| 2196 | 2196 | <input type="hidden" name="listing_type" value="<?php echo sanitize_text_field($listing_type);?>"/> |
@@ -2201,114 +2201,114 @@ discard block |
||
| 2201 | 2201 | <?php } if (isset($_REQUEST['backandedit'])) { ?>
|
| 2202 | 2202 | <input type="hidden" name="backandedit" value="<?php echo sanitize_text_field($_REQUEST['backandedit']);?>"/> |
| 2203 | 2203 | <?php |
| 2204 | - } |
|
| 2205 | - /** |
|
| 2206 | - * Called at the very top of the add listing page form for frontend. |
|
| 2207 | - * |
|
| 2208 | - * This is called just before the "Enter Listing Details" text. |
|
| 2209 | - * |
|
| 2210 | - * @since 1.0.0 |
|
| 2211 | - */ |
|
| 2212 | - do_action('geodir_before_detail_fields');
|
|
| 2213 | - ?> |
|
| 2204 | + } |
|
| 2205 | + /** |
|
| 2206 | + * Called at the very top of the add listing page form for frontend. |
|
| 2207 | + * |
|
| 2208 | + * This is called just before the "Enter Listing Details" text. |
|
| 2209 | + * |
|
| 2210 | + * @since 1.0.0 |
|
| 2211 | + */ |
|
| 2212 | + do_action('geodir_before_detail_fields');
|
|
| 2213 | + ?> |
|
| 2214 | 2214 | <h5 id="geodir_fieldset_details" class="geodir-fieldset-row" gd-fieldset="details"><?php echo LISTING_DETAILS_TEXT;?></h5> |
| 2215 | 2215 | <?php |
| 2216 | - /** |
|
| 2217 | - * Called at the top of the add listing page form for frontend. |
|
| 2218 | - * |
|
| 2219 | - * This is called after the "Enter Listing Details" text. |
|
| 2220 | - * |
|
| 2221 | - * @since 1.0.0 |
|
| 2222 | - */ |
|
| 2223 | - do_action('geodir_before_main_form_fields');
|
|
| 2224 | - ?> |
|
| 2216 | + /** |
|
| 2217 | + * Called at the top of the add listing page form for frontend. |
|
| 2218 | + * |
|
| 2219 | + * This is called after the "Enter Listing Details" text. |
|
| 2220 | + * |
|
| 2221 | + * @since 1.0.0 |
|
| 2222 | + */ |
|
| 2223 | + do_action('geodir_before_main_form_fields');
|
|
| 2224 | + ?> |
|
| 2225 | 2225 | <div id="geodir_post_title_row" class="required_field geodir_form_row clearfix gd-fieldset-details"> |
| 2226 | 2226 | <label><?php |
| 2227 | - /** |
|
| 2228 | - * Filter the add listing page title input label. |
|
| 2229 | - * |
|
| 2230 | - * @since 1.6.11 |
|
| 2231 | - * @param string $title The title to be output. |
|
| 2232 | - * @param string $cpt_singular_name The singular title of the curent CPT. |
|
| 2233 | - * @param string $listing_type The CPT being requested. ie: gd_place. |
|
| 2234 | - */ |
|
| 2235 | - echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
|
|
| 2227 | + /** |
|
| 2228 | + * Filter the add listing page title input label. |
|
| 2229 | + * |
|
| 2230 | + * @since 1.6.11 |
|
| 2231 | + * @param string $title The title to be output. |
|
| 2232 | + * @param string $cpt_singular_name The singular title of the curent CPT. |
|
| 2233 | + * @param string $listing_type The CPT being requested. ie: gd_place. |
|
| 2234 | + */ |
|
| 2235 | + echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
|
|
| 2236 | 2236 | <input type="text" field_type="text" name="post_title" id="post_title" class="geodir_textfield" |
| 2237 | 2237 | value="<?php echo esc_attr(stripslashes($title)); ?>"/> |
| 2238 | 2238 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory');?></span> |
| 2239 | 2239 | </div> |
| 2240 | 2240 | <?php |
| 2241 | - $show_editor = get_option('geodir_tiny_editor_on_add_listing');
|
|
| 2242 | - $show_editor = !empty($show_editor) && in_array($listing_type, $show_editor) ? true : false; |
|
| 2243 | - /** |
|
| 2244 | - * Filter whether to show or don't show the editor. |
|
| 2245 | - * |
|
| 2246 | - * @since 1.6.16 |
|
| 2247 | - * @param bool $show_editor If true the editor will be available for description field. |
|
| 2248 | - * @param object $package_info The listing package. |
|
| 2249 | - * @param string $listing_type The current post type. |
|
| 2250 | - * @param object $post The current post object. |
|
| 2251 | - */ |
|
| 2252 | - $show_editor = apply_filters('geodir_description_field_show_editor', $show_editor, $package_info, $listing_type, $post);
|
|
| 2253 | - |
|
| 2254 | - $desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc)); |
|
| 2255 | - $desc_limit = ''; |
|
| 2256 | - /** |
|
| 2257 | - * Filter the add listing description field character limit number. |
|
| 2258 | - * |
|
| 2259 | - * @since 1.0.0 |
|
| 2260 | - * @param int $desc_limit The amount of characters to limit the description to. |
|
| 2261 | - */ |
|
| 2262 | - $desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
|
|
| 2263 | - /** |
|
| 2264 | - * Filter the add listing description field text. |
|
| 2265 | - * |
|
| 2266 | - * @since 1.0.0 |
|
| 2267 | - * @param string $desc The text for the description field. |
|
| 2268 | - * @param int $desc_limit The character limit number if any. |
|
| 2269 | - */ |
|
| 2270 | - $desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
|
|
| 2271 | - $desc_limit_msg = ''; |
|
| 2272 | - /** |
|
| 2273 | - * Filter the add listing description limit message. |
|
| 2274 | - * |
|
| 2275 | - * This is the message shown if there is a limit applied to the amount of characters the description can use. |
|
| 2276 | - * |
|
| 2277 | - * @since 1.0.0 |
|
| 2278 | - * @param string $desc_limit_msg The limit message string if any. |
|
| 2279 | - * @param int $desc_limit The character limit numer if any. |
|
| 2280 | - */ |
|
| 2281 | - $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
|
|
| 2241 | + $show_editor = get_option('geodir_tiny_editor_on_add_listing');
|
|
| 2242 | + $show_editor = !empty($show_editor) && in_array($listing_type, $show_editor) ? true : false; |
|
| 2243 | + /** |
|
| 2244 | + * Filter whether to show or don't show the editor. |
|
| 2245 | + * |
|
| 2246 | + * @since 1.6.16 |
|
| 2247 | + * @param bool $show_editor If true the editor will be available for description field. |
|
| 2248 | + * @param object $package_info The listing package. |
|
| 2249 | + * @param string $listing_type The current post type. |
|
| 2250 | + * @param object $post The current post object. |
|
| 2251 | + */ |
|
| 2252 | + $show_editor = apply_filters('geodir_description_field_show_editor', $show_editor, $package_info, $listing_type, $post);
|
|
| 2253 | + |
|
| 2254 | + $desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc)); |
|
| 2255 | + $desc_limit = ''; |
|
| 2256 | + /** |
|
| 2257 | + * Filter the add listing description field character limit number. |
|
| 2258 | + * |
|
| 2259 | + * @since 1.0.0 |
|
| 2260 | + * @param int $desc_limit The amount of characters to limit the description to. |
|
| 2261 | + */ |
|
| 2262 | + $desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
|
|
| 2263 | + /** |
|
| 2264 | + * Filter the add listing description field text. |
|
| 2265 | + * |
|
| 2266 | + * @since 1.0.0 |
|
| 2267 | + * @param string $desc The text for the description field. |
|
| 2268 | + * @param int $desc_limit The character limit number if any. |
|
| 2269 | + */ |
|
| 2270 | + $desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
|
|
| 2271 | + $desc_limit_msg = ''; |
|
| 2272 | + /** |
|
| 2273 | + * Filter the add listing description limit message. |
|
| 2274 | + * |
|
| 2275 | + * This is the message shown if there is a limit applied to the amount of characters the description can use. |
|
| 2276 | + * |
|
| 2277 | + * @since 1.0.0 |
|
| 2278 | + * @param string $desc_limit_msg The limit message string if any. |
|
| 2279 | + * @param int $desc_limit The character limit numer if any. |
|
| 2280 | + */ |
|
| 2281 | + $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
|
|
| 2282 | 2282 | |
| 2283 | - $desc_class = ''; |
|
| 2284 | - if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2285 | - /** |
|
| 2286 | - * Called on the add listing page form for frontend just before the description field. |
|
| 2287 | - * |
|
| 2288 | - * @since 1.0.0 |
|
| 2289 | - */ |
|
| 2290 | - do_action('geodir_before_description_field');
|
|
| 2283 | + $desc_class = ''; |
|
| 2284 | + if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2285 | + /** |
|
| 2286 | + * Called on the add listing page form for frontend just before the description field. |
|
| 2287 | + * |
|
| 2288 | + * @since 1.0.0 |
|
| 2289 | + */ |
|
| 2290 | + do_action('geodir_before_description_field');
|
|
| 2291 | 2291 | |
| 2292 | - $desc_class = ' required_field'; |
|
| 2293 | - } else {
|
|
| 2294 | - $desc_class = ' hidden'; |
|
| 2295 | - } |
|
| 2296 | - ?> |
|
| 2292 | + $desc_class = ' required_field'; |
|
| 2293 | + } else {
|
|
| 2294 | + $desc_class = ' hidden'; |
|
| 2295 | + } |
|
| 2296 | + ?> |
|
| 2297 | 2297 | <div id="geodir_post_desc_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $desc_class;?>"> |
| 2298 | 2298 | <label><?php |
| 2299 | - /** |
|
| 2300 | - * Filter the add listing page description input label. |
|
| 2301 | - * |
|
| 2302 | - * @since 1.6.11 |
|
| 2303 | - * @param string $title The title to be output. |
|
| 2304 | - * @param string $cpt_singular_name The singular title of the curent CPT. |
|
| 2305 | - * @param string $listing_type The CPT being requested. ie: gd_place. |
|
| 2306 | - */ |
|
| 2307 | - echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
|
|
| 2299 | + /** |
|
| 2300 | + * Filter the add listing page description input label. |
|
| 2301 | + * |
|
| 2302 | + * @since 1.6.11 |
|
| 2303 | + * @param string $title The title to be output. |
|
| 2304 | + * @param string $cpt_singular_name The singular title of the curent CPT. |
|
| 2305 | + * @param string $listing_type The CPT being requested. ie: gd_place. |
|
| 2306 | + */ |
|
| 2307 | + echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
|
|
| 2308 | 2308 | <?php |
| 2309 | - if ($show_editor) {
|
|
| 2310 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 2311 | - ?> |
|
| 2309 | + if ($show_editor) {
|
|
| 2310 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 2311 | + ?> |
|
| 2312 | 2312 | <div class="editor" field_id="post_desc" field_type="editor"> |
| 2313 | 2313 | <?php wp_editor($desc, "post_desc", $editor_settings); ?> |
| 2314 | 2314 | </div> |
@@ -2322,56 +2322,56 @@ discard block |
||
| 2322 | 2322 | <span class="geodir_message_error"><?php echo _e($required_msg, 'geodirectory');?></span> |
| 2323 | 2323 | </div> |
| 2324 | 2324 | <?php |
| 2325 | - if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2326 | - /** |
|
| 2327 | - * Called on the add listing page form for frontend just after the description field. |
|
| 2328 | - * |
|
| 2329 | - * @since 1.0.0 |
|
| 2330 | - */ |
|
| 2331 | - do_action('geodir_after_description_field');
|
|
| 2332 | - } |
|
| 2325 | + if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2326 | + /** |
|
| 2327 | + * Called on the add listing page form for frontend just after the description field. |
|
| 2328 | + * |
|
| 2329 | + * @since 1.0.0 |
|
| 2330 | + */ |
|
| 2331 | + do_action('geodir_after_description_field');
|
|
| 2332 | + } |
|
| 2333 | 2333 | |
| 2334 | - $kw_tags = esc_attr(stripslashes($kw_tags)); |
|
| 2335 | - $kw_tags_count = TAGKW_TEXT_COUNT; |
|
| 2336 | - $kw_tags_msg = TAGKW_MSG; |
|
| 2337 | - /** |
|
| 2338 | - * Filter the add listing tags character limit. |
|
| 2339 | - * |
|
| 2340 | - * @since 1.0.0 |
|
| 2341 | - * @param int $kw_tags_count The character count limit if any. |
|
| 2342 | - */ |
|
| 2343 | - $kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
|
|
| 2344 | - /** |
|
| 2345 | - * Filter the add listing tags field value. |
|
| 2346 | - * |
|
| 2347 | - * You can use the $_REQUEST values to check if this is a go back and edit value etc. |
|
| 2348 | - * |
|
| 2349 | - * @since 1.0.0 |
|
| 2350 | - * @param string $kw_tags The tag field value, usually a comma separated list of tags. |
|
| 2351 | - * @param int $kw_tags_count The character count limit if any. |
|
| 2352 | - */ |
|
| 2353 | - $kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
|
|
| 2354 | - /** |
|
| 2355 | - * Filter the add listing tags field message text. |
|
| 2356 | - * |
|
| 2357 | - * @since 1.0.0 |
|
| 2358 | - * @param string $kw_tags_msg The message shown under the field. |
|
| 2359 | - * @param int $kw_tags_count The character count limit if any. |
|
| 2360 | - */ |
|
| 2361 | - $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
|
|
| 2334 | + $kw_tags = esc_attr(stripslashes($kw_tags)); |
|
| 2335 | + $kw_tags_count = TAGKW_TEXT_COUNT; |
|
| 2336 | + $kw_tags_msg = TAGKW_MSG; |
|
| 2337 | + /** |
|
| 2338 | + * Filter the add listing tags character limit. |
|
| 2339 | + * |
|
| 2340 | + * @since 1.0.0 |
|
| 2341 | + * @param int $kw_tags_count The character count limit if any. |
|
| 2342 | + */ |
|
| 2343 | + $kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
|
|
| 2344 | + /** |
|
| 2345 | + * Filter the add listing tags field value. |
|
| 2346 | + * |
|
| 2347 | + * You can use the $_REQUEST values to check if this is a go back and edit value etc. |
|
| 2348 | + * |
|
| 2349 | + * @since 1.0.0 |
|
| 2350 | + * @param string $kw_tags The tag field value, usually a comma separated list of tags. |
|
| 2351 | + * @param int $kw_tags_count The character count limit if any. |
|
| 2352 | + */ |
|
| 2353 | + $kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
|
|
| 2354 | + /** |
|
| 2355 | + * Filter the add listing tags field message text. |
|
| 2356 | + * |
|
| 2357 | + * @since 1.0.0 |
|
| 2358 | + * @param string $kw_tags_msg The message shown under the field. |
|
| 2359 | + * @param int $kw_tags_count The character count limit if any. |
|
| 2360 | + */ |
|
| 2361 | + $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
|
|
| 2362 | 2362 | |
| 2363 | - $tags_class = ''; |
|
| 2364 | - if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2365 | - /** |
|
| 2366 | - * Called on the add listing page form for frontend just before the tags field. |
|
| 2367 | - * |
|
| 2368 | - * @since 1.0.0 |
|
| 2369 | - */ |
|
| 2370 | - do_action('geodir_before_listing_tags_field');
|
|
| 2371 | - } else {
|
|
| 2372 | - $tags_class = ' hidden'; |
|
| 2373 | - } |
|
| 2374 | - ?> |
|
| 2363 | + $tags_class = ''; |
|
| 2364 | + if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2365 | + /** |
|
| 2366 | + * Called on the add listing page form for frontend just before the tags field. |
|
| 2367 | + * |
|
| 2368 | + * @since 1.0.0 |
|
| 2369 | + */ |
|
| 2370 | + do_action('geodir_before_listing_tags_field');
|
|
| 2371 | + } else {
|
|
| 2372 | + $tags_class = ' hidden'; |
|
| 2373 | + } |
|
| 2374 | + ?> |
|
| 2375 | 2375 | <div id="geodir_post_tags_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $tags_class;?>"> |
| 2376 | 2376 | <label><?php echo TAGKW_TEXT; ?></label> |
| 2377 | 2377 | <input name="post_tags" id="post_tags" value="<?php echo $kw_tags; ?>" type="text" class="geodir_textfield" |
@@ -2379,90 +2379,90 @@ discard block |
||
| 2379 | 2379 | <span class="geodir_message_note"><?php echo $kw_tags_msg;?></span> |
| 2380 | 2380 | </div> |
| 2381 | 2381 | <?php |
| 2382 | - if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2383 | - /** |
|
| 2384 | - * Called on the add listing page form for frontend just after the tags field. |
|
| 2385 | - * |
|
| 2386 | - * @since 1.0.0 |
|
| 2387 | - */ |
|
| 2388 | - do_action('geodir_after_listing_tags_field');
|
|
| 2389 | - } |
|
| 2382 | + if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2383 | + /** |
|
| 2384 | + * Called on the add listing page form for frontend just after the tags field. |
|
| 2385 | + * |
|
| 2386 | + * @since 1.0.0 |
|
| 2387 | + */ |
|
| 2388 | + do_action('geodir_after_listing_tags_field');
|
|
| 2389 | + } |
|
| 2390 | 2390 | |
| 2391 | - $package_info = array(); |
|
| 2392 | - $package_info = geodir_post_package_info($package_info, $post); |
|
| 2391 | + $package_info = array(); |
|
| 2392 | + $package_info = geodir_post_package_info($package_info, $post); |
|
| 2393 | 2393 | |
| 2394 | - geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type); |
|
| 2394 | + geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type); |
|
| 2395 | 2395 | |
| 2396 | - // adjust values here |
|
| 2397 | - $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls |
|
| 2396 | + // adjust values here |
|
| 2397 | + $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls |
|
| 2398 | 2398 | |
| 2399 | - $multiple = true; // allow multiple files upload |
|
| 2399 | + $multiple = true; // allow multiple files upload |
|
| 2400 | 2400 | |
| 2401 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2401 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2402 | 2402 | |
| 2403 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2403 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2404 | 2404 | |
| 2405 | - $thumb_img_arr = array(); |
|
| 2406 | - $totImg = 0; |
|
| 2407 | - if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
|
|
| 2408 | - $post = (object)$gd_session->get('listing');
|
|
| 2409 | - if (isset($post->post_images)) |
|
| 2410 | - $curImages = trim($post->post_images, ","); |
|
| 2405 | + $thumb_img_arr = array(); |
|
| 2406 | + $totImg = 0; |
|
| 2407 | + if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
|
|
| 2408 | + $post = (object)$gd_session->get('listing');
|
|
| 2409 | + if (isset($post->post_images)) |
|
| 2410 | + $curImages = trim($post->post_images, ","); |
|
| 2411 | 2411 | |
| 2412 | 2412 | |
| 2413 | - if ($curImages != '') {
|
|
| 2414 | - $curImages_array = explode(',', $curImages);
|
|
| 2415 | - $totImg = count($curImages_array); |
|
| 2416 | - } |
|
| 2413 | + if ($curImages != '') {
|
|
| 2414 | + $curImages_array = explode(',', $curImages);
|
|
| 2415 | + $totImg = count($curImages_array); |
|
| 2416 | + } |
|
| 2417 | 2417 | |
| 2418 | - $listing_type = $post->listing_type; |
|
| 2418 | + $listing_type = $post->listing_type; |
|
| 2419 | 2419 | |
| 2420 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2421 | - $post = geodir_get_post_info((int)$_REQUEST['pid']); |
|
| 2422 | - $listing_type = $post->post_type; |
|
| 2423 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 2420 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2421 | + $post = geodir_get_post_info((int)$_REQUEST['pid']); |
|
| 2422 | + $listing_type = $post->post_type; |
|
| 2423 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 2424 | 2424 | |
| 2425 | - } else {
|
|
| 2426 | - $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2427 | - } |
|
| 2425 | + } else {
|
|
| 2426 | + $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2427 | + } |
|
| 2428 | 2428 | |
| 2429 | 2429 | |
| 2430 | - if (!empty($thumb_img_arr)) {
|
|
| 2431 | - foreach ($thumb_img_arr as $img) {
|
|
| 2432 | - //$curImages = $img->src.","; |
|
| 2433 | - } |
|
| 2434 | - |
|
| 2435 | - $totImg = count((array)$thumb_img_arr); |
|
| 2436 | - } |
|
| 2430 | + if (!empty($thumb_img_arr)) {
|
|
| 2431 | + foreach ($thumb_img_arr as $img) {
|
|
| 2432 | + //$curImages = $img->src.","; |
|
| 2433 | + } |
|
| 2437 | 2434 | |
| 2438 | - if ($curImages != '') |
|
| 2439 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2440 | - else |
|
| 2441 | - $svalue = ''; |
|
| 2442 | - |
|
| 2443 | - $image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0'; |
|
| 2444 | - $show_image_input_box = ($image_limit != '0'); |
|
| 2445 | - /** |
|
| 2446 | - * Filter to be able to show/hide the image upload section of the add listing form. |
|
| 2447 | - * |
|
| 2448 | - * @since 1.0.0 |
|
| 2449 | - * @param bool $show_image_input_box Set true to show. Set false to not show. |
|
| 2450 | - * @param string $listing_type The custom post type slug. |
|
| 2451 | - */ |
|
| 2452 | - $show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
|
|
| 2453 | - if ($show_image_input_box) {
|
|
| 2454 | - ?> |
|
| 2435 | + $totImg = count((array)$thumb_img_arr); |
|
| 2436 | + } |
|
| 2437 | + |
|
| 2438 | + if ($curImages != '') |
|
| 2439 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2440 | + else |
|
| 2441 | + $svalue = ''; |
|
| 2442 | + |
|
| 2443 | + $image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0'; |
|
| 2444 | + $show_image_input_box = ($image_limit != '0'); |
|
| 2445 | + /** |
|
| 2446 | + * Filter to be able to show/hide the image upload section of the add listing form. |
|
| 2447 | + * |
|
| 2448 | + * @since 1.0.0 |
|
| 2449 | + * @param bool $show_image_input_box Set true to show. Set false to not show. |
|
| 2450 | + * @param string $listing_type The custom post type slug. |
|
| 2451 | + */ |
|
| 2452 | + $show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
|
|
| 2453 | + if ($show_image_input_box) {
|
|
| 2454 | + ?> |
|
| 2455 | 2455 | |
| 2456 | 2456 | <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php echo PRO_PHOTO_TEXT;?> |
| 2457 | 2457 | <?php if ($image_limit == 1) {
|
| 2458 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2459 | - } ?> |
|
| 2458 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2459 | + } ?> |
|
| 2460 | 2460 | <?php if ($image_limit > 1) {
|
| 2461 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2462 | - } ?> |
|
| 2461 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2462 | + } ?> |
|
| 2463 | 2463 | <?php if ($image_limit == '') {
|
| 2464 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2465 | - } ?> |
|
| 2464 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2465 | + } ?> |
|
| 2466 | 2466 | </h5> |
| 2467 | 2467 | |
| 2468 | 2468 | <div class="geodir_form_row clearfix" id="<?php echo $id; ?>dropbox" |
@@ -2500,12 +2500,12 @@ discard block |
||
| 2500 | 2500 | <?php } ?> |
| 2501 | 2501 | |
| 2502 | 2502 | <?php |
| 2503 | - /** |
|
| 2504 | - * Called on the add listing page form for frontend just after the image upload field. |
|
| 2505 | - * |
|
| 2506 | - * @since 1.0.0 |
|
| 2507 | - */ |
|
| 2508 | - do_action('geodir_after_main_form_fields');?>
|
|
| 2503 | + /** |
|
| 2504 | + * Called on the add listing page form for frontend just after the image upload field. |
|
| 2505 | + * |
|
| 2506 | + * @since 1.0.0 |
|
| 2507 | + */ |
|
| 2508 | + do_action('geodir_after_main_form_fields');?>
|
|
| 2509 | 2509 | |
| 2510 | 2510 | |
| 2511 | 2511 | <!-- add captcha code --> |
@@ -2534,7 +2534,7 @@ discard block |
||
| 2534 | 2534 | |
| 2535 | 2535 | </form> |
| 2536 | 2536 | <?php |
| 2537 | - wp_reset_query(); |
|
| 2537 | + wp_reset_query(); |
|
| 2538 | 2538 | } |
| 2539 | 2539 | |
| 2540 | 2540 | /** |
@@ -2545,7 +2545,7 @@ discard block |
||
| 2545 | 2545 | */ |
| 2546 | 2546 | function geodir_add_listing_sidebar_widget_area() |
| 2547 | 2547 | {
|
| 2548 | - dynamic_sidebar('geodir_add_listing_sidebar');
|
|
| 2548 | + dynamic_sidebar('geodir_add_listing_sidebar');
|
|
| 2549 | 2549 | } |
| 2550 | 2550 | |
| 2551 | 2551 | add_action('geodir_add_listing_sidebar_inside', 'geodir_add_listing_sidebar_widget_area', 10);
|
@@ -2560,16 +2560,16 @@ discard block |
||
| 2560 | 2560 | */ |
| 2561 | 2561 | function geodir_action_add_listing_sidebar() |
| 2562 | 2562 | {
|
| 2563 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2564 | - do_action('geodir_sidebar_right_open', 'add-listing-page', 'geodir-sidebar', 'geodir-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 2565 | - /** |
|
| 2566 | - * This is used to add the content to the add listing page sidebar. |
|
| 2567 | - * |
|
| 2568 | - * @since 1.0.0 |
|
| 2569 | - */ |
|
| 2570 | - do_action('geodir_add_listing_sidebar_inside');
|
|
| 2571 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2572 | - do_action('geodir_sidebar_right_close', 'details-page');
|
|
| 2563 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2564 | + do_action('geodir_sidebar_right_open', 'add-listing-page', 'geodir-sidebar', 'geodir-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 2565 | + /** |
|
| 2566 | + * This is used to add the content to the add listing page sidebar. |
|
| 2567 | + * |
|
| 2568 | + * @since 1.0.0 |
|
| 2569 | + */ |
|
| 2570 | + do_action('geodir_add_listing_sidebar_inside');
|
|
| 2571 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2572 | + do_action('geodir_sidebar_right_close', 'details-page');
|
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | ############################################### |
@@ -2586,11 +2586,11 @@ discard block |
||
| 2586 | 2586 | */ |
| 2587 | 2587 | function geodir_action_geodir_sidebar_signup_top() |
| 2588 | 2588 | {
|
| 2589 | - ?> |
|
| 2589 | + ?> |
|
| 2590 | 2590 | <div |
| 2591 | 2591 | class="<?php |
| 2592 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2593 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
|
|
| 2592 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2593 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
|
|
| 2594 | 2594 | <?php dynamic_sidebar('Reg/Login Top Section');?>
|
| 2595 | 2595 | </div><!-- clearfix ends here--> |
| 2596 | 2596 | <?php |
@@ -2609,11 +2609,11 @@ discard block |
||
| 2609 | 2609 | function geodir_action_signup_forms() |
| 2610 | 2610 | {
|
| 2611 | 2611 | |
| 2612 | - global $user_login; |
|
| 2612 | + global $user_login; |
|
| 2613 | 2613 | |
| 2614 | - $is_enable_signup = get_option( 'users_can_register' ); |
|
| 2614 | + $is_enable_signup = get_option( 'users_can_register' ); |
|
| 2615 | 2615 | |
| 2616 | - ?> |
|
| 2616 | + ?> |
|
| 2617 | 2617 | <script type="text/javascript"> |
| 2618 | 2618 | <?php if ( $user_login ) { ?>
|
| 2619 | 2619 | setTimeout(function () {
|
@@ -2649,67 +2649,67 @@ discard block |
||
| 2649 | 2649 | <?php } ?> |
| 2650 | 2650 | </script><?php |
| 2651 | 2651 | |
| 2652 | - global $errors; |
|
| 2653 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'claim') |
|
| 2654 | - $errors->add('claim_login', LOGIN_CLAIM);
|
|
| 2655 | - |
|
| 2656 | - if (!empty($errors)) {
|
|
| 2657 | - foreach ($errors as $errorsObj) {
|
|
| 2658 | - foreach ($errorsObj as $key => $val) {
|
|
| 2659 | - for ($i = 0; $i < count($val); $i++) {
|
|
| 2660 | - echo "<div class=error_msg_fix>" . $val[$i] . '</div>'; |
|
| 2661 | - $registration_error_msg = 1; |
|
| 2662 | - } |
|
| 2663 | - } |
|
| 2664 | - } |
|
| 2665 | - } |
|
| 2652 | + global $errors; |
|
| 2653 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'claim') |
|
| 2654 | + $errors->add('claim_login', LOGIN_CLAIM);
|
|
| 2655 | + |
|
| 2656 | + if (!empty($errors)) {
|
|
| 2657 | + foreach ($errors as $errorsObj) {
|
|
| 2658 | + foreach ($errorsObj as $key => $val) {
|
|
| 2659 | + for ($i = 0; $i < count($val); $i++) {
|
|
| 2660 | + echo "<div class=error_msg_fix>" . $val[$i] . '</div>'; |
|
| 2661 | + $registration_error_msg = 1; |
|
| 2662 | + } |
|
| 2663 | + } |
|
| 2664 | + } |
|
| 2665 | + } |
|
| 2666 | 2666 | |
| 2667 | - if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_in') {
|
|
| 2668 | - ?> |
|
| 2667 | + if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_in') {
|
|
| 2668 | + ?> |
|
| 2669 | 2669 | |
| 2670 | 2670 | <div class="login_form"> |
| 2671 | 2671 | <?php |
| 2672 | - /** |
|
| 2673 | - * Contains login form template. |
|
| 2674 | - * |
|
| 2675 | - * @since 1.0.0 |
|
| 2676 | - */ |
|
| 2677 | - include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2672 | + /** |
|
| 2673 | + * Contains login form template. |
|
| 2674 | + * |
|
| 2675 | + * @since 1.0.0 |
|
| 2676 | + */ |
|
| 2677 | + include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2678 | 2678 | </div> |
| 2679 | 2679 | |
| 2680 | 2680 | <?php } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_up' && $is_enable_signup ) { ?>
|
| 2681 | 2681 | |
| 2682 | 2682 | <div class="registration_form"> |
| 2683 | 2683 | <?php |
| 2684 | - /** |
|
| 2685 | - * Contains registration form template. |
|
| 2686 | - * |
|
| 2687 | - * @since 1.0.0 |
|
| 2688 | - */ |
|
| 2689 | - include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2684 | + /** |
|
| 2685 | + * Contains registration form template. |
|
| 2686 | + * |
|
| 2687 | + * @since 1.0.0 |
|
| 2688 | + */ |
|
| 2689 | + include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2690 | 2690 | </div> |
| 2691 | 2691 | |
| 2692 | 2692 | <?php } else { ?>
|
| 2693 | 2693 | |
| 2694 | 2694 | <div class="login_form_l"> |
| 2695 | 2695 | <?php |
| 2696 | - /** |
|
| 2697 | - * Contains login form template. |
|
| 2698 | - * |
|
| 2699 | - * @since 1.0.0 |
|
| 2700 | - */ |
|
| 2701 | - include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2696 | + /** |
|
| 2697 | + * Contains login form template. |
|
| 2698 | + * |
|
| 2699 | + * @since 1.0.0 |
|
| 2700 | + */ |
|
| 2701 | + include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2702 | 2702 | </div> |
| 2703 | 2703 | |
| 2704 | 2704 | <?php if ( $is_enable_signup ) { ?>
|
| 2705 | 2705 | <div class="registration_form_r"> |
| 2706 | 2706 | <?php |
| 2707 | - /** |
|
| 2708 | - * Contains registration form template. |
|
| 2709 | - * |
|
| 2710 | - * @since 1.0.0 |
|
| 2711 | - */ |
|
| 2712 | - include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2707 | + /** |
|
| 2708 | + * Contains registration form template. |
|
| 2709 | + * |
|
| 2710 | + * @since 1.0.0 |
|
| 2711 | + */ |
|
| 2712 | + include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2713 | 2713 | </div> |
| 2714 | 2714 | <?php } ?> |
| 2715 | 2715 | |
@@ -2741,66 +2741,66 @@ discard block |
||
| 2741 | 2741 | */ |
| 2742 | 2742 | function geodir_action_author_page_title() |
| 2743 | 2743 | {
|
| 2744 | - global $term; |
|
| 2744 | + global $term; |
|
| 2745 | 2745 | |
| 2746 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 2747 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 2746 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 2747 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 2748 | 2748 | |
| 2749 | - $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 2750 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 2751 | - $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 2752 | - } |
|
| 2749 | + $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 2750 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 2751 | + $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 2752 | + } |
|
| 2753 | 2753 | |
| 2754 | - $list_title = $add_string_in_title . $post_type_info->labels->name; |
|
| 2755 | - $single_name = $post_type_info->labels->singular_name; |
|
| 2754 | + $list_title = $add_string_in_title . $post_type_info->labels->name; |
|
| 2755 | + $single_name = $post_type_info->labels->singular_name; |
|
| 2756 | 2756 | |
| 2757 | - $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2757 | + $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2758 | 2758 | |
| 2759 | - if (!empty($term)) {
|
|
| 2760 | - $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
|
| 2761 | - if (!empty($current_term)) |
|
| 2762 | - $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
|
|
| 2763 | - } |
|
| 2759 | + if (!empty($term)) {
|
|
| 2760 | + $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
|
| 2761 | + if (!empty($current_term)) |
|
| 2762 | + $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
|
|
| 2763 | + } |
|
| 2764 | 2764 | |
| 2765 | 2765 | |
| 2766 | - if (is_search()) {
|
|
| 2767 | - $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 2766 | + if (is_search()) {
|
|
| 2767 | + $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 2768 | 2768 | |
| 2769 | - } |
|
| 2770 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2771 | - $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 2772 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2773 | - $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 2769 | + } |
|
| 2770 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2771 | + $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 2772 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2773 | + $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 2774 | 2774 | |
| 2775 | - $title = $list_title; |
|
| 2776 | - if(geodir_is_page('author')){
|
|
| 2777 | - $gd_page = 'author'; |
|
| 2778 | - if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 2779 | - $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
|
| 2780 | - }else{
|
|
| 2781 | - $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
|
| 2782 | - } |
|
| 2775 | + $title = $list_title; |
|
| 2776 | + if(geodir_is_page('author')){
|
|
| 2777 | + $gd_page = 'author'; |
|
| 2778 | + if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 2779 | + $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
|
| 2780 | + }else{
|
|
| 2781 | + $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
|
| 2782 | + } |
|
| 2783 | 2783 | |
| 2784 | - } |
|
| 2784 | + } |
|
| 2785 | 2785 | |
| 2786 | 2786 | |
| 2787 | - /** |
|
| 2788 | - * Filter page title to replace variables. |
|
| 2789 | - * |
|
| 2790 | - * @since 1.5.4 |
|
| 2791 | - * @param string $title The page title including variables. |
|
| 2792 | - * @param string $gd_page The GeoDirectory page type if any. |
|
| 2793 | - */ |
|
| 2794 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2787 | + /** |
|
| 2788 | + * Filter page title to replace variables. |
|
| 2789 | + * |
|
| 2790 | + * @since 1.5.4 |
|
| 2791 | + * @param string $title The page title including variables. |
|
| 2792 | + * @param string $gd_page The GeoDirectory page type if any. |
|
| 2793 | + */ |
|
| 2794 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2795 | 2795 | |
| 2796 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 2797 | - /** |
|
| 2798 | - * Filter the author page title text. |
|
| 2799 | - * |
|
| 2800 | - * @since 1.0.0 |
|
| 2801 | - * @param string $list_title The title for the page. |
|
| 2802 | - */ |
|
| 2803 | - apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
|
|
| 2796 | + echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 2797 | + /** |
|
| 2798 | + * Filter the author page title text. |
|
| 2799 | + * |
|
| 2800 | + * @since 1.0.0 |
|
| 2801 | + * @param string $list_title The title for the page. |
|
| 2802 | + */ |
|
| 2803 | + apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
|
|
| 2804 | 2804 | } |
| 2805 | 2805 | |
| 2806 | 2806 | |
@@ -2818,11 +2818,11 @@ discard block |
||
| 2818 | 2818 | */ |
| 2819 | 2819 | function geodir_action_geodir_sidebar_author_top() |
| 2820 | 2820 | {
|
| 2821 | - if (get_option('geodir_show_author_top_section')) { ?>
|
|
| 2821 | + if (get_option('geodir_show_author_top_section')) { ?>
|
|
| 2822 | 2822 | <div |
| 2823 | 2823 | class="<?php |
| 2824 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2825 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_top'); ?>">
|
|
| 2824 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2825 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_top'); ?>">
|
|
| 2826 | 2826 | <?php dynamic_sidebar('geodir_author_top'); ?>
|
| 2827 | 2827 | </div><!-- clearfix ends here--> |
| 2828 | 2828 | <?php } |
@@ -2838,7 +2838,7 @@ discard block |
||
| 2838 | 2838 | */ |
| 2839 | 2839 | function geodir_author_left_section() |
| 2840 | 2840 | {
|
| 2841 | - if (get_option('geodir_show_author_left_section')) { ?>
|
|
| 2841 | + if (get_option('geodir_show_author_left_section')) { ?>
|
|
| 2842 | 2842 | <div class="geodir-content-left geodir-sidebar-wrap"> |
| 2843 | 2843 | <?php dynamic_sidebar('geodir_author_left_sidebar'); ?>
|
| 2844 | 2844 | </div><!-- end geodir-content-left --> |
@@ -2859,19 +2859,19 @@ discard block |
||
| 2859 | 2859 | */ |
| 2860 | 2860 | function geodir_action_author_sidebar_left() |
| 2861 | 2861 | {
|
| 2862 | - if (get_option('geodir_show_author_left_section')) {
|
|
| 2862 | + if (get_option('geodir_show_author_left_section')) {
|
|
| 2863 | 2863 | // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='') |
| 2864 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2865 | - do_action('geodir_sidebar_left_open', 'author-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 2866 | - /** |
|
| 2867 | - * This is used to add the content to the author page left sidebar (if active). |
|
| 2868 | - * |
|
| 2869 | - * @since 1.0.0 |
|
| 2870 | - */ |
|
| 2871 | - do_action('geodir_author_sidebar_left_inside');
|
|
| 2872 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2873 | - do_action('geodir_sidebar_left_close', 'author-page');
|
|
| 2874 | - } |
|
| 2864 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2865 | + do_action('geodir_sidebar_left_open', 'author-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 2866 | + /** |
|
| 2867 | + * This is used to add the content to the author page left sidebar (if active). |
|
| 2868 | + * |
|
| 2869 | + * @since 1.0.0 |
|
| 2870 | + */ |
|
| 2871 | + do_action('geodir_author_sidebar_left_inside');
|
|
| 2872 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2873 | + do_action('geodir_sidebar_left_close', 'author-page');
|
|
| 2874 | + } |
|
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | /** |
@@ -2884,7 +2884,7 @@ discard block |
||
| 2884 | 2884 | */ |
| 2885 | 2885 | function geodir_author_right_section() |
| 2886 | 2886 | {
|
| 2887 | - if (get_option('geodir_show_author_right_section')) { ?>
|
|
| 2887 | + if (get_option('geodir_show_author_right_section')) { ?>
|
|
| 2888 | 2888 | <div class="geodir-content-right geodir-sidebar-wrap"> |
| 2889 | 2889 | <?php dynamic_sidebar('geodir_author_right_sidebar'); ?>
|
| 2890 | 2890 | </div><!-- end geodir-content-right --> |
@@ -2904,18 +2904,18 @@ discard block |
||
| 2904 | 2904 | */ |
| 2905 | 2905 | function geodir_action_author_sidebar_right() |
| 2906 | 2906 | {
|
| 2907 | - if (get_option('geodir_show_author_right_section')) {
|
|
| 2908 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2909 | - do_action('geodir_sidebar_right_open', 'author-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 2910 | - /** |
|
| 2911 | - * This is used to add the content to the author page right sidebar (if active). |
|
| 2912 | - * |
|
| 2913 | - * @since 1.0.0 |
|
| 2914 | - */ |
|
| 2915 | - do_action('geodir_author_sidebar_right_inside');
|
|
| 2916 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2917 | - do_action('geodir_sidebar_right_close', 'author-page');
|
|
| 2918 | - } |
|
| 2907 | + if (get_option('geodir_show_author_right_section')) {
|
|
| 2908 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2909 | + do_action('geodir_sidebar_right_open', 'author-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 2910 | + /** |
|
| 2911 | + * This is used to add the content to the author page right sidebar (if active). |
|
| 2912 | + * |
|
| 2913 | + * @since 1.0.0 |
|
| 2914 | + */ |
|
| 2915 | + do_action('geodir_author_sidebar_right_inside');
|
|
| 2916 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2917 | + do_action('geodir_sidebar_right_close', 'author-page');
|
|
| 2918 | + } |
|
| 2919 | 2919 | } |
| 2920 | 2920 | |
| 2921 | 2921 | /** |
@@ -2927,14 +2927,14 @@ discard block |
||
| 2927 | 2927 | */ |
| 2928 | 2928 | function geodir_action_author_content_inside() |
| 2929 | 2929 | {
|
| 2930 | - global $gridview_columns; |
|
| 2931 | - $listing_view = get_option('geodir_author_view');
|
|
| 2932 | - if (strstr($listing_view, 'gridview')) {
|
|
| 2933 | - $gridview_columns = $listing_view; |
|
| 2934 | - $listing_view_exp = explode('_', $listing_view);
|
|
| 2935 | - $listing_view = $listing_view_exp[0]; |
|
| 2936 | - } |
|
| 2937 | - geodir_get_template_part('listing', 'listview');
|
|
| 2930 | + global $gridview_columns; |
|
| 2931 | + $listing_view = get_option('geodir_author_view');
|
|
| 2932 | + if (strstr($listing_view, 'gridview')) {
|
|
| 2933 | + $gridview_columns = $listing_view; |
|
| 2934 | + $listing_view_exp = explode('_', $listing_view);
|
|
| 2935 | + $listing_view = $listing_view_exp[0]; |
|
| 2936 | + } |
|
| 2937 | + geodir_get_template_part('listing', 'listview');
|
|
| 2938 | 2938 | } |
| 2939 | 2939 | |
| 2940 | 2940 | add_action('geodir_author_content_inside', 'geodir_action_author_content_inside', 10);
|
@@ -2949,22 +2949,22 @@ discard block |
||
| 2949 | 2949 | */ |
| 2950 | 2950 | function geodir_action_author_content() |
| 2951 | 2951 | {
|
| 2952 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2953 | - do_action('geodir_main_content_open', 'author-page', 'geodir-main-content', 'author-page');
|
|
| 2954 | - echo '<div class="clearfix">'; |
|
| 2955 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2956 | - do_action('geodir_before_listing');
|
|
| 2957 | - echo '</div>'; |
|
| 2958 | - /** |
|
| 2959 | - * This is used to add the content to the author page main content. |
|
| 2960 | - * |
|
| 2961 | - * @since 1.0.0 |
|
| 2962 | - */ |
|
| 2963 | - do_action('geodir_author_content_inside');
|
|
| 2964 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2965 | - do_action('geodir_after_listing');
|
|
| 2966 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2967 | - do_action('geodir_main_content_close', 'author-page');
|
|
| 2952 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2953 | + do_action('geodir_main_content_open', 'author-page', 'geodir-main-content', 'author-page');
|
|
| 2954 | + echo '<div class="clearfix">'; |
|
| 2955 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2956 | + do_action('geodir_before_listing');
|
|
| 2957 | + echo '</div>'; |
|
| 2958 | + /** |
|
| 2959 | + * This is used to add the content to the author page main content. |
|
| 2960 | + * |
|
| 2961 | + * @since 1.0.0 |
|
| 2962 | + */ |
|
| 2963 | + do_action('geodir_author_content_inside');
|
|
| 2964 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2965 | + do_action('geodir_after_listing');
|
|
| 2966 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2967 | + do_action('geodir_main_content_close', 'author-page');
|
|
| 2968 | 2968 | } |
| 2969 | 2969 | |
| 2970 | 2970 | add_action('geodir_sidebar_author_bottom_section', 'geodir_action_sidebar_author_bottom_section', 10);
|
@@ -2978,11 +2978,11 @@ discard block |
||
| 2978 | 2978 | */ |
| 2979 | 2979 | function geodir_action_sidebar_author_bottom_section() |
| 2980 | 2980 | {
|
| 2981 | - if (get_option('geodir_show_author_bottom_section')) { ?>
|
|
| 2981 | + if (get_option('geodir_show_author_bottom_section')) { ?>
|
|
| 2982 | 2982 | <div |
| 2983 | 2983 | class="<?php |
| 2984 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 2985 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_bottom'); ?>">
|
|
| 2984 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 2985 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_bottom'); ?>">
|
|
| 2986 | 2986 | <?php dynamic_sidebar('geodir_author_bottom'); ?>
|
| 2987 | 2987 | </div><!-- clearfix ends here--> |
| 2988 | 2988 | <?php } |
@@ -3001,23 +3001,23 @@ discard block |
||
| 3001 | 3001 | */ |
| 3002 | 3002 | function geodir_action_search_page_title() |
| 3003 | 3003 | {
|
| 3004 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 3005 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 3004 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 3005 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 3006 | 3006 | |
| 3007 | - $pt_name = ''; |
|
| 3008 | - if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
|
|
| 3007 | + $pt_name = ''; |
|
| 3008 | + if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
|
|
| 3009 | 3009 | |
| 3010 | - if (is_search()) {
|
|
| 3011 | - $list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 3010 | + if (is_search()) {
|
|
| 3011 | + $list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 3012 | 3012 | |
| 3013 | - } |
|
| 3014 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3015 | - $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 3016 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3017 | - $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 3018 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 3019 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3020 | - apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
|
|
| 3013 | + } |
|
| 3014 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3015 | + $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
|
| 3016 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3017 | + $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
|
| 3018 | + echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 3019 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3020 | + apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
|
|
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | 3023 | // action for adding the listings page top widget area |
@@ -3033,11 +3033,11 @@ discard block |
||
| 3033 | 3033 | */ |
| 3034 | 3034 | function geodir_action_geodir_sidebar_search_top() |
| 3035 | 3035 | {
|
| 3036 | - if (get_option('geodir_show_search_top_section')) { ?>
|
|
| 3036 | + if (get_option('geodir_show_search_top_section')) { ?>
|
|
| 3037 | 3037 | <div |
| 3038 | 3038 | class="<?php |
| 3039 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3040 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_top'); ?>">
|
|
| 3039 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3040 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_top'); ?>">
|
|
| 3041 | 3041 | <?php dynamic_sidebar('geodir_search_top'); ?>
|
| 3042 | 3042 | </div><!-- clearfix ends here--> |
| 3043 | 3043 | <?php } |
@@ -3053,7 +3053,7 @@ discard block |
||
| 3053 | 3053 | */ |
| 3054 | 3054 | function geodir_search_left_section() |
| 3055 | 3055 | {
|
| 3056 | - if (get_option('geodir_show_search_left_section')) { ?>
|
|
| 3056 | + if (get_option('geodir_show_search_left_section')) { ?>
|
|
| 3057 | 3057 | <div class="geodir-content-left geodir-sidebar-wrap"> |
| 3058 | 3058 | <?php dynamic_sidebar('geodir_search_left_sidebar'); ?>
|
| 3059 | 3059 | </div><!-- end geodir-content-left --> |
@@ -3073,19 +3073,19 @@ discard block |
||
| 3073 | 3073 | */ |
| 3074 | 3074 | function geodir_action_search_sidebar_left() |
| 3075 | 3075 | {
|
| 3076 | - if (get_option('geodir_show_search_left_section')) {
|
|
| 3076 | + if (get_option('geodir_show_search_left_section')) {
|
|
| 3077 | 3077 | // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='') |
| 3078 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3079 | - do_action('geodir_sidebar_left_open', 'search-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 3080 | - /** |
|
| 3081 | - * This is used to add the content to the search page left sidebar (if active). |
|
| 3082 | - * |
|
| 3083 | - * @since 1.0.0 |
|
| 3084 | - */ |
|
| 3085 | - do_action('geodir_search_sidebar_left_inside');
|
|
| 3086 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3087 | - do_action('geodir_sidebar_left_close', 'search-page');
|
|
| 3088 | - } |
|
| 3078 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3079 | + do_action('geodir_sidebar_left_open', 'search-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 3080 | + /** |
|
| 3081 | + * This is used to add the content to the search page left sidebar (if active). |
|
| 3082 | + * |
|
| 3083 | + * @since 1.0.0 |
|
| 3084 | + */ |
|
| 3085 | + do_action('geodir_search_sidebar_left_inside');
|
|
| 3086 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3087 | + do_action('geodir_sidebar_left_close', 'search-page');
|
|
| 3088 | + } |
|
| 3089 | 3089 | } |
| 3090 | 3090 | |
| 3091 | 3091 | /** |
@@ -3098,7 +3098,7 @@ discard block |
||
| 3098 | 3098 | */ |
| 3099 | 3099 | function geodir_search_right_section() |
| 3100 | 3100 | {
|
| 3101 | - if (get_option('geodir_show_search_right_section')) { ?>
|
|
| 3101 | + if (get_option('geodir_show_search_right_section')) { ?>
|
|
| 3102 | 3102 | <div class="geodir-content-right geodir-sidebar-wrap"> |
| 3103 | 3103 | <?php dynamic_sidebar('geodir_search_right_sidebar'); ?>
|
| 3104 | 3104 | </div><!-- end geodir-content-right --> |
@@ -3118,18 +3118,18 @@ discard block |
||
| 3118 | 3118 | */ |
| 3119 | 3119 | function geodir_action_search_sidebar_right() |
| 3120 | 3120 | {
|
| 3121 | - if (get_option('geodir_show_search_right_section')) {
|
|
| 3122 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3123 | - do_action('geodir_sidebar_right_open', 'search-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 3124 | - /** |
|
| 3125 | - * This is used to add the content to the search page right sidebar (if active). |
|
| 3126 | - * |
|
| 3127 | - * @since 1.0.0 |
|
| 3128 | - */ |
|
| 3129 | - do_action('geodir_search_sidebar_right_inside');
|
|
| 3130 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3131 | - do_action('geodir_sidebar_right_close', 'search-page');
|
|
| 3132 | - } |
|
| 3121 | + if (get_option('geodir_show_search_right_section')) {
|
|
| 3122 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3123 | + do_action('geodir_sidebar_right_open', 'search-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 3124 | + /** |
|
| 3125 | + * This is used to add the content to the search page right sidebar (if active). |
|
| 3126 | + * |
|
| 3127 | + * @since 1.0.0 |
|
| 3128 | + */ |
|
| 3129 | + do_action('geodir_search_sidebar_right_inside');
|
|
| 3130 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3131 | + do_action('geodir_sidebar_right_close', 'search-page');
|
|
| 3132 | + } |
|
| 3133 | 3133 | } |
| 3134 | 3134 | |
| 3135 | 3135 | |
@@ -3144,11 +3144,11 @@ discard block |
||
| 3144 | 3144 | */ |
| 3145 | 3145 | function geodir_action_sidebar_search_bottom_section() |
| 3146 | 3146 | {
|
| 3147 | - if (get_option('geodir_show_search_bottom_section')) { ?>
|
|
| 3147 | + if (get_option('geodir_show_search_bottom_section')) { ?>
|
|
| 3148 | 3148 | <div |
| 3149 | 3149 | class="<?php |
| 3150 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3151 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_bottom'); ?>">
|
|
| 3150 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3151 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_bottom'); ?>">
|
|
| 3152 | 3152 | <?php dynamic_sidebar('geodir_search_bottom'); ?>
|
| 3153 | 3153 | </div><!-- clearfix ends here--> |
| 3154 | 3154 | <?php } |
@@ -3163,14 +3163,14 @@ discard block |
||
| 3163 | 3163 | */ |
| 3164 | 3164 | function geodir_action_search_content_inside() |
| 3165 | 3165 | {
|
| 3166 | - global $gridview_columns; |
|
| 3167 | - $listing_view = get_option('geodir_search_view');
|
|
| 3168 | - if (strstr($listing_view, 'gridview')) {
|
|
| 3169 | - $gridview_columns = $listing_view; |
|
| 3170 | - $listing_view_exp = explode('_', $listing_view);
|
|
| 3171 | - $listing_view = $listing_view_exp[0]; |
|
| 3172 | - } |
|
| 3173 | - geodir_get_template_part('listing', 'listview');
|
|
| 3166 | + global $gridview_columns; |
|
| 3167 | + $listing_view = get_option('geodir_search_view');
|
|
| 3168 | + if (strstr($listing_view, 'gridview')) {
|
|
| 3169 | + $gridview_columns = $listing_view; |
|
| 3170 | + $listing_view_exp = explode('_', $listing_view);
|
|
| 3171 | + $listing_view = $listing_view_exp[0]; |
|
| 3172 | + } |
|
| 3173 | + geodir_get_template_part('listing', 'listview');
|
|
| 3174 | 3174 | } |
| 3175 | 3175 | |
| 3176 | 3176 | add_action('geodir_search_content_inside', 'geodir_action_search_content_inside', 10);
|
@@ -3186,22 +3186,22 @@ discard block |
||
| 3186 | 3186 | */ |
| 3187 | 3187 | function geodir_action_search_content() |
| 3188 | 3188 | {
|
| 3189 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3190 | - do_action('geodir_main_content_open', 'search-page', 'geodir-main-content', 'search-page');
|
|
| 3191 | - echo '<div class="clearfix">'; |
|
| 3192 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3193 | - do_action('geodir_before_listing');
|
|
| 3194 | - echo '</div>'; |
|
| 3195 | - /** |
|
| 3196 | - * This is used to add the content to the search page main content. |
|
| 3197 | - * |
|
| 3198 | - * @since 1.0.0 |
|
| 3199 | - */ |
|
| 3200 | - do_action('geodir_search_content_inside');
|
|
| 3201 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3202 | - do_action('geodir_after_listing');
|
|
| 3203 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3204 | - do_action('geodir_main_content_close', 'search-page');
|
|
| 3189 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3190 | + do_action('geodir_main_content_open', 'search-page', 'geodir-main-content', 'search-page');
|
|
| 3191 | + echo '<div class="clearfix">'; |
|
| 3192 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3193 | + do_action('geodir_before_listing');
|
|
| 3194 | + echo '</div>'; |
|
| 3195 | + /** |
|
| 3196 | + * This is used to add the content to the search page main content. |
|
| 3197 | + * |
|
| 3198 | + * @since 1.0.0 |
|
| 3199 | + */ |
|
| 3200 | + do_action('geodir_search_content_inside');
|
|
| 3201 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3202 | + do_action('geodir_after_listing');
|
|
| 3203 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3204 | + do_action('geodir_main_content_close', 'search-page');
|
|
| 3205 | 3205 | } |
| 3206 | 3206 | |
| 3207 | 3207 | ############################################### |
@@ -3224,11 +3224,11 @@ discard block |
||
| 3224 | 3224 | */ |
| 3225 | 3225 | function geodir_action_geodir_sidebar_home_top() |
| 3226 | 3226 | {
|
| 3227 | - if (get_option('geodir_show_home_top_section')) { ?>
|
|
| 3227 | + if (get_option('geodir_show_home_top_section')) { ?>
|
|
| 3228 | 3228 | <div |
| 3229 | 3229 | class="<?php |
| 3230 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3231 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_top'); ?>">
|
|
| 3230 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3231 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_top'); ?>">
|
|
| 3232 | 3232 | <?php dynamic_sidebar('geodir_home_top'); ?>
|
| 3233 | 3233 | </div><!-- clearfix ends here--> |
| 3234 | 3234 | <?php } |
@@ -3244,7 +3244,7 @@ discard block |
||
| 3244 | 3244 | */ |
| 3245 | 3245 | function geodir_home_left_section() |
| 3246 | 3246 | {
|
| 3247 | - if (get_option('geodir_show_home_left_section')) { ?>
|
|
| 3247 | + if (get_option('geodir_show_home_left_section')) { ?>
|
|
| 3248 | 3248 | <div class="geodir-content-left geodir-sidebar-wrap"> |
| 3249 | 3249 | <?php dynamic_sidebar('geodir_home_left'); ?>
|
| 3250 | 3250 | </div><!-- end geodir-content-left --> |
@@ -3266,19 +3266,19 @@ discard block |
||
| 3266 | 3266 | */ |
| 3267 | 3267 | function geodir_action_home_sidebar_left() |
| 3268 | 3268 | {
|
| 3269 | - if (get_option('geodir_show_home_left_section')) {
|
|
| 3269 | + if (get_option('geodir_show_home_left_section')) {
|
|
| 3270 | 3270 | // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='') |
| 3271 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3272 | - do_action('geodir_sidebar_left_open', 'home-page', 'geodir-sidebar-left', 'geodir-sidebar geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 3273 | - /** |
|
| 3274 | - * This is used to add the content to the home page left sidebar (if active). |
|
| 3275 | - * |
|
| 3276 | - * @since 1.0.0 |
|
| 3277 | - */ |
|
| 3278 | - do_action('geodir_home_sidebar_left_inside');
|
|
| 3279 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3280 | - do_action('geodir_sidebar_left_close', 'home-page');
|
|
| 3281 | - } |
|
| 3271 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3272 | + do_action('geodir_sidebar_left_open', 'home-page', 'geodir-sidebar-left', 'geodir-sidebar geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
|
|
| 3273 | + /** |
|
| 3274 | + * This is used to add the content to the home page left sidebar (if active). |
|
| 3275 | + * |
|
| 3276 | + * @since 1.0.0 |
|
| 3277 | + */ |
|
| 3278 | + do_action('geodir_home_sidebar_left_inside');
|
|
| 3279 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3280 | + do_action('geodir_sidebar_left_close', 'home-page');
|
|
| 3281 | + } |
|
| 3282 | 3282 | } |
| 3283 | 3283 | |
| 3284 | 3284 | /** |
@@ -3291,7 +3291,7 @@ discard block |
||
| 3291 | 3291 | */ |
| 3292 | 3292 | function geodir_home_right_section() |
| 3293 | 3293 | {
|
| 3294 | - if (get_option('geodir_show_home_right_section')) { ?>
|
|
| 3294 | + if (get_option('geodir_show_home_right_section')) { ?>
|
|
| 3295 | 3295 | <div class="geodir-content-right geodir-sidebar-wrap"> |
| 3296 | 3296 | <?php dynamic_sidebar('geodir_home_right'); ?>
|
| 3297 | 3297 | </div><!-- end geodir-content-right --> |
@@ -3312,18 +3312,18 @@ discard block |
||
| 3312 | 3312 | */ |
| 3313 | 3313 | function geodir_action_home_sidebar_right() |
| 3314 | 3314 | {
|
| 3315 | - if (get_option('geodir_show_home_right_section')) {
|
|
| 3316 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3317 | - do_action('geodir_sidebar_right_open', 'home-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 3318 | - /** |
|
| 3319 | - * This is used to add the content to the home page right sidebar (if active). |
|
| 3320 | - * |
|
| 3321 | - * @since 1.0.0 |
|
| 3322 | - */ |
|
| 3323 | - do_action('geodir_home_sidebar_right_inside');
|
|
| 3324 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3325 | - do_action('geodir_sidebar_right_close', 'home-page');
|
|
| 3326 | - } |
|
| 3315 | + if (get_option('geodir_show_home_right_section')) {
|
|
| 3316 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3317 | + do_action('geodir_sidebar_right_open', 'home-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
|
|
| 3318 | + /** |
|
| 3319 | + * This is used to add the content to the home page right sidebar (if active). |
|
| 3320 | + * |
|
| 3321 | + * @since 1.0.0 |
|
| 3322 | + */ |
|
| 3323 | + do_action('geodir_home_sidebar_right_inside');
|
|
| 3324 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3325 | + do_action('geodir_sidebar_right_close', 'home-page');
|
|
| 3326 | + } |
|
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | /** |
@@ -3334,7 +3334,7 @@ discard block |
||
| 3334 | 3334 | */ |
| 3335 | 3335 | function geodir_action_home_content_inside() |
| 3336 | 3336 | {
|
| 3337 | - dynamic_sidebar('geodir_home_content');
|
|
| 3337 | + dynamic_sidebar('geodir_home_content');
|
|
| 3338 | 3338 | } |
| 3339 | 3339 | |
| 3340 | 3340 | add_action('geodir_home_content_inside', 'geodir_action_home_content_inside', 10);
|
@@ -3349,28 +3349,28 @@ discard block |
||
| 3349 | 3349 | */ |
| 3350 | 3350 | function geodir_action_home_content() |
| 3351 | 3351 | {
|
| 3352 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3353 | - do_action('geodir_main_content_open', 'home-page', 'geodir-main-content', 'home-page');
|
|
| 3354 | - /** |
|
| 3355 | - * This called before the home page main content. |
|
| 3356 | - * |
|
| 3357 | - * @since 1.0.0 |
|
| 3358 | - */ |
|
| 3359 | - do_action('geodir_before_home_content');
|
|
| 3360 | - /** |
|
| 3361 | - * This is used to add the content to the home page main content. |
|
| 3362 | - * |
|
| 3363 | - * @since 1.0.0 |
|
| 3364 | - */ |
|
| 3365 | - do_action('geodir_home_content_inside');
|
|
| 3366 | - /** |
|
| 3367 | - * This is called after the homepage main content. |
|
| 3368 | - * |
|
| 3369 | - * @since 1.0.0 |
|
| 3370 | - */ |
|
| 3371 | - do_action('geodir_after_home_content');
|
|
| 3372 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3373 | - do_action('geodir_main_content_close', 'home-page');
|
|
| 3352 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3353 | + do_action('geodir_main_content_open', 'home-page', 'geodir-main-content', 'home-page');
|
|
| 3354 | + /** |
|
| 3355 | + * This called before the home page main content. |
|
| 3356 | + * |
|
| 3357 | + * @since 1.0.0 |
|
| 3358 | + */ |
|
| 3359 | + do_action('geodir_before_home_content');
|
|
| 3360 | + /** |
|
| 3361 | + * This is used to add the content to the home page main content. |
|
| 3362 | + * |
|
| 3363 | + * @since 1.0.0 |
|
| 3364 | + */ |
|
| 3365 | + do_action('geodir_home_content_inside');
|
|
| 3366 | + /** |
|
| 3367 | + * This is called after the homepage main content. |
|
| 3368 | + * |
|
| 3369 | + * @since 1.0.0 |
|
| 3370 | + */ |
|
| 3371 | + do_action('geodir_after_home_content');
|
|
| 3372 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3373 | + do_action('geodir_main_content_close', 'home-page');
|
|
| 3374 | 3374 | } |
| 3375 | 3375 | |
| 3376 | 3376 | add_action('geodir_sidebar_location_bottom_section', 'geodir_action_sidebar_home_bottom_section', 10);
|
@@ -3385,11 +3385,11 @@ discard block |
||
| 3385 | 3385 | */ |
| 3386 | 3386 | function geodir_action_sidebar_home_bottom_section() |
| 3387 | 3387 | {
|
| 3388 | - if (get_option('geodir_show_home_bottom_section')) { ?>
|
|
| 3388 | + if (get_option('geodir_show_home_bottom_section')) { ?>
|
|
| 3389 | 3389 | <div |
| 3390 | 3390 | class="<?php |
| 3391 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 3392 | - echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_bottom'); ?>">
|
|
| 3391 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 3392 | + echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_bottom'); ?>">
|
|
| 3393 | 3393 | <?php dynamic_sidebar('geodir_home_bottom'); ?>
|
| 3394 | 3394 | </div><!-- clearfix ends here--> |
| 3395 | 3395 | <?php } |
@@ -3417,13 +3417,13 @@ discard block |
||
| 3417 | 3417 | */ |
| 3418 | 3418 | function geodir_filter_listing_page_title($list_title) |
| 3419 | 3419 | {
|
| 3420 | - if (is_search() && trim(get_search_query()) == '') {
|
|
| 3421 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 3422 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 3420 | + if (is_search() && trim(get_search_query()) == '') {
|
|
| 3421 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 3422 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 3423 | 3423 | |
| 3424 | - $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
|
|
| 3425 | - } |
|
| 3426 | - return $list_title; |
|
| 3424 | + $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
|
|
| 3425 | + } |
|
| 3426 | + return $list_title; |
|
| 3427 | 3427 | } |
| 3428 | 3428 | |
| 3429 | 3429 | add_action('geodir_message_not_found_on_listing', 'geodir_display_message_not_found_on_listing');
|
@@ -3438,62 +3438,62 @@ discard block |
||
| 3438 | 3438 | * @param string $gd_page The geodirectory page type. Default null. |
| 3439 | 3439 | */ |
| 3440 | 3440 | function geodir_add_page_content( $position = 'before', $gd_page = '' ) {
|
| 3441 | - global $post; |
|
| 3442 | - |
|
| 3443 | - $gd_page_id = NULL; |
|
| 3444 | - if ($gd_page == 'home-page' && geodir_is_page('home')) {
|
|
| 3445 | - $gd_page_id = geodir_home_page_id(); |
|
| 3446 | - } else if ($gd_page == 'details-page' && geodir_is_page('preview')) {
|
|
| 3447 | - $gd_page_id = geodir_preview_page_id(); |
|
| 3448 | - } else if ($gd_page == 'add-listing-page' && geodir_is_page('add-listing')) {
|
|
| 3449 | - $gd_page_id = geodir_add_listing_page_id(); |
|
| 3450 | - } else if ($gd_page == 'success-page' && geodir_is_page('listing-success')) {
|
|
| 3451 | - $gd_page_id = geodir_success_page_id(); |
|
| 3452 | - } else if ($gd_page == 'location-page' && geodir_is_page('location')) {
|
|
| 3453 | - $gd_page_id = geodir_location_page_id(); |
|
| 3454 | - } else if ($gd_page == 'info-page' && geodir_is_page('info')) {
|
|
| 3455 | - $gd_page_id = geodir_info_page_id(); |
|
| 3456 | - } else if ($gd_page == 'signup-page' && geodir_is_page('login')) {
|
|
| 3457 | - $gd_page_id = geodir_login_page_id(); |
|
| 3458 | - } else if ($gd_page == 'checkout-page' && geodir_is_page('checkout')) {
|
|
| 3459 | - $gd_page_id = geodir_payment_checkout_page_id(); |
|
| 3460 | - } else if ($gd_page == 'invoices-page' && geodir_is_page('invoices')) {
|
|
| 3461 | - $gd_page_id = geodir_payment_invoices_page_id(); |
|
| 3462 | - } |
|
| 3463 | - |
|
| 3464 | - if (!$gd_page_id > 0) {
|
|
| 3465 | - return; |
|
| 3466 | - } |
|
| 3441 | + global $post; |
|
| 3442 | + |
|
| 3443 | + $gd_page_id = NULL; |
|
| 3444 | + if ($gd_page == 'home-page' && geodir_is_page('home')) {
|
|
| 3445 | + $gd_page_id = geodir_home_page_id(); |
|
| 3446 | + } else if ($gd_page == 'details-page' && geodir_is_page('preview')) {
|
|
| 3447 | + $gd_page_id = geodir_preview_page_id(); |
|
| 3448 | + } else if ($gd_page == 'add-listing-page' && geodir_is_page('add-listing')) {
|
|
| 3449 | + $gd_page_id = geodir_add_listing_page_id(); |
|
| 3450 | + } else if ($gd_page == 'success-page' && geodir_is_page('listing-success')) {
|
|
| 3451 | + $gd_page_id = geodir_success_page_id(); |
|
| 3452 | + } else if ($gd_page == 'location-page' && geodir_is_page('location')) {
|
|
| 3453 | + $gd_page_id = geodir_location_page_id(); |
|
| 3454 | + } else if ($gd_page == 'info-page' && geodir_is_page('info')) {
|
|
| 3455 | + $gd_page_id = geodir_info_page_id(); |
|
| 3456 | + } else if ($gd_page == 'signup-page' && geodir_is_page('login')) {
|
|
| 3457 | + $gd_page_id = geodir_login_page_id(); |
|
| 3458 | + } else if ($gd_page == 'checkout-page' && geodir_is_page('checkout')) {
|
|
| 3459 | + $gd_page_id = geodir_payment_checkout_page_id(); |
|
| 3460 | + } else if ($gd_page == 'invoices-page' && geodir_is_page('invoices')) {
|
|
| 3461 | + $gd_page_id = geodir_payment_invoices_page_id(); |
|
| 3462 | + } |
|
| 3463 | + |
|
| 3464 | + if (!$gd_page_id > 0) {
|
|
| 3465 | + return; |
|
| 3466 | + } |
|
| 3467 | 3467 | |
| 3468 | - $display = 'before'; |
|
| 3469 | - /** |
|
| 3470 | - * Filter the position to display the page content. |
|
| 3471 | - * |
|
| 3472 | - * @since 1.6.3 |
|
| 3473 | - * |
|
| 3474 | - * @param string $display Position to add the post content. |
|
| 3475 | - * @param string $gd_page The geodirectory page type. |
|
| 3476 | - */ |
|
| 3477 | - $display = apply_filters('geodir_add_page_content_position', $display, $gd_page);
|
|
| 3478 | - |
|
| 3479 | - if ($position !== $display) {
|
|
| 3480 | - return; |
|
| 3481 | - } |
|
| 3482 | - |
|
| 3483 | - $gd_post = $post; |
|
| 3468 | + $display = 'before'; |
|
| 3469 | + /** |
|
| 3470 | + * Filter the position to display the page content. |
|
| 3471 | + * |
|
| 3472 | + * @since 1.6.3 |
|
| 3473 | + * |
|
| 3474 | + * @param string $display Position to add the post content. |
|
| 3475 | + * @param string $gd_page The geodirectory page type. |
|
| 3476 | + */ |
|
| 3477 | + $display = apply_filters('geodir_add_page_content_position', $display, $gd_page);
|
|
| 3478 | + |
|
| 3479 | + if ($position !== $display) {
|
|
| 3480 | + return; |
|
| 3481 | + } |
|
| 3482 | + |
|
| 3483 | + $gd_post = $post; |
|
| 3484 | 3484 | |
| 3485 | - setup_postdata(get_post($gd_page_id)); |
|
| 3485 | + setup_postdata(get_post($gd_page_id)); |
|
| 3486 | 3486 | |
| 3487 | - if (get_the_content()) {
|
|
| 3488 | - ?> |
|
| 3487 | + if (get_the_content()) {
|
|
| 3488 | + ?> |
|
| 3489 | 3489 | <section class="entry-content clearfix" itemprop="articleBody"><?php the_content(); ?></section> |
| 3490 | 3490 | <?php |
| 3491 | - } |
|
| 3491 | + } |
|
| 3492 | 3492 | |
| 3493 | - $post = $gd_post; |
|
| 3494 | - if (!empty($gd_post) && is_object($gd_post)) {
|
|
| 3495 | - setup_postdata($gd_post); |
|
| 3496 | - } |
|
| 3493 | + $post = $gd_post; |
|
| 3494 | + if (!empty($gd_post) && is_object($gd_post)) {
|
|
| 3495 | + setup_postdata($gd_post); |
|
| 3496 | + } |
|
| 3497 | 3497 | |
| 3498 | 3498 | } |
| 3499 | 3499 | add_action('geodir_add_page_content', 'geodir_add_page_content', 10, 2);
|
@@ -3514,13 +3514,13 @@ discard block |
||
| 3514 | 3514 | * @return string Filtered SQL JOIN clause. |
| 3515 | 3515 | */ |
| 3516 | 3516 | function geodir_previous_next_post_join( $join, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
| 3517 | - global $plugin_prefix; |
|
| 3517 | + global $plugin_prefix; |
|
| 3518 | 3518 | |
| 3519 | - if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3520 | - $join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID"; |
|
| 3521 | - } |
|
| 3519 | + if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3520 | + $join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID"; |
|
| 3521 | + } |
|
| 3522 | 3522 | |
| 3523 | - return $join; |
|
| 3523 | + return $join; |
|
| 3524 | 3524 | } |
| 3525 | 3525 | add_filter( 'get_previous_post_join', 'geodir_previous_next_post_join', 10, 5 ); |
| 3526 | 3526 | add_filter( 'get_next_post_join', 'geodir_previous_next_post_join', 10, 5 ); |
@@ -3542,31 +3542,31 @@ discard block |
||
| 3542 | 3542 | * @return string Filtered SQL WHERE clause. |
| 3543 | 3543 | */ |
| 3544 | 3544 | function geodir_previous_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
| 3545 | - global $wpdb, $plugin_prefix; |
|
| 3545 | + global $wpdb, $plugin_prefix; |
|
| 3546 | 3546 | |
| 3547 | - if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3548 | - $post_locations = ''; |
|
| 3549 | - $post_locations_var = array(); |
|
| 3547 | + if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3548 | + $post_locations = ''; |
|
| 3549 | + $post_locations_var = array(); |
|
| 3550 | 3550 | |
| 3551 | - if ( !empty( $post->country_slug ) ) {
|
|
| 3552 | - $post_locations .= " AND post_locations LIKE %s"; |
|
| 3553 | - $post_locations_var[] = "%,[" . $post->country_slug . "]"; |
|
| 3554 | - } |
|
| 3555 | - |
|
| 3556 | - if ( !empty( $post->region_slug ) ) {
|
|
| 3557 | - $post_locations .= " AND post_locations LIKE %s"; |
|
| 3558 | - $post_locations_var[] = "%,[" . $post->region_slug . "],%"; |
|
| 3559 | - } |
|
| 3560 | - |
|
| 3561 | - if ( !empty( $post->city_slug ) ) {
|
|
| 3562 | - $post_locations .= " AND post_locations LIKE %s"; |
|
| 3563 | - $post_locations_var[] = "[" . $post->city_slug . "],%"; |
|
| 3564 | - } |
|
| 3551 | + if ( !empty( $post->country_slug ) ) {
|
|
| 3552 | + $post_locations .= " AND post_locations LIKE %s"; |
|
| 3553 | + $post_locations_var[] = "%,[" . $post->country_slug . "]"; |
|
| 3554 | + } |
|
| 3555 | + |
|
| 3556 | + if ( !empty( $post->region_slug ) ) {
|
|
| 3557 | + $post_locations .= " AND post_locations LIKE %s"; |
|
| 3558 | + $post_locations_var[] = "%,[" . $post->region_slug . "],%"; |
|
| 3559 | + } |
|
| 3560 | + |
|
| 3561 | + if ( !empty( $post->city_slug ) ) {
|
|
| 3562 | + $post_locations .= " AND post_locations LIKE %s"; |
|
| 3563 | + $post_locations_var[] = "[" . $post->city_slug . "],%"; |
|
| 3564 | + } |
|
| 3565 | 3565 | |
| 3566 | - $where .= $wpdb->prepare( $post_locations, $post_locations_var ); |
|
| 3567 | - } |
|
| 3566 | + $where .= $wpdb->prepare( $post_locations, $post_locations_var ); |
|
| 3567 | + } |
|
| 3568 | 3568 | |
| 3569 | - return $where; |
|
| 3569 | + return $where; |
|
| 3570 | 3570 | } |
| 3571 | 3571 | add_filter( 'get_previous_post_where', 'geodir_previous_next_post_where', 10, 5 ); |
| 3572 | 3572 | add_filter( 'get_next_post_where', 'geodir_previous_next_post_where', 10, 5 ); |
| 3573 | 3573 | \ No newline at end of file |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | //php |
| 285 | 285 | if (!empty($tc['geodir_theme_compat_code'])) {
|
| 286 | - include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
|
|
| 286 | + include_once('geodirectory-functions/compatibility/'.$tc['geodir_theme_compat_code'].'.php');
|
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | //geodir_full_page_class |
@@ -453,13 +453,13 @@ discard block |
||
| 453 | 453 | function geodir_action_wrapper_content_open($type = '', $id = '', $class = '') |
| 454 | 454 | {
|
| 455 | 455 | if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
|
| 456 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 456 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 457 | 457 | } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
|
| 458 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 458 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 459 | 459 | } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
|
| 460 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 460 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 461 | 461 | } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
|
| 462 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 462 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 463 | 463 | } else {
|
| 464 | 464 | $width_css = ''; |
| 465 | 465 | } |
@@ -573,13 +573,13 @@ discard block |
||
| 573 | 573 | function geodir_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') |
| 574 | 574 | {
|
| 575 | 575 | if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
|
| 576 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 576 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 577 | 577 | } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
|
| 578 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 578 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 579 | 579 | } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
|
| 580 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 580 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 581 | 581 | } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
|
| 582 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 582 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 583 | 583 | } else {
|
| 584 | 584 | $width_css = ''; |
| 585 | 585 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - $post = (object)$_REQUEST; |
|
| 680 | + $post = (object) $_REQUEST; |
|
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | if (isset($post->video)) {
|
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | $json = '{';
|
| 738 | 738 | $json .= '"post_preview": "1",'; |
| 739 | - $json .= '"t": "' . $json_title . '",'; |
|
| 740 | - $json .= '"lt": "' . $post_latitude . '",'; |
|
| 741 | - $json .= '"ln": "' . $post_longitude . '",'; |
|
| 742 | - $json .= '"i":"' . $term_icon . '"'; |
|
| 739 | + $json .= '"t": "'.$json_title.'",'; |
|
| 740 | + $json .= '"lt": "'.$post_latitude.'",'; |
|
| 741 | + $json .= '"ln": "'.$post_longitude.'",'; |
|
| 742 | + $json .= '"i":"'.$term_icon.'"'; |
|
| 743 | 743 | $json .= '}'; |
| 744 | 744 | |
| 745 | 745 | $post->marker_json = $json; |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | * @param string $class The class to use. Default is 'entry-header'. |
| 967 | 967 | */ |
| 968 | 968 | $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
| 969 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>'; |
|
| 969 | + echo '<header class="'.$class_header.'"><h1 class="'.$class.'">'.stripslashes(get_the_title()).'</h1></header>'; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0; |
| 1021 | 1021 | |
| 1022 | 1022 | if ($image && $width && $height) {
|
| 1023 | - $image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
|
|
| 1023 | + $image = (object) array('src' => $image, 'width' => $width, 'height' => $height);
|
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | if (isset($image->src)) {
|
@@ -1032,9 +1032,9 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | $image_title = isset($image->title) ? $image->title : ''; |
| 1034 | 1034 | |
| 1035 | - $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1036 | - $main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>'; |
|
| 1037 | - $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1035 | + $main_slides .= '<li><img src="'.geodir_plugin_url()."/geodirectory-assets/images/spacer.gif".'" alt="'.$image_title.'" title="'.$image_title.'" style="max-height:'.$spacer_height.'px;margin:0 auto;" />'; |
|
| 1036 | + $main_slides .= '<img src="'.$image->src.'" alt="'.$image_title.'" title="'.$image_title.'" style="max-height:400px;margin:0 auto;" /></li>'; |
|
| 1037 | + $nav_slides .= '<li><img src="'.$image->src.'" alt="'.$image_title.'" title="'.$image_title.'" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1038 | 1038 | $slides++; |
| 1039 | 1039 | } |
| 1040 | 1040 | } |
@@ -1060,10 +1060,10 @@ discard block |
||
| 1060 | 1060 | } else {
|
| 1061 | 1061 | $spacer_height = ((400 - $image->height) / 2); |
| 1062 | 1062 | } |
| 1063 | - $caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : ''; |
|
| 1064 | - $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />'; |
|
| 1065 | - $main_slides .= '<img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>'; |
|
| 1066 | - $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1063 | + $caption = ''; //(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : ''; |
|
| 1064 | + $main_slides .= '<li><img src="'.geodir_plugin_url()."/geodirectory-assets/images/spacer.gif".'" alt="'.$image->title.'" title="'.$image->title.'" style="max-height:'.$spacer_height.'px;margin:0 auto;" />'; |
|
| 1065 | + $main_slides .= '<img src="'.$image->src.'" alt="'.$image->title.'" title="'.$image->title.'" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>'; |
|
| 1066 | + $nav_slides .= '<li><img src="'.$image->src.'" alt="'.$image->title.'" title="'.$image->title.'" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 1067 | 1067 | $slides++; |
| 1068 | 1068 | } |
| 1069 | 1069 | }// endfore |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | */ |
| 1099 | 1099 | function geodir_action_details_taxonomies() |
| 1100 | 1100 | {
|
| 1101 | - global $preview, $post;?> |
|
| 1101 | + global $preview, $post; ?> |
|
| 1102 | 1102 | <p class="geodir_post_taxomomies clearfix"> |
| 1103 | 1103 | <?php |
| 1104 | 1104 | $taxonomies = array(); |
@@ -1107,11 +1107,11 @@ discard block |
||
| 1107 | 1107 | |
| 1108 | 1108 | if ($preview && !$is_backend_preview) {
|
| 1109 | 1109 | $post_type = $post->listing_type; |
| 1110 | - $post_taxonomy = $post_type . 'category'; |
|
| 1110 | + $post_taxonomy = $post_type.'category'; |
|
| 1111 | 1111 | $post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
|
| 1112 | 1112 | } else {
|
| 1113 | 1113 | $post_type = $post->post_type; |
| 1114 | - $post_taxonomy = $post_type . 'category'; |
|
| 1114 | + $post_taxonomy = $post_type.'category'; |
|
| 1115 | 1115 | } |
| 1116 | 1116 | //{
|
| 1117 | 1117 | $post_type_info = get_post_type_object($post_type); |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | |
| 1120 | 1120 | if (!empty($post->post_tags)) {
|
| 1121 | 1121 | |
| 1122 | - if (taxonomy_exists($post_type . '_tags')): |
|
| 1122 | + if (taxonomy_exists($post_type.'_tags')): |
|
| 1123 | 1123 | $links = array(); |
| 1124 | 1124 | $terms = array(); |
| 1125 | 1125 | // to limit post tags |
@@ -1146,8 +1146,8 @@ discard block |
||
| 1146 | 1146 | $post_term = trim($post_term); |
| 1147 | 1147 | |
| 1148 | 1148 | $priority_location = false; |
| 1149 | - if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
|
|
| 1150 | - $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
|
|
| 1149 | + if ($insert_term = term_exists($post_term, $post_type.'_tags')) {
|
|
| 1150 | + $term = get_term_by('id', $insert_term['term_id'], $post_type.'_tags');
|
|
| 1151 | 1151 | } else {
|
| 1152 | 1152 | $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL; |
| 1153 | 1153 | $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL; |
@@ -1157,10 +1157,10 @@ discard block |
||
| 1157 | 1157 | $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false; |
| 1158 | 1158 | if ($match_country || $match_region || $match_city) {
|
| 1159 | 1159 | $priority_location = true; |
| 1160 | - $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1160 | + $term = get_term_by('name', $post_term, $post_type.'_tags');
|
|
| 1161 | 1161 | } else {
|
| 1162 | - $insert_term = wp_insert_term($post_term, $post_type . '_tags'); |
|
| 1163 | - $term = get_term_by('name', $post_term, $post_type . '_tags');
|
|
| 1162 | + $insert_term = wp_insert_term($post_term, $post_type.'_tags'); |
|
| 1163 | + $term = get_term_by('name', $post_term, $post_type.'_tags');
|
|
| 1164 | 1164 | } |
| 1165 | 1165 | } |
| 1166 | 1166 | |
@@ -1177,12 +1177,12 @@ discard block |
||
| 1177 | 1177 | * @param string $tag_link The tag link html. |
| 1178 | 1178 | * @param object $term The tag term object. |
| 1179 | 1179 | */ |
| 1180 | - $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1180 | + $tag_link = apply_filters('geodir_details_taxonomies_tag_link', $tag_link, $term);
|
|
| 1181 | 1181 | $links[] = $tag_link; |
| 1182 | 1182 | } else {
|
| 1183 | - $tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>"; |
|
| 1183 | + $tag_link = "<a href='".esc_attr(get_term_link($term->term_id, $term->taxonomy))."'>$term->name</a>"; |
|
| 1184 | 1184 | /** This action is documented in geodirectory-template_actions.php */ |
| 1185 | - $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
|
|
| 1185 | + $tag_link = apply_filters('geodir_details_taxonomies_tag_link', $tag_link, $term);
|
|
| 1186 | 1186 | $links[] = $tag_link; |
| 1187 | 1187 | } |
| 1188 | 1188 | $terms[] = $term; |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | if (!isset($listing_label)) {
|
| 1193 | 1193 | $listing_label = ''; |
| 1194 | 1194 | } |
| 1195 | - $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1195 | + $taxonomies[$post_type.'_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object) $terms);
|
|
| 1196 | 1196 | endif; |
| 1197 | 1197 | |
| 1198 | 1198 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | $term = get_term_by('id', $post_term, $post_taxonomy);
|
| 1221 | 1221 | |
| 1222 | 1222 | if (is_object($term)) {
|
| 1223 | - $term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>"; |
|
| 1223 | + $term_link = "<a href='".esc_attr(get_term_link($term, $post_taxonomy))."'>$term->name</a>"; |
|
| 1224 | 1224 | /** |
| 1225 | 1225 | * Filter the category name on the details page. |
| 1226 | 1226 | * |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | * @param string $term_link The link html to the category. |
| 1229 | 1229 | * @param object $term The category term object. |
| 1230 | 1230 | */ |
| 1231 | - $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
|
|
| 1231 | + $term_link = apply_filters('geodir_details_taxonomies_cat_link', $term_link, $term);
|
|
| 1232 | 1232 | $links[] = $term_link; |
| 1233 | 1233 | $terms[] = $term; |
| 1234 | 1234 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | if (!isset($listing_label)) {
|
| 1247 | 1247 | $listing_label = ''; |
| 1248 | 1248 | } |
| 1249 | - $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
|
|
| 1249 | + $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object) $terms);
|
|
| 1250 | 1250 | |
| 1251 | 1251 | } |
| 1252 | 1252 | |
@@ -1259,14 +1259,14 @@ discard block |
||
| 1259 | 1259 | * @param string $listing_label The post type label. |
| 1260 | 1260 | * @param string $listing_label The post type label with ucwords function. |
| 1261 | 1261 | */ |
| 1262 | - $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
|
|
| 1262 | + $taxonomies = apply_filters('geodir_details_taxonomies_output', $taxonomies, $post_type, $listing_label, geodir_ucwords($listing_label));
|
|
| 1263 | 1263 | |
| 1264 | 1264 | if (isset($taxonomies[$post_taxonomy])) {
|
| 1265 | - echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>'; |
|
| 1265 | + echo '<span class="geodir-category">'.$taxonomies[$post_taxonomy].'</span>'; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | - if (isset($taxonomies[$post_type . '_tags'])) |
|
| 1269 | - echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>'; |
|
| 1268 | + if (isset($taxonomies[$post_type.'_tags'])) |
|
| 1269 | + echo '<span class="geodir-tags">'.$taxonomies[$post_type.'_tags'].'</span>'; |
|
| 1270 | 1270 | |
| 1271 | 1271 | ?> |
| 1272 | 1272 | </p><?php |
@@ -1287,11 +1287,11 @@ discard block |
||
| 1287 | 1287 | * @param object $post Optional. The post object or blank. |
| 1288 | 1288 | * @package GeoDirectory |
| 1289 | 1289 | */ |
| 1290 | -function geodir_action_details_micordata($post='') |
|
| 1290 | +function geodir_action_details_micordata($post = '') |
|
| 1291 | 1291 | {
|
| 1292 | 1292 | |
| 1293 | 1293 | global $preview; |
| 1294 | - if(empty($post)){global $post;}
|
|
| 1294 | + if (empty($post)) {global $post; }
|
|
| 1295 | 1295 | if ($preview || !geodir_is_page('detail')) {
|
| 1296 | 1296 | return; |
| 1297 | 1297 | } |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | "description" => $review->comment_content, |
| 1313 | 1313 | "reviewRating" => array( |
| 1314 | 1314 | "@type" => "Rating", |
| 1315 | - "bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score. |
|
| 1315 | + "bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score. |
|
| 1316 | 1316 | "ratingValue" => geodir_get_commentoverall($review->comment_ID), |
| 1317 | 1317 | "worstRating" => "1" |
| 1318 | 1318 | ) |
@@ -1340,13 +1340,13 @@ discard block |
||
| 1340 | 1340 | } |
| 1341 | 1341 | //print_r($post); |
| 1342 | 1342 | // external links |
| 1343 | - $external_links = array(); |
|
| 1343 | + $external_links = array(); |
|
| 1344 | 1344 | $external_links[] = $post->geodir_website; |
| 1345 | 1345 | $external_links[] = $post->geodir_twitter; |
| 1346 | 1346 | $external_links[] = $post->geodir_facebook; |
| 1347 | 1347 | $external_links = array_filter($external_links); |
| 1348 | 1348 | |
| 1349 | - if(!empty($external_links)){
|
|
| 1349 | + if (!empty($external_links)) {
|
|
| 1350 | 1350 | $external_links = array_values($external_links); |
| 1351 | 1351 | } |
| 1352 | 1352 | |
@@ -1356,17 +1356,17 @@ discard block |
||
| 1356 | 1356 | |
| 1357 | 1357 | // schema type |
| 1358 | 1358 | $schema_type = 'LocalBusiness'; |
| 1359 | - if(isset($post->default_category) && $post->default_category){
|
|
| 1359 | + if (isset($post->default_category) && $post->default_category) {
|
|
| 1360 | 1360 | $cat_schema = get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type); |
| 1361 | - if($cat_schema){$schema_type = $cat_schema;}
|
|
| 1362 | - if(!$schema_type && $post->post_type=='gd_event'){$schema_type = 'Event';}
|
|
| 1361 | + if ($cat_schema) {$schema_type = $cat_schema; }
|
|
| 1362 | + if (!$schema_type && $post->post_type == 'gd_event') {$schema_type = 'Event'; }
|
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | $schema = array(); |
| 1366 | 1366 | $schema['@context'] = "https://schema.org"; |
| 1367 | 1367 | $schema['@type'] = $schema_type; |
| 1368 | 1368 | $schema['name'] = $post->post_title; |
| 1369 | - $schema['description'] = wp_strip_all_tags( $post->post_content, true ); |
|
| 1369 | + $schema['description'] = wp_strip_all_tags($post->post_content, true); |
|
| 1370 | 1370 | $schema['telephone'] = $post->geodir_contact; |
| 1371 | 1371 | $schema['url'] = $c_url; |
| 1372 | 1372 | $schema['sameAs'] = $external_links; |
@@ -1380,7 +1380,7 @@ discard block |
||
| 1380 | 1380 | "postalCode" => $post->post_zip |
| 1381 | 1381 | ); |
| 1382 | 1382 | |
| 1383 | - if($post->post_latitude && $post->post_longitude) {
|
|
| 1383 | + if ($post->post_latitude && $post->post_longitude) {
|
|
| 1384 | 1384 | $schema['geo'] = array( |
| 1385 | 1385 | "@type" => "GeoCoordinates", |
| 1386 | 1386 | "latitude" => $post->post_latitude, |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | ); |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | - if($post_avgratings) {
|
|
| 1391 | + if ($post_avgratings) {
|
|
| 1392 | 1392 | $schema['aggregateRating'] = array( |
| 1393 | 1393 | "@type" => "AggregateRating", |
| 1394 | 1394 | "ratingValue" => $post_avgratings, |
@@ -1407,10 +1407,10 @@ discard block |
||
| 1407 | 1407 | * @param array $schema The array of schema data to be filtered. |
| 1408 | 1408 | * @param object $post The post object. |
| 1409 | 1409 | */ |
| 1410 | - $schema = apply_filters('geodir_details_schema', $schema,$post);
|
|
| 1410 | + $schema = apply_filters('geodir_details_schema', $schema, $post);
|
|
| 1411 | 1411 | |
| 1412 | 1412 | |
| 1413 | - echo '<script type="application/ld+json">' . json_encode($schema) . '</script>'; |
|
| 1413 | + echo '<script type="application/ld+json">'.json_encode($schema).'</script>'; |
|
| 1414 | 1414 | |
| 1415 | 1415 | |
| 1416 | 1416 | $uploads = wp_upload_dir(); |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | * @param string $facebook_og The open graph html to be filtered. |
| 1424 | 1424 | * @param object $post The post object. |
| 1425 | 1425 | */ |
| 1426 | - echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
|
|
| 1426 | + echo apply_filters('geodir_details_facebook_og', $facebook_og, $post);
|
|
| 1427 | 1427 | |
| 1428 | 1428 | |
| 1429 | 1429 | |
@@ -1446,9 +1446,9 @@ discard block |
||
| 1446 | 1446 | ?> |
| 1447 | 1447 | <div class="geodir-pos_navigation clearfix"> |
| 1448 | 1448 | <div |
| 1449 | - class="geodir-post_left"><?php previous_post_link('%link', '' . __('Previous', 'geodirectory'), false) ?></div>
|
|
| 1449 | + class="geodir-post_left"><?php previous_post_link('%link', ''.__('Previous', 'geodirectory'), false) ?></div>
|
|
| 1450 | 1450 | <div |
| 1451 | - class="geodir-post_right"><?php next_post_link('%link', __('Next', 'geodirectory') . '', false) ?></div>
|
|
| 1451 | + class="geodir-post_right"><?php next_post_link('%link', __('Next', 'geodirectory').'', false) ?></div>
|
|
| 1452 | 1452 | </div><?php |
| 1453 | 1453 | } |
| 1454 | 1454 | |
@@ -1517,12 +1517,12 @@ discard block |
||
| 1517 | 1517 | $gd_post_type = geodir_get_current_posttype(); |
| 1518 | 1518 | $post_type_info = get_post_type_object($gd_post_type); |
| 1519 | 1519 | |
| 1520 | - $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 1520 | + $add_string_in_title = __('All', 'geodirectory').' ';
|
|
| 1521 | 1521 | if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
| 1522 | - $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 1522 | + $add_string_in_title = __('My Favorite', 'geodirectory').' ';
|
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | - $list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory'); |
|
| 1525 | + $list_title = $add_string_in_title.__($post_type_info->labels->name, 'geodirectory'); |
|
| 1526 | 1526 | $single_name = $post_type_info->labels->singular_name; |
| 1527 | 1527 | |
| 1528 | 1528 | $taxonomy = geodir_get_taxonomies($gd_post_type, true); |
@@ -1550,12 +1550,12 @@ discard block |
||
| 1550 | 1550 | $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
| 1551 | 1551 | if (!empty($current_term)) {
|
| 1552 | 1552 | $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
| 1553 | - if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1553 | + if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type.'category') {
|
|
| 1554 | 1554 | $location_last_char = substr($location_name, -1); |
| 1555 | 1555 | $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
| 1556 | - $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1556 | + $list_title .= __(' in', 'geodirectory').' '.$location_name.$location_name_attach.' '.$current_term_name;
|
|
| 1557 | 1557 | } else {
|
| 1558 | - $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1558 | + $list_title .= __(' in', 'geodirectory')." '".$current_term_name."'";
|
|
| 1559 | 1559 | } |
| 1560 | 1560 | } else {
|
| 1561 | 1561 | if (count($taxonomy) > 1) {
|
@@ -1563,12 +1563,12 @@ discard block |
||
| 1563 | 1563 | |
| 1564 | 1564 | if (!empty($current_term)) {
|
| 1565 | 1565 | $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory'); |
| 1566 | - if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
|
|
| 1566 | + if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type.'category') {
|
|
| 1567 | 1567 | $location_last_char = substr($location_name, -1); |
| 1568 | 1568 | $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
|
| 1569 | - $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
|
|
| 1569 | + $list_title .= __(' in', 'geodirectory').' '.$location_name.$location_name_attach.' '.$current_term_name;
|
|
| 1570 | 1570 | } else {
|
| 1571 | - $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
|
|
| 1571 | + $list_title .= __(' in', 'geodirectory')." '".$current_term_name."'";
|
|
| 1572 | 1572 | } |
| 1573 | 1573 | } |
| 1574 | 1574 | } |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
|
|
| 1599 | + $list_title .= __(' in', 'geodirectory')." '".$gd_city."'";
|
|
| 1600 | 1600 | } else if ($gd_region != '') {
|
| 1601 | 1601 | if ($gd_region_actual != '') {
|
| 1602 | 1602 | $gd_region = $gd_region_actual; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
|
|
| 1609 | + $list_title .= __(' in', 'geodirectory')." '".$gd_region."'";
|
|
| 1610 | 1610 | } else if ($gd_country != '') {
|
| 1611 | 1611 | if ($gd_country_actual != '') {
|
| 1612 | 1612 | $gd_country = $gd_country_actual; |
@@ -1616,12 +1616,12 @@ discard block |
||
| 1616 | 1616 | $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
| 1617 | 1617 | } |
| 1618 | 1618 | |
| 1619 | - $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
|
|
| 1619 | + $list_title .= __(' in', 'geodirectory')." '".$gd_country."'";
|
|
| 1620 | 1620 | } |
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | if (is_search()) {
|
| 1624 | - $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 1624 | + $list_title = __('Search', 'geodirectory').' '.__(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory').__(' For :', 'geodirectory')." '".get_search_query()."'";
|
|
| 1625 | 1625 | } |
| 1626 | 1626 | /** This action is documented in geodirectory_template_actions.php */ |
| 1627 | 1627 | $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
@@ -1631,26 +1631,26 @@ discard block |
||
| 1631 | 1631 | |
| 1632 | 1632 | $title = $list_title; |
| 1633 | 1633 | $gd_page = ''; |
| 1634 | - if(geodir_is_page('pt')){
|
|
| 1634 | + if (geodir_is_page('pt')) {
|
|
| 1635 | 1635 | $gd_page = 'pt'; |
| 1636 | - $title = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
|
|
| 1636 | + $title = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
|
|
| 1637 | 1637 | } |
| 1638 | - elseif(geodir_is_page('listing')){
|
|
| 1638 | + elseif (geodir_is_page('listing')) {
|
|
| 1639 | 1639 | $gd_page = 'listing'; |
| 1640 | 1640 | global $wp_query; |
| 1641 | 1641 | $current_term = $wp_query->get_queried_object(); |
| 1642 | - if (strpos($current_term->taxonomy,'_tags') !== false) {
|
|
| 1642 | + if (strpos($current_term->taxonomy, '_tags') !== false) {
|
|
| 1643 | 1643 | $title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
|
| 1644 | - }else{
|
|
| 1644 | + } else {
|
|
| 1645 | 1645 | $title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
|
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | } |
| 1649 | - elseif(geodir_is_page('author')){
|
|
| 1649 | + elseif (geodir_is_page('author')) {
|
|
| 1650 | 1650 | $gd_page = 'author'; |
| 1651 | - if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 1651 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 1652 | 1652 | $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
| 1653 | - }else{
|
|
| 1653 | + } else {
|
|
| 1654 | 1654 | $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
| 1655 | 1655 | } |
| 1656 | 1656 | |
@@ -1664,16 +1664,16 @@ discard block |
||
| 1664 | 1664 | * @param string $title The page title including variables. |
| 1665 | 1665 | * @param string $gd_page The GeoDirectory page type if any. |
| 1666 | 1666 | */ |
| 1667 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 1667 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 1668 | 1668 | |
| 1669 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 1669 | + echo '<header class="'.$class_header.'"><h1 class="'.$class.'">'. |
|
| 1670 | 1670 | /** |
| 1671 | 1671 | * Filter the listing page title. |
| 1672 | 1672 | * |
| 1673 | 1673 | * @since 1.0.0 |
| 1674 | 1674 | * @param string $list_title The title for the category page. |
| 1675 | 1675 | */ |
| 1676 | - apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
|
|
| 1676 | + apply_filters('geodir_listing_page_title', $title).'</h1></header>';
|
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | add_action('geodir_listings_page_description', 'geodir_action_listings_description', 10);
|
@@ -1692,16 +1692,16 @@ discard block |
||
| 1692 | 1692 | $gd_post_type = geodir_get_current_posttype(); |
| 1693 | 1693 | if (isset($current_term->term_id) && $current_term->term_id != '') {
|
| 1694 | 1694 | |
| 1695 | - $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags'); |
|
| 1695 | + $term_desc = term_description($current_term->term_id, $gd_post_type.'_tags'); |
|
| 1696 | 1696 | $saved_data = stripslashes(get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type)); |
| 1697 | 1697 | if ($term_desc && !$saved_data) {
|
| 1698 | 1698 | $saved_data = $term_desc; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | // stop payment manager filtering content length |
| 1702 | - $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); |
|
| 1703 | - if ( false !== $filter_priority ) {
|
|
| 1704 | - remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1702 | + $filter_priority = has_filter('the_content', 'geodir_payments_the_content');
|
|
| 1703 | + if (false !== $filter_priority) {
|
|
| 1704 | + remove_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | /** |
@@ -1715,14 +1715,14 @@ discard block |
||
| 1715 | 1715 | $cat_description = apply_filters('the_content', $saved_data);
|
| 1716 | 1716 | |
| 1717 | 1717 | |
| 1718 | - if ( false !== $filter_priority ) {
|
|
| 1719 | - add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1718 | + if (false !== $filter_priority) {
|
|
| 1719 | + add_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | if ($cat_description) {
|
| 1723 | 1723 | ?> |
| 1724 | 1724 | |
| 1725 | - <div class="term_description"><?php echo $cat_description;?></div> <?php |
|
| 1725 | + <div class="term_description"><?php echo $cat_description; ?></div> <?php |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | } |
@@ -1772,13 +1772,13 @@ discard block |
||
| 1772 | 1772 | function geodir_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '') |
| 1773 | 1773 | {
|
| 1774 | 1774 | if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
|
| 1775 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1775 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 1776 | 1776 | } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
|
| 1777 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1777 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 1778 | 1778 | } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
|
| 1779 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1779 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 1780 | 1780 | } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
|
| 1781 | - $width_css = 'style="width:' . $width . '%;"'; |
|
| 1781 | + $width_css = 'style="width:'.$width.'%;"'; |
|
| 1782 | 1782 | } else {
|
| 1783 | 1783 | $width_css = ''; |
| 1784 | 1784 | } |
@@ -2083,11 +2083,11 @@ discard block |
||
| 2083 | 2083 | |
| 2084 | 2084 | $title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
|
| 2085 | 2085 | |
| 2086 | - if(geodir_is_page('add-listing')){
|
|
| 2086 | + if (geodir_is_page('add-listing')) {
|
|
| 2087 | 2087 | $gd_page = 'add-listing'; |
| 2088 | - if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
|
|
| 2088 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2089 | 2089 | $title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
|
| 2090 | - }elseif(isset($listing_type)){
|
|
| 2090 | + }elseif (isset($listing_type)) {
|
|
| 2091 | 2091 | $title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
|
| 2092 | 2092 | } |
| 2093 | 2093 | |
@@ -2101,9 +2101,9 @@ discard block |
||
| 2101 | 2101 | * @param string $title The page title including variables. |
| 2102 | 2102 | * @param string $gd_page The GeoDirectory page type if any. |
| 2103 | 2103 | */ |
| 2104 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2104 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2105 | 2105 | |
| 2106 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">'; |
|
| 2106 | + echo '<header class="'.$class_header.'"><h1 class="'.$class.'">'; |
|
| 2107 | 2107 | echo $title; |
| 2108 | 2108 | echo '</h1></header>'; |
| 2109 | 2109 | } |
@@ -2117,7 +2117,7 @@ discard block |
||
| 2117 | 2117 | */ |
| 2118 | 2118 | function geodir_action_add_listing_page_mandatory() |
| 2119 | 2119 | {?>
|
| 2120 | - <p class="geodir-note "><span class="geodir-required">*</span> <?php echo INDICATES_MANDATORY_FIELDS_TEXT;?></p> |
|
| 2120 | + <p class="geodir-note "><span class="geodir-required">*</span> <?php echo INDICATES_MANDATORY_FIELDS_TEXT; ?></p> |
|
| 2121 | 2121 | <?php |
| 2122 | 2122 | } |
| 2123 | 2123 | |
@@ -2152,7 +2152,7 @@ discard block |
||
| 2152 | 2152 | |
| 2153 | 2153 | if (isset($_REQUEST['backandedit'])) {
|
| 2154 | 2154 | global $post; |
| 2155 | - $post = (object)$gd_session->get('listing');
|
|
| 2155 | + $post = (object) $gd_session->get('listing');
|
|
| 2156 | 2156 | $listing_type = $post->listing_type; |
| 2157 | 2157 | $title = $post->post_title; |
| 2158 | 2158 | $desc = $post->post_desc; |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | $thumb_img_arr = geodir_get_images($post->ID); |
| 2168 | 2168 | if ($thumb_img_arr) {
|
| 2169 | 2169 | foreach ($thumb_img_arr as $post_img) {
|
| 2170 | - $curImages .= $post_img->src . ','; |
|
| 2170 | + $curImages .= $post_img->src.','; |
|
| 2171 | 2171 | } |
| 2172 | 2172 | } |
| 2173 | 2173 | |
@@ -2175,7 +2175,7 @@ discard block |
||
| 2175 | 2175 | $title = $post->post_title; |
| 2176 | 2176 | $desc = $post->post_content; |
| 2177 | 2177 | $kw_tags = $post->post_tags; |
| 2178 | - $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
|
|
| 2178 | + $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type.'_tags', array('fields' => 'names')));
|
|
| 2179 | 2179 | } else {
|
| 2180 | 2180 | $listing_type = sanitize_text_field($_REQUEST['listing_type']); |
| 2181 | 2181 | } |
@@ -2186,20 +2186,20 @@ discard block |
||
| 2186 | 2186 | |
| 2187 | 2187 | $post_type_info = geodir_get_posttype_info($listing_type); |
| 2188 | 2188 | |
| 2189 | - $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
|
|
| 2189 | + $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing', 'geodirectory');
|
|
| 2190 | 2190 | |
| 2191 | 2191 | $package_info = array(); |
| 2192 | 2192 | $package_info = geodir_post_package_info($package_info, $post); |
| 2193 | 2193 | ?> |
| 2194 | - <form name="propertyform" id="propertyform" action="<?php echo get_page_link(geodir_preview_page_id());?>" method="post" enctype="multipart/form-data"> |
|
| 2195 | - <input type="hidden" name="preview" value="<?php echo sanitize_text_field($listing_type);?>"/> |
|
| 2196 | - <input type="hidden" name="listing_type" value="<?php echo sanitize_text_field($listing_type);?>"/> |
|
| 2194 | + <form name="propertyform" id="propertyform" action="<?php echo get_page_link(geodir_preview_page_id()); ?>" method="post" enctype="multipart/form-data"> |
|
| 2195 | + <input type="hidden" name="preview" value="<?php echo sanitize_text_field($listing_type); ?>"/> |
|
| 2196 | + <input type="hidden" name="listing_type" value="<?php echo sanitize_text_field($listing_type); ?>"/> |
|
| 2197 | 2197 | <?php if ($page_id) { ?>
|
| 2198 | - <input type="hidden" name="add_listing_page_id" value="<?php echo $page_id;?>"/> |
|
| 2198 | + <input type="hidden" name="add_listing_page_id" value="<?php echo $page_id; ?>"/> |
|
| 2199 | 2199 | <?php } if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { ?>
|
| 2200 | - <input type="hidden" name="pid" value="<?php echo sanitize_text_field($_REQUEST['pid']);?>"/> |
|
| 2200 | + <input type="hidden" name="pid" value="<?php echo sanitize_text_field($_REQUEST['pid']); ?>"/> |
|
| 2201 | 2201 | <?php } if (isset($_REQUEST['backandedit'])) { ?>
|
| 2202 | - <input type="hidden" name="backandedit" value="<?php echo sanitize_text_field($_REQUEST['backandedit']);?>"/> |
|
| 2202 | + <input type="hidden" name="backandedit" value="<?php echo sanitize_text_field($_REQUEST['backandedit']); ?>"/> |
|
| 2203 | 2203 | <?php |
| 2204 | 2204 | } |
| 2205 | 2205 | /** |
@@ -2211,7 +2211,7 @@ discard block |
||
| 2211 | 2211 | */ |
| 2212 | 2212 | do_action('geodir_before_detail_fields');
|
| 2213 | 2213 | ?> |
| 2214 | - <h5 id="geodir_fieldset_details" class="geodir-fieldset-row" gd-fieldset="details"><?php echo LISTING_DETAILS_TEXT;?></h5> |
|
| 2214 | + <h5 id="geodir_fieldset_details" class="geodir-fieldset-row" gd-fieldset="details"><?php echo LISTING_DETAILS_TEXT; ?></h5> |
|
| 2215 | 2215 | <?php |
| 2216 | 2216 | /** |
| 2217 | 2217 | * Called at the top of the add listing page form for frontend. |
@@ -2232,10 +2232,10 @@ discard block |
||
| 2232 | 2232 | * @param string $cpt_singular_name The singular title of the curent CPT. |
| 2233 | 2233 | * @param string $listing_type The CPT being requested. ie: gd_place. |
| 2234 | 2234 | */ |
| 2235 | - echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
|
|
| 2235 | + echo apply_filters('geodir_add_listing_title_label', sprintf(__('%s Title', 'geodirectory'), $cpt_singular_name), $cpt_singular_name, $listing_type); ?><span>*</span> </label>
|
|
| 2236 | 2236 | <input type="text" field_type="text" name="post_title" id="post_title" class="geodir_textfield" |
| 2237 | 2237 | value="<?php echo esc_attr(stripslashes($title)); ?>"/> |
| 2238 | - <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory');?></span> |
|
| 2238 | + <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
|
| 2239 | 2239 | </div> |
| 2240 | 2240 | <?php |
| 2241 | 2241 | $show_editor = get_option('geodir_tiny_editor_on_add_listing');
|
@@ -2281,7 +2281,7 @@ discard block |
||
| 2281 | 2281 | $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
|
| 2282 | 2282 | |
| 2283 | 2283 | $desc_class = ''; |
| 2284 | - if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2284 | + if ($desc_limit === '' || (int) $desc_limit > 0) {
|
|
| 2285 | 2285 | /** |
| 2286 | 2286 | * Called on the add listing page form for frontend just before the description field. |
| 2287 | 2287 | * |
@@ -2294,7 +2294,7 @@ discard block |
||
| 2294 | 2294 | $desc_class = ' hidden'; |
| 2295 | 2295 | } |
| 2296 | 2296 | ?> |
| 2297 | - <div id="geodir_post_desc_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $desc_class;?>"> |
|
| 2297 | + <div id="geodir_post_desc_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $desc_class; ?>"> |
|
| 2298 | 2298 | <label><?php |
| 2299 | 2299 | /** |
| 2300 | 2300 | * Filter the add listing page description input label. |
@@ -2304,7 +2304,7 @@ discard block |
||
| 2304 | 2304 | * @param string $cpt_singular_name The singular title of the curent CPT. |
| 2305 | 2305 | * @param string $listing_type The CPT being requested. ie: gd_place. |
| 2306 | 2306 | */ |
| 2307 | - echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
|
|
| 2307 | + echo apply_filters('geodir_add_listing_description_label', sprintf(__('%s Description', 'geodirectory'), $cpt_singular_name), $cpt_singular_name, $listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
|
|
| 2308 | 2308 | <?php |
| 2309 | 2309 | if ($show_editor) {
|
| 2310 | 2310 | $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
@@ -2313,16 +2313,16 @@ discard block |
||
| 2313 | 2313 | <?php wp_editor($desc, "post_desc", $editor_settings); ?> |
| 2314 | 2314 | </div> |
| 2315 | 2315 | <?php if ($desc_limit != '') { ?>
|
| 2316 | - <script type="text/javascript">jQuery('textarea#post_desc').attr('maxlength', "<?php echo $desc_limit;?>");</script>
|
|
| 2316 | + <script type="text/javascript">jQuery('textarea#post_desc').attr('maxlength', "<?php echo $desc_limit; ?>");</script>
|
|
| 2317 | 2317 | <?php } } else { ?>
|
| 2318 | 2318 | <textarea field_type="textarea" name="post_desc" id="post_desc" class="geodir_textarea" maxlength="<?php echo $desc_limit; ?>"><?php echo $desc; ?></textarea> |
| 2319 | 2319 | <?php } if ($desc_limit_msg != '') { ?>
|
| 2320 | 2320 | <span class="geodir_message_note"><?php echo $desc_limit_msg; ?></span> |
| 2321 | 2321 | <?php } ?> |
| 2322 | - <span class="geodir_message_error"><?php echo _e($required_msg, 'geodirectory');?></span> |
|
| 2322 | + <span class="geodir_message_error"><?php echo _e($required_msg, 'geodirectory'); ?></span> |
|
| 2323 | 2323 | </div> |
| 2324 | 2324 | <?php |
| 2325 | - if ($desc_limit === '' || (int)$desc_limit > 0) {
|
|
| 2325 | + if ($desc_limit === '' || (int) $desc_limit > 0) {
|
|
| 2326 | 2326 | /** |
| 2327 | 2327 | * Called on the add listing page form for frontend just after the description field. |
| 2328 | 2328 | * |
@@ -2361,7 +2361,7 @@ discard block |
||
| 2361 | 2361 | $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
|
| 2362 | 2362 | |
| 2363 | 2363 | $tags_class = ''; |
| 2364 | - if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2364 | + if ($kw_tags_count === '' || (int) $kw_tags_count > 0) {
|
|
| 2365 | 2365 | /** |
| 2366 | 2366 | * Called on the add listing page form for frontend just before the tags field. |
| 2367 | 2367 | * |
@@ -2372,14 +2372,14 @@ discard block |
||
| 2372 | 2372 | $tags_class = ' hidden'; |
| 2373 | 2373 | } |
| 2374 | 2374 | ?> |
| 2375 | - <div id="geodir_post_tags_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $tags_class;?>"> |
|
| 2375 | + <div id="geodir_post_tags_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $tags_class; ?>"> |
|
| 2376 | 2376 | <label><?php echo TAGKW_TEXT; ?></label> |
| 2377 | 2377 | <input name="post_tags" id="post_tags" value="<?php echo $kw_tags; ?>" type="text" class="geodir_textfield" |
| 2378 | - maxlength="<?php echo $kw_tags_count;?>"/> |
|
| 2379 | - <span class="geodir_message_note"><?php echo $kw_tags_msg;?></span> |
|
| 2378 | + maxlength="<?php echo $kw_tags_count; ?>"/> |
|
| 2379 | + <span class="geodir_message_note"><?php echo $kw_tags_msg; ?></span> |
|
| 2380 | 2380 | </div> |
| 2381 | 2381 | <?php |
| 2382 | - if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
|
|
| 2382 | + if ($kw_tags_count === '' || (int) $kw_tags_count > 0) {
|
|
| 2383 | 2383 | /** |
| 2384 | 2384 | * Called on the add listing page form for frontend just after the tags field. |
| 2385 | 2385 | * |
@@ -2405,7 +2405,7 @@ discard block |
||
| 2405 | 2405 | $thumb_img_arr = array(); |
| 2406 | 2406 | $totImg = 0; |
| 2407 | 2407 | if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
|
| 2408 | - $post = (object)$gd_session->get('listing');
|
|
| 2408 | + $post = (object) $gd_session->get('listing');
|
|
| 2409 | 2409 | if (isset($post->post_images)) |
| 2410 | 2410 | $curImages = trim($post->post_images, ","); |
| 2411 | 2411 | |
@@ -2418,7 +2418,7 @@ discard block |
||
| 2418 | 2418 | $listing_type = $post->listing_type; |
| 2419 | 2419 | |
| 2420 | 2420 | } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
| 2421 | - $post = geodir_get_post_info((int)$_REQUEST['pid']); |
|
| 2421 | + $post = geodir_get_post_info((int) $_REQUEST['pid']); |
|
| 2422 | 2422 | $listing_type = $post->post_type; |
| 2423 | 2423 | $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
| 2424 | 2424 | |
@@ -2432,7 +2432,7 @@ discard block |
||
| 2432 | 2432 | //$curImages = $img->src.","; |
| 2433 | 2433 | } |
| 2434 | 2434 | |
| 2435 | - $totImg = count((array)$thumb_img_arr); |
|
| 2435 | + $totImg = count((array) $thumb_img_arr); |
|
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | 2438 | if ($curImages != '') |
@@ -2453,15 +2453,15 @@ discard block |
||
| 2453 | 2453 | if ($show_image_input_box) {
|
| 2454 | 2454 | ?> |
| 2455 | 2455 | |
| 2456 | - <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php echo PRO_PHOTO_TEXT;?> |
|
| 2456 | + <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php echo PRO_PHOTO_TEXT; ?> |
|
| 2457 | 2457 | <?php if ($image_limit == 1) {
|
| 2458 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2458 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
|
|
| 2459 | 2459 | } ?> |
| 2460 | 2460 | <?php if ($image_limit > 1) {
|
| 2461 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2461 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
|
|
| 2462 | 2462 | } ?> |
| 2463 | 2463 | <?php if ($image_limit == '') {
|
| 2464 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2464 | + echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
|
|
| 2465 | 2465 | } ?> |
| 2466 | 2466 | </h5> |
| 2467 | 2467 | |
@@ -2476,11 +2476,11 @@ discard block |
||
| 2476 | 2476 | <div |
| 2477 | 2477 | class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" |
| 2478 | 2478 | id="<?php echo $id; ?>plupload-upload-ui"> |
| 2479 | - <h4><?php _e('Drop files to upload', 'geodirectory');?></h4><br/>
|
|
| 2479 | + <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4><br/>
|
|
| 2480 | 2480 | <input id="<?php echo $id; ?>plupload-browse-button" type="button" |
| 2481 | 2481 | value="<?php esc_attr_e('Select Files', 'geodirectory'); ?>" class="geodir_button"/>
|
| 2482 | 2482 | <span class="ajaxnonceplu" |
| 2483 | - id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span> |
|
| 2483 | + id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span> |
|
| 2484 | 2484 | <?php if ($width && $height): ?> |
| 2485 | 2485 | <span class="plupload-resize"></span> |
| 2486 | 2486 | <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span> |
@@ -2493,7 +2493,7 @@ discard block |
||
| 2493 | 2493 | id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;"> |
| 2494 | 2494 | </div> |
| 2495 | 2495 | <span |
| 2496 | - id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory');?></span>
|
|
| 2496 | + id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory'); ?></span>
|
|
| 2497 | 2497 | <span id="<?php echo $id; ?>upload-error" style="display:none"></span> |
| 2498 | 2498 | </div> |
| 2499 | 2499 | |
@@ -2505,7 +2505,7 @@ discard block |
||
| 2505 | 2505 | * |
| 2506 | 2506 | * @since 1.0.0 |
| 2507 | 2507 | */ |
| 2508 | - do_action('geodir_after_main_form_fields');?>
|
|
| 2508 | + do_action('geodir_after_main_form_fields'); ?>
|
|
| 2509 | 2509 | |
| 2510 | 2510 | |
| 2511 | 2511 | <!-- add captcha code --> |
@@ -2516,7 +2516,7 @@ discard block |
||
| 2516 | 2516 | </script> |
| 2517 | 2517 | <noscript> |
| 2518 | 2518 | <div> |
| 2519 | - <label><?php _e('Type 64 into this box', 'geodirectory');?></label>
|
|
| 2519 | + <label><?php _e('Type 64 into this box', 'geodirectory'); ?></label>
|
|
| 2520 | 2520 | <input type="text" id="geodir_spamblocker_top_form" name="geodir_spamblocker" value="" maxlength="10"/> |
| 2521 | 2521 | </div> |
| 2522 | 2522 | </noscript> |
@@ -2526,10 +2526,10 @@ discard block |
||
| 2526 | 2526 | <!-- end captcha code --> |
| 2527 | 2527 | |
| 2528 | 2528 | <div id="geodir-add-listing-submit" class="geodir_form_row clear_both" style="padding:2px;text-align:center;"> |
| 2529 | - <input type="submit" value="<?php echo PRO_PREVIEW_BUTTON;?>" |
|
| 2530 | - class="geodir_button" <?php echo $submit_button;?>/> |
|
| 2529 | + <input type="submit" value="<?php echo PRO_PREVIEW_BUTTON; ?>" |
|
| 2530 | + class="geodir_button" <?php echo $submit_button; ?>/> |
|
| 2531 | 2531 | <span class="geodir_message_note" |
| 2532 | - style="padding-left:0px;"> <?php _e('Note: You will be able to see a preview in the next page', 'geodirectory');?></span>
|
|
| 2532 | + style="padding-left:0px;"> <?php _e('Note: You will be able to see a preview in the next page', 'geodirectory'); ?></span>
|
|
| 2533 | 2533 | </div> |
| 2534 | 2534 | |
| 2535 | 2535 | </form> |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | class="<?php |
| 2592 | 2592 | /** This action is documented in geodirectory_template_actions.php */ |
| 2593 | 2593 | echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
|
| 2594 | - <?php dynamic_sidebar('Reg/Login Top Section');?>
|
|
| 2594 | + <?php dynamic_sidebar('Reg/Login Top Section'); ?>
|
|
| 2595 | 2595 | </div><!-- clearfix ends here--> |
| 2596 | 2596 | <?php |
| 2597 | 2597 | } |
@@ -2611,11 +2611,11 @@ discard block |
||
| 2611 | 2611 | |
| 2612 | 2612 | global $user_login; |
| 2613 | 2613 | |
| 2614 | - $is_enable_signup = get_option( 'users_can_register' ); |
|
| 2614 | + $is_enable_signup = get_option('users_can_register');
|
|
| 2615 | 2615 | |
| 2616 | 2616 | ?> |
| 2617 | 2617 | <script type="text/javascript"> |
| 2618 | - <?php if ( $user_login ) { ?>
|
|
| 2618 | + <?php if ($user_login) { ?>
|
|
| 2619 | 2619 | setTimeout(function () {
|
| 2620 | 2620 | try {
|
| 2621 | 2621 | d = document.getElementById('user_pass');
|
@@ -2632,7 +2632,7 @@ discard block |
||
| 2632 | 2632 | <?php } ?> |
| 2633 | 2633 | </script> |
| 2634 | 2634 | <script type="text/javascript"> |
| 2635 | - <?php if ( $user_login ) { ?>
|
|
| 2635 | + <?php if ($user_login) { ?>
|
|
| 2636 | 2636 | setTimeout(function () {
|
| 2637 | 2637 | try {
|
| 2638 | 2638 | d = document.getElementById('user_pass');
|
@@ -2657,7 +2657,7 @@ discard block |
||
| 2657 | 2657 | foreach ($errors as $errorsObj) {
|
| 2658 | 2658 | foreach ($errorsObj as $key => $val) {
|
| 2659 | 2659 | for ($i = 0; $i < count($val); $i++) {
|
| 2660 | - echo "<div class=error_msg_fix>" . $val[$i] . '</div>'; |
|
| 2660 | + echo "<div class=error_msg_fix>".$val[$i].'</div>'; |
|
| 2661 | 2661 | $registration_error_msg = 1; |
| 2662 | 2662 | } |
| 2663 | 2663 | } |
@@ -2674,10 +2674,10 @@ discard block |
||
| 2674 | 2674 | * |
| 2675 | 2675 | * @since 1.0.0 |
| 2676 | 2676 | */ |
| 2677 | - include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2677 | + include(geodir_plugin_path()."/geodirectory-templates/login_frm.php"); ?> |
|
| 2678 | 2678 | </div> |
| 2679 | 2679 | |
| 2680 | - <?php } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_up' && $is_enable_signup ) { ?>
|
|
| 2680 | + <?php } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_up' && $is_enable_signup) { ?>
|
|
| 2681 | 2681 | |
| 2682 | 2682 | <div class="registration_form"> |
| 2683 | 2683 | <?php |
@@ -2686,7 +2686,7 @@ discard block |
||
| 2686 | 2686 | * |
| 2687 | 2687 | * @since 1.0.0 |
| 2688 | 2688 | */ |
| 2689 | - include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2689 | + include(geodir_plugin_path()."/geodirectory-templates/reg_frm.php"); ?> |
|
| 2690 | 2690 | </div> |
| 2691 | 2691 | |
| 2692 | 2692 | <?php } else { ?>
|
@@ -2698,10 +2698,10 @@ discard block |
||
| 2698 | 2698 | * |
| 2699 | 2699 | * @since 1.0.0 |
| 2700 | 2700 | */ |
| 2701 | - include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?> |
|
| 2701 | + include(geodir_plugin_path()."/geodirectory-templates/login_frm.php"); ?> |
|
| 2702 | 2702 | </div> |
| 2703 | 2703 | |
| 2704 | - <?php if ( $is_enable_signup ) { ?>
|
|
| 2704 | + <?php if ($is_enable_signup) { ?>
|
|
| 2705 | 2705 | <div class="registration_form_r"> |
| 2706 | 2706 | <?php |
| 2707 | 2707 | /** |
@@ -2709,7 +2709,7 @@ discard block |
||
| 2709 | 2709 | * |
| 2710 | 2710 | * @since 1.0.0 |
| 2711 | 2711 | */ |
| 2712 | - include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?> |
|
| 2712 | + include(geodir_plugin_path()."/geodirectory-templates/reg_frm.php"); ?> |
|
| 2713 | 2713 | </div> |
| 2714 | 2714 | <?php } ?> |
| 2715 | 2715 | |
@@ -2746,12 +2746,12 @@ discard block |
||
| 2746 | 2746 | $gd_post_type = geodir_get_current_posttype(); |
| 2747 | 2747 | $post_type_info = get_post_type_object($gd_post_type); |
| 2748 | 2748 | |
| 2749 | - $add_string_in_title = __('All', 'geodirectory') . ' ';
|
|
| 2749 | + $add_string_in_title = __('All', 'geodirectory').' ';
|
|
| 2750 | 2750 | if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
| 2751 | - $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
|
|
| 2751 | + $add_string_in_title = __('My Favorite', 'geodirectory').' ';
|
|
| 2752 | 2752 | } |
| 2753 | 2753 | |
| 2754 | - $list_title = $add_string_in_title . $post_type_info->labels->name; |
|
| 2754 | + $list_title = $add_string_in_title.$post_type_info->labels->name; |
|
| 2755 | 2755 | $single_name = $post_type_info->labels->singular_name; |
| 2756 | 2756 | |
| 2757 | 2757 | $taxonomy = geodir_get_taxonomies($gd_post_type); |
@@ -2759,12 +2759,12 @@ discard block |
||
| 2759 | 2759 | if (!empty($term)) {
|
| 2760 | 2760 | $current_term = get_term_by('slug', $term, $taxonomy[0]);
|
| 2761 | 2761 | if (!empty($current_term)) |
| 2762 | - $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
|
|
| 2762 | + $list_title .= __(' in', 'geodirectory')." '".geodir_ucwords($current_term->name)."'";
|
|
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | 2765 | |
| 2766 | 2766 | if (is_search()) {
|
| 2767 | - $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 2767 | + $list_title = __('Search', 'geodirectory').' '.__($post_type_info->labels->name, 'geodirectory').__(' For :', 'geodirectory')." '".get_search_query()."'";
|
|
| 2768 | 2768 | |
| 2769 | 2769 | } |
| 2770 | 2770 | /** This action is documented in geodirectory_template_actions.php */ |
@@ -2773,11 +2773,11 @@ discard block |
||
| 2773 | 2773 | $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
| 2774 | 2774 | |
| 2775 | 2775 | $title = $list_title; |
| 2776 | - if(geodir_is_page('author')){
|
|
| 2776 | + if (geodir_is_page('author')) {
|
|
| 2777 | 2777 | $gd_page = 'author'; |
| 2778 | - if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
|
|
| 2778 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 2779 | 2779 | $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
|
| 2780 | - }else{
|
|
| 2780 | + } else {
|
|
| 2781 | 2781 | $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
|
| 2782 | 2782 | } |
| 2783 | 2783 | |
@@ -2791,16 +2791,16 @@ discard block |
||
| 2791 | 2791 | * @param string $title The page title including variables. |
| 2792 | 2792 | * @param string $gd_page The GeoDirectory page type if any. |
| 2793 | 2793 | */ |
| 2794 | - $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2794 | + $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
|
|
| 2795 | 2795 | |
| 2796 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 2796 | + echo '<header class="'.$class_header.'"><h1 class="'.$class.'">'. |
|
| 2797 | 2797 | /** |
| 2798 | 2798 | * Filter the author page title text. |
| 2799 | 2799 | * |
| 2800 | 2800 | * @since 1.0.0 |
| 2801 | 2801 | * @param string $list_title The title for the page. |
| 2802 | 2802 | */ |
| 2803 | - apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
|
|
| 2803 | + apply_filters('geodir_author_page_title_text', $title).'</h1></header>';
|
|
| 2804 | 2804 | } |
| 2805 | 2805 | |
| 2806 | 2806 | |
@@ -3005,19 +3005,19 @@ discard block |
||
| 3005 | 3005 | $post_type_info = get_post_type_object($gd_post_type); |
| 3006 | 3006 | |
| 3007 | 3007 | $pt_name = ''; |
| 3008 | - if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
|
|
| 3008 | + if (isset($post_type_info->labels->name)) {$pt_name = $post_type_info->labels->name; }
|
|
| 3009 | 3009 | |
| 3010 | 3010 | if (is_search()) {
|
| 3011 | - $list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
|
|
| 3011 | + $list_title = __('Search', 'geodirectory').' '.__($pt_name, 'geodirectory').__(' For :', 'geodirectory')." '".get_search_query()."'";
|
|
| 3012 | 3012 | |
| 3013 | 3013 | } |
| 3014 | 3014 | /** This action is documented in geodirectory_template_actions.php */ |
| 3015 | 3015 | $class = apply_filters('geodir_page_title_class', 'entry-title fn');
|
| 3016 | 3016 | /** This action is documented in geodirectory_template_actions.php */ |
| 3017 | 3017 | $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
|
| 3018 | - echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . |
|
| 3018 | + echo '<header class="'.$class_header.'"><h1 class="'.$class.'">'. |
|
| 3019 | 3019 | /** This action is documented in geodirectory_template_actions.php */ |
| 3020 | - apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
|
|
| 3020 | + apply_filters('geodir_listing_page_title', wptexturize($list_title)).'</h1></header>';
|
|
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | 3023 | // action for adding the listings page top widget area |
@@ -3421,7 +3421,7 @@ discard block |
||
| 3421 | 3421 | $gd_post_type = geodir_get_current_posttype(); |
| 3422 | 3422 | $post_type_info = get_post_type_object($gd_post_type); |
| 3423 | 3423 | |
| 3424 | - $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
|
|
| 3424 | + $list_title = __('Search', 'geodirectory').' '.__(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory').__(' :', 'geodirectory');
|
|
| 3425 | 3425 | } |
| 3426 | 3426 | return $list_title; |
| 3427 | 3427 | } |
@@ -3437,7 +3437,7 @@ discard block |
||
| 3437 | 3437 | * @param string $position Position to add the post content. 'before' or 'after'. Default 'before'. |
| 3438 | 3438 | * @param string $gd_page The geodirectory page type. Default null. |
| 3439 | 3439 | */ |
| 3440 | -function geodir_add_page_content( $position = 'before', $gd_page = '' ) {
|
|
| 3440 | +function geodir_add_page_content($position = 'before', $gd_page = '') {
|
|
| 3441 | 3441 | global $post; |
| 3442 | 3442 | |
| 3443 | 3443 | $gd_page_id = NULL; |
@@ -3513,17 +3513,17 @@ discard block |
||
| 3513 | 3513 | * @param WP_Post $post WP_Post object. |
| 3514 | 3514 | * @return string Filtered SQL JOIN clause. |
| 3515 | 3515 | */ |
| 3516 | -function geodir_previous_next_post_join( $join, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
|
| 3516 | +function geodir_previous_next_post_join($join, $in_same_term, $excluded_terms, $taxonomy, $post) {
|
|
| 3517 | 3517 | global $plugin_prefix; |
| 3518 | 3518 | |
| 3519 | - if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3520 | - $join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID"; |
|
| 3519 | + if (!empty($post->post_type) && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 3520 | + $join .= " INNER JOIN ".$plugin_prefix.$post->post_type."_detail AS gd ON gd.post_id = p.ID"; |
|
| 3521 | 3521 | } |
| 3522 | 3522 | |
| 3523 | 3523 | return $join; |
| 3524 | 3524 | } |
| 3525 | -add_filter( 'get_previous_post_join', 'geodir_previous_next_post_join', 10, 5 ); |
|
| 3526 | -add_filter( 'get_next_post_join', 'geodir_previous_next_post_join', 10, 5 ); |
|
| 3525 | +add_filter('get_previous_post_join', 'geodir_previous_next_post_join', 10, 5);
|
|
| 3526 | +add_filter('get_next_post_join', 'geodir_previous_next_post_join', 10, 5);
|
|
| 3527 | 3527 | |
| 3528 | 3528 | /** |
| 3529 | 3529 | * Filters the WHERE clause in the SQL for an adjacent post query. |
@@ -3541,32 +3541,32 @@ discard block |
||
| 3541 | 3541 | * @param WP_Post $post WP_Post object. |
| 3542 | 3542 | * @return string Filtered SQL WHERE clause. |
| 3543 | 3543 | */ |
| 3544 | -function geodir_previous_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
|
| 3544 | +function geodir_previous_next_post_where($where, $in_same_term, $excluded_terms, $taxonomy, $post) {
|
|
| 3545 | 3545 | global $wpdb, $plugin_prefix; |
| 3546 | 3546 | |
| 3547 | - if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 3547 | + if (!empty($post->post_type) && (!empty($post->country_slug) || !empty($post->region_slug) || !empty($post->city_slug)) && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 3548 | 3548 | $post_locations = ''; |
| 3549 | 3549 | $post_locations_var = array(); |
| 3550 | 3550 | |
| 3551 | - if ( !empty( $post->country_slug ) ) {
|
|
| 3551 | + if (!empty($post->country_slug)) {
|
|
| 3552 | 3552 | $post_locations .= " AND post_locations LIKE %s"; |
| 3553 | - $post_locations_var[] = "%,[" . $post->country_slug . "]"; |
|
| 3553 | + $post_locations_var[] = "%,[".$post->country_slug."]"; |
|
| 3554 | 3554 | } |
| 3555 | 3555 | |
| 3556 | - if ( !empty( $post->region_slug ) ) {
|
|
| 3556 | + if (!empty($post->region_slug)) {
|
|
| 3557 | 3557 | $post_locations .= " AND post_locations LIKE %s"; |
| 3558 | - $post_locations_var[] = "%,[" . $post->region_slug . "],%"; |
|
| 3558 | + $post_locations_var[] = "%,[".$post->region_slug."],%"; |
|
| 3559 | 3559 | } |
| 3560 | 3560 | |
| 3561 | - if ( !empty( $post->city_slug ) ) {
|
|
| 3561 | + if (!empty($post->city_slug)) {
|
|
| 3562 | 3562 | $post_locations .= " AND post_locations LIKE %s"; |
| 3563 | - $post_locations_var[] = "[" . $post->city_slug . "],%"; |
|
| 3563 | + $post_locations_var[] = "[".$post->city_slug."],%"; |
|
| 3564 | 3564 | } |
| 3565 | 3565 | |
| 3566 | - $where .= $wpdb->prepare( $post_locations, $post_locations_var ); |
|
| 3566 | + $where .= $wpdb->prepare($post_locations, $post_locations_var); |
|
| 3567 | 3567 | } |
| 3568 | 3568 | |
| 3569 | 3569 | return $where; |
| 3570 | 3570 | } |
| 3571 | -add_filter( 'get_previous_post_where', 'geodir_previous_next_post_where', 10, 5 ); |
|
| 3572 | -add_filter( 'get_next_post_where', 'geodir_previous_next_post_where', 10, 5 ); |
|
| 3573 | 3571 | \ No newline at end of file |
| 3572 | +add_filter('get_previous_post_where', 'geodir_previous_next_post_where', 10, 5);
|
|
| 3573 | +add_filter('get_next_post_where', 'geodir_previous_next_post_where', 10, 5); |
|
| 3574 | 3574 | \ No newline at end of file |
@@ -13,28 +13,28 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function geodir_user_favourite_listing_count($user_id=false) |
| 15 | 15 | { |
| 16 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 16 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 17 | 17 | |
| 18 | - if(!$user_id){$user_id = $current_user->ID;} |
|
| 19 | - if(!$user_id){return array();} |
|
| 18 | + if(!$user_id){$user_id = $current_user->ID;} |
|
| 19 | + if(!$user_id){return array();} |
|
| 20 | 20 | |
| 21 | - $user_favorites = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 22 | - $all_posts = get_option('geodir_favorite_link_user_dashboard'); |
|
| 21 | + $user_favorites = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 22 | + $all_posts = get_option('geodir_favorite_link_user_dashboard'); |
|
| 23 | 23 | |
| 24 | - $user_listing = array(); |
|
| 25 | - if (is_array($all_posts) && !empty($all_posts) && is_array($user_favorites) && !empty($user_favorites)) { |
|
| 26 | - $user_favorites = "'" . implode("','", $user_favorites) . "'"; |
|
| 24 | + $user_listing = array(); |
|
| 25 | + if (is_array($all_posts) && !empty($all_posts) && is_array($user_favorites) && !empty($user_favorites)) { |
|
| 26 | + $user_favorites = "'" . implode("','", $user_favorites) . "'"; |
|
| 27 | 27 | |
| 28 | - foreach ($all_posts as $ptype) { |
|
| 29 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_type='" . $ptype . "' AND post_status = 'publish' AND ID IN (" . $user_favorites . ")"); |
|
| 28 | + foreach ($all_posts as $ptype) { |
|
| 29 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_type='" . $ptype . "' AND post_status = 'publish' AND ID IN (" . $user_favorites . ")"); |
|
| 30 | 30 | |
| 31 | - if ($total_posts > 0) { |
|
| 32 | - $user_listing[$ptype] = $total_posts; |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 31 | + if ($total_posts > 0) { |
|
| 32 | + $user_listing[$ptype] = $total_posts; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return $user_listing; |
|
| 37 | + return $user_listing; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -47,51 +47,51 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | |
| 49 | 49 | function geodir_user_show_favourites($user_id='',$output_type='select'){ |
| 50 | - // My Favourites in Dashboard |
|
| 51 | - $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard'); |
|
| 52 | - $user_favourite = geodir_user_favourite_listing_count($user_id); |
|
| 53 | - |
|
| 54 | - if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) { |
|
| 55 | - $favourite_links = ''; |
|
| 56 | - $post_types = geodir_get_posttypes('object'); |
|
| 57 | - |
|
| 58 | - $author_link = get_author_posts_url($user_id); |
|
| 59 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false); |
|
| 60 | - |
|
| 61 | - foreach ($post_types as $key => $postobj) { |
|
| 62 | - if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) { |
|
| 63 | - $name = $postobj->labels->name; |
|
| 64 | - $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false); |
|
| 65 | - |
|
| 66 | - $selected = ''; |
|
| 67 | - |
|
| 68 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) { |
|
| 69 | - $selected = 'selected="selected"'; |
|
| 70 | - } |
|
| 71 | - /** |
|
| 72 | - * Filter favorite listing link. |
|
| 73 | - * |
|
| 74 | - * @since 1.0.0 |
|
| 75 | - * @param string $post_type_link Favorite listing link. |
|
| 76 | - * @param string $key Favorite listing array key. |
|
| 77 | - * @param int $current_user->ID Current user ID. |
|
| 78 | - */ |
|
| 79 | - $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $user_id); |
|
| 80 | - |
|
| 81 | - if($output_type=='select'){ |
|
| 82 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 83 | - }elseif($output_type=='link'){ |
|
| 84 | - $favourite_links[] = '<a href="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - if ($favourite_links != '') { |
|
| 92 | - $user = get_user_by( 'ID', $user_id ); |
|
| 93 | - if($output_type=='select') { |
|
| 94 | - ?> |
|
| 50 | + // My Favourites in Dashboard |
|
| 51 | + $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard'); |
|
| 52 | + $user_favourite = geodir_user_favourite_listing_count($user_id); |
|
| 53 | + |
|
| 54 | + if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) { |
|
| 55 | + $favourite_links = ''; |
|
| 56 | + $post_types = geodir_get_posttypes('object'); |
|
| 57 | + |
|
| 58 | + $author_link = get_author_posts_url($user_id); |
|
| 59 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false); |
|
| 60 | + |
|
| 61 | + foreach ($post_types as $key => $postobj) { |
|
| 62 | + if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) { |
|
| 63 | + $name = $postobj->labels->name; |
|
| 64 | + $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false); |
|
| 65 | + |
|
| 66 | + $selected = ''; |
|
| 67 | + |
|
| 68 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) { |
|
| 69 | + $selected = 'selected="selected"'; |
|
| 70 | + } |
|
| 71 | + /** |
|
| 72 | + * Filter favorite listing link. |
|
| 73 | + * |
|
| 74 | + * @since 1.0.0 |
|
| 75 | + * @param string $post_type_link Favorite listing link. |
|
| 76 | + * @param string $key Favorite listing array key. |
|
| 77 | + * @param int $current_user->ID Current user ID. |
|
| 78 | + */ |
|
| 79 | + $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $user_id); |
|
| 80 | + |
|
| 81 | + if($output_type=='select'){ |
|
| 82 | + $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 83 | + }elseif($output_type=='link'){ |
|
| 84 | + $favourite_links[] = '<a href="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + if ($favourite_links != '') { |
|
| 92 | + $user = get_user_by( 'ID', $user_id ); |
|
| 93 | + if($output_type=='select') { |
|
| 94 | + ?> |
|
| 95 | 95 | <li> |
| 96 | 96 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" |
| 97 | 97 | option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" |
@@ -102,62 +102,62 @@ discard block |
||
| 102 | 102 | </select> |
| 103 | 103 | </li> |
| 104 | 104 | <?php |
| 105 | - }elseif($output_type=='link'){ |
|
| 106 | - if(!empty($favourite_links)){ |
|
| 107 | - echo implode(" | ",$favourite_links); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 105 | + }elseif($output_type=='link'){ |
|
| 106 | + if(!empty($favourite_links)){ |
|
| 107 | + echo implode(" | ",$favourite_links); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | function geodir_user_show_listings($user_id='',$output_type='select'){ |
| 118 | 118 | |
| 119 | - $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard'); |
|
| 120 | - $user_listing = geodir_user_post_listing_count($user_id); |
|
| 121 | - |
|
| 122 | - if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) { |
|
| 123 | - $listing_links = ''; |
|
| 124 | - |
|
| 125 | - $post_types = geodir_get_posttypes('object'); |
|
| 126 | - |
|
| 127 | - $author_link = get_author_posts_url($user_id); |
|
| 128 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false); |
|
| 129 | - |
|
| 130 | - foreach ($post_types as $key => $postobj) { |
|
| 131 | - if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) { |
|
| 132 | - $name = $postobj->labels->name; |
|
| 133 | - $listing_link = geodir_getlink($author_link, array('stype' => $key), false); |
|
| 134 | - |
|
| 135 | - $selected = ''; |
|
| 136 | - if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) { |
|
| 137 | - $selected = 'selected="selected"'; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Filter my listing link. |
|
| 142 | - * |
|
| 143 | - * @since 1.0.0 |
|
| 144 | - * @param string $listing_link My listing link. |
|
| 145 | - * @param string $key My listing array key. |
|
| 146 | - * @param int $current_user->ID Current user ID. |
|
| 147 | - */ |
|
| 148 | - $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $user_id); |
|
| 149 | - if($output_type=='select') { |
|
| 150 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 151 | - }elseif($output_type=='link'){ |
|
| 152 | - $listing_links[] = '<a href="' .$listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if ($listing_links != '') { |
|
| 158 | - $user = get_user_by( 'ID', $user_id ); |
|
| 159 | - if($output_type=='select') { |
|
| 160 | - ?> |
|
| 119 | + $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard'); |
|
| 120 | + $user_listing = geodir_user_post_listing_count($user_id); |
|
| 121 | + |
|
| 122 | + if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) { |
|
| 123 | + $listing_links = ''; |
|
| 124 | + |
|
| 125 | + $post_types = geodir_get_posttypes('object'); |
|
| 126 | + |
|
| 127 | + $author_link = get_author_posts_url($user_id); |
|
| 128 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false); |
|
| 129 | + |
|
| 130 | + foreach ($post_types as $key => $postobj) { |
|
| 131 | + if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) { |
|
| 132 | + $name = $postobj->labels->name; |
|
| 133 | + $listing_link = geodir_getlink($author_link, array('stype' => $key), false); |
|
| 134 | + |
|
| 135 | + $selected = ''; |
|
| 136 | + if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) { |
|
| 137 | + $selected = 'selected="selected"'; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Filter my listing link. |
|
| 142 | + * |
|
| 143 | + * @since 1.0.0 |
|
| 144 | + * @param string $listing_link My listing link. |
|
| 145 | + * @param string $key My listing array key. |
|
| 146 | + * @param int $current_user->ID Current user ID. |
|
| 147 | + */ |
|
| 148 | + $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $user_id); |
|
| 149 | + if($output_type=='select') { |
|
| 150 | + $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 151 | + }elseif($output_type=='link'){ |
|
| 152 | + $listing_links[] = '<a href="' .$listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if ($listing_links != '') { |
|
| 158 | + $user = get_user_by( 'ID', $user_id ); |
|
| 159 | + if($output_type=='select') { |
|
| 160 | + ?> |
|
| 161 | 161 | <li> |
| 162 | 162 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" |
| 163 | 163 | option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | </select> |
| 169 | 169 | </li> |
| 170 | 170 | <?php |
| 171 | - }elseif($output_type=='link'){ |
|
| 172 | - if(!empty($listing_links )){ |
|
| 173 | - echo implode(" | ",$listing_links ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 171 | + }elseif($output_type=='link'){ |
|
| 172 | + if(!empty($listing_links )){ |
|
| 173 | + echo implode(" | ",$listing_links ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | } |
@@ -11,22 +11,22 @@ discard block |
||
| 11 | 11 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 12 | 12 | * @return array User listing count for each post type. |
| 13 | 13 | */ |
| 14 | -function geodir_user_favourite_listing_count($user_id=false) |
|
| 14 | +function geodir_user_favourite_listing_count($user_id = false) |
|
| 15 | 15 | { |
| 16 | 16 | global $wpdb, $plugin_prefix, $current_user; |
| 17 | 17 | |
| 18 | - if(!$user_id){$user_id = $current_user->ID;} |
|
| 19 | - if(!$user_id){return array();} |
|
| 18 | + if (!$user_id) {$user_id = $current_user->ID; } |
|
| 19 | + if (!$user_id) {return array(); } |
|
| 20 | 20 | |
| 21 | 21 | $user_favorites = get_user_meta($user_id, 'gd_user_favourite_post', true); |
| 22 | 22 | $all_posts = get_option('geodir_favorite_link_user_dashboard'); |
| 23 | 23 | |
| 24 | 24 | $user_listing = array(); |
| 25 | 25 | if (is_array($all_posts) && !empty($all_posts) && is_array($user_favorites) && !empty($user_favorites)) { |
| 26 | - $user_favorites = "'" . implode("','", $user_favorites) . "'"; |
|
| 26 | + $user_favorites = "'".implode("','", $user_favorites)."'"; |
|
| 27 | 27 | |
| 28 | 28 | foreach ($all_posts as $ptype) { |
| 29 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_type='" . $ptype . "' AND post_status = 'publish' AND ID IN (" . $user_favorites . ")"); |
|
| 29 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM ".$wpdb->prefix."posts WHERE post_type='".$ptype."' AND post_status = 'publish' AND ID IN (".$user_favorites.")"); |
|
| 30 | 30 | |
| 31 | 31 | if ($total_posts > 0) { |
| 32 | 32 | $user_listing[$ptype] = $total_posts; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @package GeoDirectory |
| 47 | 47 | */ |
| 48 | 48 | |
| 49 | -function geodir_user_show_favourites($user_id='',$output_type='select'){ |
|
| 49 | +function geodir_user_show_favourites($user_id = '', $output_type = 'select') { |
|
| 50 | 50 | // My Favourites in Dashboard |
| 51 | 51 | $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard'); |
| 52 | 52 | $user_favourite = geodir_user_favourite_listing_count($user_id); |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $user_id); |
| 80 | 80 | |
| 81 | - if($output_type=='select'){ |
|
| 82 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 83 | - }elseif($output_type=='link'){ |
|
| 84 | - $favourite_links[] = '<a href="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 81 | + if ($output_type == 'select') { |
|
| 82 | + $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</option>'; |
|
| 83 | + }elseif ($output_type == 'link') { |
|
| 84 | + $favourite_links[] = '<a href="'.$post_type_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</a>'; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | if ($favourite_links != '') { |
| 92 | - $user = get_user_by( 'ID', $user_id ); |
|
| 93 | - if($output_type=='select') { |
|
| 92 | + $user = get_user_by('ID', $user_id); |
|
| 93 | + if ($output_type == 'select') { |
|
| 94 | 94 | ?> |
| 95 | 95 | <li> |
| 96 | 96 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | </select> |
| 103 | 103 | </li> |
| 104 | 104 | <?php |
| 105 | - }elseif($output_type=='link'){ |
|
| 106 | - if(!empty($favourite_links)){ |
|
| 107 | - echo implode(" | ",$favourite_links); |
|
| 105 | + }elseif ($output_type == 'link') { |
|
| 106 | + if (!empty($favourite_links)) { |
|
| 107 | + echo implode(" | ", $favourite_links); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | -function geodir_user_show_listings($user_id='',$output_type='select'){ |
|
| 117 | +function geodir_user_show_listings($user_id = '', $output_type = 'select') { |
|
| 118 | 118 | |
| 119 | 119 | $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard'); |
| 120 | 120 | $user_listing = geodir_user_post_listing_count($user_id); |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | * @param int $current_user->ID Current user ID. |
| 147 | 147 | */ |
| 148 | 148 | $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $user_id); |
| 149 | - if($output_type=='select') { |
|
| 150 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
|
| 151 | - }elseif($output_type=='link'){ |
|
| 152 | - $listing_links[] = '<a href="' .$listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
|
| 149 | + if ($output_type == 'select') { |
|
| 150 | + $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</option>'; |
|
| 151 | + }elseif ($output_type == 'link') { |
|
| 152 | + $listing_links[] = '<a href="'.$listing_link.'">'.__(geodir_utf8_ucfirst($name), 'geodirectory').'</a>'; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | if ($listing_links != '') { |
| 158 | - $user = get_user_by( 'ID', $user_id ); |
|
| 159 | - if($output_type=='select') { |
|
| 158 | + $user = get_user_by('ID', $user_id); |
|
| 159 | + if ($output_type == 'select') { |
|
| 160 | 160 | ?> |
| 161 | 161 | <li> |
| 162 | 162 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | </select> |
| 169 | 169 | </li> |
| 170 | 170 | <?php |
| 171 | - }elseif($output_type=='link'){ |
|
| 172 | - if(!empty($listing_links )){ |
|
| 173 | - echo implode(" | ",$listing_links ); |
|
| 171 | + }elseif ($output_type == 'link') { |
|
| 172 | + if (!empty($listing_links)) { |
|
| 173 | + echo implode(" | ", $listing_links); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | if($output_type=='select'){ |
| 82 | 82 | $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
| 83 | - }elseif($output_type=='link'){ |
|
| 83 | + } elseif($output_type=='link'){ |
|
| 84 | 84 | $favourite_links[] = '<a href="' . $post_type_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | </select> |
| 103 | 103 | </li> |
| 104 | 104 | <?php |
| 105 | - }elseif($output_type=='link'){ |
|
| 105 | + } elseif($output_type=='link'){ |
|
| 106 | 106 | if(!empty($favourite_links)){ |
| 107 | 107 | echo implode(" | ",$favourite_links); |
| 108 | 108 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $user_id); |
| 149 | 149 | if($output_type=='select') { |
| 150 | 150 | $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</option>'; |
| 151 | - }elseif($output_type=='link'){ |
|
| 151 | + } elseif($output_type=='link'){ |
|
| 152 | 152 | $listing_links[] = '<a href="' .$listing_link . '">' . __(geodir_utf8_ucfirst($name), 'geodirectory') . '</a>'; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | </select> |
| 169 | 169 | </li> |
| 170 | 170 | <?php |
| 171 | - }elseif($output_type=='link'){ |
|
| 171 | + } elseif($output_type=='link'){ |
|
| 172 | 172 | if(!empty($listing_links )){ |
| 173 | 173 | echo implode(" | ",$listing_links ); |
| 174 | 174 | } |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function geodir_init_map_jason() |
| 17 | 17 | {
|
| 18 | - global $map_jason; |
|
| 19 | - $map_jason = array(); |
|
| 18 | + global $map_jason; |
|
| 19 | + $map_jason = array(); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function geodir_init_map_canvas_array() |
| 30 | 30 | {
|
| 31 | - global $map_canvas_arr; |
|
| 32 | - $map_canvas_arr = array(); |
|
| 31 | + global $map_canvas_arr; |
|
| 32 | + $map_canvas_arr = array(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -50,56 +50,56 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function create_marker_jason_of_posts($post) |
| 52 | 52 | {
|
| 53 | - global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
| 53 | + global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
| 54 | 54 | |
| 55 | - if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
|
|
| 55 | + if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
|
|
| 56 | 56 | |
| 57 | - if(isset($map_jason[$post->ID])){return null;}
|
|
| 57 | + if(isset($map_jason[$post->ID])){return null;}
|
|
| 58 | 58 | |
| 59 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 60 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 59 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 60 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
| 64 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
| 63 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
| 64 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
| 65 | 65 | |
| 66 | - $post_title = $post->post_title; |
|
| 67 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 66 | + $post_title = $post->post_title; |
|
| 67 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 68 | 68 | |
| 69 | - if (is_ssl()) {
|
|
| 70 | - $icon = str_replace("http:","https:",$icon );
|
|
| 71 | - } |
|
| 69 | + if (is_ssl()) {
|
|
| 70 | + $icon = str_replace("http:","https:",$icon );
|
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if ($icon != '') {
|
|
| 74 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 73 | + if ($icon != '') {
|
|
| 74 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 75 | 75 | |
| 76 | - if (isset($gd_marker_sizes[$icon])) {
|
|
| 77 | - $icon_size = $gd_marker_sizes[$icon]; |
|
| 78 | - } else {
|
|
| 79 | - $icon_size = geodir_get_marker_size($icon); |
|
| 80 | - $gd_marker_sizes[$icon] = $icon_size; |
|
| 81 | - } |
|
| 82 | - } else {
|
|
| 83 | - $icon_size = array('w' => 36, 'h' => 45);
|
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}';
|
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Filter the json data when creating output for post json marker.. |
|
| 90 | - * |
|
| 91 | - * @since 1.5.7 |
|
| 92 | - * @param string $post_json JSON representation of the post marker info. |
|
| 93 | - * @param object $post The post object. |
|
| 94 | - */ |
|
| 95 | - $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
|
|
| 96 | - |
|
| 97 | - // only assign it if it has a value |
|
| 98 | - if($post_map_json){
|
|
| 99 | - $map_jason[$post->ID] = $post_map_json; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - } |
|
| 76 | + if (isset($gd_marker_sizes[$icon])) {
|
|
| 77 | + $icon_size = $gd_marker_sizes[$icon]; |
|
| 78 | + } else {
|
|
| 79 | + $icon_size = geodir_get_marker_size($icon); |
|
| 80 | + $gd_marker_sizes[$icon] = $icon_size; |
|
| 81 | + } |
|
| 82 | + } else {
|
|
| 83 | + $icon_size = array('w' => 36, 'h' => 45);
|
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}';
|
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Filter the json data when creating output for post json marker.. |
|
| 90 | + * |
|
| 91 | + * @since 1.5.7 |
|
| 92 | + * @param string $post_json JSON representation of the post marker info. |
|
| 93 | + * @param object $post The post object. |
|
| 94 | + */ |
|
| 95 | + $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
|
|
| 96 | + |
|
| 97 | + // only assign it if it has a value |
|
| 98 | + if($post_map_json){
|
|
| 99 | + $map_jason[$post->ID] = $post_map_json; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -112,67 +112,67 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function send_marker_jason_to_js() |
| 114 | 114 | {
|
| 115 | - global $map_jason, $map_canvas_arr; |
|
| 116 | - |
|
| 117 | - if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
|
|
| 118 | - foreach ($map_canvas_arr as $canvas => $jason) {
|
|
| 119 | - if (is_array($map_jason) && !empty($map_jason)) {
|
|
| 120 | - |
|
| 121 | - // on details page only show the main marker on the map |
|
| 122 | - if(geodir_is_page('detail')){
|
|
| 123 | - global $post; |
|
| 124 | - if(isset($map_jason[$post->ID])){
|
|
| 125 | - $map_jason = array($map_jason[$post->ID]); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - $canvas_jason = $canvas . "_jason"; |
|
| 129 | - $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
| 130 | - unset($cat_content_info); |
|
| 131 | - $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
|
|
| 132 | - $totalcount = count(array_unique($map_jason)); |
|
| 133 | - if (!empty($cat_content_info)) {
|
|
| 134 | - $json_content = substr(implode(',', $cat_content_info), 1);
|
|
| 135 | - $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
|
|
| 136 | - $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
| 137 | - $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
|
|
| 138 | - } else {
|
|
| 139 | - $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 140 | - } |
|
| 141 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 145 | - * |
|
| 146 | - * You can use this filter to modify map canvas json args. |
|
| 147 | - * |
|
| 148 | - * @since 1.0.0 |
|
| 149 | - * @package GeoDirectory |
|
| 150 | - * @param string $canvas Map canvas array key. |
|
| 151 | - * @param array $map_canvas_jason_args Map canvas args. |
|
| 152 | - */ |
|
| 153 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 154 | - |
|
| 155 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 156 | - } else {
|
|
| 157 | - $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 158 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 162 | - * |
|
| 163 | - * You can use this filter to modify map canvas json args. |
|
| 164 | - * |
|
| 165 | - * @since 1.0.0 |
|
| 166 | - * @package GeoDirectory |
|
| 167 | - * @param string $canvas Map canvas array key. |
|
| 168 | - * @param array $map_canvas_jason_args Map canvas args. |
|
| 169 | - */ |
|
| 170 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 171 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - } |
|
| 115 | + global $map_jason, $map_canvas_arr; |
|
| 116 | + |
|
| 117 | + if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
|
|
| 118 | + foreach ($map_canvas_arr as $canvas => $jason) {
|
|
| 119 | + if (is_array($map_jason) && !empty($map_jason)) {
|
|
| 120 | + |
|
| 121 | + // on details page only show the main marker on the map |
|
| 122 | + if(geodir_is_page('detail')){
|
|
| 123 | + global $post; |
|
| 124 | + if(isset($map_jason[$post->ID])){
|
|
| 125 | + $map_jason = array($map_jason[$post->ID]); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + $canvas_jason = $canvas . "_jason"; |
|
| 129 | + $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
| 130 | + unset($cat_content_info); |
|
| 131 | + $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
|
|
| 132 | + $totalcount = count(array_unique($map_jason)); |
|
| 133 | + if (!empty($cat_content_info)) {
|
|
| 134 | + $json_content = substr(implode(',', $cat_content_info), 1);
|
|
| 135 | + $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
|
|
| 136 | + $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
| 137 | + $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
|
|
| 138 | + } else {
|
|
| 139 | + $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 140 | + } |
|
| 141 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 145 | + * |
|
| 146 | + * You can use this filter to modify map canvas json args. |
|
| 147 | + * |
|
| 148 | + * @since 1.0.0 |
|
| 149 | + * @package GeoDirectory |
|
| 150 | + * @param string $canvas Map canvas array key. |
|
| 151 | + * @param array $map_canvas_jason_args Map canvas args. |
|
| 152 | + */ |
|
| 153 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 154 | + |
|
| 155 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 156 | + } else {
|
|
| 157 | + $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 158 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 162 | + * |
|
| 163 | + * You can use this filter to modify map canvas json args. |
|
| 164 | + * |
|
| 165 | + * @since 1.0.0 |
|
| 166 | + * @package GeoDirectory |
|
| 167 | + * @param string $canvas Map canvas array key. |
|
| 168 | + * @param array $map_canvas_jason_args Map canvas args. |
|
| 169 | + */ |
|
| 170 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 171 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + } |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -195,99 +195,99 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | function home_map_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = true, $pading = 0, $map_canvas_name = '', $child_collapse, $is_home_map = false) |
| 197 | 197 | {
|
| 198 | - global $cat_count, $geodir_cat_icons, $gd_session; |
|
| 198 | + global $cat_count, $geodir_cat_icons, $gd_session; |
|
| 199 | 199 | |
| 200 | - $exclude_categories = get_option('geodir_exclude_cat_on_map');
|
|
| 201 | - $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 200 | + $exclude_categories = get_option('geodir_exclude_cat_on_map');
|
|
| 201 | + $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 202 | 202 | |
| 203 | - // check if exclude categories saved before fix of categories identical names |
|
| 204 | - if ($exclude_categories_new) {
|
|
| 205 | - $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
| 206 | - $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
| 207 | - } |
|
| 203 | + // check if exclude categories saved before fix of categories identical names |
|
| 204 | + if ($exclude_categories_new) {
|
|
| 205 | + $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
| 206 | + $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - $exclude_cat_str = implode(',', $exclude_categories);
|
|
| 209 | + $exclude_cat_str = implode(',', $exclude_categories);
|
|
| 210 | 210 | |
| 211 | - if ($exclude_cat_str == '') {
|
|
| 212 | - $exclude_cat_str = '0'; |
|
| 213 | - } |
|
| 211 | + if ($exclude_cat_str == '') {
|
|
| 212 | + $exclude_cat_str = '0'; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
|
|
| 215 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
|
|
| 216 | 216 | |
| 217 | - if ($hide_empty) {
|
|
| 218 | - $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
| 219 | - } |
|
| 217 | + if ($hide_empty) {
|
|
| 218 | + $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $main_list_class = ''; |
|
| 222 | - //If there are terms, start displaying |
|
| 223 | - if (count($cat_terms) > 0) {
|
|
| 224 | - //Displaying as a list |
|
| 225 | - $p = $pading * 15; |
|
| 226 | - $pading++; |
|
| 221 | + $main_list_class = ''; |
|
| 222 | + //If there are terms, start displaying |
|
| 223 | + if (count($cat_terms) > 0) {
|
|
| 224 | + //Displaying as a list |
|
| 225 | + $p = $pading * 15; |
|
| 226 | + $pading++; |
|
| 227 | 227 | |
| 228 | - if ($cat_parent == 0) {
|
|
| 229 | - $list_class = 'main_list'; |
|
| 230 | - $display = ''; |
|
| 231 | - } else {
|
|
| 232 | - $list_class = 'sub_list'; |
|
| 233 | - $display = !$child_collapse ? '' : 'display:none'; |
|
| 234 | - } |
|
| 228 | + if ($cat_parent == 0) {
|
|
| 229 | + $list_class = 'main_list'; |
|
| 230 | + $display = ''; |
|
| 231 | + } else {
|
|
| 232 | + $list_class = 'sub_list'; |
|
| 233 | + $display = !$child_collapse ? '' : 'display:none'; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 236 | + $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 237 | 237 | |
| 238 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
| 238 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
| 239 | 239 | |
| 240 | - $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 241 | - if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
|
|
| 242 | - $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
| 243 | - } |
|
| 244 | - $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
| 240 | + $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 241 | + if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
|
|
| 242 | + $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
| 243 | + } |
|
| 244 | + $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
| 245 | 245 | |
| 246 | - foreach ($cat_terms as $cat_term): |
|
| 247 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
| 248 | - |
|
| 249 | - if (!in_array($cat_term->term_id, $exclude_categories)): |
|
| 250 | - //Secret sauce. Function calls itself to display child elements, if any |
|
| 251 | - $checked = 'checked="checked"'; |
|
| 252 | - |
|
| 253 | - // Untick the category by default on home map |
|
| 254 | - if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
|
|
| 255 | - if (function_exists('icl_object_id')) { // if WPML
|
|
| 256 | - global $sitepress; |
|
| 257 | - $default_lang = $sitepress->get_default_language(); |
|
| 258 | - $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
| 259 | - }else{
|
|
| 260 | - $term_id = $cat_term->term_id; |
|
| 261 | - } |
|
| 262 | - if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
|
|
| 263 | - $checked = ''; |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
| 268 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
| 269 | - $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
| 270 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
| 271 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 272 | - |
|
| 273 | - endif; |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - // get sub category by recursion |
|
| 277 | - $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
| 278 | - |
|
| 279 | - $out .= '</li>'; |
|
| 280 | - |
|
| 281 | - endforeach; |
|
| 282 | - |
|
| 283 | - $out .= '</ul>'; |
|
| 284 | - |
|
| 285 | - return $out; |
|
| 286 | - } else {
|
|
| 287 | - if ($cat_parent == 0) |
|
| 288 | - return _e('No category', 'geodirectory');
|
|
| 289 | - } |
|
| 290 | - return; |
|
| 246 | + foreach ($cat_terms as $cat_term): |
|
| 247 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
| 248 | + |
|
| 249 | + if (!in_array($cat_term->term_id, $exclude_categories)): |
|
| 250 | + //Secret sauce. Function calls itself to display child elements, if any |
|
| 251 | + $checked = 'checked="checked"'; |
|
| 252 | + |
|
| 253 | + // Untick the category by default on home map |
|
| 254 | + if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
|
|
| 255 | + if (function_exists('icl_object_id')) { // if WPML
|
|
| 256 | + global $sitepress; |
|
| 257 | + $default_lang = $sitepress->get_default_language(); |
|
| 258 | + $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
| 259 | + }else{
|
|
| 260 | + $term_id = $cat_term->term_id; |
|
| 261 | + } |
|
| 262 | + if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
|
|
| 263 | + $checked = ''; |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
| 268 | + $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
| 269 | + $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
| 270 | + $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
| 271 | + $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 272 | + |
|
| 273 | + endif; |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + // get sub category by recursion |
|
| 277 | + $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
| 278 | + |
|
| 279 | + $out .= '</li>'; |
|
| 280 | + |
|
| 281 | + endforeach; |
|
| 282 | + |
|
| 283 | + $out .= '</ul>'; |
|
| 284 | + |
|
| 285 | + return $out; |
|
| 286 | + } else {
|
|
| 287 | + if ($cat_parent == 0) |
|
| 288 | + return _e('No category', 'geodirectory');
|
|
| 289 | + } |
|
| 290 | + return; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -299,19 +299,19 @@ discard block |
||
| 299 | 299 | * @return string The map API provider name. |
| 300 | 300 | */ |
| 301 | 301 | function geodir_map_name() {
|
| 302 | - $geodir_map_name = get_option('geodir_load_map', 'google');
|
|
| 302 | + $geodir_map_name = get_option('geodir_load_map', 'google');
|
|
| 303 | 303 | |
| 304 | - if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
|
|
| 305 | - $geodir_map_name = 'auto'; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Filter the map JS API provider name. |
|
| 310 | - * |
|
| 311 | - * @since 1.6.1 |
|
| 312 | - * @param string $geodir_map_name The map API provider name. |
|
| 313 | - */ |
|
| 314 | - return apply_filters('geodir_map_name', $geodir_map_name);
|
|
| 304 | + if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
|
|
| 305 | + $geodir_map_name = 'auto'; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Filter the map JS API provider name. |
|
| 310 | + * |
|
| 311 | + * @since 1.6.1 |
|
| 312 | + * @param string $geodir_map_name The map API provider name. |
|
| 313 | + */ |
|
| 314 | + return apply_filters('geodir_map_name', $geodir_map_name);
|
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -327,48 +327,48 @@ discard block |
||
| 327 | 327 | * @return array The icon size. |
| 328 | 328 | */ |
| 329 | 329 | function geodir_get_marker_size($icon, $default_size = array('w' => 36, 'h' => 45)) {
|
| 330 | - global $gd_marker_sizes; |
|
| 330 | + global $gd_marker_sizes; |
|
| 331 | 331 | |
| 332 | - if (empty($gd_marker_sizes)) {
|
|
| 333 | - $gd_marker_sizes = array(); |
|
| 334 | - } |
|
| 332 | + if (empty($gd_marker_sizes)) {
|
|
| 333 | + $gd_marker_sizes = array(); |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - if (!empty($gd_marker_sizes[$icon])) {
|
|
| 337 | - return $gd_marker_sizes[$icon]; |
|
| 338 | - } |
|
| 336 | + if (!empty($gd_marker_sizes[$icon])) {
|
|
| 337 | + return $gd_marker_sizes[$icon]; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - if (empty($icon)) {
|
|
| 341 | - $gd_marker_sizes[$icon] = $default_size; |
|
| 340 | + if (empty($icon)) {
|
|
| 341 | + $gd_marker_sizes[$icon] = $default_size; |
|
| 342 | 342 | |
| 343 | - return $default_size; |
|
| 344 | - } |
|
| 343 | + return $default_size; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - $icon_url = $icon; |
|
| 346 | + $icon_url = $icon; |
|
| 347 | 347 | |
| 348 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 348 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 349 | 349 | |
| 350 | - if (!path_is_absolute($icon)) {
|
|
| 351 | - $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
| 352 | - } |
|
| 350 | + if (!path_is_absolute($icon)) {
|
|
| 351 | + $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
|
|
| 355 | - $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
| 356 | - } |
|
| 354 | + if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
|
|
| 355 | + $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - $sizes = array(); |
|
| 359 | - if (is_file($icon) && file_exists($icon)) {
|
|
| 360 | - $size = getimagesize(trim($icon)); |
|
| 358 | + $sizes = array(); |
|
| 359 | + if (is_file($icon) && file_exists($icon)) {
|
|
| 360 | + $size = getimagesize(trim($icon)); |
|
| 361 | 361 | |
| 362 | - if (!empty($size[0]) && !empty($size[1])) {
|
|
| 363 | - $sizes = array('w' => $size[0], 'h' => $size[1]);
|
|
| 364 | - } |
|
| 365 | - } |
|
| 362 | + if (!empty($size[0]) && !empty($size[1])) {
|
|
| 363 | + $sizes = array('w' => $size[0], 'h' => $size[1]);
|
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - $sizes = !empty($sizes) ? $sizes : $default_size; |
|
| 367 | + $sizes = !empty($sizes) ? $sizes : $default_size; |
|
| 368 | 368 | |
| 369 | - $gd_marker_sizes[$icon_url] = $sizes; |
|
| 369 | + $gd_marker_sizes[$icon_url] = $sizes; |
|
| 370 | 370 | |
| 371 | - return $sizes; |
|
| 371 | + return $sizes; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | add_action('wp_footer', 'geodir_map_load_script', 10);
|
@@ -380,8 +380,8 @@ discard block |
||
| 380 | 380 | * @package GeoDirectory |
| 381 | 381 | */ |
| 382 | 382 | function geodir_map_load_script() {
|
| 383 | - if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
|
|
| 384 | - $plugin_url = geodir_plugin_url(); |
|
| 383 | + if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
|
|
| 384 | + $plugin_url = geodir_plugin_url(); |
|
| 385 | 385 | ?> |
| 386 | 386 | <script type="text/javascript"> |
| 387 | 387 | if (!(window.google && typeof google.maps !== 'undefined')) {
|
@@ -395,5 +395,5 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | </script> |
| 397 | 397 | <?php |
| 398 | - } |
|
| 398 | + } |
|
| 399 | 399 | } |
| 400 | 400 | \ No newline at end of file |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
|
| 56 | 56 | |
| 57 | - if(isset($map_jason[$post->ID])){return null;}
|
|
| 57 | + if (isset($map_jason[$post->ID])) {return null; }
|
|
| 58 | 58 | |
| 59 | 59 | $srcharr = array("'", "/", "-", '"', '\\');
|
| 60 | 60 | $replarr = array("′", "⁄", "–", "“", '');
|
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $title = str_replace($srcharr, $replarr, $post_title); |
| 68 | 68 | |
| 69 | 69 | if (is_ssl()) {
|
| 70 | - $icon = str_replace("http:","https:",$icon );
|
|
| 70 | + $icon = str_replace("http:", "https:", $icon);
|
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if ($icon != '') {
|
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $icon_size = array('w' => 36, 'h' => 45);
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}';
|
|
| 86 | + $post_json = '{"id":"'.$post->ID.'","t": "'.$title.'","lt": "'.$post->post_latitude.'","ln": "'.$post->post_longitude.'","mk_id":"'.$post->ID.'_'.$post->default_category.'","i":"'.$icon.'","w":"'.$icon_size['w'].'","h":"'.$icon_size['h'].'"}';
|
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Filter the json data when creating output for post json marker.. |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | * @param string $post_json JSON representation of the post marker info. |
| 93 | 93 | * @param object $post The post object. |
| 94 | 94 | */ |
| 95 | - $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
|
|
| 95 | + $post_map_json = apply_filters('geodir_create_marker_jason_of_posts', $post_json, $post);
|
|
| 96 | 96 | |
| 97 | 97 | // only assign it if it has a value |
| 98 | - if($post_map_json){
|
|
| 98 | + if ($post_map_json) {
|
|
| 99 | 99 | $map_jason[$post->ID] = $post_map_json; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | if (is_array($map_jason) && !empty($map_jason)) {
|
| 120 | 120 | |
| 121 | 121 | // on details page only show the main marker on the map |
| 122 | - if(geodir_is_page('detail')){
|
|
| 122 | + if (geodir_is_page('detail')) {
|
|
| 123 | 123 | global $post; |
| 124 | - if(isset($map_jason[$post->ID])){
|
|
| 124 | + if (isset($map_jason[$post->ID])) {
|
|
| 125 | 125 | $map_jason = array($map_jason[$post->ID]); |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - $canvas_jason = $canvas . "_jason"; |
|
| 128 | + $canvas_jason = $canvas."_jason"; |
|
| 129 | 129 | $map_canvas_arr[$canvas] = array_unique($map_jason); |
| 130 | 130 | unset($cat_content_info); |
| 131 | 131 | $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
|
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | $json_content = substr(implode(',', $cat_content_info), 1);
|
| 135 | 135 | $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
|
| 136 | 136 | $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
| 137 | - $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
|
|
| 137 | + $canvas_jason = '[{"totalcount":"'.$totalcount.'",'.$json_content.']';
|
|
| 138 | 138 | } else {
|
| 139 | 139 | $canvas_jason = '[{"totalcount":"0"}]';
|
| 140 | 140 | } |
| 141 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 141 | + $map_canvas_jason_args = array($canvas.'_jason' => $canvas_jason); |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Filter the send_marker_jason_to_js() function map canvas json args. |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | * @param string $canvas Map canvas array key. |
| 151 | 151 | * @param array $map_canvas_jason_args Map canvas args. |
| 152 | 152 | */ |
| 153 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 153 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_'.$canvas, $map_canvas_jason_args);
|
|
| 154 | 154 | |
| 155 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 155 | + wp_localize_script('geodir-map-widget', $canvas.'_jason_args', $map_canvas_jason_args);
|
|
| 156 | 156 | } else {
|
| 157 | 157 | $canvas_jason = '[{"totalcount":"0"}]';
|
| 158 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 158 | + $map_canvas_jason_args = array($canvas.'_jason' => $canvas_jason); |
|
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * Filter the send_marker_jason_to_js() function map canvas json args. |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * @param string $canvas Map canvas array key. |
| 168 | 168 | * @param array $map_canvas_jason_args Map canvas args. |
| 169 | 169 | */ |
| 170 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 171 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 170 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_'.$canvas, $map_canvas_jason_args);
|
|
| 171 | + wp_localize_script('geodir-map-widget', $canvas.'_jason_args', $map_canvas_jason_args);
|
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | $display = !$child_collapse ? '' : 'display:none'; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 236 | + $out = '<ul class="treeview '.$list_class.'" style="margin-left:'.$p.'px;'.$display.';">'; |
|
| 237 | 237 | |
| 238 | 238 | $geodir_cat_icons = geodir_get_term_icon(); |
| 239 | 239 | |
| 240 | - $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 240 | + $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 241 | 241 | if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
|
| 242 | 242 | $geodir_default_map_search_pt = $homemap_catlist_ptype; |
| 243 | 243 | } |
@@ -256,19 +256,19 @@ discard block |
||
| 256 | 256 | global $sitepress; |
| 257 | 257 | $default_lang = $sitepress->get_default_language(); |
| 258 | 258 | $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
| 259 | - }else{
|
|
| 259 | + } else {
|
|
| 260 | 260 | $term_id = $cat_term->term_id; |
| 261 | 261 | } |
| 262 | - if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
|
|
| 262 | + if (!empty($geodir_home_map_untick) && in_array($post_type.'_'.$term_id, $geodir_home_map_untick)) {
|
|
| 263 | 263 | $checked = ''; |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
| 268 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
| 269 | - $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
| 270 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
| 271 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 267 | + $term_check = '<input type="checkbox" '.$checked.' id="'.$map_canvas_name.'_tick_cat_'.$cat_term->term_id.'" class="group_selector '.$main_list_class.'"'; |
|
| 268 | + $term_check .= ' name="'.$map_canvas_name.'_cat[]" '; |
|
| 269 | + $term_check .= ' title="'.esc_attr(geodir_utf8_ucfirst($cat_term->name)).'" value="'.$cat_term->term_id.'" onclick="javascript:build_map_ajax_search_param(\''.$map_canvas_name.'\',false, this)">'; |
|
| 270 | + $term_img = '<img height="15" width="15" alt="'.$cat_term->taxonomy.'" src="'.$icon.'" title="'.geodir_utf8_ucfirst($cat_term->name).'"/>'; |
|
| 271 | + $out .= '<li>'.$term_check.'<label for="'.$map_canvas_name.'_tick_cat_'.$cat_term->term_id.'">'.$term_img.geodir_utf8_ucfirst($cat_term->name).'</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 272 | 272 | |
| 273 | 273 | endif; |
| 274 | 274 | |
@@ -380,18 +380,18 @@ discard block |
||
| 380 | 380 | * @package GeoDirectory |
| 381 | 381 | */ |
| 382 | 382 | function geodir_map_load_script() {
|
| 383 | - if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
|
|
| 383 | + if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is('geodirectory-googlemap-script', 'done')) {
|
|
| 384 | 384 | $plugin_url = geodir_plugin_url(); |
| 385 | 385 | ?> |
| 386 | 386 | <script type="text/javascript"> |
| 387 | 387 | if (!(window.google && typeof google.maps !== 'undefined')) {
|
| 388 | - var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-style-css");css.setAttribute("href","<?php echo $plugin_url;?>/geodirectory-assets/leaflet/leaflet.css?ver=<?php echo GEODIRECTORY_VERSION;?>");
|
|
| 388 | + var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-style-css");css.setAttribute("href","<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/leaflet.css?ver=<?php echo GEODIRECTORY_VERSION; ?>");
|
|
| 389 | 389 | document.getElementsByTagName("head")[0].appendChild(css);
|
| 390 | - var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-routing-style");css.setAttribute("href","<?php echo $plugin_url;?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css?ver=<?php echo GEODIRECTORY_VERSION;?>");
|
|
| 390 | + var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-routing-style");css.setAttribute("href","<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css?ver=<?php echo GEODIRECTORY_VERSION; ?>");
|
|
| 391 | 391 | document.getElementsByTagName("head")[0].appendChild(css);
|
| 392 | - document.write('<' + 'script id="geodirectory-leaflet-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>');
|
|
| 393 | - document.write('<' + 'script id="geodirectory-leaflet-geo-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/osm.geocode.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>');
|
|
| 394 | - document.write('<' + 'script id="geodirectory-leaflet-routing-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>');
|
|
| 392 | + document.write('<' + 'script id="geodirectory-leaflet-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>');
|
|
| 393 | + document.write('<' + 'script id="geodirectory-leaflet-geo-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/osm.geocode.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>');
|
|
| 394 | + document.write('<' + 'script id="geodirectory-leaflet-routing-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>');
|
|
| 395 | 395 | } |
| 396 | 396 | </script> |
| 397 | 397 | <?php |
@@ -52,31 +52,31 @@ discard block |
||
| 52 | 52 | jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
|
|
| 55 | + jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
|
|
| 56 | 56 | //alert(data ); |
| 57 | 57 | }); |
| 58 | 58 | } |
| 59 | 59 | </script> |
| 60 | 60 | <div class="geodir-list-view-select"> |
| 61 | 61 | <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);"> |
| 62 | - <?php $listing_view = (int) $gd_session->get( 'gd_listing_view' ); ?> |
|
| 63 | - <option value=""><?php _e( 'View:', 'geodirectory' ); ?></option> |
|
| 62 | + <?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
|
|
| 63 | + <option value=""><?php _e('View:', 'geodirectory'); ?></option>
|
|
| 64 | 64 | <option |
| 65 | - value="1" <?php selected( 1, $listing_view ); ?>><?php _e( 'View: List', 'geodirectory' ); ?></option> |
|
| 65 | + value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
|
|
| 66 | 66 | <option |
| 67 | - value="2" <?php selected( 2, $listing_view ); ?>><?php _e( 'View: Grid 2', 'geodirectory' ); ?></option> |
|
| 67 | + value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
|
|
| 68 | 68 | <option |
| 69 | - value="3" <?php selected( 3, $listing_view ); ?>><?php _e( 'View: Grid 3', 'geodirectory' ); ?></option> |
|
| 69 | + value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
|
|
| 70 | 70 | <option |
| 71 | - value="4" <?php selected( 4, $listing_view ); ?>><?php _e( 'View: Grid 4', 'geodirectory' ); ?></option> |
|
| 71 | + value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
|
|
| 72 | 72 | <option |
| 73 | - value="5" <?php selected( 5, $listing_view ); ?>><?php _e( 'View: Grid 5', 'geodirectory' ); ?></option> |
|
| 73 | + value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
|
|
| 74 | 74 | </select> |
| 75 | 75 | </div> |
| 76 | 76 | <?php |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | -add_action( 'geodir_before_listing', 'geodir_list_view_select', 100 ); |
|
| 79 | +add_action('geodir_before_listing', 'geodir_list_view_select', 100);
|
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Limit the listing excerpt. |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | * @global object $post The current post object. |
| 92 | 92 | * @return string The modified excerpt. |
| 93 | 93 | */ |
| 94 | -function geodir_max_excerpt( $charlength ) {
|
|
| 94 | +function geodir_max_excerpt($charlength) {
|
|
| 95 | 95 | global $post; |
| 96 | - if ( $charlength == '0' ) {
|
|
| 96 | + if ($charlength == '0') {
|
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | $out = ''; |
@@ -101,46 +101,46 @@ discard block |
||
| 101 | 101 | $temp_post = $post; |
| 102 | 102 | $excerpt = get_the_excerpt(); |
| 103 | 103 | |
| 104 | - $charlength ++; |
|
| 105 | - $excerpt_more = function_exists( 'geodirf_excerpt_more' ) ? geodirf_excerpt_more( '' ) : geodir_excerpt_more( '' ); |
|
| 106 | - if ( geodir_utf8_strlen( $excerpt ) > $charlength ) {
|
|
| 107 | - if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
|
|
| 108 | - $excut = - ( geodir_utf8_strlen( $excerpt_more ) ); |
|
| 109 | - $subex = geodir_utf8_substr( $excerpt, 0, $excut ); |
|
| 110 | - if ( $charlength > 0 && geodir_utf8_strlen( $subex ) > $charlength ) {
|
|
| 111 | - $subex = geodir_utf8_substr( $subex, 0, $charlength ); |
|
| 104 | + $charlength++; |
|
| 105 | + $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
|
|
| 106 | + if (geodir_utf8_strlen($excerpt) > $charlength) {
|
|
| 107 | + if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 108 | + $excut = - (geodir_utf8_strlen($excerpt_more)); |
|
| 109 | + $subex = geodir_utf8_substr($excerpt, 0, $excut); |
|
| 110 | + if ($charlength > 0 && geodir_utf8_strlen($subex) > $charlength) {
|
|
| 111 | + $subex = geodir_utf8_substr($subex, 0, $charlength); |
|
| 112 | 112 | } |
| 113 | 113 | $out .= $subex; |
| 114 | 114 | } else {
|
| 115 | - $subex = geodir_utf8_substr( $excerpt, 0, $charlength - 5 ); |
|
| 116 | - $exwords = explode( ' ', $subex ); |
|
| 117 | - $excut = - ( geodir_utf8_strlen( $exwords[ count( $exwords ) - 1 ] ) ); |
|
| 118 | - if ( $excut < 0 ) {
|
|
| 119 | - $out .= geodir_utf8_substr( $subex, 0, $excut ); |
|
| 115 | + $subex = geodir_utf8_substr($excerpt, 0, $charlength - 5); |
|
| 116 | + $exwords = explode(' ', $subex);
|
|
| 117 | + $excut = - (geodir_utf8_strlen($exwords[count($exwords) - 1])); |
|
| 118 | + if ($excut < 0) {
|
|
| 119 | + $out .= geodir_utf8_substr($subex, 0, $excut); |
|
| 120 | 120 | } else {
|
| 121 | 121 | $out .= $subex; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 124 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; |
|
| 125 | 125 | /** |
| 126 | 126 | * Filter excerpt read more text. |
| 127 | 127 | * |
| 128 | 128 | * @since 1.0.0 |
| 129 | 129 | */ |
| 130 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 130 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 131 | 131 | $out .= '</a>'; |
| 132 | 132 | |
| 133 | 133 | } else {
|
| 134 | - if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
|
|
| 135 | - $excut = - ( geodir_utf8_strlen( $excerpt_more ) ); |
|
| 136 | - $out .= geodir_utf8_substr( $excerpt, 0, $excut ); |
|
| 137 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 134 | + if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 135 | + $excut = - (geodir_utf8_strlen($excerpt_more)); |
|
| 136 | + $out .= geodir_utf8_substr($excerpt, 0, $excut); |
|
| 137 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; |
|
| 138 | 138 | /** |
| 139 | 139 | * Filter excerpt read more text. |
| 140 | 140 | * |
| 141 | 141 | * @since 1.0.0 |
| 142 | 142 | */ |
| 143 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 143 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 144 | 144 | $out .= '</a>'; |
| 145 | 145 | } else {
|
| 146 | 146 | $out .= $excerpt; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return object Returns filtered package info as an object. |
| 165 | 165 | */ |
| 166 | -function geodir_post_package_info( $package_info, $post = '', $post_type = '' ) {
|
|
| 166 | +function geodir_post_package_info($package_info, $post = '', $post_type = '') {
|
|
| 167 | 167 | $package_info['pid'] = 0; |
| 168 | 168 | $package_info['days'] = 0; |
| 169 | 169 | $package_info['amount'] = 0; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param object|string $post The post object. |
| 193 | 193 | * @param string $post_type The post type. |
| 194 | 194 | */ |
| 195 | - return (object) apply_filters( 'geodir_post_package_info', $package_info, $post, $post_type ); |
|
| 195 | + return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * } |
| 222 | 222 | */ |
| 223 | -function geodir_send_inquiry( $request ) {
|
|
| 223 | +function geodir_send_inquiry($request) {
|
|
| 224 | 224 | global $wpdb; |
| 225 | 225 | |
| 226 | 226 | // strip slashes from text |
| 227 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; |
|
| 227 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 228 | 228 | |
| 229 | 229 | $yourname = $request['inq_name']; |
| 230 | 230 | $youremail = $request['inq_email']; |
@@ -235,26 +235,26 @@ discard block |
||
| 235 | 235 | $author_id = ''; |
| 236 | 236 | $post_title = ''; |
| 237 | 237 | |
| 238 | - if ( $request['pid'] ) {
|
|
| 238 | + if ($request['pid']) {
|
|
| 239 | 239 | |
| 240 | 240 | $productinfosql = $wpdb->prepare( |
| 241 | 241 | "select ID,post_author,post_title from $wpdb->posts where ID =%d", |
| 242 | - array( $request['pid'] ) |
|
| 242 | + array($request['pid']) |
|
| 243 | 243 | ); |
| 244 | - $productinfo = $wpdb->get_row( $productinfosql ); |
|
| 244 | + $productinfo = $wpdb->get_row($productinfosql); |
|
| 245 | 245 | |
| 246 | 246 | $author_id = $productinfo->post_author; |
| 247 | 247 | $post_title = $productinfo->post_title; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $post_title = '<a href="' . get_permalink( $pid ) . '">' . $post_title . '</a>'; |
|
| 250 | + $post_title = '<a href="'.get_permalink($pid).'">'.$post_title.'</a>'; |
|
| 251 | 251 | |
| 252 | - $user_info = get_userdata( $author_id ); |
|
| 253 | - $to_email = geodir_get_post_meta( $pid, 'geodir_email', true ); |
|
| 254 | - $to_name = geodir_get_client_name( $author_id ); |
|
| 252 | + $user_info = get_userdata($author_id); |
|
| 253 | + $to_email = geodir_get_post_meta($pid, 'geodir_email', true); |
|
| 254 | + $to_name = geodir_get_client_name($author_id); |
|
| 255 | 255 | |
| 256 | - if ( $to_email == '' ) {
|
|
| 257 | - $to_email = get_option( 'admin_email' ); |
|
| 256 | + if ($to_email == '') {
|
|
| 257 | + $to_email = get_option('admin_email');
|
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | * } |
| 276 | 276 | * @param string $type The form type, default: `Enquiry`. |
| 277 | 277 | */ |
| 278 | - do_action( 'geodir_after_send_enquiry', $request, 'Enquiry' ); |
|
| 278 | + do_action('geodir_after_send_enquiry', $request, 'Enquiry');
|
|
| 279 | 279 | |
| 280 | 280 | $client_message = $frnd_comments; |
| 281 | - $client_message .= '<br>' . __( 'From :', 'geodirectory' ) . ' ' . $yourname . '<br>' . __( 'Phone :', 'geodirectory' ) . ' ' . $inq_phone . '<br>' . __( 'Email :', 'geodirectory' ) . ' ' . $youremail . '<br><br>' . __( 'Sent from', 'geodirectory' ) . ' - <b><a href="' . trailingslashit( home_url() ) . '">' . get_option( 'blogname' ) . '</a></b>.'; |
|
| 281 | + $client_message .= '<br>'.__('From :', 'geodirectory').' '.$yourname.'<br>'.__('Phone :', 'geodirectory').' '.$inq_phone.'<br>'.__('Email :', 'geodirectory').' '.$youremail.'<br><br>'.__('Sent from', 'geodirectory').' - <b><a href="'.trailingslashit(home_url()).'">'.get_option('blogname').'</a></b>.';
|
|
| 282 | 282 | /** |
| 283 | 283 | * Filter client message text. |
| 284 | 284 | * |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param string $client_message Client message text. |
| 288 | 288 | */ |
| 289 | - $client_message = apply_filters( 'geodir_inquiry_email_msg', $client_message ); |
|
| 289 | + $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
|
|
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | 292 | * Called before the send enquiry email is sent. |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * } |
| 307 | 307 | */ |
| 308 | - do_action( 'geodir_before_send_enquiry_email', $request ); |
|
| 309 | - if ( $to_email ) {
|
|
| 308 | + do_action('geodir_before_send_enquiry_email', $request);
|
|
| 309 | + if ($to_email) {
|
|
| 310 | 310 | // strip slashes message |
| 311 | - $client_message = stripslashes_deep( $client_message ); |
|
| 311 | + $client_message = stripslashes_deep($client_message); |
|
| 312 | 312 | |
| 313 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid'] );//To client email |
|
| 313 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | * |
| 331 | 331 | * } |
| 332 | 332 | */ |
| 333 | - do_action( 'geodir_after_send_enquiry_email', $request ); |
|
| 334 | - $url = get_permalink( $pid ); |
|
| 335 | - if ( strstr( $url, '?' ) ) {
|
|
| 336 | - $url = $url . "&send_inquiry=success"; |
|
| 333 | + do_action('geodir_after_send_enquiry_email', $request);
|
|
| 334 | + $url = get_permalink($pid); |
|
| 335 | + if (strstr($url, '?')) {
|
|
| 336 | + $url = $url."&send_inquiry=success"; |
|
| 337 | 337 | } else {
|
| 338 | - $url = $url . "?send_inquiry=success"; |
|
| 338 | + $url = $url."?send_inquiry=success"; |
|
| 339 | 339 | } |
| 340 | 340 | /** |
| 341 | 341 | * Filter redirect url after the send enquiry email is sent. |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @param string $url Redirect url. |
| 346 | 346 | */ |
| 347 | - $url = apply_filters( 'geodir_send_enquiry_after_submit_redirect', $url ); |
|
| 348 | - wp_redirect( $url ); |
|
| 347 | + $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
|
|
| 348 | + wp_redirect($url); |
|
| 349 | 349 | gd_die(); |
| 350 | 350 | |
| 351 | 351 | } |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | * } |
| 375 | 375 | * @global object $wpdb WordPress Database object. |
| 376 | 376 | */ |
| 377 | -function geodir_send_friend( $request ) {
|
|
| 377 | +function geodir_send_friend($request) {
|
|
| 378 | 378 | global $wpdb; |
| 379 | 379 | |
| 380 | 380 | // strip slashes from text |
| 381 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; |
|
| 381 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 382 | 382 | |
| 383 | 383 | $yourname = $request['yourname']; |
| 384 | 384 | $youremail = $request['youremail']; |
@@ -387,13 +387,13 @@ discard block |
||
| 387 | 387 | $pid = $request['pid']; |
| 388 | 388 | $to_email = $request['to_email']; |
| 389 | 389 | $to_name = $request['to_name']; |
| 390 | - if ( $request['pid'] ) {
|
|
| 390 | + if ($request['pid']) {
|
|
| 391 | 391 | $productinfosql = $wpdb->prepare( |
| 392 | 392 | "select ID,post_title from $wpdb->posts where ID =%d", |
| 393 | - array( $request['pid'] ) |
|
| 393 | + array($request['pid']) |
|
| 394 | 394 | ); |
| 395 | - $productinfo = $wpdb->get_results( $productinfosql ); |
|
| 396 | - foreach ( $productinfo as $productinfoObj ) {
|
|
| 395 | + $productinfo = $wpdb->get_results($productinfosql); |
|
| 396 | + foreach ($productinfo as $productinfoObj) {
|
|
| 397 | 397 | $post_title = $productinfoObj->post_title; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * } |
| 419 | 419 | */ |
| 420 | - do_action( 'geodir_before_send_to_friend_email', $request ); |
|
| 421 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid'] );//To client email |
|
| 420 | + do_action('geodir_before_send_to_friend_email', $request);
|
|
| 421 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email |
|
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Called after the send to friend email is sent. |
@@ -439,13 +439,13 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * } |
| 441 | 441 | */ |
| 442 | - do_action( 'geodir_after_send_to_friend_email', $request ); |
|
| 442 | + do_action('geodir_after_send_to_friend_email', $request);
|
|
| 443 | 443 | |
| 444 | - $url = get_permalink( $pid ); |
|
| 445 | - if ( strstr( $url, '?' ) ) {
|
|
| 446 | - $url = $url . "&sendtofrnd=success"; |
|
| 444 | + $url = get_permalink($pid); |
|
| 445 | + if (strstr($url, '?')) {
|
|
| 446 | + $url = $url."&sendtofrnd=success"; |
|
| 447 | 447 | } else {
|
| 448 | - $url = $url . "?sendtofrnd=success"; |
|
| 448 | + $url = $url."?sendtofrnd=success"; |
|
| 449 | 449 | } |
| 450 | 450 | /** |
| 451 | 451 | * Filter redirect url after the send to friend email is sent. |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @param string $url Redirect url. |
| 456 | 456 | */ |
| 457 | - $url = apply_filters( 'geodir_send_to_friend_after_submit_redirect', $url ); |
|
| 458 | - wp_redirect( $url ); |
|
| 457 | + $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
|
|
| 458 | + wp_redirect($url); |
|
| 459 | 459 | gd_die(); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | * |
| 470 | 470 | * @param string $hash_key |
| 471 | 471 | */ |
| 472 | -function geodir_before_tab_content( $hash_key ) {
|
|
| 473 | - switch ( $hash_key ) {
|
|
| 472 | +function geodir_before_tab_content($hash_key) {
|
|
| 473 | + switch ($hash_key) {
|
|
| 474 | 474 | case 'post_info' : |
| 475 | 475 | echo '<div class="geodir-company_info field-group">'; |
| 476 | 476 | break; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @since 1.0.0 |
| 482 | 482 | */ |
| 483 | - echo ' <div id="' . apply_filters( 'geodir_post_gallery_id', 'geodir-post-gallery' ) . '" class="clearfix" >'; |
|
| 483 | + echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
|
|
| 484 | 484 | break; |
| 485 | 485 | case 'reviews' : |
| 486 | 486 | echo '<div id="reviews-wrap" class="clearfix"> '; |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | * |
| 505 | 505 | * @param string $hash_key |
| 506 | 506 | */ |
| 507 | -function geodir_after_tab_content( $hash_key ) {
|
|
| 508 | - switch ( $hash_key ) {
|
|
| 507 | +function geodir_after_tab_content($hash_key) {
|
|
| 508 | + switch ($hash_key) {
|
|
| 509 | 509 | case 'post_info' : |
| 510 | 510 | echo '</div>'; |
| 511 | 511 | break; |
@@ -536,25 +536,25 @@ discard block |
||
| 536 | 536 | * @global object $wpdb WordPress Database object. |
| 537 | 537 | * @return bool|null|string Returns default sort results, when the post type is valid. Otherwise returns false. |
| 538 | 538 | */ |
| 539 | -function geodir_get_posts_default_sort( $post_type ) {
|
|
| 539 | +function geodir_get_posts_default_sort($post_type) {
|
|
| 540 | 540 | |
| 541 | 541 | global $wpdb; |
| 542 | 542 | |
| 543 | - if ( $post_type != '' ) {
|
|
| 543 | + if ($post_type != '') {
|
|
| 544 | 544 | |
| 545 | 545 | $all_postypes = geodir_get_posttypes(); |
| 546 | 546 | |
| 547 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 547 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 548 | 548 | return false; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array( |
|
| 551 | + $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where post_type= %s and is_active=%d and is_default=%d", array(
|
|
| 552 | 552 | $post_type, |
| 553 | 553 | 1, |
| 554 | 554 | 1 |
| 555 | - ) ) ); |
|
| 555 | + ))); |
|
| 556 | 556 | |
| 557 | - if ( ! empty( $sort_field_info ) ) {
|
|
| 557 | + if (!empty($sort_field_info)) {
|
|
| 558 | 558 | return $sort_field_info; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -574,20 +574,20 @@ discard block |
||
| 574 | 574 | * @global object $wpdb WordPress Database object. |
| 575 | 575 | * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false. |
| 576 | 576 | */ |
| 577 | -function geodir_get_sort_options( $post_type ) {
|
|
| 577 | +function geodir_get_sort_options($post_type) {
|
|
| 578 | 578 | global $wpdb; |
| 579 | 579 | |
| 580 | - if ( $post_type != '' ) {
|
|
| 580 | + if ($post_type != '') {
|
|
| 581 | 581 | $all_postypes = geodir_get_posttypes(); |
| 582 | 582 | |
| 583 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 583 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 584 | 584 | return false; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $sort_field_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array( |
|
| 587 | + $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
|
|
| 588 | 588 | $post_type, |
| 589 | 589 | 1 |
| 590 | - ) ) ); |
|
| 590 | + ))); |
|
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | 593 | * Filter post sort options. |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @param array $sort_field_info Unfiltered sort field array. |
| 598 | 598 | * @param string $post_type Post type. |
| 599 | 599 | */ |
| 600 | - return apply_filters( 'geodir_get_sort_options', $sort_field_info, $post_type ); |
|
| 600 | + return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
|
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | } |
@@ -618,63 +618,63 @@ discard block |
||
| 618 | 618 | * |
| 619 | 619 | * @since 1.4.4 |
| 620 | 620 | */ |
| 621 | - if ( is_search() ) {
|
|
| 621 | + if (is_search()) {
|
|
| 622 | 622 | return; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | $sort_by = ''; |
| 626 | 626 | |
| 627 | - if ( isset( $_REQUEST['sort_by'] ) ) {
|
|
| 627 | + if (isset($_REQUEST['sort_by'])) {
|
|
| 628 | 628 | $sort_by = $_REQUEST['sort_by']; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | $gd_post_type = geodir_get_current_posttype(); |
| 632 | 632 | |
| 633 | - $sort_options = geodir_get_sort_options( $gd_post_type ); |
|
| 633 | + $sort_options = geodir_get_sort_options($gd_post_type); |
|
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | $sort_field_options = ''; |
| 637 | 637 | |
| 638 | - if ( ! empty( $sort_options ) ) {
|
|
| 639 | - foreach ( $sort_options as $sort ) {
|
|
| 640 | - $sort = stripslashes_deep( $sort ); // strip slashes |
|
| 638 | + if (!empty($sort_options)) {
|
|
| 639 | + foreach ($sort_options as $sort) {
|
|
| 640 | + $sort = stripslashes_deep($sort); // strip slashes |
|
| 641 | 641 | |
| 642 | - $label = __( $sort->site_title, 'geodirectory' ); |
|
| 642 | + $label = __($sort->site_title, 'geodirectory'); |
|
| 643 | 643 | |
| 644 | - if ( $sort->field_type == 'random' ) {
|
|
| 644 | + if ($sort->field_type == 'random') {
|
|
| 645 | 645 | $key = $sort->field_type; |
| 646 | - ( $sort_by == $key || ( $sort->is_default == '1' && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 647 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 646 | + ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 647 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - if ( $sort->htmlvar_name == 'comment_count' ) {
|
|
| 650 | + if ($sort->htmlvar_name == 'comment_count') {
|
|
| 651 | 651 | $sort->htmlvar_name = 'rating_count'; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - if ( $sort->sort_asc ) {
|
|
| 655 | - $key = $sort->htmlvar_name . '_asc'; |
|
| 654 | + if ($sort->sort_asc) {
|
|
| 655 | + $key = $sort->htmlvar_name.'_asc'; |
|
| 656 | 656 | $label = $sort->site_title; |
| 657 | - if ( $sort->asc_title ) {
|
|
| 657 | + if ($sort->asc_title) {
|
|
| 658 | 658 | $label = $sort->asc_title; |
| 659 | 659 | } |
| 660 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 661 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 660 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 661 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - if ( $sort->sort_desc ) {
|
|
| 665 | - $key = $sort->htmlvar_name . '_desc'; |
|
| 664 | + if ($sort->sort_desc) {
|
|
| 665 | + $key = $sort->htmlvar_name.'_desc'; |
|
| 666 | 666 | $label = $sort->site_title; |
| 667 | - if ( $sort->desc_title ) {
|
|
| 667 | + if ($sort->desc_title) {
|
|
| 668 | 668 | $label = $sort->desc_title; |
| 669 | 669 | } |
| 670 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 671 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 670 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 671 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( $sort_field_options != '' ) {
|
|
| 677 | + if ($sort_field_options != '') {
|
|
| 678 | 678 | |
| 679 | 679 | ?> |
| 680 | 680 | |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;"> |
| 684 | 684 | |
| 685 | 685 | <option |
| 686 | - value="<?php echo esc_url( add_query_arg( 'sort_by', '' ) ); ?>" <?php if ( $sort_by == '' ) {
|
|
| 686 | + value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') {
|
|
| 687 | 687 | echo 'selected="selected"'; |
| 688 | - } ?>><?php _e( 'Sort By', 'geodirectory' ); ?></option><?php |
|
| 688 | + } ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
|
|
| 689 | 689 | |
| 690 | 690 | echo $sort_field_options; ?> |
| 691 | 691 | |
@@ -713,9 +713,9 @@ discard block |
||
| 713 | 713 | * |
| 714 | 714 | * @return string Returns the section title. |
| 715 | 715 | */ |
| 716 | -function geodir_advance_customfields_heading( $title, $field_type ) {
|
|
| 716 | +function geodir_advance_customfields_heading($title, $field_type) {
|
|
| 717 | 717 | |
| 718 | - if ( in_array( $field_type, array( 'multiselect', 'textarea', 'taxonomy' ) ) ) {
|
|
| 718 | + if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
|
|
| 719 | 719 | $title = ''; |
| 720 | 720 | } |
| 721 | 721 | |
@@ -737,19 +737,19 @@ discard block |
||
| 737 | 737 | * @global object $gd_session GeoDirectory Session object. |
| 738 | 738 | * @return string Returns related posts html. |
| 739 | 739 | */ |
| 740 | -function geodir_related_posts_display( $request ) {
|
|
| 741 | - if ( ! empty( $request ) ) {
|
|
| 742 | - $before_title = ( isset( $request['before_title'] ) && ! empty( $request['before_title'] ) ) ? $request['before_title'] : ''; |
|
| 743 | - $after_title = ( isset( $request['after_title'] ) && ! empty( $request['after_title'] ) ) ? $request['after_title'] : ''; |
|
| 744 | - |
|
| 745 | - $title = ( isset( $request['title'] ) && ! empty( $request['title'] ) ) ? $request['title'] : __( 'Related Listings', 'geodirectory' ); |
|
| 746 | - $post_number = ( isset( $request['post_number'] ) && ! empty( $request['post_number'] ) ) ? $request['post_number'] : '5'; |
|
| 747 | - $relate_to = ( isset( $request['relate_to'] ) && ! empty( $request['relate_to'] ) ) ? $request['relate_to'] : 'category'; |
|
| 748 | - $layout = ( isset( $request['layout'] ) && ! empty( $request['layout'] ) ) ? $request['layout'] : 'gridview_onehalf'; |
|
| 749 | - $add_location_filter = ( isset( $request['add_location_filter'] ) && ! empty( $request['add_location_filter'] ) ) ? $request['add_location_filter'] : '0'; |
|
| 750 | - $listing_width = ( isset( $request['listing_width'] ) && ! empty( $request['listing_width'] ) ) ? $request['listing_width'] : ''; |
|
| 751 | - $list_sort = ( isset( $request['list_sort'] ) && ! empty( $request['list_sort'] ) ) ? $request['list_sort'] : 'latest'; |
|
| 752 | - $character_count = ( isset( $request['character_count'] ) && ! empty( $request['character_count'] ) ) ? $request['character_count'] : ''; |
|
| 740 | +function geodir_related_posts_display($request) {
|
|
| 741 | + if (!empty($request)) {
|
|
| 742 | + $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : ''; |
|
| 743 | + $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : ''; |
|
| 744 | + |
|
| 745 | + $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
|
|
| 746 | + $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5'; |
|
| 747 | + $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category'; |
|
| 748 | + $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf'; |
|
| 749 | + $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0'; |
|
| 750 | + $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : ''; |
|
| 751 | + $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest'; |
|
| 752 | + $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : ''; |
|
| 753 | 753 | |
| 754 | 754 | global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon; |
| 755 | 755 | $related_parent_lat = !empty($post->post_latitude) ? $post->post_latitude : ''; |
@@ -757,10 +757,10 @@ discard block |
||
| 757 | 757 | $arr_detail_page_tabs = geodir_detail_page_tabs_list(); |
| 758 | 758 | |
| 759 | 759 | $related_listing_array = array(); |
| 760 | - if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
|
|
| 761 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); |
|
| 760 | + if (get_option('geodir_add_related_listing_posttypes')) {
|
|
| 761 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 762 | 762 | } |
| 763 | - if ( isset($post->post_type) && in_array( $post->post_type, $related_listing_array ) ) {
|
|
| 763 | + if (isset($post->post_type) && in_array($post->post_type, $related_listing_array)) {
|
|
| 764 | 764 | $arr_detail_page_tabs['related_listing']['is_display'] = true; |
| 765 | 765 | } |
| 766 | 766 | |
@@ -772,90 +772,90 @@ discard block |
||
| 772 | 772 | $tax_field = 'id'; |
| 773 | 773 | $category = array(); |
| 774 | 774 | |
| 775 | - if ( isset( $_REQUEST['backandedit'] ) ) {
|
|
| 776 | - $post = (object) $gd_session->get( 'listing' ); |
|
| 775 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 776 | + $post = (object) $gd_session->get('listing');
|
|
| 777 | 777 | $post_type = $post->listing_type; |
| 778 | - if ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
|
|
| 778 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 779 | 779 | $post_id = $_REQUEST['pid']; |
| 780 | 780 | } |
| 781 | - } elseif ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
|
|
| 782 | - $post = geodir_get_post_info( $_REQUEST['pid'] ); |
|
| 781 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 782 | + $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 783 | 783 | $post_type = $post->post_type; |
| 784 | 784 | $post_id = $_REQUEST['pid']; |
| 785 | - } elseif ( isset( $post->post_type ) && $post->post_type != '' ) {
|
|
| 785 | + } elseif (isset($post->post_type) && $post->post_type != '') {
|
|
| 786 | 786 | $post_type = $post->post_type; |
| 787 | 787 | $post_id = $post->ID; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if ( $relate_to == 'category' ) {
|
|
| 790 | + if ($relate_to == 'category') {
|
|
| 791 | 791 | |
| 792 | - $category_taxonomy = $post_type . $relate_to; |
|
| 793 | - if ( isset( $post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '' ) {
|
|
| 794 | - $category = explode( ',', trim( $post->{$category_taxonomy}, ',' ) );
|
|
| 792 | + $category_taxonomy = $post_type.$relate_to; |
|
| 793 | + if (isset($post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '') {
|
|
| 794 | + $category = explode(',', trim($post->{$category_taxonomy}, ','));
|
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - } elseif ( $relate_to == 'tags' ) {
|
|
| 797 | + } elseif ($relate_to == 'tags') {
|
|
| 798 | 798 | |
| 799 | - $category_taxonomy = $post_type . '_' . $relate_to; |
|
| 800 | - if ( $post->post_tags != '' ) {
|
|
| 801 | - $category = explode( ',', trim( $post->post_tags, ',' ) ); |
|
| 799 | + $category_taxonomy = $post_type.'_'.$relate_to; |
|
| 800 | + if ($post->post_tags != '') {
|
|
| 801 | + $category = explode(',', trim($post->post_tags, ','));
|
|
| 802 | 802 | } |
| 803 | 803 | $tax_field = 'name'; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /* --- return false in invalid request --- */ |
| 807 | - if ( empty( $category ) ) {
|
|
| 807 | + if (empty($category)) {
|
|
| 808 | 808 | return false; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | $all_postypes = geodir_get_posttypes(); |
| 812 | 812 | |
| 813 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 813 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 814 | 814 | return false; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /* --- return false in invalid request --- */ |
| 818 | 818 | |
| 819 | 819 | $location_url = ''; |
| 820 | - if ( $add_location_filter != '0' ) {
|
|
| 820 | + if ($add_location_filter != '0') {
|
|
| 821 | 821 | $location_url = array(); |
| 822 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); |
|
| 822 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 823 | 823 | |
| 824 | - $gd_city = get_query_var( 'gd_city' ); |
|
| 824 | + $gd_city = get_query_var('gd_city');
|
|
| 825 | 825 | |
| 826 | - if ( $gd_city ) {
|
|
| 827 | - $gd_country = get_query_var( 'gd_country' ); |
|
| 828 | - $gd_region = get_query_var( 'gd_region' ); |
|
| 826 | + if ($gd_city) {
|
|
| 827 | + $gd_country = get_query_var('gd_country');
|
|
| 828 | + $gd_region = get_query_var('gd_region');
|
|
| 829 | 829 | } else {
|
| 830 | 830 | $location = geodir_get_default_location(); |
| 831 | 831 | |
| 832 | - $gd_country = isset( $location->country_slug ) ? $location->country_slug : ''; |
|
| 833 | - $gd_region = isset( $location->region_slug ) ? $location->region_slug : ''; |
|
| 834 | - $gd_city = isset( $location->city_slug ) ? $location->city_slug : ''; |
|
| 832 | + $gd_country = isset($location->country_slug) ? $location->country_slug : ''; |
|
| 833 | + $gd_region = isset($location->region_slug) ? $location->region_slug : ''; |
|
| 834 | + $gd_city = isset($location->city_slug) ? $location->city_slug : ''; |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ( $geodir_show_location_url == 'all' ) {
|
|
| 837 | + if ($geodir_show_location_url == 'all') {
|
|
| 838 | 838 | $location_url[] = $gd_country; |
| 839 | 839 | $location_url[] = $gd_region; |
| 840 | - } else if ( $geodir_show_location_url == 'country_city' ) {
|
|
| 840 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 841 | 841 | $location_url[] = $gd_country; |
| 842 | - } else if ( $geodir_show_location_url == 'region_city' ) {
|
|
| 842 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 843 | 843 | $location_url[] = $gd_region; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | $location_url[] = $gd_city; |
| 847 | 847 | |
| 848 | - $location_url = implode( '/', $location_url ); |
|
| 848 | + $location_url = implode('/', $location_url);
|
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | |
| 852 | - if ( ! empty( $category ) ) {
|
|
| 852 | + if (!empty($category)) {
|
|
| 853 | 853 | global $geodir_add_location_url; |
| 854 | 854 | $geodir_add_location_url = '0'; |
| 855 | - if ( $add_location_filter != '0' ) {
|
|
| 855 | + if ($add_location_filter != '0') {
|
|
| 856 | 856 | $geodir_add_location_url = '1'; |
| 857 | 857 | } |
| 858 | - $viewall_url = get_term_link( (int) $category[0], $post_type . $category_taxonomy ); |
|
| 858 | + $viewall_url = get_term_link((int) $category[0], $post_type.$category_taxonomy); |
|
| 859 | 859 | $geodir_add_location_url = null; |
| 860 | 860 | } |
| 861 | 861 | ob_start(); |
@@ -865,24 +865,24 @@ discard block |
||
| 865 | 865 | <div class="geodir_locations geodir_location_listing"> |
| 866 | 866 | |
| 867 | 867 | <?php |
| 868 | - if ( isset( $request['is_widget'] ) && $request['is_widget'] == '1' ) {
|
|
| 868 | + if (isset($request['is_widget']) && $request['is_widget'] == '1') {
|
|
| 869 | 869 | /** geodir_before_title filter Documented in geodirectory_widgets.php */ |
| 870 | - $before_title = isset( $before_title ) ? $before_title : apply_filters( 'geodir_before_title', '<h3 class="widget-title">' ); |
|
| 870 | + $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
|
|
| 871 | 871 | /** geodir_after_title filter Documented in geodirectory_widgets.php */ |
| 872 | - $after_title = isset( $after_title ) ? $after_title : apply_filters( 'geodir_after_title', '</h3>' ); |
|
| 872 | + $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
|
|
| 873 | 873 | ?> |
| 874 | 874 | <div class="location_list_heading clearfix"> |
| 875 | - <?php echo $before_title . $title . $after_title; ?> |
|
| 875 | + <?php echo $before_title.$title.$after_title; ?> |
|
| 876 | 876 | </div> |
| 877 | 877 | <?php |
| 878 | 878 | } |
| 879 | 879 | $query_args = array( |
| 880 | 880 | 'posts_per_page' => $post_number, |
| 881 | 881 | 'is_geodir_loop' => true, |
| 882 | - 'gd_location' => ( $add_location_filter ) ? true : false, |
|
| 882 | + 'gd_location' => ($add_location_filter) ? true : false, |
|
| 883 | 883 | 'post_type' => $post_type, |
| 884 | 884 | 'order_by' => $list_sort, |
| 885 | - 'post__not_in' => array( $post_id ), |
|
| 885 | + 'post__not_in' => array($post_id), |
|
| 886 | 886 | 'excerpt_length' => $character_count, |
| 887 | 887 | 'related_listings' => $is_display |
| 888 | 888 | ); |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | 'terms' => $category |
| 894 | 894 | ); |
| 895 | 895 | |
| 896 | - $query_args['tax_query'] = array( $tax_query ); |
|
| 896 | + $query_args['tax_query'] = array($tax_query); |
|
| 897 | 897 | |
| 898 | 898 | global $gridview_columns, $post; |
| 899 | 899 | |
@@ -905,21 +905,21 @@ discard block |
||
| 905 | 905 | * @param array $query_args The query array. |
| 906 | 906 | * @param array $request Related posts request array. |
| 907 | 907 | */ |
| 908 | - $query_args = apply_filters( 'geodir_related_posts_widget_query_args', $query_args, $request ); |
|
| 908 | + $query_args = apply_filters('geodir_related_posts_widget_query_args', $query_args, $request);
|
|
| 909 | 909 | |
| 910 | - query_posts( $query_args ); |
|
| 910 | + query_posts($query_args); |
|
| 911 | 911 | |
| 912 | - if ( strstr( $layout, 'gridview' ) ) {
|
|
| 913 | - $listing_view_exp = explode( '_', $layout ); |
|
| 912 | + if (strstr($layout, 'gridview')) {
|
|
| 913 | + $listing_view_exp = explode('_', $layout);
|
|
| 914 | 914 | $gridview_columns = $layout; |
| 915 | 915 | $layout = $listing_view_exp[0]; |
| 916 | - } else if ( $layout == 'list' ) {
|
|
| 916 | + } else if ($layout == 'list') {
|
|
| 917 | 917 | $gridview_columns = ''; |
| 918 | 918 | } |
| 919 | 919 | $related_posts = true; |
| 920 | 920 | |
| 921 | 921 | $related_nearest = false; |
| 922 | - if ( $list_sort == 'nearest' ) {
|
|
| 922 | + if ($list_sort == 'nearest') {
|
|
| 923 | 923 | $related_nearest = true; |
| 924 | 924 | } |
| 925 | 925 | |
@@ -929,14 +929,14 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @since 1.0.0 |
| 931 | 931 | */ |
| 932 | - $template = apply_filters( "geodir_template_part-related-listing-listview", geodir_locate_template( 'listing-listview' ) ); |
|
| 932 | + $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
|
|
| 933 | 933 | |
| 934 | 934 | /** |
| 935 | 935 | * Includes related listing listview template. |
| 936 | 936 | * |
| 937 | 937 | * @since 1.0.0 |
| 938 | 938 | */ |
| 939 | - include( $template ); |
|
| 939 | + include($template); |
|
| 940 | 940 | |
| 941 | 941 | wp_reset_query(); |
| 942 | 942 | $post = $origi_post; |
@@ -964,12 +964,12 @@ discard block |
||
| 964 | 964 | function geodir_category_count_script() {
|
| 965 | 965 | global $geodir_post_category_str; |
| 966 | 966 | |
| 967 | - if ( ! empty( $geodir_post_category_str ) ) {
|
|
| 968 | - $geodir_post_category_str = serialize( $geodir_post_category_str ); |
|
| 967 | + if (!empty($geodir_post_category_str)) {
|
|
| 968 | + $geodir_post_category_str = serialize($geodir_post_category_str); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - $all_var['post_category_array'] = html_entity_decode( (string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8' ); |
|
| 972 | - $script = "var post_category_array = " . json_encode( $all_var ) . ';'; |
|
| 971 | + $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 972 | + $script = "var post_category_array = ".json_encode($all_var).';'; |
|
| 973 | 973 | echo '<script>'; |
| 974 | 974 | echo $script; |
| 975 | 975 | echo '</script>'; |
@@ -984,8 +984,8 @@ discard block |
||
| 984 | 984 | * @return string Returns the default language. |
| 985 | 985 | */ |
| 986 | 986 | function geodir_get_map_default_language() {
|
| 987 | - $geodir_default_map_language = get_option( 'geodir_default_map_language' ); |
|
| 988 | - if ( empty( $geodir_default_map_language ) ) {
|
|
| 987 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 988 | + if (empty($geodir_default_map_language)) {
|
|
| 989 | 989 | $geodir_default_map_language = 'en'; |
| 990 | 990 | } |
| 991 | 991 | |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | * |
| 997 | 997 | * @param string $geodir_default_map_language Default map language. |
| 998 | 998 | */ |
| 999 | - return apply_filters( 'geodir_default_map_language', $geodir_default_map_language ); |
|
| 999 | + return apply_filters('geodir_default_map_language', $geodir_default_map_language);
|
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | * @return string Returns the api key. |
| 1008 | 1008 | */ |
| 1009 | 1009 | function geodir_get_map_api_key() {
|
| 1010 | - $key = get_option( 'geodir_google_api_key' ); |
|
| 1010 | + $key = get_option('geodir_google_api_key');
|
|
| 1011 | 1011 | |
| 1012 | 1012 | /** |
| 1013 | 1013 | * Filter Google maps api key. |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | * |
| 1017 | 1017 | * @param string $key Google maps api key. |
| 1018 | 1018 | */ |
| 1019 | - return apply_filters( 'geodir_google_api_key', $key ); |
|
| 1019 | + return apply_filters('geodir_google_api_key', $key);
|
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | |
@@ -1036,20 +1036,20 @@ discard block |
||
| 1036 | 1036 | global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; |
| 1037 | 1037 | |
| 1038 | 1038 | $is_geodir_page = geodir_is_geodir_page(); |
| 1039 | - if ( ! $is_geodir_page ) {
|
|
| 1039 | + if (!$is_geodir_page) {
|
|
| 1040 | 1040 | return; |
| 1041 | 1041 | }// if non GD page, bail |
| 1042 | 1042 | |
| 1043 | 1043 | $use_gd_meta = true; |
| 1044 | - if ( ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) && !geodir_disable_yoast_seo_metas() ) {
|
|
| 1044 | + if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
|
|
| 1045 | 1045 | $use_gd_meta = false; |
| 1046 | 1046 | |
| 1047 | - if ( geodir_is_page( 'search' ) ) {
|
|
| 1047 | + if (geodir_is_page('search')) {
|
|
| 1048 | 1048 | $use_gd_meta = true; |
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - if ( ! $use_gd_meta ) {
|
|
| 1052 | + if (!$use_gd_meta) {
|
|
| 1053 | 1053 | return; |
| 1054 | 1054 | }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. |
| 1055 | 1055 | |
@@ -1057,170 +1057,170 @@ discard block |
||
| 1057 | 1057 | |
| 1058 | 1058 | $all_postypes = geodir_get_posttypes(); |
| 1059 | 1059 | |
| 1060 | - $geodir_taxonomies = geodir_get_taxonomies( '', true ); |
|
| 1060 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1061 | 1061 | |
| 1062 | 1062 | $meta_desc = ''; |
| 1063 | 1063 | $meta_key = ''; |
| 1064 | - if ( isset( $current_term->ID ) && $current_term->ID == geodir_location_page_id() ) {
|
|
| 1064 | + if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
|
|
| 1065 | 1065 | /** |
| 1066 | 1066 | * Filter SEO meta location description. |
| 1067 | 1067 | * |
| 1068 | 1068 | * @since 1.0.0 |
| 1069 | 1069 | */ |
| 1070 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', '' ); |
|
| 1070 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
|
|
| 1071 | 1071 | $meta_desc .= ''; |
| 1072 | 1072 | } |
| 1073 | - if ( have_posts() && is_single() OR is_page() ) {
|
|
| 1074 | - while ( have_posts() ) {
|
|
| 1073 | + if (have_posts() && is_single() OR is_page()) {
|
|
| 1074 | + while (have_posts()) {
|
|
| 1075 | 1075 | the_post(); |
| 1076 | 1076 | |
| 1077 | - if ( has_excerpt() ) {
|
|
| 1078 | - $out_excerpt = strip_tags( strip_shortcodes( get_the_excerpt() ) ); |
|
| 1079 | - if ( empty( $out_excerpt ) ) {
|
|
| 1080 | - $out_excerpt = strip_tags( do_shortcode( get_the_excerpt() ) ); |
|
| 1077 | + if (has_excerpt()) {
|
|
| 1078 | + $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); |
|
| 1079 | + if (empty($out_excerpt)) {
|
|
| 1080 | + $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); |
|
| 1081 | 1081 | } |
| 1082 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $out_excerpt ); |
|
| 1082 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
|
|
| 1083 | 1083 | } else {
|
| 1084 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $post->post_content ); |
|
| 1085 | - $out_excerpt = strip_tags( strip_shortcodes( $out_excerpt ) ); |
|
| 1086 | - if ( empty( $out_excerpt ) ) {
|
|
| 1087 | - $out_excerpt = strip_tags( do_shortcode( $out_excerpt ) ); // parse short code from content |
|
| 1084 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
|
|
| 1085 | + $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); |
|
| 1086 | + if (empty($out_excerpt)) {
|
|
| 1087 | + $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content |
|
| 1088 | 1088 | } |
| 1089 | - $out_excerpt = trim( wp_trim_words( $out_excerpt, 35, '' ), '.!?,;:-' ); |
|
| 1089 | + $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | $meta_desc .= $out_excerpt; |
| 1093 | 1093 | } |
| 1094 | - } elseif ( ( is_category() || is_tag() ) && isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
|
|
| 1095 | - if ( is_category() ) {
|
|
| 1096 | - $meta_desc .= __( "Posts related to Category:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_cat_title( "", false ) ); |
|
| 1097 | - } elseif ( is_tag() ) {
|
|
| 1098 | - $meta_desc .= __( "Posts related to Tag:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_tag_title( "", false ) ); |
|
| 1094 | + } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1095 | + if (is_category()) {
|
|
| 1096 | + $meta_desc .= __("Posts related to Category:", 'geodirectory')." ".geodir_utf8_ucfirst(single_cat_title("", false));
|
|
| 1097 | + } elseif (is_tag()) {
|
|
| 1098 | + $meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".geodir_utf8_ucfirst(single_tag_title("", false));
|
|
| 1099 | 1099 | } |
| 1100 | - } elseif ( isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
|
|
| 1101 | - $meta_desc .= isset( $current_term->description ) ? $current_term->description : ''; |
|
| 1100 | + } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1101 | + $meta_desc .= isset($current_term->description) ? $current_term->description : ''; |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | 1105 | $geodir_post_type = geodir_get_current_posttype(); |
| 1106 | - $geodir_post_type_info = get_post_type_object( $geodir_post_type ); |
|
| 1107 | - $geodir_is_page_listing = geodir_is_page( 'listing' ) ? true : false; |
|
| 1108 | - |
|
| 1109 | - $category_taxonomy = geodir_get_taxonomies( $geodir_post_type ); |
|
| 1110 | - $tag_taxonomy = geodir_get_taxonomies( $geodir_post_type, true ); |
|
| 1111 | - |
|
| 1112 | - $geodir_is_category = isset( $category_taxonomy[0] ) && get_query_var( $category_taxonomy[0] ) ? get_query_var( $category_taxonomy[0] ) : false; |
|
| 1113 | - $geodir_is_tag = isset( $tag_taxonomy[0] ) && get_query_var( $tag_taxonomy[0] ) ? true : false; |
|
| 1114 | - |
|
| 1115 | - $geodir_is_search = geodir_is_page( 'search' ) ? true : false; |
|
| 1116 | - $geodir_is_location = geodir_is_page( 'location' ) ? true : false; |
|
| 1117 | - $geodir_location_manager = isset( $geodir_addon_list['geodir_location_manager'] ) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1118 | - $godir_location_terms = geodir_get_current_location_terms( 'query_vars' ); |
|
| 1119 | - $gd_city = $geodir_location_manager && isset( $godir_location_terms['gd_city'] ) ? $godir_location_terms['gd_city'] : null; |
|
| 1120 | - $gd_region = $geodir_location_manager && isset( $godir_location_terms['gd_region'] ) ? $godir_location_terms['gd_region'] : null; |
|
| 1121 | - $gd_country = $geodir_location_manager && isset( $godir_location_terms['gd_country'] ) ? $godir_location_terms['gd_country'] : null; |
|
| 1122 | - $replace_location = __( 'Everywhere', 'geodirectory' ); |
|
| 1106 | + $geodir_post_type_info = get_post_type_object($geodir_post_type); |
|
| 1107 | + $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
|
|
| 1108 | + |
|
| 1109 | + $category_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 1110 | + $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); |
|
| 1111 | + |
|
| 1112 | + $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; |
|
| 1113 | + $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; |
|
| 1114 | + |
|
| 1115 | + $geodir_is_search = geodir_is_page('search') ? true : false;
|
|
| 1116 | + $geodir_is_location = geodir_is_page('location') ? true : false;
|
|
| 1117 | + $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1118 | + $godir_location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1119 | + $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : null; |
|
| 1120 | + $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : null; |
|
| 1121 | + $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : null; |
|
| 1122 | + $replace_location = __('Everywhere', 'geodirectory');
|
|
| 1123 | 1123 | $location_id = null; |
| 1124 | - if ( $geodir_location_manager ) {
|
|
| 1125 | - $sql = $wpdb->prepare( "SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array( $gd_city ) ); |
|
| 1126 | - $location_id = (int) $wpdb->get_var( $sql ); |
|
| 1124 | + if ($geodir_location_manager) {
|
|
| 1125 | + $sql = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
|
|
| 1126 | + $location_id = (int) $wpdb->get_var($sql); |
|
| 1127 | 1127 | $location_type = geodir_what_is_current_location(); |
| 1128 | - if ( $location_type == 'city' ) {
|
|
| 1129 | - $replace_location = geodir_get_current_location( array( 'what' => 'city', 'echo' => false ) ); |
|
| 1130 | - } elseif ( $location_type == 'region' ) {
|
|
| 1131 | - $replace_location = geodir_get_current_location( array( 'what' => 'region', 'echo' => false ) ); |
|
| 1132 | - } elseif ( $location_type == 'country' ) {
|
|
| 1133 | - $replace_location = geodir_get_current_location( array( 'what' => 'country', 'echo' => false ) ); |
|
| 1134 | - $replace_location = __( $replace_location, 'geodirectory' ); |
|
| 1128 | + if ($location_type == 'city') {
|
|
| 1129 | + $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
|
|
| 1130 | + } elseif ($location_type == 'region') {
|
|
| 1131 | + $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
|
|
| 1132 | + } elseif ($location_type == 'country') {
|
|
| 1133 | + $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
|
|
| 1134 | + $replace_location = __($replace_location, 'geodirectory'); |
|
| 1135 | 1135 | } |
| 1136 | - $country = get_query_var( 'gd_country' ); |
|
| 1137 | - $region = get_query_var( 'gd_region' ); |
|
| 1138 | - $city = get_query_var( 'gd_city' ); |
|
| 1136 | + $country = get_query_var('gd_country');
|
|
| 1137 | + $region = get_query_var('gd_region');
|
|
| 1138 | + $city = get_query_var('gd_city');
|
|
| 1139 | 1139 | $current_location = ''; |
| 1140 | - if ( $country != '' ) {
|
|
| 1141 | - $current_location = get_actual_location_name( 'country', $country, true ); |
|
| 1140 | + if ($country != '') {
|
|
| 1141 | + $current_location = get_actual_location_name('country', $country, true);
|
|
| 1142 | 1142 | } |
| 1143 | - if ( $region != '' ) {
|
|
| 1144 | - $current_location = get_actual_location_name( 'region', $region ); |
|
| 1143 | + if ($region != '') {
|
|
| 1144 | + $current_location = get_actual_location_name('region', $region);
|
|
| 1145 | 1145 | } |
| 1146 | - if ( $city != '' ) {
|
|
| 1147 | - $current_location = get_actual_location_name( 'city', $city ); |
|
| 1146 | + if ($city != '') {
|
|
| 1147 | + $current_location = get_actual_location_name('city', $city);
|
|
| 1148 | 1148 | } |
| 1149 | 1149 | $replace_location = $current_location != '' ? $current_location : $replace_location; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | $geodir_meta_keys = ''; |
| 1153 | 1153 | $geodir_meta_desc = ''; |
| 1154 | - if ( $is_geodir_page && ! empty( $geodir_post_type_info ) ) {
|
|
| 1155 | - if ( $geodir_is_page_listing || $geodir_is_search || geodir_is_page( 'add-listing' ) ) {
|
|
| 1156 | - $geodir_meta_keys = isset( $geodir_post_type_info->seo['meta_keyword'] ) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1154 | + if ($is_geodir_page && !empty($geodir_post_type_info)) {
|
|
| 1155 | + if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
|
|
| 1156 | + $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1157 | 1157 | |
| 1158 | - $geodir_meta_desc = isset( $geodir_post_type_info->description ) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1159 | - $geodir_meta_desc = isset( $geodir_post_type_info->seo['meta_description'] ) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1158 | + $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1159 | + $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1160 | 1160 | |
| 1161 | - if ( $geodir_is_category ) {
|
|
| 1162 | - $category = $geodir_is_category ? get_term_by( 'slug', $geodir_is_category, $category_taxonomy[0] ) : null; |
|
| 1163 | - if ( isset( $category->term_id ) && ! empty( $category->term_id ) ) {
|
|
| 1161 | + if ($geodir_is_category) {
|
|
| 1162 | + $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : null;
|
|
| 1163 | + if (isset($category->term_id) && !empty($category->term_id)) {
|
|
| 1164 | 1164 | $category_id = $category->term_id; |
| 1165 | - $category_desc = trim( $category->description ) != '' ? trim( $category->description ) : get_tax_meta( $category_id, 'ct_cat_top_desc', false, $geodir_post_type ); |
|
| 1166 | - if ( $location_id ) {
|
|
| 1167 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; |
|
| 1168 | - $cat_loc_option = get_option( $option_name ); |
|
| 1169 | - |
|
| 1170 | - $gd_cat_loc_default = ! empty( $cat_loc_option ) && isset( $cat_loc_option['gd_cat_loc_default'] ) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1171 | - if ( ! $gd_cat_loc_default ) {
|
|
| 1172 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; |
|
| 1173 | - $option = get_option( $option_name ); |
|
| 1174 | - $category_desc = isset( $option['gd_cat_loc_desc'] ) && trim( $option['gd_cat_loc_desc'] ) != '' ? trim( $option['gd_cat_loc_desc'] ) : $category_desc; |
|
| 1165 | + $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); |
|
| 1166 | + if ($location_id) {
|
|
| 1167 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id; |
|
| 1168 | + $cat_loc_option = get_option($option_name); |
|
| 1169 | + |
|
| 1170 | + $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1171 | + if (!$gd_cat_loc_default) {
|
|
| 1172 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id; |
|
| 1173 | + $option = get_option($option_name); |
|
| 1174 | + $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; |
|
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | - $geodir_meta_desc = __( "Posts related to Category:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_cat_title( "", false ) ) . '. ' . $category_desc; |
|
| 1177 | + $geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".geodir_utf8_ucfirst(single_cat_title("", false)).'. '.$category_desc;
|
|
| 1178 | 1178 | } |
| 1179 | - } else if ( $geodir_is_tag ) {
|
|
| 1180 | - $geodir_meta_desc = __( "Posts related to Tag:", 'geodirectory' ) . " " . geodir_utf8_ucfirst( single_tag_title( "", false ) ) . '. ' . $geodir_meta_desc; |
|
| 1179 | + } else if ($geodir_is_tag) {
|
|
| 1180 | + $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".geodir_utf8_ucfirst(single_tag_title("", false)).'. '.$geodir_meta_desc;
|
|
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | |
| 1186 | 1186 | $gd_page = ''; |
| 1187 | - if ( geodir_is_page( 'home' ) ) {
|
|
| 1187 | + if (geodir_is_page('home')) {
|
|
| 1188 | 1188 | $gd_page = 'home'; |
| 1189 | - $meta_desc = ( get_option( 'geodir_meta_desc_homepage' ) ) ? get_option( 'geodir_meta_desc_homepage' ) : $meta_desc; |
|
| 1190 | - } elseif ( geodir_is_page( 'detail' ) ) {
|
|
| 1189 | + $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
|
| 1190 | + } elseif (geodir_is_page('detail')) {
|
|
| 1191 | 1191 | $gd_page = 'detail'; |
| 1192 | - $meta_desc = ( get_option( 'geodir_meta_desc_detail' ) ) ? get_option( 'geodir_meta_desc_detail' ) : $meta_desc; |
|
| 1193 | - } elseif ( geodir_is_page( 'pt' ) ) {
|
|
| 1192 | + $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
|
| 1193 | + } elseif (geodir_is_page('pt')) {
|
|
| 1194 | 1194 | $gd_page = 'pt'; |
| 1195 | - $meta_desc = ( get_option( 'geodir_meta_desc_pt' ) ) ? get_option( 'geodir_meta_desc_pt' ) : $meta_desc; |
|
| 1196 | - } elseif ( geodir_is_page( 'listing' ) ) {
|
|
| 1195 | + $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
|
| 1196 | + } elseif (geodir_is_page('listing')) {
|
|
| 1197 | 1197 | $gd_page = 'listing'; |
| 1198 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing' ) ) ? get_option( 'geodir_meta_desc_listing' ) : $meta_desc; |
|
| 1199 | - } elseif ( geodir_is_page( 'location' ) ) {
|
|
| 1198 | + $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
|
| 1199 | + } elseif (geodir_is_page('location')) {
|
|
| 1200 | 1200 | $gd_page = 'location'; |
| 1201 | - $meta_desc = ( get_option( 'geodir_meta_desc_location' ) ) ? get_option( 'geodir_meta_desc_location' ) : $meta_desc; |
|
| 1202 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', $meta_desc ); |
|
| 1201 | + $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
|
| 1202 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
|
| 1203 | 1203 | |
| 1204 | - } elseif ( geodir_is_page( 'search' ) ) {
|
|
| 1204 | + } elseif (geodir_is_page('search')) {
|
|
| 1205 | 1205 | $gd_page = 'search'; |
| 1206 | - $meta_desc = ( get_option( 'geodir_meta_desc_search' ) ) ? get_option( 'geodir_meta_desc_search' ) : $meta_desc; |
|
| 1207 | - } elseif ( geodir_is_page( 'add-listing' ) ) {
|
|
| 1206 | + $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
|
| 1207 | + } elseif (geodir_is_page('add-listing')) {
|
|
| 1208 | 1208 | $gd_page = 'add-listing'; |
| 1209 | - $meta_desc = ( get_option( 'geodir_meta_desc_add-listing' ) ) ? get_option( 'geodir_meta_desc_add-listing' ) : $meta_desc; |
|
| 1210 | - } elseif ( geodir_is_page( 'author' ) ) {
|
|
| 1209 | + $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
|
| 1210 | + } elseif (geodir_is_page('author')) {
|
|
| 1211 | 1211 | $gd_page = 'author'; |
| 1212 | - $meta_desc = ( get_option( 'geodir_meta_desc_author' ) ) ? get_option( 'geodir_meta_desc_author' ) : $meta_desc; |
|
| 1213 | - } elseif ( geodir_is_page( 'login' ) ) {
|
|
| 1212 | + $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
|
| 1213 | + } elseif (geodir_is_page('login')) {
|
|
| 1214 | 1214 | $gd_page = 'login'; |
| 1215 | - $meta_desc = ( get_option( 'geodir_meta_desc_login' ) ) ? get_option( 'geodir_meta_desc_login' ) : $meta_desc; |
|
| 1216 | - } elseif ( geodir_is_page( 'listing-success' ) ) {
|
|
| 1215 | + $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
|
| 1216 | + } elseif (geodir_is_page('listing-success')) {
|
|
| 1217 | 1217 | $gd_page = 'listing-success'; |
| 1218 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing-success' ) ) ? get_option( 'geodir_meta_desc_listing-success' ) : $meta_desc; |
|
| 1218 | + $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | |
| 1222 | - if ( $meta_desc ) {
|
|
| 1223 | - $meta_desc = stripslashes_deep( $meta_desc ); |
|
| 1222 | + if ($meta_desc) {
|
|
| 1223 | + $meta_desc = stripslashes_deep($meta_desc); |
|
| 1224 | 1224 | /** |
| 1225 | 1225 | * Filter page description to replace variables. |
| 1226 | 1226 | * |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | * @param string $title The page description including variables. |
| 1230 | 1230 | * @param string $gd_page The GeoDirectory page type if any. |
| 1231 | 1231 | */ |
| 1232 | - $meta_desc = apply_filters( 'geodir_seo_meta_description_pre', __( $meta_desc, 'geodirectory' ), $gd_page, '' ); |
|
| 1232 | + $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
|
|
| 1233 | 1233 | |
| 1234 | 1234 | /** |
| 1235 | 1235 | * Filter SEO meta description. |
@@ -1238,49 +1238,49 @@ discard block |
||
| 1238 | 1238 | * |
| 1239 | 1239 | * @param string $meta_desc Meta description content. |
| 1240 | 1240 | */ |
| 1241 | - echo apply_filters( 'geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc ); |
|
| 1241 | + echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
|
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | // meta keywords |
| 1245 | - if ( isset( $post->post_type ) && in_array( $post->post_type, $all_postypes ) ) {
|
|
| 1246 | - $place_tags = wp_get_post_terms( $post->ID, $post->post_type . '_tags', array( "fields" => "names" ) ); |
|
| 1247 | - $place_cats = wp_get_post_terms( $post->ID, $post->post_type . 'category', array( "fields" => "names" ) ); |
|
| 1245 | + if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
|
|
| 1246 | + $place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
|
|
| 1247 | + $place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
|
|
| 1248 | 1248 | |
| 1249 | - $meta_key .= implode( ", ", array_merge( (array) $place_cats, (array) $place_tags ) ); |
|
| 1249 | + $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
|
|
| 1250 | 1250 | } else {
|
| 1251 | 1251 | $posttags = get_the_tags(); |
| 1252 | - if ( $posttags ) {
|
|
| 1253 | - foreach ( $posttags as $tag ) {
|
|
| 1254 | - $meta_key .= $tag->name . ' '; |
|
| 1252 | + if ($posttags) {
|
|
| 1253 | + foreach ($posttags as $tag) {
|
|
| 1254 | + $meta_key .= $tag->name.' '; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | } else {
|
| 1257 | - $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) ); |
|
| 1257 | + $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
|
|
| 1258 | 1258 | $xt = 1; |
| 1259 | 1259 | |
| 1260 | - foreach ( $tags as $tag ) {
|
|
| 1261 | - if ( $xt <= 20 ) {
|
|
| 1262 | - $meta_key .= $tag->name . ", "; |
|
| 1260 | + foreach ($tags as $tag) {
|
|
| 1261 | + if ($xt <= 20) {
|
|
| 1262 | + $meta_key .= $tag->name.", "; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - $xt ++; |
|
| 1265 | + $xt++; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | - $meta_key = $meta_key != '' ? rtrim( trim( $meta_key ), "," ) : $meta_key; |
|
| 1271 | - $geodir_meta_keys = $geodir_meta_keys != '' ? ( $meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys ) : $meta_key; |
|
| 1272 | - if ( $geodir_meta_keys != '' ) {
|
|
| 1273 | - $geodir_meta_keys = strip_tags( $geodir_meta_keys ); |
|
| 1274 | - $geodir_meta_keys = esc_html( $geodir_meta_keys ); |
|
| 1275 | - $geodir_meta_keys = geodir_strtolower( $geodir_meta_keys ); |
|
| 1276 | - $geodir_meta_keys = wp_html_excerpt( $geodir_meta_keys, 1000, '' ); |
|
| 1277 | - $geodir_meta_keys = str_replace( '%location%', $replace_location, $geodir_meta_keys ); |
|
| 1270 | + $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; |
|
| 1271 | + $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key; |
|
| 1272 | + if ($geodir_meta_keys != '') {
|
|
| 1273 | + $geodir_meta_keys = strip_tags($geodir_meta_keys); |
|
| 1274 | + $geodir_meta_keys = esc_html($geodir_meta_keys); |
|
| 1275 | + $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); |
|
| 1276 | + $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); |
|
| 1277 | + $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
|
|
| 1278 | 1278 | |
| 1279 | - $meta_key = rtrim( trim( $geodir_meta_keys ), "," ); |
|
| 1279 | + $meta_key = rtrim(trim($geodir_meta_keys), ","); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - if ( $meta_key ) {
|
|
| 1283 | - $meta_key = stripslashes_deep( $meta_key ); |
|
| 1282 | + if ($meta_key) {
|
|
| 1283 | + $meta_key = stripslashes_deep($meta_key); |
|
| 1284 | 1284 | /** |
| 1285 | 1285 | * Filter SEO meta keywords. |
| 1286 | 1286 | * |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | * |
| 1289 | 1289 | * @param string $meta_desc Meta keywords. |
| 1290 | 1290 | */ |
| 1291 | - echo apply_filters( 'geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key ); |
|
| 1291 | + echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
|
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | } |
@@ -1308,8 +1308,8 @@ discard block |
||
| 1308 | 1308 | |
| 1309 | 1309 | $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array(); |
| 1310 | 1310 | |
| 1311 | - foreach ( $geodir_detail_page_tabs_array as $key => $tabs_obj ) {
|
|
| 1312 | - $geodir_detail_page_tabs_key_value_array[ $key ] = $tabs_obj['heading_text']; |
|
| 1311 | + foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
|
|
| 1312 | + $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text']; |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | return $geodir_detail_page_tabs_key_value_array; |
@@ -1331,57 +1331,57 @@ discard block |
||
| 1331 | 1331 | * @since 1.0.0 |
| 1332 | 1332 | */ |
| 1333 | 1333 | $arr_tabs['post_profile'] = array( |
| 1334 | - 'heading_text' => __( 'Profile', 'geodirectory' ), |
|
| 1334 | + 'heading_text' => __('Profile', 'geodirectory'),
|
|
| 1335 | 1335 | 'is_active_tab' => true, |
| 1336 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_profile' ), |
|
| 1336 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
|
|
| 1337 | 1337 | 'tab_content' => '' |
| 1338 | 1338 | ); |
| 1339 | - $arr_tabs['post_info'] = array( |
|
| 1340 | - 'heading_text' => __( 'More Info', 'geodirectory' ), |
|
| 1339 | + $arr_tabs['post_info'] = array( |
|
| 1340 | + 'heading_text' => __('More Info', 'geodirectory'),
|
|
| 1341 | 1341 | 'is_active_tab' => false, |
| 1342 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_info' ), |
|
| 1342 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
|
|
| 1343 | 1343 | 'tab_content' => '' |
| 1344 | 1344 | ); |
| 1345 | 1345 | |
| 1346 | 1346 | $arr_tabs['post_images'] = array( |
| 1347 | - 'heading_text' => __( 'Photos', 'geodirectory' ), |
|
| 1347 | + 'heading_text' => __('Photos', 'geodirectory'),
|
|
| 1348 | 1348 | 'is_active_tab' => false, |
| 1349 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_images' ), |
|
| 1349 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
|
|
| 1350 | 1350 | 'tab_content' => '' |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | 1353 | $arr_tabs['post_video'] = array( |
| 1354 | - 'heading_text' => __( 'Video', 'geodirectory' ), |
|
| 1354 | + 'heading_text' => __('Video', 'geodirectory'),
|
|
| 1355 | 1355 | 'is_active_tab' => false, |
| 1356 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_video' ), |
|
| 1356 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
|
|
| 1357 | 1357 | 'tab_content' => '' |
| 1358 | 1358 | ); |
| 1359 | 1359 | |
| 1360 | 1360 | $arr_tabs['special_offers'] = array( |
| 1361 | - 'heading_text' => __( 'Special Offers', 'geodirectory' ), |
|
| 1361 | + 'heading_text' => __('Special Offers', 'geodirectory'),
|
|
| 1362 | 1362 | 'is_active_tab' => false, |
| 1363 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'special_offers' ), |
|
| 1363 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
|
|
| 1364 | 1364 | 'tab_content' => '' |
| 1365 | 1365 | ); |
| 1366 | 1366 | |
| 1367 | 1367 | $arr_tabs['post_map'] = array( |
| 1368 | - 'heading_text' => __( 'Map', 'geodirectory' ), |
|
| 1368 | + 'heading_text' => __('Map', 'geodirectory'),
|
|
| 1369 | 1369 | 'is_active_tab' => false, |
| 1370 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_map' ), |
|
| 1370 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
|
|
| 1371 | 1371 | 'tab_content' => '' |
| 1372 | 1372 | ); |
| 1373 | 1373 | |
| 1374 | 1374 | $arr_tabs['reviews'] = array( |
| 1375 | - 'heading_text' => __( 'Reviews', 'geodirectory' ), |
|
| 1375 | + 'heading_text' => __('Reviews', 'geodirectory'),
|
|
| 1376 | 1376 | 'is_active_tab' => false, |
| 1377 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'reviews' ), |
|
| 1377 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
|
|
| 1378 | 1378 | 'tab_content' => 'review display' |
| 1379 | 1379 | ); |
| 1380 | 1380 | |
| 1381 | 1381 | $arr_tabs['related_listing'] = array( |
| 1382 | - 'heading_text' => __( 'Related Listing', 'geodirectory' ), |
|
| 1382 | + 'heading_text' => __('Related Listing', 'geodirectory'),
|
|
| 1383 | 1383 | 'is_active_tab' => false, |
| 1384 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'related_listing' ), |
|
| 1384 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
|
|
| 1385 | 1385 | 'tab_content' => '' |
| 1386 | 1386 | ); |
| 1387 | 1387 | |
@@ -1390,7 +1390,7 @@ discard block |
||
| 1390 | 1390 | * |
| 1391 | 1391 | * @since 1.0.0 |
| 1392 | 1392 | */ |
| 1393 | - return apply_filters( 'geodir_detail_page_tab_list_extend', $arr_tabs ); |
|
| 1393 | + return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
|
|
| 1394 | 1394 | |
| 1395 | 1395 | |
| 1396 | 1396 | } |
@@ -1404,13 +1404,13 @@ discard block |
||
| 1404 | 1404 | * @return mixed|array Tabs array. |
| 1405 | 1405 | */ |
| 1406 | 1406 | function geodir_detail_page_tabs_list() {
|
| 1407 | - $tabs_excluded = get_option( 'geodir_detail_page_tabs_excluded' ); |
|
| 1407 | + $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1408 | 1408 | $tabs_array = geodir_detail_page_tabs_array(); |
| 1409 | 1409 | |
| 1410 | - if ( ! empty( $tabs_excluded ) ) {
|
|
| 1411 | - foreach ( $tabs_excluded as $tab ) {
|
|
| 1412 | - if ( array_key_exists( $tab, $tabs_array ) ) {
|
|
| 1413 | - unset( $tabs_array[ $tab ] ); |
|
| 1410 | + if (!empty($tabs_excluded)) {
|
|
| 1411 | + foreach ($tabs_excluded as $tab) {
|
|
| 1412 | + if (array_key_exists($tab, $tabs_array)) {
|
|
| 1413 | + unset($tabs_array[$tab]); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | } |
| 1416 | 1416 | } |
@@ -1434,58 +1434,58 @@ discard block |
||
| 1434 | 1434 | function geodir_show_detail_page_tabs() {
|
| 1435 | 1435 | global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields, $preview; |
| 1436 | 1436 | |
| 1437 | - $post_id = ! empty( $post ) && isset( $post->ID ) ? (int) $post->ID : 0; |
|
| 1438 | - $request_post_id = ! empty( $_REQUEST['p'] ) ? (int) $_REQUEST['p'] : 0; |
|
| 1439 | - $is_backend_preview = ( is_single() && ! empty( $_REQUEST['post_type'] ) && ! empty( $_REQUEST['preview'] ) && ! empty( $_REQUEST['p'] ) ) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1437 | + $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; |
|
| 1438 | + $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; |
|
| 1439 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1440 | 1440 | |
| 1441 | - if ( $is_backend_preview && ! $post_id > 0 && $request_post_id > 0 ) {
|
|
| 1442 | - $post = geodir_get_post_info( $request_post_id ); |
|
| 1443 | - setup_postdata( $post ); |
|
| 1441 | + if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
|
|
| 1442 | + $post = geodir_get_post_info($request_post_id); |
|
| 1443 | + setup_postdata($post); |
|
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - $geodir_post_detail_fields = geodir_show_listing_info( 'moreinfo' ); |
|
| 1446 | + $geodir_post_detail_fields = geodir_show_listing_info('moreinfo');
|
|
| 1447 | 1447 | |
| 1448 | 1448 | |
| 1449 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 1450 | - $video = geodir_get_video( $post->ID ); |
|
| 1451 | - $special_offers = geodir_get_special_offers( $post->ID ); |
|
| 1449 | + if (geodir_is_page('detail')) {
|
|
| 1450 | + $video = geodir_get_video($post->ID); |
|
| 1451 | + $special_offers = geodir_get_special_offers($post->ID); |
|
| 1452 | 1452 | $related_listing_array = array(); |
| 1453 | - if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
|
|
| 1454 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); |
|
| 1453 | + if (get_option('geodir_add_related_listing_posttypes')) {
|
|
| 1454 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | |
| 1458 | - $excluded_tabs = get_option( 'geodir_detail_page_tabs_excluded' ); |
|
| 1459 | - if ( ! $excluded_tabs ) {
|
|
| 1458 | + $excluded_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1459 | + if (!$excluded_tabs) {
|
|
| 1460 | 1460 | $excluded_tabs = array(); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | $related_listing = ''; |
| 1464 | - if ( in_array( $post->post_type, $related_listing_array ) && ! in_array( 'related_listing', $excluded_tabs ) ) {
|
|
| 1464 | + if (in_array($post->post_type, $related_listing_array) && !in_array('related_listing', $excluded_tabs)) {
|
|
| 1465 | 1465 | $request = array( |
| 1466 | - 'post_number' => get_option( 'geodir_related_post_count' ), |
|
| 1467 | - 'relate_to' => get_option( 'geodir_related_post_relate_to' ), |
|
| 1468 | - 'layout' => get_option( 'geodir_related_post_listing_view' ), |
|
| 1469 | - 'add_location_filter' => get_option( 'geodir_related_post_location_filter' ), |
|
| 1470 | - 'list_sort' => get_option( 'geodir_related_post_sortby' ), |
|
| 1471 | - 'character_count' => get_option( 'geodir_related_post_excerpt' ) |
|
| 1466 | + 'post_number' => get_option('geodir_related_post_count'),
|
|
| 1467 | + 'relate_to' => get_option('geodir_related_post_relate_to'),
|
|
| 1468 | + 'layout' => get_option('geodir_related_post_listing_view'),
|
|
| 1469 | + 'add_location_filter' => get_option('geodir_related_post_location_filter'),
|
|
| 1470 | + 'list_sort' => get_option('geodir_related_post_sortby'),
|
|
| 1471 | + 'character_count' => get_option('geodir_related_post_excerpt')
|
|
| 1472 | 1472 | ); |
| 1473 | 1473 | |
| 1474 | - if ( $post->post_type == 'gd_event' && defined( 'GDEVENTS_VERSION' ) ) {
|
|
| 1475 | - $related_listing = geodir_get_detail_page_related_events( $request ); |
|
| 1474 | + if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
|
|
| 1475 | + $related_listing = geodir_get_detail_page_related_events($request); |
|
| 1476 | 1476 | } else {
|
| 1477 | - $related_listing = geodir_related_posts_display( $request ); |
|
| 1477 | + $related_listing = geodir_related_posts_display($request); |
|
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | - $post_images = geodir_get_images( $post->ID, 'thumbnail' ); |
|
| 1482 | + $post_images = geodir_get_images($post->ID, 'thumbnail'); |
|
| 1483 | 1483 | $thumb_image = ''; |
| 1484 | - if ( ! empty( $post_images ) ) {
|
|
| 1485 | - foreach ( $post_images as $image ) {
|
|
| 1486 | - $caption = ( ! empty( $image->caption ) ) ? $image->caption : ''; |
|
| 1487 | - $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; |
|
| 1488 | - $thumb_image .= geodir_show_image( $image, 'thumbnail', true, false ); |
|
| 1484 | + if (!empty($post_images)) {
|
|
| 1485 | + foreach ($post_images as $image) {
|
|
| 1486 | + $caption = (!empty($image->caption)) ? $image->caption : ''; |
|
| 1487 | + $thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">'; |
|
| 1488 | + $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); |
|
| 1489 | 1489 | $thumb_image .= '</a>'; |
| 1490 | 1490 | } |
| 1491 | 1491 | } |
@@ -1494,11 +1494,11 @@ discard block |
||
| 1494 | 1494 | $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
| 1495 | 1495 | $map_args['width'] = '600'; |
| 1496 | 1496 | $map_args['height'] = '300'; |
| 1497 | - if ( $post->post_mapzoom ) {
|
|
| 1498 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
| 1497 | + if ($post->post_mapzoom) {
|
|
| 1498 | + $map_args['zoom'] = ''.$post->post_mapzoom.''; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | $map_args['autozoom'] = false; |
| 1501 | - $map_args['scrollwheel'] = ( get_option( 'geodir_add_listing_mouse_scroll' ) ) ? 0 : 1; |
|
| 1501 | + $map_args['scrollwheel'] = (get_option('geodir_add_listing_mouse_scroll')) ? 0 : 1;
|
|
| 1502 | 1502 | $map_args['child_collapse'] = '0'; |
| 1503 | 1503 | $map_args['enable_cat_filters'] = false; |
| 1504 | 1504 | $map_args['enable_text_search'] = false; |
@@ -1507,43 +1507,43 @@ discard block |
||
| 1507 | 1507 | $map_args['enable_jason_on_load'] = true; |
| 1508 | 1508 | $map_args['enable_map_direction'] = true; |
| 1509 | 1509 | $map_args['map_class_name'] = 'geodir-map-detail-page'; |
| 1510 | - $map_args['maptype'] = ( ! empty( $post->post_mapview ) ) ? $post->post_mapview : 'ROADMAP'; |
|
| 1511 | - } else if ( geodir_is_page( 'preview' ) ) {
|
|
| 1512 | - $video = isset( $post->geodir_video ) ? $post->geodir_video : ''; |
|
| 1513 | - $special_offers = isset( $post->geodir_special_offers ) ? $post->geodir_special_offers : ''; |
|
| 1510 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
| 1511 | + } else if (geodir_is_page('preview')) {
|
|
| 1512 | + $video = isset($post->geodir_video) ? $post->geodir_video : ''; |
|
| 1513 | + $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; |
|
| 1514 | 1514 | |
| 1515 | - if ( isset( $post->post_images ) ) {
|
|
| 1516 | - $post->post_images = trim( $post->post_images, "," ); |
|
| 1515 | + if (isset($post->post_images)) {
|
|
| 1516 | + $post->post_images = trim($post->post_images, ","); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | - if ( isset( $post->post_images ) && ! empty( $post->post_images ) ) {
|
|
| 1520 | - $post_images = explode( ",", $post->post_images ); |
|
| 1519 | + if (isset($post->post_images) && !empty($post->post_images)) {
|
|
| 1520 | + $post_images = explode(",", $post->post_images);
|
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | $thumb_image = ''; |
| 1524 | - if ( ! empty( $post_images ) ) {
|
|
| 1525 | - foreach ( $post_images as $image ) {
|
|
| 1526 | - if ( $image != '' ) {
|
|
| 1527 | - $thumb_image .= '<a href="' . $image . '">'; |
|
| 1528 | - $thumb_image .= geodir_show_image( array( 'src' => $image ), 'thumbnail', true, false ); |
|
| 1524 | + if (!empty($post_images)) {
|
|
| 1525 | + foreach ($post_images as $image) {
|
|
| 1526 | + if ($image != '') {
|
|
| 1527 | + $thumb_image .= '<a href="'.$image.'">'; |
|
| 1528 | + $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
|
|
| 1529 | 1529 | $thumb_image .= '</a>'; |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | 1534 | global $map_jason; |
| 1535 | - $marker_json = $post->marker_json != '' ? json_decode( $post->marker_json, true ) : array(); |
|
| 1536 | - $marker_icon = ( ! empty( $marker_json ) && ! empty( $marker_json['i'] ) ) ? $marker_json['i'] : ''; |
|
| 1537 | - $icon_size = geodir_get_marker_size( $marker_icon ); |
|
| 1535 | + $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array(); |
|
| 1536 | + $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : ''; |
|
| 1537 | + $icon_size = geodir_get_marker_size($marker_icon); |
|
| 1538 | 1538 | $marker_json['w'] = $icon_size['w']; |
| 1539 | 1539 | $marker_json['h'] = $icon_size['h']; |
| 1540 | - $map_jason[] = json_encode( $marker_json ); |
|
| 1540 | + $map_jason[] = json_encode($marker_json); |
|
| 1541 | 1541 | |
| 1542 | - $address_latitude = isset( $post->post_latitude ) ? $post->post_latitude : ''; |
|
| 1543 | - $address_longitude = isset( $post->post_longitude ) ? $post->post_longitude : ''; |
|
| 1544 | - $mapview = isset( $post->post_mapview ) ? $post->post_mapview : ''; |
|
| 1545 | - $mapzoom = isset( $post->post_mapzoom ) ? $post->post_mapzoom : ''; |
|
| 1546 | - if ( ! $mapzoom ) {
|
|
| 1542 | + $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 1543 | + $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 1544 | + $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; |
|
| 1545 | + $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; |
|
| 1546 | + if (!$mapzoom) {
|
|
| 1547 | 1547 | $mapzoom = 12; |
| 1548 | 1548 | } |
| 1549 | 1549 | |
@@ -1566,37 +1566,37 @@ discard block |
||
| 1566 | 1566 | $map_args['map_class_name'] = 'geodir-map-preview-page'; |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | - $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user |
|
| 1569 | + $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user |
|
| 1570 | 1570 | |
| 1571 | 1571 | $active_tab = ''; |
| 1572 | 1572 | $active_tab_name = ''; |
| 1573 | 1573 | $default_tab = ''; |
| 1574 | 1574 | $default_tab_name = ''; |
| 1575 | - foreach ( $arr_detail_page_tabs as $tab_index => $tabs ) {
|
|
| 1576 | - if ( isset( $tabs['is_active_tab'] ) && $tabs['is_active_tab'] && ! empty( $tabs['is_display'] ) && isset( $tabs['heading_text'] ) && $tabs['heading_text'] ) {
|
|
| 1575 | + foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
|
|
| 1576 | + if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
|
|
| 1577 | 1577 | $active_tab = $tab_index; |
| 1578 | - $active_tab_name = __( $tabs['heading_text'], 'geodirectory' ); |
|
| 1578 | + $active_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | - if ( $default_tab === '' && ! empty( $tabs['is_display'] ) && ! empty( $tabs['heading_text'] ) ) {
|
|
| 1581 | + if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
|
|
| 1582 | 1582 | $default_tab = $tab_index; |
| 1583 | - $default_tab_name = __( $tabs['heading_text'], 'geodirectory' ); |
|
| 1583 | + $default_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | - if ( $active_tab === '' && $default_tab !== '' ) { // Make first tab acs a active tab if not any tab is active.
|
|
| 1588 | - if ( isset( $arr_detail_page_tabs[ $active_tab ] ) && isset( $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] ) ) {
|
|
| 1589 | - $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] = false; |
|
| 1587 | + if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
|
|
| 1588 | + if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
|
|
| 1589 | + $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | - $arr_detail_page_tabs[ $default_tab ]['is_active_tab'] = true; |
|
| 1592 | + $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true; |
|
| 1593 | 1593 | $active_tab = $default_tab; |
| 1594 | 1594 | $active_tab_name = $default_tab_name; |
| 1595 | 1595 | } |
| 1596 | - $tab_list = ( get_option( 'geodir_disable_tabs', false ) ) ? true : false; |
|
| 1596 | + $tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
|
|
| 1597 | 1597 | ?> |
| 1598 | 1598 | <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> |
| 1599 | - <?php if ( ! $tab_list ){ ?>
|
|
| 1599 | + <?php if (!$tab_list) { ?>
|
|
| 1600 | 1600 | <div id="geodir-tab-mobile-menu"> |
| 1601 | 1601 | <i class="fa fa-bars"></i> |
| 1602 | 1602 | <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span> |
@@ -1611,26 +1611,26 @@ discard block |
||
| 1611 | 1611 | * @since 1.0.0 |
| 1612 | 1612 | * @see 'geodir_after_tab_list' |
| 1613 | 1613 | */ |
| 1614 | - do_action( 'geodir_before_tab_list' ); ?> |
|
| 1614 | + do_action('geodir_before_tab_list'); ?>
|
|
| 1615 | 1615 | <?php |
| 1616 | 1616 | |
| 1617 | - foreach ( $arr_detail_page_tabs as $tab_index => $detail_page_tab ) {
|
|
| 1618 | - if ( $detail_page_tab['is_display'] ) {
|
|
| 1617 | + foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
|
|
| 1618 | + if ($detail_page_tab['is_display']) {
|
|
| 1619 | 1619 | |
| 1620 | - if ( ! $tab_list ) {
|
|
| 1620 | + if (!$tab_list) {
|
|
| 1621 | 1621 | ?> |
| 1622 | 1622 | <dt></dt> <!-- added to comply with validation --> |
| 1623 | - <dd <?php if ( $detail_page_tab['is_active_tab'] ){ ?>class="geodir-tab-active"<?php } ?> ><a
|
|
| 1623 | + <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
|
|
| 1624 | 1624 | data-tab="#<?php echo $tab_index; ?>" |
| 1625 | - data-status="enable"><?php _e( $detail_page_tab['heading_text'], 'geodirectory' ); ?></a> |
|
| 1625 | + data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a> |
|
| 1626 | 1626 | </dd> |
| 1627 | 1627 | <?php |
| 1628 | 1628 | } |
| 1629 | 1629 | ob_start() // start tab content buffering |
| 1630 | 1630 | ?> |
| 1631 | 1631 | <li id="<?php echo $tab_index; ?>Tab"> |
| 1632 | - <?php if ( $tab_list ) {
|
|
| 1633 | - $tab_title = '<span class="gd-tab-list-title" ><a href="#' . $tab_index . '">' . __( $detail_page_tab['heading_text'], 'geodirectory' ) . '</a></span><hr />'; |
|
| 1632 | + <?php if ($tab_list) {
|
|
| 1633 | + $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />'; |
|
| 1634 | 1634 | /** |
| 1635 | 1635 | * Filter the tab list title html. |
| 1636 | 1636 | * |
@@ -1640,7 +1640,7 @@ discard block |
||
| 1640 | 1640 | * @param string $tab_index The tab index type. |
| 1641 | 1641 | * @param array $detail_page_tab The array of values including title text. |
| 1642 | 1642 | */ |
| 1643 | - echo apply_filters( 'geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab ); |
|
| 1643 | + echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
|
|
| 1644 | 1644 | } ?> |
| 1645 | 1645 | <div id="<?php echo $tab_index; ?>" class="hash-offset"></div> |
| 1646 | 1646 | <?php |
@@ -1651,7 +1651,7 @@ discard block |
||
| 1651 | 1651 | * |
| 1652 | 1652 | * @param string $tab_index The tab name ID. |
| 1653 | 1653 | */ |
| 1654 | - do_action( 'geodir_before_tab_content', $tab_index ); |
|
| 1654 | + do_action('geodir_before_tab_content', $tab_index);
|
|
| 1655 | 1655 | |
| 1656 | 1656 | /** |
| 1657 | 1657 | * Called before the details tab content is output per tab. |
@@ -1661,21 +1661,21 @@ discard block |
||
| 1661 | 1661 | * @since 1.0.0 |
| 1662 | 1662 | * @todo do we need this if we have the hook above? 'geodir_before_tab_content' |
| 1663 | 1663 | */ |
| 1664 | - do_action( 'geodir_before_' . $tab_index . '_tab_content' ); |
|
| 1664 | + do_action('geodir_before_'.$tab_index.'_tab_content');
|
|
| 1665 | 1665 | /// write a code to generate content of each tab |
| 1666 | - switch ( $tab_index ) {
|
|
| 1666 | + switch ($tab_index) {
|
|
| 1667 | 1667 | case 'post_profile': |
| 1668 | 1668 | /** |
| 1669 | 1669 | * Called before the listing description content on the details page tab. |
| 1670 | 1670 | * |
| 1671 | 1671 | * @since 1.0.0 |
| 1672 | 1672 | */ |
| 1673 | - do_action( 'geodir_before_description_on_listing_detail' ); |
|
| 1674 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 1673 | + do_action('geodir_before_description_on_listing_detail');
|
|
| 1674 | + if (geodir_is_page('detail')) {
|
|
| 1675 | 1675 | the_content(); |
| 1676 | 1676 | } else {
|
| 1677 | 1677 | /** This action is documented in geodirectory_template_actions.php */ |
| 1678 | - echo apply_filters( 'the_content', stripslashes( $post->post_desc ) ); |
|
| 1678 | + echo apply_filters('the_content', stripslashes($post->post_desc));
|
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | /** |
@@ -1683,7 +1683,7 @@ discard block |
||
| 1683 | 1683 | * |
| 1684 | 1684 | * @since 1.0.0 |
| 1685 | 1685 | */ |
| 1686 | - do_action( 'geodir_after_description_on_listing_detail' ); |
|
| 1686 | + do_action('geodir_after_description_on_listing_detail');
|
|
| 1687 | 1687 | break; |
| 1688 | 1688 | case 'post_info': |
| 1689 | 1689 | echo $geodir_post_detail_fields; |
@@ -1693,32 +1693,32 @@ discard block |
||
| 1693 | 1693 | break; |
| 1694 | 1694 | case 'post_video': |
| 1695 | 1695 | // some browsers hide $_POST data if used for embeds so we repalce with a placeholder |
| 1696 | - if ( $preview ) {
|
|
| 1697 | - if ( $video ) {
|
|
| 1698 | - echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />" . __( 'Video Preview Placeholder', 'geodirectory' ) . "</p></span>"; |
|
| 1696 | + if ($preview) {
|
|
| 1697 | + if ($video) {
|
|
| 1698 | + echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />".__('Video Preview Placeholder', 'geodirectory')."</p></span>";
|
|
| 1699 | 1699 | } |
| 1700 | 1700 | } else {
|
| 1701 | 1701 | |
| 1702 | 1702 | // stop payment manager filtering content length |
| 1703 | - $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); |
|
| 1704 | - if ( false !== $filter_priority ) {
|
|
| 1705 | - remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1703 | + $filter_priority = has_filter('the_content', 'geodir_payments_the_content');
|
|
| 1704 | + if (false !== $filter_priority) {
|
|
| 1705 | + remove_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | /** This action is documented in geodirectory_template_actions.php */ |
| 1709 | - echo apply_filters( 'the_content', stripslashes( $video ) );// we apply the_content filter so oembed works also; |
|
| 1709 | + echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
|
|
| 1710 | 1710 | |
| 1711 | - if ( false !== $filter_priority ) {
|
|
| 1712 | - add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1711 | + if (false !== $filter_priority) {
|
|
| 1712 | + add_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1713 | 1713 | } |
| 1714 | 1714 | } |
| 1715 | 1715 | break; |
| 1716 | 1716 | case 'special_offers': |
| 1717 | - echo apply_filters( 'gd_special_offers_content', wpautop( stripslashes( $special_offers ) ) ); |
|
| 1717 | + echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
|
|
| 1718 | 1718 | |
| 1719 | 1719 | break; |
| 1720 | 1720 | case 'post_map': |
| 1721 | - geodir_draw_map( $map_args ); |
|
| 1721 | + geodir_draw_map($map_args); |
|
| 1722 | 1722 | break; |
| 1723 | 1723 | case 'reviews': |
| 1724 | 1724 | comments_template(); |
@@ -1727,7 +1727,7 @@ discard block |
||
| 1727 | 1727 | echo $related_listing; |
| 1728 | 1728 | break; |
| 1729 | 1729 | default: {
|
| 1730 | - if ( ( isset( $post->{$tab_index} ) || ( ! isset( $post->{$tab_index} ) && ( strpos( $tab_index, 'gd_tab_' ) !== false || $tab_index == 'link_business' ) ) ) && ! empty( $detail_page_tab['tab_content'] ) ) {
|
|
| 1730 | + if ((isset($post->{$tab_index} ) || (!isset($post->{$tab_index} ) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
|
|
| 1731 | 1731 | echo $detail_page_tab['tab_content']; |
| 1732 | 1732 | } |
| 1733 | 1733 | } |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | * |
| 1740 | 1740 | * @since 1.0.0 |
| 1741 | 1741 | */ |
| 1742 | - do_action( 'geodir_after_tab_content', $tab_index ); |
|
| 1742 | + do_action('geodir_after_tab_content', $tab_index);
|
|
| 1743 | 1743 | |
| 1744 | 1744 | /** |
| 1745 | 1745 | * Called after the details tab content is output per tab. |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | * @since 1.0.0 |
| 1750 | 1750 | * @todo do we need this if we have the hook above? 'geodir_after_tab_content' |
| 1751 | 1751 | */ |
| 1752 | - do_action( 'geodir_after_' . $tab_index . '_tab_content' ); |
|
| 1752 | + do_action('geodir_after_'.$tab_index.'_tab_content');
|
|
| 1753 | 1753 | ?> </li> |
| 1754 | 1754 | <?php |
| 1755 | 1755 | /** |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | * |
| 1758 | 1758 | * @since 1.0.0 |
| 1759 | 1759 | */ |
| 1760 | - $arr_detail_page_tabs[ $tab_index ]['tab_content'] = apply_filters( "geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean() ); |
|
| 1760 | + $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
|
|
| 1761 | 1761 | } // end of if for is_display |
| 1762 | 1762 | }// end of foreach |
| 1763 | 1763 | |
@@ -1767,14 +1767,14 @@ discard block |
||
| 1767 | 1767 | * @since 1.0.0 |
| 1768 | 1768 | * @see 'geodir_before_tab_list' |
| 1769 | 1769 | */ |
| 1770 | - do_action( 'geodir_after_tab_list' ); |
|
| 1770 | + do_action('geodir_after_tab_list');
|
|
| 1771 | 1771 | ?> |
| 1772 | - <?php if ( ! $tab_list ){ ?></dl><?php } ?>
|
|
| 1773 | - <ul class="geodir-tabs-content entry-content <?php if ( $tab_list ) { ?>geodir-tabs-list<?php } ?>"
|
|
| 1772 | + <?php if (!$tab_list) { ?></dl><?php } ?>
|
|
| 1773 | + <ul class="geodir-tabs-content entry-content <?php if ($tab_list) { ?>geodir-tabs-list<?php } ?>"
|
|
| 1774 | 1774 | style="position:relative;"> |
| 1775 | 1775 | <?php |
| 1776 | - foreach ( $arr_detail_page_tabs as $detail_page_tab ) {
|
|
| 1777 | - if ( $detail_page_tab['is_display'] && ! empty( $detail_page_tab['tab_content'] ) ) {
|
|
| 1776 | + foreach ($arr_detail_page_tabs as $detail_page_tab) {
|
|
| 1777 | + if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
|
|
| 1778 | 1778 | echo $detail_page_tab['tab_content']; |
| 1779 | 1779 | }// end of if |
| 1780 | 1780 | }// end of foreach |
@@ -1784,11 +1784,11 @@ discard block |
||
| 1784 | 1784 | * |
| 1785 | 1785 | * @since 1.0.0 |
| 1786 | 1786 | */ |
| 1787 | - do_action( 'geodir_add_tab_content' ); ?> |
|
| 1787 | + do_action('geodir_add_tab_content'); ?>
|
|
| 1788 | 1788 | </ul> |
| 1789 | 1789 | <!--gd-tabs-content ul end--> |
| 1790 | 1790 | </div> |
| 1791 | - <?php if ( ! $tab_list ) { ?>
|
|
| 1791 | + <?php if (!$tab_list) { ?>
|
|
| 1792 | 1792 | <script> |
| 1793 | 1793 | if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
|
| 1794 | 1794 | hashVal = window.location.hash; |
@@ -1820,31 +1820,31 @@ discard block |
||
| 1820 | 1820 | * |
| 1821 | 1821 | * @return mixed Image file. |
| 1822 | 1822 | */ |
| 1823 | -function geodir_exif( $file ) {
|
|
| 1824 | - if ( empty( $file ) || ! is_array( $file ) ) {
|
|
| 1823 | +function geodir_exif($file) {
|
|
| 1824 | + if (empty($file) || !is_array($file)) {
|
|
| 1825 | 1825 | return $file; |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - $file_path = ! empty( $file['tmp_name'] ) ? sanitize_text_field( $file['tmp_name'] ) : ''; |
|
| 1829 | - if ( ! ( $file_path && file_exists( $file_path ) ) ) {
|
|
| 1828 | + $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : ''; |
|
| 1829 | + if (!($file_path && file_exists($file_path))) {
|
|
| 1830 | 1830 | return $file; |
| 1831 | 1831 | } |
| 1832 | 1832 | $file['file'] = $file_path; |
| 1833 | 1833 | |
| 1834 | - if ( ! file_is_valid_image( $file_path ) ) {
|
|
| 1834 | + if (!file_is_valid_image($file_path)) {
|
|
| 1835 | 1835 | return $file; // Bail if file is not an image. |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | - if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
|
| 1838 | + if (!function_exists('wp_get_image_editor')) {
|
|
| 1839 | 1839 | return $file; |
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | $mime_type = $file['type']; |
| 1843 | 1843 | $exif = array(); |
| 1844 | - if ( $mime_type == 'image/jpeg' && function_exists( 'exif_read_data' ) ) {
|
|
| 1844 | + if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
|
|
| 1845 | 1845 | try {
|
| 1846 | - $exif = exif_read_data( $file_path ); |
|
| 1847 | - } catch ( Exception $e ) {
|
|
| 1846 | + $exif = exif_read_data($file_path); |
|
| 1847 | + } catch (Exception $e) {
|
|
| 1848 | 1848 | $exif = array(); |
| 1849 | 1849 | } |
| 1850 | 1850 | } |
@@ -1853,13 +1853,13 @@ discard block |
||
| 1853 | 1853 | $flip = false; |
| 1854 | 1854 | $modify = false; |
| 1855 | 1855 | $orientation = 0; |
| 1856 | - if ( ! empty( $exif ) && isset( $exif['Orientation'] ) ) {
|
|
| 1857 | - switch ( (int) $exif['Orientation'] ) {
|
|
| 1856 | + if (!empty($exif) && isset($exif['Orientation'])) {
|
|
| 1857 | + switch ((int) $exif['Orientation']) {
|
|
| 1858 | 1858 | case 1: |
| 1859 | 1859 | // do nothing |
| 1860 | 1860 | break; |
| 1861 | 1861 | case 2: |
| 1862 | - $flip = array( false, true ); |
|
| 1862 | + $flip = array(false, true); |
|
| 1863 | 1863 | $modify = true; |
| 1864 | 1864 | break; |
| 1865 | 1865 | case 3: |
@@ -1868,13 +1868,13 @@ discard block |
||
| 1868 | 1868 | $modify = true; |
| 1869 | 1869 | break; |
| 1870 | 1870 | case 4: |
| 1871 | - $flip = array( true, false ); |
|
| 1871 | + $flip = array(true, false); |
|
| 1872 | 1872 | $modify = true; |
| 1873 | 1873 | break; |
| 1874 | 1874 | case 5: |
| 1875 | 1875 | $orientation = - 90; |
| 1876 | 1876 | $rotate = true; |
| 1877 | - $flip = array( false, true ); |
|
| 1877 | + $flip = array(false, true); |
|
| 1878 | 1878 | $modify = true; |
| 1879 | 1879 | break; |
| 1880 | 1880 | case 6: |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | case 7: |
| 1886 | 1886 | $orientation = - 270; |
| 1887 | 1887 | $rotate = true; |
| 1888 | - $flip = array( false, true ); |
|
| 1888 | + $flip = array(false, true); |
|
| 1889 | 1889 | $modify = true; |
| 1890 | 1890 | break; |
| 1891 | 1891 | case 8: |
@@ -1911,31 +1911,31 @@ discard block |
||
| 1911 | 1911 | * @param int|null $quality Image Compression quality between 1-100% scale. Default null. |
| 1912 | 1912 | * @param string $quality Image mime type. |
| 1913 | 1913 | */ |
| 1914 | - $quality = apply_filters( 'geodir_image_upload_set_quality', $quality, $mime_type ); |
|
| 1915 | - if ( $quality !== null ) {
|
|
| 1914 | + $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
|
|
| 1915 | + if ($quality !== null) {
|
|
| 1916 | 1916 | $modify = true; |
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | - if ( ! $modify ) {
|
|
| 1919 | + if (!$modify) {
|
|
| 1920 | 1920 | return $file; // no change |
| 1921 | 1921 | } |
| 1922 | 1922 | |
| 1923 | - $image = wp_get_image_editor( $file_path ); |
|
| 1924 | - if ( ! is_wp_error( $image ) ) {
|
|
| 1925 | - if ( $rotate ) {
|
|
| 1926 | - $image->rotate( $orientation ); |
|
| 1923 | + $image = wp_get_image_editor($file_path); |
|
| 1924 | + if (!is_wp_error($image)) {
|
|
| 1925 | + if ($rotate) {
|
|
| 1926 | + $image->rotate($orientation); |
|
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | - if ( ! empty( $flip ) ) {
|
|
| 1930 | - $image->flip( $flip[0], $flip[1] ); |
|
| 1929 | + if (!empty($flip)) {
|
|
| 1930 | + $image->flip($flip[0], $flip[1]); |
|
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | - if ( $quality !== null ) {
|
|
| 1934 | - $image->set_quality( (int) $quality ); |
|
| 1933 | + if ($quality !== null) {
|
|
| 1934 | + $image->set_quality((int) $quality); |
|
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | - $result = $image->save( $file_path ); |
|
| 1938 | - if ( ! is_wp_error( $result ) ) {
|
|
| 1937 | + $result = $image->save($file_path); |
|
| 1938 | + if (!is_wp_error($result)) {
|
|
| 1939 | 1939 | $file['file'] = $result['path']; |
| 1940 | 1940 | $file['tmp_name'] = $result['path']; |
| 1941 | 1941 | } |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | * |
| 1963 | 1963 | * @return string Returns the recent reviews html. |
| 1964 | 1964 | */ |
| 1965 | -function geodir_get_recent_reviews( $g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false ) {
|
|
| 1965 | +function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
|
|
| 1966 | 1966 | global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session; |
| 1967 | 1967 | $tablecomments = $wpdb->comments; |
| 1968 | 1968 | $tableposts = $wpdb->posts; |
@@ -1972,28 +1972,28 @@ discard block |
||
| 1972 | 1972 | $region_filter = ''; |
| 1973 | 1973 | $country_filter = ''; |
| 1974 | 1974 | |
| 1975 | - if ( $gd_session->get( 'gd_multi_location' ) ) {
|
|
| 1976 | - if ( $gd_ses_country = $gd_session->get( 'gd_country' ) ) {
|
|
| 1977 | - $country_filter = $wpdb->prepare( " AND r.post_country=%s ", str_replace( "-", " ", $gd_ses_country ) ); |
|
| 1975 | + if ($gd_session->get('gd_multi_location')) {
|
|
| 1976 | + if ($gd_ses_country = $gd_session->get('gd_country')) {
|
|
| 1977 | + $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
|
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | - if ( $gd_ses_region = $gd_session->get( 'gd_region' ) ) {
|
|
| 1981 | - $region_filter = $wpdb->prepare( " AND r.post_region=%s ", str_replace( "-", " ", $gd_ses_region ) ); |
|
| 1980 | + if ($gd_ses_region = $gd_session->get('gd_region')) {
|
|
| 1981 | + $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
|
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - if ( $gd_ses_city = $gd_session->get( 'gd_city' ) ) {
|
|
| 1985 | - $city_filter = $wpdb->prepare( " AND r.post_city=%s ", str_replace( "-", " ", $gd_ses_city ) ); |
|
| 1984 | + if ($gd_ses_city = $gd_session->get('gd_city')) {
|
|
| 1985 | + $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
|
|
| 1986 | 1986 | } |
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | 1989 | $review_table = GEODIR_REVIEW_TABLE; |
| 1990 | 1990 | $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments"; |
| 1991 | 1991 | |
| 1992 | - $comments = $wpdb->get_results( $request ); |
|
| 1992 | + $comments = $wpdb->get_results($request); |
|
| 1993 | 1993 | |
| 1994 | - foreach ( $comments as $comment ) {
|
|
| 1994 | + foreach ($comments as $comment) {
|
|
| 1995 | 1995 | // Set the extra comment info needed. |
| 1996 | - $comment_extra = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID" ); |
|
| 1996 | + $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
|
|
| 1997 | 1997 | //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID"; |
| 1998 | 1998 | $comment->comment_content = $comment_extra->comment_content; |
| 1999 | 1999 | $comment->comment_author = $comment_extra->comment_author; |
@@ -2001,75 +2001,75 @@ discard block |
||
| 2001 | 2001 | |
| 2002 | 2002 | $comment_id = ''; |
| 2003 | 2003 | $comment_id = $comment->comment_ID; |
| 2004 | - $comment_content = strip_tags( $comment->comment_content ); |
|
| 2004 | + $comment_content = strip_tags($comment->comment_content); |
|
| 2005 | 2005 | |
| 2006 | - $comment_content = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content ); |
|
| 2006 | + $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
|
|
| 2007 | 2007 | |
| 2008 | - $permalink = get_permalink( $comment->ID ) . "#comment-" . $comment->comment_ID; |
|
| 2008 | + $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID; |
|
| 2009 | 2009 | $comment_author_email = $comment->comment_author_email; |
| 2010 | 2010 | $comment_post_ID = $comment->post_id; |
| 2011 | 2011 | |
| 2012 | 2012 | $na = true; |
| 2013 | - if ( function_exists( 'icl_object_id' ) && icl_object_id( $comment_post_ID, $comment->post_type, true ) ) {
|
|
| 2014 | - $comment_post_ID2 = icl_object_id( $comment_post_ID, $comment->post_type, false ); |
|
| 2015 | - if ( $comment_post_ID == $comment_post_ID2 ) {
|
|
| 2013 | + if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
|
|
| 2014 | + $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false); |
|
| 2015 | + if ($comment_post_ID == $comment_post_ID2) {
|
|
| 2016 | 2016 | } else {
|
| 2017 | 2017 | $na = false; |
| 2018 | 2018 | } |
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | - $post_title = get_the_title( $comment_post_ID ); |
|
| 2022 | - $permalink = get_permalink( $comment_post_ID ); |
|
| 2023 | - $comment_permalink = $permalink . "#comment-" . $comment->comment_ID; |
|
| 2024 | - $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __( 'Read more', 'geodirectory' ) . '</a>'; |
|
| 2021 | + $post_title = get_the_title($comment_post_ID); |
|
| 2022 | + $permalink = get_permalink($comment_post_ID); |
|
| 2023 | + $comment_permalink = $permalink."#comment-".$comment->comment_ID; |
|
| 2024 | + $read_more = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
|
|
| 2025 | 2025 | |
| 2026 | - $comment_content_length = strlen( $comment_content ); |
|
| 2027 | - if ( $comment_content_length > $comment_lenth ) {
|
|
| 2028 | - $comment_excerpt = geodir_utf8_substr( $comment_content, 0, $comment_lenth ) . '... ' . $read_more; |
|
| 2026 | + $comment_content_length = strlen($comment_content); |
|
| 2027 | + if ($comment_content_length > $comment_lenth) {
|
|
| 2028 | + $comment_excerpt = geodir_utf8_substr($comment_content, 0, $comment_lenth).'... '.$read_more; |
|
| 2029 | 2029 | } else {
|
| 2030 | 2030 | $comment_excerpt = $comment_content; |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | - if ( $comment->user_id ) {
|
|
| 2034 | - $user_profile_url = get_author_posts_url( $comment->user_id ); |
|
| 2033 | + if ($comment->user_id) {
|
|
| 2034 | + $user_profile_url = get_author_posts_url($comment->user_id); |
|
| 2035 | 2035 | } else {
|
| 2036 | 2036 | $user_profile_url = ''; |
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | - if ( $comment_id && $na ) {
|
|
| 2039 | + if ($comment_id && $na) {
|
|
| 2040 | 2040 | $comments_echo .= '<li class="clearfix">'; |
| 2041 | - $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">"; |
|
| 2042 | - if ( function_exists( 'get_avatar' ) ) {
|
|
| 2043 | - if ( ! isset( $comment->comment_type ) ) {
|
|
| 2044 | - if ( $user_profile_url ) {
|
|
| 2045 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2041 | + $comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">"; |
|
| 2042 | + if (function_exists('get_avatar')) {
|
|
| 2043 | + if (!isset($comment->comment_type)) {
|
|
| 2044 | + if ($user_profile_url) {
|
|
| 2045 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2046 | 2046 | } |
| 2047 | - $comments_echo .= get_avatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2048 | - if ( $user_profile_url ) {
|
|
| 2047 | + $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2048 | + if ($user_profile_url) {
|
|
| 2049 | 2049 | $comments_echo .= '</a>'; |
| 2050 | 2050 | } |
| 2051 | - } elseif ( ( isset( $comment->comment_type ) && $comment->comment_type == 'trackback' ) || ( isset( $comment->comment_type ) && $comment->comment_type == 'pingback' ) ) {
|
|
| 2052 | - if ( $user_profile_url ) {
|
|
| 2053 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2051 | + } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
|
|
| 2052 | + if ($user_profile_url) {
|
|
| 2053 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2054 | 2054 | } |
| 2055 | - $comments_echo .= get_avatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2055 | + $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2056 | 2056 | } |
| 2057 | - } elseif ( function_exists( 'gravatar' ) ) {
|
|
| 2058 | - if ( $user_profile_url ) {
|
|
| 2059 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2057 | + } elseif (function_exists('gravatar')) {
|
|
| 2058 | + if ($user_profile_url) {
|
|
| 2059 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2060 | 2060 | } |
| 2061 | 2061 | $comments_echo .= "<img src=\""; |
| 2062 | - if ( '' == $comment->comment_type ) {
|
|
| 2063 | - $comments_echo .= gravatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2064 | - if ( $user_profile_url ) {
|
|
| 2062 | + if ('' == $comment->comment_type) {
|
|
| 2063 | + $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2064 | + if ($user_profile_url) {
|
|
| 2065 | 2065 | $comments_echo .= '</a>'; |
| 2066 | 2066 | } |
| 2067 | - } elseif ( ( 'trackback' == $comment->comment_type ) || ( 'pingback' == $comment->comment_type ) ) {
|
|
| 2068 | - if ( $user_profile_url ) {
|
|
| 2069 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2067 | + } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
|
|
| 2068 | + if ($user_profile_url) {
|
|
| 2069 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2070 | 2070 | } |
| 2071 | - $comments_echo .= gravatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2072 | - if ( $user_profile_url ) {
|
|
| 2071 | + $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2072 | + if ($user_profile_url) {
|
|
| 2073 | 2073 | $comments_echo .= '</a>'; |
| 2074 | 2074 | } |
| 2075 | 2075 | } |
@@ -2079,17 +2079,17 @@ discard block |
||
| 2079 | 2079 | $comments_echo .= "</span>\n"; |
| 2080 | 2080 | |
| 2081 | 2081 | $comments_echo .= '<span class="geodir_reviewer_content">'; |
| 2082 | - if ( $comment->user_id ) {
|
|
| 2083 | - $comments_echo .= '<a href="' . get_author_posts_url( $comment->user_id ) . '">'; |
|
| 2082 | + if ($comment->user_id) {
|
|
| 2083 | + $comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">'; |
|
| 2084 | 2084 | } |
| 2085 | - $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; |
|
| 2086 | - if ( $comment->user_id ) {
|
|
| 2085 | + $comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> '; |
|
| 2086 | + if ($comment->user_id) {
|
|
| 2087 | 2087 | $comments_echo .= '</a>'; |
| 2088 | 2088 | } |
| 2089 | - $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __( 'reviewed', 'geodirectory' ) . '</span> '; |
|
| 2090 | - $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; |
|
| 2091 | - $comments_echo .= geodir_get_rating_stars( $comment->overall_rating, $comment_post_ID ); |
|
| 2092 | - $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . ''; |
|
| 2089 | + $comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
|
|
| 2090 | + $comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>'; |
|
| 2091 | + $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); |
|
| 2092 | + $comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.''; |
|
| 2093 | 2093 | //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
|
| 2094 | 2094 | $comments_echo .= '</p>'; |
| 2095 | 2095 | |
@@ -2109,25 +2109,25 @@ discard block |
||
| 2109 | 2109 | * @return array Returns post categories as an array. |
| 2110 | 2110 | */ |
| 2111 | 2111 | function geodir_home_map_cats_key_value_array() {
|
| 2112 | - $post_types = geodir_get_posttypes( 'object' ); |
|
| 2112 | + $post_types = geodir_get_posttypes('object');
|
|
| 2113 | 2113 | |
| 2114 | 2114 | $return = array(); |
| 2115 | - if ( ! empty( $post_types ) ) {
|
|
| 2116 | - foreach ( $post_types as $key => $post_type ) {
|
|
| 2117 | - $cpt_name = __( $post_type->labels->singular_name, 'geodirectory' ); |
|
| 2118 | - $post_type_name = sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ); |
|
| 2119 | - $taxonomies = geodir_get_taxonomies( $key ); |
|
| 2120 | - $cat_taxonomy = ! empty( $taxonomies[0] ) ? $taxonomies[0] : null; |
|
| 2121 | - $cat_terms = $cat_taxonomy ? get_terms( $cat_taxonomy ) : null; |
|
| 2122 | - |
|
| 2123 | - if ( ! empty( $cat_terms ) ) {
|
|
| 2124 | - $return[ 'optgroup_start-' . $key ] = $post_type_name; |
|
| 2125 | - |
|
| 2126 | - foreach ( $cat_terms as $cat_term ) {
|
|
| 2127 | - $return[ $key . '_' . $cat_term->term_id ] = $cat_term->name; |
|
| 2115 | + if (!empty($post_types)) {
|
|
| 2116 | + foreach ($post_types as $key => $post_type) {
|
|
| 2117 | + $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); |
|
| 2118 | + $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
|
|
| 2119 | + $taxonomies = geodir_get_taxonomies($key); |
|
| 2120 | + $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : null; |
|
| 2121 | + $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : null; |
|
| 2122 | + |
|
| 2123 | + if (!empty($cat_terms)) {
|
|
| 2124 | + $return['optgroup_start-'.$key] = $post_type_name; |
|
| 2125 | + |
|
| 2126 | + foreach ($cat_terms as $cat_term) {
|
|
| 2127 | + $return[$key.'_'.$cat_term->term_id] = $cat_term->name; |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $return[ 'optgroup_end-' . $key ] = $post_type_name; |
|
| 2130 | + $return['optgroup_end-'.$key] = $post_type_name; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | } |
@@ -2143,14 +2143,14 @@ discard block |
||
| 2143 | 2143 | * @package GeoDirectory |
| 2144 | 2144 | */ |
| 2145 | 2145 | function geodir_twitter_tweet_button() {
|
| 2146 | - if ( isset( $_GET['gde'] ) ) {
|
|
| 2147 | - $link = '?url=' . urlencode( geodir_curPageURL() ); |
|
| 2146 | + if (isset($_GET['gde'])) {
|
|
| 2147 | + $link = '?url='.urlencode(geodir_curPageURL()); |
|
| 2148 | 2148 | } else {
|
| 2149 | 2149 | $link = ''; |
| 2150 | 2150 | } |
| 2151 | 2151 | ?> |
| 2152 | 2152 | <a href="http://twitter.com/share<?php echo $link; ?>" |
| 2153 | - class="twitter-share-button"><?php _e( 'Tweet', 'geodirectory' ); ?></a> |
|
| 2153 | + class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
|
|
| 2154 | 2154 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
| 2155 | 2155 | <?php |
| 2156 | 2156 | } |
@@ -2167,10 +2167,10 @@ discard block |
||
| 2167 | 2167 | function geodir_fb_like_button() {
|
| 2168 | 2168 | global $post; |
| 2169 | 2169 | ?> |
| 2170 | - <iframe <?php if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
|
|
| 2170 | + <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
|
|
| 2171 | 2171 | echo 'allowtransparency="true"'; |
| 2172 | 2172 | } ?> class="facebook" |
| 2173 | - src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode( get_permalink( $post->ID ) ); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
|
| 2173 | + src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
|
| 2174 | 2174 | style="border:none; overflow:hidden; width:100px; height:20px"></iframe> |
| 2175 | 2175 | <?php |
| 2176 | 2176 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
| 2201 | 2201 | |
| 2202 | 2202 | |
| 2203 | 2203 | function geodir_listing_bounce_map_pin_on_hover() {
|
| 2204 | - if ( get_option( 'geodir_listing_hover_bounce_map_pin', true ) ) {
|
|
| 2204 | + if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
|
|
| 2205 | 2205 | ?> |
| 2206 | 2206 | <script> |
| 2207 | 2207 | jQuery(function ($) {
|
@@ -2224,44 +2224,44 @@ discard block |
||
| 2224 | 2224 | } |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | -add_action( 'geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10 ); |
|
| 2227 | +add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
|
|
| 2228 | 2228 | |
| 2229 | -add_action( 'geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1 ); |
|
| 2230 | -function geodir_output_favourite_html_listings( $post_id ) {
|
|
| 2231 | - geodir_favourite_html( '', $post_id ); |
|
| 2229 | +add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
|
|
| 2230 | +function geodir_output_favourite_html_listings($post_id) {
|
|
| 2231 | + geodir_favourite_html('', $post_id);
|
|
| 2232 | 2232 | } |
| 2233 | 2233 | |
| 2234 | -add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2 ); |
|
| 2235 | -function geodir_output_pinpoint_html_listings( $post_id, $post ) {
|
|
| 2234 | +add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
|
|
| 2235 | +function geodir_output_pinpoint_html_listings($post_id, $post) {
|
|
| 2236 | 2236 | global $wp_query; |
| 2237 | 2237 | |
| 2238 | 2238 | $show_pin_point = $wp_query->is_main_query(); |
| 2239 | 2239 | |
| 2240 | - if ( ! empty( $show_pin_point ) && is_active_widget( false, "", "geodir_map_v3_listing_map" ) ) {
|
|
| 2241 | - $term_icon_url = get_tax_meta( $post->default_category, 'ct_cat_icon', false, $post->post_type ); |
|
| 2242 | - $marker_icon = isset( $term_icon_url['src'] ) ? $term_icon_url['src'] : get_option( 'geodir_default_marker_icon' ); |
|
| 2240 | + if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2241 | + $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type); |
|
| 2242 | + $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
|
|
| 2243 | 2243 | ?> |
| 2244 | 2244 | <span class="geodir-pinpoint" |
| 2245 | - style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters( 'geodir_listing_listview_pinpoint_inner_content', '', 'listing' ); ?></span>
|
|
| 2245 | + style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
|
|
| 2246 | 2246 | <a class="geodir-pinpoint-link" href="javascript:void(0)" |
| 2247 | 2247 | onclick="if(typeof openMarker=='function'){openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
|
| 2248 | 2248 | onmouseover="if(typeof animate_marker=='function'){animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
|
| 2249 | - onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e( 'Pinpoint', 'geodirectory' ); ?></a>
|
|
| 2249 | + onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e('Pinpoint', 'geodirectory'); ?></a>
|
|
| 2250 | 2250 | <?php |
| 2251 | 2251 | } |
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | function geodir_search_form_submit_button() {
|
| 2255 | 2255 | |
| 2256 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; |
|
| 2256 | + $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
|
| 2257 | 2257 | |
| 2258 | - if ( $new_style ) {
|
|
| 2258 | + if ($new_style) {
|
|
| 2259 | 2259 | $default_search_button_label = '<i class="fa fa-search" aria-hidden="true"></i>'; |
| 2260 | - }else{
|
|
| 2260 | + } else {
|
|
| 2261 | 2261 | $default_search_button_label = 'Search'; |
| 2262 | 2262 | } |
| 2263 | - if ( get_option( 'geodir_search_button_label' ) && get_option( 'geodir_search_button_label' ) != 'Search' ) {
|
|
| 2264 | - $default_search_button_label = __( get_option( 'geodir_search_button_label' ), 'geodirectory' ); |
|
| 2263 | + if (get_option('geodir_search_button_label') && get_option('geodir_search_button_label') != 'Search') {
|
|
| 2264 | + $default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
|
|
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | /** |
@@ -2273,78 +2273,78 @@ discard block |
||
| 2273 | 2273 | * |
| 2274 | 2274 | * @param string $default_search_button_label The current search button text. |
| 2275 | 2275 | */ |
| 2276 | - $default_search_button_label = apply_filters( 'geodir_search_default_search_button_text', $default_search_button_label ); |
|
| 2276 | + $default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);
|
|
| 2277 | 2277 | |
| 2278 | 2278 | $fa_class = ''; |
| 2279 | - if ( strpos( $default_search_button_label, '&#' ) !== false ) {
|
|
| 2279 | + if (strpos($default_search_button_label, '&#') !== false) {
|
|
| 2280 | 2280 | $fa_class = 'fa'; |
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | |
| 2284 | - if ( $new_style ) {
|
|
| 2284 | + if ($new_style) {
|
|
| 2285 | 2285 | ?> |
| 2286 | - <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e( $default_search_button_label ,'geodirectory'); ?></button> |
|
| 2287 | -<?php }else{?>
|
|
| 2288 | - <input type="button" value="<?php esc_attr_e( $default_search_button_label ); ?>" |
|
| 2286 | + <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e($default_search_button_label, 'geodirectory'); ?></button> |
|
| 2287 | +<?php } else {?>
|
|
| 2288 | + <input type="button" value="<?php esc_attr_e($default_search_button_label); ?>" |
|
| 2289 | 2289 | class="geodir_submit_search <?php echo $fa_class; ?>"/> |
| 2290 | 2290 | <?php } |
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | -add_action( 'geodir_before_search_button', 'geodir_search_form_submit_button', 5000 ); |
|
| 2293 | +add_action('geodir_before_search_button', 'geodir_search_form_submit_button', 5000);
|
|
| 2294 | 2294 | |
| 2295 | 2295 | function geodir_search_form_post_type_input() {
|
| 2296 | 2296 | global $geodir_search_post_type; |
| 2297 | - $post_types = apply_filters( 'geodir_search_form_post_types', geodir_get_posttypes( 'object' ) ); |
|
| 2297 | + $post_types = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
|
|
| 2298 | 2298 | $curr_post_type = $geodir_search_post_type; |
| 2299 | 2299 | |
| 2300 | - if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
|
| 2300 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 2301 | 2301 | |
| 2302 | - foreach ( $post_types as $post_type => $info ){
|
|
| 2302 | + foreach ($post_types as $post_type => $info) {
|
|
| 2303 | 2303 | global $wpdb; |
| 2304 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 2305 | - if ( ! $has_posts ) {
|
|
| 2304 | + $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
|
|
| 2305 | + if (!$has_posts) {
|
|
| 2306 | 2306 | unset($post_types->{$post_type});
|
| 2307 | 2307 | } |
| 2308 | 2308 | } |
| 2309 | 2309 | |
| 2310 | - if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
|
| 2310 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 2311 | 2311 | |
| 2312 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; |
|
| 2313 | - if ( $new_style ) {
|
|
| 2312 | + $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
|
| 2313 | + if ($new_style) {
|
|
| 2314 | 2314 | echo "<div class='gd-search-input-wrapper gd-search-field-cpt'>"; |
| 2315 | 2315 | } |
| 2316 | 2316 | ?> |
| 2317 | 2317 | <select name="stype" class="search_by_post"> |
| 2318 | - <?php foreach ( $post_types as $post_type => $info ): |
|
| 2318 | + <?php foreach ($post_types as $post_type => $info): |
|
| 2319 | 2319 | global $wpdb; |
| 2320 | 2320 | ?> |
| 2321 | 2321 | |
| 2322 | - <option data-label="<?php echo get_post_type_archive_link( $post_type ); ?>" |
|
| 2323 | - value="<?php echo $post_type; ?>" <?php if ( isset( $_REQUEST['stype'] ) ) {
|
|
| 2324 | - if ( $post_type == $_REQUEST['stype'] ) {
|
|
| 2322 | + <option data-label="<?php echo get_post_type_archive_link($post_type); ?>" |
|
| 2323 | + value="<?php echo $post_type; ?>" <?php if (isset($_REQUEST['stype'])) {
|
|
| 2324 | + if ($post_type == $_REQUEST['stype']) {
|
|
| 2325 | 2325 | echo 'selected="selected"'; |
| 2326 | 2326 | } |
| 2327 | - } elseif ( $curr_post_type == $post_type ) {
|
|
| 2327 | + } elseif ($curr_post_type == $post_type) {
|
|
| 2328 | 2328 | echo 'selected="selected"'; |
| 2329 | - } ?>><?php _e( geodir_utf8_ucfirst( $info->labels->name ), 'geodirectory' ); ?></option> |
|
| 2329 | + } ?>><?php _e(geodir_utf8_ucfirst($info->labels->name), 'geodirectory'); ?></option> |
|
| 2330 | 2330 | |
| 2331 | 2331 | <?php endforeach; ?> |
| 2332 | 2332 | </select> |
| 2333 | 2333 | <?php |
| 2334 | - if ( $new_style ) {
|
|
| 2334 | + if ($new_style) {
|
|
| 2335 | 2335 | echo "</div>"; |
| 2336 | 2336 | } |
| 2337 | - }else{
|
|
| 2338 | - if(! empty( $post_types )){
|
|
| 2339 | - $pt_arr = (array)$post_types; |
|
| 2340 | - echo '<input type="hidden" name="stype" value="' . key( $pt_arr ) . '" />'; |
|
| 2341 | - }else{
|
|
| 2337 | + } else {
|
|
| 2338 | + if (!empty($post_types)) {
|
|
| 2339 | + $pt_arr = (array) $post_types; |
|
| 2340 | + echo '<input type="hidden" name="stype" value="'.key($pt_arr).'" />'; |
|
| 2341 | + } else {
|
|
| 2342 | 2342 | echo '<input type="hidden" name="stype" value="gd_place" />'; |
| 2343 | 2343 | } |
| 2344 | 2344 | |
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | - }elseif ( ! empty( $post_types ) ) {
|
|
| 2347 | + }elseif (!empty($post_types)) {
|
|
| 2348 | 2348 | echo '<input type="hidden" name="stype" value="gd_place" />'; |
| 2349 | 2349 | } |
| 2350 | 2350 | } |
@@ -2352,26 +2352,26 @@ discard block |
||
| 2352 | 2352 | function geodir_search_form_search_input() {
|
| 2353 | 2353 | |
| 2354 | 2354 | $default_search_for_text = SEARCH_FOR_TEXT; |
| 2355 | - if ( get_option( 'geodir_search_field_default_text' ) ) {
|
|
| 2356 | - $default_search_for_text = __( get_option( 'geodir_search_field_default_text' ), 'geodirectory' ); |
|
| 2355 | + if (get_option('geodir_search_field_default_text')) {
|
|
| 2356 | + $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
|
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
| 2360 | - if($new_style){
|
|
| 2360 | + if ($new_style) {
|
|
| 2361 | 2361 | echo "<div class='gd-search-input-wrapper gd-search-field-search'>"; |
| 2362 | 2362 | } |
| 2363 | 2363 | ?> |
| 2364 | 2364 | <input class="search_text" name="s" |
| 2365 | - value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
|
|
| 2366 | - echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) ); |
|
| 2365 | + value="<?php if (isset($_REQUEST['s']) && trim($_REQUEST['s']) != '') {
|
|
| 2366 | + echo esc_attr(stripslashes_deep($_REQUEST['s'])); |
|
| 2367 | 2367 | } else {
|
| 2368 | 2368 | echo $default_search_for_text; |
| 2369 | 2369 | } ?>" type="text" |
| 2370 | - onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
|
|
| 2371 | - onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
|
|
| 2370 | + onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql($default_search_for_text); ?>';}"
|
|
| 2371 | + onfocus="if (this.value == '<?php echo esc_sql($default_search_for_text); ?>') {this.value = '';}"
|
|
| 2372 | 2372 | onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"> |
| 2373 | 2373 | <?php |
| 2374 | - if($new_style){
|
|
| 2374 | + if ($new_style) {
|
|
| 2375 | 2375 | echo "</div>"; |
| 2376 | 2376 | } |
| 2377 | 2377 | } |
@@ -2379,12 +2379,12 @@ discard block |
||
| 2379 | 2379 | function geodir_search_form_near_input() {
|
| 2380 | 2380 | |
| 2381 | 2381 | $default_near_text = NEAR_TEXT; |
| 2382 | - if ( get_option( 'geodir_near_field_default_text' ) ) {
|
|
| 2383 | - $default_near_text = __( get_option( 'geodir_near_field_default_text' ), 'geodirectory' ); |
|
| 2382 | + if (get_option('geodir_near_field_default_text')) {
|
|
| 2383 | + $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
|
|
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | - if ( isset( $_REQUEST['snear'] ) && $_REQUEST['snear'] != '' ) {
|
|
| 2387 | - $near = esc_attr( stripslashes_deep( $_REQUEST['snear'] ) ); |
|
| 2386 | + if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
|
|
| 2387 | + $near = esc_attr(stripslashes_deep($_REQUEST['snear'])); |
|
| 2388 | 2388 | } else {
|
| 2389 | 2389 | $near = $default_near_text; |
| 2390 | 2390 | } |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | * @since 1.6.9 |
| 2399 | 2399 | * @param string $curr_post_type The current post type. |
| 2400 | 2400 | */ |
| 2401 | - $near_input_extra = apply_filters('geodir_near_input_extra','',$curr_post_type);
|
|
| 2401 | + $near_input_extra = apply_filters('geodir_near_input_extra', '', $curr_post_type);
|
|
| 2402 | 2402 | |
| 2403 | 2403 | |
| 2404 | 2404 | /** |
@@ -2411,7 +2411,7 @@ discard block |
||
| 2411 | 2411 | * @param string $near The current near value. |
| 2412 | 2412 | * @param string $default_near_text The default near value. |
| 2413 | 2413 | */ |
| 2414 | - $near = apply_filters( 'geodir_search_near_text', $near, $default_near_text ); |
|
| 2414 | + $near = apply_filters('geodir_search_near_text', $near, $default_near_text);
|
|
| 2415 | 2415 | /** |
| 2416 | 2416 | * Filter the default "Near" text value for the search form. |
| 2417 | 2417 | * |
@@ -2422,7 +2422,7 @@ discard block |
||
| 2422 | 2422 | * @param string $near The current near value. |
| 2423 | 2423 | * @param string $default_near_text The default near value. |
| 2424 | 2424 | */ |
| 2425 | - $default_near_text = apply_filters( 'geodir_search_default_near_text', $default_near_text, $near ); |
|
| 2425 | + $default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
|
|
| 2426 | 2426 | /** |
| 2427 | 2427 | * Filter the class for the near search input. |
| 2428 | 2428 | * |
@@ -2430,10 +2430,10 @@ discard block |
||
| 2430 | 2430 | * |
| 2431 | 2431 | * @param string $class The class for the HTML near input, default is blank. |
| 2432 | 2432 | */ |
| 2433 | - $near_class = apply_filters( 'geodir_search_near_class', '' ); |
|
| 2433 | + $near_class = apply_filters('geodir_search_near_class', '');
|
|
| 2434 | 2434 | |
| 2435 | 2435 | $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
| 2436 | - if($new_style){
|
|
| 2436 | + if ($new_style) {
|
|
| 2437 | 2437 | echo "<div class='gd-search-input-wrapper gd-search-field-near' $near_input_extra>"; |
| 2438 | 2438 | |
| 2439 | 2439 | do_action('geodir_before_near_input');
|
@@ -2441,30 +2441,30 @@ discard block |
||
| 2441 | 2441 | |
| 2442 | 2442 | ?> |
| 2443 | 2443 | <input name="snear" class="snear <?php echo $near_class; ?>" type="text" value="<?php echo $near; ?>" |
| 2444 | - onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql( $near ); ?>' != '' ? '<?php echo esc_sql( $near ); ?>' : '<?php echo $default_near_text; ?>');}"
|
|
| 2445 | - onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql( $near ); ?>') {this.value = '';}"
|
|
| 2446 | - onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra;?>/> |
|
| 2444 | + onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql($near); ?>' != '' ? '<?php echo esc_sql($near); ?>' : '<?php echo $default_near_text; ?>');}"
|
|
| 2445 | + onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql($near); ?>') {this.value = '';}"
|
|
| 2446 | + onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra; ?>/> |
|
| 2447 | 2447 | <?php |
| 2448 | - if($new_style){
|
|
| 2448 | + if ($new_style) {
|
|
| 2449 | 2449 | do_action('geodir_after_near_input');
|
| 2450 | 2450 | |
| 2451 | 2451 | echo "</div>"; |
| 2452 | 2452 | } |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10 ); |
|
| 2456 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_search_input', 20 ); |
|
| 2457 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_near_input', 30 ); |
|
| 2455 | +add_action('geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10);
|
|
| 2456 | +add_action('geodir_search_form_inputs', 'geodir_search_form_search_input', 20);
|
|
| 2457 | +add_action('geodir_search_form_inputs', 'geodir_search_form_near_input', 30);
|
|
| 2458 | 2458 | |
| 2459 | -function geodir_get_search_post_type($pt=''){
|
|
| 2459 | +function geodir_get_search_post_type($pt = '') {
|
|
| 2460 | 2460 | global $geodir_search_post_type; |
| 2461 | 2461 | |
| 2462 | - if($pt!=''){return $geodir_search_post_type = $pt;}
|
|
| 2463 | - if(!empty($geodir_search_post_type)){ return $geodir_search_post_type;}
|
|
| 2462 | + if ($pt != '') {return $geodir_search_post_type = $pt; }
|
|
| 2463 | + if (!empty($geodir_search_post_type)) { return $geodir_search_post_type; }
|
|
| 2464 | 2464 | |
| 2465 | 2465 | $geodir_search_post_type = geodir_get_current_posttype(); |
| 2466 | 2466 | |
| 2467 | - if(!$geodir_search_post_type) {
|
|
| 2467 | + if (!$geodir_search_post_type) {
|
|
| 2468 | 2468 | $geodir_search_post_type = geodir_get_default_posttype(); |
| 2469 | 2469 | } |
| 2470 | 2470 | |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | return $geodir_search_post_type; |
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | -function geodir_search_form(){
|
|
| 2475 | +function geodir_search_form() {
|
|
| 2476 | 2476 | |
| 2477 | 2477 | geodir_get_search_post_type(); |
| 2478 | 2478 | |
@@ -2482,8 +2482,8 @@ discard block |
||
| 2482 | 2482 | die(); |
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | -add_action( 'wp_ajax_geodir_search_form', 'geodir_search_form' ); |
|
| 2486 | -add_action( 'wp_ajax_nopriv_geodir_search_form', 'geodir_search_form' ); |
|
| 2485 | +add_action('wp_ajax_geodir_search_form', 'geodir_search_form');
|
|
| 2486 | +add_action('wp_ajax_nopriv_geodir_search_form', 'geodir_search_form');
|
|
| 2487 | 2487 | |
| 2488 | 2488 | /** |
| 2489 | 2489 | * Check wpml active or not. |
@@ -2557,7 +2557,7 @@ discard block |
||
| 2557 | 2557 | } |
| 2558 | 2558 | } |
| 2559 | 2559 | } |
| 2560 | -add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |
|
| 2560 | +add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
|
|
| 2561 | 2561 | |
| 2562 | 2562 | /** |
| 2563 | 2563 | * Duplicate post listing manually after listing saved. |
@@ -2598,7 +2598,7 @@ discard block |
||
| 2598 | 2598 | function geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang) {
|
| 2599 | 2599 | global $wpdb; |
| 2600 | 2600 | |
| 2601 | - $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
|
|
| 2601 | + $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM ".GEODIR_REVIEW_TABLE." WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
|
|
| 2602 | 2602 | |
| 2603 | 2603 | if (!empty($reviews)) {
|
| 2604 | 2604 | foreach ($reviews as $review) {
|
@@ -2626,14 +2626,14 @@ discard block |
||
| 2626 | 2626 | global $wpdb, $plugin_prefix; |
| 2627 | 2627 | |
| 2628 | 2628 | $post_type = get_post_type($master_post_id); |
| 2629 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 2629 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 2630 | 2630 | |
| 2631 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 2632 | - $data = (array)$wpdb->get_row($query); |
|
| 2631 | + $query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
|
|
| 2632 | + $data = (array) $wpdb->get_row($query); |
|
| 2633 | 2633 | |
| 2634 | - if ( !empty( $data ) ) {
|
|
| 2634 | + if (!empty($data)) {
|
|
| 2635 | 2635 | $data['post_id'] = $tr_post_id; |
| 2636 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']); |
|
| 2636 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category']); |
|
| 2637 | 2637 | $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
| 2638 | 2638 | return true; |
| 2639 | 2639 | } |
@@ -2658,7 +2658,7 @@ discard block |
||
| 2658 | 2658 | global $sitepress, $wpdb; |
| 2659 | 2659 | $post_type = get_post_type($master_post_id); |
| 2660 | 2660 | |
| 2661 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 2661 | + remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 2662 | 2662 | |
| 2663 | 2663 | $taxonomies = get_object_taxonomies($post_type); |
| 2664 | 2664 | foreach ($taxonomies as $taxonomy) {
|
@@ -2667,9 +2667,9 @@ discard block |
||
| 2667 | 2667 | |
| 2668 | 2668 | if ($terms) {
|
| 2669 | 2669 | foreach ($terms as $term) {
|
| 2670 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 2670 | + $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
|
|
| 2671 | 2671 | |
| 2672 | - if (!is_null($tr_id)){
|
|
| 2672 | + if (!is_null($tr_id)) {
|
|
| 2673 | 2673 | // not using get_term - unfiltered get_term |
| 2674 | 2674 | $translated_term = $wpdb->get_row($wpdb->prepare("
|
| 2675 | 2675 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
@@ -2678,14 +2678,14 @@ discard block |
||
| 2678 | 2678 | } |
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 2682 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 2681 | + if (!is_taxonomy_hierarchical($taxonomy)) {
|
|
| 2682 | + $terms_array = array_unique(array_map('intval', $terms_array));
|
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
| 2686 | 2686 | |
| 2687 | - if ($taxonomy == $post_type . 'category') {
|
|
| 2688 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 2687 | + if ($taxonomy == $post_type.'category') {
|
|
| 2688 | + geodir_set_postcat_structure($tr_post_id, $post_type.'category'); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | } |
| 2691 | 2691 | } |
@@ -2706,15 +2706,15 @@ discard block |
||
| 2706 | 2706 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 2707 | 2707 | global $wpdb; |
| 2708 | 2708 | |
| 2709 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 2709 | + $query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 2710 | 2710 | $wpdb->query($query); |
| 2711 | 2711 | |
| 2712 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 2712 | + $query = $wpdb->prepare("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 2713 | 2713 | $post_images = $wpdb->get_results($query); |
| 2714 | 2714 | |
| 2715 | - if ( !empty( $post_images ) ) {
|
|
| 2716 | - foreach ( $post_images as $post_image) {
|
|
| 2717 | - $image_data = (array)$post_image; |
|
| 2715 | + if (!empty($post_images)) {
|
|
| 2716 | + foreach ($post_images as $post_image) {
|
|
| 2717 | + $image_data = (array) $post_image; |
|
| 2718 | 2718 | unset($image_data['ID']); |
| 2719 | 2719 | $image_data['post_id'] = $tr_post_id; |
| 2720 | 2720 | |
@@ -2747,13 +2747,13 @@ discard block |
||
| 2747 | 2747 | function geodir_wpml_duplicate_post_review($master_comment_id, $master_post_id, $tr_post_id, $lang) {
|
| 2748 | 2748 | global $wpdb, $plugin_prefix, $sitepress; |
| 2749 | 2749 | |
| 2750 | - $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
|
|
| 2750 | + $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
|
|
| 2751 | 2751 | |
| 2752 | 2752 | if (empty($review)) {
|
| 2753 | 2753 | return false; |
| 2754 | 2754 | } |
| 2755 | 2755 | if ($review['post_id'] != $master_post_id) {
|
| 2756 | - $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
|
|
| 2756 | + $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
|
|
| 2757 | 2757 | geodir_update_postrating($master_post_id, $post_type); |
| 2758 | 2758 | } |
| 2759 | 2759 | |
@@ -2764,9 +2764,9 @@ discard block |
||
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | 2766 | $post_type = get_post_type($master_post_id); |
| 2767 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 2767 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 2768 | 2768 | |
| 2769 | - $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A);
|
|
| 2769 | + $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM ".$post_table." WHERE post_id = %d", $tr_post_id), ARRAY_A);
|
|
| 2770 | 2770 | if (empty($translated_post)) {
|
| 2771 | 2771 | return false; |
| 2772 | 2772 | } |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | unset($review['id']); |
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | - $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
|
|
| 2787 | + $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
|
|
| 2788 | 2788 | |
| 2789 | 2789 | if ($tr_review_id) { // update review
|
| 2790 | 2790 | $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id));
|
@@ -2797,8 +2797,8 @@ discard block |
||
| 2797 | 2797 | geodir_update_postrating($tr_post_id, $post_type); |
| 2798 | 2798 | |
| 2799 | 2799 | if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) {
|
| 2800 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id)));
|
|
| 2801 | - $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
|
|
| 2800 | + $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id = %d", array($tr_comment_id)));
|
|
| 2801 | + $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
|
|
| 2802 | 2802 | |
| 2803 | 2803 | if (!empty($likes)) {
|
| 2804 | 2804 | foreach ($likes as $like) {
|
@@ -2900,7 +2900,7 @@ discard block |
||
| 2900 | 2900 | * @return bool True if review star disabled, otherwise false. |
| 2901 | 2901 | */ |
| 2902 | 2902 | function geodir_rating_disabled_post_types() {
|
| 2903 | - $post_types = get_option( 'geodir_disable_rating_cpt' ); |
|
| 2903 | + $post_types = get_option('geodir_disable_rating_cpt');
|
|
| 2904 | 2904 | |
| 2905 | 2905 | /** |
| 2906 | 2906 | * Filter the post types array which have rating disabled. |
@@ -2909,7 +2909,7 @@ discard block |
||
| 2909 | 2909 | * |
| 2910 | 2910 | * @param array $post_types Array of post types which have rating starts disabled. |
| 2911 | 2911 | */ |
| 2912 | - return apply_filters( 'geodir_rating_disabled_post_types', $post_types ); |
|
| 2912 | + return apply_filters('geodir_rating_disabled_post_types', $post_types);
|
|
| 2913 | 2913 | } |
| 2914 | 2914 | |
| 2915 | 2915 | /** |
@@ -2921,30 +2921,30 @@ discard block |
||
| 2921 | 2921 | * @param bool $taxonomy Whether $post_type is taxonomy or not. |
| 2922 | 2922 | * @return bool True if review star disabled, otherwise false. |
| 2923 | 2923 | */ |
| 2924 | -function geodir_cpt_has_rating_disabled( $post_type = '', $taxonomy = false ) {
|
|
| 2924 | +function geodir_cpt_has_rating_disabled($post_type = '', $taxonomy = false) {
|
|
| 2925 | 2925 | $post_types = geodir_rating_disabled_post_types(); |
| 2926 | 2926 | |
| 2927 | - if ( empty( $post_types ) ) {
|
|
| 2927 | + if (empty($post_types)) {
|
|
| 2928 | 2928 | return false; |
| 2929 | 2929 | } |
| 2930 | 2930 | |
| 2931 | - if ( is_int( $post_type ) ) {
|
|
| 2932 | - $post_type = get_post_type( $post_type ); |
|
| 2931 | + if (is_int($post_type)) {
|
|
| 2932 | + $post_type = get_post_type($post_type); |
|
| 2933 | 2933 | } |
| 2934 | 2934 | |
| 2935 | - if ( $taxonomy && !empty( $post_types ) ) {
|
|
| 2935 | + if ($taxonomy && !empty($post_types)) {
|
|
| 2936 | 2936 | $posttypes = array(); |
| 2937 | 2937 | |
| 2938 | - foreach ( $post_types as $posttype ) {
|
|
| 2939 | - $posttypes[] = $posttype . 'category'; |
|
| 2940 | - $posttypes[] = $posttype . '_tags'; |
|
| 2938 | + foreach ($post_types as $posttype) {
|
|
| 2939 | + $posttypes[] = $posttype.'category'; |
|
| 2940 | + $posttypes[] = $posttype.'_tags'; |
|
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | 2943 | $post_types = $posttypes; |
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | $return = false; |
| 2947 | - if ( $post_type != '' && !empty( $post_types ) && in_array( $post_type, $post_types ) ) {
|
|
| 2947 | + if ($post_type != '' && !empty($post_types) && in_array($post_type, $post_types)) {
|
|
| 2948 | 2948 | $return = true; |
| 2949 | 2949 | } |
| 2950 | 2950 | |
@@ -2959,5 +2959,5 @@ discard block |
||
| 2959 | 2959 | * @return bool True if Yoast SEO disabled on GD pages. |
| 2960 | 2960 | */ |
| 2961 | 2961 | function geodir_disable_yoast_seo_metas() {
|
| 2962 | - return (bool)get_option( 'geodir_disable_yoast_meta' ); |
|
| 2962 | + return (bool) get_option('geodir_disable_yoast_meta');
|
|
| 2963 | 2963 | } |
| 2964 | 2964 | \ No newline at end of file |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | 16 | function geodir_add_listing_page_id(){ |
| 17 | - $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 17 | + $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 18 | 18 | |
| 19 | - if (function_exists('icl_object_id')) { |
|
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | - } |
|
| 19 | + if (function_exists('icl_object_id')) { |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return $gd_page_id; |
|
| 23 | + return $gd_page_id; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | 33 | function geodir_preview_page_id(){ |
| 34 | - $gd_page_id = get_option('geodir_preview_page'); |
|
| 34 | + $gd_page_id = get_option('geodir_preview_page'); |
|
| 35 | 35 | |
| 36 | - if (function_exists('icl_object_id')) { |
|
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | - } |
|
| 36 | + if (function_exists('icl_object_id')) { |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $gd_page_id; |
|
| 40 | + return $gd_page_id; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | 50 | function geodir_success_page_id(){ |
| 51 | - $gd_page_id = get_option('geodir_success_page'); |
|
| 51 | + $gd_page_id = get_option('geodir_success_page'); |
|
| 52 | 52 | |
| 53 | - if (function_exists('icl_object_id')) { |
|
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | - } |
|
| 53 | + if (function_exists('icl_object_id')) { |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - return $gd_page_id; |
|
| 57 | + return $gd_page_id; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | 67 | function geodir_location_page_id(){ |
| 68 | - $gd_page_id = get_option('geodir_location_page'); |
|
| 68 | + $gd_page_id = get_option('geodir_location_page'); |
|
| 69 | 69 | |
| 70 | - if (function_exists('icl_object_id')) { |
|
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | - } |
|
| 70 | + if (function_exists('icl_object_id')) { |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $gd_page_id; |
|
| 74 | + return $gd_page_id; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | 84 | function geodir_home_page_id(){ |
| 85 | - $gd_page_id = get_option('geodir_home_page'); |
|
| 85 | + $gd_page_id = get_option('geodir_home_page'); |
|
| 86 | 86 | |
| 87 | - if (function_exists('icl_object_id')) { |
|
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | - } |
|
| 87 | + if (function_exists('icl_object_id')) { |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return $gd_page_id; |
|
| 91 | + return $gd_page_id; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | 101 | function geodir_info_page_id(){ |
| 102 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 102 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 103 | 103 | |
| 104 | - if (function_exists('icl_object_id')) { |
|
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | - } |
|
| 104 | + if (function_exists('icl_object_id')) { |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return $gd_page_id; |
|
| 108 | + return $gd_page_id; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | 118 | function geodir_login_page_id(){ |
| 119 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 119 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 120 | 120 | |
| 121 | - if (function_exists('icl_object_id')) { |
|
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | - } |
|
| 121 | + if (function_exists('icl_object_id')) { |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $gd_page_id; |
|
| 125 | + return $gd_page_id; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -134,51 +134,51 @@ discard block |
||
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | 136 | function geodir_login_url($args=array()){ |
| 137 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 138 | - |
|
| 139 | - if (function_exists('icl_object_id')) { |
|
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - if (geodir_is_wpml()){ |
|
| 148 | - $home_url = icl_get_home_url(); |
|
| 149 | - }else{ |
|
| 150 | - $home_url = home_url(); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 154 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if($gd_page_id){ |
|
| 158 | - $post = get_post($gd_page_id); |
|
| 159 | - $slug = $post->post_name; |
|
| 160 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 161 | - $login_url = trailingslashit($home_url)."$slug/"; |
|
| 162 | - }else{ |
|
| 163 | - $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if($args){ |
|
| 167 | - $login_url = add_query_arg($args,$login_url ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Filter the GeoDirectory login page url. |
|
| 172 | - * |
|
| 173 | - * This filter can be used to change the GeoDirectory page url. |
|
| 174 | - * |
|
| 175 | - * @since 1.5.3 |
|
| 176 | - * @package GeoDirectory |
|
| 177 | - * @param string $login_url The url of the login page. |
|
| 178 | - * @param array $args The array of query args used. |
|
| 179 | - * @param int $gd_page_id The page id of the GD login page. |
|
| 180 | - */ |
|
| 181 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 137 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 138 | + |
|
| 139 | + if (function_exists('icl_object_id')) { |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + if (geodir_is_wpml()){ |
|
| 148 | + $home_url = icl_get_home_url(); |
|
| 149 | + }else{ |
|
| 150 | + $home_url = home_url(); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 154 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if($gd_page_id){ |
|
| 158 | + $post = get_post($gd_page_id); |
|
| 159 | + $slug = $post->post_name; |
|
| 160 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 161 | + $login_url = trailingslashit($home_url)."$slug/"; |
|
| 162 | + }else{ |
|
| 163 | + $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if($args){ |
|
| 167 | + $login_url = add_query_arg($args,$login_url ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Filter the GeoDirectory login page url. |
|
| 172 | + * |
|
| 173 | + * This filter can be used to change the GeoDirectory page url. |
|
| 174 | + * |
|
| 175 | + * @since 1.5.3 |
|
| 176 | + * @package GeoDirectory |
|
| 177 | + * @param string $login_url The url of the login page. |
|
| 178 | + * @param array $args The array of query args used. |
|
| 179 | + * @param int $gd_page_id The page id of the GD login page. |
|
| 180 | + */ |
|
| 181 | + return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -190,40 +190,40 @@ discard block |
||
| 190 | 190 | * @return string Info page url. |
| 191 | 191 | */ |
| 192 | 192 | function geodir_info_url($args=array()){ |
| 193 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 194 | - |
|
| 195 | - if (function_exists('icl_object_id')) { |
|
| 196 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 200 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - if (geodir_is_wpml()){ |
|
| 204 | - $home_url = icl_get_home_url(); |
|
| 205 | - }else{ |
|
| 206 | - $home_url = home_url(); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 210 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - if($gd_page_id){ |
|
| 214 | - $post = get_post($gd_page_id); |
|
| 215 | - $slug = $post->post_name; |
|
| 216 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 217 | - $info_url = trailingslashit($home_url)."$slug/"; |
|
| 218 | - }else{ |
|
| 219 | - $info_url = trailingslashit($home_url); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - if($args){ |
|
| 223 | - $info_url = add_query_arg($args,$info_url ); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - return $info_url; |
|
| 193 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 194 | + |
|
| 195 | + if (function_exists('icl_object_id')) { |
|
| 196 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 200 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + if (geodir_is_wpml()){ |
|
| 204 | + $home_url = icl_get_home_url(); |
|
| 205 | + }else{ |
|
| 206 | + $home_url = home_url(); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 210 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + if($gd_page_id){ |
|
| 214 | + $post = get_post($gd_page_id); |
|
| 215 | + $slug = $post->post_name; |
|
| 216 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 217 | + $info_url = trailingslashit($home_url)."$slug/"; |
|
| 218 | + }else{ |
|
| 219 | + $info_url = trailingslashit($home_url); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + if($args){ |
|
| 223 | + $info_url = add_query_arg($args,$info_url ); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + return $info_url; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | * @return string Returns converted string. |
| 240 | 240 | */ |
| 241 | 241 | function geodir_ucwords($string, $charset='UTF-8') { |
| 242 | - if (function_exists('mb_convert_case')) { |
|
| 243 | - return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 244 | - } else { |
|
| 245 | - return ucwords($string); |
|
| 246 | - } |
|
| 242 | + if (function_exists('mb_convert_case')) { |
|
| 243 | + return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 244 | + } else { |
|
| 245 | + return ucwords($string); |
|
| 246 | + } |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | * @return string Returns converted string. |
| 260 | 260 | */ |
| 261 | 261 | function geodir_strtolower($string, $charset='UTF-8') { |
| 262 | - if (function_exists('mb_convert_case')) { |
|
| 263 | - return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 264 | - } else { |
|
| 265 | - return strtolower($string); |
|
| 266 | - } |
|
| 262 | + if (function_exists('mb_convert_case')) { |
|
| 263 | + return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 264 | + } else { |
|
| 265 | + return strtolower($string); |
|
| 266 | + } |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | * @return string Returns converted string. |
| 280 | 280 | */ |
| 281 | 281 | function geodir_strtoupper($string, $charset='UTF-8') { |
| 282 | - if (function_exists('mb_convert_case')) { |
|
| 283 | - return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 284 | - } else { |
|
| 285 | - return strtoupper($string); |
|
| 286 | - } |
|
| 282 | + if (function_exists('mb_convert_case')) { |
|
| 283 | + return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 284 | + } else { |
|
| 285 | + return strtoupper($string); |
|
| 286 | + } |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | * @package GeoDirectory |
| 463 | 463 | */ |
| 464 | 464 | function _gd_die_handler() { |
| 465 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 466 | - return '_gd_die_handler'; |
|
| 467 | - } else { |
|
| 468 | - die(); |
|
| 469 | - } |
|
| 465 | + if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 466 | + return '_gd_die_handler'; |
|
| 467 | + } else { |
|
| 468 | + die(); |
|
| 469 | + } |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | * @param int $status Optional. Status code. |
| 482 | 482 | */ |
| 483 | 483 | function gd_die( $message = '', $title = '', $status = 400 ) { |
| 484 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 484 | + add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | + add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | + wp_die( $message, $title, array( 'response' => $status )); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /* |
@@ -652,37 +652,37 @@ discard block |
||
| 652 | 652 | * @return string The formatted date. |
| 653 | 653 | */ |
| 654 | 654 | function geodir_date($date_input, $date_to, $date_from = '') { |
| 655 | - if (empty($date_input) || empty($date_to)) { |
|
| 656 | - return NULL; |
|
| 657 | - } |
|
| 655 | + if (empty($date_input) || empty($date_to)) { |
|
| 656 | + return NULL; |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - $date = ''; |
|
| 660 | - if (!empty($date_from)) { |
|
| 661 | - $datetime = date_create_from_format($date_from, $date_input); |
|
| 659 | + $date = ''; |
|
| 660 | + if (!empty($date_from)) { |
|
| 661 | + $datetime = date_create_from_format($date_from, $date_input); |
|
| 662 | 662 | |
| 663 | - if (!empty($datetime)) { |
|
| 664 | - $date = $datetime->format($date_to); |
|
| 665 | - } |
|
| 666 | - } |
|
| 663 | + if (!empty($datetime)) { |
|
| 664 | + $date = $datetime->format($date_to); |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - if (empty($date)) { |
|
| 669 | - $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input; |
|
| 670 | - $date = date_i18n($date_to, strtotime($date)); |
|
| 671 | - } |
|
| 668 | + if (empty($date)) { |
|
| 669 | + $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input; |
|
| 670 | + $date = date_i18n($date_to, strtotime($date)); |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - $date = geodir_maybe_untranslate_date($date); |
|
| 674 | - /** |
|
| 675 | - * Filter the the date format conversion. |
|
| 676 | - * |
|
| 677 | - * @since 1.6.7 |
|
| 678 | - * @package GeoDirectory |
|
| 679 | - * |
|
| 680 | - * @param string $date The date string. |
|
| 681 | - * @param string $date_input The date input. |
|
| 682 | - * @param string $date_to The destination date format. |
|
| 683 | - * @param string $date_from The source date format. |
|
| 684 | - */ |
|
| 685 | - return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from); |
|
| 673 | + $date = geodir_maybe_untranslate_date($date); |
|
| 674 | + /** |
|
| 675 | + * Filter the the date format conversion. |
|
| 676 | + * |
|
| 677 | + * @since 1.6.7 |
|
| 678 | + * @package GeoDirectory |
|
| 679 | + * |
|
| 680 | + * @param string $date The date string. |
|
| 681 | + * @param string $date_input The date input. |
|
| 682 | + * @param string $date_to The destination date format. |
|
| 683 | + * @param string $date_from The source date format. |
|
| 684 | + */ |
|
| 685 | + return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -707,91 +707,91 @@ discard block |
||
| 707 | 707 | * @return string Trimmed string. |
| 708 | 708 | */ |
| 709 | 709 | function geodir_excerpt($text, $length = 100, $options = array()) { |
| 710 | - if (!(int)$length > 0) { |
|
| 711 | - return $text; |
|
| 712 | - } |
|
| 713 | - $default = array( |
|
| 714 | - 'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false, |
|
| 710 | + if (!(int)$length > 0) { |
|
| 711 | + return $text; |
|
| 712 | + } |
|
| 713 | + $default = array( |
|
| 714 | + 'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false, |
|
| 715 | 715 | ); |
| 716 | - if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
| 717 | - $default['ellipsis'] = ""; |
|
| 718 | - } |
|
| 719 | - $options += $default; |
|
| 720 | - |
|
| 721 | - $prefix = ''; |
|
| 722 | - $suffix = $options['ellipsis']; |
|
| 723 | - |
|
| 724 | - if ($options['html']) { |
|
| 725 | - $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options); |
|
| 726 | - |
|
| 727 | - $truncateLength = 0; |
|
| 728 | - $totalLength = 0; |
|
| 729 | - $openTags = array(); |
|
| 730 | - $truncate = ''; |
|
| 731 | - |
|
| 732 | - preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER); |
|
| 733 | - foreach ($tags as $tag) { |
|
| 734 | - $contentLength = geodir_strlen($tag[3], $options); |
|
| 735 | - |
|
| 736 | - if ($truncate === '') { |
|
| 737 | - if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
| 738 | - if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
|
| 739 | - array_unshift($openTags, $tag[2]); |
|
| 740 | - } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
|
| 741 | - $pos = array_search($closeTag[1], $openTags); |
|
| 742 | - if ($pos !== false) { |
|
| 743 | - array_splice($openTags, $pos, 1); |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - $prefix .= $tag[1]; |
|
| 749 | - |
|
| 750 | - if ($totalLength + $contentLength + $ellipsisLength > $length) { |
|
| 751 | - $truncate = $tag[3]; |
|
| 752 | - $truncateLength = $length - $totalLength; |
|
| 753 | - } else { |
|
| 754 | - $prefix .= $tag[3]; |
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - $totalLength += $contentLength; |
|
| 759 | - if ($totalLength > $length) { |
|
| 760 | - break; |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - if ($totalLength <= $length) { |
|
| 765 | - return $text; |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - $text = $truncate; |
|
| 769 | - $length = $truncateLength; |
|
| 770 | - |
|
| 771 | - foreach ($openTags as $tag) { |
|
| 772 | - $suffix .= '</' . $tag . '>'; |
|
| 773 | - } |
|
| 774 | - } else { |
|
| 775 | - if (geodir_strlen($text, $options) <= $length) { |
|
| 776 | - return $text; |
|
| 777 | - } |
|
| 778 | - $ellipsisLength = geodir_strlen($options['ellipsis'], $options); |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - $result = geodir_substr($text, 0, $length - $ellipsisLength, $options); |
|
| 782 | - |
|
| 783 | - if (!$options['exact']) { |
|
| 784 | - if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
|
| 785 | - $result = geodir_remove_last_word($result); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - // Do not need to count ellipsis in the cut, if result is empty. |
|
| 789 | - if (!strlen($result)) { |
|
| 790 | - $result = geodir_substr($text, 0, $length, $options); |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - return $prefix . $result . $suffix; |
|
| 716 | + if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
| 717 | + $default['ellipsis'] = ""; |
|
| 718 | + } |
|
| 719 | + $options += $default; |
|
| 720 | + |
|
| 721 | + $prefix = ''; |
|
| 722 | + $suffix = $options['ellipsis']; |
|
| 723 | + |
|
| 724 | + if ($options['html']) { |
|
| 725 | + $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options); |
|
| 726 | + |
|
| 727 | + $truncateLength = 0; |
|
| 728 | + $totalLength = 0; |
|
| 729 | + $openTags = array(); |
|
| 730 | + $truncate = ''; |
|
| 731 | + |
|
| 732 | + preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER); |
|
| 733 | + foreach ($tags as $tag) { |
|
| 734 | + $contentLength = geodir_strlen($tag[3], $options); |
|
| 735 | + |
|
| 736 | + if ($truncate === '') { |
|
| 737 | + if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
| 738 | + if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
|
| 739 | + array_unshift($openTags, $tag[2]); |
|
| 740 | + } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
|
| 741 | + $pos = array_search($closeTag[1], $openTags); |
|
| 742 | + if ($pos !== false) { |
|
| 743 | + array_splice($openTags, $pos, 1); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + $prefix .= $tag[1]; |
|
| 749 | + |
|
| 750 | + if ($totalLength + $contentLength + $ellipsisLength > $length) { |
|
| 751 | + $truncate = $tag[3]; |
|
| 752 | + $truncateLength = $length - $totalLength; |
|
| 753 | + } else { |
|
| 754 | + $prefix .= $tag[3]; |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + $totalLength += $contentLength; |
|
| 759 | + if ($totalLength > $length) { |
|
| 760 | + break; |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + if ($totalLength <= $length) { |
|
| 765 | + return $text; |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + $text = $truncate; |
|
| 769 | + $length = $truncateLength; |
|
| 770 | + |
|
| 771 | + foreach ($openTags as $tag) { |
|
| 772 | + $suffix .= '</' . $tag . '>'; |
|
| 773 | + } |
|
| 774 | + } else { |
|
| 775 | + if (geodir_strlen($text, $options) <= $length) { |
|
| 776 | + return $text; |
|
| 777 | + } |
|
| 778 | + $ellipsisLength = geodir_strlen($options['ellipsis'], $options); |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + $result = geodir_substr($text, 0, $length - $ellipsisLength, $options); |
|
| 782 | + |
|
| 783 | + if (!$options['exact']) { |
|
| 784 | + if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
|
| 785 | + $result = geodir_remove_last_word($result); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + // Do not need to count ellipsis in the cut, if result is empty. |
|
| 789 | + if (!strlen($result)) { |
|
| 790 | + $result = geodir_substr($text, 0, $length, $options); |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + return $prefix . $result . $suffix; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -815,28 +815,28 @@ discard block |
||
| 815 | 815 | * @return int |
| 816 | 816 | */ |
| 817 | 817 | function geodir_strlen($text, array $options) { |
| 818 | - if (empty($options['trimWidth'])) { |
|
| 819 | - $strlen = 'geodir_utf8_strlen'; |
|
| 820 | - } else { |
|
| 821 | - $strlen = 'geodir_utf8_strwidth'; |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - if (empty($options['html'])) { |
|
| 825 | - return $strlen($text); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
|
| 829 | - $replace = preg_replace_callback( |
|
| 830 | - $pattern, |
|
| 831 | - function ($match) use ($strlen) { |
|
| 832 | - $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
| 833 | - |
|
| 834 | - return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
|
| 835 | - }, |
|
| 836 | - $text |
|
| 837 | - ); |
|
| 838 | - |
|
| 839 | - return $strlen($replace); |
|
| 818 | + if (empty($options['trimWidth'])) { |
|
| 819 | + $strlen = 'geodir_utf8_strlen'; |
|
| 820 | + } else { |
|
| 821 | + $strlen = 'geodir_utf8_strwidth'; |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + if (empty($options['html'])) { |
|
| 825 | + return $strlen($text); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
|
| 829 | + $replace = preg_replace_callback( |
|
| 830 | + $pattern, |
|
| 831 | + function ($match) use ($strlen) { |
|
| 832 | + $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
| 833 | + |
|
| 834 | + return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
|
| 835 | + }, |
|
| 836 | + $text |
|
| 837 | + ); |
|
| 838 | + |
|
| 839 | + return $strlen($replace); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -857,80 +857,80 @@ discard block |
||
| 857 | 857 | * @return string |
| 858 | 858 | */ |
| 859 | 859 | function geodir_substr($text, $start, $length, array $options) { |
| 860 | - if (empty($options['trimWidth'])) { |
|
| 861 | - $substr = 'geodir_utf8_substr'; |
|
| 862 | - } else { |
|
| 863 | - $substr = 'geodir_utf8_strimwidth'; |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - $maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options); |
|
| 867 | - if ($start < 0) { |
|
| 868 | - $start += $maxPosition; |
|
| 869 | - if ($start < 0) { |
|
| 870 | - $start = 0; |
|
| 871 | - } |
|
| 872 | - } |
|
| 873 | - if ($start >= $maxPosition) { |
|
| 874 | - return ''; |
|
| 875 | - } |
|
| 876 | - |
|
| 877 | - if ($length === null) { |
|
| 878 | - $length = geodir_strlen($text, $options); |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - if ($length < 0) { |
|
| 882 | - $text = geodir_substr($text, $start, null, $options); |
|
| 883 | - $start = 0; |
|
| 884 | - $length += geodir_strlen($text, $options); |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - if ($length <= 0) { |
|
| 888 | - return ''; |
|
| 889 | - } |
|
| 890 | - |
|
| 891 | - if (empty($options['html'])) { |
|
| 892 | - return (string)$substr($text, $start, $length); |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - $totalOffset = 0; |
|
| 896 | - $totalLength = 0; |
|
| 897 | - $result = ''; |
|
| 898 | - |
|
| 899 | - $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
|
| 900 | - $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 901 | - foreach ($parts as $part) { |
|
| 902 | - $offset = 0; |
|
| 903 | - |
|
| 904 | - if ($totalOffset < $start) { |
|
| 905 | - $len = geodir_strlen($part, array('trimWidth' => false) + $options); |
|
| 906 | - if ($totalOffset + $len <= $start) { |
|
| 907 | - $totalOffset += $len; |
|
| 908 | - continue; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - $offset = $start - $totalOffset; |
|
| 912 | - $totalOffset = $start; |
|
| 913 | - } |
|
| 914 | - |
|
| 915 | - $len = geodir_strlen($part, $options); |
|
| 916 | - if ($offset !== 0 || $totalLength + $len > $length) { |
|
| 917 | - if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 918 | - // Entities cannot be passed substr. |
|
| 919 | - continue; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - $part = $substr($part, $offset, $length - $totalLength); |
|
| 923 | - $len = geodir_strlen($part, $options); |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - $result .= $part; |
|
| 927 | - $totalLength += $len; |
|
| 928 | - if ($totalLength >= $length) { |
|
| 929 | - break; |
|
| 930 | - } |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - return $result; |
|
| 860 | + if (empty($options['trimWidth'])) { |
|
| 861 | + $substr = 'geodir_utf8_substr'; |
|
| 862 | + } else { |
|
| 863 | + $substr = 'geodir_utf8_strimwidth'; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options); |
|
| 867 | + if ($start < 0) { |
|
| 868 | + $start += $maxPosition; |
|
| 869 | + if ($start < 0) { |
|
| 870 | + $start = 0; |
|
| 871 | + } |
|
| 872 | + } |
|
| 873 | + if ($start >= $maxPosition) { |
|
| 874 | + return ''; |
|
| 875 | + } |
|
| 876 | + |
|
| 877 | + if ($length === null) { |
|
| 878 | + $length = geodir_strlen($text, $options); |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + if ($length < 0) { |
|
| 882 | + $text = geodir_substr($text, $start, null, $options); |
|
| 883 | + $start = 0; |
|
| 884 | + $length += geodir_strlen($text, $options); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + if ($length <= 0) { |
|
| 888 | + return ''; |
|
| 889 | + } |
|
| 890 | + |
|
| 891 | + if (empty($options['html'])) { |
|
| 892 | + return (string)$substr($text, $start, $length); |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + $totalOffset = 0; |
|
| 896 | + $totalLength = 0; |
|
| 897 | + $result = ''; |
|
| 898 | + |
|
| 899 | + $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
|
| 900 | + $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 901 | + foreach ($parts as $part) { |
|
| 902 | + $offset = 0; |
|
| 903 | + |
|
| 904 | + if ($totalOffset < $start) { |
|
| 905 | + $len = geodir_strlen($part, array('trimWidth' => false) + $options); |
|
| 906 | + if ($totalOffset + $len <= $start) { |
|
| 907 | + $totalOffset += $len; |
|
| 908 | + continue; |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + $offset = $start - $totalOffset; |
|
| 912 | + $totalOffset = $start; |
|
| 913 | + } |
|
| 914 | + |
|
| 915 | + $len = geodir_strlen($part, $options); |
|
| 916 | + if ($offset !== 0 || $totalLength + $len > $length) { |
|
| 917 | + if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 918 | + // Entities cannot be passed substr. |
|
| 919 | + continue; |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + $part = $substr($part, $offset, $length - $totalLength); |
|
| 923 | + $len = geodir_strlen($part, $options); |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + $result .= $part; |
|
| 927 | + $totalLength += $len; |
|
| 928 | + if ($totalLength >= $length) { |
|
| 929 | + break; |
|
| 930 | + } |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + return $result; |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -943,21 +943,21 @@ discard block |
||
| 943 | 943 | * @return string |
| 944 | 944 | */ |
| 945 | 945 | function geodir_remove_last_word($text) { |
| 946 | - $spacepos = geodir_utf8_strrpos($text, ' '); |
|
| 946 | + $spacepos = geodir_utf8_strrpos($text, ' '); |
|
| 947 | 947 | |
| 948 | - if ($spacepos !== false) { |
|
| 949 | - $lastWord = geodir_utf8_strrpos($text, $spacepos); |
|
| 948 | + if ($spacepos !== false) { |
|
| 949 | + $lastWord = geodir_utf8_strrpos($text, $spacepos); |
|
| 950 | 950 | |
| 951 | - // Some languages are written without word separation. |
|
| 952 | - // We recognize a string as a word if it does not contain any full-width characters. |
|
| 953 | - if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) { |
|
| 954 | - $text = geodir_utf8_substr($text, 0, $spacepos); |
|
| 955 | - } |
|
| 951 | + // Some languages are written without word separation. |
|
| 952 | + // We recognize a string as a word if it does not contain any full-width characters. |
|
| 953 | + if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) { |
|
| 954 | + $text = geodir_utf8_substr($text, 0, $spacepos); |
|
| 955 | + } |
|
| 956 | 956 | |
| 957 | - return $text; |
|
| 958 | - } |
|
| 957 | + return $text; |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | - return ''; |
|
| 960 | + return ''; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | function geodir_tool_restore_cpt_from_taxonomies(){ |
@@ -1075,11 +1075,11 @@ discard block |
||
| 1075 | 1075 | * @return string |
| 1076 | 1076 | */ |
| 1077 | 1077 | function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
| 1078 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1079 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 1080 | - } |
|
| 1078 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1079 | + return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | - return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 1082 | + return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | /** |
@@ -1093,11 +1093,11 @@ discard block |
||
| 1093 | 1093 | * @return int Returns the number of characters in string. |
| 1094 | 1094 | */ |
| 1095 | 1095 | function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
| 1096 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 1097 | - return mb_strlen( $str, $encoding ); |
|
| 1098 | - } |
|
| 1096 | + if ( function_exists( 'mb_strlen' ) ) { |
|
| 1097 | + return mb_strlen( $str, $encoding ); |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - return strlen( $str ); |
|
| 1100 | + return strlen( $str ); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1113,11 +1113,11 @@ discard block |
||
| 1113 | 1113 | * @return int Returns the position of the first occurrence of search in the string. |
| 1114 | 1114 | */ |
| 1115 | 1115 | function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
| 1116 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 1117 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 1118 | - } |
|
| 1116 | + if ( function_exists( 'mb_strpos' ) ) { |
|
| 1117 | + return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 1118 | + } |
|
| 1119 | 1119 | |
| 1120 | - return strpos( $str, $find, $offset ); |
|
| 1120 | + return strpos( $str, $find, $offset ); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1133,11 +1133,11 @@ discard block |
||
| 1133 | 1133 | * @return int Returns the position of the last occurrence of search. |
| 1134 | 1134 | */ |
| 1135 | 1135 | function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
| 1136 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 1137 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 1138 | - } |
|
| 1136 | + if ( function_exists( 'mb_strrpos' ) ) { |
|
| 1137 | + return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | - return strrpos( $str, $find, $offset ); |
|
| 1140 | + return strrpos( $str, $find, $offset ); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1154,15 +1154,15 @@ discard block |
||
| 1154 | 1154 | * @return string |
| 1155 | 1155 | */ |
| 1156 | 1156 | function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
| 1157 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 1158 | - if ( $length === null ) { |
|
| 1159 | - return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1160 | - } else { |
|
| 1161 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 1162 | - } |
|
| 1163 | - } |
|
| 1157 | + if ( function_exists( 'mb_substr' ) ) { |
|
| 1158 | + if ( $length === null ) { |
|
| 1159 | + return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1160 | + } else { |
|
| 1161 | + return mb_substr( $str, $start, $length, $encoding ); |
|
| 1162 | + } |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | - return substr( $str, $start, $length ); |
|
| 1165 | + return substr( $str, $start, $length ); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1195,20 +1195,20 @@ discard block |
||
| 1195 | 1195 | * @return string The resulting string. |
| 1196 | 1196 | */ |
| 1197 | 1197 | function geodir_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
| 1198 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 1199 | - $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 1200 | - $str_end = ""; |
|
| 1198 | + if ( function_exists( 'mb_strlen' ) ) { |
|
| 1199 | + $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 1200 | + $str_end = ""; |
|
| 1201 | 1201 | |
| 1202 | - if ( $lower_str_end ) { |
|
| 1203 | - $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 1204 | - } else { |
|
| 1205 | - $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1206 | - } |
|
| 1202 | + if ( $lower_str_end ) { |
|
| 1203 | + $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 1204 | + } else { |
|
| 1205 | + $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1206 | + } |
|
| 1207 | 1207 | |
| 1208 | - return $first_letter . $str_end; |
|
| 1209 | - } |
|
| 1208 | + return $first_letter . $str_end; |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | - return ucfirst( $str ); |
|
| 1211 | + return ucfirst( $str ); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | function geodir_total_listings_count($post_type = false) |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | * @since 1.4.6 |
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | -function geodir_add_listing_page_id(){ |
|
| 16 | +function geodir_add_listing_page_id() { |
|
| 17 | 17 | $gd_page_id = get_option('geodir_add_listing_page'); |
| 18 | 18 | |
| 19 | 19 | if (function_exists('icl_object_id')) { |
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | return $gd_page_id; |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * @since 1.4.6 |
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | -function geodir_preview_page_id(){ |
|
| 33 | +function geodir_preview_page_id() { |
|
| 34 | 34 | $gd_page_id = get_option('geodir_preview_page'); |
| 35 | 35 | |
| 36 | 36 | if (function_exists('icl_object_id')) { |
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $gd_page_id; |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * @since 1.4.6 |
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | -function geodir_success_page_id(){ |
|
| 50 | +function geodir_success_page_id() { |
|
| 51 | 51 | $gd_page_id = get_option('geodir_success_page'); |
| 52 | 52 | |
| 53 | 53 | if (function_exists('icl_object_id')) { |
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $gd_page_id; |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @since 1.4.6 |
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | -function geodir_location_page_id(){ |
|
| 67 | +function geodir_location_page_id() { |
|
| 68 | 68 | $gd_page_id = get_option('geodir_location_page'); |
| 69 | 69 | |
| 70 | 70 | if (function_exists('icl_object_id')) { |
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $gd_page_id; |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | * @since 1.5.4 |
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | -function geodir_home_page_id(){ |
|
| 84 | +function geodir_home_page_id() { |
|
| 85 | 85 | $gd_page_id = get_option('geodir_home_page'); |
| 86 | 86 | |
| 87 | 87 | if (function_exists('icl_object_id')) { |
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $gd_page_id; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @since 1.5.3 |
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | -function geodir_info_page_id(){ |
|
| 101 | +function geodir_info_page_id() { |
|
| 102 | 102 | $gd_page_id = get_option('geodir_info_page'); |
| 103 | 103 | |
| 104 | 104 | if (function_exists('icl_object_id')) { |
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return $gd_page_id; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | * @since 1.5.3 |
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | -function geodir_login_page_id(){ |
|
| 118 | +function geodir_login_page_id() { |
|
| 119 | 119 | $gd_page_id = get_option('geodir_login_page'); |
| 120 | 120 | |
| 121 | 121 | if (function_exists('icl_object_id')) { |
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $gd_page_id; |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | * @since 1.5.3 |
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | -function geodir_login_url($args=array()){ |
|
| 136 | +function geodir_login_url($args = array()) { |
|
| 137 | 137 | $gd_page_id = get_option('geodir_login_page'); |
| 138 | 138 | |
| 139 | 139 | if (function_exists('icl_object_id')) { |
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (function_exists('geodir_location_geo_home_link')) { |
| 144 | 144 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (geodir_is_wpml()){ |
|
| 147 | + if (geodir_is_wpml()) { |
|
| 148 | 148 | $home_url = icl_get_home_url(); |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | $home_url = home_url(); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if($gd_page_id){ |
|
| 157 | + if ($gd_page_id) { |
|
| 158 | 158 | $post = get_post($gd_page_id); |
| 159 | 159 | $slug = $post->post_name; |
| 160 | 160 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 161 | 161 | $login_url = trailingslashit($home_url)."$slug/"; |
| 162 | - }else{ |
|
| 162 | + } else { |
|
| 163 | 163 | $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if($args){ |
|
| 167 | - $login_url = add_query_arg($args,$login_url ); |
|
| 166 | + if ($args) { |
|
| 167 | + $login_url = add_query_arg($args, $login_url); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param array $args The array of query args used. |
| 179 | 179 | * @param int $gd_page_id The page id of the GD login page. |
| 180 | 180 | */ |
| 181 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 181 | + return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -189,20 +189,20 @@ discard block |
||
| 189 | 189 | * @since 1.5.16 Added WPML lang code to url. |
| 190 | 190 | * @return string Info page url. |
| 191 | 191 | */ |
| 192 | -function geodir_info_url($args=array()){ |
|
| 192 | +function geodir_info_url($args = array()) { |
|
| 193 | 193 | $gd_page_id = get_option('geodir_info_page'); |
| 194 | 194 | |
| 195 | 195 | if (function_exists('icl_object_id')) { |
| 196 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 196 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (function_exists('geodir_location_geo_home_link')) { |
| 200 | 200 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if (geodir_is_wpml()){ |
|
| 203 | + if (geodir_is_wpml()) { |
|
| 204 | 204 | $home_url = icl_get_home_url(); |
| 205 | - }else{ |
|
| 205 | + } else { |
|
| 206 | 206 | $home_url = home_url(); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -210,17 +210,17 @@ discard block |
||
| 210 | 210 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if($gd_page_id){ |
|
| 213 | + if ($gd_page_id) { |
|
| 214 | 214 | $post = get_post($gd_page_id); |
| 215 | 215 | $slug = $post->post_name; |
| 216 | 216 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 217 | 217 | $info_url = trailingslashit($home_url)."$slug/"; |
| 218 | - }else{ |
|
| 218 | + } else { |
|
| 219 | 219 | $info_url = trailingslashit($home_url); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if($args){ |
|
| 223 | - $info_url = add_query_arg($args,$info_url ); |
|
| 222 | + if ($args) { |
|
| 223 | + $info_url = add_query_arg($args, $info_url); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | return $info_url; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param string $charset Character set to use for conversion. |
| 239 | 239 | * @return string Returns converted string. |
| 240 | 240 | */ |
| 241 | -function geodir_ucwords($string, $charset='UTF-8') { |
|
| 241 | +function geodir_ucwords($string, $charset = 'UTF-8') { |
|
| 242 | 242 | if (function_exists('mb_convert_case')) { |
| 243 | 243 | return mb_convert_case($string, MB_CASE_TITLE, $charset); |
| 244 | 244 | } else { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @param string $charset Character set to use for conversion. |
| 259 | 259 | * @return string Returns converted string. |
| 260 | 260 | */ |
| 261 | -function geodir_strtolower($string, $charset='UTF-8') { |
|
| 261 | +function geodir_strtolower($string, $charset = 'UTF-8') { |
|
| 262 | 262 | if (function_exists('mb_convert_case')) { |
| 263 | 263 | return mb_convert_case($string, MB_CASE_LOWER, $charset); |
| 264 | 264 | } else { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param string $charset Character set to use for conversion. |
| 279 | 279 | * @return string Returns converted string. |
| 280 | 280 | */ |
| 281 | -function geodir_strtoupper($string, $charset='UTF-8') { |
|
| 281 | +function geodir_strtoupper($string, $charset = 'UTF-8') { |
|
| 282 | 282 | if (function_exists('mb_convert_case')) { |
| 283 | 283 | return mb_convert_case($string, MB_CASE_UPPER, $charset); |
| 284 | 284 | } else { |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $url = trim($parts[0]); |
| 311 | 311 | if ($formatted && $url != '') { |
| 312 | - $url = str_replace( ' ', '%20', $url ); |
|
| 312 | + $url = str_replace(' ', '%20', $url); |
|
| 313 | 313 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url); |
| 314 | 314 | |
| 315 | 315 | if (0 !== stripos($url, 'mailto:')) { |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $url = str_replace(';//', '://', $url); |
| 321 | 321 | |
| 322 | - if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 323 | - $url = 'http://' . $url; |
|
| 322 | + if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 323 | + $url = 'http://'.$url; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $url = wp_kses_normalize_entities($url); |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @package GeoDirectory |
| 463 | 463 | */ |
| 464 | 464 | function _gd_die_handler() { |
| 465 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 465 | + if (defined('GD_TESTING_MODE')) { |
|
| 466 | 466 | return '_gd_die_handler'; |
| 467 | 467 | } else { |
| 468 | 468 | die(); |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | * @param string $title Optional. Error title. |
| 481 | 481 | * @param int $status Optional. Status code. |
| 482 | 482 | */ |
| 483 | -function gd_die( $message = '', $title = '', $status = 400 ) { |
|
| 484 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 483 | +function gd_die($message = '', $title = '', $status = 400) { |
|
| 484 | + add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3); |
|
| 485 | + add_filter('wp_die_handler', '_gd_die_handler', 10, 3); |
|
| 486 | + wp_die($message, $title, array('response' => $status)); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /* |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @param string $php_format The PHP date format. |
| 494 | 494 | * @return string The jQuery format date string. |
| 495 | 495 | */ |
| 496 | -function geodir_date_format_php_to_jqueryui( $php_format ) { |
|
| 496 | +function geodir_date_format_php_to_jqueryui($php_format) { |
|
| 497 | 497 | $symbols = array( |
| 498 | 498 | // Day |
| 499 | 499 | 'd' => 'dd', |
@@ -533,27 +533,27 @@ discard block |
||
| 533 | 533 | $jqueryui_format = ""; |
| 534 | 534 | $escaping = false; |
| 535 | 535 | |
| 536 | - for ( $i = 0; $i < strlen( $php_format ); $i++ ) { |
|
| 536 | + for ($i = 0; $i < strlen($php_format); $i++) { |
|
| 537 | 537 | $char = $php_format[$i]; |
| 538 | 538 | |
| 539 | 539 | // PHP date format escaping character |
| 540 | - if ( $char === '\\' ) { |
|
| 540 | + if ($char === '\\') { |
|
| 541 | 541 | $i++; |
| 542 | 542 | |
| 543 | - if ( $escaping ) { |
|
| 543 | + if ($escaping) { |
|
| 544 | 544 | $jqueryui_format .= $php_format[$i]; |
| 545 | 545 | } else { |
| 546 | - $jqueryui_format .= '\'' . $php_format[$i]; |
|
| 546 | + $jqueryui_format .= '\''.$php_format[$i]; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | $escaping = true; |
| 550 | 550 | } else { |
| 551 | - if ( $escaping ) { |
|
| 551 | + if ($escaping) { |
|
| 552 | 552 | $jqueryui_format .= "'"; |
| 553 | 553 | $escaping = false; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - if ( isset( $symbols[$char] ) ) { |
|
| 556 | + if (isset($symbols[$char])) { |
|
| 557 | 557 | $jqueryui_format .= $symbols[$char]; |
| 558 | 558 | } else { |
| 559 | 559 | $jqueryui_format .= $char; |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * @return string The untranslated date string. |
| 573 | 573 | * @since 1.6.5 |
| 574 | 574 | */ |
| 575 | -function geodir_maybe_untranslate_date($date){ |
|
| 575 | +function geodir_maybe_untranslate_date($date) { |
|
| 576 | 576 | $english_long_months = array( |
| 577 | 577 | 'January', |
| 578 | 578 | 'February', |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | 'December', |
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | - $non_english_long_months = array( |
|
| 591 | + $non_english_long_months = array( |
|
| 592 | 592 | __('January'), |
| 593 | 593 | __('February'), |
| 594 | 594 | __('March'), |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | __('November'), |
| 603 | 603 | __('December'), |
| 604 | 604 | ); |
| 605 | - $date = str_replace($non_english_long_months,$english_long_months,$date); |
|
| 605 | + $date = str_replace($non_english_long_months, $english_long_months, $date); |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | 608 | $english_short_months = array( |
@@ -621,21 +621,21 @@ discard block |
||
| 621 | 621 | ); |
| 622 | 622 | |
| 623 | 623 | $non_english_short_months = array( |
| 624 | - ' '._x( 'Jan', 'January abbreviation' ).' ', |
|
| 625 | - ' '._x( 'Feb', 'February abbreviation' ).' ', |
|
| 626 | - ' '._x( 'Mar', 'March abbreviation' ).' ', |
|
| 627 | - ' '._x( 'Apr', 'April abbreviation' ).' ', |
|
| 628 | - ' '._x( 'May', 'May abbreviation' ).' ', |
|
| 629 | - ' '._x( 'Jun', 'June abbreviation' ).' ', |
|
| 630 | - ' '._x( 'Jul', 'July abbreviation' ).' ', |
|
| 631 | - ' '._x( 'Aug', 'August abbreviation' ).' ', |
|
| 632 | - ' '._x( 'Sep', 'September abbreviation' ).' ', |
|
| 633 | - ' '._x( 'Oct', 'October abbreviation' ).' ', |
|
| 634 | - ' '._x( 'Nov', 'November abbreviation' ).' ', |
|
| 635 | - ' '._x( 'Dec', 'December abbreviation' ).' ', |
|
| 624 | + ' '._x('Jan', 'January abbreviation').' ', |
|
| 625 | + ' '._x('Feb', 'February abbreviation').' ', |
|
| 626 | + ' '._x('Mar', 'March abbreviation').' ', |
|
| 627 | + ' '._x('Apr', 'April abbreviation').' ', |
|
| 628 | + ' '._x('May', 'May abbreviation').' ', |
|
| 629 | + ' '._x('Jun', 'June abbreviation').' ', |
|
| 630 | + ' '._x('Jul', 'July abbreviation').' ', |
|
| 631 | + ' '._x('Aug', 'August abbreviation').' ', |
|
| 632 | + ' '._x('Sep', 'September abbreviation').' ', |
|
| 633 | + ' '._x('Oct', 'October abbreviation').' ', |
|
| 634 | + ' '._x('Nov', 'November abbreviation').' ', |
|
| 635 | + ' '._x('Dec', 'December abbreviation').' ', |
|
| 636 | 636 | ); |
| 637 | 637 | |
| 638 | - $date = str_replace($non_english_short_months,$english_short_months,$date); |
|
| 638 | + $date = str_replace($non_english_short_months, $english_short_months, $date); |
|
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | return $date; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @return string Trimmed string. |
| 708 | 708 | */ |
| 709 | 709 | function geodir_excerpt($text, $length = 100, $options = array()) { |
| 710 | - if (!(int)$length > 0) { |
|
| 710 | + if (!(int) $length > 0) { |
|
| 711 | 711 | return $text; |
| 712 | 712 | } |
| 713 | 713 | $default = array( |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | $length = $truncateLength; |
| 770 | 770 | |
| 771 | 771 | foreach ($openTags as $tag) { |
| 772 | - $suffix .= '</' . $tag . '>'; |
|
| 772 | + $suffix .= '</'.$tag.'>'; |
|
| 773 | 773 | } |
| 774 | 774 | } else { |
| 775 | 775 | if (geodir_strlen($text, $options) <= $length) { |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - return $prefix . $result . $suffix; |
|
| 794 | + return $prefix.$result.$suffix; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
| 829 | 829 | $replace = preg_replace_callback( |
| 830 | 830 | $pattern, |
| 831 | - function ($match) use ($strlen) { |
|
| 831 | + function($match) use ($strlen) { |
|
| 832 | 832 | $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
| 833 | 833 | |
| 834 | 834 | return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | if (empty($options['html'])) { |
| 892 | - return (string)$substr($text, $start, $length); |
|
| 892 | + return (string) $substr($text, $start, $length); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | $totalOffset = 0; |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | |
| 915 | 915 | $len = geodir_strlen($part, $options); |
| 916 | 916 | if ($offset !== 0 || $totalLength + $len > $length) { |
| 917 | - if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 917 | + if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8')) { |
|
| 918 | 918 | // Entities cannot be passed substr. |
| 919 | 919 | continue; |
| 920 | 920 | } |
@@ -960,39 +960,39 @@ discard block |
||
| 960 | 960 | return ''; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | -function geodir_tool_restore_cpt_from_taxonomies(){ |
|
| 963 | +function geodir_tool_restore_cpt_from_taxonomies() { |
|
| 964 | 964 | |
| 965 | 965 | $cpts = get_option('geodir_post_types'); |
| 966 | 966 | |
| 967 | - if(!empty($cpts)){return;} |
|
| 967 | + if (!empty($cpts)) {return; } |
|
| 968 | 968 | |
| 969 | 969 | $taxonomies = get_option('geodir_taxonomies'); |
| 970 | 970 | |
| 971 | - if(empty($taxonomies)){return;} |
|
| 971 | + if (empty($taxonomies)) {return; } |
|
| 972 | 972 | |
| 973 | 973 | $cpts = array(); |
| 974 | 974 | |
| 975 | - foreach($taxonomies as $key => $val){ |
|
| 975 | + foreach ($taxonomies as $key => $val) { |
|
| 976 | 976 | |
| 977 | - if(strpos($val['listing_slug'], '/') === false) { |
|
| 978 | - $cpts[$val['object_type']] = array('cpt'=>$val['object_type'],'slug'=>$val['listing_slug']); |
|
| 977 | + if (strpos($val['listing_slug'], '/') === false) { |
|
| 978 | + $cpts[$val['object_type']] = array('cpt'=>$val['object_type'], 'slug'=>$val['listing_slug']); |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | - if(empty($cpts)){return;} |
|
| 983 | + if (empty($cpts)) {return; } |
|
| 984 | 984 | |
| 985 | 985 | |
| 986 | 986 | $cpts_restore = $cpts; |
| 987 | 987 | |
| 988 | - foreach($cpts as $cpt){ |
|
| 988 | + foreach ($cpts as $cpt) { |
|
| 989 | 989 | |
| 990 | 990 | |
| 991 | - $is_custom = $cpt['cpt']=='gd_place' ? 0 : 1; |
|
| 991 | + $is_custom = $cpt['cpt'] == 'gd_place' ? 0 : 1; |
|
| 992 | 992 | |
| 993 | - $cpts_restore[$cpt['cpt']] = array ( |
|
| 993 | + $cpts_restore[$cpt['cpt']] = array( |
|
| 994 | 994 | 'labels' => |
| 995 | - array ( |
|
| 995 | + array( |
|
| 996 | 996 | 'name' => $cpt['slug'], |
| 997 | 997 | 'singular_name' => $cpt['slug'], |
| 998 | 998 | 'add_new' => 'Add New', |
@@ -1020,14 +1020,14 @@ discard block |
||
| 1020 | 1020 | 'public' => true, |
| 1021 | 1021 | 'query_var' => true, |
| 1022 | 1022 | 'rewrite' => |
| 1023 | - array ( |
|
| 1023 | + array( |
|
| 1024 | 1024 | 'slug' => $cpt['slug'], |
| 1025 | 1025 | 'with_front' => false, |
| 1026 | 1026 | 'hierarchical' => true, |
| 1027 | 1027 | 'feeds' => true, |
| 1028 | 1028 | ), |
| 1029 | 1029 | 'supports' => |
| 1030 | - array ( |
|
| 1030 | + array( |
|
| 1031 | 1031 | 0 => 'title', |
| 1032 | 1032 | 1 => 'editor', |
| 1033 | 1033 | 2 => 'author', |
@@ -1037,14 +1037,14 @@ discard block |
||
| 1037 | 1037 | 6 => 'comments', |
| 1038 | 1038 | ), |
| 1039 | 1039 | 'taxonomies' => |
| 1040 | - array ( |
|
| 1040 | + array( |
|
| 1041 | 1041 | 0 => $cpt['cpt'].'category', |
| 1042 | 1042 | 1 => $cpt['cpt'].'_tags', |
| 1043 | 1043 | ), |
| 1044 | 1044 | 'is_custom' => $is_custom, |
| 1045 | 1045 | 'listing_order' => '1', |
| 1046 | 1046 | 'seo' => |
| 1047 | - array ( |
|
| 1047 | + array( |
|
| 1048 | 1048 | 'meta_keyword' => '', |
| 1049 | 1049 | 'meta_description' => '', |
| 1050 | 1050 | ), |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | |
| 1059 | - update_option('geodir_post_types',$cpts_restore); |
|
| 1059 | + update_option('geodir_post_types', $cpts_restore); |
|
| 1060 | 1060 | |
| 1061 | 1061 | } |
| 1062 | 1062 | |
@@ -1074,12 +1074,12 @@ discard block |
||
| 1074 | 1074 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1075 | 1075 | * @return string |
| 1076 | 1076 | */ |
| 1077 | -function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 1078 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1079 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 1077 | +function geodir_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 1078 | + if (function_exists('mb_strimwidth')) { |
|
| 1079 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 1082 | + return geodir_utf8_substr($str, $start, $width, $encoding).$trimmaker; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | /** |
@@ -1092,12 +1092,12 @@ discard block |
||
| 1092 | 1092 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1093 | 1093 | * @return int Returns the number of characters in string. |
| 1094 | 1094 | */ |
| 1095 | -function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 1096 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 1097 | - return mb_strlen( $str, $encoding ); |
|
| 1095 | +function geodir_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 1096 | + if (function_exists('mb_strlen')) { |
|
| 1097 | + return mb_strlen($str, $encoding); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - return strlen( $str ); |
|
| 1100 | + return strlen($str); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1112,12 +1112,12 @@ discard block |
||
| 1112 | 1112 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1113 | 1113 | * @return int Returns the position of the first occurrence of search in the string. |
| 1114 | 1114 | */ |
| 1115 | -function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 1116 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 1117 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 1115 | +function geodir_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 1116 | + if (function_exists('mb_strpos')) { |
|
| 1117 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - return strpos( $str, $find, $offset ); |
|
| 1120 | + return strpos($str, $find, $offset); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1132,12 +1132,12 @@ discard block |
||
| 1132 | 1132 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1133 | 1133 | * @return int Returns the position of the last occurrence of search. |
| 1134 | 1134 | */ |
| 1135 | -function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 1136 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 1137 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 1135 | +function geodir_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 1136 | + if (function_exists('mb_strrpos')) { |
|
| 1137 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - return strrpos( $str, $find, $offset ); |
|
| 1140 | + return strrpos($str, $find, $offset); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1153,16 +1153,16 @@ discard block |
||
| 1153 | 1153 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1154 | 1154 | * @return string |
| 1155 | 1155 | */ |
| 1156 | -function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 1157 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 1158 | - if ( $length === null ) { |
|
| 1159 | - return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1156 | +function geodir_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 1157 | + if (function_exists('mb_substr')) { |
|
| 1158 | + if ($length === null) { |
|
| 1159 | + return mb_substr($str, $start, geodir_utf8_strlen($str, $encoding), $encoding); |
|
| 1160 | 1160 | } else { |
| 1161 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 1161 | + return mb_substr($str, $start, $length, $encoding); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - return substr( $str, $start, $length ); |
|
| 1165 | + return substr($str, $start, $length); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1175,12 +1175,12 @@ discard block |
||
| 1175 | 1175 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1176 | 1176 | * @return string The width of string. |
| 1177 | 1177 | */ |
| 1178 | -function geodir_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 1179 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 1180 | - return mb_strwidth( $str, $encoding ); |
|
| 1178 | +function geodir_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 1179 | + if (function_exists('mb_strwidth')) { |
|
| 1180 | + return mb_strwidth($str, $encoding); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - return geodir_utf8_strlen( $str, $encoding ); |
|
| 1183 | + return geodir_utf8_strlen($str, $encoding); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | /** |
@@ -1194,21 +1194,21 @@ discard block |
||
| 1194 | 1194 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 1195 | 1195 | * @return string The resulting string. |
| 1196 | 1196 | */ |
| 1197 | -function geodir_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 1198 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 1199 | - $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 1197 | +function geodir_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 1198 | + if (function_exists('mb_strlen')) { |
|
| 1199 | + $first_letter = geodir_strtoupper(geodir_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 1200 | 1200 | $str_end = ""; |
| 1201 | 1201 | |
| 1202 | - if ( $lower_str_end ) { |
|
| 1203 | - $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 1202 | + if ($lower_str_end) { |
|
| 1203 | + $str_end = geodir_strtolower(geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 1204 | 1204 | } else { |
| 1205 | - $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 1205 | + $str_end = geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - return $first_letter . $str_end; |
|
| 1208 | + return $first_letter.$str_end; |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | - return ucfirst( $str ); |
|
| 1211 | + return ucfirst($str); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | function geodir_total_listings_count($post_type = false) |
@@ -1218,13 +1218,13 @@ discard block |
||
| 1218 | 1218 | $count = 0; |
| 1219 | 1219 | |
| 1220 | 1220 | if ($post_type) { |
| 1221 | - $count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $post_type . "_detail"); |
|
| 1221 | + $count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$post_type."_detail"); |
|
| 1222 | 1222 | } else { |
| 1223 | 1223 | $all_postypes = geodir_get_posttypes(); |
| 1224 | 1224 | |
| 1225 | 1225 | if (!empty($all_postypes)) { |
| 1226 | 1226 | foreach ($all_postypes as $key) { |
| 1227 | - $count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
| 1227 | + $count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$key."_detail"); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | } |
| 1230 | 1230 | } |
@@ -33,265 +33,265 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function geodir_add_nav_menu_items() |
| 35 | 35 | {
|
| 36 | - $items = ''; |
|
| 37 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | - |
|
| 39 | - if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | - |
|
| 41 | - $menu_class = ''; |
|
| 42 | - if (geodir_is_page('listing'))
|
|
| 43 | - $menu_class = 'current-menu-item'; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | - $post_types = geodir_get_posttypes('object');
|
|
| 48 | - $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | - if (!empty($post_types)) {
|
|
| 50 | - foreach ($post_types as $post_type => $args) {
|
|
| 51 | - if (!empty($show_post_type_main_nav)) {
|
|
| 52 | - if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | - if (get_post_type_archive_link($post_type)) {
|
|
| 54 | - $menu_class = ''; |
|
| 55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | - $menu_class = 'current-menu-item'; |
|
| 57 | - /** |
|
| 58 | - * Filter the menu li class. |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @param string $menu_class The menu HTML class. |
|
| 62 | - */ |
|
| 63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | - /** |
|
| 65 | - * Filter the menu a class. |
|
| 66 | - * |
|
| 67 | - * @since 1.0.0 |
|
| 68 | - */ |
|
| 69 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | - $items .= '<li class="' . $li_class . '"> |
|
| 36 | + $items = ''; |
|
| 37 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | + |
|
| 39 | + if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | + |
|
| 41 | + $menu_class = ''; |
|
| 42 | + if (geodir_is_page('listing'))
|
|
| 43 | + $menu_class = 'current-menu-item'; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | + $post_types = geodir_get_posttypes('object');
|
|
| 48 | + $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | + if (!empty($post_types)) {
|
|
| 50 | + foreach ($post_types as $post_type => $args) {
|
|
| 51 | + if (!empty($show_post_type_main_nav)) {
|
|
| 52 | + if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | + if (get_post_type_archive_link($post_type)) {
|
|
| 54 | + $menu_class = ''; |
|
| 55 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | + $menu_class = 'current-menu-item'; |
|
| 57 | + /** |
|
| 58 | + * Filter the menu li class. |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @param string $menu_class The menu HTML class. |
|
| 62 | + */ |
|
| 63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | + /** |
|
| 65 | + * Filter the menu a class. |
|
| 66 | + * |
|
| 67 | + * @since 1.0.0 |
|
| 68 | + */ |
|
| 69 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | + $items .= '<li class="' . $li_class . '"> |
|
| 71 | 71 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
| 72 | 72 | ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
| 73 | 73 | </a> |
| 74 | 74 | </li>'; |
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | - |
|
| 82 | - $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | - $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | - if ($is_listing_sub_meny_exists) {
|
|
| 85 | - /** |
|
| 86 | - * Filter the menu li class. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.0 |
|
| 89 | - * @param string $menu_class The menu HTML class. |
|
| 90 | - */ |
|
| 91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | - /** |
|
| 93 | - * Filter the sub menu li class. |
|
| 94 | - * |
|
| 95 | - * @since 1.0.0 |
|
| 96 | - * @param string $menu_class The menu HTML class. |
|
| 97 | - */ |
|
| 98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | - /** |
|
| 100 | - * Filter the sub menu ul class. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - */ |
|
| 104 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | - /** |
|
| 106 | - * Filter the menu a class. |
|
| 107 | - * |
|
| 108 | - * @since 1.0.0 |
|
| 109 | - */ |
|
| 110 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | - /** |
|
| 112 | - * Filter the sub menu a class. |
|
| 113 | - * |
|
| 114 | - * @since 1.0.0 |
|
| 115 | - */ |
|
| 116 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | - $items .= '<li class="' . $li_class . '"> |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | + |
|
| 82 | + $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | + $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | + if ($is_listing_sub_meny_exists) {
|
|
| 85 | + /** |
|
| 86 | + * Filter the menu li class. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.0 |
|
| 89 | + * @param string $menu_class The menu HTML class. |
|
| 90 | + */ |
|
| 91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | + /** |
|
| 93 | + * Filter the sub menu li class. |
|
| 94 | + * |
|
| 95 | + * @since 1.0.0 |
|
| 96 | + * @param string $menu_class The menu HTML class. |
|
| 97 | + */ |
|
| 98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | + /** |
|
| 100 | + * Filter the sub menu ul class. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + */ |
|
| 104 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | + /** |
|
| 106 | + * Filter the menu a class. |
|
| 107 | + * |
|
| 108 | + * @since 1.0.0 |
|
| 109 | + */ |
|
| 110 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | + /** |
|
| 112 | + * Filter the sub menu a class. |
|
| 113 | + * |
|
| 114 | + * @since 1.0.0 |
|
| 115 | + */ |
|
| 116 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | + $items .= '<li class="' . $li_class . '"> |
|
| 118 | 118 | <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
|
| 119 | 119 | <ul class="' . $sub_ul_class . '">'; |
| 120 | - $post_types = geodir_get_posttypes('object');
|
|
| 120 | + $post_types = geodir_get_posttypes('object');
|
|
| 121 | 121 | |
| 122 | - $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 122 | + $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 123 | 123 | |
| 124 | - if (!empty($post_types)) {
|
|
| 125 | - global $geodir_add_location_url; |
|
| 126 | - $geodir_add_location_url = true; |
|
| 127 | - foreach ($post_types as $post_type => $args) {
|
|
| 128 | - if (!empty($show_listing_post_types)) {
|
|
| 129 | - if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | - if (get_post_type_archive_link($post_type)) {
|
|
| 124 | + if (!empty($post_types)) {
|
|
| 125 | + global $geodir_add_location_url; |
|
| 126 | + $geodir_add_location_url = true; |
|
| 127 | + foreach ($post_types as $post_type => $args) {
|
|
| 128 | + if (!empty($show_listing_post_types)) {
|
|
| 129 | + if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | + if (get_post_type_archive_link($post_type)) {
|
|
| 131 | 131 | |
| 132 | - $menu_class = ''; |
|
| 133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | - $menu_class = 'current-menu-item'; |
|
| 132 | + $menu_class = ''; |
|
| 133 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | + $menu_class = 'current-menu-item'; |
|
| 135 | 135 | |
| 136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 136 | + $items .= '<li class="' . $sub_li_class . '"> |
|
| 137 | 137 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
| 138 | 138 | ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
| 139 | 139 | </a> |
| 140 | 140 | </li>'; |
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - $geodir_add_location_url = NULL; |
|
| 146 | - } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + $geodir_add_location_url = NULL; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $items .= ' </ul> '; |
|
| 149 | - /** |
|
| 150 | - * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
| 151 | - * |
|
| 152 | - * @since 1.5.9 |
|
| 153 | - */ |
|
| 154 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 155 | - $items .= '</li>'; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 160 | - |
|
| 161 | - $menu_class = ''; |
|
| 162 | - if (geodir_is_page('add-listing'))
|
|
| 163 | - $menu_class = 'current-menu-item'; |
|
| 164 | - |
|
| 165 | - //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 166 | - $post_types = geodir_get_posttypes('object');
|
|
| 167 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 168 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 169 | - |
|
| 170 | - if (!empty($post_types)) {
|
|
| 171 | - foreach ($post_types as $post_type => $args) {
|
|
| 172 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 173 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 174 | - if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 175 | - if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 176 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 177 | - |
|
| 178 | - $menu_class = ''; |
|
| 179 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 180 | - $menu_class = 'current-menu-item'; |
|
| 181 | - /** |
|
| 182 | - * Filter the menu li class. |
|
| 183 | - * |
|
| 184 | - * @since 1.0.0 |
|
| 185 | - * @param string $menu_class The menu HTML class. |
|
| 186 | - */ |
|
| 187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 188 | - /** |
|
| 189 | - * Filter the menu a class. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.0 |
|
| 192 | - */ |
|
| 193 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 194 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 195 | - $items .= '<li class="' . $li_class . '"> |
|
| 148 | + $items .= ' </ul> '; |
|
| 149 | + /** |
|
| 150 | + * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
| 151 | + * |
|
| 152 | + * @since 1.5.9 |
|
| 153 | + */ |
|
| 154 | + $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 155 | + $items .= '</li>'; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 160 | + |
|
| 161 | + $menu_class = ''; |
|
| 162 | + if (geodir_is_page('add-listing'))
|
|
| 163 | + $menu_class = 'current-menu-item'; |
|
| 164 | + |
|
| 165 | + //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 166 | + $post_types = geodir_get_posttypes('object');
|
|
| 167 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 168 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 169 | + |
|
| 170 | + if (!empty($post_types)) {
|
|
| 171 | + foreach ($post_types as $post_type => $args) {
|
|
| 172 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 173 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 174 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 175 | + if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 176 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 177 | + |
|
| 178 | + $menu_class = ''; |
|
| 179 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 180 | + $menu_class = 'current-menu-item'; |
|
| 181 | + /** |
|
| 182 | + * Filter the menu li class. |
|
| 183 | + * |
|
| 184 | + * @since 1.0.0 |
|
| 185 | + * @param string $menu_class The menu HTML class. |
|
| 186 | + */ |
|
| 187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 188 | + /** |
|
| 189 | + * Filter the menu a class. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.0 |
|
| 192 | + */ |
|
| 193 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 194 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 195 | + $items .= '<li class="' . $li_class . '"> |
|
| 196 | 196 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
| 197 | 197 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 198 | 198 | </a> |
| 199 | 199 | </li>'; |
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 211 | - $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 212 | - if ($is_add_listing_sub_meny_exists) {
|
|
| 213 | - |
|
| 214 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 215 | - /** |
|
| 216 | - * Filter the menu li class. |
|
| 217 | - * |
|
| 218 | - * @since 1.0.0 |
|
| 219 | - * @param string $menu_class The menu HTML class. |
|
| 220 | - */ |
|
| 221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 222 | - /** |
|
| 223 | - * Filter the sub menu li class. |
|
| 224 | - * |
|
| 225 | - * @since 1.0.0 |
|
| 226 | - * @param string $menu_class The menu HTML class. |
|
| 227 | - */ |
|
| 228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 229 | - /** |
|
| 230 | - * Filter the sub menu ul class. |
|
| 231 | - * |
|
| 232 | - * @since 1.0.0 |
|
| 233 | - */ |
|
| 234 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 235 | - /** |
|
| 236 | - * Filter the menu a class. |
|
| 237 | - * |
|
| 238 | - * @since 1.0.0 |
|
| 239 | - */ |
|
| 240 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 241 | - /** |
|
| 242 | - * Filter the sub menu a class. |
|
| 243 | - * |
|
| 244 | - * @since 1.0.0 |
|
| 245 | - */ |
|
| 246 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 247 | - $items .= '<li class="' . $li_class . '"> |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 211 | + $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 212 | + if ($is_add_listing_sub_meny_exists) {
|
|
| 213 | + |
|
| 214 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 215 | + /** |
|
| 216 | + * Filter the menu li class. |
|
| 217 | + * |
|
| 218 | + * @since 1.0.0 |
|
| 219 | + * @param string $menu_class The menu HTML class. |
|
| 220 | + */ |
|
| 221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 222 | + /** |
|
| 223 | + * Filter the sub menu li class. |
|
| 224 | + * |
|
| 225 | + * @since 1.0.0 |
|
| 226 | + * @param string $menu_class The menu HTML class. |
|
| 227 | + */ |
|
| 228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 229 | + /** |
|
| 230 | + * Filter the sub menu ul class. |
|
| 231 | + * |
|
| 232 | + * @since 1.0.0 |
|
| 233 | + */ |
|
| 234 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 235 | + /** |
|
| 236 | + * Filter the menu a class. |
|
| 237 | + * |
|
| 238 | + * @since 1.0.0 |
|
| 239 | + */ |
|
| 240 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 241 | + /** |
|
| 242 | + * Filter the sub menu a class. |
|
| 243 | + * |
|
| 244 | + * @since 1.0.0 |
|
| 245 | + */ |
|
| 246 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 247 | + $items .= '<li class="' . $li_class . '"> |
|
| 248 | 248 | <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
|
| 249 | 249 | <ul class="' . $sub_ul_class . '">'; |
| 250 | 250 | |
| 251 | - $post_types = geodir_get_posttypes('object');
|
|
| 252 | - |
|
| 253 | - $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 254 | - |
|
| 255 | - if (!empty($post_types)) {
|
|
| 256 | - foreach ($post_types as $post_type => $args) {
|
|
| 257 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 258 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 259 | - if (!empty($show_add_listing_post_types)) {
|
|
| 260 | - if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 261 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 262 | - |
|
| 263 | - $menu_class = ''; |
|
| 264 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 265 | - $menu_class = 'current-menu-item'; |
|
| 266 | - /** |
|
| 267 | - * Filter the menu li class. |
|
| 268 | - * |
|
| 269 | - * @since 1.0.0 |
|
| 270 | - * @param string $menu_class The menu HTML class. |
|
| 271 | - */ |
|
| 272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 273 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 274 | - $items .= '<li class="' . $li_class . '"> |
|
| 251 | + $post_types = geodir_get_posttypes('object');
|
|
| 252 | + |
|
| 253 | + $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 254 | + |
|
| 255 | + if (!empty($post_types)) {
|
|
| 256 | + foreach ($post_types as $post_type => $args) {
|
|
| 257 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 258 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 259 | + if (!empty($show_add_listing_post_types)) {
|
|
| 260 | + if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 261 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 262 | + |
|
| 263 | + $menu_class = ''; |
|
| 264 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 265 | + $menu_class = 'current-menu-item'; |
|
| 266 | + /** |
|
| 267 | + * Filter the menu li class. |
|
| 268 | + * |
|
| 269 | + * @since 1.0.0 |
|
| 270 | + * @param string $menu_class The menu HTML class. |
|
| 271 | + */ |
|
| 272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 273 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 274 | + $items .= '<li class="' . $li_class . '"> |
|
| 275 | 275 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
| 276 | 276 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 277 | 277 | </a> |
| 278 | 278 | </li>'; |
| 279 | - } |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - } |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - $items .= ' </ul> '; |
|
| 288 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 289 | - $items .= '</li>'; |
|
| 287 | + $items .= ' </ul> '; |
|
| 288 | + $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 289 | + $items .= '</li>'; |
|
| 290 | 290 | |
| 291 | - } |
|
| 292 | - } |
|
| 293 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 294 | - return $items; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 294 | + return $items; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | function geodir_pagemenu_items($menu, $args) |
| 311 | 311 | {
|
| 312 | - $locations = get_nav_menu_locations(); |
|
| 313 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 314 | - $geodir_theme_location_nav = array(); |
|
| 315 | - if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 317 | - $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 318 | - update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 319 | - } |
|
| 320 | - //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 312 | + $locations = get_nav_menu_locations(); |
|
| 313 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 314 | + $geodir_theme_location_nav = array(); |
|
| 315 | + if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 317 | + $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 318 | + update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 319 | + } |
|
| 320 | + //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 322 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 322 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 324 | 324 | |
| 325 | - return $menu; |
|
| 325 | + return $menu; |
|
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | |
@@ -342,18 +342,18 @@ discard block |
||
| 342 | 342 | function geodir_menu_items($items, $args) |
| 343 | 343 | {
|
| 344 | 344 | |
| 345 | - $location = $args->theme_location; |
|
| 345 | + $location = $args->theme_location; |
|
| 346 | 346 | |
| 347 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 347 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 348 | 348 | |
| 349 | - if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 349 | + if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 350 | 350 | |
| 351 | - $items = $items . geodir_add_nav_menu_items(); |
|
| 352 | - return $items; |
|
| 351 | + $items = $items . geodir_add_nav_menu_items(); |
|
| 352 | + return $items; |
|
| 353 | 353 | |
| 354 | - } else {
|
|
| 355 | - return $items; |
|
| 356 | - } |
|
| 354 | + } else {
|
|
| 355 | + return $items; |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -368,25 +368,25 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | function geodir_get_category_all_array() |
| 370 | 370 | {
|
| 371 | - global $wpdb; |
|
| 372 | - $return_array = array(); |
|
| 373 | - |
|
| 374 | - $taxonomies = geodir_get_taxonomies(); |
|
| 375 | - $taxonomies = implode("','", $taxonomies);
|
|
| 376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 377 | - |
|
| 378 | - $pn_categories = $wpdb->get_results( |
|
| 379 | - $wpdb->prepare( |
|
| 380 | - "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 381 | - array($wpdb->terms . term_id) |
|
| 382 | - ) |
|
| 383 | - ); |
|
| 384 | - |
|
| 385 | - foreach ($pn_categories as $pn_categories_obj) {
|
|
| 386 | - $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 387 | - "title" => $pn_categories_obj->name,); |
|
| 388 | - } |
|
| 389 | - return $return_array; |
|
| 371 | + global $wpdb; |
|
| 372 | + $return_array = array(); |
|
| 373 | + |
|
| 374 | + $taxonomies = geodir_get_taxonomies(); |
|
| 375 | + $taxonomies = implode("','", $taxonomies);
|
|
| 376 | + $taxonomies = "'" . $taxonomies . "'"; |
|
| 377 | + |
|
| 378 | + $pn_categories = $wpdb->get_results( |
|
| 379 | + $wpdb->prepare( |
|
| 380 | + "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 381 | + array($wpdb->terms . term_id) |
|
| 382 | + ) |
|
| 383 | + ); |
|
| 384 | + |
|
| 385 | + foreach ($pn_categories as $pn_categories_obj) {
|
|
| 386 | + $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 387 | + "title" => $pn_categories_obj->name,); |
|
| 388 | + } |
|
| 389 | + return $return_array; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | |
@@ -401,41 +401,41 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | function geodir_get_current_posttype() |
| 403 | 403 | {
|
| 404 | - global $wp_query, $geodir_post_type; |
|
| 404 | + global $wp_query, $geodir_post_type; |
|
| 405 | 405 | |
| 406 | - $geodir_post_type = get_query_var('post_type');
|
|
| 406 | + $geodir_post_type = get_query_var('post_type');
|
|
| 407 | 407 | |
| 408 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 409 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 411 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 412 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 413 | - } |
|
| 408 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 409 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 410 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 411 | + elseif (isset($_REQUEST['listing_type'])) |
|
| 412 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 416 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 415 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 416 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 417 | 417 | |
| 418 | - if (is_tax()) |
|
| 419 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 418 | + if (is_tax()) |
|
| 419 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 420 | 420 | |
| 421 | 421 | |
| 422 | - $all_postypes = geodir_get_posttypes(); |
|
| 423 | - $all_postypes = stripslashes_deep($all_postypes); |
|
| 422 | + $all_postypes = geodir_get_posttypes(); |
|
| 423 | + $all_postypes = stripslashes_deep($all_postypes); |
|
| 424 | 424 | |
| 425 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 426 | - $geodir_post_type = ''; |
|
| 425 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 426 | + $geodir_post_type = ''; |
|
| 427 | 427 | |
| 428 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 429 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 430 | - } |
|
| 428 | + if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 429 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Filter the default CPT return. |
|
| 435 | - * |
|
| 436 | - * @since 1.6.9 |
|
| 437 | - */ |
|
| 438 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 433 | + /** |
|
| 434 | + * Filter the default CPT return. |
|
| 435 | + * |
|
| 436 | + * @since 1.6.9 |
|
| 437 | + */ |
|
| 438 | + return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -449,22 +449,22 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | function geodir_get_default_posttype() |
| 451 | 451 | {
|
| 452 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 453 | - |
|
| 454 | - $stype = false; |
|
| 455 | - foreach ( $post_types as $post_type => $info ) {
|
|
| 456 | - global $wpdb; |
|
| 457 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 458 | - if ( $has_posts ) {
|
|
| 459 | - $stype = $post_type; break; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - if(!$stype){
|
|
| 464 | - $stype = 'gd_place'; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - return $stype; |
|
| 452 | + $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 453 | + |
|
| 454 | + $stype = false; |
|
| 455 | + foreach ( $post_types as $post_type => $info ) {
|
|
| 456 | + global $wpdb; |
|
| 457 | + $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 458 | + if ( $has_posts ) {
|
|
| 459 | + $stype = $post_type; break; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + if(!$stype){
|
|
| 464 | + $stype = 'gd_place'; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + return $stype; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -478,21 +478,21 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | function geodir_get_posttypes($output = 'names') |
| 480 | 480 | {
|
| 481 | - $post_types = array(); |
|
| 482 | - $post_types = get_option('geodir_post_types');
|
|
| 483 | - $post_types = stripslashes_deep($post_types); |
|
| 484 | - if (!empty($post_types)) {
|
|
| 485 | - switch ($output): |
|
| 486 | - case 'object': |
|
| 487 | - case 'Object': |
|
| 488 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 489 | - break; |
|
| 490 | - case 'array': |
|
| 491 | - case 'Array': |
|
| 492 | - $post_types = (array)$post_types; |
|
| 493 | - break; |
|
| 481 | + $post_types = array(); |
|
| 482 | + $post_types = get_option('geodir_post_types');
|
|
| 483 | + $post_types = stripslashes_deep($post_types); |
|
| 484 | + if (!empty($post_types)) {
|
|
| 485 | + switch ($output): |
|
| 486 | + case 'object': |
|
| 487 | + case 'Object': |
|
| 488 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 489 | + break; |
|
| 490 | + case 'array': |
|
| 491 | + case 'Array': |
|
| 492 | + $post_types = (array)$post_types; |
|
| 493 | + break; |
|
| 494 | 494 | case 'options': |
| 495 | - $post_types = (array)$post_types; |
|
| 495 | + $post_types = (array)$post_types; |
|
| 496 | 496 | |
| 497 | 497 | $options = array(); |
| 498 | 498 | if (!empty($post_types)) {
|
@@ -501,17 +501,17 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | $post_types = $options; |
| 504 | - break; |
|
| 505 | - default: |
|
| 506 | - $post_types = array_keys($post_types); |
|
| 507 | - break; |
|
| 508 | - endswitch; |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - if (!empty($post_types)) |
|
| 512 | - return $post_types; |
|
| 513 | - else |
|
| 514 | - return array(); |
|
| 504 | + break; |
|
| 505 | + default: |
|
| 506 | + $post_types = array_keys($post_types); |
|
| 507 | + break; |
|
| 508 | + endswitch; |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + if (!empty($post_types)) |
|
| 512 | + return $post_types; |
|
| 513 | + else |
|
| 514 | + return array(); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -524,108 +524,108 @@ discard block |
||
| 524 | 524 | */ |
| 525 | 525 | function geodir_get_posttype_info($post_type = '') |
| 526 | 526 | {
|
| 527 | - $post_types = array(); |
|
| 528 | - $post_types = get_option('geodir_post_types');
|
|
| 529 | - $post_types = stripslashes_deep($post_types); |
|
| 530 | - if (!empty($post_types) && $post_type != '') {
|
|
| 531 | - return $post_types[$post_type]; |
|
| 532 | - } else |
|
| 533 | - return false; |
|
| 527 | + $post_types = array(); |
|
| 528 | + $post_types = get_option('geodir_post_types');
|
|
| 529 | + $post_types = stripslashes_deep($post_types); |
|
| 530 | + if (!empty($post_types) && $post_type != '') {
|
|
| 531 | + return $post_types[$post_type]; |
|
| 532 | + } else |
|
| 533 | + return false; |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | if (!function_exists('geodir_get_taxonomies')) {
|
| 537 | - /** |
|
| 538 | - * Get all custom taxonomies. |
|
| 539 | - * |
|
| 540 | - * @since 1.0.0 |
|
| 541 | - * @package GeoDirectory |
|
| 542 | - * @param string $post_type The post type. |
|
| 543 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 544 | - * @return array|bool Taxonomies on success. false on failure. |
|
| 545 | - */ |
|
| 546 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 547 | - {
|
|
| 537 | + /** |
|
| 538 | + * Get all custom taxonomies. |
|
| 539 | + * |
|
| 540 | + * @since 1.0.0 |
|
| 541 | + * @package GeoDirectory |
|
| 542 | + * @param string $post_type The post type. |
|
| 543 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 544 | + * @return array|bool Taxonomies on success. false on failure. |
|
| 545 | + */ |
|
| 546 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 547 | + {
|
|
| 548 | 548 | |
| 549 | - $taxonomies = array(); |
|
| 550 | - $gd_taxonomies = array(); |
|
| 549 | + $taxonomies = array(); |
|
| 550 | + $gd_taxonomies = array(); |
|
| 551 | 551 | |
| 552 | - if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 552 | + if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 553 | 553 | |
| 554 | 554 | |
| 555 | - $gd_taxonomies = array_keys($taxonomies); |
|
| 555 | + $gd_taxonomies = array_keys($taxonomies); |
|
| 556 | 556 | |
| 557 | 557 | |
| 558 | - if ($post_type != '') |
|
| 559 | - $gd_taxonomies = array(); |
|
| 558 | + if ($post_type != '') |
|
| 559 | + $gd_taxonomies = array(); |
|
| 560 | 560 | |
| 561 | - $i = 0; |
|
| 562 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 561 | + $i = 0; |
|
| 562 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 563 | 563 | |
| 564 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 565 | - $gd_taxonomies[] = $taxonomy; |
|
| 564 | + if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 565 | + $gd_taxonomies[] = $taxonomy; |
|
| 566 | 566 | |
| 567 | - if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 568 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 569 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 570 | - } |
|
| 567 | + if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 568 | + if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 569 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Filter the taxonomies. |
|
| 579 | - * |
|
| 580 | - * @since 1.0.0 |
|
| 581 | - * @param array $gd_taxonomies The taxonomy array. |
|
| 582 | - */ |
|
| 583 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 584 | - |
|
| 585 | - if (!empty($taxonomies)) {
|
|
| 586 | - return $taxonomies; |
|
| 587 | - } else {
|
|
| 588 | - return false; |
|
| 589 | - } |
|
| 590 | - } |
|
| 574 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Filter the taxonomies. |
|
| 579 | + * |
|
| 580 | + * @since 1.0.0 |
|
| 581 | + * @param array $gd_taxonomies The taxonomy array. |
|
| 582 | + */ |
|
| 583 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 584 | + |
|
| 585 | + if (!empty($taxonomies)) {
|
|
| 586 | + return $taxonomies; |
|
| 587 | + } else {
|
|
| 588 | + return false; |
|
| 589 | + } |
|
| 590 | + } |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | if (!function_exists(' geodir_get_categories_dl')) {
|
| 594 | - /** |
|
| 595 | - * Get categories dropdown HTML. |
|
| 596 | - * |
|
| 597 | - * @since 1.0.0 |
|
| 598 | - * @package GeoDirectory |
|
| 599 | - * @param string $post_type The post type. |
|
| 600 | - * @param string $selected The selected value. |
|
| 601 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 602 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 603 | - * @return void|string Dropdown HTML. |
|
| 604 | - */ |
|
| 605 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 606 | - {
|
|
| 607 | - |
|
| 608 | - $html = ''; |
|
| 609 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 610 | - |
|
| 611 | - $categories = get_terms($taxonomies); |
|
| 612 | - |
|
| 613 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 614 | - |
|
| 615 | - foreach ($categories as $category_obj) {
|
|
| 616 | - $select_opt = ''; |
|
| 617 | - if ($selected == $category_obj->term_id) {
|
|
| 618 | - $select_opt = 'selected="selected"'; |
|
| 619 | - } |
|
| 620 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 621 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - if ($echo) |
|
| 625 | - echo $html; |
|
| 626 | - else |
|
| 627 | - return $html; |
|
| 628 | - } |
|
| 594 | + /** |
|
| 595 | + * Get categories dropdown HTML. |
|
| 596 | + * |
|
| 597 | + * @since 1.0.0 |
|
| 598 | + * @package GeoDirectory |
|
| 599 | + * @param string $post_type The post type. |
|
| 600 | + * @param string $selected The selected value. |
|
| 601 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 602 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 603 | + * @return void|string Dropdown HTML. |
|
| 604 | + */ |
|
| 605 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 606 | + {
|
|
| 607 | + |
|
| 608 | + $html = ''; |
|
| 609 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 610 | + |
|
| 611 | + $categories = get_terms($taxonomies); |
|
| 612 | + |
|
| 613 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 614 | + |
|
| 615 | + foreach ($categories as $category_obj) {
|
|
| 616 | + $select_opt = ''; |
|
| 617 | + if ($selected == $category_obj->term_id) {
|
|
| 618 | + $select_opt = 'selected="selected"'; |
|
| 619 | + } |
|
| 620 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 621 | + . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + if ($echo) |
|
| 625 | + echo $html; |
|
| 626 | + else |
|
| 627 | + return $html; |
|
| 628 | + } |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | |
@@ -640,28 +640,28 @@ discard block |
||
| 640 | 640 | function geodir_get_listing_slug($object_type = '') |
| 641 | 641 | {
|
| 642 | 642 | |
| 643 | - $listing_slug = ''; |
|
| 643 | + $listing_slug = ''; |
|
| 644 | 644 | |
| 645 | - $post_types = get_option('geodir_post_types');
|
|
| 646 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 645 | + $post_types = get_option('geodir_post_types');
|
|
| 646 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 647 | 647 | |
| 648 | 648 | |
| 649 | - if ($object_type != '') {
|
|
| 650 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 649 | + if ($object_type != '') {
|
|
| 650 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 651 | 651 | |
| 652 | - $object_info = $post_types[$object_type]; |
|
| 653 | - $listing_slug = $object_info['listing_slug']; |
|
| 654 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 655 | - $object_info = $taxonomies[$object_type]; |
|
| 656 | - $listing_slug = $object_info['listing_slug']; |
|
| 657 | - } |
|
| 652 | + $object_info = $post_types[$object_type]; |
|
| 653 | + $listing_slug = $object_info['listing_slug']; |
|
| 654 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 655 | + $object_info = $taxonomies[$object_type]; |
|
| 656 | + $listing_slug = $object_info['listing_slug']; |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - } |
|
| 659 | + } |
|
| 660 | 660 | |
| 661 | - if (!empty($listing_slug)) |
|
| 662 | - return $listing_slug; |
|
| 663 | - else |
|
| 664 | - return false; |
|
| 661 | + if (!empty($listing_slug)) |
|
| 662 | + return $listing_slug; |
|
| 663 | + else |
|
| 664 | + return false; |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | |
@@ -676,212 +676,212 @@ discard block |
||
| 676 | 676 | */ |
| 677 | 677 | function geodir_get_taxonomy_posttype($taxonomy = '') |
| 678 | 678 | {
|
| 679 | - global $wp_query; |
|
| 680 | - |
|
| 681 | - $post_type = array(); |
|
| 682 | - $taxonomies = array(); |
|
| 683 | - |
|
| 684 | - if (!empty($taxonomy)) {
|
|
| 685 | - $taxonomies[] = $taxonomy; |
|
| 686 | - } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 687 | - $tax_arr = $wp_query->tax_query->queries; |
|
| 688 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 689 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 690 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - if (!empty($taxonomies)) {
|
|
| 694 | - foreach (geodir_get_posttypes() as $pt) {
|
|
| 695 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 696 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 697 | - $post_type[] = $pt; |
|
| 698 | - } |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - if (!empty($post_type)) |
|
| 702 | - return $post_type[0]; |
|
| 703 | - else |
|
| 704 | - return false; |
|
| 679 | + global $wp_query; |
|
| 680 | + |
|
| 681 | + $post_type = array(); |
|
| 682 | + $taxonomies = array(); |
|
| 683 | + |
|
| 684 | + if (!empty($taxonomy)) {
|
|
| 685 | + $taxonomies[] = $taxonomy; |
|
| 686 | + } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 687 | + $tax_arr = $wp_query->tax_query->queries; |
|
| 688 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 689 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 690 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + if (!empty($taxonomies)) {
|
|
| 694 | + foreach (geodir_get_posttypes() as $pt) {
|
|
| 695 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 696 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 697 | + $post_type[] = $pt; |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + if (!empty($post_type)) |
|
| 702 | + return $post_type[0]; |
|
| 703 | + else |
|
| 704 | + return false; |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 708 | - /** |
|
| 709 | - * Custom taxonomy walker function. |
|
| 710 | - * |
|
| 711 | - * @since 1.0.0 |
|
| 712 | - * @package GeoDirectory |
|
| 713 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 714 | - * @param int $cat_parent The parent term ID. |
|
| 715 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 716 | - * @param int $pading CSS padding in pixels. |
|
| 717 | - * @return string|void taxonomy HTML. |
|
| 718 | - */ |
|
| 719 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 720 | - {
|
|
| 721 | - global $cat_display, $post_cat, $exclude_cats; |
|
| 722 | - |
|
| 723 | - $search_terms = trim($post_cat, ","); |
|
| 724 | - |
|
| 725 | - $search_terms = explode(",", $search_terms);
|
|
| 726 | - |
|
| 727 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 728 | - |
|
| 729 | - $display = ''; |
|
| 730 | - $onchange = ''; |
|
| 731 | - $term_check = ''; |
|
| 732 | - $main_list_class = ''; |
|
| 733 | - $out = ''; |
|
| 734 | - //If there are terms, start displaying |
|
| 735 | - if (count($cat_terms) > 0) {
|
|
| 736 | - //Displaying as a list |
|
| 737 | - $p = $pading * 20; |
|
| 738 | - $pading++; |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 742 | - if ($cat_parent == 0) {
|
|
| 743 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 744 | - $main_list_class = 'class="main_list_selecter"'; |
|
| 745 | - } else {
|
|
| 746 | - //$display = 'display:none'; |
|
| 747 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
| 748 | - } |
|
| 749 | - } |
|
| 708 | + /** |
|
| 709 | + * Custom taxonomy walker function. |
|
| 710 | + * |
|
| 711 | + * @since 1.0.0 |
|
| 712 | + * @package GeoDirectory |
|
| 713 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 714 | + * @param int $cat_parent The parent term ID. |
|
| 715 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 716 | + * @param int $pading CSS padding in pixels. |
|
| 717 | + * @return string|void taxonomy HTML. |
|
| 718 | + */ |
|
| 719 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 720 | + {
|
|
| 721 | + global $cat_display, $post_cat, $exclude_cats; |
|
| 722 | + |
|
| 723 | + $search_terms = trim($post_cat, ","); |
|
| 724 | + |
|
| 725 | + $search_terms = explode(",", $search_terms);
|
|
| 726 | + |
|
| 727 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 728 | + |
|
| 729 | + $display = ''; |
|
| 730 | + $onchange = ''; |
|
| 731 | + $term_check = ''; |
|
| 732 | + $main_list_class = ''; |
|
| 733 | + $out = ''; |
|
| 734 | + //If there are terms, start displaying |
|
| 735 | + if (count($cat_terms) > 0) {
|
|
| 736 | + //Displaying as a list |
|
| 737 | + $p = $pading * 20; |
|
| 738 | + $pading++; |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 742 | + if ($cat_parent == 0) {
|
|
| 743 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 744 | + $main_list_class = 'class="main_list_selecter"'; |
|
| 745 | + } else {
|
|
| 746 | + //$display = 'display:none'; |
|
| 747 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 752 | - $p = 0; |
|
| 753 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 754 | - } |
|
| 751 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 752 | + $p = 0; |
|
| 753 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - foreach ($cat_terms as $cat_term) {
|
|
| 756 | + foreach ($cat_terms as $cat_term) {
|
|
| 757 | 757 | |
| 758 | - $checked = ''; |
|
| 758 | + $checked = ''; |
|
| 759 | 759 | |
| 760 | - if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 761 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 762 | - $checked = 'selected="selected"'; |
|
| 763 | - else |
|
| 764 | - $checked = 'checked="checked"'; |
|
| 765 | - } |
|
| 760 | + if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 761 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 762 | + $checked = 'selected="selected"'; |
|
| 763 | + else |
|
| 764 | + $checked = 'checked="checked"'; |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - if ($cat_display == 'radio') |
|
| 768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 769 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 767 | + if ($cat_display == 'radio') |
|
| 768 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 769 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 770 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 771 | 771 | |
| 772 | - else {
|
|
| 773 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 774 | - } |
|
| 772 | + else {
|
|
| 773 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | - // Call recurson to print sub cats |
|
| 777 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 776 | + // Call recurson to print sub cats |
|
| 777 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 778 | 778 | |
| 779 | - } |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 782 | - $out .= '</div>'; |
|
| 781 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 782 | + $out .= '</div>'; |
|
| 783 | 783 | |
| 784 | - return $out; |
|
| 785 | - } |
|
| 786 | - return; |
|
| 787 | - } |
|
| 784 | + return $out; |
|
| 785 | + } |
|
| 786 | + return; |
|
| 787 | + } |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | if (!function_exists('geodir_custom_taxonomy_walker2')) {
|
| 791 | - /** |
|
| 792 | - * Custom taxonomy walker function. |
|
| 793 | - * |
|
| 794 | - * @since 1.0.0 |
|
| 795 | - * @package GeoDirectory |
|
| 796 | - * @global object $post WordPress Post object. |
|
| 797 | - * @global object $gd_session GeoDirectory Session object. |
|
| 798 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 799 | - * @param string $cat_limit Number of categories to display. |
|
| 800 | - */ |
|
| 801 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 802 | - {
|
|
| 803 | - $post_category = ''; |
|
| 804 | - $post_category_str = ''; |
|
| 805 | - global $exclude_cats, $gd_session; |
|
| 806 | - |
|
| 807 | - $cat_exclude = ''; |
|
| 808 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 809 | - $cat_exclude = serialize($exclude_cats); |
|
| 810 | - |
|
| 811 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 812 | - $post = (object)$gd_session->get('listing');
|
|
| 813 | - |
|
| 814 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 815 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 816 | - |
|
| 817 | - $post_categories = $post->post_category_str; |
|
| 818 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 819 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 820 | - |
|
| 821 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 822 | - global $post; |
|
| 823 | - |
|
| 824 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 825 | - if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 826 | - $post_category = $post->{$cat_taxonomy};
|
|
| 827 | - } |
|
| 791 | + /** |
|
| 792 | + * Custom taxonomy walker function. |
|
| 793 | + * |
|
| 794 | + * @since 1.0.0 |
|
| 795 | + * @package GeoDirectory |
|
| 796 | + * @global object $post WordPress Post object. |
|
| 797 | + * @global object $gd_session GeoDirectory Session object. |
|
| 798 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 799 | + * @param string $cat_limit Number of categories to display. |
|
| 800 | + */ |
|
| 801 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 802 | + {
|
|
| 803 | + $post_category = ''; |
|
| 804 | + $post_category_str = ''; |
|
| 805 | + global $exclude_cats, $gd_session; |
|
| 806 | + |
|
| 807 | + $cat_exclude = ''; |
|
| 808 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 809 | + $cat_exclude = serialize($exclude_cats); |
|
| 810 | + |
|
| 811 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 812 | + $post = (object)$gd_session->get('listing');
|
|
| 813 | + |
|
| 814 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 815 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 816 | + |
|
| 817 | + $post_categories = $post->post_category_str; |
|
| 818 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 819 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 820 | + |
|
| 821 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 822 | + global $post; |
|
| 823 | + |
|
| 824 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 825 | + if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 826 | + $post_category = $post->{$cat_taxonomy};
|
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 829 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 830 | 830 | |
| 831 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 832 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 833 | - if (is_numeric($cat_part)) {
|
|
| 834 | - $cat_part_arr[] = $cat_part; |
|
| 835 | - } |
|
| 836 | - } |
|
| 837 | - if (is_array($cat_part_arr)) {
|
|
| 838 | - $post_category = implode(',', $cat_part_arr);
|
|
| 839 | - } |
|
| 840 | - } |
|
| 831 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 832 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 833 | + if (is_numeric($cat_part)) {
|
|
| 834 | + $cat_part_arr[] = $cat_part; |
|
| 835 | + } |
|
| 836 | + } |
|
| 837 | + if (is_array($cat_part_arr)) {
|
|
| 838 | + $post_category = implode(',', $cat_part_arr);
|
|
| 839 | + } |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - if (!empty($post_category)) {
|
|
| 843 | - $cat1 = array_filter(explode(',', $post_category));
|
|
| 844 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 842 | + if (!empty($post_category)) {
|
|
| 843 | + $cat1 = array_filter(explode(',', $post_category));
|
|
| 844 | + $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 845 | 845 | |
| 846 | - } |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 848 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 849 | 849 | |
| 850 | - $post_category_upd = explode(',', $post_category);
|
|
| 851 | - $post_category_change = ''; |
|
| 852 | - foreach ($post_category_upd as $cat) {
|
|
| 850 | + $post_category_upd = explode(',', $post_category);
|
|
| 851 | + $post_category_change = ''; |
|
| 852 | + foreach ($post_category_upd as $cat) {
|
|
| 853 | 853 | |
| 854 | - if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 855 | - $post_category_change .= ',' . $cat; |
|
| 856 | - } |
|
| 857 | - } |
|
| 858 | - $post_category = $post_category_change; |
|
| 859 | - } |
|
| 854 | + if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 855 | + $post_category_change .= ',' . $cat; |
|
| 856 | + } |
|
| 857 | + } |
|
| 858 | + $post_category = $post_category_change; |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | 861 | |
| 862 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 863 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 864 | - } |
|
| 865 | - } |
|
| 862 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 863 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 864 | + } |
|
| 865 | + } |
|
| 866 | 866 | |
| 867 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 867 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 868 | 868 | |
| 869 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 869 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 870 | 870 | |
| 871 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 871 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | - ?> |
|
| 874 | + ?> |
|
| 875 | 875 | <div class="cat_sublist"> |
| 876 | 876 | <?php |
| 877 | 877 | |
| 878 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 878 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 879 | 879 | |
| 880 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 880 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 881 | 881 | |
| 882 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 883 | - } |
|
| 884 | - ?> |
|
| 882 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 883 | + } |
|
| 884 | + ?> |
|
| 885 | 885 | </div> |
| 886 | 886 | <script type="text/javascript"> |
| 887 | 887 | |
@@ -1004,22 +1004,22 @@ discard block |
||
| 1004 | 1004 | |
| 1005 | 1005 | </script> |
| 1006 | 1006 | <?php |
| 1007 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1008 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1009 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1010 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1011 | - $style = "display:none;"; |
|
| 1012 | - } |
|
| 1013 | - ?> |
|
| 1007 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1008 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1009 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1010 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1011 | + $style = "display:none;"; |
|
| 1012 | + } |
|
| 1013 | + ?> |
|
| 1014 | 1014 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 1015 | - echo $style; |
|
| 1016 | - }?> "> |
|
| 1015 | + echo $style; |
|
| 1016 | + }?> "> |
|
| 1017 | 1017 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
| 1018 | - ?> |
|
| 1018 | + ?> |
|
| 1019 | 1019 | </div> |
| 1020 | 1020 | <?php |
| 1021 | 1021 | |
| 1022 | - } |
|
| 1022 | + } |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /** |
@@ -1036,23 +1036,23 @@ discard block |
||
| 1036 | 1036 | */ |
| 1037 | 1037 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
| 1038 | 1038 | {
|
| 1039 | - global $exclude_cats; |
|
| 1039 | + global $exclude_cats; |
|
| 1040 | 1040 | |
| 1041 | - if ($exclude != '') {
|
|
| 1042 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1041 | + if ($exclude != '') {
|
|
| 1042 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1043 | 1043 | |
| 1044 | - if(is_array( $exclude_cats)){
|
|
| 1045 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1046 | - }else{
|
|
| 1047 | - $exclude_cats = intval($exclude_cats); |
|
| 1048 | - } |
|
| 1044 | + if(is_array( $exclude_cats)){
|
|
| 1045 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1046 | + }else{
|
|
| 1047 | + $exclude_cats = intval($exclude_cats); |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - } |
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1053 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1054 | - ) {
|
|
| 1055 | - ?> |
|
| 1052 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1053 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1054 | + ) {
|
|
| 1055 | + ?> |
|
| 1056 | 1056 | |
| 1057 | 1057 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1058 | 1058 | |
@@ -1081,8 +1081,8 @@ discard block |
||
| 1081 | 1081 | |
| 1082 | 1082 | <br/> |
| 1083 | 1083 | <?php |
| 1084 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1085 | - if (!empty($cat_terms)) { ?>
|
|
| 1084 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1085 | + if (!empty($cat_terms)) { ?>
|
|
| 1086 | 1086 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
|
| 1087 | 1087 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
| 1088 | 1088 | <?php } ?> |
@@ -1104,53 +1104,53 @@ discard block |
||
| 1104 | 1104 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
| 1105 | 1105 | {
|
| 1106 | 1106 | |
| 1107 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1108 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1109 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1110 | - if (is_array($post_cat_array)) {
|
|
| 1111 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1107 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1108 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1109 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1110 | + if (is_array($post_cat_array)) {
|
|
| 1111 | + $post_cat_array = array_unique( $post_cat_array ); |
|
| 1112 | 1112 | |
| 1113 | 1113 | foreach ($post_cat_array as $post_cat_html) {
|
| 1114 | 1114 | |
| 1115 | - $post_cat_info = explode(":", $post_cat_html);
|
|
| 1116 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1115 | + $post_cat_info = explode(":", $post_cat_html);
|
|
| 1116 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1117 | 1117 | |
| 1118 | - if (!empty($post_maincat_str)) {
|
|
| 1119 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1120 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1121 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1122 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1123 | - } |
|
| 1124 | - $post_sub_catid = ''; |
|
| 1125 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1126 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1127 | - } |
|
| 1118 | + if (!empty($post_maincat_str)) {
|
|
| 1119 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1120 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1121 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1122 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1123 | + } |
|
| 1124 | + $post_sub_catid = ''; |
|
| 1125 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1126 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1127 | + } |
|
| 1128 | 1128 | |
| 1129 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1129 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1130 | 1130 | |
| 1131 | - } |
|
| 1132 | - } else {
|
|
| 1131 | + } |
|
| 1132 | + } else {
|
|
| 1133 | 1133 | |
| 1134 | - $post_cat_info = explode(":", $post_cat_str);
|
|
| 1135 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1134 | + $post_cat_info = explode(":", $post_cat_str);
|
|
| 1135 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1136 | 1136 | |
| 1137 | - $post_sub_catid = ''; |
|
| 1137 | + $post_sub_catid = ''; |
|
| 1138 | 1138 | |
| 1139 | - if (!empty($post_maincat_str)) {
|
|
| 1140 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1141 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1142 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1143 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1144 | - } |
|
| 1139 | + if (!empty($post_maincat_str)) {
|
|
| 1140 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1141 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1142 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1143 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1147 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1148 | - } |
|
| 1146 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1147 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1148 | + } |
|
| 1149 | 1149 | |
| 1150 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1150 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1151 | 1151 | |
| 1152 | - } |
|
| 1153 | - } |
|
| 1152 | + } |
|
| 1153 | + } |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
@@ -1164,35 +1164,35 @@ discard block |
||
| 1164 | 1164 | */ |
| 1165 | 1165 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
| 1166 | 1166 | {
|
| 1167 | - global $exclude_cats; |
|
| 1167 | + global $exclude_cats; |
|
| 1168 | 1168 | |
| 1169 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1169 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1170 | 1170 | |
| 1171 | - if (!empty($cat_terms)) {
|
|
| 1172 | - $onchange = ''; |
|
| 1173 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1171 | + if (!empty($cat_terms)) {
|
|
| 1172 | + $onchange = ''; |
|
| 1173 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1174 | 1174 | |
| 1175 | - $option_selected = ''; |
|
| 1176 | - if (!$selected) |
|
| 1177 | - $option_slected = ' selected="selected" '; |
|
| 1175 | + $option_selected = ''; |
|
| 1176 | + if (!$selected) |
|
| 1177 | + $option_slected = ' selected="selected" '; |
|
| 1178 | 1178 | |
| 1179 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1179 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1180 | 1180 | |
| 1181 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1181 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1182 | 1182 | |
| 1183 | - foreach ($cat_terms as $cat_term) {
|
|
| 1184 | - $option_selected = ''; |
|
| 1185 | - if ($selected == $cat_term->term_id) |
|
| 1186 | - $option_selected = ' selected="selected" '; |
|
| 1183 | + foreach ($cat_terms as $cat_term) {
|
|
| 1184 | + $option_selected = ''; |
|
| 1185 | + if ($selected == $cat_term->term_id) |
|
| 1186 | + $option_selected = ' selected="selected" '; |
|
| 1187 | 1187 | |
| 1188 | - // Count child terms |
|
| 1189 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1190 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1188 | + // Count child terms |
|
| 1189 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1190 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1191 | 1191 | |
| 1192 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1193 | - } |
|
| 1194 | - echo '</select>'; |
|
| 1195 | - } |
|
| 1192 | + echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1193 | + } |
|
| 1194 | + echo '</select>'; |
|
| 1195 | + } |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | /** |
@@ -1208,28 +1208,28 @@ discard block |
||
| 1208 | 1208 | */ |
| 1209 | 1209 | function geodir_custom_update_messages($messages) |
| 1210 | 1210 | {
|
| 1211 | - global $post, $post_ID; |
|
| 1212 | - |
|
| 1213 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1214 | - |
|
| 1215 | - foreach ($post_types as $post_type => $post_object) {
|
|
| 1216 | - |
|
| 1217 | - $messages[$post_type] = array( |
|
| 1218 | - 0 => '', // Unused. Messages start at index 1. |
|
| 1219 | - 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1220 | - 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1221 | - 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1222 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1223 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1224 | - 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1225 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1226 | - 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1227 | - 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1228 | - 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1229 | - ); |
|
| 1230 | - } |
|
| 1231 | - |
|
| 1232 | - return $messages; |
|
| 1211 | + global $post, $post_ID; |
|
| 1212 | + |
|
| 1213 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1214 | + |
|
| 1215 | + foreach ($post_types as $post_type => $post_object) {
|
|
| 1216 | + |
|
| 1217 | + $messages[$post_type] = array( |
|
| 1218 | + 0 => '', // Unused. Messages start at index 1. |
|
| 1219 | + 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1220 | + 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1221 | + 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1222 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1223 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1224 | + 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1225 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1226 | + 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1227 | + 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1228 | + 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1229 | + ); |
|
| 1230 | + } |
|
| 1231 | + |
|
| 1232 | + return $messages; |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | |
@@ -1244,182 +1244,182 @@ discard block |
||
| 1244 | 1244 | function geodir_register_defaults() |
| 1245 | 1245 | {
|
| 1246 | 1246 | |
| 1247 | - global $wpdb; |
|
| 1248 | - |
|
| 1249 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1250 | - |
|
| 1251 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1252 | - $listing_slug = 'places'; |
|
| 1253 | - |
|
| 1254 | - /** |
|
| 1255 | - * Taxonomies |
|
| 1256 | - **/ |
|
| 1257 | - //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1258 | - {
|
|
| 1259 | - |
|
| 1260 | - $gd_placetags = array(); |
|
| 1261 | - $gd_placetags['object_type'] = 'gd_place'; |
|
| 1262 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1263 | - $gd_placetags['args'] = array( |
|
| 1264 | - 'public' => true, |
|
| 1265 | - 'hierarchical' => false, |
|
| 1266 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1267 | - 'query_var' => true, |
|
| 1268 | - |
|
| 1269 | - 'labels' => array( |
|
| 1270 | - 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1271 | - 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1272 | - 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1273 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1274 | - 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1275 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1276 | - 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1277 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1278 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1279 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1280 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1281 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1282 | - ), |
|
| 1283 | - ); |
|
| 1284 | - |
|
| 1285 | - |
|
| 1286 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1287 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1288 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1289 | - |
|
| 1290 | - |
|
| 1291 | - // Update post types and delete tmp options |
|
| 1292 | - flush_rewrite_rules(); |
|
| 1293 | - |
|
| 1294 | - } |
|
| 1295 | - |
|
| 1296 | - //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1297 | - {
|
|
| 1298 | - |
|
| 1299 | - $gd_placecategory = array(); |
|
| 1300 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1301 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1302 | - $gd_placecategory['args'] = array( |
|
| 1303 | - 'public' => true, |
|
| 1304 | - 'hierarchical' => true, |
|
| 1305 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1306 | - 'query_var' => true, |
|
| 1307 | - 'labels' => array( |
|
| 1308 | - 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1309 | - 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1310 | - 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1311 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1312 | - 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1313 | - 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1314 | - 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1315 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1316 | - 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1317 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1318 | - ), |
|
| 1319 | - ); |
|
| 1320 | - |
|
| 1321 | - |
|
| 1322 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1323 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1324 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1325 | - |
|
| 1326 | - |
|
| 1327 | - flush_rewrite_rules(); |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - /** |
|
| 1331 | - * Post Types |
|
| 1332 | - **/ |
|
| 1333 | - |
|
| 1334 | - //if ( ! post_type_exists('gd_place') )
|
|
| 1335 | - {
|
|
| 1336 | - |
|
| 1337 | - $labels = array( |
|
| 1338 | - 'name' => __('Places', 'geodirectory'),
|
|
| 1339 | - 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1340 | - 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1341 | - 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1342 | - 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1343 | - 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1344 | - 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1345 | - 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1346 | - 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1347 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1348 | - |
|
| 1349 | - $place_default = array( |
|
| 1350 | - 'labels' => $labels, |
|
| 1351 | - 'can_export' => true, |
|
| 1352 | - 'capability_type' => 'post', |
|
| 1353 | - 'description' => 'Place post type.', |
|
| 1354 | - 'has_archive' => $listing_slug, |
|
| 1355 | - 'hierarchical' => false, |
|
| 1356 | - 'map_meta_cap' => true, |
|
| 1357 | - 'menu_icon' => $menu_icon, |
|
| 1358 | - 'public' => true, |
|
| 1359 | - 'query_var' => true, |
|
| 1360 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1361 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1362 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1363 | - |
|
| 1364 | - //Update custom post types |
|
| 1365 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 1366 | - $geodir_post_types['gd_place'] = $place_default; |
|
| 1367 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 1368 | - |
|
| 1369 | - // Update post types and delete tmp options |
|
| 1370 | - flush_rewrite_rules(); |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - |
|
| 1374 | - geodir_register_taxonomies(); |
|
| 1375 | - geodir_register_post_types(); |
|
| 1376 | - |
|
| 1377 | - //die; |
|
| 1247 | + global $wpdb; |
|
| 1248 | + |
|
| 1249 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1250 | + |
|
| 1251 | + if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1252 | + $listing_slug = 'places'; |
|
| 1253 | + |
|
| 1254 | + /** |
|
| 1255 | + * Taxonomies |
|
| 1256 | + **/ |
|
| 1257 | + //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1258 | + {
|
|
| 1259 | + |
|
| 1260 | + $gd_placetags = array(); |
|
| 1261 | + $gd_placetags['object_type'] = 'gd_place'; |
|
| 1262 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1263 | + $gd_placetags['args'] = array( |
|
| 1264 | + 'public' => true, |
|
| 1265 | + 'hierarchical' => false, |
|
| 1266 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1267 | + 'query_var' => true, |
|
| 1268 | + |
|
| 1269 | + 'labels' => array( |
|
| 1270 | + 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1271 | + 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1272 | + 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1273 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1274 | + 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1275 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1276 | + 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1277 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1278 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1279 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1280 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1281 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1282 | + ), |
|
| 1283 | + ); |
|
| 1284 | + |
|
| 1285 | + |
|
| 1286 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1287 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1288 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1289 | + |
|
| 1290 | + |
|
| 1291 | + // Update post types and delete tmp options |
|
| 1292 | + flush_rewrite_rules(); |
|
| 1293 | + |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1297 | + {
|
|
| 1298 | + |
|
| 1299 | + $gd_placecategory = array(); |
|
| 1300 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1301 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1302 | + $gd_placecategory['args'] = array( |
|
| 1303 | + 'public' => true, |
|
| 1304 | + 'hierarchical' => true, |
|
| 1305 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1306 | + 'query_var' => true, |
|
| 1307 | + 'labels' => array( |
|
| 1308 | + 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1309 | + 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1310 | + 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1311 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1312 | + 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1313 | + 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1314 | + 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1315 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1316 | + 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1317 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1318 | + ), |
|
| 1319 | + ); |
|
| 1320 | + |
|
| 1321 | + |
|
| 1322 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1323 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1324 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1325 | + |
|
| 1326 | + |
|
| 1327 | + flush_rewrite_rules(); |
|
| 1328 | + } |
|
| 1329 | + |
|
| 1330 | + /** |
|
| 1331 | + * Post Types |
|
| 1332 | + **/ |
|
| 1333 | + |
|
| 1334 | + //if ( ! post_type_exists('gd_place') )
|
|
| 1335 | + {
|
|
| 1336 | + |
|
| 1337 | + $labels = array( |
|
| 1338 | + 'name' => __('Places', 'geodirectory'),
|
|
| 1339 | + 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1340 | + 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1341 | + 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1342 | + 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1343 | + 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1344 | + 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1345 | + 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1346 | + 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1347 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1348 | + |
|
| 1349 | + $place_default = array( |
|
| 1350 | + 'labels' => $labels, |
|
| 1351 | + 'can_export' => true, |
|
| 1352 | + 'capability_type' => 'post', |
|
| 1353 | + 'description' => 'Place post type.', |
|
| 1354 | + 'has_archive' => $listing_slug, |
|
| 1355 | + 'hierarchical' => false, |
|
| 1356 | + 'map_meta_cap' => true, |
|
| 1357 | + 'menu_icon' => $menu_icon, |
|
| 1358 | + 'public' => true, |
|
| 1359 | + 'query_var' => true, |
|
| 1360 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1361 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1362 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1363 | + |
|
| 1364 | + //Update custom post types |
|
| 1365 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 1366 | + $geodir_post_types['gd_place'] = $place_default; |
|
| 1367 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 1368 | + |
|
| 1369 | + // Update post types and delete tmp options |
|
| 1370 | + flush_rewrite_rules(); |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + |
|
| 1374 | + geodir_register_taxonomies(); |
|
| 1375 | + geodir_register_post_types(); |
|
| 1376 | + |
|
| 1377 | + //die; |
|
| 1378 | 1378 | |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | $gd_wpml_get_languages = ""; |
| 1382 | 1382 | function gd_wpml_get_lang_from_url($url) {
|
| 1383 | - global $sitepress, $gd_wpml_get_languages; |
|
| 1383 | + global $sitepress, $gd_wpml_get_languages; |
|
| 1384 | 1384 | |
| 1385 | - if (geodir_is_wpml()) {
|
|
| 1386 | - return $sitepress->get_language_from_url($url); |
|
| 1387 | - } |
|
| 1385 | + if (geodir_is_wpml()) {
|
|
| 1386 | + return $sitepress->get_language_from_url($url); |
|
| 1387 | + } |
|
| 1388 | 1388 | |
| 1389 | - if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1390 | - return $_REQUEST['lang']; |
|
| 1391 | - } |
|
| 1389 | + if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1390 | + return $_REQUEST['lang']; |
|
| 1391 | + } |
|
| 1392 | 1392 | |
| 1393 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1393 | + $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1394 | 1394 | |
| 1395 | - // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1396 | - $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1395 | + // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1396 | + $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1397 | 1397 | |
| 1398 | - $url = str_replace($site_url,"",$url); |
|
| 1398 | + $url = str_replace($site_url,"",$url); |
|
| 1399 | 1399 | |
| 1400 | - $segments = explode('/', trim($url, '/'));
|
|
| 1400 | + $segments = explode('/', trim($url, '/'));
|
|
| 1401 | 1401 | |
| 1402 | - if ($gd_wpml_get_languages) {
|
|
| 1403 | - $langs = $gd_wpml_get_languages; |
|
| 1404 | - } else {
|
|
| 1405 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1406 | - } |
|
| 1402 | + if ($gd_wpml_get_languages) {
|
|
| 1403 | + $langs = $gd_wpml_get_languages; |
|
| 1404 | + } else {
|
|
| 1405 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1406 | + } |
|
| 1407 | 1407 | |
| 1408 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1409 | - return $segments[0]; |
|
| 1410 | - } |
|
| 1408 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1409 | + return $segments[0]; |
|
| 1410 | + } |
|
| 1411 | 1411 | |
| 1412 | - return false; |
|
| 1412 | + return false; |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | function gd_wpml_slug_translation_turned_on($post_type) {
|
| 1416 | 1416 | |
| 1417 | - global $sitepress; |
|
| 1418 | - $settings = $sitepress->get_settings(); |
|
| 1419 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1420 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1421 | - && isset($settings['posts_slug_translation']['on']) |
|
| 1422 | - && $settings['posts_slug_translation']['on']; |
|
| 1417 | + global $sitepress; |
|
| 1418 | + $settings = $sitepress->get_settings(); |
|
| 1419 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1420 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1421 | + && isset($settings['posts_slug_translation']['on']) |
|
| 1422 | + && $settings['posts_slug_translation']['on']; |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | |
@@ -1446,158 +1446,158 @@ discard block |
||
| 1446 | 1446 | */ |
| 1447 | 1447 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
| 1448 | 1448 | {
|
| 1449 | - //echo $post_link."<br />".$sample ; |
|
| 1449 | + //echo $post_link."<br />".$sample ; |
|
| 1450 | 1450 | |
| 1451 | 1451 | |
| 1452 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1453 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1454 | - } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1455 | - return $post_link; |
|
| 1456 | - } else {
|
|
| 1457 | - $orig_post = $post; |
|
| 1458 | - $post = $post_obj; |
|
| 1459 | - } |
|
| 1452 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1453 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1454 | + } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1455 | + return $post_link; |
|
| 1456 | + } else {
|
|
| 1457 | + $orig_post = $post; |
|
| 1458 | + $post = $post_obj; |
|
| 1459 | + } |
|
| 1460 | 1460 | |
| 1461 | - if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1461 | + if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1462 | 1462 | |
| 1463 | - // if we dont have a GD post then try to grab it |
|
| 1464 | - if(!isset($post->default_category)){
|
|
| 1465 | - $gd_post = geodir_get_post_info($post->ID); |
|
| 1466 | - if(!empty($gd_post)){
|
|
| 1467 | - $post = $gd_post; |
|
| 1468 | - } |
|
| 1469 | - } |
|
| 1463 | + // if we dont have a GD post then try to grab it |
|
| 1464 | + if(!isset($post->default_category)){
|
|
| 1465 | + $gd_post = geodir_get_post_info($post->ID); |
|
| 1466 | + if(!empty($gd_post)){
|
|
| 1467 | + $post = $gd_post; |
|
| 1468 | + } |
|
| 1469 | + } |
|
| 1470 | 1470 | |
| 1471 | 1471 | |
| 1472 | - $post_types = get_option('geodir_post_types');
|
|
| 1473 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1472 | + $post_types = get_option('geodir_post_types');
|
|
| 1473 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1474 | 1474 | |
| 1475 | - // Alter the CPT slug if WPML is set to do so |
|
| 1476 | - if(function_exists('icl_object_id')){
|
|
| 1477 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1475 | + // Alter the CPT slug if WPML is set to do so |
|
| 1476 | + if(function_exists('icl_object_id')){
|
|
| 1477 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1478 | 1478 | |
| 1479 | - $org_slug = $slug; |
|
| 1480 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1481 | - $slug, |
|
| 1482 | - 'WordPress', |
|
| 1483 | - 'URL slug: ' . $slug, |
|
| 1484 | - $language_code); |
|
| 1479 | + $org_slug = $slug; |
|
| 1480 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1481 | + $slug, |
|
| 1482 | + 'WordPress', |
|
| 1483 | + 'URL slug: ' . $slug, |
|
| 1484 | + $language_code); |
|
| 1485 | 1485 | |
| 1486 | - if(!$slug){$slug = $org_slug;}
|
|
| 1486 | + if(!$slug){$slug = $org_slug;}
|
|
| 1487 | 1487 | |
| 1488 | - } |
|
| 1489 | - } |
|
| 1488 | + } |
|
| 1489 | + } |
|
| 1490 | 1490 | |
| 1491 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1492 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1493 | - } |
|
| 1491 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1492 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1493 | + } |
|
| 1494 | 1494 | |
| 1495 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1496 | - $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1495 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1496 | + $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1497 | 1497 | |
| 1498 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1499 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1500 | - } |
|
| 1501 | - |
|
| 1502 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1503 | - if ($fix_url) {
|
|
| 1504 | - $post_link = str_replace($site_url, '', $post_link); |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - $post_link = trailingslashit( |
|
| 1508 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1509 | - ); |
|
| 1510 | - |
|
| 1511 | - if ($fix_url) {
|
|
| 1512 | - $post_link = $site_url . $post_link; |
|
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - if (isset($comment_post_cache[$post->ID])) {
|
|
| 1516 | - $post = $comment_post_cache[$post->ID]; |
|
| 1517 | - } |
|
| 1518 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1519 | - $post_id = $post->ID; |
|
| 1520 | - if (isset($orig_post)) {
|
|
| 1521 | - $post = $orig_post; |
|
| 1522 | - } |
|
| 1523 | - return $gd_permalink_cache[$post_id]; |
|
| 1524 | - } |
|
| 1498 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1499 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1500 | + } |
|
| 1525 | 1501 | |
| 1526 | - if (!isset($post->post_locations)) {
|
|
| 1527 | - $post_type = $post->post_type; |
|
| 1528 | - $ID = $post->ID; |
|
| 1529 | - $post2 = $wpdb->get_row( |
|
| 1530 | - $wpdb->prepare( |
|
| 1531 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1532 | - array($post->ID) |
|
| 1533 | - ) |
|
| 1534 | - ); |
|
| 1502 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1503 | + if ($fix_url) {
|
|
| 1504 | + $post_link = str_replace($site_url, '', $post_link); |
|
| 1505 | + } |
|
| 1535 | 1506 | |
| 1536 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1507 | + $post_link = trailingslashit( |
|
| 1508 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1509 | + ); |
|
| 1537 | 1510 | |
| 1538 | - $comment_post_cache[$post->ID] = $post; |
|
| 1539 | - } |
|
| 1511 | + if ($fix_url) {
|
|
| 1512 | + $post_link = $site_url . $post_link; |
|
| 1513 | + } |
|
| 1540 | 1514 | |
| 1515 | + if (isset($comment_post_cache[$post->ID])) {
|
|
| 1516 | + $post = $comment_post_cache[$post->ID]; |
|
| 1517 | + } |
|
| 1518 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1519 | + $post_id = $post->ID; |
|
| 1520 | + if (isset($orig_post)) {
|
|
| 1521 | + $post = $orig_post; |
|
| 1522 | + } |
|
| 1523 | + return $gd_permalink_cache[$post_id]; |
|
| 1524 | + } |
|
| 1541 | 1525 | |
| 1526 | + if (!isset($post->post_locations)) {
|
|
| 1527 | + $post_type = $post->post_type; |
|
| 1528 | + $ID = $post->ID; |
|
| 1529 | + $post2 = $wpdb->get_row( |
|
| 1530 | + $wpdb->prepare( |
|
| 1531 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1532 | + array($post->ID) |
|
| 1533 | + ) |
|
| 1534 | + ); |
|
| 1542 | 1535 | |
| 1543 | - if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1536 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1544 | 1537 | |
| 1545 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1546 | - $location_request = ''; |
|
| 1538 | + $comment_post_cache[$post->ID] = $post; |
|
| 1539 | + } |
|
| 1547 | 1540 | |
| 1548 | 1541 | |
| 1549 | - if (!empty($post->post_locations)) {
|
|
| 1550 | - $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1551 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1552 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1553 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1554 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1555 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1556 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1557 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1558 | 1542 | |
| 1559 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1560 | - 'region_slug' => $post->region_slug, |
|
| 1561 | - 'city_slug' => $post->city_slug |
|
| 1562 | - ); |
|
| 1543 | + if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1563 | 1544 | |
| 1564 | - } else |
|
| 1565 | - $post_location = geodir_get_location(); |
|
| 1545 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1546 | + $location_request = ''; |
|
| 1566 | 1547 | |
| 1567 | 1548 | |
| 1568 | - } else {
|
|
| 1549 | + if (!empty($post->post_locations)) {
|
|
| 1550 | + $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1551 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1552 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1553 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1554 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1555 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1556 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1557 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1569 | 1558 | |
| 1570 | - $post_location_sql = $wpdb->get_results( |
|
| 1571 | - $wpdb->prepare( |
|
| 1572 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1573 | - array($post->ID) |
|
| 1574 | - ) |
|
| 1575 | - ); |
|
| 1576 | - |
|
| 1577 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1578 | - |
|
| 1579 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1580 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1581 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1582 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1583 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1584 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1585 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1586 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1587 | - |
|
| 1588 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1589 | - 'region_slug' => $post->region_slug, |
|
| 1590 | - 'city_slug' => $post->city_slug |
|
| 1591 | - ); |
|
| 1559 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1560 | + 'region_slug' => $post->region_slug, |
|
| 1561 | + 'city_slug' => $post->city_slug |
|
| 1562 | + ); |
|
| 1592 | 1563 | |
| 1593 | - } |
|
| 1594 | - } else |
|
| 1595 | - $post_location = geodir_get_location(); |
|
| 1596 | - } |
|
| 1564 | + } else |
|
| 1565 | + $post_location = geodir_get_location(); |
|
| 1597 | 1566 | |
| 1598 | 1567 | |
| 1599 | - if (!empty($post_location)) {
|
|
| 1600 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1568 | + } else {
|
|
| 1569 | + |
|
| 1570 | + $post_location_sql = $wpdb->get_results( |
|
| 1571 | + $wpdb->prepare( |
|
| 1572 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1573 | + array($post->ID) |
|
| 1574 | + ) |
|
| 1575 | + ); |
|
| 1576 | + |
|
| 1577 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1578 | + |
|
| 1579 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1580 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1581 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1582 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1583 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1584 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1585 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1586 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1587 | + |
|
| 1588 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1589 | + 'region_slug' => $post->region_slug, |
|
| 1590 | + 'city_slug' => $post->city_slug |
|
| 1591 | + ); |
|
| 1592 | + |
|
| 1593 | + } |
|
| 1594 | + } else |
|
| 1595 | + $post_location = geodir_get_location(); |
|
| 1596 | + } |
|
| 1597 | + |
|
| 1598 | + |
|
| 1599 | + if (!empty($post_location)) {
|
|
| 1600 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1601 | 1601 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
| 1602 | 1602 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
| 1603 | 1603 | |
@@ -1615,89 +1615,89 @@ discard block |
||
| 1615 | 1615 | $location_slug[] = $city_slug; |
| 1616 | 1616 | |
| 1617 | 1617 | $location_request .= implode('/', $location_slug) . '/';
|
| 1618 | - } |
|
| 1619 | - } |
|
| 1618 | + } |
|
| 1619 | + } |
|
| 1620 | 1620 | |
| 1621 | - if (get_option('geodir_add_categories_url')) {
|
|
| 1621 | + if (get_option('geodir_add_categories_url')) {
|
|
| 1622 | 1622 | |
| 1623 | - $term_request = ''; |
|
| 1624 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1623 | + $term_request = ''; |
|
| 1624 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1625 | 1625 | |
| 1626 | - $taxonomies = end($taxonomies); |
|
| 1626 | + $taxonomies = end($taxonomies); |
|
| 1627 | 1627 | |
| 1628 | - if (!empty($post->default_category)) {
|
|
| 1629 | - $post_terms = $post->default_category; |
|
| 1630 | - } else {
|
|
| 1631 | - $post_terms = ''; |
|
| 1632 | - |
|
| 1633 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1634 | - $post_terms = absint($_POST['post_default_category']); |
|
| 1635 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1636 | - $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1637 | - $post_terms = absint($post_terms[0]); |
|
| 1638 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1639 | - $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1640 | - $post_terms = $post_terms[0]; |
|
| 1641 | - } |
|
| 1628 | + if (!empty($post->default_category)) {
|
|
| 1629 | + $post_terms = $post->default_category; |
|
| 1630 | + } else {
|
|
| 1631 | + $post_terms = ''; |
|
| 1632 | + |
|
| 1633 | + if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1634 | + $post_terms = absint($_POST['post_default_category']); |
|
| 1635 | + }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1636 | + $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1637 | + $post_terms = absint($post_terms[0]); |
|
| 1638 | + }elseif (isset($post->{$taxonomies})) {
|
|
| 1639 | + $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1640 | + $post_terms = $post_terms[0]; |
|
| 1641 | + } |
|
| 1642 | 1642 | |
| 1643 | - if (!$post_terms) |
|
| 1644 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1643 | + if (!$post_terms) |
|
| 1644 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1645 | 1645 | |
| 1646 | - if (!$post_terms) {
|
|
| 1647 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1646 | + if (!$post_terms) {
|
|
| 1647 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1648 | 1648 | |
| 1649 | - if ($post_terms) {
|
|
| 1650 | - $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1651 | - $post_terms = $post_terms[0]; |
|
| 1652 | - } |
|
| 1653 | - } |
|
| 1654 | - } |
|
| 1649 | + if ($post_terms) {
|
|
| 1650 | + $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1651 | + $post_terms = $post_terms[0]; |
|
| 1652 | + } |
|
| 1653 | + } |
|
| 1654 | + } |
|
| 1655 | 1655 | |
| 1656 | - $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1656 | + $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1657 | 1657 | |
| 1658 | - if (!empty($term)) |
|
| 1659 | - $term_request = $term->slug; |
|
| 1660 | - //$term_request = $term->slug.'/'; |
|
| 1661 | - } |
|
| 1658 | + if (!empty($term)) |
|
| 1659 | + $term_request = $term->slug; |
|
| 1660 | + //$term_request = $term->slug.'/'; |
|
| 1661 | + } |
|
| 1662 | 1662 | |
| 1663 | - $request_term = ''; |
|
| 1664 | - $listingurl_separator = ''; |
|
| 1665 | - //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1666 | - $detailurl_separator = ''; |
|
| 1667 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1668 | - $request_term = $location_request; |
|
| 1669 | - //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1670 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1671 | - $request_term .= $term_request; |
|
| 1663 | + $request_term = ''; |
|
| 1664 | + $listingurl_separator = ''; |
|
| 1665 | + //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1666 | + $detailurl_separator = ''; |
|
| 1667 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1668 | + $request_term = $location_request; |
|
| 1669 | + //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1670 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1671 | + $request_term .= $term_request; |
|
| 1672 | 1672 | |
| 1673 | - } else {
|
|
| 1674 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1673 | + } else {
|
|
| 1674 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1675 | 1675 | |
| 1676 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1677 | - } |
|
| 1678 | - $request_term = trim($request_term, '/'); |
|
| 1676 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1677 | + } |
|
| 1678 | + $request_term = trim($request_term, '/'); |
|
| 1679 | 1679 | |
| 1680 | - // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1681 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1682 | - $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1683 | - } |
|
| 1680 | + // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1681 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1682 | + $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1683 | + } |
|
| 1684 | 1684 | |
| 1685 | - if (!empty($request_term)) |
|
| 1686 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1687 | - else |
|
| 1688 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1689 | - //echo $post_link ; |
|
| 1690 | - } |
|
| 1691 | - // temp cache the permalink |
|
| 1692 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1693 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1694 | - } |
|
| 1695 | - } |
|
| 1696 | - if (isset($orig_post)) {
|
|
| 1697 | - $post = $orig_post; |
|
| 1698 | - } |
|
| 1699 | - |
|
| 1700 | - return $post_link; |
|
| 1685 | + if (!empty($request_term)) |
|
| 1686 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1687 | + else |
|
| 1688 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1689 | + //echo $post_link ; |
|
| 1690 | + } |
|
| 1691 | + // temp cache the permalink |
|
| 1692 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1693 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1694 | + } |
|
| 1695 | + } |
|
| 1696 | + if (isset($orig_post)) {
|
|
| 1697 | + $post = $orig_post; |
|
| 1698 | + } |
|
| 1699 | + |
|
| 1700 | + return $post_link; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | 1703 | /** |
@@ -1713,99 +1713,99 @@ discard block |
||
| 1713 | 1713 | * @return string The term link. |
| 1714 | 1714 | */ |
| 1715 | 1715 | function geodir_term_link($termlink, $term, $taxonomy) {
|
| 1716 | - $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1716 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1717 | 1717 | |
| 1718 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1719 | - global $geodir_add_location_url, $gd_session; |
|
| 1720 | - $include_location = false; |
|
| 1721 | - $request_term = array(); |
|
| 1722 | - $add_location_url = get_option('geodir_add_location_url');
|
|
| 1723 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1718 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1719 | + global $geodir_add_location_url, $gd_session; |
|
| 1720 | + $include_location = false; |
|
| 1721 | + $request_term = array(); |
|
| 1722 | + $add_location_url = get_option('geodir_add_location_url');
|
|
| 1723 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1724 | 1724 | |
| 1725 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1725 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1726 | 1726 | |
| 1727 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1728 | - if ($geodir_add_location_url && $add_location_url) {
|
|
| 1729 | - $include_location = true; |
|
| 1730 | - } |
|
| 1731 | - } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1732 | - $include_location = true; |
|
| 1733 | - } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1734 | - $include_location = true; |
|
| 1735 | - } |
|
| 1736 | - |
|
| 1737 | - if ($include_location) {
|
|
| 1738 | - global $post; |
|
| 1727 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1728 | + if ($geodir_add_location_url && $add_location_url) {
|
|
| 1729 | + $include_location = true; |
|
| 1730 | + } |
|
| 1731 | + } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1732 | + $include_location = true; |
|
| 1733 | + } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1734 | + $include_location = true; |
|
| 1735 | + } |
|
| 1736 | + |
|
| 1737 | + if ($include_location) {
|
|
| 1738 | + global $post; |
|
| 1739 | 1739 | |
| 1740 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1740 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1741 | 1741 | |
| 1742 | - if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 1743 | - $location_terms = array( |
|
| 1744 | - 'gd_country' => $post->country_slug, |
|
| 1745 | - 'gd_region' => $post->region_slug, |
|
| 1746 | - 'gd_city' => $post->city_slug |
|
| 1747 | - ); |
|
| 1742 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 1743 | + $location_terms = array( |
|
| 1744 | + 'gd_country' => $post->country_slug, |
|
| 1745 | + 'gd_region' => $post->region_slug, |
|
| 1746 | + 'gd_city' => $post->city_slug |
|
| 1747 | + ); |
|
| 1748 | 1748 | |
| 1749 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1750 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1751 | - } |
|
| 1752 | - } else {
|
|
| 1753 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1754 | - } |
|
| 1749 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1750 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1751 | + } |
|
| 1752 | + } else {
|
|
| 1753 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1754 | + } |
|
| 1755 | 1755 | |
| 1756 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1757 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1756 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1757 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1758 | 1758 | |
| 1759 | - if (!empty($location_terms)) {
|
|
| 1760 | - $url_separator = ''; |
|
| 1759 | + if (!empty($location_terms)) {
|
|
| 1760 | + $url_separator = ''; |
|
| 1761 | 1761 | |
| 1762 | - if (get_option('permalink_structure') != '') {
|
|
| 1763 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1764 | - $request_term = implode("/", $location_terms);
|
|
| 1765 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1762 | + if (get_option('permalink_structure') != '') {
|
|
| 1763 | + $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1764 | + $request_term = implode("/", $location_terms);
|
|
| 1765 | + $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1766 | 1766 | |
| 1767 | - $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1768 | - } else {
|
|
| 1769 | - $termlink = geodir_getlink($termlink, $request_term); |
|
| 1770 | - } |
|
| 1771 | - } |
|
| 1772 | - } |
|
| 1767 | + $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1768 | + } else {
|
|
| 1769 | + $termlink = geodir_getlink($termlink, $request_term); |
|
| 1770 | + } |
|
| 1771 | + } |
|
| 1772 | + } |
|
| 1773 | 1773 | |
| 1774 | - // Alter the CPT slug is WPML is set to do so |
|
| 1775 | - /* we can replace this with the below function |
|
| 1774 | + // Alter the CPT slug is WPML is set to do so |
|
| 1775 | + /* we can replace this with the below function |
|
| 1776 | 1776 | if(function_exists('icl_object_id')){
|
| 1777 | 1777 | global $sitepress; |
| 1778 | 1778 | $post_type = str_replace("category","",$taxonomy);
|
| 1779 | 1779 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
| 1780 | 1780 | }*/ |
| 1781 | 1781 | |
| 1782 | - // Alter the CPT slug if WPML is set to do so |
|
| 1783 | - if (function_exists('icl_object_id')) {
|
|
| 1784 | - $post_types = get_option('geodir_post_types');
|
|
| 1785 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1786 | - $post_type = str_replace("_tags","",$post_type);
|
|
| 1787 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1788 | - if (gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1789 | - global $sitepress; |
|
| 1790 | - $default_lang = $sitepress->get_default_language(); |
|
| 1791 | - $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1792 | - if (!$language_code ) {
|
|
| 1793 | - $language_code = $default_lang; |
|
| 1794 | - } |
|
| 1782 | + // Alter the CPT slug if WPML is set to do so |
|
| 1783 | + if (function_exists('icl_object_id')) {
|
|
| 1784 | + $post_types = get_option('geodir_post_types');
|
|
| 1785 | + $post_type = str_replace("category","",$taxonomy);
|
|
| 1786 | + $post_type = str_replace("_tags","",$post_type);
|
|
| 1787 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1788 | + if (gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1789 | + global $sitepress; |
|
| 1790 | + $default_lang = $sitepress->get_default_language(); |
|
| 1791 | + $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1792 | + if (!$language_code ) {
|
|
| 1793 | + $language_code = $default_lang; |
|
| 1794 | + } |
|
| 1795 | 1795 | |
| 1796 | - $org_slug = $slug; |
|
| 1797 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1796 | + $org_slug = $slug; |
|
| 1797 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1798 | 1798 | |
| 1799 | - if (!$slug) {
|
|
| 1800 | - $slug = $org_slug; |
|
| 1801 | - } |
|
| 1799 | + if (!$slug) {
|
|
| 1800 | + $slug = $org_slug; |
|
| 1801 | + } |
|
| 1802 | 1802 | |
| 1803 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1804 | - } |
|
| 1805 | - } |
|
| 1806 | - } |
|
| 1803 | + $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1804 | + } |
|
| 1805 | + } |
|
| 1806 | + } |
|
| 1807 | 1807 | |
| 1808 | - return $termlink; |
|
| 1808 | + return $termlink; |
|
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | 1811 | /** |
@@ -1831,14 +1831,14 @@ discard block |
||
| 1831 | 1831 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1832 | 1832 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1833 | 1833 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
| 1834 | - $location_terms = array( |
|
| 1835 | - 'gd_country' => $post->country_slug, |
|
| 1836 | - 'gd_region' => $post->region_slug, |
|
| 1837 | - 'gd_city' => $post->city_slug |
|
| 1838 | - ); |
|
| 1839 | - } else {
|
|
| 1840 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1841 | - } |
|
| 1834 | + $location_terms = array( |
|
| 1835 | + 'gd_country' => $post->country_slug, |
|
| 1836 | + 'gd_region' => $post->region_slug, |
|
| 1837 | + 'gd_city' => $post->city_slug |
|
| 1838 | + ); |
|
| 1839 | + } else {
|
|
| 1840 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1841 | + } |
|
| 1842 | 1842 | |
| 1843 | 1843 | $location_terms = geodir_remove_location_terms($location_terms); |
| 1844 | 1844 | |
@@ -1870,17 +1870,17 @@ discard block |
||
| 1870 | 1870 | * @return void|string Label. |
| 1871 | 1871 | */ |
| 1872 | 1872 | function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
|
| 1873 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1874 | - if (!is_object($obj_post_type)) {
|
|
| 1875 | - return; |
|
| 1876 | - } |
|
| 1873 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1874 | + if (!is_object($obj_post_type)) {
|
|
| 1875 | + return; |
|
| 1876 | + } |
|
| 1877 | 1877 | |
| 1878 | - $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
| 1878 | + $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
| 1879 | 1879 | |
| 1880 | - if ($echo) |
|
| 1881 | - echo $label; |
|
| 1882 | - else |
|
| 1883 | - return $label; |
|
| 1880 | + if ($echo) |
|
| 1881 | + echo $label; |
|
| 1882 | + else |
|
| 1883 | + return $label; |
|
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | /** |
@@ -1895,19 +1895,19 @@ discard block |
||
| 1895 | 1895 | * @return void|string Label. |
| 1896 | 1896 | */ |
| 1897 | 1897 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1898 | - $all_postypes = geodir_get_posttypes(); |
|
| 1898 | + $all_postypes = geodir_get_posttypes(); |
|
| 1899 | 1899 | |
| 1900 | - if (!in_array($post_type, $all_postypes)) |
|
| 1901 | - return false; |
|
| 1900 | + if (!in_array($post_type, $all_postypes)) |
|
| 1901 | + return false; |
|
| 1902 | 1902 | |
| 1903 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1903 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1904 | 1904 | |
| 1905 | - $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1905 | + $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1906 | 1906 | |
| 1907 | - if ($echo) |
|
| 1908 | - echo $label; |
|
| 1909 | - else |
|
| 1910 | - return $label; |
|
| 1907 | + if ($echo) |
|
| 1908 | + echo $label; |
|
| 1909 | + else |
|
| 1910 | + return $label; |
|
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | 1913 | /** |
@@ -1925,51 +1925,51 @@ discard block |
||
| 1925 | 1925 | */ |
| 1926 | 1926 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
| 1927 | 1927 | {
|
| 1928 | - global $wpdb; |
|
| 1929 | - |
|
| 1930 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1931 | - $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1932 | - |
|
| 1933 | - if (is_int($term)) {
|
|
| 1934 | - if (0 == $term) |
|
| 1935 | - return 0; |
|
| 1936 | - $where = 't.term_id = %d'; |
|
| 1937 | - if (!empty($taxonomy)) |
|
| 1938 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1939 | - else |
|
| 1940 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1941 | - } |
|
| 1928 | + global $wpdb; |
|
| 1929 | + |
|
| 1930 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1931 | + $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1932 | + |
|
| 1933 | + if (is_int($term)) {
|
|
| 1934 | + if (0 == $term) |
|
| 1935 | + return 0; |
|
| 1936 | + $where = 't.term_id = %d'; |
|
| 1937 | + if (!empty($taxonomy)) |
|
| 1938 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1939 | + else |
|
| 1940 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - $term = trim(wp_unslash($term)); |
|
| 1943 | + $term = trim(wp_unslash($term)); |
|
| 1944 | 1944 | |
| 1945 | - if ('' === $slug = sanitize_title($term))
|
|
| 1946 | - return 0; |
|
| 1945 | + if ('' === $slug = sanitize_title($term))
|
|
| 1946 | + return 0; |
|
| 1947 | 1947 | |
| 1948 | - $where = 't.slug = %s'; |
|
| 1948 | + $where = 't.slug = %s'; |
|
| 1949 | 1949 | |
| 1950 | - $where_fields = array($slug); |
|
| 1951 | - if (!empty($taxonomy)) {
|
|
| 1952 | - $parent = (int)$parent; |
|
| 1953 | - if ($parent > 0) {
|
|
| 1954 | - $where_fields[] = $parent; |
|
| 1955 | - $else_where_fields[] = $parent; |
|
| 1956 | - $where .= ' AND tt.parent = %d'; |
|
| 1950 | + $where_fields = array($slug); |
|
| 1951 | + if (!empty($taxonomy)) {
|
|
| 1952 | + $parent = (int)$parent; |
|
| 1953 | + if ($parent > 0) {
|
|
| 1954 | + $where_fields[] = $parent; |
|
| 1955 | + $else_where_fields[] = $parent; |
|
| 1956 | + $where .= ' AND tt.parent = %d'; |
|
| 1957 | 1957 | |
| 1958 | - } |
|
| 1958 | + } |
|
| 1959 | 1959 | |
| 1960 | - $where_fields[] = $taxonomy; |
|
| 1960 | + $where_fields[] = $taxonomy; |
|
| 1961 | 1961 | |
| 1962 | 1962 | |
| 1963 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1964 | - return $result; |
|
| 1963 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1964 | + return $result; |
|
| 1965 | 1965 | |
| 1966 | - return false; |
|
| 1967 | - } |
|
| 1966 | + return false; |
|
| 1967 | + } |
|
| 1968 | 1968 | |
| 1969 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1970 | - return $result; |
|
| 1969 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1970 | + return $result; |
|
| 1971 | 1971 | |
| 1972 | - return false; |
|
| 1972 | + return false; |
|
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | /** |
@@ -1981,7 +1981,7 @@ discard block |
||
| 1981 | 1981 | function geodir_get_term_icon_rebuild() |
| 1982 | 1982 | {
|
| 1983 | 1983 | |
| 1984 | - update_option('gd_term_icons', '');
|
|
| 1984 | + update_option('gd_term_icons', '');
|
|
| 1985 | 1985 | |
| 1986 | 1986 | } |
| 1987 | 1987 | |
@@ -1999,61 +1999,61 @@ discard block |
||
| 1999 | 1999 | */ |
| 2000 | 2000 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
| 2001 | 2001 | {
|
| 2002 | - global $wpdb; |
|
| 2003 | - if (!$rebuild) {
|
|
| 2004 | - $terms_icons = get_option('gd_term_icons');
|
|
| 2005 | - } else {
|
|
| 2006 | - $terms_icons = array(); |
|
| 2007 | - } |
|
| 2008 | - |
|
| 2009 | - if (empty($terms_icons)) {
|
|
| 2010 | - $terms_icons = array(); |
|
| 2011 | - $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2012 | - $taxonomy = geodir_get_taxonomies(); |
|
| 2013 | - $post_types = geodir_get_posttypes(); |
|
| 2014 | - $tax_arr = array(); |
|
| 2015 | - foreach ($post_types as $post_type) {
|
|
| 2016 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2017 | - } |
|
| 2018 | - $tax_c = implode(',', $tax_arr);
|
|
| 2019 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2020 | - //$terms = get_terms( $taxonomy ); |
|
| 2021 | - |
|
| 2022 | - if($terms) {
|
|
| 2023 | - foreach ($terms as $term) {
|
|
| 2024 | - $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2025 | - $a_terms[$post_type][] = $term; |
|
| 2002 | + global $wpdb; |
|
| 2003 | + if (!$rebuild) {
|
|
| 2004 | + $terms_icons = get_option('gd_term_icons');
|
|
| 2005 | + } else {
|
|
| 2006 | + $terms_icons = array(); |
|
| 2007 | + } |
|
| 2026 | 2008 | |
| 2027 | - } |
|
| 2028 | - } |
|
| 2009 | + if (empty($terms_icons)) {
|
|
| 2010 | + $terms_icons = array(); |
|
| 2011 | + $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2012 | + $taxonomy = geodir_get_taxonomies(); |
|
| 2013 | + $post_types = geodir_get_posttypes(); |
|
| 2014 | + $tax_arr = array(); |
|
| 2015 | + foreach ($post_types as $post_type) {
|
|
| 2016 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2017 | + } |
|
| 2018 | + $tax_c = implode(',', $tax_arr);
|
|
| 2019 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2020 | + //$terms = get_terms( $taxonomy ); |
|
| 2029 | 2021 | |
| 2030 | - if($a_terms) {
|
|
| 2031 | - foreach ($a_terms as $pt => $t2) {
|
|
| 2022 | + if($terms) {
|
|
| 2023 | + foreach ($terms as $term) {
|
|
| 2024 | + $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2025 | + $a_terms[$post_type][] = $term; |
|
| 2032 | 2026 | |
| 2033 | - foreach ($t2 as $term) {
|
|
| 2034 | - $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2035 | - if ($term_icon) {
|
|
| 2036 | - $term_icon_url = $term_icon["src"]; |
|
| 2037 | - } else {
|
|
| 2038 | - $term_icon_url = $default_icon_url; |
|
| 2039 | - } |
|
| 2040 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2041 | - } |
|
| 2042 | - } |
|
| 2043 | - } |
|
| 2027 | + } |
|
| 2028 | + } |
|
| 2044 | 2029 | |
| 2045 | - update_option('gd_term_icons', $terms_icons);
|
|
| 2046 | - } |
|
| 2030 | + if($a_terms) {
|
|
| 2031 | + foreach ($a_terms as $pt => $t2) {
|
|
| 2047 | 2032 | |
| 2048 | - if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2049 | - return $terms_icons[$term_id]; |
|
| 2050 | - } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2051 | - return get_option('geodir_default_marker_icon');
|
|
| 2052 | - } |
|
| 2033 | + foreach ($t2 as $term) {
|
|
| 2034 | + $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2035 | + if ($term_icon) {
|
|
| 2036 | + $term_icon_url = $term_icon["src"]; |
|
| 2037 | + } else {
|
|
| 2038 | + $term_icon_url = $default_icon_url; |
|
| 2039 | + } |
|
| 2040 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2041 | + } |
|
| 2042 | + } |
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + update_option('gd_term_icons', $terms_icons);
|
|
| 2046 | + } |
|
| 2053 | 2047 | |
| 2054 | - if (is_ssl()) {
|
|
| 2055 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2056 | - } |
|
| 2048 | + if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2049 | + return $terms_icons[$term_id]; |
|
| 2050 | + } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2051 | + return get_option('geodir_default_marker_icon');
|
|
| 2052 | + } |
|
| 2053 | + |
|
| 2054 | + if (is_ssl()) {
|
|
| 2055 | + $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2056 | + } |
|
| 2057 | 2057 | |
| 2058 | - return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2058 | + return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2059 | 2059 | } |
| 2060 | 2060 | \ No newline at end of file |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | * @since 1.0.0 |
| 61 | 61 | * @param string $menu_class The menu HTML class. |
| 62 | 62 | */ |
| 63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 64 | 64 | /** |
| 65 | 65 | * Filter the menu a class. |
| 66 | 66 | * |
| 67 | 67 | * @since 1.0.0 |
| 68 | 68 | */ |
| 69 | 69 | $a_class = apply_filters('geodir_menu_a_class', '');
|
| 70 | - $items .= '<li class="' . $li_class . '"> |
|
| 71 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
|
| 72 | - ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
|
| 70 | + $items .= '<li class="'.$li_class.'"> |
|
| 71 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'"> |
|
| 72 | + ' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').' |
|
| 73 | 73 | </a> |
| 74 | 74 | </li>'; |
| 75 | 75 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | * @since 1.0.0 |
| 89 | 89 | * @param string $menu_class The menu HTML class. |
| 90 | 90 | */ |
| 91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class);
|
|
| 92 | 92 | /** |
| 93 | 93 | * Filter the sub menu li class. |
| 94 | 94 | * |
| 95 | 95 | * @since 1.0.0 |
| 96 | 96 | * @param string $menu_class The menu HTML class. |
| 97 | 97 | */ |
| 98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
|
|
| 99 | 99 | /** |
| 100 | 100 | * Filter the sub menu ul class. |
| 101 | 101 | * |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @since 1.0.0 |
| 115 | 115 | */ |
| 116 | 116 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
| 117 | - $items .= '<li class="' . $li_class . '"> |
|
| 118 | - <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
|
|
| 119 | - <ul class="' . $sub_ul_class . '">'; |
|
| 117 | + $items .= '<li class="'.$li_class.'"> |
|
| 118 | + <a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a>
|
|
| 119 | + <ul class="' . $sub_ul_class.'">'; |
|
| 120 | 120 | $post_types = geodir_get_posttypes('object');
|
| 121 | 121 | |
| 122 | 122 | $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
| 134 | 134 | $menu_class = 'current-menu-item'; |
| 135 | 135 | |
| 136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 137 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
|
| 138 | - ' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . ' |
|
| 136 | + $items .= '<li class="'.$sub_li_class.'"> |
|
| 137 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'"> |
|
| 138 | + ' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').' |
|
| 139 | 139 | </a> |
| 140 | 140 | </li>'; |
| 141 | 141 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @since 1.5.9 |
| 153 | 153 | */ |
| 154 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 154 | + $items .= apply_filters('geodir_menu_after_sub_ul', '');
|
|
| 155 | 155 | $items .= '</li>'; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @since 1.0.0 |
| 185 | 185 | * @param string $menu_class The menu HTML class. |
| 186 | 186 | */ |
| 187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 188 | 188 | /** |
| 189 | 189 | * Filter the menu a class. |
| 190 | 190 | * |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | $a_class = apply_filters('geodir_menu_a_class', '');
|
| 194 | 194 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
| 195 | - $items .= '<li class="' . $li_class . '"> |
|
| 196 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
|
| 197 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
|
| 195 | + $items .= '<li class="'.$li_class.'"> |
|
| 196 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'"> |
|
| 197 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
|
|
| 198 | 198 | </a> |
| 199 | 199 | </li>'; |
| 200 | 200 | } |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | * @since 1.0.0 |
| 219 | 219 | * @param string $menu_class The menu HTML class. |
| 220 | 220 | */ |
| 221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class);
|
|
| 222 | 222 | /** |
| 223 | 223 | * Filter the sub menu li class. |
| 224 | 224 | * |
| 225 | 225 | * @since 1.0.0 |
| 226 | 226 | * @param string $menu_class The menu HTML class. |
| 227 | 227 | */ |
| 228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
|
|
| 229 | 229 | /** |
| 230 | 230 | * Filter the sub menu ul class. |
| 231 | 231 | * |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * @since 1.0.0 |
| 245 | 245 | */ |
| 246 | 246 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
| 247 | - $items .= '<li class="' . $li_class . '"> |
|
| 248 | - <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
|
|
| 249 | - <ul class="' . $sub_ul_class . '">'; |
|
| 247 | + $items .= '<li class="'.$li_class.'"> |
|
| 248 | + <a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a>
|
|
| 249 | + <ul class="' . $sub_ul_class.'">'; |
|
| 250 | 250 | |
| 251 | 251 | $post_types = geodir_get_posttypes('object');
|
| 252 | 252 | |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @param string $menu_class The menu HTML class. |
| 271 | 271 | */ |
| 272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
|
|
| 273 | 273 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
| 274 | - $items .= '<li class="' . $li_class . '"> |
|
| 275 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
|
| 276 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
|
| 274 | + $items .= '<li class="'.$li_class.'"> |
|
| 275 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'"> |
|
| 276 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
|
|
| 277 | 277 | </a> |
| 278 | 278 | </li>'; |
| 279 | 279 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $items .= ' </ul> '; |
| 288 | - $items .= apply_filters('geodir_menu_after_sub_ul','');
|
|
| 288 | + $items .= apply_filters('geodir_menu_after_sub_ul', '');
|
|
| 289 | 289 | $items .= '</li>'; |
| 290 | 290 | |
| 291 | 291 | } |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | $geodir_theme_location = get_option('geodir_theme_location_nav');
|
| 314 | 314 | $geodir_theme_location_nav = array(); |
| 315 | 315 | if (empty($locations) && empty($geodir_theme_location)) {
|
| 316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
|
|
| 317 | 317 | $geodir_theme_location_nav[] = $args['theme_location']; |
| 318 | 318 | update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
| 319 | 319 | } |
| 320 | 320 | //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
| 321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 322 | 322 | else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
| 323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
|
|
| 324 | 324 | |
| 325 | 325 | return $menu; |
| 326 | 326 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
| 350 | 350 | |
| 351 | - $items = $items . geodir_add_nav_menu_items(); |
|
| 351 | + $items = $items.geodir_add_nav_menu_items(); |
|
| 352 | 352 | return $items; |
| 353 | 353 | |
| 354 | 354 | } else {
|
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $taxonomies = geodir_get_taxonomies(); |
| 375 | 375 | $taxonomies = implode("','", $taxonomies);
|
| 376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 376 | + $taxonomies = "'".$taxonomies."'"; |
|
| 377 | 377 | |
| 378 | 378 | $pn_categories = $wpdb->get_results( |
| 379 | 379 | $wpdb->prepare( |
| 380 | 380 | "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
| 381 | - array($wpdb->terms . term_id) |
|
| 381 | + array($wpdb->terms.term_id) |
|
| 382 | 382 | ) |
| 383 | 383 | ); |
| 384 | 384 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
| 409 | 409 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
| 410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 410 | + $geodir_post_type = get_post_type((int) $_REQUEST['pid']); |
|
| 411 | 411 | elseif (isset($_REQUEST['listing_type'])) |
| 412 | 412 | $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
| 413 | 413 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
| 426 | 426 | $geodir_post_type = ''; |
| 427 | 427 | |
| 428 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 428 | + if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) {
|
|
| 429 | 429 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
| 430 | 430 | } |
| 431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * |
| 436 | 436 | * @since 1.6.9 |
| 437 | 437 | */ |
| 438 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 438 | + return apply_filters('geodir_get_current_posttype', $geodir_post_type);
|
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -449,18 +449,18 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | function geodir_get_default_posttype() |
| 451 | 451 | {
|
| 452 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 452 | + $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object'));
|
|
| 453 | 453 | |
| 454 | 454 | $stype = false; |
| 455 | - foreach ( $post_types as $post_type => $info ) {
|
|
| 455 | + foreach ($post_types as $post_type => $info) {
|
|
| 456 | 456 | global $wpdb; |
| 457 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 458 | - if ( $has_posts ) {
|
|
| 457 | + $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
|
|
| 458 | + if ($has_posts) {
|
|
| 459 | 459 | $stype = $post_type; break; |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if(!$stype){
|
|
| 463 | + if (!$stype) {
|
|
| 464 | 464 | $stype = 'gd_place'; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -485,14 +485,14 @@ discard block |
||
| 485 | 485 | switch ($output): |
| 486 | 486 | case 'object': |
| 487 | 487 | case 'Object': |
| 488 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 488 | + $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types; |
|
| 489 | 489 | break; |
| 490 | 490 | case 'array': |
| 491 | 491 | case 'Array': |
| 492 | - $post_types = (array)$post_types; |
|
| 492 | + $post_types = (array) $post_types; |
|
| 493 | 493 | break; |
| 494 | 494 | case 'options': |
| 495 | - $post_types = (array)$post_types; |
|
| 495 | + $post_types = (array) $post_types; |
|
| 496 | 496 | |
| 497 | 497 | $options = array(); |
| 498 | 498 | if (!empty($post_types)) {
|
@@ -610,15 +610,15 @@ discard block |
||
| 610 | 610 | |
| 611 | 611 | $categories = get_terms($taxonomies); |
| 612 | 612 | |
| 613 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 613 | + $html .= '<option value="0">'.__('All', 'geodirectory').'</option>';
|
|
| 614 | 614 | |
| 615 | 615 | foreach ($categories as $category_obj) {
|
| 616 | 616 | $select_opt = ''; |
| 617 | 617 | if ($selected == $category_obj->term_id) {
|
| 618 | 618 | $select_opt = 'selected="selected"'; |
| 619 | 619 | } |
| 620 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 621 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 620 | + $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">' |
|
| 621 | + . geodir_utf8_ucfirst($category_obj->name).'</option>'; |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | if ($echo) |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | } elseif (isset($wp_query->tax_query->queries)) {
|
| 687 | 687 | $tax_arr = $wp_query->tax_query->queries; |
| 688 | 688 | //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
| 689 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 689 | + if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); }
|
|
| 690 | 690 | $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
| 691 | 691 | } |
| 692 | 692 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
| 742 | 742 | if ($cat_parent == 0) {
|
| 743 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 743 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display; |
|
| 744 | 744 | $main_list_class = 'class="main_list_selecter"'; |
| 745 | 745 | } else {
|
| 746 | 746 | //$display = 'display:none'; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
| 752 | 752 | $p = 0; |
| 753 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 753 | + $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">'; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | foreach ($cat_terms as $cat_term) {
|
@@ -765,12 +765,12 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | if ($cat_display == 'radio') |
| 768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 768 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>'; |
|
| 769 | 769 | elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
| 770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 770 | + $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</option>'; |
|
| 771 | 771 | |
| 772 | 772 | else {
|
| 773 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 773 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>'; |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | // Call recurson to print sub cats |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $cat_exclude = serialize($exclude_cats); |
| 810 | 810 | |
| 811 | 811 | if (isset($_REQUEST['backandedit'])) {
|
| 812 | - $post = (object)$gd_session->get('listing');
|
|
| 812 | + $post = (object) $gd_session->get('listing');
|
|
| 813 | 813 | |
| 814 | 814 | if (!is_array($post->post_category[$cat_taxonomy])) |
| 815 | 815 | $post_category = $post->post_category[$cat_taxonomy]; |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | if (!empty($post_category)) {
|
| 843 | 843 | $cat1 = array_filter(explode(',', $post_category));
|
| 844 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 844 | + $post_category = ','.implode(',', $cat1).',';
|
|
| 845 | 845 | |
| 846 | 846 | } |
| 847 | 847 | |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | foreach ($post_category_upd as $cat) {
|
| 853 | 853 | |
| 854 | 854 | if (!in_array($cat, $exclude_cats) && $cat != '') {
|
| 855 | - $post_category_change .= ',' . $cat; |
|
| 855 | + $post_category_change .= ','.$cat; |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | $post_category = $post_category_change; |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | } |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 867 | + echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']" />'; |
|
| 868 | 868 | |
| 869 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 869 | + echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']" />'; |
|
| 870 | 870 | |
| 871 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 871 | + echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']" />'; |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | 874 | ?> |
@@ -887,14 +887,14 @@ discard block |
||
| 887 | 887 | |
| 888 | 888 | function show_subcatlist(main_cat, catObj) {
|
| 889 | 889 | if (main_cat != '') {
|
| 890 | - var url = '<?php echo geodir_get_ajax_url();?>'; |
|
| 891 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
| 892 | - var cat_exclude = '<?php echo base64_encode($cat_exclude);?>'; |
|
| 890 | + var url = '<?php echo geodir_get_ajax_url(); ?>'; |
|
| 891 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
| 892 | + var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>'; |
|
| 893 | 893 | var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val();
|
| 894 | - <?php if ((int)$cat_limit > 0) { ?>
|
|
| 894 | + <?php if ((int) $cat_limit > 0) { ?>
|
|
| 895 | 895 | var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length);
|
| 896 | 896 | if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) {
|
| 897 | - alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>");
|
|
| 897 | + alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>");
|
|
| 898 | 898 | return false; |
| 899 | 899 | } |
| 900 | 900 | <?php } ?> |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | function update_listing_cat(el) {
|
| 936 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
| 936 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
| 937 | 937 | var cat_ids = ''; |
| 938 | 938 | var main_cat = ''; |
| 939 | 939 | var sub_cat = ''; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 1015 | 1015 | echo $style; |
| 1016 | 1016 | }?> "> |
| 1017 | - <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
| 1017 | + <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
| 1018 | 1018 | ?> |
| 1019 | 1019 | </div> |
| 1020 | 1020 | <?php |
@@ -1041,9 +1041,9 @@ discard block |
||
| 1041 | 1041 | if ($exclude != '') {
|
| 1042 | 1042 | $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
| 1043 | 1043 | |
| 1044 | - if(is_array( $exclude_cats)){
|
|
| 1045 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1046 | - }else{
|
|
| 1044 | + if (is_array($exclude_cats)) {
|
|
| 1045 | + $exclude_cats = array_map('intval', $exclude_cats);
|
|
| 1046 | + } else {
|
|
| 1047 | 1047 | $exclude_cats = intval($exclude_cats); |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1057,25 +1057,25 @@ discard block |
||
| 1057 | 1057 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1058 | 1058 | |
| 1059 | 1059 | <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;"> |
| 1060 | - <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>" |
|
| 1060 | + <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>" |
|
| 1061 | 1061 | onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/>
|
| 1062 | 1062 | <?php /* ?> |
| 1063 | 1063 | <img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" />
|
| 1064 | 1064 | <?php */ ?> |
| 1065 | 1065 | |
| 1066 | - <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat" |
|
| 1066 | + <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat" |
|
| 1067 | 1067 | onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()"
|
| 1068 | 1068 | checked="checked" disabled="disabled"/> |
| 1069 | 1069 | <span> |
| 1070 | - <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
|
| 1070 | + <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
|
|
| 1071 | 1071 | </span> |
| 1072 | 1072 | <br/> |
| 1073 | 1073 | |
| 1074 | 1074 | <div class="post_default_category"> |
| 1075 | - <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
|
| 1076 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
| 1075 | + <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>" |
|
| 1076 | + onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?> /> |
|
| 1077 | 1077 | <span> |
| 1078 | - <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
|
| 1078 | + <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
|
|
| 1079 | 1079 | </span> |
| 1080 | 1080 | </div> |
| 1081 | 1081 | |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | $post_cat_str = $post_categories[$request_taxonomy]; |
| 1109 | 1109 | $post_cat_array = explode("#", $post_cat_str);
|
| 1110 | 1110 | if (is_array($post_cat_array)) {
|
| 1111 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1111 | + $post_cat_array = array_unique($post_cat_array); |
|
| 1112 | 1112 | |
| 1113 | 1113 | foreach ($post_cat_array as $post_cat_html) {
|
| 1114 | 1114 | |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | } |
| 1124 | 1124 | $post_sub_catid = ''; |
| 1125 | 1125 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
| 1126 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1126 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
| 1147 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1147 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1176,9 +1176,9 @@ discard block |
||
| 1176 | 1176 | if (!$selected) |
| 1177 | 1177 | $option_slected = ' selected="selected" '; |
| 1178 | 1178 | |
| 1179 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1179 | + echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >'; |
|
| 1180 | 1180 | |
| 1181 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1181 | + echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>';
|
|
| 1182 | 1182 | |
| 1183 | 1183 | foreach ($cat_terms as $cat_term) {
|
| 1184 | 1184 | $option_selected = ''; |
@@ -1186,10 +1186,10 @@ discard block |
||
| 1186 | 1186 | $option_selected = ' selected="selected" '; |
| 1187 | 1187 | |
| 1188 | 1188 | // Count child terms |
| 1189 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1190 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1189 | + $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1));
|
|
| 1190 | + $has_child = !empty($child_terms) ? 't' : 'f'; |
|
| 1191 | 1191 | |
| 1192 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 1192 | + echo '<option '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.geodir_utf8_ucfirst($cat_term->name).'</option>'; |
|
| 1193 | 1193 | } |
| 1194 | 1194 | echo '</select>'; |
| 1195 | 1195 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | 2 => __('Custom field updated.', 'geodirectory'),
|
| 1221 | 1221 | 3 => __('Custom field deleted.', 'geodirectory'),
|
| 1222 | 1222 | 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
| 1223 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1223 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false,
|
|
| 1224 | 1224 | 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
| 1225 | 1225 | 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
| 1226 | 1226 | 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | |
| 1247 | 1247 | global $wpdb; |
| 1248 | 1248 | |
| 1249 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1249 | + $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico'; |
|
| 1250 | 1250 | |
| 1251 | 1251 | if (!$listing_slug = get_option('geodir_listing_prefix'))
|
| 1252 | 1252 | $listing_slug = 'places'; |
@@ -1259,11 +1259,11 @@ discard block |
||
| 1259 | 1259 | |
| 1260 | 1260 | $gd_placetags = array(); |
| 1261 | 1261 | $gd_placetags['object_type'] = 'gd_place'; |
| 1262 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1262 | + $gd_placetags['listing_slug'] = $listing_slug.'/tags'; |
|
| 1263 | 1263 | $gd_placetags['args'] = array( |
| 1264 | 1264 | 'public' => true, |
| 1265 | 1265 | 'hierarchical' => false, |
| 1266 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1266 | + 'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1267 | 1267 | 'query_var' => true, |
| 1268 | 1268 | |
| 1269 | 1269 | 'labels' => array( |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | 'menu_icon' => $menu_icon, |
| 1358 | 1358 | 'public' => true, |
| 1359 | 1359 | 'query_var' => true, |
| 1360 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1360 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1361 | 1361 | 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
| 1362 | 1362 | 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
| 1363 | 1363 | |
@@ -1390,12 +1390,12 @@ discard block |
||
| 1390 | 1390 | return $_REQUEST['lang']; |
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1393 | + $url = str_replace(array("http://", "https://"), "", $url);
|
|
| 1394 | 1394 | |
| 1395 | 1395 | // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
| 1396 | - $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1396 | + $site_url = str_replace(array("http://", "https://"), "", site_url());
|
|
| 1397 | 1397 | |
| 1398 | - $url = str_replace($site_url,"",$url); |
|
| 1398 | + $url = str_replace($site_url, "", $url); |
|
| 1399 | 1399 | |
| 1400 | 1400 | $segments = explode('/', trim($url, '/'));
|
| 1401 | 1401 | |
@@ -1461,9 +1461,9 @@ discard block |
||
| 1461 | 1461 | if (in_array($post->post_type, geodir_get_posttypes())) {
|
| 1462 | 1462 | |
| 1463 | 1463 | // if we dont have a GD post then try to grab it |
| 1464 | - if(!isset($post->default_category)){
|
|
| 1464 | + if (!isset($post->default_category)) {
|
|
| 1465 | 1465 | $gd_post = geodir_get_post_info($post->ID); |
| 1466 | - if(!empty($gd_post)){
|
|
| 1466 | + if (!empty($gd_post)) {
|
|
| 1467 | 1467 | $post = $gd_post; |
| 1468 | 1468 | } |
| 1469 | 1469 | } |
@@ -1473,17 +1473,17 @@ discard block |
||
| 1473 | 1473 | $slug = $post_types[$post->post_type]['rewrite']['slug']; |
| 1474 | 1474 | |
| 1475 | 1475 | // Alter the CPT slug if WPML is set to do so |
| 1476 | - if(function_exists('icl_object_id')){
|
|
| 1477 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1476 | + if (function_exists('icl_object_id')) {
|
|
| 1477 | + if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1478 | 1478 | |
| 1479 | 1479 | $org_slug = $slug; |
| 1480 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1480 | + $slug = apply_filters('wpml_translate_single_string',
|
|
| 1481 | 1481 | $slug, |
| 1482 | 1482 | 'WordPress', |
| 1483 | - 'URL slug: ' . $slug, |
|
| 1483 | + 'URL slug: '.$slug, |
|
| 1484 | 1484 | $language_code); |
| 1485 | 1485 | |
| 1486 | - if(!$slug){$slug = $org_slug;}
|
|
| 1486 | + if (!$slug) {$slug = $org_slug; }
|
|
| 1487 | 1487 | |
| 1488 | 1488 | } |
| 1489 | 1489 | } |
@@ -1505,11 +1505,11 @@ discard block |
||
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | $post_link = trailingslashit( |
| 1508 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1508 | + preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1)
|
|
| 1509 | 1509 | ); |
| 1510 | 1510 | |
| 1511 | 1511 | if ($fix_url) {
|
| 1512 | - $post_link = $site_url . $post_link; |
|
| 1512 | + $post_link = $site_url.$post_link; |
|
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | if (isset($comment_post_cache[$post->ID])) {
|
@@ -1528,12 +1528,12 @@ discard block |
||
| 1528 | 1528 | $ID = $post->ID; |
| 1529 | 1529 | $post2 = $wpdb->get_row( |
| 1530 | 1530 | $wpdb->prepare( |
| 1531 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1531 | + "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
| 1532 | 1532 | array($post->ID) |
| 1533 | 1533 | ) |
| 1534 | 1534 | ); |
| 1535 | 1535 | |
| 1536 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1536 | + $post = (object) array_merge((array) $post, (array) $post2); |
|
| 1537 | 1537 | |
| 1538 | 1538 | $comment_post_cache[$post->ID] = $post; |
| 1539 | 1539 | } |
@@ -1542,7 +1542,7 @@ discard block |
||
| 1542 | 1542 | |
| 1543 | 1543 | if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
| 1544 | 1544 | |
| 1545 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1545 | + if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) {
|
|
| 1546 | 1546 | $location_request = ''; |
| 1547 | 1547 | |
| 1548 | 1548 | |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
| 1557 | 1557 | $post->country_slug = str_replace(']', '', $post->country_slug);
|
| 1558 | 1558 | |
| 1559 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1559 | + $post_location = (object) array('country_slug' => $post->country_slug,
|
|
| 1560 | 1560 | 'region_slug' => $post->region_slug, |
| 1561 | 1561 | 'city_slug' => $post->city_slug |
| 1562 | 1562 | ); |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | |
| 1570 | 1570 | $post_location_sql = $wpdb->get_results( |
| 1571 | 1571 | $wpdb->prepare( |
| 1572 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1572 | + "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
| 1573 | 1573 | array($post->ID) |
| 1574 | 1574 | ) |
| 1575 | 1575 | ); |
@@ -1585,7 +1585,7 @@ discard block |
||
| 1585 | 1585 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
| 1586 | 1586 | $post->country_slug = str_replace(']', '', $post->country_slug);
|
| 1587 | 1587 | |
| 1588 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1588 | + $post_location = (object) array('country_slug' => $post->country_slug,
|
|
| 1589 | 1589 | 'region_slug' => $post->region_slug, |
| 1590 | 1590 | 'city_slug' => $post->city_slug |
| 1591 | 1591 | ); |
@@ -1614,7 +1614,7 @@ discard block |
||
| 1614 | 1614 | } |
| 1615 | 1615 | $location_slug[] = $city_slug; |
| 1616 | 1616 | |
| 1617 | - $location_request .= implode('/', $location_slug) . '/';
|
|
| 1617 | + $location_request .= implode('/', $location_slug).'/';
|
|
| 1618 | 1618 | } |
| 1619 | 1619 | } |
| 1620 | 1620 | |
@@ -1630,9 +1630,9 @@ discard block |
||
| 1630 | 1630 | } else {
|
| 1631 | 1631 | $post_terms = ''; |
| 1632 | 1632 | |
| 1633 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1633 | + if (isset($_POST['post_default_category']) && $_POST['post_default_category']) {
|
|
| 1634 | 1634 | $post_terms = absint($_POST['post_default_category']); |
| 1635 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1635 | + }elseif (isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1636 | 1636 | $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1637 | 1637 | $post_terms = absint($post_terms[0]); |
| 1638 | 1638 | }elseif (isset($post->{$taxonomies})) {
|
@@ -1678,14 +1678,14 @@ discard block |
||
| 1678 | 1678 | $request_term = trim($request_term, '/'); |
| 1679 | 1679 | |
| 1680 | 1680 | // Fix with WPML the location terms added twice when CPT slug is translated. |
| 1681 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1681 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) {
|
|
| 1682 | 1682 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | 1685 | if (!empty($request_term)) |
| 1686 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1686 | + $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
|
|
| 1687 | 1687 | else |
| 1688 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1688 | + $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
|
|
| 1689 | 1689 | //echo $post_link ; |
| 1690 | 1690 | } |
| 1691 | 1691 | // temp cache the permalink |
@@ -1760,9 +1760,9 @@ discard block |
||
| 1760 | 1760 | $url_separator = ''; |
| 1761 | 1761 | |
| 1762 | 1762 | if (get_option('permalink_structure') != '') {
|
| 1763 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1763 | + $old_listing_slug = '/'.$listing_slug.'/'; |
|
| 1764 | 1764 | $request_term = implode("/", $location_terms);
|
| 1765 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1765 | + $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/'; |
|
| 1766 | 1766 | |
| 1767 | 1767 | $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
| 1768 | 1768 | } else {
|
@@ -1782,25 +1782,25 @@ discard block |
||
| 1782 | 1782 | // Alter the CPT slug if WPML is set to do so |
| 1783 | 1783 | if (function_exists('icl_object_id')) {
|
| 1784 | 1784 | $post_types = get_option('geodir_post_types');
|
| 1785 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1786 | - $post_type = str_replace("_tags","",$post_type);
|
|
| 1785 | + $post_type = str_replace("category", "", $taxonomy);
|
|
| 1786 | + $post_type = str_replace("_tags", "", $post_type);
|
|
| 1787 | 1787 | $slug = $post_types[$post_type]['rewrite']['slug']; |
| 1788 | 1788 | if (gd_wpml_slug_translation_turned_on($post_type)) {
|
| 1789 | 1789 | global $sitepress; |
| 1790 | 1790 | $default_lang = $sitepress->get_default_language(); |
| 1791 | 1791 | $language_code = gd_wpml_get_lang_from_url($termlink); |
| 1792 | - if (!$language_code ) {
|
|
| 1793 | - $language_code = $default_lang; |
|
| 1792 | + if (!$language_code) {
|
|
| 1793 | + $language_code = $default_lang; |
|
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | 1796 | $org_slug = $slug; |
| 1797 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1797 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code);
|
|
| 1798 | 1798 | |
| 1799 | 1799 | if (!$slug) {
|
| 1800 | 1800 | $slug = $org_slug; |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1803 | + $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1));
|
|
| 1804 | 1804 | } |
| 1805 | 1805 | } |
| 1806 | 1806 | } |
@@ -1830,7 +1830,7 @@ discard block |
||
| 1830 | 1830 | |
| 1831 | 1831 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1832 | 1832 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1833 | - if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
|
| 1833 | + if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
|
| 1834 | 1834 | $location_terms = array( |
| 1835 | 1835 | 'gd_country' => $post->country_slug, |
| 1836 | 1836 | 'gd_region' => $post->region_slug, |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | $location_terms = implode("/", $location_terms);
|
| 1848 | 1848 | $location_terms = rtrim($location_terms, '/'); |
| 1849 | 1849 | |
| 1850 | - $link .= urldecode($location_terms) . '/'; |
|
| 1850 | + $link .= urldecode($location_terms).'/'; |
|
| 1851 | 1851 | } else {
|
| 1852 | 1852 | $link = geodir_getlink($link, $location_terms); |
| 1853 | 1853 | } |
@@ -1935,9 +1935,9 @@ discard block |
||
| 1935 | 1935 | return 0; |
| 1936 | 1936 | $where = 't.term_id = %d'; |
| 1937 | 1937 | if (!empty($taxonomy)) |
| 1938 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1938 | + return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1939 | 1939 | else |
| 1940 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1940 | + return $wpdb->get_var($wpdb->prepare($select.$where, $term)); |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | $term = trim(wp_unslash($term)); |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | |
| 1950 | 1950 | $where_fields = array($slug); |
| 1951 | 1951 | if (!empty($taxonomy)) {
|
| 1952 | - $parent = (int)$parent; |
|
| 1952 | + $parent = (int) $parent; |
|
| 1953 | 1953 | if ($parent > 0) {
|
| 1954 | 1954 | $where_fields[] = $parent; |
| 1955 | 1955 | $else_where_fields[] = $parent; |
@@ -2013,13 +2013,13 @@ discard block |
||
| 2013 | 2013 | $post_types = geodir_get_posttypes(); |
| 2014 | 2014 | $tax_arr = array(); |
| 2015 | 2015 | foreach ($post_types as $post_type) {
|
| 2016 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2016 | + $tax_arr[] = "'".$post_type."category'"; |
|
| 2017 | 2017 | } |
| 2018 | 2018 | $tax_c = implode(',', $tax_arr);
|
| 2019 | 2019 | $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
| 2020 | 2020 | //$terms = get_terms( $taxonomy ); |
| 2021 | 2021 | |
| 2022 | - if($terms) {
|
|
| 2022 | + if ($terms) {
|
|
| 2023 | 2023 | foreach ($terms as $term) {
|
| 2024 | 2024 | $post_type = str_replace("category", "", $term->taxonomy);
|
| 2025 | 2025 | $a_terms[$post_type][] = $term; |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | } |
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | - if($a_terms) {
|
|
| 2030 | + if ($a_terms) {
|
|
| 2031 | 2031 | foreach ($a_terms as $pt => $t2) {
|
| 2032 | 2032 | |
| 2033 | 2033 | foreach ($t2 as $term) {
|
@@ -2052,7 +2052,7 @@ discard block |
||
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | if (is_ssl()) {
|
| 2055 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2055 | + $terms_icons = str_replace("http:", "https:", $terms_icons);
|
|
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | if (get_option('geodir_show_listing_nav')) {
|
| 40 | 40 | |
| 41 | 41 | $menu_class = ''; |
| 42 | - if (geodir_is_page('listing'))
|
|
| 43 | - $menu_class = 'current-menu-item'; |
|
| 42 | + if (geodir_is_page('listing')) { |
|
| 43 | + $menu_class = 'current-menu-item'; |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | |
| 46 | 47 | //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | if (in_array($post_type, $show_post_type_main_nav)) {
|
| 53 | 54 | if (get_post_type_archive_link($post_type)) {
|
| 54 | 55 | $menu_class = ''; |
| 55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | - $menu_class = 'current-menu-item'; |
|
| 56 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { |
|
| 57 | + $menu_class = 'current-menu-item'; |
|
| 58 | + } |
|
| 57 | 59 | /** |
| 58 | 60 | * Filter the menu li class. |
| 59 | 61 | * |
@@ -130,8 +132,9 @@ discard block |
||
| 130 | 132 | if (get_post_type_archive_link($post_type)) {
|
| 131 | 133 | |
| 132 | 134 | $menu_class = ''; |
| 133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | - $menu_class = 'current-menu-item'; |
|
| 135 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { |
|
| 136 | + $menu_class = 'current-menu-item'; |
|
| 137 | + } |
|
| 135 | 138 | |
| 136 | 139 | $items .= '<li class="' . $sub_li_class . '"> |
| 137 | 140 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
@@ -159,8 +162,9 @@ discard block |
||
| 159 | 162 | if (get_option('geodir_show_addlisting_nav')) {
|
| 160 | 163 | |
| 161 | 164 | $menu_class = ''; |
| 162 | - if (geodir_is_page('add-listing'))
|
|
| 163 | - $menu_class = 'current-menu-item'; |
|
| 165 | + if (geodir_is_page('add-listing')) { |
|
| 166 | + $menu_class = 'current-menu-item'; |
|
| 167 | + } |
|
| 164 | 168 | |
| 165 | 169 | //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
| 166 | 170 | $post_types = geodir_get_posttypes('object');
|
@@ -176,8 +180,9 @@ discard block |
||
| 176 | 180 | if (geodir_get_addlisting_link($post_type)) {
|
| 177 | 181 | |
| 178 | 182 | $menu_class = ''; |
| 179 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 180 | - $menu_class = 'current-menu-item'; |
|
| 183 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { |
|
| 184 | + $menu_class = 'current-menu-item'; |
|
| 185 | + } |
|
| 181 | 186 | /** |
| 182 | 187 | * Filter the menu li class. |
| 183 | 188 | * |
@@ -261,8 +266,9 @@ discard block |
||
| 261 | 266 | if (geodir_get_addlisting_link($post_type)) {
|
| 262 | 267 | |
| 263 | 268 | $menu_class = ''; |
| 264 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 265 | - $menu_class = 'current-menu-item'; |
|
| 269 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { |
|
| 270 | + $menu_class = 'current-menu-item'; |
|
| 271 | + } |
|
| 266 | 272 | /** |
| 267 | 273 | * Filter the menu li class. |
| 268 | 274 | * |
@@ -319,8 +325,9 @@ discard block |
||
| 319 | 325 | } |
| 320 | 326 | //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
| 321 | 327 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 322 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 328 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) { |
|
| 329 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
| 330 | + } |
|
| 324 | 331 | |
| 325 | 332 | return $menu; |
| 326 | 333 | |
@@ -406,24 +413,28 @@ discard block |
||
| 406 | 413 | $geodir_post_type = get_query_var('post_type');
|
| 407 | 414 | |
| 408 | 415 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
| 409 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 411 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 412 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 416 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 417 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 418 | + } elseif (isset($_REQUEST['listing_type'])) { |
|
| 419 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 420 | + } |
|
| 413 | 421 | } |
| 414 | 422 | |
| 415 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 416 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 423 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) { |
|
| 424 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 425 | + } |
|
| 417 | 426 | |
| 418 | - if (is_tax()) |
|
| 419 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 427 | + if (is_tax()) { |
|
| 428 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 429 | + } |
|
| 420 | 430 | |
| 421 | 431 | |
| 422 | 432 | $all_postypes = geodir_get_posttypes(); |
| 423 | 433 | $all_postypes = stripslashes_deep($all_postypes); |
| 424 | 434 | |
| 425 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 426 | - $geodir_post_type = ''; |
|
| 435 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) { |
|
| 436 | + $geodir_post_type = ''; |
|
| 437 | + } |
|
| 427 | 438 | |
| 428 | 439 | if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
| 429 | 440 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
@@ -508,11 +519,12 @@ discard block |
||
| 508 | 519 | endswitch; |
| 509 | 520 | } |
| 510 | 521 | |
| 511 | - if (!empty($post_types)) |
|
| 512 | - return $post_types; |
|
| 513 | - else |
|
| 514 | - return array(); |
|
| 515 | -} |
|
| 522 | + if (!empty($post_types)) { |
|
| 523 | + return $post_types; |
|
| 524 | + } else { |
|
| 525 | + return array(); |
|
| 526 | + } |
|
| 527 | + } |
|
| 516 | 528 | |
| 517 | 529 | /** |
| 518 | 530 | * Get Custom Post Type info. |
@@ -529,9 +541,10 @@ discard block |
||
| 529 | 541 | $post_types = stripslashes_deep($post_types); |
| 530 | 542 | if (!empty($post_types) && $post_type != '') {
|
| 531 | 543 | return $post_types[$post_type]; |
| 532 | - } else |
|
| 533 | - return false; |
|
| 534 | -} |
|
| 544 | + } else { |
|
| 545 | + return false; |
|
| 546 | + } |
|
| 547 | + } |
|
| 535 | 548 | |
| 536 | 549 | if (!function_exists('geodir_get_taxonomies')) {
|
| 537 | 550 | /** |
@@ -555,18 +568,21 @@ discard block |
||
| 555 | 568 | $gd_taxonomies = array_keys($taxonomies); |
| 556 | 569 | |
| 557 | 570 | |
| 558 | - if ($post_type != '') |
|
| 559 | - $gd_taxonomies = array(); |
|
| 571 | + if ($post_type != '') { |
|
| 572 | + $gd_taxonomies = array(); |
|
| 573 | + } |
|
| 560 | 574 | |
| 561 | 575 | $i = 0; |
| 562 | 576 | foreach ($taxonomies as $taxonomy => $args) {
|
| 563 | 577 | |
| 564 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 565 | - $gd_taxonomies[] = $taxonomy; |
|
| 578 | + if ($post_type != '' && $args['object_type'] == $post_type) { |
|
| 579 | + $gd_taxonomies[] = $taxonomy; |
|
| 580 | + } |
|
| 566 | 581 | |
| 567 | 582 | if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
| 568 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 569 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 583 | + if (array_search($taxonomy, $gd_taxonomies) !== false) { |
|
| 584 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 585 | + } |
|
| 570 | 586 | } |
| 571 | 587 | |
| 572 | 588 | } |
@@ -621,10 +637,11 @@ discard block |
||
| 621 | 637 | . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
| 622 | 638 | } |
| 623 | 639 | |
| 624 | - if ($echo) |
|
| 625 | - echo $html; |
|
| 626 | - else |
|
| 627 | - return $html; |
|
| 640 | + if ($echo) { |
|
| 641 | + echo $html; |
|
| 642 | + } else { |
|
| 643 | + return $html; |
|
| 644 | + } |
|
| 628 | 645 | } |
| 629 | 646 | } |
| 630 | 647 | |
@@ -658,11 +675,12 @@ discard block |
||
| 658 | 675 | |
| 659 | 676 | } |
| 660 | 677 | |
| 661 | - if (!empty($listing_slug)) |
|
| 662 | - return $listing_slug; |
|
| 663 | - else |
|
| 664 | - return false; |
|
| 665 | -} |
|
| 678 | + if (!empty($listing_slug)) { |
|
| 679 | + return $listing_slug; |
|
| 680 | + } else { |
|
| 681 | + return false; |
|
| 682 | + } |
|
| 683 | + } |
|
| 666 | 684 | |
| 667 | 685 | |
| 668 | 686 | /** |
@@ -693,16 +711,18 @@ discard block |
||
| 693 | 711 | if (!empty($taxonomies)) {
|
| 694 | 712 | foreach (geodir_get_posttypes() as $pt) {
|
| 695 | 713 | $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
| 696 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 697 | - $post_type[] = $pt; |
|
| 714 | + if (array_intersect($taxonomies, $object_taxonomies)) { |
|
| 715 | + $post_type[] = $pt; |
|
| 716 | + } |
|
| 698 | 717 | } |
| 699 | 718 | } |
| 700 | 719 | |
| 701 | - if (!empty($post_type)) |
|
| 702 | - return $post_type[0]; |
|
| 703 | - else |
|
| 704 | - return false; |
|
| 705 | -} |
|
| 720 | + if (!empty($post_type)) { |
|
| 721 | + return $post_type[0]; |
|
| 722 | + } else { |
|
| 723 | + return false; |
|
| 724 | + } |
|
| 725 | + } |
|
| 706 | 726 | |
| 707 | 727 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 708 | 728 | /** |
@@ -758,18 +778,18 @@ discard block |
||
| 758 | 778 | $checked = ''; |
| 759 | 779 | |
| 760 | 780 | if (in_array($cat_term->term_id, $search_terms)) {
|
| 761 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 762 | - $checked = 'selected="selected"'; |
|
| 763 | - else |
|
| 764 | - $checked = 'checked="checked"'; |
|
| 781 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 782 | + $checked = 'selected="selected"'; |
|
| 783 | + } else { |
|
| 784 | + $checked = 'checked="checked"'; |
|
| 785 | + } |
|
| 765 | 786 | } |
| 766 | 787 | |
| 767 | - if ($cat_display == 'radio') |
|
| 768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 769 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 771 | - |
|
| 772 | - else {
|
|
| 788 | + if ($cat_display == 'radio') { |
|
| 789 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 790 | + } elseif ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 791 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 792 | + } else {
|
|
| 773 | 793 | $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
| 774 | 794 | } |
| 775 | 795 | |
@@ -778,8 +798,9 @@ discard block |
||
| 778 | 798 | |
| 779 | 799 | } |
| 780 | 800 | |
| 781 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 782 | - $out .= '</div>'; |
|
| 801 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
| 802 | + $out .= '</div>'; |
|
| 803 | + } |
|
| 783 | 804 | |
| 784 | 805 | return $out; |
| 785 | 806 | } |
@@ -805,18 +826,21 @@ discard block |
||
| 805 | 826 | global $exclude_cats, $gd_session; |
| 806 | 827 | |
| 807 | 828 | $cat_exclude = ''; |
| 808 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 809 | - $cat_exclude = serialize($exclude_cats); |
|
| 829 | + if (is_array($exclude_cats) && !empty($exclude_cats)) { |
|
| 830 | + $cat_exclude = serialize($exclude_cats); |
|
| 831 | + } |
|
| 810 | 832 | |
| 811 | 833 | if (isset($_REQUEST['backandedit'])) {
|
| 812 | 834 | $post = (object)$gd_session->get('listing');
|
| 813 | 835 | |
| 814 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 815 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 836 | + if (!is_array($post->post_category[$cat_taxonomy])) { |
|
| 837 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 838 | + } |
|
| 816 | 839 | |
| 817 | 840 | $post_categories = $post->post_category_str; |
| 818 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 819 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 841 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
| 842 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 843 | + } |
|
| 820 | 844 | |
| 821 | 845 | } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
| 822 | 846 | global $post; |
@@ -1007,8 +1031,9 @@ discard block |
||
| 1007 | 1031 | if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
| 1008 | 1032 | $post_cat_str = $post_categories[$cat_taxonomy]; |
| 1009 | 1033 | $post_cat_array = explode("#", $post_cat_str);
|
| 1010 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1011 | - $style = "display:none;"; |
|
| 1034 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) { |
|
| 1035 | + $style = "display:none;"; |
|
| 1036 | + } |
|
| 1012 | 1037 | } |
| 1013 | 1038 | ?> |
| 1014 | 1039 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
@@ -1043,7 +1068,7 @@ discard block |
||
| 1043 | 1068 | |
| 1044 | 1069 | if(is_array( $exclude_cats)){
|
| 1045 | 1070 | $exclude_cats = array_map( 'intval', $exclude_cats ); |
| 1046 | - }else{
|
|
| 1071 | + } else{
|
|
| 1047 | 1072 | $exclude_cats = intval($exclude_cats); |
| 1048 | 1073 | } |
| 1049 | 1074 | |
@@ -1073,7 +1098,10 @@ discard block |
||
| 1073 | 1098 | |
| 1074 | 1099 | <div class="post_default_category"> |
| 1075 | 1100 | <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
| 1076 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
| 1101 | + onchange="update_listing_cat()" <?php if ($default) { |
|
| 1102 | + echo ' checked="checked" '; |
|
| 1103 | +} |
|
| 1104 | +?> /> |
|
| 1077 | 1105 | <span> |
| 1078 | 1106 | <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
| 1079 | 1107 | </span> |
@@ -1173,8 +1201,9 @@ discard block |
||
| 1173 | 1201 | $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
| 1174 | 1202 | |
| 1175 | 1203 | $option_selected = ''; |
| 1176 | - if (!$selected) |
|
| 1177 | - $option_slected = ' selected="selected" '; |
|
| 1204 | + if (!$selected) { |
|
| 1205 | + $option_slected = ' selected="selected" '; |
|
| 1206 | + } |
|
| 1178 | 1207 | |
| 1179 | 1208 | echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
| 1180 | 1209 | |
@@ -1182,8 +1211,9 @@ discard block |
||
| 1182 | 1211 | |
| 1183 | 1212 | foreach ($cat_terms as $cat_term) {
|
| 1184 | 1213 | $option_selected = ''; |
| 1185 | - if ($selected == $cat_term->term_id) |
|
| 1186 | - $option_selected = ' selected="selected" '; |
|
| 1214 | + if ($selected == $cat_term->term_id) { |
|
| 1215 | + $option_selected = ' selected="selected" '; |
|
| 1216 | + } |
|
| 1187 | 1217 | |
| 1188 | 1218 | // Count child terms |
| 1189 | 1219 | $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
@@ -1248,8 +1278,9 @@ discard block |
||
| 1248 | 1278 | |
| 1249 | 1279 | $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
| 1250 | 1280 | |
| 1251 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1252 | - $listing_slug = 'places'; |
|
| 1281 | + if (!$listing_slug = get_option('geodir_listing_prefix')) { |
|
| 1282 | + $listing_slug = 'places'; |
|
| 1283 | + } |
|
| 1253 | 1284 | |
| 1254 | 1285 | /** |
| 1255 | 1286 | * Taxonomies |
@@ -1561,8 +1592,9 @@ discard block |
||
| 1561 | 1592 | 'city_slug' => $post->city_slug |
| 1562 | 1593 | ); |
| 1563 | 1594 | |
| 1564 | - } else |
|
| 1565 | - $post_location = geodir_get_location(); |
|
| 1595 | + } else { |
|
| 1596 | + $post_location = geodir_get_location(); |
|
| 1597 | + } |
|
| 1566 | 1598 | |
| 1567 | 1599 | |
| 1568 | 1600 | } else {
|
@@ -1591,8 +1623,9 @@ discard block |
||
| 1591 | 1623 | ); |
| 1592 | 1624 | |
| 1593 | 1625 | } |
| 1594 | - } else |
|
| 1595 | - $post_location = geodir_get_location(); |
|
| 1626 | + } else { |
|
| 1627 | + $post_location = geodir_get_location(); |
|
| 1628 | + } |
|
| 1596 | 1629 | } |
| 1597 | 1630 | |
| 1598 | 1631 | |
@@ -1632,16 +1665,17 @@ discard block |
||
| 1632 | 1665 | |
| 1633 | 1666 | if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
| 1634 | 1667 | $post_terms = absint($_POST['post_default_category']); |
| 1635 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1668 | + } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1636 | 1669 | $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1637 | 1670 | $post_terms = absint($post_terms[0]); |
| 1638 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1671 | + } elseif (isset($post->{$taxonomies})) {
|
|
| 1639 | 1672 | $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
| 1640 | 1673 | $post_terms = $post_terms[0]; |
| 1641 | 1674 | } |
| 1642 | 1675 | |
| 1643 | - if (!$post_terms) |
|
| 1644 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1676 | + if (!$post_terms) { |
|
| 1677 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1678 | + } |
|
| 1645 | 1679 | |
| 1646 | 1680 | if (!$post_terms) {
|
| 1647 | 1681 | $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
@@ -1655,8 +1689,9 @@ discard block |
||
| 1655 | 1689 | |
| 1656 | 1690 | $term = get_term_by('id', $post_terms, $taxonomies);
|
| 1657 | 1691 | |
| 1658 | - if (!empty($term)) |
|
| 1659 | - $term_request = $term->slug; |
|
| 1692 | + if (!empty($term)) { |
|
| 1693 | + $term_request = $term->slug; |
|
| 1694 | + } |
|
| 1660 | 1695 | //$term_request = $term->slug.'/'; |
| 1661 | 1696 | } |
| 1662 | 1697 | |
@@ -1671,9 +1706,13 @@ discard block |
||
| 1671 | 1706 | $request_term .= $term_request; |
| 1672 | 1707 | |
| 1673 | 1708 | } else {
|
| 1674 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1709 | + if (isset($location_request) && $location_request != '') { |
|
| 1710 | + $request_term = $location_request; |
|
| 1711 | + } |
|
| 1675 | 1712 | |
| 1676 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1713 | + if (isset($term_request) && $term_request != '') { |
|
| 1714 | + $request_term .= $term_request; |
|
| 1715 | + } |
|
| 1677 | 1716 | } |
| 1678 | 1717 | $request_term = trim($request_term, '/'); |
| 1679 | 1718 | |
@@ -1682,10 +1721,11 @@ discard block |
||
| 1682 | 1721 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1683 | 1722 | } |
| 1684 | 1723 | |
| 1685 | - if (!empty($request_term)) |
|
| 1686 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1687 | - else |
|
| 1688 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1724 | + if (!empty($request_term)) { |
|
| 1725 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1726 | + } else { |
|
| 1727 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1728 | + } |
|
| 1689 | 1729 | //echo $post_link ; |
| 1690 | 1730 | } |
| 1691 | 1731 | // temp cache the permalink |
@@ -1877,11 +1917,12 @@ discard block |
||
| 1877 | 1917 | |
| 1878 | 1918 | $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
| 1879 | 1919 | |
| 1880 | - if ($echo) |
|
| 1881 | - echo $label; |
|
| 1882 | - else |
|
| 1883 | - return $label; |
|
| 1884 | -} |
|
| 1920 | + if ($echo) { |
|
| 1921 | + echo $label; |
|
| 1922 | + } else { |
|
| 1923 | + return $label; |
|
| 1924 | + } |
|
| 1925 | + } |
|
| 1885 | 1926 | |
| 1886 | 1927 | /** |
| 1887 | 1928 | * Print or Get post type plural label. |
@@ -1897,18 +1938,20 @@ discard block |
||
| 1897 | 1938 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1898 | 1939 | $all_postypes = geodir_get_posttypes(); |
| 1899 | 1940 | |
| 1900 | - if (!in_array($post_type, $all_postypes)) |
|
| 1901 | - return false; |
|
| 1941 | + if (!in_array($post_type, $all_postypes)) { |
|
| 1942 | + return false; |
|
| 1943 | + } |
|
| 1902 | 1944 | |
| 1903 | 1945 | $obj_post_type = get_post_type_object($post_type); |
| 1904 | 1946 | |
| 1905 | 1947 | $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
| 1906 | 1948 | |
| 1907 | - if ($echo) |
|
| 1908 | - echo $label; |
|
| 1909 | - else |
|
| 1910 | - return $label; |
|
| 1911 | -} |
|
| 1949 | + if ($echo) { |
|
| 1950 | + echo $label; |
|
| 1951 | + } else { |
|
| 1952 | + return $label; |
|
| 1953 | + } |
|
| 1954 | + } |
|
| 1912 | 1955 | |
| 1913 | 1956 | /** |
| 1914 | 1957 | * Checks whether a term exists or not. |
@@ -1931,19 +1974,22 @@ discard block |
||
| 1931 | 1974 | $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
| 1932 | 1975 | |
| 1933 | 1976 | if (is_int($term)) {
|
| 1934 | - if (0 == $term) |
|
| 1935 | - return 0; |
|
| 1977 | + if (0 == $term) { |
|
| 1978 | + return 0; |
|
| 1979 | + } |
|
| 1936 | 1980 | $where = 't.term_id = %d'; |
| 1937 | - if (!empty($taxonomy)) |
|
| 1938 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1939 | - else |
|
| 1940 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1981 | + if (!empty($taxonomy)) { |
|
| 1982 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1983 | + } else { |
|
| 1984 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1985 | + } |
|
| 1941 | 1986 | } |
| 1942 | 1987 | |
| 1943 | 1988 | $term = trim(wp_unslash($term)); |
| 1944 | 1989 | |
| 1945 | - if ('' === $slug = sanitize_title($term))
|
|
| 1946 | - return 0; |
|
| 1990 | + if ('' === $slug = sanitize_title($term)) { |
|
| 1991 | + return 0; |
|
| 1992 | + } |
|
| 1947 | 1993 | |
| 1948 | 1994 | $where = 't.slug = %s'; |
| 1949 | 1995 | |
@@ -1960,14 +2006,16 @@ discard block |
||
| 1960 | 2006 | $where_fields[] = $taxonomy; |
| 1961 | 2007 | |
| 1962 | 2008 | |
| 1963 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1964 | - return $result; |
|
| 2009 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) { |
|
| 2010 | + return $result; |
|
| 2011 | + } |
|
| 1965 | 2012 | |
| 1966 | 2013 | return false; |
| 1967 | 2014 | } |
| 1968 | 2015 | |
| 1969 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1970 | - return $result; |
|
| 2016 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) { |
|
| 2017 | + return $result; |
|
| 2018 | + } |
|
| 1971 | 2019 | |
| 1972 | 2020 | return false; |
| 1973 | 2021 | } |
@@ -10,52 +10,52 @@ discard block |
||
| 10 | 10 | global $wpdb, $table_prefix; |
| 11 | 11 | |
| 12 | 12 | if (!function_exists('geodir_column_exist')) {
|
| 13 | - /** |
|
| 14 | - * Check table column exist or not. |
|
| 15 | - * |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - * @package GeoDirectory |
|
| 18 | - * @global object $wpdb WordPress Database object. |
|
| 19 | - * @param string $db The table name. |
|
| 20 | - * @param string $column The column name. |
|
| 21 | - * @return bool If column exists returns true. Otherwise false. |
|
| 22 | - */ |
|
| 23 | - function geodir_column_exist($db, $column) |
|
| 24 | - {
|
|
| 25 | - global $wpdb; |
|
| 26 | - $exists = false; |
|
| 27 | - $columns = $wpdb->get_col("show columns from $db");
|
|
| 28 | - foreach ($columns as $c) {
|
|
| 29 | - if ($c == $column) {
|
|
| 30 | - $exists = true; |
|
| 31 | - break; |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | - return $exists; |
|
| 35 | - } |
|
| 13 | + /** |
|
| 14 | + * Check table column exist or not. |
|
| 15 | + * |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + * @package GeoDirectory |
|
| 18 | + * @global object $wpdb WordPress Database object. |
|
| 19 | + * @param string $db The table name. |
|
| 20 | + * @param string $column The column name. |
|
| 21 | + * @return bool If column exists returns true. Otherwise false. |
|
| 22 | + */ |
|
| 23 | + function geodir_column_exist($db, $column) |
|
| 24 | + {
|
|
| 25 | + global $wpdb; |
|
| 26 | + $exists = false; |
|
| 27 | + $columns = $wpdb->get_col("show columns from $db");
|
|
| 28 | + foreach ($columns as $c) {
|
|
| 29 | + if ($c == $column) {
|
|
| 30 | + $exists = true; |
|
| 31 | + break; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | + return $exists; |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | if (!function_exists('geodir_add_column_if_not_exist')) {
|
| 39 | - /** |
|
| 40 | - * Add column if table column not exist. |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * @package GeoDirectory |
|
| 44 | - * @global object $wpdb WordPress Database object. |
|
| 45 | - * @param string $db The table name. |
|
| 46 | - * @param string $column The column name. |
|
| 47 | - * @param string $column_attr The column attributes. |
|
| 48 | - */ |
|
| 49 | - function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
| 50 | - {
|
|
| 51 | - global $wpdb; |
|
| 52 | - $result = 0;// no rows affected |
|
| 53 | - if (!geodir_column_exist($db, $column)) {
|
|
| 54 | - if (!empty($db) && !empty($column)) |
|
| 55 | - $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr");
|
|
| 56 | - } |
|
| 57 | - return $result; |
|
| 58 | - } |
|
| 39 | + /** |
|
| 40 | + * Add column if table column not exist. |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * @package GeoDirectory |
|
| 44 | + * @global object $wpdb WordPress Database object. |
|
| 45 | + * @param string $db The table name. |
|
| 46 | + * @param string $column The column name. |
|
| 47 | + * @param string $column_attr The column attributes. |
|
| 48 | + */ |
|
| 49 | + function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
| 50 | + {
|
|
| 51 | + global $wpdb; |
|
| 52 | + $result = 0;// no rows affected |
|
| 53 | + if (!geodir_column_exist($db, $column)) {
|
|
| 54 | + if (!empty($db) && !empty($column)) |
|
| 55 | + $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr");
|
|
| 56 | + } |
|
| 57 | + return $result; |
|
| 58 | + } |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -72,706 +72,706 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function geodir_post_custom_fields($package_id = '', $default = 'all', $post_type = 'gd_place', $fields_location = 'none') |
| 74 | 74 | {
|
| 75 | - global $wpdb, $geodir_post_custom_fields_cache; |
|
| 76 | - |
|
| 77 | - $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location; |
|
| 78 | - |
|
| 79 | - if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
|
|
| 80 | - return $geodir_post_custom_fields_cache[$cache_stored]; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $default_query = ''; |
|
| 84 | - |
|
| 85 | - if ($default == 'default') |
|
| 86 | - $default_query .= " and is_admin IN ('1') ";
|
|
| 87 | - elseif ($default == 'custom') |
|
| 88 | - $default_query .= " and is_admin = '0' "; |
|
| 89 | - |
|
| 90 | - if ($fields_location == 'none') {
|
|
| 91 | - } else{
|
|
| 92 | - $fields_location = esc_sql( $fields_location ); |
|
| 93 | - $default_query .= " and show_in LIKE '%%[$fields_location]%%' "; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $post_meta_info = $wpdb->get_results( |
|
| 97 | - $wpdb->prepare( |
|
| 98 | - "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
|
|
| 99 | - array($post_type) |
|
| 100 | - ) |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - $return_arr = array(); |
|
| 105 | - if ($post_meta_info) {
|
|
| 106 | - |
|
| 107 | - foreach ($post_meta_info as $post_meta_info_obj) {
|
|
| 108 | - |
|
| 109 | - $custom_fields = array( |
|
| 110 | - "name" => $post_meta_info_obj->htmlvar_name, |
|
| 111 | - "label" => $post_meta_info_obj->clabels, |
|
| 112 | - "default" => $post_meta_info_obj->default_value, |
|
| 113 | - "type" => $post_meta_info_obj->field_type, |
|
| 114 | - "desc" => $post_meta_info_obj->admin_desc); |
|
| 115 | - |
|
| 116 | - if ($post_meta_info_obj->field_type) {
|
|
| 117 | - $options = explode(',', $post_meta_info_obj->option_values);
|
|
| 118 | - $custom_fields["options"] = $options; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - foreach ($post_meta_info_obj as $key => $val) {
|
|
| 122 | - $custom_fields[$key] = $val; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $pricearr = array(); |
|
| 126 | - $pricearr = explode(',', $post_meta_info_obj->packages);
|
|
| 127 | - |
|
| 128 | - if ($package_id != '' && in_array($package_id, $pricearr)) {
|
|
| 129 | - $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
| 130 | - } elseif ($package_id == '') {
|
|
| 131 | - $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $geodir_post_custom_fields_cache[$cache_stored] = $return_arr; |
|
| 136 | - |
|
| 137 | - if (has_filter('geodir_filter_geodir_post_custom_fields')) {
|
|
| 138 | - /** |
|
| 139 | - * Filter the post custom fields array. |
|
| 140 | - * |
|
| 141 | - * @since 1.0.0 |
|
| 142 | - * |
|
| 143 | - * @param array $return_arr Post custom fields array. |
|
| 144 | - * @param int|string $package_id The package ID. |
|
| 145 | - * @param string $post_type Optional. The wordpress post type. |
|
| 146 | - * @param string $fields_location Optional. Where exactly are you going to place this custom fields?. |
|
| 147 | - */ |
|
| 148 | - $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
|
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $return_arr; |
|
| 75 | + global $wpdb, $geodir_post_custom_fields_cache; |
|
| 76 | + |
|
| 77 | + $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location; |
|
| 78 | + |
|
| 79 | + if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
|
|
| 80 | + return $geodir_post_custom_fields_cache[$cache_stored]; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $default_query = ''; |
|
| 84 | + |
|
| 85 | + if ($default == 'default') |
|
| 86 | + $default_query .= " and is_admin IN ('1') ";
|
|
| 87 | + elseif ($default == 'custom') |
|
| 88 | + $default_query .= " and is_admin = '0' "; |
|
| 89 | + |
|
| 90 | + if ($fields_location == 'none') {
|
|
| 91 | + } else{
|
|
| 92 | + $fields_location = esc_sql( $fields_location ); |
|
| 93 | + $default_query .= " and show_in LIKE '%%[$fields_location]%%' "; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $post_meta_info = $wpdb->get_results( |
|
| 97 | + $wpdb->prepare( |
|
| 98 | + "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
|
|
| 99 | + array($post_type) |
|
| 100 | + ) |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + $return_arr = array(); |
|
| 105 | + if ($post_meta_info) {
|
|
| 106 | + |
|
| 107 | + foreach ($post_meta_info as $post_meta_info_obj) {
|
|
| 108 | + |
|
| 109 | + $custom_fields = array( |
|
| 110 | + "name" => $post_meta_info_obj->htmlvar_name, |
|
| 111 | + "label" => $post_meta_info_obj->clabels, |
|
| 112 | + "default" => $post_meta_info_obj->default_value, |
|
| 113 | + "type" => $post_meta_info_obj->field_type, |
|
| 114 | + "desc" => $post_meta_info_obj->admin_desc); |
|
| 115 | + |
|
| 116 | + if ($post_meta_info_obj->field_type) {
|
|
| 117 | + $options = explode(',', $post_meta_info_obj->option_values);
|
|
| 118 | + $custom_fields["options"] = $options; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + foreach ($post_meta_info_obj as $key => $val) {
|
|
| 122 | + $custom_fields[$key] = $val; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $pricearr = array(); |
|
| 126 | + $pricearr = explode(',', $post_meta_info_obj->packages);
|
|
| 127 | + |
|
| 128 | + if ($package_id != '' && in_array($package_id, $pricearr)) {
|
|
| 129 | + $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
| 130 | + } elseif ($package_id == '') {
|
|
| 131 | + $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $geodir_post_custom_fields_cache[$cache_stored] = $return_arr; |
|
| 136 | + |
|
| 137 | + if (has_filter('geodir_filter_geodir_post_custom_fields')) {
|
|
| 138 | + /** |
|
| 139 | + * Filter the post custom fields array. |
|
| 140 | + * |
|
| 141 | + * @since 1.0.0 |
|
| 142 | + * |
|
| 143 | + * @param array $return_arr Post custom fields array. |
|
| 144 | + * @param int|string $package_id The package ID. |
|
| 145 | + * @param string $post_type Optional. The wordpress post type. |
|
| 146 | + * @param string $fields_location Optional. Where exactly are you going to place this custom fields?. |
|
| 147 | + */ |
|
| 148 | + $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
|
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + return $return_arr; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Adds admin html for custom fields. |
|
| 156 | - * |
|
| 157 | - * @since 1.0.0 |
|
| 158 | - * @package GeoDirectory |
|
| 159 | - * @global object $wpdb WordPress Database object. |
|
| 160 | - * @param string $field_type The form field type. |
|
| 161 | - * @param object|int $result_str The custom field results object or row id. |
|
| 162 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
| 163 | - * @param string $field_type_key The key of the custom field. |
|
| 164 | - */ |
|
| 165 | - function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='') |
|
| 166 | - {
|
|
| 167 | - global $wpdb; |
|
| 168 | - $cf = $result_str; |
|
| 169 | - if (!is_object($cf)) {
|
|
| 170 | - |
|
| 171 | - $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
|
|
| 172 | - |
|
| 173 | - } else {
|
|
| 174 | - $field_info = $cf; |
|
| 175 | - $result_str = $cf->id; |
|
| 176 | - } |
|
| 177 | - /** |
|
| 178 | - * Contains custom field html. |
|
| 179 | - * |
|
| 180 | - * @since 1.0.0 |
|
| 181 | - */ |
|
| 182 | - include('custom_field_html.php');
|
|
| 183 | - |
|
| 184 | - } |
|
| 154 | + /** |
|
| 155 | + * Adds admin html for custom fields. |
|
| 156 | + * |
|
| 157 | + * @since 1.0.0 |
|
| 158 | + * @package GeoDirectory |
|
| 159 | + * @global object $wpdb WordPress Database object. |
|
| 160 | + * @param string $field_type The form field type. |
|
| 161 | + * @param object|int $result_str The custom field results object or row id. |
|
| 162 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
| 163 | + * @param string $field_type_key The key of the custom field. |
|
| 164 | + */ |
|
| 165 | + function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='') |
|
| 166 | + {
|
|
| 167 | + global $wpdb; |
|
| 168 | + $cf = $result_str; |
|
| 169 | + if (!is_object($cf)) {
|
|
| 170 | + |
|
| 171 | + $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
|
|
| 172 | + |
|
| 173 | + } else {
|
|
| 174 | + $field_info = $cf; |
|
| 175 | + $result_str = $cf->id; |
|
| 176 | + } |
|
| 177 | + /** |
|
| 178 | + * Contains custom field html. |
|
| 179 | + * |
|
| 180 | + * @since 1.0.0 |
|
| 181 | + */ |
|
| 182 | + include('custom_field_html.php');
|
|
| 183 | + |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | if (!function_exists('geodir_custom_field_delete')) {
|
| 188 | - /** |
|
| 189 | - * Delete custom field using field id. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.0 |
|
| 192 | - * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
| 193 | - * @package GeoDirectory |
|
| 194 | - * @global object $wpdb WordPress Database object. |
|
| 195 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 196 | - * @param string $field_id The custom field ID. |
|
| 197 | - * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
| 198 | - */ |
|
| 199 | - function geodir_custom_field_delete($field_id = '') {
|
|
| 200 | - global $wpdb, $plugin_prefix; |
|
| 201 | - |
|
| 202 | - if ($field_id != '') {
|
|
| 203 | - $cf = trim($field_id, '_'); |
|
| 204 | - |
|
| 205 | - if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
|
|
| 206 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
|
|
| 207 | - |
|
| 208 | - $post_type = $field->post_type; |
|
| 209 | - $htmlvar_name = $field->htmlvar_name; |
|
| 210 | - |
|
| 211 | - if ($post_type != '' && $htmlvar_name != '') {
|
|
| 212 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
|
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Called after a custom field is deleted. |
|
| 217 | - * |
|
| 218 | - * @since 1.0.0 |
|
| 219 | - * @param string $cf The fields ID. |
|
| 220 | - * @param string $field->htmlvar_name The html variable name for the field. |
|
| 221 | - * @param string $post_type The post type the field belongs to. |
|
| 222 | - */ |
|
| 223 | - do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
|
|
| 224 | - |
|
| 225 | - if ($field->field_type == 'address') {
|
|
| 226 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
|
|
| 227 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
|
|
| 228 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
|
|
| 229 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
|
|
| 230 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
|
|
| 231 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
|
|
| 232 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
|
|
| 233 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
|
|
| 234 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
|
|
| 235 | - } else {
|
|
| 236 | - if ($field->field_type != 'fieldset') {
|
|
| 237 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
|
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $field_id; |
|
| 242 | - } else |
|
| 243 | - return 0; |
|
| 244 | - } else |
|
| 245 | - return 0; |
|
| 246 | - } |
|
| 188 | + /** |
|
| 189 | + * Delete custom field using field id. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.0 |
|
| 192 | + * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
| 193 | + * @package GeoDirectory |
|
| 194 | + * @global object $wpdb WordPress Database object. |
|
| 195 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 196 | + * @param string $field_id The custom field ID. |
|
| 197 | + * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
| 198 | + */ |
|
| 199 | + function geodir_custom_field_delete($field_id = '') {
|
|
| 200 | + global $wpdb, $plugin_prefix; |
|
| 201 | + |
|
| 202 | + if ($field_id != '') {
|
|
| 203 | + $cf = trim($field_id, '_'); |
|
| 204 | + |
|
| 205 | + if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
|
|
| 206 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
|
|
| 207 | + |
|
| 208 | + $post_type = $field->post_type; |
|
| 209 | + $htmlvar_name = $field->htmlvar_name; |
|
| 210 | + |
|
| 211 | + if ($post_type != '' && $htmlvar_name != '') {
|
|
| 212 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
|
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Called after a custom field is deleted. |
|
| 217 | + * |
|
| 218 | + * @since 1.0.0 |
|
| 219 | + * @param string $cf The fields ID. |
|
| 220 | + * @param string $field->htmlvar_name The html variable name for the field. |
|
| 221 | + * @param string $post_type The post type the field belongs to. |
|
| 222 | + */ |
|
| 223 | + do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
|
|
| 224 | + |
|
| 225 | + if ($field->field_type == 'address') {
|
|
| 226 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
|
|
| 227 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
|
|
| 228 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
|
|
| 229 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
|
|
| 230 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
|
|
| 231 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
|
|
| 232 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
|
|
| 233 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
|
|
| 234 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
|
|
| 235 | + } else {
|
|
| 236 | + if ($field->field_type != 'fieldset') {
|
|
| 237 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
|
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $field_id; |
|
| 242 | + } else |
|
| 243 | + return 0; |
|
| 244 | + } else |
|
| 245 | + return 0; |
|
| 246 | + } |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | if (!function_exists('geodir_custom_field_save')) {
|
| 250 | - /** |
|
| 251 | - * Save or Update custom fields into the database. |
|
| 252 | - * |
|
| 253 | - * @since 1.0.0 |
|
| 254 | - * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. |
|
| 255 | - * @package GeoDirectory |
|
| 256 | - * @global object $wpdb WordPress Database object. |
|
| 257 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 258 | - * @param array $request_field {
|
|
| 259 | - * Attributes of the request field array. |
|
| 260 | - * |
|
| 261 | - * @type string $action Ajax Action name. Default "geodir_ajax_action". |
|
| 262 | - * @type string $manage_field_type Field type Default "custom_fields". |
|
| 263 | - * @type string $create_field Create field Default "true". |
|
| 264 | - * @type string $field_ins_upd Field ins upd Default "submit". |
|
| 265 | - * @type string $_wpnonce WP nonce value. |
|
| 266 | - * @type string $listing_type Listing type Example "gd_place". |
|
| 267 | - * @type string $field_type Field type Example "radio". |
|
| 268 | - * @type string $field_id Field id Example "12". |
|
| 269 | - * @type string $data_type Data type Example "VARCHAR". |
|
| 270 | - * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. |
|
| 271 | - * @type array $show_on_pkg Package list to display this field. |
|
| 272 | - * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. |
|
| 273 | - * @type string $site_title Section title which you wish to display in frontend. |
|
| 274 | - * @type string $admin_desc Section description which will appear in frontend. |
|
| 275 | - * @type string $htmlvar_name Html variable name. This should be a unique name. |
|
| 276 | - * @type string $clabels Section Title which will appear in backend. |
|
| 277 | - * @type string $default_value The default value (for "link" this will be used as the link text). |
|
| 278 | - * @type string $sort_order The display order of this field in backend. e.g. 5. |
|
| 279 | - * @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field. |
|
| 280 | - * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. |
|
| 281 | - * @type string $is_required Use "1" to set field as required. |
|
| 282 | - * @type string $required_msg Enter text for error message if field required and have not full fill requirement. |
|
| 283 | - * @type string $show_on_listing Want to show this on listing page?. |
|
| 284 | - * @type string $show_in What locations to show the custom field in. |
|
| 285 | - * @type string $show_on_detail Want to show this in More Info tab on detail page?. |
|
| 286 | - * @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes. |
|
| 287 | - * @type string $option_values Option Values should be separated by comma. |
|
| 288 | - * @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class. |
|
| 289 | - * @type string $css_class Enter custom css class for field custom style. |
|
| 290 | - * @type array $extra_fields An array of extra fields to store. |
|
| 291 | - * |
|
| 292 | - * } |
|
| 293 | - * @param bool $default Not yet implemented. |
|
| 294 | - * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
| 295 | - */ |
|
| 296 | - function geodir_custom_field_save($request_field = array(), $default = false) |
|
| 297 | - {
|
|
| 298 | - |
|
| 299 | - global $wpdb, $plugin_prefix; |
|
| 300 | - |
|
| 301 | - $old_html_variable = ''; |
|
| 302 | - |
|
| 303 | - $data_type = trim($request_field['data_type']); |
|
| 304 | - |
|
| 305 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
| 306 | - |
|
| 307 | - // some servers fail if a POST value is VARCHAR so we change it. |
|
| 308 | - if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
|
|
| 309 | - $request_field['data_type'] = 'VARCHAR'; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - $cf = trim($result_str, '_'); |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /*-------- check duplicate validation --------*/ |
|
| 316 | - |
|
| 317 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 318 | - $post_type = $request_field['listing_type']; |
|
| 319 | - |
|
| 320 | - if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
|
|
| 321 | - $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - $check_html_variable = $wpdb->get_var( |
|
| 325 | - $wpdb->prepare( |
|
| 326 | - "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
| 327 | - array($cf, $cehhtmlvar_name, $post_type) |
|
| 328 | - ) |
|
| 329 | - ); |
|
| 330 | - |
|
| 331 | - |
|
| 332 | - if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
|
|
| 333 | - |
|
| 334 | - if ($cf != '') {
|
|
| 335 | - |
|
| 336 | - $post_meta_info = $wpdb->get_row( |
|
| 337 | - $wpdb->prepare( |
|
| 338 | - "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
| 339 | - array($cf) |
|
| 340 | - ) |
|
| 341 | - ); |
|
| 342 | - |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if (!empty($post_meta_info)) {
|
|
| 346 | - $post_val = $post_meta_info; |
|
| 347 | - $old_html_variable = $post_val->htmlvar_name; |
|
| 348 | - |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - if ($post_type == '') $post_type = 'gd_place'; |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 357 | - |
|
| 358 | - $admin_title = $request_field['admin_title']; |
|
| 359 | - $site_title = $request_field['site_title']; |
|
| 360 | - $data_type = $request_field['data_type']; |
|
| 361 | - $field_type = $request_field['field_type']; |
|
| 362 | - $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
| 363 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 364 | - $admin_desc = $request_field['admin_desc']; |
|
| 365 | - $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : ''; |
|
| 366 | - $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
| 367 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
| 368 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
| 369 | - $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
| 370 | - $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
| 371 | - $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
| 372 | - $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
| 373 | - $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
| 374 | - $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
| 375 | - $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
| 376 | - $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
| 377 | - $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
| 378 | - $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
| 379 | - $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
| 380 | - $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
| 381 | - $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
| 250 | + /** |
|
| 251 | + * Save or Update custom fields into the database. |
|
| 252 | + * |
|
| 253 | + * @since 1.0.0 |
|
| 254 | + * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. |
|
| 255 | + * @package GeoDirectory |
|
| 256 | + * @global object $wpdb WordPress Database object. |
|
| 257 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 258 | + * @param array $request_field {
|
|
| 259 | + * Attributes of the request field array. |
|
| 260 | + * |
|
| 261 | + * @type string $action Ajax Action name. Default "geodir_ajax_action". |
|
| 262 | + * @type string $manage_field_type Field type Default "custom_fields". |
|
| 263 | + * @type string $create_field Create field Default "true". |
|
| 264 | + * @type string $field_ins_upd Field ins upd Default "submit". |
|
| 265 | + * @type string $_wpnonce WP nonce value. |
|
| 266 | + * @type string $listing_type Listing type Example "gd_place". |
|
| 267 | + * @type string $field_type Field type Example "radio". |
|
| 268 | + * @type string $field_id Field id Example "12". |
|
| 269 | + * @type string $data_type Data type Example "VARCHAR". |
|
| 270 | + * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. |
|
| 271 | + * @type array $show_on_pkg Package list to display this field. |
|
| 272 | + * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. |
|
| 273 | + * @type string $site_title Section title which you wish to display in frontend. |
|
| 274 | + * @type string $admin_desc Section description which will appear in frontend. |
|
| 275 | + * @type string $htmlvar_name Html variable name. This should be a unique name. |
|
| 276 | + * @type string $clabels Section Title which will appear in backend. |
|
| 277 | + * @type string $default_value The default value (for "link" this will be used as the link text). |
|
| 278 | + * @type string $sort_order The display order of this field in backend. e.g. 5. |
|
| 279 | + * @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field. |
|
| 280 | + * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. |
|
| 281 | + * @type string $is_required Use "1" to set field as required. |
|
| 282 | + * @type string $required_msg Enter text for error message if field required and have not full fill requirement. |
|
| 283 | + * @type string $show_on_listing Want to show this on listing page?. |
|
| 284 | + * @type string $show_in What locations to show the custom field in. |
|
| 285 | + * @type string $show_on_detail Want to show this in More Info tab on detail page?. |
|
| 286 | + * @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes. |
|
| 287 | + * @type string $option_values Option Values should be separated by comma. |
|
| 288 | + * @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class. |
|
| 289 | + * @type string $css_class Enter custom css class for field custom style. |
|
| 290 | + * @type array $extra_fields An array of extra fields to store. |
|
| 291 | + * |
|
| 292 | + * } |
|
| 293 | + * @param bool $default Not yet implemented. |
|
| 294 | + * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
| 295 | + */ |
|
| 296 | + function geodir_custom_field_save($request_field = array(), $default = false) |
|
| 297 | + {
|
|
| 298 | + |
|
| 299 | + global $wpdb, $plugin_prefix; |
|
| 300 | + |
|
| 301 | + $old_html_variable = ''; |
|
| 302 | + |
|
| 303 | + $data_type = trim($request_field['data_type']); |
|
| 304 | + |
|
| 305 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
| 306 | + |
|
| 307 | + // some servers fail if a POST value is VARCHAR so we change it. |
|
| 308 | + if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
|
|
| 309 | + $request_field['data_type'] = 'VARCHAR'; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + $cf = trim($result_str, '_'); |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /*-------- check duplicate validation --------*/ |
|
| 316 | + |
|
| 317 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 318 | + $post_type = $request_field['listing_type']; |
|
| 319 | + |
|
| 320 | + if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
|
|
| 321 | + $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + $check_html_variable = $wpdb->get_var( |
|
| 325 | + $wpdb->prepare( |
|
| 326 | + "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
| 327 | + array($cf, $cehhtmlvar_name, $post_type) |
|
| 328 | + ) |
|
| 329 | + ); |
|
| 330 | + |
|
| 331 | + |
|
| 332 | + if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
|
|
| 333 | + |
|
| 334 | + if ($cf != '') {
|
|
| 335 | + |
|
| 336 | + $post_meta_info = $wpdb->get_row( |
|
| 337 | + $wpdb->prepare( |
|
| 338 | + "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
| 339 | + array($cf) |
|
| 340 | + ) |
|
| 341 | + ); |
|
| 342 | + |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + if (!empty($post_meta_info)) {
|
|
| 346 | + $post_val = $post_meta_info; |
|
| 347 | + $old_html_variable = $post_val->htmlvar_name; |
|
| 348 | + |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + if ($post_type == '') $post_type = 'gd_place'; |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 357 | + |
|
| 358 | + $admin_title = $request_field['admin_title']; |
|
| 359 | + $site_title = $request_field['site_title']; |
|
| 360 | + $data_type = $request_field['data_type']; |
|
| 361 | + $field_type = $request_field['field_type']; |
|
| 362 | + $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
| 363 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 364 | + $admin_desc = $request_field['admin_desc']; |
|
| 365 | + $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : ''; |
|
| 366 | + $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
| 367 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
| 368 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
| 369 | + $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
| 370 | + $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
| 371 | + $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
| 372 | + $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
| 373 | + $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
| 374 | + $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
| 375 | + $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
| 376 | + $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
| 377 | + $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
| 378 | + $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
| 379 | + $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
| 380 | + $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
| 381 | + $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
| 382 | 382 | |
| 383 | 383 | |
| 384 | - if(is_array($show_in)){
|
|
| 385 | - $show_in = implode(",", $request_field['show_in']);
|
|
| 386 | - } |
|
| 384 | + if(is_array($show_in)){
|
|
| 385 | + $show_in = implode(",", $request_field['show_in']);
|
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
|
|
| 389 | - $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
| 390 | - } |
|
| 388 | + if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
|
|
| 389 | + $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - $option_values = ''; |
|
| 393 | - if (isset($request_field['option_values'])) |
|
| 394 | - $option_values = $request_field['option_values']; |
|
| 392 | + $option_values = ''; |
|
| 393 | + if (isset($request_field['option_values'])) |
|
| 394 | + $option_values = $request_field['option_values']; |
|
| 395 | 395 | |
| 396 | - $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
| 396 | + $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
| 397 | 397 | |
| 398 | - $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
| 398 | + $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
| 399 | 399 | |
| 400 | - if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
| 401 | - $price_pkg = implode(",", $request_field['show_on_pkg']);
|
|
| 402 | - else {
|
|
| 403 | - $package_info = array(); |
|
| 400 | + if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
| 401 | + $price_pkg = implode(",", $request_field['show_on_pkg']);
|
|
| 402 | + else {
|
|
| 403 | + $package_info = array(); |
|
| 404 | 404 | |
| 405 | - $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
| 406 | - $price_pkg = !empty($package_info->pid) ? $package_info->pid : ''; |
|
| 407 | - } |
|
| 405 | + $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
| 406 | + $price_pkg = !empty($package_info->pid) ? $package_info->pid : ''; |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | 409 | |
| 410 | - if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
| 411 | - $extra_fields = $request_field['extra']; |
|
| 410 | + if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
| 411 | + $extra_fields = $request_field['extra']; |
|
| 412 | 412 | |
| 413 | - if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
| 414 | - $is_default = $request_field['is_default']; |
|
| 415 | - else |
|
| 416 | - $is_default = '0'; |
|
| 413 | + if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
| 414 | + $is_default = $request_field['is_default']; |
|
| 415 | + else |
|
| 416 | + $is_default = '0'; |
|
| 417 | 417 | |
| 418 | - if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
| 419 | - $is_admin = $request_field['is_admin']; |
|
| 420 | - else |
|
| 421 | - $is_admin = '0'; |
|
| 418 | + if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
| 419 | + $is_admin = $request_field['is_admin']; |
|
| 420 | + else |
|
| 421 | + $is_admin = '0'; |
|
| 422 | 422 | |
| 423 | 423 | |
| 424 | - if ($is_active == '') $is_active = 1; |
|
| 425 | - if ($is_required == '') $is_required = 0; |
|
| 424 | + if ($is_active == '') $is_active = 1; |
|
| 425 | + if ($is_required == '') $is_required = 0; |
|
| 426 | 426 | |
| 427 | 427 | |
| 428 | - if ($sort_order == '') {
|
|
| 428 | + if ($sort_order == '') {
|
|
| 429 | 429 | |
| 430 | - $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
|
|
| 430 | + $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
|
|
| 431 | 431 | |
| 432 | - $sort_order = (int)$last_order + 1; |
|
| 433 | - } |
|
| 432 | + $sort_order = (int)$last_order + 1; |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | - $default_value_add = ''; |
|
| 435 | + $default_value_add = ''; |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | - if (!empty($post_meta_info)) {
|
|
| 439 | - switch ($field_type): |
|
| 438 | + if (!empty($post_meta_info)) {
|
|
| 439 | + switch ($field_type): |
|
| 440 | 440 | |
| 441 | - case 'address': |
|
| 441 | + case 'address': |
|
| 442 | 442 | |
| 443 | - if ($htmlvar_name != '') {
|
|
| 444 | - $prefix = $htmlvar_name . '_'; |
|
| 445 | - } |
|
| 446 | - $old_prefix = $old_html_variable . '_'; |
|
| 443 | + if ($htmlvar_name != '') {
|
|
| 444 | + $prefix = $htmlvar_name . '_'; |
|
| 445 | + } |
|
| 446 | + $old_prefix = $old_html_variable . '_'; |
|
| 447 | 447 | |
| 448 | 448 | |
| 449 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
| 449 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
| 450 | 450 | |
| 451 | - if ($default_value != '') {
|
|
| 452 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 453 | - } |
|
| 451 | + if ($default_value != '') {
|
|
| 452 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - $wpdb->query($meta_field_add); |
|
| 455 | + $wpdb->query($meta_field_add); |
|
| 456 | 456 | |
| 457 | - if ($extra_fields != '') {
|
|
| 457 | + if ($extra_fields != '') {
|
|
| 458 | 458 | |
| 459 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
|
|
| 459 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
|
|
| 460 | 460 | |
| 461 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
|
|
| 462 | - if ($is_column) {
|
|
| 463 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
| 461 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
|
|
| 462 | + if ($is_column) {
|
|
| 463 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
| 464 | 464 | |
| 465 | - if ($default_value != '') {
|
|
| 466 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 467 | - } |
|
| 465 | + if ($default_value != '') {
|
|
| 466 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $wpdb->query($meta_field_add); |
|
| 470 | - } else {
|
|
| 469 | + $wpdb->query($meta_field_add); |
|
| 470 | + } else {
|
|
| 471 | 471 | |
| 472 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 473 | - if ($default_value != '') {
|
|
| 474 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 475 | - } |
|
| 476 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
| 472 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 473 | + if ($default_value != '') {
|
|
| 474 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 475 | + } |
|
| 476 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
| 477 | 477 | |
| 478 | - } |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | 480 | |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | |
| 484 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
|
|
| 484 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
|
|
| 485 | 485 | |
| 486 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
|
|
| 486 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
|
|
| 487 | 487 | |
| 488 | - if ($is_column) {
|
|
| 489 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
| 488 | + if ($is_column) {
|
|
| 489 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
| 490 | 490 | |
| 491 | - if ($default_value != '') {
|
|
| 492 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 493 | - } |
|
| 491 | + if ($default_value != '') {
|
|
| 492 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - $wpdb->query($meta_field_add); |
|
| 496 | - } else {
|
|
| 497 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 498 | - if ($default_value != '') {
|
|
| 499 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 500 | - } |
|
| 495 | + $wpdb->query($meta_field_add); |
|
| 496 | + } else {
|
|
| 497 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 498 | + if ($default_value != '') {
|
|
| 499 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
| 503 | - } |
|
| 502 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - } |
|
| 506 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
|
|
| 505 | + } |
|
| 506 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
|
|
| 507 | 507 | |
| 508 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
|
|
| 508 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
|
|
| 509 | 509 | |
| 510 | - if ($is_column) {
|
|
| 510 | + if ($is_column) {
|
|
| 511 | 511 | |
| 512 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
| 512 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
| 513 | 513 | |
| 514 | - if ($default_value != '') {
|
|
| 515 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 516 | - } |
|
| 514 | + if ($default_value != '') {
|
|
| 515 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - $wpdb->query($meta_field_add); |
|
| 519 | - } else {
|
|
| 518 | + $wpdb->query($meta_field_add); |
|
| 519 | + } else {
|
|
| 520 | 520 | |
| 521 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 522 | - if ($default_value != '') {
|
|
| 523 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 524 | - } |
|
| 521 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 522 | + if ($default_value != '') {
|
|
| 523 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
| 526 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
| 527 | 527 | |
| 528 | - } |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - } |
|
| 531 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
|
|
| 530 | + } |
|
| 531 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
|
|
| 532 | 532 | |
| 533 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
|
|
| 533 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
|
|
| 534 | 534 | |
| 535 | - if ($is_column) {
|
|
| 535 | + if ($is_column) {
|
|
| 536 | 536 | |
| 537 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
| 537 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
| 538 | 538 | |
| 539 | - if ($default_value != '') {
|
|
| 540 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 541 | - } |
|
| 539 | + if ($default_value != '') {
|
|
| 540 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - $wpdb->query($meta_field_add); |
|
| 544 | - } else {
|
|
| 543 | + $wpdb->query($meta_field_add); |
|
| 544 | + } else {
|
|
| 545 | 545 | |
| 546 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 547 | - if ($default_value != '') {
|
|
| 548 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 549 | - } |
|
| 546 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
| 547 | + if ($default_value != '') {
|
|
| 548 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
| 551 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
| 552 | 552 | |
| 553 | - } |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - } |
|
| 556 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
|
|
| 555 | + } |
|
| 556 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
|
|
| 557 | 557 | |
| 558 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
|
|
| 559 | - if ($is_column) {
|
|
| 558 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
|
|
| 559 | + if ($is_column) {
|
|
| 560 | 560 | |
| 561 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 561 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 562 | 562 | |
| 563 | - if ($default_value != '') {
|
|
| 564 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 565 | - } |
|
| 563 | + if ($default_value != '') {
|
|
| 564 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - $wpdb->query($meta_field_add); |
|
| 568 | - } else {
|
|
| 567 | + $wpdb->query($meta_field_add); |
|
| 568 | + } else {
|
|
| 569 | 569 | |
| 570 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 571 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 572 | - if ($default_value != '') {
|
|
| 573 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 574 | - } |
|
| 570 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 571 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 572 | + if ($default_value != '') {
|
|
| 573 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
| 576 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
| 577 | 577 | |
| 578 | - } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | |
| 581 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
|
|
| 581 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
|
|
| 582 | 582 | |
| 583 | - if ($is_column) {
|
|
| 584 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 583 | + if ($is_column) {
|
|
| 584 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 585 | 585 | |
| 586 | - if ($default_value != '') {
|
|
| 587 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 588 | - } |
|
| 586 | + if ($default_value != '') {
|
|
| 587 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - $wpdb->query($meta_field_add); |
|
| 591 | - } else {
|
|
| 590 | + $wpdb->query($meta_field_add); |
|
| 591 | + } else {
|
|
| 592 | 592 | |
| 593 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 594 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 595 | - if ($default_value != '') {
|
|
| 596 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 597 | - } |
|
| 593 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 594 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 595 | + if ($default_value != '') {
|
|
| 596 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
| 600 | - } |
|
| 599 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | - } |
|
| 603 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
|
|
| 602 | + } |
|
| 603 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
|
|
| 604 | 604 | |
| 605 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
|
|
| 605 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
|
|
| 606 | 606 | |
| 607 | - if ($is_column) {
|
|
| 608 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 607 | + if ($is_column) {
|
|
| 608 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 609 | 609 | |
| 610 | - if ($default_value != '') {
|
|
| 611 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 612 | - } |
|
| 610 | + if ($default_value != '') {
|
|
| 611 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 612 | + } |
|
| 613 | 613 | |
| 614 | - $wpdb->query($meta_field_add); |
|
| 615 | - } else {
|
|
| 614 | + $wpdb->query($meta_field_add); |
|
| 615 | + } else {
|
|
| 616 | 616 | |
| 617 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 617 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 618 | 618 | |
| 619 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 620 | - if ($default_value != '') {
|
|
| 621 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 622 | - } |
|
| 619 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 620 | + if ($default_value != '') {
|
|
| 621 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
| 625 | - } |
|
| 624 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | 627 | |
| 628 | - } |
|
| 629 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
|
|
| 628 | + } |
|
| 629 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
|
|
| 630 | 630 | |
| 631 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
|
|
| 632 | - if ($is_column) {
|
|
| 633 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 631 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
|
|
| 632 | + if ($is_column) {
|
|
| 633 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 634 | 634 | |
| 635 | - if ($default_value != '') {
|
|
| 636 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 637 | - } |
|
| 635 | + if ($default_value != '') {
|
|
| 636 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - $wpdb->query($meta_field_add); |
|
| 639 | + $wpdb->query($meta_field_add); |
|
| 640 | 640 | |
| 641 | - } else {
|
|
| 641 | + } else {
|
|
| 642 | 642 | |
| 643 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 643 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 644 | 644 | |
| 645 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 646 | - if ($default_value != '') {
|
|
| 647 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 648 | - } |
|
| 645 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 646 | + if ($default_value != '') {
|
|
| 647 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
| 651 | - } |
|
| 650 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | - } |
|
| 654 | - // show lat lng |
|
| 655 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
|
|
| 656 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
|
|
| 653 | + } |
|
| 654 | + // show lat lng |
|
| 655 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
|
|
| 656 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
|
|
| 657 | 657 | |
| 658 | - if ($is_column) {
|
|
| 659 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 660 | - $meta_field_add .= " DEFAULT '1'"; |
|
| 658 | + if ($is_column) {
|
|
| 659 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 660 | + $meta_field_add .= " DEFAULT '1'"; |
|
| 661 | 661 | |
| 662 | - $wpdb->query($meta_field_add); |
|
| 663 | - } else {
|
|
| 664 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 662 | + $wpdb->query($meta_field_add); |
|
| 663 | + } else {
|
|
| 664 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 665 | 665 | |
| 666 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 667 | - $meta_field_add .= " DEFAULT '1'"; |
|
| 666 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 667 | + $meta_field_add .= " DEFAULT '1'"; |
|
| 668 | 668 | |
| 669 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
| 670 | - } |
|
| 669 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | - } |
|
| 673 | - }// end extra |
|
| 672 | + } |
|
| 673 | + }// end extra |
|
| 674 | 674 | |
| 675 | - break; |
|
| 675 | + break; |
|
| 676 | 676 | |
| 677 | - case 'checkbox': |
|
| 678 | - case 'multiselect': |
|
| 679 | - case 'select': |
|
| 680 | - case 'taxonomy': |
|
| 677 | + case 'checkbox': |
|
| 678 | + case 'multiselect': |
|
| 679 | + case 'select': |
|
| 680 | + case 'taxonomy': |
|
| 681 | 681 | |
| 682 | - $op_size = '500'; |
|
| 682 | + $op_size = '500'; |
|
| 683 | 683 | |
| 684 | - // only make the field as big as it needs to be. |
|
| 685 | - if(isset($option_values) && $option_values && $field_type=='select'){
|
|
| 686 | - $option_values_arr = explode(',',$option_values);
|
|
| 687 | - if(is_array($option_values_arr)){
|
|
| 688 | - $op_max = 0; |
|
| 689 | - foreach($option_values_arr as $op_val){
|
|
| 690 | - if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
|
|
| 691 | - } |
|
| 692 | - if($op_max){$op_size =$op_max; }
|
|
| 693 | - } |
|
| 694 | - }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
|
|
| 695 | - if(strlen($option_values)){
|
|
| 696 | - $op_size = strlen($option_values); |
|
| 697 | - } |
|
| 698 | - } |
|
| 684 | + // only make the field as big as it needs to be. |
|
| 685 | + if(isset($option_values) && $option_values && $field_type=='select'){
|
|
| 686 | + $option_values_arr = explode(',',$option_values);
|
|
| 687 | + if(is_array($option_values_arr)){
|
|
| 688 | + $op_max = 0; |
|
| 689 | + foreach($option_values_arr as $op_val){
|
|
| 690 | + if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
|
|
| 691 | + } |
|
| 692 | + if($op_max){$op_size =$op_max; }
|
|
| 693 | + } |
|
| 694 | + }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
|
|
| 695 | + if(strlen($option_values)){
|
|
| 696 | + $op_size = strlen($option_values); |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
| 700 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
| 701 | 701 | |
| 702 | - if ($default_value != '') {
|
|
| 703 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 704 | - } |
|
| 702 | + if ($default_value != '') {
|
|
| 703 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - $alter_result = $wpdb->query($meta_field_add); |
|
| 707 | - if($alter_result===false){
|
|
| 708 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 709 | - } |
|
| 706 | + $alter_result = $wpdb->query($meta_field_add); |
|
| 707 | + if($alter_result===false){
|
|
| 708 | + return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | - if (isset($request_field['cat_display_type'])) |
|
| 712 | - $extra_fields = $request_field['cat_display_type']; |
|
| 711 | + if (isset($request_field['cat_display_type'])) |
|
| 712 | + $extra_fields = $request_field['cat_display_type']; |
|
| 713 | 713 | |
| 714 | - if (isset($request_field['multi_display_type'])) |
|
| 715 | - $extra_fields = $request_field['multi_display_type']; |
|
| 714 | + if (isset($request_field['multi_display_type'])) |
|
| 715 | + $extra_fields = $request_field['multi_display_type']; |
|
| 716 | 716 | |
| 717 | 717 | |
| 718 | - break; |
|
| 718 | + break; |
|
| 719 | 719 | |
| 720 | - case 'textarea': |
|
| 721 | - case 'html': |
|
| 722 | - case 'url': |
|
| 723 | - case 'file': |
|
| 720 | + case 'textarea': |
|
| 721 | + case 'html': |
|
| 722 | + case 'url': |
|
| 723 | + case 'file': |
|
| 724 | 724 | |
| 725 | - $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
|
|
| 726 | - if($alter_result===false){
|
|
| 727 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 728 | - } |
|
| 729 | - if (isset($request_field['advanced_editor'])) |
|
| 730 | - $extra_fields = $request_field['advanced_editor']; |
|
| 731 | - |
|
| 732 | - break; |
|
| 725 | + $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
|
|
| 726 | + if($alter_result===false){
|
|
| 727 | + return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 728 | + } |
|
| 729 | + if (isset($request_field['advanced_editor'])) |
|
| 730 | + $extra_fields = $request_field['advanced_editor']; |
|
| 731 | + |
|
| 732 | + break; |
|
| 733 | 733 | |
| 734 | - case 'fieldset': |
|
| 735 | - // Nothing happened for fieldset |
|
| 736 | - break; |
|
| 734 | + case 'fieldset': |
|
| 735 | + // Nothing happened for fieldset |
|
| 736 | + break; |
|
| 737 | 737 | |
| 738 | - default: |
|
| 739 | - if ($data_type != 'VARCHAR' && $data_type != '') {
|
|
| 740 | - if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
|
| 741 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
| 742 | - } else {
|
|
| 743 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
| 744 | - } |
|
| 745 | - |
|
| 746 | - if (is_numeric($default_value) && $default_value != '') {
|
|
| 747 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 748 | - } |
|
| 749 | - } else {
|
|
| 750 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
| 751 | - if ($default_value != '') {
|
|
| 752 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 753 | - } |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - $alter_result = $wpdb->query($default_value_add); |
|
| 757 | - if($alter_result===false){
|
|
| 758 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 759 | - } |
|
| 760 | - break; |
|
| 761 | - endswitch; |
|
| 762 | - |
|
| 763 | - $extra_field_query = ''; |
|
| 764 | - if (!empty($extra_fields)) {
|
|
| 765 | - $extra_field_query = serialize($extra_fields); |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
| 769 | - |
|
| 770 | - $wpdb->query( |
|
| 771 | - |
|
| 772 | - $wpdb->prepare( |
|
| 773 | - |
|
| 774 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 738 | + default: |
|
| 739 | + if ($data_type != 'VARCHAR' && $data_type != '') {
|
|
| 740 | + if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
|
| 741 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
| 742 | + } else {
|
|
| 743 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
| 744 | + } |
|
| 745 | + |
|
| 746 | + if (is_numeric($default_value) && $default_value != '') {
|
|
| 747 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 748 | + } |
|
| 749 | + } else {
|
|
| 750 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
| 751 | + if ($default_value != '') {
|
|
| 752 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 753 | + } |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + $alter_result = $wpdb->query($default_value_add); |
|
| 757 | + if($alter_result===false){
|
|
| 758 | + return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 759 | + } |
|
| 760 | + break; |
|
| 761 | + endswitch; |
|
| 762 | + |
|
| 763 | + $extra_field_query = ''; |
|
| 764 | + if (!empty($extra_fields)) {
|
|
| 765 | + $extra_field_query = serialize($extra_fields); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
| 769 | + |
|
| 770 | + $wpdb->query( |
|
| 771 | + |
|
| 772 | + $wpdb->prepare( |
|
| 773 | + |
|
| 774 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 775 | 775 | post_type = %s, |
| 776 | 776 | admin_title = %s, |
| 777 | 777 | site_title = %s, |
@@ -805,308 +805,308 @@ discard block |
||
| 805 | 805 | for_admin_use = %s |
| 806 | 806 | where id = %d", |
| 807 | 807 | |
| 808 | - array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf) |
|
| 809 | - ) |
|
| 808 | + array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf) |
|
| 809 | + ) |
|
| 810 | 810 | |
| 811 | - ); |
|
| 811 | + ); |
|
| 812 | 812 | |
| 813 | - $lastid = trim($cf); |
|
| 813 | + $lastid = trim($cf); |
|
| 814 | 814 | |
| 815 | 815 | |
| 816 | - $wpdb->query( |
|
| 817 | - $wpdb->prepare( |
|
| 818 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 816 | + $wpdb->query( |
|
| 817 | + $wpdb->prepare( |
|
| 818 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 819 | 819 | site_title=%s |
| 820 | 820 | where post_type = %s and htmlvar_name = %s", |
| 821 | - array($site_title, $post_type, $htmlvar_name) |
|
| 822 | - ) |
|
| 823 | - ); |
|
| 824 | - |
|
| 825 | - |
|
| 826 | - if ($cat_sort == '') |
|
| 827 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
|
|
| 828 | - |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * Called after all custom fields are saved for a post. |
|
| 832 | - * |
|
| 833 | - * @since 1.0.0 |
|
| 834 | - * @param int $lastid The post ID. |
|
| 835 | - */ |
|
| 836 | - do_action('geodir_after_custom_fields_updated', $lastid);
|
|
| 837 | - |
|
| 838 | - } else {
|
|
| 839 | - |
|
| 840 | - switch ($field_type): |
|
| 841 | - |
|
| 842 | - case 'address': |
|
| 843 | - |
|
| 844 | - $data_type = ''; |
|
| 845 | - |
|
| 846 | - if ($htmlvar_name != '') {
|
|
| 847 | - $prefix = $htmlvar_name . '_'; |
|
| 848 | - } |
|
| 849 | - $old_prefix = $old_html_variable; |
|
| 850 | - |
|
| 851 | - //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
| 852 | - |
|
| 853 | - $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
| 854 | - if ($default_value != '') {
|
|
| 855 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
| 859 | - //$wpdb->query($meta_field_add); |
|
| 860 | - |
|
| 861 | - |
|
| 862 | - if (!empty($extra_fields)) {
|
|
| 821 | + array($site_title, $post_type, $htmlvar_name) |
|
| 822 | + ) |
|
| 823 | + ); |
|
| 824 | + |
|
| 825 | + |
|
| 826 | + if ($cat_sort == '') |
|
| 827 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
|
|
| 828 | + |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * Called after all custom fields are saved for a post. |
|
| 832 | + * |
|
| 833 | + * @since 1.0.0 |
|
| 834 | + * @param int $lastid The post ID. |
|
| 835 | + */ |
|
| 836 | + do_action('geodir_after_custom_fields_updated', $lastid);
|
|
| 837 | + |
|
| 838 | + } else {
|
|
| 839 | + |
|
| 840 | + switch ($field_type): |
|
| 841 | + |
|
| 842 | + case 'address': |
|
| 843 | + |
|
| 844 | + $data_type = ''; |
|
| 845 | + |
|
| 846 | + if ($htmlvar_name != '') {
|
|
| 847 | + $prefix = $htmlvar_name . '_'; |
|
| 848 | + } |
|
| 849 | + $old_prefix = $old_html_variable; |
|
| 850 | + |
|
| 851 | + //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
| 852 | + |
|
| 853 | + $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
| 854 | + if ($default_value != '') {
|
|
| 855 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
| 859 | + //$wpdb->query($meta_field_add); |
|
| 860 | + |
|
| 861 | + |
|
| 862 | + if (!empty($extra_fields)) {
|
|
| 863 | 863 | |
| 864 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
|
|
| 865 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
| 866 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 867 | - if ($default_value != '') {
|
|
| 868 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
| 872 | - //$wpdb->query($meta_field_add); |
|
| 873 | - } |
|
| 874 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
|
|
| 875 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
| 876 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 877 | - if ($default_value != '') {
|
|
| 878 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
| 882 | - //$wpdb->query($meta_field_add); |
|
| 883 | - } |
|
| 884 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
|
|
| 885 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
| 886 | - |
|
| 887 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 888 | - if ($default_value != '') {
|
|
| 889 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
| 893 | - //$wpdb->query($meta_field_add); |
|
| 894 | - } |
|
| 895 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
|
|
| 896 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
| 897 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 898 | - if ($default_value != '') {
|
|
| 899 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
| 903 | - //$wpdb->query($meta_field_add); |
|
| 904 | - } |
|
| 905 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
|
|
| 906 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 907 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 908 | - if ($default_value != '') {
|
|
| 909 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 910 | - } |
|
| 911 | - |
|
| 912 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
| 913 | - //$wpdb->query($meta_field_add); |
|
| 914 | - |
|
| 915 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 916 | - |
|
| 917 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 918 | - if ($default_value != '') {
|
|
| 919 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
| 923 | - |
|
| 924 | - //$wpdb->query($meta_field_add); |
|
| 925 | - } |
|
| 926 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
|
|
| 927 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 928 | - |
|
| 929 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 930 | - if ($default_value != '') {
|
|
| 931 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 932 | - } |
|
| 933 | - |
|
| 934 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
| 935 | - |
|
| 936 | - //$wpdb->query($meta_field_add); |
|
| 937 | - } |
|
| 938 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
|
|
| 939 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 940 | - |
|
| 941 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 942 | - if ($default_value != '') {
|
|
| 943 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 944 | - } |
|
| 945 | - |
|
| 946 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
| 947 | - |
|
| 948 | - //$wpdb->query($meta_field_add); |
|
| 949 | - } |
|
| 950 | - // show lat lng |
|
| 951 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
|
|
| 952 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 953 | - |
|
| 954 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 955 | - $meta_field_add .= " DEFAULT '1'"; |
|
| 956 | - |
|
| 957 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
| 958 | - //$wpdb->query($meta_field_add); |
|
| 959 | - } |
|
| 960 | - } |
|
| 961 | - |
|
| 962 | - break; |
|
| 963 | - |
|
| 964 | - case 'checkbox': |
|
| 965 | - $data_type = 'TINYINT'; |
|
| 966 | - |
|
| 967 | - $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
| 968 | - if ((int)$default_value === 1) {
|
|
| 969 | - $meta_field_add .= " DEFAULT '1'"; |
|
| 970 | - } |
|
| 971 | - |
|
| 972 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 973 | - if ($add_result === false) {
|
|
| 974 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 975 | - } |
|
| 976 | - break; |
|
| 977 | - case 'multiselect': |
|
| 978 | - case 'select': |
|
| 979 | - $data_type = 'VARCHAR'; |
|
| 980 | - $op_size = '500'; |
|
| 981 | - |
|
| 982 | - // only make the field as big as it needs to be. |
|
| 983 | - if (isset($option_values) && $option_values && $field_type == 'select') {
|
|
| 984 | - $option_values_arr = explode(',', $option_values);
|
|
| 985 | - |
|
| 986 | - if (is_array($option_values_arr)) {
|
|
| 987 | - $op_max = 0; |
|
| 988 | - |
|
| 989 | - foreach ($option_values_arr as $op_val) {
|
|
| 990 | - if (strlen($op_val) && strlen($op_val) > $op_max) {
|
|
| 991 | - $op_max = strlen($op_val); |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - if ($op_max) {
|
|
| 996 | - $op_size = $op_max; |
|
| 997 | - } |
|
| 998 | - } |
|
| 999 | - } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
|
|
| 1000 | - if (strlen($option_values)) {
|
|
| 1001 | - $op_size = strlen($option_values); |
|
| 1002 | - } |
|
| 1003 | - |
|
| 1004 | - if (isset($request_field['multi_display_type'])) {
|
|
| 1005 | - $extra_fields = $request_field['multi_display_type']; |
|
| 1006 | - } |
|
| 1007 | - } |
|
| 1008 | - |
|
| 1009 | - $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
| 1010 | - if ($default_value != '') {
|
|
| 1011 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1012 | - } |
|
| 1013 | - |
|
| 1014 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1015 | - if ($add_result === false) {
|
|
| 1016 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1017 | - } |
|
| 1018 | - break; |
|
| 1019 | - case 'textarea': |
|
| 1020 | - case 'html': |
|
| 1021 | - case 'url': |
|
| 1022 | - case 'file': |
|
| 1023 | - |
|
| 1024 | - $data_type = 'TEXT'; |
|
| 1025 | - |
|
| 1026 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1027 | - |
|
| 1028 | - $meta_field_add = $data_type . " NULL "; |
|
| 1029 | - /*if($default_value != '') |
|
| 864 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
|
|
| 865 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
| 866 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 867 | + if ($default_value != '') {
|
|
| 868 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
| 872 | + //$wpdb->query($meta_field_add); |
|
| 873 | + } |
|
| 874 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
|
|
| 875 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
| 876 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 877 | + if ($default_value != '') {
|
|
| 878 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
| 882 | + //$wpdb->query($meta_field_add); |
|
| 883 | + } |
|
| 884 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
|
|
| 885 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
| 886 | + |
|
| 887 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
| 888 | + if ($default_value != '') {
|
|
| 889 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
| 893 | + //$wpdb->query($meta_field_add); |
|
| 894 | + } |
|
| 895 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
|
|
| 896 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
| 897 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 898 | + if ($default_value != '') {
|
|
| 899 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
| 903 | + //$wpdb->query($meta_field_add); |
|
| 904 | + } |
|
| 905 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
|
|
| 906 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
| 907 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 908 | + if ($default_value != '') {
|
|
| 909 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 910 | + } |
|
| 911 | + |
|
| 912 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
| 913 | + //$wpdb->query($meta_field_add); |
|
| 914 | + |
|
| 915 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
| 916 | + |
|
| 917 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
| 918 | + if ($default_value != '') {
|
|
| 919 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
| 923 | + |
|
| 924 | + //$wpdb->query($meta_field_add); |
|
| 925 | + } |
|
| 926 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
|
|
| 927 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
| 928 | + |
|
| 929 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
| 930 | + if ($default_value != '') {
|
|
| 931 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 932 | + } |
|
| 933 | + |
|
| 934 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
| 935 | + |
|
| 936 | + //$wpdb->query($meta_field_add); |
|
| 937 | + } |
|
| 938 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
|
|
| 939 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
| 940 | + |
|
| 941 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 942 | + if ($default_value != '') {
|
|
| 943 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 944 | + } |
|
| 945 | + |
|
| 946 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
| 947 | + |
|
| 948 | + //$wpdb->query($meta_field_add); |
|
| 949 | + } |
|
| 950 | + // show lat lng |
|
| 951 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
|
|
| 952 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
| 953 | + |
|
| 954 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
| 955 | + $meta_field_add .= " DEFAULT '1'"; |
|
| 956 | + |
|
| 957 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
| 958 | + //$wpdb->query($meta_field_add); |
|
| 959 | + } |
|
| 960 | + } |
|
| 961 | + |
|
| 962 | + break; |
|
| 963 | + |
|
| 964 | + case 'checkbox': |
|
| 965 | + $data_type = 'TINYINT'; |
|
| 966 | + |
|
| 967 | + $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
| 968 | + if ((int)$default_value === 1) {
|
|
| 969 | + $meta_field_add .= " DEFAULT '1'"; |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 973 | + if ($add_result === false) {
|
|
| 974 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 975 | + } |
|
| 976 | + break; |
|
| 977 | + case 'multiselect': |
|
| 978 | + case 'select': |
|
| 979 | + $data_type = 'VARCHAR'; |
|
| 980 | + $op_size = '500'; |
|
| 981 | + |
|
| 982 | + // only make the field as big as it needs to be. |
|
| 983 | + if (isset($option_values) && $option_values && $field_type == 'select') {
|
|
| 984 | + $option_values_arr = explode(',', $option_values);
|
|
| 985 | + |
|
| 986 | + if (is_array($option_values_arr)) {
|
|
| 987 | + $op_max = 0; |
|
| 988 | + |
|
| 989 | + foreach ($option_values_arr as $op_val) {
|
|
| 990 | + if (strlen($op_val) && strlen($op_val) > $op_max) {
|
|
| 991 | + $op_max = strlen($op_val); |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + if ($op_max) {
|
|
| 996 | + $op_size = $op_max; |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | + } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
|
|
| 1000 | + if (strlen($option_values)) {
|
|
| 1001 | + $op_size = strlen($option_values); |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + if (isset($request_field['multi_display_type'])) {
|
|
| 1005 | + $extra_fields = $request_field['multi_display_type']; |
|
| 1006 | + } |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
| 1010 | + if ($default_value != '') {
|
|
| 1011 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1012 | + } |
|
| 1013 | + |
|
| 1014 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1015 | + if ($add_result === false) {
|
|
| 1016 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1017 | + } |
|
| 1018 | + break; |
|
| 1019 | + case 'textarea': |
|
| 1020 | + case 'html': |
|
| 1021 | + case 'url': |
|
| 1022 | + case 'file': |
|
| 1023 | + |
|
| 1024 | + $data_type = 'TEXT'; |
|
| 1025 | + |
|
| 1026 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1027 | + |
|
| 1028 | + $meta_field_add = $data_type . " NULL "; |
|
| 1029 | + /*if($default_value != '') |
|
| 1030 | 1030 | { $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
|
| 1031 | 1031 | |
| 1032 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1033 | - if ($add_result === false) {
|
|
| 1034 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1035 | - } |
|
| 1032 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1033 | + if ($add_result === false) {
|
|
| 1034 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1035 | + } |
|
| 1036 | 1036 | |
| 1037 | - break; |
|
| 1037 | + break; |
|
| 1038 | 1038 | |
| 1039 | - case 'datepicker': |
|
| 1039 | + case 'datepicker': |
|
| 1040 | 1040 | |
| 1041 | - $data_type = 'DATE'; |
|
| 1041 | + $data_type = 'DATE'; |
|
| 1042 | 1042 | |
| 1043 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1043 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1044 | 1044 | |
| 1045 | - $meta_field_add = $data_type . " NULL "; |
|
| 1045 | + $meta_field_add = $data_type . " NULL "; |
|
| 1046 | 1046 | |
| 1047 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1048 | - if ($add_result === false) {
|
|
| 1049 | - return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
|
|
| 1050 | - } |
|
| 1047 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1048 | + if ($add_result === false) {
|
|
| 1049 | + return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
|
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - break; |
|
| 1052 | + break; |
|
| 1053 | 1053 | |
| 1054 | - case 'time': |
|
| 1054 | + case 'time': |
|
| 1055 | 1055 | |
| 1056 | - $data_type = 'TIME'; |
|
| 1056 | + $data_type = 'TIME'; |
|
| 1057 | 1057 | |
| 1058 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1058 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
| 1059 | 1059 | |
| 1060 | - $meta_field_add = $data_type . " NULL "; |
|
| 1060 | + $meta_field_add = $data_type . " NULL "; |
|
| 1061 | 1061 | |
| 1062 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1063 | - if ($add_result === false) {
|
|
| 1064 | - return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
|
|
| 1065 | - } |
|
| 1062 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1063 | + if ($add_result === false) {
|
|
| 1064 | + return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
|
|
| 1065 | + } |
|
| 1066 | 1066 | |
| 1067 | - break; |
|
| 1067 | + break; |
|
| 1068 | 1068 | |
| 1069 | - default: |
|
| 1069 | + default: |
|
| 1070 | 1070 | |
| 1071 | - if ($data_type != 'VARCHAR' && $data_type != '') {
|
|
| 1072 | - $meta_field_add = $data_type . " NULL "; |
|
| 1071 | + if ($data_type != 'VARCHAR' && $data_type != '') {
|
|
| 1072 | + $meta_field_add = $data_type . " NULL "; |
|
| 1073 | 1073 | |
| 1074 | - if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
|
| 1075 | - $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
| 1076 | - } |
|
| 1074 | + if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
|
| 1075 | + $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | - if (is_numeric($default_value) && $default_value != '') {
|
|
| 1079 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1080 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1081 | - } |
|
| 1082 | - } else {
|
|
| 1083 | - $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
| 1078 | + if (is_numeric($default_value) && $default_value != '') {
|
|
| 1079 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1080 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1081 | + } |
|
| 1082 | + } else {
|
|
| 1083 | + $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
| 1084 | 1084 | |
| 1085 | - if ($default_value != '') {
|
|
| 1086 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1087 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1088 | - } |
|
| 1089 | - } |
|
| 1085 | + if ($default_value != '') {
|
|
| 1086 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1087 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
| 1088 | + } |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1092 | - if ($add_result === false) {
|
|
| 1093 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1094 | - } |
|
| 1095 | - break; |
|
| 1096 | - endswitch; |
|
| 1091 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
| 1092 | + if ($add_result === false) {
|
|
| 1093 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
|
|
| 1094 | + } |
|
| 1095 | + break; |
|
| 1096 | + endswitch; |
|
| 1097 | 1097 | |
| 1098 | - $extra_field_query = ''; |
|
| 1099 | - if (!empty($extra_fields)) {
|
|
| 1100 | - $extra_field_query = serialize($extra_fields); |
|
| 1101 | - } |
|
| 1098 | + $extra_field_query = ''; |
|
| 1099 | + if (!empty($extra_fields)) {
|
|
| 1100 | + $extra_field_query = serialize($extra_fields); |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
| 1103 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
| 1104 | 1104 | |
| 1105 | - $wpdb->query( |
|
| 1105 | + $wpdb->query( |
|
| 1106 | 1106 | |
| 1107 | - $wpdb->prepare( |
|
| 1107 | + $wpdb->prepare( |
|
| 1108 | 1108 | |
| 1109 | - "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 1109 | + "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 1110 | 1110 | post_type = %s, |
| 1111 | 1111 | admin_title = %s, |
| 1112 | 1112 | site_title = %s, |
@@ -1139,26 +1139,26 @@ discard block |
||
| 1139 | 1139 | validation_msg = %s, |
| 1140 | 1140 | for_admin_use = %s ", |
| 1141 | 1141 | |
| 1142 | - array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use) |
|
| 1142 | + array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use) |
|
| 1143 | 1143 | |
| 1144 | - ) |
|
| 1144 | + ) |
|
| 1145 | 1145 | |
| 1146 | - ); |
|
| 1146 | + ); |
|
| 1147 | 1147 | |
| 1148 | - $lastid = $wpdb->insert_id; |
|
| 1148 | + $lastid = $wpdb->insert_id; |
|
| 1149 | 1149 | |
| 1150 | - $lastid = trim($lastid); |
|
| 1150 | + $lastid = trim($lastid); |
|
| 1151 | 1151 | |
| 1152 | - } |
|
| 1152 | + } |
|
| 1153 | 1153 | |
| 1154 | - return (int)$lastid; |
|
| 1154 | + return (int)$lastid; |
|
| 1155 | 1155 | |
| 1156 | 1156 | |
| 1157 | - } else {
|
|
| 1158 | - return 'HTML Variable Name should be a unique name'; |
|
| 1159 | - } |
|
| 1157 | + } else {
|
|
| 1158 | + return 'HTML Variable Name should be a unique name'; |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - } |
|
| 1161 | + } |
|
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | /** |
@@ -1173,54 +1173,54 @@ discard block |
||
| 1173 | 1173 | function godir_set_field_order($field_ids = array()) |
| 1174 | 1174 | {
|
| 1175 | 1175 | |
| 1176 | - global $wpdb; |
|
| 1176 | + global $wpdb; |
|
| 1177 | 1177 | |
| 1178 | - $count = 0; |
|
| 1179 | - if (!empty($field_ids)): |
|
| 1180 | - $post_meta_info = false; |
|
| 1181 | - foreach ($field_ids as $id) {
|
|
| 1178 | + $count = 0; |
|
| 1179 | + if (!empty($field_ids)): |
|
| 1180 | + $post_meta_info = false; |
|
| 1181 | + foreach ($field_ids as $id) {
|
|
| 1182 | 1182 | |
| 1183 | - $cf = trim($id, '_'); |
|
| 1183 | + $cf = trim($id, '_'); |
|
| 1184 | 1184 | |
| 1185 | - $post_meta_info = $wpdb->query( |
|
| 1186 | - $wpdb->prepare( |
|
| 1187 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 1185 | + $post_meta_info = $wpdb->query( |
|
| 1186 | + $wpdb->prepare( |
|
| 1187 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
| 1188 | 1188 | sort_order=%d |
| 1189 | 1189 | where id= %d", |
| 1190 | - array($count, $cf) |
|
| 1191 | - ) |
|
| 1192 | - ); |
|
| 1193 | - $count++; |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - return $post_meta_info; |
|
| 1197 | - else: |
|
| 1198 | - return false; |
|
| 1199 | - endif; |
|
| 1190 | + array($count, $cf) |
|
| 1191 | + ) |
|
| 1192 | + ); |
|
| 1193 | + $count++; |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + return $post_meta_info; |
|
| 1197 | + else: |
|
| 1198 | + return false; |
|
| 1199 | + endif; |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | |
| 1203 | 1203 | function geodir_get_cf_value($cf){
|
| 1204 | - global $gd_session; |
|
| 1205 | - $value = ''; |
|
| 1206 | - if (is_admin()) {
|
|
| 1207 | - global $post,$gd_session; |
|
| 1208 | - |
|
| 1209 | - if (isset($_REQUEST['post'])) |
|
| 1210 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
|
|
| 1214 | - $post = $gd_ses_listing; |
|
| 1215 | - $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
| 1216 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 1217 | - $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
| 1218 | - } else {
|
|
| 1219 | - if ($value == '') {
|
|
| 1220 | - $value = $cf['default']; |
|
| 1221 | - } |
|
| 1222 | - } |
|
| 1223 | - return $value; |
|
| 1204 | + global $gd_session; |
|
| 1205 | + $value = ''; |
|
| 1206 | + if (is_admin()) {
|
|
| 1207 | + global $post,$gd_session; |
|
| 1208 | + |
|
| 1209 | + if (isset($_REQUEST['post'])) |
|
| 1210 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
|
|
| 1214 | + $post = $gd_ses_listing; |
|
| 1215 | + $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
| 1216 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 1217 | + $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
| 1218 | + } else {
|
|
| 1219 | + if ($value == '') {
|
|
| 1220 | + $value = $cf['default']; |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1223 | + return $value; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1239,422 +1239,422 @@ discard block |
||
| 1239 | 1239 | * @param string $post_type Optional. The wordpress post type. |
| 1240 | 1240 | */ |
| 1241 | 1241 | function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
|
| 1242 | - global $is_default, $mapzoom, $gd_session; |
|
| 1242 | + global $is_default, $mapzoom, $gd_session; |
|
| 1243 | 1243 | |
| 1244 | - $listing_type = $post_type; |
|
| 1244 | + $listing_type = $post_type; |
|
| 1245 | 1245 | |
| 1246 | - $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
| 1246 | + $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
| 1247 | 1247 | |
| 1248 | - foreach ($custom_fields as $key => $val) {
|
|
| 1249 | - if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
|
|
| 1250 | - $val = stripslashes_deep($val); // strip slashes from labels |
|
| 1251 | - if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
|
|
| 1248 | + foreach ($custom_fields as $key => $val) {
|
|
| 1249 | + if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
|
|
| 1250 | + $val = stripslashes_deep($val); // strip slashes from labels |
|
| 1251 | + if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
|
|
| 1252 | 1252 | |
| 1253 | - $name = $val['name']; |
|
| 1254 | - $type = $val['type']; |
|
| 1255 | - $is_default = $val['is_default']; |
|
| 1253 | + $name = $val['name']; |
|
| 1254 | + $type = $val['type']; |
|
| 1255 | + $is_default = $val['is_default']; |
|
| 1256 | 1256 | |
| 1257 | - /* field available to site admin only for edit */ |
|
| 1258 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
| 1259 | - if ($for_admin_use && !is_super_admin()) {
|
|
| 1260 | - continue; |
|
| 1261 | - } |
|
| 1257 | + /* field available to site admin only for edit */ |
|
| 1258 | + $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
| 1259 | + if ($for_admin_use && !is_super_admin()) {
|
|
| 1260 | + continue; |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - if (is_admin()) {
|
|
| 1264 | - global $post; |
|
| 1263 | + if (is_admin()) {
|
|
| 1264 | + global $post; |
|
| 1265 | 1265 | |
| 1266 | - if (isset($_REQUEST['post'])) |
|
| 1267 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1268 | - } |
|
| 1266 | + if (isset($_REQUEST['post'])) |
|
| 1267 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | 1270 | |
| 1271 | 1271 | |
| 1272 | - /** |
|
| 1273 | - * Called before the custom fields info is output for submitting a post. |
|
| 1274 | - * |
|
| 1275 | - * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
| 1276 | - * |
|
| 1277 | - * @since 1.0.0 |
|
| 1278 | - * @param string $listing_type The post post type. |
|
| 1279 | - * @param int $package_id The price package ID for the post. |
|
| 1280 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
|
|
| 1281 | - * @see 'geodir_after_custom_form_field_$name' |
|
| 1282 | - */ |
|
| 1283 | - do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
|
|
| 1284 | - |
|
| 1285 | - |
|
| 1286 | - $custom_field = $val; |
|
| 1287 | - $html =''; |
|
| 1288 | - /** |
|
| 1289 | - * Filter the output for custom fields. |
|
| 1290 | - * |
|
| 1291 | - * Here we can remove or add new functions depending on the field type. |
|
| 1292 | - * |
|
| 1293 | - * @param string $html The html to be filtered (blank). |
|
| 1294 | - * @param array $custom_field The custom field array values. |
|
| 1295 | - */ |
|
| 1296 | - echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
|
|
| 1297 | - |
|
| 1298 | - |
|
| 1299 | - |
|
| 1300 | - /** |
|
| 1301 | - * Called after the custom fields info is output for submitting a post. |
|
| 1302 | - * |
|
| 1303 | - * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
| 1304 | - * |
|
| 1305 | - * @since 1.0.0 |
|
| 1306 | - * @param string $listing_type The post post type. |
|
| 1307 | - * @param int $package_id The price package ID for the post. |
|
| 1308 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
|
|
| 1309 | - * @see 'geodir_before_custom_form_field_$name' |
|
| 1310 | - */ |
|
| 1311 | - do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
|
|
| 1312 | - |
|
| 1313 | - } |
|
| 1272 | + /** |
|
| 1273 | + * Called before the custom fields info is output for submitting a post. |
|
| 1274 | + * |
|
| 1275 | + * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
| 1276 | + * |
|
| 1277 | + * @since 1.0.0 |
|
| 1278 | + * @param string $listing_type The post post type. |
|
| 1279 | + * @param int $package_id The price package ID for the post. |
|
| 1280 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
|
|
| 1281 | + * @see 'geodir_after_custom_form_field_$name' |
|
| 1282 | + */ |
|
| 1283 | + do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
|
|
| 1284 | + |
|
| 1285 | + |
|
| 1286 | + $custom_field = $val; |
|
| 1287 | + $html =''; |
|
| 1288 | + /** |
|
| 1289 | + * Filter the output for custom fields. |
|
| 1290 | + * |
|
| 1291 | + * Here we can remove or add new functions depending on the field type. |
|
| 1292 | + * |
|
| 1293 | + * @param string $html The html to be filtered (blank). |
|
| 1294 | + * @param array $custom_field The custom field array values. |
|
| 1295 | + */ |
|
| 1296 | + echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
|
|
| 1297 | + |
|
| 1298 | + |
|
| 1299 | + |
|
| 1300 | + /** |
|
| 1301 | + * Called after the custom fields info is output for submitting a post. |
|
| 1302 | + * |
|
| 1303 | + * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
| 1304 | + * |
|
| 1305 | + * @since 1.0.0 |
|
| 1306 | + * @param string $listing_type The post post type. |
|
| 1307 | + * @param int $package_id The price package ID for the post. |
|
| 1308 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
|
|
| 1309 | + * @see 'geodir_before_custom_form_field_$name' |
|
| 1310 | + */ |
|
| 1311 | + do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
|
|
| 1312 | + |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | 1318 | if (!function_exists('geodir_get_field_infoby')) {
|
| 1319 | - /** |
|
| 1320 | - * Get custom field using key and value. |
|
| 1321 | - * |
|
| 1322 | - * @since 1.0.0 |
|
| 1323 | - * @package GeoDirectory |
|
| 1324 | - * @global object $wpdb WordPress Database object. |
|
| 1325 | - * @param string $key The key you want to look for. |
|
| 1326 | - * @param string $value The value of the key you want to look for. |
|
| 1327 | - * @param string $geodir_post_type The post type. |
|
| 1328 | - * @return bool|mixed Returns field info when available. otherwise returns false. |
|
| 1329 | - */ |
|
| 1330 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
| 1331 | - {
|
|
| 1332 | - |
|
| 1333 | - global $wpdb; |
|
| 1334 | - |
|
| 1335 | - $filter = $wpdb->get_row( |
|
| 1336 | - $wpdb->prepare( |
|
| 1337 | - "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
| 1338 | - array($geodir_post_type) |
|
| 1339 | - ) |
|
| 1340 | - ); |
|
| 1341 | - |
|
| 1342 | - if ($filter) {
|
|
| 1343 | - return $filter; |
|
| 1344 | - } else {
|
|
| 1345 | - return false; |
|
| 1346 | - } |
|
| 1347 | - |
|
| 1348 | - } |
|
| 1319 | + /** |
|
| 1320 | + * Get custom field using key and value. |
|
| 1321 | + * |
|
| 1322 | + * @since 1.0.0 |
|
| 1323 | + * @package GeoDirectory |
|
| 1324 | + * @global object $wpdb WordPress Database object. |
|
| 1325 | + * @param string $key The key you want to look for. |
|
| 1326 | + * @param string $value The value of the key you want to look for. |
|
| 1327 | + * @param string $geodir_post_type The post type. |
|
| 1328 | + * @return bool|mixed Returns field info when available. otherwise returns false. |
|
| 1329 | + */ |
|
| 1330 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
| 1331 | + {
|
|
| 1332 | + |
|
| 1333 | + global $wpdb; |
|
| 1334 | + |
|
| 1335 | + $filter = $wpdb->get_row( |
|
| 1336 | + $wpdb->prepare( |
|
| 1337 | + "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
| 1338 | + array($geodir_post_type) |
|
| 1339 | + ) |
|
| 1340 | + ); |
|
| 1341 | + |
|
| 1342 | + if ($filter) {
|
|
| 1343 | + return $filter; |
|
| 1344 | + } else {
|
|
| 1345 | + return false; |
|
| 1346 | + } |
|
| 1347 | + |
|
| 1348 | + } |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | |
| 1352 | 1352 | function geodir_field_icon_proccess($cf){
|
| 1353 | 1353 | |
| 1354 | 1354 | |
| 1355 | - if (strpos($cf['field_icon'], 'http') !== false) {
|
|
| 1356 | - $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
|
|
| 1357 | - } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
|
|
| 1358 | - $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
| 1359 | - }else{
|
|
| 1360 | - $field_icon = $cf['field_icon']; |
|
| 1361 | - } |
|
| 1355 | + if (strpos($cf['field_icon'], 'http') !== false) {
|
|
| 1356 | + $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
|
|
| 1357 | + } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
|
|
| 1358 | + $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
| 1359 | + }else{
|
|
| 1360 | + $field_icon = $cf['field_icon']; |
|
| 1361 | + } |
|
| 1362 | 1362 | |
| 1363 | - return $field_icon; |
|
| 1363 | + return $field_icon; |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | if (!function_exists('geodir_show_listing_info')) {
|
| 1367 | - /** |
|
| 1368 | - * Show listing info depending on field location. |
|
| 1369 | - * |
|
| 1370 | - * @since 1.0.0 |
|
| 1371 | - * @since 1.5.7 Custom fields option values added to db translation. |
|
| 1372 | - * Changes to display url fields title. |
|
| 1373 | - * @package GeoDirectory |
|
| 1374 | - * @global object $wpdb WordPress Database object. |
|
| 1375 | - * @global object $post The current post object. |
|
| 1376 | - * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
| 1377 | - * |
|
| 1378 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
| 1379 | - * @return string Returns listing info html. |
|
| 1380 | - */ |
|
| 1381 | - function geodir_show_listing_info($fields_location = '') {
|
|
| 1382 | - global $post, $preview, $wpdb, $send_to_friend; |
|
| 1383 | - |
|
| 1384 | - $package_info = array(); |
|
| 1385 | - |
|
| 1386 | - $package_info = geodir_post_package_info($package_info, $post); |
|
| 1387 | - $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
| 1388 | - $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
| 1389 | - $send_to_friend = false; |
|
| 1390 | - |
|
| 1391 | - ob_start(); |
|
| 1392 | - $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
| 1393 | - |
|
| 1394 | - if (!empty($fields_info)) {
|
|
| 1395 | - $post = stripslashes_deep($post); // strip slashes |
|
| 1367 | + /** |
|
| 1368 | + * Show listing info depending on field location. |
|
| 1369 | + * |
|
| 1370 | + * @since 1.0.0 |
|
| 1371 | + * @since 1.5.7 Custom fields option values added to db translation. |
|
| 1372 | + * Changes to display url fields title. |
|
| 1373 | + * @package GeoDirectory |
|
| 1374 | + * @global object $wpdb WordPress Database object. |
|
| 1375 | + * @global object $post The current post object. |
|
| 1376 | + * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
| 1377 | + * |
|
| 1378 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
| 1379 | + * @return string Returns listing info html. |
|
| 1380 | + */ |
|
| 1381 | + function geodir_show_listing_info($fields_location = '') {
|
|
| 1382 | + global $post, $preview, $wpdb, $send_to_friend; |
|
| 1383 | + |
|
| 1384 | + $package_info = array(); |
|
| 1385 | + |
|
| 1386 | + $package_info = geodir_post_package_info($package_info, $post); |
|
| 1387 | + $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
| 1388 | + $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
| 1389 | + $send_to_friend = false; |
|
| 1390 | + |
|
| 1391 | + ob_start(); |
|
| 1392 | + $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
| 1393 | + |
|
| 1394 | + if (!empty($fields_info)) {
|
|
| 1395 | + $post = stripslashes_deep($post); // strip slashes |
|
| 1396 | 1396 | |
| 1397 | - //echo '<div class="geodir-company_info field-group">'; |
|
| 1398 | - global $field_set_start; |
|
| 1399 | - $field_set_start = 0; |
|
| 1400 | - |
|
| 1401 | - |
|
| 1402 | - |
|
| 1403 | - foreach ($fields_info as $type) {
|
|
| 1404 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
|
|
| 1405 | - $type = stripslashes_deep($type); // strip slashes |
|
| 1406 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
|
|
| 1407 | - $html = ''; |
|
| 1408 | - $field_icon = geodir_field_icon_proccess($type); |
|
| 1409 | - $filed_type = $type['type']; |
|
| 1410 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
| 1411 | - if($html_var=='post'){$html_var='post_address';}
|
|
| 1412 | - |
|
| 1413 | - /** |
|
| 1414 | - * Filter the output for custom fields. |
|
| 1415 | - * |
|
| 1416 | - * Here we can remove or add new functions depending on the field type. |
|
| 1417 | - * |
|
| 1418 | - * @param string $html The html to be filtered (blank). |
|
| 1419 | - * @param string $fields_location The location the field is to be show. |
|
| 1420 | - * @param array $type The array of field values. |
|
| 1421 | - */ |
|
| 1422 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
|
|
| 1423 | - |
|
| 1424 | - $variables_array = array(); |
|
| 1425 | - |
|
| 1426 | - |
|
| 1427 | - if ($type['type'] != 'fieldset'): |
|
| 1428 | - $variables_array['post_id'] = $post->ID; |
|
| 1429 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
| 1430 | - $variables_array['value'] = ''; |
|
| 1431 | - if (isset($post->{$type['htmlvar_name']}))
|
|
| 1432 | - $variables_array['value'] = $post->{$type['htmlvar_name']};
|
|
| 1433 | - endif; |
|
| 1434 | - |
|
| 1435 | - |
|
| 1436 | - if ($html): |
|
| 1437 | - |
|
| 1438 | - /** |
|
| 1439 | - * Called before a custom fields is output on the frontend. |
|
| 1440 | - * |
|
| 1441 | - * @since 1.0.0 |
|
| 1442 | - * @param string $html_var The HTML variable name for the field. |
|
| 1443 | - */ |
|
| 1444 | - do_action("geodir_before_show_{$html_var}");
|
|
| 1445 | - /** |
|
| 1446 | - * Filter custom field output. |
|
| 1447 | - * |
|
| 1448 | - * @since 1.0.0 |
|
| 1449 | - * |
|
| 1450 | - * @param string $html_var The HTML variable name for the field. |
|
| 1451 | - * @param string $html Custom field unfiltered HTML. |
|
| 1452 | - * @param array $variables_array Custom field variables array. |
|
| 1453 | - */ |
|
| 1454 | - if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
|
|
| 1455 | - |
|
| 1456 | - /** |
|
| 1457 | - * Called after a custom fields is output on the frontend. |
|
| 1458 | - * |
|
| 1459 | - * @since 1.0.0 |
|
| 1460 | - * @param string $html_var The HTML variable name for the field. |
|
| 1461 | - */ |
|
| 1462 | - do_action("geodir_after_show_{$html_var}");
|
|
| 1463 | - |
|
| 1464 | - endif; |
|
| 1465 | - |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - //echo '</div>'; |
|
| 1469 | - |
|
| 1470 | - } |
|
| 1471 | - |
|
| 1472 | - |
|
| 1473 | - $html = ob_get_clean(); |
|
| 1474 | - |
|
| 1475 | - /** |
|
| 1476 | - * Filter the custom fields over all output. |
|
| 1477 | - * |
|
| 1478 | - * @param string $html The html of the custom fields. |
|
| 1479 | - * @param string $fields_location The location the fields are being output. |
|
| 1480 | - * @since 1.6.9 |
|
| 1481 | - */ |
|
| 1482 | - return apply_filters('geodir_show_listing_info',$html,$fields_location);
|
|
| 1483 | - |
|
| 1484 | - } |
|
| 1397 | + //echo '<div class="geodir-company_info field-group">'; |
|
| 1398 | + global $field_set_start; |
|
| 1399 | + $field_set_start = 0; |
|
| 1400 | + |
|
| 1401 | + |
|
| 1402 | + |
|
| 1403 | + foreach ($fields_info as $type) {
|
|
| 1404 | + if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
|
|
| 1405 | + $type = stripslashes_deep($type); // strip slashes |
|
| 1406 | + if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
|
|
| 1407 | + $html = ''; |
|
| 1408 | + $field_icon = geodir_field_icon_proccess($type); |
|
| 1409 | + $filed_type = $type['type']; |
|
| 1410 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
| 1411 | + if($html_var=='post'){$html_var='post_address';}
|
|
| 1412 | + |
|
| 1413 | + /** |
|
| 1414 | + * Filter the output for custom fields. |
|
| 1415 | + * |
|
| 1416 | + * Here we can remove or add new functions depending on the field type. |
|
| 1417 | + * |
|
| 1418 | + * @param string $html The html to be filtered (blank). |
|
| 1419 | + * @param string $fields_location The location the field is to be show. |
|
| 1420 | + * @param array $type The array of field values. |
|
| 1421 | + */ |
|
| 1422 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
|
|
| 1423 | + |
|
| 1424 | + $variables_array = array(); |
|
| 1425 | + |
|
| 1426 | + |
|
| 1427 | + if ($type['type'] != 'fieldset'): |
|
| 1428 | + $variables_array['post_id'] = $post->ID; |
|
| 1429 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
| 1430 | + $variables_array['value'] = ''; |
|
| 1431 | + if (isset($post->{$type['htmlvar_name']}))
|
|
| 1432 | + $variables_array['value'] = $post->{$type['htmlvar_name']};
|
|
| 1433 | + endif; |
|
| 1434 | + |
|
| 1435 | + |
|
| 1436 | + if ($html): |
|
| 1437 | + |
|
| 1438 | + /** |
|
| 1439 | + * Called before a custom fields is output on the frontend. |
|
| 1440 | + * |
|
| 1441 | + * @since 1.0.0 |
|
| 1442 | + * @param string $html_var The HTML variable name for the field. |
|
| 1443 | + */ |
|
| 1444 | + do_action("geodir_before_show_{$html_var}");
|
|
| 1445 | + /** |
|
| 1446 | + * Filter custom field output. |
|
| 1447 | + * |
|
| 1448 | + * @since 1.0.0 |
|
| 1449 | + * |
|
| 1450 | + * @param string $html_var The HTML variable name for the field. |
|
| 1451 | + * @param string $html Custom field unfiltered HTML. |
|
| 1452 | + * @param array $variables_array Custom field variables array. |
|
| 1453 | + */ |
|
| 1454 | + if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
|
|
| 1455 | + |
|
| 1456 | + /** |
|
| 1457 | + * Called after a custom fields is output on the frontend. |
|
| 1458 | + * |
|
| 1459 | + * @since 1.0.0 |
|
| 1460 | + * @param string $html_var The HTML variable name for the field. |
|
| 1461 | + */ |
|
| 1462 | + do_action("geodir_after_show_{$html_var}");
|
|
| 1463 | + |
|
| 1464 | + endif; |
|
| 1465 | + |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + //echo '</div>'; |
|
| 1469 | + |
|
| 1470 | + } |
|
| 1471 | + |
|
| 1472 | + |
|
| 1473 | + $html = ob_get_clean(); |
|
| 1474 | + |
|
| 1475 | + /** |
|
| 1476 | + * Filter the custom fields over all output. |
|
| 1477 | + * |
|
| 1478 | + * @param string $html The html of the custom fields. |
|
| 1479 | + * @param string $fields_location The location the fields are being output. |
|
| 1480 | + * @since 1.6.9 |
|
| 1481 | + */ |
|
| 1482 | + return apply_filters('geodir_show_listing_info',$html,$fields_location);
|
|
| 1483 | + |
|
| 1484 | + } |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | if (!function_exists('geodir_default_date_format')) {
|
| 1488 | - /** |
|
| 1489 | - * Returns default date format. |
|
| 1490 | - * |
|
| 1491 | - * @since 1.0.0 |
|
| 1492 | - * @package GeoDirectory |
|
| 1493 | - * @return mixed|string|void Returns default date format. |
|
| 1494 | - */ |
|
| 1495 | - function geodir_default_date_format() |
|
| 1496 | - {
|
|
| 1497 | - if ($format = get_option('date_format'))
|
|
| 1498 | - return $format; |
|
| 1499 | - else |
|
| 1500 | - return 'dd-mm-yy'; |
|
| 1501 | - } |
|
| 1488 | + /** |
|
| 1489 | + * Returns default date format. |
|
| 1490 | + * |
|
| 1491 | + * @since 1.0.0 |
|
| 1492 | + * @package GeoDirectory |
|
| 1493 | + * @return mixed|string|void Returns default date format. |
|
| 1494 | + */ |
|
| 1495 | + function geodir_default_date_format() |
|
| 1496 | + {
|
|
| 1497 | + if ($format = get_option('date_format'))
|
|
| 1498 | + return $format; |
|
| 1499 | + else |
|
| 1500 | + return 'dd-mm-yy'; |
|
| 1501 | + } |
|
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | if (!function_exists('geodir_get_formated_date')) {
|
| 1505 | - /** |
|
| 1506 | - * Returns formatted date. |
|
| 1507 | - * |
|
| 1508 | - * @since 1.0.0 |
|
| 1509 | - * @package GeoDirectory |
|
| 1510 | - * @param string $date Date string to convert. |
|
| 1511 | - * @return bool|int|string Returns formatted date. |
|
| 1512 | - */ |
|
| 1513 | - function geodir_get_formated_date($date) |
|
| 1514 | - {
|
|
| 1515 | - return mysql2date(get_option('date_format'), $date);
|
|
| 1516 | - } |
|
| 1505 | + /** |
|
| 1506 | + * Returns formatted date. |
|
| 1507 | + * |
|
| 1508 | + * @since 1.0.0 |
|
| 1509 | + * @package GeoDirectory |
|
| 1510 | + * @param string $date Date string to convert. |
|
| 1511 | + * @return bool|int|string Returns formatted date. |
|
| 1512 | + */ |
|
| 1513 | + function geodir_get_formated_date($date) |
|
| 1514 | + {
|
|
| 1515 | + return mysql2date(get_option('date_format'), $date);
|
|
| 1516 | + } |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | if (!function_exists('geodir_get_formated_time')) {
|
| 1520 | - /** |
|
| 1521 | - * Returns formatted time. |
|
| 1522 | - * |
|
| 1523 | - * @since 1.0.0 |
|
| 1524 | - * @package GeoDirectory |
|
| 1525 | - * @param string $time Time string to convert. |
|
| 1526 | - * @return bool|int|string Returns formatted time. |
|
| 1527 | - */ |
|
| 1528 | - function geodir_get_formated_time($time) |
|
| 1529 | - {
|
|
| 1530 | - return mysql2date(get_option('time_format'), $time, $translate = true);
|
|
| 1531 | - } |
|
| 1520 | + /** |
|
| 1521 | + * Returns formatted time. |
|
| 1522 | + * |
|
| 1523 | + * @since 1.0.0 |
|
| 1524 | + * @package GeoDirectory |
|
| 1525 | + * @param string $time Time string to convert. |
|
| 1526 | + * @return bool|int|string Returns formatted time. |
|
| 1527 | + */ |
|
| 1528 | + function geodir_get_formated_time($time) |
|
| 1529 | + {
|
|
| 1530 | + return mysql2date(get_option('time_format'), $time, $translate = true);
|
|
| 1531 | + } |
|
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | 1534 | |
| 1535 | 1535 | if (!function_exists('geodir_save_post_file_fields')) {
|
| 1536 | - /** |
|
| 1537 | - * Save post file fields |
|
| 1538 | - * |
|
| 1539 | - * @since 1.0.0 |
|
| 1540 | - * @since 1.4.7 Added `$extra_fields` parameter. |
|
| 1541 | - * @package GeoDirectory |
|
| 1542 | - * @global object $wpdb WordPress Database object. |
|
| 1543 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1544 | - * @global object $current_user Current user object. |
|
| 1545 | - * @param int $post_id |
|
| 1546 | - * @param string $field_id |
|
| 1547 | - * @param array $post_image |
|
| 1548 | - * @param array $extra_fields Array of extra fields. |
|
| 1549 | - */ |
|
| 1550 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
| 1551 | - {
|
|
| 1536 | + /** |
|
| 1537 | + * Save post file fields |
|
| 1538 | + * |
|
| 1539 | + * @since 1.0.0 |
|
| 1540 | + * @since 1.4.7 Added `$extra_fields` parameter. |
|
| 1541 | + * @package GeoDirectory |
|
| 1542 | + * @global object $wpdb WordPress Database object. |
|
| 1543 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1544 | + * @global object $current_user Current user object. |
|
| 1545 | + * @param int $post_id |
|
| 1546 | + * @param string $field_id |
|
| 1547 | + * @param array $post_image |
|
| 1548 | + * @param array $extra_fields Array of extra fields. |
|
| 1549 | + */ |
|
| 1550 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
| 1551 | + {
|
|
| 1552 | 1552 | |
| 1553 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 1553 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 1554 | 1554 | |
| 1555 | - $post_type = get_post_type($post_id); |
|
| 1556 | - //echo $field_id; exit; |
|
| 1557 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1555 | + $post_type = get_post_type($post_id); |
|
| 1556 | + //echo $field_id; exit; |
|
| 1557 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1558 | 1558 | |
| 1559 | - $postcurr_images = array(); |
|
| 1560 | - $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
| 1561 | - $file_urls = ''; |
|
| 1559 | + $postcurr_images = array(); |
|
| 1560 | + $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
| 1561 | + $file_urls = ''; |
|
| 1562 | 1562 | |
| 1563 | - if (!empty($post_image)) {
|
|
| 1563 | + if (!empty($post_image)) {
|
|
| 1564 | 1564 | |
| 1565 | - $invalid_files = array(); |
|
| 1565 | + $invalid_files = array(); |
|
| 1566 | 1566 | |
| 1567 | - //Get and remove all old images of post from database to set by new order |
|
| 1568 | - $geodir_uploaddir = ''; |
|
| 1569 | - $uploads = wp_upload_dir(); |
|
| 1570 | - $uploads_dir = $uploads['path']; |
|
| 1567 | + //Get and remove all old images of post from database to set by new order |
|
| 1568 | + $geodir_uploaddir = ''; |
|
| 1569 | + $uploads = wp_upload_dir(); |
|
| 1570 | + $uploads_dir = $uploads['path']; |
|
| 1571 | 1571 | |
| 1572 | - $geodir_uploadpath = $uploads['path']; |
|
| 1573 | - $geodir_uploadurl = $uploads['url']; |
|
| 1574 | - $sub_dir = $uploads['subdir']; |
|
| 1572 | + $geodir_uploadpath = $uploads['path']; |
|
| 1573 | + $geodir_uploadurl = $uploads['url']; |
|
| 1574 | + $sub_dir = $uploads['subdir']; |
|
| 1575 | 1575 | |
| 1576 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 1576 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 1577 | 1577 | |
| 1578 | - for ($m = 0; $m < count($post_image); $m++) {
|
|
| 1578 | + for ($m = 0; $m < count($post_image); $m++) {
|
|
| 1579 | 1579 | |
| 1580 | - /* --------- start ------- */ |
|
| 1580 | + /* --------- start ------- */ |
|
| 1581 | 1581 | |
| 1582 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
|
|
| 1582 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
|
|
| 1583 | 1583 | |
| 1584 | 1584 | |
| 1585 | - $curr_img_url = $post_image[$m]; |
|
| 1586 | - $image_name_arr = explode('/', $curr_img_url);
|
|
| 1587 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
| 1588 | - $filename = end($image_name_arr); |
|
| 1589 | - $img_name_arr = explode('.', $filename);
|
|
| 1585 | + $curr_img_url = $post_image[$m]; |
|
| 1586 | + $image_name_arr = explode('/', $curr_img_url);
|
|
| 1587 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
| 1588 | + $filename = end($image_name_arr); |
|
| 1589 | + $img_name_arr = explode('.', $filename);
|
|
| 1590 | 1590 | |
| 1591 | - $arr_file_type = wp_check_filetype($filename); |
|
| 1591 | + $arr_file_type = wp_check_filetype($filename); |
|
| 1592 | 1592 | |
| 1593 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 1594 | - continue; |
|
| 1595 | - } |
|
| 1593 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 1594 | + continue; |
|
| 1595 | + } |
|
| 1596 | 1596 | |
| 1597 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 1598 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 1597 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 1598 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 1599 | 1599 | |
| 1600 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 1601 | - continue; // Invalid file type. |
|
| 1602 | - } |
|
| 1600 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 1601 | + continue; // Invalid file type. |
|
| 1602 | + } |
|
| 1603 | 1603 | |
| 1604 | - // Set an array containing a list of acceptable formats |
|
| 1605 | - //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
|
| 1604 | + // Set an array containing a list of acceptable formats |
|
| 1605 | + //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
|
| 1606 | 1606 | |
| 1607 | - if (!function_exists('wp_handle_upload'))
|
|
| 1608 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1607 | + if (!function_exists('wp_handle_upload'))
|
|
| 1608 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1609 | 1609 | |
| 1610 | - if (!is_dir($geodir_uploadpath)) |
|
| 1611 | - mkdir($geodir_uploadpath); |
|
| 1610 | + if (!is_dir($geodir_uploadpath)) |
|
| 1611 | + mkdir($geodir_uploadpath); |
|
| 1612 | 1612 | |
| 1613 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
| 1614 | - $explode_sub_dir = explode("/", $sub_dir);
|
|
| 1615 | - if ($curr_img_dir == end($explode_sub_dir)) {
|
|
| 1616 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1617 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1618 | - } else {
|
|
| 1619 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1620 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1621 | - } |
|
| 1613 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
| 1614 | + $explode_sub_dir = explode("/", $sub_dir);
|
|
| 1615 | + if ($curr_img_dir == end($explode_sub_dir)) {
|
|
| 1616 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1617 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1618 | + } else {
|
|
| 1619 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1620 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1621 | + } |
|
| 1622 | 1622 | |
| 1623 | - $uploaded_file = ''; |
|
| 1624 | - if (file_exists($img_path)) |
|
| 1625 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1623 | + $uploaded_file = ''; |
|
| 1624 | + if (file_exists($img_path)) |
|
| 1625 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1626 | 1626 | |
| 1627 | - if ($curr_img_dir != $geodir_uploaddir) {
|
|
| 1628 | - if (file_exists($img_path)) |
|
| 1629 | - unlink($img_path); |
|
| 1630 | - } |
|
| 1627 | + if ($curr_img_dir != $geodir_uploaddir) {
|
|
| 1628 | + if (file_exists($img_path)) |
|
| 1629 | + unlink($img_path); |
|
| 1630 | + } |
|
| 1631 | 1631 | |
| 1632 | - if (!empty($uploaded_file)) |
|
| 1633 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 1632 | + if (!empty($uploaded_file)) |
|
| 1633 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 1634 | 1634 | |
| 1635 | - } else {
|
|
| 1636 | - $file_urls = $post_image[$m]; |
|
| 1637 | - } |
|
| 1638 | - } |
|
| 1635 | + } else {
|
|
| 1636 | + $file_urls = $post_image[$m]; |
|
| 1637 | + } |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | 1640 | |
| 1641 | - } |
|
| 1641 | + } |
|
| 1642 | 1642 | |
| 1643 | - //Remove all old attachments and temp images |
|
| 1644 | - if (!empty($postcurr_images)) {
|
|
| 1643 | + //Remove all old attachments and temp images |
|
| 1644 | + if (!empty($postcurr_images)) {
|
|
| 1645 | 1645 | |
| 1646 | - if ($file_urls != $postcurr_images) {
|
|
| 1647 | - $invalid_files[] = (object)array('src' => $postcurr_images);
|
|
| 1648 | - $invalid_files = (object)$invalid_files; |
|
| 1649 | - } |
|
| 1650 | - } |
|
| 1646 | + if ($file_urls != $postcurr_images) {
|
|
| 1647 | + $invalid_files[] = (object)array('src' => $postcurr_images);
|
|
| 1648 | + $invalid_files = (object)$invalid_files; |
|
| 1649 | + } |
|
| 1650 | + } |
|
| 1651 | 1651 | |
| 1652 | - geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
| 1652 | + geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
| 1653 | 1653 | |
| 1654 | - if (!empty($invalid_files)) |
|
| 1655 | - geodir_remove_attachments($invalid_files); |
|
| 1654 | + if (!empty($invalid_files)) |
|
| 1655 | + geodir_remove_attachments($invalid_files); |
|
| 1656 | 1656 | |
| 1657 | - } |
|
| 1657 | + } |
|
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | 1660 | |
@@ -1669,76 +1669,76 @@ discard block |
||
| 1669 | 1669 | */ |
| 1670 | 1670 | function geodir_custom_upload_mimes($existing_mimes = array()) |
| 1671 | 1671 | {
|
| 1672 | - $existing_mimes['wif'] = 'text/plain'; |
|
| 1673 | - $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
| 1674 | - $existing_mimes['gif'] = 'image/gif'; |
|
| 1675 | - $existing_mimes['png'] = 'image/png'; |
|
| 1676 | - $existing_mimes['pdf'] = 'application/pdf'; |
|
| 1677 | - $existing_mimes['txt'] = 'text/text'; |
|
| 1678 | - $existing_mimes['csv'] = 'application/octet-stream'; |
|
| 1679 | - $existing_mimes['doc'] = 'application/msword'; |
|
| 1680 | - $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
| 1681 | - $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
| 1682 | - $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
| 1683 | - return $existing_mimes; |
|
| 1672 | + $existing_mimes['wif'] = 'text/plain'; |
|
| 1673 | + $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
| 1674 | + $existing_mimes['gif'] = 'image/gif'; |
|
| 1675 | + $existing_mimes['png'] = 'image/png'; |
|
| 1676 | + $existing_mimes['pdf'] = 'application/pdf'; |
|
| 1677 | + $existing_mimes['txt'] = 'text/text'; |
|
| 1678 | + $existing_mimes['csv'] = 'application/octet-stream'; |
|
| 1679 | + $existing_mimes['doc'] = 'application/msword'; |
|
| 1680 | + $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
| 1681 | + $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
| 1682 | + $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
| 1683 | + return $existing_mimes; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | if (!function_exists('geodir_plupload_action')) {
|
| 1687 | 1687 | |
| 1688 | - /** |
|
| 1689 | - * Get upload directory path details |
|
| 1690 | - * |
|
| 1691 | - * @since 1.0.0 |
|
| 1692 | - * @package GeoDirectory |
|
| 1693 | - * @global object $current_user Current user object. |
|
| 1694 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
| 1695 | - * @return mixed Returns upload directory details as an array. |
|
| 1696 | - */ |
|
| 1697 | - function geodir_upload_dir($upload) |
|
| 1698 | - {
|
|
| 1699 | - global $current_user; |
|
| 1700 | - $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
| 1701 | - $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
| 1702 | - $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
| 1703 | - return $upload; |
|
| 1704 | - } |
|
| 1705 | - |
|
| 1706 | - /** |
|
| 1707 | - * Handles place file and image upload. |
|
| 1708 | - * |
|
| 1709 | - * @since 1.0.0 |
|
| 1710 | - * @package GeoDirectory |
|
| 1711 | - */ |
|
| 1712 | - function geodir_plupload_action() |
|
| 1713 | - {
|
|
| 1714 | - // check ajax nonce |
|
| 1715 | - $imgid = $_POST["imgid"]; |
|
| 1716 | - |
|
| 1717 | - check_ajax_referer($imgid . 'pluploadan'); |
|
| 1718 | - |
|
| 1719 | - // handle custom file uploaddir |
|
| 1720 | - add_filter('upload_dir', 'geodir_upload_dir');
|
|
| 1721 | - |
|
| 1722 | - // change file orientation if needed |
|
| 1723 | - $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
| 1724 | - |
|
| 1725 | - // handle file upload |
|
| 1726 | - $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
|
|
| 1727 | - // remove handle custom file uploaddir |
|
| 1728 | - remove_filter('upload_dir', 'geodir_upload_dir');
|
|
| 1729 | - |
|
| 1730 | - if(!isset($status['url']) && isset($status['error'])){
|
|
| 1731 | - print_r($status); |
|
| 1732 | - } |
|
| 1733 | - |
|
| 1734 | - // send the uploaded file url in response |
|
| 1735 | - if (isset($status['url'])) {
|
|
| 1736 | - echo $status['url']; |
|
| 1737 | - } else {
|
|
| 1738 | - echo 'x'; |
|
| 1739 | - } |
|
| 1740 | - exit; |
|
| 1741 | - } |
|
| 1688 | + /** |
|
| 1689 | + * Get upload directory path details |
|
| 1690 | + * |
|
| 1691 | + * @since 1.0.0 |
|
| 1692 | + * @package GeoDirectory |
|
| 1693 | + * @global object $current_user Current user object. |
|
| 1694 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
| 1695 | + * @return mixed Returns upload directory details as an array. |
|
| 1696 | + */ |
|
| 1697 | + function geodir_upload_dir($upload) |
|
| 1698 | + {
|
|
| 1699 | + global $current_user; |
|
| 1700 | + $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
| 1701 | + $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
| 1702 | + $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
| 1703 | + return $upload; |
|
| 1704 | + } |
|
| 1705 | + |
|
| 1706 | + /** |
|
| 1707 | + * Handles place file and image upload. |
|
| 1708 | + * |
|
| 1709 | + * @since 1.0.0 |
|
| 1710 | + * @package GeoDirectory |
|
| 1711 | + */ |
|
| 1712 | + function geodir_plupload_action() |
|
| 1713 | + {
|
|
| 1714 | + // check ajax nonce |
|
| 1715 | + $imgid = $_POST["imgid"]; |
|
| 1716 | + |
|
| 1717 | + check_ajax_referer($imgid . 'pluploadan'); |
|
| 1718 | + |
|
| 1719 | + // handle custom file uploaddir |
|
| 1720 | + add_filter('upload_dir', 'geodir_upload_dir');
|
|
| 1721 | + |
|
| 1722 | + // change file orientation if needed |
|
| 1723 | + $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
| 1724 | + |
|
| 1725 | + // handle file upload |
|
| 1726 | + $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
|
|
| 1727 | + // remove handle custom file uploaddir |
|
| 1728 | + remove_filter('upload_dir', 'geodir_upload_dir');
|
|
| 1729 | + |
|
| 1730 | + if(!isset($status['url']) && isset($status['error'])){
|
|
| 1731 | + print_r($status); |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + // send the uploaded file url in response |
|
| 1735 | + if (isset($status['url'])) {
|
|
| 1736 | + echo $status['url']; |
|
| 1737 | + } else {
|
|
| 1738 | + echo 'x'; |
|
| 1739 | + } |
|
| 1740 | + exit; |
|
| 1741 | + } |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | /** |
@@ -1753,17 +1753,17 @@ discard block |
||
| 1753 | 1753 | */ |
| 1754 | 1754 | function geodir_get_video($post_id) |
| 1755 | 1755 | {
|
| 1756 | - global $wpdb, $plugin_prefix; |
|
| 1756 | + global $wpdb, $plugin_prefix; |
|
| 1757 | 1757 | |
| 1758 | - $post_type = get_post_type($post_id); |
|
| 1758 | + $post_type = get_post_type($post_id); |
|
| 1759 | 1759 | |
| 1760 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1760 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1761 | 1761 | |
| 1762 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
|
|
| 1762 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
|
|
| 1763 | 1763 | |
| 1764 | - if ($results) {
|
|
| 1765 | - return $results[0]->geodir_video; |
|
| 1766 | - } |
|
| 1764 | + if ($results) {
|
|
| 1765 | + return $results[0]->geodir_video; |
|
| 1766 | + } |
|
| 1767 | 1767 | |
| 1768 | 1768 | } |
| 1769 | 1769 | |
@@ -1779,40 +1779,40 @@ discard block |
||
| 1779 | 1779 | */ |
| 1780 | 1780 | function geodir_get_special_offers($post_id) |
| 1781 | 1781 | {
|
| 1782 | - global $wpdb, $plugin_prefix; |
|
| 1782 | + global $wpdb, $plugin_prefix; |
|
| 1783 | 1783 | |
| 1784 | - $post_type = get_post_type($post_id); |
|
| 1784 | + $post_type = get_post_type($post_id); |
|
| 1785 | 1785 | |
| 1786 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1786 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1787 | 1787 | |
| 1788 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
|
|
| 1788 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
|
|
| 1789 | 1789 | |
| 1790 | - if ($results) {
|
|
| 1791 | - return $results[0]->geodir_special_offers; |
|
| 1792 | - } |
|
| 1790 | + if ($results) {
|
|
| 1791 | + return $results[0]->geodir_special_offers; |
|
| 1792 | + } |
|
| 1793 | 1793 | |
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | 1796 | if (!function_exists('geodir_max_upload_size')) {
|
| 1797 | - /** |
|
| 1798 | - * Get max upload file size |
|
| 1799 | - * |
|
| 1800 | - * @since 1.0.0 |
|
| 1801 | - * @package GeoDirectory |
|
| 1802 | - * @return mixed|void Returns max upload file size. |
|
| 1803 | - */ |
|
| 1804 | - function geodir_max_upload_size() |
|
| 1805 | - {
|
|
| 1806 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1807 | - |
|
| 1808 | - if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1809 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1810 | - } else {
|
|
| 1811 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1812 | - } |
|
| 1813 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 1814 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1815 | - } |
|
| 1797 | + /** |
|
| 1798 | + * Get max upload file size |
|
| 1799 | + * |
|
| 1800 | + * @since 1.0.0 |
|
| 1801 | + * @package GeoDirectory |
|
| 1802 | + * @return mixed|void Returns max upload file size. |
|
| 1803 | + */ |
|
| 1804 | + function geodir_max_upload_size() |
|
| 1805 | + {
|
|
| 1806 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1807 | + |
|
| 1808 | + if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1809 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1810 | + } else {
|
|
| 1811 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1812 | + } |
|
| 1813 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
| 1814 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1815 | + } |
|
| 1816 | 1816 | } |
| 1817 | 1817 | |
| 1818 | 1818 | |
@@ -1830,33 +1830,33 @@ discard block |
||
| 1830 | 1830 | */ |
| 1831 | 1831 | function geodir_add_custom_sort_options($fields, $post_type) |
| 1832 | 1832 | {
|
| 1833 | - global $wpdb; |
|
| 1833 | + global $wpdb; |
|
| 1834 | 1834 | |
| 1835 | - if ($post_type != '') {
|
|
| 1835 | + if ($post_type != '') {
|
|
| 1836 | 1836 | |
| 1837 | - $all_postypes = geodir_get_posttypes(); |
|
| 1837 | + $all_postypes = geodir_get_posttypes(); |
|
| 1838 | 1838 | |
| 1839 | - if (in_array($post_type, $all_postypes)) {
|
|
| 1839 | + if (in_array($post_type, $all_postypes)) {
|
|
| 1840 | 1840 | |
| 1841 | - $custom_fields = $wpdb->get_results( |
|
| 1842 | - $wpdb->prepare( |
|
| 1843 | - "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc", |
|
| 1844 | - array($post_type) |
|
| 1845 | - ), 'ARRAY_A' |
|
| 1846 | - ); |
|
| 1841 | + $custom_fields = $wpdb->get_results( |
|
| 1842 | + $wpdb->prepare( |
|
| 1843 | + "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc", |
|
| 1844 | + array($post_type) |
|
| 1845 | + ), 'ARRAY_A' |
|
| 1846 | + ); |
|
| 1847 | 1847 | |
| 1848 | - if (!empty($custom_fields)) {
|
|
| 1848 | + if (!empty($custom_fields)) {
|
|
| 1849 | 1849 | |
| 1850 | - foreach ($custom_fields as $val) {
|
|
| 1851 | - $fields[] = $val; |
|
| 1852 | - } |
|
| 1853 | - } |
|
| 1850 | + foreach ($custom_fields as $val) {
|
|
| 1851 | + $fields[] = $val; |
|
| 1852 | + } |
|
| 1853 | + } |
|
| 1854 | 1854 | |
| 1855 | - } |
|
| 1855 | + } |
|
| 1856 | 1856 | |
| 1857 | - } |
|
| 1857 | + } |
|
| 1858 | 1858 | |
| 1859 | - return $fields; |
|
| 1859 | + return $fields; |
|
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | |
@@ -1872,76 +1872,76 @@ discard block |
||
| 1872 | 1872 | function geodir_get_custom_sort_options($post_type = '') |
| 1873 | 1873 | {
|
| 1874 | 1874 | |
| 1875 | - global $wpdb; |
|
| 1876 | - |
|
| 1877 | - if ($post_type != '') {
|
|
| 1878 | - |
|
| 1879 | - $all_postypes = geodir_get_posttypes(); |
|
| 1880 | - |
|
| 1881 | - if (!in_array($post_type, $all_postypes)) |
|
| 1882 | - return false; |
|
| 1883 | - |
|
| 1884 | - $fields = array(); |
|
| 1885 | - |
|
| 1886 | - $fields[] = array( |
|
| 1887 | - 'post_type' => $post_type, |
|
| 1888 | - 'data_type' => '', |
|
| 1889 | - 'field_type' => 'random', |
|
| 1890 | - 'site_title' => 'Random', |
|
| 1891 | - 'htmlvar_name' => 'post_title', |
|
| 1892 | - 'field_icon' => 'fa fa-random', |
|
| 1893 | - 'description' => __('Random sort (not recommended for large sites)', 'geodirectory')
|
|
| 1894 | - ); |
|
| 1895 | - |
|
| 1896 | - $fields[] = array( |
|
| 1897 | - 'post_type' => $post_type, |
|
| 1898 | - 'data_type' => '', |
|
| 1899 | - 'field_type' => 'datetime', |
|
| 1900 | - 'site_title' => __('Add date', 'geodirectory'),
|
|
| 1901 | - 'htmlvar_name' => 'post_date', |
|
| 1902 | - 'field_icon' => 'fa fa-calendar', |
|
| 1903 | - 'description' => __('Sort by date added', 'geodirectory')
|
|
| 1904 | - ); |
|
| 1905 | - $fields[] = array( |
|
| 1906 | - 'post_type' => $post_type, |
|
| 1907 | - 'data_type' => '', |
|
| 1908 | - 'field_type' => 'bigint', |
|
| 1909 | - 'site_title' => __('Review', 'geodirectory'),
|
|
| 1910 | - 'htmlvar_name' => 'comment_count', |
|
| 1911 | - 'field_icon' => 'fa fa-commenting-o', |
|
| 1912 | - 'description' => __('Sort by the number of reviews', 'geodirectory')
|
|
| 1913 | - ); |
|
| 1914 | - $fields[] = array( |
|
| 1915 | - 'post_type' => $post_type, |
|
| 1916 | - 'data_type' => '', |
|
| 1917 | - 'field_type' => 'float', |
|
| 1918 | - 'site_title' => __('Rating', 'geodirectory'),
|
|
| 1919 | - 'htmlvar_name' => 'overall_rating', |
|
| 1920 | - 'field_icon' => 'fa fa-star-o', |
|
| 1921 | - 'description' => __('Sort by the overall rating value', 'geodirectory')
|
|
| 1922 | - ); |
|
| 1923 | - $fields[] = array( |
|
| 1924 | - 'post_type' => $post_type, |
|
| 1925 | - 'data_type' => '', |
|
| 1926 | - 'field_type' => 'text', |
|
| 1927 | - 'site_title' => __('Title', 'geodirectory'),
|
|
| 1928 | - 'htmlvar_name' => 'post_title', |
|
| 1929 | - 'field_icon' => 'fa fa-sort-alpha-desc', |
|
| 1930 | - 'description' => __('Sort alphabetically by title', 'geodirectory')
|
|
| 1931 | - ); |
|
| 1932 | - |
|
| 1933 | - /** |
|
| 1934 | - * Hook to add custom sort options. |
|
| 1935 | - * |
|
| 1936 | - * @since 1.0.0 |
|
| 1937 | - * @param array $fields Unmodified sort options array. |
|
| 1938 | - * @param string $post_type Post type. |
|
| 1939 | - */ |
|
| 1940 | - return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
|
|
| 1941 | - |
|
| 1942 | - } |
|
| 1943 | - |
|
| 1944 | - return false; |
|
| 1875 | + global $wpdb; |
|
| 1876 | + |
|
| 1877 | + if ($post_type != '') {
|
|
| 1878 | + |
|
| 1879 | + $all_postypes = geodir_get_posttypes(); |
|
| 1880 | + |
|
| 1881 | + if (!in_array($post_type, $all_postypes)) |
|
| 1882 | + return false; |
|
| 1883 | + |
|
| 1884 | + $fields = array(); |
|
| 1885 | + |
|
| 1886 | + $fields[] = array( |
|
| 1887 | + 'post_type' => $post_type, |
|
| 1888 | + 'data_type' => '', |
|
| 1889 | + 'field_type' => 'random', |
|
| 1890 | + 'site_title' => 'Random', |
|
| 1891 | + 'htmlvar_name' => 'post_title', |
|
| 1892 | + 'field_icon' => 'fa fa-random', |
|
| 1893 | + 'description' => __('Random sort (not recommended for large sites)', 'geodirectory')
|
|
| 1894 | + ); |
|
| 1895 | + |
|
| 1896 | + $fields[] = array( |
|
| 1897 | + 'post_type' => $post_type, |
|
| 1898 | + 'data_type' => '', |
|
| 1899 | + 'field_type' => 'datetime', |
|
| 1900 | + 'site_title' => __('Add date', 'geodirectory'),
|
|
| 1901 | + 'htmlvar_name' => 'post_date', |
|
| 1902 | + 'field_icon' => 'fa fa-calendar', |
|
| 1903 | + 'description' => __('Sort by date added', 'geodirectory')
|
|
| 1904 | + ); |
|
| 1905 | + $fields[] = array( |
|
| 1906 | + 'post_type' => $post_type, |
|
| 1907 | + 'data_type' => '', |
|
| 1908 | + 'field_type' => 'bigint', |
|
| 1909 | + 'site_title' => __('Review', 'geodirectory'),
|
|
| 1910 | + 'htmlvar_name' => 'comment_count', |
|
| 1911 | + 'field_icon' => 'fa fa-commenting-o', |
|
| 1912 | + 'description' => __('Sort by the number of reviews', 'geodirectory')
|
|
| 1913 | + ); |
|
| 1914 | + $fields[] = array( |
|
| 1915 | + 'post_type' => $post_type, |
|
| 1916 | + 'data_type' => '', |
|
| 1917 | + 'field_type' => 'float', |
|
| 1918 | + 'site_title' => __('Rating', 'geodirectory'),
|
|
| 1919 | + 'htmlvar_name' => 'overall_rating', |
|
| 1920 | + 'field_icon' => 'fa fa-star-o', |
|
| 1921 | + 'description' => __('Sort by the overall rating value', 'geodirectory')
|
|
| 1922 | + ); |
|
| 1923 | + $fields[] = array( |
|
| 1924 | + 'post_type' => $post_type, |
|
| 1925 | + 'data_type' => '', |
|
| 1926 | + 'field_type' => 'text', |
|
| 1927 | + 'site_title' => __('Title', 'geodirectory'),
|
|
| 1928 | + 'htmlvar_name' => 'post_title', |
|
| 1929 | + 'field_icon' => 'fa fa-sort-alpha-desc', |
|
| 1930 | + 'description' => __('Sort alphabetically by title', 'geodirectory')
|
|
| 1931 | + ); |
|
| 1932 | + |
|
| 1933 | + /** |
|
| 1934 | + * Hook to add custom sort options. |
|
| 1935 | + * |
|
| 1936 | + * @since 1.0.0 |
|
| 1937 | + * @param array $fields Unmodified sort options array. |
|
| 1938 | + * @param string $post_type Post type. |
|
| 1939 | + */ |
|
| 1940 | + return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
|
|
| 1941 | + |
|
| 1942 | + } |
|
| 1943 | + |
|
| 1944 | + return false; |
|
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | |
@@ -1957,117 +1957,117 @@ discard block |
||
| 1957 | 1957 | function godir_set_sort_field_order($field_ids = array()) |
| 1958 | 1958 | {
|
| 1959 | 1959 | |
| 1960 | - global $wpdb; |
|
| 1960 | + global $wpdb; |
|
| 1961 | 1961 | |
| 1962 | - $count = 0; |
|
| 1963 | - if (!empty($field_ids)): |
|
| 1964 | - foreach ($field_ids as $id) {
|
|
| 1962 | + $count = 0; |
|
| 1963 | + if (!empty($field_ids)): |
|
| 1964 | + foreach ($field_ids as $id) {
|
|
| 1965 | 1965 | |
| 1966 | - $cf = trim($id, '_'); |
|
| 1966 | + $cf = trim($id, '_'); |
|
| 1967 | 1967 | |
| 1968 | - $post_meta_info = $wpdb->query( |
|
| 1969 | - $wpdb->prepare( |
|
| 1970 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 1968 | + $post_meta_info = $wpdb->query( |
|
| 1969 | + $wpdb->prepare( |
|
| 1970 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 1971 | 1971 | sort_order=%d |
| 1972 | 1972 | where id= %d", |
| 1973 | - array($count, $cf) |
|
| 1974 | - ) |
|
| 1975 | - ); |
|
| 1976 | - $count++; |
|
| 1977 | - } |
|
| 1978 | - |
|
| 1979 | - return $field_ids; |
|
| 1980 | - else: |
|
| 1981 | - return false; |
|
| 1982 | - endif; |
|
| 1973 | + array($count, $cf) |
|
| 1974 | + ) |
|
| 1975 | + ); |
|
| 1976 | + $count++; |
|
| 1977 | + } |
|
| 1978 | + |
|
| 1979 | + return $field_ids; |
|
| 1980 | + else: |
|
| 1981 | + return false; |
|
| 1982 | + endif; |
|
| 1983 | 1983 | } |
| 1984 | 1984 | |
| 1985 | 1985 | |
| 1986 | 1986 | if (!function_exists('geodir_custom_sort_field_save')) {
|
| 1987 | - /** |
|
| 1988 | - * Save or Update custom sort fields into the database. |
|
| 1989 | - * |
|
| 1990 | - * @since 1.0.0 |
|
| 1991 | - * @package GeoDirectory |
|
| 1992 | - * @global object $wpdb WordPress Database object. |
|
| 1993 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1994 | - * @param array $request_field {
|
|
| 1995 | - * Attributes of the Request field. |
|
| 1996 | - * |
|
| 1997 | - * @type string $action Ajax action name. |
|
| 1998 | - * @type string $manage_field_type Manage field type Default "sorting_options". |
|
| 1999 | - * @type string $create_field Do you want to create this field?. |
|
| 2000 | - * @type string $field_ins_upd Field created or updated?. |
|
| 2001 | - * @type string $_wpnonce Nonce value. |
|
| 2002 | - * @type string $listing_type The Post type. |
|
| 2003 | - * @type string $field_type Field Type. |
|
| 2004 | - * @type string $field_id Field ID. |
|
| 2005 | - * @type string $data_type Data Type. |
|
| 2006 | - * @type string $htmlvar_name HTML variable name. |
|
| 2007 | - * @type string $site_title Section title which you wish to display in frontend. |
|
| 2008 | - * @type string $is_default Is this default sorting?. |
|
| 2009 | - * @type string $is_active If not active then the field will not be displayed anywhere. |
|
| 2010 | - * @type string $sort_order Sort Order. |
|
| 2011 | - * |
|
| 2012 | - * } |
|
| 2013 | - * @param bool $default Not yet implemented. |
|
| 2014 | - * @return int Returns the last affected db table row id. |
|
| 2015 | - */ |
|
| 2016 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
| 2017 | - {
|
|
| 2018 | - |
|
| 2019 | - global $wpdb, $plugin_prefix; |
|
| 2020 | - |
|
| 2021 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
| 2022 | - |
|
| 2023 | - $cf = trim($result_str, '_'); |
|
| 2024 | - |
|
| 2025 | - /*-------- check duplicate validation --------*/ |
|
| 2026 | - |
|
| 2027 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
| 2028 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 2029 | - |
|
| 2030 | - $post_type = $request_field['listing_type']; |
|
| 2031 | - $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
| 2032 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
| 2033 | - $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
| 2034 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 2035 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
| 2036 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
| 2037 | - $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
| 2038 | - $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
| 2039 | - $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
| 2040 | - $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
| 2041 | - $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
| 2042 | - |
|
| 2043 | - $default_order = ''; |
|
| 2044 | - if ($is_default != '') {
|
|
| 2045 | - $default_order = $is_default; |
|
| 2046 | - $is_default = '1'; |
|
| 2047 | - } |
|
| 2048 | - |
|
| 2049 | - |
|
| 2050 | - $check_html_variable = $wpdb->get_var( |
|
| 2051 | - $wpdb->prepare( |
|
| 2052 | - "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
| 2053 | - array($cehhtmlvar_name, $post_type, $field_type) |
|
| 2054 | - ) |
|
| 2055 | - ); |
|
| 2056 | - |
|
| 2057 | - if ($is_default == 1) {
|
|
| 2058 | - |
|
| 2059 | - $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
|
|
| 2060 | - |
|
| 2061 | - } |
|
| 2062 | - |
|
| 2063 | - |
|
| 2064 | - if (!$check_html_variable) {
|
|
| 2065 | - |
|
| 2066 | - $wpdb->query( |
|
| 2067 | - |
|
| 2068 | - $wpdb->prepare( |
|
| 2069 | - |
|
| 2070 | - "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 1987 | + /** |
|
| 1988 | + * Save or Update custom sort fields into the database. |
|
| 1989 | + * |
|
| 1990 | + * @since 1.0.0 |
|
| 1991 | + * @package GeoDirectory |
|
| 1992 | + * @global object $wpdb WordPress Database object. |
|
| 1993 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1994 | + * @param array $request_field {
|
|
| 1995 | + * Attributes of the Request field. |
|
| 1996 | + * |
|
| 1997 | + * @type string $action Ajax action name. |
|
| 1998 | + * @type string $manage_field_type Manage field type Default "sorting_options". |
|
| 1999 | + * @type string $create_field Do you want to create this field?. |
|
| 2000 | + * @type string $field_ins_upd Field created or updated?. |
|
| 2001 | + * @type string $_wpnonce Nonce value. |
|
| 2002 | + * @type string $listing_type The Post type. |
|
| 2003 | + * @type string $field_type Field Type. |
|
| 2004 | + * @type string $field_id Field ID. |
|
| 2005 | + * @type string $data_type Data Type. |
|
| 2006 | + * @type string $htmlvar_name HTML variable name. |
|
| 2007 | + * @type string $site_title Section title which you wish to display in frontend. |
|
| 2008 | + * @type string $is_default Is this default sorting?. |
|
| 2009 | + * @type string $is_active If not active then the field will not be displayed anywhere. |
|
| 2010 | + * @type string $sort_order Sort Order. |
|
| 2011 | + * |
|
| 2012 | + * } |
|
| 2013 | + * @param bool $default Not yet implemented. |
|
| 2014 | + * @return int Returns the last affected db table row id. |
|
| 2015 | + */ |
|
| 2016 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
| 2017 | + {
|
|
| 2018 | + |
|
| 2019 | + global $wpdb, $plugin_prefix; |
|
| 2020 | + |
|
| 2021 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
| 2022 | + |
|
| 2023 | + $cf = trim($result_str, '_'); |
|
| 2024 | + |
|
| 2025 | + /*-------- check duplicate validation --------*/ |
|
| 2026 | + |
|
| 2027 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
| 2028 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 2029 | + |
|
| 2030 | + $post_type = $request_field['listing_type']; |
|
| 2031 | + $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
| 2032 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
| 2033 | + $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
| 2034 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
| 2035 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
| 2036 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
| 2037 | + $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
| 2038 | + $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
| 2039 | + $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
| 2040 | + $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
| 2041 | + $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
| 2042 | + |
|
| 2043 | + $default_order = ''; |
|
| 2044 | + if ($is_default != '') {
|
|
| 2045 | + $default_order = $is_default; |
|
| 2046 | + $is_default = '1'; |
|
| 2047 | + } |
|
| 2048 | + |
|
| 2049 | + |
|
| 2050 | + $check_html_variable = $wpdb->get_var( |
|
| 2051 | + $wpdb->prepare( |
|
| 2052 | + "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
| 2053 | + array($cehhtmlvar_name, $post_type, $field_type) |
|
| 2054 | + ) |
|
| 2055 | + ); |
|
| 2056 | + |
|
| 2057 | + if ($is_default == 1) {
|
|
| 2058 | + |
|
| 2059 | + $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
|
|
| 2060 | + |
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + |
|
| 2064 | + if (!$check_html_variable) {
|
|
| 2065 | + |
|
| 2066 | + $wpdb->query( |
|
| 2067 | + |
|
| 2068 | + $wpdb->prepare( |
|
| 2069 | + |
|
| 2070 | + "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 2071 | 2071 | post_type = %s, |
| 2072 | 2072 | data_type = %s, |
| 2073 | 2073 | field_type = %s, |
@@ -2082,23 +2082,23 @@ discard block |
||
| 2082 | 2082 | asc_title = %s, |
| 2083 | 2083 | desc_title = %s", |
| 2084 | 2084 | |
| 2085 | - array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title) |
|
| 2086 | - ) |
|
| 2085 | + array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title) |
|
| 2086 | + ) |
|
| 2087 | 2087 | |
| 2088 | - ); |
|
| 2088 | + ); |
|
| 2089 | 2089 | |
| 2090 | 2090 | |
| 2091 | - $lastid = $wpdb->insert_id; |
|
| 2091 | + $lastid = $wpdb->insert_id; |
|
| 2092 | 2092 | |
| 2093 | - $lastid = trim($lastid); |
|
| 2093 | + $lastid = trim($lastid); |
|
| 2094 | 2094 | |
| 2095 | - } else {
|
|
| 2095 | + } else {
|
|
| 2096 | 2096 | |
| 2097 | - $wpdb->query( |
|
| 2097 | + $wpdb->query( |
|
| 2098 | 2098 | |
| 2099 | - $wpdb->prepare( |
|
| 2099 | + $wpdb->prepare( |
|
| 2100 | 2100 | |
| 2101 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 2101 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
| 2102 | 2102 | post_type = %s, |
| 2103 | 2103 | data_type = %s, |
| 2104 | 2104 | field_type = %s, |
@@ -2114,123 +2114,123 @@ discard block |
||
| 2114 | 2114 | desc_title = %s |
| 2115 | 2115 | where id = %d", |
| 2116 | 2116 | |
| 2117 | - array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf) |
|
| 2118 | - ) |
|
| 2117 | + array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf) |
|
| 2118 | + ) |
|
| 2119 | 2119 | |
| 2120 | - ); |
|
| 2120 | + ); |
|
| 2121 | 2121 | |
| 2122 | - $lastid = trim($cf); |
|
| 2122 | + $lastid = trim($cf); |
|
| 2123 | 2123 | |
| 2124 | - } |
|
| 2124 | + } |
|
| 2125 | 2125 | |
| 2126 | 2126 | |
| 2127 | - return (int)$lastid; |
|
| 2127 | + return (int)$lastid; |
|
| 2128 | 2128 | |
| 2129 | - } |
|
| 2129 | + } |
|
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | 2132 | |
| 2133 | 2133 | if (!function_exists('geodir_custom_sort_field_delete')) {
|
| 2134 | - /** |
|
| 2135 | - * Delete a custom sort field using field id. |
|
| 2136 | - * @since 1.0.0 |
|
| 2137 | - * @package GeoDirectory |
|
| 2138 | - * @global object $wpdb WordPress Database object. |
|
| 2139 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2140 | - * @param string $field_id The field ID. |
|
| 2141 | - * @return int|string Returns field id when successful deletion, else returns 0. |
|
| 2142 | - */ |
|
| 2143 | - function geodir_custom_sort_field_delete($field_id = '') |
|
| 2144 | - {
|
|
| 2145 | - |
|
| 2146 | - global $wpdb, $plugin_prefix; |
|
| 2147 | - if ($field_id != '') {
|
|
| 2148 | - $cf = trim($field_id, '_'); |
|
| 2149 | - |
|
| 2150 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
|
|
| 2151 | - |
|
| 2152 | - return $field_id; |
|
| 2153 | - |
|
| 2154 | - } else |
|
| 2155 | - return 0; |
|
| 2156 | - |
|
| 2157 | - } |
|
| 2134 | + /** |
|
| 2135 | + * Delete a custom sort field using field id. |
|
| 2136 | + * @since 1.0.0 |
|
| 2137 | + * @package GeoDirectory |
|
| 2138 | + * @global object $wpdb WordPress Database object. |
|
| 2139 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2140 | + * @param string $field_id The field ID. |
|
| 2141 | + * @return int|string Returns field id when successful deletion, else returns 0. |
|
| 2142 | + */ |
|
| 2143 | + function geodir_custom_sort_field_delete($field_id = '') |
|
| 2144 | + {
|
|
| 2145 | + |
|
| 2146 | + global $wpdb, $plugin_prefix; |
|
| 2147 | + if ($field_id != '') {
|
|
| 2148 | + $cf = trim($field_id, '_'); |
|
| 2149 | + |
|
| 2150 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
|
|
| 2151 | + |
|
| 2152 | + return $field_id; |
|
| 2153 | + |
|
| 2154 | + } else |
|
| 2155 | + return 0; |
|
| 2156 | + |
|
| 2157 | + } |
|
| 2158 | 2158 | } |
| 2159 | 2159 | |
| 2160 | 2160 | |
| 2161 | 2161 | if (!function_exists('geodir_custom_sort_field_adminhtml')) {
|
| 2162 | - /** |
|
| 2163 | - * Custom sort field admin html. |
|
| 2164 | - * |
|
| 2165 | - * @since 1.0.0 |
|
| 2166 | - * @package GeoDirectory |
|
| 2167 | - * @global object $wpdb WordPress Database object. |
|
| 2168 | - * @param string $field_type The form field type. |
|
| 2169 | - * @param object|int $result_str The custom field results object or row id. |
|
| 2170 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
| 2171 | - * @param bool $default when set to true field will be for admin use only. |
|
| 2172 | - */ |
|
| 2173 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
| 2174 | - {
|
|
| 2175 | - global $wpdb; |
|
| 2176 | - $cf = $result_str; |
|
| 2177 | - if (!is_object($cf)) {
|
|
| 2178 | - $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
|
|
| 2179 | - } else {
|
|
| 2180 | - $field_info = $cf; |
|
| 2181 | - $result_str = $cf->id; |
|
| 2182 | - } |
|
| 2183 | - |
|
| 2184 | - $field_info = stripslashes_deep($field_info); // strip slashes |
|
| 2185 | - |
|
| 2186 | - if (!isset($field_info->post_type)) {
|
|
| 2187 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2188 | - } else {
|
|
| 2189 | - $post_type = $field_info->post_type; |
|
| 2190 | - } |
|
| 2191 | - |
|
| 2192 | - |
|
| 2193 | - $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
| 2194 | - |
|
| 2195 | - $site_title = ''; |
|
| 2196 | - if ($site_title == '') |
|
| 2197 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
| 2198 | - |
|
| 2199 | - if ($site_title == '') {
|
|
| 2200 | - $fields = geodir_get_custom_sort_options($post_type); |
|
| 2201 | - |
|
| 2202 | - foreach ($fields as $val) {
|
|
| 2203 | - $val = stripslashes_deep($val); // strip slashes |
|
| 2204 | - |
|
| 2205 | - if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
|
|
| 2206 | - $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
| 2207 | - } |
|
| 2208 | - } |
|
| 2209 | - } |
|
| 2210 | - |
|
| 2211 | - if ($htmlvar_name == '') |
|
| 2212 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
| 2213 | - |
|
| 2214 | - $nonce = wp_create_nonce('custom_fields_' . $result_str);
|
|
| 2215 | - |
|
| 2216 | - $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 2217 | - $cso_arr = geodir_get_custom_sort_options($post_type); |
|
| 2218 | - |
|
| 2219 | - $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
| 2220 | - foreach($cso_arr as $cso){
|
|
| 2221 | - if($cur_field_type==$cso['field_type']){
|
|
| 2222 | - |
|
| 2223 | - if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
|
|
| 2224 | - $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
| 2225 | - }elseif(isset($cso['field_icon']) && $cso['field_icon']){
|
|
| 2226 | - $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
|
|
| 2227 | - } |
|
| 2228 | - |
|
| 2229 | - } |
|
| 2230 | - } |
|
| 2231 | - |
|
| 2232 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
| 2233 | - ?> |
|
| 2162 | + /** |
|
| 2163 | + * Custom sort field admin html. |
|
| 2164 | + * |
|
| 2165 | + * @since 1.0.0 |
|
| 2166 | + * @package GeoDirectory |
|
| 2167 | + * @global object $wpdb WordPress Database object. |
|
| 2168 | + * @param string $field_type The form field type. |
|
| 2169 | + * @param object|int $result_str The custom field results object or row id. |
|
| 2170 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
| 2171 | + * @param bool $default when set to true field will be for admin use only. |
|
| 2172 | + */ |
|
| 2173 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
| 2174 | + {
|
|
| 2175 | + global $wpdb; |
|
| 2176 | + $cf = $result_str; |
|
| 2177 | + if (!is_object($cf)) {
|
|
| 2178 | + $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
|
|
| 2179 | + } else {
|
|
| 2180 | + $field_info = $cf; |
|
| 2181 | + $result_str = $cf->id; |
|
| 2182 | + } |
|
| 2183 | + |
|
| 2184 | + $field_info = stripslashes_deep($field_info); // strip slashes |
|
| 2185 | + |
|
| 2186 | + if (!isset($field_info->post_type)) {
|
|
| 2187 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2188 | + } else {
|
|
| 2189 | + $post_type = $field_info->post_type; |
|
| 2190 | + } |
|
| 2191 | + |
|
| 2192 | + |
|
| 2193 | + $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
| 2194 | + |
|
| 2195 | + $site_title = ''; |
|
| 2196 | + if ($site_title == '') |
|
| 2197 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
| 2198 | + |
|
| 2199 | + if ($site_title == '') {
|
|
| 2200 | + $fields = geodir_get_custom_sort_options($post_type); |
|
| 2201 | + |
|
| 2202 | + foreach ($fields as $val) {
|
|
| 2203 | + $val = stripslashes_deep($val); // strip slashes |
|
| 2204 | + |
|
| 2205 | + if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
|
|
| 2206 | + $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
| 2207 | + } |
|
| 2208 | + } |
|
| 2209 | + } |
|
| 2210 | + |
|
| 2211 | + if ($htmlvar_name == '') |
|
| 2212 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
| 2213 | + |
|
| 2214 | + $nonce = wp_create_nonce('custom_fields_' . $result_str);
|
|
| 2215 | + |
|
| 2216 | + $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 2217 | + $cso_arr = geodir_get_custom_sort_options($post_type); |
|
| 2218 | + |
|
| 2219 | + $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
| 2220 | + foreach($cso_arr as $cso){
|
|
| 2221 | + if($cur_field_type==$cso['field_type']){
|
|
| 2222 | + |
|
| 2223 | + if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
|
|
| 2224 | + $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
| 2225 | + }elseif(isset($cso['field_icon']) && $cso['field_icon']){
|
|
| 2226 | + $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
|
|
| 2227 | + } |
|
| 2228 | + |
|
| 2229 | + } |
|
| 2230 | + } |
|
| 2231 | + |
|
| 2232 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
| 2233 | + ?> |
|
| 2234 | 2234 | |
| 2235 | 2235 | <li class="text" id="licontainer_<?php echo $result_str;?>"> |
| 2236 | 2236 | <form><!-- we need to wrap in a form so we can use radio buttons with same name --> |
@@ -2239,7 +2239,7 @@ discard block |
||
| 2239 | 2239 | ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
|
| 2240 | 2240 | <?php |
| 2241 | 2241 | |
| 2242 | - ?> |
|
| 2242 | + ?> |
|
| 2243 | 2243 | |
| 2244 | 2244 | <div title="<?php _e('Click to remove field', 'geodirectory');?>"
|
| 2245 | 2245 | onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
|
@@ -2254,17 +2254,17 @@ discard block |
||
| 2254 | 2254 | |
| 2255 | 2255 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
| 2256 | 2256 | style="display:<?php if ($field_ins_upd == 'submit') {
|
| 2257 | - echo 'block;'; |
|
| 2258 | - } else {
|
|
| 2259 | - echo 'none;'; |
|
| 2260 | - } ?>"> |
|
| 2257 | + echo 'block;'; |
|
| 2258 | + } else {
|
|
| 2259 | + echo 'none;'; |
|
| 2260 | + } ?>"> |
|
| 2261 | 2261 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
| 2262 | 2262 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
| 2263 | 2263 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
| 2264 | 2264 | <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> |
| 2265 | 2265 | <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
|
| 2266 | - echo $field_info->data_type; |
|
| 2267 | - }?>"/> |
|
| 2266 | + echo $field_info->data_type; |
|
| 2267 | + }?>"/> |
|
| 2268 | 2268 | <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> |
| 2269 | 2269 | |
| 2270 | 2270 | |
@@ -2287,14 +2287,14 @@ discard block |
||
| 2287 | 2287 | |
| 2288 | 2288 | <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled" value="1" |
| 2289 | 2289 | <?php if ($value == '1') {
|
| 2290 | - echo 'checked'; |
|
| 2291 | - } ?>/> |
|
| 2290 | + echo 'checked'; |
|
| 2291 | + } ?>/> |
|
| 2292 | 2292 | <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 2293 | 2293 | |
| 2294 | 2294 | <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0" |
| 2295 | 2295 | <?php if ($value == '0' || !$value) {
|
| 2296 | - echo 'checked'; |
|
| 2297 | - } ?>/> |
|
| 2296 | + echo 'checked'; |
|
| 2297 | + } ?>/> |
|
| 2298 | 2298 | <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 2299 | 2299 | |
| 2300 | 2300 | </div> |
@@ -2331,8 +2331,8 @@ discard block |
||
| 2331 | 2331 | |
| 2332 | 2332 | <input type="radio" name="is_default" |
| 2333 | 2333 | value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
|
| 2334 | - echo 'checked="checked"'; |
|
| 2335 | - } ?>/> |
|
| 2334 | + echo 'checked="checked"'; |
|
| 2335 | + } ?>/> |
|
| 2336 | 2336 | </div> |
| 2337 | 2337 | |
| 2338 | 2338 | </li> |
@@ -2352,14 +2352,14 @@ discard block |
||
| 2352 | 2352 | |
| 2353 | 2353 | <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled" value="1" |
| 2354 | 2354 | <?php if ($value == '1') {
|
| 2355 | - echo 'checked'; |
|
| 2356 | - } ?>/> |
|
| 2355 | + echo 'checked'; |
|
| 2356 | + } ?>/> |
|
| 2357 | 2357 | <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 2358 | 2358 | |
| 2359 | 2359 | <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0" |
| 2360 | 2360 | <?php if ($value == '0' || !$value) {
|
| 2361 | - echo 'checked'; |
|
| 2362 | - } ?>/> |
|
| 2361 | + echo 'checked'; |
|
| 2362 | + } ?>/> |
|
| 2363 | 2363 | <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 2364 | 2364 | |
| 2365 | 2365 | </div> |
@@ -2395,8 +2395,8 @@ discard block |
||
| 2395 | 2395 | |
| 2396 | 2396 | <input type="radio" name="is_default" |
| 2397 | 2397 | value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
|
| 2398 | - echo 'checked="checked"'; |
|
| 2399 | - } ?>/> |
|
| 2398 | + echo 'checked="checked"'; |
|
| 2399 | + } ?>/> |
|
| 2400 | 2400 | </div> |
| 2401 | 2401 | |
| 2402 | 2402 | </li> |
@@ -2438,8 +2438,8 @@ discard block |
||
| 2438 | 2438 | |
| 2439 | 2439 | <input type="checkbox" name="is_default" |
| 2440 | 2440 | value="<?php echo $field_type; ?>" <?php if (isset($value) && $value == '1') {
|
| 2441 | - echo 'checked="checked"'; |
|
| 2442 | - } ?>/> |
|
| 2441 | + echo 'checked="checked"'; |
|
| 2442 | + } ?>/> |
|
| 2443 | 2443 | </div> |
| 2444 | 2444 | |
| 2445 | 2445 | |
@@ -2462,14 +2462,14 @@ discard block |
||
| 2462 | 2462 | |
| 2463 | 2463 | <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled" value="1" |
| 2464 | 2464 | <?php if ($value == '1') {
|
| 2465 | - echo 'checked'; |
|
| 2466 | - } ?>/> |
|
| 2465 | + echo 'checked'; |
|
| 2466 | + } ?>/> |
|
| 2467 | 2467 | <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 2468 | 2468 | |
| 2469 | 2469 | <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0" |
| 2470 | 2470 | <?php if ($value == '0' || !$value) {
|
| 2471 | - echo 'checked'; |
|
| 2472 | - } ?>/> |
|
| 2471 | + echo 'checked'; |
|
| 2472 | + } ?>/> |
|
| 2473 | 2473 | <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 2474 | 2474 | |
| 2475 | 2475 | </div> |
@@ -2479,8 +2479,8 @@ discard block |
||
| 2479 | 2479 | |
| 2480 | 2480 | <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" |
| 2481 | 2481 | value="<?php if (isset($field_info->sort_order)) {
|
| 2482 | - echo esc_attr($field_info->sort_order); |
|
| 2483 | - }?>" size="50"/> |
|
| 2482 | + echo esc_attr($field_info->sort_order); |
|
| 2483 | + }?>" size="50"/> |
|
| 2484 | 2484 | |
| 2485 | 2485 | |
| 2486 | 2486 | |
@@ -2504,38 +2504,38 @@ discard block |
||
| 2504 | 2504 | </form> |
| 2505 | 2505 | </li> <?php |
| 2506 | 2506 | |
| 2507 | - } |
|
| 2507 | + } |
|
| 2508 | 2508 | } |
| 2509 | 2509 | |
| 2510 | 2510 | if (!function_exists('check_field_visibility')) {
|
| 2511 | - /** |
|
| 2512 | - * Check field visibility as per price package. |
|
| 2513 | - * |
|
| 2514 | - * @since 1.0.0 |
|
| 2515 | - * @package GeoDirectory |
|
| 2516 | - * @global object $wpdb WordPress Database object. |
|
| 2517 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 2518 | - * @param int|string $package_id The package ID. |
|
| 2519 | - * @param string $field_name The field name. |
|
| 2520 | - * @param string $post_type Optional. The wordpress post type. |
|
| 2521 | - * @return bool Returns true when field visible, otherwise false. |
|
| 2522 | - */ |
|
| 2523 | - function check_field_visibility($package_id, $field_name, $post_type) |
|
| 2524 | - {
|
|
| 2525 | - global $wpdb, $geodir_addon_list; |
|
| 2526 | - if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
|
|
| 2527 | - return true; |
|
| 2528 | - } |
|
| 2529 | - if (!$package_id || !$field_name || !$post_type) {
|
|
| 2530 | - return true; |
|
| 2531 | - } |
|
| 2532 | - $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
|
|
| 2533 | - |
|
| 2534 | - if ($wpdb->get_var($sql)) {
|
|
| 2535 | - return true; |
|
| 2536 | - } |
|
| 2537 | - return false; |
|
| 2538 | - } |
|
| 2511 | + /** |
|
| 2512 | + * Check field visibility as per price package. |
|
| 2513 | + * |
|
| 2514 | + * @since 1.0.0 |
|
| 2515 | + * @package GeoDirectory |
|
| 2516 | + * @global object $wpdb WordPress Database object. |
|
| 2517 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 2518 | + * @param int|string $package_id The package ID. |
|
| 2519 | + * @param string $field_name The field name. |
|
| 2520 | + * @param string $post_type Optional. The wordpress post type. |
|
| 2521 | + * @return bool Returns true when field visible, otherwise false. |
|
| 2522 | + */ |
|
| 2523 | + function check_field_visibility($package_id, $field_name, $post_type) |
|
| 2524 | + {
|
|
| 2525 | + global $wpdb, $geodir_addon_list; |
|
| 2526 | + if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
|
|
| 2527 | + return true; |
|
| 2528 | + } |
|
| 2529 | + if (!$package_id || !$field_name || !$post_type) {
|
|
| 2530 | + return true; |
|
| 2531 | + } |
|
| 2532 | + $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
|
|
| 2533 | + |
|
| 2534 | + if ($wpdb->get_var($sql)) {
|
|
| 2535 | + return true; |
|
| 2536 | + } |
|
| 2537 | + return false; |
|
| 2538 | + } |
|
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | 2541 | /** |
@@ -2551,43 +2551,43 @@ discard block |
||
| 2551 | 2551 | */ |
| 2552 | 2552 | function geodir_string_to_options($input = '', $translated = false) |
| 2553 | 2553 | {
|
| 2554 | - $return = array(); |
|
| 2555 | - if ($input != '') {
|
|
| 2556 | - $input = trim($input); |
|
| 2557 | - $input = rtrim($input, ","); |
|
| 2558 | - $input = ltrim($input, ","); |
|
| 2559 | - $input = trim($input); |
|
| 2560 | - } |
|
| 2561 | - |
|
| 2562 | - $input_arr = explode(',', $input);
|
|
| 2563 | - |
|
| 2564 | - if (!empty($input_arr)) {
|
|
| 2565 | - foreach ($input_arr as $input_str) {
|
|
| 2566 | - $input_str = trim($input_str); |
|
| 2567 | - |
|
| 2568 | - if (strpos($input_str, "/") !== false) {
|
|
| 2569 | - $input_str = explode("/", $input_str, 2);
|
|
| 2570 | - $label = trim($input_str[0]); |
|
| 2571 | - if ($translated && $label != '') {
|
|
| 2572 | - $label = __($label, 'geodirectory'); |
|
| 2573 | - } |
|
| 2574 | - $label = geodir_utf8_ucfirst($label); |
|
| 2575 | - $value = trim($input_str[1]); |
|
| 2576 | - } else {
|
|
| 2577 | - $value = $input_str; |
|
| 2578 | - if ($translated && $input_str != '') {
|
|
| 2579 | - $input_str = __($input_str, 'geodirectory'); |
|
| 2580 | - } |
|
| 2581 | - $label = geodir_utf8_ucfirst($input_str); |
|
| 2582 | - } |
|
| 2583 | - |
|
| 2584 | - if ($label != '') {
|
|
| 2585 | - $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
|
|
| 2586 | - } |
|
| 2587 | - } |
|
| 2588 | - } |
|
| 2589 | - |
|
| 2590 | - return $return; |
|
| 2554 | + $return = array(); |
|
| 2555 | + if ($input != '') {
|
|
| 2556 | + $input = trim($input); |
|
| 2557 | + $input = rtrim($input, ","); |
|
| 2558 | + $input = ltrim($input, ","); |
|
| 2559 | + $input = trim($input); |
|
| 2560 | + } |
|
| 2561 | + |
|
| 2562 | + $input_arr = explode(',', $input);
|
|
| 2563 | + |
|
| 2564 | + if (!empty($input_arr)) {
|
|
| 2565 | + foreach ($input_arr as $input_str) {
|
|
| 2566 | + $input_str = trim($input_str); |
|
| 2567 | + |
|
| 2568 | + if (strpos($input_str, "/") !== false) {
|
|
| 2569 | + $input_str = explode("/", $input_str, 2);
|
|
| 2570 | + $label = trim($input_str[0]); |
|
| 2571 | + if ($translated && $label != '') {
|
|
| 2572 | + $label = __($label, 'geodirectory'); |
|
| 2573 | + } |
|
| 2574 | + $label = geodir_utf8_ucfirst($label); |
|
| 2575 | + $value = trim($input_str[1]); |
|
| 2576 | + } else {
|
|
| 2577 | + $value = $input_str; |
|
| 2578 | + if ($translated && $input_str != '') {
|
|
| 2579 | + $input_str = __($input_str, 'geodirectory'); |
|
| 2580 | + } |
|
| 2581 | + $label = geodir_utf8_ucfirst($input_str); |
|
| 2582 | + } |
|
| 2583 | + |
|
| 2584 | + if ($label != '') {
|
|
| 2585 | + $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
|
|
| 2586 | + } |
|
| 2587 | + } |
|
| 2588 | + } |
|
| 2589 | + |
|
| 2590 | + return $return; |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | /** |
@@ -2602,66 +2602,66 @@ discard block |
||
| 2602 | 2602 | */ |
| 2603 | 2603 | function geodir_string_values_to_options($option_values = '', $translated = false) |
| 2604 | 2604 | {
|
| 2605 | - $options = array(); |
|
| 2606 | - if ($option_values == '') {
|
|
| 2607 | - return NULL; |
|
| 2608 | - } |
|
| 2609 | - |
|
| 2610 | - if (strpos($option_values, "{/optgroup}") !== false) {
|
|
| 2611 | - $option_values_arr = explode("{/optgroup}", $option_values);
|
|
| 2612 | - |
|
| 2613 | - foreach ($option_values_arr as $optgroup) {
|
|
| 2614 | - if (strpos($optgroup, "{optgroup}") !== false) {
|
|
| 2615 | - $optgroup_arr = explode("{optgroup}", $optgroup);
|
|
| 2616 | - |
|
| 2617 | - $count = 0; |
|
| 2618 | - foreach ($optgroup_arr as $optgroup_str) {
|
|
| 2619 | - $count++; |
|
| 2620 | - $optgroup_str = trim($optgroup_str); |
|
| 2621 | - |
|
| 2622 | - $optgroup_label = ''; |
|
| 2623 | - if (strpos($optgroup_str, "|") !== false) {
|
|
| 2624 | - $optgroup_str_arr = explode("|", $optgroup_str, 2);
|
|
| 2625 | - $optgroup_label = trim($optgroup_str_arr[0]); |
|
| 2626 | - if ($translated && $optgroup_label != '') {
|
|
| 2627 | - $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
| 2628 | - } |
|
| 2629 | - $optgroup_label = geodir_utf8_ucfirst($optgroup_label); |
|
| 2630 | - $optgroup_str = $optgroup_str_arr[1]; |
|
| 2631 | - } |
|
| 2632 | - |
|
| 2633 | - $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
| 2634 | - |
|
| 2635 | - if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
|
|
| 2636 | - $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
|
|
| 2637 | - $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
|
|
| 2638 | - $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
| 2639 | - } |
|
| 2640 | - $options = array_merge($options, $optgroup3); |
|
| 2641 | - } |
|
| 2642 | - } else {
|
|
| 2643 | - $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
| 2644 | - $options = array_merge($options, $optgroup1); |
|
| 2645 | - } |
|
| 2646 | - } |
|
| 2647 | - } else {
|
|
| 2648 | - $options = geodir_string_to_options($option_values, $translated); |
|
| 2649 | - } |
|
| 2650 | - |
|
| 2651 | - return $options; |
|
| 2605 | + $options = array(); |
|
| 2606 | + if ($option_values == '') {
|
|
| 2607 | + return NULL; |
|
| 2608 | + } |
|
| 2609 | + |
|
| 2610 | + if (strpos($option_values, "{/optgroup}") !== false) {
|
|
| 2611 | + $option_values_arr = explode("{/optgroup}", $option_values);
|
|
| 2612 | + |
|
| 2613 | + foreach ($option_values_arr as $optgroup) {
|
|
| 2614 | + if (strpos($optgroup, "{optgroup}") !== false) {
|
|
| 2615 | + $optgroup_arr = explode("{optgroup}", $optgroup);
|
|
| 2616 | + |
|
| 2617 | + $count = 0; |
|
| 2618 | + foreach ($optgroup_arr as $optgroup_str) {
|
|
| 2619 | + $count++; |
|
| 2620 | + $optgroup_str = trim($optgroup_str); |
|
| 2621 | + |
|
| 2622 | + $optgroup_label = ''; |
|
| 2623 | + if (strpos($optgroup_str, "|") !== false) {
|
|
| 2624 | + $optgroup_str_arr = explode("|", $optgroup_str, 2);
|
|
| 2625 | + $optgroup_label = trim($optgroup_str_arr[0]); |
|
| 2626 | + if ($translated && $optgroup_label != '') {
|
|
| 2627 | + $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
| 2628 | + } |
|
| 2629 | + $optgroup_label = geodir_utf8_ucfirst($optgroup_label); |
|
| 2630 | + $optgroup_str = $optgroup_str_arr[1]; |
|
| 2631 | + } |
|
| 2632 | + |
|
| 2633 | + $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
| 2634 | + |
|
| 2635 | + if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
|
|
| 2636 | + $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
|
|
| 2637 | + $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
|
|
| 2638 | + $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
| 2639 | + } |
|
| 2640 | + $options = array_merge($options, $optgroup3); |
|
| 2641 | + } |
|
| 2642 | + } else {
|
|
| 2643 | + $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
| 2644 | + $options = array_merge($options, $optgroup1); |
|
| 2645 | + } |
|
| 2646 | + } |
|
| 2647 | + } else {
|
|
| 2648 | + $options = geodir_string_to_options($option_values, $translated); |
|
| 2649 | + } |
|
| 2650 | + |
|
| 2651 | + return $options; |
|
| 2652 | 2652 | } |
| 2653 | 2653 | |
| 2654 | 2654 | |
| 2655 | 2655 | function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){
|
| 2656 | - ob_start(); |
|
| 2657 | - |
|
| 2658 | - $dt_value = ''; |
|
| 2659 | - if (isset($field_info->data_type)) {
|
|
| 2660 | - $dt_value = esc_attr($field_info->data_type); |
|
| 2661 | - }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
|
|
| 2662 | - $dt_value = $cf['defaults']['data_type']; |
|
| 2663 | - } |
|
| 2664 | - ?> |
|
| 2656 | + ob_start(); |
|
| 2657 | + |
|
| 2658 | + $dt_value = ''; |
|
| 2659 | + if (isset($field_info->data_type)) {
|
|
| 2660 | + $dt_value = esc_attr($field_info->data_type); |
|
| 2661 | + }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
|
|
| 2662 | + $dt_value = $cf['defaults']['data_type']; |
|
| 2663 | + } |
|
| 2664 | + ?> |
|
| 2665 | 2665 | <li> |
| 2666 | 2666 | <label for="data_type"><?php _e('Field Data Type ? :', 'geodirectory'); ?></label>
|
| 2667 | 2667 | <div class="gd-cf-input-wrap"> |
@@ -2670,16 +2670,16 @@ discard block |
||
| 2670 | 2670 | onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');"> |
| 2671 | 2671 | <option |
| 2672 | 2672 | value="XVARCHAR" <?php if ($dt_value == 'VARCHAR') {
|
| 2673 | - echo 'selected="selected"'; |
|
| 2674 | - } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
|
|
| 2673 | + echo 'selected="selected"'; |
|
| 2674 | + } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
|
|
| 2675 | 2675 | <option |
| 2676 | 2676 | value="INT" <?php if ($dt_value == 'INT') {
|
| 2677 | - echo 'selected="selected"'; |
|
| 2678 | - } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
|
|
| 2677 | + echo 'selected="selected"'; |
|
| 2678 | + } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
|
|
| 2679 | 2679 | <option |
| 2680 | 2680 | value="FLOAT" <?php if ($dt_value == 'FLOAT') {
|
| 2681 | - echo 'selected="selected"'; |
|
| 2682 | - } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
|
|
| 2681 | + echo 'selected="selected"'; |
|
| 2682 | + } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
|
|
| 2683 | 2683 | </select> |
| 2684 | 2684 | <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span>
|
| 2685 | 2685 | |
@@ -2687,13 +2687,13 @@ discard block |
||
| 2687 | 2687 | </li> |
| 2688 | 2688 | |
| 2689 | 2689 | <?php |
| 2690 | - $value = ''; |
|
| 2691 | - if (isset($field_info->decimal_point)) {
|
|
| 2692 | - $value = esc_attr($field_info->decimal_point); |
|
| 2693 | - }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
|
|
| 2694 | - $value = $cf['defaults']['decimal_point']; |
|
| 2695 | - } |
|
| 2696 | - ?> |
|
| 2690 | + $value = ''; |
|
| 2691 | + if (isset($field_info->decimal_point)) {
|
|
| 2692 | + $value = esc_attr($field_info->decimal_point); |
|
| 2693 | + }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
|
|
| 2694 | + $value = $cf['defaults']['decimal_point']; |
|
| 2695 | + } |
|
| 2696 | + ?> |
|
| 2697 | 2697 | |
| 2698 | 2698 | <li class="decimal-point-wrapper" |
| 2699 | 2699 | style="<?php echo ($dt_value == 'FLOAT') ? '' : 'display:none' ?>"> |
@@ -2702,7 +2702,7 @@ discard block |
||
| 2702 | 2702 | <select name="decimal_point" id="decimal_point"> |
| 2703 | 2703 | <option value=""><?php echo _e('Select', 'geodirectory'); ?></option>
|
| 2704 | 2704 | <?php for ($i = 1; $i <= 10; $i++) {
|
| 2705 | - $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
| 2705 | + $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
| 2706 | 2706 | <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option> |
| 2707 | 2707 | <?php } ?> |
| 2708 | 2708 | </select> |
@@ -2711,8 +2711,8 @@ discard block |
||
| 2711 | 2711 | </li> |
| 2712 | 2712 | <?php |
| 2713 | 2713 | |
| 2714 | - $output = ob_get_clean(); |
|
| 2715 | - return $output; |
|
| 2714 | + $output = ob_get_clean(); |
|
| 2715 | + return $output; |
|
| 2716 | 2716 | } |
| 2717 | 2717 | add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4);
|
| 2718 | 2718 | |
@@ -2748,9 +2748,9 @@ discard block |
||
| 2748 | 2748 | |
| 2749 | 2749 | |
| 2750 | 2750 | function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){
|
| 2751 | - if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
|
|
| 2752 | - ob_start(); |
|
| 2753 | - ?> |
|
| 2751 | + if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
|
|
| 2752 | + ob_start(); |
|
| 2753 | + ?> |
|
| 2754 | 2754 | <li> |
| 2755 | 2755 | <label for="advanced_editor" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show advanced editor :', 'geodirectory'); ?>
|
| 2756 | 2756 | <div class="gdcf-tooltip"> |
@@ -2761,13 +2761,13 @@ discard block |
||
| 2761 | 2761 | <div class="gd-cf-input-wrap"> |
| 2762 | 2762 | |
| 2763 | 2763 | <?php |
| 2764 | - $selected = ''; |
|
| 2765 | - if (isset($field_info->extra_fields)) |
|
| 2766 | - $advanced_editor = unserialize($field_info->extra_fields); |
|
| 2764 | + $selected = ''; |
|
| 2765 | + if (isset($field_info->extra_fields)) |
|
| 2766 | + $advanced_editor = unserialize($field_info->extra_fields); |
|
| 2767 | 2767 | |
| 2768 | - if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
|
|
| 2769 | - $selected = 'checked="checked"'; |
|
| 2770 | - ?> |
|
| 2768 | + if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
|
|
| 2769 | + $selected = 'checked="checked"'; |
|
| 2770 | + ?> |
|
| 2771 | 2771 | |
| 2772 | 2772 | <input type="checkbox" name="advanced_editor[]" id="advanced_editor" |
| 2773 | 2773 | value="1" <?php echo $selected; ?>/> |
@@ -2776,22 +2776,22 @@ discard block |
||
| 2776 | 2776 | </li> |
| 2777 | 2777 | <?php |
| 2778 | 2778 | |
| 2779 | - $output = ob_get_clean(); |
|
| 2780 | - return $output; |
|
| 2779 | + $output = ob_get_clean(); |
|
| 2780 | + return $output; |
|
| 2781 | 2781 | } |
| 2782 | 2782 | add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4);
|
| 2783 | 2783 | |
| 2784 | 2784 | |
| 2785 | 2785 | function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){
|
| 2786 | - ob_start(); |
|
| 2787 | - |
|
| 2788 | - $value = ''; |
|
| 2789 | - if (isset($field_info->validation_pattern)) {
|
|
| 2790 | - $value = esc_attr($field_info->validation_pattern); |
|
| 2791 | - }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
|
|
| 2792 | - $value = esc_attr($cf['defaults']['validation_pattern']); |
|
| 2793 | - } |
|
| 2794 | - ?> |
|
| 2786 | + ob_start(); |
|
| 2787 | + |
|
| 2788 | + $value = ''; |
|
| 2789 | + if (isset($field_info->validation_pattern)) {
|
|
| 2790 | + $value = esc_attr($field_info->validation_pattern); |
|
| 2791 | + }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
|
|
| 2792 | + $value = esc_attr($cf['defaults']['validation_pattern']); |
|
| 2793 | + } |
|
| 2794 | + ?> |
|
| 2795 | 2795 | <li> |
| 2796 | 2796 | <label for="validation_pattern" class="gd-cf-tooltip-wrap"> |
| 2797 | 2797 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?>
|
@@ -2805,13 +2805,13 @@ discard block |
||
| 2805 | 2805 | </div> |
| 2806 | 2806 | </li> |
| 2807 | 2807 | <?php |
| 2808 | - $value = ''; |
|
| 2809 | - if (isset($field_info->validation_msg)) {
|
|
| 2810 | - $value = esc_attr($field_info->validation_msg); |
|
| 2811 | - }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
|
|
| 2812 | - $value = esc_attr($cf['defaults']['validation_msg']); |
|
| 2813 | - } |
|
| 2814 | - ?> |
|
| 2808 | + $value = ''; |
|
| 2809 | + if (isset($field_info->validation_msg)) {
|
|
| 2810 | + $value = esc_attr($field_info->validation_msg); |
|
| 2811 | + }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
|
|
| 2812 | + $value = esc_attr($cf['defaults']['validation_msg']); |
|
| 2813 | + } |
|
| 2814 | + ?> |
|
| 2815 | 2815 | <li> |
| 2816 | 2816 | <label for="validation_msg" class="gd-cf-tooltip-wrap"> |
| 2817 | 2817 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?>
|
@@ -2826,21 +2826,21 @@ discard block |
||
| 2826 | 2826 | </li> |
| 2827 | 2827 | <?php |
| 2828 | 2828 | |
| 2829 | - $output = ob_get_clean(); |
|
| 2830 | - return $output; |
|
| 2829 | + $output = ob_get_clean(); |
|
| 2830 | + return $output; |
|
| 2831 | 2831 | } |
| 2832 | 2832 | add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4);
|
| 2833 | 2833 | |
| 2834 | 2834 | |
| 2835 | 2835 | function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){
|
| 2836 | - ob_start(); |
|
| 2837 | - global $post_type; |
|
| 2838 | - |
|
| 2839 | - if (!isset($field_info->post_type)) {
|
|
| 2840 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2841 | - } else |
|
| 2842 | - $post_type = $field_info->post_type; |
|
| 2843 | - ?> |
|
| 2836 | + ob_start(); |
|
| 2837 | + global $post_type; |
|
| 2838 | + |
|
| 2839 | + if (!isset($field_info->post_type)) {
|
|
| 2840 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 2841 | + } else |
|
| 2842 | + $post_type = $field_info->post_type; |
|
| 2843 | + ?> |
|
| 2844 | 2844 | <li style="display: none;"> |
| 2845 | 2845 | <label for="htmlvar_name" class="gd-cf-tooltip-wrap"> |
| 2846 | 2846 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?>
|
@@ -2851,15 +2851,15 @@ discard block |
||
| 2851 | 2851 | <div class="gd-cf-input-wrap"> |
| 2852 | 2852 | <select name="htmlvar_name" id="htmlvar_name"> |
| 2853 | 2853 | <?php |
| 2854 | - $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2854 | + $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2855 | 2855 | |
| 2856 | - foreach ($gd_taxonomy as $gd_tax) {
|
|
| 2857 | - ?> |
|
| 2856 | + foreach ($gd_taxonomy as $gd_tax) {
|
|
| 2857 | + ?> |
|
| 2858 | 2858 | <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
|
| 2859 | - echo 'selected="selected"'; |
|
| 2860 | - }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
| 2861 | - } |
|
| 2862 | - ?> |
|
| 2859 | + echo 'selected="selected"'; |
|
| 2860 | + }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
| 2861 | + } |
|
| 2862 | + ?> |
|
| 2863 | 2863 | </select> |
| 2864 | 2864 | </div> |
| 2865 | 2865 | </li> |
@@ -2875,49 +2875,49 @@ discard block |
||
| 2875 | 2875 | |
| 2876 | 2876 | <select name="cat_display_type" id="cat_display_type"> |
| 2877 | 2877 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') {
|
| 2878 | - echo 'selected="selected"'; |
|
| 2879 | - }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
|
|
| 2878 | + echo 'selected="selected"'; |
|
| 2879 | + }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
|
|
| 2880 | 2880 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
|
| 2881 | - echo 'selected="selected"'; |
|
| 2882 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option>
|
|
| 2881 | + echo 'selected="selected"'; |
|
| 2882 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option>
|
|
| 2883 | 2883 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') {
|
| 2884 | - echo 'selected="selected"'; |
|
| 2885 | - }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
|
|
| 2884 | + echo 'selected="selected"'; |
|
| 2885 | + }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
|
|
| 2886 | 2886 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
|
| 2887 | - echo 'selected="selected"'; |
|
| 2888 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
|
|
| 2887 | + echo 'selected="selected"'; |
|
| 2888 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
|
|
| 2889 | 2889 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
|
| 2890 | - echo 'selected="selected"'; |
|
| 2891 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
|
|
| 2890 | + echo 'selected="selected"'; |
|
| 2891 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
|
|
| 2892 | 2892 | </select> |
| 2893 | 2893 | </div> |
| 2894 | 2894 | </li> |
| 2895 | 2895 | <?php |
| 2896 | 2896 | |
| 2897 | - $output = ob_get_clean(); |
|
| 2898 | - return $output; |
|
| 2897 | + $output = ob_get_clean(); |
|
| 2898 | + return $output; |
|
| 2899 | 2899 | } |
| 2900 | 2900 | add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4);
|
| 2901 | 2901 | |
| 2902 | 2902 | |
| 2903 | 2903 | function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){
|
| 2904 | 2904 | |
| 2905 | - ob_start(); |
|
| 2906 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
|
|
| 2907 | - $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
| 2908 | - } |
|
| 2905 | + ob_start(); |
|
| 2906 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
|
|
| 2907 | + $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
| 2908 | + } |
|
| 2909 | 2909 | |
| 2910 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
| 2911 | - ?> |
|
| 2910 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
| 2911 | + ?> |
|
| 2912 | 2912 | <?php |
| 2913 | - /** |
|
| 2914 | - * Called on the add custom fields settings page before the address field is output. |
|
| 2915 | - * |
|
| 2916 | - * @since 1.0.0 |
|
| 2917 | - * @param array $address The address settings array. |
|
| 2918 | - * @param object $field_info Extra fields info. |
|
| 2919 | - */ |
|
| 2920 | - do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
|
|
| 2913 | + /** |
|
| 2914 | + * Called on the add custom fields settings page before the address field is output. |
|
| 2915 | + * |
|
| 2916 | + * @since 1.0.0 |
|
| 2917 | + * @param array $address The address settings array. |
|
| 2918 | + * @param object $field_info Extra fields info. |
|
| 2919 | + */ |
|
| 2920 | + do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
|
|
| 2921 | 2921 | |
| 2922 | 2922 | <li> |
| 2923 | 2923 | <label for="show_zip" class="gd-cf-tooltip-wrap"> |
@@ -2930,14 +2930,14 @@ discard block |
||
| 2930 | 2930 | |
| 2931 | 2931 | <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled" value="1" |
| 2932 | 2932 | <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') {
|
| 2933 | - echo 'checked'; |
|
| 2934 | - } ?>/> |
|
| 2933 | + echo 'checked'; |
|
| 2934 | + } ?>/> |
|
| 2935 | 2935 | <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 2936 | 2936 | |
| 2937 | 2937 | <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0" |
| 2938 | 2938 | <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {
|
| 2939 | - echo 'checked'; |
|
| 2940 | - } ?>/> |
|
| 2939 | + echo 'checked'; |
|
| 2940 | + } ?>/> |
|
| 2941 | 2941 | <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 2942 | 2942 | |
| 2943 | 2943 | |
@@ -2954,8 +2954,8 @@ discard block |
||
| 2954 | 2954 | <div class="gd-cf-input-wrap"> |
| 2955 | 2955 | <input type="text" name="extra[zip_lable]" id="zip_lable" |
| 2956 | 2956 | value="<?php if (isset($address['zip_lable'])) {
|
| 2957 | - echo esc_attr($address['zip_lable']); |
|
| 2958 | - }?>"/> |
|
| 2957 | + echo esc_attr($address['zip_lable']); |
|
| 2958 | + }?>"/> |
|
| 2959 | 2959 | </div> |
| 2960 | 2960 | </li> |
| 2961 | 2961 | |
@@ -2972,8 +2972,8 @@ discard block |
||
| 2972 | 2972 | <div class="gd-cf-input-wrap"> |
| 2973 | 2973 | <input type="text" name="extra[map_lable]" id="map_lable" |
| 2974 | 2974 | value="<?php if (isset($address['map_lable'])) {
|
| 2975 | - echo esc_attr($address['map_lable']); |
|
| 2976 | - }?>"/> |
|
| 2975 | + echo esc_attr($address['map_lable']); |
|
| 2976 | + }?>"/> |
|
| 2977 | 2977 | </div> |
| 2978 | 2978 | </li> |
| 2979 | 2979 | |
@@ -2988,14 +2988,14 @@ discard block |
||
| 2988 | 2988 | |
| 2989 | 2989 | <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled" value="1" |
| 2990 | 2990 | <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') {
|
| 2991 | - echo 'checked'; |
|
| 2992 | - } ?>/> |
|
| 2991 | + echo 'checked'; |
|
| 2992 | + } ?>/> |
|
| 2993 | 2993 | <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 2994 | 2994 | |
| 2995 | 2995 | <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0" |
| 2996 | 2996 | <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) {
|
| 2997 | - echo 'checked'; |
|
| 2998 | - } ?>/> |
|
| 2997 | + echo 'checked'; |
|
| 2998 | + } ?>/> |
|
| 2999 | 2999 | <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 3000 | 3000 | |
| 3001 | 3001 | </div> |
@@ -3012,14 +3012,14 @@ discard block |
||
| 3012 | 3012 | |
| 3013 | 3013 | <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled" value="1" |
| 3014 | 3014 | <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') {
|
| 3015 | - echo 'checked'; |
|
| 3016 | - } ?>/> |
|
| 3015 | + echo 'checked'; |
|
| 3016 | + } ?>/> |
|
| 3017 | 3017 | <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 3018 | 3018 | |
| 3019 | 3019 | <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0" |
| 3020 | 3020 | <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) {
|
| 3021 | - echo 'checked'; |
|
| 3022 | - } ?>/> |
|
| 3021 | + echo 'checked'; |
|
| 3022 | + } ?>/> |
|
| 3023 | 3023 | <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 3024 | 3024 | |
| 3025 | 3025 | </div> |
@@ -3036,8 +3036,8 @@ discard block |
||
| 3036 | 3036 | <div class="gd-cf-input-wrap"> |
| 3037 | 3037 | <input type="text" name="extra[mapview_lable]" id="mapview_lable" |
| 3038 | 3038 | value="<?php if (isset($address['mapview_lable'])) {
|
| 3039 | - echo esc_attr($address['mapview_lable']); |
|
| 3040 | - }?>"/> |
|
| 3039 | + echo esc_attr($address['mapview_lable']); |
|
| 3040 | + }?>"/> |
|
| 3041 | 3041 | </div> |
| 3042 | 3042 | </li> |
| 3043 | 3043 | <li> |
@@ -3051,29 +3051,29 @@ discard block |
||
| 3051 | 3051 | |
| 3052 | 3052 | <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled" value="1" |
| 3053 | 3053 | <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') {
|
| 3054 | - echo 'checked'; |
|
| 3055 | - } ?>/> |
|
| 3054 | + echo 'checked'; |
|
| 3055 | + } ?>/> |
|
| 3056 | 3056 | <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 3057 | 3057 | |
| 3058 | 3058 | <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0" |
| 3059 | 3059 | <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) {
|
| 3060 | - echo 'checked'; |
|
| 3061 | - } ?>/> |
|
| 3060 | + echo 'checked'; |
|
| 3061 | + } ?>/> |
|
| 3062 | 3062 | <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 3063 | 3063 | |
| 3064 | 3064 | </div> |
| 3065 | 3065 | </li> |
| 3066 | 3066 | <?php |
| 3067 | 3067 | |
| 3068 | - $html = ob_get_clean(); |
|
| 3069 | - return $output.$html; |
|
| 3068 | + $html = ob_get_clean(); |
|
| 3069 | + return $output.$html; |
|
| 3070 | 3070 | } |
| 3071 | 3071 | add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4);
|
| 3072 | 3072 | |
| 3073 | 3073 | |
| 3074 | 3074 | function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){
|
| 3075 | - ob_start(); |
|
| 3076 | - ?> |
|
| 3075 | + ob_start(); |
|
| 3076 | + ?> |
|
| 3077 | 3077 | <li> |
| 3078 | 3078 | <label for="multi_display_type" class="gd-cf-tooltip-wrap"> |
| 3079 | 3079 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?>
|
@@ -3085,14 +3085,14 @@ discard block |
||
| 3085 | 3085 | |
| 3086 | 3086 | <select name="multi_display_type" id="multi_display_type"> |
| 3087 | 3087 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
|
| 3088 | - echo 'selected="selected"'; |
|
| 3089 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option>
|
|
| 3088 | + echo 'selected="selected"'; |
|
| 3089 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option>
|
|
| 3090 | 3090 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
|
| 3091 | - echo 'selected="selected"'; |
|
| 3092 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
|
|
| 3091 | + echo 'selected="selected"'; |
|
| 3092 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
|
|
| 3093 | 3093 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
|
| 3094 | - echo 'selected="selected"'; |
|
| 3095 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
|
|
| 3094 | + echo 'selected="selected"'; |
|
| 3095 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
|
|
| 3096 | 3096 | </select> |
| 3097 | 3097 | |
| 3098 | 3098 | <br/> |
@@ -3100,25 +3100,25 @@ discard block |
||
| 3100 | 3100 | </li> |
| 3101 | 3101 | <?php |
| 3102 | 3102 | |
| 3103 | - $html = ob_get_clean(); |
|
| 3104 | - return $output.$html; |
|
| 3103 | + $html = ob_get_clean(); |
|
| 3104 | + return $output.$html; |
|
| 3105 | 3105 | } |
| 3106 | 3106 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4);
|
| 3107 | 3107 | |
| 3108 | 3108 | |
| 3109 | 3109 | function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){
|
| 3110 | 3110 | |
| 3111 | - ob_start(); |
|
| 3111 | + ob_start(); |
|
| 3112 | 3112 | |
| 3113 | - $value = ''; |
|
| 3114 | - if (isset($field_info->option_values)) {
|
|
| 3115 | - $value = esc_attr($field_info->option_values); |
|
| 3116 | - }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
|
|
| 3117 | - $value = esc_attr($cf['defaults']['option_values']); |
|
| 3118 | - } |
|
| 3113 | + $value = ''; |
|
| 3114 | + if (isset($field_info->option_values)) {
|
|
| 3115 | + $value = esc_attr($field_info->option_values); |
|
| 3116 | + }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
|
|
| 3117 | + $value = esc_attr($cf['defaults']['option_values']); |
|
| 3118 | + } |
|
| 3119 | 3119 | |
| 3120 | - $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
| 3121 | - ?> |
|
| 3120 | + $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
| 3121 | + ?> |
|
| 3122 | 3122 | <li> |
| 3123 | 3123 | <label for="option_values" class="gd-cf-tooltip-wrap"> |
| 3124 | 3124 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?>
|
@@ -3145,8 +3145,8 @@ discard block |
||
| 3145 | 3145 | </li> |
| 3146 | 3146 | <?php |
| 3147 | 3147 | |
| 3148 | - $html = ob_get_clean(); |
|
| 3149 | - return $output.$html; |
|
| 3148 | + $html = ob_get_clean(); |
|
| 3149 | + return $output.$html; |
|
| 3150 | 3150 | } |
| 3151 | 3151 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4);
|
| 3152 | 3152 | add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4);
|
@@ -3154,12 +3154,12 @@ discard block |
||
| 3154 | 3154 | |
| 3155 | 3155 | |
| 3156 | 3156 | function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){
|
| 3157 | - ob_start(); |
|
| 3158 | - $extra = array(); |
|
| 3159 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
|
|
| 3160 | - $extra = unserialize($field_info->extra_fields); |
|
| 3161 | - } |
|
| 3162 | - ?> |
|
| 3157 | + ob_start(); |
|
| 3158 | + $extra = array(); |
|
| 3159 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
|
|
| 3160 | + $extra = unserialize($field_info->extra_fields); |
|
| 3161 | + } |
|
| 3162 | + ?> |
|
| 3163 | 3163 | <li> |
| 3164 | 3164 | <label for="date_format" class="gd-cf-tooltip-wrap"> |
| 3165 | 3165 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?>
|
@@ -3169,52 +3169,52 @@ discard block |
||
| 3169 | 3169 | </label> |
| 3170 | 3170 | <div class="gd-cf-input-wrap" style="overflow:inherit;"> |
| 3171 | 3171 | <?php |
| 3172 | - $date_formats = array( |
|
| 3173 | - 'm/d/Y', |
|
| 3174 | - 'd/m/Y', |
|
| 3175 | - 'Y/m/d', |
|
| 3176 | - 'm-d-Y', |
|
| 3177 | - 'd-m-Y', |
|
| 3178 | - 'Y-m-d', |
|
| 3179 | - 'F j, Y', |
|
| 3180 | - ); |
|
| 3181 | - /** |
|
| 3182 | - * Filter the custom field date format options. |
|
| 3183 | - * |
|
| 3184 | - * @since 1.6.5 |
|
| 3185 | - * @param array $date_formats The PHP date format array. |
|
| 3186 | - */ |
|
| 3187 | - $date_formats = apply_filters('geodir_date_formats',$date_formats);
|
|
| 3188 | - ?> |
|
| 3172 | + $date_formats = array( |
|
| 3173 | + 'm/d/Y', |
|
| 3174 | + 'd/m/Y', |
|
| 3175 | + 'Y/m/d', |
|
| 3176 | + 'm-d-Y', |
|
| 3177 | + 'd-m-Y', |
|
| 3178 | + 'Y-m-d', |
|
| 3179 | + 'F j, Y', |
|
| 3180 | + ); |
|
| 3181 | + /** |
|
| 3182 | + * Filter the custom field date format options. |
|
| 3183 | + * |
|
| 3184 | + * @since 1.6.5 |
|
| 3185 | + * @param array $date_formats The PHP date format array. |
|
| 3186 | + */ |
|
| 3187 | + $date_formats = apply_filters('geodir_date_formats',$date_formats);
|
|
| 3188 | + ?> |
|
| 3189 | 3189 | <select name="extra[date_format]" id="date_format"> |
| 3190 | 3190 | <?php |
| 3191 | - foreach($date_formats as $format){
|
|
| 3192 | - $selected = ''; |
|
| 3193 | - if(!empty($extra) && esc_attr($extra['date_format'])==$format){
|
|
| 3194 | - $selected = "selected='selected'"; |
|
| 3195 | - } |
|
| 3196 | - echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>";
|
|
| 3197 | - } |
|
| 3198 | - ?> |
|
| 3191 | + foreach($date_formats as $format){
|
|
| 3192 | + $selected = ''; |
|
| 3193 | + if(!empty($extra) && esc_attr($extra['date_format'])==$format){
|
|
| 3194 | + $selected = "selected='selected'"; |
|
| 3195 | + } |
|
| 3196 | + echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>";
|
|
| 3197 | + } |
|
| 3198 | + ?> |
|
| 3199 | 3199 | </select> |
| 3200 | 3200 | |
| 3201 | 3201 | </div> |
| 3202 | 3202 | </li> |
| 3203 | 3203 | <?php |
| 3204 | 3204 | |
| 3205 | - $html = ob_get_clean(); |
|
| 3206 | - return $output.$html; |
|
| 3205 | + $html = ob_get_clean(); |
|
| 3206 | + return $output.$html; |
|
| 3207 | 3207 | } |
| 3208 | 3208 | add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4);
|
| 3209 | 3209 | |
| 3210 | 3210 | |
| 3211 | 3211 | function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){
|
| 3212 | - ob_start(); |
|
| 3213 | - $allowed_file_types = geodir_allowed_mime_types(); |
|
| 3212 | + ob_start(); |
|
| 3213 | + $allowed_file_types = geodir_allowed_mime_types(); |
|
| 3214 | 3214 | |
| 3215 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
| 3216 | - $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
|
|
| 3217 | - ?> |
|
| 3215 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
| 3216 | + $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
|
|
| 3217 | + ?> |
|
| 3218 | 3218 | <li> |
| 3219 | 3219 | <label for="gd_file_types" class="gd-cf-tooltip-wrap"> |
| 3220 | 3220 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?>
|
@@ -3237,33 +3237,33 @@ discard block |
||
| 3237 | 3237 | </li> |
| 3238 | 3238 | <?php |
| 3239 | 3239 | |
| 3240 | - $html = ob_get_clean(); |
|
| 3241 | - return $output.$html; |
|
| 3240 | + $html = ob_get_clean(); |
|
| 3241 | + return $output.$html; |
|
| 3242 | 3242 | } |
| 3243 | 3243 | add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4);
|
| 3244 | 3244 | |
| 3245 | 3245 | function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){
|
| 3246 | - ob_start(); |
|
| 3246 | + ob_start(); |
|
| 3247 | 3247 | |
| 3248 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
| 3248 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
| 3249 | 3249 | // print_r($cf);echo '###'; |
| 3250 | 3250 | |
| 3251 | 3251 | |
| 3252 | 3252 | |
| 3253 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
| 3253 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
| 3254 | 3254 | |
| 3255 | 3255 | |
| 3256 | - $value = ''; |
|
| 3257 | - if ($extra_fields && isset($extra_fields['is_price'])) {
|
|
| 3258 | - $value = esc_attr($extra_fields['is_price']); |
|
| 3259 | - }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
|
|
| 3260 | - $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
| 3261 | - } |
|
| 3256 | + $value = ''; |
|
| 3257 | + if ($extra_fields && isset($extra_fields['is_price'])) {
|
|
| 3258 | + $value = esc_attr($extra_fields['is_price']); |
|
| 3259 | + }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
|
|
| 3260 | + $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
| 3261 | + } |
|
| 3262 | 3262 | |
| 3263 | - $show_price_extra = ($value==1) ? 1 : 0; |
|
| 3263 | + $show_price_extra = ($value==1) ? 1 : 0; |
|
| 3264 | 3264 | |
| 3265 | - $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
| 3266 | - ?> |
|
| 3265 | + $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
| 3266 | + ?> |
|
| 3267 | 3267 | <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>>
|
| 3268 | 3268 | <label for="is_price" class="gd-cf-tooltip-wrap"> |
| 3269 | 3269 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?>
|
@@ -3275,14 +3275,14 @@ discard block |
||
| 3275 | 3275 | |
| 3276 | 3276 | <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled" value="1" |
| 3277 | 3277 | <?php if ($value == '1') {
|
| 3278 | - echo 'checked'; |
|
| 3279 | - } ?>/> |
|
| 3278 | + echo 'checked'; |
|
| 3279 | + } ?>/> |
|
| 3280 | 3280 | <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
|
| 3281 | 3281 | |
| 3282 | 3282 | <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0" |
| 3283 | 3283 | <?php if ($value == '0' || !$value) {
|
| 3284 | - echo 'checked'; |
|
| 3285 | - } ?>/> |
|
| 3284 | + echo 'checked'; |
|
| 3285 | + } ?>/> |
|
| 3286 | 3286 | <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
|
| 3287 | 3287 | |
| 3288 | 3288 | </div> |
@@ -3290,13 +3290,13 @@ discard block |
||
| 3290 | 3290 | |
| 3291 | 3291 | <?php |
| 3292 | 3292 | |
| 3293 | - $value = ''; |
|
| 3294 | - if ($extra_fields && isset($extra_fields['thousand_separator'])) {
|
|
| 3295 | - $value = esc_attr($extra_fields['thousand_separator']); |
|
| 3296 | - }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
|
|
| 3297 | - $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
| 3298 | - } |
|
| 3299 | - ?> |
|
| 3293 | + $value = ''; |
|
| 3294 | + if ($extra_fields && isset($extra_fields['thousand_separator'])) {
|
|
| 3295 | + $value = esc_attr($extra_fields['thousand_separator']); |
|
| 3296 | + }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
|
|
| 3297 | + $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
| 3298 | + } |
|
| 3299 | + ?> |
|
| 3300 | 3300 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
|
| 3301 | 3301 | <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?>
|
| 3302 | 3302 | <div class="gdcf-tooltip"> |
@@ -3317,13 +3317,13 @@ discard block |
||
| 3317 | 3317 | |
| 3318 | 3318 | <?php |
| 3319 | 3319 | |
| 3320 | - $value = ''; |
|
| 3321 | - if ($extra_fields && isset($extra_fields['decimal_separator'])) {
|
|
| 3322 | - $value = esc_attr($extra_fields['decimal_separator']); |
|
| 3323 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
|
|
| 3324 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
| 3325 | - } |
|
| 3326 | - ?> |
|
| 3320 | + $value = ''; |
|
| 3321 | + if ($extra_fields && isset($extra_fields['decimal_separator'])) {
|
|
| 3322 | + $value = esc_attr($extra_fields['decimal_separator']); |
|
| 3323 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
|
|
| 3324 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
| 3325 | + } |
|
| 3326 | + ?> |
|
| 3327 | 3327 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
|
| 3328 | 3328 | <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?>
|
| 3329 | 3329 | <div class="gdcf-tooltip"> |
@@ -3340,13 +3340,13 @@ discard block |
||
| 3340 | 3340 | |
| 3341 | 3341 | <?php |
| 3342 | 3342 | |
| 3343 | - $value = ''; |
|
| 3344 | - if ($extra_fields && isset($extra_fields['decimal_display'])) {
|
|
| 3345 | - $value = esc_attr($extra_fields['decimal_display']); |
|
| 3346 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
|
|
| 3347 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
| 3348 | - } |
|
| 3349 | - ?> |
|
| 3343 | + $value = ''; |
|
| 3344 | + if ($extra_fields && isset($extra_fields['decimal_display'])) {
|
|
| 3345 | + $value = esc_attr($extra_fields['decimal_display']); |
|
| 3346 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
|
|
| 3347 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
| 3348 | + } |
|
| 3349 | + ?> |
|
| 3350 | 3350 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
|
| 3351 | 3351 | <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?>
|
| 3352 | 3352 | <div class="gdcf-tooltip"> |
@@ -3363,13 +3363,13 @@ discard block |
||
| 3363 | 3363 | |
| 3364 | 3364 | <?php |
| 3365 | 3365 | |
| 3366 | - $value = ''; |
|
| 3367 | - if ($extra_fields && isset($extra_fields['currency_symbol'])) {
|
|
| 3368 | - $value = esc_attr($extra_fields['currency_symbol']); |
|
| 3369 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
|
|
| 3370 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
| 3371 | - } |
|
| 3372 | - ?> |
|
| 3366 | + $value = ''; |
|
| 3367 | + if ($extra_fields && isset($extra_fields['currency_symbol'])) {
|
|
| 3368 | + $value = esc_attr($extra_fields['currency_symbol']); |
|
| 3369 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
|
|
| 3370 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
| 3371 | + } |
|
| 3372 | + ?> |
|
| 3373 | 3373 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
|
| 3374 | 3374 | <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?>
|
| 3375 | 3375 | <div class="gdcf-tooltip"> |
@@ -3384,13 +3384,13 @@ discard block |
||
| 3384 | 3384 | |
| 3385 | 3385 | <?php |
| 3386 | 3386 | |
| 3387 | - $value = ''; |
|
| 3388 | - if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
|
|
| 3389 | - $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
| 3390 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
|
|
| 3391 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
| 3392 | - } |
|
| 3393 | - ?> |
|
| 3387 | + $value = ''; |
|
| 3388 | + if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
|
|
| 3389 | + $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
| 3390 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
|
|
| 3391 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
| 3392 | + } |
|
| 3393 | + ?> |
|
| 3394 | 3394 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
|
| 3395 | 3395 | <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory');?>
|
| 3396 | 3396 | <div class="gdcf-tooltip"> |
@@ -3408,225 +3408,225 @@ discard block |
||
| 3408 | 3408 | |
| 3409 | 3409 | <?php |
| 3410 | 3410 | |
| 3411 | - $html = ob_get_clean(); |
|
| 3412 | - return $output.$html; |
|
| 3411 | + $html = ob_get_clean(); |
|
| 3412 | + return $output.$html; |
|
| 3413 | 3413 | } |
| 3414 | 3414 | add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4);
|
| 3415 | 3415 | |
| 3416 | 3416 | function geodir_default_custom_fields($post_type='gd_place',$package_id=''){
|
| 3417 | - $fields = array(); |
|
| 3418 | - $package = ($package_id=='') ? '' : array($package_id); |
|
| 3419 | - |
|
| 3420 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3421 | - 'data_type' => 'VARCHAR', |
|
| 3422 | - 'field_type' => 'taxonomy', |
|
| 3423 | - 'admin_title' => __('Category', 'geodirectory'),
|
|
| 3424 | - 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
|
|
| 3425 | - 'site_title' => __('Category', 'geodirectory'),
|
|
| 3426 | - 'htmlvar_name' => $post_type.'category', |
|
| 3427 | - 'default_value' => '', |
|
| 3428 | - 'is_default' => '1', |
|
| 3429 | - 'is_admin' => '1', |
|
| 3430 | - 'is_required' => '1', |
|
| 3431 | - 'show_in' => '[detail]', |
|
| 3432 | - 'show_on_pkg' => $package, |
|
| 3433 | - 'clabels' => __('Category', 'geodirectory'));
|
|
| 3434 | - |
|
| 3435 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3436 | - 'data_type' => 'VARCHAR', |
|
| 3437 | - 'field_type' => 'address', |
|
| 3438 | - 'admin_title' => __('Address', 'geodirectory'),
|
|
| 3439 | - 'admin_desc' => ADDRESS_MSG, |
|
| 3440 | - 'site_title' => __('Address', 'geodirectory'),
|
|
| 3441 | - 'htmlvar_name' => 'post', |
|
| 3442 | - 'default_value' => '', |
|
| 3443 | - 'option_values' => '', |
|
| 3444 | - 'is_default' => '1', |
|
| 3445 | - 'is_admin' => '1', |
|
| 3446 | - 'is_required' => '1', |
|
| 3447 | - 'show_in' => '[detail],[mapbubble]', |
|
| 3448 | - 'show_on_pkg' => $package, |
|
| 3449 | - 'required_msg' => __('Address fields are required', 'geodirectory'),
|
|
| 3450 | - 'clabels' => __('Address', 'geodirectory'),
|
|
| 3451 | - 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
|
|
| 3452 | - 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
|
|
| 3453 | - 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
|
|
| 3454 | - 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
|
|
| 3455 | - 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
|
|
| 3456 | - 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
|
|
| 3457 | - 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
| 3458 | - 'show_latlng' => 1)); |
|
| 3459 | - |
|
| 3460 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3461 | - 'data_type' => 'VARCHAR', |
|
| 3462 | - 'field_type' => 'text', |
|
| 3463 | - 'admin_title' => __('Time', 'geodirectory'),
|
|
| 3464 | - 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
|
|
| 3465 | - 'site_title' => __('Time', 'geodirectory'),
|
|
| 3466 | - 'htmlvar_name' => 'timing', |
|
| 3467 | - 'default_value' => '', |
|
| 3468 | - 'option_values' => '', |
|
| 3469 | - 'is_default' => '1', |
|
| 3470 | - 'is_admin' => '1', |
|
| 3471 | - 'show_in' => '[detail],[mapbubble]', |
|
| 3472 | - 'show_on_pkg' => $package, |
|
| 3473 | - 'clabels' => __('Time', 'geodirectory'));
|
|
| 3474 | - |
|
| 3475 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3476 | - 'data_type' => 'VARCHAR', |
|
| 3477 | - 'field_type' => 'phone', |
|
| 3478 | - 'admin_title' => __('Phone', 'geodirectory'),
|
|
| 3479 | - 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
|
|
| 3480 | - 'site_title' => __('Phone', 'geodirectory'),
|
|
| 3481 | - 'htmlvar_name' => 'contact', |
|
| 3482 | - 'default_value' => '', |
|
| 3483 | - 'option_values' => '', |
|
| 3484 | - 'is_default' => '1', |
|
| 3485 | - 'is_admin' => '1', |
|
| 3486 | - 'show_in' => '[detail],[mapbubble]', |
|
| 3487 | - 'show_on_pkg' => $package, |
|
| 3488 | - 'clabels' => __('Phone', 'geodirectory'));
|
|
| 3489 | - |
|
| 3490 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3491 | - 'data_type' => 'VARCHAR', |
|
| 3492 | - 'field_type' => 'email', |
|
| 3493 | - 'admin_title' => __('Email', 'geodirectory'),
|
|
| 3494 | - 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
|
|
| 3495 | - 'site_title' => __('Email', 'geodirectory'),
|
|
| 3496 | - 'htmlvar_name' => 'email', |
|
| 3497 | - 'default_value' => '', |
|
| 3498 | - 'option_values' => '', |
|
| 3499 | - 'is_default' => '1', |
|
| 3500 | - 'is_admin' => '1', |
|
| 3501 | - 'show_in' => '[detail]', |
|
| 3502 | - 'show_on_pkg' => $package, |
|
| 3503 | - 'clabels' => __('Email', 'geodirectory'));
|
|
| 3504 | - |
|
| 3505 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3506 | - 'data_type' => 'VARCHAR', |
|
| 3507 | - 'field_type' => 'url', |
|
| 3508 | - 'admin_title' => __('Website', 'geodirectory'),
|
|
| 3509 | - 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
|
|
| 3510 | - 'site_title' => __('Website', 'geodirectory'),
|
|
| 3511 | - 'htmlvar_name' => 'website', |
|
| 3512 | - 'default_value' => '', |
|
| 3513 | - 'option_values' => '', |
|
| 3514 | - 'is_default' => '1', |
|
| 3515 | - 'is_admin' => '1', |
|
| 3516 | - 'show_in' => '[detail]', |
|
| 3517 | - 'show_on_pkg' => $package, |
|
| 3518 | - 'clabels' => __('Website', 'geodirectory'));
|
|
| 3519 | - |
|
| 3520 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3521 | - 'data_type' => 'VARCHAR', |
|
| 3522 | - 'field_type' => 'url', |
|
| 3523 | - 'admin_title' => __('Twitter', 'geodirectory'),
|
|
| 3524 | - 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
|
|
| 3525 | - 'site_title' => __('Twitter', 'geodirectory'),
|
|
| 3526 | - 'htmlvar_name' => 'twitter', |
|
| 3527 | - 'default_value' => '', |
|
| 3528 | - 'option_values' => '', |
|
| 3529 | - 'is_default' => '1', |
|
| 3530 | - 'is_admin' => '1', |
|
| 3531 | - 'show_in' => '[detail]', |
|
| 3532 | - 'show_on_pkg' => $package, |
|
| 3533 | - 'clabels' => __('Twitter', 'geodirectory'));
|
|
| 3534 | - |
|
| 3535 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3536 | - 'data_type' => 'VARCHAR', |
|
| 3537 | - 'field_type' => 'url', |
|
| 3538 | - 'admin_title' => __('Facebook', 'geodirectory'),
|
|
| 3539 | - 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
|
|
| 3540 | - 'site_title' => __('Facebook', 'geodirectory'),
|
|
| 3541 | - 'htmlvar_name' => 'facebook', |
|
| 3542 | - 'default_value' => '', |
|
| 3543 | - 'option_values' => '', |
|
| 3544 | - 'is_default' => '1', |
|
| 3545 | - 'is_admin' => '1', |
|
| 3546 | - 'show_in' => '[detail]', |
|
| 3547 | - 'show_on_pkg' => $package, |
|
| 3548 | - 'clabels' => __('Facebook', 'geodirectory'));
|
|
| 3549 | - |
|
| 3550 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3551 | - 'data_type' => 'TEXT', |
|
| 3552 | - 'field_type' => 'textarea', |
|
| 3553 | - 'admin_title' => __('Video', 'geodirectory'),
|
|
| 3554 | - 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
|
|
| 3555 | - 'site_title' => __('Video', 'geodirectory'),
|
|
| 3556 | - 'htmlvar_name' => 'video', |
|
| 3557 | - 'default_value' => '', |
|
| 3558 | - 'option_values' => '', |
|
| 3559 | - 'is_default' => '0', |
|
| 3560 | - 'is_admin' => '1', |
|
| 3561 | - 'show_in' => '[owntab]', |
|
| 3562 | - 'show_on_pkg' => $package, |
|
| 3563 | - 'clabels' => __('Video', 'geodirectory'));
|
|
| 3564 | - |
|
| 3565 | - $fields[] = array('listing_type' => $post_type,
|
|
| 3566 | - 'data_type' => 'TEXT', |
|
| 3567 | - 'field_type' => 'textarea', |
|
| 3568 | - 'admin_title' => __('Special Offers', 'geodirectory'),
|
|
| 3569 | - 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
|
|
| 3570 | - 'site_title' => __('Special Offers', 'geodirectory'),
|
|
| 3571 | - 'htmlvar_name' => 'special_offers', |
|
| 3572 | - 'default_value' => '', |
|
| 3573 | - 'option_values' => '', |
|
| 3574 | - 'is_default' => '0', |
|
| 3575 | - 'is_admin' => '1', |
|
| 3576 | - 'show_in' => '[owntab]', |
|
| 3577 | - 'show_on_pkg' => $package, |
|
| 3578 | - 'clabels' => __('Special Offers', 'geodirectory'));
|
|
| 3579 | - |
|
| 3580 | - /** |
|
| 3581 | - * Filter the array of default custom fields DB table data. |
|
| 3582 | - * |
|
| 3583 | - * @since 1.6.6 |
|
| 3584 | - * @param string $fields The default custom fields as an array. |
|
| 3585 | - */ |
|
| 3586 | - $fields = apply_filters('geodir_default_custom_fields', $fields);
|
|
| 3587 | - |
|
| 3588 | - return $fields; |
|
| 3417 | + $fields = array(); |
|
| 3418 | + $package = ($package_id=='') ? '' : array($package_id); |
|
| 3419 | + |
|
| 3420 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3421 | + 'data_type' => 'VARCHAR', |
|
| 3422 | + 'field_type' => 'taxonomy', |
|
| 3423 | + 'admin_title' => __('Category', 'geodirectory'),
|
|
| 3424 | + 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
|
|
| 3425 | + 'site_title' => __('Category', 'geodirectory'),
|
|
| 3426 | + 'htmlvar_name' => $post_type.'category', |
|
| 3427 | + 'default_value' => '', |
|
| 3428 | + 'is_default' => '1', |
|
| 3429 | + 'is_admin' => '1', |
|
| 3430 | + 'is_required' => '1', |
|
| 3431 | + 'show_in' => '[detail]', |
|
| 3432 | + 'show_on_pkg' => $package, |
|
| 3433 | + 'clabels' => __('Category', 'geodirectory'));
|
|
| 3434 | + |
|
| 3435 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3436 | + 'data_type' => 'VARCHAR', |
|
| 3437 | + 'field_type' => 'address', |
|
| 3438 | + 'admin_title' => __('Address', 'geodirectory'),
|
|
| 3439 | + 'admin_desc' => ADDRESS_MSG, |
|
| 3440 | + 'site_title' => __('Address', 'geodirectory'),
|
|
| 3441 | + 'htmlvar_name' => 'post', |
|
| 3442 | + 'default_value' => '', |
|
| 3443 | + 'option_values' => '', |
|
| 3444 | + 'is_default' => '1', |
|
| 3445 | + 'is_admin' => '1', |
|
| 3446 | + 'is_required' => '1', |
|
| 3447 | + 'show_in' => '[detail],[mapbubble]', |
|
| 3448 | + 'show_on_pkg' => $package, |
|
| 3449 | + 'required_msg' => __('Address fields are required', 'geodirectory'),
|
|
| 3450 | + 'clabels' => __('Address', 'geodirectory'),
|
|
| 3451 | + 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
|
|
| 3452 | + 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
|
|
| 3453 | + 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
|
|
| 3454 | + 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
|
|
| 3455 | + 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
|
|
| 3456 | + 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
|
|
| 3457 | + 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
| 3458 | + 'show_latlng' => 1)); |
|
| 3459 | + |
|
| 3460 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3461 | + 'data_type' => 'VARCHAR', |
|
| 3462 | + 'field_type' => 'text', |
|
| 3463 | + 'admin_title' => __('Time', 'geodirectory'),
|
|
| 3464 | + 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
|
|
| 3465 | + 'site_title' => __('Time', 'geodirectory'),
|
|
| 3466 | + 'htmlvar_name' => 'timing', |
|
| 3467 | + 'default_value' => '', |
|
| 3468 | + 'option_values' => '', |
|
| 3469 | + 'is_default' => '1', |
|
| 3470 | + 'is_admin' => '1', |
|
| 3471 | + 'show_in' => '[detail],[mapbubble]', |
|
| 3472 | + 'show_on_pkg' => $package, |
|
| 3473 | + 'clabels' => __('Time', 'geodirectory'));
|
|
| 3474 | + |
|
| 3475 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3476 | + 'data_type' => 'VARCHAR', |
|
| 3477 | + 'field_type' => 'phone', |
|
| 3478 | + 'admin_title' => __('Phone', 'geodirectory'),
|
|
| 3479 | + 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
|
|
| 3480 | + 'site_title' => __('Phone', 'geodirectory'),
|
|
| 3481 | + 'htmlvar_name' => 'contact', |
|
| 3482 | + 'default_value' => '', |
|
| 3483 | + 'option_values' => '', |
|
| 3484 | + 'is_default' => '1', |
|
| 3485 | + 'is_admin' => '1', |
|
| 3486 | + 'show_in' => '[detail],[mapbubble]', |
|
| 3487 | + 'show_on_pkg' => $package, |
|
| 3488 | + 'clabels' => __('Phone', 'geodirectory'));
|
|
| 3489 | + |
|
| 3490 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3491 | + 'data_type' => 'VARCHAR', |
|
| 3492 | + 'field_type' => 'email', |
|
| 3493 | + 'admin_title' => __('Email', 'geodirectory'),
|
|
| 3494 | + 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
|
|
| 3495 | + 'site_title' => __('Email', 'geodirectory'),
|
|
| 3496 | + 'htmlvar_name' => 'email', |
|
| 3497 | + 'default_value' => '', |
|
| 3498 | + 'option_values' => '', |
|
| 3499 | + 'is_default' => '1', |
|
| 3500 | + 'is_admin' => '1', |
|
| 3501 | + 'show_in' => '[detail]', |
|
| 3502 | + 'show_on_pkg' => $package, |
|
| 3503 | + 'clabels' => __('Email', 'geodirectory'));
|
|
| 3504 | + |
|
| 3505 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3506 | + 'data_type' => 'VARCHAR', |
|
| 3507 | + 'field_type' => 'url', |
|
| 3508 | + 'admin_title' => __('Website', 'geodirectory'),
|
|
| 3509 | + 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
|
|
| 3510 | + 'site_title' => __('Website', 'geodirectory'),
|
|
| 3511 | + 'htmlvar_name' => 'website', |
|
| 3512 | + 'default_value' => '', |
|
| 3513 | + 'option_values' => '', |
|
| 3514 | + 'is_default' => '1', |
|
| 3515 | + 'is_admin' => '1', |
|
| 3516 | + 'show_in' => '[detail]', |
|
| 3517 | + 'show_on_pkg' => $package, |
|
| 3518 | + 'clabels' => __('Website', 'geodirectory'));
|
|
| 3519 | + |
|
| 3520 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3521 | + 'data_type' => 'VARCHAR', |
|
| 3522 | + 'field_type' => 'url', |
|
| 3523 | + 'admin_title' => __('Twitter', 'geodirectory'),
|
|
| 3524 | + 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
|
|
| 3525 | + 'site_title' => __('Twitter', 'geodirectory'),
|
|
| 3526 | + 'htmlvar_name' => 'twitter', |
|
| 3527 | + 'default_value' => '', |
|
| 3528 | + 'option_values' => '', |
|
| 3529 | + 'is_default' => '1', |
|
| 3530 | + 'is_admin' => '1', |
|
| 3531 | + 'show_in' => '[detail]', |
|
| 3532 | + 'show_on_pkg' => $package, |
|
| 3533 | + 'clabels' => __('Twitter', 'geodirectory'));
|
|
| 3534 | + |
|
| 3535 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3536 | + 'data_type' => 'VARCHAR', |
|
| 3537 | + 'field_type' => 'url', |
|
| 3538 | + 'admin_title' => __('Facebook', 'geodirectory'),
|
|
| 3539 | + 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
|
|
| 3540 | + 'site_title' => __('Facebook', 'geodirectory'),
|
|
| 3541 | + 'htmlvar_name' => 'facebook', |
|
| 3542 | + 'default_value' => '', |
|
| 3543 | + 'option_values' => '', |
|
| 3544 | + 'is_default' => '1', |
|
| 3545 | + 'is_admin' => '1', |
|
| 3546 | + 'show_in' => '[detail]', |
|
| 3547 | + 'show_on_pkg' => $package, |
|
| 3548 | + 'clabels' => __('Facebook', 'geodirectory'));
|
|
| 3549 | + |
|
| 3550 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3551 | + 'data_type' => 'TEXT', |
|
| 3552 | + 'field_type' => 'textarea', |
|
| 3553 | + 'admin_title' => __('Video', 'geodirectory'),
|
|
| 3554 | + 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
|
|
| 3555 | + 'site_title' => __('Video', 'geodirectory'),
|
|
| 3556 | + 'htmlvar_name' => 'video', |
|
| 3557 | + 'default_value' => '', |
|
| 3558 | + 'option_values' => '', |
|
| 3559 | + 'is_default' => '0', |
|
| 3560 | + 'is_admin' => '1', |
|
| 3561 | + 'show_in' => '[owntab]', |
|
| 3562 | + 'show_on_pkg' => $package, |
|
| 3563 | + 'clabels' => __('Video', 'geodirectory'));
|
|
| 3564 | + |
|
| 3565 | + $fields[] = array('listing_type' => $post_type,
|
|
| 3566 | + 'data_type' => 'TEXT', |
|
| 3567 | + 'field_type' => 'textarea', |
|
| 3568 | + 'admin_title' => __('Special Offers', 'geodirectory'),
|
|
| 3569 | + 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
|
|
| 3570 | + 'site_title' => __('Special Offers', 'geodirectory'),
|
|
| 3571 | + 'htmlvar_name' => 'special_offers', |
|
| 3572 | + 'default_value' => '', |
|
| 3573 | + 'option_values' => '', |
|
| 3574 | + 'is_default' => '0', |
|
| 3575 | + 'is_admin' => '1', |
|
| 3576 | + 'show_in' => '[owntab]', |
|
| 3577 | + 'show_on_pkg' => $package, |
|
| 3578 | + 'clabels' => __('Special Offers', 'geodirectory'));
|
|
| 3579 | + |
|
| 3580 | + /** |
|
| 3581 | + * Filter the array of default custom fields DB table data. |
|
| 3582 | + * |
|
| 3583 | + * @since 1.6.6 |
|
| 3584 | + * @param string $fields The default custom fields as an array. |
|
| 3585 | + */ |
|
| 3586 | + $fields = apply_filters('geodir_default_custom_fields', $fields);
|
|
| 3587 | + |
|
| 3588 | + return $fields; |
|
| 3589 | 3589 | } |
| 3590 | 3590 | |
| 3591 | 3591 | function geodir_currency_format_number($number='',$cf=''){
|
| 3592 | 3592 | |
| 3593 | - $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
| 3593 | + $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
| 3594 | 3594 | |
| 3595 | - $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
| 3596 | - $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
| 3597 | - $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
| 3598 | - $decimalpoint = '.'; |
|
| 3595 | + $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
| 3596 | + $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
| 3597 | + $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
| 3598 | + $decimalpoint = '.'; |
|
| 3599 | 3599 | |
| 3600 | - if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
|
|
| 3601 | - $decimalpoint = ','; |
|
| 3602 | - } |
|
| 3600 | + if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
|
|
| 3601 | + $decimalpoint = ','; |
|
| 3602 | + } |
|
| 3603 | 3603 | |
| 3604 | - $separator = ','; |
|
| 3604 | + $separator = ','; |
|
| 3605 | 3605 | |
| 3606 | - if(isset($cs['thousand_separator'])){
|
|
| 3607 | - if($cs['thousand_separator']=='comma'){$separator = ',';}
|
|
| 3608 | - if($cs['thousand_separator']=='slash'){$separator = '\\';}
|
|
| 3609 | - if($cs['thousand_separator']=='period'){$separator = '.';}
|
|
| 3610 | - if($cs['thousand_separator']=='space'){$separator = ' ';}
|
|
| 3611 | - if($cs['thousand_separator']=='none'){$separator = '';}
|
|
| 3612 | - } |
|
| 3606 | + if(isset($cs['thousand_separator'])){
|
|
| 3607 | + if($cs['thousand_separator']=='comma'){$separator = ',';}
|
|
| 3608 | + if($cs['thousand_separator']=='slash'){$separator = '\\';}
|
|
| 3609 | + if($cs['thousand_separator']=='period'){$separator = '.';}
|
|
| 3610 | + if($cs['thousand_separator']=='space'){$separator = ' ';}
|
|
| 3611 | + if($cs['thousand_separator']=='none'){$separator = '';}
|
|
| 3612 | + } |
|
| 3613 | 3613 | |
| 3614 | - $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
| 3614 | + $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
| 3615 | 3615 | |
| 3616 | - if($decimals>0 && $decimal_display=='if'){
|
|
| 3617 | - if(is_int($number) || floor( $number ) == $number) |
|
| 3618 | - $decimals = 0; |
|
| 3619 | - } |
|
| 3616 | + if($decimals>0 && $decimal_display=='if'){
|
|
| 3617 | + if(is_int($number) || floor( $number ) == $number) |
|
| 3618 | + $decimals = 0; |
|
| 3619 | + } |
|
| 3620 | 3620 | |
| 3621 | - $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
| 3621 | + $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
| 3622 | 3622 | |
| 3623 | 3623 | |
| 3624 | 3624 | |
| 3625 | - if($currency_symbol_placement=='left'){
|
|
| 3626 | - $number = $symbol . $number; |
|
| 3627 | - }else{
|
|
| 3628 | - $number = $number . $symbol; |
|
| 3629 | - } |
|
| 3625 | + if($currency_symbol_placement=='left'){
|
|
| 3626 | + $number = $symbol . $number; |
|
| 3627 | + }else{
|
|
| 3628 | + $number = $number . $symbol; |
|
| 3629 | + } |
|
| 3630 | 3630 | |
| 3631 | 3631 | |
| 3632 | 3632 | return $number; |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function geodir_session_start() |
| 18 | 18 | {
|
| 19 | - if (!session_id()) session_start(); |
|
| 20 | - global $geodir_add_location_url; |
|
| 19 | + if (!session_id()) session_start(); |
|
| 20 | + global $geodir_add_location_url; |
|
| 21 | 21 | |
| 22 | - $geodir_add_location_url = NULL; |
|
| 22 | + $geodir_add_location_url = NULL; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function geodir_modified_query($query) |
| 35 | 35 | {
|
| 36 | - if ($query->is_main_query() && ( |
|
| 37 | - (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
|
|
| 38 | - || geodir_is_page('listing')
|
|
| 39 | - || geodir_is_page('author')
|
|
| 40 | - || geodir_is_page('search')
|
|
| 41 | - || geodir_is_page('detail'))
|
|
| 42 | - ) {
|
|
| 43 | - |
|
| 44 | - $query->set('is_geodir_loop', true);
|
|
| 45 | - } |
|
| 36 | + if ($query->is_main_query() && ( |
|
| 37 | + (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
|
|
| 38 | + || geodir_is_page('listing')
|
|
| 39 | + || geodir_is_page('author')
|
|
| 40 | + || geodir_is_page('search')
|
|
| 41 | + || geodir_is_page('detail'))
|
|
| 42 | + ) {
|
|
| 43 | + |
|
| 44 | + $query->set('is_geodir_loop', true);
|
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $query; |
|
| 47 | + return $query; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -67,81 +67,81 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function set_listing_request($query ) |
| 69 | 69 | {
|
| 70 | - global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
|
| 70 | + global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce |
|
| 74 | - if (!geodir_is_geodir_page()) {
|
|
| 75 | - return; |
|
| 76 | - } |
|
| 73 | + // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce |
|
| 74 | + if (!geodir_is_geodir_page()) {
|
|
| 75 | + return; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /* remove all pre filters */ |
|
| 79 | - remove_all_filters('query');
|
|
| 80 | - remove_all_filters('posts_search');
|
|
| 81 | - remove_all_filters('posts_fields');
|
|
| 82 | - remove_all_filters('posts_join');
|
|
| 83 | - remove_all_filters('posts_orderby');
|
|
| 84 | - remove_all_filters('posts_where');
|
|
| 78 | + /* remove all pre filters */ |
|
| 79 | + remove_all_filters('query');
|
|
| 80 | + remove_all_filters('posts_search');
|
|
| 81 | + remove_all_filters('posts_fields');
|
|
| 82 | + remove_all_filters('posts_join');
|
|
| 83 | + remove_all_filters('posts_orderby');
|
|
| 84 | + remove_all_filters('posts_where');
|
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | - if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')): |
|
| 87 | + if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')): |
|
| 88 | 88 | |
| 89 | - if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = ''; |
|
| 90 | - //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = ''; |
|
| 89 | + if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = ''; |
|
| 90 | + //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = ''; |
|
| 91 | 91 | |
| 92 | - if (isset($_REQUEST['sdist'])) {
|
|
| 93 | - ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000; |
|
| 94 | - } elseif (get_option('geodir_search_dist') != '') {
|
|
| 95 | - $dist = get_option('geodir_search_dist');
|
|
| 92 | + if (isset($_REQUEST['sdist'])) {
|
|
| 93 | + ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000; |
|
| 94 | + } elseif (get_option('geodir_search_dist') != '') {
|
|
| 95 | + $dist = get_option('geodir_search_dist');
|
|
| 96 | 96 | |
| 97 | - } else {
|
|
| 98 | - $dist = 25000; |
|
| 99 | - } // Distance |
|
| 97 | + } else {
|
|
| 98 | + $dist = 25000; |
|
| 99 | + } // Distance |
|
| 100 | 100 | |
| 101 | - if (isset($_REQUEST['sgeo_lat'])) {
|
|
| 102 | - $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | - } else {
|
|
| 104 | - $mylat = (float)geodir_get_current_city_lat(); |
|
| 105 | - } // Latatude |
|
| 101 | + if (isset($_REQUEST['sgeo_lat'])) {
|
|
| 102 | + $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | + } else {
|
|
| 104 | + $mylat = (float)geodir_get_current_city_lat(); |
|
| 105 | + } // Latatude |
|
| 106 | 106 | |
| 107 | - if (isset($_REQUEST['sgeo_lon'])) {
|
|
| 108 | - $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | - } else {
|
|
| 110 | - $mylon = (float)geodir_get_current_city_lng(); |
|
| 111 | - } // Distance |
|
| 107 | + if (isset($_REQUEST['sgeo_lon'])) {
|
|
| 108 | + $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | + } else {
|
|
| 110 | + $mylon = (float)geodir_get_current_city_lng(); |
|
| 111 | + } // Distance |
|
| 112 | 112 | |
| 113 | - if (isset($_REQUEST['snear'])) {
|
|
| 114 | - $snear = trim(esc_attr($_REQUEST['snear'])); |
|
| 115 | - } |
|
| 113 | + if (isset($_REQUEST['snear'])) {
|
|
| 114 | + $snear = trim(esc_attr($_REQUEST['snear'])); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if (isset($_REQUEST['s'])) {
|
|
| 118 | - $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s']))); |
|
| 119 | - } |
|
| 117 | + if (isset($_REQUEST['s'])) {
|
|
| 118 | + $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s']))); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - if ($snear == 'NEAR ME') {
|
|
| 122 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 123 | - $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 124 | - $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude])); |
|
| 125 | - $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude])); |
|
| 126 | - } |
|
| 121 | + if ($snear == 'NEAR ME') {
|
|
| 122 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 123 | + $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 124 | + $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude])); |
|
| 125 | + $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude])); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | - if (strstr($s, ',')) {
|
|
| 130 | - $s_AA = str_replace(" ", "", $s);
|
|
| 131 | - $s_A = explode(",", $s_AA);
|
|
| 132 | - $s_A = implode('","', $s_A);
|
|
| 133 | - $s_A = '"' . $s_A . '"'; |
|
| 134 | - } else {
|
|
| 135 | - $s_A = '"' . $s . '"'; |
|
| 136 | - } |
|
| 129 | + if (strstr($s, ',')) {
|
|
| 130 | + $s_AA = str_replace(" ", "", $s);
|
|
| 131 | + $s_A = explode(",", $s_AA);
|
|
| 132 | + $s_A = implode('","', $s_A);
|
|
| 133 | + $s_A = '"' . $s_A . '"'; |
|
| 134 | + } else {
|
|
| 135 | + $s_A = '"' . $s . '"'; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - if (strstr($s, ' ')) {
|
|
| 139 | - $s_SA = explode(" ", $s);
|
|
| 140 | - } else {
|
|
| 141 | - $s_SA = ''; |
|
| 142 | - } |
|
| 138 | + if (strstr($s, ' ')) {
|
|
| 139 | + $s_SA = explode(" ", $s);
|
|
| 140 | + } else {
|
|
| 141 | + $s_SA = ''; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - endif; |
|
| 144 | + endif; |
|
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | |
@@ -162,56 +162,56 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function geodir_listing_loop_filter($query) |
| 164 | 164 | {
|
| 165 | - global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term; |
|
| 165 | + global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term; |
|
| 166 | 166 | |
| 167 | - // fix wp_reset_query for popular post view widget |
|
| 168 | - if (!geodir_is_geodir_page()) {
|
|
| 169 | - return; |
|
| 170 | - } |
|
| 167 | + // fix wp_reset_query for popular post view widget |
|
| 168 | + if (!geodir_is_geodir_page()) {
|
|
| 169 | + return; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - $geodir_post_type = geodir_get_current_posttype(); |
|
| 173 | - |
|
| 174 | - if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
|
|
| 175 | - $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
| 176 | - |
|
| 177 | - if (isset($wp_query->query[$taxonomies[0]])) {
|
|
| 178 | - $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
|
|
| 179 | - $request_term = end($request_term); |
|
| 180 | - if (!term_exists($request_term)) {
|
|
| 181 | - $args = array('number' => '1',);
|
|
| 182 | - $terms_arr = get_terms($taxonomies[0], $args); |
|
| 183 | - foreach ($terms_arr as $location_term) {
|
|
| 184 | - $term_arr = $location_term; |
|
| 185 | - $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
|
|
| 186 | - } |
|
| 187 | - $wp_query->queried_object_id = 1; |
|
| 188 | - $wp_query->queried_object = $term_arr; |
|
| 189 | - //print_r($wp_query) ; |
|
| 190 | - } |
|
| 191 | - } |
|
| 172 | + $geodir_post_type = geodir_get_current_posttype(); |
|
| 173 | + |
|
| 174 | + if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
|
|
| 175 | + $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
| 176 | + |
|
| 177 | + if (isset($wp_query->query[$taxonomies[0]])) {
|
|
| 178 | + $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
|
|
| 179 | + $request_term = end($request_term); |
|
| 180 | + if (!term_exists($request_term)) {
|
|
| 181 | + $args = array('number' => '1',);
|
|
| 182 | + $terms_arr = get_terms($taxonomies[0], $args); |
|
| 183 | + foreach ($terms_arr as $location_term) {
|
|
| 184 | + $term_arr = $location_term; |
|
| 185 | + $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
|
|
| 186 | + } |
|
| 187 | + $wp_query->queried_object_id = 1; |
|
| 188 | + $wp_query->queried_object = $term_arr; |
|
| 189 | + //print_r($wp_query) ; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - } |
|
| 194 | - if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
|
| 195 | - |
|
| 196 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 197 | - |
|
| 198 | - add_filter('posts_fields', 'geodir_posts_fields', 1);
|
|
| 199 | - add_filter('posts_join', 'geodir_posts_join', 1);
|
|
| 200 | - geodir_post_where(); |
|
| 201 | - if (!is_admin()) |
|
| 202 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 203 | - |
|
| 204 | - // advanced filter for popular post view widget |
|
| 205 | - global $wp_query; |
|
| 206 | - if (!is_admin()) {
|
|
| 207 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 208 | - add_filter('posts_join', 'geodir_filter_widget_join', 1000);
|
|
| 209 | - } |
|
| 210 | - add_filter('posts_where', 'geodir_filter_widget_where', 1000);
|
|
| 211 | - } |
|
| 193 | + } |
|
| 194 | + if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
|
| 212 | 195 | |
| 213 | - } |
|
| 214 | - return $query; |
|
| 196 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 197 | + |
|
| 198 | + add_filter('posts_fields', 'geodir_posts_fields', 1);
|
|
| 199 | + add_filter('posts_join', 'geodir_posts_join', 1);
|
|
| 200 | + geodir_post_where(); |
|
| 201 | + if (!is_admin()) |
|
| 202 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 203 | + |
|
| 204 | + // advanced filter for popular post view widget |
|
| 205 | + global $wp_query; |
|
| 206 | + if (!is_admin()) {
|
|
| 207 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 208 | + add_filter('posts_join', 'geodir_filter_widget_join', 1000);
|
|
| 209 | + } |
|
| 210 | + add_filter('posts_where', 'geodir_filter_widget_where', 1000);
|
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + } |
|
| 214 | + return $query; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -230,67 +230,67 @@ discard block |
||
| 230 | 230 | * @return string Modified fields query string. |
| 231 | 231 | */ |
| 232 | 232 | function geodir_posts_fields($fields) {
|
| 233 | - global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
|
| 233 | + global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
|
| 234 | 234 | |
| 235 | - // Filter-Location-Manager to add location table. |
|
| 236 | - $fields .= ", " . $table . ".* "; |
|
| 235 | + // Filter-Location-Manager to add location table. |
|
| 236 | + $fields .= ", " . $table . ".* "; |
|
| 237 | 237 | |
| 238 | 238 | if ($snear != '' || $gd_session->get('all_near_me')) {
|
| 239 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 239 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 240 | 240 | |
| 241 | 241 | if ($gd_session->get('all_near_me')) {
|
| 242 | - $mylat = $gd_session->get('user_lat');
|
|
| 243 | - $mylon = $gd_session->get('user_lon');
|
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - global $s; |
|
| 250 | - if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 251 | - $keywords = explode(" ", $s);
|
|
| 252 | - |
|
| 253 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | - foreach($keywords as $kkey=>$kword){
|
|
| 255 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 256 | - unset($keywords[$kkey]); |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 242 | + $mylat = $gd_session->get('user_lat');
|
|
| 243 | + $mylon = $gd_session->get('user_lon');
|
|
| 244 | + } |
|
| 260 | 245 | |
| 246 | + $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | + } |
|
| 261 | 248 | |
| 262 | - if (count($keywords) > 1) {
|
|
| 263 | - $parts = array( |
|
| 264 | - 'AND' => 'gd_alltitlematch_part', |
|
| 265 | - 'OR' => 'gd_titlematch_part' |
|
| 266 | - ); |
|
| 267 | - $gd_titlematch_part = ""; |
|
| 268 | - foreach ($parts as $key => $part) {
|
|
| 269 | - $gd_titlematch_part .= " CASE WHEN "; |
|
| 270 | - $count = 0; |
|
| 271 | - foreach ($keywords as $keyword) {
|
|
| 272 | - $keyword = trim($keyword); |
|
| 273 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 249 | + global $s; |
|
| 250 | + if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 251 | + $keywords = explode(" ", $s);
|
|
| 252 | + |
|
| 253 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | + foreach($keywords as $kkey=>$kword){
|
|
| 255 | + if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 256 | + unset($keywords[$kkey]); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + if (count($keywords) > 1) {
|
|
| 263 | + $parts = array( |
|
| 264 | + 'AND' => 'gd_alltitlematch_part', |
|
| 265 | + 'OR' => 'gd_titlematch_part' |
|
| 266 | + ); |
|
| 267 | + $gd_titlematch_part = ""; |
|
| 268 | + foreach ($parts as $key => $part) {
|
|
| 269 | + $gd_titlematch_part .= " CASE WHEN "; |
|
| 270 | + $count = 0; |
|
| 271 | + foreach ($keywords as $keyword) {
|
|
| 272 | + $keyword = trim($keyword); |
|
| 273 | + $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 274 | 274 | $count++; |
| 275 | - if ($count < count($keywords)) {
|
|
| 276 | - // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
|
| 275 | + if ($count < count($keywords)) {
|
|
| 276 | + // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
|
| 277 | 277 | $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " "; |
| 278 | - } else {
|
|
| 279 | - //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
|
| 278 | + } else {
|
|
| 279 | + //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
|
| 280 | 280 | $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) "; |
| 281 | - } |
|
| 282 | - } |
|
| 283 | - $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 284 | - } |
|
| 285 | - } else {
|
|
| 286 | - $gd_titlematch_part = ""; |
|
| 287 | - } |
|
| 288 | - $s = stripslashes_deep( $s ); |
|
| 289 | - $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 284 | + } |
|
| 285 | + } else {
|
|
| 286 | + $gd_titlematch_part = ""; |
|
| 287 | + } |
|
| 288 | + $s = stripslashes_deep( $s ); |
|
| 289 | + $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 290 | 290 | $fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s));
|
| 291 | - } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - return $fields; |
|
| 293 | + return $fields; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -307,26 +307,26 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | function geodir_posts_join($join) |
| 309 | 309 | {
|
| 310 | - global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix; |
|
| 310 | + global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix; |
|
| 311 | 311 | |
| 312 | - ########### WPML ########### |
|
| 312 | + ########### WPML ########### |
|
| 313 | 313 | |
| 314 | - if (function_exists('icl_object_id')) {
|
|
| 315 | - global $sitepress; |
|
| 316 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 317 | - $default_lang_code = $sitepress->get_default_language(); |
|
| 318 | - if ($lang_code) {
|
|
| 319 | - $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 320 | - } |
|
| 314 | + if (function_exists('icl_object_id')) {
|
|
| 315 | + global $sitepress; |
|
| 316 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 317 | + $default_lang_code = $sitepress->get_default_language(); |
|
| 318 | + if ($lang_code) {
|
|
| 319 | + $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - } |
|
| 323 | - ########### WPML ########### |
|
| 322 | + } |
|
| 323 | + ########### WPML ########### |
|
| 324 | 324 | |
| 325 | - $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 326 | - //===old code start |
|
| 327 | - //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
|
| 325 | + $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 326 | + //===old code start |
|
| 327 | + //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
|
| 328 | 328 | |
| 329 | - return $join; |
|
| 329 | + return $join; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | |
@@ -344,15 +344,15 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function geodir_posts_orderby($orderby) |
| 346 | 346 | {
|
| 347 | - global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort; |
|
| 347 | + global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort; |
|
| 348 | 348 | |
| 349 | - $sort_by = ''; |
|
| 350 | - $orderby = ' '; |
|
| 349 | + $sort_by = ''; |
|
| 350 | + $orderby = ' '; |
|
| 351 | 351 | |
| 352 | - if (get_query_var('order_by'))
|
|
| 353 | - $sort_by = get_query_var('order_by');
|
|
| 352 | + if (get_query_var('order_by'))
|
|
| 353 | + $sort_by = get_query_var('order_by');
|
|
| 354 | 354 | |
| 355 | - /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
|
|
| 355 | + /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
|
|
| 356 | 356 | $current_term = $wp_query->get_queried_object(); |
| 357 | 357 | } |
| 358 | 358 | |
@@ -366,133 +366,133 @@ discard block |
||
| 366 | 366 | }*/ |
| 367 | 367 | |
| 368 | 368 | |
| 369 | - if ($snear != '') {
|
|
| 370 | - $orderby .= " distance,"; |
|
| 371 | - } |
|
| 369 | + if ($snear != '') {
|
|
| 370 | + $orderby .= " distance,"; |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) |
|
| 374 | - $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 373 | + if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) |
|
| 374 | + $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 375 | 375 | |
| 376 | 376 | |
| 377 | - if ($sort_by == '') {
|
|
| 378 | - $default_sort = geodir_get_posts_default_sort($geodir_post_type); |
|
| 379 | - if (!empty($default_sort)) |
|
| 380 | - $sort_by = $default_sort; |
|
| 381 | - } |
|
| 377 | + if ($sort_by == '') {
|
|
| 378 | + $default_sort = geodir_get_posts_default_sort($geodir_post_type); |
|
| 379 | + if (!empty($default_sort)) |
|
| 380 | + $sort_by = $default_sort; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - /* |
|
| 383 | + /* |
|
| 384 | 384 | if search by term & no location then order always "relevance" |
| 385 | 385 | if search by location then order always "nearest" |
| 386 | 386 | */ |
| 387 | - if (is_main_query() && geodir_is_page('search')) {
|
|
| 388 | - $search_term = get_query_var('s');
|
|
| 387 | + if (is_main_query() && geodir_is_page('search')) {
|
|
| 388 | + $search_term = get_query_var('s');
|
|
| 389 | 389 | |
| 390 | - if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
|
|
| 391 | - $sort_by = 'az'; |
|
| 392 | - } |
|
| 390 | + if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
|
|
| 391 | + $sort_by = 'az'; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - if ($snear != '' && $sort_by!='farthest') {
|
|
| 395 | - $sort_by = 'nearest'; |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - switch ($sort_by): |
|
| 400 | - case 'newest': |
|
| 401 | - $orderby = "$wpdb->posts.post_date desc, "; |
|
| 402 | - break; |
|
| 403 | - case 'oldest': |
|
| 404 | - $orderby = "$wpdb->posts.post_date asc, "; |
|
| 405 | - break; |
|
| 406 | - case 'low_review': |
|
| 407 | - case 'rating_count_asc': |
|
| 408 | - $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 409 | - break; |
|
| 410 | - case 'high_review': |
|
| 411 | - case 'rating_count_desc': |
|
| 412 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 413 | - break; |
|
| 414 | - case 'low_rating': |
|
| 415 | - $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 416 | - break; |
|
| 417 | - case 'high_rating': |
|
| 418 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 419 | - break; |
|
| 420 | - case 'featured': |
|
| 421 | - $orderby = $table . ".is_featured asc, "; |
|
| 422 | - break; |
|
| 423 | - case 'nearest': |
|
| 424 | - $orderby = " distance asc, "; |
|
| 425 | - break; |
|
| 426 | - case 'farthest': |
|
| 427 | - $orderby = " distance desc, "; |
|
| 428 | - break; |
|
| 429 | - case 'random': |
|
| 430 | - $orderby = " rand(), "; |
|
| 431 | - break; |
|
| 432 | - case 'az': |
|
| 433 | - $orderby = "$wpdb->posts.post_title asc, "; |
|
| 434 | - break; |
|
| 435 | - // sort by rating |
|
| 436 | - case 'overall_rating_desc': |
|
| 437 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 438 | - break; |
|
| 439 | - case 'overall_rating_asc': |
|
| 440 | - $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 441 | - break; |
|
| 442 | - default: |
|
| 443 | - |
|
| 444 | - break; |
|
| 445 | - endswitch; |
|
| 446 | - |
|
| 447 | - if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
|
|
| 448 | - if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
|
|
| 449 | - $orderby = "$wpdb->posts.comment_count DESC, "; |
|
| 450 | - $sort_by = 'comment_count_desc'; |
|
| 451 | - } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
|
|
| 452 | - $orderby = "$wpdb->posts.comment_count ASC, "; |
|
| 453 | - $sort_by = 'comment_count_asc'; |
|
| 454 | - } |
|
| 455 | - } |
|
| 394 | + if ($snear != '' && $sort_by!='farthest') {
|
|
| 395 | + $sort_by = 'nearest'; |
|
| 396 | + } |
|
| 397 | + } |
|
| 456 | 398 | |
| 457 | - global $s; |
|
| 399 | + switch ($sort_by): |
|
| 400 | + case 'newest': |
|
| 401 | + $orderby = "$wpdb->posts.post_date desc, "; |
|
| 402 | + break; |
|
| 403 | + case 'oldest': |
|
| 404 | + $orderby = "$wpdb->posts.post_date asc, "; |
|
| 405 | + break; |
|
| 406 | + case 'low_review': |
|
| 407 | + case 'rating_count_asc': |
|
| 408 | + $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 409 | + break; |
|
| 410 | + case 'high_review': |
|
| 411 | + case 'rating_count_desc': |
|
| 412 | + $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 413 | + break; |
|
| 414 | + case 'low_rating': |
|
| 415 | + $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 416 | + break; |
|
| 417 | + case 'high_rating': |
|
| 418 | + $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 419 | + break; |
|
| 420 | + case 'featured': |
|
| 421 | + $orderby = $table . ".is_featured asc, "; |
|
| 422 | + break; |
|
| 423 | + case 'nearest': |
|
| 424 | + $orderby = " distance asc, "; |
|
| 425 | + break; |
|
| 426 | + case 'farthest': |
|
| 427 | + $orderby = " distance desc, "; |
|
| 428 | + break; |
|
| 429 | + case 'random': |
|
| 430 | + $orderby = " rand(), "; |
|
| 431 | + break; |
|
| 432 | + case 'az': |
|
| 433 | + $orderby = "$wpdb->posts.post_title asc, "; |
|
| 434 | + break; |
|
| 435 | + // sort by rating |
|
| 436 | + case 'overall_rating_desc': |
|
| 437 | + $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 438 | + break; |
|
| 439 | + case 'overall_rating_asc': |
|
| 440 | + $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 441 | + break; |
|
| 442 | + default: |
|
| 443 | + |
|
| 444 | + break; |
|
| 445 | + endswitch; |
|
| 446 | + |
|
| 447 | + if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
|
|
| 448 | + if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
|
|
| 449 | + $orderby = "$wpdb->posts.comment_count DESC, "; |
|
| 450 | + $sort_by = 'comment_count_desc'; |
|
| 451 | + } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
|
|
| 452 | + $orderby = "$wpdb->posts.comment_count ASC, "; |
|
| 453 | + $sort_by = 'comment_count_asc'; |
|
| 454 | + } |
|
| 455 | + } |
|
| 458 | 456 | |
| 459 | - if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 460 | - $keywords = explode(" ", $s);
|
|
| 461 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | - foreach($keywords as $kkey=>$kword){
|
|
| 463 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 464 | - unset($keywords[$kkey]); |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
|
| 469 | - if (count($keywords) > 1) {
|
|
| 470 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | - } else {
|
|
| 472 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | - } |
|
| 474 | - } else {
|
|
| 475 | - if (count($keywords) > 1) {
|
|
| 476 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 477 | - } else {
|
|
| 478 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 479 | - } |
|
| 480 | - } |
|
| 481 | - } |
|
| 457 | + global $s; |
|
| 458 | + |
|
| 459 | + if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 460 | + $keywords = explode(" ", $s);
|
|
| 461 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | + foreach($keywords as $kkey=>$kword){
|
|
| 463 | + if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 464 | + unset($keywords[$kkey]); |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
|
| 469 | + if (count($keywords) > 1) {
|
|
| 470 | + $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | + } else {
|
|
| 472 | + $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | + } |
|
| 474 | + } else {
|
|
| 475 | + if (count($keywords) > 1) {
|
|
| 476 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 477 | + } else {
|
|
| 478 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 479 | + } |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - /** |
|
| 484 | - * Filter order by SQL. |
|
| 485 | - * |
|
| 486 | - * @since 1.0.0 |
|
| 487 | - * @param string $orderby The orderby query string. |
|
| 488 | - * @param string $sort_by Sortby query string. |
|
| 489 | - * @param string $table Listing table name. |
|
| 490 | - */ |
|
| 491 | - $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
|
| 483 | + /** |
|
| 484 | + * Filter order by SQL. |
|
| 485 | + * |
|
| 486 | + * @since 1.0.0 |
|
| 487 | + * @param string $orderby The orderby query string. |
|
| 488 | + * @param string $sort_by Sortby query string. |
|
| 489 | + * @param string $table Listing table name. |
|
| 490 | + */ |
|
| 491 | + $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
|
| 492 | 492 | |
| 493 | - $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 493 | + $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 494 | 494 | |
| 495 | - return $orderby; |
|
| 495 | + return $orderby; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | |
@@ -510,53 +510,53 @@ discard block |
||
| 510 | 510 | function geodir_posts_order_by_custom_sort($orderby, $sort_by, $table) |
| 511 | 511 | {
|
| 512 | 512 | |
| 513 | - global $wpdb; |
|
| 513 | + global $wpdb; |
|
| 514 | 514 | |
| 515 | - if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 515 | + if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 516 | 516 | |
| 517 | - $sort_array = explode('_', $sort_by);
|
|
| 517 | + $sort_array = explode('_', $sort_by);
|
|
| 518 | 518 | |
| 519 | - $sort_by_count = count($sort_array); |
|
| 519 | + $sort_by_count = count($sort_array); |
|
| 520 | 520 | |
| 521 | - $order = $sort_array[$sort_by_count - 1]; |
|
| 521 | + $order = $sort_array[$sort_by_count - 1]; |
|
| 522 | 522 | |
| 523 | - if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
|
| 523 | + if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
|
| 524 | 524 | |
| 525 | - $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 525 | + $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 526 | 526 | |
| 527 | - switch ($sort_by): |
|
| 527 | + switch ($sort_by): |
|
| 528 | 528 | |
| 529 | - case 'post_date': |
|
| 530 | - case 'comment_count': |
|
| 529 | + case 'post_date': |
|
| 530 | + case 'comment_count': |
|
| 531 | 531 | |
| 532 | - $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 533 | - break; |
|
| 532 | + $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 533 | + break; |
|
| 534 | 534 | |
| 535 | - case 'distance': |
|
| 536 | - $orderby = $sort_by . " " . $order . ", "; |
|
| 537 | - break; |
|
| 535 | + case 'distance': |
|
| 536 | + $orderby = $sort_by . " " . $order . ", "; |
|
| 537 | + break; |
|
| 538 | 538 | |
| 539 | 539 | |
| 540 | - // sort by rating |
|
| 541 | - case 'overall_rating': |
|
| 542 | - $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 540 | + // sort by rating |
|
| 541 | + case 'overall_rating': |
|
| 542 | + $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 543 | 543 | |
| 544 | - break; |
|
| 544 | + break; |
|
| 545 | 545 | |
| 546 | 546 | |
| 547 | - default: |
|
| 548 | - if (geodir_column_exist($table, $sort_by)) {
|
|
| 547 | + default: |
|
| 548 | + if (geodir_column_exist($table, $sort_by)) {
|
|
| 549 | 549 | $orderby = $table . "." . $sort_by . " " . $order . ", "; |
| 550 | 550 | } |
| 551 | - break; |
|
| 551 | + break; |
|
| 552 | 552 | |
| 553 | - endswitch; |
|
| 553 | + endswitch; |
|
| 554 | 554 | |
| 555 | - } |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - } |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - return $orderby; |
|
| 559 | + return $orderby; |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |
@@ -571,34 +571,34 @@ discard block |
||
| 571 | 571 | {
|
| 572 | 572 | |
| 573 | 573 | |
| 574 | - global $wpdb, $geodir_post_type, $table, $s, $snear; |
|
| 574 | + global $wpdb, $geodir_post_type, $table, $s, $snear; |
|
| 575 | 575 | |
| 576 | - if (!is_admin()) {
|
|
| 576 | + if (!is_admin()) {
|
|
| 577 | 577 | |
| 578 | - if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 579 | - add_filter('posts_where', 'geodir_edit_listing_where', 1);
|
|
| 578 | + if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 579 | + add_filter('posts_where', 'geodir_edit_listing_where', 1);
|
|
| 580 | 580 | |
| 581 | - } elseif ((is_search() && $_REQUEST['geodir_search'])) {
|
|
| 581 | + } elseif ((is_search() && $_REQUEST['geodir_search'])) {
|
|
| 582 | 582 | |
| 583 | - add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 583 | + add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 584 | 584 | |
| 585 | - if ($snear != '') |
|
| 586 | - add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 585 | + if ($snear != '') |
|
| 586 | + add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 587 | 587 | |
| 588 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 588 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 589 | 589 | |
| 590 | - } elseif (geodir_is_page('author')) {
|
|
| 590 | + } elseif (geodir_is_page('author')) {
|
|
| 591 | 591 | |
| 592 | - add_filter('posts_where', 'author_filter_where', 1);
|
|
| 592 | + add_filter('posts_where', 'author_filter_where', 1);
|
|
| 593 | 593 | |
| 594 | - } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - //if (!geodir_is_page('detail'))
|
|
| 597 | - add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 596 | + //if (!geodir_is_page('detail'))
|
|
| 597 | + add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 598 | 598 | |
| 599 | - //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
|
| 599 | + //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
|
| 600 | 600 | |
| 601 | - } |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -613,13 +613,13 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | function geodir_preview_post_cap($allcaps, $caps, $args) |
| 615 | 615 | {
|
| 616 | - $user_id = get_current_user_id(); |
|
| 617 | - if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
|
|
| 616 | + $user_id = get_current_user_id(); |
|
| 617 | + if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
|
|
| 618 | 618 | |
| 619 | - $allcaps['edit_posts'] = true; |
|
| 620 | - } |
|
| 621 | - //print_r($allcaps); |
|
| 622 | - return $allcaps; |
|
| 619 | + $allcaps['edit_posts'] = true; |
|
| 620 | + } |
|
| 621 | + //print_r($allcaps); |
|
| 622 | + return $allcaps; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | |
@@ -634,9 +634,9 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | function geodir_edit_listing_where($where) |
| 636 | 636 | {
|
| 637 | - global $wpdb; |
|
| 638 | - $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
|
|
| 639 | - return $where; |
|
| 637 | + global $wpdb; |
|
| 638 | + $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
|
|
| 639 | + return $where; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | |
@@ -653,29 +653,29 @@ discard block |
||
| 653 | 653 | */ |
| 654 | 654 | function geodir_default_where($where) |
| 655 | 655 | {
|
| 656 | - global $wp_query, $wpdb; |
|
| 657 | - |
|
| 658 | - //print_r($wp_query); |
|
| 659 | - ########### WPML ########### |
|
| 660 | - |
|
| 661 | - if (function_exists('icl_object_id')) {
|
|
| 662 | - global $sitepress, $table_prefix; |
|
| 663 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 664 | - $default_lang_code = $sitepress->get_default_language(); |
|
| 665 | - $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
|
| 666 | - //echo '##########'.$q_post_type; |
|
| 667 | - if ($lang_code && $q_post_type) {
|
|
| 668 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 669 | - //$where .= " AND icl_t.language_code = '$lang_code' "; |
|
| 670 | - } |
|
| 656 | + global $wp_query, $wpdb; |
|
| 671 | 657 | |
| 672 | - } |
|
| 673 | - ########### WPML ########### |
|
| 658 | + //print_r($wp_query); |
|
| 659 | + ########### WPML ########### |
|
| 660 | + |
|
| 661 | + if (function_exists('icl_object_id')) {
|
|
| 662 | + global $sitepress, $table_prefix; |
|
| 663 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 664 | + $default_lang_code = $sitepress->get_default_language(); |
|
| 665 | + $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
|
| 666 | + //echo '##########'.$q_post_type; |
|
| 667 | + if ($lang_code && $q_post_type) {
|
|
| 668 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 669 | + //$where .= " AND icl_t.language_code = '$lang_code' "; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + } |
|
| 673 | + ########### WPML ########### |
|
| 674 | 674 | |
| 675 | 675 | |
| 676 | - return $where = str_replace("0 = 1", "1=1", $where);
|
|
| 676 | + return $where = str_replace("0 = 1", "1=1", $where);
|
|
| 677 | 677 | |
| 678 | - /* ====== old code start === |
|
| 678 | + /* ====== old code start === |
|
| 679 | 679 | $where = str_replace("0 = 1", "1=1", $where);
|
| 680 | 680 | $country = get_query_var('gd_country');
|
| 681 | 681 | $region = get_query_var('gd_region');
|
@@ -716,108 +716,108 @@ discard block |
||
| 716 | 716 | * @return string Modified where query string. |
| 717 | 717 | */ |
| 718 | 718 | function searching_filter_where($where) {
|
| 719 | - global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session; |
|
| 719 | + global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session; |
|
| 720 | 720 | |
| 721 | - $search_term = 'OR'; |
|
| 722 | - $search_term = 'AND'; |
|
| 723 | - $geodir_custom_search = ''; |
|
| 724 | - $category_search_range = ''; |
|
| 721 | + $search_term = 'OR'; |
|
| 722 | + $search_term = 'AND'; |
|
| 723 | + $geodir_custom_search = ''; |
|
| 724 | + $category_search_range = ''; |
|
| 725 | 725 | |
| 726 | - if (is_single() && get_query_var('post_type')) {
|
|
| 726 | + if (is_single() && get_query_var('post_type')) {
|
|
| 727 | 727 | return $where; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - if (is_tax()) {
|
|
| 730 | + if (is_tax()) {
|
|
| 731 | 731 | return $where; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $s = trim($s); |
| 735 | - $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | - $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 737 | - |
|
| 738 | - $where = ''; |
|
| 739 | - $better_search_terms = ''; |
|
| 740 | - if (isset($_REQUEST['stype'])) |
|
| 741 | - $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 742 | - else |
|
| 743 | - $post_types = 'gd_place'; |
|
| 744 | - |
|
| 745 | - if ($s != '') {
|
|
| 746 | - $keywords = explode(" ", $s);
|
|
| 747 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | - foreach($keywords as $kkey=>$kword){
|
|
| 749 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 750 | - unset($keywords[$kkey]); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - } |
|
| 735 | + $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | + $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 754 | 737 | |
| 755 | - if (!empty($keywords)) {
|
|
| 756 | - foreach ($keywords as $keyword) {
|
|
| 757 | - $keyword = trim($keyword); |
|
| 758 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 759 | - if ($keyword != '') {
|
|
| 760 | - /** |
|
| 761 | - * Filter the search query keywords SQL. |
|
| 762 | - * |
|
| 763 | - * @since 1.5.9 |
|
| 764 | - * @package GeoDirectory |
|
| 765 | - * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`. |
|
| 766 | - * @param array $keywords The array of keywords for the query. |
|
| 767 | - * @param string $keyword The single keyword being searched. |
|
| 768 | - */ |
|
| 738 | + $where = ''; |
|
| 739 | + $better_search_terms = ''; |
|
| 740 | + if (isset($_REQUEST['stype'])) |
|
| 741 | + $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 742 | + else |
|
| 743 | + $post_types = 'gd_place'; |
|
| 744 | + |
|
| 745 | + if ($s != '') {
|
|
| 746 | + $keywords = explode(" ", $s);
|
|
| 747 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | + foreach($keywords as $kkey=>$kword){
|
|
| 749 | + if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 750 | + unset($keywords[$kkey]); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + if (!empty($keywords)) {
|
|
| 756 | + foreach ($keywords as $keyword) {
|
|
| 757 | + $keyword = trim($keyword); |
|
| 758 | + $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 759 | + if ($keyword != '') {
|
|
| 760 | + /** |
|
| 761 | + * Filter the search query keywords SQL. |
|
| 762 | + * |
|
| 763 | + * @since 1.5.9 |
|
| 764 | + * @package GeoDirectory |
|
| 765 | + * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`. |
|
| 766 | + * @param array $keywords The array of keywords for the query. |
|
| 767 | + * @param string $keyword The single keyword being searched. |
|
| 768 | + */ |
|
| 769 | 769 | $better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
|
| 770 | - } |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - } |
|
| 770 | + } |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - /* get taxonomy */ |
|
| 776 | - $taxonomies = geodir_get_taxonomies($post_types, true); |
|
| 777 | - if($taxonomies) {
|
|
| 778 | - $taxonomies = implode("','", $taxonomies);
|
|
| 779 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | - }else{$taxonomies='';}
|
|
| 775 | + /* get taxonomy */ |
|
| 776 | + $taxonomies = geodir_get_taxonomies($post_types, true); |
|
| 777 | + if($taxonomies) {
|
|
| 778 | + $taxonomies = implode("','", $taxonomies);
|
|
| 779 | + $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | + }else{$taxonomies='';}
|
|
| 781 | 781 | |
| 782 | - $content_where = $terms_where = ''; |
|
| 782 | + $content_where = $terms_where = ''; |
|
| 783 | 783 | if ($s != '') {
|
| 784 | - /** |
|
| 785 | - * Filter the search query content where values. |
|
| 786 | - * |
|
| 787 | - * @since 1.5.0 |
|
| 788 | - * @package GeoDirectory |
|
| 789 | - * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
|
| 790 | - */ |
|
| 784 | + /** |
|
| 785 | + * Filter the search query content where values. |
|
| 786 | + * |
|
| 787 | + * @since 1.5.0 |
|
| 788 | + * @package GeoDirectory |
|
| 789 | + * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
|
| 790 | + */ |
|
| 791 | 791 | $content_where = apply_filters("geodir_search_content_where"," OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
| 792 | - /** |
|
| 793 | - * Filter the search query term values. |
|
| 794 | - * |
|
| 795 | - * @since 1.5.0 |
|
| 796 | - * @package GeoDirectory |
|
| 797 | - * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
|
| 798 | - */ |
|
| 799 | - $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 792 | + /** |
|
| 793 | + * Filter the search query term values. |
|
| 794 | + * |
|
| 795 | + * @since 1.5.0 |
|
| 796 | + * @package GeoDirectory |
|
| 797 | + * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
|
| 798 | + */ |
|
| 799 | + $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if ($snear != '') {
|
|
| 802 | + if ($snear != '') {
|
|
| 803 | 803 | |
| 804 | 804 | |
| 805 | - if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
|
|
| 806 | - $dist = $gd_session->get('near_me_range');
|
|
| 807 | - } |
|
| 808 | - $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 809 | - $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 810 | - $lat1 = $mylat - ($dist / 69); |
|
| 811 | - $lat2 = $mylat + ($dist / 69); |
|
| 805 | + if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
|
|
| 806 | + $dist = $gd_session->get('near_me_range');
|
|
| 807 | + } |
|
| 808 | + $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 809 | + $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 810 | + $lat1 = $mylat - ($dist / 69); |
|
| 811 | + $lat2 = $mylat + ($dist / 69); |
|
| 812 | 812 | |
| 813 | - $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : ''; |
|
| 814 | - $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : ''; |
|
| 815 | - $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : ''; |
|
| 816 | - $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : ''; |
|
| 813 | + $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : ''; |
|
| 814 | + $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : ''; |
|
| 815 | + $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : ''; |
|
| 816 | + $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : ''; |
|
| 817 | 817 | |
| 818 | 818 | |
| 819 | 819 | |
| 820 | - $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 820 | + $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 821 | 821 | $content_where |
| 822 | 822 | OR ($wpdb->posts.ID IN( |
| 823 | 823 | SELECT $wpdb->term_relationships.object_id as post_id |
@@ -834,13 +834,13 @@ discard block |
||
| 834 | 834 | AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 ) |
| 835 | 835 | AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) "; |
| 836 | 836 | |
| 837 | - if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
|
| 838 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 839 | - $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 840 | - } |
|
| 837 | + if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
|
| 838 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 839 | + $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - } else {
|
|
| 843 | - $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 842 | + } else {
|
|
| 843 | + $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 844 | 844 | $content_where |
| 845 | 845 | OR ( $wpdb->posts.ID IN( |
| 846 | 846 | SELECT $wpdb->term_relationships.object_id as post_id |
@@ -854,19 +854,19 @@ discard block |
||
| 854 | 854 | ) |
| 855 | 855 | AND $wpdb->posts.post_type in ('$post_types')
|
| 856 | 856 | AND ($wpdb->posts.post_status = 'publish') "; |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | 859 | ########### WPML ########### |
| 860 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 860 | + if ( function_exists( 'icl_object_id' ) ) {
|
|
| 861 | 861 | $lang_code = ICL_LANGUAGE_CODE; |
| 862 | 862 | |
| 863 | 863 | if ($lang_code && $post_types) {
|
| 864 | - $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - ########### WPML ########### |
|
| 864 | + $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + ########### WPML ########### |
|
| 868 | 868 | |
| 869 | - return $where; |
|
| 869 | + return $where; |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | |
@@ -881,45 +881,45 @@ discard block |
||
| 881 | 881 | * @return string Modified where query string. |
| 882 | 882 | */ |
| 883 | 883 | function author_filter_where($where) {
|
| 884 | - global $wpdb, $geodir_post_type, $table, $curr; |
|
| 884 | + global $wpdb, $geodir_post_type, $table, $curr; |
|
| 885 | 885 | |
| 886 | - $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
| 887 | - $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 886 | + $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
| 887 | + $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 888 | 888 | |
| 889 | - if (isset($_REQUEST['stype'])) {
|
|
| 890 | - $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 891 | - } else {
|
|
| 892 | - $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
|
| 893 | - } |
|
| 889 | + if (isset($_REQUEST['stype'])) {
|
|
| 890 | + $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 891 | + } else {
|
|
| 892 | + $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
|
| 893 | + } |
|
| 894 | 894 | |
| 895 | - if ($user_id > 0) {
|
|
| 896 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 897 | - $user_fav_posts = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 898 | - $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
|
|
| 899 | - $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
|
|
| 900 | - } else |
|
| 901 | - $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 902 | - |
|
| 903 | - if ($user_id == (int)get_current_user_id()) {
|
|
| 904 | - $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
|
| 905 | - } else {
|
|
| 906 | - $where .= " AND $wpdb->posts.post_status = 'publish' "; |
|
| 907 | - } |
|
| 908 | - } else {
|
|
| 909 | - $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' "; |
|
| 910 | - } |
|
| 895 | + if ($user_id > 0) {
|
|
| 896 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 897 | + $user_fav_posts = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 898 | + $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
|
|
| 899 | + $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
|
|
| 900 | + } else |
|
| 901 | + $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 902 | + |
|
| 903 | + if ($user_id == (int)get_current_user_id()) {
|
|
| 904 | + $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
|
| 905 | + } else {
|
|
| 906 | + $where .= " AND $wpdb->posts.post_status = 'publish' "; |
|
| 907 | + } |
|
| 908 | + } else {
|
|
| 909 | + $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' "; |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | - ########### WPML ########### |
|
| 913 | - if (function_exists('icl_object_id')) {
|
|
| 914 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 915 | - if ($lang_code) {
|
|
| 916 | - $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 917 | - } |
|
| 912 | + ########### WPML ########### |
|
| 913 | + if (function_exists('icl_object_id')) {
|
|
| 914 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 915 | + if ($lang_code) {
|
|
| 916 | + $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 917 | + } |
|
| 918 | 918 | |
| 919 | - } |
|
| 920 | - ########### WPML ########### |
|
| 919 | + } |
|
| 920 | + ########### WPML ########### |
|
| 921 | 921 | |
| 922 | - return $where; |
|
| 922 | + return $where; |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
@@ -934,11 +934,11 @@ discard block |
||
| 934 | 934 | */ |
| 935 | 935 | function geodir_filter_widget_join($join) |
| 936 | 936 | {
|
| 937 | - global $wp_query, $table; |
|
| 938 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 939 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 940 | - } |
|
| 941 | - return $join; |
|
| 937 | + global $wp_query, $table; |
|
| 938 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 939 | + $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 940 | + } |
|
| 941 | + return $join; |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | /** |
@@ -953,42 +953,42 @@ discard block |
||
| 953 | 953 | */ |
| 954 | 954 | function geodir_filter_widget_where($where) |
| 955 | 955 | {
|
| 956 | - global $wp_query, $table; |
|
| 957 | - if (!empty($wp_query->query['show_featured_only'])) {
|
|
| 958 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 959 | - } |
|
| 960 | - if (!empty($wp_query->query['show_special_only'])) {
|
|
| 961 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 962 | - } |
|
| 963 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 964 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 965 | - } |
|
| 966 | - if (!empty($wp_query->query['with_videos_only'])) {
|
|
| 967 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 968 | - } |
|
| 969 | - return $where; |
|
| 956 | + global $wp_query, $table; |
|
| 957 | + if (!empty($wp_query->query['show_featured_only'])) {
|
|
| 958 | + $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 959 | + } |
|
| 960 | + if (!empty($wp_query->query['show_special_only'])) {
|
|
| 961 | + $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 962 | + } |
|
| 963 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 964 | + $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 965 | + } |
|
| 966 | + if (!empty($wp_query->query['with_videos_only'])) {
|
|
| 967 | + $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 968 | + } |
|
| 969 | + return $where; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | |
| 973 | 973 | function geodir_related_posts_fields($fields) {
|
| 974 | - global $wp_query, $wpdb, $table, $post; |
|
| 974 | + global $wp_query, $wpdb, $table, $post; |
|
| 975 | 975 | |
| 976 | - $fields .= ", " . $table . ".* "; |
|
| 976 | + $fields .= ", " . $table . ".* "; |
|
| 977 | 977 | |
| 978 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 978 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 979 | 979 | |
| 980 | - $mylat = $post->post_latitude; |
|
| 981 | - $mylon = $post->post_longitude; |
|
| 980 | + $mylat = $post->post_latitude; |
|
| 981 | + $mylon = $post->post_longitude; |
|
| 982 | 982 | |
| 983 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | - return $fields; |
|
| 983 | + $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | + return $fields; |
|
| 985 | 985 | } |
| 986 | 986 | function geodir_related_posts_fields_filter($query) {
|
| 987 | - if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | - && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
|
| 989 | - && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
|
| 990 | - ) {
|
|
| 991 | - add_filter('posts_fields', 'geodir_related_posts_fields', 1);
|
|
| 992 | - } |
|
| 987 | + if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | + && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
|
| 989 | + && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
|
| 990 | + ) {
|
|
| 991 | + add_filter('posts_fields', 'geodir_related_posts_fields', 1);
|
|
| 992 | + } |
|
| 993 | 993 | } |
| 994 | 994 | add_action('pre_get_posts', 'geodir_related_posts_fields_filter', 1); |
| 995 | 995 | \ No newline at end of file |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @global string $s_A Extra parameters. |
| 66 | 66 | * @global string $s_SA Extra parameters. |
| 67 | 67 | */ |
| 68 | -function set_listing_request($query ) |
|
| 68 | +function set_listing_request($query) |
|
| 69 | 69 | {
|
| 70 | 70 | global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
| 71 | 71 | |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | } // Distance |
| 100 | 100 | |
| 101 | 101 | if (isset($_REQUEST['sgeo_lat'])) {
|
| 102 | - $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 102 | + $mylat = (float) esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | 103 | } else {
|
| 104 | - $mylat = (float)geodir_get_current_city_lat(); |
|
| 104 | + $mylat = (float) geodir_get_current_city_lat(); |
|
| 105 | 105 | } // Latatude |
| 106 | 106 | |
| 107 | 107 | if (isset($_REQUEST['sgeo_lon'])) {
|
| 108 | - $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 108 | + $mylon = (float) esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | 109 | } else {
|
| 110 | - $mylon = (float)geodir_get_current_city_lng(); |
|
| 110 | + $mylon = (float) geodir_get_current_city_lng(); |
|
| 111 | 111 | } // Distance |
| 112 | 112 | |
| 113 | 113 | if (isset($_REQUEST['snear'])) {
|
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | if ($snear == 'NEAR ME') {
|
| 122 | 122 | $ip = $_SERVER['REMOTE_ADDR']; |
| 123 | - $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 123 | + $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
|
|
| 124 | 124 | $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude])); |
| 125 | 125 | $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude])); |
| 126 | 126 | } |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | $s_AA = str_replace(" ", "", $s);
|
| 131 | 131 | $s_A = explode(",", $s_AA);
|
| 132 | 132 | $s_A = implode('","', $s_A);
|
| 133 | - $s_A = '"' . $s_A . '"'; |
|
| 133 | + $s_A = '"'.$s_A.'"'; |
|
| 134 | 134 | } else {
|
| 135 | - $s_A = '"' . $s . '"'; |
|
| 135 | + $s_A = '"'.$s.'"'; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (strstr($s, ' ')) {
|
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
| 195 | 195 | |
| 196 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 196 | + $table = $plugin_prefix.$geodir_post_type.'_detail'; |
|
| 197 | 197 | |
| 198 | 198 | add_filter('posts_fields', 'geodir_posts_fields', 1);
|
| 199 | 199 | add_filter('posts_join', 'geodir_posts_join', 1);
|
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
| 234 | 234 | |
| 235 | 235 | // Filter-Location-Manager to add location table. |
| 236 | - $fields .= ", " . $table . ".* "; |
|
| 236 | + $fields .= ", ".$table.".* "; |
|
| 237 | 237 | |
| 238 | 238 | if ($snear != '' || $gd_session->get('all_near_me')) {
|
| 239 | 239 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
@@ -243,16 +243,16 @@ discard block |
||
| 243 | 243 | $mylon = $gd_session->get('user_lon');
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 246 | + $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | global $s; |
| 250 | 250 | if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
| 251 | 251 | $keywords = explode(" ", $s);
|
| 252 | 252 | |
| 253 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | - foreach($keywords as $kkey=>$kword){
|
|
| 255 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 253 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 254 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 255 | + if (geodir_utf8_strlen($kword) <= $klimit) {
|
|
| 256 | 256 | unset($keywords[$kkey]); |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -270,24 +270,24 @@ discard block |
||
| 270 | 270 | $count = 0; |
| 271 | 271 | foreach ($keywords as $keyword) {
|
| 272 | 272 | $keyword = trim($keyword); |
| 273 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 273 | + $keyword = wp_specialchars_decode($keyword, ENT_QUOTES); |
|
| 274 | 274 | $count++; |
| 275 | 275 | if ($count < count($keywords)) {
|
| 276 | 276 | // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
| 277 | - $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " "; |
|
| 277 | + $gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ".$key." "; |
|
| 278 | 278 | } else {
|
| 279 | 279 | //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
| 280 | - $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) "; |
|
| 280 | + $gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) "; |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | - $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 283 | + $gd_titlematch_part .= "THEN 1 ELSE 0 END AS ".$part.","; |
|
| 284 | 284 | } |
| 285 | 285 | } else {
|
| 286 | 286 | $gd_titlematch_part = ""; |
| 287 | 287 | } |
| 288 | - $s = stripslashes_deep( $s ); |
|
| 289 | - $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 290 | - $fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s));
|
|
| 288 | + $s = stripslashes_deep($s); |
|
| 289 | + $s = wp_specialchars_decode($s, ENT_QUOTES); |
|
| 290 | + $fields .= $wpdb->prepare(", CASE WHEN ".$table.".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN ".$wpdb->posts.".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle,".$gd_titlematch_part." CASE WHEN ( ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s.'%', '% '.$s.'%', $s, $s.' %', '% '.$s.' %', '% '.$s));
|
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return $fields; |
@@ -316,13 +316,13 @@ discard block |
||
| 316 | 316 | $lang_code = ICL_LANGUAGE_CODE; |
| 317 | 317 | $default_lang_code = $sitepress->get_default_language(); |
| 318 | 318 | if ($lang_code) {
|
| 319 | - $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 319 | + $join .= "JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID"; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | ########### WPML ########### |
| 324 | 324 | |
| 325 | - $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 325 | + $join .= " INNER JOIN ".$table." ON (".$table.".post_id = $wpdb->posts.ID) ";
|
|
| 326 | 326 | //===old code start |
| 327 | 327 | //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
| 328 | 328 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $sort_by = 'az'; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if ($snear != '' && $sort_by!='farthest') {
|
|
| 394 | + if ($snear != '' && $sort_by != 'farthest') {
|
|
| 395 | 395 | $sort_by = 'nearest'; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -405,20 +405,20 @@ discard block |
||
| 405 | 405 | break; |
| 406 | 406 | case 'low_review': |
| 407 | 407 | case 'rating_count_asc': |
| 408 | - $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 408 | + $orderby = $table.".rating_count ASC, ".$table.".overall_rating ASC, "; |
|
| 409 | 409 | break; |
| 410 | 410 | case 'high_review': |
| 411 | 411 | case 'rating_count_desc': |
| 412 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 412 | + $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, "; |
|
| 413 | 413 | break; |
| 414 | 414 | case 'low_rating': |
| 415 | - $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 415 | + $orderby = "( ".$table.".overall_rating ) ASC, ".$table.".rating_count ASC, "; |
|
| 416 | 416 | break; |
| 417 | 417 | case 'high_rating': |
| 418 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 418 | + $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, "; |
|
| 419 | 419 | break; |
| 420 | 420 | case 'featured': |
| 421 | - $orderby = $table . ".is_featured asc, "; |
|
| 421 | + $orderby = $table.".is_featured asc, "; |
|
| 422 | 422 | break; |
| 423 | 423 | case 'nearest': |
| 424 | 424 | $orderby = " distance asc, "; |
@@ -434,10 +434,10 @@ discard block |
||
| 434 | 434 | break; |
| 435 | 435 | // sort by rating |
| 436 | 436 | case 'overall_rating_desc': |
| 437 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 437 | + $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, "; |
|
| 438 | 438 | break; |
| 439 | 439 | case 'overall_rating_asc': |
| 440 | - $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 440 | + $orderby = " ".$table.".overall_rating ASC, ".$table.".rating_count ASC, "; |
|
| 441 | 441 | break; |
| 442 | 442 | default: |
| 443 | 443 | |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | |
| 459 | 459 | if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
| 460 | 460 | $keywords = explode(" ", $s);
|
| 461 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | - foreach($keywords as $kkey=>$kword){
|
|
| 463 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 461 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 462 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 463 | + if (geodir_utf8_strlen($kword) <= $klimit) {
|
|
| 464 | 464 | unset($keywords[$kkey]); |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
| 469 | 469 | if (count($keywords) > 1) {
|
| 470 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 470 | + $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | 471 | } else {
|
| 472 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 472 | + $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | 473 | } |
| 474 | 474 | } else {
|
| 475 | 475 | if (count($keywords) > 1) {
|
| 476 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 476 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ".$orderby; |
|
| 477 | 477 | } else {
|
| 478 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 478 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ".$orderby; |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
| 492 | 492 | |
| 493 | - $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 493 | + $orderby .= $table.".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 494 | 494 | |
| 495 | 495 | return $orderby; |
| 496 | 496 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | global $wpdb; |
| 514 | 514 | |
| 515 | - if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 515 | + if ($sort_by != '' && (!is_search() || (isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear'] == '' && ($_REQUEST['s'] == '' || $_REQUEST['s'] == ' ')))) {
|
|
| 516 | 516 | |
| 517 | 517 | $sort_array = explode('_', $sort_by);
|
| 518 | 518 | |
@@ -522,31 +522,31 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
| 524 | 524 | |
| 525 | - $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 525 | + $sort_by = str_replace('_'.$order, '', $sort_by);
|
|
| 526 | 526 | |
| 527 | 527 | switch ($sort_by): |
| 528 | 528 | |
| 529 | 529 | case 'post_date': |
| 530 | 530 | case 'comment_count': |
| 531 | 531 | |
| 532 | - $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 532 | + $orderby = "$wpdb->posts.".$sort_by." ".$order.", ".$table.".overall_rating ".$order.", "; |
|
| 533 | 533 | break; |
| 534 | 534 | |
| 535 | 535 | case 'distance': |
| 536 | - $orderby = $sort_by . " " . $order . ", "; |
|
| 536 | + $orderby = $sort_by." ".$order.", "; |
|
| 537 | 537 | break; |
| 538 | 538 | |
| 539 | 539 | |
| 540 | 540 | // sort by rating |
| 541 | 541 | case 'overall_rating': |
| 542 | - $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 542 | + $orderby = " ".$table.".".$sort_by." ".$order.", ".$table.".rating_count ".$order.", "; |
|
| 543 | 543 | |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | |
| 547 | 547 | default: |
| 548 | 548 | if (geodir_column_exist($table, $sort_by)) {
|
| 549 | - $orderby = $table . "." . $sort_by . " " . $order . ", "; |
|
| 549 | + $orderby = $table.".".$sort_by." ".$order.", "; |
|
| 550 | 550 | } |
| 551 | 551 | break; |
| 552 | 552 | |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | //if (!geodir_is_page('detail'))
|
| 597 | - add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 597 | + add_filter('posts_where', 'geodir_default_where', 1); /**/
|
|
| 598 | 598 | |
| 599 | 599 | //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
| 600 | 600 | |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
| 666 | 666 | //echo '##########'.$q_post_type; |
| 667 | 667 | if ($lang_code && $q_post_type) {
|
| 668 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 668 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
|
|
| 669 | 669 | //$where .= " AND icl_t.language_code = '$lang_code' "; |
| 670 | 670 | } |
| 671 | 671 | |
@@ -732,8 +732,8 @@ discard block |
||
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $s = trim($s); |
| 735 | - $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | - $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 735 | + $s = wp_specialchars_decode($s, ENT_QUOTES); |
|
| 736 | + $s_A = wp_specialchars_decode($s_A, ENT_QUOTES); |
|
| 737 | 737 | |
| 738 | 738 | $where = ''; |
| 739 | 739 | $better_search_terms = ''; |
@@ -744,9 +744,9 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | if ($s != '') {
|
| 746 | 746 | $keywords = explode(" ", $s);
|
| 747 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | - foreach($keywords as $kkey=>$kword){
|
|
| 749 | - if(geodir_utf8_strlen($kword)<=$klimit){
|
|
| 747 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 748 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 749 | + if (geodir_utf8_strlen($kword) <= $klimit) {
|
|
| 750 | 750 | unset($keywords[$kkey]); |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | if (!empty($keywords)) {
|
| 756 | 756 | foreach ($keywords as $keyword) {
|
| 757 | 757 | $keyword = trim($keyword); |
| 758 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 758 | + $keyword = wp_specialchars_decode($keyword, ENT_QUOTES); |
|
| 759 | 759 | if ($keyword != '') {
|
| 760 | 760 | /** |
| 761 | 761 | * Filter the search query keywords SQL. |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * @param array $keywords The array of keywords for the query. |
| 767 | 767 | * @param string $keyword The single keyword being searched. |
| 768 | 768 | */ |
| 769 | - $better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
|
|
| 769 | + $better_search_terms .= apply_filters("geodir_search_better_search_terms", ' OR ( '.$wpdb->posts.'.post_title LIKE "'.$keyword.'" OR '.$wpdb->posts.'.post_title LIKE "'.$keyword.'%" OR '.$wpdb->posts.'.post_title LIKE "% '.$keyword.'%" )', $keywords, $keyword);
|
|
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | } |
@@ -774,10 +774,10 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | /* get taxonomy */ |
| 776 | 776 | $taxonomies = geodir_get_taxonomies($post_types, true); |
| 777 | - if($taxonomies) {
|
|
| 777 | + if ($taxonomies) {
|
|
| 778 | 778 | $taxonomies = implode("','", $taxonomies);
|
| 779 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | - }else{$taxonomies='';}
|
|
| 779 | + $taxonomies = "'".$taxonomies."'"; |
|
| 780 | + } else {$taxonomies = ''; }
|
|
| 781 | 781 | |
| 782 | 782 | $content_where = $terms_where = ''; |
| 783 | 783 | if ($s != '') {
|
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | * @package GeoDirectory |
| 789 | 789 | * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
| 790 | 790 | */ |
| 791 | - $content_where = apply_filters("geodir_search_content_where"," OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
|
| 791 | + $content_where = apply_filters("geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
|
| 792 | 792 | /** |
| 793 | 793 | * Filter the search query term values. |
| 794 | 794 | * |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @package GeoDirectory |
| 797 | 797 | * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
| 798 | 798 | */ |
| 799 | - $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 799 | + $terms_where = apply_filters("geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | if ($snear != '') {
|
@@ -831,12 +831,12 @@ discard block |
||
| 831 | 831 | ) |
| 832 | 832 | AND $wpdb->posts.post_type in ('{$post_types}')
|
| 833 | 833 | AND ($wpdb->posts.post_status = 'publish') |
| 834 | - AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 ) |
|
| 835 | - AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) "; |
|
| 834 | + AND ( ".$table.".post_latitude between $rlat1 and $rlat2 ) |
|
| 835 | + AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) "; |
|
| 836 | 836 | |
| 837 | 837 | if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
| 838 | 838 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
| 839 | - $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 839 | + $where .= " AND CONVERT((".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= ".$dist;
|
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | } else {
|
@@ -857,11 +857,11 @@ discard block |
||
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | ########### WPML ########### |
| 860 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 860 | + if (function_exists('icl_object_id')) {
|
|
| 861 | 861 | $lang_code = ICL_LANGUAGE_CODE; |
| 862 | 862 | |
| 863 | 863 | if ($lang_code && $post_types) {
|
| 864 | - $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 864 | + $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
|
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | ########### WPML ########### |
@@ -884,10 +884,10 @@ discard block |
||
| 884 | 884 | global $wpdb, $geodir_post_type, $table, $curr; |
| 885 | 885 | |
| 886 | 886 | $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
| 887 | - $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 887 | + $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0; |
|
| 888 | 888 | |
| 889 | 889 | if (isset($_REQUEST['stype'])) {
|
| 890 | - $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 890 | + $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
|
|
| 891 | 891 | } else {
|
| 892 | 892 | $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
| 893 | 893 | } |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | } else |
| 901 | 901 | $where .= " AND $wpdb->posts.post_author = $user_id"; |
| 902 | 902 | |
| 903 | - if ($user_id == (int)get_current_user_id()) {
|
|
| 903 | + if ($user_id == (int) get_current_user_id()) {
|
|
| 904 | 904 | $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
| 905 | 905 | } else {
|
| 906 | 906 | $where .= " AND $wpdb->posts.post_status = 'publish' "; |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | if (function_exists('icl_object_id')) {
|
| 914 | 914 | $lang_code = ICL_LANGUAGE_CODE; |
| 915 | 915 | if ($lang_code) {
|
| 916 | - $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 916 | + $where .= " AND icl_t.language_code='".$lang_code."' "; |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | {
|
| 937 | 937 | global $wp_query, $table; |
| 938 | 938 | if (!empty($wp_query->query['with_pics_only'])) {
|
| 939 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 939 | + $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )"; |
|
| 940 | 940 | } |
| 941 | 941 | return $join; |
| 942 | 942 | } |
@@ -955,16 +955,16 @@ discard block |
||
| 955 | 955 | {
|
| 956 | 956 | global $wp_query, $table; |
| 957 | 957 | if (!empty($wp_query->query['show_featured_only'])) {
|
| 958 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 958 | + $where .= " AND ".$table.".is_featured = '1'"; |
|
| 959 | 959 | } |
| 960 | 960 | if (!empty($wp_query->query['show_special_only'])) {
|
| 961 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 961 | + $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )"; |
|
| 962 | 962 | } |
| 963 | 963 | if (!empty($wp_query->query['with_pics_only'])) {
|
| 964 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 964 | + $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id"; |
|
| 965 | 965 | } |
| 966 | 966 | if (!empty($wp_query->query['with_videos_only'])) {
|
| 967 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 967 | + $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )"; |
|
| 968 | 968 | } |
| 969 | 969 | return $where; |
| 970 | 970 | } |
@@ -973,18 +973,18 @@ discard block |
||
| 973 | 973 | function geodir_related_posts_fields($fields) {
|
| 974 | 974 | global $wp_query, $wpdb, $table, $post; |
| 975 | 975 | |
| 976 | - $fields .= ", " . $table . ".* "; |
|
| 976 | + $fields .= ", ".$table.".* "; |
|
| 977 | 977 | |
| 978 | 978 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
| 979 | 979 | |
| 980 | 980 | $mylat = $post->post_latitude; |
| 981 | 981 | $mylon = $post->post_longitude; |
| 982 | 982 | |
| 983 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 983 | + $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | 984 | return $fields; |
| 985 | 985 | } |
| 986 | 986 | function geodir_related_posts_fields_filter($query) {
|
| 987 | - if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 987 | + if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | 988 | && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
| 989 | 989 | && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
| 990 | 990 | ) {
|