@@ -13,29 +13,29 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function geodir_register_taxonomies() |
| 15 | 15 | {
|
| 16 | - $taxonomies = array(); |
|
| 17 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 18 | - // If custom taxonomies are present, register them |
|
| 19 | - if (is_array($taxonomies)) {
|
|
| 20 | - // Sort taxonomies |
|
| 21 | - ksort($taxonomies); |
|
| 22 | - |
|
| 23 | - // Register taxonomies |
|
| 24 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 25 | - // Allow taxonomy names to be translated |
|
| 26 | - if (!empty($args['args']['labels'])) {
|
|
| 27 | - foreach ($args['args']['labels'] as $key => $tax_label) {
|
|
| 28 | - $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); |
|
| 33 | - |
|
| 34 | - if (taxonomy_exists($taxonomy)) {
|
|
| 35 | - $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - } |
|
| 16 | + $taxonomies = array(); |
|
| 17 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 18 | + // If custom taxonomies are present, register them |
|
| 19 | + if (is_array($taxonomies)) {
|
|
| 20 | + // Sort taxonomies |
|
| 21 | + ksort($taxonomies); |
|
| 22 | + |
|
| 23 | + // Register taxonomies |
|
| 24 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 25 | + // Allow taxonomy names to be translated |
|
| 26 | + if (!empty($args['args']['labels'])) {
|
|
| 27 | + foreach ($args['args']['labels'] as $key => $tax_label) {
|
|
| 28 | + $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); |
|
| 33 | + |
|
| 34 | + if (taxonomy_exists($taxonomy)) {
|
|
| 35 | + $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -46,45 +46,45 @@ discard block |
||
| 46 | 46 | * @global array $wp_post_types List of post types. |
| 47 | 47 | */ |
| 48 | 48 | function geodir_register_post_types() {
|
| 49 | - global $wp_post_types; |
|
| 49 | + global $wp_post_types; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Get available custom posttypes and taxonomies and register them. |
|
| 53 | - */ |
|
| 54 | - _x('places', 'URL slug', 'geodirectory');
|
|
| 55 | - |
|
| 56 | - $post_types = array(); |
|
| 57 | - $post_types = get_option('geodir_post_types');
|
|
| 58 | - |
|
| 59 | - // Register each post type if array of data is returned |
|
| 60 | - if (is_array($post_types)): |
|
| 61 | - |
|
| 62 | - foreach ($post_types as $post_type => $args): |
|
| 63 | - |
|
| 64 | - if (!empty($args['rewrite']['slug'])) {
|
|
| 65 | - $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); |
|
| 66 | - } |
|
| 67 | - $args = stripslashes_deep($args); |
|
| 68 | - |
|
| 69 | - if (!empty($args['labels'])) {
|
|
| 70 | - foreach ($args['labels'] as $key => $val) {
|
|
| 71 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Filter post type args. |
|
| 77 | - * |
|
| 78 | - * @since 1.0.0 |
|
| 79 | - * @param string $args Post type args. |
|
| 80 | - * @param string $post_type The post type. |
|
| 81 | - */ |
|
| 82 | - $args = apply_filters('geodir_post_type_args', $args, $post_type);
|
|
| 83 | - |
|
| 84 | - $post_type = register_post_type($post_type, $args); |
|
| 85 | - |
|
| 86 | - endforeach; |
|
| 87 | - endif; |
|
| 51 | + /** |
|
| 52 | + * Get available custom posttypes and taxonomies and register them. |
|
| 53 | + */ |
|
| 54 | + _x('places', 'URL slug', 'geodirectory');
|
|
| 55 | + |
|
| 56 | + $post_types = array(); |
|
| 57 | + $post_types = get_option('geodir_post_types');
|
|
| 58 | + |
|
| 59 | + // Register each post type if array of data is returned |
|
| 60 | + if (is_array($post_types)): |
|
| 61 | + |
|
| 62 | + foreach ($post_types as $post_type => $args): |
|
| 63 | + |
|
| 64 | + if (!empty($args['rewrite']['slug'])) {
|
|
| 65 | + $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); |
|
| 66 | + } |
|
| 67 | + $args = stripslashes_deep($args); |
|
| 68 | + |
|
| 69 | + if (!empty($args['labels'])) {
|
|
| 70 | + foreach ($args['labels'] as $key => $val) {
|
|
| 71 | + $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Filter post type args. |
|
| 77 | + * |
|
| 78 | + * @since 1.0.0 |
|
| 79 | + * @param string $args Post type args. |
|
| 80 | + * @param string $post_type The post type. |
|
| 81 | + */ |
|
| 82 | + $args = apply_filters('geodir_post_type_args', $args, $post_type);
|
|
| 83 | + |
|
| 84 | + $post_type = register_post_type($post_type, $args); |
|
| 85 | + |
|
| 86 | + endforeach; |
|
| 87 | + endif; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -98,72 +98,72 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | function geodir_post_type_args_modify($args, $post_type) |
| 100 | 100 | {
|
| 101 | - $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
|
|
| 101 | + $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
|
|
| 102 | 102 | if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
|
| 103 | 103 | |
| 104 | - $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
|
| 104 | + $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
|
| 105 | 105 | |
| 106 | - if ($post_type == 'gd_place') {
|
|
| 107 | - if (array_key_exists('has_archive', $args))
|
|
| 108 | - $args['has_archive'] = $listing_slug; |
|
| 106 | + if ($post_type == 'gd_place') {
|
|
| 107 | + if (array_key_exists('has_archive', $args))
|
|
| 108 | + $args['has_archive'] = $listing_slug; |
|
| 109 | 109 | |
| 110 | - if (array_key_exists('rewrite', $args)) {
|
|
| 111 | - if (array_key_exists('slug', $args['rewrite']))
|
|
| 112 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 113 | - } |
|
| 110 | + if (array_key_exists('rewrite', $args)) {
|
|
| 111 | + if (array_key_exists('slug', $args['rewrite']))
|
|
| 112 | + $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 115 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 116 | 116 | |
| 117 | - if (array_key_exists($post_type, $geodir_post_types)) {
|
|
| 117 | + if (array_key_exists($post_type, $geodir_post_types)) {
|
|
| 118 | 118 | |
| 119 | - if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
|
|
| 120 | - $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 119 | + if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
|
|
| 120 | + $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 121 | 121 | |
| 122 | - if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
|
| 123 | - if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 124 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 122 | + if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
|
| 123 | + if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 124 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 125 | 125 | |
| 126 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 126 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 127 | 127 | |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 130 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 131 | 131 | |
| 132 | - /* --- update taxonomies (category) --- */ |
|
| 132 | + /* --- update taxonomies (category) --- */ |
|
| 133 | 133 | |
| 134 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 134 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 135 | 135 | |
| 136 | - if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
|
| 137 | - $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
|
| 136 | + if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
|
| 137 | + $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
|
| 138 | 138 | |
| 139 | - if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 140 | - if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 141 | - if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
|
| 142 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 139 | + if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 140 | + if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 141 | + if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
|
| 142 | + $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 143 | 143 | |
| 144 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 144 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 145 | 145 | |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /* --- update taxonomies (tags) --- */ |
|
| 149 | - $geodir_taxonomies_tag = get_option('geodir_taxonomies');
|
|
| 150 | - if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
|
| 151 | - $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
|
| 148 | + /* --- update taxonomies (tags) --- */ |
|
| 149 | + $geodir_taxonomies_tag = get_option('geodir_taxonomies');
|
|
| 150 | + if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
|
| 151 | + $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
|
| 152 | 152 | |
| 153 | - if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 154 | - if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 155 | - if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
|
| 156 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 153 | + if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 154 | + if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 155 | + if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
|
| 156 | + $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 157 | 157 | |
| 158 | - update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
|
| 158 | + update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
|
| 159 | 159 | |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - return $args; |
|
| 166 | + return $args; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | function geodir_flush_rewrite_rules() |
| 178 | 178 | {
|
| 179 | - global $wp_rewrite; |
|
| 180 | - $wp_rewrite->flush_rules(false); |
|
| 179 | + global $wp_rewrite; |
|
| 180 | + $wp_rewrite->flush_rules(false); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -192,35 +192,35 @@ discard block |
||
| 192 | 192 | * @return array Rewrite rules. |
| 193 | 193 | */ |
| 194 | 194 | function geodir_listing_rewrite_rules($rules) {
|
| 195 | - $newrules = array(); |
|
| 196 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 197 | - $detail_url_seprator = get_option('geodir_detailurl_separator');
|
|
| 195 | + $newrules = array(); |
|
| 196 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 197 | + $detail_url_seprator = get_option('geodir_detailurl_separator');
|
|
| 198 | 198 | |
| 199 | 199 | // create rules for post listing |
| 200 | - if (is_array($taxonomies)): |
|
| 201 | - foreach ($taxonomies as $taxonomy => $args): |
|
| 202 | - $post_type = $args['object_type']; |
|
| 203 | - $listing_slug = $args['listing_slug']; |
|
| 204 | - |
|
| 205 | - if (strpos($taxonomy, 'tags')) {
|
|
| 206 | - $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
|
|
| 207 | - $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
|
| 208 | - } else {
|
|
| 209 | - // use this loop to add paging for details page comments paging |
|
| 210 | - $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 211 | - } |
|
| 212 | - endforeach; |
|
| 213 | - endif; |
|
| 214 | - |
|
| 215 | - // create rules for location listing |
|
| 216 | - $location_page = get_option('geodir_location_page');
|
|
| 200 | + if (is_array($taxonomies)): |
|
| 201 | + foreach ($taxonomies as $taxonomy => $args): |
|
| 202 | + $post_type = $args['object_type']; |
|
| 203 | + $listing_slug = $args['listing_slug']; |
|
| 204 | + |
|
| 205 | + if (strpos($taxonomy, 'tags')) {
|
|
| 206 | + $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
|
|
| 207 | + $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
|
| 208 | + } else {
|
|
| 209 | + // use this loop to add paging for details page comments paging |
|
| 210 | + $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 211 | + } |
|
| 212 | + endforeach; |
|
| 213 | + endif; |
|
| 214 | + |
|
| 215 | + // create rules for location listing |
|
| 216 | + $location_page = get_option('geodir_location_page');
|
|
| 217 | 217 | |
| 218 | - if($location_page) {
|
|
| 219 | - global $wpdb; |
|
| 220 | - $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
|
| 221 | - } |
|
| 222 | - if (!isset($location_prefix)) |
|
| 223 | - $location_prefix = 'location'; |
|
| 218 | + if($location_page) {
|
|
| 219 | + global $wpdb; |
|
| 220 | + $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
|
| 221 | + } |
|
| 222 | + if (!isset($location_prefix)) |
|
| 223 | + $location_prefix = 'location'; |
|
| 224 | 224 | |
| 225 | 225 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 226 | 226 | if ($location_manager) {
|
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ($location_page && geodir_is_wpml()) {
|
|
| 268 | - foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 269 | - $alt_page_id = ''; |
|
| 270 | - $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 271 | - if($alt_page_id){
|
|
| 272 | - $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
|
| 267 | + if ($location_page && geodir_is_wpml()) {
|
|
| 268 | + foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 269 | + $alt_page_id = ''; |
|
| 270 | + $alt_page_id = geodir_wpml_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 271 | + if($alt_page_id){
|
|
| 272 | + $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
|
| 273 | 273 | |
| 274 | 274 | if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
| 275 | 275 | $matches2 = ''; |
@@ -305,14 +305,14 @@ discard block |
||
| 305 | 305 | $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
| 306 | 306 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; |
| 307 | 307 | } |
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; |
|
| 312 | + $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; |
|
| 313 | 313 | |
| 314 | - $rules = array_merge($newrules, $rules); |
|
| 315 | - return $rules; |
|
| 314 | + $rules = array_merge($newrules, $rules); |
|
| 315 | + return $rules; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -327,18 +327,18 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | function geodir_htaccess_contents($rules) |
| 329 | 329 | {
|
| 330 | - global $wpdb; |
|
| 331 | - $location_prefix = get_option('geodir_location_prefix');
|
|
| 332 | - // if location page slug changed then add redirect |
|
| 333 | - if ($location_prefix == 'location') {
|
|
| 334 | - return $rules; |
|
| 335 | - } |
|
| 336 | - $my_content = <<<EOD |
|
| 330 | + global $wpdb; |
|
| 331 | + $location_prefix = get_option('geodir_location_prefix');
|
|
| 332 | + // if location page slug changed then add redirect |
|
| 333 | + if ($location_prefix == 'location') {
|
|
| 334 | + return $rules; |
|
| 335 | + } |
|
| 336 | + $my_content = <<<EOD |
|
| 337 | 337 | \n# BEGIN GeoDirectory Rules |
| 338 | 338 | #Redirect 301 /location/ /$location_prefix/ |
| 339 | 339 | # END GeoDirectory Rules\n\n |
| 340 | 340 | EOD; |
| 341 | - return $my_content . $rules; |
|
| 341 | + return $my_content . $rules; |
|
| 342 | 342 | } |
| 343 | 343 | //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
|
| 344 | 344 | |
@@ -352,10 +352,10 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | function geodir_add_location_var($public_query_vars) |
| 354 | 354 | {
|
| 355 | - $public_query_vars[] = 'gd_country'; |
|
| 356 | - $public_query_vars[] = 'gd_region'; |
|
| 357 | - $public_query_vars[] = 'gd_city'; |
|
| 358 | - return $public_query_vars; |
|
| 355 | + $public_query_vars[] = 'gd_country'; |
|
| 356 | + $public_query_vars[] = 'gd_region'; |
|
| 357 | + $public_query_vars[] = 'gd_city'; |
|
| 358 | + return $public_query_vars; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | function geodir_add_geodir_page_var($public_query_vars) |
| 370 | 370 | {
|
| 371 | - $public_query_vars[] = 'gd_is_geodir_page'; |
|
| 372 | - return $public_query_vars; |
|
| 371 | + $public_query_vars[] = 'gd_is_geodir_page'; |
|
| 372 | + return $public_query_vars; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -381,20 +381,20 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | function geodir_add_page_id_in_query_var() |
| 383 | 383 | {
|
| 384 | - global $wp_query; |
|
| 384 | + global $wp_query; |
|
| 385 | 385 | |
| 386 | - $page_id = $wp_query->get_queried_object_id(); |
|
| 386 | + $page_id = $wp_query->get_queried_object_id(); |
|
| 387 | 387 | |
| 388 | - if (!get_query_var('page_id') && !is_archive()) {
|
|
| 389 | - // fix for WP tags conflict with enfold theme |
|
| 390 | - $theme_name = geodir_strtolower(wp_get_theme()); |
|
| 391 | - if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
|
|
| 392 | - return $wp_query; |
|
| 393 | - } |
|
| 394 | - $wp_query->set('page_id', $page_id);
|
|
| 395 | - } |
|
| 388 | + if (!get_query_var('page_id') && !is_archive()) {
|
|
| 389 | + // fix for WP tags conflict with enfold theme |
|
| 390 | + $theme_name = geodir_strtolower(wp_get_theme()); |
|
| 391 | + if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
|
|
| 392 | + return $wp_query; |
|
| 393 | + } |
|
| 394 | + $wp_query->set('page_id', $page_id);
|
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - return $wp_query; |
|
| 397 | + return $wp_query; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -409,23 +409,23 @@ discard block |
||
| 409 | 409 | function geodir_set_location_var_in_session_in_core($wp) {
|
| 410 | 410 | global $gd_session; |
| 411 | 411 | |
| 412 | - // Fix for WPML removing page_id query var: |
|
| 413 | - if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
|
|
| 414 | - global $wpdb; |
|
| 412 | + // Fix for WPML removing page_id query var: |
|
| 413 | + if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
|
|
| 414 | + global $wpdb; |
|
| 415 | 415 | |
| 416 | - $page_for_posts = get_option('page_for_posts');
|
|
| 417 | - $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 416 | + $page_for_posts = get_option('page_for_posts');
|
|
| 417 | + $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 418 | 418 | |
| 419 | - if (geodir_is_wpml()) {
|
|
| 420 | - $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
|
| 421 | - } |
|
| 422 | - if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 423 | - $wp->query_vars['page_id'] = $real_page_id; |
|
| 424 | - } |
|
| 425 | - } |
|
| 419 | + if (geodir_is_wpml()) {
|
|
| 420 | + $real_page_id = geodir_wpml_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
|
| 421 | + } |
|
| 422 | + if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 423 | + $wp->query_vars['page_id'] = $real_page_id; |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | 426 | // Query Vars will have page_id parameter |
| 427 | 427 | // check if query var has page_id and that page id is location page |
| 428 | - geodir_set_is_geodir_page($wp); |
|
| 428 | + geodir_set_is_geodir_page($wp); |
|
| 429 | 429 | // if is GD homepage set the page ID |
| 430 | 430 | if (geodir_is_page('home')) {
|
| 431 | 431 | $wp->query_vars['page_id'] = get_option('page_on_front');
|
@@ -434,118 +434,118 @@ discard block |
||
| 434 | 434 | // The location url format (all or country_city or region_city or city). |
| 435 | 435 | $geodir_show_location_url = get_option('geodir_show_location_url');
|
| 436 | 436 | |
| 437 | - if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
|
|
| 438 | - $gd_country = ''; |
|
| 439 | - $gd_region = ''; |
|
| 440 | - $gd_city = ''; |
|
| 441 | - if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') |
|
| 442 | - $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 443 | - |
|
| 444 | - if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') |
|
| 445 | - $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 446 | - |
|
| 447 | - if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') |
|
| 448 | - $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 449 | - |
|
| 450 | - if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
|
|
| 451 | - $default_location = geodir_get_default_location(); |
|
| 452 | - |
|
| 453 | - if (get_option('geodir_add_location_url')) {
|
|
| 454 | - if ($geodir_show_location_url != 'all') {
|
|
| 455 | - if ($gd_region == '') {
|
|
| 456 | - if ($gd_ses_region = $gd_session->get('gd_region'))
|
|
| 457 | - $gd_region = $gd_ses_region; |
|
| 458 | - else |
|
| 459 | - $gd_region = $default_location->region_slug; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - if ($gd_city == '') {
|
|
| 463 | - if ($gd_ses_city = $gd_session->get('gd_city'))
|
|
| 464 | - $gd_city = $gd_ses_city; |
|
| 465 | - else |
|
| 466 | - $gd_city = $default_location->city_slug; |
|
| 467 | - |
|
| 468 | - $base_location_link = geodir_get_location_link('base');
|
|
| 469 | - wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
|
| 470 | - exit(); |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - $args = array( |
|
| 476 | - 'what' => 'city', |
|
| 477 | - 'city_val' => $gd_city, |
|
| 478 | - 'region_val' => $gd_region, |
|
| 479 | - 'country_val' => $gd_country, |
|
| 480 | - 'country_column_name' => 'country_slug', |
|
| 481 | - 'region_column_name' => 'region_slug', |
|
| 482 | - 'city_column_name' => 'city_slug', |
|
| 483 | - 'location_link_part' => false, |
|
| 484 | - 'compare_operator' => '' |
|
| 485 | - ); |
|
| 486 | - |
|
| 487 | - $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
|
|
| 488 | - if (!empty($location_array)) {
|
|
| 489 | - $gd_session->set('gd_multi_location', 1);
|
|
| 490 | - $gd_session->set('gd_country', $gd_country);
|
|
| 491 | - $gd_session->set('gd_region', $gd_region);
|
|
| 492 | - $gd_session->set('gd_city', $gd_city);
|
|
| 437 | + if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
|
|
| 438 | + $gd_country = ''; |
|
| 439 | + $gd_region = ''; |
|
| 440 | + $gd_city = ''; |
|
| 441 | + if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') |
|
| 442 | + $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 443 | + |
|
| 444 | + if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') |
|
| 445 | + $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 446 | + |
|
| 447 | + if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') |
|
| 448 | + $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 449 | + |
|
| 450 | + if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
|
|
| 451 | + $default_location = geodir_get_default_location(); |
|
| 452 | + |
|
| 453 | + if (get_option('geodir_add_location_url')) {
|
|
| 454 | + if ($geodir_show_location_url != 'all') {
|
|
| 455 | + if ($gd_region == '') {
|
|
| 456 | + if ($gd_ses_region = $gd_session->get('gd_region'))
|
|
| 457 | + $gd_region = $gd_ses_region; |
|
| 458 | + else |
|
| 459 | + $gd_region = $default_location->region_slug; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + if ($gd_city == '') {
|
|
| 463 | + if ($gd_ses_city = $gd_session->get('gd_city'))
|
|
| 464 | + $gd_city = $gd_ses_city; |
|
| 465 | + else |
|
| 466 | + $gd_city = $default_location->city_slug; |
|
| 467 | + |
|
| 468 | + $base_location_link = geodir_get_location_link('base');
|
|
| 469 | + wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
|
| 470 | + exit(); |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + $args = array( |
|
| 476 | + 'what' => 'city', |
|
| 477 | + 'city_val' => $gd_city, |
|
| 478 | + 'region_val' => $gd_region, |
|
| 479 | + 'country_val' => $gd_country, |
|
| 480 | + 'country_column_name' => 'country_slug', |
|
| 481 | + 'region_column_name' => 'region_slug', |
|
| 482 | + 'city_column_name' => 'city_slug', |
|
| 483 | + 'location_link_part' => false, |
|
| 484 | + 'compare_operator' => '' |
|
| 485 | + ); |
|
| 486 | + |
|
| 487 | + $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
|
|
| 488 | + if (!empty($location_array)) {
|
|
| 489 | + $gd_session->set('gd_multi_location', 1);
|
|
| 490 | + $gd_session->set('gd_country', $gd_country);
|
|
| 491 | + $gd_session->set('gd_region', $gd_region);
|
|
| 492 | + $gd_session->set('gd_city', $gd_city);
|
|
| 493 | 493 | |
| 494 | 494 | $wp->query_vars['gd_country'] = $gd_country; |
| 495 | - $wp->query_vars['gd_region'] = $gd_region; |
|
| 496 | - $wp->query_vars['gd_city'] = $gd_city; |
|
| 497 | - } else {
|
|
| 498 | - $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 499 | - } |
|
| 500 | - } else {
|
|
| 501 | - $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 505 | - if (!is_admin()) {
|
|
| 506 | - $requested_post_type = $wp->query_vars['post_type']; |
|
| 507 | - // check if this post type is geodirectory post types |
|
| 508 | - $post_type_array = geodir_get_posttypes(); |
|
| 495 | + $wp->query_vars['gd_region'] = $gd_region; |
|
| 496 | + $wp->query_vars['gd_city'] = $gd_city; |
|
| 497 | + } else {
|
|
| 498 | + $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 499 | + } |
|
| 500 | + } else {
|
|
| 501 | + $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 505 | + if (!is_admin()) {
|
|
| 506 | + $requested_post_type = $wp->query_vars['post_type']; |
|
| 507 | + // check if this post type is geodirectory post types |
|
| 508 | + $post_type_array = geodir_get_posttypes(); |
|
| 509 | 509 | |
| 510 | 510 | if (in_array($requested_post_type, $post_type_array)) {
|
| 511 | - // now u can apply geodirectory related manipulation. |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - } else {
|
|
| 515 | - // check if a geodirectory taxonomy is set |
|
| 516 | - $gd_country = ''; |
|
| 517 | - $gd_region = ''; |
|
| 518 | - $gd_city = ''; |
|
| 511 | + // now u can apply geodirectory related manipulation. |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + } else {
|
|
| 515 | + // check if a geodirectory taxonomy is set |
|
| 516 | + $gd_country = ''; |
|
| 517 | + $gd_region = ''; |
|
| 518 | + $gd_city = ''; |
|
| 519 | 519 | |
| 520 | 520 | $is_geodir_taxonomy = false; |
| 521 | - $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not |
|
| 522 | - $is_geodir_location_found = false; |
|
| 521 | + $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not |
|
| 522 | + $is_geodir_location_found = false; |
|
| 523 | 523 | |
| 524 | 524 | $geodir_taxonomy = ''; |
| 525 | - $geodir_post_type = ''; |
|
| 526 | - $geodir_term = ''; |
|
| 527 | - $geodir_set_location_session = true; |
|
| 528 | - $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 529 | - |
|
| 530 | - if(!empty($geodir_taxonomis)){
|
|
| 531 | - foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 532 | - if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 533 | - $is_geodir_taxonomy = true; |
|
| 534 | - $geodir_taxonomy = $taxonomy; |
|
| 535 | - $geodir_post_type = str_replace('category', '', $taxonomy);
|
|
| 536 | - $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
|
|
| 537 | - $geodir_term = $wp->query_vars[$geodir_taxonomy]; |
|
| 538 | - break; |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - // now get an array of all terms seperated by '/' |
|
| 544 | - $geodir_terms = explode('/', $geodir_term);
|
|
| 545 | - $geodir_last_term = end($geodir_terms); |
|
| 546 | - |
|
| 547 | - if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
|
|
| 548 | - $wp->query_vars['post_type'] = $geodir_post_type; |
|
| 525 | + $geodir_post_type = ''; |
|
| 526 | + $geodir_term = ''; |
|
| 527 | + $geodir_set_location_session = true; |
|
| 528 | + $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 529 | + |
|
| 530 | + if(!empty($geodir_taxonomis)){
|
|
| 531 | + foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 532 | + if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 533 | + $is_geodir_taxonomy = true; |
|
| 534 | + $geodir_taxonomy = $taxonomy; |
|
| 535 | + $geodir_post_type = str_replace('category', '', $taxonomy);
|
|
| 536 | + $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
|
|
| 537 | + $geodir_term = $wp->query_vars[$geodir_taxonomy]; |
|
| 538 | + break; |
|
| 539 | + } |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + // now get an array of all terms seperated by '/' |
|
| 544 | + $geodir_terms = explode('/', $geodir_term);
|
|
| 545 | + $geodir_last_term = end($geodir_terms); |
|
| 546 | + |
|
| 547 | + if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
|
|
| 548 | + $wp->query_vars['post_type'] = $geodir_post_type; |
|
| 549 | 549 | |
| 550 | 550 | // now check if last term is a post of geodirectory post types |
| 551 | 551 | $geodir_post = get_posts(array( |
@@ -594,196 +594,196 @@ discard block |
||
| 594 | 594 | //return ; |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - $geodir_location_terms = ''; |
|
| 598 | - // if last term is not a post then check if last term is a term of the specific texonomy or not |
|
| 599 | - if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
|
|
| 600 | - $is_geodir_taxonomy_term = true; |
|
| 597 | + $geodir_location_terms = ''; |
|
| 598 | + // if last term is not a post then check if last term is a term of the specific texonomy or not |
|
| 599 | + if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
|
|
| 600 | + $is_geodir_taxonomy_term = true; |
|
| 601 | 601 | |
| 602 | - $geodir_set_location_session = false; |
|
| 603 | - } |
|
| 602 | + $geodir_set_location_session = false; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | 605 | |
| 606 | - // now check if there is location parts in the url or not |
|
| 607 | - if (get_option('geodir_add_location_url')) {
|
|
| 606 | + // now check if there is location parts in the url or not |
|
| 607 | + if (get_option('geodir_add_location_url')) {
|
|
| 608 | 608 | $default_location = geodir_get_default_location(); |
| 609 | 609 | |
| 610 | 610 | if ($geodir_show_location_url == 'all') {
|
| 611 | - if (count($geodir_terms) >= 3) {
|
|
| 612 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 613 | - $gd_region = urldecode($geodir_terms[1]); |
|
| 614 | - $gd_city = urldecode($geodir_terms[2]); |
|
| 615 | - } else if (count($geodir_terms) >= 2) {
|
|
| 616 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 617 | - $gd_region = urldecode($geodir_terms[1]); |
|
| 618 | - } else if (count($geodir_terms) >= 1) {
|
|
| 619 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 623 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && |
|
| 624 | - geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) |
|
| 625 | - ) |
|
| 626 | - $is_geodir_location_found = true; |
|
| 627 | - |
|
| 628 | - // if location has not been found for country , region and city then search for country and region only |
|
| 629 | - |
|
| 630 | - if (!$is_geodir_location_found) {
|
|
| 631 | - $gd_city = ''; |
|
| 632 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 633 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) |
|
| 634 | - ) |
|
| 635 | - $is_geodir_location_found = true; |
|
| 636 | - |
|
| 637 | - } |
|
| 638 | - |
|
| 639 | - // if location has not been found for country , region then search for country only |
|
| 640 | - if (!$is_geodir_location_found) {
|
|
| 641 | - $gd_city = ''; |
|
| 642 | - $gd_region = ''; |
|
| 643 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 644 | - $is_geodir_location_found = true; |
|
| 645 | - } |
|
| 646 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 647 | - if (count($geodir_terms) >= 2) {
|
|
| 648 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 649 | - $gd_city = urldecode($geodir_terms[1]); |
|
| 650 | - } else if (count($geodir_terms) >= 1) {
|
|
| 651 | - $gd_country = urldecode($geodir_terms[0]); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 655 | - $is_geodir_location_found = true; |
|
| 656 | - |
|
| 657 | - // if location has not been found for country and city then search for country only |
|
| 658 | - if (!$is_geodir_location_found) {
|
|
| 659 | - $gd_city = ''; |
|
| 611 | + if (count($geodir_terms) >= 3) {
|
|
| 612 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 613 | + $gd_region = urldecode($geodir_terms[1]); |
|
| 614 | + $gd_city = urldecode($geodir_terms[2]); |
|
| 615 | + } else if (count($geodir_terms) >= 2) {
|
|
| 616 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 617 | + $gd_region = urldecode($geodir_terms[1]); |
|
| 618 | + } else if (count($geodir_terms) >= 1) {
|
|
| 619 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 623 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && |
|
| 624 | + geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) |
|
| 625 | + ) |
|
| 626 | + $is_geodir_location_found = true; |
|
| 627 | + |
|
| 628 | + // if location has not been found for country , region and city then search for country and region only |
|
| 629 | + |
|
| 630 | + if (!$is_geodir_location_found) {
|
|
| 631 | + $gd_city = ''; |
|
| 632 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
|
| 633 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) |
|
| 634 | + ) |
|
| 635 | + $is_geodir_location_found = true; |
|
| 636 | + |
|
| 637 | + } |
|
| 638 | + |
|
| 639 | + // if location has not been found for country , region then search for country only |
|
| 640 | + if (!$is_geodir_location_found) {
|
|
| 641 | + $gd_city = ''; |
|
| 642 | + $gd_region = ''; |
|
| 643 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 644 | + $is_geodir_location_found = true; |
|
| 645 | + } |
|
| 646 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 647 | + if (count($geodir_terms) >= 2) {
|
|
| 648 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 649 | + $gd_city = urldecode($geodir_terms[1]); |
|
| 650 | + } else if (count($geodir_terms) >= 1) {
|
|
| 651 | + $gd_country = urldecode($geodir_terms[0]); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 655 | + $is_geodir_location_found = true; |
|
| 656 | + |
|
| 657 | + // if location has not been found for country and city then search for country only |
|
| 658 | + if (!$is_geodir_location_found) {
|
|
| 659 | + $gd_city = ''; |
|
| 660 | 660 | |
| 661 | 661 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
| 662 | - $is_geodir_location_found = true; |
|
| 663 | - } |
|
| 664 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 665 | - if (count($geodir_terms) >= 2) {
|
|
| 666 | - $gd_region = urldecode($geodir_terms[0]); |
|
| 667 | - $gd_city = urldecode($geodir_terms[1]); |
|
| 668 | - } else if (count($geodir_terms) >= 1) {
|
|
| 669 | - $gd_region = urldecode($geodir_terms[0]); |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 673 | - $is_geodir_location_found = true; |
|
| 674 | - |
|
| 675 | - // if location has not been found for region and city then search for region only |
|
| 676 | - if (!$is_geodir_location_found) {
|
|
| 677 | - $gd_city = ''; |
|
| 662 | + $is_geodir_location_found = true; |
|
| 663 | + } |
|
| 664 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 665 | + if (count($geodir_terms) >= 2) {
|
|
| 666 | + $gd_region = urldecode($geodir_terms[0]); |
|
| 667 | + $gd_city = urldecode($geodir_terms[1]); |
|
| 668 | + } else if (count($geodir_terms) >= 1) {
|
|
| 669 | + $gd_region = urldecode($geodir_terms[0]); |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 673 | + $is_geodir_location_found = true; |
|
| 674 | + |
|
| 675 | + // if location has not been found for region and city then search for region only |
|
| 676 | + if (!$is_geodir_location_found) {
|
|
| 677 | + $gd_city = ''; |
|
| 678 | 678 | |
| 679 | 679 | if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) |
| 680 | - $is_geodir_location_found = true; |
|
| 681 | - } |
|
| 682 | - } else {
|
|
| 683 | - $gd_city = $geodir_terms[0]; |
|
| 684 | - |
|
| 685 | - if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
|
|
| 686 | - $is_geodir_location_found = true; |
|
| 687 | - $gd_region = $default_location->region_slug; |
|
| 688 | - $gd_country = $default_location->country_slug; |
|
| 689 | - } |
|
| 690 | - } |
|
| 691 | - // if location still not found then clear location related session variables |
|
| 692 | - if ($is_geodir_location_found && $geodir_set_location_session) {
|
|
| 693 | - $gd_session->set('gd_multi_location', 1);
|
|
| 694 | - $gd_session->set('gd_country', $gd_country);
|
|
| 695 | - $gd_session->set('gd_region', $gd_region);
|
|
| 696 | - $gd_session->set('gd_city', $gd_city);
|
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - if ($geodir_show_location_url == 'all') {
|
|
| 680 | + $is_geodir_location_found = true; |
|
| 681 | + } |
|
| 682 | + } else {
|
|
| 683 | + $gd_city = $geodir_terms[0]; |
|
| 684 | + |
|
| 685 | + if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
|
|
| 686 | + $is_geodir_location_found = true; |
|
| 687 | + $gd_region = $default_location->region_slug; |
|
| 688 | + $gd_country = $default_location->country_slug; |
|
| 689 | + } |
|
| 690 | + } |
|
| 691 | + // if location still not found then clear location related session variables |
|
| 692 | + if ($is_geodir_location_found && $geodir_set_location_session) {
|
|
| 693 | + $gd_session->set('gd_multi_location', 1);
|
|
| 694 | + $gd_session->set('gd_country', $gd_country);
|
|
| 695 | + $gd_session->set('gd_region', $gd_region);
|
|
| 696 | + $gd_session->set('gd_city', $gd_city);
|
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + if ($geodir_show_location_url == 'all') {
|
|
| 700 | 700 | } else if ($geodir_show_location_url == 'country_city') {
|
| 701 | 701 | $gd_region = ''; |
| 702 | 702 | } else if ($geodir_show_location_url == 'region_city') {
|
| 703 | 703 | $gd_country = ''; |
| 704 | 704 | } else {
|
| 705 | 705 | $gd_country = ''; |
| 706 | - $gd_region = ''; |
|
| 706 | + $gd_region = ''; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + if ($is_geodir_location_found) {
|
|
| 710 | + $wp->query_vars['gd_country'] = $gd_country; |
|
| 711 | + $wp->query_vars['gd_region'] = $gd_region; |
|
| 712 | + $wp->query_vars['gd_city'] = $gd_city; |
|
| 713 | + } else {
|
|
| 714 | + $gd_country = ''; |
|
| 715 | + $gd_region = ''; |
|
| 716 | + $gd_city = ''; |
|
| 707 | 717 | } |
| 718 | + } |
|
| 719 | + |
|
| 720 | + $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
|
| 721 | + // eliminate location related terms from taxonomy term |
|
| 722 | + if ($gd_country != '') |
|
| 723 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 724 | + |
|
| 725 | + if ($gd_region != '') |
|
| 726 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 727 | + |
|
| 728 | + if ($gd_city != '') |
|
| 729 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 708 | 730 | |
| 709 | - if ($is_geodir_location_found) {
|
|
| 710 | - $wp->query_vars['gd_country'] = $gd_country; |
|
| 711 | - $wp->query_vars['gd_region'] = $gd_region; |
|
| 712 | - $wp->query_vars['gd_city'] = $gd_city; |
|
| 713 | - } else {
|
|
| 714 | - $gd_country = ''; |
|
| 715 | - $gd_region = ''; |
|
| 716 | - $gd_city = ''; |
|
| 717 | - } |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
|
| 721 | - // eliminate location related terms from taxonomy term |
|
| 722 | - if ($gd_country != '') |
|
| 723 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 724 | - |
|
| 725 | - if ($gd_region != '') |
|
| 726 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 727 | - |
|
| 728 | - if ($gd_city != '') |
|
| 729 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 730 | - |
|
| 731 | - |
|
| 732 | - $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 733 | - $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 734 | - |
|
| 735 | - $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); |
|
| 736 | - |
|
| 737 | - if ($wp->query_vars[$geodir_taxonomy] == '') {
|
|
| 738 | - unset($wp->query_vars[$geodir_taxonomy]); |
|
| 739 | - } else {
|
|
| 740 | - if (!$is_geodir_taxonomy_term) {
|
|
| 741 | - foreach ($wp->query_vars as $key => $vars) {
|
|
| 742 | - unset($wp->query_vars[$key]); |
|
| 743 | - } |
|
| 744 | - $wp->query_vars['error'] = '404'; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - } |
|
| 731 | + |
|
| 732 | + $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 733 | + $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
|
|
| 734 | + |
|
| 735 | + $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); |
|
| 736 | + |
|
| 737 | + if ($wp->query_vars[$geodir_taxonomy] == '') {
|
|
| 738 | + unset($wp->query_vars[$geodir_taxonomy]); |
|
| 739 | + } else {
|
|
| 740 | + if (!$is_geodir_taxonomy_term) {
|
|
| 741 | + foreach ($wp->query_vars as $key => $vars) {
|
|
| 742 | + unset($wp->query_vars[$key]); |
|
| 743 | + } |
|
| 744 | + $wp->query_vars['error'] = '404'; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | 750 | // Unset location session if gd page and location not set. |
| 751 | 751 | if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
|
| 752 | 752 | $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - if ($gd_session->get('gd_multi_location') == 1) {
|
|
| 756 | - $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
|
|
| 757 | - $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
|
|
| 758 | - $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
|
|
| 759 | - } |
|
| 755 | + if ($gd_session->get('gd_multi_location') == 1) {
|
|
| 756 | + $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
|
|
| 757 | + $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
|
|
| 758 | + $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
|
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - // now check if there is location parts in the url or not |
|
| 762 | - if (get_option('geodir_add_location_url')) {
|
|
| 761 | + // now check if there is location parts in the url or not |
|
| 762 | + if (get_option('geodir_add_location_url')) {
|
|
| 763 | 763 | if ($geodir_show_location_url == 'all') {
|
| 764 | 764 | } else if ($geodir_show_location_url == 'country_city') {
|
| 765 | 765 | if (isset($wp->query_vars['gd_region'])) |
| 766 | - $wp->query_vars['gd_region'] = ''; |
|
| 766 | + $wp->query_vars['gd_region'] = ''; |
|
| 767 | 767 | } else if ($geodir_show_location_url == 'region_city') {
|
| 768 | 768 | if (isset($wp->query_vars['gd_country'])) |
| 769 | - $wp->query_vars['gd_country'] = ''; |
|
| 769 | + $wp->query_vars['gd_country'] = ''; |
|
| 770 | 770 | } else {
|
| 771 | 771 | if (isset($wp->query_vars['gd_country'])) |
| 772 | - $wp->query_vars['gd_country'] = ''; |
|
| 772 | + $wp->query_vars['gd_country'] = ''; |
|
| 773 | 773 | |
| 774 | - if (isset($wp->query_vars['gd_region'])) |
|
| 775 | - $wp->query_vars['gd_region'] = ''; |
|
| 774 | + if (isset($wp->query_vars['gd_region'])) |
|
| 775 | + $wp->query_vars['gd_region'] = ''; |
|
| 776 | 776 | } |
| 777 | - } else {
|
|
| 778 | - if (isset($wp->query_vars['gd_country'])) |
|
| 779 | - $wp->query_vars['gd_country'] = ''; |
|
| 777 | + } else {
|
|
| 778 | + if (isset($wp->query_vars['gd_country'])) |
|
| 779 | + $wp->query_vars['gd_country'] = ''; |
|
| 780 | 780 | |
| 781 | - if (isset($wp->query_vars['gd_region'])) |
|
| 782 | - $wp->query_vars['gd_region'] = ''; |
|
| 781 | + if (isset($wp->query_vars['gd_region'])) |
|
| 782 | + $wp->query_vars['gd_region'] = ''; |
|
| 783 | 783 | |
| 784 | - if (isset($wp->query_vars['gd_city'])) |
|
| 785 | - $wp->query_vars['gd_city'] = ''; |
|
| 786 | - } |
|
| 784 | + if (isset($wp->query_vars['gd_city'])) |
|
| 785 | + $wp->query_vars['gd_city'] = ''; |
|
| 786 | + } |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -797,24 +797,24 @@ discard block |
||
| 797 | 797 | */ |
| 798 | 798 | function geodir_custom_post_status() |
| 799 | 799 | {
|
| 800 | - // Virtual Page Status |
|
| 801 | - register_post_status('virtual', array(
|
|
| 802 | - 'label' => _x('Virtual', 'page', 'geodirectory'),
|
|
| 803 | - 'public' => true, |
|
| 804 | - 'exclude_from_search' => true, |
|
| 805 | - 'show_in_admin_all_list' => true, |
|
| 806 | - 'show_in_admin_status_list' => true, |
|
| 807 | - 'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
|
|
| 808 | - )); |
|
| 809 | - |
|
| 810 | - /** |
|
| 811 | - * Called after we register the custom post status 'Virtual'. |
|
| 812 | - * |
|
| 813 | - * Can be use to add more post statuses. |
|
| 814 | - * |
|
| 815 | - * @since 1.0.0 |
|
| 816 | - */ |
|
| 817 | - do_action('geodir_custom_post_status');
|
|
| 800 | + // Virtual Page Status |
|
| 801 | + register_post_status('virtual', array(
|
|
| 802 | + 'label' => _x('Virtual', 'page', 'geodirectory'),
|
|
| 803 | + 'public' => true, |
|
| 804 | + 'exclude_from_search' => true, |
|
| 805 | + 'show_in_admin_all_list' => true, |
|
| 806 | + 'show_in_admin_status_list' => true, |
|
| 807 | + 'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
|
|
| 808 | + )); |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * Called after we register the custom post status 'Virtual'. |
|
| 812 | + * |
|
| 813 | + * Can be use to add more post statuses. |
|
| 814 | + * |
|
| 815 | + * @since 1.0.0 |
|
| 816 | + */ |
|
| 817 | + do_action('geodir_custom_post_status');
|
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | function geodir_get_term_link($termlink, $term, $taxonomy) |
| 831 | 831 | {
|
| 832 | - return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php |
|
| 832 | + return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | */ |
| 844 | 844 | function geodir_get_posttype_link($link, $post_type) |
| 845 | 845 | {
|
| 846 | - return geodir_posttype_link($link, $post_type); // taxonomy_functions.php |
|
| 846 | + return geodir_posttype_link($link, $post_type); // taxonomy_functions.php |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | /** |
@@ -858,13 +858,13 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | function exclude_from_wp_list_pages($exclude_array) |
| 860 | 860 | {
|
| 861 | - $pages_ids = array(); |
|
| 862 | - $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
|
|
| 863 | - foreach ($pages_array as $page) {
|
|
| 864 | - $pages_ids[] = $page->ID; |
|
| 865 | - } |
|
| 866 | - $exclude_array = $exclude_array + $pages_ids; |
|
| 867 | - return $exclude_array; |
|
| 861 | + $pages_ids = array(); |
|
| 862 | + $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
|
|
| 863 | + foreach ($pages_array as $page) {
|
|
| 864 | + $pages_ids[] = $page->ID; |
|
| 865 | + } |
|
| 866 | + $exclude_array = $exclude_array + $pages_ids; |
|
| 867 | + return $exclude_array; |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -877,8 +877,8 @@ discard block |
||
| 877 | 877 | */ |
| 878 | 878 | function geodir_exclude_page($query) |
| 879 | 879 | {
|
| 880 | - add_filter('posts_where', 'geodir_exclude_page_where', 100);
|
|
| 881 | - return $query; |
|
| 880 | + add_filter('posts_where', 'geodir_exclude_page_where', 100);
|
|
| 881 | + return $query; |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | /** |
@@ -893,11 +893,11 @@ discard block |
||
| 893 | 893 | */ |
| 894 | 894 | function geodir_exclude_page_where($where) |
| 895 | 895 | {
|
| 896 | - global $wpdb; |
|
| 897 | - if (is_admin()) |
|
| 898 | - $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 896 | + global $wpdb; |
|
| 897 | + if (is_admin()) |
|
| 898 | + $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 899 | 899 | |
| 900 | - return $where; |
|
| 900 | + return $where; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -912,21 +912,21 @@ discard block |
||
| 912 | 912 | * @return mixed The taxonomy option value. |
| 913 | 913 | */ |
| 914 | 914 | function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
|
| 915 | - global $wp_query; |
|
| 915 | + global $wp_query; |
|
| 916 | 916 | |
| 917 | - if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
|
|
| 918 | - $term = $wp_query->get_queried_object(); |
|
| 917 | + if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
|
|
| 918 | + $term = $wp_query->get_queried_object(); |
|
| 919 | 919 | |
| 920 | - if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
|
|
| 921 | - $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); |
|
| 920 | + if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
|
|
| 921 | + $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); |
|
| 922 | 922 | |
| 923 | - if ( !empty( $image['src'] ) ) {
|
|
| 924 | - $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; |
|
| 925 | - $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - } |
|
| 929 | - return $value; |
|
| 923 | + if ( !empty( $image['src'] ) ) {
|
|
| 924 | + $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; |
|
| 925 | + $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + } |
|
| 929 | + return $value; |
|
| 930 | 930 | } |
| 931 | 931 | add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 ); |
| 932 | 932 | |
@@ -937,24 +937,24 @@ discard block |
||
| 937 | 937 | * |
| 938 | 938 | */ |
| 939 | 939 | function geodir_affiliate_wp_rewrite_fix() {
|
| 940 | - if ( !class_exists( 'Affiliate_WP' ) ) {
|
|
| 941 | - return; |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - $gd_post_types = geodir_get_posttypes( 'array' ); |
|
| 945 | - |
|
| 946 | - if ( !empty( $gd_post_types ) ) {
|
|
| 947 | - $ref = affiliate_wp()->tracking->get_referral_var(); |
|
| 948 | - if ( empty( $ref ) ) {
|
|
| 949 | - return; |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - foreach ( $gd_post_types as $key => $post_type ) {
|
|
| 953 | - if ( !empty( $key ) && !empty( $post_type['rewrite']['slug'] ) ) {
|
|
| 954 | - add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]&paged=$matches[3]', 'top');
|
|
| 955 | - add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]', 'top'); |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - } |
|
| 940 | + if ( !class_exists( 'Affiliate_WP' ) ) {
|
|
| 941 | + return; |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + $gd_post_types = geodir_get_posttypes( 'array' ); |
|
| 945 | + |
|
| 946 | + if ( !empty( $gd_post_types ) ) {
|
|
| 947 | + $ref = affiliate_wp()->tracking->get_referral_var(); |
|
| 948 | + if ( empty( $ref ) ) {
|
|
| 949 | + return; |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + foreach ( $gd_post_types as $key => $post_type ) {
|
|
| 953 | + if ( !empty( $key ) && !empty( $post_type['rewrite']['slug'] ) ) {
|
|
| 954 | + add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/page/([0-9]{1,})/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]&paged=$matches[3]', 'top');
|
|
| 955 | + add_rewrite_rule( $post_type['rewrite']['slug'] . '/' . $ref . '(/(.*))?/?$', 'index.php?post_type=' . $key . '&' . $ref . '=$matches[1]', 'top'); |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | 959 | } |
| 960 | 960 | add_action( 'init', 'geodir_affiliate_wp_rewrite_fix', 99999 ); |