Action type callbacks

<?php //Core Functions

/* Insert Html */
function insert($source_id){
global $inserts;
if($inserts[$source_id]){
foreach($inserts[$source_id] as $callback) call_user_func($callback);
}
}

/* Insert Callback */
function insert_callback($source_id,$callback){
global $inserts;
$inserts[$source_id][] = $callback;
}

?>

<!-- HTML in Header -->
<ul id="aux-nav">
<li>Hello</li>
<li>Aloha</li>
<?php insert('aux-nav') ?>
</ul>

<?php //Callback function in a module or plugin

function add_links(){?>
<li>Hola</li>
<?php
}
insert_callback('aux-nav','add_links');

?>

0 Comments

You must be logged in to post a comment.