@@ -21,84 +21,84 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function geodir_cf_checkbox($html,$location,$cf,$p=''){ |
| 23 | 23 | |
| 24 | - // check we have the post value |
|
| 25 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 26 | - else{ global $post;} |
|
| 27 | - |
|
| 28 | - if(!is_array($cf) && $cf!=''){ |
|
| 29 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 30 | - if(!$cf){return NULL;} |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - $html_var = $cf['htmlvar_name']; |
|
| 34 | - |
|
| 35 | - // Check if there is a location specific filter. |
|
| 36 | - if(has_filter("geodir_custom_field_output_checkbox_loc_{$location}")){ |
|
| 37 | - /** |
|
| 38 | - * Filter the checkbox html by location. |
|
| 39 | - * |
|
| 40 | - * @param string $html The html to filter. |
|
| 41 | - * @param array $cf The custom field array. |
|
| 42 | - * @since 1.6.6 |
|
| 43 | - */ |
|
| 44 | - $html = apply_filters("geodir_custom_field_output_checkbox_loc_{$location}",$html,$cf); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // Check if there is a custom field specific filter. |
|
| 48 | - if(has_filter("geodir_custom_field_output_checkbox_var_{$html_var}")){ |
|
| 49 | - /** |
|
| 50 | - * Filter the checkbox html by individual custom field. |
|
| 51 | - * |
|
| 52 | - * @param string $html The html to filter. |
|
| 53 | - * @param string $location The location to output the html. |
|
| 54 | - * @param array $cf The custom field array. |
|
| 55 | - * @since 1.6.6 |
|
| 56 | - */ |
|
| 57 | - $html = apply_filters("geodir_custom_field_output_checkbox_var_{$html_var}",$html,$location,$cf); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - // Check if there is a custom field key specific filter. |
|
| 61 | - if(has_filter("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}")){ |
|
| 62 | - /** |
|
| 63 | - * Filter the checkbox html by field type key. |
|
| 64 | - * |
|
| 65 | - * @param string $html The html to filter. |
|
| 66 | - * @param string $location The location to output the html. |
|
| 67 | - * @param array $cf The custom field array. |
|
| 68 | - * @since 1.6.6 |
|
| 69 | - */ |
|
| 70 | - $html = apply_filters("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // If not html then we run the standard output. |
|
| 74 | - if(empty($html)){ |
|
| 75 | - |
|
| 76 | - if ( (int) $post->{$html_var} == 1 ): |
|
| 77 | - |
|
| 78 | - if ( $post->{$html_var} == '1' ): |
|
| 79 | - $html_val = __( 'Yes', 'geodirectory' ); |
|
| 80 | - else: |
|
| 81 | - $html_val = __( 'No', 'geodirectory' ); |
|
| 82 | - endif; |
|
| 83 | - |
|
| 84 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 85 | - if (strpos($field_icon, 'http') !== false) { |
|
| 86 | - $field_icon_af = ''; |
|
| 87 | - } elseif ($field_icon == '') { |
|
| 88 | - $field_icon_af = ''; |
|
| 89 | - } else { |
|
| 90 | - $field_icon_af = $field_icon; |
|
| 91 | - $field_icon = ''; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; |
|
| 95 | - $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : ''; |
|
| 96 | - $html .= '</span>' . $html_val . '</div>'; |
|
| 97 | - endif; |
|
| 98 | - |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $html; |
|
| 24 | + // check we have the post value |
|
| 25 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 26 | + else{ global $post;} |
|
| 27 | + |
|
| 28 | + if(!is_array($cf) && $cf!=''){ |
|
| 29 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 30 | + if(!$cf){return NULL;} |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + $html_var = $cf['htmlvar_name']; |
|
| 34 | + |
|
| 35 | + // Check if there is a location specific filter. |
|
| 36 | + if(has_filter("geodir_custom_field_output_checkbox_loc_{$location}")){ |
|
| 37 | + /** |
|
| 38 | + * Filter the checkbox html by location. |
|
| 39 | + * |
|
| 40 | + * @param string $html The html to filter. |
|
| 41 | + * @param array $cf The custom field array. |
|
| 42 | + * @since 1.6.6 |
|
| 43 | + */ |
|
| 44 | + $html = apply_filters("geodir_custom_field_output_checkbox_loc_{$location}",$html,$cf); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // Check if there is a custom field specific filter. |
|
| 48 | + if(has_filter("geodir_custom_field_output_checkbox_var_{$html_var}")){ |
|
| 49 | + /** |
|
| 50 | + * Filter the checkbox html by individual custom field. |
|
| 51 | + * |
|
| 52 | + * @param string $html The html to filter. |
|
| 53 | + * @param string $location The location to output the html. |
|
| 54 | + * @param array $cf The custom field array. |
|
| 55 | + * @since 1.6.6 |
|
| 56 | + */ |
|
| 57 | + $html = apply_filters("geodir_custom_field_output_checkbox_var_{$html_var}",$html,$location,$cf); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + // Check if there is a custom field key specific filter. |
|
| 61 | + if(has_filter("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}")){ |
|
| 62 | + /** |
|
| 63 | + * Filter the checkbox html by field type key. |
|
| 64 | + * |
|
| 65 | + * @param string $html The html to filter. |
|
| 66 | + * @param string $location The location to output the html. |
|
| 67 | + * @param array $cf The custom field array. |
|
| 68 | + * @since 1.6.6 |
|
| 69 | + */ |
|
| 70 | + $html = apply_filters("geodir_custom_field_output_checkbox_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // If not html then we run the standard output. |
|
| 74 | + if(empty($html)){ |
|
| 75 | + |
|
| 76 | + if ( (int) $post->{$html_var} == 1 ): |
|
| 77 | + |
|
| 78 | + if ( $post->{$html_var} == '1' ): |
|
| 79 | + $html_val = __( 'Yes', 'geodirectory' ); |
|
| 80 | + else: |
|
| 81 | + $html_val = __( 'No', 'geodirectory' ); |
|
| 82 | + endif; |
|
| 83 | + |
|
| 84 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 85 | + if (strpos($field_icon, 'http') !== false) { |
|
| 86 | + $field_icon_af = ''; |
|
| 87 | + } elseif ($field_icon == '') { |
|
| 88 | + $field_icon_af = ''; |
|
| 89 | + } else { |
|
| 90 | + $field_icon_af = $field_icon; |
|
| 91 | + $field_icon = ''; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; |
|
| 95 | + $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : ''; |
|
| 96 | + $html .= '</span>' . $html_val . '</div>'; |
|
| 97 | + endif; |
|
| 98 | + |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $html; |
|
| 102 | 102 | } |
| 103 | 103 | add_filter('geodir_custom_field_output_checkbox','geodir_cf_checkbox',10,3); |
| 104 | 104 | |
@@ -115,71 +115,71 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function geodir_cf_fieldset($html,$location,$cf,$p=''){ |
| 117 | 117 | |
| 118 | - // check we have the post value |
|
| 119 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 120 | - else{ global $post;} |
|
| 121 | - |
|
| 122 | - if(!is_array($cf) && $cf!=''){ |
|
| 123 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 124 | - if(!$cf){return NULL;} |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $html_var = $cf['htmlvar_name']; |
|
| 128 | - |
|
| 129 | - // Check if there is a location specific filter. |
|
| 130 | - if(has_filter("geodir_custom_field_output_fieldset_loc_{$location}")){ |
|
| 131 | - /** |
|
| 132 | - * Filter the fieldset html by location. |
|
| 133 | - * |
|
| 134 | - * @param string $html The html to filter. |
|
| 135 | - * @param array $cf The custom field array. |
|
| 136 | - * @since 1.6.6 |
|
| 137 | - */ |
|
| 138 | - $html = apply_filters("geodir_custom_field_output_fieldset_loc_{$location}",$html,$cf); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - // Check if there is a custom field specific filter. |
|
| 142 | - if(has_filter("geodir_custom_field_output_fieldset_var_{$html_var}")){ |
|
| 143 | - /** |
|
| 144 | - * Filter the fieldset html by individual custom field. |
|
| 145 | - * |
|
| 146 | - * @param string $html The html to filter. |
|
| 147 | - * @param string $location The location to output the html. |
|
| 148 | - * @param array $cf The custom field array. |
|
| 149 | - * @since 1.6.6 |
|
| 150 | - */ |
|
| 151 | - $html = apply_filters("geodir_custom_field_output_fieldset_var_{$html_var}",$html,$location,$cf); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // Check if there is a custom field key specific filter. |
|
| 155 | - if(has_filter("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}")){ |
|
| 156 | - /** |
|
| 157 | - * Filter the fieldset html by field type key. |
|
| 158 | - * |
|
| 159 | - * @param string $html The html to filter. |
|
| 160 | - * @param string $location The location to output the html. |
|
| 161 | - * @param array $cf The custom field array. |
|
| 162 | - * @since 1.6.6 |
|
| 163 | - */ |
|
| 164 | - $html = apply_filters("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // If not html then we run the standard output. |
|
| 168 | - if(empty($html)){ |
|
| 169 | - |
|
| 170 | - global $field_set_start; |
|
| 171 | - $fieldset_class = 'fieldset-'.sanitize_html_class(sanitize_title_with_dashes($cf['site_title'])); |
|
| 172 | - |
|
| 173 | - if ($field_set_start == 1) { |
|
| 174 | - $html = ''; |
|
| 175 | - } else { |
|
| 176 | - $html = '<h2 class="'.$fieldset_class.'">'. __($cf['site_title'], 'geodirectory') . '</h2>'; |
|
| 177 | - //$field_set_start = 1; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return $html; |
|
| 118 | + // check we have the post value |
|
| 119 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 120 | + else{ global $post;} |
|
| 121 | + |
|
| 122 | + if(!is_array($cf) && $cf!=''){ |
|
| 123 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 124 | + if(!$cf){return NULL;} |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $html_var = $cf['htmlvar_name']; |
|
| 128 | + |
|
| 129 | + // Check if there is a location specific filter. |
|
| 130 | + if(has_filter("geodir_custom_field_output_fieldset_loc_{$location}")){ |
|
| 131 | + /** |
|
| 132 | + * Filter the fieldset html by location. |
|
| 133 | + * |
|
| 134 | + * @param string $html The html to filter. |
|
| 135 | + * @param array $cf The custom field array. |
|
| 136 | + * @since 1.6.6 |
|
| 137 | + */ |
|
| 138 | + $html = apply_filters("geodir_custom_field_output_fieldset_loc_{$location}",$html,$cf); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + // Check if there is a custom field specific filter. |
|
| 142 | + if(has_filter("geodir_custom_field_output_fieldset_var_{$html_var}")){ |
|
| 143 | + /** |
|
| 144 | + * Filter the fieldset html by individual custom field. |
|
| 145 | + * |
|
| 146 | + * @param string $html The html to filter. |
|
| 147 | + * @param string $location The location to output the html. |
|
| 148 | + * @param array $cf The custom field array. |
|
| 149 | + * @since 1.6.6 |
|
| 150 | + */ |
|
| 151 | + $html = apply_filters("geodir_custom_field_output_fieldset_var_{$html_var}",$html,$location,$cf); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // Check if there is a custom field key specific filter. |
|
| 155 | + if(has_filter("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}")){ |
|
| 156 | + /** |
|
| 157 | + * Filter the fieldset html by field type key. |
|
| 158 | + * |
|
| 159 | + * @param string $html The html to filter. |
|
| 160 | + * @param string $location The location to output the html. |
|
| 161 | + * @param array $cf The custom field array. |
|
| 162 | + * @since 1.6.6 |
|
| 163 | + */ |
|
| 164 | + $html = apply_filters("geodir_custom_field_output_fieldset_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // If not html then we run the standard output. |
|
| 168 | + if(empty($html)){ |
|
| 169 | + |
|
| 170 | + global $field_set_start; |
|
| 171 | + $fieldset_class = 'fieldset-'.sanitize_html_class(sanitize_title_with_dashes($cf['site_title'])); |
|
| 172 | + |
|
| 173 | + if ($field_set_start == 1) { |
|
| 174 | + $html = ''; |
|
| 175 | + } else { |
|
| 176 | + $html = '<h2 class="'.$fieldset_class.'">'. __($cf['site_title'], 'geodirectory') . '</h2>'; |
|
| 177 | + //$field_set_start = 1; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return $html; |
|
| 183 | 183 | } |
| 184 | 184 | add_filter('geodir_custom_field_output_fieldset','geodir_cf_fieldset',10,3); |
| 185 | 185 | |
@@ -196,106 +196,106 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | function geodir_cf_url($html,$location,$cf,$p=''){ |
| 198 | 198 | |
| 199 | - // check we have the post value |
|
| 200 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 201 | - else{ global $post;} |
|
| 202 | - |
|
| 203 | - if(!is_array($cf) && $cf!=''){ |
|
| 204 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 205 | - if(!$cf){return NULL;} |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $html_var = $cf['htmlvar_name']; |
|
| 209 | - |
|
| 210 | - // Check if there is a location specific filter. |
|
| 211 | - if(has_filter("geodir_custom_field_output_url_loc_{$location}")){ |
|
| 212 | - /** |
|
| 213 | - * Filter the url html by location. |
|
| 214 | - * |
|
| 215 | - * @param string $html The html to filter. |
|
| 216 | - * @param array $cf The custom field array. |
|
| 217 | - * @since 1.6.6 |
|
| 218 | - */ |
|
| 219 | - $html = apply_filters("geodir_custom_field_output_url_loc_{$location}",$html,$cf); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - // Check if there is a custom field specific filter. |
|
| 223 | - if(has_filter("geodir_custom_field_output_url_var_{$html_var}")){ |
|
| 224 | - /** |
|
| 225 | - * Filter the url html by individual custom field. |
|
| 226 | - * |
|
| 227 | - * @param string $html The html to filter. |
|
| 228 | - * @param string $location The location to output the html. |
|
| 229 | - * @param array $cf The custom field array. |
|
| 230 | - * @since 1.6.6 |
|
| 231 | - */ |
|
| 232 | - $html = apply_filters("geodir_custom_field_output_url_var_{$html_var}",$html,$location,$cf); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // Check if there is a custom field key specific filter. |
|
| 236 | - if(has_filter("geodir_custom_field_output_url_key_{$cf['field_type_key']}")){ |
|
| 237 | - /** |
|
| 238 | - * Filter the url html by field type key. |
|
| 239 | - * |
|
| 240 | - * @param string $html The html to filter. |
|
| 241 | - * @param string $location The location to output the html. |
|
| 242 | - * @param array $cf The custom field array. |
|
| 243 | - * @since 1.6.6 |
|
| 244 | - */ |
|
| 245 | - $html = apply_filters("geodir_custom_field_output_url_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // If not html then we run the standard output. |
|
| 249 | - if(empty($html)){ |
|
| 250 | - |
|
| 251 | - if ($post->{$cf['htmlvar_name']}): |
|
| 252 | - |
|
| 253 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 254 | - if (strpos($field_icon, 'http') !== false) { |
|
| 255 | - $field_icon_af = ''; |
|
| 256 | - } elseif ($field_icon == '') { |
|
| 257 | - |
|
| 258 | - if ($cf['name'] == 'geodir_facebook') { |
|
| 259 | - $field_icon_af = '<i class="fa fa-facebook-square"></i>'; |
|
| 260 | - } elseif ($cf['name'] == 'geodir_twitter') { |
|
| 261 | - $field_icon_af = '<i class="fa fa-twitter-square"></i>'; |
|
| 262 | - } else { |
|
| 263 | - $field_icon_af = '<i class="fa fa-link"></i>'; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - } else { |
|
| 267 | - $field_icon_af = $field_icon; |
|
| 268 | - $field_icon = ''; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $a_url = geodir_parse_custom_field_url($post->{$cf['htmlvar_name']}); |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 275 | - $title = !empty($a_url['label']) ? $a_url['label'] : $cf['site_title']; |
|
| 276 | - if(!empty($cf['default_value'])){$title = $cf['default_value'];} |
|
| 277 | - $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - // all search engines that use the nofollow value exclude links that use it from their ranking calculation |
|
| 282 | - $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; |
|
| 283 | - /** |
|
| 284 | - * Filter custom field website name. |
|
| 285 | - * |
|
| 286 | - * @since 1.0.0 |
|
| 287 | - * |
|
| 288 | - * @param string $title Website Title. |
|
| 289 | - * @param string $website Website URL. |
|
| 290 | - * @param int $post->ID Post ID. |
|
| 291 | - */ |
|
| 292 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>'; |
|
| 293 | - |
|
| 294 | - endif; |
|
| 295 | - |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - return $html; |
|
| 199 | + // check we have the post value |
|
| 200 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 201 | + else{ global $post;} |
|
| 202 | + |
|
| 203 | + if(!is_array($cf) && $cf!=''){ |
|
| 204 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 205 | + if(!$cf){return NULL;} |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $html_var = $cf['htmlvar_name']; |
|
| 209 | + |
|
| 210 | + // Check if there is a location specific filter. |
|
| 211 | + if(has_filter("geodir_custom_field_output_url_loc_{$location}")){ |
|
| 212 | + /** |
|
| 213 | + * Filter the url html by location. |
|
| 214 | + * |
|
| 215 | + * @param string $html The html to filter. |
|
| 216 | + * @param array $cf The custom field array. |
|
| 217 | + * @since 1.6.6 |
|
| 218 | + */ |
|
| 219 | + $html = apply_filters("geodir_custom_field_output_url_loc_{$location}",$html,$cf); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + // Check if there is a custom field specific filter. |
|
| 223 | + if(has_filter("geodir_custom_field_output_url_var_{$html_var}")){ |
|
| 224 | + /** |
|
| 225 | + * Filter the url html by individual custom field. |
|
| 226 | + * |
|
| 227 | + * @param string $html The html to filter. |
|
| 228 | + * @param string $location The location to output the html. |
|
| 229 | + * @param array $cf The custom field array. |
|
| 230 | + * @since 1.6.6 |
|
| 231 | + */ |
|
| 232 | + $html = apply_filters("geodir_custom_field_output_url_var_{$html_var}",$html,$location,$cf); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // Check if there is a custom field key specific filter. |
|
| 236 | + if(has_filter("geodir_custom_field_output_url_key_{$cf['field_type_key']}")){ |
|
| 237 | + /** |
|
| 238 | + * Filter the url html by field type key. |
|
| 239 | + * |
|
| 240 | + * @param string $html The html to filter. |
|
| 241 | + * @param string $location The location to output the html. |
|
| 242 | + * @param array $cf The custom field array. |
|
| 243 | + * @since 1.6.6 |
|
| 244 | + */ |
|
| 245 | + $html = apply_filters("geodir_custom_field_output_url_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // If not html then we run the standard output. |
|
| 249 | + if(empty($html)){ |
|
| 250 | + |
|
| 251 | + if ($post->{$cf['htmlvar_name']}): |
|
| 252 | + |
|
| 253 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 254 | + if (strpos($field_icon, 'http') !== false) { |
|
| 255 | + $field_icon_af = ''; |
|
| 256 | + } elseif ($field_icon == '') { |
|
| 257 | + |
|
| 258 | + if ($cf['name'] == 'geodir_facebook') { |
|
| 259 | + $field_icon_af = '<i class="fa fa-facebook-square"></i>'; |
|
| 260 | + } elseif ($cf['name'] == 'geodir_twitter') { |
|
| 261 | + $field_icon_af = '<i class="fa fa-twitter-square"></i>'; |
|
| 262 | + } else { |
|
| 263 | + $field_icon_af = '<i class="fa fa-link"></i>'; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + } else { |
|
| 267 | + $field_icon_af = $field_icon; |
|
| 268 | + $field_icon = ''; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $a_url = geodir_parse_custom_field_url($post->{$cf['htmlvar_name']}); |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 275 | + $title = !empty($a_url['label']) ? $a_url['label'] : $cf['site_title']; |
|
| 276 | + if(!empty($cf['default_value'])){$title = $cf['default_value'];} |
|
| 277 | + $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + // all search engines that use the nofollow value exclude links that use it from their ranking calculation |
|
| 282 | + $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; |
|
| 283 | + /** |
|
| 284 | + * Filter custom field website name. |
|
| 285 | + * |
|
| 286 | + * @since 1.0.0 |
|
| 287 | + * |
|
| 288 | + * @param string $title Website Title. |
|
| 289 | + * @param string $website Website URL. |
|
| 290 | + * @param int $post->ID Post ID. |
|
| 291 | + */ |
|
| 292 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>'; |
|
| 293 | + |
|
| 294 | + endif; |
|
| 295 | + |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + return $html; |
|
| 299 | 299 | } |
| 300 | 300 | add_filter('geodir_custom_field_output_url','geodir_cf_url',10,3); |
| 301 | 301 | |
@@ -312,80 +312,80 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function geodir_cf_phone($html,$location,$cf,$p=''){ |
| 314 | 314 | |
| 315 | - // check we have the post value |
|
| 316 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 317 | - else{ global $post;} |
|
| 318 | - |
|
| 319 | - if(!is_array($cf) && $cf!=''){ |
|
| 320 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 321 | - if(!$cf){return NULL;} |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - $html_var = $cf['htmlvar_name']; |
|
| 325 | - |
|
| 326 | - // Check if there is a location specific filter. |
|
| 327 | - if(has_filter("geodir_custom_field_output_phone_loc_{$location}")){ |
|
| 328 | - /** |
|
| 329 | - * Filter the phone html by location. |
|
| 330 | - * |
|
| 331 | - * @param string $html The html to filter. |
|
| 332 | - * @param array $cf The custom field array. |
|
| 333 | - * @since 1.6.6 |
|
| 334 | - */ |
|
| 335 | - $html = apply_filters("geodir_custom_field_output_phone_loc_{$location}",$html,$cf); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - // Check if there is a custom field specific filter. |
|
| 339 | - if(has_filter("geodir_custom_field_output_phone_var_{$html_var}")){ |
|
| 340 | - /** |
|
| 341 | - * Filter the phone html by individual custom field. |
|
| 342 | - * |
|
| 343 | - * @param string $html The html to filter. |
|
| 344 | - * @param string $location The location to output the html. |
|
| 345 | - * @param array $cf The custom field array. |
|
| 346 | - * @since 1.6.6 |
|
| 347 | - */ |
|
| 348 | - $html = apply_filters("geodir_custom_field_output_phone_var_{$html_var}",$html,$location,$cf); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - // Check if there is a custom field key specific filter. |
|
| 352 | - if(has_filter("geodir_custom_field_output_phone_key_{$cf['field_type_key']}")){ |
|
| 353 | - /** |
|
| 354 | - * Filter the phone html by field type key. |
|
| 355 | - * |
|
| 356 | - * @param string $html The html to filter. |
|
| 357 | - * @param string $location The location to output the html. |
|
| 358 | - * @param array $cf The custom field array. |
|
| 359 | - * @since 1.6.6 |
|
| 360 | - */ |
|
| 361 | - $html = apply_filters("geodir_custom_field_output_phone_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // If not html then we run the standard output. |
|
| 365 | - if(empty($html)){ |
|
| 366 | - |
|
| 367 | - if ($post->{$cf['htmlvar_name']}): |
|
| 368 | - |
|
| 369 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 370 | - if (strpos($field_icon, 'http') !== false) { |
|
| 371 | - $field_icon_af = ''; |
|
| 372 | - } elseif ($field_icon == '') { |
|
| 373 | - $field_icon_af = '<i class="fa fa-phone"></i>'; |
|
| 374 | - } else { |
|
| 375 | - $field_icon_af = $field_icon; |
|
| 376 | - $field_icon = ''; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . |
|
| 381 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ' '; |
|
| 382 | - $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$cf['htmlvar_name']}) . '">' . $post->{$cf['htmlvar_name']} . '</a></div>'; |
|
| 383 | - |
|
| 384 | - endif; |
|
| 385 | - |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return $html; |
|
| 315 | + // check we have the post value |
|
| 316 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 317 | + else{ global $post;} |
|
| 318 | + |
|
| 319 | + if(!is_array($cf) && $cf!=''){ |
|
| 320 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 321 | + if(!$cf){return NULL;} |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + $html_var = $cf['htmlvar_name']; |
|
| 325 | + |
|
| 326 | + // Check if there is a location specific filter. |
|
| 327 | + if(has_filter("geodir_custom_field_output_phone_loc_{$location}")){ |
|
| 328 | + /** |
|
| 329 | + * Filter the phone html by location. |
|
| 330 | + * |
|
| 331 | + * @param string $html The html to filter. |
|
| 332 | + * @param array $cf The custom field array. |
|
| 333 | + * @since 1.6.6 |
|
| 334 | + */ |
|
| 335 | + $html = apply_filters("geodir_custom_field_output_phone_loc_{$location}",$html,$cf); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + // Check if there is a custom field specific filter. |
|
| 339 | + if(has_filter("geodir_custom_field_output_phone_var_{$html_var}")){ |
|
| 340 | + /** |
|
| 341 | + * Filter the phone html by individual custom field. |
|
| 342 | + * |
|
| 343 | + * @param string $html The html to filter. |
|
| 344 | + * @param string $location The location to output the html. |
|
| 345 | + * @param array $cf The custom field array. |
|
| 346 | + * @since 1.6.6 |
|
| 347 | + */ |
|
| 348 | + $html = apply_filters("geodir_custom_field_output_phone_var_{$html_var}",$html,$location,$cf); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + // Check if there is a custom field key specific filter. |
|
| 352 | + if(has_filter("geodir_custom_field_output_phone_key_{$cf['field_type_key']}")){ |
|
| 353 | + /** |
|
| 354 | + * Filter the phone html by field type key. |
|
| 355 | + * |
|
| 356 | + * @param string $html The html to filter. |
|
| 357 | + * @param string $location The location to output the html. |
|
| 358 | + * @param array $cf The custom field array. |
|
| 359 | + * @since 1.6.6 |
|
| 360 | + */ |
|
| 361 | + $html = apply_filters("geodir_custom_field_output_phone_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // If not html then we run the standard output. |
|
| 365 | + if(empty($html)){ |
|
| 366 | + |
|
| 367 | + if ($post->{$cf['htmlvar_name']}): |
|
| 368 | + |
|
| 369 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 370 | + if (strpos($field_icon, 'http') !== false) { |
|
| 371 | + $field_icon_af = ''; |
|
| 372 | + } elseif ($field_icon == '') { |
|
| 373 | + $field_icon_af = '<i class="fa fa-phone"></i>'; |
|
| 374 | + } else { |
|
| 375 | + $field_icon_af = $field_icon; |
|
| 376 | + $field_icon = ''; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . |
|
| 381 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ' '; |
|
| 382 | + $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$cf['htmlvar_name']}) . '">' . $post->{$cf['htmlvar_name']} . '</a></div>'; |
|
| 383 | + |
|
| 384 | + endif; |
|
| 385 | + |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return $html; |
|
| 389 | 389 | } |
| 390 | 390 | add_filter('geodir_custom_field_output_phone','geodir_cf_phone',10,3); |
| 391 | 391 | |
@@ -402,85 +402,85 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | function geodir_cf_time($html,$location,$cf,$p=''){ |
| 404 | 404 | |
| 405 | - // check we have the post value |
|
| 406 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 407 | - else{ global $post;} |
|
| 408 | - |
|
| 409 | - if(!is_array($cf) && $cf!=''){ |
|
| 410 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 411 | - if(!$cf){return NULL;} |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - $html_var = $cf['htmlvar_name']; |
|
| 415 | - |
|
| 416 | - // Check if there is a location specific filter. |
|
| 417 | - if(has_filter("geodir_custom_field_output_time_loc_{$location}")){ |
|
| 418 | - /** |
|
| 419 | - * Filter the time html by location. |
|
| 420 | - * |
|
| 421 | - * @param string $html The html to filter. |
|
| 422 | - * @param array $cf The custom field array. |
|
| 423 | - * @since 1.6.6 |
|
| 424 | - */ |
|
| 425 | - $html = apply_filters("geodir_custom_field_output_time_loc_{$location}",$html,$cf); |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - // Check if there is a custom field specific filter. |
|
| 429 | - if(has_filter("geodir_custom_field_output_time_var_{$html_var}")){ |
|
| 430 | - /** |
|
| 431 | - * Filter the time html by individual custom field. |
|
| 432 | - * |
|
| 433 | - * @param string $html The html to filter. |
|
| 434 | - * @param string $location The location to output the html. |
|
| 435 | - * @param array $cf The custom field array. |
|
| 436 | - * @since 1.6.6 |
|
| 437 | - */ |
|
| 438 | - $html = apply_filters("geodir_custom_field_output_time_var_{$html_var}",$html,$location,$cf); |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - // Check if there is a custom field key specific filter. |
|
| 442 | - if(has_filter("geodir_custom_field_output_time_key_{$cf['field_type_key']}")){ |
|
| 443 | - /** |
|
| 444 | - * Filter the time html by field type key. |
|
| 445 | - * |
|
| 446 | - * @param string $html The html to filter. |
|
| 447 | - * @param string $location The location to output the html. |
|
| 448 | - * @param array $cf The custom field array. |
|
| 449 | - * @since 1.6.6 |
|
| 450 | - */ |
|
| 451 | - $html = apply_filters("geodir_custom_field_output_time_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - // If not html then we run the standard output. |
|
| 455 | - if(empty($html)){ |
|
| 456 | - |
|
| 457 | - if ($post->{$cf['htmlvar_name']}): |
|
| 458 | - |
|
| 459 | - $value = ''; |
|
| 460 | - if ($post->{$cf['htmlvar_name']} != '') |
|
| 461 | - //$value = date('h:i',strtotime($post->{$cf['htmlvar_name']})); |
|
| 462 | - $value = date(get_option('time_format'), strtotime($post->{$cf['htmlvar_name']})); |
|
| 463 | - |
|
| 464 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 465 | - if (strpos($field_icon, 'http') !== false) { |
|
| 466 | - $field_icon_af = ''; |
|
| 467 | - } elseif ($field_icon == '') { |
|
| 468 | - $field_icon_af = '<i class="fa fa-clock-o"></i>'; |
|
| 469 | - } else { |
|
| 470 | - $field_icon_af = $field_icon; |
|
| 471 | - $field_icon = ''; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - |
|
| 475 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; |
|
| 476 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ' '; |
|
| 477 | - $html .= '</span>' . $value . '</div>'; |
|
| 478 | - |
|
| 479 | - endif; |
|
| 480 | - |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - return $html; |
|
| 405 | + // check we have the post value |
|
| 406 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 407 | + else{ global $post;} |
|
| 408 | + |
|
| 409 | + if(!is_array($cf) && $cf!=''){ |
|
| 410 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 411 | + if(!$cf){return NULL;} |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + $html_var = $cf['htmlvar_name']; |
|
| 415 | + |
|
| 416 | + // Check if there is a location specific filter. |
|
| 417 | + if(has_filter("geodir_custom_field_output_time_loc_{$location}")){ |
|
| 418 | + /** |
|
| 419 | + * Filter the time html by location. |
|
| 420 | + * |
|
| 421 | + * @param string $html The html to filter. |
|
| 422 | + * @param array $cf The custom field array. |
|
| 423 | + * @since 1.6.6 |
|
| 424 | + */ |
|
| 425 | + $html = apply_filters("geodir_custom_field_output_time_loc_{$location}",$html,$cf); |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + // Check if there is a custom field specific filter. |
|
| 429 | + if(has_filter("geodir_custom_field_output_time_var_{$html_var}")){ |
|
| 430 | + /** |
|
| 431 | + * Filter the time html by individual custom field. |
|
| 432 | + * |
|
| 433 | + * @param string $html The html to filter. |
|
| 434 | + * @param string $location The location to output the html. |
|
| 435 | + * @param array $cf The custom field array. |
|
| 436 | + * @since 1.6.6 |
|
| 437 | + */ |
|
| 438 | + $html = apply_filters("geodir_custom_field_output_time_var_{$html_var}",$html,$location,$cf); |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + // Check if there is a custom field key specific filter. |
|
| 442 | + if(has_filter("geodir_custom_field_output_time_key_{$cf['field_type_key']}")){ |
|
| 443 | + /** |
|
| 444 | + * Filter the time html by field type key. |
|
| 445 | + * |
|
| 446 | + * @param string $html The html to filter. |
|
| 447 | + * @param string $location The location to output the html. |
|
| 448 | + * @param array $cf The custom field array. |
|
| 449 | + * @since 1.6.6 |
|
| 450 | + */ |
|
| 451 | + $html = apply_filters("geodir_custom_field_output_time_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + // If not html then we run the standard output. |
|
| 455 | + if(empty($html)){ |
|
| 456 | + |
|
| 457 | + if ($post->{$cf['htmlvar_name']}): |
|
| 458 | + |
|
| 459 | + $value = ''; |
|
| 460 | + if ($post->{$cf['htmlvar_name']} != '') |
|
| 461 | + //$value = date('h:i',strtotime($post->{$cf['htmlvar_name']})); |
|
| 462 | + $value = date(get_option('time_format'), strtotime($post->{$cf['htmlvar_name']})); |
|
| 463 | + |
|
| 464 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 465 | + if (strpos($field_icon, 'http') !== false) { |
|
| 466 | + $field_icon_af = ''; |
|
| 467 | + } elseif ($field_icon == '') { |
|
| 468 | + $field_icon_af = '<i class="fa fa-clock-o"></i>'; |
|
| 469 | + } else { |
|
| 470 | + $field_icon_af = $field_icon; |
|
| 471 | + $field_icon = ''; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + |
|
| 475 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; |
|
| 476 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ' '; |
|
| 477 | + $html .= '</span>' . $value . '</div>'; |
|
| 478 | + |
|
| 479 | + endif; |
|
| 480 | + |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + return $html; |
|
| 484 | 484 | } |
| 485 | 485 | add_filter('geodir_custom_field_output_time','geodir_cf_time',10,3); |
| 486 | 486 | |
@@ -496,111 +496,111 @@ discard block |
||
| 496 | 496 | * @return string The html to output for the custom field. |
| 497 | 497 | */ |
| 498 | 498 | function geodir_cf_datepicker($html,$location,$cf,$p=''){ |
| 499 | - global $preview; |
|
| 500 | - // check we have the post value |
|
| 501 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 502 | - else{ global $post;} |
|
| 503 | - |
|
| 504 | - if(!is_array($cf) && $cf!=''){ |
|
| 505 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 506 | - if(!$cf){return NULL;} |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - $html_var = $cf['htmlvar_name']; |
|
| 510 | - |
|
| 511 | - // Check if there is a location specific filter. |
|
| 512 | - if(has_filter("geodir_custom_field_output_datepicker_loc_{$location}")){ |
|
| 513 | - /** |
|
| 514 | - * Filter the datepicker html by location. |
|
| 515 | - * |
|
| 516 | - * @param string $html The html to filter. |
|
| 517 | - * @param array $cf The custom field array. |
|
| 518 | - * @since 1.6.6 |
|
| 519 | - */ |
|
| 520 | - $html = apply_filters("geodir_custom_field_output_datepicker_loc_{$location}",$html,$cf); |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - // Check if there is a custom field specific filter. |
|
| 524 | - if(has_filter("geodir_custom_field_output_datepicker_var_{$html_var}")){ |
|
| 525 | - /** |
|
| 526 | - * Filter the datepicker html by individual custom field. |
|
| 527 | - * |
|
| 528 | - * @param string $html The html to filter. |
|
| 529 | - * @param string $location The location to output the html. |
|
| 530 | - * @param array $cf The custom field array. |
|
| 531 | - * @since 1.6.6 |
|
| 532 | - */ |
|
| 533 | - $html = apply_filters("geodir_custom_field_output_datepicker_var_{$html_var}",$html,$location,$cf); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - // Check if there is a custom field key specific filter. |
|
| 537 | - if(has_filter("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}")){ |
|
| 538 | - /** |
|
| 539 | - * Filter the datepicker html by field type key. |
|
| 540 | - * |
|
| 541 | - * @param string $html The html to filter. |
|
| 542 | - * @param string $location The location to output the html. |
|
| 543 | - * @param array $cf The custom field array. |
|
| 544 | - * @since 1.6.6 |
|
| 545 | - */ |
|
| 546 | - $html = apply_filters("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - // If not html then we run the standard output. |
|
| 550 | - if(empty($html)){ |
|
| 551 | - |
|
| 552 | - if ($post->{$cf['htmlvar_name']}): |
|
| 553 | - |
|
| 554 | - $date_format = geodir_default_date_format(); |
|
| 555 | - if ($cf['extra_fields'] != '') { |
|
| 556 | - $date_format = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 557 | - $date_format = $date_format['date_format']; |
|
| 558 | - } |
|
| 559 | - // check if we need to change the format or not |
|
| 560 | - $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
| 561 | - if($date_format_len>5){// if greater then 4 then it's the old style format. |
|
| 562 | - |
|
| 563 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
| 564 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
| 565 | - |
|
| 566 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 567 | - |
|
| 568 | - $post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$cf['htmlvar_name']}) : $post->{$cf['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format |
|
| 569 | - }else{ |
|
| 570 | - $post_htmlvar_value = $post->{$cf['htmlvar_name']}; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - if ($post->{$cf['htmlvar_name']} != '' && $post->{$cf['htmlvar_name']}!="0000-00-00") { |
|
| 574 | - $date_format_from = $preview ? $date_format : 'Y-m-d'; |
|
| 575 | - $value = geodir_date($post_htmlvar_value, $date_format, $date_format_from); // save as sql format Y-m-d |
|
| 576 | - //$post_htmlvar_value = strpos($post_htmlvar_value, '/') !== false ? str_replace('/', '-', $post_htmlvar_value) : $post_htmlvar_value; |
|
| 577 | - //$value = date_i18n($date_format, strtotime($post_htmlvar_value)); |
|
| 578 | - }else{ |
|
| 579 | - return ''; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 583 | - |
|
| 584 | - if (strpos($field_icon, 'http') !== false) { |
|
| 585 | - $field_icon_af = ''; |
|
| 586 | - } elseif ($field_icon == '') { |
|
| 587 | - $field_icon_af = '<i class="fa fa-calendar"></i>'; |
|
| 588 | - } else { |
|
| 589 | - $field_icon_af = $field_icon; |
|
| 590 | - $field_icon = ''; |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - |
|
| 595 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; |
|
| 596 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 597 | - $html .= '</span>' . $value . '</div>'; |
|
| 598 | - |
|
| 599 | - endif; |
|
| 600 | - |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - return $html; |
|
| 499 | + global $preview; |
|
| 500 | + // check we have the post value |
|
| 501 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 502 | + else{ global $post;} |
|
| 503 | + |
|
| 504 | + if(!is_array($cf) && $cf!=''){ |
|
| 505 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 506 | + if(!$cf){return NULL;} |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + $html_var = $cf['htmlvar_name']; |
|
| 510 | + |
|
| 511 | + // Check if there is a location specific filter. |
|
| 512 | + if(has_filter("geodir_custom_field_output_datepicker_loc_{$location}")){ |
|
| 513 | + /** |
|
| 514 | + * Filter the datepicker html by location. |
|
| 515 | + * |
|
| 516 | + * @param string $html The html to filter. |
|
| 517 | + * @param array $cf The custom field array. |
|
| 518 | + * @since 1.6.6 |
|
| 519 | + */ |
|
| 520 | + $html = apply_filters("geodir_custom_field_output_datepicker_loc_{$location}",$html,$cf); |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + // Check if there is a custom field specific filter. |
|
| 524 | + if(has_filter("geodir_custom_field_output_datepicker_var_{$html_var}")){ |
|
| 525 | + /** |
|
| 526 | + * Filter the datepicker html by individual custom field. |
|
| 527 | + * |
|
| 528 | + * @param string $html The html to filter. |
|
| 529 | + * @param string $location The location to output the html. |
|
| 530 | + * @param array $cf The custom field array. |
|
| 531 | + * @since 1.6.6 |
|
| 532 | + */ |
|
| 533 | + $html = apply_filters("geodir_custom_field_output_datepicker_var_{$html_var}",$html,$location,$cf); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + // Check if there is a custom field key specific filter. |
|
| 537 | + if(has_filter("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}")){ |
|
| 538 | + /** |
|
| 539 | + * Filter the datepicker html by field type key. |
|
| 540 | + * |
|
| 541 | + * @param string $html The html to filter. |
|
| 542 | + * @param string $location The location to output the html. |
|
| 543 | + * @param array $cf The custom field array. |
|
| 544 | + * @since 1.6.6 |
|
| 545 | + */ |
|
| 546 | + $html = apply_filters("geodir_custom_field_output_datepicker_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + // If not html then we run the standard output. |
|
| 550 | + if(empty($html)){ |
|
| 551 | + |
|
| 552 | + if ($post->{$cf['htmlvar_name']}): |
|
| 553 | + |
|
| 554 | + $date_format = geodir_default_date_format(); |
|
| 555 | + if ($cf['extra_fields'] != '') { |
|
| 556 | + $date_format = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 557 | + $date_format = $date_format['date_format']; |
|
| 558 | + } |
|
| 559 | + // check if we need to change the format or not |
|
| 560 | + $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
| 561 | + if($date_format_len>5){// if greater then 4 then it's the old style format. |
|
| 562 | + |
|
| 563 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
| 564 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
| 565 | + |
|
| 566 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 567 | + |
|
| 568 | + $post_htmlvar_value = ($date_format == 'd/m/Y' || $date_format == 'j/n/Y' ) ? str_replace('/', '-', $post->{$cf['htmlvar_name']}) : $post->{$cf['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format |
|
| 569 | + }else{ |
|
| 570 | + $post_htmlvar_value = $post->{$cf['htmlvar_name']}; |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + if ($post->{$cf['htmlvar_name']} != '' && $post->{$cf['htmlvar_name']}!="0000-00-00") { |
|
| 574 | + $date_format_from = $preview ? $date_format : 'Y-m-d'; |
|
| 575 | + $value = geodir_date($post_htmlvar_value, $date_format, $date_format_from); // save as sql format Y-m-d |
|
| 576 | + //$post_htmlvar_value = strpos($post_htmlvar_value, '/') !== false ? str_replace('/', '-', $post_htmlvar_value) : $post_htmlvar_value; |
|
| 577 | + //$value = date_i18n($date_format, strtotime($post_htmlvar_value)); |
|
| 578 | + }else{ |
|
| 579 | + return ''; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 583 | + |
|
| 584 | + if (strpos($field_icon, 'http') !== false) { |
|
| 585 | + $field_icon_af = ''; |
|
| 586 | + } elseif ($field_icon == '') { |
|
| 587 | + $field_icon_af = '<i class="fa fa-calendar"></i>'; |
|
| 588 | + } else { |
|
| 589 | + $field_icon_af = $field_icon; |
|
| 590 | + $field_icon = ''; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + |
|
| 595 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; |
|
| 596 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 597 | + $html .= '</span>' . $value . '</div>'; |
|
| 598 | + |
|
| 599 | + endif; |
|
| 600 | + |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + return $html; |
|
| 604 | 604 | } |
| 605 | 605 | add_filter('geodir_custom_field_output_datepicker','geodir_cf_datepicker',10,3); |
| 606 | 606 | |
@@ -617,97 +617,97 @@ discard block |
||
| 617 | 617 | */ |
| 618 | 618 | function geodir_cf_text($html,$location,$cf,$p=''){ |
| 619 | 619 | |
| 620 | - // check we have the post value |
|
| 621 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 622 | - else{ global $post;} |
|
| 623 | - |
|
| 624 | - if(!is_array($cf) && $cf!=''){ |
|
| 625 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 626 | - if(!$cf){return NULL;} |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - $html_var = $cf['htmlvar_name']; |
|
| 630 | - |
|
| 631 | - // Check if there is a location specific filter. |
|
| 632 | - if(has_filter("geodir_custom_field_output_text_loc_{$location}")){ |
|
| 633 | - /** |
|
| 634 | - * Filter the text html by location. |
|
| 635 | - * |
|
| 636 | - * @param string $html The html to filter. |
|
| 637 | - * @param array $cf The custom field array. |
|
| 638 | - * @since 1.6.6 |
|
| 639 | - */ |
|
| 640 | - $html = apply_filters("geodir_custom_field_output_text_loc_{$location}",$html,$cf); |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - // Check if there is a custom field specific filter. |
|
| 644 | - if(has_filter("geodir_custom_field_output_text_var_{$html_var}")){ |
|
| 645 | - /** |
|
| 646 | - * Filter the text html by individual custom field. |
|
| 647 | - * |
|
| 648 | - * @param string $html The html to filter. |
|
| 649 | - * @param string $location The location to output the html. |
|
| 650 | - * @param array $cf The custom field array. |
|
| 651 | - * @since 1.6.6 |
|
| 652 | - */ |
|
| 653 | - $html = apply_filters("geodir_custom_field_output_text_var_{$html_var}",$html,$location,$cf); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - // Check if there is a custom field key specific filter. |
|
| 657 | - if(has_filter("geodir_custom_field_output_text_key_{$cf['field_type_key']}")){ |
|
| 658 | - /** |
|
| 659 | - * Filter the text html by field type key. |
|
| 660 | - * |
|
| 661 | - * @param string $html The html to filter. |
|
| 662 | - * @param string $location The location to output the html. |
|
| 663 | - * @param array $cf The custom field array. |
|
| 664 | - * @since 1.6.6 |
|
| 665 | - */ |
|
| 666 | - $html = apply_filters("geodir_custom_field_output_text_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 667 | - } |
|
| 620 | + // check we have the post value |
|
| 621 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 622 | + else{ global $post;} |
|
| 623 | + |
|
| 624 | + if(!is_array($cf) && $cf!=''){ |
|
| 625 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 626 | + if(!$cf){return NULL;} |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + $html_var = $cf['htmlvar_name']; |
|
| 630 | + |
|
| 631 | + // Check if there is a location specific filter. |
|
| 632 | + if(has_filter("geodir_custom_field_output_text_loc_{$location}")){ |
|
| 633 | + /** |
|
| 634 | + * Filter the text html by location. |
|
| 635 | + * |
|
| 636 | + * @param string $html The html to filter. |
|
| 637 | + * @param array $cf The custom field array. |
|
| 638 | + * @since 1.6.6 |
|
| 639 | + */ |
|
| 640 | + $html = apply_filters("geodir_custom_field_output_text_loc_{$location}",$html,$cf); |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + // Check if there is a custom field specific filter. |
|
| 644 | + if(has_filter("geodir_custom_field_output_text_var_{$html_var}")){ |
|
| 645 | + /** |
|
| 646 | + * Filter the text html by individual custom field. |
|
| 647 | + * |
|
| 648 | + * @param string $html The html to filter. |
|
| 649 | + * @param string $location The location to output the html. |
|
| 650 | + * @param array $cf The custom field array. |
|
| 651 | + * @since 1.6.6 |
|
| 652 | + */ |
|
| 653 | + $html = apply_filters("geodir_custom_field_output_text_var_{$html_var}",$html,$location,$cf); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + // Check if there is a custom field key specific filter. |
|
| 657 | + if(has_filter("geodir_custom_field_output_text_key_{$cf['field_type_key']}")){ |
|
| 658 | + /** |
|
| 659 | + * Filter the text html by field type key. |
|
| 660 | + * |
|
| 661 | + * @param string $html The html to filter. |
|
| 662 | + * @param string $location The location to output the html. |
|
| 663 | + * @param array $cf The custom field array. |
|
| 664 | + * @since 1.6.6 |
|
| 665 | + */ |
|
| 666 | + $html = apply_filters("geodir_custom_field_output_text_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | |
| 670 | 670 | |
| 671 | - // If not html then we run the standard output. |
|
| 672 | - if(empty($html)){ |
|
| 671 | + // If not html then we run the standard output. |
|
| 672 | + if(empty($html)){ |
|
| 673 | 673 | |
| 674 | - if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != '' ): |
|
| 674 | + if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != '' ): |
|
| 675 | 675 | |
| 676 | - $class = ($cf['htmlvar_name'] == 'geodir_timing') ? "geodir-i-time" : "geodir-i-text"; |
|
| 676 | + $class = ($cf['htmlvar_name'] == 'geodir_timing') ? "geodir-i-time" : "geodir-i-text"; |
|
| 677 | 677 | |
| 678 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 679 | - if (strpos($field_icon, 'http') !== false) { |
|
| 680 | - $field_icon_af = ''; |
|
| 681 | - } elseif ($field_icon == '') { |
|
| 682 | - $field_icon_af = ($cf['htmlvar_name'] == 'geodir_timing') ? '<i class="fa fa-clock-o"></i>' : ""; |
|
| 683 | - } else { |
|
| 684 | - $field_icon_af = $field_icon; |
|
| 685 | - $field_icon = ''; |
|
| 686 | - } |
|
| 678 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 679 | + if (strpos($field_icon, 'http') !== false) { |
|
| 680 | + $field_icon_af = ''; |
|
| 681 | + } elseif ($field_icon == '') { |
|
| 682 | + $field_icon_af = ($cf['htmlvar_name'] == 'geodir_timing') ? '<i class="fa fa-clock-o"></i>' : ""; |
|
| 683 | + } else { |
|
| 684 | + $field_icon_af = $field_icon; |
|
| 685 | + $field_icon = ''; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | 688 | |
| 689 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="'.$class.'" style="' . $field_icon . '">' . $field_icon_af; |
|
| 690 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 691 | - $html .= '</span>'; |
|
| 689 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="'.$class.'" style="' . $field_icon . '">' . $field_icon_af; |
|
| 690 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 691 | + $html .= '</span>'; |
|
| 692 | 692 | |
| 693 | - $value = $post->{$cf['htmlvar_name']}; |
|
| 694 | - if(isset($cf['data_type']) && ($cf['data_type']=='INT' || $cf['data_type']=='FLOAT') && isset($cf['extra_fields']) && $cf['extra_fields']){ |
|
| 695 | - $extra_fields = stripslashes_deep(maybe_unserialize($cf['extra_fields'])); |
|
| 696 | - if(isset($extra_fields['is_price']) && $extra_fields['is_price']){ |
|
| 697 | - if(!ceil($value) > 0){return '';}// dont output blank prices |
|
| 698 | - $value = geodir_currency_format_number($value,$cf); |
|
| 699 | - } |
|
| 700 | - } |
|
| 693 | + $value = $post->{$cf['htmlvar_name']}; |
|
| 694 | + if(isset($cf['data_type']) && ($cf['data_type']=='INT' || $cf['data_type']=='FLOAT') && isset($cf['extra_fields']) && $cf['extra_fields']){ |
|
| 695 | + $extra_fields = stripslashes_deep(maybe_unserialize($cf['extra_fields'])); |
|
| 696 | + if(isset($extra_fields['is_price']) && $extra_fields['is_price']){ |
|
| 697 | + if(!ceil($value) > 0){return '';}// dont output blank prices |
|
| 698 | + $value = geodir_currency_format_number($value,$cf); |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | 702 | |
| 703 | - $html .= $value; |
|
| 704 | - $html .= '</div>'; |
|
| 703 | + $html .= $value; |
|
| 704 | + $html .= '</div>'; |
|
| 705 | 705 | |
| 706 | - endif; |
|
| 706 | + endif; |
|
| 707 | 707 | |
| 708 | - } |
|
| 708 | + } |
|
| 709 | 709 | |
| 710 | - return $html; |
|
| 710 | + return $html; |
|
| 711 | 711 | } |
| 712 | 712 | add_filter('geodir_custom_field_output_text','geodir_cf_text',10,3); |
| 713 | 713 | |
@@ -724,98 +724,98 @@ discard block |
||
| 724 | 724 | */ |
| 725 | 725 | function geodir_cf_radio($html,$location,$cf,$p=''){ |
| 726 | 726 | |
| 727 | - // check we have the post value |
|
| 728 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 729 | - else{ global $post;} |
|
| 730 | - |
|
| 731 | - if(!is_array($cf) && $cf!=''){ |
|
| 732 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 733 | - if(!$cf){return NULL;} |
|
| 734 | - } |
|
| 735 | - |
|
| 736 | - $html_var = $cf['htmlvar_name']; |
|
| 737 | - |
|
| 738 | - // Check if there is a location specific filter. |
|
| 739 | - if(has_filter("geodir_custom_field_output_radio_loc_{$location}")){ |
|
| 740 | - /** |
|
| 741 | - * Filter the radio html by location. |
|
| 742 | - * |
|
| 743 | - * @param string $html The html to filter. |
|
| 744 | - * @param array $cf The custom field array. |
|
| 745 | - * @since 1.6.6 |
|
| 746 | - */ |
|
| 747 | - $html = apply_filters("geodir_custom_field_output_radio_loc_{$location}",$html,$cf); |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - // Check if there is a custom field specific filter. |
|
| 751 | - if(has_filter("geodir_custom_field_output_radio_var_{$html_var}")){ |
|
| 752 | - /** |
|
| 753 | - * Filter the radio html by individual custom field. |
|
| 754 | - * |
|
| 755 | - * @param string $html The html to filter. |
|
| 756 | - * @param string $location The location to output the html. |
|
| 757 | - * @param array $cf The custom field array. |
|
| 758 | - * @since 1.6.6 |
|
| 759 | - */ |
|
| 760 | - $html = apply_filters("geodir_custom_field_output_radio_var_{$html_var}",$html,$location,$cf); |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - // Check if there is a custom field key specific filter. |
|
| 764 | - if(has_filter("geodir_custom_field_output_radio_key_{$cf['field_type_key']}")){ |
|
| 765 | - /** |
|
| 766 | - * Filter the radio html by field type key. |
|
| 767 | - * |
|
| 768 | - * @param string $html The html to filter. |
|
| 769 | - * @param string $location The location to output the html. |
|
| 770 | - * @param array $cf The custom field array. |
|
| 771 | - * @since 1.6.6 |
|
| 772 | - */ |
|
| 773 | - $html = apply_filters("geodir_custom_field_output_radio_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - // If not html then we run the standard output. |
|
| 777 | - if(empty($html)){ |
|
| 778 | - |
|
| 779 | - $html_val = isset($post->{$cf['htmlvar_name']}) ? __($post->{$cf['htmlvar_name']}, 'geodirectory') : ''; |
|
| 780 | - if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != ''): |
|
| 781 | - |
|
| 782 | - if ($post->{$cf['htmlvar_name']} == 'f' || $post->{$cf['htmlvar_name']} == '0') { |
|
| 783 | - $html_val = __('No', 'geodirectory'); |
|
| 784 | - } else if ($post->{$cf['htmlvar_name']} == 't' || $post->{$cf['htmlvar_name']} == '1') { |
|
| 785 | - $html_val = __('Yes', 'geodirectory'); |
|
| 786 | - } else { |
|
| 787 | - if (!empty($cf['option_values'])) { |
|
| 788 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 789 | - |
|
| 790 | - if (!empty($cf_option_values)) { |
|
| 791 | - foreach ($cf_option_values as $cf_option_value) { |
|
| 792 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) { |
|
| 793 | - $html_val = $cf_option_value['label']; |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - } |
|
| 797 | - } |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 801 | - if (strpos($field_icon, 'http') !== false) { |
|
| 802 | - $field_icon_af = ''; |
|
| 803 | - } elseif ($field_icon == '') { |
|
| 804 | - $field_icon_af = ''; |
|
| 805 | - } else { |
|
| 806 | - $field_icon_af = $field_icon; |
|
| 807 | - $field_icon = ''; |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - |
|
| 811 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; |
|
| 812 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 813 | - $html .= '</span>' . $html_val . '</div>'; |
|
| 814 | - endif; |
|
| 815 | - |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - return $html; |
|
| 727 | + // check we have the post value |
|
| 728 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 729 | + else{ global $post;} |
|
| 730 | + |
|
| 731 | + if(!is_array($cf) && $cf!=''){ |
|
| 732 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 733 | + if(!$cf){return NULL;} |
|
| 734 | + } |
|
| 735 | + |
|
| 736 | + $html_var = $cf['htmlvar_name']; |
|
| 737 | + |
|
| 738 | + // Check if there is a location specific filter. |
|
| 739 | + if(has_filter("geodir_custom_field_output_radio_loc_{$location}")){ |
|
| 740 | + /** |
|
| 741 | + * Filter the radio html by location. |
|
| 742 | + * |
|
| 743 | + * @param string $html The html to filter. |
|
| 744 | + * @param array $cf The custom field array. |
|
| 745 | + * @since 1.6.6 |
|
| 746 | + */ |
|
| 747 | + $html = apply_filters("geodir_custom_field_output_radio_loc_{$location}",$html,$cf); |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + // Check if there is a custom field specific filter. |
|
| 751 | + if(has_filter("geodir_custom_field_output_radio_var_{$html_var}")){ |
|
| 752 | + /** |
|
| 753 | + * Filter the radio html by individual custom field. |
|
| 754 | + * |
|
| 755 | + * @param string $html The html to filter. |
|
| 756 | + * @param string $location The location to output the html. |
|
| 757 | + * @param array $cf The custom field array. |
|
| 758 | + * @since 1.6.6 |
|
| 759 | + */ |
|
| 760 | + $html = apply_filters("geodir_custom_field_output_radio_var_{$html_var}",$html,$location,$cf); |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + // Check if there is a custom field key specific filter. |
|
| 764 | + if(has_filter("geodir_custom_field_output_radio_key_{$cf['field_type_key']}")){ |
|
| 765 | + /** |
|
| 766 | + * Filter the radio html by field type key. |
|
| 767 | + * |
|
| 768 | + * @param string $html The html to filter. |
|
| 769 | + * @param string $location The location to output the html. |
|
| 770 | + * @param array $cf The custom field array. |
|
| 771 | + * @since 1.6.6 |
|
| 772 | + */ |
|
| 773 | + $html = apply_filters("geodir_custom_field_output_radio_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + // If not html then we run the standard output. |
|
| 777 | + if(empty($html)){ |
|
| 778 | + |
|
| 779 | + $html_val = isset($post->{$cf['htmlvar_name']}) ? __($post->{$cf['htmlvar_name']}, 'geodirectory') : ''; |
|
| 780 | + if (isset($post->{$cf['htmlvar_name']}) && $post->{$cf['htmlvar_name']} != ''): |
|
| 781 | + |
|
| 782 | + if ($post->{$cf['htmlvar_name']} == 'f' || $post->{$cf['htmlvar_name']} == '0') { |
|
| 783 | + $html_val = __('No', 'geodirectory'); |
|
| 784 | + } else if ($post->{$cf['htmlvar_name']} == 't' || $post->{$cf['htmlvar_name']} == '1') { |
|
| 785 | + $html_val = __('Yes', 'geodirectory'); |
|
| 786 | + } else { |
|
| 787 | + if (!empty($cf['option_values'])) { |
|
| 788 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 789 | + |
|
| 790 | + if (!empty($cf_option_values)) { |
|
| 791 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 792 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) { |
|
| 793 | + $html_val = $cf_option_value['label']; |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + } |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 801 | + if (strpos($field_icon, 'http') !== false) { |
|
| 802 | + $field_icon_af = ''; |
|
| 803 | + } elseif ($field_icon == '') { |
|
| 804 | + $field_icon_af = ''; |
|
| 805 | + } else { |
|
| 806 | + $field_icon_af = $field_icon; |
|
| 807 | + $field_icon = ''; |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + |
|
| 811 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; |
|
| 812 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 813 | + $html .= '</span>' . $html_val . '</div>'; |
|
| 814 | + endif; |
|
| 815 | + |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + return $html; |
|
| 819 | 819 | } |
| 820 | 820 | add_filter('geodir_custom_field_output_radio','geodir_cf_radio',10,3); |
| 821 | 821 | |
@@ -833,92 +833,92 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | function geodir_cf_select($html,$location,$cf,$p=''){ |
| 835 | 835 | |
| 836 | - // check we have the post value |
|
| 837 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 838 | - else{ global $post;} |
|
| 839 | - |
|
| 840 | - if(!is_array($cf) && $cf!=''){ |
|
| 841 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 842 | - if(!$cf){return NULL;} |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - $html_var = $cf['htmlvar_name']; |
|
| 846 | - |
|
| 847 | - // Check if there is a location specific filter. |
|
| 848 | - if(has_filter("geodir_custom_field_output_select_loc_{$location}")){ |
|
| 849 | - /** |
|
| 850 | - * Filter the select html by location. |
|
| 851 | - * |
|
| 852 | - * @param string $html The html to filter. |
|
| 853 | - * @param array $cf The custom field array. |
|
| 854 | - * @since 1.6.6 |
|
| 855 | - */ |
|
| 856 | - $html = apply_filters("geodir_custom_field_output_select_loc_{$location}",$html,$cf); |
|
| 857 | - } |
|
| 858 | - |
|
| 859 | - // Check if there is a custom field specific filter. |
|
| 860 | - if(has_filter("geodir_custom_field_output_select_var_{$html_var}")){ |
|
| 861 | - /** |
|
| 862 | - * Filter the select html by individual custom field. |
|
| 863 | - * |
|
| 864 | - * @param string $html The html to filter. |
|
| 865 | - * @param string $location The location to output the html. |
|
| 866 | - * @param array $cf The custom field array. |
|
| 867 | - * @since 1.6.6 |
|
| 868 | - */ |
|
| 869 | - $html = apply_filters("geodir_custom_field_output_select_var_{$html_var}",$html,$location,$cf); |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - // Check if there is a custom field key specific filter. |
|
| 873 | - if(has_filter("geodir_custom_field_output_select_key_{$cf['field_type_key']}")){ |
|
| 874 | - /** |
|
| 875 | - * Filter the select html by field type key. |
|
| 876 | - * |
|
| 877 | - * @param string $html The html to filter. |
|
| 878 | - * @param string $location The location to output the html. |
|
| 879 | - * @param array $cf The custom field array. |
|
| 880 | - * @since 1.6.6 |
|
| 881 | - */ |
|
| 882 | - $html = apply_filters("geodir_custom_field_output_select_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 883 | - } |
|
| 884 | - |
|
| 885 | - // If not html then we run the standard output. |
|
| 886 | - if(empty($html)){ |
|
| 887 | - |
|
| 888 | - if ($post->{$cf['htmlvar_name']}): |
|
| 889 | - $field_value = __($post->{$cf['htmlvar_name']}, 'geodirectory'); |
|
| 890 | - |
|
| 891 | - if (!empty($cf['option_values'])) { |
|
| 892 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 893 | - |
|
| 894 | - if (!empty($cf_option_values)) { |
|
| 895 | - foreach ($cf_option_values as $cf_option_value) { |
|
| 896 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) { |
|
| 897 | - $field_value = $cf_option_value['label']; // no longer needed here. Removed comment because it displays number instead of label if option vales set like "Good/1,Fair/2". |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - } |
|
| 901 | - } |
|
| 902 | - |
|
| 903 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 904 | - if (strpos($field_icon, 'http') !== false) { |
|
| 905 | - $field_icon_af = ''; |
|
| 906 | - } elseif ($field_icon == '') { |
|
| 907 | - $field_icon_af = ''; |
|
| 908 | - } else { |
|
| 909 | - $field_icon_af = $field_icon; |
|
| 910 | - $field_icon = ''; |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - |
|
| 914 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 915 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 916 | - $html .= '</span>' . $field_value . '</div>'; |
|
| 917 | - endif; |
|
| 918 | - |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - return $html; |
|
| 836 | + // check we have the post value |
|
| 837 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 838 | + else{ global $post;} |
|
| 839 | + |
|
| 840 | + if(!is_array($cf) && $cf!=''){ |
|
| 841 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 842 | + if(!$cf){return NULL;} |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + $html_var = $cf['htmlvar_name']; |
|
| 846 | + |
|
| 847 | + // Check if there is a location specific filter. |
|
| 848 | + if(has_filter("geodir_custom_field_output_select_loc_{$location}")){ |
|
| 849 | + /** |
|
| 850 | + * Filter the select html by location. |
|
| 851 | + * |
|
| 852 | + * @param string $html The html to filter. |
|
| 853 | + * @param array $cf The custom field array. |
|
| 854 | + * @since 1.6.6 |
|
| 855 | + */ |
|
| 856 | + $html = apply_filters("geodir_custom_field_output_select_loc_{$location}",$html,$cf); |
|
| 857 | + } |
|
| 858 | + |
|
| 859 | + // Check if there is a custom field specific filter. |
|
| 860 | + if(has_filter("geodir_custom_field_output_select_var_{$html_var}")){ |
|
| 861 | + /** |
|
| 862 | + * Filter the select html by individual custom field. |
|
| 863 | + * |
|
| 864 | + * @param string $html The html to filter. |
|
| 865 | + * @param string $location The location to output the html. |
|
| 866 | + * @param array $cf The custom field array. |
|
| 867 | + * @since 1.6.6 |
|
| 868 | + */ |
|
| 869 | + $html = apply_filters("geodir_custom_field_output_select_var_{$html_var}",$html,$location,$cf); |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + // Check if there is a custom field key specific filter. |
|
| 873 | + if(has_filter("geodir_custom_field_output_select_key_{$cf['field_type_key']}")){ |
|
| 874 | + /** |
|
| 875 | + * Filter the select html by field type key. |
|
| 876 | + * |
|
| 877 | + * @param string $html The html to filter. |
|
| 878 | + * @param string $location The location to output the html. |
|
| 879 | + * @param array $cf The custom field array. |
|
| 880 | + * @since 1.6.6 |
|
| 881 | + */ |
|
| 882 | + $html = apply_filters("geodir_custom_field_output_select_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 883 | + } |
|
| 884 | + |
|
| 885 | + // If not html then we run the standard output. |
|
| 886 | + if(empty($html)){ |
|
| 887 | + |
|
| 888 | + if ($post->{$cf['htmlvar_name']}): |
|
| 889 | + $field_value = __($post->{$cf['htmlvar_name']}, 'geodirectory'); |
|
| 890 | + |
|
| 891 | + if (!empty($cf['option_values'])) { |
|
| 892 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 893 | + |
|
| 894 | + if (!empty($cf_option_values)) { |
|
| 895 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 896 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$cf['htmlvar_name']}) { |
|
| 897 | + $field_value = $cf_option_value['label']; // no longer needed here. Removed comment because it displays number instead of label if option vales set like "Good/1,Fair/2". |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + } |
|
| 901 | + } |
|
| 902 | + |
|
| 903 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 904 | + if (strpos($field_icon, 'http') !== false) { |
|
| 905 | + $field_icon_af = ''; |
|
| 906 | + } elseif ($field_icon == '') { |
|
| 907 | + $field_icon_af = ''; |
|
| 908 | + } else { |
|
| 909 | + $field_icon_af = $field_icon; |
|
| 910 | + $field_icon = ''; |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + |
|
| 914 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 915 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 916 | + $html .= '</span>' . $field_value . '</div>'; |
|
| 917 | + endif; |
|
| 918 | + |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + return $html; |
|
| 922 | 922 | } |
| 923 | 923 | add_filter('geodir_custom_field_output_select','geodir_cf_select',10,3); |
| 924 | 924 | |
@@ -935,117 +935,117 @@ discard block |
||
| 935 | 935 | */ |
| 936 | 936 | function geodir_cf_multiselect($html,$location,$cf,$p=''){ |
| 937 | 937 | |
| 938 | - // check we have the post value |
|
| 939 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 940 | - else{ global $post;} |
|
| 941 | - |
|
| 942 | - if(!is_array($cf) && $cf!=''){ |
|
| 943 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 944 | - if(!$cf){return NULL;} |
|
| 945 | - } |
|
| 946 | - |
|
| 947 | - $html_var = $cf['htmlvar_name']; |
|
| 948 | - |
|
| 949 | - // Check if there is a location specific filter. |
|
| 950 | - if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){ |
|
| 951 | - /** |
|
| 952 | - * Filter the multiselect html by location. |
|
| 953 | - * |
|
| 954 | - * @param string $html The html to filter. |
|
| 955 | - * @param array $cf The custom field array. |
|
| 956 | - * @since 1.6.6 |
|
| 957 | - */ |
|
| 958 | - $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf); |
|
| 959 | - } |
|
| 960 | - |
|
| 961 | - // Check if there is a custom field specific filter. |
|
| 962 | - if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){ |
|
| 963 | - /** |
|
| 964 | - * Filter the multiselect html by individual custom field. |
|
| 965 | - * |
|
| 966 | - * @param string $html The html to filter. |
|
| 967 | - * @param string $location The location to output the html. |
|
| 968 | - * @param array $cf The custom field array. |
|
| 969 | - * @since 1.6.6 |
|
| 970 | - */ |
|
| 971 | - $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf); |
|
| 972 | - } |
|
| 973 | - |
|
| 974 | - // Check if there is a custom field key specific filter. |
|
| 975 | - if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){ |
|
| 976 | - /** |
|
| 977 | - * Filter the multiselect html by field type key. |
|
| 978 | - * |
|
| 979 | - * @param string $html The html to filter. |
|
| 980 | - * @param string $location The location to output the html. |
|
| 981 | - * @param array $cf The custom field array. |
|
| 982 | - * @since 1.6.6 |
|
| 983 | - */ |
|
| 984 | - $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 985 | - } |
|
| 986 | - |
|
| 987 | - // If not html then we run the standard output. |
|
| 988 | - if(empty($html)){ |
|
| 989 | - |
|
| 990 | - |
|
| 991 | - if (!empty($post->{$cf['htmlvar_name']})): |
|
| 992 | - |
|
| 993 | - if (is_array($post->{$cf['htmlvar_name']})) { |
|
| 994 | - $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']}); |
|
| 995 | - } |
|
| 996 | - |
|
| 997 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 998 | - if (strpos($field_icon, 'http') !== false) { |
|
| 999 | - $field_icon_af = ''; |
|
| 1000 | - } elseif ($field_icon == '') { |
|
| 1001 | - $field_icon_af = ''; |
|
| 1002 | - } else { |
|
| 1003 | - $field_icon_af = $field_icon; |
|
| 1004 | - $field_icon = ''; |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ",")); |
|
| 1008 | - |
|
| 1009 | - if(is_array($field_values)){ |
|
| 1010 | - $field_values = array_map('trim', $field_values); |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - $option_values = array(); |
|
| 1014 | - if (!empty($cf['option_values'])) { |
|
| 1015 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 1016 | - |
|
| 1017 | - if (!empty($cf_option_values)) { |
|
| 1018 | - foreach ($cf_option_values as $cf_option_value) { |
|
| 1019 | - if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) { |
|
| 1020 | - $option_values[] = $cf_option_value['label']; |
|
| 1021 | - } |
|
| 1022 | - } |
|
| 1023 | - } |
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - |
|
| 1027 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1028 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1029 | - $html .= '</span>'; |
|
| 1030 | - |
|
| 1031 | - if (count($option_values) > 1) { |
|
| 1032 | - $html .= '<ul>'; |
|
| 1033 | - |
|
| 1034 | - foreach ($option_values as $val) { |
|
| 1035 | - $html .= '<li>' . $val . '</li>'; |
|
| 1036 | - } |
|
| 1037 | - |
|
| 1038 | - $html .= '</ul>'; |
|
| 1039 | - } else { |
|
| 1040 | - $html .= __($post->{$cf['htmlvar_name']}, 'geodirectory'); |
|
| 1041 | - } |
|
| 1042 | - |
|
| 1043 | - $html .= '</div>'; |
|
| 1044 | - endif; |
|
| 1045 | - |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - return $html; |
|
| 938 | + // check we have the post value |
|
| 939 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 940 | + else{ global $post;} |
|
| 941 | + |
|
| 942 | + if(!is_array($cf) && $cf!=''){ |
|
| 943 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 944 | + if(!$cf){return NULL;} |
|
| 945 | + } |
|
| 946 | + |
|
| 947 | + $html_var = $cf['htmlvar_name']; |
|
| 948 | + |
|
| 949 | + // Check if there is a location specific filter. |
|
| 950 | + if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){ |
|
| 951 | + /** |
|
| 952 | + * Filter the multiselect html by location. |
|
| 953 | + * |
|
| 954 | + * @param string $html The html to filter. |
|
| 955 | + * @param array $cf The custom field array. |
|
| 956 | + * @since 1.6.6 |
|
| 957 | + */ |
|
| 958 | + $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf); |
|
| 959 | + } |
|
| 960 | + |
|
| 961 | + // Check if there is a custom field specific filter. |
|
| 962 | + if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){ |
|
| 963 | + /** |
|
| 964 | + * Filter the multiselect html by individual custom field. |
|
| 965 | + * |
|
| 966 | + * @param string $html The html to filter. |
|
| 967 | + * @param string $location The location to output the html. |
|
| 968 | + * @param array $cf The custom field array. |
|
| 969 | + * @since 1.6.6 |
|
| 970 | + */ |
|
| 971 | + $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf); |
|
| 972 | + } |
|
| 973 | + |
|
| 974 | + // Check if there is a custom field key specific filter. |
|
| 975 | + if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){ |
|
| 976 | + /** |
|
| 977 | + * Filter the multiselect html by field type key. |
|
| 978 | + * |
|
| 979 | + * @param string $html The html to filter. |
|
| 980 | + * @param string $location The location to output the html. |
|
| 981 | + * @param array $cf The custom field array. |
|
| 982 | + * @since 1.6.6 |
|
| 983 | + */ |
|
| 984 | + $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + // If not html then we run the standard output. |
|
| 988 | + if(empty($html)){ |
|
| 989 | + |
|
| 990 | + |
|
| 991 | + if (!empty($post->{$cf['htmlvar_name']})): |
|
| 992 | + |
|
| 993 | + if (is_array($post->{$cf['htmlvar_name']})) { |
|
| 994 | + $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']}); |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 998 | + if (strpos($field_icon, 'http') !== false) { |
|
| 999 | + $field_icon_af = ''; |
|
| 1000 | + } elseif ($field_icon == '') { |
|
| 1001 | + $field_icon_af = ''; |
|
| 1002 | + } else { |
|
| 1003 | + $field_icon_af = $field_icon; |
|
| 1004 | + $field_icon = ''; |
|
| 1005 | + } |
|
| 1006 | + |
|
| 1007 | + $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ",")); |
|
| 1008 | + |
|
| 1009 | + if(is_array($field_values)){ |
|
| 1010 | + $field_values = array_map('trim', $field_values); |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + $option_values = array(); |
|
| 1014 | + if (!empty($cf['option_values'])) { |
|
| 1015 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true); |
|
| 1016 | + |
|
| 1017 | + if (!empty($cf_option_values)) { |
|
| 1018 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 1019 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) { |
|
| 1020 | + $option_values[] = $cf_option_value['label']; |
|
| 1021 | + } |
|
| 1022 | + } |
|
| 1023 | + } |
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + |
|
| 1027 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1028 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1029 | + $html .= '</span>'; |
|
| 1030 | + |
|
| 1031 | + if (count($option_values) > 1) { |
|
| 1032 | + $html .= '<ul>'; |
|
| 1033 | + |
|
| 1034 | + foreach ($option_values as $val) { |
|
| 1035 | + $html .= '<li>' . $val . '</li>'; |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + $html .= '</ul>'; |
|
| 1039 | + } else { |
|
| 1040 | + $html .= __($post->{$cf['htmlvar_name']}, 'geodirectory'); |
|
| 1041 | + } |
|
| 1042 | + |
|
| 1043 | + $html .= '</div>'; |
|
| 1044 | + endif; |
|
| 1045 | + |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + return $html; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | add_filter('geodir_custom_field_output_multiselect','geodir_cf_multiselect',10,3); |
| 1051 | 1051 | |
@@ -1062,148 +1062,148 @@ discard block |
||
| 1062 | 1062 | */ |
| 1063 | 1063 | function geodir_cf_email($html,$location,$cf,$p=''){ |
| 1064 | 1064 | |
| 1065 | - // check we have the post value |
|
| 1066 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1067 | - else{ global $post;} |
|
| 1068 | - |
|
| 1069 | - if(!is_array($cf) && $cf!=''){ |
|
| 1070 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1071 | - if(!$cf){return NULL;} |
|
| 1072 | - } |
|
| 1073 | - |
|
| 1074 | - $html_var = $cf['htmlvar_name']; |
|
| 1075 | - |
|
| 1076 | - // Check if there is a location specific filter. |
|
| 1077 | - if(has_filter("geodir_custom_field_output_email_loc_{$location}")){ |
|
| 1078 | - /** |
|
| 1079 | - * Filter the email html by location. |
|
| 1080 | - * |
|
| 1081 | - * @param string $html The html to filter. |
|
| 1082 | - * @param array $cf The custom field array. |
|
| 1083 | - * @since 1.6.6 |
|
| 1084 | - */ |
|
| 1085 | - $html = apply_filters("geodir_custom_field_output_email_loc_{$location}",$html,$cf); |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - // Check if there is a custom field specific filter. |
|
| 1089 | - if(has_filter("geodir_custom_field_output_email_var_{$html_var}")){ |
|
| 1090 | - /** |
|
| 1091 | - * Filter the email html by individual custom field. |
|
| 1092 | - * |
|
| 1093 | - * @param string $html The html to filter. |
|
| 1094 | - * @param string $location The location to output the html. |
|
| 1095 | - * @param array $cf The custom field array. |
|
| 1096 | - * @since 1.6.6 |
|
| 1097 | - */ |
|
| 1098 | - $html = apply_filters("geodir_custom_field_output_email_var_{$html_var}",$html,$location,$cf); |
|
| 1099 | - } |
|
| 1100 | - |
|
| 1101 | - // Check if there is a custom field key specific filter. |
|
| 1102 | - if(has_filter("geodir_custom_field_output_email_key_{$cf['field_type_key']}")){ |
|
| 1103 | - /** |
|
| 1104 | - * Filter the email html by field type key. |
|
| 1105 | - * |
|
| 1106 | - * @param string $html The html to filter. |
|
| 1107 | - * @param string $location The location to output the html. |
|
| 1108 | - * @param array $cf The custom field array. |
|
| 1109 | - * @since 1.6.6 |
|
| 1110 | - */ |
|
| 1111 | - $html = apply_filters("geodir_custom_field_output_email_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - // If not html then we run the standard output. |
|
| 1115 | - if(empty($html)){ |
|
| 1116 | - |
|
| 1117 | - global $preview; |
|
| 1118 | - if ($cf['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
| 1119 | - return ''; // Remove Send Enquiry from listings page |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - $package_info = (array)geodir_post_package_info(array(), $post, $post->post_type); |
|
| 1123 | - |
|
| 1124 | - if ($cf['htmlvar_name'] == 'geodir_email' && $post->{$cf['htmlvar_name']}) { |
|
| 1125 | - $b_send_inquiry = ''; |
|
| 1126 | - |
|
| 1127 | - $html = ''; |
|
| 1128 | - if (!$preview) { |
|
| 1129 | - $b_send_inquiry = 'b_send_inquiry'; |
|
| 1130 | - $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; |
|
| 1131 | - } |
|
| 1132 | - |
|
| 1133 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1134 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1135 | - $field_icon_af = ''; |
|
| 1136 | - } elseif ($field_icon == '') { |
|
| 1137 | - $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 1138 | - } else { |
|
| 1139 | - $field_icon_af = $field_icon; |
|
| 1140 | - $field_icon = ''; |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - $html .= '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1144 | - $seperator = ''; |
|
| 1145 | - if ($post->{$cf['htmlvar_name']}) { |
|
| 1146 | - $b_send_inquiry_url = apply_filters('b_send_inquiry_url', 'javascript:void(0);'); |
|
| 1147 | - $html .= '<a href="'.$b_send_inquiry_url.'" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; |
|
| 1148 | - } |
|
| 1149 | - |
|
| 1150 | - $html .= '</span></div>'; |
|
| 1151 | - |
|
| 1152 | - |
|
| 1153 | - if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') { |
|
| 1154 | - $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; |
|
| 1155 | - } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') { |
|
| 1156 | - $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/ |
|
| 1160 | - |
|
| 1161 | - } else { |
|
| 1162 | - |
|
| 1163 | - if ($post->{$cf['htmlvar_name']}) { |
|
| 1164 | - |
|
| 1165 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1166 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1167 | - $field_icon_af = ''; |
|
| 1168 | - } elseif ($field_icon == '') { |
|
| 1169 | - $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 1170 | - } else { |
|
| 1171 | - $field_icon_af = $field_icon; |
|
| 1172 | - $field_icon = ''; |
|
| 1173 | - } |
|
| 1174 | - |
|
| 1175 | - |
|
| 1176 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1177 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1178 | - $html .= '</span><span class="geodir-email-address-output">'; |
|
| 1179 | - $email = $post->{$cf['htmlvar_name']} ; |
|
| 1180 | - if($e_split = explode('@',$email)){ |
|
| 1181 | - /** |
|
| 1182 | - * Filter email custom field name output. |
|
| 1183 | - * |
|
| 1184 | - * @since 1.5.3 |
|
| 1185 | - * |
|
| 1186 | - * @param string $email The email string being output. |
|
| 1187 | - * @param array $cf Custom field variables array. |
|
| 1188 | - */ |
|
| 1189 | - $email_name = apply_filters('geodir_email_field_name_output',$email,$cf); |
|
| 1190 | - if($location=='mapbubble'){ |
|
| 1191 | - $html .= "<a href=\"mailto:$email\">$email_name</a>"; |
|
| 1192 | - }else{ |
|
| 1193 | - $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>"; |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - }else{ |
|
| 1197 | - $html .= $email; |
|
| 1198 | - } |
|
| 1199 | - $html .= '</span></div>'; |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - } |
|
| 1203 | - |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - return $html; |
|
| 1065 | + // check we have the post value |
|
| 1066 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1067 | + else{ global $post;} |
|
| 1068 | + |
|
| 1069 | + if(!is_array($cf) && $cf!=''){ |
|
| 1070 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1071 | + if(!$cf){return NULL;} |
|
| 1072 | + } |
|
| 1073 | + |
|
| 1074 | + $html_var = $cf['htmlvar_name']; |
|
| 1075 | + |
|
| 1076 | + // Check if there is a location specific filter. |
|
| 1077 | + if(has_filter("geodir_custom_field_output_email_loc_{$location}")){ |
|
| 1078 | + /** |
|
| 1079 | + * Filter the email html by location. |
|
| 1080 | + * |
|
| 1081 | + * @param string $html The html to filter. |
|
| 1082 | + * @param array $cf The custom field array. |
|
| 1083 | + * @since 1.6.6 |
|
| 1084 | + */ |
|
| 1085 | + $html = apply_filters("geodir_custom_field_output_email_loc_{$location}",$html,$cf); |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + // Check if there is a custom field specific filter. |
|
| 1089 | + if(has_filter("geodir_custom_field_output_email_var_{$html_var}")){ |
|
| 1090 | + /** |
|
| 1091 | + * Filter the email html by individual custom field. |
|
| 1092 | + * |
|
| 1093 | + * @param string $html The html to filter. |
|
| 1094 | + * @param string $location The location to output the html. |
|
| 1095 | + * @param array $cf The custom field array. |
|
| 1096 | + * @since 1.6.6 |
|
| 1097 | + */ |
|
| 1098 | + $html = apply_filters("geodir_custom_field_output_email_var_{$html_var}",$html,$location,$cf); |
|
| 1099 | + } |
|
| 1100 | + |
|
| 1101 | + // Check if there is a custom field key specific filter. |
|
| 1102 | + if(has_filter("geodir_custom_field_output_email_key_{$cf['field_type_key']}")){ |
|
| 1103 | + /** |
|
| 1104 | + * Filter the email html by field type key. |
|
| 1105 | + * |
|
| 1106 | + * @param string $html The html to filter. |
|
| 1107 | + * @param string $location The location to output the html. |
|
| 1108 | + * @param array $cf The custom field array. |
|
| 1109 | + * @since 1.6.6 |
|
| 1110 | + */ |
|
| 1111 | + $html = apply_filters("geodir_custom_field_output_email_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1112 | + } |
|
| 1113 | + |
|
| 1114 | + // If not html then we run the standard output. |
|
| 1115 | + if(empty($html)){ |
|
| 1116 | + |
|
| 1117 | + global $preview; |
|
| 1118 | + if ($cf['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
| 1119 | + return ''; // Remove Send Enquiry from listings page |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + $package_info = (array)geodir_post_package_info(array(), $post, $post->post_type); |
|
| 1123 | + |
|
| 1124 | + if ($cf['htmlvar_name'] == 'geodir_email' && $post->{$cf['htmlvar_name']}) { |
|
| 1125 | + $b_send_inquiry = ''; |
|
| 1126 | + |
|
| 1127 | + $html = ''; |
|
| 1128 | + if (!$preview) { |
|
| 1129 | + $b_send_inquiry = 'b_send_inquiry'; |
|
| 1130 | + $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; |
|
| 1131 | + } |
|
| 1132 | + |
|
| 1133 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1134 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1135 | + $field_icon_af = ''; |
|
| 1136 | + } elseif ($field_icon == '') { |
|
| 1137 | + $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 1138 | + } else { |
|
| 1139 | + $field_icon_af = $field_icon; |
|
| 1140 | + $field_icon = ''; |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + $html .= '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1144 | + $seperator = ''; |
|
| 1145 | + if ($post->{$cf['htmlvar_name']}) { |
|
| 1146 | + $b_send_inquiry_url = apply_filters('b_send_inquiry_url', 'javascript:void(0);'); |
|
| 1147 | + $html .= '<a href="'.$b_send_inquiry_url.'" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; |
|
| 1148 | + } |
|
| 1149 | + |
|
| 1150 | + $html .= '</span></div>'; |
|
| 1151 | + |
|
| 1152 | + |
|
| 1153 | + if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') { |
|
| 1154 | + $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; |
|
| 1155 | + } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') { |
|
| 1156 | + $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/ |
|
| 1160 | + |
|
| 1161 | + } else { |
|
| 1162 | + |
|
| 1163 | + if ($post->{$cf['htmlvar_name']}) { |
|
| 1164 | + |
|
| 1165 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1166 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1167 | + $field_icon_af = ''; |
|
| 1168 | + } elseif ($field_icon == '') { |
|
| 1169 | + $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 1170 | + } else { |
|
| 1171 | + $field_icon_af = $field_icon; |
|
| 1172 | + $field_icon = ''; |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + |
|
| 1176 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1177 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1178 | + $html .= '</span><span class="geodir-email-address-output">'; |
|
| 1179 | + $email = $post->{$cf['htmlvar_name']} ; |
|
| 1180 | + if($e_split = explode('@',$email)){ |
|
| 1181 | + /** |
|
| 1182 | + * Filter email custom field name output. |
|
| 1183 | + * |
|
| 1184 | + * @since 1.5.3 |
|
| 1185 | + * |
|
| 1186 | + * @param string $email The email string being output. |
|
| 1187 | + * @param array $cf Custom field variables array. |
|
| 1188 | + */ |
|
| 1189 | + $email_name = apply_filters('geodir_email_field_name_output',$email,$cf); |
|
| 1190 | + if($location=='mapbubble'){ |
|
| 1191 | + $html .= "<a href=\"mailto:$email\">$email_name</a>"; |
|
| 1192 | + }else{ |
|
| 1193 | + $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>"; |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + }else{ |
|
| 1197 | + $html .= $email; |
|
| 1198 | + } |
|
| 1199 | + $html .= '</span></div>'; |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + } |
|
| 1203 | + |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + return $html; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | add_filter('geodir_custom_field_output_email','geodir_cf_email',10,3); |
| 1209 | 1209 | |
@@ -1220,136 +1220,136 @@ discard block |
||
| 1220 | 1220 | */ |
| 1221 | 1221 | function geodir_cf_file($html,$location,$cf,$p=''){ |
| 1222 | 1222 | |
| 1223 | - // check we have the post value |
|
| 1224 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1225 | - else{ global $post;} |
|
| 1226 | - |
|
| 1227 | - if(!is_array($cf) && $cf!=''){ |
|
| 1228 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1229 | - if(!$cf){return NULL;} |
|
| 1230 | - } |
|
| 1231 | - |
|
| 1232 | - $html_var = $cf['htmlvar_name']; |
|
| 1233 | - |
|
| 1234 | - // Check if there is a location specific filter. |
|
| 1235 | - if(has_filter("geodir_custom_field_output_file_loc_{$location}")){ |
|
| 1236 | - /** |
|
| 1237 | - * Filter the file html by location. |
|
| 1238 | - * |
|
| 1239 | - * @param string $html The html to filter. |
|
| 1240 | - * @param array $cf The custom field array. |
|
| 1241 | - * @since 1.6.6 |
|
| 1242 | - */ |
|
| 1243 | - $html = apply_filters("geodir_custom_field_output_file_loc_{$location}",$html,$cf); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - // Check if there is a custom field specific filter. |
|
| 1247 | - if(has_filter("geodir_custom_field_output_file_var_{$html_var}")){ |
|
| 1248 | - /** |
|
| 1249 | - * Filter the file html by individual custom field. |
|
| 1250 | - * |
|
| 1251 | - * @param string $html The html to filter. |
|
| 1252 | - * @param string $location The location to output the html. |
|
| 1253 | - * @param array $cf The custom field array. |
|
| 1254 | - * @since 1.6.6 |
|
| 1255 | - */ |
|
| 1256 | - $html = apply_filters("geodir_custom_field_output_file_var_{$html_var}",$html,$location,$cf); |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - // Check if there is a custom field key specific filter. |
|
| 1260 | - if(has_filter("geodir_custom_field_output_file_key_{$cf['field_type_key']}")){ |
|
| 1261 | - /** |
|
| 1262 | - * Filter the file html by field type key. |
|
| 1263 | - * |
|
| 1264 | - * @param string $html The html to filter. |
|
| 1265 | - * @param string $location The location to output the html. |
|
| 1266 | - * @param array $cf The custom field array. |
|
| 1267 | - * @since 1.6.6 |
|
| 1268 | - */ |
|
| 1269 | - $html = apply_filters("geodir_custom_field_output_file_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - // If not html then we run the standard output. |
|
| 1273 | - if(empty($html)){ |
|
| 1274 | - |
|
| 1275 | - if (!empty($post->{$cf['htmlvar_name']})): |
|
| 1276 | - |
|
| 1277 | - $files = explode(",", $post->{$cf['htmlvar_name']}); |
|
| 1278 | - if (!empty($files)): |
|
| 1279 | - |
|
| 1280 | - $extra_fields = !empty($cf['extra_fields']) ? stripslashes_deep(maybe_unserialize($cf['extra_fields'])) : NULL; |
|
| 1281 | - $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'] : ''; |
|
| 1282 | - |
|
| 1283 | - $file_paths = ''; |
|
| 1284 | - foreach ($files as $file) { |
|
| 1285 | - if (!empty($file)) { |
|
| 1286 | - |
|
| 1287 | - // $filetype = wp_check_filetype($file); |
|
| 1288 | - |
|
| 1289 | - $image_name_arr = explode('/', $file); |
|
| 1290 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
| 1291 | - $filename = end($image_name_arr); |
|
| 1292 | - $img_name_arr = explode('.', $filename); |
|
| 1293 | - |
|
| 1294 | - $arr_file_type = wp_check_filetype($filename); |
|
| 1295 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
| 1296 | - continue; |
|
| 1297 | - } |
|
| 1298 | - |
|
| 1299 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 1300 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 1301 | - |
|
| 1302 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
| 1303 | - continue; // Invalid file type. |
|
| 1304 | - } |
|
| 1305 | - |
|
| 1306 | - //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); |
|
| 1307 | - $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); |
|
| 1308 | - $audio_file_types = array('audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid'); |
|
| 1309 | - |
|
| 1310 | - // If the uploaded file is image |
|
| 1311 | - if (in_array($uploaded_file_type, $image_file_types)) { |
|
| 1312 | - $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
|
| 1313 | - $file_paths .= '<a href="'.$file.'">'; |
|
| 1314 | - $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); |
|
| 1315 | - $file_paths .= '</a>'; |
|
| 1316 | - //$file_paths .= '<img src="'.$file.'" />'; |
|
| 1317 | - $file_paths .= '</div>'; |
|
| 1318 | - }elseif (in_array($uploaded_file_type, $audio_file_types)) {// if audio |
|
| 1319 | - $ext_path = '_' . $html_var . '_'; |
|
| 1320 | - $filename = explode($ext_path, $filename); |
|
| 1321 | - $file_paths .= '<span class="gd-audio-name">'.$filename[count($filename) - 1].'</span>'; |
|
| 1322 | - $file_paths .= do_shortcode('[audio src="'.$file.'" ]'); |
|
| 1323 | - } else { |
|
| 1324 | - $ext_path = '_' . $html_var . '_'; |
|
| 1325 | - $filename = explode($ext_path, $filename); |
|
| 1326 | - $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 1327 | - } |
|
| 1328 | - } |
|
| 1329 | - } |
|
| 1330 | - |
|
| 1331 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1332 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1333 | - $field_icon_af = ''; |
|
| 1334 | - } elseif ($field_icon == '') { |
|
| 1335 | - $field_icon_af = ''; |
|
| 1336 | - } else { |
|
| 1337 | - $field_icon_af = $field_icon; |
|
| 1338 | - $field_icon = ''; |
|
| 1339 | - } |
|
| 1340 | - |
|
| 1341 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' geodir-custom-file-box ' . $cf['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1342 | - $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; |
|
| 1343 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1344 | - $html .= '</span>'; |
|
| 1345 | - $html .= $file_paths . '</div></div>'; |
|
| 1346 | - |
|
| 1347 | - endif; |
|
| 1348 | - endif; |
|
| 1349 | - |
|
| 1350 | - } |
|
| 1351 | - |
|
| 1352 | - return $html; |
|
| 1223 | + // check we have the post value |
|
| 1224 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1225 | + else{ global $post;} |
|
| 1226 | + |
|
| 1227 | + if(!is_array($cf) && $cf!=''){ |
|
| 1228 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1229 | + if(!$cf){return NULL;} |
|
| 1230 | + } |
|
| 1231 | + |
|
| 1232 | + $html_var = $cf['htmlvar_name']; |
|
| 1233 | + |
|
| 1234 | + // Check if there is a location specific filter. |
|
| 1235 | + if(has_filter("geodir_custom_field_output_file_loc_{$location}")){ |
|
| 1236 | + /** |
|
| 1237 | + * Filter the file html by location. |
|
| 1238 | + * |
|
| 1239 | + * @param string $html The html to filter. |
|
| 1240 | + * @param array $cf The custom field array. |
|
| 1241 | + * @since 1.6.6 |
|
| 1242 | + */ |
|
| 1243 | + $html = apply_filters("geodir_custom_field_output_file_loc_{$location}",$html,$cf); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + // Check if there is a custom field specific filter. |
|
| 1247 | + if(has_filter("geodir_custom_field_output_file_var_{$html_var}")){ |
|
| 1248 | + /** |
|
| 1249 | + * Filter the file html by individual custom field. |
|
| 1250 | + * |
|
| 1251 | + * @param string $html The html to filter. |
|
| 1252 | + * @param string $location The location to output the html. |
|
| 1253 | + * @param array $cf The custom field array. |
|
| 1254 | + * @since 1.6.6 |
|
| 1255 | + */ |
|
| 1256 | + $html = apply_filters("geodir_custom_field_output_file_var_{$html_var}",$html,$location,$cf); |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + // Check if there is a custom field key specific filter. |
|
| 1260 | + if(has_filter("geodir_custom_field_output_file_key_{$cf['field_type_key']}")){ |
|
| 1261 | + /** |
|
| 1262 | + * Filter the file html by field type key. |
|
| 1263 | + * |
|
| 1264 | + * @param string $html The html to filter. |
|
| 1265 | + * @param string $location The location to output the html. |
|
| 1266 | + * @param array $cf The custom field array. |
|
| 1267 | + * @since 1.6.6 |
|
| 1268 | + */ |
|
| 1269 | + $html = apply_filters("geodir_custom_field_output_file_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + // If not html then we run the standard output. |
|
| 1273 | + if(empty($html)){ |
|
| 1274 | + |
|
| 1275 | + if (!empty($post->{$cf['htmlvar_name']})): |
|
| 1276 | + |
|
| 1277 | + $files = explode(",", $post->{$cf['htmlvar_name']}); |
|
| 1278 | + if (!empty($files)): |
|
| 1279 | + |
|
| 1280 | + $extra_fields = !empty($cf['extra_fields']) ? stripslashes_deep(maybe_unserialize($cf['extra_fields'])) : NULL; |
|
| 1281 | + $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'] : ''; |
|
| 1282 | + |
|
| 1283 | + $file_paths = ''; |
|
| 1284 | + foreach ($files as $file) { |
|
| 1285 | + if (!empty($file)) { |
|
| 1286 | + |
|
| 1287 | + // $filetype = wp_check_filetype($file); |
|
| 1288 | + |
|
| 1289 | + $image_name_arr = explode('/', $file); |
|
| 1290 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
| 1291 | + $filename = end($image_name_arr); |
|
| 1292 | + $img_name_arr = explode('.', $filename); |
|
| 1293 | + |
|
| 1294 | + $arr_file_type = wp_check_filetype($filename); |
|
| 1295 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
| 1296 | + continue; |
|
| 1297 | + } |
|
| 1298 | + |
|
| 1299 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 1300 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 1301 | + |
|
| 1302 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
| 1303 | + continue; // Invalid file type. |
|
| 1304 | + } |
|
| 1305 | + |
|
| 1306 | + //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); |
|
| 1307 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); |
|
| 1308 | + $audio_file_types = array('audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid'); |
|
| 1309 | + |
|
| 1310 | + // If the uploaded file is image |
|
| 1311 | + if (in_array($uploaded_file_type, $image_file_types)) { |
|
| 1312 | + $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
|
| 1313 | + $file_paths .= '<a href="'.$file.'">'; |
|
| 1314 | + $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); |
|
| 1315 | + $file_paths .= '</a>'; |
|
| 1316 | + //$file_paths .= '<img src="'.$file.'" />'; |
|
| 1317 | + $file_paths .= '</div>'; |
|
| 1318 | + }elseif (in_array($uploaded_file_type, $audio_file_types)) {// if audio |
|
| 1319 | + $ext_path = '_' . $html_var . '_'; |
|
| 1320 | + $filename = explode($ext_path, $filename); |
|
| 1321 | + $file_paths .= '<span class="gd-audio-name">'.$filename[count($filename) - 1].'</span>'; |
|
| 1322 | + $file_paths .= do_shortcode('[audio src="'.$file.'" ]'); |
|
| 1323 | + } else { |
|
| 1324 | + $ext_path = '_' . $html_var . '_'; |
|
| 1325 | + $filename = explode($ext_path, $filename); |
|
| 1326 | + $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 1327 | + } |
|
| 1328 | + } |
|
| 1329 | + } |
|
| 1330 | + |
|
| 1331 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1332 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1333 | + $field_icon_af = ''; |
|
| 1334 | + } elseif ($field_icon == '') { |
|
| 1335 | + $field_icon_af = ''; |
|
| 1336 | + } else { |
|
| 1337 | + $field_icon_af = $field_icon; |
|
| 1338 | + $field_icon = ''; |
|
| 1339 | + } |
|
| 1340 | + |
|
| 1341 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' geodir-custom-file-box ' . $cf['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1342 | + $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; |
|
| 1343 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1344 | + $html .= '</span>'; |
|
| 1345 | + $html .= $file_paths . '</div></div>'; |
|
| 1346 | + |
|
| 1347 | + endif; |
|
| 1348 | + endif; |
|
| 1349 | + |
|
| 1350 | + } |
|
| 1351 | + |
|
| 1352 | + return $html; |
|
| 1353 | 1353 | } |
| 1354 | 1354 | add_filter('geodir_custom_field_output_file','geodir_cf_file',10,3); |
| 1355 | 1355 | |
@@ -1367,80 +1367,80 @@ discard block |
||
| 1367 | 1367 | */ |
| 1368 | 1368 | function geodir_cf_textarea($html,$location,$cf,$p=''){ |
| 1369 | 1369 | |
| 1370 | - // check we have the post value |
|
| 1371 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1372 | - else{ global $post;} |
|
| 1373 | - |
|
| 1374 | - if(!is_array($cf) && $cf!=''){ |
|
| 1375 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1376 | - if(!$cf){return NULL;} |
|
| 1377 | - } |
|
| 1378 | - |
|
| 1379 | - $html_var = $cf['htmlvar_name']; |
|
| 1380 | - |
|
| 1381 | - // Check if there is a location specific filter. |
|
| 1382 | - if(has_filter("geodir_custom_field_output_textarea_loc_{$location}")){ |
|
| 1383 | - /** |
|
| 1384 | - * Filter the textarea html by location. |
|
| 1385 | - * |
|
| 1386 | - * @param string $html The html to filter. |
|
| 1387 | - * @param array $cf The custom field array. |
|
| 1388 | - * @since 1.6.6 |
|
| 1389 | - */ |
|
| 1390 | - $html = apply_filters("geodir_custom_field_output_textarea_loc_{$location}",$html,$cf); |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - // Check if there is a custom field specific filter. |
|
| 1394 | - if(has_filter("geodir_custom_field_output_textarea_var_{$html_var}")){ |
|
| 1395 | - /** |
|
| 1396 | - * Filter the textarea html by individual custom field. |
|
| 1397 | - * |
|
| 1398 | - * @param string $html The html to filter. |
|
| 1399 | - * @param string $location The location to output the html. |
|
| 1400 | - * @param array $cf The custom field array. |
|
| 1401 | - * @since 1.6.6 |
|
| 1402 | - */ |
|
| 1403 | - $html = apply_filters("geodir_custom_field_output_textarea_var_{$html_var}",$html,$location,$cf); |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - // Check if there is a custom field key specific filter. |
|
| 1407 | - if(has_filter("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}")){ |
|
| 1408 | - /** |
|
| 1409 | - * Filter the textarea html by field type key. |
|
| 1410 | - * |
|
| 1411 | - * @param string $html The html to filter. |
|
| 1412 | - * @param string $location The location to output the html. |
|
| 1413 | - * @param array $cf The custom field array. |
|
| 1414 | - * @since 1.6.6 |
|
| 1415 | - */ |
|
| 1416 | - $html = apply_filters("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - // If not html then we run the standard output. |
|
| 1420 | - if(empty($html)){ |
|
| 1421 | - |
|
| 1422 | - if (!empty($post->{$cf['htmlvar_name']})) { |
|
| 1423 | - |
|
| 1424 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1425 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1426 | - $field_icon_af = ''; |
|
| 1427 | - } elseif ($field_icon == '') { |
|
| 1428 | - $field_icon_af = ''; |
|
| 1429 | - } else { |
|
| 1430 | - $field_icon_af = $field_icon; |
|
| 1431 | - $field_icon = ''; |
|
| 1432 | - } |
|
| 1433 | - |
|
| 1434 | - |
|
| 1435 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1436 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1437 | - $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>'; |
|
| 1438 | - |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - return $html; |
|
| 1370 | + // check we have the post value |
|
| 1371 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1372 | + else{ global $post;} |
|
| 1373 | + |
|
| 1374 | + if(!is_array($cf) && $cf!=''){ |
|
| 1375 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1376 | + if(!$cf){return NULL;} |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + $html_var = $cf['htmlvar_name']; |
|
| 1380 | + |
|
| 1381 | + // Check if there is a location specific filter. |
|
| 1382 | + if(has_filter("geodir_custom_field_output_textarea_loc_{$location}")){ |
|
| 1383 | + /** |
|
| 1384 | + * Filter the textarea html by location. |
|
| 1385 | + * |
|
| 1386 | + * @param string $html The html to filter. |
|
| 1387 | + * @param array $cf The custom field array. |
|
| 1388 | + * @since 1.6.6 |
|
| 1389 | + */ |
|
| 1390 | + $html = apply_filters("geodir_custom_field_output_textarea_loc_{$location}",$html,$cf); |
|
| 1391 | + } |
|
| 1392 | + |
|
| 1393 | + // Check if there is a custom field specific filter. |
|
| 1394 | + if(has_filter("geodir_custom_field_output_textarea_var_{$html_var}")){ |
|
| 1395 | + /** |
|
| 1396 | + * Filter the textarea html by individual custom field. |
|
| 1397 | + * |
|
| 1398 | + * @param string $html The html to filter. |
|
| 1399 | + * @param string $location The location to output the html. |
|
| 1400 | + * @param array $cf The custom field array. |
|
| 1401 | + * @since 1.6.6 |
|
| 1402 | + */ |
|
| 1403 | + $html = apply_filters("geodir_custom_field_output_textarea_var_{$html_var}",$html,$location,$cf); |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + // Check if there is a custom field key specific filter. |
|
| 1407 | + if(has_filter("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}")){ |
|
| 1408 | + /** |
|
| 1409 | + * Filter the textarea html by field type key. |
|
| 1410 | + * |
|
| 1411 | + * @param string $html The html to filter. |
|
| 1412 | + * @param string $location The location to output the html. |
|
| 1413 | + * @param array $cf The custom field array. |
|
| 1414 | + * @since 1.6.6 |
|
| 1415 | + */ |
|
| 1416 | + $html = apply_filters("geodir_custom_field_output_textarea_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + // If not html then we run the standard output. |
|
| 1420 | + if(empty($html)){ |
|
| 1421 | + |
|
| 1422 | + if (!empty($post->{$cf['htmlvar_name']})) { |
|
| 1423 | + |
|
| 1424 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1425 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1426 | + $field_icon_af = ''; |
|
| 1427 | + } elseif ($field_icon == '') { |
|
| 1428 | + $field_icon_af = ''; |
|
| 1429 | + } else { |
|
| 1430 | + $field_icon_af = $field_icon; |
|
| 1431 | + $field_icon = ''; |
|
| 1432 | + } |
|
| 1433 | + |
|
| 1434 | + |
|
| 1435 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1436 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1437 | + $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>'; |
|
| 1438 | + |
|
| 1439 | + } |
|
| 1440 | + |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + return $html; |
|
| 1444 | 1444 | } |
| 1445 | 1445 | add_filter('geodir_custom_field_output_textarea','geodir_cf_textarea',10,3); |
| 1446 | 1446 | |
@@ -1458,79 +1458,79 @@ discard block |
||
| 1458 | 1458 | */ |
| 1459 | 1459 | function geodir_cf_html($html,$location,$cf,$p=''){ |
| 1460 | 1460 | |
| 1461 | - // check we have the post value |
|
| 1462 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1463 | - else{ global $post;} |
|
| 1464 | - |
|
| 1465 | - if(!is_array($cf) && $cf!=''){ |
|
| 1466 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1467 | - if(!$cf){return NULL;} |
|
| 1468 | - } |
|
| 1469 | - |
|
| 1470 | - $html_var = $cf['htmlvar_name']; |
|
| 1471 | - |
|
| 1472 | - // Check if there is a location specific filter. |
|
| 1473 | - if(has_filter("geodir_custom_field_output_html_loc_{$location}")){ |
|
| 1474 | - /** |
|
| 1475 | - * Filter the html html by location. |
|
| 1476 | - * |
|
| 1477 | - * @param string $html The html to filter. |
|
| 1478 | - * @param array $cf The custom field array. |
|
| 1479 | - * @since 1.6.6 |
|
| 1480 | - */ |
|
| 1481 | - $html = apply_filters("geodir_custom_field_output_html_loc_{$location}",$html,$cf); |
|
| 1482 | - } |
|
| 1483 | - |
|
| 1484 | - // Check if there is a custom field specific filter. |
|
| 1485 | - if(has_filter("geodir_custom_field_output_html_var_{$html_var}")){ |
|
| 1486 | - /** |
|
| 1487 | - * Filter the html html by individual custom field. |
|
| 1488 | - * |
|
| 1489 | - * @param string $html The html to filter. |
|
| 1490 | - * @param string $location The location to output the html. |
|
| 1491 | - * @param array $cf The custom field array. |
|
| 1492 | - * @since 1.6.6 |
|
| 1493 | - */ |
|
| 1494 | - $html = apply_filters("geodir_custom_field_output_html_var_{$html_var}",$html,$location,$cf); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - // Check if there is a custom field key specific filter. |
|
| 1498 | - if(has_filter("geodir_custom_field_output_html_key_{$cf['field_type_key']}")){ |
|
| 1499 | - /** |
|
| 1500 | - * Filter the html html by field type key. |
|
| 1501 | - * |
|
| 1502 | - * @param string $html The html to filter. |
|
| 1503 | - * @param string $location The location to output the html. |
|
| 1504 | - * @param array $cf The custom field array. |
|
| 1505 | - * @since 1.6.6 |
|
| 1506 | - */ |
|
| 1507 | - $html = apply_filters("geodir_custom_field_output_html_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1508 | - } |
|
| 1509 | - |
|
| 1510 | - // If not html then we run the standard output. |
|
| 1511 | - if(empty($html)){ |
|
| 1512 | - |
|
| 1513 | - if (!empty($post->{$cf['htmlvar_name']})) { |
|
| 1514 | - |
|
| 1515 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1516 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1517 | - $field_icon_af = ''; |
|
| 1518 | - } elseif ($field_icon == '') { |
|
| 1519 | - $field_icon_af = ''; |
|
| 1520 | - } else { |
|
| 1521 | - $field_icon_af = $field_icon; |
|
| 1522 | - $field_icon = ''; |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1526 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1527 | - $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>'; |
|
| 1528 | - |
|
| 1529 | - } |
|
| 1530 | - |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - return $html; |
|
| 1461 | + // check we have the post value |
|
| 1462 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1463 | + else{ global $post;} |
|
| 1464 | + |
|
| 1465 | + if(!is_array($cf) && $cf!=''){ |
|
| 1466 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1467 | + if(!$cf){return NULL;} |
|
| 1468 | + } |
|
| 1469 | + |
|
| 1470 | + $html_var = $cf['htmlvar_name']; |
|
| 1471 | + |
|
| 1472 | + // Check if there is a location specific filter. |
|
| 1473 | + if(has_filter("geodir_custom_field_output_html_loc_{$location}")){ |
|
| 1474 | + /** |
|
| 1475 | + * Filter the html html by location. |
|
| 1476 | + * |
|
| 1477 | + * @param string $html The html to filter. |
|
| 1478 | + * @param array $cf The custom field array. |
|
| 1479 | + * @since 1.6.6 |
|
| 1480 | + */ |
|
| 1481 | + $html = apply_filters("geodir_custom_field_output_html_loc_{$location}",$html,$cf); |
|
| 1482 | + } |
|
| 1483 | + |
|
| 1484 | + // Check if there is a custom field specific filter. |
|
| 1485 | + if(has_filter("geodir_custom_field_output_html_var_{$html_var}")){ |
|
| 1486 | + /** |
|
| 1487 | + * Filter the html html by individual custom field. |
|
| 1488 | + * |
|
| 1489 | + * @param string $html The html to filter. |
|
| 1490 | + * @param string $location The location to output the html. |
|
| 1491 | + * @param array $cf The custom field array. |
|
| 1492 | + * @since 1.6.6 |
|
| 1493 | + */ |
|
| 1494 | + $html = apply_filters("geodir_custom_field_output_html_var_{$html_var}",$html,$location,$cf); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + // Check if there is a custom field key specific filter. |
|
| 1498 | + if(has_filter("geodir_custom_field_output_html_key_{$cf['field_type_key']}")){ |
|
| 1499 | + /** |
|
| 1500 | + * Filter the html html by field type key. |
|
| 1501 | + * |
|
| 1502 | + * @param string $html The html to filter. |
|
| 1503 | + * @param string $location The location to output the html. |
|
| 1504 | + * @param array $cf The custom field array. |
|
| 1505 | + * @since 1.6.6 |
|
| 1506 | + */ |
|
| 1507 | + $html = apply_filters("geodir_custom_field_output_html_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1508 | + } |
|
| 1509 | + |
|
| 1510 | + // If not html then we run the standard output. |
|
| 1511 | + if(empty($html)){ |
|
| 1512 | + |
|
| 1513 | + if (!empty($post->{$cf['htmlvar_name']})) { |
|
| 1514 | + |
|
| 1515 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1516 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1517 | + $field_icon_af = ''; |
|
| 1518 | + } elseif ($field_icon == '') { |
|
| 1519 | + $field_icon_af = ''; |
|
| 1520 | + } else { |
|
| 1521 | + $field_icon_af = $field_icon; |
|
| 1522 | + $field_icon = ''; |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1526 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1527 | + $html .= '</span>' . wpautop($post->{$cf['htmlvar_name']}) . '</div>'; |
|
| 1528 | + |
|
| 1529 | + } |
|
| 1530 | + |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + return $html; |
|
| 1534 | 1534 | } |
| 1535 | 1535 | add_filter('geodir_custom_field_output_html','geodir_cf_html',10,3); |
| 1536 | 1536 | |
@@ -1548,113 +1548,113 @@ discard block |
||
| 1548 | 1548 | */ |
| 1549 | 1549 | function geodir_cf_taxonomy($html,$location,$cf,$p=''){ |
| 1550 | 1550 | |
| 1551 | - // check we have the post value |
|
| 1552 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1553 | - else{ global $post;} |
|
| 1554 | - |
|
| 1555 | - if(!is_array($cf) && $cf!=''){ |
|
| 1556 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1557 | - if(!$cf){return NULL;} |
|
| 1558 | - } |
|
| 1559 | - |
|
| 1560 | - $html_var = $cf['htmlvar_name']; |
|
| 1561 | - |
|
| 1562 | - // Check if there is a location specific filter. |
|
| 1563 | - if(has_filter("geodir_custom_field_output_taxonomy_loc_{$location}")){ |
|
| 1564 | - /** |
|
| 1565 | - * Filter the taxonomy html by location. |
|
| 1566 | - * |
|
| 1567 | - * @param string $html The html to filter. |
|
| 1568 | - * @param array $cf The custom field array. |
|
| 1569 | - * @since 1.6.6 |
|
| 1570 | - */ |
|
| 1571 | - $html = apply_filters("geodir_custom_field_output_taxonomy_loc_{$location}",$html,$cf); |
|
| 1572 | - } |
|
| 1573 | - |
|
| 1574 | - // Check if there is a custom field specific filter. |
|
| 1575 | - if(has_filter("geodir_custom_field_output_taxonomy_var_{$html_var}")){ |
|
| 1576 | - /** |
|
| 1577 | - * Filter the taxonomy html by individual custom field. |
|
| 1578 | - * |
|
| 1579 | - * @param string $html The html to filter. |
|
| 1580 | - * @param string $location The location to output the html. |
|
| 1581 | - * @param array $cf The custom field array. |
|
| 1582 | - * @since 1.6.6 |
|
| 1583 | - */ |
|
| 1584 | - $html = apply_filters("geodir_custom_field_output_taxonomy_var_{$html_var}",$html,$location,$cf); |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - // Check if there is a custom field key specific filter. |
|
| 1588 | - if(has_filter("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}")){ |
|
| 1589 | - /** |
|
| 1590 | - * Filter the taxonomy html by field type key. |
|
| 1591 | - * |
|
| 1592 | - * @param string $html The html to filter. |
|
| 1593 | - * @param string $location The location to output the html. |
|
| 1594 | - * @param array $cf The custom field array. |
|
| 1595 | - * @since 1.6.6 |
|
| 1596 | - */ |
|
| 1597 | - $html = apply_filters("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - // If not html then we run the standard output. |
|
| 1601 | - if(empty($html)){ |
|
| 1602 | - |
|
| 1603 | - if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) { |
|
| 1604 | - $post_taxonomy = $post->post_type . 'category'; |
|
| 1605 | - $field_value = $post->{$html_var}; |
|
| 1606 | - $links = array(); |
|
| 1607 | - $terms = array(); |
|
| 1608 | - $termsOrdered = array(); |
|
| 1609 | - if (!is_array($field_value)) { |
|
| 1610 | - $field_value = explode(",", trim($field_value, ",")); |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - $field_value = array_unique($field_value); |
|
| 1614 | - |
|
| 1615 | - if (!empty($field_value)) { |
|
| 1616 | - foreach ($field_value as $term) { |
|
| 1617 | - $term = trim($term); |
|
| 1618 | - |
|
| 1619 | - if ($term != '') { |
|
| 1620 | - $term = get_term_by('id', $term, $html_var); |
|
| 1621 | - if (is_object($term)) { |
|
| 1622 | - $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; |
|
| 1623 | - $terms[] = $term; |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1626 | - } |
|
| 1627 | - if (!empty($links)) { |
|
| 1628 | - // order alphabetically |
|
| 1629 | - asort($links); |
|
| 1630 | - foreach (array_keys($links) as $key) { |
|
| 1631 | - $termsOrdered[$key] = $terms[$key]; |
|
| 1632 | - } |
|
| 1633 | - $terms = $termsOrdered; |
|
| 1634 | - } |
|
| 1635 | - } |
|
| 1636 | - $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : ''; |
|
| 1637 | - |
|
| 1638 | - if ($html_value != '') { |
|
| 1639 | - $field_icon = geodir_field_icon_proccess($cf); |
|
| 1640 | - if (strpos($field_icon, 'http') !== false) { |
|
| 1641 | - $field_icon_af = ''; |
|
| 1642 | - } else if ($field_icon == '') { |
|
| 1643 | - $field_icon_af = ''; |
|
| 1644 | - } else { |
|
| 1645 | - $field_icon_af = $field_icon; |
|
| 1646 | - $field_icon = ''; |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1650 | - $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1651 | - $html .= '</span> ' . $html_value . '</div>'; |
|
| 1652 | - } |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - } |
|
| 1656 | - |
|
| 1657 | - return $html; |
|
| 1551 | + // check we have the post value |
|
| 1552 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1553 | + else{ global $post;} |
|
| 1554 | + |
|
| 1555 | + if(!is_array($cf) && $cf!=''){ |
|
| 1556 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1557 | + if(!$cf){return NULL;} |
|
| 1558 | + } |
|
| 1559 | + |
|
| 1560 | + $html_var = $cf['htmlvar_name']; |
|
| 1561 | + |
|
| 1562 | + // Check if there is a location specific filter. |
|
| 1563 | + if(has_filter("geodir_custom_field_output_taxonomy_loc_{$location}")){ |
|
| 1564 | + /** |
|
| 1565 | + * Filter the taxonomy html by location. |
|
| 1566 | + * |
|
| 1567 | + * @param string $html The html to filter. |
|
| 1568 | + * @param array $cf The custom field array. |
|
| 1569 | + * @since 1.6.6 |
|
| 1570 | + */ |
|
| 1571 | + $html = apply_filters("geodir_custom_field_output_taxonomy_loc_{$location}",$html,$cf); |
|
| 1572 | + } |
|
| 1573 | + |
|
| 1574 | + // Check if there is a custom field specific filter. |
|
| 1575 | + if(has_filter("geodir_custom_field_output_taxonomy_var_{$html_var}")){ |
|
| 1576 | + /** |
|
| 1577 | + * Filter the taxonomy html by individual custom field. |
|
| 1578 | + * |
|
| 1579 | + * @param string $html The html to filter. |
|
| 1580 | + * @param string $location The location to output the html. |
|
| 1581 | + * @param array $cf The custom field array. |
|
| 1582 | + * @since 1.6.6 |
|
| 1583 | + */ |
|
| 1584 | + $html = apply_filters("geodir_custom_field_output_taxonomy_var_{$html_var}",$html,$location,$cf); |
|
| 1585 | + } |
|
| 1586 | + |
|
| 1587 | + // Check if there is a custom field key specific filter. |
|
| 1588 | + if(has_filter("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}")){ |
|
| 1589 | + /** |
|
| 1590 | + * Filter the taxonomy html by field type key. |
|
| 1591 | + * |
|
| 1592 | + * @param string $html The html to filter. |
|
| 1593 | + * @param string $location The location to output the html. |
|
| 1594 | + * @param array $cf The custom field array. |
|
| 1595 | + * @since 1.6.6 |
|
| 1596 | + */ |
|
| 1597 | + $html = apply_filters("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1598 | + } |
|
| 1599 | + |
|
| 1600 | + // If not html then we run the standard output. |
|
| 1601 | + if(empty($html)){ |
|
| 1602 | + |
|
| 1603 | + if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) { |
|
| 1604 | + $post_taxonomy = $post->post_type . 'category'; |
|
| 1605 | + $field_value = $post->{$html_var}; |
|
| 1606 | + $links = array(); |
|
| 1607 | + $terms = array(); |
|
| 1608 | + $termsOrdered = array(); |
|
| 1609 | + if (!is_array($field_value)) { |
|
| 1610 | + $field_value = explode(",", trim($field_value, ",")); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + $field_value = array_unique($field_value); |
|
| 1614 | + |
|
| 1615 | + if (!empty($field_value)) { |
|
| 1616 | + foreach ($field_value as $term) { |
|
| 1617 | + $term = trim($term); |
|
| 1618 | + |
|
| 1619 | + if ($term != '') { |
|
| 1620 | + $term = get_term_by('id', $term, $html_var); |
|
| 1621 | + if (is_object($term)) { |
|
| 1622 | + $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; |
|
| 1623 | + $terms[] = $term; |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | + } |
|
| 1627 | + if (!empty($links)) { |
|
| 1628 | + // order alphabetically |
|
| 1629 | + asort($links); |
|
| 1630 | + foreach (array_keys($links) as $key) { |
|
| 1631 | + $termsOrdered[$key] = $terms[$key]; |
|
| 1632 | + } |
|
| 1633 | + $terms = $termsOrdered; |
|
| 1634 | + } |
|
| 1635 | + } |
|
| 1636 | + $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : ''; |
|
| 1637 | + |
|
| 1638 | + if ($html_value != '') { |
|
| 1639 | + $field_icon = geodir_field_icon_proccess($cf); |
|
| 1640 | + if (strpos($field_icon, 'http') !== false) { |
|
| 1641 | + $field_icon_af = ''; |
|
| 1642 | + } else if ($field_icon == '') { |
|
| 1643 | + $field_icon_af = ''; |
|
| 1644 | + } else { |
|
| 1645 | + $field_icon_af = $field_icon; |
|
| 1646 | + $field_icon = ''; |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1650 | + $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; |
|
| 1651 | + $html .= '</span> ' . $html_value . '</div>'; |
|
| 1652 | + } |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + } |
|
| 1656 | + |
|
| 1657 | + return $html; |
|
| 1658 | 1658 | } |
| 1659 | 1659 | add_filter('geodir_custom_field_output_taxonomy','geodir_cf_taxonomy',10,3); |
| 1660 | 1660 | |
@@ -1672,176 +1672,176 @@ discard block |
||
| 1672 | 1672 | */ |
| 1673 | 1673 | function geodir_cf_address($html,$location,$cf,$p=''){ |
| 1674 | 1674 | |
| 1675 | - // check we have the post value |
|
| 1676 | - if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1677 | - else{ global $post;} |
|
| 1678 | - |
|
| 1679 | - if(!is_array($cf) && $cf!=''){ |
|
| 1680 | - $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1681 | - if(!$cf){return NULL;} |
|
| 1682 | - } |
|
| 1683 | - |
|
| 1684 | - $html_var = $cf['htmlvar_name']; |
|
| 1685 | - |
|
| 1686 | - // Check if there is a location specific filter. |
|
| 1687 | - if(has_filter("geodir_custom_field_output_address_loc_{$location}")){ |
|
| 1688 | - /** |
|
| 1689 | - * Filter the address html by location. |
|
| 1690 | - * |
|
| 1691 | - * @param string $html The html to filter. |
|
| 1692 | - * @param array $cf The custom field array. |
|
| 1693 | - * @since 1.6.6 |
|
| 1694 | - */ |
|
| 1695 | - $html = apply_filters("geodir_custom_field_output_address_loc_{$location}",$html,$cf); |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - // Check if there is a custom field specific filter. |
|
| 1699 | - if(has_filter("geodir_custom_field_output_address_var_{$html_var}")){ |
|
| 1700 | - /** |
|
| 1701 | - * Filter the address html by individual custom field. |
|
| 1702 | - * |
|
| 1703 | - * @param string $html The html to filter. |
|
| 1704 | - * @param string $location The location to output the html. |
|
| 1705 | - * @param array $cf The custom field array. |
|
| 1706 | - * @since 1.6.6 |
|
| 1707 | - */ |
|
| 1708 | - $html = apply_filters("geodir_custom_field_output_address_var_{$html_var}",$html,$location,$cf); |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - // Check if there is a custom field key specific filter. |
|
| 1712 | - if(has_filter("geodir_custom_field_output_address_key_{$cf['field_type_key']}")){ |
|
| 1713 | - /** |
|
| 1714 | - * Filter the address html by field type key. |
|
| 1715 | - * |
|
| 1716 | - * @param string $html The html to filter. |
|
| 1717 | - * @param string $location The location to output the html. |
|
| 1718 | - * @param array $cf The custom field array. |
|
| 1719 | - * @since 1.6.6 |
|
| 1720 | - */ |
|
| 1721 | - $html = apply_filters("geodir_custom_field_output_address_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1722 | - } |
|
| 1723 | - |
|
| 1724 | - // If not html then we run the standard output. |
|
| 1725 | - if(empty($html)){ |
|
| 1726 | - |
|
| 1727 | - global $preview; |
|
| 1728 | - $html_var = $cf['htmlvar_name'] . '_address'; |
|
| 1729 | - |
|
| 1730 | - if ($cf['extra_fields']) { |
|
| 1731 | - |
|
| 1732 | - $extra_fields = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 1733 | - |
|
| 1734 | - $addition_fields = ''; |
|
| 1735 | - |
|
| 1736 | - if (!empty($extra_fields)) { |
|
| 1737 | - |
|
| 1738 | - $show_city_in_address = false; |
|
| 1739 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
| 1740 | - $show_city_in_address = true; |
|
| 1741 | - } |
|
| 1742 | - /** |
|
| 1743 | - * Filter "show city in address" value. |
|
| 1744 | - * |
|
| 1745 | - * @since 1.0.0 |
|
| 1746 | - */ |
|
| 1747 | - $show_city_in_address = apply_filters('geodir_show_city_in_address', $show_city_in_address); |
|
| 1748 | - |
|
| 1749 | - |
|
| 1750 | - $show_region_in_address = false; |
|
| 1751 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
| 1752 | - $show_region_in_address = true; |
|
| 1753 | - } |
|
| 1754 | - /** |
|
| 1755 | - * Filter "show region in address" value. |
|
| 1756 | - * |
|
| 1757 | - * @since 1.6.6 |
|
| 1758 | - */ |
|
| 1759 | - $show_region_in_address = apply_filters('geodir_show_region_in_address', $show_region_in_address); |
|
| 1760 | - |
|
| 1761 | - $show_country_in_address = false; |
|
| 1762 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
| 1763 | - $show_country_in_address = true; |
|
| 1764 | - } |
|
| 1765 | - /** |
|
| 1766 | - * Filter "show country in address" value. |
|
| 1767 | - * |
|
| 1768 | - * @since 1.6.6 |
|
| 1769 | - */ |
|
| 1770 | - $show_country_in_address = apply_filters('geodir_show_country_in_address', $show_country_in_address); |
|
| 1771 | - |
|
| 1772 | - $show_zip_in_address = false; |
|
| 1773 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
| 1774 | - $show_zip_in_address = true; |
|
| 1775 | - } |
|
| 1776 | - /** |
|
| 1777 | - * Filter "show zip in address" value. |
|
| 1778 | - * |
|
| 1779 | - * @since 1.6.6 |
|
| 1780 | - */ |
|
| 1781 | - $show_zip_in_address = apply_filters('geodir_show_zip_in_address', $show_zip_in_address); |
|
| 1782 | - |
|
| 1783 | - |
|
| 1784 | - } |
|
| 1785 | - |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - |
|
| 1789 | - if ($post->{$html_var}) { |
|
| 1790 | - |
|
| 1791 | - $field_icon = geodir_field_icon_proccess( $cf ); |
|
| 1792 | - if ( strpos( $field_icon, 'http' ) !== false ) { |
|
| 1793 | - $field_icon_af = ''; |
|
| 1794 | - } elseif ( $field_icon == '' ) { |
|
| 1795 | - $field_icon_af = '<i class="fa fa-home"></i>'; |
|
| 1796 | - } else { |
|
| 1797 | - $field_icon_af = $field_icon; |
|
| 1798 | - $field_icon = ''; |
|
| 1799 | - } |
|
| 1675 | + // check we have the post value |
|
| 1676 | + if(is_int($p)){$post = geodir_get_post_info($p);} |
|
| 1677 | + else{ global $post;} |
|
| 1678 | + |
|
| 1679 | + if(!is_array($cf) && $cf!=''){ |
|
| 1680 | + $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); |
|
| 1681 | + if(!$cf){return NULL;} |
|
| 1682 | + } |
|
| 1683 | + |
|
| 1684 | + $html_var = $cf['htmlvar_name']; |
|
| 1685 | + |
|
| 1686 | + // Check if there is a location specific filter. |
|
| 1687 | + if(has_filter("geodir_custom_field_output_address_loc_{$location}")){ |
|
| 1688 | + /** |
|
| 1689 | + * Filter the address html by location. |
|
| 1690 | + * |
|
| 1691 | + * @param string $html The html to filter. |
|
| 1692 | + * @param array $cf The custom field array. |
|
| 1693 | + * @since 1.6.6 |
|
| 1694 | + */ |
|
| 1695 | + $html = apply_filters("geodir_custom_field_output_address_loc_{$location}",$html,$cf); |
|
| 1696 | + } |
|
| 1697 | + |
|
| 1698 | + // Check if there is a custom field specific filter. |
|
| 1699 | + if(has_filter("geodir_custom_field_output_address_var_{$html_var}")){ |
|
| 1700 | + /** |
|
| 1701 | + * Filter the address html by individual custom field. |
|
| 1702 | + * |
|
| 1703 | + * @param string $html The html to filter. |
|
| 1704 | + * @param string $location The location to output the html. |
|
| 1705 | + * @param array $cf The custom field array. |
|
| 1706 | + * @since 1.6.6 |
|
| 1707 | + */ |
|
| 1708 | + $html = apply_filters("geodir_custom_field_output_address_var_{$html_var}",$html,$location,$cf); |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + // Check if there is a custom field key specific filter. |
|
| 1712 | + if(has_filter("geodir_custom_field_output_address_key_{$cf['field_type_key']}")){ |
|
| 1713 | + /** |
|
| 1714 | + * Filter the address html by field type key. |
|
| 1715 | + * |
|
| 1716 | + * @param string $html The html to filter. |
|
| 1717 | + * @param string $location The location to output the html. |
|
| 1718 | + * @param array $cf The custom field array. |
|
| 1719 | + * @since 1.6.6 |
|
| 1720 | + */ |
|
| 1721 | + $html = apply_filters("geodir_custom_field_output_address_key_{$cf['field_type_key']}",$html,$location,$cf); |
|
| 1722 | + } |
|
| 1723 | + |
|
| 1724 | + // If not html then we run the standard output. |
|
| 1725 | + if(empty($html)){ |
|
| 1726 | + |
|
| 1727 | + global $preview; |
|
| 1728 | + $html_var = $cf['htmlvar_name'] . '_address'; |
|
| 1729 | + |
|
| 1730 | + if ($cf['extra_fields']) { |
|
| 1731 | + |
|
| 1732 | + $extra_fields = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 1733 | + |
|
| 1734 | + $addition_fields = ''; |
|
| 1735 | + |
|
| 1736 | + if (!empty($extra_fields)) { |
|
| 1737 | + |
|
| 1738 | + $show_city_in_address = false; |
|
| 1739 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
| 1740 | + $show_city_in_address = true; |
|
| 1741 | + } |
|
| 1742 | + /** |
|
| 1743 | + * Filter "show city in address" value. |
|
| 1744 | + * |
|
| 1745 | + * @since 1.0.0 |
|
| 1746 | + */ |
|
| 1747 | + $show_city_in_address = apply_filters('geodir_show_city_in_address', $show_city_in_address); |
|
| 1748 | + |
|
| 1749 | + |
|
| 1750 | + $show_region_in_address = false; |
|
| 1751 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
| 1752 | + $show_region_in_address = true; |
|
| 1753 | + } |
|
| 1754 | + /** |
|
| 1755 | + * Filter "show region in address" value. |
|
| 1756 | + * |
|
| 1757 | + * @since 1.6.6 |
|
| 1758 | + */ |
|
| 1759 | + $show_region_in_address = apply_filters('geodir_show_region_in_address', $show_region_in_address); |
|
| 1760 | + |
|
| 1761 | + $show_country_in_address = false; |
|
| 1762 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
| 1763 | + $show_country_in_address = true; |
|
| 1764 | + } |
|
| 1765 | + /** |
|
| 1766 | + * Filter "show country in address" value. |
|
| 1767 | + * |
|
| 1768 | + * @since 1.6.6 |
|
| 1769 | + */ |
|
| 1770 | + $show_country_in_address = apply_filters('geodir_show_country_in_address', $show_country_in_address); |
|
| 1771 | + |
|
| 1772 | + $show_zip_in_address = false; |
|
| 1773 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
| 1774 | + $show_zip_in_address = true; |
|
| 1775 | + } |
|
| 1776 | + /** |
|
| 1777 | + * Filter "show zip in address" value. |
|
| 1778 | + * |
|
| 1779 | + * @since 1.6.6 |
|
| 1780 | + */ |
|
| 1781 | + $show_zip_in_address = apply_filters('geodir_show_zip_in_address', $show_zip_in_address); |
|
| 1782 | + |
|
| 1783 | + |
|
| 1784 | + } |
|
| 1785 | + |
|
| 1786 | + } |
|
| 1787 | + |
|
| 1788 | + |
|
| 1789 | + if ($post->{$html_var}) { |
|
| 1790 | + |
|
| 1791 | + $field_icon = geodir_field_icon_proccess( $cf ); |
|
| 1792 | + if ( strpos( $field_icon, 'http' ) !== false ) { |
|
| 1793 | + $field_icon_af = ''; |
|
| 1794 | + } elseif ( $field_icon == '' ) { |
|
| 1795 | + $field_icon_af = '<i class="fa fa-home"></i>'; |
|
| 1796 | + } else { |
|
| 1797 | + $field_icon_af = $field_icon; |
|
| 1798 | + $field_icon = ''; |
|
| 1799 | + } |
|
| 1800 | 1800 | |
| 1801 | - $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;" itemscope itemtype="https://schema.org/PostalAddress">'; |
|
| 1802 | - $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1803 | - $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : ' '; |
|
| 1804 | - $html .= '</span>'; |
|
| 1801 | + $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;" itemscope itemtype="https://schema.org/PostalAddress">'; |
|
| 1802 | + $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; |
|
| 1803 | + $html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) . ': ' : ' '; |
|
| 1804 | + $html .= '</span>'; |
|
| 1805 | 1805 | |
| 1806 | - $address_fields = array(); |
|
| 1807 | - |
|
| 1808 | - if ( isset($post->post_address) ) { |
|
| 1809 | - $address_fields['post_address'] = '<span itemprop="streetAddress">' . $post->post_address . '</span>'; |
|
| 1810 | - } |
|
| 1811 | - if ($show_city_in_address && isset( $post->post_city ) && $post->post_city ) { |
|
| 1812 | - $address_fields['post_city'] = '<span itemprop="addressLocality">' . $post->post_city . '</span>'; |
|
| 1813 | - } |
|
| 1814 | - if ($show_region_in_address && isset( $post->post_region ) && $post->post_region ) { |
|
| 1815 | - $address_fields['post_region'] = '<span itemprop="addressRegion">' . $post->post_region . '</span>'; |
|
| 1816 | - } |
|
| 1817 | - if ($show_zip_in_address && isset( $post->post_zip ) && $post->post_zip ) { |
|
| 1818 | - $address_fields['post_zip'] = '<span itemprop="postalCode">' . $post->post_zip . '</span>'; |
|
| 1819 | - } |
|
| 1820 | - if ($show_country_in_address && isset( $post->post_country ) && $post->post_country ) { |
|
| 1821 | - $address_fields['post_country'] = '<span itemprop="addressCountry">' . __( $post->post_country, 'geodirectory' ) . '</span>'; |
|
| 1822 | - } |
|
| 1806 | + $address_fields = array(); |
|
| 1807 | + |
|
| 1808 | + if ( isset($post->post_address) ) { |
|
| 1809 | + $address_fields['post_address'] = '<span itemprop="streetAddress">' . $post->post_address . '</span>'; |
|
| 1810 | + } |
|
| 1811 | + if ($show_city_in_address && isset( $post->post_city ) && $post->post_city ) { |
|
| 1812 | + $address_fields['post_city'] = '<span itemprop="addressLocality">' . $post->post_city . '</span>'; |
|
| 1813 | + } |
|
| 1814 | + if ($show_region_in_address && isset( $post->post_region ) && $post->post_region ) { |
|
| 1815 | + $address_fields['post_region'] = '<span itemprop="addressRegion">' . $post->post_region . '</span>'; |
|
| 1816 | + } |
|
| 1817 | + if ($show_zip_in_address && isset( $post->post_zip ) && $post->post_zip ) { |
|
| 1818 | + $address_fields['post_zip'] = '<span itemprop="postalCode">' . $post->post_zip . '</span>'; |
|
| 1819 | + } |
|
| 1820 | + if ($show_country_in_address && isset( $post->post_country ) && $post->post_country ) { |
|
| 1821 | + $address_fields['post_country'] = '<span itemprop="addressCountry">' . __( $post->post_country, 'geodirectory' ) . '</span>'; |
|
| 1822 | + } |
|
| 1823 | 1823 | |
| 1824 | - /** |
|
| 1825 | - * Filter the address fields array being displayed. |
|
| 1826 | - * |
|
| 1827 | - * @param array $address_fields The array of address fields. |
|
| 1828 | - * @param object $post The current post object. |
|
| 1829 | - * @param array $cf The custom field array details. |
|
| 1830 | - * @param string $location The location to output the html. |
|
| 1831 | - * |
|
| 1832 | - * @since 1.6.21 |
|
| 1833 | - */ |
|
| 1834 | - $address_fields = apply_filters('geodir_custom_field_output_address_fields', $address_fields, $post, $cf, $location); |
|
| 1824 | + /** |
|
| 1825 | + * Filter the address fields array being displayed. |
|
| 1826 | + * |
|
| 1827 | + * @param array $address_fields The array of address fields. |
|
| 1828 | + * @param object $post The current post object. |
|
| 1829 | + * @param array $cf The custom field array details. |
|
| 1830 | + * @param string $location The location to output the html. |
|
| 1831 | + * |
|
| 1832 | + * @since 1.6.21 |
|
| 1833 | + */ |
|
| 1834 | + $address_fields = apply_filters('geodir_custom_field_output_address_fields', $address_fields, $post, $cf, $location); |
|
| 1835 | 1835 | |
| 1836 | - if (!empty($address_fields) && is_array($address_fields)) { |
|
| 1837 | - $address_fields = array_values($address_fields); |
|
| 1838 | - $html .= implode('<br>', $address_fields); |
|
| 1839 | - } |
|
| 1836 | + if (!empty($address_fields) && is_array($address_fields)) { |
|
| 1837 | + $address_fields = array_values($address_fields); |
|
| 1838 | + $html .= implode('<br>', $address_fields); |
|
| 1839 | + } |
|
| 1840 | 1840 | |
| 1841 | - $html .= '</div>'; |
|
| 1842 | - } |
|
| 1843 | - } |
|
| 1841 | + $html .= '</div>'; |
|
| 1842 | + } |
|
| 1843 | + } |
|
| 1844 | 1844 | |
| 1845 | - return $html; |
|
| 1845 | + return $html; |
|
| 1846 | 1846 | } |
| 1847 | 1847 | add_filter('geodir_custom_field_output_address','geodir_cf_address',10,3); |
| 1848 | 1848 | \ No newline at end of file |
@@ -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="' . $sub_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="' . $sub_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 | |
@@ -402,49 +402,49 @@ discard block |
||
| 402 | 402 | * @return string The post type. |
| 403 | 403 | */ |
| 404 | 404 | function geodir_get_current_posttype() {
|
| 405 | - global $wp_query, $post, $geodir_post_type; |
|
| 405 | + global $wp_query, $post, $geodir_post_type; |
|
| 406 | 406 | |
| 407 | - $geodir_post_type = get_query_var('post_type');
|
|
| 407 | + $geodir_post_type = get_query_var('post_type');
|
|
| 408 | 408 | |
| 409 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 410 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 411 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 412 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 413 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 414 | - } |
|
| 409 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 410 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 411 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 412 | + elseif (isset($_REQUEST['listing_type'])) |
|
| 413 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 417 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 416 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 417 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 418 | 418 | |
| 419 | - if (is_tax()) |
|
| 420 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 419 | + if (is_tax()) |
|
| 420 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 421 | 421 | |
| 422 | - // Retrive post type for map marker html ajax request on preview page. |
|
| 423 | - if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
|
| 424 | - if (!empty($post->post_type)) {
|
|
| 425 | - $geodir_post_type = $post->post_type; |
|
| 426 | - } else if (!empty($post->listing_type)) {
|
|
| 427 | - $geodir_post_type = $post->listing_type; |
|
| 428 | - } |
|
| 429 | - } |
|
| 422 | + // Retrive post type for map marker html ajax request on preview page. |
|
| 423 | + if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
|
| 424 | + if (!empty($post->post_type)) {
|
|
| 425 | + $geodir_post_type = $post->post_type; |
|
| 426 | + } else if (!empty($post->listing_type)) {
|
|
| 427 | + $geodir_post_type = $post->listing_type; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - $all_postypes = geodir_get_posttypes(); |
|
| 432 | - $all_postypes = stripslashes_deep($all_postypes); |
|
| 431 | + $all_postypes = geodir_get_posttypes(); |
|
| 432 | + $all_postypes = stripslashes_deep($all_postypes); |
|
| 433 | 433 | |
| 434 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 435 | - $geodir_post_type = ''; |
|
| 434 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 435 | + $geodir_post_type = ''; |
|
| 436 | 436 | |
| 437 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 438 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 439 | - } |
|
| 437 | + if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
|
| 438 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Filter the default CPT return. |
|
| 444 | - * |
|
| 445 | - * @since 1.6.9 |
|
| 446 | - */ |
|
| 447 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 442 | + /** |
|
| 443 | + * Filter the default CPT return. |
|
| 444 | + * |
|
| 445 | + * @since 1.6.9 |
|
| 446 | + */ |
|
| 447 | + return apply_filters('geodir_get_current_posttype',$geodir_post_type);
|
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -458,22 +458,22 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function geodir_get_default_posttype() |
| 460 | 460 | {
|
| 461 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 462 | - |
|
| 463 | - $stype = false; |
|
| 464 | - foreach ( $post_types as $post_type => $info ) {
|
|
| 465 | - global $wpdb; |
|
| 466 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 467 | - if ( $has_posts ) {
|
|
| 468 | - $stype = $post_type; break; |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if(!$stype){
|
|
| 473 | - $stype = 'gd_place'; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - return $stype; |
|
| 461 | + $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
| 462 | + |
|
| 463 | + $stype = false; |
|
| 464 | + foreach ( $post_types as $post_type => $info ) {
|
|
| 465 | + global $wpdb; |
|
| 466 | + $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 467 | + if ( $has_posts ) {
|
|
| 468 | + $stype = $post_type; break; |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if(!$stype){
|
|
| 473 | + $stype = 'gd_place'; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + return $stype; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -487,21 +487,21 @@ discard block |
||
| 487 | 487 | */ |
| 488 | 488 | function geodir_get_posttypes($output = 'names') |
| 489 | 489 | {
|
| 490 | - $post_types = array(); |
|
| 491 | - $post_types = get_option('geodir_post_types');
|
|
| 492 | - $post_types = stripslashes_deep($post_types); |
|
| 493 | - if (!empty($post_types)) {
|
|
| 494 | - switch ($output): |
|
| 495 | - case 'object': |
|
| 496 | - case 'Object': |
|
| 497 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 498 | - break; |
|
| 499 | - case 'array': |
|
| 500 | - case 'Array': |
|
| 501 | - $post_types = (array)$post_types; |
|
| 502 | - break; |
|
| 490 | + $post_types = array(); |
|
| 491 | + $post_types = get_option('geodir_post_types');
|
|
| 492 | + $post_types = stripslashes_deep($post_types); |
|
| 493 | + if (!empty($post_types)) {
|
|
| 494 | + switch ($output): |
|
| 495 | + case 'object': |
|
| 496 | + case 'Object': |
|
| 497 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 498 | + break; |
|
| 499 | + case 'array': |
|
| 500 | + case 'Array': |
|
| 501 | + $post_types = (array)$post_types; |
|
| 502 | + break; |
|
| 503 | 503 | case 'options': |
| 504 | - $post_types = (array)$post_types; |
|
| 504 | + $post_types = (array)$post_types; |
|
| 505 | 505 | |
| 506 | 506 | $options = array(); |
| 507 | 507 | if (!empty($post_types)) {
|
@@ -510,17 +510,17 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | $post_types = $options; |
| 513 | - break; |
|
| 514 | - default: |
|
| 515 | - $post_types = array_keys($post_types); |
|
| 516 | - break; |
|
| 517 | - endswitch; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - if (!empty($post_types)) |
|
| 521 | - return $post_types; |
|
| 522 | - else |
|
| 523 | - return array(); |
|
| 513 | + break; |
|
| 514 | + default: |
|
| 515 | + $post_types = array_keys($post_types); |
|
| 516 | + break; |
|
| 517 | + endswitch; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + if (!empty($post_types)) |
|
| 521 | + return $post_types; |
|
| 522 | + else |
|
| 523 | + return array(); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -533,104 +533,104 @@ discard block |
||
| 533 | 533 | */ |
| 534 | 534 | function geodir_get_posttype_info($post_type = '') |
| 535 | 535 | {
|
| 536 | - $post_types = array(); |
|
| 537 | - $post_types = get_option('geodir_post_types');
|
|
| 538 | - $post_types = stripslashes_deep($post_types); |
|
| 539 | - if (!empty($post_types) && $post_type != '') {
|
|
| 540 | - return $post_types[$post_type]; |
|
| 541 | - } else |
|
| 542 | - return false; |
|
| 536 | + $post_types = array(); |
|
| 537 | + $post_types = get_option('geodir_post_types');
|
|
| 538 | + $post_types = stripslashes_deep($post_types); |
|
| 539 | + if (!empty($post_types) && $post_type != '') {
|
|
| 540 | + return $post_types[$post_type]; |
|
| 541 | + } else |
|
| 542 | + return false; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | if (!function_exists('geodir_get_taxonomies')) {
|
| 546 | - /** |
|
| 547 | - * Get all custom taxonomies. |
|
| 548 | - * |
|
| 549 | - * @since 1.0.0 |
|
| 550 | - * @package GeoDirectory |
|
| 551 | - * @param string $post_type The post type. |
|
| 552 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 553 | - * @return array|bool Taxonomies on success. false on failure. |
|
| 554 | - */ |
|
| 555 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
|
|
| 556 | - $taxonomies = array(); |
|
| 557 | - $gd_taxonomies = array(); |
|
| 558 | - |
|
| 559 | - if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 560 | - $gd_taxonomies = array_keys($taxonomies); |
|
| 561 | - |
|
| 562 | - if ($post_type != '') {
|
|
| 563 | - $gd_taxonomies = array(); |
|
| 564 | - } |
|
| 546 | + /** |
|
| 547 | + * Get all custom taxonomies. |
|
| 548 | + * |
|
| 549 | + * @since 1.0.0 |
|
| 550 | + * @package GeoDirectory |
|
| 551 | + * @param string $post_type The post type. |
|
| 552 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 553 | + * @return array|bool Taxonomies on success. false on failure. |
|
| 554 | + */ |
|
| 555 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
|
|
| 556 | + $taxonomies = array(); |
|
| 557 | + $gd_taxonomies = array(); |
|
| 558 | + |
|
| 559 | + if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 560 | + $gd_taxonomies = array_keys($taxonomies); |
|
| 561 | + |
|
| 562 | + if ($post_type != '') {
|
|
| 563 | + $gd_taxonomies = array(); |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - $i = 0; |
|
| 567 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 568 | - if ($post_type != '' && $args['object_type'] == $post_type) {
|
|
| 569 | - $gd_taxonomies[] = $taxonomy; |
|
| 570 | - } |
|
| 566 | + $i = 0; |
|
| 567 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 568 | + if ($post_type != '' && $args['object_type'] == $post_type) {
|
|
| 569 | + $gd_taxonomies[] = $taxonomy; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
|
|
| 573 | - if (array_search($taxonomy, $gd_taxonomies) !== false) {
|
|
| 574 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - } |
|
| 572 | + if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
|
|
| 573 | + if (array_search($taxonomy, $gd_taxonomies) !== false) {
|
|
| 574 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * Filter the taxonomies. |
|
| 584 | - * |
|
| 585 | - * @since 1.0.0 |
|
| 586 | - * @param array $gd_taxonomies The taxonomy array. |
|
| 587 | - */ |
|
| 588 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 589 | - |
|
| 590 | - if (!empty($taxonomies)) {
|
|
| 591 | - return $taxonomies; |
|
| 592 | - } else {
|
|
| 593 | - return false; |
|
| 594 | - } |
|
| 595 | - } |
|
| 579 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * Filter the taxonomies. |
|
| 584 | + * |
|
| 585 | + * @since 1.0.0 |
|
| 586 | + * @param array $gd_taxonomies The taxonomy array. |
|
| 587 | + */ |
|
| 588 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 589 | + |
|
| 590 | + if (!empty($taxonomies)) {
|
|
| 591 | + return $taxonomies; |
|
| 592 | + } else {
|
|
| 593 | + return false; |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | if (!function_exists(' geodir_get_categories_dl')) {
|
| 599 | - /** |
|
| 600 | - * Get categories dropdown HTML. |
|
| 601 | - * |
|
| 602 | - * @since 1.0.0 |
|
| 603 | - * @package GeoDirectory |
|
| 604 | - * @param string $post_type The post type. |
|
| 605 | - * @param string $selected The selected value. |
|
| 606 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 607 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 608 | - * @return void|string Dropdown HTML. |
|
| 609 | - */ |
|
| 610 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 611 | - {
|
|
| 612 | - |
|
| 613 | - $html = ''; |
|
| 614 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 615 | - |
|
| 616 | - $categories = get_terms($taxonomies); |
|
| 617 | - |
|
| 618 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 619 | - |
|
| 620 | - foreach ($categories as $category_obj) {
|
|
| 621 | - $select_opt = ''; |
|
| 622 | - if ($selected == $category_obj->term_id) {
|
|
| 623 | - $select_opt = 'selected="selected"'; |
|
| 624 | - } |
|
| 625 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 626 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - if ($echo) |
|
| 630 | - echo $html; |
|
| 631 | - else |
|
| 632 | - return $html; |
|
| 633 | - } |
|
| 599 | + /** |
|
| 600 | + * Get categories dropdown HTML. |
|
| 601 | + * |
|
| 602 | + * @since 1.0.0 |
|
| 603 | + * @package GeoDirectory |
|
| 604 | + * @param string $post_type The post type. |
|
| 605 | + * @param string $selected The selected value. |
|
| 606 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 607 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 608 | + * @return void|string Dropdown HTML. |
|
| 609 | + */ |
|
| 610 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 611 | + {
|
|
| 612 | + |
|
| 613 | + $html = ''; |
|
| 614 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 615 | + |
|
| 616 | + $categories = get_terms($taxonomies); |
|
| 617 | + |
|
| 618 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 619 | + |
|
| 620 | + foreach ($categories as $category_obj) {
|
|
| 621 | + $select_opt = ''; |
|
| 622 | + if ($selected == $category_obj->term_id) {
|
|
| 623 | + $select_opt = 'selected="selected"'; |
|
| 624 | + } |
|
| 625 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 626 | + . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if ($echo) |
|
| 630 | + echo $html; |
|
| 631 | + else |
|
| 632 | + return $html; |
|
| 633 | + } |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | |
@@ -645,28 +645,28 @@ discard block |
||
| 645 | 645 | function geodir_get_listing_slug($object_type = '') |
| 646 | 646 | {
|
| 647 | 647 | |
| 648 | - $listing_slug = ''; |
|
| 648 | + $listing_slug = ''; |
|
| 649 | 649 | |
| 650 | - $post_types = get_option('geodir_post_types');
|
|
| 651 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 650 | + $post_types = get_option('geodir_post_types');
|
|
| 651 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 652 | 652 | |
| 653 | 653 | |
| 654 | - if ($object_type != '') {
|
|
| 655 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 654 | + if ($object_type != '') {
|
|
| 655 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 656 | 656 | |
| 657 | - $object_info = $post_types[$object_type]; |
|
| 658 | - $listing_slug = $object_info['listing_slug']; |
|
| 659 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 660 | - $object_info = $taxonomies[$object_type]; |
|
| 661 | - $listing_slug = $object_info['listing_slug']; |
|
| 662 | - } |
|
| 657 | + $object_info = $post_types[$object_type]; |
|
| 658 | + $listing_slug = $object_info['listing_slug']; |
|
| 659 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 660 | + $object_info = $taxonomies[$object_type]; |
|
| 661 | + $listing_slug = $object_info['listing_slug']; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - } |
|
| 664 | + } |
|
| 665 | 665 | |
| 666 | - if (!empty($listing_slug)) |
|
| 667 | - return $listing_slug; |
|
| 668 | - else |
|
| 669 | - return false; |
|
| 666 | + if (!empty($listing_slug)) |
|
| 667 | + return $listing_slug; |
|
| 668 | + else |
|
| 669 | + return false; |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
@@ -681,212 +681,212 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | function geodir_get_taxonomy_posttype($taxonomy = '') |
| 683 | 683 | {
|
| 684 | - global $wp_query; |
|
| 685 | - |
|
| 686 | - $post_type = array(); |
|
| 687 | - $taxonomies = array(); |
|
| 688 | - |
|
| 689 | - if (!empty($taxonomy)) {
|
|
| 690 | - $taxonomies[] = $taxonomy; |
|
| 691 | - } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 692 | - $tax_arr = $wp_query->tax_query->queries; |
|
| 693 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 694 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 695 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - if (!empty($taxonomies)) {
|
|
| 699 | - foreach (geodir_get_posttypes() as $pt) {
|
|
| 700 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 701 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 702 | - $post_type[] = $pt; |
|
| 703 | - } |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - if (!empty($post_type)) |
|
| 707 | - return $post_type[0]; |
|
| 708 | - else |
|
| 709 | - return false; |
|
| 684 | + global $wp_query; |
|
| 685 | + |
|
| 686 | + $post_type = array(); |
|
| 687 | + $taxonomies = array(); |
|
| 688 | + |
|
| 689 | + if (!empty($taxonomy)) {
|
|
| 690 | + $taxonomies[] = $taxonomy; |
|
| 691 | + } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 692 | + $tax_arr = $wp_query->tax_query->queries; |
|
| 693 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 694 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 695 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + if (!empty($taxonomies)) {
|
|
| 699 | + foreach (geodir_get_posttypes() as $pt) {
|
|
| 700 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 701 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 702 | + $post_type[] = $pt; |
|
| 703 | + } |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + if (!empty($post_type)) |
|
| 707 | + return $post_type[0]; |
|
| 708 | + else |
|
| 709 | + return false; |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 713 | - /** |
|
| 714 | - * Custom taxonomy walker function. |
|
| 715 | - * |
|
| 716 | - * @since 1.0.0 |
|
| 717 | - * @package GeoDirectory |
|
| 718 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 719 | - * @param int $cat_parent The parent term ID. |
|
| 720 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 721 | - * @param int $pading CSS padding in pixels. |
|
| 722 | - * @return string|void taxonomy HTML. |
|
| 723 | - */ |
|
| 724 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 725 | - {
|
|
| 726 | - global $cat_display, $post_cat, $exclude_cats; |
|
| 727 | - |
|
| 728 | - $search_terms = trim($post_cat, ","); |
|
| 729 | - |
|
| 730 | - $search_terms = explode(",", $search_terms);
|
|
| 731 | - |
|
| 732 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 733 | - |
|
| 734 | - $display = ''; |
|
| 735 | - $onchange = ''; |
|
| 736 | - $term_check = ''; |
|
| 737 | - $main_list_class = ''; |
|
| 738 | - $out = ''; |
|
| 739 | - //If there are terms, start displaying |
|
| 740 | - if (count($cat_terms) > 0) {
|
|
| 741 | - //Displaying as a list |
|
| 742 | - $p = $pading * 20; |
|
| 743 | - $pading++; |
|
| 744 | - |
|
| 745 | - |
|
| 746 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 747 | - if ($cat_parent == 0) {
|
|
| 748 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 749 | - $main_list_class = 'class="main_list_selecter"'; |
|
| 750 | - } else {
|
|
| 751 | - //$display = 'display:none'; |
|
| 752 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
| 753 | - } |
|
| 754 | - } |
|
| 713 | + /** |
|
| 714 | + * Custom taxonomy walker function. |
|
| 715 | + * |
|
| 716 | + * @since 1.0.0 |
|
| 717 | + * @package GeoDirectory |
|
| 718 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 719 | + * @param int $cat_parent The parent term ID. |
|
| 720 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 721 | + * @param int $pading CSS padding in pixels. |
|
| 722 | + * @return string|void taxonomy HTML. |
|
| 723 | + */ |
|
| 724 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 725 | + {
|
|
| 726 | + global $cat_display, $post_cat, $exclude_cats; |
|
| 727 | + |
|
| 728 | + $search_terms = trim($post_cat, ","); |
|
| 729 | + |
|
| 730 | + $search_terms = explode(",", $search_terms);
|
|
| 731 | + |
|
| 732 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 733 | + |
|
| 734 | + $display = ''; |
|
| 735 | + $onchange = ''; |
|
| 736 | + $term_check = ''; |
|
| 737 | + $main_list_class = ''; |
|
| 738 | + $out = ''; |
|
| 739 | + //If there are terms, start displaying |
|
| 740 | + if (count($cat_terms) > 0) {
|
|
| 741 | + //Displaying as a list |
|
| 742 | + $p = $pading * 20; |
|
| 743 | + $pading++; |
|
| 744 | + |
|
| 745 | + |
|
| 746 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 747 | + if ($cat_parent == 0) {
|
|
| 748 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 749 | + $main_list_class = 'class="main_list_selecter"'; |
|
| 750 | + } else {
|
|
| 751 | + //$display = 'display:none'; |
|
| 752 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
| 753 | + } |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 757 | - $p = 0; |
|
| 758 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 759 | - } |
|
| 756 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 757 | + $p = 0; |
|
| 758 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - foreach ($cat_terms as $cat_term) {
|
|
| 761 | + foreach ($cat_terms as $cat_term) {
|
|
| 762 | 762 | |
| 763 | - $checked = ''; |
|
| 763 | + $checked = ''; |
|
| 764 | 764 | |
| 765 | - if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 766 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 767 | - $checked = 'selected="selected"'; |
|
| 768 | - else |
|
| 769 | - $checked = 'checked="checked"'; |
|
| 770 | - } |
|
| 765 | + if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 766 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 767 | + $checked = 'selected="selected"'; |
|
| 768 | + else |
|
| 769 | + $checked = 'checked="checked"'; |
|
| 770 | + } |
|
| 771 | 771 | |
| 772 | - if ($cat_display == 'radio') |
|
| 773 | - $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>'; |
|
| 774 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 775 | - $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>'; |
|
| 772 | + if ($cat_display == 'radio') |
|
| 773 | + $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>'; |
|
| 774 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 775 | + $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>'; |
|
| 776 | 776 | |
| 777 | - else {
|
|
| 778 | - $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>'; |
|
| 779 | - } |
|
| 777 | + else {
|
|
| 778 | + $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>'; |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - // Call recurson to print sub cats |
|
| 782 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 781 | + // Call recurson to print sub cats |
|
| 782 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 783 | 783 | |
| 784 | - } |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 787 | - $out .= '</div>'; |
|
| 786 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 787 | + $out .= '</div>'; |
|
| 788 | 788 | |
| 789 | - return $out; |
|
| 790 | - } |
|
| 791 | - return; |
|
| 792 | - } |
|
| 789 | + return $out; |
|
| 790 | + } |
|
| 791 | + return; |
|
| 792 | + } |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | if (!function_exists('geodir_custom_taxonomy_walker2')) {
|
| 796 | - /** |
|
| 797 | - * Custom taxonomy walker function. |
|
| 798 | - * |
|
| 799 | - * @since 1.0.0 |
|
| 800 | - * @package GeoDirectory |
|
| 801 | - * @global object $post WordPress Post object. |
|
| 802 | - * @global object $gd_session GeoDirectory Session object. |
|
| 803 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 804 | - * @param string $cat_limit Number of categories to display. |
|
| 805 | - */ |
|
| 806 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 807 | - {
|
|
| 808 | - $post_category = ''; |
|
| 809 | - $post_category_str = ''; |
|
| 810 | - global $exclude_cats, $gd_session; |
|
| 811 | - |
|
| 812 | - $cat_exclude = ''; |
|
| 813 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 814 | - $cat_exclude = serialize($exclude_cats); |
|
| 815 | - |
|
| 816 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 817 | - $post = (object)$gd_session->get('listing');
|
|
| 818 | - |
|
| 819 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 820 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 821 | - |
|
| 822 | - $post_categories = $post->post_category_str; |
|
| 823 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 824 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 825 | - |
|
| 826 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 827 | - global $post; |
|
| 828 | - |
|
| 829 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 830 | - if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 831 | - $post_category = $post->{$cat_taxonomy};
|
|
| 832 | - } |
|
| 796 | + /** |
|
| 797 | + * Custom taxonomy walker function. |
|
| 798 | + * |
|
| 799 | + * @since 1.0.0 |
|
| 800 | + * @package GeoDirectory |
|
| 801 | + * @global object $post WordPress Post object. |
|
| 802 | + * @global object $gd_session GeoDirectory Session object. |
|
| 803 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 804 | + * @param string $cat_limit Number of categories to display. |
|
| 805 | + */ |
|
| 806 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 807 | + {
|
|
| 808 | + $post_category = ''; |
|
| 809 | + $post_category_str = ''; |
|
| 810 | + global $exclude_cats, $gd_session; |
|
| 811 | + |
|
| 812 | + $cat_exclude = ''; |
|
| 813 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 814 | + $cat_exclude = serialize($exclude_cats); |
|
| 815 | + |
|
| 816 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 817 | + $post = (object)$gd_session->get('listing');
|
|
| 818 | + |
|
| 819 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 820 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 821 | + |
|
| 822 | + $post_categories = $post->post_category_str; |
|
| 823 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 824 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 825 | + |
|
| 826 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 827 | + global $post; |
|
| 828 | + |
|
| 829 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 830 | + if (empty($post_category) && isset($post->{$cat_taxonomy})) {
|
|
| 831 | + $post_category = $post->{$cat_taxonomy};
|
|
| 832 | + } |
|
| 833 | 833 | |
| 834 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 834 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 835 | 835 | |
| 836 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 837 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 838 | - if (is_numeric($cat_part)) {
|
|
| 839 | - $cat_part_arr[] = $cat_part; |
|
| 840 | - } |
|
| 841 | - } |
|
| 842 | - if (is_array($cat_part_arr)) {
|
|
| 843 | - $post_category = implode(',', $cat_part_arr);
|
|
| 844 | - } |
|
| 845 | - } |
|
| 836 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 837 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 838 | + if (is_numeric($cat_part)) {
|
|
| 839 | + $cat_part_arr[] = $cat_part; |
|
| 840 | + } |
|
| 841 | + } |
|
| 842 | + if (is_array($cat_part_arr)) {
|
|
| 843 | + $post_category = implode(',', $cat_part_arr);
|
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | 846 | |
| 847 | - if (!empty($post_category)) {
|
|
| 848 | - $cat1 = array_filter(explode(',', $post_category));
|
|
| 849 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 847 | + if (!empty($post_category)) {
|
|
| 848 | + $cat1 = array_filter(explode(',', $post_category));
|
|
| 849 | + $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 850 | 850 | |
| 851 | - } |
|
| 851 | + } |
|
| 852 | 852 | |
| 853 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 853 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 854 | 854 | |
| 855 | - $post_category_upd = explode(',', $post_category);
|
|
| 856 | - $post_category_change = ''; |
|
| 857 | - foreach ($post_category_upd as $cat) {
|
|
| 855 | + $post_category_upd = explode(',', $post_category);
|
|
| 856 | + $post_category_change = ''; |
|
| 857 | + foreach ($post_category_upd as $cat) {
|
|
| 858 | 858 | |
| 859 | - if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 860 | - $post_category_change .= ',' . $cat; |
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - $post_category = $post_category_change; |
|
| 864 | - } |
|
| 859 | + if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 860 | + $post_category_change .= ',' . $cat; |
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + $post_category = $post_category_change; |
|
| 864 | + } |
|
| 865 | 865 | |
| 866 | 866 | |
| 867 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 868 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 869 | - } |
|
| 870 | - } |
|
| 867 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 868 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 869 | + } |
|
| 870 | + } |
|
| 871 | 871 | |
| 872 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 872 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 873 | 873 | |
| 874 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 874 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 875 | 875 | |
| 876 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 876 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 877 | 877 | |
| 878 | 878 | |
| 879 | - ?> |
|
| 879 | + ?> |
|
| 880 | 880 | <div class="cat_sublist"> |
| 881 | 881 | <?php |
| 882 | 882 | |
| 883 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 883 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 884 | 884 | |
| 885 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 885 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 886 | 886 | |
| 887 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 888 | - } |
|
| 889 | - ?> |
|
| 887 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 888 | + } |
|
| 889 | + ?> |
|
| 890 | 890 | </div> |
| 891 | 891 | <script type="text/javascript"> |
| 892 | 892 | |
@@ -1009,22 +1009,22 @@ discard block |
||
| 1009 | 1009 | |
| 1010 | 1010 | </script> |
| 1011 | 1011 | <?php |
| 1012 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1013 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1014 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1015 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1016 | - $style = "display:none;"; |
|
| 1017 | - } |
|
| 1018 | - ?> |
|
| 1012 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 1013 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 1014 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1015 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1016 | + $style = "display:none;"; |
|
| 1017 | + } |
|
| 1018 | + ?> |
|
| 1019 | 1019 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 1020 | - echo $style; |
|
| 1021 | - }?> "> |
|
| 1020 | + echo $style; |
|
| 1021 | + }?> "> |
|
| 1022 | 1022 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
| 1023 | - ?> |
|
| 1023 | + ?> |
|
| 1024 | 1024 | </div> |
| 1025 | 1025 | <?php |
| 1026 | 1026 | |
| 1027 | - } |
|
| 1027 | + } |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | /** |
@@ -1041,23 +1041,23 @@ discard block |
||
| 1041 | 1041 | */ |
| 1042 | 1042 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
| 1043 | 1043 | {
|
| 1044 | - global $exclude_cats; |
|
| 1044 | + global $exclude_cats; |
|
| 1045 | 1045 | |
| 1046 | - if ($exclude != '') {
|
|
| 1047 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1046 | + if ($exclude != '') {
|
|
| 1047 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 1048 | 1048 | |
| 1049 | - if(is_array( $exclude_cats)){
|
|
| 1050 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1051 | - }else{
|
|
| 1052 | - $exclude_cats = intval($exclude_cats); |
|
| 1053 | - } |
|
| 1049 | + if(is_array( $exclude_cats)){
|
|
| 1050 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1051 | + }else{
|
|
| 1052 | + $exclude_cats = intval($exclude_cats); |
|
| 1053 | + } |
|
| 1054 | 1054 | |
| 1055 | - } |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1058 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1059 | - ) {
|
|
| 1060 | - ?> |
|
| 1057 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1058 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1059 | + ) {
|
|
| 1060 | + ?> |
|
| 1061 | 1061 | |
| 1062 | 1062 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1063 | 1063 | |
@@ -1086,8 +1086,8 @@ discard block |
||
| 1086 | 1086 | |
| 1087 | 1087 | <br/> |
| 1088 | 1088 | <?php |
| 1089 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1090 | - if (!empty($cat_terms)) { ?>
|
|
| 1089 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1090 | + if (!empty($cat_terms)) { ?>
|
|
| 1091 | 1091 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
|
| 1092 | 1092 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
| 1093 | 1093 | <?php } ?> |
@@ -1109,53 +1109,53 @@ discard block |
||
| 1109 | 1109 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
| 1110 | 1110 | {
|
| 1111 | 1111 | |
| 1112 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1113 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1114 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1115 | - if (is_array($post_cat_array)) {
|
|
| 1116 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1112 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1113 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1114 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1115 | + if (is_array($post_cat_array)) {
|
|
| 1116 | + $post_cat_array = array_unique( $post_cat_array ); |
|
| 1117 | 1117 | |
| 1118 | 1118 | foreach ($post_cat_array as $post_cat_html) {
|
| 1119 | 1119 | |
| 1120 | - $post_cat_info = explode(":", $post_cat_html);
|
|
| 1121 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1120 | + $post_cat_info = explode(":", $post_cat_html);
|
|
| 1121 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1122 | 1122 | |
| 1123 | - if (!empty($post_maincat_str)) {
|
|
| 1124 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1125 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1126 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1127 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1128 | - } |
|
| 1129 | - $post_sub_catid = ''; |
|
| 1130 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1131 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1132 | - } |
|
| 1123 | + if (!empty($post_maincat_str)) {
|
|
| 1124 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1125 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1126 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1127 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1128 | + } |
|
| 1129 | + $post_sub_catid = ''; |
|
| 1130 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1131 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1134 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1135 | 1135 | |
| 1136 | - } |
|
| 1137 | - } else {
|
|
| 1136 | + } |
|
| 1137 | + } else {
|
|
| 1138 | 1138 | |
| 1139 | - $post_cat_info = explode(":", $post_cat_str);
|
|
| 1140 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1139 | + $post_cat_info = explode(":", $post_cat_str);
|
|
| 1140 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1141 | 1141 | |
| 1142 | - $post_sub_catid = ''; |
|
| 1142 | + $post_sub_catid = ''; |
|
| 1143 | 1143 | |
| 1144 | - if (!empty($post_maincat_str)) {
|
|
| 1145 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1146 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1147 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1148 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1149 | - } |
|
| 1144 | + if (!empty($post_maincat_str)) {
|
|
| 1145 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1146 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1147 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1148 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1152 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1153 | - } |
|
| 1151 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1152 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1155 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1156 | 1156 | |
| 1157 | - } |
|
| 1158 | - } |
|
| 1157 | + } |
|
| 1158 | + } |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | /** |
@@ -1169,35 +1169,35 @@ discard block |
||
| 1169 | 1169 | */ |
| 1170 | 1170 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
| 1171 | 1171 | {
|
| 1172 | - global $exclude_cats; |
|
| 1172 | + global $exclude_cats; |
|
| 1173 | 1173 | |
| 1174 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1174 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1175 | 1175 | |
| 1176 | - if (!empty($cat_terms)) {
|
|
| 1177 | - $onchange = ''; |
|
| 1178 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1176 | + if (!empty($cat_terms)) {
|
|
| 1177 | + $onchange = ''; |
|
| 1178 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1179 | 1179 | |
| 1180 | - $option_selected = ''; |
|
| 1181 | - if (!$selected) |
|
| 1182 | - $option_slected = ' selected="selected" '; |
|
| 1180 | + $option_selected = ''; |
|
| 1181 | + if (!$selected) |
|
| 1182 | + $option_slected = ' selected="selected" '; |
|
| 1183 | 1183 | |
| 1184 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1184 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1185 | 1185 | |
| 1186 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1186 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1187 | 1187 | |
| 1188 | - foreach ($cat_terms as $cat_term) {
|
|
| 1189 | - $option_selected = ''; |
|
| 1190 | - if ($selected == $cat_term->term_id) |
|
| 1191 | - $option_selected = ' selected="selected" '; |
|
| 1188 | + foreach ($cat_terms as $cat_term) {
|
|
| 1189 | + $option_selected = ''; |
|
| 1190 | + if ($selected == $cat_term->term_id) |
|
| 1191 | + $option_selected = ' selected="selected" '; |
|
| 1192 | 1192 | |
| 1193 | - // Count child terms |
|
| 1194 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1195 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1193 | + // Count child terms |
|
| 1194 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1195 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1196 | 1196 | |
| 1197 | - 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>'; |
|
| 1198 | - } |
|
| 1199 | - echo '</select>'; |
|
| 1200 | - } |
|
| 1197 | + 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>'; |
|
| 1198 | + } |
|
| 1199 | + echo '</select>'; |
|
| 1200 | + } |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | /** |
@@ -1213,28 +1213,28 @@ discard block |
||
| 1213 | 1213 | */ |
| 1214 | 1214 | function geodir_custom_update_messages($messages) |
| 1215 | 1215 | {
|
| 1216 | - global $post, $post_ID; |
|
| 1217 | - |
|
| 1218 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1219 | - |
|
| 1220 | - foreach ($post_types as $post_type => $post_object) {
|
|
| 1221 | - |
|
| 1222 | - $messages[$post_type] = array( |
|
| 1223 | - 0 => '', // Unused. Messages start at index 1. |
|
| 1224 | - 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),
|
|
| 1225 | - 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1226 | - 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1227 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1228 | - 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,
|
|
| 1229 | - 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),
|
|
| 1230 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1231 | - 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),
|
|
| 1232 | - 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),
|
|
| 1233 | - 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),
|
|
| 1234 | - ); |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - return $messages; |
|
| 1216 | + global $post, $post_ID; |
|
| 1217 | + |
|
| 1218 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1219 | + |
|
| 1220 | + foreach ($post_types as $post_type => $post_object) {
|
|
| 1221 | + |
|
| 1222 | + $messages[$post_type] = array( |
|
| 1223 | + 0 => '', // Unused. Messages start at index 1. |
|
| 1224 | + 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),
|
|
| 1225 | + 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1226 | + 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1227 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1228 | + 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,
|
|
| 1229 | + 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),
|
|
| 1230 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1231 | + 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),
|
|
| 1232 | + 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),
|
|
| 1233 | + 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),
|
|
| 1234 | + ); |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + return $messages; |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | |
@@ -1249,182 +1249,182 @@ discard block |
||
| 1249 | 1249 | function geodir_register_defaults() |
| 1250 | 1250 | {
|
| 1251 | 1251 | |
| 1252 | - global $wpdb; |
|
| 1253 | - |
|
| 1254 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1255 | - |
|
| 1256 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1257 | - $listing_slug = 'places'; |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * Taxonomies |
|
| 1261 | - **/ |
|
| 1262 | - //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1263 | - {
|
|
| 1264 | - |
|
| 1265 | - $gd_placetags = array(); |
|
| 1266 | - $gd_placetags['object_type'] = 'gd_place'; |
|
| 1267 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1268 | - $gd_placetags['args'] = array( |
|
| 1269 | - 'public' => true, |
|
| 1270 | - 'hierarchical' => false, |
|
| 1271 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1272 | - 'query_var' => true, |
|
| 1273 | - |
|
| 1274 | - 'labels' => array( |
|
| 1275 | - 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1276 | - 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1277 | - 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1278 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1279 | - 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1280 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1281 | - 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1282 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1283 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1284 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1285 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1286 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1287 | - ), |
|
| 1288 | - ); |
|
| 1289 | - |
|
| 1290 | - |
|
| 1291 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1292 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1293 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1294 | - |
|
| 1295 | - |
|
| 1296 | - // Update post types and delete tmp options |
|
| 1297 | - flush_rewrite_rules(); |
|
| 1298 | - |
|
| 1299 | - } |
|
| 1300 | - |
|
| 1301 | - //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1302 | - {
|
|
| 1303 | - |
|
| 1304 | - $gd_placecategory = array(); |
|
| 1305 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1306 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1307 | - $gd_placecategory['args'] = array( |
|
| 1308 | - 'public' => true, |
|
| 1309 | - 'hierarchical' => true, |
|
| 1310 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1311 | - 'query_var' => true, |
|
| 1312 | - 'labels' => array( |
|
| 1313 | - 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1314 | - 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1315 | - 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1316 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1317 | - 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1318 | - 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1319 | - 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1320 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1321 | - 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1322 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1323 | - ), |
|
| 1324 | - ); |
|
| 1325 | - |
|
| 1326 | - |
|
| 1327 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1328 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1329 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1330 | - |
|
| 1331 | - |
|
| 1332 | - flush_rewrite_rules(); |
|
| 1333 | - } |
|
| 1334 | - |
|
| 1335 | - /** |
|
| 1336 | - * Post Types |
|
| 1337 | - **/ |
|
| 1338 | - |
|
| 1339 | - //if ( ! post_type_exists('gd_place') )
|
|
| 1340 | - {
|
|
| 1341 | - |
|
| 1342 | - $labels = array( |
|
| 1343 | - 'name' => __('Places', 'geodirectory'),
|
|
| 1344 | - 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1345 | - 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1346 | - 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1347 | - 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1348 | - 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1349 | - 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1350 | - 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1351 | - 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1352 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1353 | - |
|
| 1354 | - $place_default = array( |
|
| 1355 | - 'labels' => $labels, |
|
| 1356 | - 'can_export' => true, |
|
| 1357 | - 'capability_type' => 'post', |
|
| 1358 | - 'description' => 'Place post type.', |
|
| 1359 | - 'has_archive' => $listing_slug, |
|
| 1360 | - 'hierarchical' => false, |
|
| 1361 | - 'map_meta_cap' => true, |
|
| 1362 | - 'menu_icon' => $menu_icon, |
|
| 1363 | - 'public' => true, |
|
| 1364 | - 'query_var' => true, |
|
| 1365 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1366 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1367 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1368 | - |
|
| 1369 | - //Update custom post types |
|
| 1370 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 1371 | - $geodir_post_types['gd_place'] = $place_default; |
|
| 1372 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 1373 | - |
|
| 1374 | - // Update post types and delete tmp options |
|
| 1375 | - flush_rewrite_rules(); |
|
| 1376 | - } |
|
| 1377 | - |
|
| 1378 | - |
|
| 1379 | - geodir_register_taxonomies(); |
|
| 1380 | - geodir_register_post_types(); |
|
| 1381 | - |
|
| 1382 | - //die; |
|
| 1252 | + global $wpdb; |
|
| 1253 | + |
|
| 1254 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1255 | + |
|
| 1256 | + if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1257 | + $listing_slug = 'places'; |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * Taxonomies |
|
| 1261 | + **/ |
|
| 1262 | + //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1263 | + {
|
|
| 1264 | + |
|
| 1265 | + $gd_placetags = array(); |
|
| 1266 | + $gd_placetags['object_type'] = 'gd_place'; |
|
| 1267 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1268 | + $gd_placetags['args'] = array( |
|
| 1269 | + 'public' => true, |
|
| 1270 | + 'hierarchical' => false, |
|
| 1271 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1272 | + 'query_var' => true, |
|
| 1273 | + |
|
| 1274 | + 'labels' => array( |
|
| 1275 | + 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1276 | + 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1277 | + 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1278 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1279 | + 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1280 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1281 | + 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1282 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1283 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1284 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1285 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1286 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1287 | + ), |
|
| 1288 | + ); |
|
| 1289 | + |
|
| 1290 | + |
|
| 1291 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1292 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1293 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1294 | + |
|
| 1295 | + |
|
| 1296 | + // Update post types and delete tmp options |
|
| 1297 | + flush_rewrite_rules(); |
|
| 1298 | + |
|
| 1299 | + } |
|
| 1300 | + |
|
| 1301 | + //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1302 | + {
|
|
| 1303 | + |
|
| 1304 | + $gd_placecategory = array(); |
|
| 1305 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1306 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1307 | + $gd_placecategory['args'] = array( |
|
| 1308 | + 'public' => true, |
|
| 1309 | + 'hierarchical' => true, |
|
| 1310 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1311 | + 'query_var' => true, |
|
| 1312 | + 'labels' => array( |
|
| 1313 | + 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1314 | + 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1315 | + 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1316 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1317 | + 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1318 | + 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1319 | + 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1320 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1321 | + 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1322 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1323 | + ), |
|
| 1324 | + ); |
|
| 1325 | + |
|
| 1326 | + |
|
| 1327 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1328 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1329 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1330 | + |
|
| 1331 | + |
|
| 1332 | + flush_rewrite_rules(); |
|
| 1333 | + } |
|
| 1334 | + |
|
| 1335 | + /** |
|
| 1336 | + * Post Types |
|
| 1337 | + **/ |
|
| 1338 | + |
|
| 1339 | + //if ( ! post_type_exists('gd_place') )
|
|
| 1340 | + {
|
|
| 1341 | + |
|
| 1342 | + $labels = array( |
|
| 1343 | + 'name' => __('Places', 'geodirectory'),
|
|
| 1344 | + 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1345 | + 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1346 | + 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1347 | + 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1348 | + 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1349 | + 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1350 | + 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1351 | + 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1352 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1353 | + |
|
| 1354 | + $place_default = array( |
|
| 1355 | + 'labels' => $labels, |
|
| 1356 | + 'can_export' => true, |
|
| 1357 | + 'capability_type' => 'post', |
|
| 1358 | + 'description' => 'Place post type.', |
|
| 1359 | + 'has_archive' => $listing_slug, |
|
| 1360 | + 'hierarchical' => false, |
|
| 1361 | + 'map_meta_cap' => true, |
|
| 1362 | + 'menu_icon' => $menu_icon, |
|
| 1363 | + 'public' => true, |
|
| 1364 | + 'query_var' => true, |
|
| 1365 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
|
|
| 1366 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1367 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1368 | + |
|
| 1369 | + //Update custom post types |
|
| 1370 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 1371 | + $geodir_post_types['gd_place'] = $place_default; |
|
| 1372 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 1373 | + |
|
| 1374 | + // Update post types and delete tmp options |
|
| 1375 | + flush_rewrite_rules(); |
|
| 1376 | + } |
|
| 1377 | + |
|
| 1378 | + |
|
| 1379 | + geodir_register_taxonomies(); |
|
| 1380 | + geodir_register_post_types(); |
|
| 1381 | + |
|
| 1382 | + //die; |
|
| 1383 | 1383 | |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | $gd_wpml_get_languages = ""; |
| 1387 | 1387 | function gd_wpml_get_lang_from_url($url) {
|
| 1388 | - global $sitepress, $gd_wpml_get_languages; |
|
| 1388 | + global $sitepress, $gd_wpml_get_languages; |
|
| 1389 | 1389 | |
| 1390 | - if (geodir_is_wpml()) {
|
|
| 1391 | - return $sitepress->get_language_from_url($url); |
|
| 1392 | - } |
|
| 1390 | + if (geodir_is_wpml()) {
|
|
| 1391 | + return $sitepress->get_language_from_url($url); |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1395 | - return $_REQUEST['lang']; |
|
| 1396 | - } |
|
| 1394 | + if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
|
|
| 1395 | + return $_REQUEST['lang']; |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1398 | + $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1399 | 1399 | |
| 1400 | - // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1401 | - $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1400 | + // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
|
|
| 1401 | + $site_url = str_replace(array("http://","https://"),"",site_url());
|
|
| 1402 | 1402 | |
| 1403 | - $url = str_replace($site_url,"",$url); |
|
| 1403 | + $url = str_replace($site_url,"",$url); |
|
| 1404 | 1404 | |
| 1405 | - $segments = explode('/', trim($url, '/'));
|
|
| 1405 | + $segments = explode('/', trim($url, '/'));
|
|
| 1406 | 1406 | |
| 1407 | - if ($gd_wpml_get_languages) {
|
|
| 1408 | - $langs = $gd_wpml_get_languages; |
|
| 1409 | - } else {
|
|
| 1410 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1411 | - } |
|
| 1407 | + if ($gd_wpml_get_languages) {
|
|
| 1408 | + $langs = $gd_wpml_get_languages; |
|
| 1409 | + } else {
|
|
| 1410 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1411 | + } |
|
| 1412 | 1412 | |
| 1413 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1414 | - return $segments[0]; |
|
| 1415 | - } |
|
| 1413 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1414 | + return $segments[0]; |
|
| 1415 | + } |
|
| 1416 | 1416 | |
| 1417 | - return false; |
|
| 1417 | + return false; |
|
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | function gd_wpml_slug_translation_turned_on($post_type) {
|
| 1421 | 1421 | |
| 1422 | - global $sitepress; |
|
| 1423 | - $settings = $sitepress->get_settings(); |
|
| 1424 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1425 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1426 | - && isset($settings['posts_slug_translation']['on']) |
|
| 1427 | - && $settings['posts_slug_translation']['on']; |
|
| 1422 | + global $sitepress; |
|
| 1423 | + $settings = $sitepress->get_settings(); |
|
| 1424 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1425 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1426 | + && isset($settings['posts_slug_translation']['on']) |
|
| 1427 | + && $settings['posts_slug_translation']['on']; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | |
@@ -1451,162 +1451,162 @@ discard block |
||
| 1451 | 1451 | */ |
| 1452 | 1452 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
| 1453 | 1453 | {
|
| 1454 | - //echo $post_link."<br />".$sample ; |
|
| 1454 | + //echo $post_link."<br />".$sample ; |
|
| 1455 | 1455 | |
| 1456 | 1456 | |
| 1457 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache, $gd_cache_post; |
|
| 1458 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1459 | - if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;}
|
|
| 1460 | - } elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) {
|
|
| 1461 | - return $post_link; |
|
| 1462 | - } else {
|
|
| 1463 | - $orig_post = $post; |
|
| 1464 | - $post = $post_obj; |
|
| 1465 | - } |
|
| 1457 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache, $gd_cache_post; |
|
| 1458 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1459 | + if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;}
|
|
| 1460 | + } elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) {
|
|
| 1461 | + return $post_link; |
|
| 1462 | + } else {
|
|
| 1463 | + $orig_post = $post; |
|
| 1464 | + $post = $post_obj; |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | 1467 | |
| 1468 | 1468 | |
| 1469 | - if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit;
|
|
| 1469 | + if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit;
|
|
| 1470 | 1470 | |
| 1471 | 1471 | |
| 1472 | - // if we dont have a GD post then try to grab it |
|
| 1473 | - if(!isset($post->default_category)){
|
|
| 1474 | - $gd_post = geodir_get_post_info($post->ID); |
|
| 1475 | - if(!empty($gd_post)){
|
|
| 1476 | - $post = $gd_post; |
|
| 1477 | - } |
|
| 1478 | - } |
|
| 1472 | + // if we dont have a GD post then try to grab it |
|
| 1473 | + if(!isset($post->default_category)){
|
|
| 1474 | + $gd_post = geodir_get_post_info($post->ID); |
|
| 1475 | + if(!empty($gd_post)){
|
|
| 1476 | + $post = $gd_post; |
|
| 1477 | + } |
|
| 1478 | + } |
|
| 1479 | 1479 | |
| 1480 | 1480 | |
| 1481 | - $post_types = get_option('geodir_post_types');
|
|
| 1482 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1481 | + $post_types = get_option('geodir_post_types');
|
|
| 1482 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1483 | 1483 | |
| 1484 | - // Alter the CPT slug if WPML is set to do so |
|
| 1485 | - if(geodir_wpml_is_post_type_translated($post->post_type)){
|
|
| 1486 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1484 | + // Alter the CPT slug if WPML is set to do so |
|
| 1485 | + if(geodir_wpml_is_post_type_translated($post->post_type)){
|
|
| 1486 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1487 | 1487 | |
| 1488 | - $org_slug = $slug; |
|
| 1489 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1490 | - $slug, |
|
| 1491 | - 'WordPress', |
|
| 1492 | - 'URL slug: ' . $slug, |
|
| 1493 | - $language_code); |
|
| 1488 | + $org_slug = $slug; |
|
| 1489 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1490 | + $slug, |
|
| 1491 | + 'WordPress', |
|
| 1492 | + 'URL slug: ' . $slug, |
|
| 1493 | + $language_code); |
|
| 1494 | 1494 | |
| 1495 | - if(!$slug){$slug = $org_slug;}
|
|
| 1495 | + if(!$slug){$slug = $org_slug;}
|
|
| 1496 | 1496 | |
| 1497 | - } |
|
| 1498 | - } |
|
| 1497 | + } |
|
| 1498 | + } |
|
| 1499 | 1499 | |
| 1500 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1501 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1502 | - } |
|
| 1500 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1501 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1505 | - $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1504 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1505 | + $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1506 | 1506 | |
| 1507 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1508 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1509 | - } |
|
| 1510 | - |
|
| 1511 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1512 | - if ($fix_url) {
|
|
| 1513 | - $post_link = str_replace($site_url, '', $post_link); |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - $post_link = trailingslashit( |
|
| 1517 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1518 | - ); |
|
| 1519 | - |
|
| 1520 | - if ($fix_url) {
|
|
| 1521 | - $post_link = $site_url . $post_link; |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - if (isset($comment_post_cache[$post->ID])) {
|
|
| 1525 | - $post = $comment_post_cache[$post->ID]; |
|
| 1526 | - } |
|
| 1527 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1528 | - $post_id = $post->ID; |
|
| 1529 | - if (isset($orig_post)) {
|
|
| 1530 | - $post = $orig_post; |
|
| 1531 | - } |
|
| 1532 | - return $gd_permalink_cache[$post_id]; |
|
| 1533 | - } |
|
| 1507 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1508 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1509 | + } |
|
| 1510 | + |
|
| 1511 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1512 | + if ($fix_url) {
|
|
| 1513 | + $post_link = str_replace($site_url, '', $post_link); |
|
| 1514 | + } |
|
| 1534 | 1515 | |
| 1535 | - if (!isset($post->post_locations)) {
|
|
| 1536 | - $post_type = $post->post_type; |
|
| 1537 | - $ID = $post->ID; |
|
| 1538 | - $post2 = $wpdb->get_row( |
|
| 1539 | - $wpdb->prepare( |
|
| 1540 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1541 | - array($post->ID) |
|
| 1542 | - ) |
|
| 1543 | - ); |
|
| 1516 | + $post_link = trailingslashit( |
|
| 1517 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1518 | + ); |
|
| 1544 | 1519 | |
| 1545 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1520 | + if ($fix_url) {
|
|
| 1521 | + $post_link = $site_url . $post_link; |
|
| 1522 | + } |
|
| 1546 | 1523 | |
| 1547 | - $comment_post_cache[$post->ID] = $post; |
|
| 1548 | - } |
|
| 1524 | + if (isset($comment_post_cache[$post->ID])) {
|
|
| 1525 | + $post = $comment_post_cache[$post->ID]; |
|
| 1526 | + } |
|
| 1527 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1528 | + $post_id = $post->ID; |
|
| 1529 | + if (isset($orig_post)) {
|
|
| 1530 | + $post = $orig_post; |
|
| 1531 | + } |
|
| 1532 | + return $gd_permalink_cache[$post_id]; |
|
| 1533 | + } |
|
| 1549 | 1534 | |
| 1535 | + if (!isset($post->post_locations)) {
|
|
| 1536 | + $post_type = $post->post_type; |
|
| 1537 | + $ID = $post->ID; |
|
| 1538 | + $post2 = $wpdb->get_row( |
|
| 1539 | + $wpdb->prepare( |
|
| 1540 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1541 | + array($post->ID) |
|
| 1542 | + ) |
|
| 1543 | + ); |
|
| 1550 | 1544 | |
| 1545 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1551 | 1546 | |
| 1552 | - if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1547 | + $comment_post_cache[$post->ID] = $post; |
|
| 1548 | + } |
|
| 1553 | 1549 | |
| 1554 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1555 | - $location_request = ''; |
|
| 1556 | 1550 | |
| 1557 | 1551 | |
| 1558 | - if (!empty($post->post_locations)) {
|
|
| 1559 | - $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1560 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1561 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1562 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1563 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1564 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1565 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1566 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1552 | + if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1567 | 1553 | |
| 1568 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1569 | - 'region_slug' => $post->region_slug, |
|
| 1570 | - 'city_slug' => $post->city_slug |
|
| 1571 | - ); |
|
| 1554 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1555 | + $location_request = ''; |
|
| 1572 | 1556 | |
| 1573 | - } else |
|
| 1574 | - $post_location = geodir_get_location(); |
|
| 1575 | 1557 | |
| 1558 | + if (!empty($post->post_locations)) {
|
|
| 1559 | + $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1560 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1561 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1562 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1563 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1564 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1565 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1566 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1576 | 1567 | |
| 1577 | - } else {
|
|
| 1568 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1569 | + 'region_slug' => $post->region_slug, |
|
| 1570 | + 'city_slug' => $post->city_slug |
|
| 1571 | + ); |
|
| 1578 | 1572 | |
| 1579 | - $post_location_sql = $wpdb->get_results( |
|
| 1580 | - $wpdb->prepare( |
|
| 1581 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1582 | - array($post->ID) |
|
| 1583 | - ) |
|
| 1584 | - ); |
|
| 1585 | - |
|
| 1586 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1587 | - |
|
| 1588 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1589 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1590 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1591 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1592 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1593 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1594 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1595 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1596 | - |
|
| 1597 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1598 | - 'region_slug' => $post->region_slug, |
|
| 1599 | - 'city_slug' => $post->city_slug |
|
| 1600 | - ); |
|
| 1573 | + } else |
|
| 1574 | + $post_location = geodir_get_location(); |
|
| 1601 | 1575 | |
| 1602 | - } |
|
| 1603 | - } else |
|
| 1604 | - $post_location = geodir_get_location(); |
|
| 1605 | - } |
|
| 1576 | + |
|
| 1577 | + } else {
|
|
| 1578 | + |
|
| 1579 | + $post_location_sql = $wpdb->get_results( |
|
| 1580 | + $wpdb->prepare( |
|
| 1581 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1582 | + array($post->ID) |
|
| 1583 | + ) |
|
| 1584 | + ); |
|
| 1585 | + |
|
| 1586 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1587 | + |
|
| 1588 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1589 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1590 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1591 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1592 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1593 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1594 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1595 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1596 | + |
|
| 1597 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1598 | + 'region_slug' => $post->region_slug, |
|
| 1599 | + 'city_slug' => $post->city_slug |
|
| 1600 | + ); |
|
| 1601 | + |
|
| 1602 | + } |
|
| 1603 | + } else |
|
| 1604 | + $post_location = geodir_get_location(); |
|
| 1605 | + } |
|
| 1606 | 1606 | |
| 1607 | 1607 | |
| 1608 | - if (!empty($post_location)) {
|
|
| 1609 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1608 | + if (!empty($post_location)) {
|
|
| 1609 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1610 | 1610 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
| 1611 | 1611 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
| 1612 | 1612 | |
@@ -1624,89 +1624,89 @@ discard block |
||
| 1624 | 1624 | $location_slug[] = $city_slug; |
| 1625 | 1625 | |
| 1626 | 1626 | $location_request .= implode('/', $location_slug) . '/';
|
| 1627 | - } |
|
| 1628 | - } |
|
| 1627 | + } |
|
| 1628 | + } |
|
| 1629 | 1629 | |
| 1630 | - if (get_option('geodir_add_categories_url')) {
|
|
| 1630 | + if (get_option('geodir_add_categories_url')) {
|
|
| 1631 | 1631 | |
| 1632 | - $term_request = ''; |
|
| 1633 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1634 | - $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : ''; |
|
| 1632 | + $term_request = ''; |
|
| 1633 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1634 | + $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : ''; |
|
| 1635 | 1635 | |
| 1636 | - if (!empty($post->default_category)) {
|
|
| 1637 | - $post_terms = $post->default_category; |
|
| 1638 | - } else {
|
|
| 1639 | - $post_terms = ''; |
|
| 1640 | - |
|
| 1641 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1642 | - $post_terms = absint($_POST['post_default_category']); |
|
| 1643 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1644 | - $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1645 | - $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
| 1646 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1647 | - $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1648 | - $post_terms = $post_terms[0]; |
|
| 1649 | - } |
|
| 1636 | + if (!empty($post->default_category)) {
|
|
| 1637 | + $post_terms = $post->default_category; |
|
| 1638 | + } else {
|
|
| 1639 | + $post_terms = ''; |
|
| 1640 | + |
|
| 1641 | + if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
|
| 1642 | + $post_terms = absint($_POST['post_default_category']); |
|
| 1643 | + }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1644 | + $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
|
| 1645 | + $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
| 1646 | + }elseif (isset($post->{$taxonomies})) {
|
|
| 1647 | + $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
|
| 1648 | + $post_terms = $post_terms[0]; |
|
| 1649 | + } |
|
| 1650 | 1650 | |
| 1651 | - if (!$post_terms) |
|
| 1652 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1651 | + if (!$post_terms) |
|
| 1652 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1653 | 1653 | |
| 1654 | - if (!$post_terms) {
|
|
| 1655 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1654 | + if (!$post_terms) {
|
|
| 1655 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1656 | 1656 | |
| 1657 | - if ($post_terms) {
|
|
| 1658 | - $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1659 | - $post_terms = $post_terms[0]; |
|
| 1660 | - } |
|
| 1661 | - } |
|
| 1662 | - } |
|
| 1657 | + if ($post_terms) {
|
|
| 1658 | + $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1659 | + $post_terms = $post_terms[0]; |
|
| 1660 | + } |
|
| 1661 | + } |
|
| 1662 | + } |
|
| 1663 | 1663 | |
| 1664 | - $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1664 | + $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1665 | 1665 | |
| 1666 | - if (!empty($term)) |
|
| 1667 | - $term_request = $term->slug; |
|
| 1668 | - //$term_request = $term->slug.'/'; |
|
| 1669 | - } |
|
| 1666 | + if (!empty($term)) |
|
| 1667 | + $term_request = $term->slug; |
|
| 1668 | + //$term_request = $term->slug.'/'; |
|
| 1669 | + } |
|
| 1670 | 1670 | |
| 1671 | - $request_term = ''; |
|
| 1672 | - $listingurl_separator = ''; |
|
| 1673 | - //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1674 | - $detailurl_separator = ''; |
|
| 1675 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1676 | - $request_term = $location_request; |
|
| 1677 | - //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1678 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1679 | - $request_term .= $term_request; |
|
| 1671 | + $request_term = ''; |
|
| 1672 | + $listingurl_separator = ''; |
|
| 1673 | + //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1674 | + $detailurl_separator = ''; |
|
| 1675 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1676 | + $request_term = $location_request; |
|
| 1677 | + //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1678 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1679 | + $request_term .= $term_request; |
|
| 1680 | 1680 | |
| 1681 | - } else {
|
|
| 1682 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1681 | + } else {
|
|
| 1682 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1683 | 1683 | |
| 1684 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1685 | - } |
|
| 1686 | - $request_term = trim($request_term, '/'); |
|
| 1684 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1685 | + } |
|
| 1686 | + $request_term = trim($request_term, '/'); |
|
| 1687 | 1687 | |
| 1688 | - // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1689 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1690 | - $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1691 | - } |
|
| 1688 | + // Fix with WPML the location terms added twice when CPT slug is translated. |
|
| 1689 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
|
|
| 1690 | + $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
|
| 1691 | + } |
|
| 1692 | 1692 | |
| 1693 | - if (!empty($request_term)) |
|
| 1694 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1695 | - else |
|
| 1696 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1697 | - //echo $post_link ; |
|
| 1698 | - } |
|
| 1699 | - // temp cache the permalink |
|
| 1700 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1701 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1702 | - } |
|
| 1703 | - } |
|
| 1704 | - if (isset($orig_post)) {
|
|
| 1705 | - $post = $orig_post; |
|
| 1706 | - } |
|
| 1693 | + if (!empty($request_term)) |
|
| 1694 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1695 | + else |
|
| 1696 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1697 | + //echo $post_link ; |
|
| 1698 | + } |
|
| 1699 | + // temp cache the permalink |
|
| 1700 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1701 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1702 | + } |
|
| 1703 | + } |
|
| 1704 | + if (isset($orig_post)) {
|
|
| 1705 | + $post = $orig_post; |
|
| 1706 | + } |
|
| 1707 | 1707 | $gd_cache_post = $post; |
| 1708 | 1708 | |
| 1709 | - return $post_link; |
|
| 1709 | + return $post_link; |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
@@ -1722,117 +1722,117 @@ discard block |
||
| 1722 | 1722 | * @return string The term link. |
| 1723 | 1723 | */ |
| 1724 | 1724 | function geodir_term_link($termlink, $term, $taxonomy) {
|
| 1725 | - $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1725 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1726 | 1726 | |
| 1727 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1728 | - global $geodir_add_location_url, $gd_session; |
|
| 1729 | - $include_location = false; |
|
| 1730 | - $request_term = array(); |
|
| 1731 | - $add_location_url = get_option('geodir_add_location_url');
|
|
| 1732 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1727 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1728 | + global $geodir_add_location_url, $gd_session; |
|
| 1729 | + $include_location = false; |
|
| 1730 | + $request_term = array(); |
|
| 1731 | + $add_location_url = get_option('geodir_add_location_url');
|
|
| 1732 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1733 | 1733 | |
| 1734 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1734 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1735 | 1735 | |
| 1736 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1737 | - if ($geodir_add_location_url && $add_location_url) {
|
|
| 1738 | - $include_location = true; |
|
| 1739 | - } |
|
| 1740 | - } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1741 | - $include_location = true; |
|
| 1742 | - } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1743 | - $include_location = true; |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - if ($include_location) {
|
|
| 1747 | - global $post; |
|
| 1748 | - $location_terms = array(); |
|
| 1736 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1737 | + if ($geodir_add_location_url && $add_location_url) {
|
|
| 1738 | + $include_location = true; |
|
| 1739 | + } |
|
| 1740 | + } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
|
|
| 1741 | + $include_location = true; |
|
| 1742 | + } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
|
|
| 1743 | + $include_location = true; |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + if ($include_location) {
|
|
| 1747 | + global $post; |
|
| 1748 | + $location_terms = array(); |
|
| 1749 | 1749 | |
| 1750 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1750 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1751 | 1751 | |
| 1752 | - if (geodir_is_page('detail')) {
|
|
| 1753 | - if (!isset($post->country_slug) && !empty($post->post_locations)) {
|
|
| 1754 | - $post_locations = explode(',', $post->post_locations);
|
|
| 1755 | - |
|
| 1756 | - if (count($post_locations) == 3) {
|
|
| 1757 | - $post->city_slug = str_replace('[', '', $post_locations[0]);
|
|
| 1758 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1759 | - $post->region_slug = str_replace('[', '', $post_locations[1]);
|
|
| 1760 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1761 | - $post->country_slug = str_replace('[', '', $post_locations[2]);
|
|
| 1762 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1763 | - } |
|
| 1764 | - } |
|
| 1752 | + if (geodir_is_page('detail')) {
|
|
| 1753 | + if (!isset($post->country_slug) && !empty($post->post_locations)) {
|
|
| 1754 | + $post_locations = explode(',', $post->post_locations);
|
|
| 1755 | + |
|
| 1756 | + if (count($post_locations) == 3) {
|
|
| 1757 | + $post->city_slug = str_replace('[', '', $post_locations[0]);
|
|
| 1758 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1759 | + $post->region_slug = str_replace('[', '', $post_locations[1]);
|
|
| 1760 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1761 | + $post->country_slug = str_replace('[', '', $post_locations[2]);
|
|
| 1762 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1763 | + } |
|
| 1764 | + } |
|
| 1765 | 1765 | |
| 1766 | - if (isset($post->country_slug)) {
|
|
| 1767 | - $location_terms = array( |
|
| 1768 | - 'gd_country' => $post->country_slug, |
|
| 1769 | - 'gd_region' => $post->region_slug, |
|
| 1770 | - 'gd_city' => $post->city_slug |
|
| 1771 | - ); |
|
| 1766 | + if (isset($post->country_slug)) {
|
|
| 1767 | + $location_terms = array( |
|
| 1768 | + 'gd_country' => $post->country_slug, |
|
| 1769 | + 'gd_region' => $post->region_slug, |
|
| 1770 | + 'gd_city' => $post->city_slug |
|
| 1771 | + ); |
|
| 1772 | 1772 | |
| 1773 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1774 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - } |
|
| 1773 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1774 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 1775 | + } |
|
| 1776 | + } |
|
| 1777 | + } |
|
| 1778 | 1778 | |
| 1779 | - if (empty($location_terms)) {
|
|
| 1780 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1781 | - } |
|
| 1779 | + if (empty($location_terms)) {
|
|
| 1780 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1781 | + } |
|
| 1782 | 1782 | |
| 1783 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1784 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1783 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1784 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1785 | 1785 | |
| 1786 | - if (!empty($location_terms)) {
|
|
| 1787 | - $url_separator = ''; |
|
| 1786 | + if (!empty($location_terms)) {
|
|
| 1787 | + $url_separator = ''; |
|
| 1788 | 1788 | |
| 1789 | - if (get_option('permalink_structure') != '') {
|
|
| 1790 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1791 | - $request_term = implode("/", $location_terms);
|
|
| 1792 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1789 | + if (get_option('permalink_structure') != '') {
|
|
| 1790 | + $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1791 | + $request_term = implode("/", $location_terms);
|
|
| 1792 | + $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1793 | 1793 | |
| 1794 | - $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1795 | - } else {
|
|
| 1796 | - $termlink = geodir_getlink($termlink, $request_term); |
|
| 1797 | - } |
|
| 1798 | - } |
|
| 1799 | - } |
|
| 1794 | + $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1795 | + } else {
|
|
| 1796 | + $termlink = geodir_getlink($termlink, $request_term); |
|
| 1797 | + } |
|
| 1798 | + } |
|
| 1799 | + } |
|
| 1800 | 1800 | |
| 1801 | - // Alter the CPT slug is WPML is set to do so |
|
| 1802 | - /* we can replace this with the below function |
|
| 1801 | + // Alter the CPT slug is WPML is set to do so |
|
| 1802 | + /* we can replace this with the below function |
|
| 1803 | 1803 | if(geodir_is_wpml()){
|
| 1804 | 1804 | global $sitepress; |
| 1805 | 1805 | $post_type = str_replace("category","",$taxonomy);
|
| 1806 | 1806 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
| 1807 | 1807 | }*/ |
| 1808 | 1808 | |
| 1809 | - // Alter the CPT slug if WPML is set to do so |
|
| 1810 | - if (geodir_is_wpml()) {
|
|
| 1811 | - $post_types = get_option('geodir_post_types');
|
|
| 1812 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1813 | - $post_type = str_replace("_tags","",$post_type);
|
|
| 1814 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1815 | - if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1816 | - global $sitepress; |
|
| 1817 | - $default_lang = $sitepress->get_default_language(); |
|
| 1818 | - $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1819 | - if (!$language_code ) {
|
|
| 1820 | - $language_code = $default_lang; |
|
| 1821 | - } |
|
| 1809 | + // Alter the CPT slug if WPML is set to do so |
|
| 1810 | + if (geodir_is_wpml()) {
|
|
| 1811 | + $post_types = get_option('geodir_post_types');
|
|
| 1812 | + $post_type = str_replace("category","",$taxonomy);
|
|
| 1813 | + $post_type = str_replace("_tags","",$post_type);
|
|
| 1814 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1815 | + if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
|
|
| 1816 | + global $sitepress; |
|
| 1817 | + $default_lang = $sitepress->get_default_language(); |
|
| 1818 | + $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1819 | + if (!$language_code ) {
|
|
| 1820 | + $language_code = $default_lang; |
|
| 1821 | + } |
|
| 1822 | 1822 | |
| 1823 | - $org_slug = $slug; |
|
| 1824 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1823 | + $org_slug = $slug; |
|
| 1824 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
|
|
| 1825 | 1825 | |
| 1826 | - if (!$slug) {
|
|
| 1827 | - $slug = $org_slug; |
|
| 1828 | - } |
|
| 1826 | + if (!$slug) {
|
|
| 1827 | + $slug = $org_slug; |
|
| 1828 | + } |
|
| 1829 | 1829 | |
| 1830 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1831 | - } |
|
| 1832 | - } |
|
| 1833 | - } |
|
| 1830 | + $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1));
|
|
| 1831 | + } |
|
| 1832 | + } |
|
| 1833 | + } |
|
| 1834 | 1834 | |
| 1835 | - return $termlink; |
|
| 1835 | + return $termlink; |
|
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | /** |
@@ -1858,14 +1858,14 @@ discard block |
||
| 1858 | 1858 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1859 | 1859 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1860 | 1860 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
| 1861 | - $location_terms = array( |
|
| 1862 | - 'gd_country' => $post->country_slug, |
|
| 1863 | - 'gd_region' => $post->region_slug, |
|
| 1864 | - 'gd_city' => $post->city_slug |
|
| 1865 | - ); |
|
| 1866 | - } else {
|
|
| 1867 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1868 | - } |
|
| 1861 | + $location_terms = array( |
|
| 1862 | + 'gd_country' => $post->country_slug, |
|
| 1863 | + 'gd_region' => $post->region_slug, |
|
| 1864 | + 'gd_city' => $post->city_slug |
|
| 1865 | + ); |
|
| 1866 | + } else {
|
|
| 1867 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1868 | + } |
|
| 1869 | 1869 | |
| 1870 | 1870 | $location_terms = geodir_remove_location_terms($location_terms); |
| 1871 | 1871 | |
@@ -1897,17 +1897,17 @@ discard block |
||
| 1897 | 1897 | * @return void|string Label. |
| 1898 | 1898 | */ |
| 1899 | 1899 | function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
|
| 1900 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1901 | - if (!is_object($obj_post_type)) {
|
|
| 1902 | - return; |
|
| 1903 | - } |
|
| 1900 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1901 | + if (!is_object($obj_post_type)) {
|
|
| 1902 | + return; |
|
| 1903 | + } |
|
| 1904 | 1904 | |
| 1905 | - $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
| 1905 | + $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_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 | /** |
@@ -1922,19 +1922,19 @@ discard block |
||
| 1922 | 1922 | * @return void|string Label. |
| 1923 | 1923 | */ |
| 1924 | 1924 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1925 | - $all_postypes = geodir_get_posttypes(); |
|
| 1925 | + $all_postypes = geodir_get_posttypes(); |
|
| 1926 | 1926 | |
| 1927 | - if (!in_array($post_type, $all_postypes)) |
|
| 1928 | - return false; |
|
| 1927 | + if (!in_array($post_type, $all_postypes)) |
|
| 1928 | + return false; |
|
| 1929 | 1929 | |
| 1930 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1930 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1931 | 1931 | |
| 1932 | - $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1932 | + $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
| 1933 | 1933 | |
| 1934 | - if ($echo) |
|
| 1935 | - echo $label; |
|
| 1936 | - else |
|
| 1937 | - return $label; |
|
| 1934 | + if ($echo) |
|
| 1935 | + echo $label; |
|
| 1936 | + else |
|
| 1937 | + return $label; |
|
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | 1940 | /** |
@@ -1952,51 +1952,51 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
| 1954 | 1954 | {
|
| 1955 | - global $wpdb; |
|
| 1956 | - |
|
| 1957 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1958 | - $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 "; |
|
| 1959 | - |
|
| 1960 | - if (is_int($term)) {
|
|
| 1961 | - if (0 == $term) |
|
| 1962 | - return 0; |
|
| 1963 | - $where = 't.term_id = %d'; |
|
| 1964 | - if (!empty($taxonomy)) |
|
| 1965 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1966 | - else |
|
| 1967 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1968 | - } |
|
| 1955 | + global $wpdb; |
|
| 1956 | + |
|
| 1957 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1958 | + $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 "; |
|
| 1959 | + |
|
| 1960 | + if (is_int($term)) {
|
|
| 1961 | + if (0 == $term) |
|
| 1962 | + return 0; |
|
| 1963 | + $where = 't.term_id = %d'; |
|
| 1964 | + if (!empty($taxonomy)) |
|
| 1965 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1966 | + else |
|
| 1967 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1968 | + } |
|
| 1969 | 1969 | |
| 1970 | - $term = trim(wp_unslash($term)); |
|
| 1970 | + $term = trim(wp_unslash($term)); |
|
| 1971 | 1971 | |
| 1972 | - if ('' === $slug = sanitize_title($term))
|
|
| 1973 | - return 0; |
|
| 1972 | + if ('' === $slug = sanitize_title($term))
|
|
| 1973 | + return 0; |
|
| 1974 | 1974 | |
| 1975 | - $where = 't.slug = %s'; |
|
| 1975 | + $where = 't.slug = %s'; |
|
| 1976 | 1976 | |
| 1977 | - $where_fields = array($slug); |
|
| 1978 | - if (!empty($taxonomy)) {
|
|
| 1979 | - $parent = (int)$parent; |
|
| 1980 | - if ($parent > 0) {
|
|
| 1981 | - $where_fields[] = $parent; |
|
| 1982 | - $else_where_fields[] = $parent; |
|
| 1983 | - $where .= ' AND tt.parent = %d'; |
|
| 1977 | + $where_fields = array($slug); |
|
| 1978 | + if (!empty($taxonomy)) {
|
|
| 1979 | + $parent = (int)$parent; |
|
| 1980 | + if ($parent > 0) {
|
|
| 1981 | + $where_fields[] = $parent; |
|
| 1982 | + $else_where_fields[] = $parent; |
|
| 1983 | + $where .= ' AND tt.parent = %d'; |
|
| 1984 | 1984 | |
| 1985 | - } |
|
| 1985 | + } |
|
| 1986 | 1986 | |
| 1987 | - $where_fields[] = $taxonomy; |
|
| 1987 | + $where_fields[] = $taxonomy; |
|
| 1988 | 1988 | |
| 1989 | 1989 | |
| 1990 | - 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))
|
|
| 1991 | - return $result; |
|
| 1990 | + 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))
|
|
| 1991 | + return $result; |
|
| 1992 | 1992 | |
| 1993 | - return false; |
|
| 1994 | - } |
|
| 1993 | + return false; |
|
| 1994 | + } |
|
| 1995 | 1995 | |
| 1996 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1997 | - return $result; |
|
| 1996 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1997 | + return $result; |
|
| 1998 | 1998 | |
| 1999 | - return false; |
|
| 1999 | + return false; |
|
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | 2002 | /** |
@@ -2008,7 +2008,7 @@ discard block |
||
| 2008 | 2008 | function geodir_get_term_icon_rebuild() |
| 2009 | 2009 | {
|
| 2010 | 2010 | |
| 2011 | - update_option('gd_term_icons', '');
|
|
| 2011 | + update_option('gd_term_icons', '');
|
|
| 2012 | 2012 | |
| 2013 | 2013 | } |
| 2014 | 2014 | |
@@ -2026,61 +2026,61 @@ discard block |
||
| 2026 | 2026 | */ |
| 2027 | 2027 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
| 2028 | 2028 | {
|
| 2029 | - global $wpdb; |
|
| 2030 | - if (!$rebuild) {
|
|
| 2031 | - $terms_icons = get_option('gd_term_icons');
|
|
| 2032 | - } else {
|
|
| 2033 | - $terms_icons = array(); |
|
| 2034 | - } |
|
| 2035 | - |
|
| 2036 | - if (empty($terms_icons)) {
|
|
| 2037 | - $terms_icons = array(); |
|
| 2038 | - $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2039 | - $taxonomy = geodir_get_taxonomies(); |
|
| 2040 | - $post_types = geodir_get_posttypes(); |
|
| 2041 | - $tax_arr = array(); |
|
| 2042 | - foreach ($post_types as $post_type) {
|
|
| 2043 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2044 | - } |
|
| 2045 | - $tax_c = implode(',', $tax_arr);
|
|
| 2046 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2047 | - //$terms = get_terms( $taxonomy ); |
|
| 2048 | - |
|
| 2049 | - if($terms) {
|
|
| 2050 | - foreach ($terms as $term) {
|
|
| 2051 | - $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2052 | - $a_terms[$post_type][] = $term; |
|
| 2029 | + global $wpdb; |
|
| 2030 | + if (!$rebuild) {
|
|
| 2031 | + $terms_icons = get_option('gd_term_icons');
|
|
| 2032 | + } else {
|
|
| 2033 | + $terms_icons = array(); |
|
| 2034 | + } |
|
| 2053 | 2035 | |
| 2054 | - } |
|
| 2055 | - } |
|
| 2036 | + if (empty($terms_icons)) {
|
|
| 2037 | + $terms_icons = array(); |
|
| 2038 | + $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 2039 | + $taxonomy = geodir_get_taxonomies(); |
|
| 2040 | + $post_types = geodir_get_posttypes(); |
|
| 2041 | + $tax_arr = array(); |
|
| 2042 | + foreach ($post_types as $post_type) {
|
|
| 2043 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
| 2044 | + } |
|
| 2045 | + $tax_c = implode(',', $tax_arr);
|
|
| 2046 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 2047 | + //$terms = get_terms( $taxonomy ); |
|
| 2056 | 2048 | |
| 2057 | - if($a_terms) {
|
|
| 2058 | - foreach ($a_terms as $pt => $t2) {
|
|
| 2049 | + if($terms) {
|
|
| 2050 | + foreach ($terms as $term) {
|
|
| 2051 | + $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 2052 | + $a_terms[$post_type][] = $term; |
|
| 2059 | 2053 | |
| 2060 | - foreach ($t2 as $term) {
|
|
| 2061 | - $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2062 | - if ($term_icon) {
|
|
| 2063 | - $term_icon_url = $term_icon["src"]; |
|
| 2064 | - } else {
|
|
| 2065 | - $term_icon_url = $default_icon_url; |
|
| 2066 | - } |
|
| 2067 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2068 | - } |
|
| 2069 | - } |
|
| 2070 | - } |
|
| 2054 | + } |
|
| 2055 | + } |
|
| 2056 | + |
|
| 2057 | + if($a_terms) {
|
|
| 2058 | + foreach ($a_terms as $pt => $t2) {
|
|
| 2071 | 2059 | |
| 2072 | - update_option('gd_term_icons', $terms_icons);
|
|
| 2073 | - } |
|
| 2060 | + foreach ($t2 as $term) {
|
|
| 2061 | + $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 2062 | + if ($term_icon) {
|
|
| 2063 | + $term_icon_url = $term_icon["src"]; |
|
| 2064 | + } else {
|
|
| 2065 | + $term_icon_url = $default_icon_url; |
|
| 2066 | + } |
|
| 2067 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
| 2068 | + } |
|
| 2069 | + } |
|
| 2070 | + } |
|
| 2074 | 2071 | |
| 2075 | - if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2076 | - return $terms_icons[$term_id]; |
|
| 2077 | - } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2078 | - return get_option('geodir_default_marker_icon');
|
|
| 2079 | - } |
|
| 2072 | + update_option('gd_term_icons', $terms_icons);
|
|
| 2073 | + } |
|
| 2074 | + |
|
| 2075 | + if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 2076 | + return $terms_icons[$term_id]; |
|
| 2077 | + } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 2078 | + return get_option('geodir_default_marker_icon');
|
|
| 2079 | + } |
|
| 2080 | 2080 | |
| 2081 | - if (is_ssl()) {
|
|
| 2082 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2083 | - } |
|
| 2081 | + if (is_ssl()) {
|
|
| 2082 | + $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 2083 | + } |
|
| 2084 | 2084 | |
| 2085 | - return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2085 | + return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
|
|
| 2086 | 2086 | } |
| 2087 | 2087 | \ No newline at end of file |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | // Enable map cache if set |
| 10 | 10 | if(get_option('geodir_enable_map_cache')){
|
| 11 | - add_filter('geodir_get_markers_cache','geodir_get_map_cache');
|
|
| 12 | - add_filter('geodir_markers_json','geodir_save_map_cache',10);
|
|
| 11 | + add_filter('geodir_get_markers_cache','geodir_get_map_cache');
|
|
| 12 | + add_filter('geodir_markers_json','geodir_save_map_cache',10);
|
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | |
@@ -23,59 +23,59 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function geodir_get_map_cache($cache){
|
| 25 | 25 | |
| 26 | - // if a search is going on then dont even try to check for cache. |
|
| 27 | - if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
|
|
| 28 | - return $cache; |
|
| 29 | - } |
|
| 26 | + // if a search is going on then dont even try to check for cache. |
|
| 27 | + if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
|
|
| 28 | + return $cache; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $url_params = array(); |
|
| 32 | - $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
| 33 | - $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
| 34 | - $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
| 35 | - $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
| 36 | - $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
| 37 | - $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
| 38 | - $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
| 39 | - $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
| 40 | - $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
| 41 | - $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
| 42 | - $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
| 43 | - $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
| 44 | - $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
| 31 | + $url_params = array(); |
|
| 32 | + $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
| 33 | + $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
| 34 | + $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
| 35 | + $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
| 36 | + $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
| 37 | + $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
| 38 | + $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
| 39 | + $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
| 40 | + $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
| 41 | + $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
| 42 | + $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
| 43 | + $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
| 44 | + $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
| 45 | 45 | |
| 46 | - $file_name = sanitize_file_name( md5( implode("-",$url_params) ) );
|
|
| 46 | + $file_name = sanitize_file_name( md5( implode("-",$url_params) ) );
|
|
| 47 | 47 | |
| 48 | - $blog_id = get_current_blog_id(); |
|
| 49 | - if($blog_id>1){
|
|
| 50 | - $file_name = $blog_id."_".$file_name; |
|
| 51 | - } |
|
| 48 | + $blog_id = get_current_blog_id(); |
|
| 49 | + if($blog_id>1){
|
|
| 50 | + $file_name = $blog_id."_".$file_name; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
| 53 | + $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - if(file_exists($file_path.$file_name.".json")){
|
|
| 56 | + if(file_exists($file_path.$file_name.".json")){
|
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - ob_start(); |
|
| 60 | - readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents |
|
| 61 | - $content = ob_get_clean(); |
|
| 59 | + ob_start(); |
|
| 60 | + readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents |
|
| 61 | + $content = ob_get_clean(); |
|
| 62 | 62 | |
| 63 | - // do the cache delete stuff |
|
| 64 | - $cache_time = get_option('geodir_map_cache');
|
|
| 65 | - if(!$cache_time){
|
|
| 66 | - $cache_time = time(); |
|
| 67 | - update_option('geodir_map_cache', $cache_time);
|
|
| 68 | - } |
|
| 63 | + // do the cache delete stuff |
|
| 64 | + $cache_time = get_option('geodir_map_cache');
|
|
| 65 | + if(!$cache_time){
|
|
| 66 | + $cache_time = time(); |
|
| 67 | + update_option('geodir_map_cache', $cache_time);
|
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
|
|
| 71 | - geodir_delete_map_cache(); |
|
| 72 | - } |
|
| 70 | + if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
|
|
| 71 | + geodir_delete_map_cache(); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $content; |
|
| 74 | + return $content; |
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return $cache; |
|
| 78 | + return $cache; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -88,101 +88,101 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | function geodir_save_map_cache($map_json){
|
| 90 | 90 | |
| 91 | - // if a search is going on then dont even try to check for cache. |
|
| 92 | - if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
|
|
| 93 | - return $map_json; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $url_params = array(); |
|
| 97 | - $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
| 98 | - $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
| 99 | - $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
| 100 | - $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
| 101 | - $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
| 102 | - $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
| 103 | - $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
| 104 | - $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
| 105 | - $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
| 106 | - $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
| 107 | - $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
| 108 | - $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
| 109 | - $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
| 110 | - |
|
| 111 | - $file_name = sanitize_file_name( md5( implode("-",$url_params) ) );
|
|
| 112 | - |
|
| 113 | - $blog_id = get_current_blog_id(); |
|
| 114 | - if($blog_id>1){
|
|
| 115 | - $file_name = $blog_id."_".$file_name; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - global $wp_filesystem; |
|
| 122 | - if (empty($wp_filesystem)) {
|
|
| 123 | - require_once (ABSPATH . '/wp-admin/includes/file.php'); |
|
| 124 | - WP_Filesystem(); |
|
| 125 | - } |
|
| 126 | - $wp_filesystem->put_contents( |
|
| 127 | - $file_path.$file_name.".json", |
|
| 128 | - $map_json, |
|
| 129 | - FS_CHMOD_FILE // predefined mode settings for WP files |
|
| 130 | - ); |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - return $map_json; |
|
| 91 | + // if a search is going on then dont even try to check for cache. |
|
| 92 | + if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
|
|
| 93 | + return $map_json; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $url_params = array(); |
|
| 97 | + $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
| 98 | + $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
| 99 | + $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
| 100 | + $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
| 101 | + $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
| 102 | + $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
| 103 | + $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
| 104 | + $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
| 105 | + $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
| 106 | + $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
| 107 | + $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
| 108 | + $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
| 109 | + $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
| 110 | + |
|
| 111 | + $file_name = sanitize_file_name( md5( implode("-",$url_params) ) );
|
|
| 112 | + |
|
| 113 | + $blog_id = get_current_blog_id(); |
|
| 114 | + if($blog_id>1){
|
|
| 115 | + $file_name = $blog_id."_".$file_name; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + global $wp_filesystem; |
|
| 122 | + if (empty($wp_filesystem)) {
|
|
| 123 | + require_once (ABSPATH . '/wp-admin/includes/file.php'); |
|
| 124 | + WP_Filesystem(); |
|
| 125 | + } |
|
| 126 | + $wp_filesystem->put_contents( |
|
| 127 | + $file_path.$file_name.".json", |
|
| 128 | + $map_json, |
|
| 129 | + FS_CHMOD_FILE // predefined mode settings for WP files |
|
| 130 | + ); |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + return $map_json; |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') {
|
| 139 | - global $gd_session; |
|
| 140 | - $gd_post_type = sanitize_text_field($_REQUEST['post_type']); |
|
| 141 | - $gd_session->set('homemap_catlist_ptype', $gd_post_type);
|
|
| 142 | - $post_taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 143 | - $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']); |
|
| 144 | - $child_collapse = (bool)$_REQUEST['child_collapse']; |
|
| 145 | - echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true); |
|
| 146 | - die; |
|
| 139 | + global $gd_session; |
|
| 140 | + $gd_post_type = sanitize_text_field($_REQUEST['post_type']); |
|
| 141 | + $gd_session->set('homemap_catlist_ptype', $gd_post_type);
|
|
| 142 | + $post_taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 143 | + $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']); |
|
| 144 | + $child_collapse = (bool)$_REQUEST['child_collapse']; |
|
| 145 | + echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true); |
|
| 146 | + die; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // Send the content-type header with correct encoding |
| 150 | 150 | header("Content-type: text/javascript; charset=utf-8");
|
| 151 | 151 | |
| 152 | 152 | if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') { // Retrives markers data for categories
|
| 153 | - echo get_markers(); |
|
| 154 | - exit; |
|
| 153 | + echo get_markers(); |
|
| 154 | + exit; |
|
| 155 | 155 | } else if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') { // Retrives marker info window html
|
| 156 | - /** |
|
| 157 | - * @global object $wpdb WordPress Database object. |
|
| 158 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 159 | - * @global object $gd_session GeoDirectory Session object. |
|
| 160 | - */ |
|
| 161 | - global $wpdb, $plugin_prefix, $gd_session, $sitepress; |
|
| 156 | + /** |
|
| 157 | + * @global object $wpdb WordPress Database object. |
|
| 158 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 159 | + * @global object $gd_session GeoDirectory Session object. |
|
| 160 | + */ |
|
| 161 | + global $wpdb, $plugin_prefix, $gd_session, $sitepress; |
|
| 162 | 162 | |
| 163 | - if ($_REQUEST['m_id'] != '') {
|
|
| 164 | - $pid = (int)$_REQUEST['m_id']; |
|
| 165 | - } else {
|
|
| 166 | - echo __('No marker data found', 'geodirectory');
|
|
| 167 | - exit; |
|
| 168 | - } |
|
| 163 | + if ($_REQUEST['m_id'] != '') {
|
|
| 164 | + $pid = (int)$_REQUEST['m_id']; |
|
| 165 | + } else {
|
|
| 166 | + echo __('No marker data found', 'geodirectory');
|
|
| 167 | + exit; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
|
|
| 171 | - $post = (object)$gd_ses_listing; |
|
| 172 | - echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']); |
|
| 173 | - } else {
|
|
| 174 | - $geodir_post_type = get_post_type($pid); |
|
| 170 | + if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
|
|
| 171 | + $post = (object)$gd_ses_listing; |
|
| 172 | + echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']); |
|
| 173 | + } else {
|
|
| 174 | + $geodir_post_type = get_post_type($pid); |
|
| 175 | 175 | |
| 176 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 176 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 177 | 177 | |
| 178 | - $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
|
|
| 178 | + $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
|
|
| 179 | 179 | |
| 180 | - $postinfo = $wpdb->get_results($sql); |
|
| 180 | + $postinfo = $wpdb->get_results($sql); |
|
| 181 | 181 | |
| 182 | - $data_arr = array(); |
|
| 182 | + $data_arr = array(); |
|
| 183 | 183 | |
| 184 | - if ($postinfo) {
|
|
| 185 | - $switch_lang = false; |
|
| 184 | + if ($postinfo) {
|
|
| 185 | + $switch_lang = false; |
|
| 186 | 186 | if ( geodir_is_wpml() && is_post_type_translated( $geodir_post_type ) ) {
|
| 187 | 187 | $post_lang = $sitepress->get_language_for_element( $pid, 'post_' . $geodir_post_type ); |
| 188 | 188 | $current_lang = $sitepress->get_current_language(); |
@@ -193,18 +193,18 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $srcharr = array("'", "/", "-", '"', '\\');
|
| 196 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 196 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 197 | 197 | |
| 198 | - foreach ($postinfo as $postinfo_obj) {
|
|
| 199 | - echo geodir_get_infowindow_html($postinfo_obj); |
|
| 200 | - } |
|
| 198 | + foreach ($postinfo as $postinfo_obj) {
|
|
| 199 | + echo geodir_get_infowindow_html($postinfo_obj); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | if ( $switch_lang !== false ) {
|
| 203 | 203 | $sitepress->switch_lang( $switch_lang, true ); |
| 204 | 204 | } |
| 205 | - } |
|
| 206 | - } |
|
| 207 | - exit; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + exit; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -223,93 +223,93 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | function get_markers() {
|
| 225 | 225 | |
| 226 | - global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session; |
|
| 226 | + global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session; |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Filter to allow for any map caching to be output before queries. |
|
| 231 | - * |
|
| 232 | - * @since 1.6.22 |
|
| 233 | - */ |
|
| 234 | - $map_cache = apply_filters('geodir_get_markers_cache','');
|
|
| 235 | - if($map_cache){
|
|
| 236 | - return $map_cache; |
|
| 237 | - wp_die(); |
|
| 238 | - } |
|
| 229 | + /** |
|
| 230 | + * Filter to allow for any map caching to be output before queries. |
|
| 231 | + * |
|
| 232 | + * @since 1.6.22 |
|
| 233 | + */ |
|
| 234 | + $map_cache = apply_filters('geodir_get_markers_cache','');
|
|
| 235 | + if($map_cache){
|
|
| 236 | + return $map_cache; |
|
| 237 | + wp_die(); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | |
| 242 | - $search = ''; |
|
| 242 | + $search = ''; |
|
| 243 | 243 | |
| 244 | - $srcharr = array("'", "/", "-", '"', '\\', ''');
|
|
| 245 | - $replarr = array("′", "⁄", "–", "“", '', "′");
|
|
| 244 | + $srcharr = array("'", "/", "-", '"', '\\', ''');
|
|
| 245 | + $replarr = array("′", "⁄", "–", "“", '', "′");
|
|
| 246 | 246 | |
| 247 | - $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place'; |
|
| 247 | + $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place'; |
|
| 248 | 248 | |
| 249 | - $map_cat_ids_array = array('0');
|
|
| 250 | - $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
|
|
| 249 | + $map_cat_ids_array = array('0');
|
|
| 250 | + $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
|
|
| 251 | 251 | |
| 252 | 252 | |
| 253 | - $field_default_cat = ''; |
|
| 254 | - if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
|
|
| 255 | - $map_cat_arr = trim($_REQUEST['cat_id'], ','); |
|
| 253 | + $field_default_cat = ''; |
|
| 254 | + if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
|
|
| 255 | + $map_cat_arr = trim($_REQUEST['cat_id'], ','); |
|
| 256 | 256 | |
| 257 | - if (!empty($map_cat_arr)) {
|
|
| 258 | - $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
|
|
| 257 | + if (!empty($map_cat_arr)) {
|
|
| 258 | + $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
|
|
| 259 | 259 | |
| 260 | - $map_cat_ids_array = explode(',', $map_cat_arr);
|
|
| 261 | - $cat_find_array = array(); |
|
| 262 | - foreach ($map_cat_ids_array as $cat_id) {
|
|
| 263 | - $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id "; |
|
| 264 | - $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)"; |
|
| 265 | - $main_query_array[] = $cat_id; |
|
| 266 | - } |
|
| 260 | + $map_cat_ids_array = explode(',', $map_cat_arr);
|
|
| 261 | + $cat_find_array = array(); |
|
| 262 | + foreach ($map_cat_ids_array as $cat_id) {
|
|
| 263 | + $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id "; |
|
| 264 | + $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)"; |
|
| 265 | + $main_query_array[] = $cat_id; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - } |
|
| 269 | - } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - if (!empty($field_default_cat)) |
|
| 272 | - $field_default_cat = ''; |
|
| 271 | + if (!empty($field_default_cat)) |
|
| 272 | + $field_default_cat = ''; |
|
| 273 | 273 | |
| 274 | - if (!empty($cat_find_array)) |
|
| 275 | - $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
|
|
| 274 | + if (!empty($cat_find_array)) |
|
| 275 | + $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
|
|
| 276 | 276 | |
| 277 | - $main_query_array = $map_cat_ids_array; |
|
| 277 | + $main_query_array = $map_cat_ids_array; |
|
| 278 | 278 | |
| 279 | - if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
|
|
| 280 | - $search .= " AND p.post_title LIKE %s"; |
|
| 281 | - $main_query_array[] = "%" . $_REQUEST['search'] . "%"; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Filter the marker query search SQL, values are replaces with %s or %d. |
|
| 286 | - * |
|
| 287 | - * @since 1.5.3 |
|
| 288 | - * |
|
| 289 | - * @param string $search The SQL query for search/where. |
|
| 290 | - */ |
|
| 291 | - $search = apply_filters('geodir_marker_search', $search);
|
|
| 292 | - /** |
|
| 293 | - * Filter the marker query search SQL values %s and %d, this is an array of values. |
|
| 294 | - * |
|
| 295 | - * @since 1.5.3 |
|
| 296 | - * |
|
| 297 | - * @param array $main_query_array The SQL query values for search/where. |
|
| 298 | - */ |
|
| 299 | - $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
|
|
| 300 | - |
|
| 301 | - $gd_posttype = ''; |
|
| 302 | - if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
|
|
| 303 | - $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail'; |
|
| 304 | - $gd_posttype = " AND p.post_type = %s"; |
|
| 305 | - $main_query_array[] = $_REQUEST['gd_posttype']; |
|
| 306 | - |
|
| 307 | - } else |
|
| 308 | - $table = $plugin_prefix . 'gd_place_detail'; |
|
| 309 | - |
|
| 310 | - $join = ", " . $table . " AS pd "; |
|
| 311 | - |
|
| 312 | - /** |
|
| 279 | + if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
|
|
| 280 | + $search .= " AND p.post_title LIKE %s"; |
|
| 281 | + $main_query_array[] = "%" . $_REQUEST['search'] . "%"; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Filter the marker query search SQL, values are replaces with %s or %d. |
|
| 286 | + * |
|
| 287 | + * @since 1.5.3 |
|
| 288 | + * |
|
| 289 | + * @param string $search The SQL query for search/where. |
|
| 290 | + */ |
|
| 291 | + $search = apply_filters('geodir_marker_search', $search);
|
|
| 292 | + /** |
|
| 293 | + * Filter the marker query search SQL values %s and %d, this is an array of values. |
|
| 294 | + * |
|
| 295 | + * @since 1.5.3 |
|
| 296 | + * |
|
| 297 | + * @param array $main_query_array The SQL query values for search/where. |
|
| 298 | + */ |
|
| 299 | + $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
|
|
| 300 | + |
|
| 301 | + $gd_posttype = ''; |
|
| 302 | + if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
|
|
| 303 | + $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail'; |
|
| 304 | + $gd_posttype = " AND p.post_type = %s"; |
|
| 305 | + $main_query_array[] = $_REQUEST['gd_posttype']; |
|
| 306 | + |
|
| 307 | + } else |
|
| 308 | + $table = $plugin_prefix . 'gd_place_detail'; |
|
| 309 | + |
|
| 310 | + $join = ", " . $table . " AS pd "; |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | 313 | * Filter the SQL JOIN clause for the markers data |
| 314 | 314 | * |
| 315 | 315 | * @since 1.0.0 |
@@ -326,16 +326,16 @@ discard block |
||
| 326 | 326 | * @param string $search Row of searched fields to use in WHERE clause. |
| 327 | 327 | */ |
| 328 | 328 | $search = apply_filters('geodir_home_map_listing_where', $search);
|
| 329 | - $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
|
|
| 330 | - $cat_type = $post_type . 'category'; |
|
| 331 | - if ($post_type == 'gd_event') {
|
|
| 332 | - $event_select = ", pd.recurring_dates, pd.is_recurring"; |
|
| 333 | - } else {
|
|
| 334 | - $event_select = ""; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select; |
|
| 338 | - /** |
|
| 329 | + $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
|
|
| 330 | + $cat_type = $post_type . 'category'; |
|
| 331 | + if ($post_type == 'gd_event') {
|
|
| 332 | + $event_select = ", pd.recurring_dates, pd.is_recurring"; |
|
| 333 | + } else {
|
|
| 334 | + $event_select = ""; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select; |
|
| 338 | + /** |
|
| 339 | 339 | * Filter the SQL SELECT clause to retrive fields data |
| 340 | 340 | * |
| 341 | 341 | * @since 1.0.0 |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | $groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
|
| 356 | 356 | |
| 357 | - $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
|
|
| 357 | + $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
|
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * Filter the SQL query to retrive markers data |
@@ -370,276 +370,276 @@ discard block |
||
| 370 | 370 | // print_r($gd_session); |
| 371 | 371 | // print_r($_SESSION); |
| 372 | 372 | |
| 373 | - $catinfo = $wpdb->get_results($catsql); |
|
| 373 | + $catinfo = $wpdb->get_results($catsql); |
|
| 374 | 374 | |
| 375 | - $cat_content_info = array(); |
|
| 376 | - $content_data = array(); |
|
| 377 | - $post_ids = array(); |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Called before marker data is processed into JSON. |
|
| 381 | - * |
|
| 382 | - * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 383 | - * |
|
| 384 | - * @since 1.5.3 |
|
| 385 | - * @param object $catinfo The posts object containing all marker data. |
|
| 386 | - * @see 'geodir_after_marker_post_process' |
|
| 387 | - */ |
|
| 388 | - $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
|
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Called before marker data is processed into JSON. |
|
| 392 | - * |
|
| 393 | - * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 394 | - * |
|
| 395 | - * @since 1.4.9 |
|
| 396 | - * @param object $catinfo The posts object containing all marker data. |
|
| 397 | - * @see 'geodir_after_marker_post_process' |
|
| 398 | - */ |
|
| 399 | - do_action('geodir_before_marker_post_process_action', $catinfo);
|
|
| 400 | - |
|
| 401 | - // Sort any posts into a ajax array |
|
| 402 | - if (!empty($catinfo)) {
|
|
| 403 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
| 404 | - global $geodir_date_time_format, $geodir_date_format, $geodir_time_format; |
|
| 405 | - |
|
| 406 | - $today = strtotime(date_i18n('Y-m-d'));
|
|
| 407 | - $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
|
|
| 375 | + $cat_content_info = array(); |
|
| 376 | + $content_data = array(); |
|
| 377 | + $post_ids = array(); |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Called before marker data is processed into JSON. |
|
| 381 | + * |
|
| 382 | + * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 383 | + * |
|
| 384 | + * @since 1.5.3 |
|
| 385 | + * @param object $catinfo The posts object containing all marker data. |
|
| 386 | + * @see 'geodir_after_marker_post_process' |
|
| 387 | + */ |
|
| 388 | + $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
|
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Called before marker data is processed into JSON. |
|
| 392 | + * |
|
| 393 | + * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 394 | + * |
|
| 395 | + * @since 1.4.9 |
|
| 396 | + * @param object $catinfo The posts object containing all marker data. |
|
| 397 | + * @see 'geodir_after_marker_post_process' |
|
| 398 | + */ |
|
| 399 | + do_action('geodir_before_marker_post_process_action', $catinfo);
|
|
| 400 | + |
|
| 401 | + // Sort any posts into a ajax array |
|
| 402 | + if (!empty($catinfo)) {
|
|
| 403 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
| 404 | + global $geodir_date_time_format, $geodir_date_format, $geodir_time_format; |
|
| 405 | + |
|
| 406 | + $today = strtotime(date_i18n('Y-m-d'));
|
|
| 407 | + $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
|
|
| 408 | 408 | |
| 409 | - foreach ($catinfo as $catinfo_obj) {
|
|
| 410 | - $post_title = $catinfo_obj->post_title; |
|
| 409 | + foreach ($catinfo as $catinfo_obj) {
|
|
| 410 | + $post_title = $catinfo_obj->post_title; |
|
| 411 | 411 | |
| 412 | - if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
|
|
| 413 | - $event_dates = ''; |
|
| 414 | - $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array(); |
|
| 412 | + if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
|
|
| 413 | + $event_dates = ''; |
|
| 414 | + $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array(); |
|
| 415 | 415 | |
| 416 | - $post_info = geodir_get_post_info($catinfo_obj->post_id); |
|
| 416 | + $post_info = geodir_get_post_info($catinfo_obj->post_id); |
|
| 417 | 417 | |
| 418 | - if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
|
|
| 419 | - $starttimes = ''; |
|
| 420 | - $endtimes = ''; |
|
| 421 | - $astarttimes = array(); |
|
| 422 | - $aendtimes = array(); |
|
| 423 | - if ( !isset( $recurring_data['repeat_type'] ) ) {
|
|
| 424 | - $recurring_data['repeat_type'] = 'custom'; |
|
| 425 | - } |
|
| 426 | - $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom |
|
| 427 | - $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false; |
|
| 418 | + if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
|
|
| 419 | + $starttimes = ''; |
|
| 420 | + $endtimes = ''; |
|
| 421 | + $astarttimes = array(); |
|
| 422 | + $aendtimes = array(); |
|
| 423 | + if ( !isset( $recurring_data['repeat_type'] ) ) {
|
|
| 424 | + $recurring_data['repeat_type'] = 'custom'; |
|
| 425 | + } |
|
| 426 | + $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom |
|
| 427 | + $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false; |
|
| 428 | 428 | |
| 429 | - $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
|
|
| 429 | + $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
|
|
| 430 | 430 | |
| 431 | - if ( !empty( $recurring_dates ) ) {
|
|
| 432 | - if ( empty( $recurring_data['all_day'] ) ) {
|
|
| 433 | - if ( $repeat_type == 'custom' && $different_times ) {
|
|
| 434 | - $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
| 435 | - $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
| 436 | - } else {
|
|
| 437 | - $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
| 438 | - $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
| 439 | - } |
|
| 440 | - } |
|
| 431 | + if ( !empty( $recurring_dates ) ) {
|
|
| 432 | + if ( empty( $recurring_data['all_day'] ) ) {
|
|
| 433 | + if ( $repeat_type == 'custom' && $different_times ) {
|
|
| 434 | + $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
| 435 | + $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
| 436 | + } else {
|
|
| 437 | + $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
| 438 | + $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - $e = 0; |
|
| 443 | - foreach( $recurring_dates as $key => $date ) {
|
|
| 444 | - if ( $repeat_type == 'custom' && $different_times ) {
|
|
| 445 | - if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
|
|
| 446 | - $starttimes = $astarttimes[$key]; |
|
| 447 | - $endtimes = $aendtimes[$key]; |
|
| 448 | - } else {
|
|
| 449 | - $starttimes = ''; |
|
| 450 | - $endtimes = ''; |
|
| 451 | - } |
|
| 452 | - } |
|
| 442 | + $e = 0; |
|
| 443 | + foreach( $recurring_dates as $key => $date ) {
|
|
| 444 | + if ( $repeat_type == 'custom' && $different_times ) {
|
|
| 445 | + if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
|
|
| 446 | + $starttimes = $astarttimes[$key]; |
|
| 447 | + $endtimes = $aendtimes[$key]; |
|
| 448 | + } else {
|
|
| 449 | + $starttimes = ''; |
|
| 450 | + $endtimes = ''; |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1; |
|
| 455 | - $duration--; |
|
| 456 | - $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) ); |
|
| 454 | + $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1; |
|
| 455 | + $duration--; |
|
| 456 | + $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) ); |
|
| 457 | 457 | |
| 458 | - // Hide past dates |
|
| 459 | - if ( strtotime( $enddate ) < $today ) {
|
|
| 460 | - continue; |
|
| 461 | - } |
|
| 458 | + // Hide past dates |
|
| 459 | + if ( strtotime( $enddate ) < $today ) {
|
|
| 460 | + continue; |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - $sdate = strtotime( $date . ' ' . $starttimes ); |
|
| 464 | - $edate = strtotime( $enddate . ' ' . $endtimes ); |
|
| 463 | + $sdate = strtotime( $date . ' ' . $starttimes ); |
|
| 464 | + $edate = strtotime( $enddate . ' ' . $endtimes ); |
|
| 465 | 465 | |
| 466 | - $start_date = date_i18n( $geodir_date_time_format, $sdate ); |
|
| 467 | - $end_date = date_i18n( $geodir_date_time_format, $edate ); |
|
| 466 | + $start_date = date_i18n( $geodir_date_time_format, $sdate ); |
|
| 467 | + $end_date = date_i18n( $geodir_date_time_format, $edate ); |
|
| 468 | 468 | |
| 469 | - $same_day = false; |
|
| 470 | - $full_day = false; |
|
| 471 | - $same_datetime = false; |
|
| 469 | + $same_day = false; |
|
| 470 | + $full_day = false; |
|
| 471 | + $same_datetime = false; |
|
| 472 | 472 | |
| 473 | - if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
|
|
| 474 | - $full_day = true; |
|
| 475 | - } |
|
| 473 | + if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
|
|
| 474 | + $full_day = true; |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | - if ( $start_date == $end_date && $full_day ) {
|
|
| 478 | - $same_datetime = true; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - $link_date = date_i18n( 'Y-m-d', $sdate ); |
|
| 482 | - $title_date = date_i18n( $geodir_date_format, $sdate ); |
|
| 483 | - if ( $full_day ) {
|
|
| 484 | - $start_date = $title_date; |
|
| 485 | - $end_date = date_i18n( $geodir_date_format, $edate ); |
|
| 486 | - } |
|
| 477 | + if ( $start_date == $end_date && $full_day ) {
|
|
| 478 | + $same_datetime = true; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + $link_date = date_i18n( 'Y-m-d', $sdate ); |
|
| 482 | + $title_date = date_i18n( $geodir_date_format, $sdate ); |
|
| 483 | + if ( $full_day ) {
|
|
| 484 | + $start_date = $title_date; |
|
| 485 | + $end_date = date_i18n( $geodir_date_format, $edate ); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
|
|
| 489 | - $same_day = true; |
|
| 488 | + if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
|
|
| 489 | + $same_day = true; |
|
| 490 | 490 | |
| 491 | - $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate ); |
|
| 492 | - } |
|
| 491 | + $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate ); |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - $event_dates .= ' :: ' . $start_date; |
|
| 494 | + $event_dates .= ' :: ' . $start_date; |
|
| 495 | 495 | |
| 496 | - if ( !$same_day && !$same_datetime ) {
|
|
| 497 | - $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
| 498 | - } |
|
| 496 | + if ( !$same_day && !$same_datetime ) {
|
|
| 497 | + $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - $e++; |
|
| 500 | + $e++; |
|
| 501 | 501 | |
| 502 | - if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
|
|
| 503 | - break; |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - } else {
|
|
| 508 | - $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : ''; |
|
| 509 | - $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date; |
|
| 510 | - $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false; |
|
| 511 | - $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
| 512 | - $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
| 502 | + if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
|
|
| 503 | + break; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + } else {
|
|
| 508 | + $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : ''; |
|
| 509 | + $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date; |
|
| 510 | + $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false; |
|
| 511 | + $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
| 512 | + $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
| 513 | 513 | |
| 514 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 515 | - $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
| 516 | - $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
| 514 | + $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 515 | + $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
| 516 | + $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
| 517 | 517 | |
| 518 | - if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
|
|
| 519 | - $start_date = $event_recurring_dates[0]; |
|
| 520 | - } |
|
| 518 | + if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
|
|
| 519 | + $start_date = $event_recurring_dates[0]; |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | - if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
|
|
| 523 | - $end_date = $start_date; |
|
| 524 | - } |
|
| 522 | + if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
|
|
| 523 | + $end_date = $start_date; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - if ($end_date != '' && strtotime($end_date) >= $today) {
|
|
| 527 | - if ( $starttime == '' && !empty( $starttimes ) ) {
|
|
| 528 | - $starttime = $starttimes[0]; |
|
| 529 | - $endtime = $endtimes[0]; |
|
| 530 | - } |
|
| 526 | + if ($end_date != '' && strtotime($end_date) >= $today) {
|
|
| 527 | + if ( $starttime == '' && !empty( $starttimes ) ) {
|
|
| 528 | + $starttime = $starttimes[0]; |
|
| 529 | + $endtime = $endtimes[0]; |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | - $same_day = false; |
|
| 533 | - $one_day = false; |
|
| 534 | - if ( $start_date == $end_date && $all_day ) {
|
|
| 535 | - $one_day = true; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - if ( $all_day ) {
|
|
| 539 | - $start_datetime = strtotime( $start_date ); |
|
| 540 | - $end_datetime = strtotime( $end_date ); |
|
| 532 | + $same_day = false; |
|
| 533 | + $one_day = false; |
|
| 534 | + if ( $start_date == $end_date && $all_day ) {
|
|
| 535 | + $one_day = true; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + if ( $all_day ) {
|
|
| 539 | + $start_datetime = strtotime( $start_date ); |
|
| 540 | + $end_datetime = strtotime( $end_date ); |
|
| 541 | 541 | |
| 542 | - $start_date = date_i18n( $geodir_date_format, $start_datetime ); |
|
| 543 | - $end_date = date_i18n( $geodir_date_format, $end_datetime ); |
|
| 544 | - if ( $start_date == $end_date ) {
|
|
| 545 | - $one_day = true; |
|
| 546 | - } |
|
| 547 | - } else {
|
|
| 548 | - if ( $start_date == $end_date && $starttime == $endtime ) {
|
|
| 549 | - $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) ); |
|
| 550 | - $one_day = false; |
|
| 551 | - } |
|
| 552 | - $start_datetime = strtotime( $start_date . ' ' . $starttime ); |
|
| 553 | - $end_datetime = strtotime( $end_date . ' ' . $endtime ); |
|
| 542 | + $start_date = date_i18n( $geodir_date_format, $start_datetime ); |
|
| 543 | + $end_date = date_i18n( $geodir_date_format, $end_datetime ); |
|
| 544 | + if ( $start_date == $end_date ) {
|
|
| 545 | + $one_day = true; |
|
| 546 | + } |
|
| 547 | + } else {
|
|
| 548 | + if ( $start_date == $end_date && $starttime == $endtime ) {
|
|
| 549 | + $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) ); |
|
| 550 | + $one_day = false; |
|
| 551 | + } |
|
| 552 | + $start_datetime = strtotime( $start_date . ' ' . $starttime ); |
|
| 553 | + $end_datetime = strtotime( $end_date . ' ' . $endtime ); |
|
| 554 | 554 | |
| 555 | - $start_date = date_i18n( $geodir_date_time_format, $start_datetime ); |
|
| 556 | - $end_date = date_i18n( $geodir_date_time_format, $end_datetime ); |
|
| 557 | - } |
|
| 555 | + $start_date = date_i18n( $geodir_date_time_format, $start_datetime ); |
|
| 556 | + $end_date = date_i18n( $geodir_date_time_format, $end_datetime ); |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
|
|
| 560 | - $same_day = true; |
|
| 559 | + if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
|
|
| 560 | + $same_day = true; |
|
| 561 | 561 | |
| 562 | - $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime ); |
|
| 563 | - } |
|
| 562 | + $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime ); |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - $event_dates .= ' :: ' . $start_date; |
|
| 565 | + $event_dates .= ' :: ' . $start_date; |
|
| 566 | 566 | |
| 567 | - if ( !$same_day && !$one_day ) {
|
|
| 568 | - $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - if (empty($event_dates)) {
|
|
| 574 | - continue; |
|
| 575 | - } |
|
| 567 | + if ( !$same_day && !$one_day ) {
|
|
| 568 | + $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + if (empty($event_dates)) {
|
|
| 574 | + continue; |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - $post_title .= $event_dates; |
|
| 578 | - } |
|
| 577 | + $post_title .= $event_dates; |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - $map_cat_ids_array; |
|
| 581 | - $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : ''; |
|
| 580 | + $map_cat_ids_array; |
|
| 581 | + $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : ''; |
|
| 582 | 582 | |
| 583 | - // if single cat lets just show that icon |
|
| 584 | - if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
|
|
| 585 | - $default_cat = (int)$map_cat_ids_array[0]; |
|
| 586 | - } |
|
| 583 | + // if single cat lets just show that icon |
|
| 584 | + if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
|
|
| 585 | + $default_cat = (int)$map_cat_ids_array[0]; |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : ''; |
|
| 589 | - $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : ''; |
|
| 590 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 588 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : ''; |
|
| 589 | + $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : ''; |
|
| 590 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 591 | 591 | |
| 592 | - if ($icon != '') {
|
|
| 593 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 592 | + if ($icon != '') {
|
|
| 593 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 594 | 594 | |
| 595 | - if (isset($gd_marker_sizes[$icon])) {
|
|
| 596 | - $icon_size = $gd_marker_sizes[$icon]; |
|
| 597 | - } else {
|
|
| 598 | - $icon_size = geodir_get_marker_size($icon); |
|
| 599 | - $gd_marker_sizes[$icon] = $icon_size; |
|
| 600 | - } |
|
| 601 | - } else {
|
|
| 602 | - $icon_size = array('w' => 36, 'h' => 45);
|
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
|
|
| 606 | - $post_ids[] = $catinfo_obj->post_id; |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * Called after marker data is processed into JSON. |
|
| 612 | - * |
|
| 613 | - * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 614 | - * |
|
| 615 | - * @since 1.4.9 |
|
| 616 | - * @param array $content_data The array containing all markers in JSON format. |
|
| 617 | - * @param object $catinfo The posts object containing all marker data. |
|
| 618 | - * @see 'geodir_before_marker_post_process' |
|
| 619 | - */ |
|
| 620 | - do_action('geodir_after_marker_post_process', $content_data, $catinfo);
|
|
| 621 | - |
|
| 622 | - if (!empty($content_data)) {
|
|
| 623 | - $cat_content_info[] = implode(',', $content_data);
|
|
| 624 | - } |
|
| 625 | - |
|
| 626 | - $totalcount = count(array_unique($post_ids)); |
|
| 627 | - |
|
| 628 | - if (!empty($cat_content_info)) {
|
|
| 629 | - $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
|
|
| 630 | - } |
|
| 631 | - else {
|
|
| 632 | - $map_json = '[{"totalcount":"0"}]';
|
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * Filter the marker json return. |
|
| 638 | - * |
|
| 639 | - * @since 1.6.22 |
|
| 640 | - * @param string $map_json The JSON string of the map markers results. |
|
| 641 | - */ |
|
| 642 | - return apply_filters('geodir_markers_json',$map_json);
|
|
| 595 | + if (isset($gd_marker_sizes[$icon])) {
|
|
| 596 | + $icon_size = $gd_marker_sizes[$icon]; |
|
| 597 | + } else {
|
|
| 598 | + $icon_size = geodir_get_marker_size($icon); |
|
| 599 | + $gd_marker_sizes[$icon] = $icon_size; |
|
| 600 | + } |
|
| 601 | + } else {
|
|
| 602 | + $icon_size = array('w' => 36, 'h' => 45);
|
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
|
|
| 606 | + $post_ids[] = $catinfo_obj->post_id; |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * Called after marker data is processed into JSON. |
|
| 612 | + * |
|
| 613 | + * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
| 614 | + * |
|
| 615 | + * @since 1.4.9 |
|
| 616 | + * @param array $content_data The array containing all markers in JSON format. |
|
| 617 | + * @param object $catinfo The posts object containing all marker data. |
|
| 618 | + * @see 'geodir_before_marker_post_process' |
|
| 619 | + */ |
|
| 620 | + do_action('geodir_after_marker_post_process', $content_data, $catinfo);
|
|
| 621 | + |
|
| 622 | + if (!empty($content_data)) {
|
|
| 623 | + $cat_content_info[] = implode(',', $content_data);
|
|
| 624 | + } |
|
| 625 | + |
|
| 626 | + $totalcount = count(array_unique($post_ids)); |
|
| 627 | + |
|
| 628 | + if (!empty($cat_content_info)) {
|
|
| 629 | + $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
|
|
| 630 | + } |
|
| 631 | + else {
|
|
| 632 | + $map_json = '[{"totalcount":"0"}]';
|
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * Filter the marker json return. |
|
| 638 | + * |
|
| 639 | + * @since 1.6.22 |
|
| 640 | + * @param string $map_json The JSON string of the map markers results. |
|
| 641 | + */ |
|
| 642 | + return apply_filters('geodir_markers_json',$map_json);
|
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | |