Completed
Push — master ( 9ba92a...6f958b )
by David
02:43
created
src/includes/class-wordlift-relation-service.php 1 patch
Indentation   +328 added lines, -328 removed lines patch added patch discarded remove patch
@@ -18,334 +18,334 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Relation_Service {
20 20
 
21
-	/**
22
-	 * The singleton instance.
23
-	 *
24
-	 * @since  3.15.0
25
-	 * @access private
26
-	 * @var \Wordlift_Relation_Service $instance The singleton instance.
27
-	 */
28
-	private static $instance;
29
-
30
-	/**
31
-	 * The relation table name in MySQL, set during instantiation.
32
-	 *
33
-	 * @since  3.15.0
34
-	 * @access private
35
-	 * @var string $relation_table The relation table name.
36
-	 */
37
-	private $relation_table;
38
-
39
-	/**
40
-	 * Create a {@link Wordlift_Relation_Service} instance.
41
-	 *
42
-	 * @since 3.15.0
43
-	 */
44
-	public function __construct() {
45
-		global $wpdb;
46
-
47
-		// The relations table.
48
-		$this->relation_table = "{$wpdb->prefix}wl_relation_instances";
49
-
50
-		self::$instance = $this;
51
-
52
-	}
53
-
54
-	/**
55
-	 * Get the singleton instance.
56
-	 *
57
-	 * @since  3.15.0
58
-	 * @access public
59
-	 * @return \Wordlift_Relation_Service The {@link Wordlift_Relation_Service}
60
-	 *                                    singleton instance.
61
-	 */
62
-	public static function get_instance() {
63
-
64
-		return self::$instance;
65
-	}
66
-
67
-	/**
68
-	 * Get the articles referencing the specified entity {@link WP_Post}.
69
-	 *
70
-	 * @since 3.15.0
71
-	 *
72
-	 * @param int|array   $object_id The entity {@link WP_Post}'s id.
73
-	 * @param string      $fields    The fields to return, 'ids' to only return ids or
74
-	 *                               '*' to return all fields, by default '*'.
75
-	 * @param null|string $predicate The predicate (who|what|...), by default all.
76
-	 * @param null|string $status    The status, by default all.
77
-	 * @param array       $excludes  An array of ids to exclude from the results.
78
-	 * @param null|int    $limit     The maximum number of results, by default
79
-	 *                               no limit.
80
-	 * @param null|array  $include   The {@link WP_Post}s' ids to include.
81
-	 *
82
-	 * @return array|object|null Database query results
83
-	 */
84
-	public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null ) {
85
-		global $wpdb;
86
-
87
-		// The output fields.
88
-		$actual_fields = self::fields( $fields );
89
-
90
-		$objects = $this->article_id_to_entity_id( $object_id );
91
-
92
-		$sql =
93
-			"
21
+    /**
22
+     * The singleton instance.
23
+     *
24
+     * @since  3.15.0
25
+     * @access private
26
+     * @var \Wordlift_Relation_Service $instance The singleton instance.
27
+     */
28
+    private static $instance;
29
+
30
+    /**
31
+     * The relation table name in MySQL, set during instantiation.
32
+     *
33
+     * @since  3.15.0
34
+     * @access private
35
+     * @var string $relation_table The relation table name.
36
+     */
37
+    private $relation_table;
38
+
39
+    /**
40
+     * Create a {@link Wordlift_Relation_Service} instance.
41
+     *
42
+     * @since 3.15.0
43
+     */
44
+    public function __construct() {
45
+        global $wpdb;
46
+
47
+        // The relations table.
48
+        $this->relation_table = "{$wpdb->prefix}wl_relation_instances";
49
+
50
+        self::$instance = $this;
51
+
52
+    }
53
+
54
+    /**
55
+     * Get the singleton instance.
56
+     *
57
+     * @since  3.15.0
58
+     * @access public
59
+     * @return \Wordlift_Relation_Service The {@link Wordlift_Relation_Service}
60
+     *                                    singleton instance.
61
+     */
62
+    public static function get_instance() {
63
+
64
+        return self::$instance;
65
+    }
66
+
67
+    /**
68
+     * Get the articles referencing the specified entity {@link WP_Post}.
69
+     *
70
+     * @since 3.15.0
71
+     *
72
+     * @param int|array   $object_id The entity {@link WP_Post}'s id.
73
+     * @param string      $fields    The fields to return, 'ids' to only return ids or
74
+     *                               '*' to return all fields, by default '*'.
75
+     * @param null|string $predicate The predicate (who|what|...), by default all.
76
+     * @param null|string $status    The status, by default all.
77
+     * @param array       $excludes  An array of ids to exclude from the results.
78
+     * @param null|int    $limit     The maximum number of results, by default
79
+     *                               no limit.
80
+     * @param null|array  $include   The {@link WP_Post}s' ids to include.
81
+     *
82
+     * @return array|object|null Database query results
83
+     */
84
+    public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null ) {
85
+        global $wpdb;
86
+
87
+        // The output fields.
88
+        $actual_fields = self::fields( $fields );
89
+
90
+        $objects = $this->article_id_to_entity_id( $object_id );
91
+
92
+        $sql =
93
+            "
94 94
 			SELECT DISTINCT p.$actual_fields
95 95
 			FROM {$this->relation_table} r
96 96
 			INNER JOIN $wpdb->posts p
97 97
 				ON p.id = r.subject_id
98 98
 			"
99
-			// Add the status clause.
100
-			. self::and_status( $status )
101
-			. self::inner_join_is_article()
102
-			. self::where_object_id( $objects )
103
-			// Since `object_id` can be an article ID we need to exclude it from
104
-			// the results.
105
-			. self::and_article_not_in( array_merge( $excludes, (array) $object_id ) )
106
-			. self::and_article_in( $include )
107
-			. " AND p.post_type IN ( 'post', 'page', 'entity' ) "
108
-			. self::and_predicate( $predicate )
109
-			. self::limit( $limit );
110
-
111
-		return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
112
-	}
113
-
114
-	/**
115
-	 * Add the limit clause if specified.
116
-	 *
117
-	 * @since 3.15.0
118
-	 *
119
-	 * @param null|int $limit The maximum number of results.
120
-	 *
121
-	 * @return string The limit clause (empty if no limit has been specified).
122
-	 */
123
-	private static function limit( $limit = null ) {
124
-
125
-		if ( null === $limit ) {
126
-			return '';
127
-		}
128
-
129
-		return "LIMIT $limit";
130
-	}
131
-
132
-	/**
133
-	 * Map the provided ids into entities (i.e. return the id if it's an entity
134
-	 * or get the entities if it's a post).
135
-	 *
136
-	 * @since 3.15.0
137
-	 *
138
-	 * @param int|array $object_id An array of posts/entities' ids.
139
-	 *
140
-	 * @return array An array of entities' ids.
141
-	 */
142
-	private function article_id_to_entity_id( $object_id ) {
143
-
144
-		$entity_service = Wordlift_Entity_Service::get_instance();
145
-
146
-		$relation_service = $this;
147
-
148
-		return array_reduce( (array) $object_id, function ( $carry, $item ) use ( $entity_service, $relation_service ) {
149
-			if ( $entity_service->is_entity( $item ) ) {
150
-				return array_merge( $carry, (array) $item );
151
-			}
152
-
153
-			return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) );
154
-		}, array() );
155
-
156
-	}
157
-
158
-	/**
159
-	 * Add the WHERE clause.
160
-	 *
161
-	 * @since 3.15.0
162
-	 *
163
-	 * @param int|array $object_id An array of {@link WP_Post}s' ids.
164
-	 *
165
-	 * @return string The WHERE clause.
166
-	 */
167
-	private static function where_object_id( $object_id ) {
168
-
169
-		return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )';
170
-	}
171
-
172
-	/**
173
-	 * Add the exclude clause.
174
-	 *
175
-	 * @since 3.15.0
176
-	 *
177
-	 * @param int|array $exclude An array of {@link WP_Post}s' ids to exclude.
178
-	 *
179
-	 * @return string The exclude clause.
180
-	 */
181
-	private static function and_article_not_in( $exclude ) {
182
-
183
-		return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )';
184
-	}
185
-
186
-	/**
187
-	 * Add the include clause.
188
-	 *
189
-	 * @since 3.15.0
190
-	 *
191
-	 * @param null|int|array $include An array of {@link WP_Post}s' ids.
192
-	 *
193
-	 * @return string An empty string if $include is null otherwise the include
194
-	 *                clause.
195
-	 */
196
-	private static function and_article_in( $include = null ) {
197
-
198
-		if ( null === $include ) {
199
-			return '';
200
-		}
201
-
202
-		return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )';
203
-	}
204
-
205
-	/**
206
-	 * Get the entities' {@link WP_Post}s' ids referencing the specified {@link WP_Post}.
207
-	 *
208
-	 * @since 3.15.0
209
-	 *
210
-	 * @param int         $object_id The object {@link WP_Post}'s id.
211
-	 * @param string      $fields    The fields to return, 'ids' to only return ids or
212
-	 *                               '*' to return all fields, by default '*'.
213
-	 * @param null|string $status    The status, by default all.
214
-	 *
215
-	 * @return array|object|null Database query results
216
-	 */
217
-	public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) {
218
-		global $wpdb;
219
-
220
-		// The output fields.
221
-		$actual_fields = self::fields( $fields );
222
-
223
-		$sql = $wpdb->prepare(
224
-			"
99
+            // Add the status clause.
100
+            . self::and_status( $status )
101
+            . self::inner_join_is_article()
102
+            . self::where_object_id( $objects )
103
+            // Since `object_id` can be an article ID we need to exclude it from
104
+            // the results.
105
+            . self::and_article_not_in( array_merge( $excludes, (array) $object_id ) )
106
+            . self::and_article_in( $include )
107
+            . " AND p.post_type IN ( 'post', 'page', 'entity' ) "
108
+            . self::and_predicate( $predicate )
109
+            . self::limit( $limit );
110
+
111
+        return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
112
+    }
113
+
114
+    /**
115
+     * Add the limit clause if specified.
116
+     *
117
+     * @since 3.15.0
118
+     *
119
+     * @param null|int $limit The maximum number of results.
120
+     *
121
+     * @return string The limit clause (empty if no limit has been specified).
122
+     */
123
+    private static function limit( $limit = null ) {
124
+
125
+        if ( null === $limit ) {
126
+            return '';
127
+        }
128
+
129
+        return "LIMIT $limit";
130
+    }
131
+
132
+    /**
133
+     * Map the provided ids into entities (i.e. return the id if it's an entity
134
+     * or get the entities if it's a post).
135
+     *
136
+     * @since 3.15.0
137
+     *
138
+     * @param int|array $object_id An array of posts/entities' ids.
139
+     *
140
+     * @return array An array of entities' ids.
141
+     */
142
+    private function article_id_to_entity_id( $object_id ) {
143
+
144
+        $entity_service = Wordlift_Entity_Service::get_instance();
145
+
146
+        $relation_service = $this;
147
+
148
+        return array_reduce( (array) $object_id, function ( $carry, $item ) use ( $entity_service, $relation_service ) {
149
+            if ( $entity_service->is_entity( $item ) ) {
150
+                return array_merge( $carry, (array) $item );
151
+            }
152
+
153
+            return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) );
154
+        }, array() );
155
+
156
+    }
157
+
158
+    /**
159
+     * Add the WHERE clause.
160
+     *
161
+     * @since 3.15.0
162
+     *
163
+     * @param int|array $object_id An array of {@link WP_Post}s' ids.
164
+     *
165
+     * @return string The WHERE clause.
166
+     */
167
+    private static function where_object_id( $object_id ) {
168
+
169
+        return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )';
170
+    }
171
+
172
+    /**
173
+     * Add the exclude clause.
174
+     *
175
+     * @since 3.15.0
176
+     *
177
+     * @param int|array $exclude An array of {@link WP_Post}s' ids to exclude.
178
+     *
179
+     * @return string The exclude clause.
180
+     */
181
+    private static function and_article_not_in( $exclude ) {
182
+
183
+        return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )';
184
+    }
185
+
186
+    /**
187
+     * Add the include clause.
188
+     *
189
+     * @since 3.15.0
190
+     *
191
+     * @param null|int|array $include An array of {@link WP_Post}s' ids.
192
+     *
193
+     * @return string An empty string if $include is null otherwise the include
194
+     *                clause.
195
+     */
196
+    private static function and_article_in( $include = null ) {
197
+
198
+        if ( null === $include ) {
199
+            return '';
200
+        }
201
+
202
+        return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )';
203
+    }
204
+
205
+    /**
206
+     * Get the entities' {@link WP_Post}s' ids referencing the specified {@link WP_Post}.
207
+     *
208
+     * @since 3.15.0
209
+     *
210
+     * @param int         $object_id The object {@link WP_Post}'s id.
211
+     * @param string      $fields    The fields to return, 'ids' to only return ids or
212
+     *                               '*' to return all fields, by default '*'.
213
+     * @param null|string $status    The status, by default all.
214
+     *
215
+     * @return array|object|null Database query results
216
+     */
217
+    public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) {
218
+        global $wpdb;
219
+
220
+        // The output fields.
221
+        $actual_fields = self::fields( $fields );
222
+
223
+        $sql = $wpdb->prepare(
224
+            "
225 225
 			SELECT p.$actual_fields
226 226
 			FROM {$this->relation_table} r
227 227
 			INNER JOIN $wpdb->posts p
228 228
 				ON p.id = r.subject_id
229 229
 			"
230
-			// Add the status clause.
231
-			. self::and_status( $status )
232
-			. self::inner_join_is_not_article() .
233
-			"
230
+            // Add the status clause.
231
+            . self::and_status( $status )
232
+            . self::inner_join_is_not_article() .
233
+            "
234 234
 			WHERE r.object_id = %d
235 235
 				AND p.post_type IN ( 'post', 'page', 'entity' )
236 236
 			"
237
-			,
238
-			$object_id
239
-		);
240
-
241
-		return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
242
-	}
243
-
244
-	/**
245
-	 * Get the entities referenced by the specified {@link WP_Post}.
246
-	 *
247
-	 * @since 3.15.0
248
-	 *
249
-	 * @param int         $subject_id The {@link WP_Post}'s id.
250
-	 * @param string      $fields     The fields to return, 'ids' to only return ids or
251
-	 *                                '*' to return all fields, by default '*'.
252
-	 * @param null|string $predicate  The predicate (who|what|...), by default all.
253
-	 * @param null|string $status     The status, by default all.
254
-	 *
255
-	 * @return array|object|null Database query results
256
-	 */
257
-	public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) {
258
-		global $wpdb;
259
-
260
-		// The output fields.
261
-		$actual_fields = self::fields( $fields );
262
-
263
-		$sql = $wpdb->prepare(
264
-			"
237
+            ,
238
+            $object_id
239
+        );
240
+
241
+        return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
242
+    }
243
+
244
+    /**
245
+     * Get the entities referenced by the specified {@link WP_Post}.
246
+     *
247
+     * @since 3.15.0
248
+     *
249
+     * @param int         $subject_id The {@link WP_Post}'s id.
250
+     * @param string      $fields     The fields to return, 'ids' to only return ids or
251
+     *                                '*' to return all fields, by default '*'.
252
+     * @param null|string $predicate  The predicate (who|what|...), by default all.
253
+     * @param null|string $status     The status, by default all.
254
+     *
255
+     * @return array|object|null Database query results
256
+     */
257
+    public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) {
258
+        global $wpdb;
259
+
260
+        // The output fields.
261
+        $actual_fields = self::fields( $fields );
262
+
263
+        $sql = $wpdb->prepare(
264
+            "
265 265
 			SELECT p.$actual_fields
266 266
 			FROM {$this->relation_table} r
267 267
 			INNER JOIN $wpdb->posts p
268 268
 				ON p.id = r.object_id
269 269
 			"
270
-			// Add the status clause.
271
-			. self::and_status( $status )
272
-			. self::inner_join_is_not_article()
273
-			. "
270
+            // Add the status clause.
271
+            . self::and_status( $status )
272
+            . self::inner_join_is_not_article()
273
+            . "
274 274
 			WHERE r.subject_id = %d
275 275
 				AND p.post_type IN ( 'post', 'page', 'entity' )
276 276
 			"
277
-			. self::and_predicate( $predicate )
278
-			,
279
-			$subject_id
280
-		);
281
-
282
-		return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
283
-	}
284
-
285
-	/**
286
-	 * Add the `post_status` clause.
287
-	 *
288
-	 * @since 3.15.0
289
-	 *
290
-	 * @param null|string|array $status The status values.
291
-	 *
292
-	 * @return string An empty string if $status is null, otherwise the status clause.
293
-	 */
294
-	private static function and_status( $status = null ) {
295
-
296
-		if ( null === $status ) {
297
-			return '';
298
-		}
299
-
300
-		return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')";
301
-	}
302
-
303
-	/**
304
-	 * Add the `predicate` clause.
305
-	 *
306
-	 * @since 3.15.0
307
-	 *
308
-	 * @param null|string|array $predicate An array of predicates.
309
-	 *
310
-	 * @return string An empty string if $predicate is null otherwise the predicate
311
-	 *                clause.
312
-	 */
313
-	private static function and_predicate( $predicate = null ) {
314
-
315
-		if ( null === $predicate ) {
316
-			return '';
317
-		}
318
-
319
-		return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')";
320
-	}
321
-
322
-	/**
323
-	 * The select fields.
324
-	 *
325
-	 * @since 3.15.0
326
-	 *
327
-	 * @param string $fields Either 'ids' or '*', by default '*'.
328
-	 *
329
-	 * @return string The `id` field if `ids` otherwise `*`.
330
-	 */
331
-	private static function fields( $fields = '*' ) {
332
-
333
-		// The output fields.
334
-		return 'ids' === $fields ? 'id' : '*';
335
-	}
336
-
337
-	/**
338
-	 * The inner join clause for articles.
339
-	 *
340
-	 * @since 3.15.0
341
-	 *
342
-	 * @return string The articles inner join clause.
343
-	 */
344
-	private static function inner_join_is_article() {
345
-		global $wpdb;
346
-
347
-		return $wpdb->prepare(
348
-			"
277
+            . self::and_predicate( $predicate )
278
+            ,
279
+            $subject_id
280
+        );
281
+
282
+        return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql );
283
+    }
284
+
285
+    /**
286
+     * Add the `post_status` clause.
287
+     *
288
+     * @since 3.15.0
289
+     *
290
+     * @param null|string|array $status The status values.
291
+     *
292
+     * @return string An empty string if $status is null, otherwise the status clause.
293
+     */
294
+    private static function and_status( $status = null ) {
295
+
296
+        if ( null === $status ) {
297
+            return '';
298
+        }
299
+
300
+        return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')";
301
+    }
302
+
303
+    /**
304
+     * Add the `predicate` clause.
305
+     *
306
+     * @since 3.15.0
307
+     *
308
+     * @param null|string|array $predicate An array of predicates.
309
+     *
310
+     * @return string An empty string if $predicate is null otherwise the predicate
311
+     *                clause.
312
+     */
313
+    private static function and_predicate( $predicate = null ) {
314
+
315
+        if ( null === $predicate ) {
316
+            return '';
317
+        }
318
+
319
+        return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')";
320
+    }
321
+
322
+    /**
323
+     * The select fields.
324
+     *
325
+     * @since 3.15.0
326
+     *
327
+     * @param string $fields Either 'ids' or '*', by default '*'.
328
+     *
329
+     * @return string The `id` field if `ids` otherwise `*`.
330
+     */
331
+    private static function fields( $fields = '*' ) {
332
+
333
+        // The output fields.
334
+        return 'ids' === $fields ? 'id' : '*';
335
+    }
336
+
337
+    /**
338
+     * The inner join clause for articles.
339
+     *
340
+     * @since 3.15.0
341
+     *
342
+     * @return string The articles inner join clause.
343
+     */
344
+    private static function inner_join_is_article() {
345
+        global $wpdb;
346
+
347
+        return $wpdb->prepare(
348
+            "
349 349
 			INNER JOIN $wpdb->term_relationships tr
350 350
 			 ON p.id = tr.object_id
351 351
 			INNER JOIN $wpdb->term_taxonomy tt
@@ -355,23 +355,23 @@  discard block
 block discarded – undo
355 355
 			 ON t.term_id = tt.term_id
356 356
 			  AND t.slug = %s
357 357
 			",
358
-			'wl_entity_type',
359
-			'article'
360
-		);
361
-	}
362
-
363
-	/**
364
-	 * The inner join clause for non-articles.
365
-	 *
366
-	 * @since 3.15.0
367
-	 *
368
-	 * @return string The non-articles inner join clause.
369
-	 */
370
-	private static function inner_join_is_not_article() {
371
-		global $wpdb;
372
-
373
-		return $wpdb->prepare(
374
-			"
358
+            'wl_entity_type',
359
+            'article'
360
+        );
361
+    }
362
+
363
+    /**
364
+     * The inner join clause for non-articles.
365
+     *
366
+     * @since 3.15.0
367
+     *
368
+     * @return string The non-articles inner join clause.
369
+     */
370
+    private static function inner_join_is_not_article() {
371
+        global $wpdb;
372
+
373
+        return $wpdb->prepare(
374
+            "
375 375
 			INNER JOIN $wpdb->term_relationships tr
376 376
 			 ON p.id = tr.object_id
377 377
 			INNER JOIN $wpdb->term_taxonomy tt
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 			 ON t.term_id = tt.term_id
382 382
 			  AND NOT t.slug = %s
383 383
 			",
384
-			'wl_entity_type',
385
-			'article'
386
-		);
387
-	}
384
+            'wl_entity_type',
385
+            'article'
386
+        );
387
+    }
388 388
 
389 389
 }
Please login to merge, or discard this patch.
src/admin/wordlift_admin_meta_box_entities.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_register_metaboxes() {
12 12
 
13
-	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
13
+    // Load metabox classes.
14
+    require_once( 'WL_Metabox/class-wl-metabox.php' );
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+    $wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19 19
 if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
20
+    add_action( 'load-post.php', 'wl_register_metaboxes' );
21
+    add_action( 'load-post-new.php', 'wl_register_metaboxes' );
22 22
 }
23 23
 
24 24
 
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function wl_admin_add_entities_meta_box( $post_type ) {
31 31
 
32
-	// Add main meta box for related entities and 4W.
33
-	add_meta_box(
34
-		'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
35
-	);
32
+    // Add main meta box for related entities and 4W.
33
+    add_meta_box(
34
+        'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
35
+    );
36 36
 }
37 37
 
38 38
 add_action( 'add_meta_boxes', 'wl_admin_add_entities_meta_box' );
@@ -44,92 +44,92 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function wl_entities_box_content( $post ) {
46 46
 
47
-	// Angularjs edit-post widget wrapper.
48
-	echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
49
-
50
-	// Angularjs edit-post widget classification boxes configuration.
51
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
52
-
53
-	// Array to store all related entities ids.
54
-	$all_referenced_entities_ids = array();
55
-
56
-	// Add selected entities to classification_boxes.
57
-	foreach ( $classification_boxes as $i => $box ) {
58
-		// Build the proper relation name.
59
-		$relation_name = $box['id'];
60
-
61
-		// Get the entity referenced from the post content.
62
-		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
63
-
64
-		// Enhance current box selected entities.
65
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
66
-
67
-		// Maps the URIs to entity posts.
68
-		$entity_service = Wordlift_Entity_Service::get_instance();
69
-
70
-		// Replace all entity URI's with post ID's if found or null if there is no related post.
71
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
72
-			// Return entity post by the entity URI or null.
73
-			$post = $entity_service->get_entity_post_by_uri( $item );
74
-
75
-			// Check that the post object is not null.
76
-			if ( ! empty( $post ) ) {
77
-				return $post->ID;
78
-			}
79
-		}, $entity_uris );
80
-		// Store the entity ids for all the 4W.
81
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
82
-
83
-	}
84
-	// Json encoding for classification boxes structure.
85
-	$classification_boxes = wp_json_encode( $classification_boxes );
86
-
87
-	// Ensure there are no repetitions of the referenced entities.
88
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
89
-
90
-	// Remove all null, false and empty strings.
91
-	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
92
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
93
-
94
-	// Build the entity storage object.
95
-	$referenced_entities_obj = array();
96
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
97
-		$entity                                   = wl_serialize_entity( $referenced_entity );
98
-		$referenced_entities_obj[ $entity['id'] ] = $entity;
99
-	}
100
-
101
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
102
-		'{}' : wp_json_encode( $referenced_entities_obj );
103
-
104
-	$published_place_id  = get_post_meta(
105
-		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
106
-	);
107
-	$published_place_obj = ( $published_place_id ) ?
108
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
109
-		'undefined';
110
-
111
-	$topic_id  = get_post_meta(
112
-		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
113
-	);
114
-	$topic_obj = ( $topic_id ) ?
115
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
116
-		'undefined';
117
-
118
-	$configuration_service = Wordlift_Configuration_Service::get_instance();
119
-
120
-	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
121
-	$default_path           = WL_DEFAULT_PATH;
122
-	$dataset_uri            = $configuration_service->get_dataset_uri();
123
-	$current_post_uri       = wl_get_entity_uri( $post->ID );
124
-
125
-	// Retrieve the current post author.
126
-	$post_author = get_userdata( $post->post_author )->display_name;
127
-	// Retrive the published date.
128
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
129
-	// Current language.
130
-	$current_language = $configuration_service->get_language_code();
131
-
132
-	echo <<<EOF
47
+    // Angularjs edit-post widget wrapper.
48
+    echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
49
+
50
+    // Angularjs edit-post widget classification boxes configuration.
51
+    $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
52
+
53
+    // Array to store all related entities ids.
54
+    $all_referenced_entities_ids = array();
55
+
56
+    // Add selected entities to classification_boxes.
57
+    foreach ( $classification_boxes as $i => $box ) {
58
+        // Build the proper relation name.
59
+        $relation_name = $box['id'];
60
+
61
+        // Get the entity referenced from the post content.
62
+        $entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
63
+
64
+        // Enhance current box selected entities.
65
+        $classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
66
+
67
+        // Maps the URIs to entity posts.
68
+        $entity_service = Wordlift_Entity_Service::get_instance();
69
+
70
+        // Replace all entity URI's with post ID's if found or null if there is no related post.
71
+        $entity_ids = array_map( function ( $item ) use ( $entity_service ) {
72
+            // Return entity post by the entity URI or null.
73
+            $post = $entity_service->get_entity_post_by_uri( $item );
74
+
75
+            // Check that the post object is not null.
76
+            if ( ! empty( $post ) ) {
77
+                return $post->ID;
78
+            }
79
+        }, $entity_uris );
80
+        // Store the entity ids for all the 4W.
81
+        $all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
82
+
83
+    }
84
+    // Json encoding for classification boxes structure.
85
+    $classification_boxes = wp_json_encode( $classification_boxes );
86
+
87
+    // Ensure there are no repetitions of the referenced entities.
88
+    $all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
89
+
90
+    // Remove all null, false and empty strings.
91
+    // NULL is being returned in some cases, when there is not related post, so we need to remove it.
92
+    $all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
93
+
94
+    // Build the entity storage object.
95
+    $referenced_entities_obj = array();
96
+    foreach ( $all_referenced_entities_ids as $referenced_entity ) {
97
+        $entity                                   = wl_serialize_entity( $referenced_entity );
98
+        $referenced_entities_obj[ $entity['id'] ] = $entity;
99
+    }
100
+
101
+    $referenced_entities_obj = empty( $referenced_entities_obj ) ?
102
+        '{}' : wp_json_encode( $referenced_entities_obj );
103
+
104
+    $published_place_id  = get_post_meta(
105
+        $post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
106
+    );
107
+    $published_place_obj = ( $published_place_id ) ?
108
+        wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
109
+        'undefined';
110
+
111
+    $topic_id  = get_post_meta(
112
+        $post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
113
+    );
114
+    $topic_obj = ( $topic_id ) ?
115
+        wp_json_encode( wl_serialize_entity( $topic_id ) ) :
116
+        'undefined';
117
+
118
+    $configuration_service = Wordlift_Configuration_Service::get_instance();
119
+
120
+    $default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
121
+    $default_path           = WL_DEFAULT_PATH;
122
+    $dataset_uri            = $configuration_service->get_dataset_uri();
123
+    $current_post_uri       = wl_get_entity_uri( $post->ID );
124
+
125
+    // Retrieve the current post author.
126
+    $post_author = get_userdata( $post->post_author )->display_name;
127
+    // Retrive the published date.
128
+    $published_date = get_the_time( 'Y-m-d', $post->ID );
129
+    // Current language.
130
+    $current_language = $configuration_service->get_language_code();
131
+
132
+    echo <<<EOF
133 133
 	<script type="text/javascript">
134 134
 		jQuery( function() {
135 135
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 function wl_register_metaboxes() {
12 12
 
13 13
 	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
14
+	require_once('WL_Metabox/class-wl-metabox.php');
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+	$wl_metabox = new WL_Metabox(); // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19
-if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
19
+if (is_admin()) {
20
+	add_action('load-post.php', 'wl_register_metaboxes');
21
+	add_action('load-post-new.php', 'wl_register_metaboxes');
22 22
 }
23 23
 
24 24
 
@@ -27,105 +27,103 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @param string $post_type The type of the current open post.
29 29
  */
30
-function wl_admin_add_entities_meta_box( $post_type ) {
30
+function wl_admin_add_entities_meta_box($post_type) {
31 31
 
32 32
 	// Add main meta box for related entities and 4W.
33 33
 	add_meta_box(
34
-		'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
34
+		'wordlift_entities_box', __('WordLift', 'wordlift'), 'wl_entities_box_content', $post_type, 'side', 'high'
35 35
 	);
36 36
 }
37 37
 
38
-add_action( 'add_meta_boxes', 'wl_admin_add_entities_meta_box' );
38
+add_action('add_meta_boxes', 'wl_admin_add_entities_meta_box');
39 39
 
40 40
 /**
41 41
  * Displays the meta box contents (called by *add_meta_box* callback).
42 42
  *
43 43
  * @param WP_Post $post The current post.
44 44
  */
45
-function wl_entities_box_content( $post ) {
45
+function wl_entities_box_content($post) {
46 46
 
47 47
 	// Angularjs edit-post widget wrapper.
48 48
 	echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
49 49
 
50 50
 	// Angularjs edit-post widget classification boxes configuration.
51
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
51
+	$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
52 52
 
53 53
 	// Array to store all related entities ids.
54 54
 	$all_referenced_entities_ids = array();
55 55
 
56 56
 	// Add selected entities to classification_boxes.
57
-	foreach ( $classification_boxes as $i => $box ) {
57
+	foreach ($classification_boxes as $i => $box) {
58 58
 		// Build the proper relation name.
59 59
 		$relation_name = $box['id'];
60 60
 
61 61
 		// Get the entity referenced from the post content.
62
-		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
62
+		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris($post->post_content);
63 63
 
64 64
 		// Enhance current box selected entities.
65
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
65
+		$classification_boxes[$i]['selectedEntities'] = $entity_uris;
66 66
 
67 67
 		// Maps the URIs to entity posts.
68 68
 		$entity_service = Wordlift_Entity_Service::get_instance();
69 69
 
70 70
 		// Replace all entity URI's with post ID's if found or null if there is no related post.
71
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
71
+		$entity_ids = array_map(function($item) use ($entity_service) {
72 72
 			// Return entity post by the entity URI or null.
73
-			$post = $entity_service->get_entity_post_by_uri( $item );
73
+			$post = $entity_service->get_entity_post_by_uri($item);
74 74
 
75 75
 			// Check that the post object is not null.
76
-			if ( ! empty( $post ) ) {
76
+			if ( ! empty($post)) {
77 77
 				return $post->ID;
78 78
 			}
79
-		}, $entity_uris );
79
+		}, $entity_uris);
80 80
 		// Store the entity ids for all the 4W.
81
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
81
+		$all_referenced_entities_ids = array_merge($all_referenced_entities_ids, $entity_ids);
82 82
 
83 83
 	}
84 84
 	// Json encoding for classification boxes structure.
85
-	$classification_boxes = wp_json_encode( $classification_boxes );
85
+	$classification_boxes = wp_json_encode($classification_boxes);
86 86
 
87 87
 	// Ensure there are no repetitions of the referenced entities.
88
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
88
+	$all_referenced_entities_ids = array_unique($all_referenced_entities_ids);
89 89
 
90 90
 	// Remove all null, false and empty strings.
91 91
 	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
92
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
92
+	$all_referenced_entities_ids = array_filter($all_referenced_entities_ids);
93 93
 
94 94
 	// Build the entity storage object.
95 95
 	$referenced_entities_obj = array();
96
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
97
-		$entity                                   = wl_serialize_entity( $referenced_entity );
98
-		$referenced_entities_obj[ $entity['id'] ] = $entity;
96
+	foreach ($all_referenced_entities_ids as $referenced_entity) {
97
+		$entity                                   = wl_serialize_entity($referenced_entity);
98
+		$referenced_entities_obj[$entity['id']] = $entity;
99 99
 	}
100 100
 
101
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
102
-		'{}' : wp_json_encode( $referenced_entities_obj );
101
+	$referenced_entities_obj = empty($referenced_entities_obj) ?
102
+		'{}' : wp_json_encode($referenced_entities_obj);
103 103
 
104 104
 	$published_place_id  = get_post_meta(
105 105
 		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
106 106
 	);
107
-	$published_place_obj = ( $published_place_id ) ?
108
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
109
-		'undefined';
107
+	$published_place_obj = ($published_place_id) ?
108
+		wp_json_encode(wl_serialize_entity($published_place_id)) : 'undefined';
110 109
 
111 110
 	$topic_id  = get_post_meta(
112 111
 		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
113 112
 	);
114
-	$topic_obj = ( $topic_id ) ?
115
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
116
-		'undefined';
113
+	$topic_obj = ($topic_id) ?
114
+		wp_json_encode(wl_serialize_entity($topic_id)) : 'undefined';
117 115
 
118 116
 	$configuration_service = Wordlift_Configuration_Service::get_instance();
119 117
 
120 118
 	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
121 119
 	$default_path           = WL_DEFAULT_PATH;
122 120
 	$dataset_uri            = $configuration_service->get_dataset_uri();
123
-	$current_post_uri       = wl_get_entity_uri( $post->ID );
121
+	$current_post_uri       = wl_get_entity_uri($post->ID);
124 122
 
125 123
 	// Retrieve the current post author.
126
-	$post_author = get_userdata( $post->post_author )->display_name;
124
+	$post_author = get_userdata($post->post_author)->display_name;
127 125
 	// Retrive the published date.
128
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
126
+	$published_date = get_the_time('Y-m-d', $post->ID);
129 127
 	// Current language.
130 128
 	$current_language = $configuration_service->get_language_code();
131 129
 
Please login to merge, or discard this patch.
src/public/class-wordlift-public.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -22,107 +22,107 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Public {
24 24
 
25
-	/**
26
-	 * The ID of this plugin.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   private
30
-	 * @var      string $plugin_name The ID of this plugin.
31
-	 */
32
-	private $plugin_name;
33
-
34
-	/**
35
-	 * The version of this plugin.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   private
39
-	 * @var      string $version The current version of this plugin.
40
-	 */
41
-	private $version;
42
-
43
-	/**
44
-	 * Initialize the class and set its properties.
45
-	 *
46
-	 * @since    1.0.0
47
-	 *
48
-	 * @param      string $plugin_name The name of the plugin.
49
-	 * @param      string $version     The version of this plugin.
50
-	 */
51
-	public function __construct( $plugin_name, $version ) {
52
-
53
-		$this->plugin_name = $plugin_name;
54
-		$this->version     = $version;
55
-
56
-	}
57
-
58
-	/**
59
-	 * Register the stylesheets for the public-facing side of the site.
60
-	 *
61
-	 * @since    1.0.0
62
-	 */
63
-	public function enqueue_styles() {
64
-
65
-		/**
66
-		 * This function is provided for demonstration purposes only.
67
-		 *
68
-		 * An instance of this class should be passed to the run() function
69
-		 * defined in Wordlift_Loader as all of the hooks are defined
70
-		 * in that particular class.
71
-		 *
72
-		 * The Wordlift_Loader will then create the relationship
73
-		 * between the defined hooks and the functions defined in this
74
-		 * class.
75
-		 */
76
-
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
-
79
-	}
80
-
81
-	/**
82
-	 * Register the stylesheets for the public-facing side of the site.
83
-	 *
84
-	 * @since    1.0.0
85
-	 */
86
-	public function enqueue_scripts() {
87
-
88
-		/**
89
-		 * This function is provided for demonstration purposes only.
90
-		 *
91
-		 * An instance of this class should be passed to the run() function
92
-		 * defined in Wordlift_Loader as all of the hooks are defined
93
-		 * in that particular class.
94
-		 *
95
-		 * The Wordlift_Loader will then create the relationship
96
-		 * between the defined hooks and the functions defined in this
97
-		 * class.
98
-		 */
99
-
100
-		// Prepare a settings array for client-side functions.
101
-		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
-		);
104
-
105
-		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
107
-			$settings['postId'] = get_the_ID();
108
-		}
109
-
110
-		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
112
-			$settings['isHome'] = true;
113
-		}
114
-
115
-		// Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
116
-		// be loaded.
117
-		//
118
-		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
119
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', true );
120
-
121
-		// Note that we switched the js to be loaded in footer, since it is loading
122
-		// the json-ld representation.
123
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
124
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
125
-
126
-	}
25
+    /**
26
+     * The ID of this plugin.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   private
30
+     * @var      string $plugin_name The ID of this plugin.
31
+     */
32
+    private $plugin_name;
33
+
34
+    /**
35
+     * The version of this plugin.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   private
39
+     * @var      string $version The current version of this plugin.
40
+     */
41
+    private $version;
42
+
43
+    /**
44
+     * Initialize the class and set its properties.
45
+     *
46
+     * @since    1.0.0
47
+     *
48
+     * @param      string $plugin_name The name of the plugin.
49
+     * @param      string $version     The version of this plugin.
50
+     */
51
+    public function __construct( $plugin_name, $version ) {
52
+
53
+        $this->plugin_name = $plugin_name;
54
+        $this->version     = $version;
55
+
56
+    }
57
+
58
+    /**
59
+     * Register the stylesheets for the public-facing side of the site.
60
+     *
61
+     * @since    1.0.0
62
+     */
63
+    public function enqueue_styles() {
64
+
65
+        /**
66
+         * This function is provided for demonstration purposes only.
67
+         *
68
+         * An instance of this class should be passed to the run() function
69
+         * defined in Wordlift_Loader as all of the hooks are defined
70
+         * in that particular class.
71
+         *
72
+         * The Wordlift_Loader will then create the relationship
73
+         * between the defined hooks and the functions defined in this
74
+         * class.
75
+         */
76
+
77
+        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
+
79
+    }
80
+
81
+    /**
82
+     * Register the stylesheets for the public-facing side of the site.
83
+     *
84
+     * @since    1.0.0
85
+     */
86
+    public function enqueue_scripts() {
87
+
88
+        /**
89
+         * This function is provided for demonstration purposes only.
90
+         *
91
+         * An instance of this class should be passed to the run() function
92
+         * defined in Wordlift_Loader as all of the hooks are defined
93
+         * in that particular class.
94
+         *
95
+         * The Wordlift_Loader will then create the relationship
96
+         * between the defined hooks and the functions defined in this
97
+         * class.
98
+         */
99
+
100
+        // Prepare a settings array for client-side functions.
101
+        $settings = array(
102
+            'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
+        );
104
+
105
+        // If we're in a single page, then print out the post id.
106
+        if ( is_singular() ) {
107
+            $settings['postId'] = get_the_ID();
108
+        }
109
+
110
+        // Add flag that we are on home/blog page.
111
+        if ( is_home() || is_front_page() ) {
112
+            $settings['isHome'] = true;
113
+        }
114
+
115
+        // Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
116
+        // be loaded.
117
+        //
118
+        // @see https://github.com/insideout10/wordlift-plugin/issues/642.
119
+        $settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', true );
120
+
121
+        // Note that we switched the js to be loaded in footer, since it is loading
122
+        // the json-ld representation.
123
+        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
124
+        wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
125
+
126
+    }
127 127
 
128 128
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param      string $plugin_name The name of the plugin.
49 49
 	 * @param      string $version     The version of this plugin.
50 50
 	 */
51
-	public function __construct( $plugin_name, $version ) {
51
+	public function __construct($plugin_name, $version) {
52 52
 
53 53
 		$this->plugin_name = $plugin_name;
54 54
 		$this->version     = $version;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * class.
75 75
 		 */
76 76
 
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
77
+		wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-public.css', array(), $this->version, 'all');
78 78
 
79 79
 	}
80 80
 
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Prepare a settings array for client-side functions.
101 101
 		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
102
+			'ajaxUrl' => admin_url('admin-ajax.php'),
103 103
 		);
104 104
 
105 105
 		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
106
+		if (is_singular()) {
107 107
 			$settings['postId'] = get_the_ID();
108 108
 		}
109 109
 
110 110
 		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
111
+		if (is_home() || is_front_page()) {
112 112
 			$settings['isHome'] = true;
113 113
 		}
114 114
 
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 		// be loaded.
117 117
 		//
118 118
 		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
119
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', true );
119
+		$settings['jsonld_enabled'] = apply_filters('wl_jsonld_enabled', true);
120 120
 
121 121
 		// Note that we switched the js to be loaded in footer, since it is loading
122 122
 		// the json-ld representation.
123
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
124
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
123
+		wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wordlift-public.js', array('jquery'), $this->version, true);
124
+		wp_localize_script($this->plugin_name, 'wlSettings', $settings);
125 125
 
126 126
 	}
127 127
 
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-publisher-element.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -19,122 +19,122 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Admin_Publisher_Element extends Wordlift_Admin_Author_Element {
21 21
 
22
-	/**
23
-	 * The {@link Wordlift_Configuration_Service} instance.
24
-	 *
25
-	 * @since  3.11.0
26
-	 * @access private
27
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
28
-	 */
29
-	private $configuration_service;
30
-
31
-	/**
32
-	 * The {@link Wordlift_Publisher_Service} instance.
33
-	 *
34
-	 * @since  3.11.0
35
-	 * @access private
36
-	 * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
37
-	 */
38
-	private $publisher_service;
39
-
40
-	/**
41
-	 * @var Wordlift_Admin_Tabs_Element
42
-	 */
43
-	private $tabs_element;
44
-
45
-	/**
46
-	 * Create a {@link Wordlift_Admin_Publisher_Element} instance.
47
-	 *
48
-	 * @since 3.11.0
49
-	 *
50
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
51
-	 * @param \Wordlift_Publisher_Service     $publisher_service     The {@link Wordlift_Publisher_Service} instance.
52
-	 * @param \Wordlift_Admin_Tabs_Element    $tabs_element          The {@link Wordlift_Admin_Tabs_Element} instance.
53
-	 * @param \Wordlift_Admin_Select2_Element $select_element        The {@link Wordlift_Admin_Select_Element} instance.
54
-	 */
55
-	function __construct( $configuration_service, $publisher_service, $tabs_element, $select_element ) {
56
-		parent::__construct( $publisher_service, $select_element );
57
-
58
-		$this->configuration_service = $configuration_service;
59
-		$this->publisher_service     = $publisher_service;
60
-
61
-		// Child elements.
62
-		$this->tabs_element = $tabs_element;
63
-
64
-	}
65
-
66
-	/**
67
-	 * @inheritdoc
68
-	 */
69
-	public function render( $args ) {
70
-
71
-		// Parse the arguments and merge with default values.
72
-		$params = wp_parse_args( $args, array(
73
-			'id'   => uniqid( 'wl-input-' ),
74
-			'name' => uniqid( 'wl-input-' ),
75
-		) );
76
-
77
-		// Get the number of potential candidates as publishers.
78
-		$count = $this->publisher_service->count();
79
-
80
-		$this->tabs_element->render( array(
81
-			'tabs'   => array(
82
-				array(
83
-					'label'    => __( 'Select an Existing Publisher', 'wordlift' ),
84
-					'callback' => array( $this, 'select' ),
85
-					'args'     => $params,
86
-				),
87
-				array(
88
-					'label'    => __( 'Create a New Publisher', 'wordlift' ),
89
-					'callback' => array( $this, 'create' ),
90
-					'args'     => $params,
91
-				),
92
-			),
93
-			// Set the default tab according to the number of potential publishers
94
-			// configured in WP: 0 = select, 1 = create.
95
-			'active' => 0 === $count ? 1 : 0,
96
-		) );
97
-
98
-		// Finally return the element instance.
99
-		return $this;
100
-	}
101
-
102
-	/**
103
-	 * Render the publisher's select.
104
-	 *
105
-	 * @since 3.11.0
106
-	 *
107
-	 * @param array $params An array of parameters.
108
-	 */
109
-	public function select( $params ) {
110
-
111
-		// Get the configured publisher id. In case a publisher id is already configured
112
-		// this must be pre-loaded in the options.
113
-		$publisher_id = $this->configuration_service->get_publisher_id();
114
-
115
-		// Get the publisher data.
116
-		$data = $this->publisher_service->query();
117
-		array_unshift( $data, array(
118
-			'id'            => '',
119
-			'text'          => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ),
120
-			'type'          => '',
121
-			'thumbnail_url' => false,
122
-		) );
123
-
124
-		// Call the select internal render.
125
-		$this->do_render( $params, $publisher_id, $data );
126
-
127
-	}
128
-
129
-	/**
130
-	 * Render the 'create publisher' form.
131
-	 *
132
-	 * @since 3.11.0
133
-	 *
134
-	 * @param array $params An array of parameters.
135
-	 */
136
-	public function create( $params ) {
137
-		?>
22
+    /**
23
+     * The {@link Wordlift_Configuration_Service} instance.
24
+     *
25
+     * @since  3.11.0
26
+     * @access private
27
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
28
+     */
29
+    private $configuration_service;
30
+
31
+    /**
32
+     * The {@link Wordlift_Publisher_Service} instance.
33
+     *
34
+     * @since  3.11.0
35
+     * @access private
36
+     * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
37
+     */
38
+    private $publisher_service;
39
+
40
+    /**
41
+     * @var Wordlift_Admin_Tabs_Element
42
+     */
43
+    private $tabs_element;
44
+
45
+    /**
46
+     * Create a {@link Wordlift_Admin_Publisher_Element} instance.
47
+     *
48
+     * @since 3.11.0
49
+     *
50
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
51
+     * @param \Wordlift_Publisher_Service     $publisher_service     The {@link Wordlift_Publisher_Service} instance.
52
+     * @param \Wordlift_Admin_Tabs_Element    $tabs_element          The {@link Wordlift_Admin_Tabs_Element} instance.
53
+     * @param \Wordlift_Admin_Select2_Element $select_element        The {@link Wordlift_Admin_Select_Element} instance.
54
+     */
55
+    function __construct( $configuration_service, $publisher_service, $tabs_element, $select_element ) {
56
+        parent::__construct( $publisher_service, $select_element );
57
+
58
+        $this->configuration_service = $configuration_service;
59
+        $this->publisher_service     = $publisher_service;
60
+
61
+        // Child elements.
62
+        $this->tabs_element = $tabs_element;
63
+
64
+    }
65
+
66
+    /**
67
+     * @inheritdoc
68
+     */
69
+    public function render( $args ) {
70
+
71
+        // Parse the arguments and merge with default values.
72
+        $params = wp_parse_args( $args, array(
73
+            'id'   => uniqid( 'wl-input-' ),
74
+            'name' => uniqid( 'wl-input-' ),
75
+        ) );
76
+
77
+        // Get the number of potential candidates as publishers.
78
+        $count = $this->publisher_service->count();
79
+
80
+        $this->tabs_element->render( array(
81
+            'tabs'   => array(
82
+                array(
83
+                    'label'    => __( 'Select an Existing Publisher', 'wordlift' ),
84
+                    'callback' => array( $this, 'select' ),
85
+                    'args'     => $params,
86
+                ),
87
+                array(
88
+                    'label'    => __( 'Create a New Publisher', 'wordlift' ),
89
+                    'callback' => array( $this, 'create' ),
90
+                    'args'     => $params,
91
+                ),
92
+            ),
93
+            // Set the default tab according to the number of potential publishers
94
+            // configured in WP: 0 = select, 1 = create.
95
+            'active' => 0 === $count ? 1 : 0,
96
+        ) );
97
+
98
+        // Finally return the element instance.
99
+        return $this;
100
+    }
101
+
102
+    /**
103
+     * Render the publisher's select.
104
+     *
105
+     * @since 3.11.0
106
+     *
107
+     * @param array $params An array of parameters.
108
+     */
109
+    public function select( $params ) {
110
+
111
+        // Get the configured publisher id. In case a publisher id is already configured
112
+        // this must be pre-loaded in the options.
113
+        $publisher_id = $this->configuration_service->get_publisher_id();
114
+
115
+        // Get the publisher data.
116
+        $data = $this->publisher_service->query();
117
+        array_unshift( $data, array(
118
+            'id'            => '',
119
+            'text'          => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ),
120
+            'type'          => '',
121
+            'thumbnail_url' => false,
122
+        ) );
123
+
124
+        // Call the select internal render.
125
+        $this->do_render( $params, $publisher_id, $data );
126
+
127
+    }
128
+
129
+    /**
130
+     * Render the 'create publisher' form.
131
+     *
132
+     * @since 3.11.0
133
+     *
134
+     * @param array $params An array of parameters.
135
+     */
136
+    public function create( $params ) {
137
+        ?>
138 138
 		<p>
139 139
 			<strong><?php esc_html_e( 'Are you publishing as an individual or as a company?', 'wordlift' ) ?></strong>
140 140
 		</p>
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 				       name="wl_publisher[type]" value="person"
145 145
 				       checked="checked">
146 146
 				<label for="wl-publisher-person"><?php
147
-					esc_html_e( 'Person', 'wordlift' ) ?></label>
147
+                    esc_html_e( 'Person', 'wordlift' ) ?></label>
148 148
 			</span>
149 149
 			<span>
150 150
 				<input id="wl-publisher-company" type="radio"
151 151
 				       name="wl_publisher[type]" value="organization"">
152 152
 				<label for="wl-publisher-company"><?php
153
-					esc_html_e( 'Company', 'wordlift' ) ?></label>
153
+                    esc_html_e( 'Company', 'wordlift' ) ?></label>
154 154
 			</span>
155 155
 		</p>
156 156
 		<p id="wl-publisher-name">
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 				<img id="wl-publisher-media-uploader-preview" />
168 168
 				<button type="button" class="button"
169 169
 				        id="wl-publisher-media-uploader"><?php
170
-					esc_html_e( 'Select an existing image or upload a new one', 'wordlift' ); ?></button>
170
+                    esc_html_e( 'Select an existing image or upload a new one', 'wordlift' ); ?></button>
171 171
 			</p>
172 172
 		</div>
173 173
 		<?php
174
-	}
174
+    }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 * @param \Wordlift_Admin_Tabs_Element    $tabs_element          The {@link Wordlift_Admin_Tabs_Element} instance.
53 53
 	 * @param \Wordlift_Admin_Select2_Element $select_element        The {@link Wordlift_Admin_Select_Element} instance.
54 54
 	 */
55
-	function __construct( $configuration_service, $publisher_service, $tabs_element, $select_element ) {
56
-		parent::__construct( $publisher_service, $select_element );
55
+	function __construct($configuration_service, $publisher_service, $tabs_element, $select_element) {
56
+		parent::__construct($publisher_service, $select_element);
57 57
 
58 58
 		$this->configuration_service = $configuration_service;
59 59
 		$this->publisher_service     = $publisher_service;
@@ -66,34 +66,34 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @inheritdoc
68 68
 	 */
69
-	public function render( $args ) {
69
+	public function render($args) {
70 70
 
71 71
 		// Parse the arguments and merge with default values.
72
-		$params = wp_parse_args( $args, array(
73
-			'id'   => uniqid( 'wl-input-' ),
74
-			'name' => uniqid( 'wl-input-' ),
75
-		) );
72
+		$params = wp_parse_args($args, array(
73
+			'id'   => uniqid('wl-input-'),
74
+			'name' => uniqid('wl-input-'),
75
+		));
76 76
 
77 77
 		// Get the number of potential candidates as publishers.
78 78
 		$count = $this->publisher_service->count();
79 79
 
80
-		$this->tabs_element->render( array(
80
+		$this->tabs_element->render(array(
81 81
 			'tabs'   => array(
82 82
 				array(
83
-					'label'    => __( 'Select an Existing Publisher', 'wordlift' ),
84
-					'callback' => array( $this, 'select' ),
83
+					'label'    => __('Select an Existing Publisher', 'wordlift'),
84
+					'callback' => array($this, 'select'),
85 85
 					'args'     => $params,
86 86
 				),
87 87
 				array(
88
-					'label'    => __( 'Create a New Publisher', 'wordlift' ),
89
-					'callback' => array( $this, 'create' ),
88
+					'label'    => __('Create a New Publisher', 'wordlift'),
89
+					'callback' => array($this, 'create'),
90 90
 					'args'     => $params,
91 91
 				),
92 92
 			),
93 93
 			// Set the default tab according to the number of potential publishers
94 94
 			// configured in WP: 0 = select, 1 = create.
95 95
 			'active' => 0 === $count ? 1 : 0,
96
-		) );
96
+		));
97 97
 
98 98
 		// Finally return the element instance.
99 99
 		return $this;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param array $params An array of parameters.
108 108
 	 */
109
-	public function select( $params ) {
109
+	public function select($params) {
110 110
 
111 111
 		// Get the configured publisher id. In case a publisher id is already configured
112 112
 		// this must be pre-loaded in the options.
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 
115 115
 		// Get the publisher data.
116 116
 		$data = $this->publisher_service->query();
117
-		array_unshift( $data, array(
117
+		array_unshift($data, array(
118 118
 			'id'            => '',
119
-			'text'          => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ),
119
+			'text'          => _x('(none)', 'Publisher Select in Settings Screen.', 'wordlift'),
120 120
 			'type'          => '',
121 121
 			'thumbnail_url' => false,
122
-		) );
122
+		));
123 123
 
124 124
 		// Call the select internal render.
125
-		$this->do_render( $params, $publisher_id, $data );
125
+		$this->do_render($params, $publisher_id, $data);
126 126
 
127 127
 	}
128 128
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param array $params An array of parameters.
135 135
 	 */
136
-	public function create( $params ) {
136
+	public function create($params) {
137 137
 		?>
138 138
 		<p>
139
-			<strong><?php esc_html_e( 'Are you publishing as an individual or as a company?', 'wordlift' ) ?></strong>
139
+			<strong><?php esc_html_e('Are you publishing as an individual or as a company?', 'wordlift') ?></strong>
140 140
 		</p>
141 141
 		<p id="wl-publisher-type">
142 142
 			<span>
@@ -144,30 +144,30 @@  discard block
 block discarded – undo
144 144
 				       name="wl_publisher[type]" value="person"
145 145
 				       checked="checked">
146 146
 				<label for="wl-publisher-person"><?php
147
-					esc_html_e( 'Person', 'wordlift' ) ?></label>
147
+					esc_html_e('Person', 'wordlift') ?></label>
148 148
 			</span>
149 149
 			<span>
150 150
 				<input id="wl-publisher-company" type="radio"
151 151
 				       name="wl_publisher[type]" value="organization"">
152 152
 				<label for="wl-publisher-company"><?php
153
-					esc_html_e( 'Company', 'wordlift' ) ?></label>
153
+					esc_html_e('Company', 'wordlift') ?></label>
154 154
 			</span>
155 155
 		</p>
156 156
 		<p id="wl-publisher-name">
157 157
 			<input type="text" name="wl_publisher[name]"
158
-			       placeholder="<?php echo esc_attr__( "What's your name?", 'wordlift' ) ?>">
158
+			       placeholder="<?php echo esc_attr__("What's your name?", 'wordlift') ?>">
159 159
 		</p>
160 160
 		<div id="wl-publisher-logo">
161 161
 			<input type="hidden" id="wl-publisher-media-uploader-id"
162 162
 			       name="wl_publisher[thumbnail_id]" />
163 163
 			<p>
164
-				<b><?php esc_html_e( "Choose the publisher's Logo", 'wordlift' ) ?></b>
164
+				<b><?php esc_html_e("Choose the publisher's Logo", 'wordlift') ?></b>
165 165
 			</p>
166 166
 			<p>
167 167
 				<img id="wl-publisher-media-uploader-preview" />
168 168
 				<button type="button" class="button"
169 169
 				        id="wl-publisher-media-uploader"><?php
170
-					esc_html_e( 'Select an existing image or upload a new one', 'wordlift' ); ?></button>
170
+					esc_html_e('Select an existing image or upload a new one', 'wordlift'); ?></button>
171 171
 			</p>
172 172
 		</div>
173 173
 		<?php
Please login to merge, or discard this patch.
src/includes/class-wordlift-content-filter-service.php 2 patches
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -18,236 +18,236 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Content_Filter_Service {
20 20
 
21
-	/**
22
-	 * The pattern to find entities in text.
23
-	 *
24
-	 * @since 3.8.0
25
-	 */
26
-	const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
-
28
-	/**
29
-	 * A {@link Wordlift_Entity_Service} instance.
30
-	 *
31
-	 * @since  3.8.0
32
-	 * @access private
33
-	 * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
-	 */
35
-	private $entity_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Configuration_Service} instance.
39
-	 *
40
-	 * @since  3.13.0
41
-	 * @access private
42
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
-	 */
44
-	private $configuration_service;
45
-
46
-	/**
47
-	 * The `link by default` setting.
48
-	 *
49
-	 * @since  3.13.0
50
-	 * @access private
51
-	 * @var bool True if link by default is enabled otherwise false.
52
-	 */
53
-	private $is_link_by_default;
54
-
55
-	/**
56
-	 * The {@link Wordlift_Content_Filter_Service} singleton instance.
57
-	 *
58
-	 * @since  3.14.2
59
-	 * @access private
60
-	 * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
61
-	 */
62
-	private static $instance;
63
-
64
-	/**
65
-	 * Create a {@link Wordlift_Content_Filter_Service} instance.
66
-	 *
67
-	 * @since 3.8.0
68
-	 *
69
-	 * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
70
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
71
-	 */
72
-	public function __construct( $entity_service, $configuration_service ) {
73
-
74
-		$this->entity_service        = $entity_service;
75
-		$this->configuration_service = $configuration_service;
76
-
77
-		self::$instance = $this;
78
-
79
-	}
80
-
81
-	/**
82
-	 * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
83
-	 *
84
-	 * @since 3.14.2
85
-	 * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
86
-	 */
87
-	public static function get_instance() {
88
-
89
-		return self::$instance;
90
-	}
91
-
92
-	/**
93
-	 * Mangle the content by adding links to the entity pages. This function is
94
-	 * hooked to the 'the_content' WP's filter.
95
-	 *
96
-	 * @since 3.8.0
97
-	 *
98
-	 * @param string $content The content being filtered.
99
-	 *
100
-	 * @return string The filtered content.
101
-	 */
102
-	public function the_content( $content ) {
103
-
104
-		// Links should be added only on the front end and not for RSS.
105
-		if ( is_feed() ) {
106
-			return $content;
107
-		}
108
-
109
-		// Preload the `link by default` setting.
110
-		$this->is_link_by_default = $this->configuration_service->is_link_by_default();
111
-
112
-		// Replace each match of the entity tag with the entity link. If an error
113
-		// occurs fail silently returning the original content.
114
-		return preg_replace_callback( self::PATTERN, array(
115
-			$this,
116
-			'link',
117
-		), $content ) ?: $content;
118
-	}
119
-
120
-	/**
121
-	 * Get the entity match and replace it with a page link.
122
-	 *
123
-	 * @since 3.8.0
124
-	 *
125
-	 * @param array $matches An array of matches.
126
-	 *
127
-	 * @return string The replaced text with the link to the entity page.
128
-	 */
129
-	private function link( $matches ) {
130
-
131
-		// Get the entity itemid URI and label.
132
-		$css_class = $matches[2];
133
-		$uri       = $matches[3];
134
-		$label     = $matches[4];
135
-
136
-		// Get the entity post by URI.
137
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
138
-		if ( null === $post ) {
139
-
140
-			// If the entity post is not found return the label w/o the markup
141
-			// around it.
142
-			//
143
-			// See https://github.com/insideout10/wordlift-plugin/issues/461.
144
-			return $label;
145
-		}
146
-
147
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' );
148
-		$link    = - 1 < strpos( $css_class, 'wl-link' );
149
-
150
-		// Don't link if links are disabled and the entity is not link or the
151
-		// entity is do not link.
152
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
153
-
154
-		// Return the label if it's don't link.
155
-		if ( $dont_link ) {
156
-			return $label;
157
-		}
158
-
159
-		// Get the link.
160
-		$href = get_permalink( $post );
161
-
162
-		// Get an alternative title attribute.
163
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
164
-
165
-		// Return the link.
166
-		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
167
-	}
168
-
169
-	/**
170
-	 * Get a `title` attribute with an alternative label for the link.
171
-	 *
172
-	 * If an alternative title isn't available an empty string is returned.
173
-	 *
174
-	 * @since 3.15.0
175
-	 *
176
-	 * @param int    $post_id The {@link WP_Post}'s id.
177
-	 * @param string $label   The main link label.
178
-	 *
179
-	 * @return string A `title` attribute with an alternative label or an empty
180
-	 *                string if none available.
181
-	 */
182
-	private function get_title_attribute( $post_id, $label ) {
183
-
184
-		// Get an alternative title.
185
-		$title = $this->get_link_title( $post_id, $label );
186
-		if ( ! empty( $title ) ) {
187
-			return 'title="' . esc_attr( $title ) . '"';
188
-		}
189
-
190
-		return '';
191
-	}
192
-
193
-	/**
194
-	 * Get a string to be used as a title attribute in links to a post
195
-	 *
196
-	 * @since 3.15.0
197
-	 *
198
-	 * @param int    $post_id      The post id of the post being linked.
199
-	 * @param string $ignore_label A label to ignore.
200
-	 *
201
-	 * @return string    The title to be used in the link. An empty string when
202
-	 *                    there is no alternative that is not the $ignore_label.
203
-	 */
204
-	function get_link_title( $post_id, $ignore_label ) {
205
-
206
-		// Get possible alternative labels we can select from.
207
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
208
-
209
-		/*
21
+    /**
22
+     * The pattern to find entities in text.
23
+     *
24
+     * @since 3.8.0
25
+     */
26
+    const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
+
28
+    /**
29
+     * A {@link Wordlift_Entity_Service} instance.
30
+     *
31
+     * @since  3.8.0
32
+     * @access private
33
+     * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
+     */
35
+    private $entity_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Configuration_Service} instance.
39
+     *
40
+     * @since  3.13.0
41
+     * @access private
42
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
+     */
44
+    private $configuration_service;
45
+
46
+    /**
47
+     * The `link by default` setting.
48
+     *
49
+     * @since  3.13.0
50
+     * @access private
51
+     * @var bool True if link by default is enabled otherwise false.
52
+     */
53
+    private $is_link_by_default;
54
+
55
+    /**
56
+     * The {@link Wordlift_Content_Filter_Service} singleton instance.
57
+     *
58
+     * @since  3.14.2
59
+     * @access private
60
+     * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
61
+     */
62
+    private static $instance;
63
+
64
+    /**
65
+     * Create a {@link Wordlift_Content_Filter_Service} instance.
66
+     *
67
+     * @since 3.8.0
68
+     *
69
+     * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
70
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
71
+     */
72
+    public function __construct( $entity_service, $configuration_service ) {
73
+
74
+        $this->entity_service        = $entity_service;
75
+        $this->configuration_service = $configuration_service;
76
+
77
+        self::$instance = $this;
78
+
79
+    }
80
+
81
+    /**
82
+     * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
83
+     *
84
+     * @since 3.14.2
85
+     * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
86
+     */
87
+    public static function get_instance() {
88
+
89
+        return self::$instance;
90
+    }
91
+
92
+    /**
93
+     * Mangle the content by adding links to the entity pages. This function is
94
+     * hooked to the 'the_content' WP's filter.
95
+     *
96
+     * @since 3.8.0
97
+     *
98
+     * @param string $content The content being filtered.
99
+     *
100
+     * @return string The filtered content.
101
+     */
102
+    public function the_content( $content ) {
103
+
104
+        // Links should be added only on the front end and not for RSS.
105
+        if ( is_feed() ) {
106
+            return $content;
107
+        }
108
+
109
+        // Preload the `link by default` setting.
110
+        $this->is_link_by_default = $this->configuration_service->is_link_by_default();
111
+
112
+        // Replace each match of the entity tag with the entity link. If an error
113
+        // occurs fail silently returning the original content.
114
+        return preg_replace_callback( self::PATTERN, array(
115
+            $this,
116
+            'link',
117
+        ), $content ) ?: $content;
118
+    }
119
+
120
+    /**
121
+     * Get the entity match and replace it with a page link.
122
+     *
123
+     * @since 3.8.0
124
+     *
125
+     * @param array $matches An array of matches.
126
+     *
127
+     * @return string The replaced text with the link to the entity page.
128
+     */
129
+    private function link( $matches ) {
130
+
131
+        // Get the entity itemid URI and label.
132
+        $css_class = $matches[2];
133
+        $uri       = $matches[3];
134
+        $label     = $matches[4];
135
+
136
+        // Get the entity post by URI.
137
+        $post = $this->entity_service->get_entity_post_by_uri( $uri );
138
+        if ( null === $post ) {
139
+
140
+            // If the entity post is not found return the label w/o the markup
141
+            // around it.
142
+            //
143
+            // See https://github.com/insideout10/wordlift-plugin/issues/461.
144
+            return $label;
145
+        }
146
+
147
+        $no_link = - 1 < strpos( $css_class, 'wl-no-link' );
148
+        $link    = - 1 < strpos( $css_class, 'wl-link' );
149
+
150
+        // Don't link if links are disabled and the entity is not link or the
151
+        // entity is do not link.
152
+        $dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
153
+
154
+        // Return the label if it's don't link.
155
+        if ( $dont_link ) {
156
+            return $label;
157
+        }
158
+
159
+        // Get the link.
160
+        $href = get_permalink( $post );
161
+
162
+        // Get an alternative title attribute.
163
+        $title_attribute = $this->get_title_attribute( $post->ID, $label );
164
+
165
+        // Return the link.
166
+        return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
167
+    }
168
+
169
+    /**
170
+     * Get a `title` attribute with an alternative label for the link.
171
+     *
172
+     * If an alternative title isn't available an empty string is returned.
173
+     *
174
+     * @since 3.15.0
175
+     *
176
+     * @param int    $post_id The {@link WP_Post}'s id.
177
+     * @param string $label   The main link label.
178
+     *
179
+     * @return string A `title` attribute with an alternative label or an empty
180
+     *                string if none available.
181
+     */
182
+    private function get_title_attribute( $post_id, $label ) {
183
+
184
+        // Get an alternative title.
185
+        $title = $this->get_link_title( $post_id, $label );
186
+        if ( ! empty( $title ) ) {
187
+            return 'title="' . esc_attr( $title ) . '"';
188
+        }
189
+
190
+        return '';
191
+    }
192
+
193
+    /**
194
+     * Get a string to be used as a title attribute in links to a post
195
+     *
196
+     * @since 3.15.0
197
+     *
198
+     * @param int    $post_id      The post id of the post being linked.
199
+     * @param string $ignore_label A label to ignore.
200
+     *
201
+     * @return string    The title to be used in the link. An empty string when
202
+     *                    there is no alternative that is not the $ignore_label.
203
+     */
204
+    function get_link_title( $post_id, $ignore_label ) {
205
+
206
+        // Get possible alternative labels we can select from.
207
+        $labels = $this->entity_service->get_alternative_labels( $post_id );
208
+
209
+        /*
210 210
 		 * Since the original text might use an alternative label than the
211 211
 		 * Entity title, add the title itself which is not returned by the api.
212 212
 		 */
213
-		$labels[] = get_the_title( $post_id );
214
-
215
-		// Add some randomness to the label selection.
216
-		shuffle( $labels );
217
-
218
-		// Select the first label which is not to be ignored.
219
-		$title = '';
220
-		foreach ( $labels as $label ) {
221
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
222
-				$title = $label;
223
-				break;
224
-			}
225
-		}
226
-
227
-		return $title;
228
-	}
229
-
230
-	/**
231
-	 * Get the entity URIs (configured in the `itemid` attribute) contained in
232
-	 * the provided content.
233
-	 *
234
-	 * @since 3.14.2
235
-	 *
236
-	 * @param string $content The content.
237
-	 *
238
-	 * @return array An array of URIs.
239
-	 */
240
-	public function get_entity_uris( $content ) {
241
-
242
-		$matches = array();
243
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
244
-
245
-		// We need to use `array_values` here in order to avoid further `json_encode`
246
-		// to turn it into an object (since if the 3rd match isn't found the index
247
-		// is not sequential.
248
-		//
249
-		// See https://github.com/insideout10/wordlift-plugin/issues/646.
250
-		return array_values( array_unique( $matches[3] ) );
251
-	}
213
+        $labels[] = get_the_title( $post_id );
214
+
215
+        // Add some randomness to the label selection.
216
+        shuffle( $labels );
217
+
218
+        // Select the first label which is not to be ignored.
219
+        $title = '';
220
+        foreach ( $labels as $label ) {
221
+            if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
222
+                $title = $label;
223
+                break;
224
+            }
225
+        }
226
+
227
+        return $title;
228
+    }
229
+
230
+    /**
231
+     * Get the entity URIs (configured in the `itemid` attribute) contained in
232
+     * the provided content.
233
+     *
234
+     * @since 3.14.2
235
+     *
236
+     * @param string $content The content.
237
+     *
238
+     * @return array An array of URIs.
239
+     */
240
+    public function get_entity_uris( $content ) {
241
+
242
+        $matches = array();
243
+        preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
244
+
245
+        // We need to use `array_values` here in order to avoid further `json_encode`
246
+        // to turn it into an object (since if the 3rd match isn't found the index
247
+        // is not sequential.
248
+        //
249
+        // See https://github.com/insideout10/wordlift-plugin/issues/646.
250
+        return array_values( array_unique( $matches[3] ) );
251
+    }
252 252
 
253 253
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
70 70
 	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
71 71
 	 */
72
-	public function __construct( $entity_service, $configuration_service ) {
72
+	public function __construct($entity_service, $configuration_service) {
73 73
 
74 74
 		$this->entity_service        = $entity_service;
75 75
 		$this->configuration_service = $configuration_service;
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string The filtered content.
101 101
 	 */
102
-	public function the_content( $content ) {
102
+	public function the_content($content) {
103 103
 
104 104
 		// Links should be added only on the front end and not for RSS.
105
-		if ( is_feed() ) {
105
+		if (is_feed()) {
106 106
 			return $content;
107 107
 		}
108 108
 
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 
112 112
 		// Replace each match of the entity tag with the entity link. If an error
113 113
 		// occurs fail silently returning the original content.
114
-		return preg_replace_callback( self::PATTERN, array(
114
+		return preg_replace_callback(self::PATTERN, array(
115 115
 			$this,
116 116
 			'link',
117
-		), $content ) ?: $content;
117
+		), $content) ?: $content;
118 118
 	}
119 119
 
120 120
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string The replaced text with the link to the entity page.
128 128
 	 */
129
-	private function link( $matches ) {
129
+	private function link($matches) {
130 130
 
131 131
 		// Get the entity itemid URI and label.
132 132
 		$css_class = $matches[2];
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		$label     = $matches[4];
135 135
 
136 136
 		// Get the entity post by URI.
137
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
138
-		if ( null === $post ) {
137
+		$post = $this->entity_service->get_entity_post_by_uri($uri);
138
+		if (null === $post) {
139 139
 
140 140
 			// If the entity post is not found return the label w/o the markup
141 141
 			// around it.
@@ -144,23 +144,23 @@  discard block
 block discarded – undo
144 144
 			return $label;
145 145
 		}
146 146
 
147
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' );
148
-		$link    = - 1 < strpos( $css_class, 'wl-link' );
147
+		$no_link = - 1 < strpos($css_class, 'wl-no-link');
148
+		$link    = - 1 < strpos($css_class, 'wl-link');
149 149
 
150 150
 		// Don't link if links are disabled and the entity is not link or the
151 151
 		// entity is do not link.
152
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
152
+		$dont_link = ( ! $this->is_link_by_default && ! $link) || $no_link;
153 153
 
154 154
 		// Return the label if it's don't link.
155
-		if ( $dont_link ) {
155
+		if ($dont_link) {
156 156
 			return $label;
157 157
 		}
158 158
 
159 159
 		// Get the link.
160
-		$href = get_permalink( $post );
160
+		$href = get_permalink($post);
161 161
 
162 162
 		// Get an alternative title attribute.
163
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
163
+		$title_attribute = $this->get_title_attribute($post->ID, $label);
164 164
 
165 165
 		// Return the link.
166 166
 		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 	 * @return string A `title` attribute with an alternative label or an empty
180 180
 	 *                string if none available.
181 181
 	 */
182
-	private function get_title_attribute( $post_id, $label ) {
182
+	private function get_title_attribute($post_id, $label) {
183 183
 
184 184
 		// Get an alternative title.
185
-		$title = $this->get_link_title( $post_id, $label );
186
-		if ( ! empty( $title ) ) {
187
-			return 'title="' . esc_attr( $title ) . '"';
185
+		$title = $this->get_link_title($post_id, $label);
186
+		if ( ! empty($title)) {
187
+			return 'title="'.esc_attr($title).'"';
188 188
 		}
189 189
 
190 190
 		return '';
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
 	 * @return string    The title to be used in the link. An empty string when
202 202
 	 *                    there is no alternative that is not the $ignore_label.
203 203
 	 */
204
-	function get_link_title( $post_id, $ignore_label ) {
204
+	function get_link_title($post_id, $ignore_label) {
205 205
 
206 206
 		// Get possible alternative labels we can select from.
207
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
207
+		$labels = $this->entity_service->get_alternative_labels($post_id);
208 208
 
209 209
 		/*
210 210
 		 * Since the original text might use an alternative label than the
211 211
 		 * Entity title, add the title itself which is not returned by the api.
212 212
 		 */
213
-		$labels[] = get_the_title( $post_id );
213
+		$labels[] = get_the_title($post_id);
214 214
 
215 215
 		// Add some randomness to the label selection.
216
-		shuffle( $labels );
216
+		shuffle($labels);
217 217
 
218 218
 		// Select the first label which is not to be ignored.
219 219
 		$title = '';
220
-		foreach ( $labels as $label ) {
221
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
220
+		foreach ($labels as $label) {
221
+			if (0 !== strcasecmp($label, $ignore_label)) {
222 222
 				$title = $label;
223 223
 				break;
224 224
 			}
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return array An array of URIs.
239 239
 	 */
240
-	public function get_entity_uris( $content ) {
240
+	public function get_entity_uris($content) {
241 241
 
242 242
 		$matches = array();
243
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
243
+		preg_match_all(Wordlift_Content_Filter_Service::PATTERN, $content, $matches);
244 244
 
245 245
 		// We need to use `array_values` here in order to avoid further `json_encode`
246 246
 		// to turn it into an object (since if the 3rd match isn't found the index
247 247
 		// is not sequential.
248 248
 		//
249 249
 		// See https://github.com/insideout10/wordlift-plugin/issues/646.
250
-		return array_values( array_unique( $matches[3] ) );
250
+		return array_values(array_unique($matches[3]));
251 251
 	}
252 252
 
253 253
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 1 patch
Indentation   +1369 added lines, -1369 removed lines patch added patch discarded remove patch
@@ -29,1416 +29,1416 @@
 block discarded – undo
29 29
  */
30 30
 class Wordlift {
31 31
 
32
-	/**
33
-	 * The loader that's responsible for maintaining and registering all hooks that power
34
-	 * the plugin.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   protected
38
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
-	 */
40
-	protected $loader;
41
-
42
-	/**
43
-	 * The unique identifier of this plugin.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   protected
47
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
48
-	 */
49
-	protected $plugin_name;
50
-
51
-	/**
52
-	 * The current version of the plugin.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   protected
56
-	 * @var      string $version The current version of the plugin.
57
-	 */
58
-	protected $version;
59
-
60
-	/**
61
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
62
-	 *
63
-	 * @since  3.12.0
64
-	 * @access protected
65
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
66
-	 */
67
-	protected $tinymce_adapter;
68
-
69
-	/**
70
-	 * The Thumbnail service.
71
-	 *
72
-	 * @since  3.1.5
73
-	 * @access private
74
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
75
-	 */
76
-	private $thumbnail_service;
77
-
78
-	/**
79
-	 * The UI service.
80
-	 *
81
-	 * @since  3.2.0
82
-	 * @access private
83
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
84
-	 */
85
-	private $ui_service;
86
-
87
-	/**
88
-	 * The Schema service.
89
-	 *
90
-	 * @since  3.3.0
91
-	 * @access protected
92
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
93
-	 */
94
-	protected $schema_service;
95
-
96
-	/**
97
-	 * The Entity service.
98
-	 *
99
-	 * @since  3.1.0
100
-	 * @access protected
101
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
102
-	 */
103
-	protected $entity_service;
104
-
105
-	/**
106
-	 * The Topic Taxonomy service.
107
-	 *
108
-	 * @since  3.5.0
109
-	 * @access private
110
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
111
-	 */
112
-	private $topic_taxonomy_service;
113
-
114
-	/**
115
-	 * The User service.
116
-	 *
117
-	 * @since  3.1.7
118
-	 * @access protected
119
-	 * @var \Wordlift_User_Service $user_service The User service.
120
-	 */
121
-	protected $user_service;
122
-
123
-	/**
124
-	 * The Timeline service.
125
-	 *
126
-	 * @since  3.1.0
127
-	 * @access private
128
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
129
-	 */
130
-	private $timeline_service;
131
-
132
-	/**
133
-	 * The Redirect service.
134
-	 *
135
-	 * @since  3.2.0
136
-	 * @access private
137
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
138
-	 */
139
-	private $redirect_service;
140
-
141
-	/**
142
-	 * The Notice service.
143
-	 *
144
-	 * @since  3.3.0
145
-	 * @access private
146
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
147
-	 */
148
-	private $notice_service;
149
-
150
-	/**
151
-	 * The Entity list customization.
152
-	 *
153
-	 * @since  3.3.0
154
-	 * @access private
155
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
156
-	 */
157
-	private $entity_list_service;
158
-
159
-	/**
160
-	 * The Entity Types Taxonomy Walker.
161
-	 *
162
-	 * @since  3.1.0
163
-	 * @access private
164
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
165
-	 */
166
-	private $entity_types_taxonomy_walker;
167
-
168
-	/**
169
-	 * The ShareThis service.
170
-	 *
171
-	 * @since  3.2.0
172
-	 * @access private
173
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
174
-	 */
175
-	private $sharethis_service;
176
-
177
-	/**
178
-	 * The PrimaShop adapter.
179
-	 *
180
-	 * @since  3.2.3
181
-	 * @access private
182
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
183
-	 */
184
-	private $primashop_adapter;
185
-
186
-	/**
187
-	 * The WordLift Dashboard adapter.
188
-	 *
189
-	 * @since  3.4.0
190
-	 * @access private
191
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
192
-	 */
193
-	private $dashboard_service;
194
-
195
-	/**
196
-	 * The entity type service.
197
-	 *
198
-	 * @since  3.6.0
199
-	 * @access private
200
-	 * @var \Wordlift_Entity_Post_Type_Service
201
-	 */
202
-	private $entity_post_type_service;
203
-
204
-	/**
205
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
206
-	 *
207
-	 * @since  3.6.0
208
-	 * @access private
209
-	 * @var \Wordlift_Entity_Link_Service
210
-	 */
211
-	private $entity_link_service;
212
-
213
-	/**
214
-	 * A {@link Wordlift_Sparql_Service} instance.
215
-	 *
216
-	 * @var    3.6.0
217
-	 * @access protected
218
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
219
-	 */
220
-	protected $sparql_service;
221
-
222
-	/**
223
-	 * A {@link Wordlift_Import_Service} instance.
224
-	 *
225
-	 * @since  3.6.0
226
-	 * @access private
227
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
228
-	 */
229
-	private $import_service;
230
-
231
-	/**
232
-	 * A {@link Wordlift_Rebuild_Service} instance.
233
-	 *
234
-	 * @since  3.6.0
235
-	 * @access private
236
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
237
-	 */
238
-	private $rebuild_service;
239
-
240
-	/**
241
-	 * A {@link Wordlift_Jsonld_Service} instance.
242
-	 *
243
-	 * @since  3.7.0
244
-	 * @access protected
245
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
246
-	 */
247
-	protected $jsonld_service;
248
-
249
-	/**
250
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
251
-	 *
252
-	 * @since  3.14.0
253
-	 * @access protected
254
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
255
-	 */
256
-	protected $jsonld_website_converter;
257
-
258
-	/**
259
-	 *
260
-	 * @since  3.7.0
261
-	 * @access private
262
-	 * @var \Wordlift_Property_Factory $property_factory
263
-	 */
264
-	private $property_factory;
265
-
266
-	/**
267
-	 * The 'Download Your Data' page.
268
-	 *
269
-	 * @since  3.6.0
270
-	 * @access private
271
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
-	 */
273
-	private $download_your_data_page;
274
-
275
-	/**
276
-	 * The 'WordLift Settings' page.
277
-	 *
278
-	 * @since  3.11.0
279
-	 * @access protected
280
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
-	 */
282
-	protected $settings_page;
283
-
284
-	/**
285
-	 * The 'WordLift Batch analysis' page.
286
-	 *
287
-	 * @since  3.14.0
288
-	 * @access protected
289
-	 * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
-	 */
291
-	protected $batch_analysis_page;
292
-
293
-	/**
294
-	 * The install wizard page.
295
-	 *
296
-	 * @since  3.9.0
297
-	 * @access private
298
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
-	 */
300
-	private $admin_setup;
301
-
302
-	/**
303
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
304
-	 * linking of entities to their pages.
305
-	 *
306
-	 * @since  3.8.0
307
-	 * @access private
308
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
-	 */
310
-	private $content_filter_service;
311
-
312
-	/**
313
-	 * A {@link Wordlift_Key_Validation_Service} instance.
314
-	 *
315
-	 * @since  3.9.0
316
-	 * @access private
317
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
-	 */
319
-	private $key_validation_service;
320
-
321
-	/**
322
-	 * A {@link Wordlift_Rating_Service} instance.
323
-	 *
324
-	 * @since  3.10.0
325
-	 * @access private
326
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
-	 */
328
-	private $rating_service;
329
-
330
-	/**
331
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
-	 *
333
-	 * @since  3.10.0
334
-	 * @access protected
335
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
-	 */
337
-	protected $post_to_jsonld_converter;
338
-
339
-	/**
340
-	 * A {@link Wordlift_Configuration_Service} instance.
341
-	 *
342
-	 * @since  3.10.0
343
-	 * @access protected
344
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
-	 */
346
-	protected $configuration_service;
347
-
348
-	/**
349
-	 * A {@link Wordlift_Entity_Type_Service} instance.
350
-	 *
351
-	 * @since  3.10.0
352
-	 * @access protected
353
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
-	 */
355
-	protected $entity_type_service;
356
-
357
-	/**
358
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
-	 *
360
-	 * @since  3.10.0
361
-	 * @access protected
362
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
-	 */
364
-	protected $entity_post_to_jsonld_converter;
365
-
366
-	/**
367
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
-	 *
369
-	 * @since  3.10.0
370
-	 * @access protected
371
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
-	 */
373
-	protected $postid_to_jsonld_converter;
374
-
375
-	/**
376
-	 * The {@link Wordlift_Admin_Status_Page} class.
377
-	 *
378
-	 * @since  3.9.8
379
-	 * @access private
380
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
-	 */
382
-	private $status_page;
383
-
384
-	/**
385
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
-	 *
387
-	 * @since  3.11.0
388
-	 * @access protected
389
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
-	 */
391
-	protected $category_taxonomy_service;
392
-
393
-	/**
394
-	 * The {@link Wordlift_Entity_Page_Service} instance.
395
-	 *
396
-	 * @since  3.11.0
397
-	 * @access protected
398
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
-	 */
400
-	protected $entity_page_service;
401
-
402
-	/**
403
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
-	 *
405
-	 * @since  3.11.0
406
-	 * @access protected
407
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
-	 */
409
-	protected $settings_page_action_link;
410
-
411
-	/**
412
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
-	 *
414
-	 * @since  3.11.0
415
-	 * @access protected
416
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
-	 */
418
-	protected $publisher_ajax_adapter;
419
-
420
-	/**
421
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
422
-	 *
423
-	 * @since  3.11.0
424
-	 * @access protected
425
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
-	 */
427
-	protected $input_element;
428
-
429
-	/**
430
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
-	 *
432
-	 * @since  3.13.0
433
-	 * @access protected
434
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
-	 */
436
-	protected $radio_input_element;
437
-
438
-	/**
439
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
-	 *
441
-	 * @since  3.11.0
442
-	 * @access protected
443
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
-	 */
445
-	protected $language_select_element;
446
-
447
-	/**
448
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
-	 *
450
-	 * @since  3.11.0
451
-	 * @access protected
452
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
-	 */
454
-	protected $publisher_element;
455
-
456
-	/**
457
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
-	 *
459
-	 * @since  3.11.0
460
-	 * @access protected
461
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
-	 */
463
-	protected $select2_element;
464
-
465
-	/**
466
-	 * The controller for the entity type list admin page
467
-	 *
468
-	 * @since  3.11.0
469
-	 * @access private
470
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
-	 */
472
-	private $entity_type_admin_page;
473
-
474
-	/**
475
-	 * The controller for the entity type settings admin page
476
-	 *
477
-	 * @since  3.11.0
478
-	 * @access private
479
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
-	 */
481
-	private $entity_type_settings_admin_page;
482
-
483
-	/**
484
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
-	 *
486
-	 * @since  3.11.0
487
-	 * @access protected
488
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
-	 */
490
-	protected $related_entities_cloud_widget;
491
-
492
-	/**
493
-	 * The {@link Wordlift_Admin_Author_Element} instance.
494
-	 *
495
-	 * @since  3.14.0
496
-	 * @access protected
497
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
-	 */
499
-	protected $author_element;
500
-
501
-	/**
502
-	 * The {@link Wordlift_Batch_Analysis_Service} instance.
503
-	 *
504
-	 * @since  3.14.0
505
-	 * @access protected
506
-	 * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
-	 */
508
-	protected $batch_analysis_service;
509
-
510
-	/**
511
-	 * The {@link Wordlift_Sample_Data_Service} instance.
512
-	 *
513
-	 * @since  3.12.0
514
-	 * @access protected
515
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
-	 */
517
-	protected $sample_data_service;
518
-
519
-	/**
520
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
-	 *
522
-	 * @since  3.12.0
523
-	 * @access protected
524
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
-	 */
526
-	protected $sample_data_ajax_adapter;
527
-
528
-	/**
529
-	 * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
-	 *
531
-	 * @since  3.14.2
532
-	 * @access protected
533
-	 * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
-	 */
535
-	private $batch_analysis_adapter;
536
-
537
-	/**
538
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
-	 *
540
-	 * @since  3.14.3
541
-	 * @access private
542
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
-	 */
544
-	private $relation_rebuild_service;
545
-
546
-	/**
547
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
-	 *
549
-	 * @since  3.14.3
550
-	 * @access private
551
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
-	 */
553
-	private $relation_rebuild_adapter;
554
-
555
-	/**
556
-	 * {@link Wordlift}'s singleton instance.
557
-	 *
558
-	 * @since  3.15.0
559
-	 * @access protected
560
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
561
-	 */
562
-	protected $entity_type_adapter;
563
-
564
-	/**
565
-	 * The {@link Wordlift_Linked_Data_Service} instance.
566
-	 *
567
-	 * @since  3.15.0
568
-	 * @access protected
569
-	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
570
-	 */
571
-	protected $linked_data_service;
572
-
573
-	/**
574
-	 * The {@link Wordlift_Storage_Factory} instance.
575
-	 *
576
-	 * @since  3.15.0
577
-	 * @access protected
578
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
579
-	 */
580
-	protected $storage_factory;
581
-
582
-	/**
583
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
584
-	 *
585
-	 * @since  3.15.0
586
-	 * @access protected
587
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
588
-	 */
589
-	protected $rendition_factory;
590
-
591
-	/**
592
-	 * The {@link Wordlift_Autocomplete_Service} instance.
593
-	 *
594
-	 * @since  3.15.0
595
-	 * @access private
596
-	 * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
597
-	 */
598
-	private $autocomplete_service;
599
-
600
-	/**
601
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
602
-	 *
603
-	 * @since  3.15.0
604
-	 * @access private
605
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
606
-	 */
607
-	private $autocomplete_adapter;
608
-
609
-	/**
610
-	 * The {@link Wordlift_Relation_Service} instance.
611
-	 *
612
-	 * @since  3.15.0
613
-	 * @access private
614
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
615
-	 */
616
-	private $relation_service;
617
-
618
-	/**
619
-	 * {@link Wordlift}'s singleton instance.
620
-	 *
621
-	 * @since  3.11.2
622
-	 * @access private
623
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
624
-	 */
625
-	private static $instance;
626
-
627
-	/**
628
-	 * Define the core functionality of the plugin.
629
-	 *
630
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
631
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
632
-	 * the public-facing side of the site.
633
-	 *
634
-	 * @since    1.0.0
635
-	 */
636
-	public function __construct() {
637
-
638
-		$this->plugin_name = 'wordlift';
639
-		$this->version     = '3.15.1';
640
-		$this->load_dependencies();
641
-		$this->set_locale();
642
-		$this->define_admin_hooks();
643
-		$this->define_public_hooks();
644
-
645
-		self::$instance = $this;
646
-
647
-	}
648
-
649
-	/**
650
-	 * Get the singleton instance.
651
-	 *
652
-	 * @since 3.11.2
653
-	 *
654
-	 * @return Wordlift The {@link Wordlift} singleton instance.
655
-	 */
656
-	public static function get_instance() {
657
-
658
-		return self::$instance;
659
-	}
660
-
661
-	/**
662
-	 * Load the required dependencies for this plugin.
663
-	 *
664
-	 * Include the following files that make up the plugin:
665
-	 *
666
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
667
-	 * - Wordlift_i18n. Defines internationalization functionality.
668
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
669
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
670
-	 *
671
-	 * Create an instance of the loader which will be used to register the hooks
672
-	 * with WordPress.
673
-	 *
674
-	 * @since    1.0.0
675
-	 * @access   private
676
-	 */
677
-	private function load_dependencies() {
678
-
679
-		/**
680
-		 * The class responsible for orchestrating the actions and filters of the
681
-		 * core plugin.
682
-		 */
683
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
684
-
685
-		/**
686
-		 * The class responsible for defining internationalization functionality
687
-		 * of the plugin.
688
-		 */
689
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
690
-
691
-		/**
692
-		 * WordLift's supported languages.
693
-		 */
694
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
695
-
696
-		/**
697
-		 * Provide support functions to sanitize data.
698
-		 */
699
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
700
-
701
-		/** Services. */
702
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
703
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
704
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
705
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
706
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
707
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
708
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
709
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
710
-
711
-		/**
712
-		 * The Query builder.
713
-		 */
714
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
715
-
716
-		/**
717
-		 * The Schema service.
718
-		 */
719
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
720
-
721
-		/**
722
-		 * The schema:url property service.
723
-		 */
724
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
725
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
726
-
727
-		/**
728
-		 * The UI service.
729
-		 */
730
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
731
-
732
-		/**
733
-		 * The Thumbnail service.
734
-		 */
735
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
736
-
737
-		/**
738
-		 * The Entity Types Taxonomy service.
739
-		 */
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
741
-
742
-		/**
743
-		 * The Entity service.
744
-		 */
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
746
-
747
-		// Add the entity rating service.
748
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
749
-
750
-		/**
751
-		 * The User service.
752
-		 */
753
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
754
-
755
-		/**
756
-		 * The Timeline service.
757
-		 */
758
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
759
-
760
-		/**
761
-		 * The Topic Taxonomy service.
762
-		 */
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
764
-
765
-		/**
766
-		 * The SPARQL service.
767
-		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
769
-
770
-		/**
771
-		 * The WordLift import service.
772
-		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
774
-
775
-		/**
776
-		 * The WordLift URI service.
777
-		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
779
-
780
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
781
-
782
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
783
-
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
785
-
786
-		/**
787
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
788
-		 */
789
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
790
-
791
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
792
-
793
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
794
-
795
-		/**
796
-		 * Load the converters.
797
-		 */
798
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
799
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
800
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
801
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
803
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
804
-
805
-		/**
806
-		 * Load the content filter.
807
-		 */
808
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
809
-
810
-		/*
32
+    /**
33
+     * The loader that's responsible for maintaining and registering all hooks that power
34
+     * the plugin.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   protected
38
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
+     */
40
+    protected $loader;
41
+
42
+    /**
43
+     * The unique identifier of this plugin.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   protected
47
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
48
+     */
49
+    protected $plugin_name;
50
+
51
+    /**
52
+     * The current version of the plugin.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   protected
56
+     * @var      string $version The current version of the plugin.
57
+     */
58
+    protected $version;
59
+
60
+    /**
61
+     * The {@link Wordlift_Tinymce_Adapter} instance.
62
+     *
63
+     * @since  3.12.0
64
+     * @access protected
65
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
66
+     */
67
+    protected $tinymce_adapter;
68
+
69
+    /**
70
+     * The Thumbnail service.
71
+     *
72
+     * @since  3.1.5
73
+     * @access private
74
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
75
+     */
76
+    private $thumbnail_service;
77
+
78
+    /**
79
+     * The UI service.
80
+     *
81
+     * @since  3.2.0
82
+     * @access private
83
+     * @var \Wordlift_UI_Service $ui_service The UI service.
84
+     */
85
+    private $ui_service;
86
+
87
+    /**
88
+     * The Schema service.
89
+     *
90
+     * @since  3.3.0
91
+     * @access protected
92
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
93
+     */
94
+    protected $schema_service;
95
+
96
+    /**
97
+     * The Entity service.
98
+     *
99
+     * @since  3.1.0
100
+     * @access protected
101
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
102
+     */
103
+    protected $entity_service;
104
+
105
+    /**
106
+     * The Topic Taxonomy service.
107
+     *
108
+     * @since  3.5.0
109
+     * @access private
110
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
111
+     */
112
+    private $topic_taxonomy_service;
113
+
114
+    /**
115
+     * The User service.
116
+     *
117
+     * @since  3.1.7
118
+     * @access protected
119
+     * @var \Wordlift_User_Service $user_service The User service.
120
+     */
121
+    protected $user_service;
122
+
123
+    /**
124
+     * The Timeline service.
125
+     *
126
+     * @since  3.1.0
127
+     * @access private
128
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
129
+     */
130
+    private $timeline_service;
131
+
132
+    /**
133
+     * The Redirect service.
134
+     *
135
+     * @since  3.2.0
136
+     * @access private
137
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
138
+     */
139
+    private $redirect_service;
140
+
141
+    /**
142
+     * The Notice service.
143
+     *
144
+     * @since  3.3.0
145
+     * @access private
146
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
147
+     */
148
+    private $notice_service;
149
+
150
+    /**
151
+     * The Entity list customization.
152
+     *
153
+     * @since  3.3.0
154
+     * @access private
155
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
156
+     */
157
+    private $entity_list_service;
158
+
159
+    /**
160
+     * The Entity Types Taxonomy Walker.
161
+     *
162
+     * @since  3.1.0
163
+     * @access private
164
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
165
+     */
166
+    private $entity_types_taxonomy_walker;
167
+
168
+    /**
169
+     * The ShareThis service.
170
+     *
171
+     * @since  3.2.0
172
+     * @access private
173
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
174
+     */
175
+    private $sharethis_service;
176
+
177
+    /**
178
+     * The PrimaShop adapter.
179
+     *
180
+     * @since  3.2.3
181
+     * @access private
182
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
183
+     */
184
+    private $primashop_adapter;
185
+
186
+    /**
187
+     * The WordLift Dashboard adapter.
188
+     *
189
+     * @since  3.4.0
190
+     * @access private
191
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
192
+     */
193
+    private $dashboard_service;
194
+
195
+    /**
196
+     * The entity type service.
197
+     *
198
+     * @since  3.6.0
199
+     * @access private
200
+     * @var \Wordlift_Entity_Post_Type_Service
201
+     */
202
+    private $entity_post_type_service;
203
+
204
+    /**
205
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
206
+     *
207
+     * @since  3.6.0
208
+     * @access private
209
+     * @var \Wordlift_Entity_Link_Service
210
+     */
211
+    private $entity_link_service;
212
+
213
+    /**
214
+     * A {@link Wordlift_Sparql_Service} instance.
215
+     *
216
+     * @var    3.6.0
217
+     * @access protected
218
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
219
+     */
220
+    protected $sparql_service;
221
+
222
+    /**
223
+     * A {@link Wordlift_Import_Service} instance.
224
+     *
225
+     * @since  3.6.0
226
+     * @access private
227
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
228
+     */
229
+    private $import_service;
230
+
231
+    /**
232
+     * A {@link Wordlift_Rebuild_Service} instance.
233
+     *
234
+     * @since  3.6.0
235
+     * @access private
236
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
237
+     */
238
+    private $rebuild_service;
239
+
240
+    /**
241
+     * A {@link Wordlift_Jsonld_Service} instance.
242
+     *
243
+     * @since  3.7.0
244
+     * @access protected
245
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
246
+     */
247
+    protected $jsonld_service;
248
+
249
+    /**
250
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
251
+     *
252
+     * @since  3.14.0
253
+     * @access protected
254
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
255
+     */
256
+    protected $jsonld_website_converter;
257
+
258
+    /**
259
+     *
260
+     * @since  3.7.0
261
+     * @access private
262
+     * @var \Wordlift_Property_Factory $property_factory
263
+     */
264
+    private $property_factory;
265
+
266
+    /**
267
+     * The 'Download Your Data' page.
268
+     *
269
+     * @since  3.6.0
270
+     * @access private
271
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
+     */
273
+    private $download_your_data_page;
274
+
275
+    /**
276
+     * The 'WordLift Settings' page.
277
+     *
278
+     * @since  3.11.0
279
+     * @access protected
280
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
+     */
282
+    protected $settings_page;
283
+
284
+    /**
285
+     * The 'WordLift Batch analysis' page.
286
+     *
287
+     * @since  3.14.0
288
+     * @access protected
289
+     * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
+     */
291
+    protected $batch_analysis_page;
292
+
293
+    /**
294
+     * The install wizard page.
295
+     *
296
+     * @since  3.9.0
297
+     * @access private
298
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
+     */
300
+    private $admin_setup;
301
+
302
+    /**
303
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
304
+     * linking of entities to their pages.
305
+     *
306
+     * @since  3.8.0
307
+     * @access private
308
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
+     */
310
+    private $content_filter_service;
311
+
312
+    /**
313
+     * A {@link Wordlift_Key_Validation_Service} instance.
314
+     *
315
+     * @since  3.9.0
316
+     * @access private
317
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
+     */
319
+    private $key_validation_service;
320
+
321
+    /**
322
+     * A {@link Wordlift_Rating_Service} instance.
323
+     *
324
+     * @since  3.10.0
325
+     * @access private
326
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
+     */
328
+    private $rating_service;
329
+
330
+    /**
331
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
+     *
333
+     * @since  3.10.0
334
+     * @access protected
335
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
+     */
337
+    protected $post_to_jsonld_converter;
338
+
339
+    /**
340
+     * A {@link Wordlift_Configuration_Service} instance.
341
+     *
342
+     * @since  3.10.0
343
+     * @access protected
344
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
+     */
346
+    protected $configuration_service;
347
+
348
+    /**
349
+     * A {@link Wordlift_Entity_Type_Service} instance.
350
+     *
351
+     * @since  3.10.0
352
+     * @access protected
353
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
+     */
355
+    protected $entity_type_service;
356
+
357
+    /**
358
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
+     *
360
+     * @since  3.10.0
361
+     * @access protected
362
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
+     */
364
+    protected $entity_post_to_jsonld_converter;
365
+
366
+    /**
367
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
+     *
369
+     * @since  3.10.0
370
+     * @access protected
371
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
+     */
373
+    protected $postid_to_jsonld_converter;
374
+
375
+    /**
376
+     * The {@link Wordlift_Admin_Status_Page} class.
377
+     *
378
+     * @since  3.9.8
379
+     * @access private
380
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
+     */
382
+    private $status_page;
383
+
384
+    /**
385
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
+     *
387
+     * @since  3.11.0
388
+     * @access protected
389
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
+     */
391
+    protected $category_taxonomy_service;
392
+
393
+    /**
394
+     * The {@link Wordlift_Entity_Page_Service} instance.
395
+     *
396
+     * @since  3.11.0
397
+     * @access protected
398
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
+     */
400
+    protected $entity_page_service;
401
+
402
+    /**
403
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
+     *
405
+     * @since  3.11.0
406
+     * @access protected
407
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
+     */
409
+    protected $settings_page_action_link;
410
+
411
+    /**
412
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
+     *
414
+     * @since  3.11.0
415
+     * @access protected
416
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
+     */
418
+    protected $publisher_ajax_adapter;
419
+
420
+    /**
421
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
422
+     *
423
+     * @since  3.11.0
424
+     * @access protected
425
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
+     */
427
+    protected $input_element;
428
+
429
+    /**
430
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
+     *
432
+     * @since  3.13.0
433
+     * @access protected
434
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
+     */
436
+    protected $radio_input_element;
437
+
438
+    /**
439
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
+     *
441
+     * @since  3.11.0
442
+     * @access protected
443
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
+     */
445
+    protected $language_select_element;
446
+
447
+    /**
448
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
+     *
450
+     * @since  3.11.0
451
+     * @access protected
452
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
+     */
454
+    protected $publisher_element;
455
+
456
+    /**
457
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
+     *
459
+     * @since  3.11.0
460
+     * @access protected
461
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
+     */
463
+    protected $select2_element;
464
+
465
+    /**
466
+     * The controller for the entity type list admin page
467
+     *
468
+     * @since  3.11.0
469
+     * @access private
470
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
+     */
472
+    private $entity_type_admin_page;
473
+
474
+    /**
475
+     * The controller for the entity type settings admin page
476
+     *
477
+     * @since  3.11.0
478
+     * @access private
479
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
+     */
481
+    private $entity_type_settings_admin_page;
482
+
483
+    /**
484
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
+     *
486
+     * @since  3.11.0
487
+     * @access protected
488
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
+     */
490
+    protected $related_entities_cloud_widget;
491
+
492
+    /**
493
+     * The {@link Wordlift_Admin_Author_Element} instance.
494
+     *
495
+     * @since  3.14.0
496
+     * @access protected
497
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
+     */
499
+    protected $author_element;
500
+
501
+    /**
502
+     * The {@link Wordlift_Batch_Analysis_Service} instance.
503
+     *
504
+     * @since  3.14.0
505
+     * @access protected
506
+     * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
+     */
508
+    protected $batch_analysis_service;
509
+
510
+    /**
511
+     * The {@link Wordlift_Sample_Data_Service} instance.
512
+     *
513
+     * @since  3.12.0
514
+     * @access protected
515
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
+     */
517
+    protected $sample_data_service;
518
+
519
+    /**
520
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
+     *
522
+     * @since  3.12.0
523
+     * @access protected
524
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
+     */
526
+    protected $sample_data_ajax_adapter;
527
+
528
+    /**
529
+     * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
+     *
531
+     * @since  3.14.2
532
+     * @access protected
533
+     * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
+     */
535
+    private $batch_analysis_adapter;
536
+
537
+    /**
538
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
+     *
540
+     * @since  3.14.3
541
+     * @access private
542
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
+     */
544
+    private $relation_rebuild_service;
545
+
546
+    /**
547
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
+     *
549
+     * @since  3.14.3
550
+     * @access private
551
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
+     */
553
+    private $relation_rebuild_adapter;
554
+
555
+    /**
556
+     * {@link Wordlift}'s singleton instance.
557
+     *
558
+     * @since  3.15.0
559
+     * @access protected
560
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
561
+     */
562
+    protected $entity_type_adapter;
563
+
564
+    /**
565
+     * The {@link Wordlift_Linked_Data_Service} instance.
566
+     *
567
+     * @since  3.15.0
568
+     * @access protected
569
+     * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
570
+     */
571
+    protected $linked_data_service;
572
+
573
+    /**
574
+     * The {@link Wordlift_Storage_Factory} instance.
575
+     *
576
+     * @since  3.15.0
577
+     * @access protected
578
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
579
+     */
580
+    protected $storage_factory;
581
+
582
+    /**
583
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
584
+     *
585
+     * @since  3.15.0
586
+     * @access protected
587
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
588
+     */
589
+    protected $rendition_factory;
590
+
591
+    /**
592
+     * The {@link Wordlift_Autocomplete_Service} instance.
593
+     *
594
+     * @since  3.15.0
595
+     * @access private
596
+     * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
597
+     */
598
+    private $autocomplete_service;
599
+
600
+    /**
601
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
602
+     *
603
+     * @since  3.15.0
604
+     * @access private
605
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
606
+     */
607
+    private $autocomplete_adapter;
608
+
609
+    /**
610
+     * The {@link Wordlift_Relation_Service} instance.
611
+     *
612
+     * @since  3.15.0
613
+     * @access private
614
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
615
+     */
616
+    private $relation_service;
617
+
618
+    /**
619
+     * {@link Wordlift}'s singleton instance.
620
+     *
621
+     * @since  3.11.2
622
+     * @access private
623
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
624
+     */
625
+    private static $instance;
626
+
627
+    /**
628
+     * Define the core functionality of the plugin.
629
+     *
630
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
631
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
632
+     * the public-facing side of the site.
633
+     *
634
+     * @since    1.0.0
635
+     */
636
+    public function __construct() {
637
+
638
+        $this->plugin_name = 'wordlift';
639
+        $this->version     = '3.15.1';
640
+        $this->load_dependencies();
641
+        $this->set_locale();
642
+        $this->define_admin_hooks();
643
+        $this->define_public_hooks();
644
+
645
+        self::$instance = $this;
646
+
647
+    }
648
+
649
+    /**
650
+     * Get the singleton instance.
651
+     *
652
+     * @since 3.11.2
653
+     *
654
+     * @return Wordlift The {@link Wordlift} singleton instance.
655
+     */
656
+    public static function get_instance() {
657
+
658
+        return self::$instance;
659
+    }
660
+
661
+    /**
662
+     * Load the required dependencies for this plugin.
663
+     *
664
+     * Include the following files that make up the plugin:
665
+     *
666
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
667
+     * - Wordlift_i18n. Defines internationalization functionality.
668
+     * - Wordlift_Admin. Defines all hooks for the admin area.
669
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
670
+     *
671
+     * Create an instance of the loader which will be used to register the hooks
672
+     * with WordPress.
673
+     *
674
+     * @since    1.0.0
675
+     * @access   private
676
+     */
677
+    private function load_dependencies() {
678
+
679
+        /**
680
+         * The class responsible for orchestrating the actions and filters of the
681
+         * core plugin.
682
+         */
683
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
684
+
685
+        /**
686
+         * The class responsible for defining internationalization functionality
687
+         * of the plugin.
688
+         */
689
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
690
+
691
+        /**
692
+         * WordLift's supported languages.
693
+         */
694
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
695
+
696
+        /**
697
+         * Provide support functions to sanitize data.
698
+         */
699
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
700
+
701
+        /** Services. */
702
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
703
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
704
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
705
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
706
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
707
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
708
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
709
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
710
+
711
+        /**
712
+         * The Query builder.
713
+         */
714
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
715
+
716
+        /**
717
+         * The Schema service.
718
+         */
719
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
720
+
721
+        /**
722
+         * The schema:url property service.
723
+         */
724
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
725
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
726
+
727
+        /**
728
+         * The UI service.
729
+         */
730
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
731
+
732
+        /**
733
+         * The Thumbnail service.
734
+         */
735
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
736
+
737
+        /**
738
+         * The Entity Types Taxonomy service.
739
+         */
740
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
741
+
742
+        /**
743
+         * The Entity service.
744
+         */
745
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
746
+
747
+        // Add the entity rating service.
748
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
749
+
750
+        /**
751
+         * The User service.
752
+         */
753
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
754
+
755
+        /**
756
+         * The Timeline service.
757
+         */
758
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
759
+
760
+        /**
761
+         * The Topic Taxonomy service.
762
+         */
763
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
764
+
765
+        /**
766
+         * The SPARQL service.
767
+         */
768
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
769
+
770
+        /**
771
+         * The WordLift import service.
772
+         */
773
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
774
+
775
+        /**
776
+         * The WordLift URI service.
777
+         */
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
779
+
780
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
781
+
782
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
783
+
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
785
+
786
+        /**
787
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
788
+         */
789
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
790
+
791
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
792
+
793
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
794
+
795
+        /**
796
+         * Load the converters.
797
+         */
798
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
799
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
800
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
801
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
802
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
803
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
804
+
805
+        /**
806
+         * Load the content filter.
807
+         */
808
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
809
+
810
+        /*
811 811
 		 * Load the excerpt helper.
812 812
 		 */
813
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
814
-
815
-		/**
816
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
817
-		 *
818
-		 * @since 3.8.0
819
-		 */
820
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
821
-
822
-		// The Publisher Service and the AJAX adapter.
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
824
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
825
-
826
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
827
-
828
-		/**
829
-		 * Load the WordLift key validation service.
830
-		 */
831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
832
-
833
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
834
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
835
-
836
-		// Load the `Wordlift_Entity_Page_Service` class definition.
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
840
-
841
-		/** Linked Data. */
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
843
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
844
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
845
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
846
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
848
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
849
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
850
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
853
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
854
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
855
-
856
-		/** Adapters. */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
858
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
859
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
860
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
861
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
862
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
863
-
864
-		/** Async Tasks. */
865
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php';
866
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
869
-
870
-		/** Async Tasks. */
871
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
872
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
873
-
874
-		/**
875
-		 * The class responsible for defining all actions that occur in the admin area.
876
-		 */
877
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
878
-
879
-		/**
880
-		 * The class to customize the entity list admin page.
881
-		 */
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
883
-
884
-		/**
885
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
886
-		 */
887
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
888
-
889
-		/**
890
-		 * The Notice service.
891
-		 */
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
893
-
894
-		/**
895
-		 * The PrimaShop adapter.
896
-		 */
897
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
898
-
899
-		/**
900
-		 * The WordLift Dashboard service.
901
-		 */
902
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
903
-
904
-		/**
905
-		 * The admin 'Install wizard' page.
906
-		 */
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
908
-
909
-		/**
910
-		 * The WordLift entity type list admin page controller.
911
-		 */
912
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
913
-
914
-		/**
915
-		 * The WordLift entity type settings admin page controller.
916
-		 */
917
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
918
-
919
-		/**
920
-		 * The admin 'Download Your Data' page.
921
-		 */
922
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
923
-
924
-		/**
925
-		 * The admin 'Download Your Data' page.
926
-		 */
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
928
-
929
-		/**
930
-		 * The admin 'WordLift Settings' page.
931
-		 */
932
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
933
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
934
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
936
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
937
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
938
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
939
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
941
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
942
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
943
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
944
-
945
-		/** Admin Pages */
946
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
947
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
948
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
950
-
951
-		/**
952
-		 * The class responsible for defining all actions that occur in the public-facing
953
-		 * side of the site.
954
-		 */
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
956
-
957
-		/**
958
-		 * The shortcode abstract class.
959
-		 */
960
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
961
-
962
-		/**
963
-		 * The Timeline shortcode.
964
-		 */
965
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
966
-
967
-		/**
968
-		 * The Navigator shortcode.
969
-		 */
970
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
971
-
972
-		/**
973
-		 * The chord shortcode.
974
-		 */
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
976
-
977
-		/**
978
-		 * The geomap shortcode.
979
-		 */
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
981
-
982
-		/**
983
-		 * The entity cloud shortcode.
984
-		 */
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
986
-
987
-		/**
988
-		 * The ShareThis service.
989
-		 */
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
991
-
992
-		/**
993
-		 * The SEO service.
994
-		 */
995
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
996
-
997
-		/**
998
-		 * The AMP service.
999
-		 */
1000
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1001
-
1002
-		/** Widgets */
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1004
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1005
-
1006
-		$this->loader = new Wordlift_Loader();
1007
-
1008
-		// Instantiate a global logger.
1009
-		global $wl_logger;
1010
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1011
-
1012
-		/** Services. */
1013
-		// Create the configuration service.
1014
-		$this->configuration_service = new Wordlift_Configuration_Service();
1015
-
1016
-		// Create an entity type service instance. It'll be later bound to the init action.
1017
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1018
-
1019
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1020
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1021
-
1022
-		// Create an instance of the UI service.
1023
-		$this->ui_service = new Wordlift_UI_Service();
1024
-
1025
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1026
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1027
-
1028
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1029
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1030
-		$this->notice_service        = new Wordlift_Notice_Service();
1031
-		$this->relation_service      = new Wordlift_Relation_Service();
1032
-		$this->entity_service        = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service );
1033
-		$this->user_service          = new Wordlift_User_Service();
1034
-
1035
-		// Instantiate the JSON-LD service.
1036
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1037
-
1038
-		/** Linked Data. */
1039
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1040
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1041
-
1042
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1043
-
1044
-		// Create a new instance of the Redirect service.
1045
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1046
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1047
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1048
-
1049
-		// Create a new instance of the Timeline service and Timeline shortcode.
1050
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1051
-
1052
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
813
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
814
+
815
+        /**
816
+         * Load the JSON-LD service to publish entities using JSON-LD.s
817
+         *
818
+         * @since 3.8.0
819
+         */
820
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
821
+
822
+        // The Publisher Service and the AJAX adapter.
823
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
824
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
825
+
826
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
827
+
828
+        /**
829
+         * Load the WordLift key validation service.
830
+         */
831
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
832
+
833
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
834
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
835
+
836
+        // Load the `Wordlift_Entity_Page_Service` class definition.
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
838
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php';
839
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
840
+
841
+        /** Linked Data. */
842
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
843
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
844
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
845
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
846
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
847
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
848
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
849
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
850
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
851
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
853
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
854
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
855
+
856
+        /** Adapters. */
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
858
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
859
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
860
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
861
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
862
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
863
+
864
+        /** Async Tasks. */
865
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php';
866
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
867
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
868
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
869
+
870
+        /** Async Tasks. */
871
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
872
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
873
+
874
+        /**
875
+         * The class responsible for defining all actions that occur in the admin area.
876
+         */
877
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
878
+
879
+        /**
880
+         * The class to customize the entity list admin page.
881
+         */
882
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
883
+
884
+        /**
885
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
886
+         */
887
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
888
+
889
+        /**
890
+         * The Notice service.
891
+         */
892
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
893
+
894
+        /**
895
+         * The PrimaShop adapter.
896
+         */
897
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
898
+
899
+        /**
900
+         * The WordLift Dashboard service.
901
+         */
902
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
903
+
904
+        /**
905
+         * The admin 'Install wizard' page.
906
+         */
907
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
908
+
909
+        /**
910
+         * The WordLift entity type list admin page controller.
911
+         */
912
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
913
+
914
+        /**
915
+         * The WordLift entity type settings admin page controller.
916
+         */
917
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
918
+
919
+        /**
920
+         * The admin 'Download Your Data' page.
921
+         */
922
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
923
+
924
+        /**
925
+         * The admin 'Download Your Data' page.
926
+         */
927
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
928
+
929
+        /**
930
+         * The admin 'WordLift Settings' page.
931
+         */
932
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
933
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
934
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
935
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
936
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
937
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
938
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
939
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
940
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
941
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
942
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
943
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
944
+
945
+        /** Admin Pages */
946
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
947
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
948
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
949
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
950
+
951
+        /**
952
+         * The class responsible for defining all actions that occur in the public-facing
953
+         * side of the site.
954
+         */
955
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
956
+
957
+        /**
958
+         * The shortcode abstract class.
959
+         */
960
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
961
+
962
+        /**
963
+         * The Timeline shortcode.
964
+         */
965
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
966
+
967
+        /**
968
+         * The Navigator shortcode.
969
+         */
970
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
971
+
972
+        /**
973
+         * The chord shortcode.
974
+         */
975
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
976
+
977
+        /**
978
+         * The geomap shortcode.
979
+         */
980
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
981
+
982
+        /**
983
+         * The entity cloud shortcode.
984
+         */
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
986
+
987
+        /**
988
+         * The ShareThis service.
989
+         */
990
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
991
+
992
+        /**
993
+         * The SEO service.
994
+         */
995
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
996
+
997
+        /**
998
+         * The AMP service.
999
+         */
1000
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1001
+
1002
+        /** Widgets */
1003
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1004
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1005
+
1006
+        $this->loader = new Wordlift_Loader();
1007
+
1008
+        // Instantiate a global logger.
1009
+        global $wl_logger;
1010
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1011
+
1012
+        /** Services. */
1013
+        // Create the configuration service.
1014
+        $this->configuration_service = new Wordlift_Configuration_Service();
1015
+
1016
+        // Create an entity type service instance. It'll be later bound to the init action.
1017
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1018
+
1019
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1020
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1021
+
1022
+        // Create an instance of the UI service.
1023
+        $this->ui_service = new Wordlift_UI_Service();
1024
+
1025
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1026
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1027
+
1028
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1029
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1030
+        $this->notice_service        = new Wordlift_Notice_Service();
1031
+        $this->relation_service      = new Wordlift_Relation_Service();
1032
+        $this->entity_service        = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service );
1033
+        $this->user_service          = new Wordlift_User_Service();
1034
+
1035
+        // Instantiate the JSON-LD service.
1036
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1037
+
1038
+        /** Linked Data. */
1039
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1040
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1041
+
1042
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1043
+
1044
+        // Create a new instance of the Redirect service.
1045
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1046
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1047
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1048
+
1049
+        // Create a new instance of the Timeline service and Timeline shortcode.
1050
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1051
+
1052
+        $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1053 1053
 
1054
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1054
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1055 1055
 
1056
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1056
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1057 1057
 
1058
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1059
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1058
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1059
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1060 1060
 
1061
-		// Create an instance of the PrimaShop adapter.
1062
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1061
+        // Create an instance of the PrimaShop adapter.
1062
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1063 1063
 
1064
-		// Create an import service instance to hook later to WP's import function.
1065
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1064
+        // Create an import service instance to hook later to WP's import function.
1065
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1066 1066
 
1067
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1067
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1068 1068
 
1069
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1070
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1069
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1070
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1071 1071
 
1072
-		// Create the entity rating service.
1073
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1072
+        // Create the entity rating service.
1073
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1074 1074
 
1075
-		// Create entity list customization (wp-admin/edit.php)
1076
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1075
+        // Create entity list customization (wp-admin/edit.php)
1076
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1077 1077
 
1078
-		// Create a new instance of the Redirect service.
1079
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1078
+        // Create a new instance of the Redirect service.
1079
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1080 1080
 
1081
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1082
-		$publisher_service      = new Wordlift_Publisher_Service();
1083
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1084
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1081
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1082
+        $publisher_service      = new Wordlift_Publisher_Service();
1083
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1084
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1085 1085
 
1086
-		$attachment_service = new Wordlift_Attachment_Service();
1086
+        $attachment_service = new Wordlift_Attachment_Service();
1087 1087
 
1088
-		// Instantiate the JSON-LD service.
1089
-		$property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
-		$this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1091
-		$this->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1092
-		$this->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1093
-		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1094
-		$this->jsonld_service                  = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter, $this->jsonld_website_converter );
1088
+        // Instantiate the JSON-LD service.
1089
+        $property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
+        $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1091
+        $this->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1092
+        $this->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1093
+        $this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1094
+        $this->jsonld_service                  = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter, $this->jsonld_website_converter );
1095 1095
 
1096
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1097
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service );
1098
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1099
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service );
1100
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1096
+        $this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1097
+        $this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service );
1098
+        $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1099
+        $this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service );
1100
+        $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1101 1101
 
1102
-		// Initialize the shortcodes.
1103
-		new Wordlift_Navigator_Shortcode();
1104
-		new Wordlift_Chord_Shortcode();
1105
-		new Wordlift_Geomap_Shortcode();
1106
-		new Wordlift_Timeline_Shortcode();
1107
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1102
+        // Initialize the shortcodes.
1103
+        new Wordlift_Navigator_Shortcode();
1104
+        new Wordlift_Chord_Shortcode();
1105
+        new Wordlift_Geomap_Shortcode();
1106
+        new Wordlift_Timeline_Shortcode();
1107
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1108 1108
 
1109
-		// Initialize the SEO service.
1110
-		new Wordlift_Seo_Service();
1109
+        // Initialize the SEO service.
1110
+        new Wordlift_Seo_Service();
1111 1111
 
1112
-		// Initialize the AMP service.
1113
-		new Wordlift_AMP_Service();
1112
+        // Initialize the AMP service.
1113
+        new Wordlift_AMP_Service();
1114 1114
 
1115
-		/** Adapters. */
1116
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1117
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1118
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1119
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1120
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1115
+        /** Adapters. */
1116
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1117
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1118
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1119
+        $this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1120
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1121 1121
 
1122
-		/** Async Tasks. */
1123
-		new Wordlift_Sparql_Query_Async_Task();
1124
-		new Wordlift_Batch_Analysis_Request_Async_Task();
1125
-		new Wordlift_Batch_Analysis_Complete_Async_Task();
1122
+        /** Async Tasks. */
1123
+        new Wordlift_Sparql_Query_Async_Task();
1124
+        new Wordlift_Batch_Analysis_Request_Async_Task();
1125
+        new Wordlift_Batch_Analysis_Complete_Async_Task();
1126 1126
 
1127
-		/** WL Autocomplete. */
1128
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1129
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1127
+        /** WL Autocomplete. */
1128
+        $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1129
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1130 1130
 
1131
-		/** WordPress Admin UI. */
1131
+        /** WordPress Admin UI. */
1132 1132
 
1133
-		// UI elements.
1134
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1135
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1136
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1137
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1138
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1139
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1140
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1133
+        // UI elements.
1134
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1135
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1136
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1137
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1138
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1139
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1140
+        $this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1141 1141
 
1142
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1143
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1144
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1142
+        $this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1143
+        $this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1144
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1145 1145
 
1146
-		// Pages.
1147
-		new Wordlift_Admin_Post_Edit_Page( $this );
1148
-		new Wordlift_Entity_Type_Admin_Service();
1146
+        // Pages.
1147
+        new Wordlift_Admin_Post_Edit_Page( $this );
1148
+        new Wordlift_Entity_Type_Admin_Service();
1149 1149
 
1150
-		// create an instance of the entity type list admin page controller.
1151
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1150
+        // create an instance of the entity type list admin page controller.
1151
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1152 1152
 
1153
-		// create an instance of the entity type etting admin page controller.
1154
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1155
-
1156
-		/** Widgets */
1157
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1158
-
1159
-		//** WordPress Admin */
1160
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1161
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1162
-
1163
-		// Create an instance of the install wizard.
1164
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1165
-
1166
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1167
-
1168
-		// User Profile.
1169
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1170
-
1171
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1172
-
1173
-		// Load the debug service if WP is in debug mode.
1174
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1175
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1176
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1177
-		}
1178
-
1179
-	}
1180
-
1181
-	/**
1182
-	 * Define the locale for this plugin for internationalization.
1183
-	 *
1184
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1185
-	 * with WordPress.
1186
-	 *
1187
-	 * @since    1.0.0
1188
-	 * @access   private
1189
-	 */
1190
-	private function set_locale() {
1191
-
1192
-		$plugin_i18n = new Wordlift_i18n();
1193
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1194
-
1195
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1196
-
1197
-	}
1198
-
1199
-	/**
1200
-	 * Register all of the hooks related to the admin area functionality
1201
-	 * of the plugin.
1202
-	 *
1203
-	 * @since    1.0.0
1204
-	 * @access   private
1205
-	 */
1206
-	private function define_admin_hooks() {
1207
-
1208
-		$plugin_admin = new Wordlift_Admin(
1209
-			$this->get_plugin_name(),
1210
-			$this->get_version(),
1211
-			$this->configuration_service,
1212
-			$this->notice_service,
1213
-			$this->user_service
1214
-		);
1215
-
1216
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1217
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1218
-
1219
-		// Hook the init action to the Topic Taxonomy service.
1220
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1221
-
1222
-		// Hook the deleted_post_meta action to the Thumbnail service.
1223
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1224
-
1225
-		// Hook the added_post_meta action to the Thumbnail service.
1226
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1227
-
1228
-		// Hook the updated_post_meta action to the Thumbnail service.
1229
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1230
-
1231
-		// Hook the AJAX wl_timeline action to the Timeline service.
1232
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1233
-
1234
-		// Register custom allowed redirect hosts.
1235
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1236
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1237
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1238
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1239
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1240
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1241
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1242
-
1243
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1244
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1245
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1246
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1247
-
1248
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1249
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1250
-
1251
-		// Entity listing customization (wp-admin/edit.php)
1252
-		// Add custom columns
1253
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1254
-		// no explicit entity as it prevents handling of other post types.
1255
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1256
-		// Add 4W selection
1257
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1258
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1259
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1260
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1261
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1262
-
1263
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1264
-		// entities.
1265
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1266
-
1267
-		// Filter imported post meta.
1268
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1269
-
1270
-		// Notify the import service when an import starts and ends.
1271
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1272
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1273
-
1274
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1275
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1276
-
1277
-		// Hook the menu to the Download Your Data page.
1278
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1279
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1280
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1281
-
1282
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1283
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1284
-
1285
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1286
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1287
-
1288
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1289
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1290
-
1291
-		// Hook the `admin_init` function to the Admin Setup.
1292
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1293
-
1294
-		// Hook the admin_init to the settings page.
1295
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1296
-
1297
-		// Hook the menu creation on the general wordlift menu creation
1298
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1299
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1300
-			// Add the functionality only if a flag is set in wp-config.php .
1301
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1302
-		}
1303
-
1304
-		// Hook key update.
1305
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1306
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1307
-
1308
-		// Add additional action links to the WordLift plugin in the plugins page.
1309
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1310
-
1311
-		// Hook the AJAX `wl_publisher` action name.
1312
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1313
-
1314
-		// Hook row actions for the entity type list admin.
1315
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1316
-
1317
-		// Hook capabilities manipulation to allow access to entity type admin
1318
-		// page  on wordpress versions before 4.7.
1319
-		global $wp_version;
1320
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1321
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1322
-		}
1323
-
1324
-		$this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1325
-
1326
-		/** Adapters. */
1327
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1328
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1329
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1330
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1331
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1332
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1333
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1334
-
1335
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1336
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1337
-
1338
-		// Handle the autocomplete request.
1339
-		add_action( 'wp_ajax_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1340
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1341
-
1342
-		// Hooks to restrict multisite super admin from manipulating entity types.
1343
-		if ( is_multisite() ) {
1344
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1345
-		}
1346
-
1347
-	}
1348
-
1349
-	/**
1350
-	 * Register all of the hooks related to the public-facing functionality
1351
-	 * of the plugin.
1352
-	 *
1353
-	 * @since    1.0.0
1354
-	 * @access   private
1355
-	 */
1356
-	private function define_public_hooks() {
1153
+        // create an instance of the entity type etting admin page controller.
1154
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1155
+
1156
+        /** Widgets */
1157
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1158
+
1159
+        //** WordPress Admin */
1160
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1161
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1162
+
1163
+        // Create an instance of the install wizard.
1164
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1165
+
1166
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1167
+
1168
+        // User Profile.
1169
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1170
+
1171
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1172
+
1173
+        // Load the debug service if WP is in debug mode.
1174
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1175
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1176
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1177
+        }
1178
+
1179
+    }
1180
+
1181
+    /**
1182
+     * Define the locale for this plugin for internationalization.
1183
+     *
1184
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1185
+     * with WordPress.
1186
+     *
1187
+     * @since    1.0.0
1188
+     * @access   private
1189
+     */
1190
+    private function set_locale() {
1191
+
1192
+        $plugin_i18n = new Wordlift_i18n();
1193
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1194
+
1195
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1196
+
1197
+    }
1198
+
1199
+    /**
1200
+     * Register all of the hooks related to the admin area functionality
1201
+     * of the plugin.
1202
+     *
1203
+     * @since    1.0.0
1204
+     * @access   private
1205
+     */
1206
+    private function define_admin_hooks() {
1207
+
1208
+        $plugin_admin = new Wordlift_Admin(
1209
+            $this->get_plugin_name(),
1210
+            $this->get_version(),
1211
+            $this->configuration_service,
1212
+            $this->notice_service,
1213
+            $this->user_service
1214
+        );
1215
+
1216
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1217
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1218
+
1219
+        // Hook the init action to the Topic Taxonomy service.
1220
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1221
+
1222
+        // Hook the deleted_post_meta action to the Thumbnail service.
1223
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1224
+
1225
+        // Hook the added_post_meta action to the Thumbnail service.
1226
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1227
+
1228
+        // Hook the updated_post_meta action to the Thumbnail service.
1229
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1230
+
1231
+        // Hook the AJAX wl_timeline action to the Timeline service.
1232
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1233
+
1234
+        // Register custom allowed redirect hosts.
1235
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1236
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1237
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1238
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1239
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1240
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1241
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1242
+
1243
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1244
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1245
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1246
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1247
+
1248
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1249
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1250
+
1251
+        // Entity listing customization (wp-admin/edit.php)
1252
+        // Add custom columns
1253
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1254
+        // no explicit entity as it prevents handling of other post types.
1255
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1256
+        // Add 4W selection
1257
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1258
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1259
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1260
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1261
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1262
+
1263
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1264
+        // entities.
1265
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1266
+
1267
+        // Filter imported post meta.
1268
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1269
+
1270
+        // Notify the import service when an import starts and ends.
1271
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1272
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1273
+
1274
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1275
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1276
+
1277
+        // Hook the menu to the Download Your Data page.
1278
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1279
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1280
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1281
+
1282
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1283
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1284
+
1285
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1286
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1287
+
1288
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1289
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1290
+
1291
+        // Hook the `admin_init` function to the Admin Setup.
1292
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1293
+
1294
+        // Hook the admin_init to the settings page.
1295
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1296
+
1297
+        // Hook the menu creation on the general wordlift menu creation
1298
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1299
+        if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1300
+            // Add the functionality only if a flag is set in wp-config.php .
1301
+            $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1302
+        }
1303
+
1304
+        // Hook key update.
1305
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1306
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1307
+
1308
+        // Add additional action links to the WordLift plugin in the plugins page.
1309
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1310
+
1311
+        // Hook the AJAX `wl_publisher` action name.
1312
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1313
+
1314
+        // Hook row actions for the entity type list admin.
1315
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1316
+
1317
+        // Hook capabilities manipulation to allow access to entity type admin
1318
+        // page  on wordpress versions before 4.7.
1319
+        global $wp_version;
1320
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1321
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1322
+        }
1323
+
1324
+        $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1325
+
1326
+        /** Adapters. */
1327
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1328
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1329
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1330
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1331
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1332
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1333
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1334
+
1335
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1336
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1337
+
1338
+        // Handle the autocomplete request.
1339
+        add_action( 'wp_ajax_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1340
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1341
+
1342
+        // Hooks to restrict multisite super admin from manipulating entity types.
1343
+        if ( is_multisite() ) {
1344
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1345
+        }
1346
+
1347
+    }
1348
+
1349
+    /**
1350
+     * Register all of the hooks related to the public-facing functionality
1351
+     * of the plugin.
1352
+     *
1353
+     * @since    1.0.0
1354
+     * @access   private
1355
+     */
1356
+    private function define_public_hooks() {
1357 1357
 
1358
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1358
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1359 1359
 
1360
-		// Register the entity post type.
1361
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1360
+        // Register the entity post type.
1361
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1362 1362
 
1363
-		// Bind the link generation and handling hooks to the entity link service.
1364
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1365
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1366
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1367
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1363
+        // Bind the link generation and handling hooks to the entity link service.
1364
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1365
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1366
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1367
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1368 1368
 
1369
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1370
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1369
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1370
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1371 1371
 
1372
-		// Hook the content filter service to add entity links.
1373
-		$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1372
+        // Hook the content filter service to add entity links.
1373
+        $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1374 1374
 
1375
-		// Hook the AJAX wl_timeline action to the Timeline service.
1376
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1375
+        // Hook the AJAX wl_timeline action to the Timeline service.
1376
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1377 1377
 
1378
-		// Hook the ShareThis service.
1379
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1380
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1378
+        // Hook the ShareThis service.
1379
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1380
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1381 1381
 
1382
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1383
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1382
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1383
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1384 1384
 
1385
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1386
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1387
-		// to categories.
1388
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1385
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1386
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1387
+        // to categories.
1388
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1389 1389
 
1390
-		/*
1390
+        /*
1391 1391
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1392 1392
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1393 1393
 		 * order of start time.
1394 1394
 		 */
1395
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1396
-
1397
-		$this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1398
-
1399
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1400
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1401
-
1402
-	}
1403
-
1404
-	/**
1405
-	 * Run the loader to execute all of the hooks with WordPress.
1406
-	 *
1407
-	 * @since    1.0.0
1408
-	 */
1409
-	public function run() {
1410
-		$this->loader->run();
1411
-	}
1412
-
1413
-	/**
1414
-	 * The name of the plugin used to uniquely identify it within the context of
1415
-	 * WordPress and to define internationalization functionality.
1416
-	 *
1417
-	 * @since     1.0.0
1418
-	 * @return    string    The name of the plugin.
1419
-	 */
1420
-	public function get_plugin_name() {
1421
-		return $this->plugin_name;
1422
-	}
1423
-
1424
-	/**
1425
-	 * The reference to the class that orchestrates the hooks with the plugin.
1426
-	 *
1427
-	 * @since     1.0.0
1428
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1429
-	 */
1430
-	public function get_loader() {
1431
-		return $this->loader;
1432
-	}
1433
-
1434
-	/**
1435
-	 * Retrieve the version number of the plugin.
1436
-	 *
1437
-	 * @since     1.0.0
1438
-	 * @return    string    The version number of the plugin.
1439
-	 */
1440
-	public function get_version() {
1441
-		return $this->version;
1442
-	}
1395
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1396
+
1397
+        $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1398
+
1399
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1400
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1401
+
1402
+    }
1403
+
1404
+    /**
1405
+     * Run the loader to execute all of the hooks with WordPress.
1406
+     *
1407
+     * @since    1.0.0
1408
+     */
1409
+    public function run() {
1410
+        $this->loader->run();
1411
+    }
1412
+
1413
+    /**
1414
+     * The name of the plugin used to uniquely identify it within the context of
1415
+     * WordPress and to define internationalization functionality.
1416
+     *
1417
+     * @since     1.0.0
1418
+     * @return    string    The name of the plugin.
1419
+     */
1420
+    public function get_plugin_name() {
1421
+        return $this->plugin_name;
1422
+    }
1423
+
1424
+    /**
1425
+     * The reference to the class that orchestrates the hooks with the plugin.
1426
+     *
1427
+     * @since     1.0.0
1428
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1429
+     */
1430
+    public function get_loader() {
1431
+        return $this->loader;
1432
+    }
1433
+
1434
+    /**
1435
+     * Retrieve the version number of the plugin.
1436
+     *
1437
+     * @since     1.0.0
1438
+     * @return    string    The version number of the plugin.
1439
+     */
1440
+    public function get_version() {
1441
+        return $this->version;
1442
+    }
1443 1443
 
1444 1444
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-jsonld-service.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -13,158 +13,158 @@
 block discarded – undo
13 13
  */
14 14
 class Wordlift_Jsonld_Service {
15 15
 
16
-	/**
17
-	 * A {@link Wordlift_Entity_Service} instance.
18
-	 *
19
-	 * @since  3.8.0
20
-	 * @access private
21
-	 * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
22
-	 */
23
-	private $entity_service;
24
-
25
-	/**
26
-	 * A {@link Wordlift_Post_Converter} instance.
27
-	 *
28
-	 * @since  3.8.0
29
-	 * @access private
30
-	 * @var \Wordlift_Post_Converter A {@link Wordlift_Post_Converter} instance.
31
-	 */
32
-	private $converter;
33
-
34
-
35
-	/**
36
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
37
-	 *
38
-	 * @since  3.14.0
39
-	 * @access private
40
-	 * @var \Wordlift_Website_Jsonld_Converter A {@link Wordlift_Website_Jsonld_Converter} instance.
41
-	 */
42
-	private $website_converter;
43
-
44
-	/**
45
-	 * The singleton instance for the JSON-LD service.
46
-	 *
47
-	 * @since 3.15.1
48
-	 *
49
-	 * @var \Wordlift_Jsonld_Service $instance The singleton instance for the JSON-LD service.
50
-	 */
51
-	private static $instance;
52
-
53
-	/**
54
-	 * Create a JSON-LD service.
55
-	 *
56
-	 * @since 3.8.0
57
-	 *
58
-	 * @param \Wordlift_Entity_Service           $entity_service    A {@link Wordlift_Entity_Service} instance.
59
-	 * @param \Wordlift_Post_Converter           $converter         A {@link Wordlift_Uri_To_Jsonld_Converter} instance.
60
-	 * @param \Wordlift_Website_Jsonld_Converter $website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
61
-	 */
62
-	public function __construct( $entity_service, $converter, $website_converter ) {
63
-
64
-		$this->entity_service    = $entity_service;
65
-		$this->converter         = $converter;
66
-		$this->website_converter = $website_converter;
67
-
68
-		self::$instance = $this;
69
-
70
-	}
71
-
72
-	/**
73
-	 * Get the singleton instance for the JSON-LD service.
74
-	 *
75
-	 * @since 3.15.1
76
-	 *
77
-	 * @return \Wordlift_Jsonld_Service The singleton instance for the JSON-LD service.
78
-	 */
79
-	public static function get_instance() {
80
-
81
-		return self::$instance;
82
-	}
83
-
84
-	/**
85
-	 * Process calls to the AJAX 'wl_jsonld' endpoint.
86
-	 *
87
-	 * @since 3.8.0
88
-	 */
89
-	public function get() {
90
-		// Clear the buffer to be sure someone doesn't mess with our response.
91
-		//
92
-		// See https://github.com/insideout10/wordlift-plugin/issues/406.
93
-		// See https://codex.wordpress.org/AJAX_in_Plugins.
94
-		@ob_clean();
95
-
96
-		// Get the parameter from the request.
97
-		$is_homepage = isset( $_REQUEST['homepage'] );
98
-		$post_id     = isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : null;
99
-
100
-		// Send the generated JSON-LD.
101
-		wp_send_json( $this->get_jsonld( $is_homepage, $post_id ) );
102
-
103
-	}
104
-
105
-	/**
106
-	 * Get the JSON-LD.
107
-	 *
108
-	 * @since 3.15.1
109
-	 *
110
-	 * @param bool     $is_homepage Whether the JSON-LD for the homepage is being requested.
111
-	 * @param int|null $post_id     The JSON-LD for the specified {@link WP_Post} id.
112
-	 *
113
-	 * @return array A JSON-LD structure.
114
-	 */
115
-	public function get_jsonld( $is_homepage = false, $post_id = null ) {
116
-
117
-		// Tell NewRelic to ignore us, otherwise NewRelic customers might receive
118
-		// e-mails with a low apdex score.
119
-		//
120
-		// See https://github.com/insideout10/wordlift-plugin/issues/521
121
-		Wordlift_NewRelic_Adapter::ignore_apdex();
122
-
123
-		// Switch to Website converter if is home page.
124
-		if ( $is_homepage ) {
125
-			/**
126
-			 * Filter: 'wordlift_disable_website_json_ld' - Allow disabling of the json+ld output.
127
-			 *
128
-			 * @since  3.14.0
129
-			 * @api    bool $display_search Whether or not to display json+ld search on the frontend.
130
-			 */
131
-			if ( ! apply_filters( 'wordlift_disable_website_json_ld', false ) ) {
132
-				// Set a reference to the website_converter.
133
-				$website_converter = $this->website_converter;
134
-
135
-				// Send JSON-LD.
136
-				return $website_converter->create_schema();
137
-			}
138
-		}
139
-
140
-		// If no id has been provided return an empty array.
141
-		if ( ! isset( $post_id ) ) {
142
-			return array();
143
-		}
144
-
145
-		// An array of references which is captured when converting an URI to a
146
-		// json which we gather to further expand our json-ld.
147
-		$references = array();
148
-
149
-		// Set a reference to the entity_to_jsonld_converter to use in the closures.
150
-		$entity_to_jsonld_converter = $this->converter;
151
-
152
-		// Convert each URI to a JSON-LD array, while gathering referenced entities.
153
-		// in the references array.
154
-		$jsonld = array_merge(
155
-			array( $entity_to_jsonld_converter->convert( $post_id, $references ) ),
156
-			// Convert each URI in the references array to JSON-LD. We don't output
157
-			// entities already output above (hence the array_diff).
158
-			array_map( function ( $item ) use ( $entity_to_jsonld_converter, $references ) {
159
-
160
-				// "2nd level properties" may not output here, e.g. a post
161
-				// mentioning an event, located in a place: the place is referenced
162
-				// via the `@id` but no other properties are loaded.
163
-				return $entity_to_jsonld_converter->convert( $item, $references );
164
-			}, $references ) );
165
-
166
-		// Finally send the JSON-LD.
167
-		return $jsonld;
168
-	}
16
+    /**
17
+     * A {@link Wordlift_Entity_Service} instance.
18
+     *
19
+     * @since  3.8.0
20
+     * @access private
21
+     * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
22
+     */
23
+    private $entity_service;
24
+
25
+    /**
26
+     * A {@link Wordlift_Post_Converter} instance.
27
+     *
28
+     * @since  3.8.0
29
+     * @access private
30
+     * @var \Wordlift_Post_Converter A {@link Wordlift_Post_Converter} instance.
31
+     */
32
+    private $converter;
33
+
34
+
35
+    /**
36
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
37
+     *
38
+     * @since  3.14.0
39
+     * @access private
40
+     * @var \Wordlift_Website_Jsonld_Converter A {@link Wordlift_Website_Jsonld_Converter} instance.
41
+     */
42
+    private $website_converter;
43
+
44
+    /**
45
+     * The singleton instance for the JSON-LD service.
46
+     *
47
+     * @since 3.15.1
48
+     *
49
+     * @var \Wordlift_Jsonld_Service $instance The singleton instance for the JSON-LD service.
50
+     */
51
+    private static $instance;
52
+
53
+    /**
54
+     * Create a JSON-LD service.
55
+     *
56
+     * @since 3.8.0
57
+     *
58
+     * @param \Wordlift_Entity_Service           $entity_service    A {@link Wordlift_Entity_Service} instance.
59
+     * @param \Wordlift_Post_Converter           $converter         A {@link Wordlift_Uri_To_Jsonld_Converter} instance.
60
+     * @param \Wordlift_Website_Jsonld_Converter $website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
61
+     */
62
+    public function __construct( $entity_service, $converter, $website_converter ) {
63
+
64
+        $this->entity_service    = $entity_service;
65
+        $this->converter         = $converter;
66
+        $this->website_converter = $website_converter;
67
+
68
+        self::$instance = $this;
69
+
70
+    }
71
+
72
+    /**
73
+     * Get the singleton instance for the JSON-LD service.
74
+     *
75
+     * @since 3.15.1
76
+     *
77
+     * @return \Wordlift_Jsonld_Service The singleton instance for the JSON-LD service.
78
+     */
79
+    public static function get_instance() {
80
+
81
+        return self::$instance;
82
+    }
83
+
84
+    /**
85
+     * Process calls to the AJAX 'wl_jsonld' endpoint.
86
+     *
87
+     * @since 3.8.0
88
+     */
89
+    public function get() {
90
+        // Clear the buffer to be sure someone doesn't mess with our response.
91
+        //
92
+        // See https://github.com/insideout10/wordlift-plugin/issues/406.
93
+        // See https://codex.wordpress.org/AJAX_in_Plugins.
94
+        @ob_clean();
95
+
96
+        // Get the parameter from the request.
97
+        $is_homepage = isset( $_REQUEST['homepage'] );
98
+        $post_id     = isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : null;
99
+
100
+        // Send the generated JSON-LD.
101
+        wp_send_json( $this->get_jsonld( $is_homepage, $post_id ) );
102
+
103
+    }
104
+
105
+    /**
106
+     * Get the JSON-LD.
107
+     *
108
+     * @since 3.15.1
109
+     *
110
+     * @param bool     $is_homepage Whether the JSON-LD for the homepage is being requested.
111
+     * @param int|null $post_id     The JSON-LD for the specified {@link WP_Post} id.
112
+     *
113
+     * @return array A JSON-LD structure.
114
+     */
115
+    public function get_jsonld( $is_homepage = false, $post_id = null ) {
116
+
117
+        // Tell NewRelic to ignore us, otherwise NewRelic customers might receive
118
+        // e-mails with a low apdex score.
119
+        //
120
+        // See https://github.com/insideout10/wordlift-plugin/issues/521
121
+        Wordlift_NewRelic_Adapter::ignore_apdex();
122
+
123
+        // Switch to Website converter if is home page.
124
+        if ( $is_homepage ) {
125
+            /**
126
+             * Filter: 'wordlift_disable_website_json_ld' - Allow disabling of the json+ld output.
127
+             *
128
+             * @since  3.14.0
129
+             * @api    bool $display_search Whether or not to display json+ld search on the frontend.
130
+             */
131
+            if ( ! apply_filters( 'wordlift_disable_website_json_ld', false ) ) {
132
+                // Set a reference to the website_converter.
133
+                $website_converter = $this->website_converter;
134
+
135
+                // Send JSON-LD.
136
+                return $website_converter->create_schema();
137
+            }
138
+        }
139
+
140
+        // If no id has been provided return an empty array.
141
+        if ( ! isset( $post_id ) ) {
142
+            return array();
143
+        }
144
+
145
+        // An array of references which is captured when converting an URI to a
146
+        // json which we gather to further expand our json-ld.
147
+        $references = array();
148
+
149
+        // Set a reference to the entity_to_jsonld_converter to use in the closures.
150
+        $entity_to_jsonld_converter = $this->converter;
151
+
152
+        // Convert each URI to a JSON-LD array, while gathering referenced entities.
153
+        // in the references array.
154
+        $jsonld = array_merge(
155
+            array( $entity_to_jsonld_converter->convert( $post_id, $references ) ),
156
+            // Convert each URI in the references array to JSON-LD. We don't output
157
+            // entities already output above (hence the array_diff).
158
+            array_map( function ( $item ) use ( $entity_to_jsonld_converter, $references ) {
159
+
160
+                // "2nd level properties" may not output here, e.g. a post
161
+                // mentioning an event, located in a place: the place is referenced
162
+                // via the `@id` but no other properties are loaded.
163
+                return $entity_to_jsonld_converter->convert( $item, $references );
164
+            }, $references ) );
165
+
166
+        // Finally send the JSON-LD.
167
+        return $jsonld;
168
+    }
169 169
 
170 170
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param \Wordlift_Post_Converter           $converter         A {@link Wordlift_Uri_To_Jsonld_Converter} instance.
60 60
 	 * @param \Wordlift_Website_Jsonld_Converter $website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
61 61
 	 */
62
-	public function __construct( $entity_service, $converter, $website_converter ) {
62
+	public function __construct($entity_service, $converter, $website_converter) {
63 63
 
64 64
 		$this->entity_service    = $entity_service;
65 65
 		$this->converter         = $converter;
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 		@ob_clean();
95 95
 
96 96
 		// Get the parameter from the request.
97
-		$is_homepage = isset( $_REQUEST['homepage'] );
98
-		$post_id     = isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : null;
97
+		$is_homepage = isset($_REQUEST['homepage']);
98
+		$post_id     = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
99 99
 
100 100
 		// Send the generated JSON-LD.
101
-		wp_send_json( $this->get_jsonld( $is_homepage, $post_id ) );
101
+		wp_send_json($this->get_jsonld($is_homepage, $post_id));
102 102
 
103 103
 	}
104 104
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return array A JSON-LD structure.
114 114
 	 */
115
-	public function get_jsonld( $is_homepage = false, $post_id = null ) {
115
+	public function get_jsonld($is_homepage = false, $post_id = null) {
116 116
 
117 117
 		// Tell NewRelic to ignore us, otherwise NewRelic customers might receive
118 118
 		// e-mails with a low apdex score.
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 		Wordlift_NewRelic_Adapter::ignore_apdex();
122 122
 
123 123
 		// Switch to Website converter if is home page.
124
-		if ( $is_homepage ) {
124
+		if ($is_homepage) {
125 125
 			/**
126 126
 			 * Filter: 'wordlift_disable_website_json_ld' - Allow disabling of the json+ld output.
127 127
 			 *
128 128
 			 * @since  3.14.0
129 129
 			 * @api    bool $display_search Whether or not to display json+ld search on the frontend.
130 130
 			 */
131
-			if ( ! apply_filters( 'wordlift_disable_website_json_ld', false ) ) {
131
+			if ( ! apply_filters('wordlift_disable_website_json_ld', false)) {
132 132
 				// Set a reference to the website_converter.
133 133
 				$website_converter = $this->website_converter;
134 134
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		}
139 139
 
140 140
 		// If no id has been provided return an empty array.
141
-		if ( ! isset( $post_id ) ) {
141
+		if ( ! isset($post_id)) {
142 142
 			return array();
143 143
 		}
144 144
 
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
 		// Convert each URI to a JSON-LD array, while gathering referenced entities.
153 153
 		// in the references array.
154 154
 		$jsonld = array_merge(
155
-			array( $entity_to_jsonld_converter->convert( $post_id, $references ) ),
155
+			array($entity_to_jsonld_converter->convert($post_id, $references)),
156 156
 			// Convert each URI in the references array to JSON-LD. We don't output
157 157
 			// entities already output above (hence the array_diff).
158
-			array_map( function ( $item ) use ( $entity_to_jsonld_converter, $references ) {
158
+			array_map(function($item) use ($entity_to_jsonld_converter, $references) {
159 159
 
160 160
 				// "2nd level properties" may not output here, e.g. a post
161 161
 				// mentioning an event, located in a place: the place is referenced
162 162
 				// via the `@id` but no other properties are loaded.
163
-				return $entity_to_jsonld_converter->convert( $item, $references );
164
-			}, $references ) );
163
+				return $entity_to_jsonld_converter->convert($item, $references);
164
+			}, $references) );
165 165
 
166 166
 		// Finally send the JSON-LD.
167 167
 		return $jsonld;
Please login to merge, or discard this patch.