[wp-hackers] Overriding Cor Functions (Was: IIS Problem)

Dan Thrue rummanddan at gmail.com
Sun Apr 3 22:30:55 GMT 2005

I think this a very good approach to have more control from
plugins/modules whatever the should be called over core functions...

Similar your approach i have always wandered why there wasnt an
"activate" and "deactivate" hook for plugins... I always do it
manually :)

On Apr 3, 2005 8:40 PM, Ryan Boren <ryan at boren.nu> wrote:
> On Sun, 2005-04-03 at 03:32 -0500, Scott Reilly wrote:
> > Since you mentioned it, WP doesn't currently support plugins
> > overriding core functions even if those core functions are wrapped in
> > function_exists(), correct?  I know the intent is for plugins to be
> > able to do that, but how?  Plugins aren't sourced until after all core
> > files have been sourced, which is too late.  Or am I missing
> > something?
> Here's an approach I've been mulling over.
> Add a preload_file action to be called from plugin files.  This allows
> plugin files to specify a file to be loaded before the core WP
> includes.  In the plugin:
> function test_plugin_preload_file() {
>   preload_file(dirname(__FILE__). '/test_preload.php');
> }
> add_action('preload_file', 'test_plugin_preload_file');
> preload_file() runs plugin_basename() on the supplied file and adds it
> to a 'preload' array in the options DB.
> In plugins.php, we call the preload_file action whenever a plugin is
> activated.  This is a bit tricky.  First we'll have to unset all
> existing preload actions and then include the just activated plugin.
> Then we call the preload_file action.  This is the only situation where
> the preload_file action is called.
> In wp-settings.php, we loop through the list of preloaded files after
> wp-db.php is included but before functions.php is included.  Since
> functions.php is not yet included, we have to be careful not to call
> get_option() to retrieve the preload array etc.  Only wpdb may be used.
> Thoughts?
> Ryan
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list