wordpress - Does this simple PHP function wrapper look sensible for its purpose? -
With the new to PHP, and riding on this "function wrapper", I thought I got some feedback I would like to get around five comments if possible, and a slight reaction.
Before asking now, I have several reasons to wrap other (WordPress) functions, primary trouble free upgrade. It was also important to be able to set a custom name for each function definition, so $ wrap array
.
But I retreat, is it acceptable and relatively bulletproof?
function core_oo ($ function) {$ args = array_slice (func_get_args (), 1); $ Wrap = array ('comment' = & gt; 'the_comment', 'comments' = & gt; 'has_comments', 'post' = & gt; 'the_post', 'posts' = & gt; 'has_posts'); Return call_user_func_array ($ wrap [$ function], $ args); }
... and the function will be called in this way ...
core_oo ('post', 'arg1', 'arg2') ;
Many thanks!
Edit:
Sugeestion below the chaos, is this the correct way to declare $ wrap in a steady form?
Fixed $ wrap = array (...
Comments
Post a Comment