Function Reference: geodir_save_cat_location

Summary

Save category location.

Global Values

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

Default: None

Package

GeoDirectory_Location_Manager

Change Log

Since: 1.0.0

Source File

geodir_save_cat_location() is located in geodir_location_manager/geodir_location_functions.php [Line: 2426]

Source Code

function geodir_save_cat_location() {
	global $wpdb;

	$wpnonce = isset($_REQUEST['wpnonce']) ? $_REQUEST['wpnonce'] : '';
	$locid = isset($_REQUEST['locid']) ? (int)$_REQUEST['locid'] : '';
	$catid = isset($_REQUEST['catid']) ? (int)$_REQUEST['catid'] : '';
	$posttype = isset($_REQUEST['posttype']) ? $_REQUEST['posttype'] : '';
	$content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
	$loc_default = isset($_REQUEST['loc_default']) ? $_REQUEST['loc_default'] : '';

	$category_taxonomy = geodir_get_taxonomies($posttype);
	$taxonomy = isset($category_taxonomy[0]) && $category_taxonomy[0] ? $category_taxonomy[0] : 'gd_placecategory';

	if(is_admin() && $wpnonce && current_user_can( 'manage_options' ) && $locid>0 && $catid>0 && $posttype) {
		$option = array();
		$option['gd_cat_loc_default'] = (int)$loc_default;
		$option['gd_cat_loc_cat_id'] = $catid;
		$option['gd_cat_loc_post_type'] = $posttype;
		$option['gd_cat_loc_taxonomy'] = $taxonomy;
		$option_name = 'geodir_cat_loc_'.$posttype.'_'.$catid;

		update_option($option_name, $option);

		$option = array();
		$option['gd_cat_loc_loc_id'] = (int)$locid;
		$option['gd_cat_loc_cat_id'] = (int)$catid;
		$option['gd_cat_loc_post_type'] = $posttype;
		$option['gd_cat_loc_taxonomy'] = $taxonomy;
		$option['gd_cat_loc_desc'] = $content;
		$option_name = 'geodir_cat_loc_'.$posttype.'_'.$catid.'_'.$locid;

		update_option($option_name, $option);

		echo 'OK';
		exit;
	}
	echo 'FAIL';
	exit;
}