Completed
Push — develop ( b5d97d...fc257b )
by David
02:25
created
src/public/class-wordlift-term-jsonld-adapter.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -16,219 +16,219 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Term_JsonLd_Adapter {
18 18
 
19
-	/**
20
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
21
-	 *
22
-	 * @since 3.20.0
23
-	 * @access private
24
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
25
-	 */
26
-	private $entity_uri_service;
27
-
28
-	/**
29
-	 * The {@link Wordlift_Jsonld_Service} instance.
30
-	 *
31
-	 * @since 3.20.0
32
-	 * @access private
33
-	 * @var \Wordlift_Jsonld_Service $jsonld_service The {@link Wordlift_Jsonld_Service} instance.
34
-	 */
35
-	private $jsonld_service;
36
-
37
-	private static $instance;
38
-
39
-	/**
40
-	 * Wordlift_Term_JsonLd_Adapter constructor.
41
-	 *
42
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
-	 * @param \Wordlift_Jsonld_Service $jsonld_service The {@link Wordlift_Jsonld_Service} instance.
44
-	 *
45
-	 * @since 3.20.0
46
-	 *
47
-	 */
48
-	public function __construct( $entity_uri_service, $jsonld_service ) {
49
-
50
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
51
-
52
-		$this->entity_uri_service = $entity_uri_service;
53
-		$this->jsonld_service     = $jsonld_service;
54
-
55
-		self::$instance = $this;
56
-	}
57
-
58
-	public static function get_instance() {
59
-
60
-		return self::$instance;
61
-	}
62
-
63
-	/**
64
-	 * Adds carousel json ld data to term page if the conditions match
65
-	 *
66
-	 * @return array|boolean
67
-	 */
68
-	public function get_carousel_jsonld( $id = null ) {
69
-		$posts       = $this->get_posts( $id );
70
-		$post_jsonld = array();
71
-		if ( ! is_array( $posts ) || count( $posts ) < 2 ) {
72
-			// Bail out if no posts are present.
73
-			return false;
74
-		}
75
-
76
-		if ( ! is_null( $id ) ) {
77
-			$term                       = get_term( $id );
78
-			$post_jsonld['description'] = strip_tags( strip_shortcodes( $term->description ) );
79
-			$thumbnail_id               = get_term_meta( $id, 'thumbnail_id', true );
80
-			if ( ! empty( $thumbnail_id ) ) {
81
-				$post_jsonld['image'] = wp_get_attachment_url( $thumbnail_id );
82
-			}
83
-		}
84
-
85
-		// More than 2 items are present, so construct the post_jsonld data
86
-		$post_jsonld['@context']        = 'https://schema.org';
87
-		$post_jsonld['@type']           = 'ItemList';
88
-		$post_jsonld['url']             = $this->get_term_url( $id );
89
-		$post_jsonld['itemListElement'] = array();
90
-		$position                       = 1;
91
-
92
-		foreach ( $posts as $post_id ) {
93
-			$maybe_url = get_post_meta( $post_id, 'wl_schema_url', true );
94
-			$result    = array(
95
-				'@type'    => 'ListItem',
96
-				'position' => $position,
97
-				/**
98
-				 * We can't use `item` here unless we change the URL for the item to point to the current page.
99
-				 *
100
-				 * See https://developers.google.com/search/docs/data-types/carousel
101
-				 */
102
-				'url'      => empty( $maybe_url ) ? get_permalink( $post_id ) : $maybe_url,
103
-			);
104
-			array_push( $post_jsonld['itemListElement'], $result );
105
-			$position += 1;
106
-		}
107
-
108
-		return $post_jsonld;
109
-	}
110
-
111
-	private function get_posts( $id ) {
112
-		global $wp_query;
113
-
114
-		if ( ! is_null( $wp_query->posts ) ) {
115
-			return array_map( function ( $post ) {
116
-				return $post->ID;
117
-			}, $wp_query->posts );
118
-		}
119
-
120
-		if ( is_null( $id ) ) {
121
-			return null;
122
-		}
123
-
124
-		$term = get_term( $id );
125
-
126
-		return get_objects_in_term( $id, $term->taxonomy );
127
-	}
128
-
129
-	/**
130
-	 * Hook to `wp_head` to print the JSON-LD.
131
-	 *
132
-	 * @since 3.20.0
133
-	 */
134
-	public function wp_head() {
135
-		$query_object = get_queried_object();
136
-
137
-		// Check if it is a term page.
138
-		if ( ! $query_object instanceof WP_Term ) {
139
-			return;
140
-		}
141
-
142
-		$term_id = $query_object->term_id;
143
-
144
-		$jsonld = $this->get( $term_id );
145
-
146
-		// Bail out if the JSON-LD is empty.
147
-		if ( empty( $jsonld ) || empty( $jsonld['jsonld'] ) ) {
148
-			return;
149
-		}
150
-
151
-		$jsonld_string = wp_json_encode( $jsonld['jsonld'] );
152
-
153
-		echo "<script type=\"application/ld+json\" id=\"wl-jsonld-term\">$jsonld_string</script>";
154
-
155
-	}
156
-
157
-	public function get( $id ) {
158
-
159
-		/**
160
-		 * Support for carousel rich snippet, get jsonld data present
161
-		 * for all the posts shown in the term page, and add the jsonld data
162
-		 * to list
163
-		 *
164
-		 * see here: https://developers.google.com/search/docs/data-types/carousel
165
-		 *
166
-		 * @since 3.26.0
167
-		 */
168
-		$carousel_data = $this->get_carousel_jsonld( $id );
169
-		$jsonld_array  = array();
170
-		if ( $carousel_data ) {
171
-			$jsonld_array[] = $carousel_data;
172
-		}
173
-		$entities_jsonld_array = $this->get_entity_jsonld( $id );
174
-
175
-		$result = array(
176
-			'jsonld'     => array_merge( $jsonld_array, $entities_jsonld_array ),
177
-			'references' => array()
178
-		);
179
-
180
-		/**
181
-		 * @since 3.26.3
182
-		 * Filter: wl_term_jsonld_array
183
-		 * @var $id int Term id
184
-		 * @var $jsonld_array array An array containing jsonld for term and entities.
185
-		 */
186
-		$arr = apply_filters( 'wl_term_jsonld_array', $result, $id );
187
-
188
-		return $arr['jsonld'];
189
-	}
190
-
191
-	private function get_term_url( $id ) {
192
-
193
-		if ( is_null( $id ) ) {
194
-			return $_SERVER['REQUEST_URI'];
195
-		}
196
-
197
-		$maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
198
-		if ( ! empty( $maybe_url ) ) {
199
-			return $maybe_url;
200
-		}
201
-
202
-		return get_term_link( $id );
203
-	}
204
-
205
-	/**
206
-	 * Return jsonld for entities bound to terms.
207
-	 *
208
-	 * @param $id
209
-	 *
210
-	 * @return array
211
-	 */
212
-	private function get_entity_jsonld( $id ) {
213
-		// The `_wl_entity_id` are URIs.
214
-		$entity_ids         = get_term_meta( $id, '_wl_entity_id' );
215
-		$entity_uri_service = $this->entity_uri_service;
216
-
217
-		$local_entity_ids = array_filter( $entity_ids, function ( $uri ) use ( $entity_uri_service ) {
218
-			return $entity_uri_service->is_internal( $uri );
219
-		} );
220
-
221
-		// Bail out if there are no entities.
222
-		if ( empty( $local_entity_ids ) ) {
223
-			return array();
224
-		}
225
-
226
-		$post   = $this->entity_uri_service->get_entity( array_shift( $local_entity_ids ) );
227
-		$jsonld = $this->jsonld_service->get_jsonld( false, $post->ID );
228
-		// Reset the `url` to the term page.
229
-		$jsonld[0]['url'] = get_term_link( $id );
230
-
231
-		return $jsonld;
232
-	}
19
+    /**
20
+     * The {@link Wordlift_Entity_Uri_Service} instance.
21
+     *
22
+     * @since 3.20.0
23
+     * @access private
24
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
25
+     */
26
+    private $entity_uri_service;
27
+
28
+    /**
29
+     * The {@link Wordlift_Jsonld_Service} instance.
30
+     *
31
+     * @since 3.20.0
32
+     * @access private
33
+     * @var \Wordlift_Jsonld_Service $jsonld_service The {@link Wordlift_Jsonld_Service} instance.
34
+     */
35
+    private $jsonld_service;
36
+
37
+    private static $instance;
38
+
39
+    /**
40
+     * Wordlift_Term_JsonLd_Adapter constructor.
41
+     *
42
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
+     * @param \Wordlift_Jsonld_Service $jsonld_service The {@link Wordlift_Jsonld_Service} instance.
44
+     *
45
+     * @since 3.20.0
46
+     *
47
+     */
48
+    public function __construct( $entity_uri_service, $jsonld_service ) {
49
+
50
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
51
+
52
+        $this->entity_uri_service = $entity_uri_service;
53
+        $this->jsonld_service     = $jsonld_service;
54
+
55
+        self::$instance = $this;
56
+    }
57
+
58
+    public static function get_instance() {
59
+
60
+        return self::$instance;
61
+    }
62
+
63
+    /**
64
+     * Adds carousel json ld data to term page if the conditions match
65
+     *
66
+     * @return array|boolean
67
+     */
68
+    public function get_carousel_jsonld( $id = null ) {
69
+        $posts       = $this->get_posts( $id );
70
+        $post_jsonld = array();
71
+        if ( ! is_array( $posts ) || count( $posts ) < 2 ) {
72
+            // Bail out if no posts are present.
73
+            return false;
74
+        }
75
+
76
+        if ( ! is_null( $id ) ) {
77
+            $term                       = get_term( $id );
78
+            $post_jsonld['description'] = strip_tags( strip_shortcodes( $term->description ) );
79
+            $thumbnail_id               = get_term_meta( $id, 'thumbnail_id', true );
80
+            if ( ! empty( $thumbnail_id ) ) {
81
+                $post_jsonld['image'] = wp_get_attachment_url( $thumbnail_id );
82
+            }
83
+        }
84
+
85
+        // More than 2 items are present, so construct the post_jsonld data
86
+        $post_jsonld['@context']        = 'https://schema.org';
87
+        $post_jsonld['@type']           = 'ItemList';
88
+        $post_jsonld['url']             = $this->get_term_url( $id );
89
+        $post_jsonld['itemListElement'] = array();
90
+        $position                       = 1;
91
+
92
+        foreach ( $posts as $post_id ) {
93
+            $maybe_url = get_post_meta( $post_id, 'wl_schema_url', true );
94
+            $result    = array(
95
+                '@type'    => 'ListItem',
96
+                'position' => $position,
97
+                /**
98
+                 * We can't use `item` here unless we change the URL for the item to point to the current page.
99
+                 *
100
+                 * See https://developers.google.com/search/docs/data-types/carousel
101
+                 */
102
+                'url'      => empty( $maybe_url ) ? get_permalink( $post_id ) : $maybe_url,
103
+            );
104
+            array_push( $post_jsonld['itemListElement'], $result );
105
+            $position += 1;
106
+        }
107
+
108
+        return $post_jsonld;
109
+    }
110
+
111
+    private function get_posts( $id ) {
112
+        global $wp_query;
113
+
114
+        if ( ! is_null( $wp_query->posts ) ) {
115
+            return array_map( function ( $post ) {
116
+                return $post->ID;
117
+            }, $wp_query->posts );
118
+        }
119
+
120
+        if ( is_null( $id ) ) {
121
+            return null;
122
+        }
123
+
124
+        $term = get_term( $id );
125
+
126
+        return get_objects_in_term( $id, $term->taxonomy );
127
+    }
128
+
129
+    /**
130
+     * Hook to `wp_head` to print the JSON-LD.
131
+     *
132
+     * @since 3.20.0
133
+     */
134
+    public function wp_head() {
135
+        $query_object = get_queried_object();
136
+
137
+        // Check if it is a term page.
138
+        if ( ! $query_object instanceof WP_Term ) {
139
+            return;
140
+        }
141
+
142
+        $term_id = $query_object->term_id;
143
+
144
+        $jsonld = $this->get( $term_id );
145
+
146
+        // Bail out if the JSON-LD is empty.
147
+        if ( empty( $jsonld ) || empty( $jsonld['jsonld'] ) ) {
148
+            return;
149
+        }
150
+
151
+        $jsonld_string = wp_json_encode( $jsonld['jsonld'] );
152
+
153
+        echo "<script type=\"application/ld+json\" id=\"wl-jsonld-term\">$jsonld_string</script>";
154
+
155
+    }
156
+
157
+    public function get( $id ) {
158
+
159
+        /**
160
+         * Support for carousel rich snippet, get jsonld data present
161
+         * for all the posts shown in the term page, and add the jsonld data
162
+         * to list
163
+         *
164
+         * see here: https://developers.google.com/search/docs/data-types/carousel
165
+         *
166
+         * @since 3.26.0
167
+         */
168
+        $carousel_data = $this->get_carousel_jsonld( $id );
169
+        $jsonld_array  = array();
170
+        if ( $carousel_data ) {
171
+            $jsonld_array[] = $carousel_data;
172
+        }
173
+        $entities_jsonld_array = $this->get_entity_jsonld( $id );
174
+
175
+        $result = array(
176
+            'jsonld'     => array_merge( $jsonld_array, $entities_jsonld_array ),
177
+            'references' => array()
178
+        );
179
+
180
+        /**
181
+         * @since 3.26.3
182
+         * Filter: wl_term_jsonld_array
183
+         * @var $id int Term id
184
+         * @var $jsonld_array array An array containing jsonld for term and entities.
185
+         */
186
+        $arr = apply_filters( 'wl_term_jsonld_array', $result, $id );
187
+
188
+        return $arr['jsonld'];
189
+    }
190
+
191
+    private function get_term_url( $id ) {
192
+
193
+        if ( is_null( $id ) ) {
194
+            return $_SERVER['REQUEST_URI'];
195
+        }
196
+
197
+        $maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
198
+        if ( ! empty( $maybe_url ) ) {
199
+            return $maybe_url;
200
+        }
201
+
202
+        return get_term_link( $id );
203
+    }
204
+
205
+    /**
206
+     * Return jsonld for entities bound to terms.
207
+     *
208
+     * @param $id
209
+     *
210
+     * @return array
211
+     */
212
+    private function get_entity_jsonld( $id ) {
213
+        // The `_wl_entity_id` are URIs.
214
+        $entity_ids         = get_term_meta( $id, '_wl_entity_id' );
215
+        $entity_uri_service = $this->entity_uri_service;
216
+
217
+        $local_entity_ids = array_filter( $entity_ids, function ( $uri ) use ( $entity_uri_service ) {
218
+            return $entity_uri_service->is_internal( $uri );
219
+        } );
220
+
221
+        // Bail out if there are no entities.
222
+        if ( empty( $local_entity_ids ) ) {
223
+            return array();
224
+        }
225
+
226
+        $post   = $this->entity_uri_service->get_entity( array_shift( $local_entity_ids ) );
227
+        $jsonld = $this->jsonld_service->get_jsonld( false, $post->ID );
228
+        // Reset the `url` to the term page.
229
+        $jsonld[0]['url'] = get_term_link( $id );
230
+
231
+        return $jsonld;
232
+    }
233 233
 
234 234
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @since 3.20.0
46 46
 	 *
47 47
 	 */
48
-	public function __construct( $entity_uri_service, $jsonld_service ) {
48
+	public function __construct($entity_uri_service, $jsonld_service) {
49 49
 
50
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
50
+		add_action('wp_head', array($this, 'wp_head'));
51 51
 
52 52
 		$this->entity_uri_service = $entity_uri_service;
53 53
 		$this->jsonld_service     = $jsonld_service;
@@ -65,32 +65,32 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return array|boolean
67 67
 	 */
68
-	public function get_carousel_jsonld( $id = null ) {
69
-		$posts       = $this->get_posts( $id );
68
+	public function get_carousel_jsonld($id = null) {
69
+		$posts       = $this->get_posts($id);
70 70
 		$post_jsonld = array();
71
-		if ( ! is_array( $posts ) || count( $posts ) < 2 ) {
71
+		if ( ! is_array($posts) || count($posts) < 2) {
72 72
 			// Bail out if no posts are present.
73 73
 			return false;
74 74
 		}
75 75
 
76
-		if ( ! is_null( $id ) ) {
77
-			$term                       = get_term( $id );
78
-			$post_jsonld['description'] = strip_tags( strip_shortcodes( $term->description ) );
79
-			$thumbnail_id               = get_term_meta( $id, 'thumbnail_id', true );
80
-			if ( ! empty( $thumbnail_id ) ) {
81
-				$post_jsonld['image'] = wp_get_attachment_url( $thumbnail_id );
76
+		if ( ! is_null($id)) {
77
+			$term                       = get_term($id);
78
+			$post_jsonld['description'] = strip_tags(strip_shortcodes($term->description));
79
+			$thumbnail_id               = get_term_meta($id, 'thumbnail_id', true);
80
+			if ( ! empty($thumbnail_id)) {
81
+				$post_jsonld['image'] = wp_get_attachment_url($thumbnail_id);
82 82
 			}
83 83
 		}
84 84
 
85 85
 		// More than 2 items are present, so construct the post_jsonld data
86 86
 		$post_jsonld['@context']        = 'https://schema.org';
87 87
 		$post_jsonld['@type']           = 'ItemList';
88
-		$post_jsonld['url']             = $this->get_term_url( $id );
88
+		$post_jsonld['url']             = $this->get_term_url($id);
89 89
 		$post_jsonld['itemListElement'] = array();
90 90
 		$position                       = 1;
91 91
 
92
-		foreach ( $posts as $post_id ) {
93
-			$maybe_url = get_post_meta( $post_id, 'wl_schema_url', true );
92
+		foreach ($posts as $post_id) {
93
+			$maybe_url = get_post_meta($post_id, 'wl_schema_url', true);
94 94
 			$result    = array(
95 95
 				'@type'    => 'ListItem',
96 96
 				'position' => $position,
@@ -99,31 +99,31 @@  discard block
 block discarded – undo
99 99
 				 *
100 100
 				 * See https://developers.google.com/search/docs/data-types/carousel
101 101
 				 */
102
-				'url'      => empty( $maybe_url ) ? get_permalink( $post_id ) : $maybe_url,
102
+				'url'      => empty($maybe_url) ? get_permalink($post_id) : $maybe_url,
103 103
 			);
104
-			array_push( $post_jsonld['itemListElement'], $result );
104
+			array_push($post_jsonld['itemListElement'], $result);
105 105
 			$position += 1;
106 106
 		}
107 107
 
108 108
 		return $post_jsonld;
109 109
 	}
110 110
 
111
-	private function get_posts( $id ) {
111
+	private function get_posts($id) {
112 112
 		global $wp_query;
113 113
 
114
-		if ( ! is_null( $wp_query->posts ) ) {
115
-			return array_map( function ( $post ) {
114
+		if ( ! is_null($wp_query->posts)) {
115
+			return array_map(function($post) {
116 116
 				return $post->ID;
117
-			}, $wp_query->posts );
117
+			}, $wp_query->posts);
118 118
 		}
119 119
 
120
-		if ( is_null( $id ) ) {
120
+		if (is_null($id)) {
121 121
 			return null;
122 122
 		}
123 123
 
124
-		$term = get_term( $id );
124
+		$term = get_term($id);
125 125
 
126
-		return get_objects_in_term( $id, $term->taxonomy );
126
+		return get_objects_in_term($id, $term->taxonomy);
127 127
 	}
128 128
 
129 129
 	/**
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 		$query_object = get_queried_object();
136 136
 
137 137
 		// Check if it is a term page.
138
-		if ( ! $query_object instanceof WP_Term ) {
138
+		if ( ! $query_object instanceof WP_Term) {
139 139
 			return;
140 140
 		}
141 141
 
142 142
 		$term_id = $query_object->term_id;
143 143
 
144
-		$jsonld = $this->get( $term_id );
144
+		$jsonld = $this->get($term_id);
145 145
 
146 146
 		// Bail out if the JSON-LD is empty.
147
-		if ( empty( $jsonld ) || empty( $jsonld['jsonld'] ) ) {
147
+		if (empty($jsonld) || empty($jsonld['jsonld'])) {
148 148
 			return;
149 149
 		}
150 150
 
151
-		$jsonld_string = wp_json_encode( $jsonld['jsonld'] );
151
+		$jsonld_string = wp_json_encode($jsonld['jsonld']);
152 152
 
153 153
 		echo "<script type=\"application/ld+json\" id=\"wl-jsonld-term\">$jsonld_string</script>";
154 154
 
155 155
 	}
156 156
 
157
-	public function get( $id ) {
157
+	public function get($id) {
158 158
 
159 159
 		/**
160 160
 		 * Support for carousel rich snippet, get jsonld data present
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 		 *
166 166
 		 * @since 3.26.0
167 167
 		 */
168
-		$carousel_data = $this->get_carousel_jsonld( $id );
168
+		$carousel_data = $this->get_carousel_jsonld($id);
169 169
 		$jsonld_array  = array();
170
-		if ( $carousel_data ) {
170
+		if ($carousel_data) {
171 171
 			$jsonld_array[] = $carousel_data;
172 172
 		}
173
-		$entities_jsonld_array = $this->get_entity_jsonld( $id );
173
+		$entities_jsonld_array = $this->get_entity_jsonld($id);
174 174
 
175 175
 		$result = array(
176
-			'jsonld'     => array_merge( $jsonld_array, $entities_jsonld_array ),
176
+			'jsonld'     => array_merge($jsonld_array, $entities_jsonld_array),
177 177
 			'references' => array()
178 178
 		);
179 179
 
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
 		 * @var $id int Term id
184 184
 		 * @var $jsonld_array array An array containing jsonld for term and entities.
185 185
 		 */
186
-		$arr = apply_filters( 'wl_term_jsonld_array', $result, $id );
186
+		$arr = apply_filters('wl_term_jsonld_array', $result, $id);
187 187
 
188 188
 		return $arr['jsonld'];
189 189
 	}
190 190
 
191
-	private function get_term_url( $id ) {
191
+	private function get_term_url($id) {
192 192
 
193
-		if ( is_null( $id ) ) {
193
+		if (is_null($id)) {
194 194
 			return $_SERVER['REQUEST_URI'];
195 195
 		}
196 196
 
197
-		$maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
198
-		if ( ! empty( $maybe_url ) ) {
197
+		$maybe_url = get_term_meta($id, Wordlift_Url_Property_Service::META_KEY, true);
198
+		if ( ! empty($maybe_url)) {
199 199
 			return $maybe_url;
200 200
 		}
201 201
 
202
-		return get_term_link( $id );
202
+		return get_term_link($id);
203 203
 	}
204 204
 
205 205
 	/**
@@ -209,24 +209,24 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @return array
211 211
 	 */
212
-	private function get_entity_jsonld( $id ) {
212
+	private function get_entity_jsonld($id) {
213 213
 		// The `_wl_entity_id` are URIs.
214
-		$entity_ids         = get_term_meta( $id, '_wl_entity_id' );
214
+		$entity_ids         = get_term_meta($id, '_wl_entity_id');
215 215
 		$entity_uri_service = $this->entity_uri_service;
216 216
 
217
-		$local_entity_ids = array_filter( $entity_ids, function ( $uri ) use ( $entity_uri_service ) {
218
-			return $entity_uri_service->is_internal( $uri );
217
+		$local_entity_ids = array_filter($entity_ids, function($uri) use ($entity_uri_service) {
218
+			return $entity_uri_service->is_internal($uri);
219 219
 		} );
220 220
 
221 221
 		// Bail out if there are no entities.
222
-		if ( empty( $local_entity_ids ) ) {
222
+		if (empty($local_entity_ids)) {
223 223
 			return array();
224 224
 		}
225 225
 
226
-		$post   = $this->entity_uri_service->get_entity( array_shift( $local_entity_ids ) );
227
-		$jsonld = $this->jsonld_service->get_jsonld( false, $post->ID );
226
+		$post   = $this->entity_uri_service->get_entity(array_shift($local_entity_ids));
227
+		$jsonld = $this->jsonld_service->get_jsonld(false, $post->ID);
228 228
 		// Reset the `url` to the term page.
229
-		$jsonld[0]['url'] = get_term_link( $id );
229
+		$jsonld[0]['url'] = get_term_link($id);
230 230
 
231 231
 		return $jsonld;
232 232
 	}
Please login to merge, or discard this patch.