WordPress.org

Ready to get started?Download WordPress

Forums

Core Control
cron module incorrectly displays hooks if they are a class method (1 post)

  1. Vladimir Kolesnikov
    Member
    Posted 3 years ago #

    Core Control's cron module incorrectly displays "Hook to run" if it is a class method. In this case it displays something like this:

    hook_name
    Hooked functions: Array()

    The problem is that the code assumes that if a method is hooked, cron structure will have 'class' and 'function' fields which is not correct: the structire will have only 'function' field which will be either array(object, method) for methods and string(function) for regular functions (see http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback for details).

    Patch:

    --- core-control/modules/core_control_cron.php.orig    2010-09-10 09:20:08.000000000 -0400
    +++ core-control/modules/core_control_cron.php    2010-09-10 09:31:38.000000000 -0400
    @@ -138,8 +138,23 @@
                             if ( isset($GLOBALS['wp_filter'][$hook]) ) {
                                 $functions = array();
                                 foreach ( (array)$GLOBALS['wp_filter'][$hook] as $priority => $function ) {
    -                                foreach ( $function as $hook_details )
    -                                    $functions[] = (isset($hook_details['class']) ? $hook_details['class'] . '::' : '') . $hook_details['function'] . '()';
    +                                foreach ( $function as $hook_details ) {
    +                                    $hook = '';
    +                                    $f    = $hook_details['function'];
    +                                    if (is_array($f)) {
    +                                        if (is_object($f[0])) {
    +                                            $hook = get_class($f[0]);
    +                                        }
    +                                        else {
    +                                            $hook = $f[0];
    +                                        }
    +                                        $hook .= '::' . $f[1];
    +                                    }
    +                                    else {
    +                                        $hook = $f;
    +                                    }
    +                                    $functions[] = $hook . '()';
    +                                }
                                 }
                                 echo '<br/><strong>Hooked functions:</strong> ' . implode(', ', $functions);
                             }

    http://wordpress.org/extend/plugins/core-control/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by Vladimir Kolesnikov
  • This topic is not a support question
  • WordPress version: 3.0.1