@@ -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 |
@@ -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 | } |
@@ -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 |
@@ -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) |
@@ -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 |
@@ -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 |
@@ -13,125 +13,125 @@ discard block |
||
| 13 | 13 | * @package GeoDirectory |
| 14 | 14 | */ |
| 15 | 15 | function geodir_deactivation() {
|
| 16 | - // Update installed variable |
|
| 17 | - update_option("geodir_installed", 0);
|
|
| 16 | + // Update installed variable |
|
| 17 | + update_option("geodir_installed", 0);
|
|
| 18 | 18 | |
| 19 | - // Remove rewrite rules and then recreate rewrite rules. |
|
| 20 | - flush_rewrite_rules(); |
|
| 19 | + // Remove rewrite rules and then recreate rewrite rules. |
|
| 20 | + flush_rewrite_rules(); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!function_exists('geodir_admin_styles')) {
|
| 24 | - /** |
|
| 25 | - * Enqueue Admin Styles. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - * @package GeoDirectory |
|
| 29 | - */ |
|
| 30 | - function geodir_admin_styles() {
|
|
| 31 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 32 | - wp_enqueue_style('geodirectory-admin-css');
|
|
| 24 | + /** |
|
| 25 | + * Enqueue Admin Styles. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + * @package GeoDirectory |
|
| 29 | + */ |
|
| 30 | + function geodir_admin_styles() {
|
|
| 31 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 32 | + wp_enqueue_style('geodirectory-admin-css');
|
|
| 33 | 33 | |
| 34 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 35 | - wp_enqueue_style('geodirectory-frontend-style');
|
|
| 34 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 35 | + wp_enqueue_style('geodirectory-frontend-style');
|
|
| 36 | 36 | |
| 37 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 38 | - wp_enqueue_style('geodir-chosen-style');
|
|
| 37 | + wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 38 | + wp_enqueue_style('geodir-chosen-style');
|
|
| 39 | 39 | |
| 40 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 41 | - wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 40 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 41 | + wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 42 | 42 | |
| 43 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 44 | - wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 43 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 44 | + wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 45 | 45 | |
| 46 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 47 | - wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 46 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 47 | + wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | - wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 49 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | + wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 51 | 51 | |
| 52 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | - wp_enqueue_style('geodir-rating-style');
|
|
| 52 | + wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | + wp_enqueue_style('geodir-rating-style');
|
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | - wp_enqueue_style('geodir-rtl-style');
|
|
| 57 | - } |
|
| 55 | + wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | + wp_enqueue_style('geodir-rtl-style');
|
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!function_exists('geodir_admin_styles_req')) {
|
| 61 | - /** |
|
| 62 | - * Loads stylesheets from CDN. |
|
| 63 | - * |
|
| 64 | - * @since 1.0.0 |
|
| 65 | - * @package GeoDirectory |
|
| 66 | - */ |
|
| 67 | - function geodir_admin_styles_req() |
|
| 68 | - {
|
|
| 61 | + /** |
|
| 62 | + * Loads stylesheets from CDN. |
|
| 63 | + * |
|
| 64 | + * @since 1.0.0 |
|
| 65 | + * @package GeoDirectory |
|
| 66 | + */ |
|
| 67 | + function geodir_admin_styles_req() |
|
| 68 | + {
|
|
| 69 | 69 | |
| 70 | - wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | - wp_enqueue_style('font-awesome');
|
|
| 70 | + wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | + wp_enqueue_style('font-awesome');
|
|
| 72 | 72 | |
| 73 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 74 | - wp_enqueue_script('geodirectory-admin');
|
|
| 73 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 74 | + wp_enqueue_script('geodirectory-admin');
|
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (!function_exists('geodir_admin_scripts')) {
|
| 80 | - /** |
|
| 81 | - * Enqueue Admin Scripts. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * @package GeoDirectory |
|
| 85 | - */ |
|
| 86 | - function geodir_admin_scripts() |
|
| 87 | - {
|
|
| 88 | - $geodir_map_name = geodir_map_name(); |
|
| 80 | + /** |
|
| 81 | + * Enqueue Admin Scripts. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * @package GeoDirectory |
|
| 85 | + */ |
|
| 86 | + function geodir_admin_scripts() |
|
| 87 | + {
|
|
| 88 | + $geodir_map_name = geodir_map_name(); |
|
| 89 | 89 | |
| 90 | - wp_enqueue_script('jquery');
|
|
| 90 | + wp_enqueue_script('jquery');
|
|
| 91 | 91 | |
| 92 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 92 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 93 | 93 | |
| 94 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 95 | - wp_enqueue_script('chosen');
|
|
| 94 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 95 | + wp_enqueue_script('chosen');
|
|
| 96 | 96 | |
| 97 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 98 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 97 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 98 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 99 | 99 | |
| 100 | - if (isset($_REQUEST['listing_type'])) {
|
|
| 101 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 102 | - } |
|
| 100 | + if (isset($_REQUEST['listing_type'])) {
|
|
| 101 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 105 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 104 | + wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 105 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 106 | 106 | |
| 107 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 107 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 108 | 108 | |
| 109 | - if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 110 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 111 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 112 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
| 113 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 114 | - wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 115 | - } |
|
| 109 | + if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 110 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 111 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 112 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
| 113 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 114 | + wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if ($geodir_map_name == 'osm') {
|
|
| 118 | - // Leaflet OpenStreetMap |
|
| 119 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 120 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 117 | + if ($geodir_map_name == 'osm') {
|
|
| 118 | + // Leaflet OpenStreetMap |
|
| 119 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 121 | 121 | |
| 122 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 123 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 122 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 123 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 124 | 124 | |
| 125 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 126 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 127 | - } |
|
| 128 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 125 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 126 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 127 | + } |
|
| 128 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 129 | 129 | |
| 130 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 131 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 130 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 131 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 132 | 132 | |
| 133 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 133 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 135 | 135 | |
| 136 | 136 | // font awesome rating script |
| 137 | 137 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -142,167 +142,167 @@ discard block |
||
| 142 | 142 | wp_enqueue_script('geodir-jRating-js');
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 146 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 147 | - |
|
| 148 | - |
|
| 149 | - // SCRIPT FOR UPLOAD |
|
| 150 | - wp_enqueue_script('plupload-all');
|
|
| 151 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 152 | - |
|
| 153 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 155 | - |
|
| 156 | - // SCRIPT FOR UPLOAD END |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - // place js config array for plupload |
|
| 160 | - $plupload_init = array( |
|
| 161 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 162 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 163 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 164 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 165 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 166 | - 'multiple_queues' => true, |
|
| 167 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 168 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 169 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 170 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 171 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 172 | - 'multipart' => true, |
|
| 173 | - 'urlstream_upload' => true, |
|
| 174 | - 'multi_selection' => false, // will be added per uploader |
|
| 175 | - // additional post data to send to our ajax hook |
|
| 176 | - 'multipart_params' => array( |
|
| 177 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 178 | - 'action' => 'plupload_action', // the ajax action name |
|
| 179 | - 'imgid' => 0 // will be added per uploader |
|
| 180 | - ) |
|
| 181 | - ); |
|
| 182 | - $base_plupload_config = json_encode($plupload_init); |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - $thumb_img_arr = array(); |
|
| 186 | - |
|
| 187 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 188 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 189 | - |
|
| 190 | - $totImg = ''; |
|
| 191 | - $image_limit = ''; |
|
| 192 | - if (!empty($thumb_img_arr)) {
|
|
| 193 | - $totImg = count($thumb_img_arr); |
|
| 194 | - } |
|
| 145 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 146 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 147 | + |
|
| 148 | + |
|
| 149 | + // SCRIPT FOR UPLOAD |
|
| 150 | + wp_enqueue_script('plupload-all');
|
|
| 151 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 152 | + |
|
| 153 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 155 | + |
|
| 156 | + // SCRIPT FOR UPLOAD END |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + // place js config array for plupload |
|
| 160 | + $plupload_init = array( |
|
| 161 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 162 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 163 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 164 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 165 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 166 | + 'multiple_queues' => true, |
|
| 167 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 168 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 169 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 170 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 171 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 172 | + 'multipart' => true, |
|
| 173 | + 'urlstream_upload' => true, |
|
| 174 | + 'multi_selection' => false, // will be added per uploader |
|
| 175 | + // additional post data to send to our ajax hook |
|
| 176 | + 'multipart_params' => array( |
|
| 177 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 178 | + 'action' => 'plupload_action', // the ajax action name |
|
| 179 | + 'imgid' => 0 // will be added per uploader |
|
| 180 | + ) |
|
| 181 | + ); |
|
| 182 | + $base_plupload_config = json_encode($plupload_init); |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + $thumb_img_arr = array(); |
|
| 186 | + |
|
| 187 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 188 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 189 | + |
|
| 190 | + $totImg = ''; |
|
| 191 | + $image_limit = ''; |
|
| 192 | + if (!empty($thumb_img_arr)) {
|
|
| 193 | + $totImg = count($thumb_img_arr); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 197 | - 'totalImg' => $totImg, |
|
| 198 | - 'image_limit' => $image_limit, |
|
| 199 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 196 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 197 | + 'totalImg' => $totImg, |
|
| 198 | + 'image_limit' => $image_limit, |
|
| 199 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 200 | 200 | |
| 201 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 201 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 202 | 202 | |
| 203 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 204 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 203 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 204 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 205 | 205 | |
| 206 | 206 | |
| 207 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 208 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 207 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 208 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 209 | 209 | |
| 210 | - wp_enqueue_style('farbtastic');
|
|
| 211 | - wp_enqueue_script('farbtastic');
|
|
| 210 | + wp_enqueue_style('farbtastic');
|
|
| 211 | + wp_enqueue_script('farbtastic');
|
|
| 212 | 212 | |
| 213 | - $screen = get_current_screen(); |
|
| 214 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 215 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 216 | - } |
|
| 213 | + $screen = get_current_screen(); |
|
| 214 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 215 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 219 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 218 | + $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 219 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if (!function_exists('geodir_admin_menu')) {
|
| 225 | - /** |
|
| 226 | - * Admin Menus |
|
| 227 | - * |
|
| 228 | - * Sets up the admin menus in wordpress. |
|
| 229 | - * |
|
| 230 | - * @since 1.0.0 |
|
| 231 | - * @package GeoDirectory |
|
| 232 | - * @global array $menu Menu array. |
|
| 233 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 234 | - */ |
|
| 235 | - function geodir_admin_menu() |
|
| 236 | - {
|
|
| 237 | - global $menu, $geodirectory; |
|
| 225 | + /** |
|
| 226 | + * Admin Menus |
|
| 227 | + * |
|
| 228 | + * Sets up the admin menus in wordpress. |
|
| 229 | + * |
|
| 230 | + * @since 1.0.0 |
|
| 231 | + * @package GeoDirectory |
|
| 232 | + * @global array $menu Menu array. |
|
| 233 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 234 | + */ |
|
| 235 | + function geodir_admin_menu() |
|
| 236 | + {
|
|
| 237 | + global $menu, $geodirectory; |
|
| 238 | 238 | |
| 239 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 239 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 240 | 240 | |
| 241 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 241 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | - } |
|
| 244 | + } |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if (!function_exists('geodir_admin_menu_order')) {
|
| 248 | - /** |
|
| 249 | - * Order admin menus. |
|
| 250 | - * |
|
| 251 | - * @since 1.0.0 |
|
| 252 | - * @package GeoDirectory |
|
| 253 | - * @param array $menu_order Menu order array. |
|
| 254 | - * @return array Modified menu order array. |
|
| 255 | - */ |
|
| 256 | - function geodir_admin_menu_order($menu_order) |
|
| 257 | - {
|
|
| 258 | - |
|
| 259 | - // Initialize our custom order array |
|
| 260 | - $geodir_menu_order = array(); |
|
| 261 | - |
|
| 262 | - // Get the index of our custom separator |
|
| 263 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 264 | - |
|
| 265 | - // Get index of posttype menu |
|
| 266 | - $post_types = geodir_get_posttypes(); |
|
| 267 | - |
|
| 268 | - // Loop through menu order and do some rearranging |
|
| 269 | - foreach ($menu_order as $index => $item) : |
|
| 270 | - |
|
| 271 | - if ((('geodirectory') == $item)) :
|
|
| 272 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 273 | - if (!empty($post_types)) {
|
|
| 274 | - foreach ($post_types as $post_type) {
|
|
| 275 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - $geodir_menu_order[] = $item; |
|
| 248 | + /** |
|
| 249 | + * Order admin menus. |
|
| 250 | + * |
|
| 251 | + * @since 1.0.0 |
|
| 252 | + * @package GeoDirectory |
|
| 253 | + * @param array $menu_order Menu order array. |
|
| 254 | + * @return array Modified menu order array. |
|
| 255 | + */ |
|
| 256 | + function geodir_admin_menu_order($menu_order) |
|
| 257 | + {
|
|
| 279 | 258 | |
| 280 | - unset($menu_order[$geodir_separator]); |
|
| 281 | - //unset( $menu_order[$geodir_places] ); |
|
| 282 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 283 | - $geodir_menu_order[] = $item; |
|
| 284 | - endif; |
|
| 259 | + // Initialize our custom order array |
|
| 260 | + $geodir_menu_order = array(); |
|
| 285 | 261 | |
| 286 | - endforeach; |
|
| 262 | + // Get the index of our custom separator |
|
| 263 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 287 | 264 | |
| 288 | - // Return order |
|
| 289 | - return $geodir_menu_order; |
|
| 290 | - } |
|
| 265 | + // Get index of posttype menu |
|
| 266 | + $post_types = geodir_get_posttypes(); |
|
| 267 | + |
|
| 268 | + // Loop through menu order and do some rearranging |
|
| 269 | + foreach ($menu_order as $index => $item) : |
|
| 270 | + |
|
| 271 | + if ((('geodirectory') == $item)) :
|
|
| 272 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 273 | + if (!empty($post_types)) {
|
|
| 274 | + foreach ($post_types as $post_type) {
|
|
| 275 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + $geodir_menu_order[] = $item; |
|
| 279 | + |
|
| 280 | + unset($menu_order[$geodir_separator]); |
|
| 281 | + //unset( $menu_order[$geodir_places] ); |
|
| 282 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 283 | + $geodir_menu_order[] = $item; |
|
| 284 | + endif; |
|
| 285 | + |
|
| 286 | + endforeach; |
|
| 287 | + |
|
| 288 | + // Return order |
|
| 289 | + return $geodir_menu_order; |
|
| 290 | + } |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 294 | - /** |
|
| 295 | - * Enables custom menu order. |
|
| 296 | - * |
|
| 297 | - * @since 1.0.0 |
|
| 298 | - * @package GeoDirectory |
|
| 299 | - * @return bool |
|
| 300 | - */ |
|
| 301 | - function geodir_admin_custom_menu_order() |
|
| 302 | - {
|
|
| 303 | - if (!current_user_can('manage_options')) return false;
|
|
| 304 | - return true; |
|
| 305 | - } |
|
| 294 | + /** |
|
| 295 | + * Enables custom menu order. |
|
| 296 | + * |
|
| 297 | + * @since 1.0.0 |
|
| 298 | + * @package GeoDirectory |
|
| 299 | + * @return bool |
|
| 300 | + */ |
|
| 301 | + function geodir_admin_custom_menu_order() |
|
| 302 | + {
|
|
| 303 | + if (!current_user_can('manage_options')) return false;
|
|
| 304 | + return true; |
|
| 305 | + } |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -313,51 +313,51 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function geodir_before_admin_panel() |
| 315 | 315 | {
|
| 316 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 317 | - echo '<div id="message" class="updated fade"> |
|
| 316 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 317 | + echo '<div id="message" class="updated fade"> |
|
| 318 | 318 | <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
|
| 319 | 319 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 320 | 320 | </div>'; |
| 321 | 321 | |
| 322 | - } |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 325 | - switch ($_REQUEST['msg']) {
|
|
| 326 | - case 'success': |
|
| 327 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 328 | - flush_rewrite_rules(false); |
|
| 324 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 325 | + switch ($_REQUEST['msg']) {
|
|
| 326 | + case 'success': |
|
| 327 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 328 | + flush_rewrite_rules(false); |
|
| 329 | 329 | |
| 330 | - break; |
|
| 330 | + break; |
|
| 331 | 331 | case 'fail': |
| 332 | 332 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 333 | 333 | |
| 334 | 334 | if ($gderr == 21) |
| 335 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 335 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 336 | 336 | else |
| 337 | 337 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 338 | - break; |
|
| 339 | - } |
|
| 340 | - } |
|
| 338 | + break; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - $geodir_load_map = get_option('geodir_load_map');
|
|
| 343 | - $need_map_key = false; |
|
| 344 | - if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 345 | - $need_map_key = true; |
|
| 346 | - } |
|
| 342 | + $geodir_load_map = get_option('geodir_load_map');
|
|
| 343 | + $need_map_key = false; |
|
| 344 | + if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 345 | + $need_map_key = true; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 349 | - echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 350 | - } |
|
| 348 | + if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 349 | + echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - if (!geodir_is_default_location_set()) {
|
|
| 353 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 352 | + if (!geodir_is_default_location_set()) {
|
|
| 353 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 354 | 354 | |
| 355 | - } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - if (!function_exists('curl_init')) {
|
|
| 358 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 357 | + if (!function_exists('curl_init')) {
|
|
| 358 | + echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 359 | 359 | |
| 360 | - } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | 362 | |
| 363 | 363 | |
@@ -374,19 +374,19 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function geodir_handle_option_form_submit($current_tab) |
| 376 | 376 | {
|
| 377 | - global $geodir_settings; |
|
| 378 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 379 | - /** |
|
| 380 | - * Contains settings array for current tab. |
|
| 381 | - * |
|
| 382 | - * @since 1.0.0 |
|
| 383 | - * @package GeoDirectory |
|
| 384 | - */ |
|
| 385 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 386 | - } |
|
| 387 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 388 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 389 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 377 | + global $geodir_settings; |
|
| 378 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 379 | + /** |
|
| 380 | + * Contains settings array for current tab. |
|
| 381 | + * |
|
| 382 | + * @since 1.0.0 |
|
| 383 | + * @package GeoDirectory |
|
| 384 | + */ |
|
| 385 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 386 | + } |
|
| 387 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 388 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 389 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * Fires before updating geodirectory admin settings. |
@@ -398,38 +398,38 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 400 | 400 | |
| 401 | - if (!empty($geodir_settings[$current_tab])) |
|
| 402 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 401 | + if (!empty($geodir_settings[$current_tab])) |
|
| 402 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 403 | 403 | |
| 404 | - /** |
|
| 405 | - * Called after GeoDirectory options settings are updated. |
|
| 406 | - * |
|
| 407 | - * @since 1.0.0 |
|
| 408 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 409 | - * @see 'geodir_before_update_options' |
|
| 410 | - */ |
|
| 411 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 404 | + /** |
|
| 405 | + * Called after GeoDirectory options settings are updated. |
|
| 406 | + * |
|
| 407 | + * @since 1.0.0 |
|
| 408 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 409 | + * @see 'geodir_before_update_options' |
|
| 410 | + */ |
|
| 411 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Called after GeoDirectory options settings are updated. |
|
| 415 | - * |
|
| 416 | - * Provides tab specific settings. |
|
| 417 | - * |
|
| 418 | - * @since 1.0.0 |
|
| 419 | - * @param string $current_tab The current settings tab name. |
|
| 420 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 421 | - */ |
|
| 422 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 413 | + /** |
|
| 414 | + * Called after GeoDirectory options settings are updated. |
|
| 415 | + * |
|
| 416 | + * Provides tab specific settings. |
|
| 417 | + * |
|
| 418 | + * @since 1.0.0 |
|
| 419 | + * @param string $current_tab The current settings tab name. |
|
| 420 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 421 | + */ |
|
| 422 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 423 | 423 | |
| 424 | - flush_rewrite_rules(false); |
|
| 424 | + flush_rewrite_rules(false); |
|
| 425 | 425 | |
| 426 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 426 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 427 | 427 | |
| 428 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 428 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 429 | 429 | |
| 430 | - wp_redirect($redirect_url); |
|
| 431 | - exit(); |
|
| 432 | - endif; |
|
| 430 | + wp_redirect($redirect_url); |
|
| 431 | + exit(); |
|
| 432 | + endif; |
|
| 433 | 433 | |
| 434 | 434 | |
| 435 | 435 | } |
@@ -447,144 +447,144 @@ discard block |
||
| 447 | 447 | * @return bool Returns true if saved. |
| 448 | 448 | */ |
| 449 | 449 | function geodir_update_options($options, $dummy = false) {
|
| 450 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 450 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 451 | 451 | |
| 452 | - foreach ($options as $value) {
|
|
| 453 | - if ($dummy && isset($value['std'])) |
|
| 454 | - $_POST[$value['id']] = $value['std']; |
|
| 452 | + foreach ($options as $value) {
|
|
| 453 | + if ($dummy && isset($value['std'])) |
|
| 454 | + $_POST[$value['id']] = $value['std']; |
|
| 455 | 455 | |
| 456 | 456 | |
| 457 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 457 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 458 | 458 | |
| 459 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 460 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 461 | - } else {
|
|
| 462 | - update_option($value['id'], 0); |
|
| 463 | - } |
|
| 459 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 460 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 461 | + } else {
|
|
| 462 | + update_option($value['id'], 0); |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 465 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 466 | 466 | |
| 467 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 468 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 469 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 470 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 471 | - update_option($value['id'] . '_crop', 1); |
|
| 472 | - else : |
|
| 473 | - update_option($value['id'] . '_crop', 0); |
|
| 474 | - endif; |
|
| 475 | - } else {
|
|
| 476 | - update_option($value['id'] . '_width', $value['std']); |
|
| 477 | - update_option($value['id'] . '_height', $value['std']); |
|
| 478 | - update_option($value['id'] . '_crop', 1); |
|
| 479 | - } |
|
| 467 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 468 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 469 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 470 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 471 | + update_option($value['id'] . '_crop', 1); |
|
| 472 | + else : |
|
| 473 | + update_option($value['id'] . '_crop', 0); |
|
| 474 | + endif; |
|
| 475 | + } else {
|
|
| 476 | + update_option($value['id'] . '_width', $value['std']); |
|
| 477 | + update_option($value['id'] . '_height', $value['std']); |
|
| 478 | + update_option($value['id'] . '_crop', 1); |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 482 | - $post_types = array(); |
|
| 483 | - $categories = array(); |
|
| 481 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 482 | + $post_types = array(); |
|
| 483 | + $categories = array(); |
|
| 484 | 484 | |
| 485 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 486 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 487 | - $post_types[] = $post_type; |
|
| 488 | - endforeach; |
|
| 489 | - endif; |
|
| 485 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 486 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 487 | + $post_types[] = $post_type; |
|
| 488 | + endforeach; |
|
| 489 | + endif; |
|
| 490 | 490 | |
| 491 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 491 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 492 | 492 | |
| 493 | - if (!empty($_POST['post_category'])) : |
|
| 494 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 495 | - $categories[$texonomy] = array(); |
|
| 496 | - foreach ($cat_arr as $category) : |
|
| 497 | - $categories[$texonomy][] = $category; |
|
| 498 | - endforeach; |
|
| 499 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 500 | - endforeach; |
|
| 501 | - endif; |
|
| 502 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 503 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 504 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 493 | + if (!empty($_POST['post_category'])) : |
|
| 494 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 495 | + $categories[$texonomy] = array(); |
|
| 496 | + foreach ($cat_arr as $category) : |
|
| 497 | + $categories[$texonomy][] = $category; |
|
| 498 | + endforeach; |
|
| 499 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 500 | + endforeach; |
|
| 501 | + endif; |
|
| 502 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 503 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 504 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 505 | 505 | |
| 506 | 506 | |
| 507 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 508 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 509 | - endif; |
|
| 507 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 508 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 509 | + endif; |
|
| 510 | 510 | |
| 511 | 511 | |
| 512 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 513 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 514 | - endif; |
|
| 512 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 513 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 514 | + endif; |
|
| 515 | 515 | |
| 516 | 516 | |
| 517 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 517 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 518 | 518 | |
| 519 | 519 | |
| 520 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 520 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 521 | 521 | |
| 522 | - if (get_option($value['id'])) {
|
|
| 523 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 524 | - $noimg_name = end($image_name_arr); |
|
| 525 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 526 | - if (file_exists($img_path)) |
|
| 527 | - unlink($img_path); |
|
| 528 | - } |
|
| 522 | + if (get_option($value['id'])) {
|
|
| 523 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 524 | + $noimg_name = end($image_name_arr); |
|
| 525 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 526 | + if (file_exists($img_path)) |
|
| 527 | + unlink($img_path); |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - update_option($value['id'], ''); |
|
| 531 | - } |
|
| 530 | + update_option($value['id'], ''); |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 534 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 535 | - |
|
| 536 | - if (!empty($filename)): |
|
| 537 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 538 | - $uplaods = array(); |
|
| 539 | - |
|
| 540 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 541 | - if ($key == 'name'): |
|
| 542 | - $uplaods[$key] = $filename; |
|
| 543 | - else : |
|
| 544 | - $uplaods[$key] = $uplaod; |
|
| 545 | - endif; |
|
| 546 | - endforeach; |
|
| 547 | - |
|
| 548 | - $uploads = wp_upload_dir(); |
|
| 549 | - |
|
| 550 | - if (get_option($value['id'])) {
|
|
| 551 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 552 | - $noimg_name = end($image_name_arr); |
|
| 553 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 554 | - if (file_exists($img_path)) |
|
| 555 | - unlink($img_path); |
|
| 556 | - } |
|
| 533 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 534 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 535 | + |
|
| 536 | + if (!empty($filename)): |
|
| 537 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 538 | + $uplaods = array(); |
|
| 539 | + |
|
| 540 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 541 | + if ($key == 'name'): |
|
| 542 | + $uplaods[$key] = $filename; |
|
| 543 | + else : |
|
| 544 | + $uplaods[$key] = $uplaod; |
|
| 545 | + endif; |
|
| 546 | + endforeach; |
|
| 547 | + |
|
| 548 | + $uploads = wp_upload_dir(); |
|
| 549 | + |
|
| 550 | + if (get_option($value['id'])) {
|
|
| 551 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 552 | + $noimg_name = end($image_name_arr); |
|
| 553 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 554 | + if (file_exists($img_path)) |
|
| 555 | + unlink($img_path); |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | - $upload_overrides = array('test_form' => false);
|
|
| 559 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 558 | + $upload_overrides = array('test_form' => false);
|
|
| 559 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 560 | 560 | |
| 561 | - update_option($value['id'], $movefile['url']); |
|
| 561 | + update_option($value['id'], $movefile['url']); |
|
| 562 | 562 | |
| 563 | - endif; |
|
| 563 | + endif; |
|
| 564 | 564 | |
| 565 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 566 | - update_option($value['id'], $value['value']); |
|
| 567 | - endif; |
|
| 565 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 566 | + update_option($value['id'], $value['value']); |
|
| 567 | + endif; |
|
| 568 | 568 | |
| 569 | 569 | |
| 570 | - else : |
|
| 571 | - // same menu setting per theme. |
|
| 572 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 573 | - $theme = wp_get_theme(); |
|
| 574 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 575 | - } |
|
| 570 | + else : |
|
| 571 | + // same menu setting per theme. |
|
| 572 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 573 | + $theme = wp_get_theme(); |
|
| 574 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 578 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 579 | - } else {
|
|
| 580 | - delete_option($value['id']); |
|
| 581 | - } |
|
| 577 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 578 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 579 | + } else {
|
|
| 580 | + delete_option($value['id']); |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | - endif; |
|
| 584 | - } |
|
| 585 | - if ($dummy) |
|
| 586 | - $_POST = array(); |
|
| 587 | - return true; |
|
| 583 | + endif; |
|
| 584 | + } |
|
| 585 | + if ($dummy) |
|
| 586 | + $_POST = array(); |
|
| 587 | + return true; |
|
| 588 | 588 | |
| 589 | 589 | } |
| 590 | 590 | |
@@ -633,33 +633,33 @@ discard block |
||
| 633 | 633 | function places_custom_fields_tab($tabs) |
| 634 | 634 | {
|
| 635 | 635 | |
| 636 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 636 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 637 | 637 | |
| 638 | - if (!empty($geodir_post_types)) {
|
|
| 638 | + if (!empty($geodir_post_types)) {
|
|
| 639 | 639 | |
| 640 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 640 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 641 | 641 | |
| 642 | - $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 642 | + $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 643 | 643 | |
| 644 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 645 | - 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 646 | - 'subtabs' => array( |
|
| 647 | - array('subtab' => 'custom_fields',
|
|
| 648 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 649 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 650 | - array('subtab' => 'sorting_options',
|
|
| 651 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 652 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 653 | - ), |
|
| 654 | - 'tab_index' => 9, |
|
| 655 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 656 | - ); |
|
| 644 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 645 | + 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 646 | + 'subtabs' => array( |
|
| 647 | + array('subtab' => 'custom_fields',
|
|
| 648 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 649 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 650 | + array('subtab' => 'sorting_options',
|
|
| 651 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 652 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 653 | + ), |
|
| 654 | + 'tab_index' => 9, |
|
| 655 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 656 | + ); |
|
| 657 | 657 | |
| 658 | - endforeach; |
|
| 658 | + endforeach; |
|
| 659 | 659 | |
| 660 | - } |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | - return $tabs; |
|
| 662 | + return $tabs; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
@@ -675,9 +675,9 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | function geodir_tools_setting_tab($tabs) |
| 677 | 677 | {
|
| 678 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 679 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 680 | - return $tabs; |
|
| 678 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 679 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 680 | + return $tabs; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | */ |
| 693 | 693 | function geodir_compatibility_setting_tab($tabs) |
| 694 | 694 | {
|
| 695 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 696 | - return $tabs; |
|
| 695 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 696 | + return $tabs; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -709,144 +709,144 @@ discard block |
||
| 709 | 709 | */ |
| 710 | 710 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 711 | 711 | {
|
| 712 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 713 | - return $tabs; |
|
| 712 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 713 | + return $tabs; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
| 717 | 717 | if (!function_exists('geodir_edit_post_columns')) {
|
| 718 | - /** |
|
| 719 | - * Modify admin post listing page columns. |
|
| 720 | - * |
|
| 721 | - * @since 1.0.0 |
|
| 722 | - * @package GeoDirectory |
|
| 723 | - * @param array $columns The column array. |
|
| 724 | - * @return array Altered column array. |
|
| 725 | - */ |
|
| 726 | - function geodir_edit_post_columns($columns) |
|
| 727 | - {
|
|
| 728 | - |
|
| 729 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 730 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 731 | - |
|
| 732 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 733 | - {
|
|
| 734 | - $offset = 0; // should we prepend $array with $data? |
|
| 735 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 736 | - } |
|
| 718 | + /** |
|
| 719 | + * Modify admin post listing page columns. |
|
| 720 | + * |
|
| 721 | + * @since 1.0.0 |
|
| 722 | + * @package GeoDirectory |
|
| 723 | + * @param array $columns The column array. |
|
| 724 | + * @return array Altered column array. |
|
| 725 | + */ |
|
| 726 | + function geodir_edit_post_columns($columns) |
|
| 727 | + {
|
|
| 737 | 728 | |
| 738 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 729 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 730 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 739 | 731 | |
| 740 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 732 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 733 | + {
|
|
| 734 | + $offset = 0; // should we prepend $array with $data? |
|
| 735 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 736 | + } |
|
| 741 | 737 | |
| 742 | - return $columns; |
|
| 743 | - } |
|
| 738 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 739 | + |
|
| 740 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 741 | + |
|
| 742 | + return $columns; |
|
| 743 | + } |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | |
| 747 | 747 | if (!function_exists('geodir_manage_post_columns')) {
|
| 748 | - /** |
|
| 749 | - * Adds content to our custom post listing page columns. |
|
| 750 | - * |
|
| 751 | - * @since 1.0.0 |
|
| 752 | - * @package GeoDirectory |
|
| 753 | - * @global object $wpdb WordPress Database object. |
|
| 754 | - * @global object $post WordPress Post object. |
|
| 755 | - * @param string $column The column name. |
|
| 756 | - * @param int $post_id The post ID. |
|
| 757 | - */ |
|
| 758 | - function geodir_manage_post_columns($column, $post_id) |
|
| 759 | - {
|
|
| 760 | - global $post, $wpdb; |
|
| 761 | - |
|
| 762 | - switch ($column): |
|
| 763 | - /* If displaying the 'city' column. */ |
|
| 764 | - case 'location' : |
|
| 765 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 766 | - $location = geodir_get_location($location_id); |
|
| 767 | - /* If no city is found, output a default message. */ |
|
| 768 | - if (empty($location)) {
|
|
| 769 | - _e('Unknown', 'geodirectory');
|
|
| 770 | - } else {
|
|
| 771 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 772 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 773 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 774 | - } |
|
| 775 | - break; |
|
| 776 | - |
|
| 777 | - /* If displaying the 'expire' column. */ |
|
| 778 | - case 'expire' : |
|
| 779 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 780 | - $d1 = $expire_date; // get expire_date |
|
| 781 | - $d2 = date('Y-m-d'); // get current date
|
|
| 782 | - $state = __('days left', 'geodirectory');
|
|
| 783 | - $date_diff_text = ''; |
|
| 784 | - $expire_class = 'expire_left'; |
|
| 785 | - if ($expire_date != 'Never') {
|
|
| 786 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 787 | - $state = __('days overdue', 'geodirectory');
|
|
| 788 | - $expire_class = 'expire_over'; |
|
| 789 | - } |
|
| 790 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 791 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 792 | - } |
|
| 793 | - /* If no expire_date is found, output a default message. */ |
|
| 794 | - if (empty($expire_date)) |
|
| 795 | - echo __('Unknown', 'geodirectory');
|
|
| 796 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 797 | - else |
|
| 798 | - echo $expire_date . $date_diff_text; |
|
| 799 | - break; |
|
| 800 | - |
|
| 801 | - /* If displaying the 'categorys' column. */ |
|
| 802 | - case 'categorys' : |
|
| 803 | - |
|
| 804 | - /* Get the categorys for the post. */ |
|
| 805 | - |
|
| 806 | - |
|
| 807 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 808 | - |
|
| 809 | - /* If terms were found. */ |
|
| 810 | - if (!empty($terms)) {
|
|
| 811 | - $out = array(); |
|
| 812 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 813 | - foreach ($terms as $term) {
|
|
| 814 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 815 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 816 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 817 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 818 | - ); |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - /* Join the terms, separating them with a comma. */ |
|
| 822 | - echo(join(', ', $out));
|
|
| 823 | - } /* If no terms were found, output a default message. */ |
|
| 824 | - else {
|
|
| 825 | - _e('No Categories', 'geodirectory');
|
|
| 826 | - } |
|
| 827 | - break; |
|
| 748 | + /** |
|
| 749 | + * Adds content to our custom post listing page columns. |
|
| 750 | + * |
|
| 751 | + * @since 1.0.0 |
|
| 752 | + * @package GeoDirectory |
|
| 753 | + * @global object $wpdb WordPress Database object. |
|
| 754 | + * @global object $post WordPress Post object. |
|
| 755 | + * @param string $column The column name. |
|
| 756 | + * @param int $post_id The post ID. |
|
| 757 | + */ |
|
| 758 | + function geodir_manage_post_columns($column, $post_id) |
|
| 759 | + {
|
|
| 760 | + global $post, $wpdb; |
|
| 761 | + |
|
| 762 | + switch ($column): |
|
| 763 | + /* If displaying the 'city' column. */ |
|
| 764 | + case 'location' : |
|
| 765 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 766 | + $location = geodir_get_location($location_id); |
|
| 767 | + /* If no city is found, output a default message. */ |
|
| 768 | + if (empty($location)) {
|
|
| 769 | + _e('Unknown', 'geodirectory');
|
|
| 770 | + } else {
|
|
| 771 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 772 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 773 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 774 | + } |
|
| 775 | + break; |
|
| 776 | + |
|
| 777 | + /* If displaying the 'expire' column. */ |
|
| 778 | + case 'expire' : |
|
| 779 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 780 | + $d1 = $expire_date; // get expire_date |
|
| 781 | + $d2 = date('Y-m-d'); // get current date
|
|
| 782 | + $state = __('days left', 'geodirectory');
|
|
| 783 | + $date_diff_text = ''; |
|
| 784 | + $expire_class = 'expire_left'; |
|
| 785 | + if ($expire_date != 'Never') {
|
|
| 786 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 787 | + $state = __('days overdue', 'geodirectory');
|
|
| 788 | + $expire_class = 'expire_over'; |
|
| 789 | + } |
|
| 790 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 791 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 792 | + } |
|
| 793 | + /* If no expire_date is found, output a default message. */ |
|
| 794 | + if (empty($expire_date)) |
|
| 795 | + echo __('Unknown', 'geodirectory');
|
|
| 796 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 797 | + else |
|
| 798 | + echo $expire_date . $date_diff_text; |
|
| 799 | + break; |
|
| 828 | 800 | |
| 829 | - endswitch; |
|
| 830 | - } |
|
| 801 | + /* If displaying the 'categorys' column. */ |
|
| 802 | + case 'categorys' : |
|
| 803 | + |
|
| 804 | + /* Get the categorys for the post. */ |
|
| 805 | + |
|
| 806 | + |
|
| 807 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 808 | + |
|
| 809 | + /* If terms were found. */ |
|
| 810 | + if (!empty($terms)) {
|
|
| 811 | + $out = array(); |
|
| 812 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 813 | + foreach ($terms as $term) {
|
|
| 814 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 815 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 816 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 817 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 818 | + ); |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + /* Join the terms, separating them with a comma. */ |
|
| 822 | + echo(join(', ', $out));
|
|
| 823 | + } /* If no terms were found, output a default message. */ |
|
| 824 | + else {
|
|
| 825 | + _e('No Categories', 'geodirectory');
|
|
| 826 | + } |
|
| 827 | + break; |
|
| 828 | + |
|
| 829 | + endswitch; |
|
| 830 | + } |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
| 834 | 834 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 835 | - /** |
|
| 836 | - * Makes admin post listing page columns sortable. |
|
| 837 | - * |
|
| 838 | - * @since 1.0.0 |
|
| 839 | - * @package GeoDirectory |
|
| 840 | - * @param array $columns The column array. |
|
| 841 | - * @return array Altered column array. |
|
| 842 | - */ |
|
| 843 | - function geodir_post_sortable_columns($columns) |
|
| 844 | - {
|
|
| 845 | - |
|
| 846 | - $columns['expire'] = 'expire'; |
|
| 847 | - |
|
| 848 | - return $columns; |
|
| 849 | - } |
|
| 835 | + /** |
|
| 836 | + * Makes admin post listing page columns sortable. |
|
| 837 | + * |
|
| 838 | + * @since 1.0.0 |
|
| 839 | + * @package GeoDirectory |
|
| 840 | + * @param array $columns The column array. |
|
| 841 | + * @return array Altered column array. |
|
| 842 | + */ |
|
| 843 | + function geodir_post_sortable_columns($columns) |
|
| 844 | + {
|
|
| 845 | + |
|
| 846 | + $columns['expire'] = 'expire'; |
|
| 847 | + |
|
| 848 | + return $columns; |
|
| 849 | + } |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -860,32 +860,32 @@ discard block |
||
| 860 | 860 | * @param int $post_id The post ID. |
| 861 | 861 | */ |
| 862 | 862 | function geodir_post_information_save($post_id, $post) {
|
| 863 | - global $wpdb, $current_user; |
|
| 863 | + global $wpdb, $current_user; |
|
| 864 | 864 | |
| 865 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 866 | - return; |
|
| 867 | - } |
|
| 865 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 866 | + return; |
|
| 867 | + } |
|
| 868 | 868 | |
| 869 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 869 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 870 | 870 | |
| 871 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 872 | - return; |
|
| 871 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 872 | + return; |
|
| 873 | 873 | |
| 874 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 875 | - if (isset($_REQUEST['_status'])) |
|
| 876 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 874 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 875 | + if (isset($_REQUEST['_status'])) |
|
| 876 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 877 | 877 | |
| 878 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 879 | - return; |
|
| 878 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 879 | + return; |
|
| 880 | 880 | |
| 881 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 882 | - return; |
|
| 881 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 882 | + return; |
|
| 883 | 883 | |
| 884 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 885 | - return; |
|
| 884 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 885 | + return; |
|
| 886 | 886 | |
| 887 | - geodir_save_listing($_REQUEST); |
|
| 888 | - } |
|
| 887 | + geodir_save_listing($_REQUEST); |
|
| 888 | + } |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -901,102 +901,102 @@ discard block |
||
| 901 | 901 | */ |
| 902 | 902 | function geodir_admin_fields($options) |
| 903 | 903 | {
|
| 904 | - global $geodirectory; |
|
| 905 | - |
|
| 906 | - $first_title = true; |
|
| 907 | - $tab_id = ''; |
|
| 908 | - $i = 0; |
|
| 909 | - foreach ($options as $value) : |
|
| 910 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 911 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 912 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 913 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 914 | - $desc = ''; |
|
| 915 | - switch ($value['type']) : |
|
| 916 | - case 'dummy_installer': |
|
| 917 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 918 | - geodir_autoinstall_admin_header($post_type); |
|
| 919 | - break; |
|
| 920 | - case 'title': |
|
| 921 | - |
|
| 922 | - if ($i == 0) {
|
|
| 923 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 924 | - echo '<div class="inner_content_tab_main">'; |
|
| 925 | - } |
|
| 904 | + global $geodirectory; |
|
| 905 | + |
|
| 906 | + $first_title = true; |
|
| 907 | + $tab_id = ''; |
|
| 908 | + $i = 0; |
|
| 909 | + foreach ($options as $value) : |
|
| 910 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 911 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 912 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 913 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 914 | + $desc = ''; |
|
| 915 | + switch ($value['type']) : |
|
| 916 | + case 'dummy_installer': |
|
| 917 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 918 | + geodir_autoinstall_admin_header($post_type); |
|
| 919 | + break; |
|
| 920 | + case 'title': |
|
| 921 | + |
|
| 922 | + if ($i == 0) {
|
|
| 923 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 924 | + echo '<div class="inner_content_tab_main">'; |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | - $i++; |
|
| 927 | + $i++; |
|
| 928 | 928 | |
| 929 | - if (isset($value['id']) && $value['id']) |
|
| 930 | - $tab_id = $value['id']; |
|
| 929 | + if (isset($value['id']) && $value['id']) |
|
| 930 | + $tab_id = $value['id']; |
|
| 931 | 931 | |
| 932 | - if (isset($value['desc']) && $value['desc']) |
|
| 933 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 932 | + if (isset($value['desc']) && $value['desc']) |
|
| 933 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 934 | 934 | |
| 935 | - if (isset($value['name']) && $value['name']) {
|
|
| 936 | - if ($first_title === true) {
|
|
| 937 | - $first_title = false; |
|
| 938 | - } else {
|
|
| 939 | - echo '</div>'; |
|
| 940 | - } |
|
| 941 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 935 | + if (isset($value['name']) && $value['name']) {
|
|
| 936 | + if ($first_title === true) {
|
|
| 937 | + $first_title = false; |
|
| 938 | + } else {
|
|
| 939 | + echo '</div>'; |
|
| 940 | + } |
|
| 941 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 942 | 942 | |
| 943 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 944 | - } |
|
| 943 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - /** |
|
| 947 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 948 | - * |
|
| 949 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 950 | - * |
|
| 951 | - * @since 1.0.0 |
|
| 952 | - */ |
|
| 953 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 954 | - break; |
|
| 955 | - |
|
| 956 | - case 'no_tabs': |
|
| 957 | - |
|
| 958 | - echo '<div class="inner_content_tab_main">'; |
|
| 959 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 960 | - |
|
| 961 | - break; |
|
| 962 | - |
|
| 963 | - case 'sectionstart': |
|
| 964 | - if (isset($value['desc']) && $value['desc']) |
|
| 965 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 966 | - if (isset($value['name']) && $value['name']) |
|
| 967 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 968 | - /** |
|
| 969 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 970 | - * |
|
| 971 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 972 | - * |
|
| 973 | - * @since 1.0.0 |
|
| 974 | - */ |
|
| 975 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 976 | - echo '<table class="form-table">' . "\n\n"; |
|
| 977 | - |
|
| 978 | - break; |
|
| 979 | - case 'sectionend': |
|
| 980 | - /** |
|
| 981 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 982 | - * |
|
| 983 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 984 | - * |
|
| 985 | - * @since 1.0.0 |
|
| 986 | - */ |
|
| 987 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 988 | - echo '</table>'; |
|
| 989 | - /** |
|
| 990 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 991 | - * |
|
| 992 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 993 | - * |
|
| 994 | - * @since 1.0.0 |
|
| 995 | - */ |
|
| 996 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 997 | - break; |
|
| 998 | - case 'text': |
|
| 999 | - ?> |
|
| 946 | + /** |
|
| 947 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 948 | + * |
|
| 949 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 950 | + * |
|
| 951 | + * @since 1.0.0 |
|
| 952 | + */ |
|
| 953 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 954 | + break; |
|
| 955 | + |
|
| 956 | + case 'no_tabs': |
|
| 957 | + |
|
| 958 | + echo '<div class="inner_content_tab_main">'; |
|
| 959 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 960 | + |
|
| 961 | + break; |
|
| 962 | + |
|
| 963 | + case 'sectionstart': |
|
| 964 | + if (isset($value['desc']) && $value['desc']) |
|
| 965 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 966 | + if (isset($value['name']) && $value['name']) |
|
| 967 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 968 | + /** |
|
| 969 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 970 | + * |
|
| 971 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 972 | + * |
|
| 973 | + * @since 1.0.0 |
|
| 974 | + */ |
|
| 975 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 976 | + echo '<table class="form-table">' . "\n\n"; |
|
| 977 | + |
|
| 978 | + break; |
|
| 979 | + case 'sectionend': |
|
| 980 | + /** |
|
| 981 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 982 | + * |
|
| 983 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 984 | + * |
|
| 985 | + * @since 1.0.0 |
|
| 986 | + */ |
|
| 987 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 988 | + echo '</table>'; |
|
| 989 | + /** |
|
| 990 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 991 | + * |
|
| 992 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 993 | + * |
|
| 994 | + * @since 1.0.0 |
|
| 995 | + */ |
|
| 996 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 997 | + break; |
|
| 998 | + case 'text': |
|
| 999 | + ?> |
|
| 1000 | 1000 | <tr valign="top"> |
| 1001 | 1001 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1002 | 1002 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1005,15 +1005,15 @@ discard block |
||
| 1005 | 1005 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1006 | 1006 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1007 | 1007 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1008 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1009 | - } else {
|
|
| 1010 | - echo esc_attr($value['std']); |
|
| 1011 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1008 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1009 | + } else {
|
|
| 1010 | + echo esc_attr($value['std']); |
|
| 1011 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1012 | 1012 | </tr><?php |
| 1013 | - break; |
|
| 1013 | + break; |
|
| 1014 | 1014 | |
| 1015 | - case 'map-key': |
|
| 1016 | - ?> |
|
| 1015 | + case 'map-key': |
|
| 1016 | + ?> |
|
| 1017 | 1017 | <tr valign="top"> |
| 1018 | 1018 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1019 | 1019 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1022,17 +1022,17 @@ discard block |
||
| 1022 | 1022 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1023 | 1023 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1024 | 1024 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1025 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1026 | - } else {
|
|
| 1027 | - echo esc_attr($value['std']); |
|
| 1028 | - } ?>"/> |
|
| 1025 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1026 | + } else {
|
|
| 1027 | + echo esc_attr($value['std']); |
|
| 1028 | + } ?>"/> |
|
| 1029 | 1029 | <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a>
|
| 1030 | 1030 | <span class="description"><?php echo $value['desc']; ?></span></td> |
| 1031 | 1031 | </tr><?php |
| 1032 | - break; |
|
| 1032 | + break; |
|
| 1033 | 1033 | |
| 1034 | - case 'password': |
|
| 1035 | - ?> |
|
| 1034 | + case 'password': |
|
| 1035 | + ?> |
|
| 1036 | 1036 | <tr valign="top"> |
| 1037 | 1037 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1038 | 1038 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1041,42 +1041,42 @@ discard block |
||
| 1041 | 1041 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1042 | 1042 | style="<?php echo esc_attr($value['css']); ?>" |
| 1043 | 1043 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1044 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1045 | - } else {
|
|
| 1046 | - echo esc_attr($value['std']); |
|
| 1047 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1044 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1045 | + } else {
|
|
| 1046 | + echo esc_attr($value['std']); |
|
| 1047 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1048 | 1048 | </tr><?php |
| 1049 | - break; |
|
| 1049 | + break; |
|
| 1050 | 1050 | |
| 1051 | - case 'html_content': |
|
| 1052 | - ?> |
|
| 1051 | + case 'html_content': |
|
| 1052 | + ?> |
|
| 1053 | 1053 | <tr valign="top"> |
| 1054 | 1054 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1055 | 1055 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 1056 | 1056 | </tr><?php |
| 1057 | - break; |
|
| 1057 | + break; |
|
| 1058 | 1058 | |
| 1059 | - case 'color' : |
|
| 1060 | - ?> |
|
| 1059 | + case 'color' : |
|
| 1060 | + ?> |
|
| 1061 | 1061 | <tr valign="top"> |
| 1062 | 1062 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1063 | 1063 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1064 | 1064 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 1065 | 1065 | style="<?php echo esc_attr($value['css']); ?>" |
| 1066 | 1066 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1067 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1068 | - } else {
|
|
| 1069 | - echo esc_attr($value['std']); |
|
| 1070 | - } ?>" class="colorpick"/> <span |
|
| 1067 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1068 | + } else {
|
|
| 1069 | + echo esc_attr($value['std']); |
|
| 1070 | + } ?>" class="colorpick"/> <span |
|
| 1071 | 1071 | class="description"><?php echo $value['desc']; ?></span> |
| 1072 | 1072 | |
| 1073 | 1073 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 1074 | 1074 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 1075 | 1075 | </td> |
| 1076 | 1076 | </tr><?php |
| 1077 | - break; |
|
| 1078 | - case 'image_width' : |
|
| 1079 | - ?> |
|
| 1077 | + break; |
|
| 1078 | + case 'image_width' : |
|
| 1079 | + ?> |
|
| 1080 | 1080 | <tr valign="top"> |
| 1081 | 1081 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1082 | 1082 | <td class="forminp"> |
@@ -1098,11 +1098,11 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1100 | 1100 | </tr><?php |
| 1101 | - break; |
|
| 1102 | - case 'select': |
|
| 1103 | - $option_value = get_option($value['id']); |
|
| 1104 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1105 | - ?> |
|
| 1101 | + break; |
|
| 1102 | + case 'select': |
|
| 1103 | + $option_value = get_option($value['id']); |
|
| 1104 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1105 | + ?> |
|
| 1106 | 1106 | <tr valign="top"> |
| 1107 | 1107 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1108 | 1108 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1111,33 +1111,33 @@ discard block |
||
| 1111 | 1111 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1112 | 1112 | option-ajaxchosen="false"> |
| 1113 | 1113 | <?php |
| 1114 | - foreach ($value['options'] as $key => $val) {
|
|
| 1115 | - $geodir_select_value = ''; |
|
| 1116 | - if ($option_value != '') {
|
|
| 1117 | - if ($option_value != '' && $option_value == $key) |
|
| 1118 | - $geodir_select_value = ' selected="selected" '; |
|
| 1119 | - } else {
|
|
| 1120 | - if ($value['std'] == $key) |
|
| 1121 | - $geodir_select_value = ' selected="selected" '; |
|
| 1122 | - } |
|
| 1123 | - ?> |
|
| 1114 | + foreach ($value['options'] as $key => $val) {
|
|
| 1115 | + $geodir_select_value = ''; |
|
| 1116 | + if ($option_value != '') {
|
|
| 1117 | + if ($option_value != '' && $option_value == $key) |
|
| 1118 | + $geodir_select_value = ' selected="selected" '; |
|
| 1119 | + } else {
|
|
| 1120 | + if ($value['std'] == $key) |
|
| 1121 | + $geodir_select_value = ' selected="selected" '; |
|
| 1122 | + } |
|
| 1123 | + ?> |
|
| 1124 | 1124 | <option |
| 1125 | 1125 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo geodir_utf8_ucfirst($val) ?></option> |
| 1126 | 1126 | <?php |
| 1127 | - } |
|
| 1128 | - ?> |
|
| 1127 | + } |
|
| 1128 | + ?> |
|
| 1129 | 1129 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1130 | 1130 | </td> |
| 1131 | 1131 | </tr><?php |
| 1132 | - break; |
|
| 1132 | + break; |
|
| 1133 | 1133 | |
| 1134 | - case 'multiselect': |
|
| 1135 | - $option_values = get_option($value['id']); |
|
| 1136 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1137 | - $option_values = $value['std']; |
|
| 1138 | - } |
|
| 1139 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1140 | - ?> |
|
| 1134 | + case 'multiselect': |
|
| 1135 | + $option_values = get_option($value['id']); |
|
| 1136 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1137 | + $option_values = $value['std']; |
|
| 1138 | + } |
|
| 1139 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1140 | + ?> |
|
| 1141 | 1141 | <tr valign="top"> |
| 1142 | 1142 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1143 | 1143 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1147,25 +1147,25 @@ discard block |
||
| 1147 | 1147 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 1148 | 1148 | option-ajaxchosen="false"> |
| 1149 | 1149 | <?php |
| 1150 | - foreach ($value['options'] as $key => $val) {
|
|
| 1151 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1152 | - ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
| 1153 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1154 | - ?></optgroup><?php |
|
| 1155 | - } else {
|
|
| 1156 | - ?> |
|
| 1150 | + foreach ($value['options'] as $key => $val) {
|
|
| 1151 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1152 | + ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
| 1153 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1154 | + ?></optgroup><?php |
|
| 1155 | + } else {
|
|
| 1156 | + ?> |
|
| 1157 | 1157 | <option |
| 1158 | 1158 | value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo geodir_utf8_ucfirst($val) ?></option> |
| 1159 | 1159 | <?php |
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - ?> |
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + ?> |
|
| 1163 | 1163 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1164 | 1164 | </td> |
| 1165 | 1165 | </tr><?php |
| 1166 | - break; |
|
| 1167 | - case 'file': |
|
| 1168 | - ?> |
|
| 1166 | + break; |
|
| 1167 | + case 'file': |
|
| 1168 | + ?> |
|
| 1169 | 1169 | <tr valign="top"> |
| 1170 | 1170 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1171 | 1171 | <td class="forminp"> |
@@ -1185,87 +1185,87 @@ discard block |
||
| 1185 | 1185 | <?php } ?> |
| 1186 | 1186 | </td> |
| 1187 | 1187 | </tr><?php |
| 1188 | - break; |
|
| 1189 | - case 'map_default_settings' : |
|
| 1190 | - ?> |
|
| 1188 | + break; |
|
| 1189 | + case 'map_default_settings' : |
|
| 1190 | + ?> |
|
| 1191 | 1191 | |
| 1192 | 1192 | <tr valign="top"> |
| 1193 | 1193 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 1194 | 1194 | <td width="60%"> |
| 1195 | 1195 | <select name="geodir_default_map_language" style="width:60%"> |
| 1196 | 1196 | <?php |
| 1197 | - $arr_map_langages = array( |
|
| 1198 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1199 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1200 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1201 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1202 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1203 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1204 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 1205 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1206 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 1207 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1208 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1209 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1210 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1211 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1212 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1213 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1214 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1215 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1216 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1217 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1218 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1219 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1220 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1221 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1222 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1223 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1224 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1225 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1226 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1227 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1228 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1229 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1230 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1231 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1232 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1233 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1234 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1235 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1236 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1237 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1238 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1239 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1240 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1241 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1242 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1243 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1244 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1245 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1246 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1247 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 1248 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1249 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1250 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1251 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1252 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1253 | - ); |
|
| 1254 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1255 | - if (empty($geodir_default_map_language)) |
|
| 1256 | - $geodir_default_map_language = 'en'; |
|
| 1257 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1258 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1259 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 1260 | - else |
|
| 1261 | - $geodir_default_language_selected = ''; |
|
| 1262 | - |
|
| 1263 | - ?> |
|
| 1197 | + $arr_map_langages = array( |
|
| 1198 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1199 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1200 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1201 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1202 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1203 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1204 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 1205 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1206 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 1207 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1208 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1209 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1210 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1211 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1212 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1213 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1214 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1215 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1216 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1217 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1218 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1219 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1220 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1221 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1222 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1223 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1224 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1225 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1226 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1227 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1228 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1229 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1230 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1231 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1232 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1233 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1234 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1235 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1236 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1237 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1238 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1239 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1240 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1241 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1242 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1243 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1244 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1245 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1246 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1247 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 1248 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1249 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1250 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1251 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1252 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1253 | + ); |
|
| 1254 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1255 | + if (empty($geodir_default_map_language)) |
|
| 1256 | + $geodir_default_map_language = 'en'; |
|
| 1257 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1258 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1259 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 1260 | + else |
|
| 1261 | + $geodir_default_language_selected = ''; |
|
| 1262 | + |
|
| 1263 | + ?> |
|
| 1264 | 1264 | <option |
| 1265 | 1265 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 1266 | 1266 | |
| 1267 | 1267 | <?php } |
| 1268 | - ?> |
|
| 1268 | + ?> |
|
| 1269 | 1269 | </select> |
| 1270 | 1270 | </td> |
| 1271 | 1271 | </tr> |
@@ -1276,46 +1276,46 @@ discard block |
||
| 1276 | 1276 | <td width="60%"> |
| 1277 | 1277 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1278 | 1278 | <?php |
| 1279 | - $post_types = geodir_get_posttypes('array');
|
|
| 1280 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1281 | - if (empty($geodir_default_map_search_pt)) |
|
| 1282 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 1283 | - if (is_array($post_types)) {
|
|
| 1284 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 1285 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1286 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 1287 | - else |
|
| 1288 | - $geodir_search_pt_selected = ''; |
|
| 1289 | - |
|
| 1290 | - ?> |
|
| 1279 | + $post_types = geodir_get_posttypes('array');
|
|
| 1280 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1281 | + if (empty($geodir_default_map_search_pt)) |
|
| 1282 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 1283 | + if (is_array($post_types)) {
|
|
| 1284 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 1285 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1286 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 1287 | + else |
|
| 1288 | + $geodir_search_pt_selected = ''; |
|
| 1289 | + |
|
| 1290 | + ?> |
|
| 1291 | 1291 | <option |
| 1292 | 1292 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option> |
| 1293 | 1293 | |
| 1294 | 1294 | <?php } |
| 1295 | 1295 | |
| 1296 | - } |
|
| 1296 | + } |
|
| 1297 | 1297 | |
| 1298 | - ?> |
|
| 1298 | + ?> |
|
| 1299 | 1299 | </select> |
| 1300 | 1300 | </td> |
| 1301 | 1301 | </tr> |
| 1302 | 1302 | |
| 1303 | 1303 | <?php |
| 1304 | - break; |
|
| 1304 | + break; |
|
| 1305 | 1305 | |
| 1306 | - case 'map': |
|
| 1307 | - ?> |
|
| 1306 | + case 'map': |
|
| 1307 | + ?> |
|
| 1308 | 1308 | <tr valign="top"> |
| 1309 | 1309 | <td class="forminp"> |
| 1310 | 1310 | <?php |
| 1311 | - global $post_cat, $cat_display; |
|
| 1312 | - $post_types = geodir_get_posttypes('object');
|
|
| 1313 | - $cat_display = 'checkbox'; |
|
| 1314 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1315 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1316 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1317 | - $count = 1; |
|
| 1318 | - ?> |
|
| 1311 | + global $post_cat, $cat_display; |
|
| 1312 | + $post_types = geodir_get_posttypes('object');
|
|
| 1313 | + $cat_display = 'checkbox'; |
|
| 1314 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1315 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1316 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1317 | + $count = 1; |
|
| 1318 | + ?> |
|
| 1319 | 1319 | <table width="70%" class="widefat"> |
| 1320 | 1320 | <thead> |
| 1321 | 1321 | <tr> |
@@ -1324,18 +1324,18 @@ discard block |
||
| 1324 | 1324 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 1325 | 1325 | </tr> |
| 1326 | 1326 | <?php |
| 1327 | - $gd_categs = $gd_cats; |
|
| 1328 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 1329 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1330 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1331 | - if ($gd_cats_upgrade) {
|
|
| 1332 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1333 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1334 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1335 | - } |
|
| 1336 | - $post_cat = implode(',', $gd_cats);
|
|
| 1337 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1338 | - ?> |
|
| 1327 | + $gd_categs = $gd_cats; |
|
| 1328 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 1329 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1330 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1331 | + if ($gd_cats_upgrade) {
|
|
| 1332 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1333 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1334 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1335 | + } |
|
| 1336 | + $post_cat = implode(',', $gd_cats);
|
|
| 1337 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1338 | + ?> |
|
| 1339 | 1339 | <tr> |
| 1340 | 1340 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 1341 | 1341 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1356,19 +1356,19 @@ discard block |
||
| 1356 | 1356 | </td> |
| 1357 | 1357 | </tr> |
| 1358 | 1358 | <?php |
| 1359 | - break; |
|
| 1359 | + break; |
|
| 1360 | 1360 | |
| 1361 | - case 'checkbox' : |
|
| 1361 | + case 'checkbox' : |
|
| 1362 | 1362 | |
| 1363 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1364 | - ?> |
|
| 1363 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1364 | + ?> |
|
| 1365 | 1365 | <tr valign="top"> |
| 1366 | 1366 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1367 | 1367 | <td class="forminp"> |
| 1368 | 1368 | <?php |
| 1369 | - endif; |
|
| 1369 | + endif; |
|
| 1370 | 1370 | |
| 1371 | - ?> |
|
| 1371 | + ?> |
|
| 1372 | 1372 | <fieldset> |
| 1373 | 1373 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1374 | 1374 | <label for="<?php echo $value['id'] ?>"> |
@@ -1378,49 +1378,49 @@ discard block |
||
| 1378 | 1378 | </fieldset> |
| 1379 | 1379 | <?php |
| 1380 | 1380 | |
| 1381 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1382 | - ?> |
|
| 1381 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1382 | + ?> |
|
| 1383 | 1383 | </td> |
| 1384 | 1384 | </tr> |
| 1385 | 1385 | <?php |
| 1386 | - endif; |
|
| 1386 | + endif; |
|
| 1387 | 1387 | |
| 1388 | - break; |
|
| 1388 | + break; |
|
| 1389 | 1389 | |
| 1390 | - case 'radio' : |
|
| 1390 | + case 'radio' : |
|
| 1391 | 1391 | |
| 1392 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1393 | - ?> |
|
| 1392 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1393 | + ?> |
|
| 1394 | 1394 | <tr valign="top"> |
| 1395 | 1395 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1396 | 1396 | <td class="forminp"> |
| 1397 | 1397 | <?php |
| 1398 | - endif; |
|
| 1398 | + endif; |
|
| 1399 | 1399 | |
| 1400 | - ?> |
|
| 1400 | + ?> |
|
| 1401 | 1401 | <fieldset> |
| 1402 | 1402 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1403 | 1403 | <label for="<?php echo $value['id'];?>"> |
| 1404 | 1404 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1405 | 1405 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 1406 | 1406 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1407 | - echo 'checked="checked"'; |
|
| 1408 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1407 | + echo 'checked="checked"'; |
|
| 1408 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1409 | 1409 | <?php echo $value['desc']; ?></label><br> |
| 1410 | 1410 | </fieldset> |
| 1411 | 1411 | <?php |
| 1412 | 1412 | |
| 1413 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1414 | - ?> |
|
| 1413 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1414 | + ?> |
|
| 1415 | 1415 | </td> |
| 1416 | 1416 | </tr> |
| 1417 | 1417 | <?php |
| 1418 | - endif; |
|
| 1418 | + endif; |
|
| 1419 | 1419 | |
| 1420 | - break; |
|
| 1420 | + break; |
|
| 1421 | 1421 | |
| 1422 | - case 'textarea': |
|
| 1423 | - ?> |
|
| 1422 | + case 'textarea': |
|
| 1423 | + ?> |
|
| 1424 | 1424 | <tr valign="top"> |
| 1425 | 1425 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1426 | 1426 | <td class="forminp"> |
@@ -1433,30 +1433,30 @@ discard block |
||
| 1433 | 1433 | |
| 1434 | 1434 | </td> |
| 1435 | 1435 | </tr><?php |
| 1436 | - break; |
|
| 1436 | + break; |
|
| 1437 | 1437 | |
| 1438 | - case 'editor': |
|
| 1439 | - ?> |
|
| 1438 | + case 'editor': |
|
| 1439 | + ?> |
|
| 1440 | 1440 | <tr valign="top"> |
| 1441 | 1441 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1442 | 1442 | <td class="forminp"><?php |
| 1443 | - if (get_option($value['id'])) |
|
| 1444 | - $content = stripslashes(get_option($value['id'])); |
|
| 1445 | - else |
|
| 1446 | - $content = $value['std']; |
|
| 1443 | + if (get_option($value['id'])) |
|
| 1444 | + $content = stripslashes(get_option($value['id'])); |
|
| 1445 | + else |
|
| 1446 | + $content = $value['std']; |
|
| 1447 | 1447 | |
| 1448 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1448 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1449 | 1449 | |
| 1450 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1450 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1451 | 1451 | |
| 1452 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1452 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1453 | 1453 | |
| 1454 | 1454 | </td> |
| 1455 | 1455 | </tr><?php |
| 1456 | - break; |
|
| 1456 | + break; |
|
| 1457 | 1457 | |
| 1458 | - case 'single_select_page' : |
|
| 1459 | - // WPML |
|
| 1458 | + case 'single_select_page' : |
|
| 1459 | + // WPML |
|
| 1460 | 1460 | $switch_lang = false; |
| 1461 | 1461 | $disabled = ''; |
| 1462 | 1462 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -1474,18 +1474,18 @@ discard block |
||
| 1474 | 1474 | // |
| 1475 | 1475 | $page_setting = (int)get_option($value['id']); |
| 1476 | 1476 | |
| 1477 | - $args = array('name' => $value['id'],
|
|
| 1478 | - 'id' => $value['id'], |
|
| 1479 | - 'sort_column' => 'menu_order', |
|
| 1480 | - 'sort_order' => 'ASC', |
|
| 1481 | - 'show_option_none' => ' ', |
|
| 1482 | - 'class' => $value['class'], |
|
| 1483 | - 'echo' => false, |
|
| 1484 | - 'selected' => $page_setting); |
|
| 1477 | + $args = array('name' => $value['id'],
|
|
| 1478 | + 'id' => $value['id'], |
|
| 1479 | + 'sort_column' => 'menu_order', |
|
| 1480 | + 'sort_order' => 'ASC', |
|
| 1481 | + 'show_option_none' => ' ', |
|
| 1482 | + 'class' => $value['class'], |
|
| 1483 | + 'echo' => false, |
|
| 1484 | + 'selected' => $page_setting); |
|
| 1485 | 1485 | |
| 1486 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1486 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1487 | 1487 | |
| 1488 | - ?> |
|
| 1488 | + ?> |
|
| 1489 | 1489 | <tr valign="top" class="single_select_page"> |
| 1490 | 1490 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1491 | 1491 | <td class="forminp"> |
@@ -1496,17 +1496,17 @@ discard block |
||
| 1496 | 1496 | if ($switch_lang) {
|
| 1497 | 1497 | $sitepress->switch_lang($switch_lang, true); |
| 1498 | 1498 | } |
| 1499 | - break; |
|
| 1500 | - case 'single_select_country' : |
|
| 1501 | - $country_setting = (string)get_option($value['id']); |
|
| 1502 | - if (strstr($country_setting, ':')) : |
|
| 1503 | - $country = current(explode(':', $country_setting));
|
|
| 1504 | - $state = end(explode(':', $country_setting));
|
|
| 1505 | - else : |
|
| 1506 | - $country = $country_setting; |
|
| 1507 | - $state = '*'; |
|
| 1508 | - endif; |
|
| 1509 | - ?> |
|
| 1499 | + break; |
|
| 1500 | + case 'single_select_country' : |
|
| 1501 | + $country_setting = (string)get_option($value['id']); |
|
| 1502 | + if (strstr($country_setting, ':')) : |
|
| 1503 | + $country = current(explode(':', $country_setting));
|
|
| 1504 | + $state = end(explode(':', $country_setting));
|
|
| 1505 | + else : |
|
| 1506 | + $country = $country_setting; |
|
| 1507 | + $state = '*'; |
|
| 1508 | + endif; |
|
| 1509 | + ?> |
|
| 1510 | 1510 | <tr valign="top"> |
| 1511 | 1511 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 1512 | 1512 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1517,12 +1517,12 @@ discard block |
||
| 1517 | 1517 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1518 | 1518 | </td> |
| 1519 | 1519 | </tr><?php |
| 1520 | - break; |
|
| 1521 | - case 'multi_select_countries' : |
|
| 1522 | - $countries = $geodirectory->countries->countries; |
|
| 1523 | - asort($countries); |
|
| 1524 | - $selections = (array)get_option($value['id']); |
|
| 1525 | - ?> |
|
| 1520 | + break; |
|
| 1521 | + case 'multi_select_countries' : |
|
| 1522 | + $countries = $geodirectory->countries->countries; |
|
| 1523 | + asort($countries); |
|
| 1524 | + $selections = (array)get_option($value['id']); |
|
| 1525 | + ?> |
|
| 1526 | 1526 | <tr valign="top"> |
| 1527 | 1527 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1528 | 1528 | <td class="forminp"> |
@@ -1530,21 +1530,21 @@ discard block |
||
| 1530 | 1530 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 1531 | 1531 | title="Country" class="chosen_select"> |
| 1532 | 1532 | <?php |
| 1533 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 1534 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1535 | - endforeach; |
|
| 1536 | - ?> |
|
| 1533 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 1534 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1535 | + endforeach; |
|
| 1536 | + ?> |
|
| 1537 | 1537 | </select> |
| 1538 | 1538 | </td> |
| 1539 | 1539 | </tr> |
| 1540 | 1540 | |
| 1541 | 1541 | <?php |
| 1542 | 1542 | |
| 1543 | - break; |
|
| 1543 | + break; |
|
| 1544 | 1544 | |
| 1545 | - case 'google_analytics' : |
|
| 1546 | - $selections = (array)get_option($value['id']); |
|
| 1547 | - ?> |
|
| 1545 | + case 'google_analytics' : |
|
| 1546 | + $selections = (array)get_option($value['id']); |
|
| 1547 | + ?> |
|
| 1548 | 1548 | <tr valign="top"> |
| 1549 | 1549 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1550 | 1550 | <td class="forminp"> |
@@ -1552,62 +1552,62 @@ discard block |
||
| 1552 | 1552 | |
| 1553 | 1553 | <?php |
| 1554 | 1554 | |
| 1555 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1556 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1557 | - $state = "&state=123";//any string |
|
| 1558 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1559 | - $response_type = "&response_type=code"; |
|
| 1560 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1561 | - $access_type = "&access_type=offline"; |
|
| 1562 | - $approval_prompt = "&approval_prompt=force"; |
|
| 1555 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1556 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1557 | + $state = "&state=123";//any string |
|
| 1558 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1559 | + $response_type = "&response_type=code"; |
|
| 1560 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1561 | + $access_type = "&access_type=offline"; |
|
| 1562 | + $approval_prompt = "&approval_prompt=force"; |
|
| 1563 | 1563 | |
| 1564 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1564 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1565 | 1565 | |
| 1566 | 1566 | |
| 1567 | - if (get_option('geodir_ga_auth_token')) {
|
|
| 1568 | - ?> |
|
| 1567 | + if (get_option('geodir_ga_auth_token')) {
|
|
| 1568 | + ?> |
|
| 1569 | 1569 | <span class="button-primary" |
| 1570 | 1570 | onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
|
| 1571 | 1571 | <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 1572 | 1572 | <?php |
| 1573 | - global $gd_ga_errors; |
|
| 1574 | - if(!empty($gd_ga_errors)){
|
|
| 1575 | - print_r($gd_ga_errors); |
|
| 1576 | - } |
|
| 1577 | - } else {
|
|
| 1578 | - ?> |
|
| 1573 | + global $gd_ga_errors; |
|
| 1574 | + if(!empty($gd_ga_errors)){
|
|
| 1575 | + print_r($gd_ga_errors); |
|
| 1576 | + } |
|
| 1577 | + } else {
|
|
| 1578 | + ?> |
|
| 1579 | 1579 | <span class="button-primary" |
| 1580 | 1580 | onclick="window.open('<?php echo geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory');?></span>
|
| 1581 | 1581 | <?php |
| 1582 | - } |
|
| 1583 | - ?> |
|
| 1582 | + } |
|
| 1583 | + ?> |
|
| 1584 | 1584 | </td> |
| 1585 | 1585 | </tr> |
| 1586 | 1586 | |
| 1587 | 1587 | <?php |
| 1588 | 1588 | |
| 1589 | 1589 | |
| 1590 | - break; |
|
| 1590 | + break; |
|
| 1591 | 1591 | |
| 1592 | - case 'field_seperator' : |
|
| 1592 | + case 'field_seperator' : |
|
| 1593 | 1593 | |
| 1594 | - ?> |
|
| 1594 | + ?> |
|
| 1595 | 1595 | <tr valign="top"> |
| 1596 | 1596 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 1597 | 1597 | </tr> |
| 1598 | 1598 | <?php |
| 1599 | 1599 | |
| 1600 | - break; |
|
| 1600 | + break; |
|
| 1601 | 1601 | |
| 1602 | - endswitch; |
|
| 1602 | + endswitch; |
|
| 1603 | 1603 | |
| 1604 | - endforeach; |
|
| 1604 | + endforeach; |
|
| 1605 | 1605 | |
| 1606 | - if ($first_title === false) {
|
|
| 1607 | - echo "</div>"; |
|
| 1608 | - } |
|
| 1606 | + if ($first_title === false) {
|
|
| 1607 | + echo "</div>"; |
|
| 1608 | + } |
|
| 1609 | 1609 | |
| 1610 | - ?> |
|
| 1610 | + ?> |
|
| 1611 | 1611 | |
| 1612 | 1612 | <script type="text/javascript"> |
| 1613 | 1613 | |
@@ -1667,33 +1667,33 @@ discard block |
||
| 1667 | 1667 | */ |
| 1668 | 1668 | function geodir_post_info_setting() |
| 1669 | 1669 | {
|
| 1670 | - global $post, $post_id; |
|
| 1671 | - |
|
| 1672 | - $post_type = get_post_type(); |
|
| 1673 | - |
|
| 1674 | - $package_info = array(); |
|
| 1675 | - |
|
| 1676 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1677 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1678 | - echo '<div id="geodir_wrapper">'; |
|
| 1679 | - /** |
|
| 1680 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 1681 | - * |
|
| 1682 | - * @since 1.0.0 |
|
| 1683 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 1684 | - */ |
|
| 1685 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 1686 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1687 | - // to display all fields in one information box |
|
| 1688 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1689 | - /** |
|
| 1690 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 1691 | - * |
|
| 1692 | - * @since 1.0.0 |
|
| 1693 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 1694 | - */ |
|
| 1695 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 1696 | - echo '</div>'; |
|
| 1670 | + global $post, $post_id; |
|
| 1671 | + |
|
| 1672 | + $post_type = get_post_type(); |
|
| 1673 | + |
|
| 1674 | + $package_info = array(); |
|
| 1675 | + |
|
| 1676 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1677 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1678 | + echo '<div id="geodir_wrapper">'; |
|
| 1679 | + /** |
|
| 1680 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 1681 | + * |
|
| 1682 | + * @since 1.0.0 |
|
| 1683 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 1684 | + */ |
|
| 1685 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 1686 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1687 | + // to display all fields in one information box |
|
| 1688 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1689 | + /** |
|
| 1690 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 1691 | + * |
|
| 1692 | + * @since 1.0.0 |
|
| 1693 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 1694 | + */ |
|
| 1695 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 1696 | + echo '</div>'; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | /** |
@@ -1706,18 +1706,18 @@ discard block |
||
| 1706 | 1706 | */ |
| 1707 | 1707 | function geodir_post_addinfo_setting() |
| 1708 | 1708 | {
|
| 1709 | - global $post, $post_id; |
|
| 1709 | + global $post, $post_id; |
|
| 1710 | 1710 | |
| 1711 | - $post_type = get_post_type(); |
|
| 1711 | + $post_type = get_post_type(); |
|
| 1712 | 1712 | |
| 1713 | - $package_info = array(); |
|
| 1713 | + $package_info = array(); |
|
| 1714 | 1714 | |
| 1715 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1715 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1716 | 1716 | |
| 1717 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1718 | - echo '<div id="geodir_wrapper">'; |
|
| 1719 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1720 | - echo '</div>'; |
|
| 1717 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1718 | + echo '<div id="geodir_wrapper">'; |
|
| 1719 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1720 | + echo '</div>'; |
|
| 1721 | 1721 | |
| 1722 | 1722 | } |
| 1723 | 1723 | |
@@ -1731,60 +1731,60 @@ discard block |
||
| 1731 | 1731 | */ |
| 1732 | 1732 | function geodir_post_attachments() |
| 1733 | 1733 | {
|
| 1734 | - global $post, $post_id; |
|
| 1734 | + global $post, $post_id; |
|
| 1735 | 1735 | |
| 1736 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1736 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1737 | 1737 | |
| 1738 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1739 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1740 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1741 | - } |
|
| 1738 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1739 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1740 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | - $image_limit = 0; |
|
| 1743 | + $image_limit = 0; |
|
| 1744 | 1744 | |
| 1745 | - ?> |
|
| 1745 | + ?> |
|
| 1746 | 1746 | |
| 1747 | 1747 | |
| 1748 | 1748 | <h5 class="form_title"> |
| 1749 | 1749 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 1750 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1751 | - } ?> |
|
| 1750 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1751 | + } ?> |
|
| 1752 | 1752 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 1753 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1754 | - } ?> |
|
| 1753 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1754 | + } ?> |
|
| 1755 | 1755 | <?php if ($image_limit == 0) {
|
| 1756 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1757 | - } ?> |
|
| 1756 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1757 | + } ?> |
|
| 1758 | 1758 | </h5> |
| 1759 | 1759 | |
| 1760 | 1760 | |
| 1761 | 1761 | <?php |
| 1762 | 1762 | |
| 1763 | - $curImages = geodir_get_images($post_id); |
|
| 1764 | - $place_img_array = array(); |
|
| 1763 | + $curImages = geodir_get_images($post_id); |
|
| 1764 | + $place_img_array = array(); |
|
| 1765 | 1765 | |
| 1766 | - if (!empty($curImages)): |
|
| 1767 | - foreach ($curImages as $p_img): |
|
| 1768 | - $place_img_array[] = $p_img->src; |
|
| 1769 | - endforeach; |
|
| 1770 | - endif; |
|
| 1766 | + if (!empty($curImages)): |
|
| 1767 | + foreach ($curImages as $p_img): |
|
| 1768 | + $place_img_array[] = $p_img->src; |
|
| 1769 | + endforeach; |
|
| 1770 | + endif; |
|
| 1771 | 1771 | |
| 1772 | - if (!empty($place_img_array)) |
|
| 1773 | - $curImages = implode(',', $place_img_array);
|
|
| 1772 | + if (!empty($place_img_array)) |
|
| 1773 | + $curImages = implode(',', $place_img_array);
|
|
| 1774 | 1774 | |
| 1775 | 1775 | |
| 1776 | - // adjust values here |
|
| 1777 | - $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 |
|
| 1776 | + // adjust values here |
|
| 1777 | + $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 |
|
| 1778 | 1778 | |
| 1779 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1779 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1780 | 1780 | |
| 1781 | - $multiple = true; // allow multiple files upload |
|
| 1781 | + $multiple = true; // allow multiple files upload |
|
| 1782 | 1782 | |
| 1783 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1783 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1784 | 1784 | |
| 1785 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1785 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1786 | 1786 | |
| 1787 | - ?> |
|
| 1787 | + ?> |
|
| 1788 | 1788 | |
| 1789 | 1789 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 1790 | 1790 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -1826,13 +1826,13 @@ discard block |
||
| 1826 | 1826 | */ |
| 1827 | 1827 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 1828 | 1828 | {
|
| 1829 | - $post_type = get_post_type($post_ID); |
|
| 1829 | + $post_type = get_post_type($post_ID); |
|
| 1830 | 1830 | |
| 1831 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1832 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
|
|
| 1833 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1834 | - } |
|
| 1835 | - } |
|
| 1831 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1832 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
|
|
| 1833 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1834 | + } |
|
| 1835 | + } |
|
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | /** |
@@ -1847,39 +1847,39 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | function geodir_notification_add_bcc_option($settings) |
| 1849 | 1849 | {
|
| 1850 | - if (!empty($settings)) {
|
|
| 1851 | - $new_settings = array(); |
|
| 1852 | - foreach ($settings as $setting) {
|
|
| 1853 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1854 | - $geodir_bcc_listing_published_yes = array( |
|
| 1855 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1856 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 1857 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1858 | - 'std' => 'yes', |
|
| 1859 | - 'type' => 'radio', |
|
| 1860 | - 'value' => '1', |
|
| 1861 | - 'radiogroup' => 'start' |
|
| 1862 | - ); |
|
| 1863 | - |
|
| 1864 | - $geodir_bcc_listing_published_no = array( |
|
| 1865 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1866 | - 'desc' => __('No', 'geodirectory'),
|
|
| 1867 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1868 | - 'std' => 'yes', |
|
| 1869 | - 'type' => 'radio', |
|
| 1870 | - 'value' => '0', |
|
| 1871 | - 'radiogroup' => 'end' |
|
| 1872 | - ); |
|
| 1873 | - |
|
| 1874 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1875 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1876 | - } |
|
| 1877 | - $new_settings[] = $setting; |
|
| 1878 | - } |
|
| 1879 | - $settings = $new_settings; |
|
| 1880 | - } |
|
| 1850 | + if (!empty($settings)) {
|
|
| 1851 | + $new_settings = array(); |
|
| 1852 | + foreach ($settings as $setting) {
|
|
| 1853 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1854 | + $geodir_bcc_listing_published_yes = array( |
|
| 1855 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1856 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 1857 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1858 | + 'std' => 'yes', |
|
| 1859 | + 'type' => 'radio', |
|
| 1860 | + 'value' => '1', |
|
| 1861 | + 'radiogroup' => 'start' |
|
| 1862 | + ); |
|
| 1863 | + |
|
| 1864 | + $geodir_bcc_listing_published_no = array( |
|
| 1865 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1866 | + 'desc' => __('No', 'geodirectory'),
|
|
| 1867 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1868 | + 'std' => 'yes', |
|
| 1869 | + 'type' => 'radio', |
|
| 1870 | + 'value' => '0', |
|
| 1871 | + 'radiogroup' => 'end' |
|
| 1872 | + ); |
|
| 1873 | + |
|
| 1874 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1875 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1876 | + } |
|
| 1877 | + $new_settings[] = $setting; |
|
| 1878 | + } |
|
| 1879 | + $settings = $new_settings; |
|
| 1880 | + } |
|
| 1881 | 1881 | |
| 1882 | - return $settings; |
|
| 1882 | + return $settings; |
|
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | 1885 | |
@@ -1894,19 +1894,19 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | function get_gd_theme_compat_callback() |
| 1896 | 1896 | {
|
| 1897 | - global $wpdb; |
|
| 1898 | - $themes = get_option('gd_theme_compats');
|
|
| 1899 | - |
|
| 1900 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1901 | - if (isset($_POST['export'])) {
|
|
| 1902 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1903 | - } else {
|
|
| 1904 | - echo json_encode($themes[$_POST['theme']]); |
|
| 1905 | - } |
|
| 1897 | + global $wpdb; |
|
| 1898 | + $themes = get_option('gd_theme_compats');
|
|
| 1906 | 1899 | |
| 1907 | - } |
|
| 1900 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1901 | + if (isset($_POST['export'])) {
|
|
| 1902 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1903 | + } else {
|
|
| 1904 | + echo json_encode($themes[$_POST['theme']]); |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - die(); |
|
| 1909 | + die(); |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -1920,20 +1920,20 @@ discard block |
||
| 1920 | 1920 | */ |
| 1921 | 1921 | function get_gd_theme_compat_import_callback() |
| 1922 | 1922 | {
|
| 1923 | - global $wpdb; |
|
| 1924 | - $themes = get_option('gd_theme_compats');
|
|
| 1925 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1926 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1927 | - if (!empty($json) && is_array($json)) {
|
|
| 1928 | - $key = sanitize_text_field(key($json)); |
|
| 1929 | - $themes[$key] = $json[$key]; |
|
| 1930 | - update_option('gd_theme_compats', $themes);
|
|
| 1931 | - echo $key; |
|
| 1932 | - die(); |
|
| 1933 | - } |
|
| 1934 | - } |
|
| 1935 | - echo '0'; |
|
| 1936 | - die(); |
|
| 1923 | + global $wpdb; |
|
| 1924 | + $themes = get_option('gd_theme_compats');
|
|
| 1925 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1926 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1927 | + if (!empty($json) && is_array($json)) {
|
|
| 1928 | + $key = sanitize_text_field(key($json)); |
|
| 1929 | + $themes[$key] = $json[$key]; |
|
| 1930 | + update_option('gd_theme_compats', $themes);
|
|
| 1931 | + echo $key; |
|
| 1932 | + die(); |
|
| 1933 | + } |
|
| 1934 | + } |
|
| 1935 | + echo '0'; |
|
| 1936 | + die(); |
|
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | |
@@ -1946,39 +1946,39 @@ discard block |
||
| 1946 | 1946 | */ |
| 1947 | 1947 | function gd_set_theme_compat() |
| 1948 | 1948 | {
|
| 1949 | - global $wpdb; |
|
| 1950 | - $theme = wp_get_theme(); |
|
| 1949 | + global $wpdb; |
|
| 1950 | + $theme = wp_get_theme(); |
|
| 1951 | 1951 | |
| 1952 | - if ($theme->parent()) {
|
|
| 1953 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1954 | - } else {
|
|
| 1955 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1956 | - } |
|
| 1952 | + if ($theme->parent()) {
|
|
| 1953 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1954 | + } else {
|
|
| 1955 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1956 | + } |
|
| 1957 | 1957 | |
| 1958 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 1959 | - $current_compat = get_option('gd_theme_compat');
|
|
| 1960 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1958 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 1959 | + $current_compat = get_option('gd_theme_compat');
|
|
| 1960 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1961 | 1961 | |
| 1962 | - if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1963 | - return; |
|
| 1964 | - }// if already running correct compat then bail |
|
| 1962 | + if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1963 | + return; |
|
| 1964 | + }// if already running correct compat then bail |
|
| 1965 | 1965 | |
| 1966 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1967 | - update_option('gd_theme_compat', $theme_name);
|
|
| 1968 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1966 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1967 | + update_option('gd_theme_compat', $theme_name);
|
|
| 1968 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1969 | 1969 | |
| 1970 | - // if there are default options to set then set them |
|
| 1971 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1970 | + // if there are default options to set then set them |
|
| 1971 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1972 | 1972 | |
| 1973 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1974 | - update_option($key, $val); |
|
| 1975 | - } |
|
| 1976 | - } |
|
| 1973 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1974 | + update_option($key, $val); |
|
| 1975 | + } |
|
| 1976 | + } |
|
| 1977 | 1977 | |
| 1978 | - } else {
|
|
| 1979 | - update_option('gd_theme_compat', '');
|
|
| 1980 | - update_option('theme_compatibility_setting', '');
|
|
| 1981 | - } |
|
| 1978 | + } else {
|
|
| 1979 | + update_option('gd_theme_compat', '');
|
|
| 1980 | + update_option('theme_compatibility_setting', '');
|
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | 1983 | |
| 1984 | 1984 | } |
@@ -1993,9 +1993,9 @@ discard block |
||
| 1993 | 1993 | */ |
| 1994 | 1994 | function gd_check_avada_compat() |
| 1995 | 1995 | {
|
| 1996 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 1997 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 1998 | - } |
|
| 1996 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 1997 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 1998 | + } |
|
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | 2001 | |
@@ -2008,22 +2008,22 @@ discard block |
||
| 2008 | 2008 | function gd_avada_compat_warning() |
| 2009 | 2009 | {
|
| 2010 | 2010 | |
| 2011 | - /* |
|
| 2011 | + /* |
|
| 2012 | 2012 | $msg_type = error |
| 2013 | 2013 | $msg_type = updated fade |
| 2014 | 2014 | $msg_type = update-nag |
| 2015 | 2015 | */ |
| 2016 | 2016 | |
| 2017 | - $plugin = 'avada-nag'; |
|
| 2018 | - $timestamp = 'avada-nag1234'; |
|
| 2019 | - $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
|
|
| 2020 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2021 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2022 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2023 | - echo "<p>$message</p>"; |
|
| 2024 | - echo "</div>"; |
|
| 2017 | + $plugin = 'avada-nag'; |
|
| 2018 | + $timestamp = 'avada-nag1234'; |
|
| 2019 | + $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
|
|
| 2020 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2021 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2022 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2023 | + echo "<p>$message</p>"; |
|
| 2024 | + echo "</div>"; |
|
| 2025 | 2025 | |
| 2026 | - ?> |
|
| 2026 | + ?> |
|
| 2027 | 2027 | <script> |
| 2028 | 2028 | function gdRemoveANotification($plugin, $timestamp) {
|
| 2029 | 2029 | |
@@ -2091,10 +2091,10 @@ discard block |
||
| 2091 | 2091 | */ |
| 2092 | 2092 | function geodir_avada_remove_notification() |
| 2093 | 2093 | {
|
| 2094 | - update_option('avada_nag', TRUE);
|
|
| 2094 | + update_option('avada_nag', TRUE);
|
|
| 2095 | 2095 | |
| 2096 | - // Always die in functions echoing ajax content |
|
| 2097 | - die(); |
|
| 2096 | + // Always die in functions echoing ajax content |
|
| 2097 | + die(); |
|
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | 2100 | |
@@ -2116,9 +2116,9 @@ discard block |
||
| 2116 | 2116 | global $post, $typenow, $current_screen; |
| 2117 | 2117 | |
| 2118 | 2118 | $post_type = NULL; |
| 2119 | - if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2119 | + if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2120 | 2120 | $post_type = get_post_type($_REQUEST['post']); |
| 2121 | - elseif ($post && isset($post->post_type)) |
|
| 2121 | + elseif ($post && isset($post->post_type)) |
|
| 2122 | 2122 | $post_type = $post->post_type; |
| 2123 | 2123 | elseif ($typenow) |
| 2124 | 2124 | $post_type = $typenow; |
@@ -2153,7 +2153,7 @@ discard block |
||
| 2153 | 2153 | // Don't allow same slug url for listing and location |
| 2154 | 2154 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2155 | 2155 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 2156 | - wp_redirect($redirect_url); |
|
| 2156 | + wp_redirect($redirect_url); |
|
| 2157 | 2157 | exit; |
| 2158 | 2158 | } |
| 2159 | 2159 | |
@@ -2183,10 +2183,10 @@ discard block |
||
| 2183 | 2183 | * @package GeoDirectory |
| 2184 | 2184 | */ |
| 2185 | 2185 | function geodir_hide_admin_preview_button() {
|
| 2186 | - global $post_type; |
|
| 2187 | - $post_types = geodir_get_posttypes(); |
|
| 2188 | - if(in_array($post_type, $post_types)) |
|
| 2189 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2186 | + global $post_type; |
|
| 2187 | + $post_types = geodir_get_posttypes(); |
|
| 2188 | + if(in_array($post_type, $post_types)) |
|
| 2189 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2190 | 2190 | } |
| 2191 | 2191 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 2192 | 2192 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2201,7 +2201,7 @@ discard block |
||
| 2201 | 2201 | */ |
| 2202 | 2202 | function geodir_import_export_tab( $tabs ) {
|
| 2203 | 2203 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 2204 | - return $tabs; |
|
| 2204 | + return $tabs; |
|
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | /** |
@@ -2216,26 +2216,26 @@ discard block |
||
| 2216 | 2216 | function geodir_import_export_page() {
|
| 2217 | 2217 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 2218 | 2218 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 2219 | - /** |
|
| 2220 | - * Filter sample category data csv file url. |
|
| 2221 | - * |
|
| 2222 | - * @since 1.0.0 |
|
| 2223 | - * @package GeoDirectory |
|
| 2224 | - * |
|
| 2225 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2226 | - */ |
|
| 2219 | + /** |
|
| 2220 | + * Filter sample category data csv file url. |
|
| 2221 | + * |
|
| 2222 | + * @since 1.0.0 |
|
| 2223 | + * @package GeoDirectory |
|
| 2224 | + * |
|
| 2225 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2226 | + */ |
|
| 2227 | 2227 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 2228 | 2228 | |
| 2229 | 2229 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 2230 | - /** |
|
| 2231 | - * Filter sample post data csv file url. |
|
| 2232 | - * |
|
| 2233 | - * @since 1.0.0 |
|
| 2234 | - * @package GeoDirectory |
|
| 2235 | - * |
|
| 2236 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2237 | - */ |
|
| 2238 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2230 | + /** |
|
| 2231 | + * Filter sample post data csv file url. |
|
| 2232 | + * |
|
| 2233 | + * @since 1.0.0 |
|
| 2234 | + * @package GeoDirectory |
|
| 2235 | + * |
|
| 2236 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2237 | + */ |
|
| 2238 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2239 | 2239 | |
| 2240 | 2240 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 2241 | 2241 | |
@@ -2258,14 +2258,14 @@ discard block |
||
| 2258 | 2258 | $gd_chunksize_options[100000] = 100000; |
| 2259 | 2259 | |
| 2260 | 2260 | /** |
| 2261 | - * Filter max entries per export csv file. |
|
| 2262 | - * |
|
| 2263 | - * @since 1.5.6 |
|
| 2264 | - * @package GeoDirectory |
|
| 2265 | - * |
|
| 2266 | - * @param string $gd_chunksize_options Entries options. |
|
| 2267 | - */ |
|
| 2268 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2261 | + * Filter max entries per export csv file. |
|
| 2262 | + * |
|
| 2263 | + * @since 1.5.6 |
|
| 2264 | + * @package GeoDirectory |
|
| 2265 | + * |
|
| 2266 | + * @param string $gd_chunksize_options Entries options. |
|
| 2267 | + */ |
|
| 2268 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2269 | 2269 | |
| 2270 | 2270 | $gd_chunksize_option = ''; |
| 2271 | 2271 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -2282,12 +2282,12 @@ discard block |
||
| 2282 | 2282 | <div class="gd-content-heading"> |
| 2283 | 2283 | |
| 2284 | 2284 | <?php |
| 2285 | - ini_set('max_execution_time', 999999);
|
|
| 2286 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2287 | - ini_restore('max_execution_time');
|
|
| 2285 | + ini_set('max_execution_time', 999999);
|
|
| 2286 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2287 | + ini_restore('max_execution_time');
|
|
| 2288 | 2288 | |
| 2289 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2290 | - ?> |
|
| 2289 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2290 | + ?> |
|
| 2291 | 2291 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2292 | 2292 | <div class="meta-box-sortables ui-sortable"> |
| 2293 | 2293 | <div class="postbox"> |
@@ -2462,7 +2462,7 @@ discard block |
||
| 2462 | 2462 | * Called just after the sample CSV download link. |
| 2463 | 2463 | * |
| 2464 | 2464 | * @since 1.0.0 |
| 2465 | - * @package GeoDirectory |
|
| 2465 | + * @package GeoDirectory |
|
| 2466 | 2466 | */ |
| 2467 | 2467 | do_action('geodir_sample_cats_csv_download_link');
|
| 2468 | 2468 | ?> |
@@ -2547,11 +2547,11 @@ discard block |
||
| 2547 | 2547 | * |
| 2548 | 2548 | * Called after the last setting on the GD > Import & Export page. |
| 2549 | 2549 | * @since 1.4.6 |
| 2550 | - * @package GeoDirectory |
|
| 2550 | + * @package GeoDirectory |
|
| 2551 | 2551 | * |
| 2552 | 2552 | * @param array $gd_posttypes GD post types. |
| 2553 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 2554 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 2553 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 2554 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 2555 | 2555 | */ |
| 2556 | 2556 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 2557 | 2557 | ?> |
@@ -3238,44 +3238,44 @@ discard block |
||
| 3238 | 3238 | function geodir_init_filesystem() |
| 3239 | 3239 | {
|
| 3240 | 3240 | |
| 3241 | - if(!function_exists('get_filesystem_method')){
|
|
| 3242 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3243 | - } |
|
| 3244 | - $access_type = get_filesystem_method(); |
|
| 3245 | - if ($access_type === 'direct') {
|
|
| 3246 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3247 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3248 | - |
|
| 3249 | - /* initialize the API */ |
|
| 3250 | - if (!WP_Filesystem($creds)) {
|
|
| 3251 | - /* any problems and we exit */ |
|
| 3252 | - //return '@@@3'; |
|
| 3253 | - return false; |
|
| 3254 | - } |
|
| 3241 | + if(!function_exists('get_filesystem_method')){
|
|
| 3242 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3243 | + } |
|
| 3244 | + $access_type = get_filesystem_method(); |
|
| 3245 | + if ($access_type === 'direct') {
|
|
| 3246 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3247 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3248 | + |
|
| 3249 | + /* initialize the API */ |
|
| 3250 | + if (!WP_Filesystem($creds)) {
|
|
| 3251 | + /* any problems and we exit */ |
|
| 3252 | + //return '@@@3'; |
|
| 3253 | + return false; |
|
| 3254 | + } |
|
| 3255 | 3255 | |
| 3256 | - global $wp_filesystem; |
|
| 3257 | - return $wp_filesystem; |
|
| 3258 | - /* do our file manipulations below */ |
|
| 3259 | - } elseif (defined('FTP_USER')) {
|
|
| 3260 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3256 | + global $wp_filesystem; |
|
| 3257 | + return $wp_filesystem; |
|
| 3258 | + /* do our file manipulations below */ |
|
| 3259 | + } elseif (defined('FTP_USER')) {
|
|
| 3260 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3261 | + |
|
| 3262 | + /* initialize the API */ |
|
| 3263 | + if (!WP_Filesystem($creds)) {
|
|
| 3264 | + /* any problems and we exit */ |
|
| 3265 | + //return '@@@33'; |
|
| 3266 | + return false; |
|
| 3267 | + } |
|
| 3261 | 3268 | |
| 3262 | - /* initialize the API */ |
|
| 3263 | - if (!WP_Filesystem($creds)) {
|
|
| 3264 | - /* any problems and we exit */ |
|
| 3265 | - //return '@@@33'; |
|
| 3266 | - return false; |
|
| 3267 | - } |
|
| 3269 | + global $wp_filesystem; |
|
| 3270 | + //return '@@@1'; |
|
| 3271 | + return $wp_filesystem; |
|
| 3268 | 3272 | |
| 3269 | - global $wp_filesystem; |
|
| 3270 | - //return '@@@1'; |
|
| 3271 | - return $wp_filesystem; |
|
| 3272 | - |
|
| 3273 | - } else {
|
|
| 3274 | - //return '@@@2'; |
|
| 3275 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 3276 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3277 | - return false; |
|
| 3278 | - } |
|
| 3273 | + } else {
|
|
| 3274 | + //return '@@@2'; |
|
| 3275 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 3276 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3277 | + return false; |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | 3280 | } |
| 3281 | 3281 | |
@@ -3293,10 +3293,10 @@ discard block |
||
| 3293 | 3293 | */ |
| 3294 | 3294 | function geodir_filesystem_notice() |
| 3295 | 3295 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 3296 | - $access_type = get_filesystem_method(); |
|
| 3297 | - if ($access_type === 'direct') {
|
|
| 3298 | - } elseif (!defined('FTP_USER')) {
|
|
| 3299 | - ?> |
|
| 3296 | + $access_type = get_filesystem_method(); |
|
| 3297 | + if ($access_type === 'direct') {
|
|
| 3298 | + } elseif (!defined('FTP_USER')) {
|
|
| 3299 | + ?> |
|
| 3300 | 3300 | <div class="error"> |
| 3301 | 3301 | <p><?php _e('GeoDirectory does not have access to your filesystem, thing like import/export will not work. Please define your details in wp-config.php as explained here', 'geodirectory'); ?>
|
| 3302 | 3302 | <a target="_blank" href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants</a> |
@@ -3323,1265 +3323,1265 @@ discard block |
||
| 3323 | 3323 | * @return string Json data. |
| 3324 | 3324 | */ |
| 3325 | 3325 | function geodir_ajax_import_export() {
|
| 3326 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3326 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3327 | 3327 | |
| 3328 | - error_reporting(0); |
|
| 3328 | + error_reporting(0); |
|
| 3329 | 3329 | |
| 3330 | - $xstart = microtime(true); |
|
| 3330 | + $xstart = microtime(true); |
|
| 3331 | 3331 | |
| 3332 | - // try to set higher limits for import |
|
| 3333 | - $max_input_time = ini_get('max_input_time');
|
|
| 3334 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 3335 | - $memory_limit= ini_get('memory_limit');
|
|
| 3332 | + // try to set higher limits for import |
|
| 3333 | + $max_input_time = ini_get('max_input_time');
|
|
| 3334 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 3335 | + $memory_limit= ini_get('memory_limit');
|
|
| 3336 | 3336 | |
| 3337 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3338 | - ini_set('max_input_time', 3000);
|
|
| 3339 | - } |
|
| 3337 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 3338 | + ini_set('max_input_time', 3000);
|
|
| 3339 | + } |
|
| 3340 | 3340 | |
| 3341 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3342 | - ini_set('max_execution_time', 3000);
|
|
| 3343 | - } |
|
| 3341 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3342 | + ini_set('max_execution_time', 3000);
|
|
| 3343 | + } |
|
| 3344 | 3344 | |
| 3345 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3346 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3347 | - ini_set('memory_limit', '256M');
|
|
| 3348 | - } |
|
| 3349 | - } |
|
| 3345 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3346 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 3347 | + ini_set('memory_limit', '256M');
|
|
| 3348 | + } |
|
| 3349 | + } |
|
| 3350 | 3350 | |
| 3351 | - $json = array(); |
|
| 3351 | + $json = array(); |
|
| 3352 | 3352 | |
| 3353 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3354 | - wp_send_json( $json ); |
|
| 3355 | - } |
|
| 3353 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3354 | + wp_send_json( $json ); |
|
| 3355 | + } |
|
| 3356 | 3356 | |
| 3357 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3358 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3359 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3357 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3358 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3359 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3360 | 3360 | |
| 3361 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3362 | - wp_send_json( $json ); |
|
| 3363 | - } |
|
| 3361 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3362 | + wp_send_json( $json ); |
|
| 3363 | + } |
|
| 3364 | 3364 | |
| 3365 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3366 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3367 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3368 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3365 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3366 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3367 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3368 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3369 | 3369 | |
| 3370 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 3371 | - if (!$wp_filesystem) {
|
|
| 3372 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3373 | - wp_send_json( $json ); |
|
| 3374 | - } |
|
| 3370 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 3371 | + if (!$wp_filesystem) {
|
|
| 3372 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3373 | + wp_send_json( $json ); |
|
| 3374 | + } |
|
| 3375 | 3375 | |
| 3376 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3377 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3378 | - wp_send_json( $json ); |
|
| 3379 | - } |
|
| 3376 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3377 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3378 | + wp_send_json( $json ); |
|
| 3379 | + } |
|
| 3380 | 3380 | |
| 3381 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3382 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3383 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3384 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3385 | - wp_send_json( $json ); |
|
| 3386 | - } |
|
| 3387 | - } |
|
| 3381 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 3382 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3383 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3384 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3385 | + wp_send_json( $json ); |
|
| 3386 | + } |
|
| 3387 | + } |
|
| 3388 | 3388 | |
| 3389 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3390 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3391 | - |
|
| 3392 | - switch ( $task ) {
|
|
| 3393 | - case 'export_posts': {
|
|
| 3394 | - // WPML |
|
| 3395 | - $is_wpml = geodir_is_wpml(); |
|
| 3396 | - if ($is_wpml) {
|
|
| 3397 | - global $sitepress; |
|
| 3398 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3389 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3390 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3391 | + |
|
| 3392 | + switch ( $task ) {
|
|
| 3393 | + case 'export_posts': {
|
|
| 3394 | + // WPML |
|
| 3395 | + $is_wpml = geodir_is_wpml(); |
|
| 3396 | + if ($is_wpml) {
|
|
| 3397 | + global $sitepress; |
|
| 3398 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3399 | 3399 | |
| 3400 | - $sitepress->switch_lang('all', true);
|
|
| 3401 | - } |
|
| 3402 | - // WPML |
|
| 3403 | - if ( $post_type == 'gd_event' ) {
|
|
| 3404 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3405 | - } |
|
| 3406 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3400 | + $sitepress->switch_lang('all', true);
|
|
| 3401 | + } |
|
| 3402 | + // WPML |
|
| 3403 | + if ( $post_type == 'gd_event' ) {
|
|
| 3404 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3405 | + } |
|
| 3406 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3407 | 3407 | |
| 3408 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3409 | - if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3410 | - $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3411 | - } |
|
| 3412 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3413 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3414 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3415 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3416 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3408 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3409 | + if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3410 | + $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3411 | + } |
|
| 3412 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3413 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3414 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3415 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3416 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3417 | 3417 | |
| 3418 | - $chunk_file_paths = array(); |
|
| 3418 | + $chunk_file_paths = array(); |
|
| 3419 | 3419 | |
| 3420 | - if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3421 | - $json['total'] = $posts_count; |
|
| 3422 | - // WPML |
|
| 3423 | - if ($is_wpml) {
|
|
| 3424 | - $sitepress->switch_lang($active_lang, true); |
|
| 3425 | - } |
|
| 3426 | - // WPML |
|
| 3427 | - wp_send_json( $json ); |
|
| 3428 | - gd_die(); |
|
| 3429 | - } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3430 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3431 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3432 | - $percentage = min( $percentage, 100 ); |
|
| 3420 | + if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3421 | + $json['total'] = $posts_count; |
|
| 3422 | + // WPML |
|
| 3423 | + if ($is_wpml) {
|
|
| 3424 | + $sitepress->switch_lang($active_lang, true); |
|
| 3425 | + } |
|
| 3426 | + // WPML |
|
| 3427 | + wp_send_json( $json ); |
|
| 3428 | + gd_die(); |
|
| 3429 | + } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3430 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3431 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3432 | + $percentage = min( $percentage, 100 ); |
|
| 3433 | 3433 | |
| 3434 | - $json['percentage'] = $percentage; |
|
| 3435 | - // WPML |
|
| 3436 | - if ($is_wpml) {
|
|
| 3437 | - $sitepress->switch_lang($active_lang, true); |
|
| 3438 | - } |
|
| 3439 | - // WPML |
|
| 3440 | - wp_send_json( $json ); |
|
| 3441 | - gd_die(); |
|
| 3442 | - } else {
|
|
| 3443 | - if ( !$posts_count > 0 ) {
|
|
| 3444 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3445 | - } else {
|
|
| 3446 | - $total_posts = $posts_count; |
|
| 3447 | - if ($chunk_per_page > $total_posts) {
|
|
| 3448 | - $chunk_per_page = $total_posts; |
|
| 3449 | - } |
|
| 3450 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3434 | + $json['percentage'] = $percentage; |
|
| 3435 | + // WPML |
|
| 3436 | + if ($is_wpml) {
|
|
| 3437 | + $sitepress->switch_lang($active_lang, true); |
|
| 3438 | + } |
|
| 3439 | + // WPML |
|
| 3440 | + wp_send_json( $json ); |
|
| 3441 | + gd_die(); |
|
| 3442 | + } else {
|
|
| 3443 | + if ( !$posts_count > 0 ) {
|
|
| 3444 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3445 | + } else {
|
|
| 3446 | + $total_posts = $posts_count; |
|
| 3447 | + if ($chunk_per_page > $total_posts) {
|
|
| 3448 | + $chunk_per_page = $total_posts; |
|
| 3449 | + } |
|
| 3450 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3451 | 3451 | |
| 3452 | - $j = $chunk_page_no; |
|
| 3453 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3452 | + $j = $chunk_page_no; |
|
| 3453 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3454 | 3454 | |
| 3455 | - $per_page = 500; |
|
| 3456 | - if ($per_page > $chunk_per_page) {
|
|
| 3457 | - $per_page = $chunk_per_page; |
|
| 3458 | - } |
|
| 3459 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3455 | + $per_page = 500; |
|
| 3456 | + if ($per_page > $chunk_per_page) {
|
|
| 3457 | + $per_page = $chunk_per_page; |
|
| 3458 | + } |
|
| 3459 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3460 | 3460 | |
| 3461 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3462 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3461 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3462 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3463 | 3463 | |
| 3464 | - $clear = $i == 0 ? true : false; |
|
| 3465 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3466 | - } |
|
| 3464 | + $clear = $i == 0 ? true : false; |
|
| 3465 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3466 | + } |
|
| 3467 | 3467 | |
| 3468 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3469 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3470 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3471 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3472 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3468 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3469 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3470 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3471 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3472 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3473 | 3473 | |
| 3474 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3475 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3476 | - } |
|
| 3474 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3475 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3476 | + } |
|
| 3477 | 3477 | |
| 3478 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3479 | - $json['total'] = $posts_count; |
|
| 3480 | - $json['files'] = $chunk_file_paths; |
|
| 3481 | - } else {
|
|
| 3482 | - if ($j > 1) {
|
|
| 3483 | - $json['total'] = $posts_count; |
|
| 3484 | - $json['files'] = array(); |
|
| 3485 | - } else {
|
|
| 3486 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3487 | - } |
|
| 3488 | - } |
|
| 3489 | - } |
|
| 3490 | - // WPML |
|
| 3491 | - if ($is_wpml) {
|
|
| 3492 | - $sitepress->switch_lang($active_lang, true); |
|
| 3493 | - } |
|
| 3494 | - // WPML |
|
| 3495 | - wp_send_json( $json ); |
|
| 3496 | - } |
|
| 3497 | - } |
|
| 3498 | - break; |
|
| 3499 | - case 'export_cats': {
|
|
| 3500 | - // WPML |
|
| 3501 | - $is_wpml = geodir_is_wpml(); |
|
| 3502 | - if ($is_wpml) {
|
|
| 3503 | - global $sitepress; |
|
| 3504 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3478 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3479 | + $json['total'] = $posts_count; |
|
| 3480 | + $json['files'] = $chunk_file_paths; |
|
| 3481 | + } else {
|
|
| 3482 | + if ($j > 1) {
|
|
| 3483 | + $json['total'] = $posts_count; |
|
| 3484 | + $json['files'] = array(); |
|
| 3485 | + } else {
|
|
| 3486 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3487 | + } |
|
| 3488 | + } |
|
| 3489 | + } |
|
| 3490 | + // WPML |
|
| 3491 | + if ($is_wpml) {
|
|
| 3492 | + $sitepress->switch_lang($active_lang, true); |
|
| 3493 | + } |
|
| 3494 | + // WPML |
|
| 3495 | + wp_send_json( $json ); |
|
| 3496 | + } |
|
| 3497 | + } |
|
| 3498 | + break; |
|
| 3499 | + case 'export_cats': {
|
|
| 3500 | + // WPML |
|
| 3501 | + $is_wpml = geodir_is_wpml(); |
|
| 3502 | + if ($is_wpml) {
|
|
| 3503 | + global $sitepress; |
|
| 3504 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3505 | 3505 | |
| 3506 | - $sitepress->switch_lang('all', true);
|
|
| 3507 | - } |
|
| 3508 | - // WPML |
|
| 3509 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3506 | + $sitepress->switch_lang('all', true);
|
|
| 3507 | + } |
|
| 3508 | + // WPML |
|
| 3509 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3510 | 3510 | |
| 3511 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3512 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3513 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3514 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3515 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3511 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3512 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3513 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3514 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3515 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3516 | 3516 | |
| 3517 | - $chunk_file_paths = array(); |
|
| 3517 | + $chunk_file_paths = array(); |
|
| 3518 | 3518 | |
| 3519 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3520 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3521 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3522 | - $percentage = min( $percentage, 100 ); |
|
| 3519 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3520 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3521 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3522 | + $percentage = min( $percentage, 100 ); |
|
| 3523 | 3523 | |
| 3524 | - $json['percentage'] = $percentage; |
|
| 3525 | - // WPML |
|
| 3526 | - if ($is_wpml) {
|
|
| 3527 | - $sitepress->switch_lang($active_lang, true); |
|
| 3528 | - } |
|
| 3529 | - // WPML |
|
| 3530 | - wp_send_json( $json ); |
|
| 3531 | - } else {
|
|
| 3532 | - if ( !$terms_count > 0 ) {
|
|
| 3533 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3534 | - } else {
|
|
| 3535 | - $total_terms = $terms_count; |
|
| 3536 | - if ($chunk_per_page > $terms_count) {
|
|
| 3537 | - $chunk_per_page = $terms_count; |
|
| 3538 | - } |
|
| 3539 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3524 | + $json['percentage'] = $percentage; |
|
| 3525 | + // WPML |
|
| 3526 | + if ($is_wpml) {
|
|
| 3527 | + $sitepress->switch_lang($active_lang, true); |
|
| 3528 | + } |
|
| 3529 | + // WPML |
|
| 3530 | + wp_send_json( $json ); |
|
| 3531 | + } else {
|
|
| 3532 | + if ( !$terms_count > 0 ) {
|
|
| 3533 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3534 | + } else {
|
|
| 3535 | + $total_terms = $terms_count; |
|
| 3536 | + if ($chunk_per_page > $terms_count) {
|
|
| 3537 | + $chunk_per_page = $terms_count; |
|
| 3538 | + } |
|
| 3539 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3540 | 3540 | |
| 3541 | - $j = $chunk_page_no; |
|
| 3542 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3541 | + $j = $chunk_page_no; |
|
| 3542 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3543 | 3543 | |
| 3544 | - $per_page = 500; |
|
| 3545 | - if ($per_page > $chunk_per_page) {
|
|
| 3546 | - $per_page = $chunk_per_page; |
|
| 3547 | - } |
|
| 3548 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3544 | + $per_page = 500; |
|
| 3545 | + if ($per_page > $chunk_per_page) {
|
|
| 3546 | + $per_page = $chunk_per_page; |
|
| 3547 | + } |
|
| 3548 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3549 | 3549 | |
| 3550 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3551 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3550 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3551 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3552 | 3552 | |
| 3553 | - $clear = $i == 0 ? true : false; |
|
| 3554 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3555 | - } |
|
| 3553 | + $clear = $i == 0 ? true : false; |
|
| 3554 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3555 | + } |
|
| 3556 | 3556 | |
| 3557 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3558 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3559 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3560 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3561 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3557 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3558 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3559 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3560 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3561 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3562 | 3562 | |
| 3563 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3564 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3565 | - } |
|
| 3563 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3564 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3565 | + } |
|
| 3566 | 3566 | |
| 3567 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3568 | - $json['total'] = $terms_count; |
|
| 3569 | - $json['files'] = $chunk_file_paths; |
|
| 3570 | - } else {
|
|
| 3571 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3572 | - } |
|
| 3573 | - } |
|
| 3574 | - // WPML |
|
| 3575 | - if ($is_wpml) {
|
|
| 3576 | - $sitepress->switch_lang($active_lang, true); |
|
| 3577 | - } |
|
| 3578 | - // WPML |
|
| 3579 | - wp_send_json( $json ); |
|
| 3580 | - } |
|
| 3581 | - } |
|
| 3582 | - break; |
|
| 3583 | - case 'export_locations': {
|
|
| 3584 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3585 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3586 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3587 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3588 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3567 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3568 | + $json['total'] = $terms_count; |
|
| 3569 | + $json['files'] = $chunk_file_paths; |
|
| 3570 | + } else {
|
|
| 3571 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3572 | + } |
|
| 3573 | + } |
|
| 3574 | + // WPML |
|
| 3575 | + if ($is_wpml) {
|
|
| 3576 | + $sitepress->switch_lang($active_lang, true); |
|
| 3577 | + } |
|
| 3578 | + // WPML |
|
| 3579 | + wp_send_json( $json ); |
|
| 3580 | + } |
|
| 3581 | + } |
|
| 3582 | + break; |
|
| 3583 | + case 'export_locations': {
|
|
| 3584 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3585 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3586 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3587 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3588 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3589 | 3589 | |
| 3590 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3590 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3591 | 3591 | |
| 3592 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3593 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3594 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3595 | - $percentage = min( $percentage, 100 ); |
|
| 3592 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3593 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3594 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3595 | + $percentage = min( $percentage, 100 ); |
|
| 3596 | 3596 | |
| 3597 | - $json['percentage'] = $percentage; |
|
| 3598 | - wp_send_json( $json ); |
|
| 3599 | - } else {
|
|
| 3600 | - $chunk_file_paths = array(); |
|
| 3597 | + $json['percentage'] = $percentage; |
|
| 3598 | + wp_send_json( $json ); |
|
| 3599 | + } else {
|
|
| 3600 | + $chunk_file_paths = array(); |
|
| 3601 | 3601 | |
| 3602 | - if ( !$items_count > 0 ) {
|
|
| 3603 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3604 | - } else {
|
|
| 3605 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3606 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3602 | + if ( !$items_count > 0 ) {
|
|
| 3603 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3604 | + } else {
|
|
| 3605 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3606 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3607 | 3607 | |
| 3608 | - $j = $chunk_page_no; |
|
| 3609 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3608 | + $j = $chunk_page_no; |
|
| 3609 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3610 | 3610 | |
| 3611 | - $per_page = 500; |
|
| 3612 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3613 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3611 | + $per_page = 500; |
|
| 3612 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3613 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3614 | 3614 | |
| 3615 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3616 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3615 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3616 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3617 | 3617 | |
| 3618 | - $clear = $i == 0 ? true : false; |
|
| 3619 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3620 | - } |
|
| 3618 | + $clear = $i == 0 ? true : false; |
|
| 3619 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3620 | + } |
|
| 3621 | 3621 | |
| 3622 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3623 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3624 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3625 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3626 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3622 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3623 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3624 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3625 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3626 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3627 | 3627 | |
| 3628 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3629 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3630 | - } |
|
| 3628 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3629 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3630 | + } |
|
| 3631 | 3631 | |
| 3632 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3633 | - $json['total'] = $items_count; |
|
| 3634 | - $json['files'] = $chunk_file_paths; |
|
| 3635 | - } else {
|
|
| 3636 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3637 | - } |
|
| 3638 | - } |
|
| 3639 | - wp_send_json( $json ); |
|
| 3640 | - } |
|
| 3641 | - } |
|
| 3642 | - break; |
|
| 3643 | - case 'export_hoods': {
|
|
| 3644 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3645 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3646 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3647 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3648 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3632 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3633 | + $json['total'] = $items_count; |
|
| 3634 | + $json['files'] = $chunk_file_paths; |
|
| 3635 | + } else {
|
|
| 3636 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3637 | + } |
|
| 3638 | + } |
|
| 3639 | + wp_send_json( $json ); |
|
| 3640 | + } |
|
| 3641 | + } |
|
| 3642 | + break; |
|
| 3643 | + case 'export_hoods': {
|
|
| 3644 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3645 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3646 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3647 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3648 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3649 | 3649 | |
| 3650 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3650 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3651 | 3651 | |
| 3652 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3653 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3654 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3655 | - $percentage = min( $percentage, 100 ); |
|
| 3652 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3653 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3654 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3655 | + $percentage = min( $percentage, 100 ); |
|
| 3656 | 3656 | |
| 3657 | - $json['percentage'] = $percentage; |
|
| 3658 | - wp_send_json( $json ); |
|
| 3659 | - } else {
|
|
| 3660 | - $chunk_file_paths = array(); |
|
| 3657 | + $json['percentage'] = $percentage; |
|
| 3658 | + wp_send_json( $json ); |
|
| 3659 | + } else {
|
|
| 3660 | + $chunk_file_paths = array(); |
|
| 3661 | 3661 | |
| 3662 | - if ( !$items_count > 0 ) {
|
|
| 3663 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3664 | - } else {
|
|
| 3665 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3666 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3662 | + if ( !$items_count > 0 ) {
|
|
| 3663 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3664 | + } else {
|
|
| 3665 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3666 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3667 | 3667 | |
| 3668 | - $j = $chunk_page_no; |
|
| 3669 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3668 | + $j = $chunk_page_no; |
|
| 3669 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3670 | 3670 | |
| 3671 | - $per_page = 500; |
|
| 3672 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3673 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3671 | + $per_page = 500; |
|
| 3672 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3673 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3674 | 3674 | |
| 3675 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3676 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3675 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3676 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3677 | 3677 | |
| 3678 | - $clear = $i == 0 ? true : false; |
|
| 3679 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3680 | - } |
|
| 3678 | + $clear = $i == 0 ? true : false; |
|
| 3679 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3680 | + } |
|
| 3681 | 3681 | |
| 3682 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3683 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3684 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3685 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3686 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3682 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3683 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3684 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3685 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3686 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3687 | 3687 | |
| 3688 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3689 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3690 | - } |
|
| 3688 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3689 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3690 | + } |
|
| 3691 | 3691 | |
| 3692 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3693 | - $json['total'] = $items_count; |
|
| 3694 | - $json['files'] = $chunk_file_paths; |
|
| 3695 | - } else {
|
|
| 3696 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3697 | - } |
|
| 3698 | - } |
|
| 3699 | - wp_send_json( $json ); |
|
| 3700 | - } |
|
| 3701 | - } |
|
| 3702 | - break; |
|
| 3703 | - case 'prepare_import': |
|
| 3704 | - case 'import_cat': |
|
| 3705 | - case 'import_post': |
|
| 3706 | - case 'import_loc': |
|
| 3707 | - case 'import_hood': {
|
|
| 3708 | - // WPML |
|
| 3709 | - $is_wpml = geodir_is_wpml(); |
|
| 3710 | - if ($is_wpml) {
|
|
| 3711 | - global $sitepress; |
|
| 3712 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3713 | - } |
|
| 3714 | - // WPML |
|
| 3692 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3693 | + $json['total'] = $items_count; |
|
| 3694 | + $json['files'] = $chunk_file_paths; |
|
| 3695 | + } else {
|
|
| 3696 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3697 | + } |
|
| 3698 | + } |
|
| 3699 | + wp_send_json( $json ); |
|
| 3700 | + } |
|
| 3701 | + } |
|
| 3702 | + break; |
|
| 3703 | + case 'prepare_import': |
|
| 3704 | + case 'import_cat': |
|
| 3705 | + case 'import_post': |
|
| 3706 | + case 'import_loc': |
|
| 3707 | + case 'import_hood': {
|
|
| 3708 | + // WPML |
|
| 3709 | + $is_wpml = geodir_is_wpml(); |
|
| 3710 | + if ($is_wpml) {
|
|
| 3711 | + global $sitepress; |
|
| 3712 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3713 | + } |
|
| 3714 | + // WPML |
|
| 3715 | 3715 | |
| 3716 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3716 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 3717 | 3717 | |
| 3718 | - $uploads = wp_upload_dir(); |
|
| 3719 | - $uploads_dir = $uploads['path']; |
|
| 3720 | - $uploads_subdir = $uploads['subdir']; |
|
| 3718 | + $uploads = wp_upload_dir(); |
|
| 3719 | + $uploads_dir = $uploads['path']; |
|
| 3720 | + $uploads_subdir = $uploads['subdir']; |
|
| 3721 | 3721 | |
| 3722 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3723 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3722 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3723 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3724 | 3724 | |
| 3725 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3726 | - $csv_filename = end( $csv_file_arr ); |
|
| 3727 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3725 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 3726 | + $csv_filename = end( $csv_file_arr ); |
|
| 3727 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3728 | 3728 | |
| 3729 | - $json['file'] = $csv_file; |
|
| 3730 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3731 | - $file = array(); |
|
| 3729 | + $json['file'] = $csv_file; |
|
| 3730 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3731 | + $file = array(); |
|
| 3732 | 3732 | |
| 3733 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3734 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3733 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3734 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3735 | 3735 | |
| 3736 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3737 | - $json['error'] = NULL; |
|
| 3738 | - $json['rows'] = 0; |
|
| 3736 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3737 | + $json['error'] = NULL; |
|
| 3738 | + $json['rows'] = 0; |
|
| 3739 | 3739 | |
| 3740 | - $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3741 | - setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3742 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3743 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3744 | - if ( !empty( $data ) ) {
|
|
| 3745 | - $file[] = $data; |
|
| 3746 | - } |
|
| 3747 | - } |
|
| 3748 | - fclose($handle); |
|
| 3749 | - } |
|
| 3750 | - setlocale(LC_ALL, $lc_all); |
|
| 3740 | + $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3741 | + setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3742 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3743 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3744 | + if ( !empty( $data ) ) {
|
|
| 3745 | + $file[] = $data; |
|
| 3746 | + } |
|
| 3747 | + } |
|
| 3748 | + fclose($handle); |
|
| 3749 | + } |
|
| 3750 | + setlocale(LC_ALL, $lc_all); |
|
| 3751 | 3751 | |
| 3752 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3752 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3753 | 3753 | |
| 3754 | - if (!$json['rows'] > 0) {
|
|
| 3755 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3756 | - } |
|
| 3757 | - } else {
|
|
| 3758 | - wp_send_json( $json ); |
|
| 3759 | - } |
|
| 3760 | - } else {
|
|
| 3761 | - wp_send_json( $json ); |
|
| 3762 | - } |
|
| 3754 | + if (!$json['rows'] > 0) {
|
|
| 3755 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3756 | + } |
|
| 3757 | + } else {
|
|
| 3758 | + wp_send_json( $json ); |
|
| 3759 | + } |
|
| 3760 | + } else {
|
|
| 3761 | + wp_send_json( $json ); |
|
| 3762 | + } |
|
| 3763 | 3763 | |
| 3764 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3765 | - wp_send_json( $json ); |
|
| 3766 | - } |
|
| 3764 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3765 | + wp_send_json( $json ); |
|
| 3766 | + } |
|
| 3767 | 3767 | |
| 3768 | - $total = $json['rows']; |
|
| 3769 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3770 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3768 | + $total = $json['rows']; |
|
| 3769 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3770 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3771 | 3771 | |
| 3772 | - $count = $limit; |
|
| 3772 | + $count = $limit; |
|
| 3773 | 3773 | |
| 3774 | - if ($count < $total) {
|
|
| 3775 | - $count = $processed + $count; |
|
| 3776 | - if ($count > $total) {
|
|
| 3777 | - $count = $total; |
|
| 3778 | - } |
|
| 3779 | - } else {
|
|
| 3780 | - $count = $total; |
|
| 3781 | - } |
|
| 3774 | + if ($count < $total) {
|
|
| 3775 | + $count = $processed + $count; |
|
| 3776 | + if ($count > $total) {
|
|
| 3777 | + $count = $total; |
|
| 3778 | + } |
|
| 3779 | + } else {
|
|
| 3780 | + $count = $total; |
|
| 3781 | + } |
|
| 3782 | 3782 | |
| 3783 | - $created = 0; |
|
| 3784 | - $updated = 0; |
|
| 3785 | - $skipped = 0; |
|
| 3786 | - $invalid = 0; |
|
| 3787 | - $invalid_addr = 0; |
|
| 3788 | - $images = 0; |
|
| 3783 | + $created = 0; |
|
| 3784 | + $updated = 0; |
|
| 3785 | + $skipped = 0; |
|
| 3786 | + $invalid = 0; |
|
| 3787 | + $invalid_addr = 0; |
|
| 3788 | + $images = 0; |
|
| 3789 | 3789 | |
| 3790 | - $gd_post_info = array(); |
|
| 3791 | - $countpost = 0; |
|
| 3790 | + $gd_post_info = array(); |
|
| 3791 | + $countpost = 0; |
|
| 3792 | 3792 | |
| 3793 | - $post_types = geodir_get_posttypes(); |
|
| 3793 | + $post_types = geodir_get_posttypes(); |
|
| 3794 | 3794 | |
| 3795 | - if ( $task == 'import_cat' ) {
|
|
| 3796 | - if (!empty($file)) {
|
|
| 3797 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3795 | + if ( $task == 'import_cat' ) {
|
|
| 3796 | + if (!empty($file)) {
|
|
| 3797 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3798 | 3798 | |
| 3799 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3800 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 3801 | - wp_send_json( $json ); |
|
| 3802 | - exit; |
|
| 3803 | - } |
|
| 3799 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3800 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 3801 | + wp_send_json( $json ); |
|
| 3802 | + exit; |
|
| 3803 | + } |
|
| 3804 | 3804 | |
| 3805 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3805 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3806 | 3806 | |
| 3807 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 3808 | - $index = $processed + $i; |
|
| 3807 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 3808 | + $index = $processed + $i; |
|
| 3809 | 3809 | |
| 3810 | - if (isset($file[$index])) {
|
|
| 3811 | - $row = $file[$index]; |
|
| 3812 | - $row = array_map( 'trim', $row ); |
|
| 3813 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 3810 | + if (isset($file[$index])) {
|
|
| 3811 | + $row = $file[$index]; |
|
| 3812 | + $row = array_map( 'trim', $row ); |
|
| 3813 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 3814 | 3814 | |
| 3815 | - $cat_id = ''; |
|
| 3816 | - $cat_name = ''; |
|
| 3817 | - $cat_slug = ''; |
|
| 3818 | - $cat_posttype = ''; |
|
| 3819 | - $cat_parent = ''; |
|
| 3820 | - $cat_description = ''; |
|
| 3821 | - $cat_schema = ''; |
|
| 3822 | - $cat_top_description = ''; |
|
| 3823 | - $cat_image = ''; |
|
| 3824 | - $cat_icon = ''; |
|
| 3825 | - $cat_language = ''; |
|
| 3826 | - $cat_id_original = ''; |
|
| 3815 | + $cat_id = ''; |
|
| 3816 | + $cat_name = ''; |
|
| 3817 | + $cat_slug = ''; |
|
| 3818 | + $cat_posttype = ''; |
|
| 3819 | + $cat_parent = ''; |
|
| 3820 | + $cat_description = ''; |
|
| 3821 | + $cat_schema = ''; |
|
| 3822 | + $cat_top_description = ''; |
|
| 3823 | + $cat_image = ''; |
|
| 3824 | + $cat_icon = ''; |
|
| 3825 | + $cat_language = ''; |
|
| 3826 | + $cat_id_original = ''; |
|
| 3827 | 3827 | |
| 3828 | - $c = 0; |
|
| 3829 | - foreach ($columns as $column ) {
|
|
| 3830 | - if ( $column == 'cat_id' ) {
|
|
| 3831 | - $cat_id = (int)$row[$c]; |
|
| 3832 | - } else if ( $column == 'cat_name' ) {
|
|
| 3833 | - $cat_name = $row[$c]; |
|
| 3834 | - } else if ( $column == 'cat_slug' ) {
|
|
| 3835 | - $cat_slug = $row[$c]; |
|
| 3836 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 3837 | - $cat_posttype = $row[$c]; |
|
| 3838 | - } else if ( $column == 'cat_parent' ) {
|
|
| 3839 | - $cat_parent = trim($row[$c]); |
|
| 3840 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3841 | - $cat_schema = $row[$c]; |
|
| 3842 | - } else if ( $column == 'cat_description' ) {
|
|
| 3843 | - $cat_description = $row[$c]; |
|
| 3844 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 3845 | - $cat_top_description = $row[$c]; |
|
| 3846 | - } else if ( $column == 'cat_image' ) {
|
|
| 3847 | - $cat_image = $row[$c]; |
|
| 3848 | - } else if ( $column == 'cat_icon' ) {
|
|
| 3849 | - $cat_icon = $row[$c]; |
|
| 3850 | - } |
|
| 3851 | - // WPML |
|
| 3852 | - if ( $is_wpml ) {
|
|
| 3853 | - if ( $column == 'cat_language' ) {
|
|
| 3854 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3855 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 3856 | - $cat_id_original = (int)$row[$c]; |
|
| 3857 | - } |
|
| 3858 | - } |
|
| 3859 | - // WPML |
|
| 3860 | - $c++; |
|
| 3861 | - } |
|
| 3828 | + $c = 0; |
|
| 3829 | + foreach ($columns as $column ) {
|
|
| 3830 | + if ( $column == 'cat_id' ) {
|
|
| 3831 | + $cat_id = (int)$row[$c]; |
|
| 3832 | + } else if ( $column == 'cat_name' ) {
|
|
| 3833 | + $cat_name = $row[$c]; |
|
| 3834 | + } else if ( $column == 'cat_slug' ) {
|
|
| 3835 | + $cat_slug = $row[$c]; |
|
| 3836 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 3837 | + $cat_posttype = $row[$c]; |
|
| 3838 | + } else if ( $column == 'cat_parent' ) {
|
|
| 3839 | + $cat_parent = trim($row[$c]); |
|
| 3840 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3841 | + $cat_schema = $row[$c]; |
|
| 3842 | + } else if ( $column == 'cat_description' ) {
|
|
| 3843 | + $cat_description = $row[$c]; |
|
| 3844 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 3845 | + $cat_top_description = $row[$c]; |
|
| 3846 | + } else if ( $column == 'cat_image' ) {
|
|
| 3847 | + $cat_image = $row[$c]; |
|
| 3848 | + } else if ( $column == 'cat_icon' ) {
|
|
| 3849 | + $cat_icon = $row[$c]; |
|
| 3850 | + } |
|
| 3851 | + // WPML |
|
| 3852 | + if ( $is_wpml ) {
|
|
| 3853 | + if ( $column == 'cat_language' ) {
|
|
| 3854 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3855 | + } else if ( $column == 'cat_id_original' ) {
|
|
| 3856 | + $cat_id_original = (int)$row[$c]; |
|
| 3857 | + } |
|
| 3858 | + } |
|
| 3859 | + // WPML |
|
| 3860 | + $c++; |
|
| 3861 | + } |
|
| 3862 | 3862 | |
| 3863 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3864 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3863 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3864 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3865 | 3865 | |
| 3866 | - $invalid++; |
|
| 3867 | - continue; |
|
| 3868 | - } |
|
| 3866 | + $invalid++; |
|
| 3867 | + continue; |
|
| 3868 | + } |
|
| 3869 | 3869 | |
| 3870 | - // WPML |
|
| 3871 | - if ($is_wpml && $cat_language != '') {
|
|
| 3872 | - $sitepress->switch_lang($cat_language, true); |
|
| 3873 | - } |
|
| 3874 | - // WPML |
|
| 3870 | + // WPML |
|
| 3871 | + if ($is_wpml && $cat_language != '') {
|
|
| 3872 | + $sitepress->switch_lang($cat_language, true); |
|
| 3873 | + } |
|
| 3874 | + // WPML |
|
| 3875 | 3875 | |
| 3876 | - $term_data = array(); |
|
| 3877 | - $term_data['name'] = $cat_name; |
|
| 3878 | - $term_data['slug'] = $cat_slug; |
|
| 3879 | - $term_data['description'] = $cat_description; |
|
| 3880 | - $term_data['cat_schema'] = $cat_schema; |
|
| 3881 | - $term_data['top_description'] = $cat_top_description; |
|
| 3882 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3883 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3876 | + $term_data = array(); |
|
| 3877 | + $term_data['name'] = $cat_name; |
|
| 3878 | + $term_data['slug'] = $cat_slug; |
|
| 3879 | + $term_data['description'] = $cat_description; |
|
| 3880 | + $term_data['cat_schema'] = $cat_schema; |
|
| 3881 | + $term_data['top_description'] = $cat_top_description; |
|
| 3882 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3883 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3884 | 3884 | |
| 3885 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3885 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3886 | 3886 | |
| 3887 | - $taxonomy = $cat_posttype . 'category'; |
|
| 3887 | + $taxonomy = $cat_posttype . 'category'; |
|
| 3888 | 3888 | |
| 3889 | - $term_data['taxonomy'] = $taxonomy; |
|
| 3889 | + $term_data['taxonomy'] = $taxonomy; |
|
| 3890 | 3890 | |
| 3891 | - $term_parent_id = 0; |
|
| 3892 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3893 | - $term_parent = ''; |
|
| 3891 | + $term_parent_id = 0; |
|
| 3892 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3893 | + $term_parent = ''; |
|
| 3894 | 3894 | |
| 3895 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3896 | - // |
|
| 3897 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3898 | - // |
|
| 3899 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3900 | - // |
|
| 3901 | - } else {
|
|
| 3902 | - $term_parent_data = array(); |
|
| 3903 | - $term_parent_data['name'] = $cat_parent; |
|
| 3904 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3905 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3895 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3896 | + // |
|
| 3897 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3898 | + // |
|
| 3899 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3900 | + // |
|
| 3901 | + } else {
|
|
| 3902 | + $term_parent_data = array(); |
|
| 3903 | + $term_parent_data['name'] = $cat_parent; |
|
| 3904 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3905 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3906 | 3906 | |
| 3907 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3908 | - } |
|
| 3907 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3908 | + } |
|
| 3909 | 3909 | |
| 3910 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3911 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 3912 | - } |
|
| 3913 | - } |
|
| 3914 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 3910 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3911 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 3912 | + } |
|
| 3913 | + } |
|
| 3914 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 3915 | 3915 | |
| 3916 | - $term_id = NULL; |
|
| 3917 | - if ( $import_choice == 'update' ) {
|
|
| 3918 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3919 | - $term_data['term_id'] = $term['term_id']; |
|
| 3916 | + $term_id = NULL; |
|
| 3917 | + if ( $import_choice == 'update' ) {
|
|
| 3918 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3919 | + $term_data['term_id'] = $term['term_id']; |
|
| 3920 | 3920 | |
| 3921 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3922 | - $updated++; |
|
| 3923 | - } else {
|
|
| 3924 | - $invalid++; |
|
| 3925 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3926 | - } |
|
| 3927 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3928 | - $term_data['term_id'] = $term['term_id']; |
|
| 3921 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3922 | + $updated++; |
|
| 3923 | + } else {
|
|
| 3924 | + $invalid++; |
|
| 3925 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3926 | + } |
|
| 3927 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3928 | + $term_data['term_id'] = $term['term_id']; |
|
| 3929 | 3929 | |
| 3930 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3931 | - $updated++; |
|
| 3932 | - } else {
|
|
| 3933 | - $invalid++; |
|
| 3934 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3935 | - } |
|
| 3936 | - } else {
|
|
| 3937 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3938 | - $created++; |
|
| 3939 | - } else {
|
|
| 3940 | - $invalid++; |
|
| 3941 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3942 | - } |
|
| 3943 | - } |
|
| 3944 | - } else if ( $import_choice == 'skip' ) {
|
|
| 3945 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3946 | - $skipped++; |
|
| 3947 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3948 | - $skipped++; |
|
| 3949 | - } else {
|
|
| 3950 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3951 | - $created++; |
|
| 3952 | - } else {
|
|
| 3953 | - $invalid++; |
|
| 3954 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3955 | - } |
|
| 3956 | - } |
|
| 3957 | - } else {
|
|
| 3958 | - $invalid++; |
|
| 3959 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3960 | - } |
|
| 3930 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3931 | + $updated++; |
|
| 3932 | + } else {
|
|
| 3933 | + $invalid++; |
|
| 3934 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3935 | + } |
|
| 3936 | + } else {
|
|
| 3937 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3938 | + $created++; |
|
| 3939 | + } else {
|
|
| 3940 | + $invalid++; |
|
| 3941 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3942 | + } |
|
| 3943 | + } |
|
| 3944 | + } else if ( $import_choice == 'skip' ) {
|
|
| 3945 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3946 | + $skipped++; |
|
| 3947 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3948 | + $skipped++; |
|
| 3949 | + } else {
|
|
| 3950 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3951 | + $created++; |
|
| 3952 | + } else {
|
|
| 3953 | + $invalid++; |
|
| 3954 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3955 | + } |
|
| 3956 | + } |
|
| 3957 | + } else {
|
|
| 3958 | + $invalid++; |
|
| 3959 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3960 | + } |
|
| 3961 | 3961 | |
| 3962 | - if ( $term_id ) {
|
|
| 3963 | - // WPML |
|
| 3964 | - if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3965 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3966 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3967 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3968 | - |
|
| 3969 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3962 | + if ( $term_id ) {
|
|
| 3963 | + // WPML |
|
| 3964 | + if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3965 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3966 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3967 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3968 | + |
|
| 3969 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3970 | 3970 | |
| 3971 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3972 | - } |
|
| 3973 | - // WPML |
|
| 3971 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3972 | + } |
|
| 3973 | + // WPML |
|
| 3974 | 3974 | |
| 3975 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 3976 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3977 | - } |
|
| 3975 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 3976 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3977 | + } |
|
| 3978 | 3978 | |
| 3979 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3980 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3981 | - } |
|
| 3979 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3980 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3981 | + } |
|
| 3982 | 3982 | |
| 3983 | - $attachment = false; |
|
| 3984 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3985 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3986 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3983 | + $attachment = false; |
|
| 3984 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3985 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3986 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3987 | 3987 | |
| 3988 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3989 | - $attachment = true; |
|
| 3990 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 3991 | - } |
|
| 3992 | - } |
|
| 3988 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3989 | + $attachment = true; |
|
| 3990 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 3991 | + } |
|
| 3992 | + } |
|
| 3993 | 3993 | |
| 3994 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 3995 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 3996 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 3997 | - |
|
| 3998 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 3999 | - $attachment = true; |
|
| 4000 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4001 | - } |
|
| 4002 | - } |
|
| 3994 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 3995 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 3996 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 3997 | + |
|
| 3998 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 3999 | + $attachment = true; |
|
| 4000 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4001 | + } |
|
| 4002 | + } |
|
| 4003 | 4003 | |
| 4004 | - if ( $attachment ) {
|
|
| 4005 | - $images++; |
|
| 4006 | - } |
|
| 4007 | - } |
|
| 4004 | + if ( $attachment ) {
|
|
| 4005 | + $images++; |
|
| 4006 | + } |
|
| 4007 | + } |
|
| 4008 | 4008 | |
| 4009 | - // WPML |
|
| 4010 | - if ($is_wpml && $cat_language != '') {
|
|
| 4011 | - $sitepress->switch_lang($active_lang, true); |
|
| 4012 | - } |
|
| 4013 | - // WPML |
|
| 4014 | - } |
|
| 4015 | - } |
|
| 4016 | - } |
|
| 4009 | + // WPML |
|
| 4010 | + if ($is_wpml && $cat_language != '') {
|
|
| 4011 | + $sitepress->switch_lang($active_lang, true); |
|
| 4012 | + } |
|
| 4013 | + // WPML |
|
| 4014 | + } |
|
| 4015 | + } |
|
| 4016 | + } |
|
| 4017 | 4017 | |
| 4018 | - $json = array(); |
|
| 4019 | - $json['processed'] = $limit; |
|
| 4020 | - $json['created'] = $created; |
|
| 4021 | - $json['updated'] = $updated; |
|
| 4022 | - $json['skipped'] = $skipped; |
|
| 4023 | - $json['invalid'] = $invalid; |
|
| 4024 | - $json['images'] = $images; |
|
| 4018 | + $json = array(); |
|
| 4019 | + $json['processed'] = $limit; |
|
| 4020 | + $json['created'] = $created; |
|
| 4021 | + $json['updated'] = $updated; |
|
| 4022 | + $json['skipped'] = $skipped; |
|
| 4023 | + $json['invalid'] = $invalid; |
|
| 4024 | + $json['images'] = $images; |
|
| 4025 | 4025 | |
| 4026 | - wp_send_json( $json ); |
|
| 4027 | - exit; |
|
| 4028 | - } else if ( $task == 'import_post' ) {
|
|
| 4029 | - $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4030 | - //run some stuff to make the import quicker |
|
| 4031 | - wp_defer_term_counting( true ); |
|
| 4032 | - wp_defer_comment_counting( true ); |
|
| 4033 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4026 | + wp_send_json( $json ); |
|
| 4027 | + exit; |
|
| 4028 | + } else if ( $task == 'import_post' ) {
|
|
| 4029 | + $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4030 | + //run some stuff to make the import quicker |
|
| 4031 | + wp_defer_term_counting( true ); |
|
| 4032 | + wp_defer_comment_counting( true ); |
|
| 4033 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4034 | 4034 | // |
| 4035 | 4035 | // remove_all_actions('publish_post');
|
| 4036 | 4036 | // remove_all_actions('transition_post_status');
|
| 4037 | 4037 | // remove_all_actions('publish_future_post');
|
| 4038 | 4038 | |
| 4039 | - if (!empty($file)) {
|
|
| 4040 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4041 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4042 | - $default_status = 'publish'; |
|
| 4043 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4039 | + if (!empty($file)) {
|
|
| 4040 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4041 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4042 | + $default_status = 'publish'; |
|
| 4043 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4044 | 4044 | |
| 4045 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4045 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4046 | 4046 | |
| 4047 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4048 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4049 | - wp_send_json( $json ); |
|
| 4050 | - exit; |
|
| 4051 | - } |
|
| 4052 | - $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4053 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4054 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4055 | - $processed_actual = 0; |
|
| 4056 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4057 | - $index = $processed + $i; |
|
| 4058 | - $gd_post = array(); |
|
| 4047 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4048 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4049 | + wp_send_json( $json ); |
|
| 4050 | + exit; |
|
| 4051 | + } |
|
| 4052 | + $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4053 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4054 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4055 | + $processed_actual = 0; |
|
| 4056 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4057 | + $index = $processed + $i; |
|
| 4058 | + $gd_post = array(); |
|
| 4059 | 4059 | |
| 4060 | - if (isset($file[$index])) {
|
|
| 4061 | - $processed_actual++; |
|
| 4062 | - $row = $file[$index]; |
|
| 4063 | - $row = array_map( 'trim', $row ); |
|
| 4064 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4065 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4060 | + if (isset($file[$index])) {
|
|
| 4061 | + $processed_actual++; |
|
| 4062 | + $row = $file[$index]; |
|
| 4063 | + $row = array_map( 'trim', $row ); |
|
| 4064 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4065 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 4066 | 4066 | |
| 4067 | - $post_id = ''; |
|
| 4068 | - $post_title = ''; |
|
| 4069 | - $post_date = ''; |
|
| 4070 | - $post_author = ''; |
|
| 4071 | - $post_content = ''; |
|
| 4072 | - $post_category_arr = array(); |
|
| 4073 | - $default_category = ''; |
|
| 4074 | - $post_tags = array(); |
|
| 4075 | - $post_type = ''; |
|
| 4076 | - $post_status = ''; |
|
| 4077 | - $geodir_video = ''; |
|
| 4078 | - $post_address = ''; |
|
| 4079 | - $post_city = ''; |
|
| 4080 | - $post_region = ''; |
|
| 4081 | - $post_country = ''; |
|
| 4082 | - $post_zip = ''; |
|
| 4083 | - $post_latitude = ''; |
|
| 4084 | - $post_longitude = ''; |
|
| 4085 | - $post_neighbourhood = ''; |
|
| 4086 | - $neighbourhood_latitude = ''; |
|
| 4087 | - $neighbourhood_longitude = ''; |
|
| 4088 | - $geodir_timing = ''; |
|
| 4089 | - $geodir_contact = ''; |
|
| 4090 | - $geodir_email = ''; |
|
| 4091 | - $geodir_website = ''; |
|
| 4092 | - $geodir_twitter = ''; |
|
| 4093 | - $geodir_facebook = ''; |
|
| 4094 | - $geodir_twitter = ''; |
|
| 4095 | - $post_images = array(); |
|
| 4067 | + $post_id = ''; |
|
| 4068 | + $post_title = ''; |
|
| 4069 | + $post_date = ''; |
|
| 4070 | + $post_author = ''; |
|
| 4071 | + $post_content = ''; |
|
| 4072 | + $post_category_arr = array(); |
|
| 4073 | + $default_category = ''; |
|
| 4074 | + $post_tags = array(); |
|
| 4075 | + $post_type = ''; |
|
| 4076 | + $post_status = ''; |
|
| 4077 | + $geodir_video = ''; |
|
| 4078 | + $post_address = ''; |
|
| 4079 | + $post_city = ''; |
|
| 4080 | + $post_region = ''; |
|
| 4081 | + $post_country = ''; |
|
| 4082 | + $post_zip = ''; |
|
| 4083 | + $post_latitude = ''; |
|
| 4084 | + $post_longitude = ''; |
|
| 4085 | + $post_neighbourhood = ''; |
|
| 4086 | + $neighbourhood_latitude = ''; |
|
| 4087 | + $neighbourhood_longitude = ''; |
|
| 4088 | + $geodir_timing = ''; |
|
| 4089 | + $geodir_contact = ''; |
|
| 4090 | + $geodir_email = ''; |
|
| 4091 | + $geodir_website = ''; |
|
| 4092 | + $geodir_twitter = ''; |
|
| 4093 | + $geodir_facebook = ''; |
|
| 4094 | + $geodir_twitter = ''; |
|
| 4095 | + $post_images = array(); |
|
| 4096 | 4096 | |
| 4097 | - $expire_date = 'Never'; |
|
| 4097 | + $expire_date = 'Never'; |
|
| 4098 | 4098 | |
| 4099 | - $language = ''; |
|
| 4100 | - $original_post_id = ''; |
|
| 4099 | + $language = ''; |
|
| 4100 | + $original_post_id = ''; |
|
| 4101 | 4101 | |
| 4102 | - $c = 0; |
|
| 4103 | - foreach ($columns as $column ) {
|
|
| 4104 | - $gd_post[$column] = $row[$c]; |
|
| 4102 | + $c = 0; |
|
| 4103 | + foreach ($columns as $column ) {
|
|
| 4104 | + $gd_post[$column] = $row[$c]; |
|
| 4105 | 4105 | |
| 4106 | - if ( $column == 'post_id' ) {
|
|
| 4107 | - $post_id = $row[$c]; |
|
| 4108 | - } else if ( $column == 'post_title' ) {
|
|
| 4109 | - $post_title = sanitize_text_field($row[$c]); |
|
| 4110 | - } else if ( $column == 'post_author' ) {
|
|
| 4111 | - $post_author = $row[$c]; |
|
| 4112 | - } else if ( $column == 'post_date' ) {
|
|
| 4113 | - $post_date = $row[$c]; |
|
| 4114 | - } else if ( $column == 'post_content' ) {
|
|
| 4115 | - $post_content = $row[$c]; |
|
| 4116 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4117 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4118 | - } else if ( $column == 'default_category' ) {
|
|
| 4119 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4120 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4121 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4122 | - } else if ( $column == 'post_type' ) {
|
|
| 4123 | - $post_type = $row[$c]; |
|
| 4124 | - } else if ( $column == 'post_status' ) {
|
|
| 4125 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4126 | - } else if ( $column == 'is_featured' ) {
|
|
| 4127 | - $is_featured = (int)$row[$c]; |
|
| 4128 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4129 | - $geodir_video = $row[$c]; |
|
| 4130 | - } else if ( $column == 'post_address' ) {
|
|
| 4131 | - $post_address = sanitize_text_field($row[$c]); |
|
| 4132 | - } else if ( $column == 'post_city' ) {
|
|
| 4133 | - $post_city = sanitize_text_field($row[$c]); |
|
| 4134 | - } else if ( $column == 'post_region' ) {
|
|
| 4135 | - $post_region = sanitize_text_field($row[$c]); |
|
| 4136 | - } else if ( $column == 'post_country' ) {
|
|
| 4137 | - $post_country = sanitize_text_field($row[$c]); |
|
| 4138 | - } else if ( $column == 'post_zip' ) {
|
|
| 4139 | - $post_zip = sanitize_text_field($row[$c]); |
|
| 4140 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4141 | - $post_latitude = sanitize_text_field($row[$c]); |
|
| 4142 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4143 | - $post_longitude = sanitize_text_field($row[$c]); |
|
| 4144 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4145 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4146 | - unset($gd_post[$column]); |
|
| 4147 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4148 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4149 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4150 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4151 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4152 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4153 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4154 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4155 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4156 | - $geodir_email = sanitize_email($row[$c]); |
|
| 4157 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4158 | - $geodir_website = sanitize_text_field($row[$c]); |
|
| 4159 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4160 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4161 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4162 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4163 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4164 | - $post_images[] = $row[$c]; |
|
| 4165 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4166 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4167 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4168 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4169 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4170 | - } |
|
| 4171 | - // WPML |
|
| 4172 | - if ($is_wpml) {
|
|
| 4173 | - if ($column == 'language') {
|
|
| 4174 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 4175 | - } else if ($column == 'original_post_id') {
|
|
| 4176 | - $original_post_id = (int)$row[$c]; |
|
| 4177 | - } |
|
| 4178 | - } |
|
| 4179 | - // WPML |
|
| 4180 | - $c++; |
|
| 4181 | - } |
|
| 4182 | - // listing claimed or not |
|
| 4183 | - if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4184 | - $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4185 | - } |
|
| 4106 | + if ( $column == 'post_id' ) {
|
|
| 4107 | + $post_id = $row[$c]; |
|
| 4108 | + } else if ( $column == 'post_title' ) {
|
|
| 4109 | + $post_title = sanitize_text_field($row[$c]); |
|
| 4110 | + } else if ( $column == 'post_author' ) {
|
|
| 4111 | + $post_author = $row[$c]; |
|
| 4112 | + } else if ( $column == 'post_date' ) {
|
|
| 4113 | + $post_date = $row[$c]; |
|
| 4114 | + } else if ( $column == 'post_content' ) {
|
|
| 4115 | + $post_content = $row[$c]; |
|
| 4116 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4117 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 4118 | + } else if ( $column == 'default_category' ) {
|
|
| 4119 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4120 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4121 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4122 | + } else if ( $column == 'post_type' ) {
|
|
| 4123 | + $post_type = $row[$c]; |
|
| 4124 | + } else if ( $column == 'post_status' ) {
|
|
| 4125 | + $post_status = sanitize_key( $row[$c] ); |
|
| 4126 | + } else if ( $column == 'is_featured' ) {
|
|
| 4127 | + $is_featured = (int)$row[$c]; |
|
| 4128 | + } else if ( $column == 'geodir_video' ) {
|
|
| 4129 | + $geodir_video = $row[$c]; |
|
| 4130 | + } else if ( $column == 'post_address' ) {
|
|
| 4131 | + $post_address = sanitize_text_field($row[$c]); |
|
| 4132 | + } else if ( $column == 'post_city' ) {
|
|
| 4133 | + $post_city = sanitize_text_field($row[$c]); |
|
| 4134 | + } else if ( $column == 'post_region' ) {
|
|
| 4135 | + $post_region = sanitize_text_field($row[$c]); |
|
| 4136 | + } else if ( $column == 'post_country' ) {
|
|
| 4137 | + $post_country = sanitize_text_field($row[$c]); |
|
| 4138 | + } else if ( $column == 'post_zip' ) {
|
|
| 4139 | + $post_zip = sanitize_text_field($row[$c]); |
|
| 4140 | + } else if ( $column == 'post_latitude' ) {
|
|
| 4141 | + $post_latitude = sanitize_text_field($row[$c]); |
|
| 4142 | + } else if ( $column == 'post_longitude' ) {
|
|
| 4143 | + $post_longitude = sanitize_text_field($row[$c]); |
|
| 4144 | + } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4145 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4146 | + unset($gd_post[$column]); |
|
| 4147 | + } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4148 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4149 | + } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4150 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4151 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 4152 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4153 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 4154 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4155 | + } else if ( $column == 'geodir_email' ) {
|
|
| 4156 | + $geodir_email = sanitize_email($row[$c]); |
|
| 4157 | + } else if ( $column == 'geodir_website' ) {
|
|
| 4158 | + $geodir_website = sanitize_text_field($row[$c]); |
|
| 4159 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 4160 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4161 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 4162 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4163 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4164 | + $post_images[] = $row[$c]; |
|
| 4165 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4166 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4167 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4168 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4169 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4170 | + } |
|
| 4171 | + // WPML |
|
| 4172 | + if ($is_wpml) {
|
|
| 4173 | + if ($column == 'language') {
|
|
| 4174 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 4175 | + } else if ($column == 'original_post_id') {
|
|
| 4176 | + $original_post_id = (int)$row[$c]; |
|
| 4177 | + } |
|
| 4178 | + } |
|
| 4179 | + // WPML |
|
| 4180 | + $c++; |
|
| 4181 | + } |
|
| 4182 | + // listing claimed or not |
|
| 4183 | + if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4184 | + $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4185 | + } |
|
| 4186 | 4186 | |
| 4187 | - // WPML |
|
| 4188 | - if ($is_wpml && $language != '') {
|
|
| 4189 | - $sitepress->switch_lang($language, true); |
|
| 4190 | - } |
|
| 4191 | - // WPML |
|
| 4187 | + // WPML |
|
| 4188 | + if ($is_wpml && $language != '') {
|
|
| 4189 | + $sitepress->switch_lang($language, true); |
|
| 4190 | + } |
|
| 4191 | + // WPML |
|
| 4192 | 4192 | |
| 4193 | - $gd_post['IMAGE'] = $post_images; |
|
| 4193 | + $gd_post['IMAGE'] = $post_images; |
|
| 4194 | 4194 | |
| 4195 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4196 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4195 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4196 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4197 | 4197 | |
| 4198 | - $valid = true; |
|
| 4198 | + $valid = true; |
|
| 4199 | 4199 | |
| 4200 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4201 | - $invalid++; |
|
| 4202 | - $valid = false; |
|
| 4203 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4204 | - } |
|
| 4205 | - $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4206 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4207 | - if ( $location_allowed ) {
|
|
| 4208 | - $location_result = geodir_get_default_location(); |
|
| 4209 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4210 | - $invalid_addr++; |
|
| 4211 | - $valid = false; |
|
| 4212 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4213 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4214 | - if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 4215 | - $invalid_addr++; |
|
| 4216 | - $valid = false; |
|
| 4217 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4218 | - } else {
|
|
| 4219 | - if (!$location_manager) {
|
|
| 4220 | - $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 4221 | - } |
|
| 4222 | - } |
|
| 4223 | - } |
|
| 4224 | - } |
|
| 4225 | - $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4226 | - if ( !$valid ) {
|
|
| 4227 | - continue; |
|
| 4228 | - } |
|
| 4200 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4201 | + $invalid++; |
|
| 4202 | + $valid = false; |
|
| 4203 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4204 | + } |
|
| 4205 | + $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4206 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4207 | + if ( $location_allowed ) {
|
|
| 4208 | + $location_result = geodir_get_default_location(); |
|
| 4209 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4210 | + $invalid_addr++; |
|
| 4211 | + $valid = false; |
|
| 4212 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4213 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4214 | + if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 4215 | + $invalid_addr++; |
|
| 4216 | + $valid = false; |
|
| 4217 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4218 | + } else {
|
|
| 4219 | + if (!$location_manager) {
|
|
| 4220 | + $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 4221 | + } |
|
| 4222 | + } |
|
| 4223 | + } |
|
| 4224 | + } |
|
| 4225 | + $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4226 | + if ( !$valid ) {
|
|
| 4227 | + continue; |
|
| 4228 | + } |
|
| 4229 | 4229 | |
| 4230 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4231 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4230 | + $cat_taxonomy = $post_type . 'category'; |
|
| 4231 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 4232 | 4232 | |
| 4233 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4234 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4235 | - } |
|
| 4233 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4234 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4235 | + } |
|
| 4236 | 4236 | |
| 4237 | - $post_category = array(); |
|
| 4238 | - $default_category_id = NULL; |
|
| 4239 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4240 | - foreach ( $post_category_arr as $value ) {
|
|
| 4241 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4237 | + $post_category = array(); |
|
| 4238 | + $default_category_id = NULL; |
|
| 4239 | + if ( !empty( $post_category_arr ) ) {
|
|
| 4240 | + foreach ( $post_category_arr as $value ) {
|
|
| 4241 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4242 | 4242 | |
| 4243 | - if ( $category_name != '' ) {
|
|
| 4244 | - $term_category = array(); |
|
| 4243 | + if ( $category_name != '' ) {
|
|
| 4244 | + $term_category = array(); |
|
| 4245 | 4245 | |
| 4246 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4247 | - $term_category = $term; |
|
| 4248 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4249 | - $term_category = $term; |
|
| 4250 | - } else {
|
|
| 4251 | - $term_data = array(); |
|
| 4252 | - $term_data['name'] = $category_name; |
|
| 4253 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4246 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4247 | + $term_category = $term; |
|
| 4248 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4249 | + $term_category = $term; |
|
| 4250 | + } else {
|
|
| 4251 | + $term_data = array(); |
|
| 4252 | + $term_data['name'] = $category_name; |
|
| 4253 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4254 | 4254 | |
| 4255 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4256 | - if ( $term_id ) {
|
|
| 4257 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4258 | - } |
|
| 4259 | - } |
|
| 4255 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4256 | + if ( $term_id ) {
|
|
| 4257 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4258 | + } |
|
| 4259 | + } |
|
| 4260 | 4260 | |
| 4261 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4262 | - $post_category[] = intval($term_category->term_id); |
|
| 4261 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4262 | + $post_category[] = intval($term_category->term_id); |
|
| 4263 | 4263 | |
| 4264 | - if ($category_name == $default_category) {
|
|
| 4265 | - $default_category_id = intval($term_category->term_id); |
|
| 4266 | - } |
|
| 4267 | - } |
|
| 4268 | - } |
|
| 4269 | - } |
|
| 4270 | - } |
|
| 4271 | - $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4272 | - $save_post = array(); |
|
| 4273 | - $save_post['post_title'] = $post_title; |
|
| 4274 | - if (!empty($post_date)) {
|
|
| 4275 | - $save_post['post_date'] = $post_date; |
|
| 4276 | - $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
| 4277 | - } |
|
| 4278 | - $save_post['post_content'] = $post_content; |
|
| 4279 | - $save_post['post_type'] = $post_type; |
|
| 4280 | - $save_post['post_author'] = $post_author; |
|
| 4281 | - $save_post['post_status'] = $post_status; |
|
| 4282 | - $save_post['post_category'] = $post_category; |
|
| 4283 | - $save_post['post_tags'] = $post_tags; |
|
| 4284 | - |
|
| 4285 | - $saved_post_id = NULL; |
|
| 4286 | - if ( $import_choice == 'update' ) {
|
|
| 4287 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4264 | + if ($category_name == $default_category) {
|
|
| 4265 | + $default_category_id = intval($term_category->term_id); |
|
| 4266 | + } |
|
| 4267 | + } |
|
| 4268 | + } |
|
| 4269 | + } |
|
| 4270 | + } |
|
| 4271 | + $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4272 | + $save_post = array(); |
|
| 4273 | + $save_post['post_title'] = $post_title; |
|
| 4274 | + if (!empty($post_date)) {
|
|
| 4275 | + $save_post['post_date'] = $post_date; |
|
| 4276 | + $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
| 4277 | + } |
|
| 4278 | + $save_post['post_content'] = $post_content; |
|
| 4279 | + $save_post['post_type'] = $post_type; |
|
| 4280 | + $save_post['post_author'] = $post_author; |
|
| 4281 | + $save_post['post_status'] = $post_status; |
|
| 4282 | + $save_post['post_category'] = $post_category; |
|
| 4283 | + $save_post['post_tags'] = $post_tags; |
|
| 4284 | + |
|
| 4285 | + $saved_post_id = NULL; |
|
| 4286 | + if ( $import_choice == 'update' ) {
|
|
| 4287 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4288 | 4288 | |
| 4289 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4290 | - $save_post['ID'] = $post_id; |
|
| 4289 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4290 | + $save_post['ID'] = $post_id; |
|
| 4291 | 4291 | |
| 4292 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4293 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4294 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4295 | - $saved_post_id = 0; |
|
| 4296 | - } else {
|
|
| 4297 | - $saved_post_id = $post_id; |
|
| 4298 | - $updated++; |
|
| 4299 | - } |
|
| 4300 | - } |
|
| 4301 | - } else {
|
|
| 4302 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4303 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4304 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4305 | - $saved_post_id = 0; |
|
| 4306 | - } else {
|
|
| 4307 | - $created++; |
|
| 4308 | - } |
|
| 4309 | - } |
|
| 4310 | - } |
|
| 4292 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4293 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4294 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4295 | + $saved_post_id = 0; |
|
| 4296 | + } else {
|
|
| 4297 | + $saved_post_id = $post_id; |
|
| 4298 | + $updated++; |
|
| 4299 | + } |
|
| 4300 | + } |
|
| 4301 | + } else {
|
|
| 4302 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4303 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4304 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4305 | + $saved_post_id = 0; |
|
| 4306 | + } else {
|
|
| 4307 | + $created++; |
|
| 4308 | + } |
|
| 4309 | + } |
|
| 4310 | + } |
|
| 4311 | 4311 | |
| 4312 | - if ( !$saved_post_id > 0 ) {
|
|
| 4313 | - $invalid++; |
|
| 4314 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4315 | - } |
|
| 4316 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4317 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4318 | - $skipped++; |
|
| 4319 | - } else {
|
|
| 4320 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4321 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4322 | - $invalid++; |
|
| 4312 | + if ( !$saved_post_id > 0 ) {
|
|
| 4313 | + $invalid++; |
|
| 4314 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4315 | + } |
|
| 4316 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4317 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4318 | + $skipped++; |
|
| 4319 | + } else {
|
|
| 4320 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4321 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4322 | + $invalid++; |
|
| 4323 | 4323 | |
| 4324 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4325 | - $saved_post_id = 0; |
|
| 4326 | - } else {
|
|
| 4327 | - $created++; |
|
| 4328 | - } |
|
| 4329 | - } else {
|
|
| 4330 | - $invalid++; |
|
| 4324 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4325 | + $saved_post_id = 0; |
|
| 4326 | + } else {
|
|
| 4327 | + $created++; |
|
| 4328 | + } |
|
| 4329 | + } else {
|
|
| 4330 | + $invalid++; |
|
| 4331 | 4331 | |
| 4332 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4333 | - } |
|
| 4334 | - } |
|
| 4335 | - } else {
|
|
| 4336 | - $invalid++; |
|
| 4332 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4333 | + } |
|
| 4334 | + } |
|
| 4335 | + } else {
|
|
| 4336 | + $invalid++; |
|
| 4337 | 4337 | |
| 4338 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4339 | - } |
|
| 4340 | - $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4341 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4342 | - // WPML |
|
| 4343 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4344 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4345 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4346 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4347 | - |
|
| 4348 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4338 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4339 | + } |
|
| 4340 | + $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4341 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 4342 | + // WPML |
|
| 4343 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4344 | + $wpml_post_type = 'post_' . $post_type; |
|
| 4345 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4346 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4347 | + |
|
| 4348 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4349 | 4349 | |
| 4350 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4351 | - } |
|
| 4352 | - // WPML |
|
| 4353 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4350 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4351 | + } |
|
| 4352 | + // WPML |
|
| 4353 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4354 | 4354 | |
| 4355 | - $gd_post['post_id'] = $saved_post_id; |
|
| 4356 | - $gd_post['ID'] = $saved_post_id; |
|
| 4357 | - $gd_post['post_tags'] = $post_tags; |
|
| 4358 | - $gd_post['post_title'] = $post_title; |
|
| 4359 | - $gd_post['post_status'] = $post_status; |
|
| 4360 | - $gd_post['submit_time'] = time(); |
|
| 4361 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4355 | + $gd_post['post_id'] = $saved_post_id; |
|
| 4356 | + $gd_post['ID'] = $saved_post_id; |
|
| 4357 | + $gd_post['post_tags'] = $post_tags; |
|
| 4358 | + $gd_post['post_title'] = $post_title; |
|
| 4359 | + $gd_post['post_status'] = $post_status; |
|
| 4360 | + $gd_post['submit_time'] = time(); |
|
| 4361 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4362 | 4362 | |
| 4363 | - // post location |
|
| 4364 | - $post_location_id = 0; |
|
| 4365 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4366 | - $gd_post['post_neighbourhood'] = ''; |
|
| 4363 | + // post location |
|
| 4364 | + $post_location_id = 0; |
|
| 4365 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4366 | + $gd_post['post_neighbourhood'] = ''; |
|
| 4367 | 4367 | |
| 4368 | - $post_location_info = array( |
|
| 4369 | - 'city' => $post_city, |
|
| 4370 | - 'region' => $post_region, |
|
| 4371 | - 'country' => $post_country, |
|
| 4372 | - 'geo_lat' => $post_latitude, |
|
| 4373 | - 'geo_lng' => $post_longitude |
|
| 4374 | - ); |
|
| 4375 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4376 | - $post_location_id = $location_id; |
|
| 4377 | - } |
|
| 4368 | + $post_location_info = array( |
|
| 4369 | + 'city' => $post_city, |
|
| 4370 | + 'region' => $post_region, |
|
| 4371 | + 'country' => $post_country, |
|
| 4372 | + 'geo_lat' => $post_latitude, |
|
| 4373 | + 'geo_lng' => $post_longitude |
|
| 4374 | + ); |
|
| 4375 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4376 | + $post_location_id = $location_id; |
|
| 4377 | + } |
|
| 4378 | 4378 | |
| 4379 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4380 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4379 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4380 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4381 | 4381 | |
| 4382 | - $hood_data = array(); |
|
| 4383 | - $hood_data['hood_location_id'] = $post_location_id; |
|
| 4384 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4382 | + $hood_data = array(); |
|
| 4383 | + $hood_data['hood_location_id'] = $post_location_id; |
|
| 4384 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4385 | 4385 | |
| 4386 | - if (!empty($neighbourhood_info)) {
|
|
| 4387 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4388 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4386 | + if (!empty($neighbourhood_info)) {
|
|
| 4387 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4388 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4389 | 4389 | |
| 4390 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4391 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4392 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4393 | - } |
|
| 4394 | - } |
|
| 4390 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4391 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4392 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4393 | + } |
|
| 4394 | + } |
|
| 4395 | 4395 | |
| 4396 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4397 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4398 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4399 | - } |
|
| 4396 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4397 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4398 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4399 | + } |
|
| 4400 | 4400 | |
| 4401 | - $hood_data['hood_latitude'] = $post_latitude; |
|
| 4402 | - $hood_data['hood_longitude'] = $post_longitude; |
|
| 4403 | - |
|
| 4404 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4405 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4406 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4407 | - } |
|
| 4408 | - } |
|
| 4409 | - } |
|
| 4410 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 4401 | + $hood_data['hood_latitude'] = $post_latitude; |
|
| 4402 | + $hood_data['hood_longitude'] = $post_longitude; |
|
| 4403 | + |
|
| 4404 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4405 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4406 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4407 | + } |
|
| 4408 | + } |
|
| 4409 | + } |
|
| 4410 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 4411 | 4411 | |
| 4412 | - // post package info |
|
| 4413 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4414 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4415 | - $package_id = $gd_post_info->package_id; |
|
| 4416 | - } |
|
| 4412 | + // post package info |
|
| 4413 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4414 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4415 | + $package_id = $gd_post_info->package_id; |
|
| 4416 | + } |
|
| 4417 | 4417 | |
| 4418 | - $package_info = array(); |
|
| 4419 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4420 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4418 | + $package_info = array(); |
|
| 4419 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4420 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4421 | 4421 | |
| 4422 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4423 | - $package_info = array(); |
|
| 4424 | - } |
|
| 4425 | - } |
|
| 4422 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4423 | + $package_info = array(); |
|
| 4424 | + } |
|
| 4425 | + } |
|
| 4426 | 4426 | |
| 4427 | - if (empty($package_info)) {
|
|
| 4428 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4429 | - } |
|
| 4427 | + if (empty($package_info)) {
|
|
| 4428 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4429 | + } |
|
| 4430 | 4430 | |
| 4431 | - if (!empty($package_info)) {
|
|
| 4432 | - $package_id = $package_info['pid']; |
|
| 4431 | + if (!empty($package_info)) {
|
|
| 4432 | + $package_id = $package_info['pid']; |
|
| 4433 | 4433 | |
| 4434 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4435 | - $gd_post['expire_date'] = $expire_date; |
|
| 4436 | - } else {
|
|
| 4437 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4438 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4439 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4440 | - } else {
|
|
| 4441 | - $gd_post['expire_date'] = 'Never'; |
|
| 4442 | - } |
|
| 4443 | - } |
|
| 4434 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4435 | + $gd_post['expire_date'] = $expire_date; |
|
| 4436 | + } else {
|
|
| 4437 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4438 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4439 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4440 | + } else {
|
|
| 4441 | + $gd_post['expire_date'] = 'Never'; |
|
| 4442 | + } |
|
| 4443 | + } |
|
| 4444 | 4444 | |
| 4445 | - $gd_post['package_id'] = $package_id; |
|
| 4446 | - } |
|
| 4445 | + $gd_post['package_id'] = $package_id; |
|
| 4446 | + } |
|
| 4447 | 4447 | |
| 4448 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4448 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4449 | 4449 | |
| 4450 | - if ($post_type == 'gd_event') {
|
|
| 4451 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4452 | - } |
|
| 4450 | + if ($post_type == 'gd_event') {
|
|
| 4451 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4452 | + } |
|
| 4453 | 4453 | |
| 4454 | - if (isset($gd_post['post_id'])) {
|
|
| 4455 | - unset($gd_post['post_id']); |
|
| 4456 | - } |
|
| 4454 | + if (isset($gd_post['post_id'])) {
|
|
| 4455 | + unset($gd_post['post_id']); |
|
| 4456 | + } |
|
| 4457 | 4457 | |
| 4458 | - // Export franchise fields |
|
| 4459 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4460 | - if ($is_franchise_active) {
|
|
| 4461 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4462 | - $gd_franchise_lock = array(); |
|
| 4458 | + // Export franchise fields |
|
| 4459 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4460 | + if ($is_franchise_active) {
|
|
| 4461 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4462 | + $gd_franchise_lock = array(); |
|
| 4463 | 4463 | |
| 4464 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4465 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4466 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4467 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4468 | - } |
|
| 4464 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4465 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4466 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4467 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4468 | + } |
|
| 4469 | 4469 | |
| 4470 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4471 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4472 | - } else {
|
|
| 4473 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4474 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4475 | - } |
|
| 4476 | - } |
|
| 4477 | - } |
|
| 4470 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4471 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4472 | + } else {
|
|
| 4473 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4474 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4475 | + } |
|
| 4476 | + } |
|
| 4477 | + } |
|
| 4478 | 4478 | |
| 4479 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4480 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4481 | - if ($default_category_id) {
|
|
| 4482 | - $save_post['post_default_category'] = $default_category_id; |
|
| 4483 | - $gd_post['default_category'] = $default_category_id; |
|
| 4484 | - } |
|
| 4485 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4486 | - } |
|
| 4487 | - $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4488 | - // Save post info |
|
| 4489 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4490 | - $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4491 | - // post taxonomies |
|
| 4492 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4493 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4479 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4480 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4481 | + if ($default_category_id) {
|
|
| 4482 | + $save_post['post_default_category'] = $default_category_id; |
|
| 4483 | + $gd_post['default_category'] = $default_category_id; |
|
| 4484 | + } |
|
| 4485 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4486 | + } |
|
| 4487 | + $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4488 | + // Save post info |
|
| 4489 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4490 | + $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4491 | + // post taxonomies |
|
| 4492 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4493 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4494 | 4494 | |
| 4495 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4496 | - if ($default_category_id) {
|
|
| 4497 | - $post_default_category = $default_category_id; |
|
| 4498 | - } |
|
| 4499 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4500 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4501 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4495 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4496 | + if ($default_category_id) {
|
|
| 4497 | + $post_default_category = $default_category_id; |
|
| 4498 | + } |
|
| 4499 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4500 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4501 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4502 | 4502 | |
| 4503 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 4504 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4505 | - } |
|
| 4503 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 4504 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4505 | + } |
|
| 4506 | 4506 | |
| 4507 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4507 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4508 | 4508 | |
| 4509 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4510 | - } |
|
| 4511 | - $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4512 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4513 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4514 | - } |
|
| 4515 | - $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4516 | - // Post images |
|
| 4517 | - if ( !empty( $post_images ) ) {
|
|
| 4518 | - $post_images = array_unique($post_images); |
|
| 4509 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4510 | + } |
|
| 4511 | + $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4512 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4513 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4514 | + } |
|
| 4515 | + $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4516 | + // Post images |
|
| 4517 | + if ( !empty( $post_images ) ) {
|
|
| 4518 | + $post_images = array_unique($post_images); |
|
| 4519 | 4519 | |
| 4520 | - $old_post_images_arr = array(); |
|
| 4521 | - $saved_post_images_arr = array(); |
|
| 4520 | + $old_post_images_arr = array(); |
|
| 4521 | + $saved_post_images_arr = array(); |
|
| 4522 | 4522 | |
| 4523 | - $order = 1; |
|
| 4523 | + $order = 1; |
|
| 4524 | 4524 | |
| 4525 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4526 | - $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4527 | - if (!empty($old_post_images)) {
|
|
| 4528 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4529 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4530 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 4531 | - } |
|
| 4532 | - } |
|
| 4533 | - } |
|
| 4525 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4526 | + $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4527 | + if (!empty($old_post_images)) {
|
|
| 4528 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 4529 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4530 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 4531 | + } |
|
| 4532 | + } |
|
| 4533 | + } |
|
| 4534 | 4534 | |
| 4535 | - foreach ( $post_images as $post_image ) {
|
|
| 4536 | - $image_name = basename( $post_image ); |
|
| 4537 | - $saved_post_images_arr[] = $image_name; |
|
| 4535 | + foreach ( $post_images as $post_image ) {
|
|
| 4536 | + $image_name = basename( $post_image ); |
|
| 4537 | + $saved_post_images_arr[] = $image_name; |
|
| 4538 | 4538 | |
| 4539 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4540 | - continue; // Skip if image already exists. |
|
| 4541 | - } |
|
| 4539 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4540 | + continue; // Skip if image already exists. |
|
| 4541 | + } |
|
| 4542 | 4542 | |
| 4543 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4544 | - array_pop( $image_name_parts ); |
|
| 4545 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4546 | - $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4547 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4548 | - $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4549 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4550 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 4543 | + $image_name_parts = explode( '.', $image_name ); |
|
| 4544 | + array_pop( $image_name_parts ); |
|
| 4545 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4546 | + $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4547 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4548 | + $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4549 | + if ( !empty( $arr_file_type ) ) {
|
|
| 4550 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 4551 | 4551 | |
| 4552 | - $attachment = array(); |
|
| 4553 | - $attachment['post_id'] = $saved_post_id; |
|
| 4554 | - $attachment['title'] = $proper_image_name; |
|
| 4555 | - $attachment['content'] = ''; |
|
| 4556 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4557 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 4558 | - $attachment['menu_order'] = $order; |
|
| 4559 | - $attachment['is_featured'] = 0; |
|
| 4560 | - |
|
| 4561 | - $attachment_set = ''; |
|
| 4562 | - foreach ( $attachment as $key => $val ) {
|
|
| 4563 | - if ( $val != '' ) {
|
|
| 4564 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4565 | - } |
|
| 4566 | - } |
|
| 4567 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4552 | + $attachment = array(); |
|
| 4553 | + $attachment['post_id'] = $saved_post_id; |
|
| 4554 | + $attachment['title'] = $proper_image_name; |
|
| 4555 | + $attachment['content'] = ''; |
|
| 4556 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4557 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 4558 | + $attachment['menu_order'] = $order; |
|
| 4559 | + $attachment['is_featured'] = 0; |
|
| 4560 | + |
|
| 4561 | + $attachment_set = ''; |
|
| 4562 | + foreach ( $attachment as $key => $val ) {
|
|
| 4563 | + if ( $val != '' ) {
|
|
| 4564 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4565 | + } |
|
| 4566 | + } |
|
| 4567 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 4568 | 4568 | |
| 4569 | - // Add new attachment |
|
| 4570 | - $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4571 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4572 | - $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4573 | - $order++; |
|
| 4574 | - } |
|
| 4575 | - } |
|
| 4576 | - |
|
| 4577 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4578 | - // Remove previous attachment |
|
| 4579 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4580 | - $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4581 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4582 | - geodir_set_wp_featured_image($saved_post_id); |
|
| 4583 | - $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4584 | - /* |
|
| 4569 | + // Add new attachment |
|
| 4570 | + $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4571 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4572 | + $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4573 | + $order++; |
|
| 4574 | + } |
|
| 4575 | + } |
|
| 4576 | + |
|
| 4577 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4578 | + // Remove previous attachment |
|
| 4579 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4580 | + $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4581 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4582 | + geodir_set_wp_featured_image($saved_post_id); |
|
| 4583 | + $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4584 | + /* |
|
| 4585 | 4585 | $menu_order = 1; |
| 4586 | 4586 | |
| 4587 | 4587 | foreach ( $saved_post_images_arr as $img_name ) {
|
@@ -4594,288 +4594,288 @@ discard block |
||
| 4594 | 4594 | } |
| 4595 | 4595 | $menu_order++; |
| 4596 | 4596 | }*/ |
| 4597 | - } |
|
| 4597 | + } |
|
| 4598 | 4598 | |
| 4599 | - if ( $order > 1 ) {
|
|
| 4600 | - $images++; |
|
| 4601 | - } |
|
| 4602 | - } |
|
| 4603 | - $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4604 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4605 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4606 | - $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4607 | - if (isset($is_featured)) {
|
|
| 4608 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4609 | - } |
|
| 4610 | - if (isset($gd_post['alive_days'])) {
|
|
| 4611 | - geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4612 | - } |
|
| 4613 | - if (isset($gd_post['expire_date'])) {
|
|
| 4614 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4615 | - } |
|
| 4616 | - $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4617 | - } |
|
| 4599 | + if ( $order > 1 ) {
|
|
| 4600 | + $images++; |
|
| 4601 | + } |
|
| 4602 | + } |
|
| 4603 | + $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4604 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4605 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4606 | + $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4607 | + if (isset($is_featured)) {
|
|
| 4608 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4609 | + } |
|
| 4610 | + if (isset($gd_post['alive_days'])) {
|
|
| 4611 | + geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4612 | + } |
|
| 4613 | + if (isset($gd_post['expire_date'])) {
|
|
| 4614 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4615 | + } |
|
| 4616 | + $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4617 | + } |
|
| 4618 | 4618 | |
| 4619 | - // WPML |
|
| 4620 | - if ($is_wpml && $language != '') {
|
|
| 4621 | - $sitepress->switch_lang($active_lang, true); |
|
| 4622 | - } |
|
| 4623 | - // WPML |
|
| 4624 | - } |
|
| 4625 | - } |
|
| 4626 | - } |
|
| 4619 | + // WPML |
|
| 4620 | + if ($is_wpml && $language != '') {
|
|
| 4621 | + $sitepress->switch_lang($active_lang, true); |
|
| 4622 | + } |
|
| 4623 | + // WPML |
|
| 4624 | + } |
|
| 4625 | + } |
|
| 4626 | + } |
|
| 4627 | 4627 | |
| 4628 | - //undo some stuff to make the import quicker |
|
| 4629 | - wp_defer_term_counting( false ); |
|
| 4630 | - wp_defer_comment_counting( false ); |
|
| 4631 | - $wpdb->query( 'COMMIT;' ); |
|
| 4632 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4633 | - $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4634 | - $json = array(); |
|
| 4635 | - $json['processed'] = $processed_actual; |
|
| 4636 | - $json['created'] = $created; |
|
| 4637 | - $json['updated'] = $updated; |
|
| 4638 | - $json['skipped'] = $skipped; |
|
| 4639 | - $json['invalid'] = $invalid; |
|
| 4640 | - $json['invalid_addr'] = $invalid_addr; |
|
| 4641 | - $json['images'] = $images; |
|
| 4642 | - $json['timing'] = microtime(true)-$xstart; |
|
| 4643 | - $json['timings'] = $xtimings; |
|
| 4628 | + //undo some stuff to make the import quicker |
|
| 4629 | + wp_defer_term_counting( false ); |
|
| 4630 | + wp_defer_comment_counting( false ); |
|
| 4631 | + $wpdb->query( 'COMMIT;' ); |
|
| 4632 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4633 | + $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4634 | + $json = array(); |
|
| 4635 | + $json['processed'] = $processed_actual; |
|
| 4636 | + $json['created'] = $created; |
|
| 4637 | + $json['updated'] = $updated; |
|
| 4638 | + $json['skipped'] = $skipped; |
|
| 4639 | + $json['invalid'] = $invalid; |
|
| 4640 | + $json['invalid_addr'] = $invalid_addr; |
|
| 4641 | + $json['images'] = $images; |
|
| 4642 | + $json['timing'] = microtime(true)-$xstart; |
|
| 4643 | + $json['timings'] = $xtimings; |
|
| 4644 | 4644 | |
| 4645 | 4645 | |
| 4646 | - wp_send_json( $json ); |
|
| 4647 | - exit; |
|
| 4648 | - } else if ( $task == 'import_loc' ) {
|
|
| 4649 | - global $gd_post_types; |
|
| 4650 | - $gd_post_types = $post_types; |
|
| 4646 | + wp_send_json( $json ); |
|
| 4647 | + exit; |
|
| 4648 | + } else if ( $task == 'import_loc' ) {
|
|
| 4649 | + global $gd_post_types; |
|
| 4650 | + $gd_post_types = $post_types; |
|
| 4651 | 4651 | |
| 4652 | - if (!empty($file)) {
|
|
| 4653 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4652 | + if (!empty($file)) {
|
|
| 4653 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4654 | 4654 | |
| 4655 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4656 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4657 | - wp_send_json( $json ); |
|
| 4658 | - } |
|
| 4655 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4656 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4657 | + wp_send_json( $json ); |
|
| 4658 | + } |
|
| 4659 | 4659 | |
| 4660 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4661 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4662 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4663 | - $index = $processed + $i; |
|
| 4660 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4661 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4662 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4663 | + $index = $processed + $i; |
|
| 4664 | 4664 | |
| 4665 | - if (isset($file[$index])) {
|
|
| 4666 | - $row = $file[$index]; |
|
| 4667 | - $row = array_map( 'trim', $row ); |
|
| 4668 | - $data = array(); |
|
| 4665 | + if (isset($file[$index])) {
|
|
| 4666 | + $row = $file[$index]; |
|
| 4667 | + $row = array_map( 'trim', $row ); |
|
| 4668 | + $data = array(); |
|
| 4669 | 4669 | |
| 4670 | - foreach ($columns as $c => $column ) {
|
|
| 4671 | - if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
|
|
| 4672 | - $data[$column] = $row[$c]; |
|
| 4673 | - } |
|
| 4674 | - } |
|
| 4670 | + foreach ($columns as $c => $column ) {
|
|
| 4671 | + if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
|
|
| 4672 | + $data[$column] = $row[$c]; |
|
| 4673 | + } |
|
| 4674 | + } |
|
| 4675 | 4675 | |
| 4676 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4677 | - $invalid++; |
|
| 4678 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4679 | - continue; |
|
| 4680 | - } |
|
| 4676 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4677 | + $invalid++; |
|
| 4678 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4679 | + continue; |
|
| 4680 | + } |
|
| 4681 | 4681 | |
| 4682 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4682 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4683 | 4683 | |
| 4684 | - if ( $import_choice == 'update' ) {
|
|
| 4685 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4686 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4687 | - $updated++; |
|
| 4688 | - } else {
|
|
| 4689 | - $invalid++; |
|
| 4690 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4691 | - } |
|
| 4692 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4693 | - $data['location_id'] = (int)$location->location_id; |
|
| 4684 | + if ( $import_choice == 'update' ) {
|
|
| 4685 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4686 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4687 | + $updated++; |
|
| 4688 | + } else {
|
|
| 4689 | + $invalid++; |
|
| 4690 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4691 | + } |
|
| 4692 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4693 | + $data['location_id'] = (int)$location->location_id; |
|
| 4694 | 4694 | |
| 4695 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4696 | - $data['location_id'] = (int)$location->location_id; |
|
| 4697 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4698 | - $data['location_id'] = (int)$location->location_id; |
|
| 4699 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4700 | - $data['location_id'] = (int)$location->location_id; |
|
| 4701 | - } |
|
| 4695 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4696 | + $data['location_id'] = (int)$location->location_id; |
|
| 4697 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4698 | + $data['location_id'] = (int)$location->location_id; |
|
| 4699 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4700 | + $data['location_id'] = (int)$location->location_id; |
|
| 4701 | + } |
|
| 4702 | 4702 | |
| 4703 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4704 | - $updated++; |
|
| 4705 | - } else {
|
|
| 4706 | - $invalid++; |
|
| 4707 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4708 | - } |
|
| 4709 | - } else {
|
|
| 4710 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4711 | - $created++; |
|
| 4712 | - } else {
|
|
| 4713 | - $invalid++; |
|
| 4714 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4715 | - } |
|
| 4716 | - } |
|
| 4717 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4718 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4719 | - $skipped++; |
|
| 4720 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4721 | - $skipped++; |
|
| 4722 | - } else {
|
|
| 4723 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4724 | - $created++; |
|
| 4725 | - } else {
|
|
| 4726 | - $invalid++; |
|
| 4727 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4728 | - } |
|
| 4729 | - } |
|
| 4730 | - } else {
|
|
| 4731 | - $invalid++; |
|
| 4732 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4733 | - } |
|
| 4734 | - } |
|
| 4735 | - } |
|
| 4736 | - } |
|
| 4703 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4704 | + $updated++; |
|
| 4705 | + } else {
|
|
| 4706 | + $invalid++; |
|
| 4707 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4708 | + } |
|
| 4709 | + } else {
|
|
| 4710 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4711 | + $created++; |
|
| 4712 | + } else {
|
|
| 4713 | + $invalid++; |
|
| 4714 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4715 | + } |
|
| 4716 | + } |
|
| 4717 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4718 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4719 | + $skipped++; |
|
| 4720 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4721 | + $skipped++; |
|
| 4722 | + } else {
|
|
| 4723 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4724 | + $created++; |
|
| 4725 | + } else {
|
|
| 4726 | + $invalid++; |
|
| 4727 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4728 | + } |
|
| 4729 | + } |
|
| 4730 | + } else {
|
|
| 4731 | + $invalid++; |
|
| 4732 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4733 | + } |
|
| 4734 | + } |
|
| 4735 | + } |
|
| 4736 | + } |
|
| 4737 | 4737 | |
| 4738 | - $json = array(); |
|
| 4739 | - $json['processed'] = $limit; |
|
| 4740 | - $json['created'] = $created; |
|
| 4741 | - $json['updated'] = $updated; |
|
| 4742 | - $json['skipped'] = $skipped; |
|
| 4743 | - $json['invalid'] = $invalid; |
|
| 4744 | - $json['images'] = $images; |
|
| 4738 | + $json = array(); |
|
| 4739 | + $json['processed'] = $limit; |
|
| 4740 | + $json['created'] = $created; |
|
| 4741 | + $json['updated'] = $updated; |
|
| 4742 | + $json['skipped'] = $skipped; |
|
| 4743 | + $json['invalid'] = $invalid; |
|
| 4744 | + $json['images'] = $images; |
|
| 4745 | 4745 | |
| 4746 | - wp_send_json( $json ); |
|
| 4747 | - } else if ( $task == 'import_hood' ) {
|
|
| 4748 | - if (!empty($file)) {
|
|
| 4749 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4746 | + wp_send_json( $json ); |
|
| 4747 | + } else if ( $task == 'import_hood' ) {
|
|
| 4748 | + if (!empty($file)) {
|
|
| 4749 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4750 | 4750 | |
| 4751 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4752 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4753 | - wp_send_json( $json ); |
|
| 4754 | - } |
|
| 4751 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4752 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4753 | + wp_send_json( $json ); |
|
| 4754 | + } |
|
| 4755 | 4755 | |
| 4756 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4757 | - $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4758 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4759 | - $index = $processed + $i; |
|
| 4756 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4757 | + $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4758 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4759 | + $index = $processed + $i; |
|
| 4760 | 4760 | |
| 4761 | - if (isset($file[$index])) {
|
|
| 4762 | - $row = $file[$index]; |
|
| 4763 | - $row = array_map( 'trim', $row ); |
|
| 4764 | - $data = array(); |
|
| 4761 | + if (isset($file[$index])) {
|
|
| 4762 | + $row = $file[$index]; |
|
| 4763 | + $row = array_map( 'trim', $row ); |
|
| 4764 | + $data = array(); |
|
| 4765 | 4765 | |
| 4766 | - foreach ($columns as $c => $column) {
|
|
| 4767 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4768 | - $data[$column] = sanitize_text_field($row[$c]); |
|
| 4769 | - } |
|
| 4770 | - } |
|
| 4766 | + foreach ($columns as $c => $column) {
|
|
| 4767 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4768 | + $data[$column] = sanitize_text_field($row[$c]); |
|
| 4769 | + } |
|
| 4770 | + } |
|
| 4771 | 4771 | |
| 4772 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4773 | - $invalid++; |
|
| 4774 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4775 | - continue; |
|
| 4776 | - } |
|
| 4772 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4773 | + $invalid++; |
|
| 4774 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4775 | + continue; |
|
| 4776 | + } |
|
| 4777 | 4777 | |
| 4778 | - $location_info = array(); |
|
| 4779 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4780 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4781 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4782 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4783 | - } |
|
| 4778 | + $location_info = array(); |
|
| 4779 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4780 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4781 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4782 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4783 | + } |
|
| 4784 | 4784 | |
| 4785 | - if (empty($location_info)) {
|
|
| 4786 | - $invalid++; |
|
| 4787 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4788 | - continue; |
|
| 4789 | - } |
|
| 4785 | + if (empty($location_info)) {
|
|
| 4786 | + $invalid++; |
|
| 4787 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4788 | + continue; |
|
| 4789 | + } |
|
| 4790 | 4790 | |
| 4791 | - $location_id = $location_info->location_id; |
|
| 4791 | + $location_id = $location_info->location_id; |
|
| 4792 | 4792 | |
| 4793 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4793 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4794 | 4794 | |
| 4795 | - $hood_data = array(); |
|
| 4796 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4797 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4798 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4799 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4800 | - $hood_data['hood_location_id'] = $location_id; |
|
| 4795 | + $hood_data = array(); |
|
| 4796 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4797 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4798 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4799 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4800 | + $hood_data['hood_location_id'] = $location_id; |
|
| 4801 | 4801 | |
| 4802 | - if ( $import_choice == 'update' ) {
|
|
| 4803 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4804 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4802 | + if ( $import_choice == 'update' ) {
|
|
| 4803 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4804 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4805 | 4805 | |
| 4806 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4807 | - $updated++; |
|
| 4808 | - } else {
|
|
| 4809 | - $invalid++; |
|
| 4810 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4811 | - } |
|
| 4812 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4813 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4806 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4807 | + $updated++; |
|
| 4808 | + } else {
|
|
| 4809 | + $invalid++; |
|
| 4810 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4811 | + } |
|
| 4812 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4813 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4814 | 4814 | |
| 4815 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4816 | - $updated++; |
|
| 4817 | - } else {
|
|
| 4818 | - $invalid++; |
|
| 4819 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4820 | - } |
|
| 4821 | - } else {
|
|
| 4822 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4823 | - $created++; |
|
| 4824 | - } else {
|
|
| 4825 | - $invalid++; |
|
| 4826 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4827 | - } |
|
| 4828 | - } |
|
| 4829 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4830 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4831 | - $skipped++; |
|
| 4832 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4833 | - $skipped++; |
|
| 4834 | - } else {
|
|
| 4815 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4816 | + $updated++; |
|
| 4817 | + } else {
|
|
| 4818 | + $invalid++; |
|
| 4819 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4820 | + } |
|
| 4821 | + } else {
|
|
| 4822 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4823 | + $created++; |
|
| 4824 | + } else {
|
|
| 4825 | + $invalid++; |
|
| 4826 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4827 | + } |
|
| 4828 | + } |
|
| 4829 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4830 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4831 | + $skipped++; |
|
| 4832 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4833 | + $skipped++; |
|
| 4834 | + } else {
|
|
| 4835 | 4835 | |
| 4836 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4837 | - $created++; |
|
| 4838 | - } else {
|
|
| 4839 | - $invalid++; |
|
| 4840 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4841 | - } |
|
| 4842 | - } |
|
| 4843 | - } else {
|
|
| 4844 | - $invalid++; |
|
| 4845 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4846 | - } |
|
| 4847 | - } |
|
| 4848 | - } |
|
| 4849 | - } |
|
| 4836 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4837 | + $created++; |
|
| 4838 | + } else {
|
|
| 4839 | + $invalid++; |
|
| 4840 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4841 | + } |
|
| 4842 | + } |
|
| 4843 | + } else {
|
|
| 4844 | + $invalid++; |
|
| 4845 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4846 | + } |
|
| 4847 | + } |
|
| 4848 | + } |
|
| 4849 | + } |
|
| 4850 | 4850 | |
| 4851 | - $json = array(); |
|
| 4852 | - $json['processed'] = $limit; |
|
| 4853 | - $json['created'] = $created; |
|
| 4854 | - $json['updated'] = $updated; |
|
| 4855 | - $json['skipped'] = $skipped; |
|
| 4856 | - $json['invalid'] = $invalid; |
|
| 4857 | - $json['images'] = $images; |
|
| 4851 | + $json = array(); |
|
| 4852 | + $json['processed'] = $limit; |
|
| 4853 | + $json['created'] = $created; |
|
| 4854 | + $json['updated'] = $updated; |
|
| 4855 | + $json['skipped'] = $skipped; |
|
| 4856 | + $json['invalid'] = $invalid; |
|
| 4857 | + $json['images'] = $images; |
|
| 4858 | 4858 | |
| 4859 | - wp_send_json( $json ); |
|
| 4860 | - } |
|
| 4861 | - } |
|
| 4862 | - break; |
|
| 4863 | - case 'import_finish':{
|
|
| 4864 | - /** |
|
| 4865 | - * Run an action when an import finishes. |
|
| 4866 | - * |
|
| 4867 | - * This action can be used to fire functions after an import ends. |
|
| 4868 | - * |
|
| 4869 | - * @since 1.5.3 |
|
| 4870 | - * @package GeoDirectory |
|
| 4871 | - */ |
|
| 4872 | - do_action('geodir_import_finished');
|
|
| 4873 | - } |
|
| 4874 | - break; |
|
| 4859 | + wp_send_json( $json ); |
|
| 4860 | + } |
|
| 4861 | + } |
|
| 4862 | + break; |
|
| 4863 | + case 'import_finish':{
|
|
| 4864 | + /** |
|
| 4865 | + * Run an action when an import finishes. |
|
| 4866 | + * |
|
| 4867 | + * This action can be used to fire functions after an import ends. |
|
| 4868 | + * |
|
| 4869 | + * @since 1.5.3 |
|
| 4870 | + * @package GeoDirectory |
|
| 4871 | + */ |
|
| 4872 | + do_action('geodir_import_finished');
|
|
| 4873 | + } |
|
| 4874 | + break; |
|
| 4875 | 4875 | |
| 4876 | - } |
|
| 4877 | - echo '0'; |
|
| 4878 | - gd_die(); |
|
| 4876 | + } |
|
| 4877 | + echo '0'; |
|
| 4878 | + gd_die(); |
|
| 4879 | 4879 | } |
| 4880 | 4880 | |
| 4881 | 4881 | /** |
@@ -4919,12 +4919,12 @@ discard block |
||
| 4919 | 4919 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 4920 | 4920 | } |
| 4921 | 4921 | |
| 4922 | - if( !empty( $term ) ) {
|
|
| 4922 | + if( !empty( $term ) ) {
|
|
| 4923 | 4923 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 4924 | - if( !is_wp_error( $result ) ) {
|
|
| 4925 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4926 | - } |
|
| 4927 | - } |
|
| 4924 | + if( !is_wp_error( $result ) ) {
|
|
| 4925 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4926 | + } |
|
| 4927 | + } |
|
| 4928 | 4928 | |
| 4929 | 4929 | return false; |
| 4930 | 4930 | } |
@@ -4970,16 +4970,16 @@ discard block |
||
| 4970 | 4970 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 4971 | 4971 | |
| 4972 | 4972 | if( !is_wp_error( $result ) ) {
|
| 4973 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4974 | - } |
|
| 4973 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4974 | + } |
|
| 4975 | 4975 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 4976 | 4976 | $term_data['term_id'] = $term_info['term_id']; |
| 4977 | 4977 | |
| 4978 | 4978 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 4979 | 4979 | |
| 4980 | 4980 | if( !is_wp_error( $result ) ) {
|
| 4981 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4982 | - } |
|
| 4981 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4982 | + } |
|
| 4983 | 4983 | } else {
|
| 4984 | 4984 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 4985 | 4985 | } |
@@ -5001,47 +5001,47 @@ discard block |
||
| 5001 | 5001 | * @return int Posts count. |
| 5002 | 5002 | */ |
| 5003 | 5003 | function geodir_get_posts_count( $post_type ) {
|
| 5004 | - global $wpdb, $plugin_prefix; |
|
| 5004 | + global $wpdb, $plugin_prefix; |
|
| 5005 | 5005 | |
| 5006 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5007 | - return 0; |
|
| 5008 | - } |
|
| 5006 | + if ( !post_type_exists( $post_type ) ) {
|
|
| 5007 | + return 0; |
|
| 5008 | + } |
|
| 5009 | 5009 | |
| 5010 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5010 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5011 | 5011 | |
| 5012 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5013 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5014 | - $where_statuses = ''; |
|
| 5015 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5016 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5017 | - } |
|
| 5012 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5013 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5014 | + $where_statuses = ''; |
|
| 5015 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5016 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5017 | + } |
|
| 5018 | 5018 | |
| 5019 | - /** |
|
| 5020 | - * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5021 | - * |
|
| 5022 | - * @since 1.6.4 |
|
| 5023 | - * @package GeoDirectory |
|
| 5024 | - * |
|
| 5025 | - * @param string $where SQL where clause part. |
|
| 5026 | - */ |
|
| 5027 | - $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5028 | - |
|
| 5029 | - $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5030 | - |
|
| 5031 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5019 | + /** |
|
| 5020 | + * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5021 | + * |
|
| 5022 | + * @since 1.6.4 |
|
| 5023 | + * @package GeoDirectory |
|
| 5024 | + * |
|
| 5025 | + * @param string $where SQL where clause part. |
|
| 5026 | + */ |
|
| 5027 | + $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5028 | + |
|
| 5029 | + $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5030 | + |
|
| 5031 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5032 | 5032 | |
| 5033 | - /** |
|
| 5034 | - * Modify returned post counts for the current post type. |
|
| 5035 | - * |
|
| 5036 | - * @since 1.4.6 |
|
| 5037 | - * @package GeoDirectory |
|
| 5038 | - * |
|
| 5039 | - * @param int $posts_count Post counts. |
|
| 5040 | - * @param string $post_type Post type. |
|
| 5041 | - */ |
|
| 5042 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5043 | - |
|
| 5044 | - return $posts_count; |
|
| 5033 | + /** |
|
| 5034 | + * Modify returned post counts for the current post type. |
|
| 5035 | + * |
|
| 5036 | + * @since 1.4.6 |
|
| 5037 | + * @package GeoDirectory |
|
| 5038 | + * |
|
| 5039 | + * @param int $posts_count Post counts. |
|
| 5040 | + * @param string $post_type Post type. |
|
| 5041 | + */ |
|
| 5042 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5043 | + |
|
| 5044 | + return $posts_count; |
|
| 5045 | 5045 | } |
| 5046 | 5046 | |
| 5047 | 5047 | /** |
@@ -5070,10 +5070,10 @@ discard block |
||
| 5070 | 5070 | |
| 5071 | 5071 | if ( !empty( $posts ) ) {
|
| 5072 | 5072 | $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
| 5073 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5074 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5075 | - $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5076 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 5073 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5074 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5075 | + $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5076 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 5077 | 5077 | |
| 5078 | 5078 | $csv_row = array(); |
| 5079 | 5079 | $csv_row[] = 'post_id'; |
@@ -5105,7 +5105,7 @@ discard block |
||
| 5105 | 5105 | } |
| 5106 | 5106 | $csv_row[] = 'post_status'; |
| 5107 | 5107 | $csv_row[] = 'is_featured'; |
| 5108 | - // Export claim listing field |
|
| 5108 | + // Export claim listing field |
|
| 5109 | 5109 | if ($is_claim_active) {
|
| 5110 | 5110 | $csv_row[] = 'claimed'; |
| 5111 | 5111 | } |
@@ -5114,7 +5114,7 @@ discard block |
||
| 5114 | 5114 | $csv_row[] = 'alive_days'; |
| 5115 | 5115 | $csv_row[] = 'expire_date'; |
| 5116 | 5116 | } |
| 5117 | - $csv_row[] = 'post_date'; |
|
| 5117 | + $csv_row[] = 'post_date'; |
|
| 5118 | 5118 | $csv_row[] = 'post_address'; |
| 5119 | 5119 | $csv_row[] = 'post_city'; |
| 5120 | 5120 | $csv_row[] = 'post_region'; |
@@ -5122,11 +5122,11 @@ discard block |
||
| 5122 | 5122 | $csv_row[] = 'post_zip'; |
| 5123 | 5123 | $csv_row[] = 'post_latitude'; |
| 5124 | 5124 | $csv_row[] = 'post_longitude'; |
| 5125 | - if ($neighbourhood_active) {
|
|
| 5126 | - $csv_row[] = 'post_neighbourhood'; |
|
| 5127 | - $csv_row[] = 'neighbourhood_latitude'; |
|
| 5128 | - $csv_row[] = 'neighbourhood_longitude'; |
|
| 5129 | - } |
|
| 5125 | + if ($neighbourhood_active) {
|
|
| 5126 | + $csv_row[] = 'post_neighbourhood'; |
|
| 5127 | + $csv_row[] = 'neighbourhood_latitude'; |
|
| 5128 | + $csv_row[] = 'neighbourhood_longitude'; |
|
| 5129 | + } |
|
| 5130 | 5130 | $csv_row[] = 'geodir_timing'; |
| 5131 | 5131 | $csv_row[] = 'geodir_contact'; |
| 5132 | 5132 | $csv_row[] = 'geodir_email'; |
@@ -5158,21 +5158,21 @@ discard block |
||
| 5158 | 5158 | $csv_row[] = 'franchise'; |
| 5159 | 5159 | } |
| 5160 | 5160 | |
| 5161 | - /** |
|
| 5162 | - * Filter columns field names of gd export listings csv. |
|
| 5163 | - * |
|
| 5164 | - * @since 1.6.5 |
|
| 5165 | - * @package GeoDirectory |
|
| 5166 | - * |
|
| 5167 | - * @param array $csv_row Column names being exported in csv. |
|
| 5168 | - * @param string $post_type The post type. |
|
| 5169 | - */ |
|
| 5170 | - $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5161 | + /** |
|
| 5162 | + * Filter columns field names of gd export listings csv. |
|
| 5163 | + * |
|
| 5164 | + * @since 1.6.5 |
|
| 5165 | + * @package GeoDirectory |
|
| 5166 | + * |
|
| 5167 | + * @param array $csv_row Column names being exported in csv. |
|
| 5168 | + * @param string $post_type The post type. |
|
| 5169 | + */ |
|
| 5170 | + $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5171 | 5171 | |
| 5172 | 5172 | $csv_rows[] = $csv_row; |
| 5173 | 5173 | |
| 5174 | 5174 | $images_count = 5; |
| 5175 | - $xx=0; |
|
| 5175 | + $xx=0; |
|
| 5176 | 5176 | foreach ( $posts as $post ) {$xx++;
|
| 5177 | 5177 | $post_id = $post['ID']; |
| 5178 | 5178 | |
@@ -5303,15 +5303,15 @@ discard block |
||
| 5303 | 5303 | } |
| 5304 | 5304 | $csv_row[] = $post_info['post_status']; // post_status |
| 5305 | 5305 | $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
| 5306 | - if ($is_claim_active) {
|
|
| 5307 | - $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5308 | - } |
|
| 5306 | + if ($is_claim_active) {
|
|
| 5307 | + $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5308 | + } |
|
| 5309 | 5309 | if ($is_payment_plugin) {
|
| 5310 | 5310 | $csv_row[] = (int)$post_info['package_id']; // package_id |
| 5311 | 5311 | $csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days |
| 5312 | 5312 | $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
| 5313 | 5313 | } |
| 5314 | - $csv_row[] = $post_info['post_date']; // post_date |
|
| 5314 | + $csv_row[] = $post_info['post_date']; // post_date |
|
| 5315 | 5315 | $csv_row[] = stripslashes($post_info['post_address']); // post_address |
| 5316 | 5316 | $csv_row[] = stripslashes($post_info['post_city']); // post_city |
| 5317 | 5317 | $csv_row[] = stripslashes($post_info['post_region']); // post_region |
@@ -5319,21 +5319,21 @@ discard block |
||
| 5319 | 5319 | $csv_row[] = stripslashes($post_info['post_zip']); // post_zip |
| 5320 | 5320 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
| 5321 | 5321 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
| 5322 | - if ($neighbourhood_active) {
|
|
| 5323 | - $post_neighbourhood = ''; |
|
| 5324 | - $neighbourhood_latitude = ''; |
|
| 5325 | - $neighbourhood_longitude = ''; |
|
| 5326 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5327 | - if (!empty($hood_info)) {
|
|
| 5328 | - $post_neighbourhood = $hood_info->hood_name; |
|
| 5329 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5330 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5331 | - } |
|
| 5332 | - } |
|
| 5333 | - $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5334 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5335 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5336 | - } |
|
| 5322 | + if ($neighbourhood_active) {
|
|
| 5323 | + $post_neighbourhood = ''; |
|
| 5324 | + $neighbourhood_latitude = ''; |
|
| 5325 | + $neighbourhood_longitude = ''; |
|
| 5326 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5327 | + if (!empty($hood_info)) {
|
|
| 5328 | + $post_neighbourhood = $hood_info->hood_name; |
|
| 5329 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5330 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5331 | + } |
|
| 5332 | + } |
|
| 5333 | + $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5334 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5335 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5336 | + } |
|
| 5337 | 5337 | $csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing |
| 5338 | 5338 | $csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact |
| 5339 | 5339 | $csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email |
@@ -5373,16 +5373,16 @@ discard block |
||
| 5373 | 5373 | $csv_row[] = (int)$franchise; // franchise id |
| 5374 | 5374 | } |
| 5375 | 5375 | |
| 5376 | - /** |
|
| 5377 | - * Filter columns values of gd export listings csv file |
|
| 5378 | - * |
|
| 5379 | - * @since 1.6.5 |
|
| 5380 | - * @package GeoDirectory |
|
| 5381 | - * |
|
| 5382 | - * @param array $csv_row Field values being exported in csv. |
|
| 5383 | - * @param array $post_info The post info. |
|
| 5384 | - */ |
|
| 5385 | - $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5376 | + /** |
|
| 5377 | + * Filter columns values of gd export listings csv file |
|
| 5378 | + * |
|
| 5379 | + * @since 1.6.5 |
|
| 5380 | + * @package GeoDirectory |
|
| 5381 | + * |
|
| 5382 | + * @param array $csv_row Field values being exported in csv. |
|
| 5383 | + * @param array $post_info The post info. |
|
| 5384 | + */ |
|
| 5385 | + $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5386 | 5386 | |
| 5387 | 5387 | for ( $c = 0; $c < $images_count; $c++ ) {
|
| 5388 | 5388 | $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
@@ -5415,64 +5415,64 @@ discard block |
||
| 5415 | 5415 | * @return array Array of posts data. |
| 5416 | 5416 | */ |
| 5417 | 5417 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5418 | - global $wpdb, $plugin_prefix; |
|
| 5418 | + global $wpdb, $plugin_prefix; |
|
| 5419 | 5419 | |
| 5420 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5421 | - return new stdClass; |
|
| 5420 | + if ( ! post_type_exists( $post_type ) ) |
|
| 5421 | + return new stdClass; |
|
| 5422 | 5422 | |
| 5423 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5423 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5424 | 5424 | |
| 5425 | - $limit = ''; |
|
| 5426 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5427 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5425 | + $limit = ''; |
|
| 5426 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5427 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 5428 | 5428 | |
| 5429 | - if ( $offset > 0 ) {
|
|
| 5430 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5431 | - } else {
|
|
| 5432 | - $limit = " LIMIT " . $per_page; |
|
| 5433 | - } |
|
| 5434 | - } |
|
| 5429 | + if ( $offset > 0 ) {
|
|
| 5430 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5431 | + } else {
|
|
| 5432 | + $limit = " LIMIT " . $per_page; |
|
| 5433 | + } |
|
| 5434 | + } |
|
| 5435 | 5435 | |
| 5436 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5437 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5438 | - $where_statuses = ''; |
|
| 5439 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5440 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5441 | - } |
|
| 5436 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5437 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5438 | + $where_statuses = ''; |
|
| 5439 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5440 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5441 | + } |
|
| 5442 | 5442 | |
| 5443 | - /** |
|
| 5444 | - * Filter the SQL where clause part to filter posts in import/export. |
|
| 5445 | - * |
|
| 5446 | - * @since 1.6.4 |
|
| 5447 | - * @package GeoDirectory |
|
| 5448 | - * |
|
| 5449 | - * @param string $where SQL where clause part. |
|
| 5450 | - */ |
|
| 5451 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5452 | - |
|
| 5453 | - $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
|
|
| 5454 | - /** |
|
| 5455 | - * Modify returned posts SQL query for the current post type. |
|
| 5456 | - * |
|
| 5457 | - * @since 1.4.6 |
|
| 5458 | - * @package GeoDirectory |
|
| 5459 | - * |
|
| 5460 | - * @param int $query The SQL query. |
|
| 5461 | - * @param string $post_type Post type. |
|
| 5462 | - */ |
|
| 5463 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5464 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5465 | - |
|
| 5466 | - /** |
|
| 5467 | - * Modify returned post results for the current post type. |
|
| 5468 | - * |
|
| 5469 | - * @since 1.4.6 |
|
| 5470 | - * @package GeoDirectory |
|
| 5471 | - * |
|
| 5472 | - * @param object $results An object containing all post ids. |
|
| 5473 | - * @param string $post_type Post type. |
|
| 5474 | - */ |
|
| 5475 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5443 | + /** |
|
| 5444 | + * Filter the SQL where clause part to filter posts in import/export. |
|
| 5445 | + * |
|
| 5446 | + * @since 1.6.4 |
|
| 5447 | + * @package GeoDirectory |
|
| 5448 | + * |
|
| 5449 | + * @param string $where SQL where clause part. |
|
| 5450 | + */ |
|
| 5451 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5452 | + |
|
| 5453 | + $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
|
|
| 5454 | + /** |
|
| 5455 | + * Modify returned posts SQL query for the current post type. |
|
| 5456 | + * |
|
| 5457 | + * @since 1.4.6 |
|
| 5458 | + * @package GeoDirectory |
|
| 5459 | + * |
|
| 5460 | + * @param int $query The SQL query. |
|
| 5461 | + * @param string $post_type Post type. |
|
| 5462 | + */ |
|
| 5463 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5464 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5465 | + |
|
| 5466 | + /** |
|
| 5467 | + * Modify returned post results for the current post type. |
|
| 5468 | + * |
|
| 5469 | + * @since 1.4.6 |
|
| 5470 | + * @package GeoDirectory |
|
| 5471 | + * |
|
| 5472 | + * @param object $results An object containing all post ids. |
|
| 5473 | + * @param string $post_type Post type. |
|
| 5474 | + */ |
|
| 5475 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5476 | 5476 | } |
| 5477 | 5477 | |
| 5478 | 5478 | /** |
@@ -5491,26 +5491,26 @@ discard block |
||
| 5491 | 5491 | * @return string The SQL query. |
| 5492 | 5492 | */ |
| 5493 | 5493 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 5494 | - if ( $post_type == 'gd_event' ) {
|
|
| 5495 | - global $wpdb, $plugin_prefix; |
|
| 5494 | + if ( $post_type == 'gd_event' ) {
|
|
| 5495 | + global $wpdb, $plugin_prefix; |
|
| 5496 | 5496 | |
| 5497 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5498 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5497 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5498 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5499 | 5499 | |
| 5500 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5501 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5502 | - $where_statuses = ''; |
|
| 5503 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5504 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5505 | - } |
|
| 5500 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5501 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5502 | + $where_statuses = ''; |
|
| 5503 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5504 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5505 | + } |
|
| 5506 | 5506 | |
| 5507 | - /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5508 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5507 | + /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5508 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5509 | 5509 | |
| 5510 | - $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
|
|
| 5511 | - } |
|
| 5510 | + $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
|
|
| 5511 | + } |
|
| 5512 | 5512 | |
| 5513 | - return $query; |
|
| 5513 | + return $query; |
|
| 5514 | 5514 | } |
| 5515 | 5515 | |
| 5516 | 5516 | /** |
@@ -5532,36 +5532,36 @@ discard block |
||
| 5532 | 5532 | * @return int Total terms count. |
| 5533 | 5533 | */ |
| 5534 | 5534 | function geodir_get_terms_count( $post_type ) {
|
| 5535 | - $args = array( 'hide_empty' => 0 ); |
|
| 5535 | + $args = array( 'hide_empty' => 0 ); |
|
| 5536 | 5536 | |
| 5537 | - remove_all_filters( 'get_terms' ); |
|
| 5537 | + remove_all_filters( 'get_terms' ); |
|
| 5538 | 5538 | |
| 5539 | - $taxonomy = $post_type . 'category'; |
|
| 5539 | + $taxonomy = $post_type . 'category'; |
|
| 5540 | 5540 | |
| 5541 | - // WPML |
|
| 5542 | - $is_wpml = geodir_is_wpml(); |
|
| 5543 | - $active_lang = 'all'; |
|
| 5544 | - if ( $is_wpml ) {
|
|
| 5545 | - global $sitepress; |
|
| 5546 | - $active_lang = $sitepress->get_current_language(); |
|
| 5541 | + // WPML |
|
| 5542 | + $is_wpml = geodir_is_wpml(); |
|
| 5543 | + $active_lang = 'all'; |
|
| 5544 | + if ( $is_wpml ) {
|
|
| 5545 | + global $sitepress; |
|
| 5546 | + $active_lang = $sitepress->get_current_language(); |
|
| 5547 | 5547 | |
| 5548 | - if ( $active_lang != 'all' ) {
|
|
| 5549 | - $sitepress->switch_lang( 'all', true ); |
|
| 5550 | - } |
|
| 5551 | - } |
|
| 5552 | - // WPML |
|
| 5548 | + if ( $active_lang != 'all' ) {
|
|
| 5549 | + $sitepress->switch_lang( 'all', true ); |
|
| 5550 | + } |
|
| 5551 | + } |
|
| 5552 | + // WPML |
|
| 5553 | 5553 | |
| 5554 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5554 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5555 | 5555 | |
| 5556 | - // WPML |
|
| 5557 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5558 | - global $sitepress; |
|
| 5559 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5560 | - } |
|
| 5561 | - // WPML |
|
| 5562 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5556 | + // WPML |
|
| 5557 | + if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5558 | + global $sitepress; |
|
| 5559 | + $sitepress->switch_lang( $active_lang, true ); |
|
| 5560 | + } |
|
| 5561 | + // WPML |
|
| 5562 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5563 | 5563 | |
| 5564 | - return $count_terms; |
|
| 5564 | + return $count_terms; |
|
| 5565 | 5565 | } |
| 5566 | 5566 | |
| 5567 | 5567 | /** |
@@ -5600,11 +5600,11 @@ discard block |
||
| 5600 | 5600 | $csv_row[] = 'cat_posttype'; |
| 5601 | 5601 | $csv_row[] = 'cat_parent'; |
| 5602 | 5602 | $csv_row[] = 'cat_schema'; |
| 5603 | - // WPML |
|
| 5603 | + // WPML |
|
| 5604 | 5604 | $is_wpml = geodir_is_wpml(); |
| 5605 | 5605 | if ($is_wpml) {
|
| 5606 | 5606 | $csv_row[] = 'cat_language'; |
| 5607 | - $csv_row[] = 'cat_id_original'; |
|
| 5607 | + $csv_row[] = 'cat_id_original'; |
|
| 5608 | 5608 | } |
| 5609 | 5609 | // WPML |
| 5610 | 5610 | $csv_row[] = 'cat_description'; |
@@ -5634,10 +5634,10 @@ discard block |
||
| 5634 | 5634 | $csv_row[] = $post_type; |
| 5635 | 5635 | $csv_row[] = $cat_parent; |
| 5636 | 5636 | $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
| 5637 | - // WPML |
|
| 5637 | + // WPML |
|
| 5638 | 5638 | if ($is_wpml) {
|
| 5639 | 5639 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
| 5640 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5640 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5641 | 5641 | } |
| 5642 | 5642 | // WPML |
| 5643 | 5643 | $csv_row[] = $term->description; |
@@ -6055,43 +6055,43 @@ discard block |
||
| 6055 | 6055 | * @param string $status Post status. |
| 6056 | 6056 | */ |
| 6057 | 6057 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
|
| 6058 | - global $wpdb, $current_user; |
|
| 6059 | - |
|
| 6060 | - $option_value = get_option($option); |
|
| 6061 | - |
|
| 6062 | - if ($option_value > 0) : |
|
| 6063 | - if (get_post($option_value)) : |
|
| 6064 | - // Page exists |
|
| 6065 | - return; |
|
| 6066 | - endif; |
|
| 6067 | - endif; |
|
| 6068 | - |
|
| 6069 | - $page_found = $wpdb->get_var( |
|
| 6070 | - $wpdb->prepare( |
|
| 6071 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6072 | - array($slug) |
|
| 6073 | - ) |
|
| 6074 | - ); |
|
| 6075 | - |
|
| 6076 | - if ($page_found) : |
|
| 6077 | - // Page exists |
|
| 6078 | - if (!$option_value) update_option($option, $page_found); |
|
| 6079 | - return; |
|
| 6080 | - endif; |
|
| 6081 | - |
|
| 6082 | - $page_data = array( |
|
| 6083 | - 'post_status' => $status, |
|
| 6084 | - 'post_type' => 'page', |
|
| 6085 | - 'post_author' => $current_user->ID, |
|
| 6086 | - 'post_name' => $slug, |
|
| 6087 | - 'post_title' => $page_title, |
|
| 6088 | - 'post_content' => $page_content, |
|
| 6089 | - 'post_parent' => $post_parent, |
|
| 6090 | - 'comment_status' => 'closed' |
|
| 6091 | - ); |
|
| 6092 | - $page_id = wp_insert_post($page_data); |
|
| 6093 | - |
|
| 6094 | - add_option($option, $page_id); |
|
| 6058 | + global $wpdb, $current_user; |
|
| 6059 | + |
|
| 6060 | + $option_value = get_option($option); |
|
| 6061 | + |
|
| 6062 | + if ($option_value > 0) : |
|
| 6063 | + if (get_post($option_value)) : |
|
| 6064 | + // Page exists |
|
| 6065 | + return; |
|
| 6066 | + endif; |
|
| 6067 | + endif; |
|
| 6068 | + |
|
| 6069 | + $page_found = $wpdb->get_var( |
|
| 6070 | + $wpdb->prepare( |
|
| 6071 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6072 | + array($slug) |
|
| 6073 | + ) |
|
| 6074 | + ); |
|
| 6075 | + |
|
| 6076 | + if ($page_found) : |
|
| 6077 | + // Page exists |
|
| 6078 | + if (!$option_value) update_option($option, $page_found); |
|
| 6079 | + return; |
|
| 6080 | + endif; |
|
| 6081 | + |
|
| 6082 | + $page_data = array( |
|
| 6083 | + 'post_status' => $status, |
|
| 6084 | + 'post_type' => 'page', |
|
| 6085 | + 'post_author' => $current_user->ID, |
|
| 6086 | + 'post_name' => $slug, |
|
| 6087 | + 'post_title' => $page_title, |
|
| 6088 | + 'post_content' => $page_content, |
|
| 6089 | + 'post_parent' => $post_parent, |
|
| 6090 | + 'comment_status' => 'closed' |
|
| 6091 | + ); |
|
| 6092 | + $page_id = wp_insert_post($page_data); |
|
| 6093 | + |
|
| 6094 | + add_option($option, $page_id); |
|
| 6095 | 6095 | |
| 6096 | 6096 | } |
| 6097 | 6097 | |
@@ -6122,9 +6122,9 @@ discard block |
||
| 6122 | 6122 | * @package GeoDirectory |
| 6123 | 6123 | */ |
| 6124 | 6124 | function geodir_admin_upgrade_notice() {
|
| 6125 | - $class = "error"; |
|
| 6126 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6127 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6125 | + $class = "error"; |
|
| 6126 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6127 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6128 | 6128 | } |
| 6129 | 6129 | |
| 6130 | 6130 | /** |
@@ -6137,18 +6137,18 @@ discard block |
||
| 6137 | 6137 | */ |
| 6138 | 6138 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 6139 | 6139 | {
|
| 6140 | - // readme contents |
|
| 6141 | - $args = array( |
|
| 6142 | - 'timeout' => 15, |
|
| 6143 | - 'redirection' => 5 |
|
| 6144 | - ); |
|
| 6145 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6146 | - $data = wp_remote_get( $url, $args ); |
|
| 6140 | + // readme contents |
|
| 6141 | + $args = array( |
|
| 6142 | + 'timeout' => 15, |
|
| 6143 | + 'redirection' => 5 |
|
| 6144 | + ); |
|
| 6145 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6146 | + $data = wp_remote_get( $url, $args ); |
|
| 6147 | 6147 | |
| 6148 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6148 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6149 | 6149 | |
| 6150 | - geodir_in_plugin_update_message($data['body']); |
|
| 6151 | - } |
|
| 6150 | + geodir_in_plugin_update_message($data['body']); |
|
| 6151 | + } |
|
| 6152 | 6152 | } |
| 6153 | 6153 | |
| 6154 | 6154 | |
@@ -6156,28 +6156,28 @@ discard block |
||
| 6156 | 6156 | * @param string $content http response body |
| 6157 | 6157 | */ |
| 6158 | 6158 | function geodir_in_plugin_update_message($content) {
|
| 6159 | - // Output Upgrade Notice |
|
| 6160 | - $matches = null; |
|
| 6161 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6162 | - $upgrade_notice = ''; |
|
| 6163 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6164 | - if(empty($matches)){return;}
|
|
| 6165 | - |
|
| 6166 | - $version = trim( $matches[1] ); |
|
| 6167 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6168 | - |
|
| 6169 | - |
|
| 6170 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6171 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6172 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6173 | - foreach ( $notices as $index => $line ) {
|
|
| 6174 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6175 | - } |
|
| 6176 | - $upgrade_notice .= '</div> '; |
|
| 6177 | - } |
|
| 6178 | - } |
|
| 6179 | - } |
|
| 6180 | - echo $upgrade_notice; |
|
| 6159 | + // Output Upgrade Notice |
|
| 6160 | + $matches = null; |
|
| 6161 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6162 | + $upgrade_notice = ''; |
|
| 6163 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6164 | + if(empty($matches)){return;}
|
|
| 6165 | + |
|
| 6166 | + $version = trim( $matches[1] ); |
|
| 6167 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6168 | + |
|
| 6169 | + |
|
| 6170 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6171 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6172 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6173 | + foreach ( $notices as $index => $line ) {
|
|
| 6174 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6175 | + } |
|
| 6176 | + $upgrade_notice .= '</div> '; |
|
| 6177 | + } |
|
| 6178 | + } |
|
| 6179 | + } |
|
| 6180 | + echo $upgrade_notice; |
|
| 6181 | 6181 | } |
| 6182 | 6182 | |
| 6183 | 6183 | /** |
@@ -6210,19 +6210,19 @@ discard block |
||
| 6210 | 6210 | * @param array Listing statuses to be skipped. |
| 6211 | 6211 | */ |
| 6212 | 6212 | function geodir_imex_export_skip_statuses() {
|
| 6213 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6213 | + $statuses = array( 'trash', 'auto-draft' ); |
|
| 6214 | 6214 | |
| 6215 | - /** |
|
| 6216 | - * Filter the statuses to skip during GD export listings. |
|
| 6217 | - * |
|
| 6218 | - * @since 1.6.0 |
|
| 6219 | - * @package GeoDirectory |
|
| 6220 | - * |
|
| 6221 | - * @param array $statuses Listing statuses to be skipped. |
|
| 6222 | - */ |
|
| 6223 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6215 | + /** |
|
| 6216 | + * Filter the statuses to skip during GD export listings. |
|
| 6217 | + * |
|
| 6218 | + * @since 1.6.0 |
|
| 6219 | + * @package GeoDirectory |
|
| 6220 | + * |
|
| 6221 | + * @param array $statuses Listing statuses to be skipped. |
|
| 6222 | + */ |
|
| 6223 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6224 | 6224 | |
| 6225 | - return $statuses; |
|
| 6225 | + return $statuses; |
|
| 6226 | 6226 | } |
| 6227 | 6227 | |
| 6228 | 6228 | /** |
@@ -6238,42 +6238,42 @@ discard block |
||
| 6238 | 6238 | * @global string $typenow Current post type. |
| 6239 | 6239 | */ |
| 6240 | 6240 | function geodir_admin_dequeue_scripts() {
|
| 6241 | - global $typenow; |
|
| 6241 | + global $typenow; |
|
| 6242 | 6242 | |
| 6243 | - // EDD |
|
| 6244 | - if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6245 | - wp_dequeue_script('jquery-chosen');
|
|
| 6246 | - } |
|
| 6243 | + // EDD |
|
| 6244 | + if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6245 | + wp_dequeue_script('jquery-chosen');
|
|
| 6246 | + } |
|
| 6247 | 6247 | |
| 6248 | - // Ultimate Addons for Visual Composer |
|
| 6249 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6250 | - wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6251 | - } |
|
| 6248 | + // Ultimate Addons for Visual Composer |
|
| 6249 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6250 | + wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6251 | + } |
|
| 6252 | 6252 | |
| 6253 | - // VC editor conflicts |
|
| 6254 | - if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6255 | - wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6256 | - } |
|
| 6253 | + // VC editor conflicts |
|
| 6254 | + if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6255 | + wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6256 | + } |
|
| 6257 | 6257 | |
| 6258 | - // Ultimate chosen |
|
| 6259 | - if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6260 | - wp_dequeue_script('ultimate-chosen-script');
|
|
| 6261 | - } |
|
| 6258 | + // Ultimate chosen |
|
| 6259 | + if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6260 | + wp_dequeue_script('ultimate-chosen-script');
|
|
| 6261 | + } |
|
| 6262 | 6262 | |
| 6263 | - // Crum composer choosen |
|
| 6264 | - if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6265 | - wp_dequeue_script('crum-composer-choosen');
|
|
| 6266 | - } |
|
| 6263 | + // Crum composer choosen |
|
| 6264 | + if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6265 | + wp_dequeue_script('crum-composer-choosen');
|
|
| 6266 | + } |
|
| 6267 | 6267 | |
| 6268 | - // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6269 | - if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6270 | - wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6271 | - } |
|
| 6268 | + // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6269 | + if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6270 | + wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6271 | + } |
|
| 6272 | 6272 | |
| 6273 | - // Fix conflicts timepicker & setting date value. |
|
| 6274 | - if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
|
|
| 6275 | - wp_dequeue_script('acf-timepicker');
|
|
| 6276 | - } |
|
| 6273 | + // Fix conflicts timepicker & setting date value. |
|
| 6274 | + if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
|
|
| 6275 | + wp_dequeue_script('acf-timepicker');
|
|
| 6276 | + } |
|
| 6277 | 6277 | } |
| 6278 | 6278 | |
| 6279 | 6279 | /** |
@@ -6289,48 +6289,48 @@ discard block |
||
| 6289 | 6289 | * @return string SQL where clause part. |
| 6290 | 6290 | */ |
| 6291 | 6291 | function geodir_imex_get_filter_where($where = '', $post_type = '') {
|
| 6292 | - global $wpdb; |
|
| 6292 | + global $wpdb; |
|
| 6293 | 6293 | |
| 6294 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6294 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6295 | 6295 | |
| 6296 | - if ( !empty( $filters ) ) {
|
|
| 6297 | - foreach ( $filters as $field => $value ) {
|
|
| 6298 | - switch ($field) {
|
|
| 6299 | - case 'start_date': |
|
| 6300 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6301 | - break; |
|
| 6302 | - case 'end_date': |
|
| 6303 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6304 | - break; |
|
| 6305 | - } |
|
| 6306 | - } |
|
| 6307 | - } |
|
| 6296 | + if ( !empty( $filters ) ) {
|
|
| 6297 | + foreach ( $filters as $field => $value ) {
|
|
| 6298 | + switch ($field) {
|
|
| 6299 | + case 'start_date': |
|
| 6300 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6301 | + break; |
|
| 6302 | + case 'end_date': |
|
| 6303 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6304 | + break; |
|
| 6305 | + } |
|
| 6306 | + } |
|
| 6307 | + } |
|
| 6308 | 6308 | |
| 6309 | - return $where; |
|
| 6309 | + return $where; |
|
| 6310 | 6310 | } |
| 6311 | 6311 | add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
|
| 6312 | 6312 | add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
|
| 6313 | 6313 | |
| 6314 | 6314 | |
| 6315 | 6315 | function geodir_fix_for_primer_theme(){
|
| 6316 | - if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6317 | - global $pagenow; |
|
| 6316 | + if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6317 | + global $pagenow; |
|
| 6318 | 6318 | |
| 6319 | - if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6319 | + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6320 | 6320 | |
| 6321 | - $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6321 | + $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6322 | 6322 | |
| 6323 | - $post_types = geodir_get_posttypes(); |
|
| 6324 | - if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6325 | - global $primer_customizer_layouts; |
|
| 6326 | - remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6327 | - } |
|
| 6328 | - } |
|
| 6323 | + $post_types = geodir_get_posttypes(); |
|
| 6324 | + if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6325 | + global $primer_customizer_layouts; |
|
| 6326 | + remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6327 | + } |
|
| 6328 | + } |
|
| 6329 | 6329 | |
| 6330 | 6330 | } |
| 6331 | 6331 | |
| 6332 | 6332 | if(is_admin()){
|
| 6333 | - add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6333 | + add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6334 | 6334 | } |
| 6335 | 6335 | |
| 6336 | 6336 | |
@@ -6463,96 +6463,96 @@ discard block |
||
| 6463 | 6463 | |
| 6464 | 6464 | function geodir_ga_activation_url() {
|
| 6465 | 6465 | |
| 6466 | - return add_query_arg( array( |
|
| 6467 | - 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6468 | - 'scope' => GEODIR_GA_SCOPE, |
|
| 6469 | - 'response_type' => 'code', |
|
| 6470 | - 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6471 | - 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6472 | - ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6466 | + return add_query_arg( array( |
|
| 6467 | + 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6468 | + 'scope' => GEODIR_GA_SCOPE, |
|
| 6469 | + 'response_type' => 'code', |
|
| 6470 | + 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6471 | + 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6472 | + ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6473 | 6473 | |
| 6474 | - return $url; |
|
| 6474 | + return $url; |
|
| 6475 | 6475 | } |
| 6476 | 6476 | |
| 6477 | 6477 | function geodir_gd_accounts(){
|
| 6478 | - $accounts = array(); |
|
| 6479 | - $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6480 | - if($useAuth){
|
|
| 6481 | - try {
|
|
| 6482 | - $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6483 | - } catch (Exception $e) {
|
|
| 6484 | - geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6485 | - } |
|
| 6478 | + $accounts = array(); |
|
| 6479 | + $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6480 | + if($useAuth){
|
|
| 6481 | + try {
|
|
| 6482 | + $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6483 | + } catch (Exception $e) {
|
|
| 6484 | + geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6485 | + } |
|
| 6486 | 6486 | |
| 6487 | - if(is_array($accounts)){
|
|
| 6488 | - $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6489 | - }elseif(get_option('geodir_ga_account_id')){
|
|
| 6490 | - $accounts = array(); |
|
| 6491 | - $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6492 | - } |
|
| 6493 | - } |
|
| 6494 | - return $accounts; |
|
| 6487 | + if(is_array($accounts)){
|
|
| 6488 | + $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6489 | + }elseif(get_option('geodir_ga_account_id')){
|
|
| 6490 | + $accounts = array(); |
|
| 6491 | + $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6492 | + } |
|
| 6493 | + } |
|
| 6494 | + return $accounts; |
|
| 6495 | 6495 | } |
| 6496 | 6496 | |
| 6497 | 6497 | function geodir_ga_get_analytics_accounts() |
| 6498 | 6498 | {
|
| 6499 | - global $gd_ga_errors; |
|
| 6500 | - $accounts = array(); |
|
| 6499 | + global $gd_ga_errors; |
|
| 6500 | + $accounts = array(); |
|
| 6501 | 6501 | |
| 6502 | - if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6502 | + if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6503 | 6503 | |
| 6504 | 6504 | |
| 6505 | - if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6506 | - return get_option('geodir_gd_uids');
|
|
| 6507 | - } |
|
| 6505 | + if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6506 | + return get_option('geodir_gd_uids');
|
|
| 6507 | + } |
|
| 6508 | 6508 | |
| 6509 | - # Create a new Gdata call |
|
| 6510 | - if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6511 | - $stats = new GDGoogleAnalyticsStats(); |
|
| 6512 | - else |
|
| 6513 | - return false; |
|
| 6509 | + # Create a new Gdata call |
|
| 6510 | + if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6511 | + $stats = new GDGoogleAnalyticsStats(); |
|
| 6512 | + else |
|
| 6513 | + return false; |
|
| 6514 | 6514 | |
| 6515 | - # Check if Google sucessfully logged in |
|
| 6516 | - if ( ! $stats->checkLogin() ) |
|
| 6517 | - return false; |
|
| 6515 | + # Check if Google sucessfully logged in |
|
| 6516 | + if ( ! $stats->checkLogin() ) |
|
| 6517 | + return false; |
|
| 6518 | 6518 | |
| 6519 | - # Get a list of accounts |
|
| 6520 | - try {
|
|
| 6521 | - $accounts = $stats->getAllProfiles(); |
|
| 6522 | - } catch (Exception $e) {
|
|
| 6523 | - $gd_ga_errors[] = $e->getMessage(); |
|
| 6524 | - return false; |
|
| 6525 | - } |
|
| 6519 | + # Get a list of accounts |
|
| 6520 | + try {
|
|
| 6521 | + $accounts = $stats->getAllProfiles(); |
|
| 6522 | + } catch (Exception $e) {
|
|
| 6523 | + $gd_ga_errors[] = $e->getMessage(); |
|
| 6524 | + return false; |
|
| 6525 | + } |
|
| 6526 | 6526 | |
| 6527 | 6527 | |
| 6528 | - natcasesort ($accounts); |
|
| 6528 | + natcasesort ($accounts); |
|
| 6529 | 6529 | |
| 6530 | - # Return the account array if there are accounts |
|
| 6531 | - if ( count($accounts) > 0 ){
|
|
| 6532 | - update_option('geodir_gd_uids',$accounts);
|
|
| 6533 | - return $accounts; |
|
| 6534 | - } |
|
| 6535 | - else |
|
| 6536 | - return false; |
|
| 6530 | + # Return the account array if there are accounts |
|
| 6531 | + if ( count($accounts) > 0 ){
|
|
| 6532 | + update_option('geodir_gd_uids',$accounts);
|
|
| 6533 | + return $accounts; |
|
| 6534 | + } |
|
| 6535 | + else |
|
| 6536 | + return false; |
|
| 6537 | 6537 | } |
| 6538 | 6538 | |
| 6539 | 6539 | add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' ); |
| 6540 | 6540 | function geodir_ga_deauthorize(){
|
| 6541 | 6541 | |
| 6542 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6542 | + if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6543 | 6543 | |
| 6544 | - die( 'Security check' ); |
|
| 6544 | + die( 'Security check' ); |
|
| 6545 | 6545 | |
| 6546 | - } else {
|
|
| 6547 | - update_option('geodir_ga_auth_token','');
|
|
| 6548 | - update_option('geodir_ga_auth_code','');
|
|
| 6549 | - update_option('geodir_gd_uids','');
|
|
| 6546 | + } else {
|
|
| 6547 | + update_option('geodir_ga_auth_token','');
|
|
| 6548 | + update_option('geodir_ga_auth_code','');
|
|
| 6549 | + update_option('geodir_gd_uids','');
|
|
| 6550 | 6550 | |
| 6551 | 6551 | |
| 6552 | - echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6553 | - } |
|
| 6552 | + echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6553 | + } |
|
| 6554 | 6554 | |
| 6555 | - die(); |
|
| 6555 | + die(); |
|
| 6556 | 6556 | } |
| 6557 | 6557 | |
| 6558 | 6558 | |
@@ -6563,12 +6563,12 @@ discard block |
||
| 6563 | 6563 | * @package GeoDirectory |
| 6564 | 6564 | */ |
| 6565 | 6565 | function geodir_post_type_setting_fun() {
|
| 6566 | - $post_type_arr = array(); |
|
| 6566 | + $post_type_arr = array(); |
|
| 6567 | 6567 | |
| 6568 | - $post_types = geodir_get_posttypes('object');
|
|
| 6568 | + $post_types = geodir_get_posttypes('object');
|
|
| 6569 | 6569 | |
| 6570 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 6571 | - $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
| 6572 | - } |
|
| 6573 | - return $post_type_arr; |
|
| 6570 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 6571 | + $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
| 6572 | + } |
|
| 6573 | + return $post_type_arr; |
|
| 6574 | 6574 | } |
| 6575 | 6575 | \ No newline at end of file |