/var/www/html_de/wp-content/plugins/query-monitor/classes/Hook.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php declare(strict_types 1);
/**
 * Hook processor.
 *
 * @package query-monitor
 */

class QM_Hook {

    
/**
     * @param string $name
     * @param string $type
     * @param array<string, WP_Hook> $wp_filter
     * @param bool $hide_qm
     * @param bool $hide_core
     * @return array<int, array<string, mixed>>
     * @phpstan-param 'action'|'filter' $type
     * @phpstan-return array{
     *   name: string,
     *   type: 'action'|'filter',
     *   actions: list<array{
     *     priority: int,
     *     callback: array<string, mixed>,
     *   }>,
     *   parts: list<string>,
     *   components: array<string, string>,
     * }
     */
    
public static function process$namestring $type, array $wp_filter$hide_qm false$hide_core false ) {

        
$actions = array();
        
$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 $cb ) {

                    
$callback QM_Util::populate_callback$cb );

                    if ( isset( 
$callback['component'] ) ) {
                        if (
                            ( 
$hide_qm && 'query-monitor' === $callback['component']->context )
                            || ( 
$hide_core && 'core' === $callback['component']->context )
                        ) {
                            continue;
                        }

                        
$components$callback['component']->name ] = $callback['component']->name;
                    }

                    
$actions[] = array(
                        
'priority' => $priority,
                        
'callback' => $callback,
                    );

                }
            }
        }

        
$parts array_valuesarray_filter( (array) preg_split'#[_/.-]#'$name ) ) );

        return array(
            
'name' => $name,
            
'type' => $type,
            
'actions' => $actions,
            
'parts' => $parts,
            
'components' => $components,
        );

    }

}