Function Reference: geodir_location_cat_loc_desc

Summary

Adds additional description form fields to the listing category.

Global Values

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

Default: None

Package

GeoDirectory_Location_Manager

Parameters

($row) (required)

Default: None

Change Log

Since: 1.0.0

Source File

geodir_location_cat_loc_desc() is located in geodir_location_manager/geodir_location_hooks_actions.php [Line: 3354]

Source Code

function geodir_location_cat_loc_desc($row) {
	global $wpdb, $wp_version;
	
	if( !is_admin() ) {
		return;
	}
	
	$taxonomy = !empty($row) && !empty($row->taxonomy) ? $row->taxonomy : '';
	if (!$taxonomy) {
		return;
	}
	$taxObject = get_taxonomy($taxonomy);

	$post_type = isset($taxObject->object_type[0]) ? $taxObject->object_type[0] : '';

	if (!$post_type) {
		return;
	}
	
	if ( $taxonomy != $post_type . 'category' ) {
		return;
	}
	$sql = "SELECT loc.location_id, loc.country, loc.region, loc.city, loc.city_meta FROM ".POST_LOCATION_TABLE." AS loc ORDER BY loc.city ASC";
	$locations = $wpdb->get_results($sql);
	if (empty($locations)) {
		return;
	}
	
	$term_id = $row->term_id;
	$term_name = $row->name;
	$term_slug = $row->slug;
	
	$gd_cat_loc_default = 1;
	
	$option_name = 'geodir_cat_loc_'.$post_type.'_'.$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']) ? (int)$cat_loc_option['gd_cat_loc_default'] : $gd_cat_loc_default;
	if (isset($_REQUEST['topdesc_type'])) {
		$gd_cat_loc_default = true;
	}
	
	$is_default = true;
	if ($gd_cat_loc_default==0) {
		$is_default = false;
	}
	
	$location_options_arr = array();
	$location_options = '';
	$count = 0;
	if (isset($_REQUEST['gd_location'])) {
		$gd_location = (int)$_REQUEST['gd_location'];
	}
	foreach ($locations as $location) {
		$count++;
		$location_id = (int)$location->location_id;
		if ($count==1 && !isset($gd_location)) {
			$gd_location = $location_id;
		}
		$country = $location->country;
		$region = $location->region;
		$city = $location->city;
		$location_name = $city.', '.$region.', '. __( $country, GEODIRECTORY_TEXTDOMAIN );
		$location_options_arr[] = array('value' => $location_id, 'label' => $location_name);
		$selected = $gd_location == $location_id ? 'selected="selected"' : '';
		if ($gd_location == $location_id) {
			$gd_location_name = $location_name;
		}
		$location_options .= '';
	}
	
	$option_name = 'geodir_cat_loc_'.$post_type.'_'.$term_id.'_'.$gd_location;
	$option = get_option($option_name);
	$gd_cat_loc_desc = !empty($option) && isset($option['gd_cat_loc_desc']) ? $option['gd_cat_loc_desc'] : '';
	if (isset($_REQUEST['gd_cat_loc'])) {
		$gd_cat_loc_desc = $_REQUEST['gd_cat_loc'];
	}
	$description = esc_attr( $gd_cat_loc_desc );
	?>
	
		
		 /> Use description of default for all locations
>
'; ?>
'; echo ''; if ( version_compare( $wp_version, '3.2.1' ) < 1 ) { echo ''; } else { $settings = array( 'textarea_name' => $field_name,'media_buttons' => true, 'editor_class' => 'at-wysiwyg cat-loc-desc', 'textarea_rows' => 10 ); // Use new wp_editor() since WP 3.3 wp_editor( stripslashes(html_entity_decode($description)), $field_id, $settings ); } ?>