Function Reference: geodir_location_action_listings_description

Summary

Adds listing description to the page.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$wp_query
(object) (required) WordPress Query object.

Default: None

Package

GeoDirectory_Location_Manager

Change Log

Since: 1.0.0

Filters

‘the_content’ [Line: 3718]

Source File

geodir_location_action_listings_description() is located in geodir_location_manager/geodir_location_hooks_actions.php [Line: 3655]

Source Code

function geodir_location_action_listings_description() {
	global $wpdb, $wp_query;
    $current_term = $wp_query->get_queried_object();
	$gd_post_type = geodir_get_current_posttype();
	if (isset($current_term->term_id) && $current_term->term_id != '') {
		$term_desc = term_description( $current_term->term_id, $gd_post_type.'_tags' ) ;
		$saved_data = stripslashes(get_tax_meta($current_term->term_id,'ct_cat_top_desc', false, $gd_post_type));
		if($term_desc && !$saved_data) { 
			$saved_data = $term_desc;
		}
		$default_location = geodir_get_default_location();
		$location_type = geodir_what_is_current_location();
		$replace_location = __('Everywhere', GEODIRLOCATION_TEXTDOMAIN);
		
		$gd_country = get_query_var( 'gd_country' );
		$gd_region = get_query_var( 'gd_region' );
		$gd_city = get_query_var( 'gd_city' );
		$current_location = '';
		if ( $gd_country != '' ) {
			$location_type = 'country';
			$current_location = get_actual_location_name( 'country', $gd_country, true );
		}
		if ( $gd_region != '' ) {
			$location_type = 'region';
			$current_location = get_actual_location_name( 'region', $gd_region );
		}
		if ( $gd_city != '' ) {
			$location_type = 'city';
			$current_location = get_actual_location_name( 'city', $gd_city );
		}
		
		if ($location_type == 'city') {
			$replace_location = geodir_get_current_location(array('what' => 'city' , 'echo'=>false));
			
			$option_name = 'geodir_cat_loc_'.$gd_post_type.'_'.$current_term->term_id;
			$cat_loc_option = get_option($option_name);
			
			$gd_cat_loc_default = !empty( $cat_loc_option ) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default']>0 ? true : false;
			
			if ( !$gd_cat_loc_default && $gd_city != '' ) {
				$post_type = $gd_post_type;
				$term_id = $current_term->term_id; 
				$sql = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1",array($gd_city));
				$location_id = $wpdb->get_var($sql);
				if ($location_id>0) {
					$option_name = 'geodir_cat_loc_'.$post_type.'_'.$term_id.'_'.$location_id;
					$option = get_option($option_name);
					$gd_cat_loc_desc = !empty($option) && isset($option['gd_cat_loc_desc']) ? trim($option['gd_cat_loc_desc']) : '';
					if ($gd_cat_loc_desc!='') {
						$saved_data = stripslashes_deep($gd_cat_loc_desc);
					}
				}
			}
		} else if($location_type == 'region') {
			$replace_location = geodir_get_current_location(array('what' => 'region' , 'echo'=>false));
		} else if($location_type == 'country') {
			$replace_location = geodir_get_current_location(array('what' => 'country' , 'echo'=>false));
			$replace_location = __( $replace_location, GEODIRECTORY_TEXTDOMAIN );
		}
		$replace_location = $current_location != '' ? $current_location : $replace_location;
		
		$saved_data = str_replace('%location%', $replace_location, $saved_data);
		
		$cat_description =  apply_filters( 'the_content', $saved_data );
		if($cat_description) {
			echo '
'.$cat_description.'
'; } } }