[wp-hackers] function_exists - user woes

Garett Harnish garett at harnish.ca
Fri Jul 30 21:29:36 UTC 2004


Stephen O'Connor wrote:

> What about a new template-tag function for plugins? To call 
> xyz_photos(), the user would add this line to their template:
>
> <?php wp_tag('xyz_photos'); ?>
>
> The wp_tag would take care of function-exists checks as well as 
> anything else that comes up. If an error occurs such as the function 
> being non-existent, it could create a log entry to be viewed in a 
> wp-admin log.
>
> Also if the function needs to be given parameters, you could use the 
> URI-style as a second parameter.
>
> <?php wp_tag('xyz_photos', 'foo=bar&x=3'); ?>
>
> Just a little thought I had.
>

That sounds like a very easy to implement and functional solution.  How 
about something like this:

function wp_call_plugin_function ($function, $params)
{
   if (function_exists($function))
   {
          call_user_func($function, $params);
   }
}

and called like so:

<?php wp_call_plugin_function('xyz_phots', array('foo' => 'bar', 'x' => 
'3')); ?>

Using a parameter array would definitely make it a lot easier as well.

---
Garett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : /pipermail/hackers_wordpress.org/attachments/20040730/f032724d/signature.bin


More information about the hackers mailing list