PluginProbe
Parse.ly / 3.8.4
Parse.ly v3.8.4
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
← All changes | src/Endpoints/class-graphql-metadata.php +15 -20 3.2.03.8.4 View file →
@@ -1,11 +1,13 @@
1 1 <?php
2 2 /**
3 - * GraphQL support class.
4 - * Note: this class will only work if the WPGraphQL plugin is installed.
3 + * Endpoints: GraphQL metadata endpoint class
5 4 *
5 + * Adds support for GraphQL.
6 + * Note: This class will only work if the WPGraphQL plugin is installed.
7 + *
6 8 * @package Parsely
7 - * @since 3.2.0
9 + * @since 3.2.0
8 10 */
9 11
10 12 declare(strict_types=1);
11 13
@@ -13,9 +15,9 @@
13 15
14 16 use WP_Post;
15 17
16 18 /**
17 - * Add Parse.ly metadata fields to the WP GraphQL server.
19 + * Adds Parse.ly metadata fields to the WP GraphQL server.
18 20 *
19 21 * @since 3.2.0
20 22 */
21 23 class GraphQL_Metadata extends Metadata_Endpoint {
@@ -22,33 +24,30 @@
22 24 private const GRAPHQL_VERSION = '1.0.0';
23 25 private const GRAPHQL_CONTAINER_TYPE = 'ParselyMetaContainer';
24 26
25 27 /**
26 - * Register fields in WPGraphQL plugin.
28 + * Registers fields in WPGraphQL plugin.
27 29 *
28 30 * @since 3.2.0
29 - *
30 - * @return void
31 31 */
32 32 public function run(): void {
33 33 /**
34 - * Filter whether GraphQL support is enabled or not.
34 + * Filters whether GraphQL support is enabled or not.
35 35 *
36 36 * @since 3.2.0
37 37 *
38 38 * @param bool $enabled True if enabled, false if not.
39 39 */
40 - if ( apply_filters( 'wp_parsely_enable_graphql_support', true ) && $this->parsely->api_key_is_set() ) {
40 + if ( apply_filters( 'wp_parsely_enable_graphql_support', true ) && $this->parsely->site_id_is_set() ) {
41 41 add_action( 'graphql_register_types', array( $this, 'register_meta' ) );
42 42 }
43 43 }
44 44
45 45 /**
46 - * Register the meta field on the appropriate resource types in the REST API.
46 + * Registers the meta field on the appropriate resource types in the REST
47 + * API.
47 48 *
48 49 * @since 3.2.0
49 - *
50 - * @return void
51 50 */
52 51 public function register_meta(): void {
53 52 $this->register_object_types();
54 53 $this->register_fields();
@@ -54,13 +53,12 @@
54 53 $this->register_fields();
55 54 }
56 55
57 56 /**
58 - * Register the new custom types for Parse.ly Metadata into the GraphQL instance.
57 + * Registers the new custom types for Parse.ly Metadata into the GraphQL
58 + * instance.
59 59 *
60 60 * @since 3.2.0
61 - *
62 - * @return void
63 61 */
64 62 private function register_object_types(): void {
65 63 $container_type = array(
66 64 'description' => __( 'Parse.ly Metadata root type.', 'wp-parsely' ),
@@ -119,13 +117,11 @@
119 117 register_graphql_object_type( self::GRAPHQL_CONTAINER_TYPE, $container_type );
120 118 }
121 119
122 120 /**
123 - * Register the custom metadata fields, so they can be queried in GraphQL.
121 + * Registers the custom metadata fields, so they can be queried in GraphQL.
124 122 *
125 123 * @since 3.2.0
126 - *
127 - * @return void
128 124 */
129 125 private function register_fields(): void {
130 126 $resolve = function ( \WPGraphQL\Model\Post $graphql_post ) {
131 127 $post_id = $graphql_post->ID;
@@ -134,10 +130,9 @@
134 130 if ( false === $post ) {
135 131 return null;
136 132 }
137 133
138 - $options = $this->parsely->get_options();
139 - $object_types = array_unique( array_merge( $options['track_post_types'], $options['track_page_types'] ) );
134 + $object_types = $this->parsely->get_all_track_types();
140 135 $current_object_type = get_post_type( $post );
141 136
142 137 return array(
143 138 'version' => self::GRAPHQL_VERSION,