Conditions | 7 |
Paths | 3 |
Total Lines | 49 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function extendMenu(WP_Admin_Bar $adminBar): void |
||
30 | { |
||
31 | $isUserAllowed = current_user_can('manage_options'); |
||
32 | $isBackend = is_admin(); |
||
33 | |||
34 | /** |
||
35 | * Control whether to show the data layer UI. |
||
36 | * |
||
37 | * @param bool $isEnabled |
||
38 | */ |
||
39 | $isEnabled = apply_filters('helick_gtm_enable_data_layer_ui', true); |
||
40 | |||
41 | if (!$isUserAllowed || $isBackend || !$isEnabled) { |
||
42 | return; |
||
43 | } |
||
44 | |||
45 | $adminBar->add_menu([ |
||
46 | 'id' => 'helick-gtm', |
||
47 | 'title' => sprintf( |
||
48 | '<span class="ab-icon dashicons-filter"></span> <span class="ab-label">%s</span>', |
||
49 | __('Data Layer', DOMAIN) |
||
50 | ), |
||
51 | ]); |
||
52 | |||
53 | $dataLayer = data_layer(); |
||
54 | |||
55 | // Flatten data layer |
||
56 | $flatten = static function (array $data, string $prefix = '') use (&$flatten) { |
||
57 | $flattened = []; |
||
58 | |||
59 | foreach ($data as $key => $value) { |
||
60 | if (is_array($value)) { |
||
61 | $flattened = array_merge($flattened, $flatten($value, $prefix . $key . '.')); |
||
62 | } else { |
||
63 | $flattened[$prefix . $key] = trim(json_encode($value), '"'); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | return $flattened; |
||
68 | }; |
||
69 | |||
70 | foreach ($flatten($dataLayer) as $key => $value) { |
||
71 | $adminBar->add_node([ |
||
72 | 'id' => sanitize_key('helick-gtm-' . $key), |
||
73 | 'parent' => 'helick-gtm', |
||
74 | 'title' => sprintf( |
||
75 | '<span style="font-weight: bold">%s:</span> %s', |
||
76 | $key, |
||
77 | wp_unslash($value) |
||
78 | ), |
||
83 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths