• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wp-graphql / wp-graphql / 13316763745

13 Feb 2025 08:45PM UTC coverage: 82.712% (-0.3%) from 83.023%
13316763745

push

github

web-flow
Merge pull request #3307 from wp-graphql/release/v2.0.0

release: v2.0.0

195 of 270 new or added lines in 20 files covered. (72.22%)

180 existing lines in 42 files now uncovered.

13836 of 16728 relevant lines covered (82.71%)

299.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/Data/Loader/PluginLoader.php
1
<?php
2

3
namespace WPGraphQL\Data\Loader;
4

5
use WPGraphQL\Model\Plugin;
6

7
/**
8
 * Class PluginLoader
9
 *
10
 * @package WPGraphQL\Data\Loader
11
 */
12
class PluginLoader extends AbstractDataLoader {
13

14
        /**
15
         * {@inheritDoc}
16
         *
17
         * @param array<string,mixed> $entry The plugin data
18
         *
19
         * @return \WPGraphQL\Model\Plugin
20
         * @throws \Exception
21
         */
22
        protected function get_model( $entry, $key ) {
7✔
23
                return new Plugin( $entry );
7✔
24
        }
25

26
        /**
27
         * {@inheritDoc}
28
         *
29
         * @param string[] $keys Array of plugin names to load
30
         *
31
         * @return array<string,array<string,mixed>|null>
32
         * @throws \Exception
33
         */
34
        public function loadKeys( array $keys ) {
8✔
35
                if ( empty( $keys ) ) {
8✔
36
                        return $keys;
×
37
                }
38

39
                if ( ! function_exists( 'get_plugins' ) ) {
8✔
40
                        // @phpstan-ignore requireOnce.fileNotFound
NEW
41
                        require_once ABSPATH . 'wp-admin/includes/plugin.php';
×
42
                }
43

44
                // This is missing must use and drop in plugins, so we need to fetch and merge them separately.
45
                $site_plugins   = apply_filters( 'all_plugins', get_plugins() );
8✔
46
                $mu_plugins     = apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ? get_mu_plugins() : [];
8✔
47
                $dropin_plugins = apply_filters( 'show_advanced_plugins', true, 'dropins' ) ? get_dropins() : [];
8✔
48

49
                $plugins = array_merge( $site_plugins, $mu_plugins, $dropin_plugins );
8✔
50

51
                $loaded = [];
8✔
52
                if ( ! empty( $plugins ) ) {
8✔
53
                        foreach ( $keys as $key ) {
8✔
54
                                if ( isset( $plugins[ $key ] ) ) {
8✔
55
                                        $plugin         = $plugins[ $key ];
7✔
56
                                        $plugin['Path'] = $key;
7✔
57
                                        $loaded[ $key ] = $plugin;
7✔
58
                                } else {
59
                                        $loaded[ $key ] = null;
1✔
60
                                }
61
                        }
62
                }
63

64
                return $loaded;
8✔
65
        }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc