ReversedK edited this page Aug 16, 2016 · 4 revisions

The Addon Helper Class doesn't provide a wrapper for every hook in LocateAnything. Here are some hooks you can use if needed.

Hook : locate_anything_marker_params

Description : Alters the "low level" params of the markers such as latitude, longitude, address, etc...before generation of the JSON.

Arguments
[array] $marker_params : variables and respective values of the current marker [int] $map_id : Map ID
[int] $marker_id : marker ID
[string] $type : Post type (or 'user') or 'all'. Determines the scope.

Return : $marker_params

Example

function alter_marker_params($marker_params,$marker_id,$map_id){  
	/* only for users */	
	if($post_params["post_type"]!=='user') return $post_params;	
	/* No latlon?*/
	if(empty($post_params["locate-anything-lat"]) || empty($post_params["locate-anything-lon"])) {		
	/* code  to get the lat/lon for marker... */
	}
	return $marker_params
}  
add_filter('locate_anything_marker_params',alter_marker_params,10,3);

Hook : locate_anything_find_markers_query_args

Description : Alter parameters of the find query. Those parameters will be used in a query_posts call by LocateAnything_Tools::findSomething()

Arguments
[array] $query_args : query parameters
[array] $settings : current map settings

Return : $query_args

Example

function locate_anything_alter_query($query_args,$settings){
	if($settings['locate-anything-source']=="recipe") {
		$query_args['post_status'] = 'draft';
	}
	return $query_args;
} 
add_filter('locate_anything_find_markers_query_args',locate_anything_alter_query,10,2);
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.