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

wp-graphql / wp-graphql / 15710056976

17 Jun 2025 02:27PM UTC coverage: 84.17% (-0.1%) from 84.287%
15710056976

push

github

actions-user
release: merge develop into master for v2.3.3

15925 of 18920 relevant lines covered (84.17%)

258.66 hits per line

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

92.31
/src/Model/Plugin.php
1
<?php
2

3
namespace WPGraphQL\Model;
4

5
use GraphQLRelay\Relay;
6

7
/**
8
 * Class Plugin - Models the Plugin object
9
 *
10
 * @property ?string $author
11
 * @property ?string $authorUri
12
 * @property ?string $description
13
 * @property ?string $id
14
 * @property ?string $name
15
 * @property ?string $path
16
 * @property ?string $pluginUri
17
 * @property ?string $version
18
 *
19
 * @package WPGraphQL\Model
20
 *
21
 * @extends \WPGraphQL\Model\Model<array<string,mixed>>
22
 */
23
class Plugin extends Model {
24
        /**
25
         * Plugin constructor.
26
         *
27
         * @param array<string,mixed> $plugin The incoming Plugin data to be modeled.
28
         */
29
        public function __construct( $plugin ) {
7✔
30
                $this->data = $plugin;
7✔
31
                parent::__construct();
7✔
32
        }
33

34
        /**
35
         * {@inheritDoc}
36
         */
37
        protected function is_private() {
7✔
38
                if ( is_multisite() ) {
7✔
39
                                // update_, install_, and delete_ are handled above with is_super_admin().
40
                                $menu_perms = get_site_option( 'menu_items', [] );
7✔
41
                        if ( empty( $menu_perms['plugins'] ) && ! current_user_can( 'manage_network_plugins' ) ) {
7✔
42
                                return true;
×
43
                        }
44
                } elseif ( ! current_user_can( 'activate_plugins' ) ) {
×
45
                        return true;
×
46
                }
47

48
                return false;
7✔
49
        }
50

51
        /**
52
         * {@inheritDoc}
53
         */
54
        protected function init() {
7✔
55
                if ( empty( $this->fields ) ) {
7✔
56
                        $this->fields = [
7✔
57
                                'author'      => function () {
7✔
58
                                        return ! empty( $this->data['Author'] ) ? $this->data['Author'] : null;
1✔
59
                                },
7✔
60
                                'authorUri'   => function () {
7✔
61
                                        return ! empty( $this->data['AuthorURI'] ) ? $this->data['AuthorURI'] : null;
1✔
62
                                },
7✔
63
                                'description' => function () {
7✔
64
                                        return ! empty( $this->data['Description'] ) ? $this->data['Description'] : null;
1✔
65
                                },
7✔
66
                                'id'          => function () {
7✔
67
                                        return ! empty( $this->path ) ? Relay::toGlobalId( 'plugin', $this->path ) : null;
7✔
68
                                },
7✔
69
                                'name'        => function () {
7✔
70
                                        return ! empty( $this->data['Name'] ) ? $this->data['Name'] : null;
5✔
71
                                },
7✔
72
                                'path'        => function () {
7✔
73
                                        return ! empty( $this->data['Path'] ) ? $this->data['Path'] : null;
7✔
74
                                },
7✔
75
                                'pluginUri'   => function () {
7✔
76
                                        return ! empty( $this->data['PluginURI'] ) ? $this->data['PluginURI'] : null;
1✔
77
                                },
7✔
78
                                'version'     => function () {
7✔
79
                                        return ! empty( $this->data['Version'] ) ? $this->data['Version'] : null;
1✔
80
                                },
7✔
81
                        ];
7✔
82
                }
83
        }
84
}
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

© 2025 Coveralls, Inc