Completed
Push — develop ( af6205...8b9ef1 )
by
unknown
28s queued 11s
created
src/modules/linked_data/wordlift_linked_data.php 2 patches
Indentation   +400 added lines, -400 removed lines patch added patch discarded remove patch
@@ -17,60 +17,60 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function wl_linked_data_save_post( $post_id ) {
19 19
 
20
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
21
-
22
-	$log->trace( "Saving post $post_id to Linked Data..." );
23
-
24
-	// If it's not numeric exit from here.
25
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
26
-		$log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
27
-
28
-		return;
29
-	}
30
-
31
-	// Get the post type and check whether it supports the editor.
32
-	//
33
-	// @see https://github.com/insideout10/wordlift-plugin/issues/659.
34
-	$post_type = get_post_type( $post_id );
35
-	/**
36
-	 * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
37
-	 *
38
-	 * @since 3.19.4
39
-	 *
40
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/847.
41
-	 */
42
-	$is_editor_supported = wl_post_type_supports_editor( $post_type );
43
-
44
-	// Bail out if it's not an entity.
45
-	if ( ! $is_editor_supported ) {
46
-		$log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
47
-
48
-		return;
49
-	}
50
-
51
-	/**
52
-	 * Only process valid post types
53
-	 *
54
-	 * @since 3.25.6
55
-	 *
56
-	 */
57
-	$supported_types = Wordlift_Entity_Service::valid_entity_post_types();
58
-
59
-	// Bail out if it's not a valid entity.
60
-	if ( ! in_array( $post_type, $supported_types ) ) {
61
-		$log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
62
-
63
-		return;
64
-	}
65
-
66
-	// Unhook this function so it doesn't loop infinitely.
67
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
68
-
69
-	// raise the *wl_linked_data_save_post* event.
70
-	do_action( 'wl_linked_data_save_post', $post_id );
71
-
72
-	// Re-hook this function.
73
-	add_action( 'save_post', 'wl_linked_data_save_post' );
20
+    $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
21
+
22
+    $log->trace( "Saving post $post_id to Linked Data..." );
23
+
24
+    // If it's not numeric exit from here.
25
+    if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
26
+        $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
27
+
28
+        return;
29
+    }
30
+
31
+    // Get the post type and check whether it supports the editor.
32
+    //
33
+    // @see https://github.com/insideout10/wordlift-plugin/issues/659.
34
+    $post_type = get_post_type( $post_id );
35
+    /**
36
+     * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
37
+     *
38
+     * @since 3.19.4
39
+     *
40
+     * @see https://github.com/insideout10/wordlift-plugin/issues/847.
41
+     */
42
+    $is_editor_supported = wl_post_type_supports_editor( $post_type );
43
+
44
+    // Bail out if it's not an entity.
45
+    if ( ! $is_editor_supported ) {
46
+        $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
47
+
48
+        return;
49
+    }
50
+
51
+    /**
52
+     * Only process valid post types
53
+     *
54
+     * @since 3.25.6
55
+     *
56
+     */
57
+    $supported_types = Wordlift_Entity_Service::valid_entity_post_types();
58
+
59
+    // Bail out if it's not a valid entity.
60
+    if ( ! in_array( $post_type, $supported_types ) ) {
61
+        $log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
62
+
63
+        return;
64
+    }
65
+
66
+    // Unhook this function so it doesn't loop infinitely.
67
+    remove_action( 'save_post', 'wl_linked_data_save_post' );
68
+
69
+    // raise the *wl_linked_data_save_post* event.
70
+    do_action( 'wl_linked_data_save_post', $post_id );
71
+
72
+    // Re-hook this function.
73
+    add_action( 'save_post', 'wl_linked_data_save_post' );
74 74
 }
75 75
 
76 76
 add_action( 'save_post', 'wl_linked_data_save_post' );
@@ -85,165 +85,165 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function wl_linked_data_save_post_and_related_entities( $post_id ) {
87 87
 
88
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
88
+    $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
89 89
 
90
-	$log->trace( "Saving $post_id to Linked Data along with related entities..." );
90
+    $log->trace( "Saving $post_id to Linked Data along with related entities..." );
91 91
 
92
-	// Ignore auto-saves
93
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
94
-		$log->trace( 'Doing autosave, skipping...' );
92
+    // Ignore auto-saves
93
+    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
94
+        $log->trace( 'Doing autosave, skipping...' );
95 95
 
96
-		return;
97
-	}
96
+        return;
97
+    }
98 98
 
99
-	// get the current post.
100
-	$post = get_post( $post_id );
99
+    // get the current post.
100
+    $post = get_post( $post_id );
101 101
 
102
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
102
+    remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
103 103
 
104
-	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
104
+    // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
105 105
 
106
-	// Get the entity service instance.
107
-	$entity_service = Wordlift_Entity_Service::get_instance();
106
+    // Get the entity service instance.
107
+    $entity_service = Wordlift_Entity_Service::get_instance();
108 108
 
109
-	// Store mapping between tmp new entities uris and real new entities uri
110
-	$entities_uri_mapping = array();
109
+    // Store mapping between tmp new entities uris and real new entities uri
110
+    $entities_uri_mapping = array();
111 111
 
112
-	// Save the entities coming with POST data.
113
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
112
+    // Save the entities coming with POST data.
113
+    if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
114 114
 
115
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
116
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
117
-		wl_write_log( "]" );
118
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
119
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
120
-		wl_write_log( "]" );
115
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
116
+        wl_write_log( json_encode( $_POST['wl_entities'] ) );
117
+        wl_write_log( "]" );
118
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
119
+        wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
120
+        wl_write_log( "]" );
121 121
 
122
-		$entities_via_post = $_POST['wl_entities'];
123
-		$boxes_via_post    = $_POST['wl_boxes'];
122
+        $entities_via_post = $_POST['wl_entities'];
123
+        $boxes_via_post    = $_POST['wl_boxes'];
124 124
 
125
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
125
+        foreach ( $entities_via_post as $entity_uri => $entity ) {
126 126
 
127
-			// Only if the current entity is created from scratch let's avoid to
128
-			// create more than one entity with same label & entity type.
129
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
130
-				$entity['main_type'] : null;
127
+            // Only if the current entity is created from scratch let's avoid to
128
+            // create more than one entity with same label & entity type.
129
+            $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
130
+                $entity['main_type'] : null;
131 131
 
132
-			// Look if current entity uri matches an internal existing entity, meaning:
133
-			// 1. when $entity_uri is an internal uri
134
-			// 2. when $entity_uri is an external uri used as sameAs of an internal entity
135
-			$ie = $entity_service->get_entity_post_by_uri( $entity_uri );
132
+            // Look if current entity uri matches an internal existing entity, meaning:
133
+            // 1. when $entity_uri is an internal uri
134
+            // 2. when $entity_uri is an external uri used as sameAs of an internal entity
135
+            $ie = $entity_service->get_entity_post_by_uri( $entity_uri );
136 136
 
137
-			// Detect the uri depending if is an existing or a new entity
138
-			$uri = ( null === $ie ) ?
139
-				Wordlift_Uri_Service::get_instance()->build_uri(
140
-					$entity['label'],
141
-					Wordlift_Entity_Service::TYPE_NAME,
142
-					$entity_type
143
-				) : wl_get_entity_uri( $ie->ID );
137
+            // Detect the uri depending if is an existing or a new entity
138
+            $uri = ( null === $ie ) ?
139
+                Wordlift_Uri_Service::get_instance()->build_uri(
140
+                    $entity['label'],
141
+                    Wordlift_Entity_Service::TYPE_NAME,
142
+                    $entity_type
143
+                ) : wl_get_entity_uri( $ie->ID );
144 144
 
145
-			wl_write_log( "Map $entity_uri on $uri" );
146
-			$entities_uri_mapping[ $entity_uri ] = $uri;
145
+            wl_write_log( "Map $entity_uri on $uri" );
146
+            $entities_uri_mapping[ $entity_uri ] = $uri;
147 147
 
148
-			// Local entities have a tmp uri with 'local-entity-' prefix
149
-			// These uris need to be rewritten here and replaced in the content
150
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
151
-				// Override the entity obj
152
-				$entity['uri'] = $uri;
153
-			}
148
+            // Local entities have a tmp uri with 'local-entity-' prefix
149
+            // These uris need to be rewritten here and replaced in the content
150
+            if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
151
+                // Override the entity obj
152
+                $entity['uri'] = $uri;
153
+            }
154 154
 
155
-			// Update entity data with related post
156
-			$entity['related_post_id'] = $post_id;
155
+            // Update entity data with related post
156
+            $entity['related_post_id'] = $post_id;
157 157
 
158
-			// Save the entity if is a new entity
159
-			if ( null === $ie ) {
160
-				wl_save_entity( $entity );
161
-			}
158
+            // Save the entity if is a new entity
159
+            if ( null === $ie ) {
160
+                wl_save_entity( $entity );
161
+            }
162 162
 
163
-		}
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167
-	// Replace tmp uris in content post if needed
168
-	$updated_post_content = $post->post_content;
167
+    // Replace tmp uris in content post if needed
168
+    $updated_post_content = $post->post_content;
169 169
 
170
-	// Update the post content if we found mappings of new entities.
171
-	if ( ! empty( $entities_uri_mapping ) ) {
172
-		// Save each entity and store the post id.
173
-		foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
174
-			if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
175
-				continue;
176
-			}
170
+    // Update the post content if we found mappings of new entities.
171
+    if ( ! empty( $entities_uri_mapping ) ) {
172
+        // Save each entity and store the post id.
173
+        foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
174
+            if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
175
+                continue;
176
+            }
177 177
 
178
-			$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
179
-		}
178
+            $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
179
+        }
180 180
 
181
-		// Update the post content.
182
-		/**
183
-		 * Note: wp_update_post do stripslashes before saving the
184
-		 * content, so add the slashes to prevent back slash getting
185
-		 * removed.
186
-		 */
187
-		wp_update_post( array(
188
-			'ID'           => $post->ID,
189
-			'post_content' => addslashes( $updated_post_content ),
190
-		) );
191
-	}
192
-
193
-	// Extract related/referenced entities from text.
194
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
195
-
196
-	// Reset previously saved instances.
197
-	wl_core_delete_relation_instances( $post_id );
198
-
199
-	// Save relation instances
200
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
201
-
202
-		wl_core_add_relation_instance(
203
-			$post_id,
204
-			$entity_service->get_classification_scope_for( $referenced_entity_id ),
205
-			$referenced_entity_id
206
-		);
207
-
208
-	}
209
-
210
-	if ( isset( $_POST['wl_entities'] ) ) {
211
-		// Save post metadata if available
212
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
213
-			$_POST['wl_metadata'] : array();
214
-
215
-		$fields = array(
216
-			Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
217
-			Wordlift_Schema_Service::FIELD_TOPIC,
218
-		);
219
-
220
-		// Unlink topic taxonomy terms
221
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
222
-
223
-		foreach ( $fields as $field ) {
224
-
225
-			// Delete current values
226
-			delete_post_meta( $post->ID, $field );
227
-			// Retrieve the entity uri
228
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
229
-				stripslashes( $metadata_via_post[ $field ] ) : '';
230
-
231
-			$entity = $entity_service->get_entity_post_by_uri( $uri );
232
-
233
-			if ( $entity ) {
234
-				add_post_meta( $post->ID, $field, $entity->ID, true );
235
-				// Set also the topic taxonomy
236
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
237
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
238
-				}
239
-			}
240
-		}
241
-	}
242
-
243
-	// Push the post to Redlink.
244
-	do_action( 'wl_legacy_linked_data__push', $post->ID );
245
-
246
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
181
+        // Update the post content.
182
+        /**
183
+         * Note: wp_update_post do stripslashes before saving the
184
+         * content, so add the slashes to prevent back slash getting
185
+         * removed.
186
+         */
187
+        wp_update_post( array(
188
+            'ID'           => $post->ID,
189
+            'post_content' => addslashes( $updated_post_content ),
190
+        ) );
191
+    }
192
+
193
+    // Extract related/referenced entities from text.
194
+    $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
195
+
196
+    // Reset previously saved instances.
197
+    wl_core_delete_relation_instances( $post_id );
198
+
199
+    // Save relation instances
200
+    foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
201
+
202
+        wl_core_add_relation_instance(
203
+            $post_id,
204
+            $entity_service->get_classification_scope_for( $referenced_entity_id ),
205
+            $referenced_entity_id
206
+        );
207
+
208
+    }
209
+
210
+    if ( isset( $_POST['wl_entities'] ) ) {
211
+        // Save post metadata if available
212
+        $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
213
+            $_POST['wl_metadata'] : array();
214
+
215
+        $fields = array(
216
+            Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
217
+            Wordlift_Schema_Service::FIELD_TOPIC,
218
+        );
219
+
220
+        // Unlink topic taxonomy terms
221
+        Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
222
+
223
+        foreach ( $fields as $field ) {
224
+
225
+            // Delete current values
226
+            delete_post_meta( $post->ID, $field );
227
+            // Retrieve the entity uri
228
+            $uri = ( isset( $metadata_via_post[ $field ] ) ) ?
229
+                stripslashes( $metadata_via_post[ $field ] ) : '';
230
+
231
+            $entity = $entity_service->get_entity_post_by_uri( $uri );
232
+
233
+            if ( $entity ) {
234
+                add_post_meta( $post->ID, $field, $entity->ID, true );
235
+                // Set also the topic taxonomy
236
+                if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
237
+                    Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
238
+                }
239
+            }
240
+        }
241
+    }
242
+
243
+    // Push the post to Redlink.
244
+    do_action( 'wl_legacy_linked_data__push', $post->ID );
245
+
246
+    add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
247 247
 }
248 248
 
249 249
 add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
@@ -266,203 +266,203 @@  discard block
 block discarded – undo
266 266
  */
267 267
 function wl_save_entity( $entity_data ) {
268 268
 
269
-	// Required for REST API calls
270
-	if ( ! function_exists( 'wp_crop_image' ) ) {
271
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
272
-	}
269
+    // Required for REST API calls
270
+    if ( ! function_exists( 'wp_crop_image' ) ) {
271
+        require_once( ABSPATH . 'wp-admin/includes/image.php' );
272
+    }
273 273
 
274
-	$log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
274
+    $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
275 275
 
276
-	$uri = $entity_data['uri'];
277
-	/*
276
+    $uri = $entity_data['uri'];
277
+    /*
278 278
 	 * Data is coming from a $_POST, sanitize it.
279 279
 	 *
280 280
 	 * @since 3.19.4
281 281
 	 *
282 282
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/841
283 283
 	 */
284
-	$label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
285
-	$type_uri         = $entity_data['main_type'];
286
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
287
-	$description      = $entity_data['description'];
288
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
289
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
290
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
291
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
292
-
293
-	// Get the synonyms.
294
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
295
-
296
-	// Check whether an entity already exists with the provided URI.
297
-	if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
298
-		$log->debug( "Post already exists for URI $uri." );
299
-
300
-		return $post;
301
-	}
302
-
303
-	// Prepare properties of the new entity.
304
-	$params = array(
305
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
306
-		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
307
-		'post_title'   => $label,
308
-		'post_content' => $description,
309
-		'post_excerpt' => '',
310
-		// Ensure we're using a valid slug. We're not overwriting an existing
311
-		// entity with a post_name already set, since this call is made only for
312
-		// new entities.
313
-		//
314
-		// See https://github.com/insideout10/wordlift-plugin/issues/282
315
-		'post_name'    => sanitize_title( $label ),
316
-	);
317
-
318
-	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
319
-	// the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
320
-	// Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
321
-	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
322
-	// is created when saving a post.
323
-	global $wpseo_metabox, $seo_ultimate;
324
-	if ( isset( $wpseo_metabox ) ) {
325
-		remove_action( 'wp_insert_post', array(
326
-			$wpseo_metabox,
327
-			'save_postdata',
328
-		) );
329
-	}
330
-
331
-	if ( isset( $seo_ultimate ) ) {
332
-		remove_action( 'save_post', array(
333
-			$seo_ultimate,
334
-			'save_postmeta_box',
335
-		) );
336
-	}
337
-
338
-	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
339
-	// save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
340
-	// to the save_post and restore them after we saved the entity.
341
-	// see https://github.com/insideout10/wordlift-plugin/issues/203
342
-	// see https://github.com/insideout10/wordlift-plugin/issues/156
343
-	// see https://github.com/insideout10/wordlift-plugin/issues/148
344
-	global $wp_filter;
345
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
346
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
347
-
348
-
349
-	$log->trace( 'Going to insert new post...' );
350
-
351
-	// create or update the post.
352
-	$post_id = wp_insert_post( $params, true );
353
-
354
-	// Setting the alternative labels for this entity.
355
-	Wordlift_Entity_Service::get_instance()
356
-	                       ->set_alternative_labels( $post_id, $synonyms );
357
-
358
-	// Restore all the existing filters.
359
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
360
-
361
-	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
362
-	if ( isset( $wpseo_metabox ) ) {
363
-		add_action( 'wp_insert_post', array(
364
-			$wpseo_metabox,
365
-			'save_postdata',
366
-		) );
367
-	}
368
-
369
-	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
370
-	if ( isset( $seo_ultimate ) ) {
371
-		add_action( 'save_post', array(
372
-			$seo_ultimate,
373
-			'save_postmeta_box',
374
-		), 10, 2 );
375
-	}
376
-
377
-	// TODO: handle errors.
378
-	if ( is_wp_error( $post_id ) ) {
379
-		$log->error( 'An error occurred: ' . $post_id->get_error_message() );
380
-
381
-		// inform an error occurred.
382
-		return null;
383
-	}
384
-
385
-	wl_set_entity_main_type( $post_id, $type_uri );
386
-
387
-	// Save the entity types.
388
-	wl_set_entity_rdf_types( $post_id, $entity_types );
389
-
390
-	// Get a dataset URI for the entity.
391
-	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
392
-
393
-	// Add the uri to the sameAs data if it's not a local URI.
394
-	if ( $wl_uri !== $uri ) {
395
-		array_push( $same_as, $uri );
396
-	}
397
-
398
-	// Save the sameAs data for the entity.
399
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
400
-
401
-	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
402
-	foreach ( $other_properties as $property_name => $property_value ) {
403
-		wl_schema_set_value( $post_id, $property_name, $property_value );
404
-	}
405
-
406
-	// Call hooks.
407
-	do_action( 'wl_save_entity', $post_id );
408
-
409
-	foreach ( $images as $image_remote_url ) {
410
-
411
-		// Check if image is already present in local DB
412
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
413
-			// Do nothing.
414
-			continue;
415
-		}
416
-
417
-		// Check if there is an existing attachment for this post ID and source URL.
418
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
419
-
420
-		// Skip if an existing image is found.
421
-		if ( null !== $existing_image ) {
422
-			continue;
423
-		}
424
-
425
-		// Save the image and get the local path.
426
-		$image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
427
-
428
-		if ( false === $image || is_wp_error( $image ) ) {
429
-			continue;
430
-		}
431
-
432
-		// Get the local URL.
433
-		$filename     = $image['path'];
434
-		$url          = $image['url'];
435
-		$content_type = $image['content_type'];
436
-
437
-		$attachment = array(
438
-			'guid'           => $url,
439
-			// post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
440
-			'post_title'     => $label,
441
-			// Set the title to the post title.
442
-			'post_content'   => '',
443
-			'post_status'    => 'inherit',
444
-			'post_mime_type' => $content_type,
445
-		);
284
+    $label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
285
+    $type_uri         = $entity_data['main_type'];
286
+    $entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
287
+    $description      = $entity_data['description'];
288
+    $images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
289
+    $same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
290
+    $related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
291
+    $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
292
+
293
+    // Get the synonyms.
294
+    $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
295
+
296
+    // Check whether an entity already exists with the provided URI.
297
+    if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
298
+        $log->debug( "Post already exists for URI $uri." );
299
+
300
+        return $post;
301
+    }
302
+
303
+    // Prepare properties of the new entity.
304
+    $params = array(
305
+        'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
306
+        'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
307
+        'post_title'   => $label,
308
+        'post_content' => $description,
309
+        'post_excerpt' => '',
310
+        // Ensure we're using a valid slug. We're not overwriting an existing
311
+        // entity with a post_name already set, since this call is made only for
312
+        // new entities.
313
+        //
314
+        // See https://github.com/insideout10/wordlift-plugin/issues/282
315
+        'post_name'    => sanitize_title( $label ),
316
+    );
317
+
318
+    // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
319
+    // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
320
+    // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
321
+    // This does NOT affect saving an entity from the entity admin page since this function is called when an entity
322
+    // is created when saving a post.
323
+    global $wpseo_metabox, $seo_ultimate;
324
+    if ( isset( $wpseo_metabox ) ) {
325
+        remove_action( 'wp_insert_post', array(
326
+            $wpseo_metabox,
327
+            'save_postdata',
328
+        ) );
329
+    }
330
+
331
+    if ( isset( $seo_ultimate ) ) {
332
+        remove_action( 'save_post', array(
333
+            $seo_ultimate,
334
+            'save_postmeta_box',
335
+        ) );
336
+    }
337
+
338
+    // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
339
+    // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
340
+    // to the save_post and restore them after we saved the entity.
341
+    // see https://github.com/insideout10/wordlift-plugin/issues/203
342
+    // see https://github.com/insideout10/wordlift-plugin/issues/156
343
+    // see https://github.com/insideout10/wordlift-plugin/issues/148
344
+    global $wp_filter;
345
+    $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
346
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
347
+
348
+
349
+    $log->trace( 'Going to insert new post...' );
350
+
351
+    // create or update the post.
352
+    $post_id = wp_insert_post( $params, true );
353
+
354
+    // Setting the alternative labels for this entity.
355
+    Wordlift_Entity_Service::get_instance()
356
+                            ->set_alternative_labels( $post_id, $synonyms );
357
+
358
+    // Restore all the existing filters.
359
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
360
+
361
+    // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
362
+    if ( isset( $wpseo_metabox ) ) {
363
+        add_action( 'wp_insert_post', array(
364
+            $wpseo_metabox,
365
+            'save_postdata',
366
+        ) );
367
+    }
368
+
369
+    // If SEO Ultimate is installed, add back the hook we removed a few lines above.
370
+    if ( isset( $seo_ultimate ) ) {
371
+        add_action( 'save_post', array(
372
+            $seo_ultimate,
373
+            'save_postmeta_box',
374
+        ), 10, 2 );
375
+    }
376
+
377
+    // TODO: handle errors.
378
+    if ( is_wp_error( $post_id ) ) {
379
+        $log->error( 'An error occurred: ' . $post_id->get_error_message() );
380
+
381
+        // inform an error occurred.
382
+        return null;
383
+    }
384
+
385
+    wl_set_entity_main_type( $post_id, $type_uri );
386
+
387
+    // Save the entity types.
388
+    wl_set_entity_rdf_types( $post_id, $entity_types );
389
+
390
+    // Get a dataset URI for the entity.
391
+    $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
392
+
393
+    // Add the uri to the sameAs data if it's not a local URI.
394
+    if ( $wl_uri !== $uri ) {
395
+        array_push( $same_as, $uri );
396
+    }
397
+
398
+    // Save the sameAs data for the entity.
399
+    wl_schema_set_value( $post_id, 'sameAs', $same_as );
400
+
401
+    // Save the other properties (latitude, langitude, startDate, endDate, etc.)
402
+    foreach ( $other_properties as $property_name => $property_value ) {
403
+        wl_schema_set_value( $post_id, $property_name, $property_value );
404
+    }
405
+
406
+    // Call hooks.
407
+    do_action( 'wl_save_entity', $post_id );
408
+
409
+    foreach ( $images as $image_remote_url ) {
410
+
411
+        // Check if image is already present in local DB
412
+        if ( strpos( $image_remote_url, site_url() ) !== false ) {
413
+            // Do nothing.
414
+            continue;
415
+        }
416
+
417
+        // Check if there is an existing attachment for this post ID and source URL.
418
+        $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
419
+
420
+        // Skip if an existing image is found.
421
+        if ( null !== $existing_image ) {
422
+            continue;
423
+        }
424
+
425
+        // Save the image and get the local path.
426
+        $image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
427
+
428
+        if ( false === $image || is_wp_error( $image ) ) {
429
+            continue;
430
+        }
431
+
432
+        // Get the local URL.
433
+        $filename     = $image['path'];
434
+        $url          = $image['url'];
435
+        $content_type = $image['content_type'];
436
+
437
+        $attachment = array(
438
+            'guid'           => $url,
439
+            // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
440
+            'post_title'     => $label,
441
+            // Set the title to the post title.
442
+            'post_content'   => '',
443
+            'post_status'    => 'inherit',
444
+            'post_mime_type' => $content_type,
445
+        );
446 446
 
447
-		// Create the attachment in WordPress and generate the related metadata.
448
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
449
-
450
-		// Set the source URL for the image.
451
-		wl_set_source_url( $attachment_id, $image_remote_url );
452
-
453
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
454
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
455
-
456
-		// Set it as the featured image.
457
-		set_post_thumbnail( $post_id, $attachment_id );
458
-	}
459
-
460
-	// The entity is pushed to Redlink on save by the function hooked to save_post.
461
-	// save the entity in the triple store.
462
-	do_action( 'wl_legacy_linked_data__push', $post_id );
463
-
464
-	// finally return the entity post.
465
-	return get_post( $post_id );
447
+        // Create the attachment in WordPress and generate the related metadata.
448
+        $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
449
+
450
+        // Set the source URL for the image.
451
+        wl_set_source_url( $attachment_id, $image_remote_url );
452
+
453
+        $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
454
+        wp_update_attachment_metadata( $attachment_id, $attachment_data );
455
+
456
+        // Set it as the featured image.
457
+        set_post_thumbnail( $post_id, $attachment_id );
458
+    }
459
+
460
+    // The entity is pushed to Redlink on save by the function hooked to save_post.
461
+    // save the entity in the triple store.
462
+    do_action( 'wl_legacy_linked_data__push', $post_id );
463
+
464
+    // finally return the entity post.
465
+    return get_post( $post_id );
466 466
 }
467 467
 
468 468
 /**
@@ -476,40 +476,40 @@  discard block
 block discarded – undo
476 476
  */
477 477
 function wl_linked_data_content_get_embedded_entities( $content ) {
478 478
 
479
-	// Remove quote escapes.
480
-	$content = str_replace( '\\"', '"', $content );
479
+    // Remove quote escapes.
480
+    $content = str_replace( '\\"', '"', $content );
481 481
 
482
-	// Match all itemid attributes.
483
-	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
482
+    // Match all itemid attributes.
483
+    $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
484 484
 
485
-	//	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
485
+    //	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
486 486
 
487
-	// Remove the pattern while it is found (match nested annotations).
488
-	$matches = array();
487
+    // Remove the pattern while it is found (match nested annotations).
488
+    $matches = array();
489 489
 
490
-	// In case of errors, return an empty array.
491
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
492
-		wl_write_log( "Found no entities embedded in content" );
490
+    // In case of errors, return an empty array.
491
+    if ( false === preg_match_all( $pattern, $content, $matches ) ) {
492
+        wl_write_log( "Found no entities embedded in content" );
493 493
 
494
-		return array();
495
-	}
494
+        return array();
495
+    }
496 496
 
497 497
 //    wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]");
498 498
 
499
-	// Collect the entities.
500
-	$entities = array();
501
-	foreach ( $matches[1] as $uri ) {
502
-		$uri_d = html_entity_decode( $uri );
499
+    // Collect the entities.
500
+    $entities = array();
501
+    foreach ( $matches[1] as $uri ) {
502
+        $uri_d = html_entity_decode( $uri );
503 503
 
504
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
504
+        $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
505 505
 
506
-		if ( null !== $entity ) {
507
-			array_push( $entities, $entity->ID );
508
-		}
509
-	}
506
+        if ( null !== $entity ) {
507
+            array_push( $entities, $entity->ID );
508
+        }
509
+    }
510 510
 
511
-	// $count = sizeof( $entities );
512
-	// wl_write_log( "Found $count entities embedded in content" );
511
+    // $count = sizeof( $entities );
512
+    // wl_write_log( "Found $count entities embedded in content" );
513 513
 
514
-	return $entities;
514
+    return $entities;
515 515
 }
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
  * @since 3.0.0
16 16
  *
17 17
  */
18
-function wl_linked_data_save_post( $post_id ) {
18
+function wl_linked_data_save_post($post_id) {
19 19
 
20
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
20
+	$log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post');
21 21
 
22
-	$log->trace( "Saving post $post_id to Linked Data..." );
22
+	$log->trace("Saving post $post_id to Linked Data...");
23 23
 
24 24
 	// If it's not numeric exit from here.
25
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
26
-		$log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
25
+	if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) {
26
+		$log->debug("Skipping $post_id, because id is not numeric or is a post revision.");
27 27
 
28 28
 		return;
29 29
 	}
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	// Get the post type and check whether it supports the editor.
32 32
 	//
33 33
 	// @see https://github.com/insideout10/wordlift-plugin/issues/659.
34
-	$post_type = get_post_type( $post_id );
34
+	$post_type = get_post_type($post_id);
35 35
 	/**
36 36
 	 * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
37 37
 	 *
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/847.
41 41
 	 */
42
-	$is_editor_supported = wl_post_type_supports_editor( $post_type );
42
+	$is_editor_supported = wl_post_type_supports_editor($post_type);
43 43
 
44 44
 	// Bail out if it's not an entity.
45
-	if ( ! $is_editor_supported ) {
46
-		$log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
45
+	if ( ! $is_editor_supported) {
46
+		$log->debug("Skipping $post_id, because $post_type doesn't support the editor (content).");
47 47
 
48 48
 		return;
49 49
 	}
@@ -57,23 +57,23 @@  discard block
 block discarded – undo
57 57
 	$supported_types = Wordlift_Entity_Service::valid_entity_post_types();
58 58
 
59 59
 	// Bail out if it's not a valid entity.
60
-	if ( ! in_array( $post_type, $supported_types ) ) {
61
-		$log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
60
+	if ( ! in_array($post_type, $supported_types)) {
61
+		$log->debug("Skipping $post_id, because $post_type is not a valid entity.");
62 62
 
63 63
 		return;
64 64
 	}
65 65
 
66 66
 	// Unhook this function so it doesn't loop infinitely.
67
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
67
+	remove_action('save_post', 'wl_linked_data_save_post');
68 68
 
69 69
 	// raise the *wl_linked_data_save_post* event.
70
-	do_action( 'wl_linked_data_save_post', $post_id );
70
+	do_action('wl_linked_data_save_post', $post_id);
71 71
 
72 72
 	// Re-hook this function.
73
-	add_action( 'save_post', 'wl_linked_data_save_post' );
73
+	add_action('save_post', 'wl_linked_data_save_post');
74 74
 }
75 75
 
76
-add_action( 'save_post', 'wl_linked_data_save_post' );
76
+add_action('save_post', 'wl_linked_data_save_post');
77 77
 
78 78
 /**
79 79
  * Save the post to the triple store. Also saves the entities locally and on the triple store.
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
  * @since 3.0.0
84 84
  *
85 85
  */
86
-function wl_linked_data_save_post_and_related_entities( $post_id ) {
86
+function wl_linked_data_save_post_and_related_entities($post_id) {
87 87
 
88
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
88
+	$log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post_and_related_entities');
89 89
 
90
-	$log->trace( "Saving $post_id to Linked Data along with related entities..." );
90
+	$log->trace("Saving $post_id to Linked Data along with related entities...");
91 91
 
92 92
 	// Ignore auto-saves
93
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
94
-		$log->trace( 'Doing autosave, skipping...' );
93
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
94
+		$log->trace('Doing autosave, skipping...');
95 95
 
96 96
 		return;
97 97
 	}
98 98
 
99 99
 	// get the current post.
100
-	$post = get_post( $post_id );
100
+	$post = get_post($post_id);
101 101
 
102
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
102
+	remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
103 103
 
104 104
 	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
105 105
 
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	$entities_uri_mapping = array();
111 111
 
112 112
 	// Save the entities coming with POST data.
113
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
113
+	if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) {
114 114
 
115
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
116
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
117
-		wl_write_log( "]" );
118
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
119
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
120
-		wl_write_log( "]" );
115
+		wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: ");
116
+		wl_write_log(json_encode($_POST['wl_entities']));
117
+		wl_write_log("]");
118
+		wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: ");
119
+		wl_write_log(json_encode($_POST['wl_boxes'], true));
120
+		wl_write_log("]");
121 121
 
122 122
 		$entities_via_post = $_POST['wl_entities'];
123 123
 		$boxes_via_post    = $_POST['wl_boxes'];
124 124
 
125
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
125
+		foreach ($entities_via_post as $entity_uri => $entity) {
126 126
 
127 127
 			// Only if the current entity is created from scratch let's avoid to
128 128
 			// create more than one entity with same label & entity type.
129
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
129
+			$entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ?
130 130
 				$entity['main_type'] : null;
131 131
 
132 132
 			// Look if current entity uri matches an internal existing entity, meaning:
133 133
 			// 1. when $entity_uri is an internal uri
134 134
 			// 2. when $entity_uri is an external uri used as sameAs of an internal entity
135
-			$ie = $entity_service->get_entity_post_by_uri( $entity_uri );
135
+			$ie = $entity_service->get_entity_post_by_uri($entity_uri);
136 136
 
137 137
 			// Detect the uri depending if is an existing or a new entity
138
-			$uri = ( null === $ie ) ?
138
+			$uri = (null === $ie) ?
139 139
 				Wordlift_Uri_Service::get_instance()->build_uri(
140 140
 					$entity['label'],
141 141
 					Wordlift_Entity_Service::TYPE_NAME,
142 142
 					$entity_type
143
-				) : wl_get_entity_uri( $ie->ID );
143
+				) : wl_get_entity_uri($ie->ID);
144 144
 
145
-			wl_write_log( "Map $entity_uri on $uri" );
146
-			$entities_uri_mapping[ $entity_uri ] = $uri;
145
+			wl_write_log("Map $entity_uri on $uri");
146
+			$entities_uri_mapping[$entity_uri] = $uri;
147 147
 
148 148
 			// Local entities have a tmp uri with 'local-entity-' prefix
149 149
 			// These uris need to be rewritten here and replaced in the content
150
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
150
+			if (preg_match('/^local-entity-.+/', $entity_uri) > 0) {
151 151
 				// Override the entity obj
152 152
 				$entity['uri'] = $uri;
153 153
 			}
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			$entity['related_post_id'] = $post_id;
157 157
 
158 158
 			// Save the entity if is a new entity
159
-			if ( null === $ie ) {
160
-				wl_save_entity( $entity );
159
+			if (null === $ie) {
160
+				wl_save_entity($entity);
161 161
 			}
162 162
 
163 163
 		}
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
 	$updated_post_content = $post->post_content;
169 169
 
170 170
 	// Update the post content if we found mappings of new entities.
171
-	if ( ! empty( $entities_uri_mapping ) ) {
171
+	if ( ! empty($entities_uri_mapping)) {
172 172
 		// Save each entity and store the post id.
173
-		foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
174
-			if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
173
+		foreach ($entities_uri_mapping as $tmp_uri => $uri) {
174
+			if (1 !== preg_match('@^(https?://|local-entity-)@', $tmp_uri)) {
175 175
 				continue;
176 176
 			}
177 177
 
178
-			$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
178
+			$updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content);
179 179
 		}
180 180
 
181 181
 		// Update the post content.
@@ -184,32 +184,32 @@  discard block
 block discarded – undo
184 184
 		 * content, so add the slashes to prevent back slash getting
185 185
 		 * removed.
186 186
 		 */
187
-		wp_update_post( array(
187
+		wp_update_post(array(
188 188
 			'ID'           => $post->ID,
189
-			'post_content' => addslashes( $updated_post_content ),
190
-		) );
189
+			'post_content' => addslashes($updated_post_content),
190
+		));
191 191
 	}
192 192
 
193 193
 	// Extract related/referenced entities from text.
194
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
194
+	$disambiguated_entities = wl_linked_data_content_get_embedded_entities($updated_post_content);
195 195
 
196 196
 	// Reset previously saved instances.
197
-	wl_core_delete_relation_instances( $post_id );
197
+	wl_core_delete_relation_instances($post_id);
198 198
 
199 199
 	// Save relation instances
200
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
200
+	foreach (array_unique($disambiguated_entities) as $referenced_entity_id) {
201 201
 
202 202
 		wl_core_add_relation_instance(
203 203
 			$post_id,
204
-			$entity_service->get_classification_scope_for( $referenced_entity_id ),
204
+			$entity_service->get_classification_scope_for($referenced_entity_id),
205 205
 			$referenced_entity_id
206 206
 		);
207 207
 
208 208
 	}
209 209
 
210
-	if ( isset( $_POST['wl_entities'] ) ) {
210
+	if (isset($_POST['wl_entities'])) {
211 211
 		// Save post metadata if available
212
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
212
+		$metadata_via_post = (isset($_POST['wl_metadata'])) ?
213 213
 			$_POST['wl_metadata'] : array();
214 214
 
215 215
 		$fields = array(
@@ -218,35 +218,35 @@  discard block
 block discarded – undo
218 218
 		);
219 219
 
220 220
 		// Unlink topic taxonomy terms
221
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
221
+		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID);
222 222
 
223
-		foreach ( $fields as $field ) {
223
+		foreach ($fields as $field) {
224 224
 
225 225
 			// Delete current values
226
-			delete_post_meta( $post->ID, $field );
226
+			delete_post_meta($post->ID, $field);
227 227
 			// Retrieve the entity uri
228
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
229
-				stripslashes( $metadata_via_post[ $field ] ) : '';
228
+			$uri = (isset($metadata_via_post[$field])) ?
229
+				stripslashes($metadata_via_post[$field]) : '';
230 230
 
231
-			$entity = $entity_service->get_entity_post_by_uri( $uri );
231
+			$entity = $entity_service->get_entity_post_by_uri($uri);
232 232
 
233
-			if ( $entity ) {
234
-				add_post_meta( $post->ID, $field, $entity->ID, true );
233
+			if ($entity) {
234
+				add_post_meta($post->ID, $field, $entity->ID, true);
235 235
 				// Set also the topic taxonomy
236
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
237
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
236
+				if ($field === Wordlift_Schema_Service::FIELD_TOPIC) {
237
+					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity);
238 238
 				}
239 239
 			}
240 240
 		}
241 241
 	}
242 242
 
243 243
 	// Push the post to Redlink.
244
-	do_action( 'wl_legacy_linked_data__push', $post->ID );
244
+	do_action('wl_legacy_linked_data__push', $post->ID);
245 245
 
246
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
246
+	add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
247 247
 }
248 248
 
249
-add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
249
+add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
250 250
 
251 251
 /**
252 252
  * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @return null|WP_Post A post instance or null in case of failure.
266 266
  */
267
-function wl_save_entity( $entity_data ) {
267
+function wl_save_entity($entity_data) {
268 268
 
269 269
 	// Required for REST API calls
270
-	if ( ! function_exists( 'wp_crop_image' ) ) {
271
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
270
+	if ( ! function_exists('wp_crop_image')) {
271
+		require_once(ABSPATH.'wp-admin/includes/image.php');
272 272
 	}
273 273
 
274
-	$log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
274
+	$log = Wordlift_Log_Service::get_logger('wl_save_entity');
275 275
 
276 276
 	$uri = $entity_data['uri'];
277 277
 	/*
@@ -281,28 +281,28 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/841
283 283
 	 */
284
-	$label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
284
+	$label            = preg_replace('/\xEF\xBB\xBF/', '', sanitize_text_field($entity_data['label']));
285 285
 	$type_uri         = $entity_data['main_type'];
286
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
286
+	$entity_types     = isset($entity_data['type']) ? $entity_data['type'] : array();
287 287
 	$description      = $entity_data['description'];
288
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
289
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
290
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
291
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
288
+	$images           = isset($entity_data['image']) ? (array) $entity_data['image'] : array();
289
+	$same_as          = isset($entity_data['sameas']) ? (array) $entity_data['sameas'] : array();
290
+	$related_post_id  = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null;
291
+	$other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array();
292 292
 
293 293
 	// Get the synonyms.
294
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
294
+	$synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array();
295 295
 
296 296
 	// Check whether an entity already exists with the provided URI.
297
-	if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
298
-		$log->debug( "Post already exists for URI $uri." );
297
+	if (null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) {
298
+		$log->debug("Post already exists for URI $uri.");
299 299
 
300 300
 		return $post;
301 301
 	}
302 302
 
303 303
 	// Prepare properties of the new entity.
304 304
 	$params = array(
305
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
305
+		'post_status'  => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'),
306 306
 		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
307 307
 		'post_title'   => $label,
308 308
 		'post_content' => $description,
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		// new entities.
313 313
 		//
314 314
 		// See https://github.com/insideout10/wordlift-plugin/issues/282
315
-		'post_name'    => sanitize_title( $label ),
315
+		'post_name'    => sanitize_title($label),
316 316
 	);
317 317
 
318 318
 	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
@@ -321,18 +321,18 @@  discard block
 block discarded – undo
321 321
 	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
322 322
 	// is created when saving a post.
323 323
 	global $wpseo_metabox, $seo_ultimate;
324
-	if ( isset( $wpseo_metabox ) ) {
325
-		remove_action( 'wp_insert_post', array(
324
+	if (isset($wpseo_metabox)) {
325
+		remove_action('wp_insert_post', array(
326 326
 			$wpseo_metabox,
327 327
 			'save_postdata',
328
-		) );
328
+		));
329 329
 	}
330 330
 
331
-	if ( isset( $seo_ultimate ) ) {
332
-		remove_action( 'save_post', array(
331
+	if (isset($seo_ultimate)) {
332
+		remove_action('save_post', array(
333 333
 			$seo_ultimate,
334 334
 			'save_postmeta_box',
335
-		) );
335
+		));
336 336
 	}
337 337
 
338 338
 	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
@@ -342,90 +342,90 @@  discard block
 block discarded – undo
342 342
 	// see https://github.com/insideout10/wordlift-plugin/issues/156
343 343
 	// see https://github.com/insideout10/wordlift-plugin/issues/148
344 344
 	global $wp_filter;
345
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
346
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
345
+	$save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
346
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
347 347
 
348 348
 
349
-	$log->trace( 'Going to insert new post...' );
349
+	$log->trace('Going to insert new post...');
350 350
 
351 351
 	// create or update the post.
352
-	$post_id = wp_insert_post( $params, true );
352
+	$post_id = wp_insert_post($params, true);
353 353
 
354 354
 	// Setting the alternative labels for this entity.
355 355
 	Wordlift_Entity_Service::get_instance()
356
-	                       ->set_alternative_labels( $post_id, $synonyms );
356
+	                       ->set_alternative_labels($post_id, $synonyms);
357 357
 
358 358
 	// Restore all the existing filters.
359
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
359
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
360 360
 
361 361
 	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
362
-	if ( isset( $wpseo_metabox ) ) {
363
-		add_action( 'wp_insert_post', array(
362
+	if (isset($wpseo_metabox)) {
363
+		add_action('wp_insert_post', array(
364 364
 			$wpseo_metabox,
365 365
 			'save_postdata',
366
-		) );
366
+		));
367 367
 	}
368 368
 
369 369
 	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
370
-	if ( isset( $seo_ultimate ) ) {
371
-		add_action( 'save_post', array(
370
+	if (isset($seo_ultimate)) {
371
+		add_action('save_post', array(
372 372
 			$seo_ultimate,
373 373
 			'save_postmeta_box',
374
-		), 10, 2 );
374
+		), 10, 2);
375 375
 	}
376 376
 
377 377
 	// TODO: handle errors.
378
-	if ( is_wp_error( $post_id ) ) {
379
-		$log->error( 'An error occurred: ' . $post_id->get_error_message() );
378
+	if (is_wp_error($post_id)) {
379
+		$log->error('An error occurred: '.$post_id->get_error_message());
380 380
 
381 381
 		// inform an error occurred.
382 382
 		return null;
383 383
 	}
384 384
 
385
-	wl_set_entity_main_type( $post_id, $type_uri );
385
+	wl_set_entity_main_type($post_id, $type_uri);
386 386
 
387 387
 	// Save the entity types.
388
-	wl_set_entity_rdf_types( $post_id, $entity_types );
388
+	wl_set_entity_rdf_types($post_id, $entity_types);
389 389
 
390 390
 	// Get a dataset URI for the entity.
391
-	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
391
+	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri($post_id);
392 392
 
393 393
 	// Add the uri to the sameAs data if it's not a local URI.
394
-	if ( $wl_uri !== $uri ) {
395
-		array_push( $same_as, $uri );
394
+	if ($wl_uri !== $uri) {
395
+		array_push($same_as, $uri);
396 396
 	}
397 397
 
398 398
 	// Save the sameAs data for the entity.
399
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
399
+	wl_schema_set_value($post_id, 'sameAs', $same_as);
400 400
 
401 401
 	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
402
-	foreach ( $other_properties as $property_name => $property_value ) {
403
-		wl_schema_set_value( $post_id, $property_name, $property_value );
402
+	foreach ($other_properties as $property_name => $property_value) {
403
+		wl_schema_set_value($post_id, $property_name, $property_value);
404 404
 	}
405 405
 
406 406
 	// Call hooks.
407
-	do_action( 'wl_save_entity', $post_id );
407
+	do_action('wl_save_entity', $post_id);
408 408
 
409
-	foreach ( $images as $image_remote_url ) {
409
+	foreach ($images as $image_remote_url) {
410 410
 
411 411
 		// Check if image is already present in local DB
412
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
412
+		if (strpos($image_remote_url, site_url()) !== false) {
413 413
 			// Do nothing.
414 414
 			continue;
415 415
 		}
416 416
 
417 417
 		// Check if there is an existing attachment for this post ID and source URL.
418
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
418
+		$existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url);
419 419
 
420 420
 		// Skip if an existing image is found.
421
-		if ( null !== $existing_image ) {
421
+		if (null !== $existing_image) {
422 422
 			continue;
423 423
 		}
424 424
 
425 425
 		// Save the image and get the local path.
426
-		$image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
426
+		$image = Wordlift_Remote_Image_Service::save_from_url($image_remote_url);
427 427
 
428
-		if ( false === $image || is_wp_error( $image ) ) {
428
+		if (false === $image || is_wp_error($image)) {
429 429
 			continue;
430 430
 		}
431 431
 
@@ -445,24 +445,24 @@  discard block
 block discarded – undo
445 445
 		);
446 446
 
447 447
 		// Create the attachment in WordPress and generate the related metadata.
448
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
448
+		$attachment_id = wp_insert_attachment($attachment, $filename, $post_id);
449 449
 
450 450
 		// Set the source URL for the image.
451
-		wl_set_source_url( $attachment_id, $image_remote_url );
451
+		wl_set_source_url($attachment_id, $image_remote_url);
452 452
 
453
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
454
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
453
+		$attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
454
+		wp_update_attachment_metadata($attachment_id, $attachment_data);
455 455
 
456 456
 		// Set it as the featured image.
457
-		set_post_thumbnail( $post_id, $attachment_id );
457
+		set_post_thumbnail($post_id, $attachment_id);
458 458
 	}
459 459
 
460 460
 	// The entity is pushed to Redlink on save by the function hooked to save_post.
461 461
 	// save the entity in the triple store.
462
-	do_action( 'wl_legacy_linked_data__push', $post_id );
462
+	do_action('wl_legacy_linked_data__push', $post_id);
463 463
 
464 464
 	// finally return the entity post.
465
-	return get_post( $post_id );
465
+	return get_post($post_id);
466 466
 }
467 467
 
468 468
 /**
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
  * @since 3.0.0
475 475
  *
476 476
  */
477
-function wl_linked_data_content_get_embedded_entities( $content ) {
477
+function wl_linked_data_content_get_embedded_entities($content) {
478 478
 
479 479
 	// Remove quote escapes.
480
-	$content = str_replace( '\\"', '"', $content );
480
+	$content = str_replace('\\"', '"', $content);
481 481
 
482 482
 	// Match all itemid attributes.
483 483
 	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 	$matches = array();
489 489
 
490 490
 	// In case of errors, return an empty array.
491
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
492
-		wl_write_log( "Found no entities embedded in content" );
491
+	if (false === preg_match_all($pattern, $content, $matches)) {
492
+		wl_write_log("Found no entities embedded in content");
493 493
 
494 494
 		return array();
495 495
 	}
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
 
499 499
 	// Collect the entities.
500 500
 	$entities = array();
501
-	foreach ( $matches[1] as $uri ) {
502
-		$uri_d = html_entity_decode( $uri );
501
+	foreach ($matches[1] as $uri) {
502
+		$uri_d = html_entity_decode($uri);
503 503
 
504
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
504
+		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d);
505 505
 
506
-		if ( null !== $entity ) {
507
-			array_push( $entities, $entity->ID );
506
+		if (null !== $entity) {
507
+			array_push($entities, $entity->ID);
508 508
 		}
509 509
 	}
510 510
 
Please login to merge, or discard this patch.
src/wordlift/api/class-default-api-service.php 2 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -7,123 +7,123 @@
 block discarded – undo
7 7
 namespace Wordlift\Api;
8 8
 
9 9
 class Default_Api_Service implements Api_Service {
10
-	/**
11
-	 * @var Default_Api_Service
12
-	 */
13
-	private static $instance;
14
-
15
-	/**
16
-	 * @var string
17
-	 */
18
-	private $wordlift_key;
19
-	/**
20
-	 * @var int
21
-	 */
22
-	private $timeout;
23
-
24
-	/**
25
-	 * @var string
26
-	 */
27
-	private $user_agent;
28
-
29
-	/**
30
-	 * @var array
31
-	 */
32
-	private $headers;
33
-	/**
34
-	 * @var string
35
-	 */
36
-	private $base_url;
37
-
38
-	/**
39
-	 * @var \Wordlift_Log_Service
40
-	 */
41
-	private $log;
42
-
43
-	/**
44
-	 * Default_Api_Service constructor.
45
-	 *
46
-	 * @param string $base_url
47
-	 * @param int $timeout
48
-	 * @param string $user_agent
49
-	 * @param string $wordlift_key
50
-	 */
51
-	public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
52
-
53
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
54
-
55
-		$this->base_url     = untrailingslashit( $base_url );
56
-		$this->timeout      = $timeout;
57
-		$this->user_agent   = $user_agent;
58
-		$this->wordlift_key = $wordlift_key;
59
-
60
-		$this->headers = array(
61
-			'Content-Type'  => 'application/json',
62
-			'Authorization' => "Key $wordlift_key",
63
-			'Expect'        => '',
64
-		);
65
-
66
-		self::$instance = $this;
67
-	}
68
-
69
-	public static function get_instance() {
70
-		return self::$instance;
71
-	}
72
-
73
-	public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
74
-
75
-		// Get the timeout for this request.
76
-		$request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
77
-
78
-		// Set the time limit if lesser than our request timeout.
79
-		$max_execution_time = ini_get( 'max_execution_time' );
80
-		if ( $max_execution_time < $request_timeout ) {
81
-			@set_time_limit( $request_timeout );
82
-		}
83
-
84
-		$request_url = $this->base_url . $path;
85
-
86
-		// Create the request args in the following order:
87
-		//  1. use `$args` as base if provided.
88
-		//  2. set the custom timeout if provided.
89
-		//  3. set the custom user-agent if provided.
90
-		//  4. merge the API headers to the provided headers.
91
-		//  5. add the body.
92
-		//
93
-		// In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults.
94
-		$request_args = $args + array(
95
-				'method'     => $method,
96
-				'timeout'    => $request_timeout,
97
-				'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
98
-				'headers'    => $headers + $this->headers,
99
-				'body'       => $body,
100
-			);
101
-
102
-		/**
103
-		 * Allow 3rd parties to process the response.
104
-		 */
105
-		$response = apply_filters( 'wl_api_service__response',
106
-			wp_remote_request( $request_url, $request_args ), $request_url, $request_args );
107
-
108
-		if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
109
-			$this->log->trace(
110
-				"=== REQUEST  ===========================\n"
111
-				. "=== URL: $request_url ===========================\n"
112
-				. var_export( $request_args, true )
113
-				. "=== RESPONSE ===========================\n"
114
-				. var_export( $response, true ) );
115
-		}
116
-
117
-		return new Response( $response );
118
-	}
119
-
120
-	public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
121
-
122
-		return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
123
-	}
124
-
125
-	public function get_base_url() {
126
-		return $this->base_url;
127
-	}
10
+    /**
11
+     * @var Default_Api_Service
12
+     */
13
+    private static $instance;
14
+
15
+    /**
16
+     * @var string
17
+     */
18
+    private $wordlift_key;
19
+    /**
20
+     * @var int
21
+     */
22
+    private $timeout;
23
+
24
+    /**
25
+     * @var string
26
+     */
27
+    private $user_agent;
28
+
29
+    /**
30
+     * @var array
31
+     */
32
+    private $headers;
33
+    /**
34
+     * @var string
35
+     */
36
+    private $base_url;
37
+
38
+    /**
39
+     * @var \Wordlift_Log_Service
40
+     */
41
+    private $log;
42
+
43
+    /**
44
+     * Default_Api_Service constructor.
45
+     *
46
+     * @param string $base_url
47
+     * @param int $timeout
48
+     * @param string $user_agent
49
+     * @param string $wordlift_key
50
+     */
51
+    public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
52
+
53
+        $this->log = \Wordlift_Log_Service::get_logger( get_class() );
54
+
55
+        $this->base_url     = untrailingslashit( $base_url );
56
+        $this->timeout      = $timeout;
57
+        $this->user_agent   = $user_agent;
58
+        $this->wordlift_key = $wordlift_key;
59
+
60
+        $this->headers = array(
61
+            'Content-Type'  => 'application/json',
62
+            'Authorization' => "Key $wordlift_key",
63
+            'Expect'        => '',
64
+        );
65
+
66
+        self::$instance = $this;
67
+    }
68
+
69
+    public static function get_instance() {
70
+        return self::$instance;
71
+    }
72
+
73
+    public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
74
+
75
+        // Get the timeout for this request.
76
+        $request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
77
+
78
+        // Set the time limit if lesser than our request timeout.
79
+        $max_execution_time = ini_get( 'max_execution_time' );
80
+        if ( $max_execution_time < $request_timeout ) {
81
+            @set_time_limit( $request_timeout );
82
+        }
83
+
84
+        $request_url = $this->base_url . $path;
85
+
86
+        // Create the request args in the following order:
87
+        //  1. use `$args` as base if provided.
88
+        //  2. set the custom timeout if provided.
89
+        //  3. set the custom user-agent if provided.
90
+        //  4. merge the API headers to the provided headers.
91
+        //  5. add the body.
92
+        //
93
+        // In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults.
94
+        $request_args = $args + array(
95
+                'method'     => $method,
96
+                'timeout'    => $request_timeout,
97
+                'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
98
+                'headers'    => $headers + $this->headers,
99
+                'body'       => $body,
100
+            );
101
+
102
+        /**
103
+         * Allow 3rd parties to process the response.
104
+         */
105
+        $response = apply_filters( 'wl_api_service__response',
106
+            wp_remote_request( $request_url, $request_args ), $request_url, $request_args );
107
+
108
+        if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
109
+            $this->log->trace(
110
+                "=== REQUEST  ===========================\n"
111
+                . "=== URL: $request_url ===========================\n"
112
+                . var_export( $request_args, true )
113
+                . "=== RESPONSE ===========================\n"
114
+                . var_export( $response, true ) );
115
+        }
116
+
117
+        return new Response( $response );
118
+    }
119
+
120
+    public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
121
+
122
+        return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
123
+    }
124
+
125
+    public function get_base_url() {
126
+        return $this->base_url;
127
+    }
128 128
 
129 129
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	 * @param string $user_agent
49 49
 	 * @param string $wordlift_key
50 50
 	 */
51
-	public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
51
+	public function __construct($base_url, $timeout, $user_agent, $wordlift_key) {
52 52
 
53
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
53
+		$this->log = \Wordlift_Log_Service::get_logger(get_class());
54 54
 
55
-		$this->base_url     = untrailingslashit( $base_url );
55
+		$this->base_url     = untrailingslashit($base_url);
56 56
 		$this->timeout      = $timeout;
57 57
 		$this->user_agent   = $user_agent;
58 58
 		$this->wordlift_key = $wordlift_key;
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 		return self::$instance;
71 71
 	}
72 72
 
73
-	public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
73
+	public function request($method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) {
74 74
 
75 75
 		// Get the timeout for this request.
76
-		$request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
76
+		$request_timeout = isset($timeout) ? $timeout : $this->timeout;
77 77
 
78 78
 		// Set the time limit if lesser than our request timeout.
79
-		$max_execution_time = ini_get( 'max_execution_time' );
80
-		if ( $max_execution_time < $request_timeout ) {
81
-			@set_time_limit( $request_timeout );
79
+		$max_execution_time = ini_get('max_execution_time');
80
+		if ($max_execution_time < $request_timeout) {
81
+			@set_time_limit($request_timeout);
82 82
 		}
83 83
 
84
-		$request_url = $this->base_url . $path;
84
+		$request_url = $this->base_url.$path;
85 85
 
86 86
 		// Create the request args in the following order:
87 87
 		//  1. use `$args` as base if provided.
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		$request_args = $args + array(
95 95
 				'method'     => $method,
96 96
 				'timeout'    => $request_timeout,
97
-				'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
97
+				'user-agent' => isset($user_agent) ? $user_agent : $this->user_agent,
98 98
 				'headers'    => $headers + $this->headers,
99 99
 				'body'       => $body,
100 100
 			);
@@ -102,24 +102,24 @@  discard block
 block discarded – undo
102 102
 		/**
103 103
 		 * Allow 3rd parties to process the response.
104 104
 		 */
105
-		$response = apply_filters( 'wl_api_service__response',
106
-			wp_remote_request( $request_url, $request_args ), $request_url, $request_args );
105
+		$response = apply_filters('wl_api_service__response',
106
+			wp_remote_request($request_url, $request_args), $request_url, $request_args);
107 107
 
108
-		if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
108
+		if (defined('WL_DEBUG') && WL_DEBUG) {
109 109
 			$this->log->trace(
110 110
 				"=== REQUEST  ===========================\n"
111 111
 				. "=== URL: $request_url ===========================\n"
112
-				. var_export( $request_args, true )
112
+				. var_export($request_args, true)
113 113
 				. "=== RESPONSE ===========================\n"
114
-				. var_export( $response, true ) );
114
+				. var_export($response, true) );
115 115
 		}
116 116
 
117
-		return new Response( $response );
117
+		return new Response($response);
118 118
 	}
119 119
 
120
-	public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
120
+	public function get($path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) {
121 121
 
122
-		return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
122
+		return $this->request('GET', $path, $headers, $body, $timeout, $user_agent, $args);
123 123
 	}
124 124
 
125 125
 	public function get_base_url() {
Please login to merge, or discard this patch.
src/shortcodes/wordlift_shortcode_navigator.php 2 patches
Indentation   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function wl_shortcode_navigator_data() {
18 18
 
19
-	// Create the cache key.
20
-	$cache_key_params = $_REQUEST;
21
-	unset( $cache_key_params['uniqid'] );
22
-	$cache_key = array( 'request_params' => $cache_key_params );
19
+    // Create the cache key.
20
+    $cache_key_params = $_REQUEST;
21
+    unset( $cache_key_params['uniqid'] );
22
+    $cache_key = array( 'request_params' => $cache_key_params );
23 23
 
24
-	// Create the TTL cache and try to get the results.
25
-	$cache         = new Ttl_Cache( "navigator", 8 * 60 * 60 ); // 8 hours.
26
-	$cache_results = $cache->get( $cache_key );
24
+    // Create the TTL cache and try to get the results.
25
+    $cache         = new Ttl_Cache( "navigator", 8 * 60 * 60 ); // 8 hours.
26
+    $cache_results = $cache->get( $cache_key );
27 27
 
28
-	if ( isset( $cache_results ) ) {
29
-		header( 'X-WordLift-Cache: HIT' );
28
+    if ( isset( $cache_results ) ) {
29
+        header( 'X-WordLift-Cache: HIT' );
30 30
 
31
-		return $cache_results;
32
-	}
31
+        return $cache_results;
32
+    }
33 33
 
34
-	header( 'X-WordLift-Cache: MISS' );
34
+    header( 'X-WordLift-Cache: MISS' );
35 35
 
36
-	$results = _wl_navigator_get_data();
36
+    $results = _wl_navigator_get_data();
37 37
 
38
-	// Put the result before sending the json to the client, since sending the json will terminate us.
39
-	$cache->put( $cache_key, $results );
38
+    // Put the result before sending the json to the client, since sending the json will terminate us.
39
+    $cache->put( $cache_key, $results );
40 40
 
41
-	return $results;
41
+    return $results;
42 42
 }
43 43
 
44 44
 /**
@@ -53,195 +53,195 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function wl_network_navigator_wp_json( $request ) {
55 55
 
56
-	// Create the cache key.
57
-	$cache_key_params = $_REQUEST;
58
-	unset( $cache_key_params['uniqid'] );
59
-	$cache_key = array( 'request_params' => $cache_key_params );
56
+    // Create the cache key.
57
+    $cache_key_params = $_REQUEST;
58
+    unset( $cache_key_params['uniqid'] );
59
+    $cache_key = array( 'request_params' => $cache_key_params );
60 60
 
61
-	// Create the TTL cache and try to get the results.
62
-	$cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
-	$cache_results = $cache->get( $cache_key );
61
+    // Create the TTL cache and try to get the results.
62
+    $cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
+    $cache_results = $cache->get( $cache_key );
64 64
 
65
-	if ( isset( $cache_results ) ) {
66
-		header( 'X-WordLift-Cache: HIT' );
65
+    if ( isset( $cache_results ) ) {
66
+        header( 'X-WordLift-Cache: HIT' );
67 67
 
68
-		return $cache_results;
69
-	}
68
+        return $cache_results;
69
+    }
70 70
 
71
-	header( 'X-WordLift-Cache: MISS' );
71
+    header( 'X-WordLift-Cache: MISS' );
72 72
 
73
-	$results = _wl_network_navigator_get_data( $request );
73
+    $results = _wl_network_navigator_get_data( $request );
74 74
 
75
-	// Put the result before sending the json to the client, since sending the json will terminate us.
76
-	$cache->put( $cache_key, $results );
75
+    // Put the result before sending the json to the client, since sending the json will terminate us.
76
+    $cache->put( $cache_key, $results );
77 77
 
78
-	return $results;
78
+    return $results;
79 79
 
80 80
 }
81 81
 
82 82
 function _wl_navigator_get_data() {
83 83
 
84
-	// Post ID must be defined
85
-	if ( ! isset( $_GET['post_id'] ) ) {
86
-		wp_send_json_error( 'No post_id given' );
87
-
88
-		return array();
89
-	}
90
-
91
-	// Limit the results (defaults to 4)
92
-	$navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
-	$navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
95
-
96
-	$current_post_id = $_GET['post_id'];
97
-	$current_post    = get_post( $current_post_id );
98
-
99
-	$navigator_id = $_GET['uniqid'];
100
-
101
-	// Post ID has to match an existing item
102
-	if ( null === $current_post ) {
103
-		wp_send_json_error( 'No valid post_id given' );
104
-
105
-		return array();
106
-	}
107
-
108
-	// Determine navigator type and call respective _get_results
109
-	if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
-		$referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
111
-			'ID',
112
-			'post_title',
113
-		), $order_by, $navigator_length, $navigator_offset );
114
-	} else {
115
-		$referencing_posts = _wl_navigator_get_results( $current_post_id, array(
116
-			'ID',
117
-			'post_title',
118
-		), $order_by, $navigator_length, $navigator_offset );
119
-	}
120
-
121
-	// loop over them and take the first one which is not already in the $related_posts
122
-	$results = array();
123
-	foreach ( $referencing_posts as $referencing_post ) {
124
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
125
-
126
-		/**
127
-		 * Use the thumbnail.
128
-		 *
129
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
130
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/837
131
-		 *
132
-		 * @since 3.19.3 We're using the medium size image.
133
-		 */
134
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
135
-
136
-		$result = array(
137
-			'post'   => array(
138
-				'permalink' => get_permalink( $referencing_post->ID ),
139
-				'title'     => $referencing_post->post_title,
140
-				'thumbnail' => $thumbnail,
141
-			),
142
-			'entity' => array(
143
-				'label'     => $serialized_entity['label'],
144
-				'mainType'  => $serialized_entity['mainType'],
145
-				'permalink' => get_permalink( $referencing_post->entity_id ),
146
-			),
147
-		);
148
-
149
-		$result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
-		$result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
151
-
152
-		$results[] = $result;
153
-	}
154
-
155
-	if ( count( $results ) < $navigator_length ) {
156
-		$results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
157
-	}
158
-
159
-	return $results;
84
+    // Post ID must be defined
85
+    if ( ! isset( $_GET['post_id'] ) ) {
86
+        wp_send_json_error( 'No post_id given' );
87
+
88
+        return array();
89
+    }
90
+
91
+    // Limit the results (defaults to 4)
92
+    $navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
+    $navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
+    $order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
95
+
96
+    $current_post_id = $_GET['post_id'];
97
+    $current_post    = get_post( $current_post_id );
98
+
99
+    $navigator_id = $_GET['uniqid'];
100
+
101
+    // Post ID has to match an existing item
102
+    if ( null === $current_post ) {
103
+        wp_send_json_error( 'No valid post_id given' );
104
+
105
+        return array();
106
+    }
107
+
108
+    // Determine navigator type and call respective _get_results
109
+    if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
+        $referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
111
+            'ID',
112
+            'post_title',
113
+        ), $order_by, $navigator_length, $navigator_offset );
114
+    } else {
115
+        $referencing_posts = _wl_navigator_get_results( $current_post_id, array(
116
+            'ID',
117
+            'post_title',
118
+        ), $order_by, $navigator_length, $navigator_offset );
119
+    }
120
+
121
+    // loop over them and take the first one which is not already in the $related_posts
122
+    $results = array();
123
+    foreach ( $referencing_posts as $referencing_post ) {
124
+        $serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
125
+
126
+        /**
127
+         * Use the thumbnail.
128
+         *
129
+         * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
130
+         * @see https://github.com/insideout10/wordlift-plugin/issues/837
131
+         *
132
+         * @since 3.19.3 We're using the medium size image.
133
+         */
134
+        $thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
135
+
136
+        $result = array(
137
+            'post'   => array(
138
+                'permalink' => get_permalink( $referencing_post->ID ),
139
+                'title'     => $referencing_post->post_title,
140
+                'thumbnail' => $thumbnail,
141
+            ),
142
+            'entity' => array(
143
+                'label'     => $serialized_entity['label'],
144
+                'mainType'  => $serialized_entity['mainType'],
145
+                'permalink' => get_permalink( $referencing_post->entity_id ),
146
+            ),
147
+        );
148
+
149
+        $result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
+        $result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
151
+
152
+        $results[] = $result;
153
+    }
154
+
155
+    if ( count( $results ) < $navigator_length ) {
156
+        $results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
157
+    }
158
+
159
+    return $results;
160 160
 }
161 161
 
162 162
 function _wl_network_navigator_get_data( $request ) {
163 163
 
164
-	// Limit the results (defaults to 4)
165
-	$navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
-	$navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
167
-	$navigator_id     = $request['uniqid'];
168
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
169
-
170
-	$entities = $request['entities'];
171
-
172
-	// Post ID has to match an existing item
173
-	if ( ! isset( $entities ) || empty( $entities ) ) {
174
-		wp_send_json_error( 'No valid entities provided' );
175
-	}
176
-
177
-	$referencing_posts = _wl_network_navigator_get_results( $entities, array(
178
-		'ID',
179
-		'post_title',
180
-	), $order_by, $navigator_length, $navigator_offset );
181
-
182
-	// loop over them and take the first one which is not already in the $related_posts
183
-	$results = array();
184
-	foreach ( $referencing_posts as $referencing_post ) {
185
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
186
-
187
-		/**
188
-		 * Use the thumbnail.
189
-		 *
190
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
191
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/837
192
-		 *
193
-		 * @since 3.19.3 We're using the medium size image.
194
-		 */
195
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
196
-
197
-		$result = array(
198
-			'post'   => array(
199
-				'permalink' => get_permalink( $referencing_post->ID ),
200
-				'title'     => $referencing_post->post_title,
201
-				'thumbnail' => $thumbnail,
202
-			),
203
-			'entity' => array(
204
-				'label'     => $serialized_entity['label'],
205
-				'mainType'  => $serialized_entity['mainType'],
206
-				'permalink' => get_permalink( $referencing_post->entity_id ),
207
-			),
208
-		);
209
-
210
-		$result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
-		$result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
212
-
213
-		$results[] = $result;
214
-
215
-	}
216
-
217
-	if ( count( $results ) < $navigator_length ) {
218
-		$results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
219
-	}
220
-
221
-	return $results;
164
+    // Limit the results (defaults to 4)
165
+    $navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
+    $navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
167
+    $navigator_id     = $request['uniqid'];
168
+    $order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
169
+
170
+    $entities = $request['entities'];
171
+
172
+    // Post ID has to match an existing item
173
+    if ( ! isset( $entities ) || empty( $entities ) ) {
174
+        wp_send_json_error( 'No valid entities provided' );
175
+    }
176
+
177
+    $referencing_posts = _wl_network_navigator_get_results( $entities, array(
178
+        'ID',
179
+        'post_title',
180
+    ), $order_by, $navigator_length, $navigator_offset );
181
+
182
+    // loop over them and take the first one which is not already in the $related_posts
183
+    $results = array();
184
+    foreach ( $referencing_posts as $referencing_post ) {
185
+        $serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
186
+
187
+        /**
188
+         * Use the thumbnail.
189
+         *
190
+         * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
191
+         * @see https://github.com/insideout10/wordlift-plugin/issues/837
192
+         *
193
+         * @since 3.19.3 We're using the medium size image.
194
+         */
195
+        $thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
196
+
197
+        $result = array(
198
+            'post'   => array(
199
+                'permalink' => get_permalink( $referencing_post->ID ),
200
+                'title'     => $referencing_post->post_title,
201
+                'thumbnail' => $thumbnail,
202
+            ),
203
+            'entity' => array(
204
+                'label'     => $serialized_entity['label'],
205
+                'mainType'  => $serialized_entity['mainType'],
206
+                'permalink' => get_permalink( $referencing_post->entity_id ),
207
+            ),
208
+        );
209
+
210
+        $result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
+        $result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
212
+
213
+        $results[] = $result;
214
+
215
+    }
216
+
217
+    if ( count( $results ) < $navigator_length ) {
218
+        $results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
219
+    }
220
+
221
+    return $results;
222 222
 
223 223
 }
224 224
 
225 225
 
226 226
 function _wl_navigator_get_results(
227
-	$post_id, $fields = array(
228
-	'ID',
229
-	'post_title',
227
+    $post_id, $fields = array(
228
+    'ID',
229
+    'post_title',
230 230
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
231 231
 ) {
232
-	global $wpdb;
232
+    global $wpdb;
233 233
 
234
-	$select = implode( ', ', array_map( function ( $item ) {
235
-		return "p.$item AS $item";
236
-	}, (array) $fields ) );
234
+    $select = implode( ', ', array_map( function ( $item ) {
235
+        return "p.$item AS $item";
236
+    }, (array) $fields ) );
237 237
 
238
-	$order_by = implode( ', ', array_map( function ( $item ) {
239
-		return "p.$item";
240
-	}, (array) $order_by ) );
238
+    $order_by = implode( ', ', array_map( function ( $item ) {
239
+        return "p.$item";
240
+    }, (array) $order_by ) );
241 241
 
242
-	/** @noinspection SqlNoDataSourceInspection */
243
-	return $wpdb->get_results(
244
-		$wpdb->prepare( <<<EOF
242
+    /** @noinspection SqlNoDataSourceInspection */
243
+    return $wpdb->get_results(
244
+        $wpdb->prepare( <<<EOF
245 245
 SELECT %4\$s, p2.ID as entity_id
246 246
  FROM {$wpdb->prefix}wl_relation_instances r1
247 247
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -273,30 +273,30 @@  discard block
 block discarded – undo
273 273
  LIMIT %2\$d
274 274
  OFFSET %3\$d
275 275
 EOF
276
-			, $post_id, $limit, $offset, $select, $order_by )
277
-	);
276
+            , $post_id, $limit, $offset, $select, $order_by )
277
+    );
278 278
 
279 279
 }
280 280
 
281 281
 function _wl_entity_navigator_get_results(
282
-	$post_id, $fields = array(
283
-	'ID',
284
-	'post_title',
282
+    $post_id, $fields = array(
283
+    'ID',
284
+    'post_title',
285 285
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
286 286
 ) {
287
-	global $wpdb;
287
+    global $wpdb;
288 288
 
289
-	$select = implode( ', ', array_map( function ( $item ) {
290
-		return "p.$item AS $item";
291
-	}, (array) $fields ) );
289
+    $select = implode( ', ', array_map( function ( $item ) {
290
+        return "p.$item AS $item";
291
+    }, (array) $fields ) );
292 292
 
293
-	$order_by = implode( ', ', array_map( function ( $item ) {
294
-		return "p.$item";
295
-	}, (array) $order_by ) );
293
+    $order_by = implode( ', ', array_map( function ( $item ) {
294
+        return "p.$item";
295
+    }, (array) $order_by ) );
296 296
 
297
-	/** @noinspection SqlNoDataSourceInspection */
298
-	return $wpdb->get_results(
299
-		$wpdb->prepare( <<<EOF
297
+    /** @noinspection SqlNoDataSourceInspection */
298
+    return $wpdb->get_results(
299
+        $wpdb->prepare( <<<EOF
300 300
 SELECT %4\$s, p2.ID as entity_id
301 301
  FROM {$wpdb->prefix}wl_relation_instances r1
302 302
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -325,36 +325,36 @@  discard block
 block discarded – undo
325 325
  LIMIT %2\$d
326 326
  OFFSET %3\$d
327 327
 EOF
328
-			, $post_id, $limit, $offset, $select, $order_by )
329
-	);
328
+            , $post_id, $limit, $offset, $select, $order_by )
329
+    );
330 330
 }
331 331
 
332 332
 function _wl_network_navigator_get_results(
333
-	$entities, $fields = array(
334
-	'ID',
335
-	'post_title',
333
+    $entities, $fields = array(
334
+    'ID',
335
+    'post_title',
336 336
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
337 337
 ) {
338
-	global $wpdb;
339
-
340
-	$select = implode( ', ', array_map( function ( $item ) {
341
-		return "p.$item AS $item";
342
-	}, (array) $fields ) );
343
-
344
-	$order_by = implode( ', ', array_map( function ( $item ) {
345
-		return "p.$item";
346
-	}, (array) $order_by ) );
347
-
348
-	$entities_in = implode( ',', array_map( function ( $item ) {
349
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
-		if ( isset( $entity ) ) {
351
-			return $entity->ID;
352
-		}
353
-	}, $entities ) );
354
-
355
-	/** @noinspection SqlNoDataSourceInspection */
356
-	return $wpdb->get_results(
357
-		$wpdb->prepare( <<<EOF
338
+    global $wpdb;
339
+
340
+    $select = implode( ', ', array_map( function ( $item ) {
341
+        return "p.$item AS $item";
342
+    }, (array) $fields ) );
343
+
344
+    $order_by = implode( ', ', array_map( function ( $item ) {
345
+        return "p.$item";
346
+    }, (array) $order_by ) );
347
+
348
+    $entities_in = implode( ',', array_map( function ( $item ) {
349
+        $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
+        if ( isset( $entity ) ) {
351
+            return $entity->ID;
352
+        }
353
+    }, $entities ) );
354
+
355
+    /** @noinspection SqlNoDataSourceInspection */
356
+    return $wpdb->get_results(
357
+        $wpdb->prepare( <<<EOF
358 358
 SELECT %3\$s, p2.ID as entity_id
359 359
  FROM {$wpdb->prefix}wl_relation_instances r1
360 360
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
  LIMIT %1\$d
381 381
  OFFSET %2\$d
382 382
 EOF
383
-			, $limit, $offset, $select, $order_by )
384
-	);
383
+            , $limit, $offset, $select, $order_by )
384
+    );
385 385
 
386 386
 }
387 387
 
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function wl_shortcode_navigator_ajax() {
394 394
 
395
-	// Temporary blocking the Navigator.
396
-	$results = wl_shortcode_navigator_data();
397
-	wl_core_send_json( $results );
395
+    // Temporary blocking the Navigator.
396
+    $results = wl_shortcode_navigator_data();
397
+    wl_core_send_json( $results );
398 398
 
399 399
 }
400 400
 
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function wl_shortcode_navigator_wp_json() {
408 408
 
409
-	$results = wl_shortcode_navigator_data();
410
-	if ( ob_get_contents() ) {
411
-		ob_clean();
412
-	}
409
+    $results = wl_shortcode_navigator_data();
410
+    if ( ob_get_contents() ) {
411
+        ob_clean();
412
+    }
413 413
 
414
-	return array(
415
-		'items' => array(
416
-			array( 'values' => $results ),
417
-		),
418
-	);
414
+    return array(
415
+        'items' => array(
416
+            array( 'values' => $results ),
417
+        ),
418
+    );
419 419
 
420 420
 }
421 421
 
@@ -423,22 +423,22 @@  discard block
 block discarded – undo
423 423
  * Adding `rest_api_init` action for amp backend of navigator
424 424
  */
425 425
 add_action( 'rest_api_init', function () {
426
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427
-		'methods'             => 'GET',
428
-		'permission_callback' => '__return_true',
429
-		'callback'            => 'wl_shortcode_navigator_wp_json'
430
-	) );
426
+    register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427
+        'methods'             => 'GET',
428
+        'permission_callback' => '__return_true',
429
+        'callback'            => 'wl_shortcode_navigator_wp_json'
430
+    ) );
431 431
 } );
432 432
 
433 433
 /**
434 434
  * Adding `rest_api_init` action for backend of network navigator
435 435
  */
436 436
 add_action( 'rest_api_init', function () {
437
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
438
-		'methods'             => 'GET',
439
-		'callback'            => 'wl_network_navigator_wp_json',
440
-		'permission_callback' => '__return_true',
441
-	) );
437
+    register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
438
+        'methods'             => 'GET',
439
+        'callback'            => 'wl_network_navigator_wp_json',
440
+        'permission_callback' => '__return_true',
441
+    ) );
442 442
 } );
443 443
 
444 444
 /**
@@ -448,22 +448,22 @@  discard block
 block discarded – undo
448 448
  */
449 449
 add_action( 'plugins_loaded', function () {
450 450
 
451
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
452
-		return;
453
-	}
451
+    if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
452
+        return;
453
+    }
454 454
 
455
-	remove_action( 'plugins_loaded', 'rocket_init' );
456
-	remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
457
-	remove_action( 'plugins_loaded', 'wpseo_init', 14 );
455
+    remove_action( 'plugins_loaded', 'rocket_init' );
456
+    remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
457
+    remove_action( 'plugins_loaded', 'wpseo_init', 14 );
458 458
 }, 0 );
459 459
 
460 460
 add_action( 'init', function () {
461 461
 
462
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
463
-		return;
464
-	}
462
+    if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
463
+        return;
464
+    }
465 465
 
466
-	remove_action( 'init', 'wp_widgets_init', 1 );
467
-	remove_action( 'init', 'gglcptch_init' );
466
+    remove_action( 'init', 'wp_widgets_init', 1 );
467
+    remove_action( 'init', 'gglcptch_init' );
468 468
 }, 0 );
469 469
 
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -18,25 +18,25 @@  discard block
 block discarded – undo
18 18
 
19 19
 	// Create the cache key.
20 20
 	$cache_key_params = $_REQUEST;
21
-	unset( $cache_key_params['uniqid'] );
22
-	$cache_key = array( 'request_params' => $cache_key_params );
21
+	unset($cache_key_params['uniqid']);
22
+	$cache_key = array('request_params' => $cache_key_params);
23 23
 
24 24
 	// Create the TTL cache and try to get the results.
25
-	$cache         = new Ttl_Cache( "navigator", 8 * 60 * 60 ); // 8 hours.
26
-	$cache_results = $cache->get( $cache_key );
25
+	$cache         = new Ttl_Cache("navigator", 8 * 60 * 60); // 8 hours.
26
+	$cache_results = $cache->get($cache_key);
27 27
 
28
-	if ( isset( $cache_results ) ) {
29
-		header( 'X-WordLift-Cache: HIT' );
28
+	if (isset($cache_results)) {
29
+		header('X-WordLift-Cache: HIT');
30 30
 
31 31
 		return $cache_results;
32 32
 	}
33 33
 
34
-	header( 'X-WordLift-Cache: MISS' );
34
+	header('X-WordLift-Cache: MISS');
35 35
 
36 36
 	$results = _wl_navigator_get_data();
37 37
 
38 38
 	// Put the result before sending the json to the client, since sending the json will terminate us.
39
-	$cache->put( $cache_key, $results );
39
+	$cache->put($cache_key, $results);
40 40
 
41 41
 	return $results;
42 42
 }
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
  * @since 3.22.6
52 52
  *
53 53
  */
54
-function wl_network_navigator_wp_json( $request ) {
54
+function wl_network_navigator_wp_json($request) {
55 55
 
56 56
 	// Create the cache key.
57 57
 	$cache_key_params = $_REQUEST;
58
-	unset( $cache_key_params['uniqid'] );
59
-	$cache_key = array( 'request_params' => $cache_key_params );
58
+	unset($cache_key_params['uniqid']);
59
+	$cache_key = array('request_params' => $cache_key_params);
60 60
 
61 61
 	// Create the TTL cache and try to get the results.
62
-	$cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
-	$cache_results = $cache->get( $cache_key );
62
+	$cache         = new Ttl_Cache("network-navigator", 24 * 60 * 60); // 24 hours.
63
+	$cache_results = $cache->get($cache_key);
64 64
 
65
-	if ( isset( $cache_results ) ) {
66
-		header( 'X-WordLift-Cache: HIT' );
65
+	if (isset($cache_results)) {
66
+		header('X-WordLift-Cache: HIT');
67 67
 
68 68
 		return $cache_results;
69 69
 	}
70 70
 
71
-	header( 'X-WordLift-Cache: MISS' );
71
+	header('X-WordLift-Cache: MISS');
72 72
 
73
-	$results = _wl_network_navigator_get_data( $request );
73
+	$results = _wl_network_navigator_get_data($request);
74 74
 
75 75
 	// Put the result before sending the json to the client, since sending the json will terminate us.
76
-	$cache->put( $cache_key, $results );
76
+	$cache->put($cache_key, $results);
77 77
 
78 78
 	return $results;
79 79
 
@@ -82,46 +82,46 @@  discard block
 block discarded – undo
82 82
 function _wl_navigator_get_data() {
83 83
 
84 84
 	// Post ID must be defined
85
-	if ( ! isset( $_GET['post_id'] ) ) {
86
-		wp_send_json_error( 'No post_id given' );
85
+	if ( ! isset($_GET['post_id'])) {
86
+		wp_send_json_error('No post_id given');
87 87
 
88 88
 		return array();
89 89
 	}
90 90
 
91 91
 	// Limit the results (defaults to 4)
92
-	$navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
-	$navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
92
+	$navigator_length = isset($_GET['limit']) ? intval($_GET['limit']) : 4;
93
+	$navigator_offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
94
+	$order_by         = isset($_GET['sort']) ? sanitize_sql_orderby($_GET['sort']) : 'ID DESC';
95 95
 
96 96
 	$current_post_id = $_GET['post_id'];
97
-	$current_post    = get_post( $current_post_id );
97
+	$current_post    = get_post($current_post_id);
98 98
 
99 99
 	$navigator_id = $_GET['uniqid'];
100 100
 
101 101
 	// Post ID has to match an existing item
102
-	if ( null === $current_post ) {
103
-		wp_send_json_error( 'No valid post_id given' );
102
+	if (null === $current_post) {
103
+		wp_send_json_error('No valid post_id given');
104 104
 
105 105
 		return array();
106 106
 	}
107 107
 
108 108
 	// Determine navigator type and call respective _get_results
109
-	if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
-		$referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
109
+	if (get_post_type($current_post_id) === Wordlift_Entity_Service::TYPE_NAME) {
110
+		$referencing_posts = _wl_entity_navigator_get_results($current_post_id, array(
111 111
 			'ID',
112 112
 			'post_title',
113
-		), $order_by, $navigator_length, $navigator_offset );
113
+		), $order_by, $navigator_length, $navigator_offset);
114 114
 	} else {
115
-		$referencing_posts = _wl_navigator_get_results( $current_post_id, array(
115
+		$referencing_posts = _wl_navigator_get_results($current_post_id, array(
116 116
 			'ID',
117 117
 			'post_title',
118
-		), $order_by, $navigator_length, $navigator_offset );
118
+		), $order_by, $navigator_length, $navigator_offset);
119 119
 	}
120 120
 
121 121
 	// loop over them and take the first one which is not already in the $related_posts
122 122
 	$results = array();
123
-	foreach ( $referencing_posts as $referencing_post ) {
124
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
123
+	foreach ($referencing_posts as $referencing_post) {
124
+		$serialized_entity = wl_serialize_entity($referencing_post->entity_id);
125 125
 
126 126
 		/**
127 127
 		 * Use the thumbnail.
@@ -131,58 +131,58 @@  discard block
 block discarded – undo
131 131
 		 *
132 132
 		 * @since 3.19.3 We're using the medium size image.
133 133
 		 */
134
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
134
+		$thumbnail = get_the_post_thumbnail_url($referencing_post, 'medium');
135 135
 
136 136
 		$result = array(
137 137
 			'post'   => array(
138
-				'permalink' => get_permalink( $referencing_post->ID ),
138
+				'permalink' => get_permalink($referencing_post->ID),
139 139
 				'title'     => $referencing_post->post_title,
140 140
 				'thumbnail' => $thumbnail,
141 141
 			),
142 142
 			'entity' => array(
143 143
 				'label'     => $serialized_entity['label'],
144 144
 				'mainType'  => $serialized_entity['mainType'],
145
-				'permalink' => get_permalink( $referencing_post->entity_id ),
145
+				'permalink' => get_permalink($referencing_post->entity_id),
146 146
 			),
147 147
 		);
148 148
 
149
-		$result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
-		$result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
149
+		$result['post']   = apply_filters('wl_navigator_data_post', $result['post'], intval($referencing_post->ID), $navigator_id);
150
+		$result['entity'] = apply_filters('wl_navigator_data_entity', $result['entity'], intval($referencing_post->entity_id), $navigator_id);
151 151
 
152 152
 		$results[] = $result;
153 153
 	}
154 154
 
155
-	if ( count( $results ) < $navigator_length ) {
156
-		$results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
155
+	if (count($results) < $navigator_length) {
156
+		$results = apply_filters('wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length);
157 157
 	}
158 158
 
159 159
 	return $results;
160 160
 }
161 161
 
162
-function _wl_network_navigator_get_data( $request ) {
162
+function _wl_network_navigator_get_data($request) {
163 163
 
164 164
 	// Limit the results (defaults to 4)
165
-	$navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
-	$navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
165
+	$navigator_length = isset($request['limit']) ? intval($request['limit']) : 4;
166
+	$navigator_offset = isset($request['offset']) ? intval($request['offset']) : 0;
167 167
 	$navigator_id     = $request['uniqid'];
168
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
168
+	$order_by         = isset($_GET['sort']) ? sanitize_sql_orderby($_GET['sort']) : 'ID DESC';
169 169
 
170 170
 	$entities = $request['entities'];
171 171
 
172 172
 	// Post ID has to match an existing item
173
-	if ( ! isset( $entities ) || empty( $entities ) ) {
174
-		wp_send_json_error( 'No valid entities provided' );
173
+	if ( ! isset($entities) || empty($entities)) {
174
+		wp_send_json_error('No valid entities provided');
175 175
 	}
176 176
 
177
-	$referencing_posts = _wl_network_navigator_get_results( $entities, array(
177
+	$referencing_posts = _wl_network_navigator_get_results($entities, array(
178 178
 		'ID',
179 179
 		'post_title',
180
-	), $order_by, $navigator_length, $navigator_offset );
180
+	), $order_by, $navigator_length, $navigator_offset);
181 181
 
182 182
 	// loop over them and take the first one which is not already in the $related_posts
183 183
 	$results = array();
184
-	foreach ( $referencing_posts as $referencing_post ) {
185
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
184
+	foreach ($referencing_posts as $referencing_post) {
185
+		$serialized_entity = wl_serialize_entity($referencing_post->entity_id);
186 186
 
187 187
 		/**
188 188
 		 * Use the thumbnail.
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 		 *
193 193
 		 * @since 3.19.3 We're using the medium size image.
194 194
 		 */
195
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
195
+		$thumbnail = get_the_post_thumbnail_url($referencing_post, 'medium');
196 196
 
197 197
 		$result = array(
198 198
 			'post'   => array(
199
-				'permalink' => get_permalink( $referencing_post->ID ),
199
+				'permalink' => get_permalink($referencing_post->ID),
200 200
 				'title'     => $referencing_post->post_title,
201 201
 				'thumbnail' => $thumbnail,
202 202
 			),
203 203
 			'entity' => array(
204 204
 				'label'     => $serialized_entity['label'],
205 205
 				'mainType'  => $serialized_entity['mainType'],
206
-				'permalink' => get_permalink( $referencing_post->entity_id ),
206
+				'permalink' => get_permalink($referencing_post->entity_id),
207 207
 			),
208 208
 		);
209 209
 
210
-		$result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
-		$result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
210
+		$result['post']   = apply_filters('wl_network_navigator_data_post', $result['post'], intval($referencing_post->ID), $navigator_id);
211
+		$result['entity'] = apply_filters('wl_network_navigator_data_entity', $result['entity'], intval($referencing_post->entity_id), $navigator_id);
212 212
 
213 213
 		$results[] = $result;
214 214
 
215 215
 	}
216 216
 
217
-	if ( count( $results ) < $navigator_length ) {
218
-		$results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
217
+	if (count($results) < $navigator_length) {
218
+		$results = apply_filters('wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length);
219 219
 	}
220 220
 
221 221
 	return $results;
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
 ) {
232 232
 	global $wpdb;
233 233
 
234
-	$select = implode( ', ', array_map( function ( $item ) {
234
+	$select = implode(', ', array_map(function($item) {
235 235
 		return "p.$item AS $item";
236
-	}, (array) $fields ) );
236
+	}, (array) $fields));
237 237
 
238
-	$order_by = implode( ', ', array_map( function ( $item ) {
238
+	$order_by = implode(', ', array_map(function($item) {
239 239
 		return "p.$item";
240
-	}, (array) $order_by ) );
240
+	}, (array) $order_by));
241 241
 
242 242
 	/** @noinspection SqlNoDataSourceInspection */
243 243
 	return $wpdb->get_results(
244
-		$wpdb->prepare( <<<EOF
244
+		$wpdb->prepare(<<<EOF
245 245
 SELECT %4\$s, p2.ID as entity_id
246 246
  FROM {$wpdb->prefix}wl_relation_instances r1
247 247
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
  LIMIT %2\$d
274 274
  OFFSET %3\$d
275 275
 EOF
276
-			, $post_id, $limit, $offset, $select, $order_by )
276
+			, $post_id, $limit, $offset, $select, $order_by)
277 277
 	);
278 278
 
279 279
 }
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 ) {
287 287
 	global $wpdb;
288 288
 
289
-	$select = implode( ', ', array_map( function ( $item ) {
289
+	$select = implode(', ', array_map(function($item) {
290 290
 		return "p.$item AS $item";
291
-	}, (array) $fields ) );
291
+	}, (array) $fields));
292 292
 
293
-	$order_by = implode( ', ', array_map( function ( $item ) {
293
+	$order_by = implode(', ', array_map(function($item) {
294 294
 		return "p.$item";
295
-	}, (array) $order_by ) );
295
+	}, (array) $order_by));
296 296
 
297 297
 	/** @noinspection SqlNoDataSourceInspection */
298 298
 	return $wpdb->get_results(
299
-		$wpdb->prepare( <<<EOF
299
+		$wpdb->prepare(<<<EOF
300 300
 SELECT %4\$s, p2.ID as entity_id
301 301
  FROM {$wpdb->prefix}wl_relation_instances r1
302 302
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  LIMIT %2\$d
326 326
  OFFSET %3\$d
327 327
 EOF
328
-			, $post_id, $limit, $offset, $select, $order_by )
328
+			, $post_id, $limit, $offset, $select, $order_by)
329 329
 	);
330 330
 }
331 331
 
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 ) {
338 338
 	global $wpdb;
339 339
 
340
-	$select = implode( ', ', array_map( function ( $item ) {
340
+	$select = implode(', ', array_map(function($item) {
341 341
 		return "p.$item AS $item";
342
-	}, (array) $fields ) );
342
+	}, (array) $fields));
343 343
 
344
-	$order_by = implode( ', ', array_map( function ( $item ) {
344
+	$order_by = implode(', ', array_map(function($item) {
345 345
 		return "p.$item";
346
-	}, (array) $order_by ) );
346
+	}, (array) $order_by));
347 347
 
348
-	$entities_in = implode( ',', array_map( function ( $item ) {
349
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
-		if ( isset( $entity ) ) {
348
+	$entities_in = implode(',', array_map(function($item) {
349
+		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri(urldecode($item));
350
+		if (isset($entity)) {
351 351
 			return $entity->ID;
352 352
 		}
353
-	}, $entities ) );
353
+	}, $entities));
354 354
 
355 355
 	/** @noinspection SqlNoDataSourceInspection */
356 356
 	return $wpdb->get_results(
357
-		$wpdb->prepare( <<<EOF
357
+		$wpdb->prepare(<<<EOF
358 358
 SELECT %3\$s, p2.ID as entity_id
359 359
  FROM {$wpdb->prefix}wl_relation_instances r1
360 360
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
  LIMIT %1\$d
381 381
  OFFSET %2\$d
382 382
 EOF
383
-			, $limit, $offset, $select, $order_by )
383
+			, $limit, $offset, $select, $order_by)
384 384
 	);
385 385
 
386 386
 }
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 
395 395
 	// Temporary blocking the Navigator.
396 396
 	$results = wl_shortcode_navigator_data();
397
-	wl_core_send_json( $results );
397
+	wl_core_send_json($results);
398 398
 
399 399
 }
400 400
 
401
-add_action( 'wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax' );
402
-add_action( 'wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax' );
401
+add_action('wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax');
402
+add_action('wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax');
403 403
 
404 404
 /**
405 405
  * wp-json call for the navigator widget
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 function wl_shortcode_navigator_wp_json() {
408 408
 
409 409
 	$results = wl_shortcode_navigator_data();
410
-	if ( ob_get_contents() ) {
410
+	if (ob_get_contents()) {
411 411
 		ob_clean();
412 412
 	}
413 413
 
414 414
 	return array(
415 415
 		'items' => array(
416
-			array( 'values' => $results ),
416
+			array('values' => $results),
417 417
 		),
418 418
 	);
419 419
 
@@ -422,23 +422,23 @@  discard block
 block discarded – undo
422 422
 /**
423 423
  * Adding `rest_api_init` action for amp backend of navigator
424 424
  */
425
-add_action( 'rest_api_init', function () {
426
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
425
+add_action('rest_api_init', function() {
426
+	register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427 427
 		'methods'             => 'GET',
428 428
 		'permission_callback' => '__return_true',
429 429
 		'callback'            => 'wl_shortcode_navigator_wp_json'
430
-	) );
430
+	));
431 431
 } );
432 432
 
433 433
 /**
434 434
  * Adding `rest_api_init` action for backend of network navigator
435 435
  */
436
-add_action( 'rest_api_init', function () {
437
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
436
+add_action('rest_api_init', function() {
437
+	register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
438 438
 		'methods'             => 'GET',
439 439
 		'callback'            => 'wl_network_navigator_wp_json',
440 440
 		'permission_callback' => '__return_true',
441
-	) );
441
+	));
442 442
 } );
443 443
 
444 444
 /**
@@ -446,24 +446,24 @@  discard block
 block discarded – undo
446 446
  *
447 447
  * @since 2.2.0
448 448
  */
449
-add_action( 'plugins_loaded', function () {
449
+add_action('plugins_loaded', function() {
450 450
 
451
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
451
+	if ( ! defined('DOING_AJAX') || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action']) {
452 452
 		return;
453 453
 	}
454 454
 
455
-	remove_action( 'plugins_loaded', 'rocket_init' );
456
-	remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
457
-	remove_action( 'plugins_loaded', 'wpseo_init', 14 );
458
-}, 0 );
455
+	remove_action('plugins_loaded', 'rocket_init');
456
+	remove_action('plugins_loaded', 'wpseo_premium_init', 14);
457
+	remove_action('plugins_loaded', 'wpseo_init', 14);
458
+}, 0);
459 459
 
460
-add_action( 'init', function () {
460
+add_action('init', function() {
461 461
 
462
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
462
+	if ( ! defined('DOING_AJAX') || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action']) {
463 463
 		return;
464 464
 	}
465 465
 
466
-	remove_action( 'init', 'wp_widgets_init', 1 );
467
-	remove_action( 'init', 'gglcptch_init' );
468
-}, 0 );
466
+	remove_action('init', 'wp_widgets_init', 1);
467
+	remove_action('init', 'gglcptch_init');
468
+}, 0);
469 469
 
Please login to merge, or discard this patch.
src/shortcodes/wordlift_shortcode_faceted_search.php 2 patches
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function wl_shortcode_faceted_search( $request ) {
20 20
 
21
-	// Create the cache key.
22
-	$cache_key = array(
23
-		'request_params' => $_GET,
24
-	);
21
+    // Create the cache key.
22
+    $cache_key = array(
23
+        'request_params' => $_GET,
24
+    );
25 25
 
26
-	// Create the TTL cache and try to get the results.
27
-	$cache         = new Ttl_Cache( "faceted-search", 8 * 60 * 60 ); // 8 hours.
28
-	$cache_results = $cache->get( $cache_key );
26
+    // Create the TTL cache and try to get the results.
27
+    $cache         = new Ttl_Cache( "faceted-search", 8 * 60 * 60 ); // 8 hours.
28
+    $cache_results = $cache->get( $cache_key );
29 29
 
30
-	if ( isset( $cache_results ) ) {
31
-		header( 'X-WordLift-Cache: HIT' );
32
-		wl_core_send_json( $cache_results );
30
+    if ( isset( $cache_results ) ) {
31
+        header( 'X-WordLift-Cache: HIT' );
32
+        wl_core_send_json( $cache_results );
33 33
 
34
-		return;
35
-	}
34
+        return;
35
+    }
36 36
 
37
-	header( 'X-WordLift-Cache: MISS' );
37
+    header( 'X-WordLift-Cache: MISS' );
38 38
 
39
-	$results = wl_shortcode_faceted_search_origin( $request );
39
+    $results = wl_shortcode_faceted_search_origin( $request );
40 40
 
41
-	// Put the result before sending the json to the client, since sending the json will terminate us.
42
-	$cache->put( $cache_key, $results );
41
+    // Put the result before sending the json to the client, since sending the json will terminate us.
42
+    $cache->put( $cache_key, $results );
43 43
 
44
-	wl_core_send_json( $results );
44
+    wl_core_send_json( $results );
45 45
 
46 46
 }
47 47
 
@@ -52,135 +52,135 @@  discard block
 block discarded – undo
52 52
  * @since        3.26.0
53 53
  */
54 54
 function wl_shortcode_faceted_search_origin( $request ) {
55
-	// Post ID must be defined.
56
-	if ( ! isset( $_GET['post_id'] ) ) { // WPCS: input var ok; CSRF ok.
57
-		wp_die( 'No post_id given' );
58
-
59
-		return;
60
-	}
61
-
62
-	$current_post_id = $_GET['post_id']; // WPCS: input var ok; CSRF ok.
63
-	$current_post    = get_post( $current_post_id );
64
-	$faceted_id      = $_GET['uniqid'];
65
-
66
-	// Post ID has to match an existing item.
67
-	if ( null === $current_post ) {
68
-		wp_die( 'No valid post_id given' );
69
-
70
-		return;
71
-	}
72
-
73
-	// If the current post is an entity,
74
-	// the current post is used as main entity.
75
-	// Otherwise, current post related entities are used.
76
-	$entity_service = Wordlift_Entity_Service::get_instance();
77
-	$entity_ids     = $entity_service->is_entity( $current_post->ID ) ?
78
-		array( $current_post->ID ) :
79
-		$entity_service->get_related_entities( $current_post->ID );
80
-
81
-	// If there are no entities we cannot render the widget.
82
-	if ( 0 === count( $entity_ids ) ) {
83
-		/**
84
-		 * If this function is not called from ajax
85
-		 * then this should not throw an error.
86
-		 * Note: Used in scripbox longtail project on json endpoint.
87
-		 */
88
-		if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
89
-			wp_die( 'No entities available' );
90
-		}
91
-
92
-	}
93
-
94
-	$limit = ( isset( $_GET['limit'] ) ) ? (int) $_GET['limit'] : 4;  // WPCS: input var ok; CSRF ok.
95
-	$amp   = ( isset( $_GET['amp'] ) ) ? true : false;
96
-
97
-
98
-	/**
99
-	 * see https://github.com/insideout10/wordlift-plugin/issues/1181
100
-	 * The ordering should be descending by date on default.
101
-	 */
102
-	$order_by = 'DESC';
103
-	if ( isset( $_GET['sort'] ) && is_string( $_GET['sort'] ) ) {
104
-		$order_by = (string) $_GET['sort'];
105
-	}
106
-
107
-	$referencing_posts = Wordlift_Relation_Service::get_instance()->get_article_subjects(
108
-		$entity_ids,
109
-		'*',
110
-		null,
111
-		'publish',
112
-		array( $current_post_id ),
113
-		$limit,
114
-		null,
115
-		$order_by
116
-	);
117
-
118
-	$referencing_post_ids = array_map( function ( $p ) {
119
-		return $p->ID;
120
-	}, $referencing_posts );
121
-
122
-	$post_results   = array();
123
-	$entity_results = array();
124
-
125
-	// Populate $post_results
126
-
127
-	$filtered_posts = ( empty( $filtering_entity_uris ) ) ?
128
-		$referencing_posts :
129
-		Wordlift_Relation_Service::get_instance()->get_article_subjects(
130
-			wl_get_entity_post_ids_by_uris( $filtering_entity_uris ),
131
-			'*',
132
-			null,
133
-			null,
134
-			array(),
135
-			null,
136
-			$referencing_post_ids
137
-		);
138
-
139
-	if ( $filtered_posts ) {
140
-		foreach ( $filtered_posts as $post_obj ) {
141
-
142
-			/**
143
-			 * Use the thumbnail.
144
-			 *
145
-			 * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
146
-			 * @see https://github.com/insideout10/wordlift-plugin/issues/837
147
-			 *
148
-			 * @since 3.19.3 We're using the medium size image.
149
-			 */
150
-			$thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
151
-			$post_obj->thumbnail = ( $thumbnail ) ?
152
-				$thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
153
-			$post_obj->permalink = get_permalink( $post_obj->ID );
154
-
155
-			$result         = $post_obj;
156
-			$post_results[] = $result;
157
-		}
158
-	}
159
-
160
-	// Add filler posts if needed
161
-
162
-	$filler_count         = $limit - count( $post_results );
163
-	$filler_posts         = wl_shortcode_faceted_search_filler_posts( $filler_count, $current_post_id, $referencing_post_ids );
164
-	$post_results         = array_merge( $post_results, $filler_posts );
165
-	$referencing_post_ids = array_map( function ( $post ) {
166
-		return $post->ID;
167
-	}, $post_results );
168
-
169
-	// Populate $entity_results
170
-
171
-	global $wpdb;
172
-
173
-	// Retrieve Wordlift relation instances table name.
174
-	$table_name = wl_core_get_relation_instances_table_name();
175
-
176
-	/*
55
+    // Post ID must be defined.
56
+    if ( ! isset( $_GET['post_id'] ) ) { // WPCS: input var ok; CSRF ok.
57
+        wp_die( 'No post_id given' );
58
+
59
+        return;
60
+    }
61
+
62
+    $current_post_id = $_GET['post_id']; // WPCS: input var ok; CSRF ok.
63
+    $current_post    = get_post( $current_post_id );
64
+    $faceted_id      = $_GET['uniqid'];
65
+
66
+    // Post ID has to match an existing item.
67
+    if ( null === $current_post ) {
68
+        wp_die( 'No valid post_id given' );
69
+
70
+        return;
71
+    }
72
+
73
+    // If the current post is an entity,
74
+    // the current post is used as main entity.
75
+    // Otherwise, current post related entities are used.
76
+    $entity_service = Wordlift_Entity_Service::get_instance();
77
+    $entity_ids     = $entity_service->is_entity( $current_post->ID ) ?
78
+        array( $current_post->ID ) :
79
+        $entity_service->get_related_entities( $current_post->ID );
80
+
81
+    // If there are no entities we cannot render the widget.
82
+    if ( 0 === count( $entity_ids ) ) {
83
+        /**
84
+         * If this function is not called from ajax
85
+         * then this should not throw an error.
86
+         * Note: Used in scripbox longtail project on json endpoint.
87
+         */
88
+        if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
89
+            wp_die( 'No entities available' );
90
+        }
91
+
92
+    }
93
+
94
+    $limit = ( isset( $_GET['limit'] ) ) ? (int) $_GET['limit'] : 4;  // WPCS: input var ok; CSRF ok.
95
+    $amp   = ( isset( $_GET['amp'] ) ) ? true : false;
96
+
97
+
98
+    /**
99
+     * see https://github.com/insideout10/wordlift-plugin/issues/1181
100
+     * The ordering should be descending by date on default.
101
+     */
102
+    $order_by = 'DESC';
103
+    if ( isset( $_GET['sort'] ) && is_string( $_GET['sort'] ) ) {
104
+        $order_by = (string) $_GET['sort'];
105
+    }
106
+
107
+    $referencing_posts = Wordlift_Relation_Service::get_instance()->get_article_subjects(
108
+        $entity_ids,
109
+        '*',
110
+        null,
111
+        'publish',
112
+        array( $current_post_id ),
113
+        $limit,
114
+        null,
115
+        $order_by
116
+    );
117
+
118
+    $referencing_post_ids = array_map( function ( $p ) {
119
+        return $p->ID;
120
+    }, $referencing_posts );
121
+
122
+    $post_results   = array();
123
+    $entity_results = array();
124
+
125
+    // Populate $post_results
126
+
127
+    $filtered_posts = ( empty( $filtering_entity_uris ) ) ?
128
+        $referencing_posts :
129
+        Wordlift_Relation_Service::get_instance()->get_article_subjects(
130
+            wl_get_entity_post_ids_by_uris( $filtering_entity_uris ),
131
+            '*',
132
+            null,
133
+            null,
134
+            array(),
135
+            null,
136
+            $referencing_post_ids
137
+        );
138
+
139
+    if ( $filtered_posts ) {
140
+        foreach ( $filtered_posts as $post_obj ) {
141
+
142
+            /**
143
+             * Use the thumbnail.
144
+             *
145
+             * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
146
+             * @see https://github.com/insideout10/wordlift-plugin/issues/837
147
+             *
148
+             * @since 3.19.3 We're using the medium size image.
149
+             */
150
+            $thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
151
+            $post_obj->thumbnail = ( $thumbnail ) ?
152
+                $thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
153
+            $post_obj->permalink = get_permalink( $post_obj->ID );
154
+
155
+            $result         = $post_obj;
156
+            $post_results[] = $result;
157
+        }
158
+    }
159
+
160
+    // Add filler posts if needed
161
+
162
+    $filler_count         = $limit - count( $post_results );
163
+    $filler_posts         = wl_shortcode_faceted_search_filler_posts( $filler_count, $current_post_id, $referencing_post_ids );
164
+    $post_results         = array_merge( $post_results, $filler_posts );
165
+    $referencing_post_ids = array_map( function ( $post ) {
166
+        return $post->ID;
167
+    }, $post_results );
168
+
169
+    // Populate $entity_results
170
+
171
+    global $wpdb;
172
+
173
+    // Retrieve Wordlift relation instances table name.
174
+    $table_name = wl_core_get_relation_instances_table_name();
175
+
176
+    /*
177 177
 	 * Make sure we have some referenced post, otherwise the IN parts of
178 178
 	 * the SQL will produce an SQL error.
179 179
 	 */
180
-	if ( ! empty( $referencing_post_ids ) ) {
181
-		$subject_ids = implode( ',', $referencing_post_ids );
180
+    if ( ! empty( $referencing_post_ids ) ) {
181
+        $subject_ids = implode( ',', $referencing_post_ids );
182 182
 
183
-		$query = "
183
+        $query = "
184 184
 				SELECT
185 185
 					object_id AS ID,
186 186
 					count( object_id ) AS counter
@@ -192,119 +192,119 @@  discard block
 block discarded – undo
192 192
 				LIMIT $limit;
193 193
 			";
194 194
 
195
-		wl_write_log( "Going to find related entities for the current post [ post ID :: $current_post_id ] [ query :: $query ]" );
195
+        wl_write_log( "Going to find related entities for the current post [ post ID :: $current_post_id ] [ query :: $query ]" );
196 196
 
197
-		$entities = $wpdb->get_results( $query, OBJECT ); // No cache ok.
197
+        $entities = $wpdb->get_results( $query, OBJECT ); // No cache ok.
198 198
 
199
-		wl_write_log( 'Entities found ' . count( $entities ) );
199
+        wl_write_log( 'Entities found ' . count( $entities ) );
200 200
 
201
-		foreach ( $entities as $obj ) {
201
+        foreach ( $entities as $obj ) {
202 202
 
203
-			$entity = get_post( $obj->ID );
203
+            $entity = get_post( $obj->ID );
204 204
 
205
-			// Ensure only valid and published entities are returned.
206
-			if ( ( null !== $entity ) && ( 'publish' === $entity->post_status ) ) {
205
+            // Ensure only valid and published entities are returned.
206
+            if ( ( null !== $entity ) && ( 'publish' === $entity->post_status ) ) {
207 207
 
208
-				$serialized_entity                    = wl_serialize_entity( $entity );
209
-				$serialized_entity['label']           = wl_shortcode_faceted_search_get_the_title( $obj->ID );
210
-				$serialized_entity['counter']         = $obj->counter;
211
-				$serialized_entity['createdAt']       = $entity->post_date;
212
-				$serialized_entity['referencedPosts'] = Wordlift_Relation_Service::get_instance()->get_article_subjects(
213
-					$obj->ID,
214
-					'ids',
215
-					null,
216
-					null,
217
-					array(),
218
-					null,
219
-					$referencing_post_ids
220
-				);
221
-				$entity_results[]                     = $serialized_entity;
222
-			}
223
-		}
224
-	}
208
+                $serialized_entity                    = wl_serialize_entity( $entity );
209
+                $serialized_entity['label']           = wl_shortcode_faceted_search_get_the_title( $obj->ID );
210
+                $serialized_entity['counter']         = $obj->counter;
211
+                $serialized_entity['createdAt']       = $entity->post_date;
212
+                $serialized_entity['referencedPosts'] = Wordlift_Relation_Service::get_instance()->get_article_subjects(
213
+                    $obj->ID,
214
+                    'ids',
215
+                    null,
216
+                    null,
217
+                    array(),
218
+                    null,
219
+                    $referencing_post_ids
220
+                );
221
+                $entity_results[]                     = $serialized_entity;
222
+            }
223
+        }
224
+    }
225 225
 
226
-	$post_results   = apply_filters( 'wl_faceted_data_posts', $post_results, $faceted_id );
227
-	$entity_results = apply_filters( 'wl_faceted_data_entities', $entity_results, $faceted_id );
226
+    $post_results   = apply_filters( 'wl_faceted_data_posts', $post_results, $faceted_id );
227
+    $entity_results = apply_filters( 'wl_faceted_data_entities', $entity_results, $faceted_id );
228 228
 
229
-	return array(
230
-		'posts'    => $amp ? array( array( 'values' => $post_results ) ) : $post_results,
231
-		'entities' => $entity_results
232
-	);
229
+    return array(
230
+        'posts'    => $amp ? array( array( 'values' => $post_results ) ) : $post_results,
231
+        'entities' => $entity_results
232
+    );
233 233
 
234 234
 }
235 235
 
236 236
 function wl_shortcode_faceted_search_get_the_title( $post_id ) {
237 237
 
238
-	$title = get_the_title( $post_id );
238
+    $title = get_the_title( $post_id );
239 239
 
240
-	if ( get_post_type( $post_id ) !== Wordlift_Entity_Service::TYPE_NAME ) {
241
-		$alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id );
240
+    if ( get_post_type( $post_id ) !== Wordlift_Entity_Service::TYPE_NAME ) {
241
+        $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id );
242 242
 
243
-		if ( count( $alternative_labels ) > 0 ) {
244
-			$title = $alternative_labels[0];
245
-		}
246
-	}
243
+        if ( count( $alternative_labels ) > 0 ) {
244
+            $title = $alternative_labels[0];
245
+        }
246
+    }
247 247
 
248
-	return remove_accents( $title );
248
+    return remove_accents( $title );
249 249
 
250 250
 }
251 251
 
252 252
 function wl_shortcode_faceted_search_filler_posts( $filler_count, $current_post_id, $referencing_post_ids ) {
253 253
 
254
-	$filler_posts = array();
255
-
256
-	// First add latest posts from same categories as the current post
257
-	if ( $filler_count > 0 ) {
258
-
259
-		$current_post_categories = wp_get_post_categories( $current_post_id );
260
-
261
-		$args = array(
262
-			'meta_query'          => array(
263
-				array(
264
-					'key' => '_thumbnail_id'
265
-				)
266
-			),
267
-			'category__in'        => $current_post_categories,
268
-			'numberposts'         => $filler_count,
269
-			'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids ),
270
-			'ignore_sticky_posts' => 1
271
-		);
272
-
273
-		$filler_posts = get_posts( $args );
274
-	}
275
-
276
-	$filler_count    = $filler_count - count( $filler_posts );
277
-	$filler_post_ids = array_map( function ( $post ) {
278
-		return $post->ID;
279
-	}, $filler_posts );
280
-
281
-	// If that does not fill, add latest posts irrespective of category
282
-	if ( $filler_count > 0 ) {
283
-
284
-		$args = array(
285
-			'meta_query'          => array(
286
-				array(
287
-					'key' => '_thumbnail_id'
288
-				)
289
-			),
290
-			'numberposts'         => $filler_count,
291
-			'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids, $filler_post_ids ),
292
-			'ignore_sticky_posts' => 1
293
-		);
294
-
295
-		$filler_posts = array_merge( $filler_posts, get_posts( $args ) );
296
-
297
-	}
298
-
299
-	// Add thumbnail and permalink to filler posts
300
-	foreach ( $filler_posts as $post_obj ) {
301
-		$thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
302
-		$post_obj->thumbnail = ( $thumbnail ) ?
303
-			$thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
304
-		$post_obj->permalink = get_permalink( $post_obj->ID );
305
-	}
306
-
307
-	return $filler_posts;
254
+    $filler_posts = array();
255
+
256
+    // First add latest posts from same categories as the current post
257
+    if ( $filler_count > 0 ) {
258
+
259
+        $current_post_categories = wp_get_post_categories( $current_post_id );
260
+
261
+        $args = array(
262
+            'meta_query'          => array(
263
+                array(
264
+                    'key' => '_thumbnail_id'
265
+                )
266
+            ),
267
+            'category__in'        => $current_post_categories,
268
+            'numberposts'         => $filler_count,
269
+            'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids ),
270
+            'ignore_sticky_posts' => 1
271
+        );
272
+
273
+        $filler_posts = get_posts( $args );
274
+    }
275
+
276
+    $filler_count    = $filler_count - count( $filler_posts );
277
+    $filler_post_ids = array_map( function ( $post ) {
278
+        return $post->ID;
279
+    }, $filler_posts );
280
+
281
+    // If that does not fill, add latest posts irrespective of category
282
+    if ( $filler_count > 0 ) {
283
+
284
+        $args = array(
285
+            'meta_query'          => array(
286
+                array(
287
+                    'key' => '_thumbnail_id'
288
+                )
289
+            ),
290
+            'numberposts'         => $filler_count,
291
+            'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids, $filler_post_ids ),
292
+            'ignore_sticky_posts' => 1
293
+        );
294
+
295
+        $filler_posts = array_merge( $filler_posts, get_posts( $args ) );
296
+
297
+    }
298
+
299
+    // Add thumbnail and permalink to filler posts
300
+    foreach ( $filler_posts as $post_obj ) {
301
+        $thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
302
+        $post_obj->thumbnail = ( $thumbnail ) ?
303
+            $thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
304
+        $post_obj->permalink = get_permalink( $post_obj->ID );
305
+    }
306
+
307
+    return $filler_posts;
308 308
 
309 309
 }
310 310
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
  * Adding `rest_api_init` action for network faceted-search
313 313
  */
314 314
 add_action( 'rest_api_init', function () {
315
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search', array(
316
-		'methods'             => 'GET',
317
-		'callback'            => 'wl_shortcode_faceted_search',
318
-		'permission_callback' => '__return_true',
319
-	) );
315
+    register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search', array(
316
+        'methods'             => 'GET',
317
+        'callback'            => 'wl_shortcode_faceted_search',
318
+        'permission_callback' => '__return_true',
319
+    ) );
320 320
 } );
Please login to merge, or discard this patch.
Spacing   +78 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @since 3.21.4 fix the cache key by also using the request body.
17 17
  * @since 3.21.2 add a caching layer.
18 18
  */
19
-function wl_shortcode_faceted_search( $request ) {
19
+function wl_shortcode_faceted_search($request) {
20 20
 
21 21
 	// Create the cache key.
22 22
 	$cache_key = array(
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 	);
25 25
 
26 26
 	// Create the TTL cache and try to get the results.
27
-	$cache         = new Ttl_Cache( "faceted-search", 8 * 60 * 60 ); // 8 hours.
28
-	$cache_results = $cache->get( $cache_key );
27
+	$cache         = new Ttl_Cache("faceted-search", 8 * 60 * 60); // 8 hours.
28
+	$cache_results = $cache->get($cache_key);
29 29
 
30
-	if ( isset( $cache_results ) ) {
31
-		header( 'X-WordLift-Cache: HIT' );
32
-		wl_core_send_json( $cache_results );
30
+	if (isset($cache_results)) {
31
+		header('X-WordLift-Cache: HIT');
32
+		wl_core_send_json($cache_results);
33 33
 
34 34
 		return;
35 35
 	}
36 36
 
37
-	header( 'X-WordLift-Cache: MISS' );
37
+	header('X-WordLift-Cache: MISS');
38 38
 
39
-	$results = wl_shortcode_faceted_search_origin( $request );
39
+	$results = wl_shortcode_faceted_search_origin($request);
40 40
 
41 41
 	// Put the result before sending the json to the client, since sending the json will terminate us.
42
-	$cache->put( $cache_key, $results );
42
+	$cache->put($cache_key, $results);
43 43
 
44
-	wl_core_send_json( $results );
44
+	wl_core_send_json($results);
45 45
 
46 46
 }
47 47
 
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
  * @return array $results
52 52
  * @since        3.26.0
53 53
  */
54
-function wl_shortcode_faceted_search_origin( $request ) {
54
+function wl_shortcode_faceted_search_origin($request) {
55 55
 	// Post ID must be defined.
56
-	if ( ! isset( $_GET['post_id'] ) ) { // WPCS: input var ok; CSRF ok.
57
-		wp_die( 'No post_id given' );
56
+	if ( ! isset($_GET['post_id'])) { // WPCS: input var ok; CSRF ok.
57
+		wp_die('No post_id given');
58 58
 
59 59
 		return;
60 60
 	}
61 61
 
62 62
 	$current_post_id = $_GET['post_id']; // WPCS: input var ok; CSRF ok.
63
-	$current_post    = get_post( $current_post_id );
63
+	$current_post    = get_post($current_post_id);
64 64
 	$faceted_id      = $_GET['uniqid'];
65 65
 
66 66
 	// Post ID has to match an existing item.
67
-	if ( null === $current_post ) {
68
-		wp_die( 'No valid post_id given' );
67
+	if (null === $current_post) {
68
+		wp_die('No valid post_id given');
69 69
 
70 70
 		return;
71 71
 	}
@@ -74,25 +74,24 @@  discard block
 block discarded – undo
74 74
 	// the current post is used as main entity.
75 75
 	// Otherwise, current post related entities are used.
76 76
 	$entity_service = Wordlift_Entity_Service::get_instance();
77
-	$entity_ids     = $entity_service->is_entity( $current_post->ID ) ?
78
-		array( $current_post->ID ) :
79
-		$entity_service->get_related_entities( $current_post->ID );
77
+	$entity_ids     = $entity_service->is_entity($current_post->ID) ?
78
+		array($current_post->ID) : $entity_service->get_related_entities($current_post->ID);
80 79
 
81 80
 	// If there are no entities we cannot render the widget.
82
-	if ( 0 === count( $entity_ids ) ) {
81
+	if (0 === count($entity_ids)) {
83 82
 		/**
84 83
 		 * If this function is not called from ajax
85 84
 		 * then this should not throw an error.
86 85
 		 * Note: Used in scripbox longtail project on json endpoint.
87 86
 		 */
88
-		if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
89
-			wp_die( 'No entities available' );
87
+		if (apply_filters('wp_doing_ajax', defined('DOING_AJAX') && DOING_AJAX)) {
88
+			wp_die('No entities available');
90 89
 		}
91 90
 
92 91
 	}
93 92
 
94
-	$limit = ( isset( $_GET['limit'] ) ) ? (int) $_GET['limit'] : 4;  // WPCS: input var ok; CSRF ok.
95
-	$amp   = ( isset( $_GET['amp'] ) ) ? true : false;
93
+	$limit = (isset($_GET['limit'])) ? (int) $_GET['limit'] : 4; // WPCS: input var ok; CSRF ok.
94
+	$amp   = (isset($_GET['amp'])) ? true : false;
96 95
 
97 96
 
98 97
 	/**
@@ -100,7 +99,7 @@  discard block
 block discarded – undo
100 99
 	 * The ordering should be descending by date on default.
101 100
 	 */
102 101
 	$order_by = 'DESC';
103
-	if ( isset( $_GET['sort'] ) && is_string( $_GET['sort'] ) ) {
102
+	if (isset($_GET['sort']) && is_string($_GET['sort'])) {
104 103
 		$order_by = (string) $_GET['sort'];
105 104
 	}
106 105
 
@@ -109,25 +108,24 @@  discard block
 block discarded – undo
109 108
 		'*',
110 109
 		null,
111 110
 		'publish',
112
-		array( $current_post_id ),
111
+		array($current_post_id),
113 112
 		$limit,
114 113
 		null,
115 114
 		$order_by
116 115
 	);
117 116
 
118
-	$referencing_post_ids = array_map( function ( $p ) {
117
+	$referencing_post_ids = array_map(function($p) {
119 118
 		return $p->ID;
120
-	}, $referencing_posts );
119
+	}, $referencing_posts);
121 120
 
122 121
 	$post_results   = array();
123 122
 	$entity_results = array();
124 123
 
125 124
 	// Populate $post_results
126 125
 
127
-	$filtered_posts = ( empty( $filtering_entity_uris ) ) ?
128
-		$referencing_posts :
129
-		Wordlift_Relation_Service::get_instance()->get_article_subjects(
130
-			wl_get_entity_post_ids_by_uris( $filtering_entity_uris ),
126
+	$filtered_posts = (empty($filtering_entity_uris)) ?
127
+		$referencing_posts : Wordlift_Relation_Service::get_instance()->get_article_subjects(
128
+			wl_get_entity_post_ids_by_uris($filtering_entity_uris),
131 129
 			'*',
132 130
 			null,
133 131
 			null,
@@ -136,8 +134,8 @@  discard block
 block discarded – undo
136 134
 			$referencing_post_ids
137 135
 		);
138 136
 
139
-	if ( $filtered_posts ) {
140
-		foreach ( $filtered_posts as $post_obj ) {
137
+	if ($filtered_posts) {
138
+		foreach ($filtered_posts as $post_obj) {
141 139
 
142 140
 			/**
143 141
 			 * Use the thumbnail.
@@ -147,10 +145,10 @@  discard block
 block discarded – undo
147 145
 			 *
148 146
 			 * @since 3.19.3 We're using the medium size image.
149 147
 			 */
150
-			$thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
151
-			$post_obj->thumbnail = ( $thumbnail ) ?
148
+			$thumbnail           = get_the_post_thumbnail_url($post_obj, 'medium');
149
+			$post_obj->thumbnail = ($thumbnail) ?
152 150
 				$thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
153
-			$post_obj->permalink = get_permalink( $post_obj->ID );
151
+			$post_obj->permalink = get_permalink($post_obj->ID);
154 152
 
155 153
 			$result         = $post_obj;
156 154
 			$post_results[] = $result;
@@ -159,12 +157,12 @@  discard block
 block discarded – undo
159 157
 
160 158
 	// Add filler posts if needed
161 159
 
162
-	$filler_count         = $limit - count( $post_results );
163
-	$filler_posts         = wl_shortcode_faceted_search_filler_posts( $filler_count, $current_post_id, $referencing_post_ids );
164
-	$post_results         = array_merge( $post_results, $filler_posts );
165
-	$referencing_post_ids = array_map( function ( $post ) {
160
+	$filler_count         = $limit - count($post_results);
161
+	$filler_posts         = wl_shortcode_faceted_search_filler_posts($filler_count, $current_post_id, $referencing_post_ids);
162
+	$post_results         = array_merge($post_results, $filler_posts);
163
+	$referencing_post_ids = array_map(function($post) {
166 164
 		return $post->ID;
167
-	}, $post_results );
165
+	}, $post_results);
168 166
 
169 167
 	// Populate $entity_results
170 168
 
@@ -177,8 +175,8 @@  discard block
 block discarded – undo
177 175
 	 * Make sure we have some referenced post, otherwise the IN parts of
178 176
 	 * the SQL will produce an SQL error.
179 177
 	 */
180
-	if ( ! empty( $referencing_post_ids ) ) {
181
-		$subject_ids = implode( ',', $referencing_post_ids );
178
+	if ( ! empty($referencing_post_ids)) {
179
+		$subject_ids = implode(',', $referencing_post_ids);
182 180
 
183 181
 		$query = "
184 182
 				SELECT
@@ -192,21 +190,21 @@  discard block
 block discarded – undo
192 190
 				LIMIT $limit;
193 191
 			";
194 192
 
195
-		wl_write_log( "Going to find related entities for the current post [ post ID :: $current_post_id ] [ query :: $query ]" );
193
+		wl_write_log("Going to find related entities for the current post [ post ID :: $current_post_id ] [ query :: $query ]");
196 194
 
197
-		$entities = $wpdb->get_results( $query, OBJECT ); // No cache ok.
195
+		$entities = $wpdb->get_results($query, OBJECT); // No cache ok.
198 196
 
199
-		wl_write_log( 'Entities found ' . count( $entities ) );
197
+		wl_write_log('Entities found '.count($entities));
200 198
 
201
-		foreach ( $entities as $obj ) {
199
+		foreach ($entities as $obj) {
202 200
 
203
-			$entity = get_post( $obj->ID );
201
+			$entity = get_post($obj->ID);
204 202
 
205 203
 			// Ensure only valid and published entities are returned.
206
-			if ( ( null !== $entity ) && ( 'publish' === $entity->post_status ) ) {
204
+			if ((null !== $entity) && ('publish' === $entity->post_status)) {
207 205
 
208
-				$serialized_entity                    = wl_serialize_entity( $entity );
209
-				$serialized_entity['label']           = wl_shortcode_faceted_search_get_the_title( $obj->ID );
206
+				$serialized_entity                    = wl_serialize_entity($entity);
207
+				$serialized_entity['label']           = wl_shortcode_faceted_search_get_the_title($obj->ID);
210 208
 				$serialized_entity['counter']         = $obj->counter;
211 209
 				$serialized_entity['createdAt']       = $entity->post_date;
212 210
 				$serialized_entity['referencedPosts'] = Wordlift_Relation_Service::get_instance()->get_article_subjects(
@@ -218,45 +216,45 @@  discard block
 block discarded – undo
218 216
 					null,
219 217
 					$referencing_post_ids
220 218
 				);
221
-				$entity_results[]                     = $serialized_entity;
219
+				$entity_results[] = $serialized_entity;
222 220
 			}
223 221
 		}
224 222
 	}
225 223
 
226
-	$post_results   = apply_filters( 'wl_faceted_data_posts', $post_results, $faceted_id );
227
-	$entity_results = apply_filters( 'wl_faceted_data_entities', $entity_results, $faceted_id );
224
+	$post_results   = apply_filters('wl_faceted_data_posts', $post_results, $faceted_id);
225
+	$entity_results = apply_filters('wl_faceted_data_entities', $entity_results, $faceted_id);
228 226
 
229 227
 	return array(
230
-		'posts'    => $amp ? array( array( 'values' => $post_results ) ) : $post_results,
228
+		'posts'    => $amp ? array(array('values' => $post_results)) : $post_results,
231 229
 		'entities' => $entity_results
232 230
 	);
233 231
 
234 232
 }
235 233
 
236
-function wl_shortcode_faceted_search_get_the_title( $post_id ) {
234
+function wl_shortcode_faceted_search_get_the_title($post_id) {
237 235
 
238
-	$title = get_the_title( $post_id );
236
+	$title = get_the_title($post_id);
239 237
 
240
-	if ( get_post_type( $post_id ) !== Wordlift_Entity_Service::TYPE_NAME ) {
241
-		$alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id );
238
+	if (get_post_type($post_id) !== Wordlift_Entity_Service::TYPE_NAME) {
239
+		$alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels($post_id);
242 240
 
243
-		if ( count( $alternative_labels ) > 0 ) {
241
+		if (count($alternative_labels) > 0) {
244 242
 			$title = $alternative_labels[0];
245 243
 		}
246 244
 	}
247 245
 
248
-	return remove_accents( $title );
246
+	return remove_accents($title);
249 247
 
250 248
 }
251 249
 
252
-function wl_shortcode_faceted_search_filler_posts( $filler_count, $current_post_id, $referencing_post_ids ) {
250
+function wl_shortcode_faceted_search_filler_posts($filler_count, $current_post_id, $referencing_post_ids) {
253 251
 
254 252
 	$filler_posts = array();
255 253
 
256 254
 	// First add latest posts from same categories as the current post
257
-	if ( $filler_count > 0 ) {
255
+	if ($filler_count > 0) {
258 256
 
259
-		$current_post_categories = wp_get_post_categories( $current_post_id );
257
+		$current_post_categories = wp_get_post_categories($current_post_id);
260 258
 
261 259
 		$args = array(
262 260
 			'meta_query'          => array(
@@ -266,20 +264,20 @@  discard block
 block discarded – undo
266 264
 			),
267 265
 			'category__in'        => $current_post_categories,
268 266
 			'numberposts'         => $filler_count,
269
-			'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids ),
267
+			'post__not_in'        => array_merge(array($current_post_id), $referencing_post_ids),
270 268
 			'ignore_sticky_posts' => 1
271 269
 		);
272 270
 
273
-		$filler_posts = get_posts( $args );
271
+		$filler_posts = get_posts($args);
274 272
 	}
275 273
 
276
-	$filler_count    = $filler_count - count( $filler_posts );
277
-	$filler_post_ids = array_map( function ( $post ) {
274
+	$filler_count    = $filler_count - count($filler_posts);
275
+	$filler_post_ids = array_map(function($post) {
278 276
 		return $post->ID;
279
-	}, $filler_posts );
277
+	}, $filler_posts);
280 278
 
281 279
 	// If that does not fill, add latest posts irrespective of category
282
-	if ( $filler_count > 0 ) {
280
+	if ($filler_count > 0) {
283 281
 
284 282
 		$args = array(
285 283
 			'meta_query'          => array(
@@ -288,20 +286,20 @@  discard block
 block discarded – undo
288 286
 				)
289 287
 			),
290 288
 			'numberposts'         => $filler_count,
291
-			'post__not_in'        => array_merge( array( $current_post_id ), $referencing_post_ids, $filler_post_ids ),
289
+			'post__not_in'        => array_merge(array($current_post_id), $referencing_post_ids, $filler_post_ids),
292 290
 			'ignore_sticky_posts' => 1
293 291
 		);
294 292
 
295
-		$filler_posts = array_merge( $filler_posts, get_posts( $args ) );
293
+		$filler_posts = array_merge($filler_posts, get_posts($args));
296 294
 
297 295
 	}
298 296
 
299 297
 	// Add thumbnail and permalink to filler posts
300
-	foreach ( $filler_posts as $post_obj ) {
301
-		$thumbnail           = get_the_post_thumbnail_url( $post_obj, 'medium' );
302
-		$post_obj->thumbnail = ( $thumbnail ) ?
298
+	foreach ($filler_posts as $post_obj) {
299
+		$thumbnail           = get_the_post_thumbnail_url($post_obj, 'medium');
300
+		$post_obj->thumbnail = ($thumbnail) ?
303 301
 			$thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
304
-		$post_obj->permalink = get_permalink( $post_obj->ID );
302
+		$post_obj->permalink = get_permalink($post_obj->ID);
305 303
 	}
306 304
 
307 305
 	return $filler_posts;
@@ -311,10 +309,10 @@  discard block
 block discarded – undo
311 309
 /**
312 310
  * Adding `rest_api_init` action for network faceted-search
313 311
  */
314
-add_action( 'rest_api_init', function () {
315
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search', array(
312
+add_action('rest_api_init', function() {
313
+	register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search', array(
316 314
 		'methods'             => 'GET',
317 315
 		'callback'            => 'wl_shortcode_faceted_search',
318 316
 		'permission_callback' => '__return_true',
319
-	) );
317
+	));
320 318
 } );
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 2 patches
Indentation   +1813 added lines, -1813 removed lines patch added patch discarded remove patch
@@ -66,1556 +66,1556 @@  discard block
 block discarded – undo
66 66
  */
67 67
 class Wordlift {
68 68
 
69
-	//<editor-fold desc="## FIELDS">
70
-
71
-	/**
72
-	 * The loader that's responsible for maintaining and registering all hooks that power
73
-	 * the plugin.
74
-	 *
75
-	 * @since    1.0.0
76
-	 * @access   protected
77
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
78
-	 */
79
-	protected $loader;
80
-
81
-	/**
82
-	 * The unique identifier of this plugin.
83
-	 *
84
-	 * @since    1.0.0
85
-	 * @access   protected
86
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
87
-	 */
88
-	protected $plugin_name;
89
-
90
-	/**
91
-	 * The current version of the plugin.
92
-	 *
93
-	 * @since    1.0.0
94
-	 * @access   protected
95
-	 * @var      string $version The current version of the plugin.
96
-	 */
97
-	protected $version;
98
-
99
-	/**
100
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
101
-	 *
102
-	 * @since  3.12.0
103
-	 * @access protected
104
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
105
-	 */
106
-	protected $tinymce_adapter;
107
-
108
-	/**
109
-	 * The {@link Faq_Tinymce_Adapter} instance
110
-	 * @since 3.26.0
111
-	 * @access protected
112
-	 * @var Faq_Tinymce_Adapter $faq_tinymce_adapter .
113
-	 */
114
-	//protected $faq_tinymce_adapter;
115
-
116
-	/**
117
-	 * The Thumbnail service.
118
-	 *
119
-	 * @since  3.1.5
120
-	 * @access private
121
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
122
-	 */
123
-	private $thumbnail_service;
124
-
125
-	/**
126
-	 * The UI service.
127
-	 *
128
-	 * @since  3.2.0
129
-	 * @access private
130
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
131
-	 */
132
-	private $ui_service;
133
-
134
-	/**
135
-	 * The Schema service.
136
-	 *
137
-	 * @since  3.3.0
138
-	 * @access protected
139
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
140
-	 */
141
-	protected $schema_service;
142
-
143
-	/**
144
-	 * The Entity service.
145
-	 *
146
-	 * @since  3.1.0
147
-	 * @access protected
148
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
149
-	 */
150
-	protected $entity_service;
151
-
152
-	/**
153
-	 * The Topic Taxonomy service.
154
-	 *
155
-	 * @since  3.5.0
156
-	 * @access private
157
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
158
-	 */
159
-	private $topic_taxonomy_service;
160
-
161
-	/**
162
-	 * The Entity Types Taxonomy service.
163
-	 *
164
-	 * @since  3.18.0
165
-	 * @access private
166
-	 * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
167
-	 */
168
-	private $entity_types_taxonomy_service;
169
-
170
-	/**
171
-	 * The User service.
172
-	 *
173
-	 * @since  3.1.7
174
-	 * @access protected
175
-	 * @var \Wordlift_User_Service $user_service The User service.
176
-	 */
177
-	protected $user_service;
178
-
179
-	/**
180
-	 * The Timeline service.
181
-	 *
182
-	 * @since  3.1.0
183
-	 * @access private
184
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
185
-	 */
186
-	private $timeline_service;
187
-
188
-	/**
189
-	 * The Redirect service.
190
-	 *
191
-	 * @since  3.2.0
192
-	 * @access private
193
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
194
-	 */
195
-	private $redirect_service;
196
-
197
-	/**
198
-	 * The Notice service.
199
-	 *
200
-	 * @since  3.3.0
201
-	 * @access private
202
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
203
-	 */
204
-	private $notice_service;
205
-
206
-	/**
207
-	 * The Entity list customization.
208
-	 *
209
-	 * @since  3.3.0
210
-	 * @access protected
211
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
212
-	 */
213
-	protected $entity_list_service;
214
-
215
-	/**
216
-	 * The Entity Types Taxonomy Walker.
217
-	 *
218
-	 * @since  3.1.0
219
-	 * @access private
220
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
221
-	 */
222
-	private $entity_types_taxonomy_walker;
223
-
224
-	/**
225
-	 * The ShareThis service.
226
-	 *
227
-	 * @since  3.2.0
228
-	 * @access private
229
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
230
-	 */
231
-	private $sharethis_service;
232
-
233
-	/**
234
-	 * The PrimaShop adapter.
235
-	 *
236
-	 * @since  3.2.3
237
-	 * @access private
238
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
239
-	 */
240
-	private $primashop_adapter;
241
-
242
-	/**
243
-	 * The WordLift Dashboard adapter.
244
-	 *
245
-	 * @since  3.4.0
246
-	 * @access private
247
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
248
-	 */
249
-	private $dashboard_service;
250
-
251
-	/**
252
-	 * The entity type service.
253
-	 *
254
-	 * @since  3.6.0
255
-	 * @access private
256
-	 * @var \Wordlift_Entity_Post_Type_Service
257
-	 */
258
-	private $entity_post_type_service;
259
-
260
-	/**
261
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
262
-	 *
263
-	 * @since  3.6.0
264
-	 * @access private
265
-	 * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
266
-	 */
267
-	private $entity_link_service;
268
-
269
-	/**
270
-	 * A {@link Wordlift_Sparql_Service} instance.
271
-	 *
272
-	 * @since    3.6.0
273
-	 * @access   protected
274
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
275
-	 */
276
-	protected $sparql_service;
277
-
278
-	/**
279
-	 * A {@link Wordlift_Import_Service} instance.
280
-	 *
281
-	 * @since  3.6.0
282
-	 * @access private
283
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
284
-	 */
285
-	private $import_service;
286
-
287
-	/**
288
-	 * A {@link Wordlift_Rebuild_Service} instance.
289
-	 *
290
-	 * @since  3.6.0
291
-	 * @access private
292
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
293
-	 */
294
-	private $rebuild_service;
295
-
296
-	/**
297
-	 * A {@link Wordlift_Jsonld_Service} instance.
298
-	 *
299
-	 * @since  3.7.0
300
-	 * @access protected
301
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
302
-	 */
303
-	protected $jsonld_service;
304
-
305
-	/**
306
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
307
-	 *
308
-	 * @since  3.14.0
309
-	 * @access protected
310
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
311
-	 */
312
-	protected $jsonld_website_converter;
313
-
314
-	/**
315
-	 * A {@link Wordlift_Property_Factory} instance.
316
-	 *
317
-	 * @since  3.7.0
318
-	 * @access private
319
-	 * @var \Wordlift_Property_Factory $property_factory
320
-	 */
321
-	private $property_factory;
322
-
323
-	/**
324
-	 * The 'Download Your Data' page.
325
-	 *
326
-	 * @since  3.6.0
327
-	 * @access private
328
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
329
-	 */
330
-	private $download_your_data_page;
331
-
332
-	/**
333
-	 * The 'WordLift Settings' page.
334
-	 *
335
-	 * @since  3.11.0
336
-	 * @access protected
337
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
338
-	 */
339
-	protected $settings_page;
340
-
341
-	/**
342
-	 * The install wizard page.
343
-	 *
344
-	 * @since  3.9.0
345
-	 * @access private
346
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
347
-	 */
348
-	public $admin_setup;
349
-
350
-	/**
351
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
352
-	 * linking of entities to their pages.
353
-	 *
354
-	 * @since  3.8.0
355
-	 * @access private
356
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
357
-	 */
358
-	private $content_filter_service;
359
-
360
-	/**
361
-	 * The Faq Content filter service
362
-	 * @since  3.26.0
363
-	 * @access private
364
-	 * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance.
365
-	 */
366
-	private $faq_content_filter_service;
367
-
368
-	/**
369
-	 * A {@link Wordlift_Key_Validation_Service} instance.
370
-	 *
371
-	 * @since  3.9.0
372
-	 * @access private
373
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
374
-	 */
375
-	private $key_validation_service;
376
-
377
-	/**
378
-	 * A {@link Wordlift_Rating_Service} instance.
379
-	 *
380
-	 * @since  3.10.0
381
-	 * @access private
382
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
383
-	 */
384
-	private $rating_service;
385
-
386
-	/**
387
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
388
-	 *
389
-	 * @since  3.10.0
390
-	 * @access protected
391
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
392
-	 */
393
-	protected $post_to_jsonld_converter;
394
-
395
-	/**
396
-	 * A {@link Wordlift_Configuration_Service} instance.
397
-	 *
398
-	 * @since  3.10.0
399
-	 * @access protected
400
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
401
-	 */
402
-	protected $configuration_service;
403
-
404
-	/**
405
-	 * A {@link Wordlift_Install_Service} instance.
406
-	 *
407
-	 * @since  3.18.0
408
-	 * @access protected
409
-	 * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
410
-	 */
411
-	protected $install_service;
412
-
413
-	/**
414
-	 * A {@link Wordlift_Entity_Type_Service} instance.
415
-	 *
416
-	 * @since  3.10.0
417
-	 * @access protected
418
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
419
-	 */
420
-	protected $entity_type_service;
421
-
422
-	/**
423
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
424
-	 *
425
-	 * @since  3.10.0
426
-	 * @access protected
427
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
428
-	 */
429
-	protected $entity_post_to_jsonld_converter;
430
-
431
-	/**
432
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
433
-	 *
434
-	 * @since  3.10.0
435
-	 * @access protected
436
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
437
-	 */
438
-	protected $postid_to_jsonld_converter;
439
-
440
-	/**
441
-	 * The {@link Wordlift_Admin_Status_Page} class.
442
-	 *
443
-	 * @since  3.9.8
444
-	 * @access private
445
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
446
-	 */
447
-	private $status_page;
448
-
449
-	/**
450
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
451
-	 *
452
-	 * @since  3.11.0
453
-	 * @access protected
454
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
455
-	 */
456
-	protected $category_taxonomy_service;
457
-
458
-	/**
459
-	 * The {@link Wordlift_Entity_Page_Service} instance.
460
-	 *
461
-	 * @since  3.11.0
462
-	 * @access protected
463
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
464
-	 */
465
-	protected $entity_page_service;
466
-
467
-	/**
468
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
469
-	 *
470
-	 * @since  3.11.0
471
-	 * @access protected
472
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
473
-	 */
474
-	protected $settings_page_action_link;
475
-
476
-	/**
477
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
478
-	 *
479
-	 * @since  3.11.0
480
-	 * @access protected
481
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
482
-	 */
483
-	protected $analytics_settings_page_action_link;
484
-
485
-	/**
486
-	 * The {@link Wordlift_Analytics_Connect} class.
487
-	 *
488
-	 * @since  3.11.0
489
-	 * @access protected
490
-	 * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
491
-	 */
492
-	protected $analytics_connect;
493
-
494
-	/**
495
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
496
-	 *
497
-	 * @since  3.11.0
498
-	 * @access protected
499
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
500
-	 */
501
-	protected $publisher_ajax_adapter;
502
-
503
-	/**
504
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
505
-	 *
506
-	 * @since  3.11.0
507
-	 * @access protected
508
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
509
-	 */
510
-	protected $input_element;
511
-
512
-	/**
513
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
514
-	 *
515
-	 * @since  3.13.0
516
-	 * @access protected
517
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
518
-	 */
519
-	protected $radio_input_element;
520
-
521
-	/**
522
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
523
-	 *
524
-	 * @since  3.11.0
525
-	 * @access protected
526
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
527
-	 */
528
-	protected $language_select_element;
529
-
530
-	/**
531
-	 * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
532
-	 *
533
-	 * @since  3.18.0
534
-	 * @access protected
535
-	 * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
536
-	 */
537
-	protected $country_select_element;
538
-
539
-	/**
540
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
541
-	 *
542
-	 * @since  3.11.0
543
-	 * @access protected
544
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
545
-	 */
546
-	protected $publisher_element;
547
-
548
-	/**
549
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
550
-	 *
551
-	 * @since  3.11.0
552
-	 * @access protected
553
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
554
-	 */
555
-	protected $select2_element;
556
-
557
-	/**
558
-	 * The controller for the entity type list admin page
559
-	 *
560
-	 * @since  3.11.0
561
-	 * @access private
562
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
563
-	 */
564
-	private $entity_type_admin_page;
565
-
566
-	/**
567
-	 * The controller for the entity type settings admin page
568
-	 *
569
-	 * @since  3.11.0
570
-	 * @access private
571
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
572
-	 */
573
-	private $entity_type_settings_admin_page;
574
-
575
-	/**
576
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
577
-	 *
578
-	 * @since  3.11.0
579
-	 * @access protected
580
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
581
-	 */
582
-	protected $related_entities_cloud_widget;
583
-
584
-	/**
585
-	 * The {@link Wordlift_Admin_Author_Element} instance.
586
-	 *
587
-	 * @since  3.14.0
588
-	 * @access protected
589
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
590
-	 */
591
-	protected $author_element;
592
-
593
-	/**
594
-	 * The {@link Wordlift_Sample_Data_Service} instance.
595
-	 *
596
-	 * @since  3.12.0
597
-	 * @access protected
598
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
599
-	 */
600
-	protected $sample_data_service;
601
-
602
-	/**
603
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
604
-	 *
605
-	 * @since  3.12.0
606
-	 * @access protected
607
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
608
-	 */
609
-	protected $sample_data_ajax_adapter;
610
-
611
-	/**
612
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
613
-	 *
614
-	 * @since  3.14.3
615
-	 * @access private
616
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
617
-	 */
618
-	private $relation_rebuild_service;
619
-
620
-	/**
621
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
622
-	 *
623
-	 * @since  3.14.3
624
-	 * @access private
625
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
626
-	 */
627
-	private $relation_rebuild_adapter;
628
-
629
-	/**
630
-	 * The {@link Wordlift_Reference_Rebuild_Service} instance.
631
-	 *
632
-	 * @since  3.18.0
633
-	 * @access private
634
-	 * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance.
635
-	 */
636
-	private $reference_rebuild_service;
637
-
638
-	/**
639
-	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
640
-	 *
641
-	 * @since  3.16.0
642
-	 * @access protected
643
-	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
644
-	 */
645
-	protected $google_analytics_export_service;
646
-
647
-	/**
648
-	 * {@link Wordlift}'s singleton instance.
649
-	 *
650
-	 * @since  3.15.0
651
-	 * @access protected
652
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
653
-	 */
654
-	protected $entity_type_adapter;
655
-
656
-	/**
657
-	 * The {@link Wordlift_Storage_Factory} instance.
658
-	 *
659
-	 * @since  3.15.0
660
-	 * @access protected
661
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
662
-	 */
663
-	protected $storage_factory;
664
-
665
-	/**
666
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
667
-	 *
668
-	 * @since  3.15.0
669
-	 * @access protected
670
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
671
-	 */
672
-	protected $rendition_factory;
673
-
674
-	/**
675
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
676
-	 *
677
-	 * @since  3.15.0
678
-	 * @access private
679
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
680
-	 */
681
-	private $autocomplete_adapter;
682
-
683
-	/**
684
-	 * The {@link Wordlift_Relation_Service} instance.
685
-	 *
686
-	 * @since  3.15.0
687
-	 * @access protected
688
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
689
-	 */
690
-	protected $relation_service;
691
-
692
-	/**
693
-	 * The {@link Wordlift_Cached_Post_Converter} instance.
694
-	 *
695
-	 * @since  3.16.0
696
-	 * @access protected
697
-	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
698
-	 *
699
-	 */
700
-	protected $cached_postid_to_jsonld_converter;
701
-
702
-	/**
703
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
704
-	 *
705
-	 * @since  3.16.3
706
-	 * @access protected
707
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
708
-	 */
709
-	protected $entity_uri_service;
710
-
711
-	/**
712
-	 * The {@link Wordlift_Publisher_Service} instance.
713
-	 *
714
-	 * @since  3.19.0
715
-	 * @access protected
716
-	 * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
717
-	 */
718
-	protected $publisher_service;
719
-
720
-	/**
721
-	 * The {@link Wordlift_Context_Cards_Service} instance.
722
-	 *
723
-	 * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
724
-	 */
725
-	protected $context_cards_service;
726
-
727
-	/**
728
-	 * {@link Wordlift}'s singleton instance.
729
-	 *
730
-	 * @since  3.11.2
731
-	 * @access private
732
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
733
-	 */
734
-	private static $instance;
735
-
736
-	//</editor-fold>
737
-
738
-	/**
739
-	 * Define the core functionality of the plugin.
740
-	 *
741
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
742
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
743
-	 * the public-facing side of the site.
744
-	 *
745
-	 * @since    1.0.0
746
-	 */
747
-	public function __construct() {
748
-
749
-		self::$instance = $this;
750
-
751
-		$this->plugin_name = 'wordlift';
752
-		$this->version     = '3.27.7';
753
-		$this->load_dependencies();
754
-		$this->set_locale();
755
-		$this->define_admin_hooks();
756
-		$this->define_public_hooks();
757
-
758
-		// If we're in `WP_CLI` load the related files.
759
-		if ( class_exists( 'WP_CLI' ) ) {
760
-			$this->load_cli_dependencies();
761
-		}
762
-
763
-	}
764
-
765
-	/**
766
-	 * Get the singleton instance.
767
-	 *
768
-	 * @return Wordlift The {@link Wordlift} singleton instance.
769
-	 * @since 3.11.2
770
-	 *
771
-	 */
772
-	public static function get_instance() {
773
-
774
-		return self::$instance;
775
-	}
776
-
777
-	/**
778
-	 * Load the required dependencies for this plugin.
779
-	 *
780
-	 * Include the following files that make up the plugin:
781
-	 *
782
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
783
-	 * - Wordlift_i18n. Defines internationalization functionality.
784
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
785
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
786
-	 *
787
-	 * Create an instance of the loader which will be used to register the hooks
788
-	 * with WordPress.
789
-	 *
790
-	 * @throws Exception
791
-	 * @since    1.0.0
792
-	 * @access   private
793
-	 */
794
-	private function load_dependencies() {
795
-
796
-		/**
797
-		 * The class responsible for orchestrating the actions and filters of the
798
-		 * core plugin.
799
-		 */
800
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
801
-
802
-		// The class responsible for plugin uninstall.
803
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
804
-
805
-		/**
806
-		 * The class responsible for defining internationalization functionality
807
-		 * of the plugin.
808
-		 */
809
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
810
-
811
-		/**
812
-		 * WordLift's supported languages.
813
-		 */
814
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
815
-
816
-		/**
817
-		 * WordLift's supported countries.
818
-		 */
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
820
-
821
-		/**
822
-		 * Provide support functions to sanitize data.
823
-		 */
824
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
825
-
826
-		/** Services. */
827
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
829
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
833
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
834
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
835
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
836
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
837
-
838
-		/**
839
-		 * The Query builder.
840
-		 */
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
842
-
843
-		/**
844
-		 * The Schema service.
845
-		 */
846
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
847
-
848
-		/**
849
-		 * The schema:url property service.
850
-		 */
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
853
-
854
-		/**
855
-		 * The UI service.
856
-		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
858
-
859
-		/**
860
-		 * The Thumbnail service.
861
-		 */
862
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
863
-
864
-		/**
865
-		 * The Entity Types Taxonomy service.
866
-		 */
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
868
-
869
-		/**
870
-		 * The Entity service.
871
-		 */
872
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
873
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
874
-
875
-		// Add the entity rating service.
876
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
877
-
878
-		/**
879
-		 * The User service.
880
-		 */
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
882
-
883
-		/**
884
-		 * The Timeline service.
885
-		 */
886
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
887
-
888
-		/**
889
-		 * The Topic Taxonomy service.
890
-		 */
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
892
-
893
-		/**
894
-		 * The SPARQL service.
895
-		 */
896
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
897
-
898
-		/**
899
-		 * The WordLift import service.
900
-		 */
901
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
902
-
903
-		/**
904
-		 * The WordLift URI service.
905
-		 */
906
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
908
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
909
-
910
-		/**
911
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
912
-		 */
913
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
914
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
916
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
917
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
918
-
919
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
921
-
922
-		/**
923
-		 * Load the converters.
924
-		 */
925
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
926
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
928
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
929
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
931
-
932
-		/**
933
-		 * Load cache-related files.
934
-		 */
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
936
-
937
-		/**
938
-		 * Load the content filter.
939
-		 */
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
941
-
942
-		/*
69
+    //<editor-fold desc="## FIELDS">
70
+
71
+    /**
72
+     * The loader that's responsible for maintaining and registering all hooks that power
73
+     * the plugin.
74
+     *
75
+     * @since    1.0.0
76
+     * @access   protected
77
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
78
+     */
79
+    protected $loader;
80
+
81
+    /**
82
+     * The unique identifier of this plugin.
83
+     *
84
+     * @since    1.0.0
85
+     * @access   protected
86
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
87
+     */
88
+    protected $plugin_name;
89
+
90
+    /**
91
+     * The current version of the plugin.
92
+     *
93
+     * @since    1.0.0
94
+     * @access   protected
95
+     * @var      string $version The current version of the plugin.
96
+     */
97
+    protected $version;
98
+
99
+    /**
100
+     * The {@link Wordlift_Tinymce_Adapter} instance.
101
+     *
102
+     * @since  3.12.0
103
+     * @access protected
104
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
105
+     */
106
+    protected $tinymce_adapter;
107
+
108
+    /**
109
+     * The {@link Faq_Tinymce_Adapter} instance
110
+     * @since 3.26.0
111
+     * @access protected
112
+     * @var Faq_Tinymce_Adapter $faq_tinymce_adapter .
113
+     */
114
+    //protected $faq_tinymce_adapter;
115
+
116
+    /**
117
+     * The Thumbnail service.
118
+     *
119
+     * @since  3.1.5
120
+     * @access private
121
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
122
+     */
123
+    private $thumbnail_service;
124
+
125
+    /**
126
+     * The UI service.
127
+     *
128
+     * @since  3.2.0
129
+     * @access private
130
+     * @var \Wordlift_UI_Service $ui_service The UI service.
131
+     */
132
+    private $ui_service;
133
+
134
+    /**
135
+     * The Schema service.
136
+     *
137
+     * @since  3.3.0
138
+     * @access protected
139
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
140
+     */
141
+    protected $schema_service;
142
+
143
+    /**
144
+     * The Entity service.
145
+     *
146
+     * @since  3.1.0
147
+     * @access protected
148
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
149
+     */
150
+    protected $entity_service;
151
+
152
+    /**
153
+     * The Topic Taxonomy service.
154
+     *
155
+     * @since  3.5.0
156
+     * @access private
157
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
158
+     */
159
+    private $topic_taxonomy_service;
160
+
161
+    /**
162
+     * The Entity Types Taxonomy service.
163
+     *
164
+     * @since  3.18.0
165
+     * @access private
166
+     * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
167
+     */
168
+    private $entity_types_taxonomy_service;
169
+
170
+    /**
171
+     * The User service.
172
+     *
173
+     * @since  3.1.7
174
+     * @access protected
175
+     * @var \Wordlift_User_Service $user_service The User service.
176
+     */
177
+    protected $user_service;
178
+
179
+    /**
180
+     * The Timeline service.
181
+     *
182
+     * @since  3.1.0
183
+     * @access private
184
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
185
+     */
186
+    private $timeline_service;
187
+
188
+    /**
189
+     * The Redirect service.
190
+     *
191
+     * @since  3.2.0
192
+     * @access private
193
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
194
+     */
195
+    private $redirect_service;
196
+
197
+    /**
198
+     * The Notice service.
199
+     *
200
+     * @since  3.3.0
201
+     * @access private
202
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
203
+     */
204
+    private $notice_service;
205
+
206
+    /**
207
+     * The Entity list customization.
208
+     *
209
+     * @since  3.3.0
210
+     * @access protected
211
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
212
+     */
213
+    protected $entity_list_service;
214
+
215
+    /**
216
+     * The Entity Types Taxonomy Walker.
217
+     *
218
+     * @since  3.1.0
219
+     * @access private
220
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
221
+     */
222
+    private $entity_types_taxonomy_walker;
223
+
224
+    /**
225
+     * The ShareThis service.
226
+     *
227
+     * @since  3.2.0
228
+     * @access private
229
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
230
+     */
231
+    private $sharethis_service;
232
+
233
+    /**
234
+     * The PrimaShop adapter.
235
+     *
236
+     * @since  3.2.3
237
+     * @access private
238
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
239
+     */
240
+    private $primashop_adapter;
241
+
242
+    /**
243
+     * The WordLift Dashboard adapter.
244
+     *
245
+     * @since  3.4.0
246
+     * @access private
247
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
248
+     */
249
+    private $dashboard_service;
250
+
251
+    /**
252
+     * The entity type service.
253
+     *
254
+     * @since  3.6.0
255
+     * @access private
256
+     * @var \Wordlift_Entity_Post_Type_Service
257
+     */
258
+    private $entity_post_type_service;
259
+
260
+    /**
261
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
262
+     *
263
+     * @since  3.6.0
264
+     * @access private
265
+     * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
266
+     */
267
+    private $entity_link_service;
268
+
269
+    /**
270
+     * A {@link Wordlift_Sparql_Service} instance.
271
+     *
272
+     * @since    3.6.0
273
+     * @access   protected
274
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
275
+     */
276
+    protected $sparql_service;
277
+
278
+    /**
279
+     * A {@link Wordlift_Import_Service} instance.
280
+     *
281
+     * @since  3.6.0
282
+     * @access private
283
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
284
+     */
285
+    private $import_service;
286
+
287
+    /**
288
+     * A {@link Wordlift_Rebuild_Service} instance.
289
+     *
290
+     * @since  3.6.0
291
+     * @access private
292
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
293
+     */
294
+    private $rebuild_service;
295
+
296
+    /**
297
+     * A {@link Wordlift_Jsonld_Service} instance.
298
+     *
299
+     * @since  3.7.0
300
+     * @access protected
301
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
302
+     */
303
+    protected $jsonld_service;
304
+
305
+    /**
306
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
307
+     *
308
+     * @since  3.14.0
309
+     * @access protected
310
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
311
+     */
312
+    protected $jsonld_website_converter;
313
+
314
+    /**
315
+     * A {@link Wordlift_Property_Factory} instance.
316
+     *
317
+     * @since  3.7.0
318
+     * @access private
319
+     * @var \Wordlift_Property_Factory $property_factory
320
+     */
321
+    private $property_factory;
322
+
323
+    /**
324
+     * The 'Download Your Data' page.
325
+     *
326
+     * @since  3.6.0
327
+     * @access private
328
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
329
+     */
330
+    private $download_your_data_page;
331
+
332
+    /**
333
+     * The 'WordLift Settings' page.
334
+     *
335
+     * @since  3.11.0
336
+     * @access protected
337
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
338
+     */
339
+    protected $settings_page;
340
+
341
+    /**
342
+     * The install wizard page.
343
+     *
344
+     * @since  3.9.0
345
+     * @access private
346
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
347
+     */
348
+    public $admin_setup;
349
+
350
+    /**
351
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
352
+     * linking of entities to their pages.
353
+     *
354
+     * @since  3.8.0
355
+     * @access private
356
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
357
+     */
358
+    private $content_filter_service;
359
+
360
+    /**
361
+     * The Faq Content filter service
362
+     * @since  3.26.0
363
+     * @access private
364
+     * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance.
365
+     */
366
+    private $faq_content_filter_service;
367
+
368
+    /**
369
+     * A {@link Wordlift_Key_Validation_Service} instance.
370
+     *
371
+     * @since  3.9.0
372
+     * @access private
373
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
374
+     */
375
+    private $key_validation_service;
376
+
377
+    /**
378
+     * A {@link Wordlift_Rating_Service} instance.
379
+     *
380
+     * @since  3.10.0
381
+     * @access private
382
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
383
+     */
384
+    private $rating_service;
385
+
386
+    /**
387
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
388
+     *
389
+     * @since  3.10.0
390
+     * @access protected
391
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
392
+     */
393
+    protected $post_to_jsonld_converter;
394
+
395
+    /**
396
+     * A {@link Wordlift_Configuration_Service} instance.
397
+     *
398
+     * @since  3.10.0
399
+     * @access protected
400
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
401
+     */
402
+    protected $configuration_service;
403
+
404
+    /**
405
+     * A {@link Wordlift_Install_Service} instance.
406
+     *
407
+     * @since  3.18.0
408
+     * @access protected
409
+     * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
410
+     */
411
+    protected $install_service;
412
+
413
+    /**
414
+     * A {@link Wordlift_Entity_Type_Service} instance.
415
+     *
416
+     * @since  3.10.0
417
+     * @access protected
418
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
419
+     */
420
+    protected $entity_type_service;
421
+
422
+    /**
423
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
424
+     *
425
+     * @since  3.10.0
426
+     * @access protected
427
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
428
+     */
429
+    protected $entity_post_to_jsonld_converter;
430
+
431
+    /**
432
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
433
+     *
434
+     * @since  3.10.0
435
+     * @access protected
436
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
437
+     */
438
+    protected $postid_to_jsonld_converter;
439
+
440
+    /**
441
+     * The {@link Wordlift_Admin_Status_Page} class.
442
+     *
443
+     * @since  3.9.8
444
+     * @access private
445
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
446
+     */
447
+    private $status_page;
448
+
449
+    /**
450
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
451
+     *
452
+     * @since  3.11.0
453
+     * @access protected
454
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
455
+     */
456
+    protected $category_taxonomy_service;
457
+
458
+    /**
459
+     * The {@link Wordlift_Entity_Page_Service} instance.
460
+     *
461
+     * @since  3.11.0
462
+     * @access protected
463
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
464
+     */
465
+    protected $entity_page_service;
466
+
467
+    /**
468
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
469
+     *
470
+     * @since  3.11.0
471
+     * @access protected
472
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
473
+     */
474
+    protected $settings_page_action_link;
475
+
476
+    /**
477
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
478
+     *
479
+     * @since  3.11.0
480
+     * @access protected
481
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
482
+     */
483
+    protected $analytics_settings_page_action_link;
484
+
485
+    /**
486
+     * The {@link Wordlift_Analytics_Connect} class.
487
+     *
488
+     * @since  3.11.0
489
+     * @access protected
490
+     * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
491
+     */
492
+    protected $analytics_connect;
493
+
494
+    /**
495
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
496
+     *
497
+     * @since  3.11.0
498
+     * @access protected
499
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
500
+     */
501
+    protected $publisher_ajax_adapter;
502
+
503
+    /**
504
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
505
+     *
506
+     * @since  3.11.0
507
+     * @access protected
508
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
509
+     */
510
+    protected $input_element;
511
+
512
+    /**
513
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
514
+     *
515
+     * @since  3.13.0
516
+     * @access protected
517
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
518
+     */
519
+    protected $radio_input_element;
520
+
521
+    /**
522
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
523
+     *
524
+     * @since  3.11.0
525
+     * @access protected
526
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
527
+     */
528
+    protected $language_select_element;
529
+
530
+    /**
531
+     * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
532
+     *
533
+     * @since  3.18.0
534
+     * @access protected
535
+     * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
536
+     */
537
+    protected $country_select_element;
538
+
539
+    /**
540
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
541
+     *
542
+     * @since  3.11.0
543
+     * @access protected
544
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
545
+     */
546
+    protected $publisher_element;
547
+
548
+    /**
549
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
550
+     *
551
+     * @since  3.11.0
552
+     * @access protected
553
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
554
+     */
555
+    protected $select2_element;
556
+
557
+    /**
558
+     * The controller for the entity type list admin page
559
+     *
560
+     * @since  3.11.0
561
+     * @access private
562
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
563
+     */
564
+    private $entity_type_admin_page;
565
+
566
+    /**
567
+     * The controller for the entity type settings admin page
568
+     *
569
+     * @since  3.11.0
570
+     * @access private
571
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
572
+     */
573
+    private $entity_type_settings_admin_page;
574
+
575
+    /**
576
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
577
+     *
578
+     * @since  3.11.0
579
+     * @access protected
580
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
581
+     */
582
+    protected $related_entities_cloud_widget;
583
+
584
+    /**
585
+     * The {@link Wordlift_Admin_Author_Element} instance.
586
+     *
587
+     * @since  3.14.0
588
+     * @access protected
589
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
590
+     */
591
+    protected $author_element;
592
+
593
+    /**
594
+     * The {@link Wordlift_Sample_Data_Service} instance.
595
+     *
596
+     * @since  3.12.0
597
+     * @access protected
598
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
599
+     */
600
+    protected $sample_data_service;
601
+
602
+    /**
603
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
604
+     *
605
+     * @since  3.12.0
606
+     * @access protected
607
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
608
+     */
609
+    protected $sample_data_ajax_adapter;
610
+
611
+    /**
612
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
613
+     *
614
+     * @since  3.14.3
615
+     * @access private
616
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
617
+     */
618
+    private $relation_rebuild_service;
619
+
620
+    /**
621
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
622
+     *
623
+     * @since  3.14.3
624
+     * @access private
625
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
626
+     */
627
+    private $relation_rebuild_adapter;
628
+
629
+    /**
630
+     * The {@link Wordlift_Reference_Rebuild_Service} instance.
631
+     *
632
+     * @since  3.18.0
633
+     * @access private
634
+     * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance.
635
+     */
636
+    private $reference_rebuild_service;
637
+
638
+    /**
639
+     * The {@link Wordlift_Google_Analytics_Export_Service} instance.
640
+     *
641
+     * @since  3.16.0
642
+     * @access protected
643
+     * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
644
+     */
645
+    protected $google_analytics_export_service;
646
+
647
+    /**
648
+     * {@link Wordlift}'s singleton instance.
649
+     *
650
+     * @since  3.15.0
651
+     * @access protected
652
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
653
+     */
654
+    protected $entity_type_adapter;
655
+
656
+    /**
657
+     * The {@link Wordlift_Storage_Factory} instance.
658
+     *
659
+     * @since  3.15.0
660
+     * @access protected
661
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
662
+     */
663
+    protected $storage_factory;
664
+
665
+    /**
666
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
667
+     *
668
+     * @since  3.15.0
669
+     * @access protected
670
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
671
+     */
672
+    protected $rendition_factory;
673
+
674
+    /**
675
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
676
+     *
677
+     * @since  3.15.0
678
+     * @access private
679
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
680
+     */
681
+    private $autocomplete_adapter;
682
+
683
+    /**
684
+     * The {@link Wordlift_Relation_Service} instance.
685
+     *
686
+     * @since  3.15.0
687
+     * @access protected
688
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
689
+     */
690
+    protected $relation_service;
691
+
692
+    /**
693
+     * The {@link Wordlift_Cached_Post_Converter} instance.
694
+     *
695
+     * @since  3.16.0
696
+     * @access protected
697
+     * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
698
+     *
699
+     */
700
+    protected $cached_postid_to_jsonld_converter;
701
+
702
+    /**
703
+     * The {@link Wordlift_Entity_Uri_Service} instance.
704
+     *
705
+     * @since  3.16.3
706
+     * @access protected
707
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
708
+     */
709
+    protected $entity_uri_service;
710
+
711
+    /**
712
+     * The {@link Wordlift_Publisher_Service} instance.
713
+     *
714
+     * @since  3.19.0
715
+     * @access protected
716
+     * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
717
+     */
718
+    protected $publisher_service;
719
+
720
+    /**
721
+     * The {@link Wordlift_Context_Cards_Service} instance.
722
+     *
723
+     * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
724
+     */
725
+    protected $context_cards_service;
726
+
727
+    /**
728
+     * {@link Wordlift}'s singleton instance.
729
+     *
730
+     * @since  3.11.2
731
+     * @access private
732
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
733
+     */
734
+    private static $instance;
735
+
736
+    //</editor-fold>
737
+
738
+    /**
739
+     * Define the core functionality of the plugin.
740
+     *
741
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
742
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
743
+     * the public-facing side of the site.
744
+     *
745
+     * @since    1.0.0
746
+     */
747
+    public function __construct() {
748
+
749
+        self::$instance = $this;
750
+
751
+        $this->plugin_name = 'wordlift';
752
+        $this->version     = '3.27.7';
753
+        $this->load_dependencies();
754
+        $this->set_locale();
755
+        $this->define_admin_hooks();
756
+        $this->define_public_hooks();
757
+
758
+        // If we're in `WP_CLI` load the related files.
759
+        if ( class_exists( 'WP_CLI' ) ) {
760
+            $this->load_cli_dependencies();
761
+        }
762
+
763
+    }
764
+
765
+    /**
766
+     * Get the singleton instance.
767
+     *
768
+     * @return Wordlift The {@link Wordlift} singleton instance.
769
+     * @since 3.11.2
770
+     *
771
+     */
772
+    public static function get_instance() {
773
+
774
+        return self::$instance;
775
+    }
776
+
777
+    /**
778
+     * Load the required dependencies for this plugin.
779
+     *
780
+     * Include the following files that make up the plugin:
781
+     *
782
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
783
+     * - Wordlift_i18n. Defines internationalization functionality.
784
+     * - Wordlift_Admin. Defines all hooks for the admin area.
785
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
786
+     *
787
+     * Create an instance of the loader which will be used to register the hooks
788
+     * with WordPress.
789
+     *
790
+     * @throws Exception
791
+     * @since    1.0.0
792
+     * @access   private
793
+     */
794
+    private function load_dependencies() {
795
+
796
+        /**
797
+         * The class responsible for orchestrating the actions and filters of the
798
+         * core plugin.
799
+         */
800
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
801
+
802
+        // The class responsible for plugin uninstall.
803
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
804
+
805
+        /**
806
+         * The class responsible for defining internationalization functionality
807
+         * of the plugin.
808
+         */
809
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
810
+
811
+        /**
812
+         * WordLift's supported languages.
813
+         */
814
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
815
+
816
+        /**
817
+         * WordLift's supported countries.
818
+         */
819
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
820
+
821
+        /**
822
+         * Provide support functions to sanitize data.
823
+         */
824
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
825
+
826
+        /** Services. */
827
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
828
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
829
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
830
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
831
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
832
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
833
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
834
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
835
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
836
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
837
+
838
+        /**
839
+         * The Query builder.
840
+         */
841
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
842
+
843
+        /**
844
+         * The Schema service.
845
+         */
846
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
847
+
848
+        /**
849
+         * The schema:url property service.
850
+         */
851
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
853
+
854
+        /**
855
+         * The UI service.
856
+         */
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
858
+
859
+        /**
860
+         * The Thumbnail service.
861
+         */
862
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
863
+
864
+        /**
865
+         * The Entity Types Taxonomy service.
866
+         */
867
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
868
+
869
+        /**
870
+         * The Entity service.
871
+         */
872
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
873
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
874
+
875
+        // Add the entity rating service.
876
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
877
+
878
+        /**
879
+         * The User service.
880
+         */
881
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
882
+
883
+        /**
884
+         * The Timeline service.
885
+         */
886
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
887
+
888
+        /**
889
+         * The Topic Taxonomy service.
890
+         */
891
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
892
+
893
+        /**
894
+         * The SPARQL service.
895
+         */
896
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
897
+
898
+        /**
899
+         * The WordLift import service.
900
+         */
901
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
902
+
903
+        /**
904
+         * The WordLift URI service.
905
+         */
906
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
907
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
908
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
909
+
910
+        /**
911
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
912
+         */
913
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
914
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
915
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
916
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
917
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
918
+
919
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
920
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
921
+
922
+        /**
923
+         * Load the converters.
924
+         */
925
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
926
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
927
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
928
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
929
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
930
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
931
+
932
+        /**
933
+         * Load cache-related files.
934
+         */
935
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
936
+
937
+        /**
938
+         * Load the content filter.
939
+         */
940
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
941
+
942
+        /*
943 943
 		 * Load the excerpt helper.
944 944
 		 */
945
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
946
-
947
-		/**
948
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
949
-		 *
950
-		 * @since 3.8.0
951
-		 */
952
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
953
-
954
-		// The Publisher Service and the AJAX adapter.
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
956
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
957
-
958
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
959
-
960
-		/**
961
-		 * Load the WordLift key validation service.
962
-		 */
963
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
964
-
965
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
966
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
967
-
968
-		// Load the `Wordlift_Entity_Page_Service` class definition.
969
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
970
-
971
-		/** Linked Data. */
972
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
973
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
974
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
976
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
981
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
983
-
984
-		/** Linked Data Rendition. */
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
986
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
987
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
988
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
989
-
990
-		/** Services. */
991
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
992
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
993
-
994
-		/** Adapters. */
995
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
996
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
997
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
998
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
999
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
1000
-
1001
-		/** Async Tasks. */
1002
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
1004
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
1005
-
1006
-		/** Autocomplete. */
1007
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
1008
-
1009
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
1010
-
1011
-		/** Analytics */
1012
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
1013
-
1014
-		/**
1015
-		 * The class responsible for defining all actions that occur in the admin area.
1016
-		 */
1017
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
1018
-
1019
-		/**
1020
-		 * The class to customize the entity list admin page.
1021
-		 */
1022
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
1023
-
1024
-		/**
1025
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
1026
-		 */
1027
-		global $wp_version;
1028
-		if ( version_compare( $wp_version, '5.3', '<' ) ) {
1029
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
1030
-		} else {
1031
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1032
-		}
1033
-
1034
-		/**
1035
-		 * The Notice service.
1036
-		 */
1037
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1038
-
1039
-		/**
1040
-		 * The PrimaShop adapter.
1041
-		 */
1042
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1043
-
1044
-		/**
1045
-		 * The WordLift Dashboard service.
1046
-		 */
1047
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1048
-
1049
-		/**
1050
-		 * The admin 'Install wizard' page.
1051
-		 */
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1053
-
1054
-		/**
1055
-		 * The WordLift entity type list admin page controller.
1056
-		 */
1057
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1058
-
1059
-		/**
1060
-		 * The WordLift entity type settings admin page controller.
1061
-		 */
1062
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1063
-
1064
-		/**
1065
-		 * The admin 'Download Your Data' page.
1066
-		 */
1067
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1068
-
1069
-		/**
1070
-		 * The admin 'WordLift Settings' page.
1071
-		 */
1072
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
1073
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
1074
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
1075
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
1076
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
1077
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
1078
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
1079
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
1080
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
1081
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
1082
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1083
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1084
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
1085
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1086
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1087
-
1088
-		/** Admin Pages */
1089
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1090
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1091
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php';
1092
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1093
-
1094
-		/**
1095
-		 * The class responsible for defining all actions that occur in the public-facing
1096
-		 * side of the site.
1097
-		 */
1098
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1099
-
1100
-		/**
1101
-		 * The shortcode abstract class.
1102
-		 */
1103
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1104
-
1105
-		/**
1106
-		 * The Timeline shortcode.
1107
-		 */
1108
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1109
-
1110
-		/**
1111
-		 * The Navigator shortcode.
1112
-		 */
1113
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1114
-
1115
-		/**
1116
-		 * The Products Navigator shortcode.
1117
-		 */
1118
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php';
1119
-
1120
-		/**
1121
-		 * The chord shortcode.
1122
-		 */
1123
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1124
-
1125
-		/**
1126
-		 * The geomap shortcode.
1127
-		 */
1128
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1129
-
1130
-		/**
1131
-		 * The entity cloud shortcode.
1132
-		 */
1133
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1134
-
1135
-		/**
1136
-		 * The entity glossary shortcode.
1137
-		 */
1138
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1139
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1140
-
1141
-		/**
1142
-		 * Faceted Search shortcode.
1143
-		 */
1144
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
1145
-
1146
-		/**
1147
-		 * The ShareThis service.
1148
-		 */
1149
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1150
-
1151
-		/**
1152
-		 * The SEO service.
1153
-		 */
1154
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1155
-
1156
-		/**
1157
-		 * The AMP service.
1158
-		 */
1159
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1160
-
1161
-		/** Widgets */
1162
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1163
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1164
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1165
-
1166
-		/*
945
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
946
+
947
+        /**
948
+         * Load the JSON-LD service to publish entities using JSON-LD.s
949
+         *
950
+         * @since 3.8.0
951
+         */
952
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
953
+
954
+        // The Publisher Service and the AJAX adapter.
955
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
956
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
957
+
958
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
959
+
960
+        /**
961
+         * Load the WordLift key validation service.
962
+         */
963
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
964
+
965
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
966
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
967
+
968
+        // Load the `Wordlift_Entity_Page_Service` class definition.
969
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
970
+
971
+        /** Linked Data. */
972
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
973
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
974
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
975
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
976
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
977
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
978
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
979
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
980
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
981
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
982
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
983
+
984
+        /** Linked Data Rendition. */
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
986
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
987
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
988
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
989
+
990
+        /** Services. */
991
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
992
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
993
+
994
+        /** Adapters. */
995
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
996
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
997
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
998
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
999
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
1000
+
1001
+        /** Async Tasks. */
1002
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
1003
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
1004
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
1005
+
1006
+        /** Autocomplete. */
1007
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
1008
+
1009
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
1010
+
1011
+        /** Analytics */
1012
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
1013
+
1014
+        /**
1015
+         * The class responsible for defining all actions that occur in the admin area.
1016
+         */
1017
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
1018
+
1019
+        /**
1020
+         * The class to customize the entity list admin page.
1021
+         */
1022
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
1023
+
1024
+        /**
1025
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
1026
+         */
1027
+        global $wp_version;
1028
+        if ( version_compare( $wp_version, '5.3', '<' ) ) {
1029
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
1030
+        } else {
1031
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1032
+        }
1033
+
1034
+        /**
1035
+         * The Notice service.
1036
+         */
1037
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1038
+
1039
+        /**
1040
+         * The PrimaShop adapter.
1041
+         */
1042
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1043
+
1044
+        /**
1045
+         * The WordLift Dashboard service.
1046
+         */
1047
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1048
+
1049
+        /**
1050
+         * The admin 'Install wizard' page.
1051
+         */
1052
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1053
+
1054
+        /**
1055
+         * The WordLift entity type list admin page controller.
1056
+         */
1057
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1058
+
1059
+        /**
1060
+         * The WordLift entity type settings admin page controller.
1061
+         */
1062
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1063
+
1064
+        /**
1065
+         * The admin 'Download Your Data' page.
1066
+         */
1067
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1068
+
1069
+        /**
1070
+         * The admin 'WordLift Settings' page.
1071
+         */
1072
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
1073
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
1074
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
1075
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
1076
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
1077
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
1078
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
1079
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
1080
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
1081
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
1082
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1083
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1084
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
1085
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1086
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1087
+
1088
+        /** Admin Pages */
1089
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1090
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1091
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php';
1092
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1093
+
1094
+        /**
1095
+         * The class responsible for defining all actions that occur in the public-facing
1096
+         * side of the site.
1097
+         */
1098
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1099
+
1100
+        /**
1101
+         * The shortcode abstract class.
1102
+         */
1103
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1104
+
1105
+        /**
1106
+         * The Timeline shortcode.
1107
+         */
1108
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1109
+
1110
+        /**
1111
+         * The Navigator shortcode.
1112
+         */
1113
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1114
+
1115
+        /**
1116
+         * The Products Navigator shortcode.
1117
+         */
1118
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php';
1119
+
1120
+        /**
1121
+         * The chord shortcode.
1122
+         */
1123
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1124
+
1125
+        /**
1126
+         * The geomap shortcode.
1127
+         */
1128
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1129
+
1130
+        /**
1131
+         * The entity cloud shortcode.
1132
+         */
1133
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1134
+
1135
+        /**
1136
+         * The entity glossary shortcode.
1137
+         */
1138
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1139
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1140
+
1141
+        /**
1142
+         * Faceted Search shortcode.
1143
+         */
1144
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
1145
+
1146
+        /**
1147
+         * The ShareThis service.
1148
+         */
1149
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1150
+
1151
+        /**
1152
+         * The SEO service.
1153
+         */
1154
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1155
+
1156
+        /**
1157
+         * The AMP service.
1158
+         */
1159
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1160
+
1161
+        /** Widgets */
1162
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1163
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1164
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1165
+
1166
+        /*
1167 1167
 		 * Schema.org Services.
1168 1168
 		 *
1169 1169
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1170 1170
 		 */
1171
-		if ( WL_ALL_ENTITY_TYPES ) {
1172
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1173
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1174
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1175
-			new Wordlift_Schemaorg_Sync_Service();
1176
-			$schemaorg_property_service = new Wordlift_Schemaorg_Property_Service();
1177
-			new Wordlift_Schemaorg_Class_Service();
1178
-		} else {
1179
-			$schemaorg_property_service = null;
1180
-		}
1171
+        if ( WL_ALL_ENTITY_TYPES ) {
1172
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1173
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1174
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1175
+            new Wordlift_Schemaorg_Sync_Service();
1176
+            $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service();
1177
+            new Wordlift_Schemaorg_Class_Service();
1178
+        } else {
1179
+            $schemaorg_property_service = null;
1180
+        }
1181 1181
 
1182
-		$this->loader = new Wordlift_Loader();
1182
+        $this->loader = new Wordlift_Loader();
1183 1183
 
1184
-		// Instantiate a global logger.
1185
-		global $wl_logger;
1186
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1184
+        // Instantiate a global logger.
1185
+        global $wl_logger;
1186
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1187 1187
 
1188
-		// Load the `wl-api` end-point.
1189
-		new Wordlift_Http_Api();
1188
+        // Load the `wl-api` end-point.
1189
+        new Wordlift_Http_Api();
1190 1190
 
1191
-		// Load the Install Service.
1192
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1193
-		$this->install_service = new Wordlift_Install_Service();
1191
+        // Load the Install Service.
1192
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1193
+        $this->install_service = new Wordlift_Install_Service();
1194 1194
 
1195
-		/** Services. */
1196
-		// Create the configuration service.
1197
-		$this->configuration_service = new Wordlift_Configuration_Service();
1198
-		$api_service                 = new Wordlift_Api_Service( $this->configuration_service );
1195
+        /** Services. */
1196
+        // Create the configuration service.
1197
+        $this->configuration_service = new Wordlift_Configuration_Service();
1198
+        $api_service                 = new Wordlift_Api_Service( $this->configuration_service );
1199 1199
 
1200
-		// Create an entity type service instance. It'll be later bound to the init action.
1201
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1200
+        // Create an entity type service instance. It'll be later bound to the init action.
1201
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1202 1202
 
1203
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1204
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1203
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1204
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1205 1205
 
1206
-		// Create an instance of the UI service.
1207
-		$this->ui_service = new Wordlift_UI_Service();
1206
+        // Create an instance of the UI service.
1207
+        $this->ui_service = new Wordlift_UI_Service();
1208 1208
 
1209
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1210
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1209
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1210
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1211 1211
 
1212
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1213
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1214
-		$this->notice_service        = new Wordlift_Notice_Service();
1215
-		$this->relation_service      = new Wordlift_Relation_Service();
1212
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1213
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1214
+        $this->notice_service        = new Wordlift_Notice_Service();
1215
+        $this->relation_service      = new Wordlift_Relation_Service();
1216 1216
 
1217
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1218
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1219
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1220
-		$this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1217
+        $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1218
+        $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1219
+        $this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1220
+        $this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1221 1221
 
1222
-		// Instantiate the JSON-LD service.
1223
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1222
+        // Instantiate the JSON-LD service.
1223
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1224 1224
 
1225
-		/** Linked Data. */
1226
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1227
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1225
+        /** Linked Data. */
1226
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1227
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1228 1228
 
1229
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1229
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1230 1230
 
1231
-		// Create a new instance of the Redirect service.
1232
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_uri_service );
1233
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1231
+        // Create a new instance of the Redirect service.
1232
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_uri_service );
1233
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1234 1234
 
1235
-		if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1236
-			new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1237
-		}
1235
+        if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1236
+            new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1237
+        }
1238 1238
 
1239
-		// Create a new instance of the Timeline service and Timeline shortcode.
1240
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1239
+        // Create a new instance of the Timeline service and Timeline shortcode.
1240
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1241 1241
 
1242
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1242
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1243 1243
 
1244
-		$this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1245
-		$this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1244
+        $this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1245
+        $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1246 1246
 
1247
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1248
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1247
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1248
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1249 1249
 
1250
-		// Create an instance of the PrimaShop adapter.
1251
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1250
+        // Create an instance of the PrimaShop adapter.
1251
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1252 1252
 
1253
-		// Create an import service instance to hook later to WP's import function.
1254
-		$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() );
1253
+        // Create an import service instance to hook later to WP's import function.
1254
+        $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() );
1255 1255
 
1256
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1256
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1257 1257
 
1258
-		// Create the entity rating service.
1259
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1258
+        // Create the entity rating service.
1259
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1260 1260
 
1261
-		// Create entity list customization (wp-admin/edit.php).
1262
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1261
+        // Create entity list customization (wp-admin/edit.php).
1262
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1263 1263
 
1264
-		// Create a new instance of the Redirect service.
1265
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1264
+        // Create a new instance of the Redirect service.
1265
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1266 1266
 
1267
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1268
-		$this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1269
-		$this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1270
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1267
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1268
+        $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1269
+        $this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1270
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1271 1271
 
1272
-		$attachment_service = new Wordlift_Attachment_Service();
1272
+        $attachment_service = new Wordlift_Attachment_Service();
1273 1273
 
1274
-		// Instantiate the JSON-LD service.
1275
-		$property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1276
-		$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 );
1277
-		$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, $schemaorg_property_service, $this->post_to_jsonld_converter );
1278
-		$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 );
1279
-		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1274
+        // Instantiate the JSON-LD service.
1275
+        $property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1276
+        $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 );
1277
+        $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, $schemaorg_property_service, $this->post_to_jsonld_converter );
1278
+        $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 );
1279
+        $this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1280 1280
 
1281
-		$jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1282
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache );
1283
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1281
+        $jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1282
+        $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache );
1283
+        $this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1284 1284
 
1285
-		/*
1285
+        /*
1286 1286
 		 * Load the `Wordlift_Term_JsonLd_Adapter`.
1287 1287
 		 *
1288 1288
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/892
1289 1289
 		 *
1290 1290
 		 * @since 3.20.0
1291 1291
 		 */
1292
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1293
-		$term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service );
1294
-		$jsonld_service      = new Jsonld_Service(
1295
-			$this->jsonld_service,
1296
-			$term_jsonld_adapter,
1297
-			new Jsonld_User_Service( $this->user_service ) );
1298
-		new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service );
1299
-
1300
-		// Prints the JSON-LD in the head.
1301
-		new Jsonld_Adapter( $this->jsonld_service );
1302
-
1303
-		new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service );
1304
-
1305
-		$this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service );
1306
-		$this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1307
-		// Creating Faq Content filter service.
1308
-		$this->faq_content_filter_service = new Faq_Content_Filter();
1309
-		$this->relation_rebuild_service   = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1310
-		$this->sample_data_service        = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1311
-		$this->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1312
-		$this->reference_rebuild_service  = new Wordlift_Reference_Rebuild_Service( $this->entity_service );
1313
-
1314
-		$this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' );
1315
-
1316
-		/**
1317
-		 * Filter: wl_feature__enable__blocks.
1318
-		 *
1319
-		 * @param bool whether the blocks needed to be registered, defaults to true.
1320
-		 *
1321
-		 * @return bool
1322
-		 * @since 3.27.6
1323
-		 */
1324
-		if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1325
-			// Initialize the short-codes.
1326
-			new Wordlift_Navigator_Shortcode();
1327
-			new Wordlift_Chord_Shortcode();
1328
-			new Wordlift_Geomap_Shortcode();
1329
-			new Wordlift_Timeline_Shortcode();
1330
-			new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1331
-			new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1332
-			new Wordlift_Faceted_Search_Shortcode();
1333
-		}
1334
-
1335
-		new Wordlift_Products_Navigator_Shortcode();
1336
-
1337
-
1338
-		// Initialize the Context Cards Service
1339
-		$this->context_cards_service = new Wordlift_Context_Cards_Service();
1340
-
1341
-		// Initialize the SEO service.
1342
-		new Wordlift_Seo_Service();
1343
-
1344
-		// Initialize the AMP service.
1345
-		new Wordlift_AMP_Service( $this->jsonld_service );
1346
-
1347
-		/** Services. */
1348
-		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1349
-		new Wordlift_Image_Service();
1350
-
1351
-		/** Adapters. */
1352
-		$this->entity_type_adapter    = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1353
-		$this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1354
-		$this->tinymce_adapter        = new Wordlift_Tinymce_Adapter( $this );
1355
-		//$this->faq_tinymce_adapter      = new Faq_Tinymce_Adapter();
1356
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1357
-
1358
-		/*
1292
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1293
+        $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service );
1294
+        $jsonld_service      = new Jsonld_Service(
1295
+            $this->jsonld_service,
1296
+            $term_jsonld_adapter,
1297
+            new Jsonld_User_Service( $this->user_service ) );
1298
+        new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service );
1299
+
1300
+        // Prints the JSON-LD in the head.
1301
+        new Jsonld_Adapter( $this->jsonld_service );
1302
+
1303
+        new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service );
1304
+
1305
+        $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service );
1306
+        $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1307
+        // Creating Faq Content filter service.
1308
+        $this->faq_content_filter_service = new Faq_Content_Filter();
1309
+        $this->relation_rebuild_service   = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1310
+        $this->sample_data_service        = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1311
+        $this->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1312
+        $this->reference_rebuild_service  = new Wordlift_Reference_Rebuild_Service( $this->entity_service );
1313
+
1314
+        $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' );
1315
+
1316
+        /**
1317
+         * Filter: wl_feature__enable__blocks.
1318
+         *
1319
+         * @param bool whether the blocks needed to be registered, defaults to true.
1320
+         *
1321
+         * @return bool
1322
+         * @since 3.27.6
1323
+         */
1324
+        if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1325
+            // Initialize the short-codes.
1326
+            new Wordlift_Navigator_Shortcode();
1327
+            new Wordlift_Chord_Shortcode();
1328
+            new Wordlift_Geomap_Shortcode();
1329
+            new Wordlift_Timeline_Shortcode();
1330
+            new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1331
+            new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1332
+            new Wordlift_Faceted_Search_Shortcode();
1333
+        }
1334
+
1335
+        new Wordlift_Products_Navigator_Shortcode();
1336
+
1337
+
1338
+        // Initialize the Context Cards Service
1339
+        $this->context_cards_service = new Wordlift_Context_Cards_Service();
1340
+
1341
+        // Initialize the SEO service.
1342
+        new Wordlift_Seo_Service();
1343
+
1344
+        // Initialize the AMP service.
1345
+        new Wordlift_AMP_Service( $this->jsonld_service );
1346
+
1347
+        /** Services. */
1348
+        $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1349
+        new Wordlift_Image_Service();
1350
+
1351
+        /** Adapters. */
1352
+        $this->entity_type_adapter    = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1353
+        $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1354
+        $this->tinymce_adapter        = new Wordlift_Tinymce_Adapter( $this );
1355
+        //$this->faq_tinymce_adapter      = new Faq_Tinymce_Adapter();
1356
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1357
+
1358
+        /*
1359 1359
 		 * Exclude our public js from WP-Rocket.
1360 1360
 		 *
1361 1361
 		 * @since 3.19.4
1362 1362
 		 *
1363 1363
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
1364 1364
 		 */
1365
-		new Wordlift_WpRocket_Adapter();
1366
-
1367
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1368
-		$this->rebuild_service = new Wordlift_Rebuild_Service(
1369
-			$this->sparql_service,
1370
-			$uri_service
1371
-		);
1372
-
1373
-		/** Async Tasks. */
1374
-		if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1375
-			new Wordlift_Sparql_Query_Async_Task();
1376
-			new Wordlift_Push_References_Async_Task();
1377
-		}
1378
-
1379
-		/** WordPress Admin UI. */
1380
-
1381
-		// UI elements.
1382
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1383
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1384
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1385
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1386
-		$this->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1387
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1388
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1389
-		$this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1390
-
1391
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element );
1392
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1393
-
1394
-		$this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element );
1395
-		$this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page );
1396
-		$this->analytics_connect                   = new Wordlift_Analytics_Connect();
1397
-
1398
-		// Pages.
1399
-		/*
1365
+        new Wordlift_WpRocket_Adapter();
1366
+
1367
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1368
+        $this->rebuild_service = new Wordlift_Rebuild_Service(
1369
+            $this->sparql_service,
1370
+            $uri_service
1371
+        );
1372
+
1373
+        /** Async Tasks. */
1374
+        if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1375
+            new Wordlift_Sparql_Query_Async_Task();
1376
+            new Wordlift_Push_References_Async_Task();
1377
+        }
1378
+
1379
+        /** WordPress Admin UI. */
1380
+
1381
+        // UI elements.
1382
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1383
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1384
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1385
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1386
+        $this->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1387
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1388
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1389
+        $this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1390
+
1391
+        $this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element );
1392
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1393
+
1394
+        $this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element );
1395
+        $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page );
1396
+        $this->analytics_connect                   = new Wordlift_Analytics_Connect();
1397
+
1398
+        // Pages.
1399
+        /*
1400 1400
 		 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
1401 1401
 		 *
1402 1402
 		 * @since 3.20.3
1403 1403
 		 *
1404 1404
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/914
1405 1405
 		 */
1406
-		if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1407
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1408
-			new Wordlift_Admin_Post_Edit_Page( $this );
1409
-		}
1410
-		new Wordlift_Entity_Type_Admin_Service();
1406
+        if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1407
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1408
+            new Wordlift_Admin_Post_Edit_Page( $this );
1409
+        }
1410
+        new Wordlift_Entity_Type_Admin_Service();
1411 1411
 
1412
-		// create an instance of the entity type list admin page controller.
1413
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1412
+        // create an instance of the entity type list admin page controller.
1413
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1414 1414
 
1415
-		// create an instance of the entity type setting admin page controller.
1416
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1415
+        // create an instance of the entity type setting admin page controller.
1416
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1417 1417
 
1418
-		/** Widgets */
1419
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1418
+        /** Widgets */
1419
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1420 1420
 
1421
-		/* WordPress Admin. */
1422
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1423
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1421
+        /* WordPress Admin. */
1422
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1423
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1424 1424
 
1425
-		// Create an instance of the install wizard.
1426
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element );
1425
+        // Create an instance of the install wizard.
1426
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element );
1427 1427
 
1428
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1428
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1429 1429
 
1430
-		// User Profile.
1431
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1430
+        // User Profile.
1431
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1432 1432
 
1433
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1433
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1434 1434
 
1435
-		// Load the debug service if WP is in debug mode.
1436
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1437
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1438
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1439
-		}
1435
+        // Load the debug service if WP is in debug mode.
1436
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1437
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1438
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1439
+        }
1440 1440
 
1441
-		// Remote Image Service.
1442
-		new Wordlift_Remote_Image_Service();
1441
+        // Remote Image Service.
1442
+        new Wordlift_Remote_Image_Service();
1443 1443
 
1444
-		/*
1444
+        /*
1445 1445
 		 * Provides mappings between post types and entity types.
1446 1446
 		 *
1447 1447
 		 * @since 3.20.0
1448 1448
 		 *
1449 1449
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/852.
1450 1450
 		 */
1451
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1452
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1453
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1451
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1452
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1453
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1454 1454
 
1455
-		// Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1456
-		new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1455
+        // Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1456
+        new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1457 1457
 
1458
-		/*
1458
+        /*
1459 1459
 		 * Batch Operations. They're similar to Batch Actions but do not require working on post types.
1460 1460
 		 *
1461 1461
 		 * Eventually Batch Actions will become Batch Operations.
1462 1462
 		 *
1463 1463
 		 * @since 3.20.0
1464 1464
 		 */
1465
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1466
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1465
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1466
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1467 1467
 
1468
-		/*
1468
+        /*
1469 1469
 		 * Add the Search Keywords taxonomy to manage the Search Keywords on WLS.
1470 1470
 		 *
1471 1471
 		 * @link https://github.com/insideout10/wordlift-plugin/issues/761
1472 1472
 		 *
1473 1473
 		 * @since 3.20.0
1474 1474
 		 */
1475
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1476
-		new Wordlift_Search_Keyword_Taxonomy( $api_service );
1475
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1476
+        new Wordlift_Search_Keyword_Taxonomy( $api_service );
1477 1477
 
1478
-		/*
1478
+        /*
1479 1479
 		 * Load the Mappings JSON-LD post processing.
1480 1480
 		 *
1481 1481
 		 * @since 3.25.0
1482 1482
 		 */
1483 1483
 
1484
-		$mappings_dbo           = new Mappings_DBO();
1485
-		$default_rule_validator = new Taxonomy_Rule_Validator();
1486
-		new Post_Type_Rule_Validator();
1487
-		// Taxonomy term rule validator for validating rules for term pages.
1488
-		new Taxonomy_Term_Rule_Validator();
1489
-		$rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1490
-		$rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1491
-		$mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1492
-
1493
-		new Url_To_Entity_Transform_Function( $this->entity_uri_service );
1494
-		new Taxonomy_To_Terms_Transform_Function();
1495
-		new Post_Id_To_Entity_Transform_Function();
1496
-		$mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1497
-
1498
-		/**
1499
-		 * @since 3.27.1
1500
-		 * Intiailize the acf group data formatter.
1501
-		 */
1502
-		new Acf_Group_Formatter();
1503
-		new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1504
-
1505
-		/**
1506
-		 * @since 3.26.0
1507
-		 * Initialize the Faq JSON LD converter here - disabled.
1508
-		 */
1509
-		// new Faq_To_Jsonld_Converter();
1510
-		/*
1484
+        $mappings_dbo           = new Mappings_DBO();
1485
+        $default_rule_validator = new Taxonomy_Rule_Validator();
1486
+        new Post_Type_Rule_Validator();
1487
+        // Taxonomy term rule validator for validating rules for term pages.
1488
+        new Taxonomy_Term_Rule_Validator();
1489
+        $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1490
+        $rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1491
+        $mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1492
+
1493
+        new Url_To_Entity_Transform_Function( $this->entity_uri_service );
1494
+        new Taxonomy_To_Terms_Transform_Function();
1495
+        new Post_Id_To_Entity_Transform_Function();
1496
+        $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1497
+
1498
+        /**
1499
+         * @since 3.27.1
1500
+         * Intiailize the acf group data formatter.
1501
+         */
1502
+        new Acf_Group_Formatter();
1503
+        new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1504
+
1505
+        /**
1506
+         * @since 3.26.0
1507
+         * Initialize the Faq JSON LD converter here - disabled.
1508
+         */
1509
+        // new Faq_To_Jsonld_Converter();
1510
+        /*
1511 1511
 		 * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php
1512 1512
 		 * end-point.
1513 1513
 		 *
1514 1514
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/834
1515 1515
 		 * @since 3.24.4
1516 1516
 		 */
1517
-		new Templates_Ajax_Endpoint();
1518
-		// Call this static method to register FAQ routes to rest api - disabled
1519
-		//Faq_Rest_Controller::register_routes();
1517
+        new Templates_Ajax_Endpoint();
1518
+        // Call this static method to register FAQ routes to rest api - disabled
1519
+        //Faq_Rest_Controller::register_routes();
1520 1520
 
1521
-		/*
1521
+        /*
1522 1522
 		 * Create a singleton for the Analysis_Response_Ops_Factory.
1523 1523
 		 */
1524
-		$entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service );
1525
-		new Analysis_Response_Ops_Factory(
1526
-			$this->entity_uri_service,
1527
-			$this->entity_service,
1528
-			$this->entity_type_service,
1529
-			$this->storage_factory->post_images(),
1530
-			$entity_helper
1531
-		);
1532
-
1533
-		/** WL Autocomplete. */
1534
-		$autocomplete_service       = new All_Autocomplete_Service( array(
1535
-			new Local_Autocomplete_Service(),
1536
-			new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ),
1537
-		) );
1538
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1539
-
1540
-		/**
1541
-		 * @since 3.27.2
1542
-		 * Integrate the recipe maker jsonld & set recipe
1543
-		 * as default entity type to the wprm_recipe CPT.
1544
-		 */
1545
-		new Recipe_Maker_Post_Type_Hook();
1546
-		$recipe_maker_validation_service = new Recipe_Maker_Validation_Service();
1547
-		new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service );
1548
-		new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service );
1549
-		new Recipe_Maker_Warning( $recipe_maker_validation_service );
1550
-		new Yoast_Jsonld( $recipe_maker_validation_service );
1551
-
1552
-		/**
1553
-		 * @since 3.27.4
1554
-		 * Add the faq duplicate markup hook.
1555
-		 */
1556
-		new Faq_Duplicate_Markup_Remover();
1557
-	}
1558
-
1559
-	/**
1560
-	 * Define the locale for this plugin for internationalization.
1561
-	 *
1562
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1563
-	 * with WordPress.
1564
-	 *
1565
-	 * @since    1.0.0
1566
-	 * @access   private
1567
-	 */
1568
-	private function set_locale() {
1569
-
1570
-		$plugin_i18n = new Wordlift_i18n();
1571
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1572
-
1573
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1574
-
1575
-	}
1576
-
1577
-	/**
1578
-	 * Register all of the hooks related to the admin area functionality
1579
-	 * of the plugin.
1580
-	 *
1581
-	 * @since    1.0.0
1582
-	 * @access   private
1583
-	 */
1584
-	private function define_admin_hooks() {
1585
-
1586
-		$plugin_admin = new Wordlift_Admin(
1587
-			$this->get_plugin_name(),
1588
-			$this->get_version(),
1589
-			$this->configuration_service,
1590
-			$this->notice_service,
1591
-			$this->user_service
1592
-		);
1593
-
1594
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1595
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1596
-
1597
-		// Hook the init action to taxonomy services.
1598
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1599
-		$this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1600
-
1601
-		// Hook the deleted_post_meta action to the Thumbnail service.
1602
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1603
-
1604
-		// Hook the added_post_meta action to the Thumbnail service.
1605
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1606
-
1607
-		// Hook the updated_post_meta action to the Thumbnail service.
1608
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1609
-
1610
-		// Hook the AJAX wl_timeline action to the Timeline service.
1611
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1612
-
1613
-		// Register custom allowed redirect hosts.
1614
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1615
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1616
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1617
-
1618
-		/*
1524
+        $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service );
1525
+        new Analysis_Response_Ops_Factory(
1526
+            $this->entity_uri_service,
1527
+            $this->entity_service,
1528
+            $this->entity_type_service,
1529
+            $this->storage_factory->post_images(),
1530
+            $entity_helper
1531
+        );
1532
+
1533
+        /** WL Autocomplete. */
1534
+        $autocomplete_service       = new All_Autocomplete_Service( array(
1535
+            new Local_Autocomplete_Service(),
1536
+            new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ),
1537
+        ) );
1538
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1539
+
1540
+        /**
1541
+         * @since 3.27.2
1542
+         * Integrate the recipe maker jsonld & set recipe
1543
+         * as default entity type to the wprm_recipe CPT.
1544
+         */
1545
+        new Recipe_Maker_Post_Type_Hook();
1546
+        $recipe_maker_validation_service = new Recipe_Maker_Validation_Service();
1547
+        new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service );
1548
+        new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service );
1549
+        new Recipe_Maker_Warning( $recipe_maker_validation_service );
1550
+        new Yoast_Jsonld( $recipe_maker_validation_service );
1551
+
1552
+        /**
1553
+         * @since 3.27.4
1554
+         * Add the faq duplicate markup hook.
1555
+         */
1556
+        new Faq_Duplicate_Markup_Remover();
1557
+    }
1558
+
1559
+    /**
1560
+     * Define the locale for this plugin for internationalization.
1561
+     *
1562
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1563
+     * with WordPress.
1564
+     *
1565
+     * @since    1.0.0
1566
+     * @access   private
1567
+     */
1568
+    private function set_locale() {
1569
+
1570
+        $plugin_i18n = new Wordlift_i18n();
1571
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1572
+
1573
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1574
+
1575
+    }
1576
+
1577
+    /**
1578
+     * Register all of the hooks related to the admin area functionality
1579
+     * of the plugin.
1580
+     *
1581
+     * @since    1.0.0
1582
+     * @access   private
1583
+     */
1584
+    private function define_admin_hooks() {
1585
+
1586
+        $plugin_admin = new Wordlift_Admin(
1587
+            $this->get_plugin_name(),
1588
+            $this->get_version(),
1589
+            $this->configuration_service,
1590
+            $this->notice_service,
1591
+            $this->user_service
1592
+        );
1593
+
1594
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1595
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1596
+
1597
+        // Hook the init action to taxonomy services.
1598
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1599
+        $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1600
+
1601
+        // Hook the deleted_post_meta action to the Thumbnail service.
1602
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1603
+
1604
+        // Hook the added_post_meta action to the Thumbnail service.
1605
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1606
+
1607
+        // Hook the updated_post_meta action to the Thumbnail service.
1608
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1609
+
1610
+        // Hook the AJAX wl_timeline action to the Timeline service.
1611
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1612
+
1613
+        // Register custom allowed redirect hosts.
1614
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1615
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1616
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1617
+
1618
+        /*
1619 1619
 		 * The old dashboard is replaced with dashboard v2.
1620 1620
 		 *
1621 1621
 		 * The old dashboard service is still loaded because its functions are used.
@@ -1624,389 +1624,389 @@  discard block
 block discarded – undo
1624 1624
 		 *
1625 1625
 		 * @since 3.20.0
1626 1626
 		 */
1627
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1628
-		// $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1629
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1630
-		// $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1631
-
1632
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1633
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1634
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1635
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1636
-
1637
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1638
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1639
-
1640
-		// Entity listing customization (wp-admin/edit.php)
1641
-		// Add custom columns.
1642
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1643
-		// no explicit entity as it prevents handling of other post types.
1644
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1645
-		// Add 4W selection.
1646
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1647
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1648
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1649
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1650
-
1651
-		/*
1627
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1628
+        // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1629
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1630
+        // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1631
+
1632
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1633
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1634
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1635
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1636
+
1637
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1638
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1639
+
1640
+        // Entity listing customization (wp-admin/edit.php)
1641
+        // Add custom columns.
1642
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1643
+        // no explicit entity as it prevents handling of other post types.
1644
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1645
+        // Add 4W selection.
1646
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1647
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1648
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1649
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1650
+
1651
+        /*
1652 1652
 		 * If `All Entity Types` is disable, use the radio button Walker.
1653 1653
 		 *
1654 1654
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1655 1655
 		 */
1656
-		if ( ! WL_ALL_ENTITY_TYPES ) {
1657
-			$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1658
-		}
1659
-
1660
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1661
-		// entities.
1662
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1663
-
1664
-		// Filter imported post meta.
1665
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1666
-
1667
-		// Notify the import service when an import starts and ends.
1668
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1669
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1670
-
1671
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1672
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1673
-		$this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1674
-
1675
-		/**
1676
-		 * Filter: wl_feature__enable__screens.
1677
-		 *
1678
-		 * @param bool whether the screens needed to be registered, defaults to true.
1679
-		 *
1680
-		 * @return bool
1681
-		 * @since 3.27.6
1682
-		 */
1683
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1684
-			// Hook the menu to the Download Your Data page.
1685
-			$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1686
-			$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1687
-			$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1688
-		}
1689
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1690
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1691
-
1692
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1693
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1694
-		$this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1695
-		$this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1696
-
1697
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1698
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1699
-
1700
-		// Hook the AJAX wl_update_country_options action to the countries.
1701
-		$this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' );
1702
-
1703
-		// Hook the `admin_init` function to the Admin Setup.
1704
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1705
-
1706
-		// Hook the admin_init to the settings page.
1707
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1708
-		$this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' );
1709
-
1710
-		$this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1711
-
1712
-		// Hook the menu creation on the general wordlift menu creation.
1713
-		/**
1714
-		 * Filter: wl_feature__enable__screens.
1715
-		 *
1716
-		 * @param bool whether the screens needed to be registered, defaults to true.
1717
-		 *
1718
-		 * @return bool
1719
-		 * @since 3.27.6
1720
-		 */
1721
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1722
-			$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1723
-		}
1724
-		/*
1656
+        if ( ! WL_ALL_ENTITY_TYPES ) {
1657
+            $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1658
+        }
1659
+
1660
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1661
+        // entities.
1662
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1663
+
1664
+        // Filter imported post meta.
1665
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1666
+
1667
+        // Notify the import service when an import starts and ends.
1668
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1669
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1670
+
1671
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1672
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1673
+        $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1674
+
1675
+        /**
1676
+         * Filter: wl_feature__enable__screens.
1677
+         *
1678
+         * @param bool whether the screens needed to be registered, defaults to true.
1679
+         *
1680
+         * @return bool
1681
+         * @since 3.27.6
1682
+         */
1683
+        if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1684
+            // Hook the menu to the Download Your Data page.
1685
+            $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1686
+            $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1687
+            $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1688
+        }
1689
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1690
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1691
+
1692
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1693
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1694
+        $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1695
+        $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1696
+
1697
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1698
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1699
+
1700
+        // Hook the AJAX wl_update_country_options action to the countries.
1701
+        $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' );
1702
+
1703
+        // Hook the `admin_init` function to the Admin Setup.
1704
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1705
+
1706
+        // Hook the admin_init to the settings page.
1707
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1708
+        $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' );
1709
+
1710
+        $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1711
+
1712
+        // Hook the menu creation on the general wordlift menu creation.
1713
+        /**
1714
+         * Filter: wl_feature__enable__screens.
1715
+         *
1716
+         * @param bool whether the screens needed to be registered, defaults to true.
1717
+         *
1718
+         * @return bool
1719
+         * @since 3.27.6
1720
+         */
1721
+        if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1722
+            $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1723
+        }
1724
+        /*
1725 1725
 		 * Display the `Wordlift_Admin_Search_Rankings_Page` page.
1726 1726
 		 *
1727 1727
 		 * @link https://github.com/insideout10/wordlift-plugin/issues/761
1728 1728
 		 *
1729 1729
 		 * @since 3.20.0
1730 1730
 		 */
1731
-		if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) {
1732
-			/**
1733
-			 * Filter: wl_feature__enable__screens.
1734
-			 *
1735
-			 * @param bool whether the screens needed to be registered, defaults to true.
1736
-			 *
1737
-			 * @return bool
1738
-			 * @since 3.27.6
1739
-			 */
1740
-			if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1741
-				$admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page();
1742
-				$this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' );
1743
-			}
1744
-		}
1745
-
1746
-		// Hook key update.
1747
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1748
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1749
-
1750
-		// Add additional action links to the WordLift plugin in the plugins page.
1751
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1752
-
1753
-		/*
1731
+        if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) {
1732
+            /**
1733
+             * Filter: wl_feature__enable__screens.
1734
+             *
1735
+             * @param bool whether the screens needed to be registered, defaults to true.
1736
+             *
1737
+             * @return bool
1738
+             * @since 3.27.6
1739
+             */
1740
+            if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1741
+                $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page();
1742
+                $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' );
1743
+            }
1744
+        }
1745
+
1746
+        // Hook key update.
1747
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1748
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1749
+
1750
+        // Add additional action links to the WordLift plugin in the plugins page.
1751
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1752
+
1753
+        /*
1754 1754
 		 * Remove the Analytics Settings link from the plugin page.
1755 1755
 		 *
1756 1756
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/932
1757 1757
 		 * @since 3.21.1
1758 1758
 		 */
1759
-		// $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 );
1760
-
1761
-		// Hook the AJAX `wl_publisher` action name.
1762
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1763
-
1764
-		// Hook row actions for the entity type list admin.
1765
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1766
-
1767
-		/** Ajax actions. */
1768
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1769
-
1770
-		// Hook capabilities manipulation to allow access to entity type admin
1771
-		// page  on WordPress versions before 4.7.
1772
-		global $wp_version;
1773
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1774
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1775
-		}
1776
-
1777
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1778
-
1779
-		/** Adapters. */
1780
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1781
-		/**
1782
-		 * Disabling Faq temporarily.
1783
-		 * Load the tinymce editor button on the tool bar.
1784
-		 * @since 3.26.0
1785
-		 */
1786
-		//$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' );
1787
-		//$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 );
1788
-		//$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 );
1789
-
1790
-
1791
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1792
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1793
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1794
-		/**
1795
-		 * @since 3.26.0
1796
-		 */
1797
-		if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) {
1798
-			$excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter();
1799
-			$this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' );
1800
-			// Adding Rest route for the post excerpt
1801
-			Post_Excerpt_Rest_Controller::register_routes();
1802
-		}
1803
-
1804
-		$this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1805
-		$this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1806
-
1807
-		// Handle the autocomplete request.
1808
-		add_action( 'wp_ajax_wl_autocomplete', array(
1809
-			$this->autocomplete_adapter,
1810
-			'wl_autocomplete',
1811
-		) );
1812
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1813
-			$this->autocomplete_adapter,
1814
-			'wl_autocomplete',
1815
-		) );
1816
-
1817
-		// Hooks to restrict multisite super admin from manipulating entity types.
1818
-		if ( is_multisite() ) {
1819
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1820
-		}
1821
-
1822
-		$deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1823
-
1824
-		add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1825
-		add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1826
-		add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1827
-
1828
-		/**
1829
-		 * Always allow the `wordlift/classification` block.
1830
-		 *
1831
-		 * @since 3.23.0
1832
-		 */
1833
-		add_filter( 'allowed_block_types', function ( $value ) {
1834
-
1835
-			if ( true === $value ) {
1836
-				return $value;
1837
-			}
1838
-
1839
-			return array_merge( (array) $value, array( 'wordlift/classification' ) );
1840
-		}, PHP_INT_MAX );
1841
-
1842
-		/**
1843
-		 * @since 3.27.7
1844
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
1845
-		 */
1846
-		new Top_Entities();
1847
-	}
1848
-
1849
-	/**
1850
-	 * Register all of the hooks related to the public-facing functionality
1851
-	 * of the plugin.
1852
-	 *
1853
-	 * @since    1.0.0
1854
-	 * @access   private
1855
-	 */
1856
-	private function define_public_hooks() {
1857
-
1858
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1859
-
1860
-		// Register the entity post type.
1861
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1862
-
1863
-		// Bind the link generation and handling hooks to the entity link service.
1864
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1865
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1866
-		// $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 );
1867
-		// $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 );
1868
-
1869
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1870
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1871
-		$this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' );
1872
-
1873
-		// Registering Faq_Content_Filter service used for removing faq question and answer tags from the html.
1874
-		$this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' );
1875
-		// Hook the content filter service to add entity links.
1876
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1877
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1878
-		}
1879
-
1880
-		// Hook the AJAX wl_timeline action to the Timeline service.
1881
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1882
-
1883
-		// Hook the ShareThis service.
1884
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1885
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1886
-
1887
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1888
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1889
-
1890
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1891
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1892
-		// to categories.
1893
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1894
-
1895
-		/*
1759
+        // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 );
1760
+
1761
+        // Hook the AJAX `wl_publisher` action name.
1762
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1763
+
1764
+        // Hook row actions for the entity type list admin.
1765
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1766
+
1767
+        /** Ajax actions. */
1768
+        $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1769
+
1770
+        // Hook capabilities manipulation to allow access to entity type admin
1771
+        // page  on WordPress versions before 4.7.
1772
+        global $wp_version;
1773
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1774
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1775
+        }
1776
+
1777
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1778
+
1779
+        /** Adapters. */
1780
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1781
+        /**
1782
+         * Disabling Faq temporarily.
1783
+         * Load the tinymce editor button on the tool bar.
1784
+         * @since 3.26.0
1785
+         */
1786
+        //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' );
1787
+        //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 );
1788
+        //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 );
1789
+
1790
+
1791
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1792
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1793
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1794
+        /**
1795
+         * @since 3.26.0
1796
+         */
1797
+        if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) {
1798
+            $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter();
1799
+            $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' );
1800
+            // Adding Rest route for the post excerpt
1801
+            Post_Excerpt_Rest_Controller::register_routes();
1802
+        }
1803
+
1804
+        $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1805
+        $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1806
+
1807
+        // Handle the autocomplete request.
1808
+        add_action( 'wp_ajax_wl_autocomplete', array(
1809
+            $this->autocomplete_adapter,
1810
+            'wl_autocomplete',
1811
+        ) );
1812
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1813
+            $this->autocomplete_adapter,
1814
+            'wl_autocomplete',
1815
+        ) );
1816
+
1817
+        // Hooks to restrict multisite super admin from manipulating entity types.
1818
+        if ( is_multisite() ) {
1819
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1820
+        }
1821
+
1822
+        $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1823
+
1824
+        add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1825
+        add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1826
+        add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1827
+
1828
+        /**
1829
+         * Always allow the `wordlift/classification` block.
1830
+         *
1831
+         * @since 3.23.0
1832
+         */
1833
+        add_filter( 'allowed_block_types', function ( $value ) {
1834
+
1835
+            if ( true === $value ) {
1836
+                return $value;
1837
+            }
1838
+
1839
+            return array_merge( (array) $value, array( 'wordlift/classification' ) );
1840
+        }, PHP_INT_MAX );
1841
+
1842
+        /**
1843
+         * @since 3.27.7
1844
+         * @see https://github.com/insideout10/wordlift-plugin/issues/1214
1845
+         */
1846
+        new Top_Entities();
1847
+    }
1848
+
1849
+    /**
1850
+     * Register all of the hooks related to the public-facing functionality
1851
+     * of the plugin.
1852
+     *
1853
+     * @since    1.0.0
1854
+     * @access   private
1855
+     */
1856
+    private function define_public_hooks() {
1857
+
1858
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1859
+
1860
+        // Register the entity post type.
1861
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1862
+
1863
+        // Bind the link generation and handling hooks to the entity link service.
1864
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1865
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1866
+        // $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 );
1867
+        // $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 );
1868
+
1869
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1870
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1871
+        $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' );
1872
+
1873
+        // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html.
1874
+        $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' );
1875
+        // Hook the content filter service to add entity links.
1876
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1877
+            $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1878
+        }
1879
+
1880
+        // Hook the AJAX wl_timeline action to the Timeline service.
1881
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1882
+
1883
+        // Hook the ShareThis service.
1884
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1885
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1886
+
1887
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1888
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1889
+
1890
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1891
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1892
+        // to categories.
1893
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1894
+
1895
+        /*
1896 1896
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1897 1897
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1898 1898
 		 * order of start time.
1899 1899
 		 */
1900
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1901
-
1902
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1903
-
1904
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1905
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1906
-
1907
-		// Analytics Script Frontend.
1908
-		if ( $this->configuration_service->is_analytics_enable() ) {
1909
-			$this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 );
1910
-		}
1911
-
1912
-	}
1913
-
1914
-	/**
1915
-	 * Run the loader to execute all of the hooks with WordPress.
1916
-	 *
1917
-	 * @since    1.0.0
1918
-	 */
1919
-	public function run() {
1920
-		$this->loader->run();
1921
-	}
1922
-
1923
-	/**
1924
-	 * The name of the plugin used to uniquely identify it within the context of
1925
-	 * WordPress and to define internationalization functionality.
1926
-	 *
1927
-	 * @return    string    The name of the plugin.
1928
-	 * @since     1.0.0
1929
-	 */
1930
-	public function get_plugin_name() {
1931
-		return $this->plugin_name;
1932
-	}
1933
-
1934
-	/**
1935
-	 * The reference to the class that orchestrates the hooks with the plugin.
1936
-	 *
1937
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1938
-	 * @since     1.0.0
1939
-	 */
1940
-	public function get_loader() {
1941
-		return $this->loader;
1942
-	}
1943
-
1944
-	/**
1945
-	 * Retrieve the version number of the plugin.
1946
-	 *
1947
-	 * @return    string    The version number of the plugin.
1948
-	 * @since     1.0.0
1949
-	 */
1950
-	public function get_version() {
1951
-		return $this->version;
1952
-	}
1953
-
1954
-	/**
1955
-	 * Load dependencies for WP-CLI.
1956
-	 *
1957
-	 * @throws Exception
1958
-	 * @since 3.18.0
1959
-	 */
1960
-	private function load_cli_dependencies() {
1961
-
1962
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1963
-
1964
-		$push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service );
1965
-
1966
-		WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1967
-
1968
-	}
1969
-
1970
-	/**
1971
-	 * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions.
1972
-	 *
1973
-	 * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance.
1974
-	 * @since 3.20.0
1975
-	 */
1976
-	public function get_dashboard_service() {
1977
-
1978
-		return $this->dashboard_service;
1979
-	}
1980
-
1981
-	public function add_wl_enabled_blocks() {
1982
-		/**
1983
-		 * Filter: wl_feature__enable__blocks.
1984
-		 *
1985
-		 * @param bool whether the blocks needed to be registered, defaults to true.
1986
-		 *
1987
-		 * @return bool
1988
-		 * @since 3.27.6
1989
-		 */
1990
-
1991
-		wp_register_script( 'wl_enabled_blocks', false );
1992
-
1993
-		$enabled_blocks = array( 'wordlift/products-navigator' );
1994
-
1995
-		if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1996
-			// To intimate JS
1997
-			$enabled_blocks = array_merge( $enabled_blocks, array(
1998
-				'wordlift/navigator',
1999
-				'wordlift/chord',
2000
-				'wordlift/geomap',
2001
-				'wordlift/timeline',
2002
-				'wordlift/cloud',
2003
-				'wordlift/vocabulary',
2004
-				'wordlift/faceted-search'
2005
-			) );
2006
-		}
2007
-
2008
-		wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks );
2009
-		wp_enqueue_script( 'wl_enabled_blocks' );
2010
-	}
1900
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1901
+
1902
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1903
+
1904
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1905
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1906
+
1907
+        // Analytics Script Frontend.
1908
+        if ( $this->configuration_service->is_analytics_enable() ) {
1909
+            $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 );
1910
+        }
1911
+
1912
+    }
1913
+
1914
+    /**
1915
+     * Run the loader to execute all of the hooks with WordPress.
1916
+     *
1917
+     * @since    1.0.0
1918
+     */
1919
+    public function run() {
1920
+        $this->loader->run();
1921
+    }
1922
+
1923
+    /**
1924
+     * The name of the plugin used to uniquely identify it within the context of
1925
+     * WordPress and to define internationalization functionality.
1926
+     *
1927
+     * @return    string    The name of the plugin.
1928
+     * @since     1.0.0
1929
+     */
1930
+    public function get_plugin_name() {
1931
+        return $this->plugin_name;
1932
+    }
1933
+
1934
+    /**
1935
+     * The reference to the class that orchestrates the hooks with the plugin.
1936
+     *
1937
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1938
+     * @since     1.0.0
1939
+     */
1940
+    public function get_loader() {
1941
+        return $this->loader;
1942
+    }
1943
+
1944
+    /**
1945
+     * Retrieve the version number of the plugin.
1946
+     *
1947
+     * @return    string    The version number of the plugin.
1948
+     * @since     1.0.0
1949
+     */
1950
+    public function get_version() {
1951
+        return $this->version;
1952
+    }
1953
+
1954
+    /**
1955
+     * Load dependencies for WP-CLI.
1956
+     *
1957
+     * @throws Exception
1958
+     * @since 3.18.0
1959
+     */
1960
+    private function load_cli_dependencies() {
1961
+
1962
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1963
+
1964
+        $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service );
1965
+
1966
+        WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1967
+
1968
+    }
1969
+
1970
+    /**
1971
+     * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions.
1972
+     *
1973
+     * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance.
1974
+     * @since 3.20.0
1975
+     */
1976
+    public function get_dashboard_service() {
1977
+
1978
+        return $this->dashboard_service;
1979
+    }
1980
+
1981
+    public function add_wl_enabled_blocks() {
1982
+        /**
1983
+         * Filter: wl_feature__enable__blocks.
1984
+         *
1985
+         * @param bool whether the blocks needed to be registered, defaults to true.
1986
+         *
1987
+         * @return bool
1988
+         * @since 3.27.6
1989
+         */
1990
+
1991
+        wp_register_script( 'wl_enabled_blocks', false );
1992
+
1993
+        $enabled_blocks = array( 'wordlift/products-navigator' );
1994
+
1995
+        if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1996
+            // To intimate JS
1997
+            $enabled_blocks = array_merge( $enabled_blocks, array(
1998
+                'wordlift/navigator',
1999
+                'wordlift/chord',
2000
+                'wordlift/geomap',
2001
+                'wordlift/timeline',
2002
+                'wordlift/cloud',
2003
+                'wordlift/vocabulary',
2004
+                'wordlift/faceted-search'
2005
+            ) );
2006
+        }
2007
+
2008
+        wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks );
2009
+        wp_enqueue_script( 'wl_enabled_blocks' );
2010
+    }
2011 2011
 
2012 2012
 }
Please login to merge, or discard this patch.
Spacing   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		$this->define_public_hooks();
757 757
 
758 758
 		// If we're in `WP_CLI` load the related files.
759
-		if ( class_exists( 'WP_CLI' ) ) {
759
+		if (class_exists('WP_CLI')) {
760 760
 			$this->load_cli_dependencies();
761 761
 		}
762 762
 
@@ -797,381 +797,381 @@  discard block
 block discarded – undo
797 797
 		 * The class responsible for orchestrating the actions and filters of the
798 798
 		 * core plugin.
799 799
 		 */
800
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
800
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php';
801 801
 
802 802
 		// The class responsible for plugin uninstall.
803
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
803
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-deactivator-feedback.php';
804 804
 
805 805
 		/**
806 806
 		 * The class responsible for defining internationalization functionality
807 807
 		 * of the plugin.
808 808
 		 */
809
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
809
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php';
810 810
 
811 811
 		/**
812 812
 		 * WordLift's supported languages.
813 813
 		 */
814
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
814
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php';
815 815
 
816 816
 		/**
817 817
 		 * WordLift's supported countries.
818 818
 		 */
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
819
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-countries.php';
820 820
 
821 821
 		/**
822 822
 		 * Provide support functions to sanitize data.
823 823
 		 */
824
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
824
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php';
825 825
 
826 826
 		/** Services. */
827
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
829
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
833
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
834
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
835
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
836
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
827
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php';
828
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php';
829
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php';
830
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php';
831
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php';
832
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php';
833
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php';
834
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php';
835
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php';
836
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-image-service.php';
837 837
 
838 838
 		/**
839 839
 		 * The Query builder.
840 840
 		 */
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
841
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php';
842 842
 
843 843
 		/**
844 844
 		 * The Schema service.
845 845
 		 */
846
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
846
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php';
847 847
 
848 848
 		/**
849 849
 		 * The schema:url property service.
850 850
 		 */
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
851
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php';
852
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php';
853 853
 
854 854
 		/**
855 855
 		 * The UI service.
856 856
 		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
857
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php';
858 858
 
859 859
 		/**
860 860
 		 * The Thumbnail service.
861 861
 		 */
862
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
862
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php';
863 863
 
864 864
 		/**
865 865
 		 * The Entity Types Taxonomy service.
866 866
 		 */
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
867
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-taxonomy-service.php';
868 868
 
869 869
 		/**
870 870
 		 * The Entity service.
871 871
 		 */
872
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
873
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
872
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-service.php';
873
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php';
874 874
 
875 875
 		// Add the entity rating service.
876
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
876
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php';
877 877
 
878 878
 		/**
879 879
 		 * The User service.
880 880
 		 */
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
881
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php';
882 882
 
883 883
 		/**
884 884
 		 * The Timeline service.
885 885
 		 */
886
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
886
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php';
887 887
 
888 888
 		/**
889 889
 		 * The Topic Taxonomy service.
890 890
 		 */
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
891
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php';
892 892
 
893 893
 		/**
894 894
 		 * The SPARQL service.
895 895
 		 */
896
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
896
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php';
897 897
 
898 898
 		/**
899 899
 		 * The WordLift import service.
900 900
 		 */
901
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
901
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php';
902 902
 
903 903
 		/**
904 904
 		 * The WordLift URI service.
905 905
 		 */
906
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
908
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
906
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php';
907
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php';
908
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php';
909 909
 
910 910
 		/**
911 911
 		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
912 912
 		 */
913
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
914
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
916
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
917
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
913
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-listable.php';
914
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-rebuild-service.php';
915
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-reference-rebuild-service.php';
916
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-service.php';
917
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
918 918
 
919
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
919
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php';
920
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php';
921 921
 
922 922
 		/**
923 923
 		 * Load the converters.
924 924
 		 */
925
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
926
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
928
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
929
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
925
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php';
926
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
927
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php';
928
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php';
929
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php';
930
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php';
931 931
 
932 932
 		/**
933 933
 		 * Load cache-related files.
934 934
 		 */
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
935
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php';
936 936
 
937 937
 		/**
938 938
 		 * Load the content filter.
939 939
 		 */
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
940
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php';
941 941
 
942 942
 		/*
943 943
 		 * Load the excerpt helper.
944 944
 		 */
945
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
945
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php';
946 946
 
947 947
 		/**
948 948
 		 * Load the JSON-LD service to publish entities using JSON-LD.s
949 949
 		 *
950 950
 		 * @since 3.8.0
951 951
 		 */
952
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
952
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php';
953 953
 
954 954
 		// The Publisher Service and the AJAX adapter.
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
956
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
955
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php';
956
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php';
957 957
 
958
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
958
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php';
959 959
 
960 960
 		/**
961 961
 		 * Load the WordLift key validation service.
962 962
 		 */
963
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
963
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php';
964 964
 
965 965
 		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
966
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
966
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php';
967 967
 
968 968
 		// Load the `Wordlift_Entity_Page_Service` class definition.
969
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
969
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php';
970 970
 
971 971
 		/** Linked Data. */
972
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
973
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
974
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
976
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
981
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
972
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage.php';
973
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
974
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-property-storage.php';
975
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
976
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
977
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-author-storage.php';
978
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
979
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-image-storage.php';
980
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-related-storage.php';
981
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-url-property-storage.php';
982
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage-factory.php';
983 983
 
984 984
 		/** Linked Data Rendition. */
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
986
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
987
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
988
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
985
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
986
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
987
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
988
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
989 989
 
990 990
 		/** Services. */
991
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
992
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
991
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php';
992
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-api-service.php';
993 993
 
994 994
 		/** Adapters. */
995
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
996
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
997
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
998
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
999
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
995
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php';
996
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php';
997
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-ajax-adapter.php';
998
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-adapter.php';
999
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-wprocket-adapter.php';
1000 1000
 
1001 1001
 		/** Async Tasks. */
1002
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
1004
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
1002
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-async-task.php';
1003
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
1004
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-push-references-async-task.php';
1005 1005
 
1006 1006
 		/** Autocomplete. */
1007
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
1007
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-adapter.php';
1008 1008
 
1009
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
1009
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-remote-image-service.php';
1010 1010
 
1011 1011
 		/** Analytics */
1012
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
1012
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/analytics/class-wordlift-analytics-connect.php';
1013 1013
 
1014 1014
 		/**
1015 1015
 		 * The class responsible for defining all actions that occur in the admin area.
1016 1016
 		 */
1017
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
1017
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php';
1018 1018
 
1019 1019
 		/**
1020 1020
 		 * The class to customize the entity list admin page.
1021 1021
 		 */
1022
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
1022
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php';
1023 1023
 
1024 1024
 		/**
1025 1025
 		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
1026 1026
 		 */
1027 1027
 		global $wp_version;
1028
-		if ( version_compare( $wp_version, '5.3', '<' ) ) {
1029
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
1028
+		if (version_compare($wp_version, '5.3', '<')) {
1029
+			require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php';
1030 1030
 		} else {
1031
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1031
+			require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1032 1032
 		}
1033 1033
 
1034 1034
 		/**
1035 1035
 		 * The Notice service.
1036 1036
 		 */
1037
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1037
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php';
1038 1038
 
1039 1039
 		/**
1040 1040
 		 * The PrimaShop adapter.
1041 1041
 		 */
1042
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1042
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php';
1043 1043
 
1044 1044
 		/**
1045 1045
 		 * The WordLift Dashboard service.
1046 1046
 		 */
1047
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1047
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php';
1048 1048
 
1049 1049
 		/**
1050 1050
 		 * The admin 'Install wizard' page.
1051 1051
 		 */
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1052
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php';
1053 1053
 
1054 1054
 		/**
1055 1055
 		 * The WordLift entity type list admin page controller.
1056 1056
 		 */
1057
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1057
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1058 1058
 
1059 1059
 		/**
1060 1060
 		 * The WordLift entity type settings admin page controller.
1061 1061
 		 */
1062
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1062
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php';
1063 1063
 
1064 1064
 		/**
1065 1065
 		 * The admin 'Download Your Data' page.
1066 1066
 		 */
1067
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1067
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php';
1068 1068
 
1069 1069
 		/**
1070 1070
 		 * The admin 'WordLift Settings' page.
1071 1071
 		 */
1072
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
1073
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
1074
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
1075
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
1076
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
1077
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
1078
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
1079
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
1080
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
1081
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
1082
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1083
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1084
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
1085
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1086
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1072
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/intf-wordlift-admin-element.php';
1073
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-element.php';
1074
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-radio-element.php';
1075
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select-element.php';
1076
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select2-element.php';
1077
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-language-select-element.php';
1078
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-country-select-element.php';
1079
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-tabs-element.php';
1080
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-author-element.php';
1081
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-publisher-element.php';
1082
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php';
1083
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php';
1084
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page.php';
1085
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php';
1086
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1087 1087
 
1088 1088
 		/** Admin Pages */
1089
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1090
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1091
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php';
1092
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1089
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-user-profile-page.php';
1090
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php';
1091
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-search-rankings-page.php';
1092
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-admin-service.php';
1093 1093
 
1094 1094
 		/**
1095 1095
 		 * The class responsible for defining all actions that occur in the public-facing
1096 1096
 		 * side of the site.
1097 1097
 		 */
1098
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1098
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php';
1099 1099
 
1100 1100
 		/**
1101 1101
 		 * The shortcode abstract class.
1102 1102
 		 */
1103
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1103
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php';
1104 1104
 
1105 1105
 		/**
1106 1106
 		 * The Timeline shortcode.
1107 1107
 		 */
1108
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1108
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php';
1109 1109
 
1110 1110
 		/**
1111 1111
 		 * The Navigator shortcode.
1112 1112
 		 */
1113
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1113
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php';
1114 1114
 
1115 1115
 		/**
1116 1116
 		 * The Products Navigator shortcode.
1117 1117
 		 */
1118
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php';
1118
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-products-navigator-shortcode.php';
1119 1119
 
1120 1120
 		/**
1121 1121
 		 * The chord shortcode.
1122 1122
 		 */
1123
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1123
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php';
1124 1124
 
1125 1125
 		/**
1126 1126
 		 * The geomap shortcode.
1127 1127
 		 */
1128
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1128
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php';
1129 1129
 
1130 1130
 		/**
1131 1131
 		 * The entity cloud shortcode.
1132 1132
 		 */
1133
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1133
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php';
1134 1134
 
1135 1135
 		/**
1136 1136
 		 * The entity glossary shortcode.
1137 1137
 		 */
1138
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1139
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1138
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-alphabet-service.php';
1139
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-vocabulary-shortcode.php';
1140 1140
 
1141 1141
 		/**
1142 1142
 		 * Faceted Search shortcode.
1143 1143
 		 */
1144
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
1144
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-faceted-search-shortcode.php';
1145 1145
 
1146 1146
 		/**
1147 1147
 		 * The ShareThis service.
1148 1148
 		 */
1149
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1149
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php';
1150 1150
 
1151 1151
 		/**
1152 1152
 		 * The SEO service.
1153 1153
 		 */
1154
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1154
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php';
1155 1155
 
1156 1156
 		/**
1157 1157
 		 * The AMP service.
1158 1158
 		 */
1159
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1159
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php';
1160 1160
 
1161 1161
 		/** Widgets */
1162
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1163
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1164
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1162
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php';
1163
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php';
1164
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-context-cards.php';
1165 1165
 
1166 1166
 		/*
1167 1167
 		 * Schema.org Services.
1168 1168
 		 *
1169 1169
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1170 1170
 		 */
1171
-		if ( WL_ALL_ENTITY_TYPES ) {
1172
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1173
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1174
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1171
+		if (WL_ALL_ENTITY_TYPES) {
1172
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1173
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1174
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1175 1175
 			new Wordlift_Schemaorg_Sync_Service();
1176 1176
 			$schemaorg_property_service = new Wordlift_Schemaorg_Property_Service();
1177 1177
 			new Wordlift_Schemaorg_Class_Service();
@@ -1183,25 +1183,25 @@  discard block
 block discarded – undo
1183 1183
 
1184 1184
 		// Instantiate a global logger.
1185 1185
 		global $wl_logger;
1186
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1186
+		$wl_logger = Wordlift_Log_Service::get_logger('WordLift');
1187 1187
 
1188 1188
 		// Load the `wl-api` end-point.
1189 1189
 		new Wordlift_Http_Api();
1190 1190
 
1191 1191
 		// Load the Install Service.
1192
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1192
+		require_once plugin_dir_path(dirname(__FILE__)).'install/class-wordlift-install-service.php';
1193 1193
 		$this->install_service = new Wordlift_Install_Service();
1194 1194
 
1195 1195
 		/** Services. */
1196 1196
 		// Create the configuration service.
1197 1197
 		$this->configuration_service = new Wordlift_Configuration_Service();
1198
-		$api_service                 = new Wordlift_Api_Service( $this->configuration_service );
1198
+		$api_service                 = new Wordlift_Api_Service($this->configuration_service);
1199 1199
 
1200 1200
 		// Create an entity type service instance. It'll be later bound to the init action.
1201
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1201
+		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path());
1202 1202
 
1203 1203
 		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1204
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1204
+		$this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path());
1205 1205
 
1206 1206
 		// Create an instance of the UI service.
1207 1207
 		$this->ui_service = new Wordlift_UI_Service();
@@ -1210,34 +1210,34 @@  discard block
 block discarded – undo
1210 1210
 		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1211 1211
 
1212 1212
 		$this->sparql_service        = new Wordlift_Sparql_Service();
1213
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1213
+		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service);
1214 1214
 		$this->notice_service        = new Wordlift_Notice_Service();
1215 1215
 		$this->relation_service      = new Wordlift_Relation_Service();
1216 1216
 
1217
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1218
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1219
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1220
-		$this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1217
+		$entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/');
1218
+		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service($this->configuration_service, $entity_uri_cache_service);
1219
+		$this->entity_service     = new Wordlift_Entity_Service($this->ui_service, $this->relation_service, $this->entity_uri_service);
1220
+		$this->user_service       = new Wordlift_User_Service($this->sparql_service, $this->entity_service);
1221 1221
 
1222 1222
 		// Instantiate the JSON-LD service.
1223
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1223
+		$property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service);
1224 1224
 
1225 1225
 		/** Linked Data. */
1226
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1227
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1226
+		$this->storage_factory   = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter);
1227
+		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service);
1228 1228
 
1229
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1229
+		$this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service);
1230 1230
 
1231 1231
 		// Create a new instance of the Redirect service.
1232
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_uri_service );
1233
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1232
+		$this->redirect_service    = new Wordlift_Redirect_Service($this->entity_uri_service);
1233
+		$this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service);
1234 1234
 
1235
-		if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1236
-			new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1235
+		if (apply_filters('wl_feature__enable__dataset-ng', false)) {
1236
+			new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service);
1237 1237
 		}
1238 1238
 
1239 1239
 		// Create a new instance of the Timeline service and Timeline shortcode.
1240
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1240
+		$this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service);
1241 1241
 
1242 1242
 		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1243 1243
 
@@ -1251,36 +1251,36 @@  discard block
 block discarded – undo
1251 1251
 		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1252 1252
 
1253 1253
 		// Create an import service instance to hook later to WP's import function.
1254
-		$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() );
1254
+		$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());
1255 1255
 
1256
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1256
+		$uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']);
1257 1257
 
1258 1258
 		// Create the entity rating service.
1259
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1259
+		$this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service);
1260 1260
 
1261 1261
 		// Create entity list customization (wp-admin/edit.php).
1262
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1262
+		$this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service);
1263 1263
 
1264 1264
 		// Create a new instance of the Redirect service.
1265
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1265
+		$this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service);
1266 1266
 
1267 1267
 		// Create an instance of the Publisher Service and the AJAX Adapter.
1268
-		$this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1269
-		$this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1270
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1268
+		$this->publisher_service = new Wordlift_Publisher_Service($this->configuration_service);
1269
+		$this->property_factory  = new Wordlift_Property_Factory($schema_url_property_service);
1270
+		$this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service);
1271 1271
 
1272 1272
 		$attachment_service = new Wordlift_Attachment_Service();
1273 1273
 
1274 1274
 		// Instantiate the JSON-LD service.
1275
-		$property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1276
-		$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 );
1277
-		$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, $schemaorg_property_service, $this->post_to_jsonld_converter );
1278
-		$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 );
1279
-		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1275
+		$property_getter                       = Wordlift_Property_Getter_Factory::create($this->entity_service);
1276
+		$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);
1277
+		$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, $schemaorg_property_service, $this->post_to_jsonld_converter);
1278
+		$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);
1279
+		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service);
1280 1280
 
1281
-		$jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1282
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache );
1283
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1281
+		$jsonld_cache                            = new Ttl_Cache('jsonld', 86400);
1282
+		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache);
1283
+		$this->jsonld_service                    = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter);
1284 1284
 
1285 1285
 		/*
1286 1286
 		 * Load the `Wordlift_Term_JsonLd_Adapter`.
@@ -1289,29 +1289,29 @@  discard block
 block discarded – undo
1289 1289
 		 *
1290 1290
 		 * @since 3.20.0
1291 1291
 		 */
1292
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1293
-		$term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service );
1292
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-term-jsonld-adapter.php';
1293
+		$term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter($this->entity_uri_service, $this->jsonld_service);
1294 1294
 		$jsonld_service      = new Jsonld_Service(
1295 1295
 			$this->jsonld_service,
1296 1296
 			$term_jsonld_adapter,
1297
-			new Jsonld_User_Service( $this->user_service ) );
1298
-		new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service );
1297
+			new Jsonld_User_Service($this->user_service) );
1298
+		new Jsonld_Endpoint($jsonld_service, $this->entity_uri_service);
1299 1299
 
1300 1300
 		// Prints the JSON-LD in the head.
1301
-		new Jsonld_Adapter( $this->jsonld_service );
1301
+		new Jsonld_Adapter($this->jsonld_service);
1302 1302
 
1303
-		new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service );
1303
+		new Jsonld_By_Id_Endpoint($this->jsonld_service, $this->entity_uri_service);
1304 1304
 
1305
-		$this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service );
1306
-		$this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1305
+		$this->key_validation_service = new Wordlift_Key_Validation_Service($this->configuration_service);
1306
+		$this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service, $this->entity_uri_service);
1307 1307
 		// Creating Faq Content filter service.
1308 1308
 		$this->faq_content_filter_service = new Faq_Content_Filter();
1309
-		$this->relation_rebuild_service   = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1310
-		$this->sample_data_service        = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1311
-		$this->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1312
-		$this->reference_rebuild_service  = new Wordlift_Reference_Rebuild_Service( $this->entity_service );
1309
+		$this->relation_rebuild_service   = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service);
1310
+		$this->sample_data_service        = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service, $this->user_service);
1311
+		$this->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service);
1312
+		$this->reference_rebuild_service  = new Wordlift_Reference_Rebuild_Service($this->entity_service);
1313 1313
 
1314
-		$this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' );
1314
+		$this->loader->add_action('enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks');
1315 1315
 
1316 1316
 		/**
1317 1317
 		 * Filter: wl_feature__enable__blocks.
@@ -1321,14 +1321,14 @@  discard block
 block discarded – undo
1321 1321
 		 * @return bool
1322 1322
 		 * @since 3.27.6
1323 1323
 		 */
1324
-		if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1324
+		if (apply_filters('wl_feature__enable__blocks', true)) {
1325 1325
 			// Initialize the short-codes.
1326 1326
 			new Wordlift_Navigator_Shortcode();
1327 1327
 			new Wordlift_Chord_Shortcode();
1328 1328
 			new Wordlift_Geomap_Shortcode();
1329 1329
 			new Wordlift_Timeline_Shortcode();
1330
-			new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1331
-			new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1330
+			new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service);
1331
+			new Wordlift_Vocabulary_Shortcode($this->configuration_service);
1332 1332
 			new Wordlift_Faceted_Search_Shortcode();
1333 1333
 		}
1334 1334
 
@@ -1342,18 +1342,18 @@  discard block
 block discarded – undo
1342 1342
 		new Wordlift_Seo_Service();
1343 1343
 
1344 1344
 		// Initialize the AMP service.
1345
-		new Wordlift_AMP_Service( $this->jsonld_service );
1345
+		new Wordlift_AMP_Service($this->jsonld_service);
1346 1346
 
1347 1347
 		/** Services. */
1348 1348
 		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1349 1349
 		new Wordlift_Image_Service();
1350 1350
 
1351 1351
 		/** Adapters. */
1352
-		$this->entity_type_adapter    = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1353
-		$this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1354
-		$this->tinymce_adapter        = new Wordlift_Tinymce_Adapter( $this );
1352
+		$this->entity_type_adapter    = new Wordlift_Entity_Type_Adapter($this->entity_type_service);
1353
+		$this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($this->publisher_service);
1354
+		$this->tinymce_adapter        = new Wordlift_Tinymce_Adapter($this);
1355 1355
 		//$this->faq_tinymce_adapter      = new Faq_Tinymce_Adapter();
1356
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1356
+		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service);
1357 1357
 
1358 1358
 		/*
1359 1359
 		 * Exclude our public js from WP-Rocket.
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 		);
1372 1372
 
1373 1373
 		/** Async Tasks. */
1374
-		if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
1374
+		if ( ! apply_filters('wl_feature__enable__dataset-ng', false)) {
1375 1375
 			new Wordlift_Sparql_Query_Async_Task();
1376 1376
 			new Wordlift_Push_References_Async_Task();
1377 1377
 		}
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1386 1386
 		$this->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1387 1387
 		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1388
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1389
-		$this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1388
+		$this->publisher_element       = new Wordlift_Admin_Publisher_Element($this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element);
1389
+		$this->author_element          = new Wordlift_Admin_Author_Element($this->publisher_service, $this->select2_element);
1390 1390
 
1391
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element );
1392
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1391
+		$this->settings_page             = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element);
1392
+		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page);
1393 1393
 
1394
-		$this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element );
1395
-		$this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page );
1394
+		$this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page($this->configuration_service, $this->input_element, $this->radio_input_element);
1395
+		$this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link($this->analytics_settings_page);
1396 1396
 		$this->analytics_connect                   = new Wordlift_Analytics_Connect();
1397 1397
 
1398 1398
 		// Pages.
@@ -1403,9 +1403,9 @@  discard block
 block discarded – undo
1403 1403
 		 *
1404 1404
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/914
1405 1405
 		 */
1406
-		if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1407
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1408
-			new Wordlift_Admin_Post_Edit_Page( $this );
1406
+		if (apply_filters('wl_can_see_classification_box', true)) {
1407
+			require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php';
1408
+			new Wordlift_Admin_Post_Edit_Page($this);
1409 1409
 		}
1410 1410
 		new Wordlift_Entity_Type_Admin_Service();
1411 1411
 
@@ -1419,23 +1419,23 @@  discard block
 block discarded – undo
1419 1419
 		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1420 1420
 
1421 1421
 		/* WordPress Admin. */
1422
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1423
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1422
+		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service);
1423
+		$this->status_page             = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service);
1424 1424
 
1425 1425
 		// Create an instance of the install wizard.
1426
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element );
1426
+		$this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element);
1427 1427
 
1428
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1428
+		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service);
1429 1429
 
1430 1430
 		// User Profile.
1431
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1431
+		new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service);
1432 1432
 
1433 1433
 		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1434 1434
 
1435 1435
 		// Load the debug service if WP is in debug mode.
1436
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1437
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1438
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1436
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1437
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php';
1438
+			new Wordlift_Debug_Service($this->entity_service, $uri_service);
1439 1439
 		}
1440 1440
 
1441 1441
 		// Remote Image Service.
@@ -1448,12 +1448,12 @@  discard block
 block discarded – undo
1448 1448
 		 *
1449 1449
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/852.
1450 1450
 		 */
1451
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1452
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1453
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1451
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-action.php';
1452
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-service.php';
1453
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1454 1454
 
1455 1455
 		// Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1456
-		new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1456
+		new Wordlift_Mapping_Ajax_Adapter(new Wordlift_Mapping_Service(Wordlift_Entity_Type_Service::get_instance()));
1457 1457
 
1458 1458
 		/*
1459 1459
 		 * Batch Operations. They're similar to Batch Actions but do not require working on post types.
@@ -1462,8 +1462,8 @@  discard block
 block discarded – undo
1462 1462
 		 *
1463 1463
 		 * @since 3.20.0
1464 1464
 		 */
1465
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1466
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1465
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/intf-wordlift-batch-operation.php';
1466
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1467 1467
 
1468 1468
 		/*
1469 1469
 		 * Add the Search Keywords taxonomy to manage the Search Keywords on WLS.
@@ -1472,8 +1472,8 @@  discard block
 block discarded – undo
1472 1472
 		 *
1473 1473
 		 * @since 3.20.0
1474 1474
 		 */
1475
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1476
-		new Wordlift_Search_Keyword_Taxonomy( $api_service );
1475
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1476
+		new Wordlift_Search_Keyword_Taxonomy($api_service);
1477 1477
 
1478 1478
 		/*
1479 1479
 		 * Load the Mappings JSON-LD post processing.
@@ -1486,11 +1486,11 @@  discard block
 block discarded – undo
1486 1486
 		new Post_Type_Rule_Validator();
1487 1487
 		// Taxonomy term rule validator for validating rules for term pages.
1488 1488
 		new Taxonomy_Term_Rule_Validator();
1489
-		$rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1490
-		$rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1491
-		$mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1489
+		$rule_validators_registry = new Rule_Validators_Registry($default_rule_validator);
1490
+		$rule_groups_validator    = new Rule_Groups_Validator($rule_validators_registry);
1491
+		$mappings_validator       = new Mappings_Validator($mappings_dbo, $rule_groups_validator);
1492 1492
 
1493
-		new Url_To_Entity_Transform_Function( $this->entity_uri_service );
1493
+		new Url_To_Entity_Transform_Function($this->entity_uri_service);
1494 1494
 		new Taxonomy_To_Terms_Transform_Function();
1495 1495
 		new Post_Id_To_Entity_Transform_Function();
1496 1496
 		$mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 		 * Intiailize the acf group data formatter.
1501 1501
 		 */
1502 1502
 		new Acf_Group_Formatter();
1503
-		new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1503
+		new Jsonld_Converter($mappings_validator, $mappings_transform_functions_registry);
1504 1504
 
1505 1505
 		/**
1506 1506
 		 * @since 3.26.0
@@ -1521,7 +1521,7 @@  discard block
 block discarded – undo
1521 1521
 		/*
1522 1522
 		 * Create a singleton for the Analysis_Response_Ops_Factory.
1523 1523
 		 */
1524
-		$entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service );
1524
+		$entity_helper = new Entity_Helper($this->entity_uri_service, $this->entity_service);
1525 1525
 		new Analysis_Response_Ops_Factory(
1526 1526
 			$this->entity_uri_service,
1527 1527
 			$this->entity_service,
@@ -1531,11 +1531,11 @@  discard block
 block discarded – undo
1531 1531
 		);
1532 1532
 
1533 1533
 		/** WL Autocomplete. */
1534
-		$autocomplete_service       = new All_Autocomplete_Service( array(
1534
+		$autocomplete_service = new All_Autocomplete_Service(array(
1535 1535
 			new Local_Autocomplete_Service(),
1536
-			new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ),
1537
-		) );
1538
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1536
+			new Linked_Data_Autocomplete_Service($this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service),
1537
+		));
1538
+		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($autocomplete_service);
1539 1539
 
1540 1540
 		/**
1541 1541
 		 * @since 3.27.2
@@ -1544,10 +1544,10 @@  discard block
 block discarded – undo
1544 1544
 		 */
1545 1545
 		new Recipe_Maker_Post_Type_Hook();
1546 1546
 		$recipe_maker_validation_service = new Recipe_Maker_Validation_Service();
1547
-		new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service );
1548
-		new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service );
1549
-		new Recipe_Maker_Warning( $recipe_maker_validation_service );
1550
-		new Yoast_Jsonld( $recipe_maker_validation_service );
1547
+		new Recipe_Maker_Jsonld_Hook($attachment_service, $recipe_maker_validation_service);
1548
+		new Recipe_Maker_After_Get_Jsonld_Hook($recipe_maker_validation_service);
1549
+		new Recipe_Maker_Warning($recipe_maker_validation_service);
1550
+		new Yoast_Jsonld($recipe_maker_validation_service);
1551 1551
 
1552 1552
 		/**
1553 1553
 		 * @since 3.27.4
@@ -1568,9 +1568,9 @@  discard block
 block discarded – undo
1568 1568
 	private function set_locale() {
1569 1569
 
1570 1570
 		$plugin_i18n = new Wordlift_i18n();
1571
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1571
+		$plugin_i18n->set_domain($this->get_plugin_name());
1572 1572
 
1573
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1573
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
1574 1574
 
1575 1575
 	}
1576 1576
 
@@ -1591,29 +1591,29 @@  discard block
 block discarded – undo
1591 1591
 			$this->user_service
1592 1592
 		);
1593 1593
 
1594
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1595
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1594
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
1595
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11);
1596 1596
 
1597 1597
 		// Hook the init action to taxonomy services.
1598
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1599
-		$this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1598
+		$this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0);
1599
+		$this->loader->add_action('init', $this->entity_types_taxonomy_service, 'init', 0);
1600 1600
 
1601 1601
 		// Hook the deleted_post_meta action to the Thumbnail service.
1602
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1602
+		$this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4);
1603 1603
 
1604 1604
 		// Hook the added_post_meta action to the Thumbnail service.
1605
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1605
+		$this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1606 1606
 
1607 1607
 		// Hook the updated_post_meta action to the Thumbnail service.
1608
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1608
+		$this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1609 1609
 
1610 1610
 		// Hook the AJAX wl_timeline action to the Timeline service.
1611
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1611
+		$this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline');
1612 1612
 
1613 1613
 		// Register custom allowed redirect hosts.
1614
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1614
+		$this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts');
1615 1615
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1616
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1616
+		$this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect');
1617 1617
 
1618 1618
 		/*
1619 1619
 		 * The old dashboard is replaced with dashboard v2.
@@ -1631,46 +1631,46 @@  discard block
 block discarded – undo
1631 1631
 
1632 1632
 		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1633 1633
 		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1634
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1635
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1634
+		$this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3);
1635
+		$this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1);
1636 1636
 
1637
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1638
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1637
+		$this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1);
1638
+		$this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header');
1639 1639
 
1640 1640
 		// Entity listing customization (wp-admin/edit.php)
1641 1641
 		// Add custom columns.
1642
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1642
+		$this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns');
1643 1643
 		// no explicit entity as it prevents handling of other post types.
1644
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1644
+		$this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2);
1645 1645
 		// Add 4W selection.
1646
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1647
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1648
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1649
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1646
+		$this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope');
1647
+		$this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope');
1648
+		$this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts');
1649
+		$this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit');
1650 1650
 
1651 1651
 		/*
1652 1652
 		 * If `All Entity Types` is disable, use the radio button Walker.
1653 1653
 		 *
1654 1654
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1655 1655
 		 */
1656
-		if ( ! WL_ALL_ENTITY_TYPES ) {
1657
-			$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1656
+		if ( ! WL_ALL_ENTITY_TYPES) {
1657
+			$this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args');
1658 1658
 		}
1659 1659
 
1660 1660
 		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1661 1661
 		// entities.
1662
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1662
+		$this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2);
1663 1663
 
1664 1664
 		// Filter imported post meta.
1665
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1665
+		$this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3);
1666 1666
 
1667 1667
 		// Notify the import service when an import starts and ends.
1668
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1669
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1668
+		$this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0);
1669
+		$this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0);
1670 1670
 
1671 1671
 		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1672
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1673
-		$this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1672
+		$this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild');
1673
+		$this->loader->add_action('wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild');
1674 1674
 
1675 1675
 		/**
1676 1676
 		 * Filter: wl_feature__enable__screens.
@@ -1680,34 +1680,34 @@  discard block
 block discarded – undo
1680 1680
 		 * @return bool
1681 1681
 		 * @since 3.27.6
1682 1682
 		 */
1683
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1683
+		if (apply_filters('wl_feature__enable__screens', true)) {
1684 1684
 			// Hook the menu to the Download Your Data page.
1685
-			$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1686
-			$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1687
-			$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1685
+			$this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0);
1686
+			$this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0);
1687
+			$this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0);
1688 1688
 		}
1689 1689
 		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1690
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1690
+		$this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10);
1691 1691
 
1692 1692
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1693
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1694
-		$this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1695
-		$this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1693
+		$this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get');
1694
+		$this->loader->add_action('admin_post_wl_jsonld', $this->jsonld_service, 'get');
1695
+		$this->loader->add_action('admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get');
1696 1696
 
1697 1697
 		// Hook the AJAX wl_validate_key action to the Key Validation service.
1698
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1698
+		$this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key');
1699 1699
 
1700 1700
 		// Hook the AJAX wl_update_country_options action to the countries.
1701
-		$this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' );
1701
+		$this->loader->add_action('wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html');
1702 1702
 
1703 1703
 		// Hook the `admin_init` function to the Admin Setup.
1704
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1704
+		$this->loader->add_action('admin_init', $this->admin_setup, 'admin_init');
1705 1705
 
1706 1706
 		// Hook the admin_init to the settings page.
1707
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1708
-		$this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' );
1707
+		$this->loader->add_action('admin_init', $this->settings_page, 'admin_init');
1708
+		$this->loader->add_action('admin_init', $this->analytics_settings_page, 'admin_init');
1709 1709
 
1710
-		$this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1710
+		$this->loader->add_filter('admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction');
1711 1711
 
1712 1712
 		// Hook the menu creation on the general wordlift menu creation.
1713 1713
 		/**
@@ -1718,8 +1718,8 @@  discard block
 block discarded – undo
1718 1718
 		 * @return bool
1719 1719
 		 * @since 3.27.6
1720 1720
 		 */
1721
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1722
-			$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1721
+		if (apply_filters('wl_feature__enable__screens', true)) {
1722
+			$this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2);
1723 1723
 		}
1724 1724
 		/*
1725 1725
 		 * Display the `Wordlift_Admin_Search_Rankings_Page` page.
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 		 *
1729 1729
 		 * @since 3.20.0
1730 1730
 		 */
1731
-		if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) {
1731
+		if (in_array($this->configuration_service->get_package_type(), array('editorial', 'business'))) {
1732 1732
 			/**
1733 1733
 			 * Filter: wl_feature__enable__screens.
1734 1734
 			 *
@@ -1737,18 +1737,18 @@  discard block
 block discarded – undo
1737 1737
 			 * @return bool
1738 1738
 			 * @since 3.27.6
1739 1739
 			 */
1740
-			if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
1740
+			if (apply_filters('wl_feature__enable__screens', true)) {
1741 1741
 				$admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page();
1742
-				$this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' );
1742
+				$this->loader->add_action('wl_admin_menu', $admin_search_rankings_page, 'admin_menu');
1743 1743
 			}
1744 1744
 		}
1745 1745
 
1746 1746
 		// Hook key update.
1747
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1748
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1747
+		$this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2);
1748
+		$this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2);
1749 1749
 
1750 1750
 		// Add additional action links to the WordLift plugin in the plugins page.
1751
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1751
+		$this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1);
1752 1752
 
1753 1753
 		/*
1754 1754
 		 * Remove the Analytics Settings link from the plugin page.
@@ -1759,25 +1759,25 @@  discard block
 block discarded – undo
1759 1759
 		// $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 );
1760 1760
 
1761 1761
 		// Hook the AJAX `wl_publisher` action name.
1762
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1762
+		$this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher');
1763 1763
 
1764 1764
 		// Hook row actions for the entity type list admin.
1765
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1765
+		$this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2);
1766 1766
 
1767 1767
 		/** Ajax actions. */
1768
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1768
+		$this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export');
1769 1769
 
1770 1770
 		// Hook capabilities manipulation to allow access to entity type admin
1771 1771
 		// page  on WordPress versions before 4.7.
1772 1772
 		global $wp_version;
1773
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1774
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1773
+		if (version_compare($wp_version, '4.7', '<')) {
1774
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4);
1775 1775
 		}
1776 1776
 
1777
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1777
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1778 1778
 
1779 1779
 		/** Adapters. */
1780
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1780
+		$this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1);
1781 1781
 		/**
1782 1782
 		 * Disabling Faq temporarily.
1783 1783
 		 * Load the tinymce editor button on the tool bar.
@@ -1788,56 +1788,56 @@  discard block
 block discarded – undo
1788 1788
 		//$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 );
1789 1789
 
1790 1790
 
1791
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1792
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1793
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1791
+		$this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all');
1792
+		$this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create');
1793
+		$this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete');
1794 1794
 		/**
1795 1795
 		 * @since 3.26.0
1796 1796
 		 */
1797
-		if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) {
1797
+		if (apply_filters('wl_feature__enable__post_excerpt', true)) {
1798 1798
 			$excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter();
1799
-			$this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' );
1799
+			$this->loader->add_action('do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box');
1800 1800
 			// Adding Rest route for the post excerpt
1801 1801
 			Post_Excerpt_Rest_Controller::register_routes();
1802 1802
 		}
1803 1803
 
1804
-		$this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1805
-		$this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1804
+		$this->loader->add_action('update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5);
1805
+		$this->loader->add_action('delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5);
1806 1806
 
1807 1807
 		// Handle the autocomplete request.
1808
-		add_action( 'wp_ajax_wl_autocomplete', array(
1808
+		add_action('wp_ajax_wl_autocomplete', array(
1809 1809
 			$this->autocomplete_adapter,
1810 1810
 			'wl_autocomplete',
1811
-		) );
1812
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1811
+		));
1812
+		add_action('wp_ajax_nopriv_wl_autocomplete', array(
1813 1813
 			$this->autocomplete_adapter,
1814 1814
 			'wl_autocomplete',
1815
-		) );
1815
+		));
1816 1816
 
1817 1817
 		// Hooks to restrict multisite super admin from manipulating entity types.
1818
-		if ( is_multisite() ) {
1819
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1818
+		if (is_multisite()) {
1819
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4);
1820 1820
 		}
1821 1821
 
1822
-		$deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1822
+		$deactivator_feedback = new Wordlift_Deactivator_Feedback($this->configuration_service);
1823 1823
 
1824
-		add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1825
-		add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1826
-		add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1824
+		add_action('admin_footer', array($deactivator_feedback, 'render_feedback_popup'));
1825
+		add_action('admin_enqueue_scripts', array($deactivator_feedback, 'enqueue_popup_scripts'));
1826
+		add_action('wp_ajax_wl_deactivation_feedback', array($deactivator_feedback, 'wl_deactivation_feedback'));
1827 1827
 
1828 1828
 		/**
1829 1829
 		 * Always allow the `wordlift/classification` block.
1830 1830
 		 *
1831 1831
 		 * @since 3.23.0
1832 1832
 		 */
1833
-		add_filter( 'allowed_block_types', function ( $value ) {
1833
+		add_filter('allowed_block_types', function($value) {
1834 1834
 
1835
-			if ( true === $value ) {
1835
+			if (true === $value) {
1836 1836
 				return $value;
1837 1837
 			}
1838 1838
 
1839
-			return array_merge( (array) $value, array( 'wordlift/classification' ) );
1840
-		}, PHP_INT_MAX );
1839
+			return array_merge((array) $value, array('wordlift/classification'));
1840
+		}, PHP_INT_MAX);
1841 1841
 
1842 1842
 		/**
1843 1843
 		 * @since 3.27.7
@@ -1855,58 +1855,58 @@  discard block
 block discarded – undo
1855 1855
 	 */
1856 1856
 	private function define_public_hooks() {
1857 1857
 
1858
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1858
+		$plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version());
1859 1859
 
1860 1860
 		// Register the entity post type.
1861
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1861
+		$this->loader->add_action('init', $this->entity_post_type_service, 'register');
1862 1862
 
1863 1863
 		// Bind the link generation and handling hooks to the entity link service.
1864
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1865
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1864
+		$this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4);
1865
+		$this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1);
1866 1866
 		// $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 );
1867 1867
 		// $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 );
1868 1868
 
1869
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1870
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1871
-		$this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' );
1869
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
1870
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
1871
+		$this->loader->add_action('wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts');
1872 1872
 
1873 1873
 		// Registering Faq_Content_Filter service used for removing faq question and answer tags from the html.
1874
-		$this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' );
1874
+		$this->loader->add_filter('the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags');
1875 1875
 		// Hook the content filter service to add entity links.
1876
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1877
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1876
+		if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) {
1877
+			$this->loader->add_filter('the_content', $this->content_filter_service, 'the_content');
1878 1878
 		}
1879 1879
 
1880 1880
 		// Hook the AJAX wl_timeline action to the Timeline service.
1881
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1881
+		$this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline');
1882 1882
 
1883 1883
 		// Hook the ShareThis service.
1884
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1885
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1884
+		$this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99);
1885
+		$this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99);
1886 1886
 
1887 1887
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1888
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1888
+		$this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get');
1889 1889
 
1890 1890
 		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1891 1891
 		// in order to tweak WP's `WP_Query` to include entities in queries related
1892 1892
 		// to categories.
1893
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1893
+		$this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1);
1894 1894
 
1895 1895
 		/*
1896 1896
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1897 1897
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1898 1898
 		 * order of start time.
1899 1899
 		 */
1900
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1900
+		$this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1);
1901 1901
 
1902
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1902
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1903 1903
 
1904 1904
 		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1905
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1905
+		$this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3);
1906 1906
 
1907 1907
 		// Analytics Script Frontend.
1908
-		if ( $this->configuration_service->is_analytics_enable() ) {
1909
-			$this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 );
1908
+		if ($this->configuration_service->is_analytics_enable()) {
1909
+			$this->loader->add_action('wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10);
1910 1910
 		}
1911 1911
 
1912 1912
 	}
@@ -1959,11 +1959,11 @@  discard block
 block discarded – undo
1959 1959
 	 */
1960 1960
 	private function load_cli_dependencies() {
1961 1961
 
1962
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1962
+		require_once plugin_dir_path(dirname(__FILE__)).'cli/class-wordlift-push-reference-data-command.php';
1963 1963
 
1964
-		$push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service );
1964
+		$push_reference_data_command = new Wordlift_Push_Reference_Data_Command($this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service);
1965 1965
 
1966
-		WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1966
+		WP_CLI::add_command('wl references push', $push_reference_data_command);
1967 1967
 
1968 1968
 	}
1969 1969
 
@@ -1988,13 +1988,13 @@  discard block
 block discarded – undo
1988 1988
 		 * @since 3.27.6
1989 1989
 		 */
1990 1990
 
1991
-		wp_register_script( 'wl_enabled_blocks', false );
1991
+		wp_register_script('wl_enabled_blocks', false);
1992 1992
 
1993
-		$enabled_blocks = array( 'wordlift/products-navigator' );
1993
+		$enabled_blocks = array('wordlift/products-navigator');
1994 1994
 
1995
-		if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1995
+		if (apply_filters('wl_feature__enable__blocks', true)) {
1996 1996
 			// To intimate JS
1997
-			$enabled_blocks = array_merge( $enabled_blocks, array(
1997
+			$enabled_blocks = array_merge($enabled_blocks, array(
1998 1998
 				'wordlift/navigator',
1999 1999
 				'wordlift/chord',
2000 2000
 				'wordlift/geomap',
@@ -2002,11 +2002,11 @@  discard block
 block discarded – undo
2002 2002
 				'wordlift/cloud',
2003 2003
 				'wordlift/vocabulary',
2004 2004
 				'wordlift/faceted-search'
2005
-			) );
2005
+			));
2006 2006
 		}
2007 2007
 
2008
-		wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks );
2009
-		wp_enqueue_script( 'wl_enabled_blocks' );
2008
+		wp_localize_script('wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks);
2009
+		wp_enqueue_script('wl_enabled_blocks');
2010 2010
 	}
2011 2011
 
2012 2012
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +598 added lines, -598 removed lines patch added patch discarded remove patch
@@ -18,522 +18,522 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Entity_Service {
20 20
 
21
-	/**
22
-	 * The Log service.
23
-	 *
24
-	 * @since  3.2.0
25
-	 * @access private
26
-	 * @var \Wordlift_Log_Service $log The Log service.
27
-	 */
28
-	private $log;
29
-
30
-	/**
31
-	 * The UI service.
32
-	 *
33
-	 * @since  3.2.0
34
-	 * @access private
35
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
36
-	 */
37
-	private $ui_service;
38
-
39
-	/**
40
-	 * The {@link Wordlift_Relation_Service} instance.
41
-	 *
42
-	 * @since  3.15.0
43
-	 * @access private
44
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
45
-	 */
46
-	private $relation_service;
47
-
48
-	/**
49
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
50
-	 *
51
-	 * @since  3.16.3
52
-	 * @access private
53
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
54
-	 */
55
-	private $entity_uri_service;
56
-
57
-	/**
58
-	 * The entity post type name.
59
-	 *
60
-	 * @since 3.1.0
61
-	 */
62
-	const TYPE_NAME = 'entity';
63
-
64
-	/**
65
-	 * The alternative label meta key.
66
-	 *
67
-	 * @since 3.2.0
68
-	 */
69
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
70
-
71
-	/**
72
-	 * The alternative label input template.
73
-	 *
74
-	 * @since 3.2.0
75
-	 */
76
-	// TODO: this should be moved to a class that deals with HTML code.
77
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
21
+    /**
22
+     * The Log service.
23
+     *
24
+     * @since  3.2.0
25
+     * @access private
26
+     * @var \Wordlift_Log_Service $log The Log service.
27
+     */
28
+    private $log;
29
+
30
+    /**
31
+     * The UI service.
32
+     *
33
+     * @since  3.2.0
34
+     * @access private
35
+     * @var \Wordlift_UI_Service $ui_service The UI service.
36
+     */
37
+    private $ui_service;
38
+
39
+    /**
40
+     * The {@link Wordlift_Relation_Service} instance.
41
+     *
42
+     * @since  3.15.0
43
+     * @access private
44
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
45
+     */
46
+    private $relation_service;
47
+
48
+    /**
49
+     * The {@link Wordlift_Entity_Uri_Service} instance.
50
+     *
51
+     * @since  3.16.3
52
+     * @access private
53
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
54
+     */
55
+    private $entity_uri_service;
56
+
57
+    /**
58
+     * The entity post type name.
59
+     *
60
+     * @since 3.1.0
61
+     */
62
+    const TYPE_NAME = 'entity';
63
+
64
+    /**
65
+     * The alternative label meta key.
66
+     *
67
+     * @since 3.2.0
68
+     */
69
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
70
+
71
+    /**
72
+     * The alternative label input template.
73
+     *
74
+     * @since 3.2.0
75
+     */
76
+    // TODO: this should be moved to a class that deals with HTML code.
77
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
78 78
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
79 79
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
80 80
                 <button class="button wl-delete-button">%s</button>
81 81
                 </div>';
82 82
 
83
-	/**
84
-	 * A singleton instance of the Entity service.
85
-	 *
86
-	 * @since  3.2.0
87
-	 * @access private
88
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
89
-	 */
90
-	private static $instance;
91
-
92
-	/**
93
-	 * Create a Wordlift_Entity_Service instance.
94
-	 *
95
-	 * @param \Wordlift_UI_Service $ui_service The UI service.
96
-	 * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
97
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
98
-	 *
99
-	 * @since 3.2.0
100
-	 *
101
-	 */
102
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
103
-
104
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
105
-
106
-		$this->ui_service         = $ui_service;
107
-		$this->relation_service   = $relation_service;
108
-		$this->entity_uri_service = $entity_uri_service;
109
-
110
-		// Set the singleton instance.
111
-		self::$instance = $this;
112
-	}
113
-
114
-	/**
115
-	 * Get the singleton instance of the Entity service.
116
-	 *
117
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
118
-	 * @since 3.2.0
119
-	 */
120
-	public static function get_instance() {
121
-
122
-		return self::$instance;
123
-	}
124
-
125
-	/**
126
-	 * Determines whether a post is an entity or not. Entity is in this context
127
-	 * something which is not an article.
128
-	 *
129
-	 * @param int $post_id A post id.
130
-	 *
131
-	 * @return bool Return true if the post is an entity otherwise false.
132
-	 * @since 3.1.0
133
-	 *
134
-	 */
135
-	public function is_entity( $post_id ) {
136
-
137
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
138
-
139
-		if ( is_wp_error( $terms ) ) {
140
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
141
-
142
-			return false;
143
-		}
144
-
145
-		if ( empty( $terms ) ) {
146
-			return false;
147
-		}
148
-
149
-		/*
83
+    /**
84
+     * A singleton instance of the Entity service.
85
+     *
86
+     * @since  3.2.0
87
+     * @access private
88
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
89
+     */
90
+    private static $instance;
91
+
92
+    /**
93
+     * Create a Wordlift_Entity_Service instance.
94
+     *
95
+     * @param \Wordlift_UI_Service $ui_service The UI service.
96
+     * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
97
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
98
+     *
99
+     * @since 3.2.0
100
+     *
101
+     */
102
+    public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
103
+
104
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
105
+
106
+        $this->ui_service         = $ui_service;
107
+        $this->relation_service   = $relation_service;
108
+        $this->entity_uri_service = $entity_uri_service;
109
+
110
+        // Set the singleton instance.
111
+        self::$instance = $this;
112
+    }
113
+
114
+    /**
115
+     * Get the singleton instance of the Entity service.
116
+     *
117
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
118
+     * @since 3.2.0
119
+     */
120
+    public static function get_instance() {
121
+
122
+        return self::$instance;
123
+    }
124
+
125
+    /**
126
+     * Determines whether a post is an entity or not. Entity is in this context
127
+     * something which is not an article.
128
+     *
129
+     * @param int $post_id A post id.
130
+     *
131
+     * @return bool Return true if the post is an entity otherwise false.
132
+     * @since 3.1.0
133
+     *
134
+     */
135
+    public function is_entity( $post_id ) {
136
+
137
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
138
+
139
+        if ( is_wp_error( $terms ) ) {
140
+            $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
141
+
142
+            return false;
143
+        }
144
+
145
+        if ( empty( $terms ) ) {
146
+            return false;
147
+        }
148
+
149
+        /*
150 150
 		 * We don't consider an `article` to be an entity.
151 151
 		 *
152 152
 		 * @since 3.20.0 At least one associated mustn't be an `article`.
153 153
 		 *
154 154
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
155 155
 		 */
156
-		foreach ( $terms as $term ) {
157
-			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
158
-				return true;
159
-			}
160
-		}
161
-
162
-		return false;
163
-	}
164
-
165
-	/**
166
-	 * Get the proper classification scope for a given entity post
167
-	 *
168
-	 * @param integer $post_id An entity post id.
169
-	 *
170
-	 * @param string $default The default classification scope, `what` if not
171
-	 *                         provided.
172
-	 *
173
-	 * @return string Returns a classification scope (e.g. 'what').
174
-	 * @since 3.5.0
175
-	 *
176
-	 */
177
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
178
-
179
-		if ( false === $this->is_entity( $post_id ) ) {
180
-			return $default;
181
-		}
182
-
183
-		// Retrieve the entity type
184
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
185
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
186
-		// Retrieve classification boxes configuration
187
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
188
-		foreach ( $classification_boxes as $cb ) {
189
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
190
-				return $cb['id'];
191
-			}
192
-		}
193
-
194
-		return $default;
195
-	}
196
-
197
-	/**
198
-	 * Check whether a {@link WP_Post} is used.
199
-	 *
200
-	 * @param int $post_id The {@link WP_Post}'s id.
201
-	 *
202
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
203
-	 */
204
-	public function is_used( $post_id ) {
205
-
206
-		if ( false === $this->is_entity( $post_id ) ) {
207
-			return null;
208
-		}
209
-		// Retrieve the post
210
-		$entity = get_post( $post_id );
211
-
212
-		global $wpdb;
213
-		// Retrieve Wordlift relation instances table name
214
-		$table_name = wl_core_get_relation_instances_table_name();
215
-
216
-		// Check is it's referenced / related to another post / entity
217
-		$stmt = $wpdb->prepare(
218
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
219
-			$entity->ID
220
-		);
221
-
222
-		// Perform the query
223
-		$relation_instances = (int) $wpdb->get_var( $stmt );
224
-		// If there is at least one relation instance for the current entity, then it's used
225
-		if ( 0 < $relation_instances ) {
226
-			return true;
227
-		}
228
-
229
-		// Check if the entity uri is used as meta_value
230
-		$stmt = $wpdb->prepare(
231
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
232
-			$entity->ID,
233
-			wl_get_entity_uri( $entity->ID )
234
-		);
235
-		// Perform the query
236
-		$meta_instances = (int) $wpdb->get_var( $stmt );
237
-
238
-		// If there is at least one meta that refers the current entity uri, then current entity is used
239
-		if ( 0 < $meta_instances ) {
240
-			return true;
241
-		}
242
-
243
-		// If we are here, it means the current entity is not used at the moment
244
-		return false;
245
-	}
246
-
247
-	/**
248
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
249
-	 *
250
-	 * @param string $uri The entity URI.
251
-	 *
252
-	 * @return WP_Post|null A WP_Post instance or null if not found.
253
-	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
254
-	 *
255
-	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
256
-	 * @since      3.2.0
257
-	 *
258
-	 */
259
-	public function get_entity_post_by_uri( $uri ) {
260
-
261
-		return $this->entity_uri_service->get_entity( $uri );
262
-	}
263
-
264
-	/**
265
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
266
-	 * we check that the post we're saving is the current post.
267
-	 *
268
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
269
-	 *
270
-	 * @since 3.2.0
271
-	 *
272
-	 * @param int $post_id Post ID.
273
-	 * @param WP_Post $post Post object.
274
-	 * @param bool $update Whether this is an existing post being updated or not.
275
-	 */
276
-	public function save_post( $post_id, $post, $update ) {
277
-
278
-		// Avoid doing anything if post is autosave or a revision.
279
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
280
-			return;
281
-		}
282
-
283
-		// We're setting the alternative label that have been provided via the UI
284
-		// (in fact we're using $_REQUEST), while save_post may be also called
285
-		// programmatically by some other function: we need to check therefore if
286
-		// the $post_id in the save_post call matches the post id set in the request.
287
-		//
288
-		// If this is not the current post being saved or if it's not an entity, return.
289
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
290
-			return;
291
-		}
292
-
293
-		// Get the alt labels from the request (or empty array).
294
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
295
-
296
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
297
-			// This is via classic editor, so set the alternative labels.
298
-			$this->set_alternative_labels( $post_id, $alt_labels );
299
-		}
300
-
301
-
302
-	}
303
-
304
-	/**
305
-	 * Set the alternative labels.
306
-	 *
307
-	 * @param int $post_id The post id.
308
-	 * @param array $alt_labels An array of labels.
309
-	 *
310
-	 * @since 3.2.0
311
-	 *
312
-	 */
313
-	public function set_alternative_labels( $post_id, $alt_labels ) {
314
-
315
-		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
316
-		// instead of post id.
317
-		if ( ! is_numeric( $post_id ) ) {
318
-			return;
319
-		}
320
-
321
-		// Force $alt_labels to be an array
322
-		if ( ! is_array( $alt_labels ) ) {
323
-			$alt_labels = array( $alt_labels );
324
-		}
325
-
326
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
327
-
328
-		// Delete all the existing alternate labels.
329
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
330
-
331
-		// Set the alternative labels.
332
-		foreach ( $alt_labels as $alt_label ) {
333
-			if ( ! empty( $alt_label ) ) {
334
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
335
-			}
336
-		}
337
-
338
-	}
339
-
340
-	/**
341
-	 * Retrieve the alternate labels.
342
-	 *
343
-	 * @param int $post_id Post id.
344
-	 *
345
-	 * @return mixed An array  of alternative labels.
346
-	 * @since 3.2.0
347
-	 *
348
-	 */
349
-	public function get_alternative_labels( $post_id ) {
350
-
351
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
352
-	}
353
-
354
-	/**
355
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
356
-	 *
357
-	 * @param int $post_id The entity {@link WP_Post} id.
358
-	 *
359
-	 * @return array An array with the entity title and labels.
360
-	 * @since 3.12.0
361
-	 *
362
-	 */
363
-	public function get_labels( $post_id ) {
364
-
365
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
366
-	}
367
-
368
-	/**
369
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
370
-	 *
371
-	 * @param WP_Post $post Post object.
372
-	 *
373
-	 * @since 3.2.0
374
-	 *
375
-	 */
376
-	public function edit_form_before_permalink( $post ) {
377
-
378
-		// If it's not an entity, return.
379
-		if ( ! $this->is_entity( $post->ID ) ) {
380
-			return;
381
-		}
382
-
383
-		// Print the input template.
384
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
385
-
386
-		// Print all the currently set alternative labels.
387
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
388
-
389
-			echo $this->get_alternative_label_input( $alt_label );
390
-
391
-		};
392
-
393
-		// Print the button.
394
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
395
-
396
-	}
397
-
398
-	/**
399
-	 * Get the URI for the entity with the specified post id.
400
-	 *
401
-	 * @param int $post_id The entity post id.
402
-	 *
403
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
404
-	 * @since 3.6.0
405
-	 *
406
-	 */
407
-	private function get_uri_for_post( $post_id ) {
408
-
409
-		$log = Wordlift_Log_Service::get_logger( get_class() );
410
-
411
-		// If a null is given, nothing to do
412
-		if ( is_null( $post_id ) ) {
413
-			return null;
414
-		}
415
-
416
-		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
417
-
418
-		if ( empty( $dataset_uri ) ) {
419
-			// Continue even if the dataset uri is not properly configured. It is handled in function wl_build_entity_uri()
420
-			$log->debug( 'Continuing, dataset uri not configured...' );
421
-		}
422
-
423
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
424
-
425
-		/*
156
+        foreach ( $terms as $term ) {
157
+            if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
158
+                return true;
159
+            }
160
+        }
161
+
162
+        return false;
163
+    }
164
+
165
+    /**
166
+     * Get the proper classification scope for a given entity post
167
+     *
168
+     * @param integer $post_id An entity post id.
169
+     *
170
+     * @param string $default The default classification scope, `what` if not
171
+     *                         provided.
172
+     *
173
+     * @return string Returns a classification scope (e.g. 'what').
174
+     * @since 3.5.0
175
+     *
176
+     */
177
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
178
+
179
+        if ( false === $this->is_entity( $post_id ) ) {
180
+            return $default;
181
+        }
182
+
183
+        // Retrieve the entity type
184
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
185
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
186
+        // Retrieve classification boxes configuration
187
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
188
+        foreach ( $classification_boxes as $cb ) {
189
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
190
+                return $cb['id'];
191
+            }
192
+        }
193
+
194
+        return $default;
195
+    }
196
+
197
+    /**
198
+     * Check whether a {@link WP_Post} is used.
199
+     *
200
+     * @param int $post_id The {@link WP_Post}'s id.
201
+     *
202
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
203
+     */
204
+    public function is_used( $post_id ) {
205
+
206
+        if ( false === $this->is_entity( $post_id ) ) {
207
+            return null;
208
+        }
209
+        // Retrieve the post
210
+        $entity = get_post( $post_id );
211
+
212
+        global $wpdb;
213
+        // Retrieve Wordlift relation instances table name
214
+        $table_name = wl_core_get_relation_instances_table_name();
215
+
216
+        // Check is it's referenced / related to another post / entity
217
+        $stmt = $wpdb->prepare(
218
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
219
+            $entity->ID
220
+        );
221
+
222
+        // Perform the query
223
+        $relation_instances = (int) $wpdb->get_var( $stmt );
224
+        // If there is at least one relation instance for the current entity, then it's used
225
+        if ( 0 < $relation_instances ) {
226
+            return true;
227
+        }
228
+
229
+        // Check if the entity uri is used as meta_value
230
+        $stmt = $wpdb->prepare(
231
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
232
+            $entity->ID,
233
+            wl_get_entity_uri( $entity->ID )
234
+        );
235
+        // Perform the query
236
+        $meta_instances = (int) $wpdb->get_var( $stmt );
237
+
238
+        // If there is at least one meta that refers the current entity uri, then current entity is used
239
+        if ( 0 < $meta_instances ) {
240
+            return true;
241
+        }
242
+
243
+        // If we are here, it means the current entity is not used at the moment
244
+        return false;
245
+    }
246
+
247
+    /**
248
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
249
+     *
250
+     * @param string $uri The entity URI.
251
+     *
252
+     * @return WP_Post|null A WP_Post instance or null if not found.
253
+     * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
254
+     *
255
+     * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
256
+     * @since      3.2.0
257
+     *
258
+     */
259
+    public function get_entity_post_by_uri( $uri ) {
260
+
261
+        return $this->entity_uri_service->get_entity( $uri );
262
+    }
263
+
264
+    /**
265
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
266
+     * we check that the post we're saving is the current post.
267
+     *
268
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
269
+     *
270
+     * @since 3.2.0
271
+     *
272
+     * @param int $post_id Post ID.
273
+     * @param WP_Post $post Post object.
274
+     * @param bool $update Whether this is an existing post being updated or not.
275
+     */
276
+    public function save_post( $post_id, $post, $update ) {
277
+
278
+        // Avoid doing anything if post is autosave or a revision.
279
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
280
+            return;
281
+        }
282
+
283
+        // We're setting the alternative label that have been provided via the UI
284
+        // (in fact we're using $_REQUEST), while save_post may be also called
285
+        // programmatically by some other function: we need to check therefore if
286
+        // the $post_id in the save_post call matches the post id set in the request.
287
+        //
288
+        // If this is not the current post being saved or if it's not an entity, return.
289
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
290
+            return;
291
+        }
292
+
293
+        // Get the alt labels from the request (or empty array).
294
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
295
+
296
+        if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
297
+            // This is via classic editor, so set the alternative labels.
298
+            $this->set_alternative_labels( $post_id, $alt_labels );
299
+        }
300
+
301
+
302
+    }
303
+
304
+    /**
305
+     * Set the alternative labels.
306
+     *
307
+     * @param int $post_id The post id.
308
+     * @param array $alt_labels An array of labels.
309
+     *
310
+     * @since 3.2.0
311
+     *
312
+     */
313
+    public function set_alternative_labels( $post_id, $alt_labels ) {
314
+
315
+        // Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
316
+        // instead of post id.
317
+        if ( ! is_numeric( $post_id ) ) {
318
+            return;
319
+        }
320
+
321
+        // Force $alt_labels to be an array
322
+        if ( ! is_array( $alt_labels ) ) {
323
+            $alt_labels = array( $alt_labels );
324
+        }
325
+
326
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
327
+
328
+        // Delete all the existing alternate labels.
329
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
330
+
331
+        // Set the alternative labels.
332
+        foreach ( $alt_labels as $alt_label ) {
333
+            if ( ! empty( $alt_label ) ) {
334
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
335
+            }
336
+        }
337
+
338
+    }
339
+
340
+    /**
341
+     * Retrieve the alternate labels.
342
+     *
343
+     * @param int $post_id Post id.
344
+     *
345
+     * @return mixed An array  of alternative labels.
346
+     * @since 3.2.0
347
+     *
348
+     */
349
+    public function get_alternative_labels( $post_id ) {
350
+
351
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
352
+    }
353
+
354
+    /**
355
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
356
+     *
357
+     * @param int $post_id The entity {@link WP_Post} id.
358
+     *
359
+     * @return array An array with the entity title and labels.
360
+     * @since 3.12.0
361
+     *
362
+     */
363
+    public function get_labels( $post_id ) {
364
+
365
+        return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
366
+    }
367
+
368
+    /**
369
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
370
+     *
371
+     * @param WP_Post $post Post object.
372
+     *
373
+     * @since 3.2.0
374
+     *
375
+     */
376
+    public function edit_form_before_permalink( $post ) {
377
+
378
+        // If it's not an entity, return.
379
+        if ( ! $this->is_entity( $post->ID ) ) {
380
+            return;
381
+        }
382
+
383
+        // Print the input template.
384
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
385
+
386
+        // Print all the currently set alternative labels.
387
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
388
+
389
+            echo $this->get_alternative_label_input( $alt_label );
390
+
391
+        };
392
+
393
+        // Print the button.
394
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
395
+
396
+    }
397
+
398
+    /**
399
+     * Get the URI for the entity with the specified post id.
400
+     *
401
+     * @param int $post_id The entity post id.
402
+     *
403
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
404
+     * @since 3.6.0
405
+     *
406
+     */
407
+    private function get_uri_for_post( $post_id ) {
408
+
409
+        $log = Wordlift_Log_Service::get_logger( get_class() );
410
+
411
+        // If a null is given, nothing to do
412
+        if ( is_null( $post_id ) ) {
413
+            return null;
414
+        }
415
+
416
+        $dataset_uri = wl_configuration_get_redlink_dataset_uri();
417
+
418
+        if ( empty( $dataset_uri ) ) {
419
+            // Continue even if the dataset uri is not properly configured. It is handled in function wl_build_entity_uri()
420
+            $log->debug( 'Continuing, dataset uri not configured...' );
421
+        }
422
+
423
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
424
+
425
+        /*
426 426
 		 * Consider the URI invalid if it doesn't start with the dataset URI.
427 427
 		 *
428 428
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/996
429 429
 		 */
430
-		if ( null === $dataset_uri || 0 !== strpos( $uri, $dataset_uri ) ) {
431
-			$uri = null;
432
-		}
433
-
434
-		// Set the URI if it isn't set yet.
435
-		$post_status = get_post_status( $post_id );
436
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'inherit' !== $post_status ) {
437
-			$uri = wl_build_entity_uri( $post_id );
438
-			wl_set_entity_uri( $post_id, $uri );
439
-		}
440
-
441
-		return $uri;
442
-	}
443
-
444
-	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
445
-
446
-		if ( Object_Type_Enum::POST === $type ) {
447
-			return $this->get_uri_for_post( $object_id );
448
-		}
449
-
450
-		if ( Object_Type_Enum::USER === $type ) {
451
-			$uri = Wordlift_User_Service::get_instance()->get_uri( $object_id );
452
-
453
-			return ( false === $uri ? null : $uri );
454
-		}
455
-
456
-		return null;
457
-	}
458
-
459
-	/**
460
-	 * Get the alternative label input HTML code.
461
-	 *
462
-	 * @param string $value The input value.
463
-	 *
464
-	 * @return string The input HTML code.
465
-	 * @since 3.2.0
466
-	 *
467
-	 */
468
-	private function get_alternative_label_input( $value = '' ) {
469
-
470
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
471
-	}
472
-
473
-	/**
474
-	 * Get the number of entity posts published in this blog.
475
-	 *
476
-	 * @return int The number of published entity posts.
477
-	 * @since 3.6.0
478
-	 *
479
-	 */
480
-	public function count() {
481
-		global $wpdb;
482
-
483
-		// Try to get the count from the transient.
484
-		$count = get_transient( '_wl_entity_service__count' );
485
-		if ( false !== $count ) {
486
-			return $count;
487
-		}
488
-
489
-		// Query the count.
490
-		$count = $wpdb->get_var( $wpdb->prepare(
491
-			"SELECT COUNT( DISTINCT( tr.object_id ) )"
492
-			. " FROM {$wpdb->term_relationships} tr"
493
-			. " INNER JOIN {$wpdb->term_taxonomy} tt"
494
-			. "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
495
-			. " INNER JOIN {$wpdb->terms} t"
496
-			. "  ON t.term_id = tt.term_id AND t.name != %s",
497
-			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
498
-			'article'
499
-		) );
500
-
501
-		// Store the count in cache.
502
-		set_transient( '_wl_entity_service__count', $count, 900 );
503
-
504
-		return $count;
505
-	}
506
-
507
-	/**
508
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
509
-	 * call.
510
-	 *
511
-	 * @param array $args The arguments for a `get_posts` call.
512
-	 *
513
-	 * @return array The arguments for a `get_posts` call.
514
-	 * @since 3.15.0
515
-	 *
516
-	 */
517
-	public static function add_criterias( $args ) {
518
-
519
-		// Build an optimal tax-query.
520
-		$tax_query = array(
521
-			'relation' => 'AND',
522
-			array(
523
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
524
-				'operator' => 'EXISTS',
525
-			),
526
-			array(
527
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
528
-				'field'    => 'slug',
529
-				'terms'    => 'article',
530
-				'operator' => 'NOT IN',
531
-			),
532
-		);
533
-
534
-		return $args + array(
535
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
536
-				/*
430
+        if ( null === $dataset_uri || 0 !== strpos( $uri, $dataset_uri ) ) {
431
+            $uri = null;
432
+        }
433
+
434
+        // Set the URI if it isn't set yet.
435
+        $post_status = get_post_status( $post_id );
436
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'inherit' !== $post_status ) {
437
+            $uri = wl_build_entity_uri( $post_id );
438
+            wl_set_entity_uri( $post_id, $uri );
439
+        }
440
+
441
+        return $uri;
442
+    }
443
+
444
+    public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
445
+
446
+        if ( Object_Type_Enum::POST === $type ) {
447
+            return $this->get_uri_for_post( $object_id );
448
+        }
449
+
450
+        if ( Object_Type_Enum::USER === $type ) {
451
+            $uri = Wordlift_User_Service::get_instance()->get_uri( $object_id );
452
+
453
+            return ( false === $uri ? null : $uri );
454
+        }
455
+
456
+        return null;
457
+    }
458
+
459
+    /**
460
+     * Get the alternative label input HTML code.
461
+     *
462
+     * @param string $value The input value.
463
+     *
464
+     * @return string The input HTML code.
465
+     * @since 3.2.0
466
+     *
467
+     */
468
+    private function get_alternative_label_input( $value = '' ) {
469
+
470
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
471
+    }
472
+
473
+    /**
474
+     * Get the number of entity posts published in this blog.
475
+     *
476
+     * @return int The number of published entity posts.
477
+     * @since 3.6.0
478
+     *
479
+     */
480
+    public function count() {
481
+        global $wpdb;
482
+
483
+        // Try to get the count from the transient.
484
+        $count = get_transient( '_wl_entity_service__count' );
485
+        if ( false !== $count ) {
486
+            return $count;
487
+        }
488
+
489
+        // Query the count.
490
+        $count = $wpdb->get_var( $wpdb->prepare(
491
+            "SELECT COUNT( DISTINCT( tr.object_id ) )"
492
+            . " FROM {$wpdb->term_relationships} tr"
493
+            . " INNER JOIN {$wpdb->term_taxonomy} tt"
494
+            . "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
495
+            . " INNER JOIN {$wpdb->terms} t"
496
+            . "  ON t.term_id = tt.term_id AND t.name != %s",
497
+            Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
498
+            'article'
499
+        ) );
500
+
501
+        // Store the count in cache.
502
+        set_transient( '_wl_entity_service__count', $count, 900 );
503
+
504
+        return $count;
505
+    }
506
+
507
+    /**
508
+     * Add the entity filtering criterias to the arguments for a `get_posts`
509
+     * call.
510
+     *
511
+     * @param array $args The arguments for a `get_posts` call.
512
+     *
513
+     * @return array The arguments for a `get_posts` call.
514
+     * @since 3.15.0
515
+     *
516
+     */
517
+    public static function add_criterias( $args ) {
518
+
519
+        // Build an optimal tax-query.
520
+        $tax_query = array(
521
+            'relation' => 'AND',
522
+            array(
523
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
524
+                'operator' => 'EXISTS',
525
+            ),
526
+            array(
527
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
528
+                'field'    => 'slug',
529
+                'terms'    => 'article',
530
+                'operator' => 'NOT IN',
531
+            ),
532
+        );
533
+
534
+        return $args + array(
535
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
536
+                /*
537 537
 				 * Ensure compatibility with Polylang.
538 538
 				 *
539 539
 				 * @see https://github.com/insideout10/wordlift-plugin/issues/855.
@@ -541,102 +541,102 @@  discard block
 block discarded – undo
541 541
 				 *
542 542
 				 * @since 3.19.5
543 543
 				 */
544
-				'lang'      => '',
545
-				'tax_query' => $tax_query,
546
-			);
547
-	}
548
-
549
-	/**
550
-	 * Create a new entity.
551
-	 *
552
-	 * @param string $name The entity name.
553
-	 * @param string $type_uri The entity's type URI.
554
-	 * @param null $logo The entity logo id (or NULL if none).
555
-	 * @param string $status The post status, by default 'publish'.
556
-	 *
557
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
558
-	 * @since 3.9.0
559
-	 *
560
-	 */
561
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
562
-
563
-		// Create an entity for the publisher.
564
-		$post_id = @wp_insert_post( array(
565
-			'post_type'    => self::TYPE_NAME,
566
-			'post_title'   => $name,
567
-			'post_status'  => $status,
568
-			'post_content' => '',
569
-		) );
570
-
571
-		// Return the error if any.
572
-		if ( is_wp_error( $post_id ) ) {
573
-			return $post_id;
574
-		}
575
-
576
-		// Set the entity logo.
577
-		if ( $logo && is_numeric( $logo ) ) {
578
-			set_post_thumbnail( $post_id, $logo );
579
-		}
580
-
581
-		// Set the entity type.
582
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
583
-
584
-		return $post_id;
585
-	}
586
-
587
-	/**
588
-	 * Get the entities related to the one with the specified id. By default only
589
-	 * published entities will be returned.
590
-	 *
591
-	 * @param int $id The post id.
592
-	 * @param string $post_status The target post status (default = publish).
593
-	 *
594
-	 * @return array An array of post ids.
595
-	 * @since 3.10.0
596
-	 *
597
-	 */
598
-	public function get_related_entities( $id, $post_status = 'publish' ) {
599
-
600
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
601
-	}
602
-
603
-	/**
604
-	 * Get the list of entities.
605
-	 *
606
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
607
-	 *
608
-	 * @return array An array of entity posts.
609
-	 * @since 3.12.2
610
-	 *
611
-	 */
612
-	public function get( $params = array() ) {
613
-
614
-		// Set the defaults.
615
-		$defaults = array( 'post_type' => 'entity' );
616
-
617
-		// Merge the defaults with the provided parameters.
618
-		$args = wp_parse_args( $params, $defaults );
619
-
620
-		// Call the `get_posts` function.
621
-		return get_posts( $args );
622
-	}
623
-
624
-	/**
625
-	 * The list of post type names which can be used for entities
626
-	 *
627
-	 * Criteria is that the post type is public. The list of valid post types
628
-	 * can be overridden with a filter.
629
-	 *
630
-	 * @return array Array containing the names of the valid post types.
631
-	 * @since 3.15.0
632
-	 *
633
-	 */
634
-	static function valid_entity_post_types() {
635
-
636
-		// Ignore builtins in the call to avoid getting attachments.
637
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
638
-
639
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
640
-	}
544
+                'lang'      => '',
545
+                'tax_query' => $tax_query,
546
+            );
547
+    }
548
+
549
+    /**
550
+     * Create a new entity.
551
+     *
552
+     * @param string $name The entity name.
553
+     * @param string $type_uri The entity's type URI.
554
+     * @param null $logo The entity logo id (or NULL if none).
555
+     * @param string $status The post status, by default 'publish'.
556
+     *
557
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
558
+     * @since 3.9.0
559
+     *
560
+     */
561
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
562
+
563
+        // Create an entity for the publisher.
564
+        $post_id = @wp_insert_post( array(
565
+            'post_type'    => self::TYPE_NAME,
566
+            'post_title'   => $name,
567
+            'post_status'  => $status,
568
+            'post_content' => '',
569
+        ) );
570
+
571
+        // Return the error if any.
572
+        if ( is_wp_error( $post_id ) ) {
573
+            return $post_id;
574
+        }
575
+
576
+        // Set the entity logo.
577
+        if ( $logo && is_numeric( $logo ) ) {
578
+            set_post_thumbnail( $post_id, $logo );
579
+        }
580
+
581
+        // Set the entity type.
582
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
583
+
584
+        return $post_id;
585
+    }
586
+
587
+    /**
588
+     * Get the entities related to the one with the specified id. By default only
589
+     * published entities will be returned.
590
+     *
591
+     * @param int $id The post id.
592
+     * @param string $post_status The target post status (default = publish).
593
+     *
594
+     * @return array An array of post ids.
595
+     * @since 3.10.0
596
+     *
597
+     */
598
+    public function get_related_entities( $id, $post_status = 'publish' ) {
599
+
600
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
601
+    }
602
+
603
+    /**
604
+     * Get the list of entities.
605
+     *
606
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
607
+     *
608
+     * @return array An array of entity posts.
609
+     * @since 3.12.2
610
+     *
611
+     */
612
+    public function get( $params = array() ) {
613
+
614
+        // Set the defaults.
615
+        $defaults = array( 'post_type' => 'entity' );
616
+
617
+        // Merge the defaults with the provided parameters.
618
+        $args = wp_parse_args( $params, $defaults );
619
+
620
+        // Call the `get_posts` function.
621
+        return get_posts( $args );
622
+    }
623
+
624
+    /**
625
+     * The list of post type names which can be used for entities
626
+     *
627
+     * Criteria is that the post type is public. The list of valid post types
628
+     * can be overridden with a filter.
629
+     *
630
+     * @return array Array containing the names of the valid post types.
631
+     * @since 3.15.0
632
+     *
633
+     */
634
+    static function valid_entity_post_types() {
635
+
636
+        // Ignore builtins in the call to avoid getting attachments.
637
+        $post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
638
+
639
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
640
+    }
641 641
 
642 642
 }
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * @since 3.2.0
100 100
 	 *
101 101
 	 */
102
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
102
+	public function __construct($ui_service, $relation_service, $entity_uri_service) {
103 103
 
104
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
104
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
105 105
 
106 106
 		$this->ui_service         = $ui_service;
107 107
 		$this->relation_service   = $relation_service;
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 	 * @since 3.1.0
133 133
 	 *
134 134
 	 */
135
-	public function is_entity( $post_id ) {
135
+	public function is_entity($post_id) {
136 136
 
137
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
137
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
138 138
 
139
-		if ( is_wp_error( $terms ) ) {
140
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
139
+		if (is_wp_error($terms)) {
140
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
141 141
 
142 142
 			return false;
143 143
 		}
144 144
 
145
-		if ( empty( $terms ) ) {
145
+		if (empty($terms)) {
146 146
 			return false;
147 147
 		}
148 148
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 		 *
154 154
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
155 155
 		 */
156
-		foreach ( $terms as $term ) {
157
-			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
156
+		foreach ($terms as $term) {
157
+			if (1 !== preg_match('~(^|-)article$~', $term->slug)) {
158 158
 				return true;
159 159
 			}
160 160
 		}
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
 	 * @since 3.5.0
175 175
 	 *
176 176
 	 */
177
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
177
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
178 178
 
179
-		if ( false === $this->is_entity( $post_id ) ) {
179
+		if (false === $this->is_entity($post_id)) {
180 180
 			return $default;
181 181
 		}
182 182
 
183 183
 		// Retrieve the entity type
184
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
185
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
184
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
185
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
186 186
 		// Retrieve classification boxes configuration
187
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
188
-		foreach ( $classification_boxes as $cb ) {
189
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
187
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
188
+		foreach ($classification_boxes as $cb) {
189
+			if (in_array($entity_type, $cb['registeredTypes'])) {
190 190
 				return $cb['id'];
191 191
 			}
192 192
 		}
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
203 203
 	 */
204
-	public function is_used( $post_id ) {
204
+	public function is_used($post_id) {
205 205
 
206
-		if ( false === $this->is_entity( $post_id ) ) {
206
+		if (false === $this->is_entity($post_id)) {
207 207
 			return null;
208 208
 		}
209 209
 		// Retrieve the post
210
-		$entity = get_post( $post_id );
210
+		$entity = get_post($post_id);
211 211
 
212 212
 		global $wpdb;
213 213
 		// Retrieve Wordlift relation instances table name
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 		);
221 221
 
222 222
 		// Perform the query
223
-		$relation_instances = (int) $wpdb->get_var( $stmt );
223
+		$relation_instances = (int) $wpdb->get_var($stmt);
224 224
 		// If there is at least one relation instance for the current entity, then it's used
225
-		if ( 0 < $relation_instances ) {
225
+		if (0 < $relation_instances) {
226 226
 			return true;
227 227
 		}
228 228
 
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 		$stmt = $wpdb->prepare(
231 231
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
232 232
 			$entity->ID,
233
-			wl_get_entity_uri( $entity->ID )
233
+			wl_get_entity_uri($entity->ID)
234 234
 		);
235 235
 		// Perform the query
236
-		$meta_instances = (int) $wpdb->get_var( $stmt );
236
+		$meta_instances = (int) $wpdb->get_var($stmt);
237 237
 
238 238
 		// If there is at least one meta that refers the current entity uri, then current entity is used
239
-		if ( 0 < $meta_instances ) {
239
+		if (0 < $meta_instances) {
240 240
 			return true;
241 241
 		}
242 242
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	 * @since      3.2.0
257 257
 	 *
258 258
 	 */
259
-	public function get_entity_post_by_uri( $uri ) {
259
+	public function get_entity_post_by_uri($uri) {
260 260
 
261
-		return $this->entity_uri_service->get_entity( $uri );
261
+		return $this->entity_uri_service->get_entity($uri);
262 262
 	}
263 263
 
264 264
 	/**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 * @param WP_Post $post Post object.
274 274
 	 * @param bool $update Whether this is an existing post being updated or not.
275 275
 	 */
276
-	public function save_post( $post_id, $post, $update ) {
276
+	public function save_post($post_id, $post, $update) {
277 277
 
278 278
 		// Avoid doing anything if post is autosave or a revision.
279
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
279
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
280 280
 			return;
281 281
 		}
282 282
 
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 		// the $post_id in the save_post call matches the post id set in the request.
287 287
 		//
288 288
 		// If this is not the current post being saved or if it's not an entity, return.
289
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
289
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
290 290
 			return;
291 291
 		}
292 292
 
293 293
 		// Get the alt labels from the request (or empty array).
294
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
294
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array();
295 295
 
296
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
296
+		if (( ! empty($_POST['content']) && ! empty($_POST['post_content'])) || isset($_REQUEST['wl_alternative_label'])) {
297 297
 			// This is via classic editor, so set the alternative labels.
298
-			$this->set_alternative_labels( $post_id, $alt_labels );
298
+			$this->set_alternative_labels($post_id, $alt_labels);
299 299
 		}
300 300
 
301 301
 
@@ -310,28 +310,28 @@  discard block
 block discarded – undo
310 310
 	 * @since 3.2.0
311 311
 	 *
312 312
 	 */
313
-	public function set_alternative_labels( $post_id, $alt_labels ) {
313
+	public function set_alternative_labels($post_id, $alt_labels) {
314 314
 
315 315
 		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
316 316
 		// instead of post id.
317
-		if ( ! is_numeric( $post_id ) ) {
317
+		if ( ! is_numeric($post_id)) {
318 318
 			return;
319 319
 		}
320 320
 
321 321
 		// Force $alt_labels to be an array
322
-		if ( ! is_array( $alt_labels ) ) {
323
-			$alt_labels = array( $alt_labels );
322
+		if ( ! is_array($alt_labels)) {
323
+			$alt_labels = array($alt_labels);
324 324
 		}
325 325
 
326
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
326
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
327 327
 
328 328
 		// Delete all the existing alternate labels.
329
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
329
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
330 330
 
331 331
 		// Set the alternative labels.
332
-		foreach ( $alt_labels as $alt_label ) {
333
-			if ( ! empty( $alt_label ) ) {
334
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
332
+		foreach ($alt_labels as $alt_label) {
333
+			if ( ! empty($alt_label)) {
334
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label);
335 335
 			}
336 336
 		}
337 337
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 	 * @since 3.2.0
347 347
 	 *
348 348
 	 */
349
-	public function get_alternative_labels( $post_id ) {
349
+	public function get_alternative_labels($post_id) {
350 350
 
351
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
351
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
352 352
 	}
353 353
 
354 354
 	/**
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @since 3.12.0
361 361
 	 *
362 362
 	 */
363
-	public function get_labels( $post_id ) {
363
+	public function get_labels($post_id) {
364 364
 
365
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
365
+		return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
366 366
 	}
367 367
 
368 368
 	/**
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	 * @since 3.2.0
374 374
 	 *
375 375
 	 */
376
-	public function edit_form_before_permalink( $post ) {
376
+	public function edit_form_before_permalink($post) {
377 377
 
378 378
 		// If it's not an entity, return.
379
-		if ( ! $this->is_entity( $post->ID ) ) {
379
+		if ( ! $this->is_entity($post->ID)) {
380 380
 			return;
381 381
 		}
382 382
 
383 383
 		// Print the input template.
384
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
384
+		$this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
385 385
 
386 386
 		// Print all the currently set alternative labels.
387
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
387
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
388 388
 
389
-			echo $this->get_alternative_label_input( $alt_label );
389
+			echo $this->get_alternative_label_input($alt_label);
390 390
 
391 391
 		};
392 392
 
393 393
 		// Print the button.
394
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
394
+		$this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
395 395
 
396 396
 	}
397 397
 
@@ -404,53 +404,53 @@  discard block
 block discarded – undo
404 404
 	 * @since 3.6.0
405 405
 	 *
406 406
 	 */
407
-	private function get_uri_for_post( $post_id ) {
407
+	private function get_uri_for_post($post_id) {
408 408
 
409
-		$log = Wordlift_Log_Service::get_logger( get_class() );
409
+		$log = Wordlift_Log_Service::get_logger(get_class());
410 410
 
411 411
 		// If a null is given, nothing to do
412
-		if ( is_null( $post_id ) ) {
412
+		if (is_null($post_id)) {
413 413
 			return null;
414 414
 		}
415 415
 
416 416
 		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
417 417
 
418
-		if ( empty( $dataset_uri ) ) {
418
+		if (empty($dataset_uri)) {
419 419
 			// Continue even if the dataset uri is not properly configured. It is handled in function wl_build_entity_uri()
420
-			$log->debug( 'Continuing, dataset uri not configured...' );
420
+			$log->debug('Continuing, dataset uri not configured...');
421 421
 		}
422 422
 
423
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
423
+		$uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, true);
424 424
 
425 425
 		/*
426 426
 		 * Consider the URI invalid if it doesn't start with the dataset URI.
427 427
 		 *
428 428
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/996
429 429
 		 */
430
-		if ( null === $dataset_uri || 0 !== strpos( $uri, $dataset_uri ) ) {
430
+		if (null === $dataset_uri || 0 !== strpos($uri, $dataset_uri)) {
431 431
 			$uri = null;
432 432
 		}
433 433
 
434 434
 		// Set the URI if it isn't set yet.
435
-		$post_status = get_post_status( $post_id );
436
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'inherit' !== $post_status ) {
437
-			$uri = wl_build_entity_uri( $post_id );
438
-			wl_set_entity_uri( $post_id, $uri );
435
+		$post_status = get_post_status($post_id);
436
+		if (empty($uri) && 'auto-draft' !== $post_status && 'inherit' !== $post_status) {
437
+			$uri = wl_build_entity_uri($post_id);
438
+			wl_set_entity_uri($post_id, $uri);
439 439
 		}
440 440
 
441 441
 		return $uri;
442 442
 	}
443 443
 
444
-	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
444
+	public function get_uri($object_id, $type = Object_Type_Enum::POST) {
445 445
 
446
-		if ( Object_Type_Enum::POST === $type ) {
447
-			return $this->get_uri_for_post( $object_id );
446
+		if (Object_Type_Enum::POST === $type) {
447
+			return $this->get_uri_for_post($object_id);
448 448
 		}
449 449
 
450
-		if ( Object_Type_Enum::USER === $type ) {
451
-			$uri = Wordlift_User_Service::get_instance()->get_uri( $object_id );
450
+		if (Object_Type_Enum::USER === $type) {
451
+			$uri = Wordlift_User_Service::get_instance()->get_uri($object_id);
452 452
 
453
-			return ( false === $uri ? null : $uri );
453
+			return (false === $uri ? null : $uri);
454 454
 		}
455 455
 
456 456
 		return null;
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	 * @since 3.2.0
466 466
 	 *
467 467
 	 */
468
-	private function get_alternative_label_input( $value = '' ) {
468
+	private function get_alternative_label_input($value = '') {
469 469
 
470
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
470
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
471 471
 	}
472 472
 
473 473
 	/**
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 		global $wpdb;
482 482
 
483 483
 		// Try to get the count from the transient.
484
-		$count = get_transient( '_wl_entity_service__count' );
485
-		if ( false !== $count ) {
484
+		$count = get_transient('_wl_entity_service__count');
485
+		if (false !== $count) {
486 486
 			return $count;
487 487
 		}
488 488
 
489 489
 		// Query the count.
490
-		$count = $wpdb->get_var( $wpdb->prepare(
490
+		$count = $wpdb->get_var($wpdb->prepare(
491 491
 			"SELECT COUNT( DISTINCT( tr.object_id ) )"
492 492
 			. " FROM {$wpdb->term_relationships} tr"
493 493
 			. " INNER JOIN {$wpdb->term_taxonomy} tt"
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 			. "  ON t.term_id = tt.term_id AND t.name != %s",
497 497
 			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
498 498
 			'article'
499
-		) );
499
+		));
500 500
 
501 501
 		// Store the count in cache.
502
-		set_transient( '_wl_entity_service__count', $count, 900 );
502
+		set_transient('_wl_entity_service__count', $count, 900);
503 503
 
504 504
 		return $count;
505 505
 	}
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 	 * @since 3.15.0
515 515
 	 *
516 516
 	 */
517
-	public static function add_criterias( $args ) {
517
+	public static function add_criterias($args) {
518 518
 
519 519
 		// Build an optimal tax-query.
520 520
 		$tax_query = array(
@@ -558,28 +558,28 @@  discard block
 block discarded – undo
558 558
 	 * @since 3.9.0
559 559
 	 *
560 560
 	 */
561
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
561
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
562 562
 
563 563
 		// Create an entity for the publisher.
564
-		$post_id = @wp_insert_post( array(
564
+		$post_id = @wp_insert_post(array(
565 565
 			'post_type'    => self::TYPE_NAME,
566 566
 			'post_title'   => $name,
567 567
 			'post_status'  => $status,
568 568
 			'post_content' => '',
569
-		) );
569
+		));
570 570
 
571 571
 		// Return the error if any.
572
-		if ( is_wp_error( $post_id ) ) {
572
+		if (is_wp_error($post_id)) {
573 573
 			return $post_id;
574 574
 		}
575 575
 
576 576
 		// Set the entity logo.
577
-		if ( $logo && is_numeric( $logo ) ) {
578
-			set_post_thumbnail( $post_id, $logo );
577
+		if ($logo && is_numeric($logo)) {
578
+			set_post_thumbnail($post_id, $logo);
579 579
 		}
580 580
 
581 581
 		// Set the entity type.
582
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
582
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
583 583
 
584 584
 		return $post_id;
585 585
 	}
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	 * @since 3.10.0
596 596
 	 *
597 597
 	 */
598
-	public function get_related_entities( $id, $post_status = 'publish' ) {
598
+	public function get_related_entities($id, $post_status = 'publish') {
599 599
 
600
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
600
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
601 601
 	}
602 602
 
603 603
 	/**
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 	 * @since 3.12.2
610 610
 	 *
611 611
 	 */
612
-	public function get( $params = array() ) {
612
+	public function get($params = array()) {
613 613
 
614 614
 		// Set the defaults.
615
-		$defaults = array( 'post_type' => 'entity' );
615
+		$defaults = array('post_type' => 'entity');
616 616
 
617 617
 		// Merge the defaults with the provided parameters.
618
-		$args = wp_parse_args( $params, $defaults );
618
+		$args = wp_parse_args($params, $defaults);
619 619
 
620 620
 		// Call the `get_posts` function.
621
-		return get_posts( $args );
621
+		return get_posts($args);
622 622
 	}
623 623
 
624 624
 	/**
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	static function valid_entity_post_types() {
635 635
 
636 636
 		// Ignore builtins in the call to avoid getting attachments.
637
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
637
+		$post_types = array('post', 'page', self::TYPE_NAME, 'product');
638 638
 
639
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
639
+		return apply_filters('wl_valid_entity_post_types', $post_types);
640 640
 	}
641 641
 
642 642
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-user-service.php 2 patches
Indentation   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -19,487 +19,487 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_User_Service {
21 21
 
22
-	/**
23
-	 * The meta key where the user's URI is stored.
24
-	 *
25
-	 * @since 3.1.7
26
-	 */
27
-	const URI_META_KEY = '_wl_uri';
28
-
29
-	/**
30
-	 * The user meta key where the deny entity edit flag is stored.
31
-	 *
32
-	 * @since 3.14.0
33
-	 */
34
-	const DENY_ENTITY_CREATE_META_KEY = '_wl_deny_entity_create';
35
-
36
-	/**
37
-	 * The meta key holding the entity id representing a {@link WP_User}.
38
-	 *
39
-	 * @since 3.14.0
40
-	 */
41
-	const ENTITY_META_KEY = '_wl_entity';
42
-
43
-	/**
44
-	 * The Log service.
45
-	 *
46
-	 * @since  3.1.7
47
-	 * @access private
48
-	 * @var \Wordlift_Log_Service $log_service The Log service.
49
-	 */
50
-	private $log_service;
51
-
52
-	/**
53
-	 * The singleton instance of the User service.
54
-	 *
55
-	 * @since  3.1.7
56
-	 * @access private
57
-	 * @var \Wordlift_User_Service $user_service The singleton instance of the User service.
58
-	 */
59
-	private static $instance;
60
-
61
-	/**
62
-	 * The {@link Wordlift_Sparql_Service} instance.
63
-	 *
64
-	 * @since  3.18.0
65
-	 * @access private
66
-	 * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
67
-	 */
68
-	private $sparql_service;
69
-
70
-	/**
71
-	 * The Entity service.
72
-	 *
73
-	 * @since  3.18.0
74
-	 * @access private
75
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
76
-	 */
77
-	private $entity_service;
78
-
79
-	/**
80
-	 * Create an instance of the User service.
81
-	 *
82
-	 * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
83
-	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
84
-	 *
85
-	 * @since 3.1.7
86
-	 *
87
-	 */
88
-	public function __construct( $sparql_service, $entity_service ) {
89
-
90
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_User_Service' );
91
-
92
-		self::$instance = $this;
93
-
94
-		$this->sparql_service = $sparql_service;
95
-		$this->entity_service = $entity_service;
96
-
97
-		add_filter( 'user_has_cap', array( $this, 'has_cap' ), 10, 3 );
98
-	}
99
-
100
-	/**
101
-	 * Get the singleton instance of the User service.
102
-	 *
103
-	 * @return \Wordlift_User_Service The singleton instance of the User service.
104
-	 * @since 3.1.7
105
-	 */
106
-	public static function get_instance() {
107
-
108
-		return self::$instance;
109
-	}
110
-
111
-	/**
112
-	 * Get the URI for a user.
113
-	 *
114
-	 * @param int $user_id The user id
115
-	 *
116
-	 * @return false|string The user's URI or false in case of failure.
117
-	 * @since 3.1.7
118
-	 *
119
-	 */
120
-	public function get_uri( $user_id ) {
121
-
122
-		// Try to get the URI stored in the user's meta and return it if available.
123
-		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
124
-		$user_uri    = $this->_get_uri( $user_id );
125
-		if ( ! empty( $dataset_uri ) && ! empty( $user_uri ) && 0 === strpos( $user_uri, $dataset_uri ) ) {
126
-			return $user_uri;
127
-		}
128
-
129
-		// Try to build an URI, return false in case of failure.
130
-		if ( false === ( $user_uri = $this->_build_uri( $user_id ) ) ) {
131
-			return false;
132
-		}
133
-
134
-		// Store the URI for future requests (we need a "permanent" URI).
135
-		$this->_set_uri( $user_id, $user_uri );
136
-
137
-		return $user_uri;
138
-	}
139
-
140
-	/**
141
-	 * Set the `id` of the entity representing a {@link WP_User}.
142
-	 *
143
-	 * If the `id` is set to 0 (or less) then the meta is deleted.
144
-	 *
145
-	 * @param int $user_id The {@link WP_User}.
146
-	 * @param int $value The entity {@link WP_Post} `id`.
147
-	 *
148
-	 * @return bool|int  Meta ID if the key didn't exist, true on successful update, false on failure.
149
-	 * @since 3.14.0
150
-	 *
151
-	 */
152
-	public function set_entity( $user_id, $value ) {
153
-
154
-		return 0 < $value
155
-			? update_user_meta( $user_id, self::ENTITY_META_KEY, $value )
156
-			: delete_user_meta( $user_id, self::ENTITY_META_KEY );
157
-	}
158
-
159
-	/**
160
-	 * Get the {@link WP_Post} `id` of the entity representing a {@link WP_User}.
161
-	 *
162
-	 * @param int $user_id The {@link WP_User}'s `id`.
163
-	 *
164
-	 * @return string|false The entity {@link WP_Post} `id` or an empty string if not set or false if the object id is invalid
165
-	 * @since 3.14.0
166
-	 *
167
-	 */
168
-	public function get_entity( $user_id ) {
169
-
170
-		return get_user_meta( $user_id, self::ENTITY_META_KEY, true );
171
-	}
172
-
173
-	/**
174
-	 * Get the user's URI stored in the user's meta.
175
-	 *
176
-	 * @param int $user_id The user id.
177
-	 *
178
-	 * @return false|string The user's URI or false if not found.
179
-	 * @since 3.1.7
180
-	 *
181
-	 */
182
-	private function _get_uri( $user_id ) {
183
-
184
-		$user_uri = get_user_meta( $user_id, self::URI_META_KEY, true );
185
-
186
-		if ( empty( $user_uri ) ) {
187
-			return false;
188
-		}
189
-
190
-		return $user_uri;
191
-	}
192
-
193
-	/**
194
-	 * Build an URI for a user.
195
-	 *
196
-	 * @param int $user_id The user's id.
197
-	 *
198
-	 * @return false|string The user's URI or false in case of failure.
199
-	 * @since 3.1.7
200
-	 *
201
-	 */
202
-	private function _build_uri( $user_id ) {
203
-
204
-		// Get the user, return false in case of failure.
205
-		if ( false === ( $user = get_userdata( $user_id ) ) ) {
206
-			return false;
207
-		};
208
-
209
-		// If the nicename is not set, return a failure.
210
-		if ( empty( $user->user_nicename ) ) {
211
-			return false;
212
-		}
213
-
214
-		/**
215
-		 * @since 3.27.7 changed `user` to `author` to avoid potential clashes with CPTs ( `author` is reserved
216
-		 *  https://developer.wordpress.org/reference/functions/register_post_type/#reserved-post-types )
217
-		 */
218
-		return wl_configuration_get_redlink_dataset_uri() . "/author/$user->user_nicename";
219
-	}
220
-
221
-	/**
222
-	 * Store the URI in user's meta.
223
-	 *
224
-	 * @param int $user_id The user's id.
225
-	 * @param string $user_uri The user's uri.
226
-	 *
227
-	 * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
228
-	 * @since 3.1.7
229
-	 *
230
-	 */
231
-	private function _set_uri( $user_id, $user_uri ) {
232
-
233
-		return update_user_meta( $user_id, self::URI_META_KEY, $user_uri );
234
-	}
235
-
236
-	/**
237
-	 * Mark an editor user as denied from editing entities.
238
-	 * Does nothing if the user is not an editor
239
-	 *
240
-	 * @param integer $user_id The ID of the user
241
-	 *
242
-	 * @since 3.14.0
243
-	 *
244
-	 */
245
-	public function deny_editor_entity_create( $user_id ) {
246
-
247
-		// Bail out if the user is not an editor.
248
-		if ( ! $this->is_editor( $user_id ) ) {
249
-			return;
250
-		}
251
-
252
-		// The user explicitly do not have the capability.
253
-		update_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY, 'yes' );
254
-
255
-	}
256
-
257
-	/**
258
-	 * Remove the "deny entity editing" mark from an editor user.
259
-	 * Does nothing if the user is not an editor
260
-	 *
261
-	 * @param integer $user_id The ID of the user
262
-	 *
263
-	 * @since 3.14.0
264
-	 *
265
-	 */
266
-	public function allow_editor_entity_create( $user_id ) {
267
-
268
-		// Bail out if the user is not an editor.
269
-		if ( ! $this->is_editor( $user_id ) ) {
270
-			return;
271
-		}
272
-
273
-		// The user explicitly do not have the capability.
274
-		delete_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY );
275
-
276
-	}
277
-
278
-	/**
279
-	 * Get whether the 'deny editor entity editing' flag is set.
280
-	 *
281
-	 * @param int $user_id The {@link WP_User} `id`.
282
-	 *
283
-	 * @return int bool True if editing is denied otherwise false.
284
-	 * @since 3.14.0
285
-	 *
286
-	 */
287
-	public function is_deny_editor_entity_create( $user_id ) {
288
-
289
-		return 'yes' === get_user_option( self::DENY_ENTITY_CREATE_META_KEY, $user_id );
290
-	}
291
-
292
-	/**
293
-	 * Check whether the {@link WP_User} with the specified `id` is an editor,
294
-	 * i.e. has the `editor` role.
295
-	 *
296
-	 * @param int $user_id The {@link WP_User} `id`.
297
-	 *
298
-	 * @return bool True if the {@link WP_User} is an editor otherwise false.
299
-	 * @since 3.14.0
300
-	 *
301
-	 */
302
-	public function is_editor( $user_id ) {
303
-
304
-		// Get the user.
305
-		$user = get_user_by( 'id', $user_id );
306
-
307
-		// Return true, if the user is found and has the `editor` role.
308
-		return is_a( $user, 'WP_User' ) && in_array( 'editor', (array) $user->roles );
309
-	}
310
-
311
-	/**
312
-	 * Check if an editor can create entities.
313
-	 *
314
-	 * @param int $user_id The user id of the user being checked.
315
-	 *
316
-	 * @return bool    false if it is an editor that is denied from edit entities, true otherwise.
317
-	 * @since 3.14.0
318
-	 *
319
-	 */
320
-	public function editor_can_create_entities( $user_id ) {
321
-
322
-		// Return true if not an editor.
323
-		if ( ! $this->is_editor( $user_id ) ) {
324
-			return true;
325
-		}
326
-
327
-		// Check if the user explicitly denied.
328
-		return ! $this->is_deny_editor_entity_create( $user_id );
329
-	}
330
-
331
-	/**
332
-	 * Filter capabilities of user.
333
-	 *
334
-	 * Deny the capability of managing and editing entities for some users.
335
-	 *
336
-	 * @param array $allcaps All the capabilities of the user
337
-	 * @param array $cap [0] Required capability
338
-	 * @param array $args [0] Requested capability
339
-	 *                       [1] User ID
340
-	 *                       [2] Associated object ID
341
-	 *
342
-	 * @return array The capabilities array.
343
-	 * @since 3.14.0
344
-	 *
345
-	 */
346
-	public function has_cap( $allcaps, $cap, $args ) {
347
-		/*
22
+    /**
23
+     * The meta key where the user's URI is stored.
24
+     *
25
+     * @since 3.1.7
26
+     */
27
+    const URI_META_KEY = '_wl_uri';
28
+
29
+    /**
30
+     * The user meta key where the deny entity edit flag is stored.
31
+     *
32
+     * @since 3.14.0
33
+     */
34
+    const DENY_ENTITY_CREATE_META_KEY = '_wl_deny_entity_create';
35
+
36
+    /**
37
+     * The meta key holding the entity id representing a {@link WP_User}.
38
+     *
39
+     * @since 3.14.0
40
+     */
41
+    const ENTITY_META_KEY = '_wl_entity';
42
+
43
+    /**
44
+     * The Log service.
45
+     *
46
+     * @since  3.1.7
47
+     * @access private
48
+     * @var \Wordlift_Log_Service $log_service The Log service.
49
+     */
50
+    private $log_service;
51
+
52
+    /**
53
+     * The singleton instance of the User service.
54
+     *
55
+     * @since  3.1.7
56
+     * @access private
57
+     * @var \Wordlift_User_Service $user_service The singleton instance of the User service.
58
+     */
59
+    private static $instance;
60
+
61
+    /**
62
+     * The {@link Wordlift_Sparql_Service} instance.
63
+     *
64
+     * @since  3.18.0
65
+     * @access private
66
+     * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
67
+     */
68
+    private $sparql_service;
69
+
70
+    /**
71
+     * The Entity service.
72
+     *
73
+     * @since  3.18.0
74
+     * @access private
75
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
76
+     */
77
+    private $entity_service;
78
+
79
+    /**
80
+     * Create an instance of the User service.
81
+     *
82
+     * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
83
+     * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
84
+     *
85
+     * @since 3.1.7
86
+     *
87
+     */
88
+    public function __construct( $sparql_service, $entity_service ) {
89
+
90
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_User_Service' );
91
+
92
+        self::$instance = $this;
93
+
94
+        $this->sparql_service = $sparql_service;
95
+        $this->entity_service = $entity_service;
96
+
97
+        add_filter( 'user_has_cap', array( $this, 'has_cap' ), 10, 3 );
98
+    }
99
+
100
+    /**
101
+     * Get the singleton instance of the User service.
102
+     *
103
+     * @return \Wordlift_User_Service The singleton instance of the User service.
104
+     * @since 3.1.7
105
+     */
106
+    public static function get_instance() {
107
+
108
+        return self::$instance;
109
+    }
110
+
111
+    /**
112
+     * Get the URI for a user.
113
+     *
114
+     * @param int $user_id The user id
115
+     *
116
+     * @return false|string The user's URI or false in case of failure.
117
+     * @since 3.1.7
118
+     *
119
+     */
120
+    public function get_uri( $user_id ) {
121
+
122
+        // Try to get the URI stored in the user's meta and return it if available.
123
+        $dataset_uri = wl_configuration_get_redlink_dataset_uri();
124
+        $user_uri    = $this->_get_uri( $user_id );
125
+        if ( ! empty( $dataset_uri ) && ! empty( $user_uri ) && 0 === strpos( $user_uri, $dataset_uri ) ) {
126
+            return $user_uri;
127
+        }
128
+
129
+        // Try to build an URI, return false in case of failure.
130
+        if ( false === ( $user_uri = $this->_build_uri( $user_id ) ) ) {
131
+            return false;
132
+        }
133
+
134
+        // Store the URI for future requests (we need a "permanent" URI).
135
+        $this->_set_uri( $user_id, $user_uri );
136
+
137
+        return $user_uri;
138
+    }
139
+
140
+    /**
141
+     * Set the `id` of the entity representing a {@link WP_User}.
142
+     *
143
+     * If the `id` is set to 0 (or less) then the meta is deleted.
144
+     *
145
+     * @param int $user_id The {@link WP_User}.
146
+     * @param int $value The entity {@link WP_Post} `id`.
147
+     *
148
+     * @return bool|int  Meta ID if the key didn't exist, true on successful update, false on failure.
149
+     * @since 3.14.0
150
+     *
151
+     */
152
+    public function set_entity( $user_id, $value ) {
153
+
154
+        return 0 < $value
155
+            ? update_user_meta( $user_id, self::ENTITY_META_KEY, $value )
156
+            : delete_user_meta( $user_id, self::ENTITY_META_KEY );
157
+    }
158
+
159
+    /**
160
+     * Get the {@link WP_Post} `id` of the entity representing a {@link WP_User}.
161
+     *
162
+     * @param int $user_id The {@link WP_User}'s `id`.
163
+     *
164
+     * @return string|false The entity {@link WP_Post} `id` or an empty string if not set or false if the object id is invalid
165
+     * @since 3.14.0
166
+     *
167
+     */
168
+    public function get_entity( $user_id ) {
169
+
170
+        return get_user_meta( $user_id, self::ENTITY_META_KEY, true );
171
+    }
172
+
173
+    /**
174
+     * Get the user's URI stored in the user's meta.
175
+     *
176
+     * @param int $user_id The user id.
177
+     *
178
+     * @return false|string The user's URI or false if not found.
179
+     * @since 3.1.7
180
+     *
181
+     */
182
+    private function _get_uri( $user_id ) {
183
+
184
+        $user_uri = get_user_meta( $user_id, self::URI_META_KEY, true );
185
+
186
+        if ( empty( $user_uri ) ) {
187
+            return false;
188
+        }
189
+
190
+        return $user_uri;
191
+    }
192
+
193
+    /**
194
+     * Build an URI for a user.
195
+     *
196
+     * @param int $user_id The user's id.
197
+     *
198
+     * @return false|string The user's URI or false in case of failure.
199
+     * @since 3.1.7
200
+     *
201
+     */
202
+    private function _build_uri( $user_id ) {
203
+
204
+        // Get the user, return false in case of failure.
205
+        if ( false === ( $user = get_userdata( $user_id ) ) ) {
206
+            return false;
207
+        };
208
+
209
+        // If the nicename is not set, return a failure.
210
+        if ( empty( $user->user_nicename ) ) {
211
+            return false;
212
+        }
213
+
214
+        /**
215
+         * @since 3.27.7 changed `user` to `author` to avoid potential clashes with CPTs ( `author` is reserved
216
+         *  https://developer.wordpress.org/reference/functions/register_post_type/#reserved-post-types )
217
+         */
218
+        return wl_configuration_get_redlink_dataset_uri() . "/author/$user->user_nicename";
219
+    }
220
+
221
+    /**
222
+     * Store the URI in user's meta.
223
+     *
224
+     * @param int $user_id The user's id.
225
+     * @param string $user_uri The user's uri.
226
+     *
227
+     * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
228
+     * @since 3.1.7
229
+     *
230
+     */
231
+    private function _set_uri( $user_id, $user_uri ) {
232
+
233
+        return update_user_meta( $user_id, self::URI_META_KEY, $user_uri );
234
+    }
235
+
236
+    /**
237
+     * Mark an editor user as denied from editing entities.
238
+     * Does nothing if the user is not an editor
239
+     *
240
+     * @param integer $user_id The ID of the user
241
+     *
242
+     * @since 3.14.0
243
+     *
244
+     */
245
+    public function deny_editor_entity_create( $user_id ) {
246
+
247
+        // Bail out if the user is not an editor.
248
+        if ( ! $this->is_editor( $user_id ) ) {
249
+            return;
250
+        }
251
+
252
+        // The user explicitly do not have the capability.
253
+        update_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY, 'yes' );
254
+
255
+    }
256
+
257
+    /**
258
+     * Remove the "deny entity editing" mark from an editor user.
259
+     * Does nothing if the user is not an editor
260
+     *
261
+     * @param integer $user_id The ID of the user
262
+     *
263
+     * @since 3.14.0
264
+     *
265
+     */
266
+    public function allow_editor_entity_create( $user_id ) {
267
+
268
+        // Bail out if the user is not an editor.
269
+        if ( ! $this->is_editor( $user_id ) ) {
270
+            return;
271
+        }
272
+
273
+        // The user explicitly do not have the capability.
274
+        delete_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY );
275
+
276
+    }
277
+
278
+    /**
279
+     * Get whether the 'deny editor entity editing' flag is set.
280
+     *
281
+     * @param int $user_id The {@link WP_User} `id`.
282
+     *
283
+     * @return int bool True if editing is denied otherwise false.
284
+     * @since 3.14.0
285
+     *
286
+     */
287
+    public function is_deny_editor_entity_create( $user_id ) {
288
+
289
+        return 'yes' === get_user_option( self::DENY_ENTITY_CREATE_META_KEY, $user_id );
290
+    }
291
+
292
+    /**
293
+     * Check whether the {@link WP_User} with the specified `id` is an editor,
294
+     * i.e. has the `editor` role.
295
+     *
296
+     * @param int $user_id The {@link WP_User} `id`.
297
+     *
298
+     * @return bool True if the {@link WP_User} is an editor otherwise false.
299
+     * @since 3.14.0
300
+     *
301
+     */
302
+    public function is_editor( $user_id ) {
303
+
304
+        // Get the user.
305
+        $user = get_user_by( 'id', $user_id );
306
+
307
+        // Return true, if the user is found and has the `editor` role.
308
+        return is_a( $user, 'WP_User' ) && in_array( 'editor', (array) $user->roles );
309
+    }
310
+
311
+    /**
312
+     * Check if an editor can create entities.
313
+     *
314
+     * @param int $user_id The user id of the user being checked.
315
+     *
316
+     * @return bool    false if it is an editor that is denied from edit entities, true otherwise.
317
+     * @since 3.14.0
318
+     *
319
+     */
320
+    public function editor_can_create_entities( $user_id ) {
321
+
322
+        // Return true if not an editor.
323
+        if ( ! $this->is_editor( $user_id ) ) {
324
+            return true;
325
+        }
326
+
327
+        // Check if the user explicitly denied.
328
+        return ! $this->is_deny_editor_entity_create( $user_id );
329
+    }
330
+
331
+    /**
332
+     * Filter capabilities of user.
333
+     *
334
+     * Deny the capability of managing and editing entities for some users.
335
+     *
336
+     * @param array $allcaps All the capabilities of the user
337
+     * @param array $cap [0] Required capability
338
+     * @param array $args [0] Requested capability
339
+     *                       [1] User ID
340
+     *                       [2] Associated object ID
341
+     *
342
+     * @return array The capabilities array.
343
+     * @since 3.14.0
344
+     *
345
+     */
346
+    public function has_cap( $allcaps, $cap, $args ) {
347
+        /*
348 348
 		 * For entity management/editing related capabilities
349 349
 		 * check that an editor was not explicitly denied (in user profile)
350 350
 		 * the capability.
351 351
 		 */
352 352
 
353
-		/*
353
+        /*
354 354
 		 * Need protection against the case of edit_user and likes which do not
355 355
 		 * require a capability, just request one.
356 356
 		 */
357
-		if ( empty( $cap ) || ! isset( $cap[0] ) ) {
358
-			return $allcaps;
359
-		}
360
-
361
-		if (
362
-			( 'edit_wordlift_entity' === $cap[0] ) ||
363
-			( 'edit_wordlift_entities' === $cap[0] ) ||
364
-			( 'edit_others_wordlift_entities' === $cap[0] ) ||
365
-			( 'publish_wordlift_entities' === $cap[0] ) ||
366
-			( 'read_private_wordlift_entities' === $cap[0] ) ||
367
-			( 'delete_wordlift_entity' === $cap[0] ) ||
368
-			( 'delete_wordlift_entities' === $cap[0] ) ||
369
-			( 'delete_others_wordlift_entities' === $cap[0] ) ||
370
-			( 'delete_published_wordlift_entities' === $cap[0] ) ||
371
-			( 'delete_private_wordlift_entities' === $cap[0] )
372
-		) {
373
-			$user_id = $args[1];
374
-
375
-			if ( ! $this->editor_can_create_entities( $user_id ) ) {
376
-				$allcaps[ $cap[0] ] = false;
377
-			}
378
-		}
379
-
380
-		return $allcaps;
381
-	}
382
-
383
-	/**
384
-	 * Hook on update user meta to check if the user author has changed.
385
-	 * If so we need to execute sparql query that will update all user posts author triple.
386
-	 *
387
-	 * @param null $null
388
-	 * @param int $object_id The user ID.
389
-	 * @param string $meta_key The meta key name.
390
-	 * @param mixed $meta_value Meta value.
391
-	 * @param mixed $prev_value The previous metadata value.
392
-	 *
393
-	 * @return  null Null if the `meta_key` is not `Wordlift_User_Service::ENTITY_META_KEY`
394
-	 *                or if the author has not changed.
395
-	 * @since   3.18.0
396
-	 *
397
-	 */
398
-	public function update_user_metadata( $null, $object_id, $meta_key, $meta_value, $prev_value ) {
399
-		// Bail if the meta key is not the author meta.
400
-		if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
401
-			return null;
402
-		}
403
-
404
-		// Check whether the user is associated with any of the existing publishers/
405
-		$entity_id = $this->get_entity( $object_id );
406
-
407
-		if ( false === $entity_id ) {
408
-			// An error occurred.
409
-			$this->log_service->error( "An error occurred: entity_id can't be false." );
410
-
411
-			return;
412
-		}
413
-
414
-		// Get the old uri if the entity is set..
415
-		$old_uri = ! empty( $entity_id )
416
-			? $this->entity_service->get_uri( $entity_id )
417
-			: $this->get_uri( $object_id );
418
-
419
-		// Get the new user uri's.
420
-		$new_uri = $this->entity_service->get_uri( $meta_value );
421
-
422
-		// Bail if the uri is the same.
423
-		if ( $old_uri === $new_uri ) {
424
-			return null;
425
-		}
426
-
427
-		$this->update_author( $old_uri, $new_uri );
428
-	}
429
-
430
-	/**
431
-	 * Hook on delete user meta to execute sparql query
432
-	 * that will update all user posts author triple.
433
-	 *
434
-	 * @param null $null
435
-	 * @param int $object_id The user ID.
436
-	 * @param string $meta_key The meta key name.
437
-	 * @param mixed $meta_value Meta value.
438
-	 * @param bool $delete_all Whether to delete the matching metadata entries
439
-	 *                              for all objects.
440
-	 *
441
-	 * @return  null Null if the `meta_key` is not `Wordlift_User_Service::ENTITY_META_KEY`
442
-	 *               or if the author has not changed.
443
-	 * @since   3.18.0
444
-	 *
445
-	 */
446
-	public function delete_user_metadata( $null, $object_id, $meta_key, $meta_value, $delete_all ) {
447
-		// Bail if the meta key is not the author meta.
448
-		if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
449
-			return null;
450
-		}
451
-
452
-		// Check whether the user is associated with any of the existing publishers/
453
-		$entity_id = $this->get_entity( $object_id );
454
-
455
-		if ( false === $entity_id ) {
456
-			// An error occurred.
457
-			$this->log_service->error( "An error occurred: entity_id can't be false." );
458
-
459
-			return;
460
-		}
461
-
462
-		// Get the old uri if the entity is set.
463
-		$old_uri = $this->entity_service->get_uri( $entity_id );
464
-
465
-		$new_uri = $this->get_uri( $object_id );
466
-
467
-		$this->update_author( $old_uri, $new_uri );
468
-
469
-	}
470
-
471
-	/**
472
-	 * Update the schema:author when the user author is changed.
473
-	 *
474
-	 * @param string $old_uri The old uri to remove.
475
-	 * @param string $new_uri The new uri to add.
476
-	 *
477
-	 * @since   3.18.0
478
-	 *
479
-	 */
480
-	private function update_author( $old_uri, $new_uri ) {
481
-		// Bail in case one of the uris is empty.
482
-		if ( empty( $old_uri ) || empty( $new_uri ) ) {
483
-			// An error occurred.
484
-			$this->log_service->error( "An error occurred: old_uri and/or new_uri can't be null." );
485
-
486
-			return;
487
-		}
488
-
489
-		// Build the update query.
490
-		$query = sprintf(
491
-			'DELETE { ?s <%1$s> <%2$s> } INSERT { ?s <%1$s> <%3$s> } WHERE { ?s <%1$s> <%2$s> }',
492
-			// Schema:author triple.
493
-			$this->sparql_service->escape_uri( Wordlift_Query_Builder::SCHEMA_AUTHOR_URI ),
494
-			// Old author uri to remove,
495
-			$this->sparql_service->escape_uri( $old_uri ),
496
-			// New author uri to add,
497
-			$this->sparql_service->escape_uri( $new_uri )
498
-		);
499
-
500
-		// Execute the query and update the author.
501
-		$this->sparql_service->execute( $query );
502
-
503
-	}
357
+        if ( empty( $cap ) || ! isset( $cap[0] ) ) {
358
+            return $allcaps;
359
+        }
360
+
361
+        if (
362
+            ( 'edit_wordlift_entity' === $cap[0] ) ||
363
+            ( 'edit_wordlift_entities' === $cap[0] ) ||
364
+            ( 'edit_others_wordlift_entities' === $cap[0] ) ||
365
+            ( 'publish_wordlift_entities' === $cap[0] ) ||
366
+            ( 'read_private_wordlift_entities' === $cap[0] ) ||
367
+            ( 'delete_wordlift_entity' === $cap[0] ) ||
368
+            ( 'delete_wordlift_entities' === $cap[0] ) ||
369
+            ( 'delete_others_wordlift_entities' === $cap[0] ) ||
370
+            ( 'delete_published_wordlift_entities' === $cap[0] ) ||
371
+            ( 'delete_private_wordlift_entities' === $cap[0] )
372
+        ) {
373
+            $user_id = $args[1];
374
+
375
+            if ( ! $this->editor_can_create_entities( $user_id ) ) {
376
+                $allcaps[ $cap[0] ] = false;
377
+            }
378
+        }
379
+
380
+        return $allcaps;
381
+    }
382
+
383
+    /**
384
+     * Hook on update user meta to check if the user author has changed.
385
+     * If so we need to execute sparql query that will update all user posts author triple.
386
+     *
387
+     * @param null $null
388
+     * @param int $object_id The user ID.
389
+     * @param string $meta_key The meta key name.
390
+     * @param mixed $meta_value Meta value.
391
+     * @param mixed $prev_value The previous metadata value.
392
+     *
393
+     * @return  null Null if the `meta_key` is not `Wordlift_User_Service::ENTITY_META_KEY`
394
+     *                or if the author has not changed.
395
+     * @since   3.18.0
396
+     *
397
+     */
398
+    public function update_user_metadata( $null, $object_id, $meta_key, $meta_value, $prev_value ) {
399
+        // Bail if the meta key is not the author meta.
400
+        if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
401
+            return null;
402
+        }
403
+
404
+        // Check whether the user is associated with any of the existing publishers/
405
+        $entity_id = $this->get_entity( $object_id );
406
+
407
+        if ( false === $entity_id ) {
408
+            // An error occurred.
409
+            $this->log_service->error( "An error occurred: entity_id can't be false." );
410
+
411
+            return;
412
+        }
413
+
414
+        // Get the old uri if the entity is set..
415
+        $old_uri = ! empty( $entity_id )
416
+            ? $this->entity_service->get_uri( $entity_id )
417
+            : $this->get_uri( $object_id );
418
+
419
+        // Get the new user uri's.
420
+        $new_uri = $this->entity_service->get_uri( $meta_value );
421
+
422
+        // Bail if the uri is the same.
423
+        if ( $old_uri === $new_uri ) {
424
+            return null;
425
+        }
426
+
427
+        $this->update_author( $old_uri, $new_uri );
428
+    }
429
+
430
+    /**
431
+     * Hook on delete user meta to execute sparql query
432
+     * that will update all user posts author triple.
433
+     *
434
+     * @param null $null
435
+     * @param int $object_id The user ID.
436
+     * @param string $meta_key The meta key name.
437
+     * @param mixed $meta_value Meta value.
438
+     * @param bool $delete_all Whether to delete the matching metadata entries
439
+     *                              for all objects.
440
+     *
441
+     * @return  null Null if the `meta_key` is not `Wordlift_User_Service::ENTITY_META_KEY`
442
+     *               or if the author has not changed.
443
+     * @since   3.18.0
444
+     *
445
+     */
446
+    public function delete_user_metadata( $null, $object_id, $meta_key, $meta_value, $delete_all ) {
447
+        // Bail if the meta key is not the author meta.
448
+        if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
449
+            return null;
450
+        }
451
+
452
+        // Check whether the user is associated with any of the existing publishers/
453
+        $entity_id = $this->get_entity( $object_id );
454
+
455
+        if ( false === $entity_id ) {
456
+            // An error occurred.
457
+            $this->log_service->error( "An error occurred: entity_id can't be false." );
458
+
459
+            return;
460
+        }
461
+
462
+        // Get the old uri if the entity is set.
463
+        $old_uri = $this->entity_service->get_uri( $entity_id );
464
+
465
+        $new_uri = $this->get_uri( $object_id );
466
+
467
+        $this->update_author( $old_uri, $new_uri );
468
+
469
+    }
470
+
471
+    /**
472
+     * Update the schema:author when the user author is changed.
473
+     *
474
+     * @param string $old_uri The old uri to remove.
475
+     * @param string $new_uri The new uri to add.
476
+     *
477
+     * @since   3.18.0
478
+     *
479
+     */
480
+    private function update_author( $old_uri, $new_uri ) {
481
+        // Bail in case one of the uris is empty.
482
+        if ( empty( $old_uri ) || empty( $new_uri ) ) {
483
+            // An error occurred.
484
+            $this->log_service->error( "An error occurred: old_uri and/or new_uri can't be null." );
485
+
486
+            return;
487
+        }
488
+
489
+        // Build the update query.
490
+        $query = sprintf(
491
+            'DELETE { ?s <%1$s> <%2$s> } INSERT { ?s <%1$s> <%3$s> } WHERE { ?s <%1$s> <%2$s> }',
492
+            // Schema:author triple.
493
+            $this->sparql_service->escape_uri( Wordlift_Query_Builder::SCHEMA_AUTHOR_URI ),
494
+            // Old author uri to remove,
495
+            $this->sparql_service->escape_uri( $old_uri ),
496
+            // New author uri to add,
497
+            $this->sparql_service->escape_uri( $new_uri )
498
+        );
499
+
500
+        // Execute the query and update the author.
501
+        $this->sparql_service->execute( $query );
502
+
503
+    }
504 504
 
505 505
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 * @since 3.1.7
86 86
 	 *
87 87
 	 */
88
-	public function __construct( $sparql_service, $entity_service ) {
88
+	public function __construct($sparql_service, $entity_service) {
89 89
 
90
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_User_Service' );
90
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_User_Service');
91 91
 
92 92
 		self::$instance = $this;
93 93
 
94 94
 		$this->sparql_service = $sparql_service;
95 95
 		$this->entity_service = $entity_service;
96 96
 
97
-		add_filter( 'user_has_cap', array( $this, 'has_cap' ), 10, 3 );
97
+		add_filter('user_has_cap', array($this, 'has_cap'), 10, 3);
98 98
 	}
99 99
 
100 100
 	/**
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 	 * @since 3.1.7
118 118
 	 *
119 119
 	 */
120
-	public function get_uri( $user_id ) {
120
+	public function get_uri($user_id) {
121 121
 
122 122
 		// Try to get the URI stored in the user's meta and return it if available.
123 123
 		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
124
-		$user_uri    = $this->_get_uri( $user_id );
125
-		if ( ! empty( $dataset_uri ) && ! empty( $user_uri ) && 0 === strpos( $user_uri, $dataset_uri ) ) {
124
+		$user_uri    = $this->_get_uri($user_id);
125
+		if ( ! empty($dataset_uri) && ! empty($user_uri) && 0 === strpos($user_uri, $dataset_uri)) {
126 126
 			return $user_uri;
127 127
 		}
128 128
 
129 129
 		// Try to build an URI, return false in case of failure.
130
-		if ( false === ( $user_uri = $this->_build_uri( $user_id ) ) ) {
130
+		if (false === ($user_uri = $this->_build_uri($user_id))) {
131 131
 			return false;
132 132
 		}
133 133
 
134 134
 		// Store the URI for future requests (we need a "permanent" URI).
135
-		$this->_set_uri( $user_id, $user_uri );
135
+		$this->_set_uri($user_id, $user_uri);
136 136
 
137 137
 		return $user_uri;
138 138
 	}
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 	 * @since 3.14.0
150 150
 	 *
151 151
 	 */
152
-	public function set_entity( $user_id, $value ) {
152
+	public function set_entity($user_id, $value) {
153 153
 
154 154
 		return 0 < $value
155
-			? update_user_meta( $user_id, self::ENTITY_META_KEY, $value )
156
-			: delete_user_meta( $user_id, self::ENTITY_META_KEY );
155
+			? update_user_meta($user_id, self::ENTITY_META_KEY, $value)
156
+			: delete_user_meta($user_id, self::ENTITY_META_KEY);
157 157
 	}
158 158
 
159 159
 	/**
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @since 3.14.0
166 166
 	 *
167 167
 	 */
168
-	public function get_entity( $user_id ) {
168
+	public function get_entity($user_id) {
169 169
 
170
-		return get_user_meta( $user_id, self::ENTITY_META_KEY, true );
170
+		return get_user_meta($user_id, self::ENTITY_META_KEY, true);
171 171
 	}
172 172
 
173 173
 	/**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	 * @since 3.1.7
180 180
 	 *
181 181
 	 */
182
-	private function _get_uri( $user_id ) {
182
+	private function _get_uri($user_id) {
183 183
 
184
-		$user_uri = get_user_meta( $user_id, self::URI_META_KEY, true );
184
+		$user_uri = get_user_meta($user_id, self::URI_META_KEY, true);
185 185
 
186
-		if ( empty( $user_uri ) ) {
186
+		if (empty($user_uri)) {
187 187
 			return false;
188 188
 		}
189 189
 
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 	 * @since 3.1.7
200 200
 	 *
201 201
 	 */
202
-	private function _build_uri( $user_id ) {
202
+	private function _build_uri($user_id) {
203 203
 
204 204
 		// Get the user, return false in case of failure.
205
-		if ( false === ( $user = get_userdata( $user_id ) ) ) {
205
+		if (false === ($user = get_userdata($user_id))) {
206 206
 			return false;
207 207
 		};
208 208
 
209 209
 		// If the nicename is not set, return a failure.
210
-		if ( empty( $user->user_nicename ) ) {
210
+		if (empty($user->user_nicename)) {
211 211
 			return false;
212 212
 		}
213 213
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		 * @since 3.27.7 changed `user` to `author` to avoid potential clashes with CPTs ( `author` is reserved
216 216
 		 *  https://developer.wordpress.org/reference/functions/register_post_type/#reserved-post-types )
217 217
 		 */
218
-		return wl_configuration_get_redlink_dataset_uri() . "/author/$user->user_nicename";
218
+		return wl_configuration_get_redlink_dataset_uri()."/author/$user->user_nicename";
219 219
 	}
220 220
 
221 221
 	/**
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 * @since 3.1.7
229 229
 	 *
230 230
 	 */
231
-	private function _set_uri( $user_id, $user_uri ) {
231
+	private function _set_uri($user_id, $user_uri) {
232 232
 
233
-		return update_user_meta( $user_id, self::URI_META_KEY, $user_uri );
233
+		return update_user_meta($user_id, self::URI_META_KEY, $user_uri);
234 234
 	}
235 235
 
236 236
 	/**
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 	 * @since 3.14.0
243 243
 	 *
244 244
 	 */
245
-	public function deny_editor_entity_create( $user_id ) {
245
+	public function deny_editor_entity_create($user_id) {
246 246
 
247 247
 		// Bail out if the user is not an editor.
248
-		if ( ! $this->is_editor( $user_id ) ) {
248
+		if ( ! $this->is_editor($user_id)) {
249 249
 			return;
250 250
 		}
251 251
 
252 252
 		// The user explicitly do not have the capability.
253
-		update_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY, 'yes' );
253
+		update_user_option($user_id, self::DENY_ENTITY_CREATE_META_KEY, 'yes');
254 254
 
255 255
 	}
256 256
 
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	 * @since 3.14.0
264 264
 	 *
265 265
 	 */
266
-	public function allow_editor_entity_create( $user_id ) {
266
+	public function allow_editor_entity_create($user_id) {
267 267
 
268 268
 		// Bail out if the user is not an editor.
269
-		if ( ! $this->is_editor( $user_id ) ) {
269
+		if ( ! $this->is_editor($user_id)) {
270 270
 			return;
271 271
 		}
272 272
 
273 273
 		// The user explicitly do not have the capability.
274
-		delete_user_option( $user_id, self::DENY_ENTITY_CREATE_META_KEY );
274
+		delete_user_option($user_id, self::DENY_ENTITY_CREATE_META_KEY);
275 275
 
276 276
 	}
277 277
 
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 	 * @since 3.14.0
285 285
 	 *
286 286
 	 */
287
-	public function is_deny_editor_entity_create( $user_id ) {
287
+	public function is_deny_editor_entity_create($user_id) {
288 288
 
289
-		return 'yes' === get_user_option( self::DENY_ENTITY_CREATE_META_KEY, $user_id );
289
+		return 'yes' === get_user_option(self::DENY_ENTITY_CREATE_META_KEY, $user_id);
290 290
 	}
291 291
 
292 292
 	/**
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 	 * @since 3.14.0
300 300
 	 *
301 301
 	 */
302
-	public function is_editor( $user_id ) {
302
+	public function is_editor($user_id) {
303 303
 
304 304
 		// Get the user.
305
-		$user = get_user_by( 'id', $user_id );
305
+		$user = get_user_by('id', $user_id);
306 306
 
307 307
 		// Return true, if the user is found and has the `editor` role.
308
-		return is_a( $user, 'WP_User' ) && in_array( 'editor', (array) $user->roles );
308
+		return is_a($user, 'WP_User') && in_array('editor', (array) $user->roles);
309 309
 	}
310 310
 
311 311
 	/**
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
 	 * @since 3.14.0
318 318
 	 *
319 319
 	 */
320
-	public function editor_can_create_entities( $user_id ) {
320
+	public function editor_can_create_entities($user_id) {
321 321
 
322 322
 		// Return true if not an editor.
323
-		if ( ! $this->is_editor( $user_id ) ) {
323
+		if ( ! $this->is_editor($user_id)) {
324 324
 			return true;
325 325
 		}
326 326
 
327 327
 		// Check if the user explicitly denied.
328
-		return ! $this->is_deny_editor_entity_create( $user_id );
328
+		return ! $this->is_deny_editor_entity_create($user_id);
329 329
 	}
330 330
 
331 331
 	/**
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * @since 3.14.0
344 344
 	 *
345 345
 	 */
346
-	public function has_cap( $allcaps, $cap, $args ) {
346
+	public function has_cap($allcaps, $cap, $args) {
347 347
 		/*
348 348
 		 * For entity management/editing related capabilities
349 349
 		 * check that an editor was not explicitly denied (in user profile)
@@ -354,26 +354,26 @@  discard block
 block discarded – undo
354 354
 		 * Need protection against the case of edit_user and likes which do not
355 355
 		 * require a capability, just request one.
356 356
 		 */
357
-		if ( empty( $cap ) || ! isset( $cap[0] ) ) {
357
+		if (empty($cap) || ! isset($cap[0])) {
358 358
 			return $allcaps;
359 359
 		}
360 360
 
361 361
 		if (
362
-			( 'edit_wordlift_entity' === $cap[0] ) ||
363
-			( 'edit_wordlift_entities' === $cap[0] ) ||
364
-			( 'edit_others_wordlift_entities' === $cap[0] ) ||
365
-			( 'publish_wordlift_entities' === $cap[0] ) ||
366
-			( 'read_private_wordlift_entities' === $cap[0] ) ||
367
-			( 'delete_wordlift_entity' === $cap[0] ) ||
368
-			( 'delete_wordlift_entities' === $cap[0] ) ||
369
-			( 'delete_others_wordlift_entities' === $cap[0] ) ||
370
-			( 'delete_published_wordlift_entities' === $cap[0] ) ||
371
-			( 'delete_private_wordlift_entities' === $cap[0] )
362
+			('edit_wordlift_entity' === $cap[0]) ||
363
+			('edit_wordlift_entities' === $cap[0]) ||
364
+			('edit_others_wordlift_entities' === $cap[0]) ||
365
+			('publish_wordlift_entities' === $cap[0]) ||
366
+			('read_private_wordlift_entities' === $cap[0]) ||
367
+			('delete_wordlift_entity' === $cap[0]) ||
368
+			('delete_wordlift_entities' === $cap[0]) ||
369
+			('delete_others_wordlift_entities' === $cap[0]) ||
370
+			('delete_published_wordlift_entities' === $cap[0]) ||
371
+			('delete_private_wordlift_entities' === $cap[0])
372 372
 		) {
373 373
 			$user_id = $args[1];
374 374
 
375
-			if ( ! $this->editor_can_create_entities( $user_id ) ) {
376
-				$allcaps[ $cap[0] ] = false;
375
+			if ( ! $this->editor_can_create_entities($user_id)) {
376
+				$allcaps[$cap[0]] = false;
377 377
 			}
378 378
 		}
379 379
 
@@ -395,36 +395,36 @@  discard block
 block discarded – undo
395 395
 	 * @since   3.18.0
396 396
 	 *
397 397
 	 */
398
-	public function update_user_metadata( $null, $object_id, $meta_key, $meta_value, $prev_value ) {
398
+	public function update_user_metadata($null, $object_id, $meta_key, $meta_value, $prev_value) {
399 399
 		// Bail if the meta key is not the author meta.
400
-		if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
400
+		if ($meta_key !== Wordlift_User_Service::ENTITY_META_KEY) {
401 401
 			return null;
402 402
 		}
403 403
 
404 404
 		// Check whether the user is associated with any of the existing publishers/
405
-		$entity_id = $this->get_entity( $object_id );
405
+		$entity_id = $this->get_entity($object_id);
406 406
 
407
-		if ( false === $entity_id ) {
407
+		if (false === $entity_id) {
408 408
 			// An error occurred.
409
-			$this->log_service->error( "An error occurred: entity_id can't be false." );
409
+			$this->log_service->error("An error occurred: entity_id can't be false.");
410 410
 
411 411
 			return;
412 412
 		}
413 413
 
414 414
 		// Get the old uri if the entity is set..
415
-		$old_uri = ! empty( $entity_id )
416
-			? $this->entity_service->get_uri( $entity_id )
417
-			: $this->get_uri( $object_id );
415
+		$old_uri = ! empty($entity_id)
416
+			? $this->entity_service->get_uri($entity_id)
417
+			: $this->get_uri($object_id);
418 418
 
419 419
 		// Get the new user uri's.
420
-		$new_uri = $this->entity_service->get_uri( $meta_value );
420
+		$new_uri = $this->entity_service->get_uri($meta_value);
421 421
 
422 422
 		// Bail if the uri is the same.
423
-		if ( $old_uri === $new_uri ) {
423
+		if ($old_uri === $new_uri) {
424 424
 			return null;
425 425
 		}
426 426
 
427
-		$this->update_author( $old_uri, $new_uri );
427
+		$this->update_author($old_uri, $new_uri);
428 428
 	}
429 429
 
430 430
 	/**
@@ -443,28 +443,28 @@  discard block
 block discarded – undo
443 443
 	 * @since   3.18.0
444 444
 	 *
445 445
 	 */
446
-	public function delete_user_metadata( $null, $object_id, $meta_key, $meta_value, $delete_all ) {
446
+	public function delete_user_metadata($null, $object_id, $meta_key, $meta_value, $delete_all) {
447 447
 		// Bail if the meta key is not the author meta.
448
-		if ( $meta_key !== Wordlift_User_Service::ENTITY_META_KEY ) {
448
+		if ($meta_key !== Wordlift_User_Service::ENTITY_META_KEY) {
449 449
 			return null;
450 450
 		}
451 451
 
452 452
 		// Check whether the user is associated with any of the existing publishers/
453
-		$entity_id = $this->get_entity( $object_id );
453
+		$entity_id = $this->get_entity($object_id);
454 454
 
455
-		if ( false === $entity_id ) {
455
+		if (false === $entity_id) {
456 456
 			// An error occurred.
457
-			$this->log_service->error( "An error occurred: entity_id can't be false." );
457
+			$this->log_service->error("An error occurred: entity_id can't be false.");
458 458
 
459 459
 			return;
460 460
 		}
461 461
 
462 462
 		// Get the old uri if the entity is set.
463
-		$old_uri = $this->entity_service->get_uri( $entity_id );
463
+		$old_uri = $this->entity_service->get_uri($entity_id);
464 464
 
465
-		$new_uri = $this->get_uri( $object_id );
465
+		$new_uri = $this->get_uri($object_id);
466 466
 
467
-		$this->update_author( $old_uri, $new_uri );
467
+		$this->update_author($old_uri, $new_uri);
468 468
 
469 469
 	}
470 470
 
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * @since   3.18.0
478 478
 	 *
479 479
 	 */
480
-	private function update_author( $old_uri, $new_uri ) {
480
+	private function update_author($old_uri, $new_uri) {
481 481
 		// Bail in case one of the uris is empty.
482
-		if ( empty( $old_uri ) || empty( $new_uri ) ) {
482
+		if (empty($old_uri) || empty($new_uri)) {
483 483
 			// An error occurred.
484
-			$this->log_service->error( "An error occurred: old_uri and/or new_uri can't be null." );
484
+			$this->log_service->error("An error occurred: old_uri and/or new_uri can't be null.");
485 485
 
486 486
 			return;
487 487
 		}
@@ -490,15 +490,15 @@  discard block
 block discarded – undo
490 490
 		$query = sprintf(
491 491
 			'DELETE { ?s <%1$s> <%2$s> } INSERT { ?s <%1$s> <%3$s> } WHERE { ?s <%1$s> <%2$s> }',
492 492
 			// Schema:author triple.
493
-			$this->sparql_service->escape_uri( Wordlift_Query_Builder::SCHEMA_AUTHOR_URI ),
493
+			$this->sparql_service->escape_uri(Wordlift_Query_Builder::SCHEMA_AUTHOR_URI),
494 494
 			// Old author uri to remove,
495
-			$this->sparql_service->escape_uri( $old_uri ),
495
+			$this->sparql_service->escape_uri($old_uri),
496 496
 			// New author uri to add,
497
-			$this->sparql_service->escape_uri( $new_uri )
497
+			$this->sparql_service->escape_uri($new_uri)
498 498
 		);
499 499
 
500 500
 		// Execute the query and update the author.
501
-		$this->sparql_service->execute( $query );
501
+		$this->sparql_service->execute($query);
502 502
 
503 503
 	}
504 504
 
Please login to merge, or discard this patch.
src/includes/cache/class-wordlift-cached-entity-uri-service.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -14,214 +14,214 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Cached_Entity_Uri_Service extends Wordlift_Entity_Uri_Service {
16 16
 
17
-	/**
18
-	 * The {@link Wordlift_Cache_Service} instance.
19
-	 *
20
-	 * @since  3.16.3
21
-	 * @access private
22
-	 * @var \Wordlift_Cache_Service $cache_service The {@link Wordlift_Cache_Service} instance.
23
-	 */
24
-	private $cache_service;
25
-
26
-	/**
27
-	 * A {@link Wordlift_Log_Service} instance.
28
-	 *
29
-	 * @since  3.16.3
30
-	 * @access private
31
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
32
-	 */
33
-	private $log;
34
-
35
-	/**
36
-	 * Create a {@link Wordlift_Cached_Entity_Uri_Service} instance.
37
-	 *
38
-	 * @param \Wordlift_Configuration_Service $configuration_service
39
-	 * @param \Wordlift_Cache_Service $cache_service
40
-	 *
41
-	 * @since 3.16.3
42
-	 *
43
-	 */
44
-	public function __construct( $configuration_service, $cache_service ) {
45
-		parent::__construct( $configuration_service );
46
-
47
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
48
-
49
-		// Add hooks for meta being added/modified/deleted.
50
-		$this->cache_service = $cache_service;
51
-
52
-		add_action( 'add_post_meta', array(
53
-			$this,
54
-			'on_before_post_meta_add',
55
-		), 10, 3 );
56
-		add_action( 'update_post_meta', array(
57
-			$this,
58
-			'on_before_post_meta_change',
59
-		), 10, 4 );
60
-		add_action( 'delete_post_meta', array(
61
-			$this,
62
-			'on_before_post_meta_change',
63
-		), 10, 4 );
64
-
65
-	}
66
-
67
-	/**
68
-	 * Preload the URIs.
69
-	 *
70
-	 * @param array $uris Preload an array of URIs.
71
-	 *
72
-	 * @since 3.16.3
73
-	 *
74
-	 */
75
-	public function preload_uris( $uris ) {
76
-
77
-		// Filter the URIs which aren't yet cached.
78
-		$cache_service = $this->cache_service;
79
-		$uris_to_cache = array_filter( (array) $uris, function ( $item ) use ( $cache_service ) {
80
-			return ! $cache_service->has_cache( $item );
81
-		} );
82
-
83
-		// Preload the URIs.
84
-		parent::preload_uris( $uris_to_cache );
85
-
86
-		// Store them in cache.
87
-		if ( is_array( $this->uri_to_post ) && ! empty( $this->uri_to_post ) ) {
88
-			foreach ( $this->uri_to_post as $uri => $post ) {
89
-				$this->set_cache( $uri, $post );
90
-			}
91
-		}
92
-
93
-	}
94
-
95
-	/**
96
-	 * Get the entity post for the specified URI.
97
-	 *
98
-	 * @param string $uri The URI.
99
-	 *
100
-	 * @return null|WP_Post The {@link WP_Post} or null if not found.
101
-	 * @since 3.16.3
102
-	 *
103
-	 */
104
-	public function get_entity( $uri ) {
105
-
106
-		$this->log->trace( "Getting entity for uri $uri..." );
107
-
108
-		// Get the cached post for the specified URI.
109
-		$cache = $this->cache_service->get_cache( $uri );
110
-
111
-		// Return the cached data if valid.
112
-		if ( false !== $cache && is_numeric( $cache ) ) {
113
-			$this->log->debug( "Cached entity $cache for uri $uri found." );
114
-
115
-			return get_post( $cache );
116
-		}
117
-
118
-		// Get the actual result.
119
-		$post = parent::get_entity( $uri );
120
-
121
-		// Cache the result, if a post is not found we cache -1.
122
-		$this->set_cache( $uri, $post );
123
-
124
-		// Return the result.
125
-		return $post;
126
-	}
127
-
128
-	/**
129
-	 * Set the cached URI for the specified {@link WP_Post}.
130
-	 *
131
-	 * @param string $uri The URI.
132
-	 * @param WP_Post $post The post.
133
-	 *
134
-	 * @since 3.16.3
135
-	 *
136
-	 */
137
-	private function set_cache( $uri, $post ) {
138
-
139
-		// Cache the result, if a post is not found we cache -1.
140
-		$this->cache_service->set_cache( $uri, ( null === $post ? - 1 : $post->ID ) );
141
-
142
-	}
143
-
144
-	/**
145
-	 * Delete the cache for the specified URIs.
146
-	 *
147
-	 * @param array $uris An array of URIs.
148
-	 *
149
-	 * @since 3.16.3
150
-	 *
151
-	 */
152
-	private function delete_cache( $uris ) {
153
-
154
-		// Delete the cache for each URI.
155
-		foreach ( $uris as $uri ) {
156
-			// Delete the single cache file.
157
-			$this->cache_service->delete_cache( $uri );
158
-		}
159
-
160
-	}
161
-
162
-	/**
163
-	 * Before post meta change.
164
-	 *
165
-	 * When a post meta is going to be changed, we check if the `meta_key` is
166
-	 * either the `entity_url` or the `same_as` in which case we delete the cache
167
-	 * for all the associated URIs.
168
-	 *
169
-	 * @param int|array $meta_ids The {@link WP_Post} meta id(s).
170
-	 * @param int $post_id The {@link WP_Post} id.
171
-	 * @param string $meta_key The meta key.
172
-	 * @param mixed $meta_value The meta value(s).
173
-	 *
174
-	 * @since 3.16.3
175
-	 *
176
-	 */
177
-	public function on_before_post_meta_change( $meta_ids, $post_id, $meta_key, $meta_value ) {
178
-
179
-		// Bail out if we're not interested in the meta key.
180
-		if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
181
-			return;
182
-		}
183
-
184
-		$this->log->trace( "Updating/deleting $meta_key for post $post_id ($meta_key), invalidating cache..." );
185
-
186
-		// The list of existing URIs, plus the list of URIs being deleted/updated.
187
-		$old_value = get_post_meta( $post_id, $meta_key );
188
-
189
-		// We expect an array here from the `get_post_meta` signature. However `get_post_meta` is prone to side effects
190
-		// because of filters. So if it's not we return an empty array.
191
-		if ( ! is_array( $old_value ) ) {
192
-			$old_value = array();
193
-		}
194
-		$new_value = isset( $meta_value ) ? (array) $meta_value : array();
195
-		$uris      = array_merge( $old_value, $new_value );
196
-
197
-		// Delete the cache for those URIs.
198
-		$this->delete_cache( $uris );
199
-
200
-	}
201
-
202
-	/**
203
-	 * Hook to meta add for a {@link WP_Post}, will cause the cache to
204
-	 * invalidate.
205
-	 *
206
-	 * @param int $post_id The {@link WP_Post} id.
207
-	 * @param string $meta_key The meta key.
208
-	 * @param mixed $meta_value The meta value(s).
209
-	 *
210
-	 * @since 3.16.3
211
-	 *
212
-	 */
213
-	public function on_before_post_meta_add( $post_id, $meta_key, $meta_value ) {
214
-
215
-		// Bail out if we're not interested in the meta key.
216
-		if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
217
-			return;
218
-		}
219
-
220
-		$this->log->trace( "Adding $meta_key for post $post_id ($meta_key), invalidating cache..." );
221
-
222
-		// Delete the cache for the URIs being added.
223
-		$this->delete_cache( (array) $meta_value );
224
-
225
-	}
17
+    /**
18
+     * The {@link Wordlift_Cache_Service} instance.
19
+     *
20
+     * @since  3.16.3
21
+     * @access private
22
+     * @var \Wordlift_Cache_Service $cache_service The {@link Wordlift_Cache_Service} instance.
23
+     */
24
+    private $cache_service;
25
+
26
+    /**
27
+     * A {@link Wordlift_Log_Service} instance.
28
+     *
29
+     * @since  3.16.3
30
+     * @access private
31
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
32
+     */
33
+    private $log;
34
+
35
+    /**
36
+     * Create a {@link Wordlift_Cached_Entity_Uri_Service} instance.
37
+     *
38
+     * @param \Wordlift_Configuration_Service $configuration_service
39
+     * @param \Wordlift_Cache_Service $cache_service
40
+     *
41
+     * @since 3.16.3
42
+     *
43
+     */
44
+    public function __construct( $configuration_service, $cache_service ) {
45
+        parent::__construct( $configuration_service );
46
+
47
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
48
+
49
+        // Add hooks for meta being added/modified/deleted.
50
+        $this->cache_service = $cache_service;
51
+
52
+        add_action( 'add_post_meta', array(
53
+            $this,
54
+            'on_before_post_meta_add',
55
+        ), 10, 3 );
56
+        add_action( 'update_post_meta', array(
57
+            $this,
58
+            'on_before_post_meta_change',
59
+        ), 10, 4 );
60
+        add_action( 'delete_post_meta', array(
61
+            $this,
62
+            'on_before_post_meta_change',
63
+        ), 10, 4 );
64
+
65
+    }
66
+
67
+    /**
68
+     * Preload the URIs.
69
+     *
70
+     * @param array $uris Preload an array of URIs.
71
+     *
72
+     * @since 3.16.3
73
+     *
74
+     */
75
+    public function preload_uris( $uris ) {
76
+
77
+        // Filter the URIs which aren't yet cached.
78
+        $cache_service = $this->cache_service;
79
+        $uris_to_cache = array_filter( (array) $uris, function ( $item ) use ( $cache_service ) {
80
+            return ! $cache_service->has_cache( $item );
81
+        } );
82
+
83
+        // Preload the URIs.
84
+        parent::preload_uris( $uris_to_cache );
85
+
86
+        // Store them in cache.
87
+        if ( is_array( $this->uri_to_post ) && ! empty( $this->uri_to_post ) ) {
88
+            foreach ( $this->uri_to_post as $uri => $post ) {
89
+                $this->set_cache( $uri, $post );
90
+            }
91
+        }
92
+
93
+    }
94
+
95
+    /**
96
+     * Get the entity post for the specified URI.
97
+     *
98
+     * @param string $uri The URI.
99
+     *
100
+     * @return null|WP_Post The {@link WP_Post} or null if not found.
101
+     * @since 3.16.3
102
+     *
103
+     */
104
+    public function get_entity( $uri ) {
105
+
106
+        $this->log->trace( "Getting entity for uri $uri..." );
107
+
108
+        // Get the cached post for the specified URI.
109
+        $cache = $this->cache_service->get_cache( $uri );
110
+
111
+        // Return the cached data if valid.
112
+        if ( false !== $cache && is_numeric( $cache ) ) {
113
+            $this->log->debug( "Cached entity $cache for uri $uri found." );
114
+
115
+            return get_post( $cache );
116
+        }
117
+
118
+        // Get the actual result.
119
+        $post = parent::get_entity( $uri );
120
+
121
+        // Cache the result, if a post is not found we cache -1.
122
+        $this->set_cache( $uri, $post );
123
+
124
+        // Return the result.
125
+        return $post;
126
+    }
127
+
128
+    /**
129
+     * Set the cached URI for the specified {@link WP_Post}.
130
+     *
131
+     * @param string $uri The URI.
132
+     * @param WP_Post $post The post.
133
+     *
134
+     * @since 3.16.3
135
+     *
136
+     */
137
+    private function set_cache( $uri, $post ) {
138
+
139
+        // Cache the result, if a post is not found we cache -1.
140
+        $this->cache_service->set_cache( $uri, ( null === $post ? - 1 : $post->ID ) );
141
+
142
+    }
143
+
144
+    /**
145
+     * Delete the cache for the specified URIs.
146
+     *
147
+     * @param array $uris An array of URIs.
148
+     *
149
+     * @since 3.16.3
150
+     *
151
+     */
152
+    private function delete_cache( $uris ) {
153
+
154
+        // Delete the cache for each URI.
155
+        foreach ( $uris as $uri ) {
156
+            // Delete the single cache file.
157
+            $this->cache_service->delete_cache( $uri );
158
+        }
159
+
160
+    }
161
+
162
+    /**
163
+     * Before post meta change.
164
+     *
165
+     * When a post meta is going to be changed, we check if the `meta_key` is
166
+     * either the `entity_url` or the `same_as` in which case we delete the cache
167
+     * for all the associated URIs.
168
+     *
169
+     * @param int|array $meta_ids The {@link WP_Post} meta id(s).
170
+     * @param int $post_id The {@link WP_Post} id.
171
+     * @param string $meta_key The meta key.
172
+     * @param mixed $meta_value The meta value(s).
173
+     *
174
+     * @since 3.16.3
175
+     *
176
+     */
177
+    public function on_before_post_meta_change( $meta_ids, $post_id, $meta_key, $meta_value ) {
178
+
179
+        // Bail out if we're not interested in the meta key.
180
+        if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
181
+            return;
182
+        }
183
+
184
+        $this->log->trace( "Updating/deleting $meta_key for post $post_id ($meta_key), invalidating cache..." );
185
+
186
+        // The list of existing URIs, plus the list of URIs being deleted/updated.
187
+        $old_value = get_post_meta( $post_id, $meta_key );
188
+
189
+        // We expect an array here from the `get_post_meta` signature. However `get_post_meta` is prone to side effects
190
+        // because of filters. So if it's not we return an empty array.
191
+        if ( ! is_array( $old_value ) ) {
192
+            $old_value = array();
193
+        }
194
+        $new_value = isset( $meta_value ) ? (array) $meta_value : array();
195
+        $uris      = array_merge( $old_value, $new_value );
196
+
197
+        // Delete the cache for those URIs.
198
+        $this->delete_cache( $uris );
199
+
200
+    }
201
+
202
+    /**
203
+     * Hook to meta add for a {@link WP_Post}, will cause the cache to
204
+     * invalidate.
205
+     *
206
+     * @param int $post_id The {@link WP_Post} id.
207
+     * @param string $meta_key The meta key.
208
+     * @param mixed $meta_value The meta value(s).
209
+     *
210
+     * @since 3.16.3
211
+     *
212
+     */
213
+    public function on_before_post_meta_add( $post_id, $meta_key, $meta_value ) {
214
+
215
+        // Bail out if we're not interested in the meta key.
216
+        if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
217
+            return;
218
+        }
219
+
220
+        $this->log->trace( "Adding $meta_key for post $post_id ($meta_key), invalidating cache..." );
221
+
222
+        // Delete the cache for the URIs being added.
223
+        $this->delete_cache( (array) $meta_value );
224
+
225
+    }
226 226
 
227 227
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -41,26 +41,26 @@  discard block
 block discarded – undo
41 41
 	 * @since 3.16.3
42 42
 	 *
43 43
 	 */
44
-	public function __construct( $configuration_service, $cache_service ) {
45
-		parent::__construct( $configuration_service );
44
+	public function __construct($configuration_service, $cache_service) {
45
+		parent::__construct($configuration_service);
46 46
 
47
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
47
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
48 48
 
49 49
 		// Add hooks for meta being added/modified/deleted.
50 50
 		$this->cache_service = $cache_service;
51 51
 
52
-		add_action( 'add_post_meta', array(
52
+		add_action('add_post_meta', array(
53 53
 			$this,
54 54
 			'on_before_post_meta_add',
55
-		), 10, 3 );
56
-		add_action( 'update_post_meta', array(
55
+		), 10, 3);
56
+		add_action('update_post_meta', array(
57 57
 			$this,
58 58
 			'on_before_post_meta_change',
59
-		), 10, 4 );
60
-		add_action( 'delete_post_meta', array(
59
+		), 10, 4);
60
+		add_action('delete_post_meta', array(
61 61
 			$this,
62 62
 			'on_before_post_meta_change',
63
-		), 10, 4 );
63
+		), 10, 4);
64 64
 
65 65
 	}
66 66
 
@@ -72,21 +72,21 @@  discard block
 block discarded – undo
72 72
 	 * @since 3.16.3
73 73
 	 *
74 74
 	 */
75
-	public function preload_uris( $uris ) {
75
+	public function preload_uris($uris) {
76 76
 
77 77
 		// Filter the URIs which aren't yet cached.
78 78
 		$cache_service = $this->cache_service;
79
-		$uris_to_cache = array_filter( (array) $uris, function ( $item ) use ( $cache_service ) {
80
-			return ! $cache_service->has_cache( $item );
79
+		$uris_to_cache = array_filter((array) $uris, function($item) use ($cache_service) {
80
+			return ! $cache_service->has_cache($item);
81 81
 		} );
82 82
 
83 83
 		// Preload the URIs.
84
-		parent::preload_uris( $uris_to_cache );
84
+		parent::preload_uris($uris_to_cache);
85 85
 
86 86
 		// Store them in cache.
87
-		if ( is_array( $this->uri_to_post ) && ! empty( $this->uri_to_post ) ) {
88
-			foreach ( $this->uri_to_post as $uri => $post ) {
89
-				$this->set_cache( $uri, $post );
87
+		if (is_array($this->uri_to_post) && ! empty($this->uri_to_post)) {
88
+			foreach ($this->uri_to_post as $uri => $post) {
89
+				$this->set_cache($uri, $post);
90 90
 			}
91 91
 		}
92 92
 
@@ -101,25 +101,25 @@  discard block
 block discarded – undo
101 101
 	 * @since 3.16.3
102 102
 	 *
103 103
 	 */
104
-	public function get_entity( $uri ) {
104
+	public function get_entity($uri) {
105 105
 
106
-		$this->log->trace( "Getting entity for uri $uri..." );
106
+		$this->log->trace("Getting entity for uri $uri...");
107 107
 
108 108
 		// Get the cached post for the specified URI.
109
-		$cache = $this->cache_service->get_cache( $uri );
109
+		$cache = $this->cache_service->get_cache($uri);
110 110
 
111 111
 		// Return the cached data if valid.
112
-		if ( false !== $cache && is_numeric( $cache ) ) {
113
-			$this->log->debug( "Cached entity $cache for uri $uri found." );
112
+		if (false !== $cache && is_numeric($cache)) {
113
+			$this->log->debug("Cached entity $cache for uri $uri found.");
114 114
 
115
-			return get_post( $cache );
115
+			return get_post($cache);
116 116
 		}
117 117
 
118 118
 		// Get the actual result.
119
-		$post = parent::get_entity( $uri );
119
+		$post = parent::get_entity($uri);
120 120
 
121 121
 		// Cache the result, if a post is not found we cache -1.
122
-		$this->set_cache( $uri, $post );
122
+		$this->set_cache($uri, $post);
123 123
 
124 124
 		// Return the result.
125 125
 		return $post;
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 * @since 3.16.3
135 135
 	 *
136 136
 	 */
137
-	private function set_cache( $uri, $post ) {
137
+	private function set_cache($uri, $post) {
138 138
 
139 139
 		// Cache the result, if a post is not found we cache -1.
140
-		$this->cache_service->set_cache( $uri, ( null === $post ? - 1 : $post->ID ) );
140
+		$this->cache_service->set_cache($uri, (null === $post ? -1 : $post->ID));
141 141
 
142 142
 	}
143 143
 
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 	 * @since 3.16.3
150 150
 	 *
151 151
 	 */
152
-	private function delete_cache( $uris ) {
152
+	private function delete_cache($uris) {
153 153
 
154 154
 		// Delete the cache for each URI.
155
-		foreach ( $uris as $uri ) {
155
+		foreach ($uris as $uri) {
156 156
 			// Delete the single cache file.
157
-			$this->cache_service->delete_cache( $uri );
157
+			$this->cache_service->delete_cache($uri);
158 158
 		}
159 159
 
160 160
 	}
@@ -174,28 +174,28 @@  discard block
 block discarded – undo
174 174
 	 * @since 3.16.3
175 175
 	 *
176 176
 	 */
177
-	public function on_before_post_meta_change( $meta_ids, $post_id, $meta_key, $meta_value ) {
177
+	public function on_before_post_meta_change($meta_ids, $post_id, $meta_key, $meta_value) {
178 178
 
179 179
 		// Bail out if we're not interested in the meta key.
180
-		if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
180
+		if (WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key) {
181 181
 			return;
182 182
 		}
183 183
 
184
-		$this->log->trace( "Updating/deleting $meta_key for post $post_id ($meta_key), invalidating cache..." );
184
+		$this->log->trace("Updating/deleting $meta_key for post $post_id ($meta_key), invalidating cache...");
185 185
 
186 186
 		// The list of existing URIs, plus the list of URIs being deleted/updated.
187
-		$old_value = get_post_meta( $post_id, $meta_key );
187
+		$old_value = get_post_meta($post_id, $meta_key);
188 188
 
189 189
 		// We expect an array here from the `get_post_meta` signature. However `get_post_meta` is prone to side effects
190 190
 		// because of filters. So if it's not we return an empty array.
191
-		if ( ! is_array( $old_value ) ) {
191
+		if ( ! is_array($old_value)) {
192 192
 			$old_value = array();
193 193
 		}
194
-		$new_value = isset( $meta_value ) ? (array) $meta_value : array();
195
-		$uris      = array_merge( $old_value, $new_value );
194
+		$new_value = isset($meta_value) ? (array) $meta_value : array();
195
+		$uris      = array_merge($old_value, $new_value);
196 196
 
197 197
 		// Delete the cache for those URIs.
198
-		$this->delete_cache( $uris );
198
+		$this->delete_cache($uris);
199 199
 
200 200
 	}
201 201
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 	 * @since 3.16.3
211 211
 	 *
212 212
 	 */
213
-	public function on_before_post_meta_add( $post_id, $meta_key, $meta_value ) {
213
+	public function on_before_post_meta_add($post_id, $meta_key, $meta_value) {
214 214
 
215 215
 		// Bail out if we're not interested in the meta key.
216
-		if ( WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key ) {
216
+		if (WL_ENTITY_URL_META_NAME !== $meta_key && Wordlift_Schema_Service::FIELD_SAME_AS !== $meta_key) {
217 217
 			return;
218 218
 		}
219 219
 
220
-		$this->log->trace( "Adding $meta_key for post $post_id ($meta_key), invalidating cache..." );
220
+		$this->log->trace("Adding $meta_key for post $post_id ($meta_key), invalidating cache...");
221 221
 
222 222
 		// Delete the cache for the URIs being added.
223
-		$this->delete_cache( (array) $meta_value );
223
+		$this->delete_cache((array) $meta_value);
224 224
 
225 225
 	}
226 226
 
Please login to merge, or discard this patch.