Plugins / call_anchor()

Description

“Calls an anchor”: sets up a callback for plugins. Can be used to define an action spot in the code or set up a filter on data.

Usage

<?php 
	call_anchor( $name, $params ); 
?>

Parameters

$name

  • required
  • string

The name of the anchor.

$function

  • optional
  • string or array

Any data/parameters you need to send to plugin functions. Can be a single string value or an array of values. It is recommended that arrays be associative, for ease of use on the receiving end.

Examples

<?php 
	call_anchor( "my_anchor", array( "country" => "Denmark", "city" => "Copenhagen" ) ); 
	hook( "my_anchor", "my_func" ); 
 
	function my_func( $data ) 
	{ 
		// extract() can be used 
		extract( $data ); 
		echo "$city, $country"; 
 
		// or you can do it cumbersomely 
		$city= $data['city']; 
		$country= $data['country']; 
		echo "$city, $country"; 
	} 
?>

Related