[wp-trac] [WordPress Trac] #18405: Check if pluggable function was already defined by other plugin

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 15 01:27:32 UTC 2011


#18405: Check if pluggable function was already defined by other plugin
-------------------------+-----------------------------
 Reporter:  F J Kaiser   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Plugins      |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Currently there's no way to check if a pluggable function is already
 defined by some other plugin in a normal single site WP installation.

 With the current design "pluggables" are only ''really pluggable'' for
 your own installations. Hosting a plugin the redefines a pluggable
 function in the official repository will only lead to lots of problems and
 unsatisfied/angry users that run into non-debugable errors.

 The problem is that there's no standartized way to check if the function
 was already defined. Imho there ''should'' be a hook to allow for save
 checking if the function was defined and then throw something like a
 {{
 _doing_it_wrong();
 }}
 -message, visible only for developers.

 Sample plugin (for a multisite installation) to test and discuss this.


 {{{
 /*
 Plugin Name:    ___Pluggable Test
 Plugin URI:             ___
 Description:    ___
 Author:                 ___
 Author URI:     ___
 Version:                0.1
 License:                ___
 */
 function wp_rand( $min = 0, $max = 0 )
 {
         return 'I am just a test';
 }

 function trac_test_the_hook()
 {
         $title = 'pluggable test output';

         $msg  = 'The current filter is "'.current_filter().'" and works.';
         if ( function_exists( 'wp_rand' ) )
                 $msg .= '<br />The function <em>"wp_rand()"</em> was
 already defined elsewhere.';

         wp_die( $msg, $title );
 }
 // Change the 'muplugins_loaded' to test other hooks
 add_action( 'muplugins_loaded', 'trac_test_the_hook', 999 );
 }}}


 [1] {wp-hackers thread|https://groups.google.com/forum/?hl=de#!topic/wp-
 hackers/-EJbmkdMLjg]

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18405>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list