Some anchors let plugins modify the value of a variable that is to be used later in the code. Let's take a look at a simple example, where we allow plugins to format a title that will be displayed on the page:
<?php // First define the anchor define_anchor( "formatTitle" ); // $title could be a value grabbed from the database, for example $title= "Line's Music Blog"; $title= call_anchor( "formatTitle", $title ); ?>
Now, if one were to create a plugin that modified this title in some way, it would look like this:
<?php hook( "formatTitle", "myFormatting" ); function myFormatting( $title ) { return '<h1>' . $title . '</h1>'; } ?>
Whatever value is returned by the plugin function will replace the original value of the variable.
<?php echo $title; // prints <h1>Line's Music Blog</h1> ?>
Note too, that the value sent by call_anchor() can be of any type. If you need to send multiple values, supplying an array offers an easy workaround:
<?php hook( "anchorName", "modifyAnchor" ); // Call anchor with multiple values call_anchor( "anchorName", array( 'val1', 'val2', 'val3' ) ); // Example plugin function function modifyAnchor( $vals ) { $val1= $vals[0]; $val2= $vals[1]; $val3= $vals[2]; } ?>