Function Reference: geodir_sc_location_description
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $wp
- (object) (required) WordPress object.
- Default: None
Parameters
- ($atts) (required)
- Default: None
Return Values
- (null|string)
Source File
geodir_sc_location_description() is located in geodir_location_manager/geodir_location_shortcodes.php [Line: 100]
Source Code
function geodir_sc_location_description( $atts ) {
global $wpdb, $wp;
ob_start();
$gd_country = isset( $wp->query_vars['gd_country'] ) ? $wp->query_vars['gd_country'] : '';
$gd_region = isset( $wp->query_vars['gd_region'] ) ? $wp->query_vars['gd_region'] : '';
$gd_city = isset( $wp->query_vars['gd_city'] ) ? $wp->query_vars['gd_city'] : '';
$location_title = '';
$seo_title = '';
$seo_desc = '';
if ( $gd_city ) {
$info = geodir_city_info_by_slug( $gd_city, $gd_country, $gd_region );
if ( ! empty( $info ) ) {
$location_title = $info->city;
$seo_title = $info->city_meta;
$seo_desc = $info->city_desc;
}
} else if ( ! $gd_city && $gd_region ) {
$info = geodir_location_seo_by_slug( $gd_region, 'region', $gd_country );
if ( ! empty( $info ) ) {
$seo_title = $info->seo_title;
$seo_desc = $info->seo_desc;
$location_title = $wpdb->get_var( $wpdb->prepare( "SELECT region FROM " . POST_LOCATION_TABLE . " WHERE region_slug!='' AND region_slug=%s ORDER BY location_id ASC", array( $gd_region ) ) );
}
} else if ( ! $gd_city && ! $gd_region && $gd_country ) {
$info = geodir_location_seo_by_slug( $gd_country, 'country' );
if ( ! empty( $info ) ) {
$seo_title = $info->seo_title;
$seo_desc = $info->seo_desc;
$location_title = $wpdb->get_var( $wpdb->prepare( "SELECT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug!='' AND country_slug=%s ORDER BY location_id ASC", array( $gd_country ) ) );
}
}
$location_desc = $seo_desc;
if ( $location_desc == '' ) {
return null;
}
$location_desc = stripslashes_deep( $location_desc );
echo '' . $location_desc . '';
$output = ob_get_contents();
ob_end_clean();
return $output;
}