populate_callback() public static method

public static populate_callback ( array $callback )
$callback array
Beispiel #1
0
 protected function process_action($name, array $wp_filter)
 {
     $actions = $components = array();
     if (isset($wp_filter[$name])) {
         # http://core.trac.wordpress.org/ticket/17817
         $action = $wp_filter[$name];
         foreach ($action as $priority => $callbacks) {
             foreach ($callbacks as $callback) {
                 $callback = QM_Util::populate_callback($callback);
                 if (isset($callback['component'])) {
                     if ($this->hide_qm and 'query-monitor' === $callback['component']->context) {
                         continue;
                     }
                     $components[$callback['component']->name] = $callback['component']->name;
                 }
                 $actions[] = array('priority' => $priority, 'callback' => $callback);
             }
         }
     }
     $parts = array_filter(preg_split('#[_/-]#', $name));
     return array('name' => $name, 'actions' => $actions, 'parts' => $parts, 'components' => $components);
 }
Beispiel #2
0
 public function process()
 {
     global $wp_actions, $wp_filter;
     if (is_admin() and $admin = QueryMonitor::get_collector('admin')) {
         $this->data['screen'] = $admin->data['base'];
     } else {
         $this->data['screen'] = '';
     }
     $hooks = $parts = $components = array();
     foreach ($wp_actions as $name => $count) {
         $actions = array();
         # @TODO better variable name:
         $c = array();
         if (isset($wp_filter[$name])) {
             # http://core.trac.wordpress.org/ticket/17817
             $action = $wp_filter[$name];
             foreach ($action as $priority => $callbacks) {
                 foreach ($callbacks as $callback) {
                     $callback = QM_Util::populate_callback($callback);
                     if (isset($callback['component'])) {
                         $c[$callback['component']->name] = $callback['component']->name;
                     }
                     $actions[] = array('priority' => $priority, 'callback' => $callback);
                 }
             }
         }
         # @TODO better variable name:
         $p = array_filter(preg_split('/[_\\/-]/', $name));
         $parts = array_merge($parts, $p);
         $components = array_merge($components, $c);
         $hooks[$name] = array('name' => $name, 'actions' => $actions, 'parts' => $p, 'components' => $c);
     }
     $this->data['hooks'] = $hooks;
     $this->data['parts'] = array_unique(array_filter($parts));
     $this->data['components'] = array_unique(array_filter($components));
 }
 public function test_populate_callback_invalid_static_class_string()
 {
     $function = 'Invalid_Class::goodbye';
     $callback = self::get_callback($function);
     $actual = QM_Util::populate_callback($callback);
     $this->assertWPError($actual['error']);
 }