Function Reference: geodir_location_replace_vars
Summary
This function has not been documented yet.
Filters
‘geodir_meta_description_location_empty_text’ [Line: 696]
‘geodir_meta_description_single_location_empty_text’ [Line: 710]
‘geodir_filter_location_replace_variables’ [Line: 738]
Source File
geodir_location_replace_vars() is located in geodirectory-functions/location_functions.php [Line: 605]
Source Code
function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){ global $wp; $location_manager = defined('GEODIRLOCATION_VERSION') ? true : false; if (empty($location_array)) { $location_array = geodir_get_current_location_terms('query_vars'); } $location_terms = array(); $location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : ''; $location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : ''; $location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : ''; $location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : ''; $location_names = array(); foreach ($location_terms as $type => $location) { $location_name = $location; if (!empty($location_name)) { if ($location_manager) { $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; $location_name = get_actual_location_name($location_type, $location, true); } else { $location_name = preg_replace( '/-(\d+)$/', '', $location_name); $location_name = preg_replace( '/[_-]/', ' ', $location_name ); $location_name = __(geodir_ucwords($location_name), 'geodirectory'); } } $location_names[$type] = $location_name; } $location_single = ''; foreach ($location_terms as $type => $location) { if (!empty($location)) { if (!empty($location_names[$type])) { $location_single = $location_names[$type]; } else { if ($location_manager) { $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; $location_single = get_actual_location_name($location_type, $location, true); } else { $location_name = preg_replace( '/-(\d+)$/', '', $location); $location_name = preg_replace( '/[_-]/', ' ', $location_name ); $location_single = __(geodir_ucwords($location_name), 'geodirectory'); } } break; } } $full_location = array(); if (!empty($location_array)) { $location_array = array_reverse($location_array); foreach ($location_array as $type => $location) { if (!empty($location_names[$type])) { $location_name = $location_names[$type]; } else { if ($location_manager) { $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; $location_name = get_actual_location_name($location_type, $location, true); } else { $location_name = preg_replace( '/-(\d+)$/', '', $location); $location_name = preg_replace( '/[_-]/', ' ', $location_name ); $location_name = __(geodir_ucwords($location_name), 'geodirectory'); } } $full_location[] = $location_name; } if (!empty($full_location)) { $full_location = array_unique($full_location); } } $full_location = !empty($full_location) ? implode(', ', $full_location): ''; if ( empty( $full_location ) ) { /** * Filter the text in meta description in full location is empty. * * @since 1.6.22 * * @param string $full_location Default: Empty. * @param array $location_array The array of location variables. * @param string $gd_page The page being filtered. * @param string $sep The separator. */ $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep ); } if ( empty( $location_single ) ) { /** * Filter the text in meta description in single location is empty. * * @since 1.6.22 * * @param string $location_single Default: Empty. * @param array $location_array The array of location variables. * @param string $gd_page The page being filtered. * @param string $sep The separator. */ $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep ); } $location_replace_vars = array(); $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|'; $location_replace_vars['%%location%%'] = $full_location; $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : ''; $location_replace_vars['%%location_single%%'] = $location_single; $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : ''; foreach ($location_names as $type => $name) { $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; $location_replace_vars['%%location_' . $location_type . '%%'] = $name; $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : ''; } /** * Filter the location terms variables to search & replace. * * @since 1.6.16 * @package GeoDirectory * * @param array $location_replace_vars The array of search & replace variables. * @param array $location_array The array of location variables. * @param string $gd_page The page being filtered. * @param string $sep The separator. */ return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep ); }