Completed
Push — master ( 38c060...9e660e )
by David
02:43
created
src/wordlift/mappings/class-jsonld-converter.php 2 patches
Indentation   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -16,259 +16,259 @@
 block discarded – undo
16 16
  * @since 3.25.0
17 17
  */
18 18
 class Jsonld_Converter {
19
-	/**
20
-	 * Enumerations for the field types.
21
-	 * Enumerations for the field types.
22
-	 */
23
-	const FIELD_TYPE_TEXT_FIELD = 'text';
24
-	const FIELD_TYPE_CUSTOM_FIELD = 'custom_field';
25
-	const FIELD_TYPE_ACF = 'acf';
26
-	/**
27
-	 * The {@link Mappings_Validator} instance to test.
28
-	 *
29
-	 * @since  3.25.0
30
-	 * @access private
31
-	 * @var Mappings_Validator $validator The {@link Mappings_Validator} instance.
32
-	 */
33
-	private $validator;
34
-
35
-	/**
36
-	 * The {@link Mappings_Transform_Functions_Registry} instance.
37
-	 *
38
-	 * @since  3.25.0
39
-	 * @access private
40
-	 * @var Mappings_Transform_Functions_Registry $transform_functions_registry The {@link Mappings_Transform_Functions_Registry} instance.
41
-	 */
42
-	private $transform_functions_registry;
43
-
44
-	/**
45
-	 * Initialize all dependencies required.
46
-	 *
47
-	 * @param Mappings_Validator $validator A {@link Mappings_Validator} instance.
48
-	 * @param Mappings_Transform_Functions_Registry $transform_functions_registry
49
-	 */
50
-	public function __construct( $validator, $transform_functions_registry ) {
51
-
52
-		$this->validator                    = $validator;
53
-		$this->transform_functions_registry = $transform_functions_registry;
54
-
55
-		// Hook to refactor the JSON-LD.
56
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
57
-		add_filter( 'wl_entity_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 3 );
58
-
59
-	}
60
-
61
-	/**
62
-	 * Hook to `wl_post_jsonld_array` and `wl_entity_jsonld_array`.
63
-	 *
64
-	 * Receive the JSON-LD and the references in the array along with the post ID and transform them according to
65
-	 * the configuration.
66
-	 *
67
-	 * @param array $value {
68
-	 *      The array containing the JSON-LD and the references.
69
-	 *
70
-	 * @type array $jsonld The JSON-LD array.
71
-	 * @type int[] $references An array of post ID referenced by the JSON-LD (will be expanded by the converter).
72
-	 * }
73
-	 *
74
-	 * @param int $post_id The post ID.
75
-	 *
76
-	 * @return array An array with the updated JSON-LD and references.
77
-	 */
78
-	public function wl_post_jsonld_array( $value, $post_id ) {
79
-
80
-		$jsonld     = $value['jsonld'];
81
-		$references = $value['references'];
82
-
83
-		return array(
84
-			'jsonld'     => $this->wl_post_jsonld( $jsonld, $post_id, $references ),
85
-			'references' => $references,
86
-		);
87
-	}
88
-
89
-	/**
90
-	 * Returns JSON-LD data after applying transformation functions.
91
-	 *
92
-	 * @param array $jsonld The JSON-LD structure.
93
-	 * @param int $post_id The {@link WP_Post} id.
94
-	 * @param array $references An array of post references.
95
-	 *
96
-	 * @return array the new refactored array structure.
97
-	 * @since 3.25.0
98
-	 */
99
-	private function wl_post_jsonld( $jsonld, $post_id, &$references ) {
100
-
101
-		// @@todo I think there's an issue here with the Validator, because you're changing the instance state and the
102
-		// instance may be reused afterwards.
103
-
104
-		$properties        = $this->validator->validate( $post_id );
105
-		$nested_properties = array();
106
-
107
-		foreach ( $properties as $property ) {
108
-			// If the property has the character '/' in the property name then it is a nested property.
109
-			if ( strpos( $property['property_name'], '/' ) !== false ) {
110
-				$nested_properties[] = $property;
111
-				continue;
112
-			}
113
-			$property_transformed_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
114
-			if ( false !== $property_transformed_data ) {
115
-				$jsonld[ $property['property_name'] ] = $property_transformed_data;
116
-			}
117
-		}
118
-
119
-		$jsonld = $this->process_nested_properties( $nested_properties, $jsonld, $post_id, $references );
120
-
121
-		return $jsonld;
122
-	}
123
-
124
-	/**
125
-	 * Get the property data by applying the transformation function
126
-	 *
127
-	 * @param $property
128
-	 * @param $jsonld
129
-	 * @param $post_id
130
-	 * @param $references
131
-	 *
132
-	 * @return array|bool|null
133
-	 */
134
-	public function get_property_data( $property, $jsonld, $post_id, &$references ) {
135
-		$transform_instance = $this->transform_functions_registry->get_transform_function( $property['transform_function'] );
136
-		$data               = $this->get_data_from_data_source( $post_id, $property );
137
-		if ( null !== $transform_instance ) {
138
-			$transform_data = $transform_instance->transform_data( $data, $jsonld, $references, $post_id );
139
-			if ( null !== $transform_data ) {
140
-				return $this->make_single( $transform_data );
141
-			}
142
-		} else {
143
-			return $this->make_single( $data );
144
-		}
145
-
146
-		return false;
147
-	}
148
-
149
-	/**
150
-	 * Process all the nested properties.
151
-	 *
152
-	 * @param $nested_properties array
153
-	 * @param $jsonld array
154
-	 *
155
-	 * @return array
156
-	 */
157
-	public function process_nested_properties( $nested_properties, $jsonld, $post_id, &$references ) {
158
-		foreach ( $nested_properties as $property ) {
159
-			$property_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
160
-			if ( false === $property_data ) {
161
-				// No need to create nested levels.
162
-				continue;
163
-			}
164
-
165
-			$keys = explode( '/', $property['property_name'] );
166
-			// end is the last level of the nested property.
167
-			$end                      = array_pop( $keys );
168
-			$current_property_pointer = &$jsonld;
169
-
170
-			/**
171
-			 * Once we find all the nested levels from the property name
172
-			 * loop through it and create associative array if the levels
173
-			 * didnt exist.
174
-			 */
175
-			while ( count( $keys ) > 0 ) {
176
-				$key = array_shift( $keys );
177
-				if ( $key === "" ) {
178
-					continue;
179
-				}
180
-				if ( ! array_key_exists( $key, $current_property_pointer ) ) {
181
-					$current_property_pointer[ $key ] = array();
182
-				}
183
-				// We are setting the pointer to the current key, so that at the end
184
-				// we can add the data at last level.
185
-				$current_property_pointer = &$current_property_pointer[ $key ];
186
-			}
187
-			$current_property_pointer[ $end ] = $property_data;
188
-		}
189
-
190
-		return $jsonld;
191
-	}
192
-
193
-
194
-	/**
195
-	 * Returns data from data source.
196
-	 *
197
-	 * @param int $post_id Id of the post.
198
-	 * @param array $property_data The property data for the post_id.
199
-	 *
200
-	 * @return array Returns key, value array, if the value is not found, then it returns null.
201
-	 */
202
-	final public function get_data_from_data_source( $post_id, $property_data ) {
203
-		$value = $property_data['field_name'];
204
-
205
-		// Do 1 to 1 mapping and return result.
206
-		switch ( $property_data['field_type'] ) {
207
-			case self::FIELD_TYPE_ACF:
208
-				if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) {
209
-					return array();
210
-				}
211
-
212
-				return $this->get_data_for_acf_field( $property_data['field_name'], $post_id );
213
-
214
-			case self::FIELD_TYPE_CUSTOM_FIELD:
215
-
216
-				return array_map( 'wp_strip_all_tags', get_post_meta( $post_id, $value ) );
217
-
218
-			default:
219
-				return $value;
220
-		}
221
-
222
-	}
223
-
224
-	/**
225
-	 * Gets data from acf, format the data if it is a repeater field.
226
-	 *
227
-	 * @param $field_name
228
-	 * @param $post_id
229
-	 *
230
-	 * @return array|mixed
231
-	 */
232
-	public function get_data_for_acf_field( $field_name, $post_id ) {
233
-		$field_data = get_field_object( $field_name, $post_id );
234
-		$data       = get_field( $field_name, $post_id );
235
-
236
-		// only process if it is a repeater field, else return the data.
237
-		if ( is_array( $field_data ) && array_key_exists( 'type', $field_data )
238
-		     && $field_data['type'] === 'repeater' ) {
239
-			// check if we have only one sub field, currently we only support one subfield.
240
-			if ( is_array( $data ) && count( $data ) > 0 && count( array_keys( $data[0] ) === 1 ) ) {
241
-				$repeater_formatted_data = array();
242
-				foreach ( $data as $item ) {
243
-					$repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) );
244
-				}
245
-				// Remove non unique values.
246
-				$repeater_formatted_data = array_unique( $repeater_formatted_data );
247
-				// Remove empty values
248
-				$repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' );
249
-
250
-				// re-index all the values.
251
-				return array_values( $repeater_formatted_data );
252
-			}
253
-		}
254
-
255
-		// Return normal acf data if it is not a repeater field.
256
-		return $data;
257
-	}
258
-
259
-	private function make_single( $value ) {
260
-
261
-		$values = (array) $value;
262
-
263
-		if ( empty( $values ) ) {
264
-			return null;
265
-		}
266
-
267
-		if ( 1 === count( $values ) && 0 === key( $values ) ) {
268
-			return current( $values );
269
-		}
270
-
271
-		return $values;
272
-	}
19
+    /**
20
+     * Enumerations for the field types.
21
+     * Enumerations for the field types.
22
+     */
23
+    const FIELD_TYPE_TEXT_FIELD = 'text';
24
+    const FIELD_TYPE_CUSTOM_FIELD = 'custom_field';
25
+    const FIELD_TYPE_ACF = 'acf';
26
+    /**
27
+     * The {@link Mappings_Validator} instance to test.
28
+     *
29
+     * @since  3.25.0
30
+     * @access private
31
+     * @var Mappings_Validator $validator The {@link Mappings_Validator} instance.
32
+     */
33
+    private $validator;
34
+
35
+    /**
36
+     * The {@link Mappings_Transform_Functions_Registry} instance.
37
+     *
38
+     * @since  3.25.0
39
+     * @access private
40
+     * @var Mappings_Transform_Functions_Registry $transform_functions_registry The {@link Mappings_Transform_Functions_Registry} instance.
41
+     */
42
+    private $transform_functions_registry;
43
+
44
+    /**
45
+     * Initialize all dependencies required.
46
+     *
47
+     * @param Mappings_Validator $validator A {@link Mappings_Validator} instance.
48
+     * @param Mappings_Transform_Functions_Registry $transform_functions_registry
49
+     */
50
+    public function __construct( $validator, $transform_functions_registry ) {
51
+
52
+        $this->validator                    = $validator;
53
+        $this->transform_functions_registry = $transform_functions_registry;
54
+
55
+        // Hook to refactor the JSON-LD.
56
+        add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
57
+        add_filter( 'wl_entity_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 3 );
58
+
59
+    }
60
+
61
+    /**
62
+     * Hook to `wl_post_jsonld_array` and `wl_entity_jsonld_array`.
63
+     *
64
+     * Receive the JSON-LD and the references in the array along with the post ID and transform them according to
65
+     * the configuration.
66
+     *
67
+     * @param array $value {
68
+     *      The array containing the JSON-LD and the references.
69
+     *
70
+     * @type array $jsonld The JSON-LD array.
71
+     * @type int[] $references An array of post ID referenced by the JSON-LD (will be expanded by the converter).
72
+     * }
73
+     *
74
+     * @param int $post_id The post ID.
75
+     *
76
+     * @return array An array with the updated JSON-LD and references.
77
+     */
78
+    public function wl_post_jsonld_array( $value, $post_id ) {
79
+
80
+        $jsonld     = $value['jsonld'];
81
+        $references = $value['references'];
82
+
83
+        return array(
84
+            'jsonld'     => $this->wl_post_jsonld( $jsonld, $post_id, $references ),
85
+            'references' => $references,
86
+        );
87
+    }
88
+
89
+    /**
90
+     * Returns JSON-LD data after applying transformation functions.
91
+     *
92
+     * @param array $jsonld The JSON-LD structure.
93
+     * @param int $post_id The {@link WP_Post} id.
94
+     * @param array $references An array of post references.
95
+     *
96
+     * @return array the new refactored array structure.
97
+     * @since 3.25.0
98
+     */
99
+    private function wl_post_jsonld( $jsonld, $post_id, &$references ) {
100
+
101
+        // @@todo I think there's an issue here with the Validator, because you're changing the instance state and the
102
+        // instance may be reused afterwards.
103
+
104
+        $properties        = $this->validator->validate( $post_id );
105
+        $nested_properties = array();
106
+
107
+        foreach ( $properties as $property ) {
108
+            // If the property has the character '/' in the property name then it is a nested property.
109
+            if ( strpos( $property['property_name'], '/' ) !== false ) {
110
+                $nested_properties[] = $property;
111
+                continue;
112
+            }
113
+            $property_transformed_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
114
+            if ( false !== $property_transformed_data ) {
115
+                $jsonld[ $property['property_name'] ] = $property_transformed_data;
116
+            }
117
+        }
118
+
119
+        $jsonld = $this->process_nested_properties( $nested_properties, $jsonld, $post_id, $references );
120
+
121
+        return $jsonld;
122
+    }
123
+
124
+    /**
125
+     * Get the property data by applying the transformation function
126
+     *
127
+     * @param $property
128
+     * @param $jsonld
129
+     * @param $post_id
130
+     * @param $references
131
+     *
132
+     * @return array|bool|null
133
+     */
134
+    public function get_property_data( $property, $jsonld, $post_id, &$references ) {
135
+        $transform_instance = $this->transform_functions_registry->get_transform_function( $property['transform_function'] );
136
+        $data               = $this->get_data_from_data_source( $post_id, $property );
137
+        if ( null !== $transform_instance ) {
138
+            $transform_data = $transform_instance->transform_data( $data, $jsonld, $references, $post_id );
139
+            if ( null !== $transform_data ) {
140
+                return $this->make_single( $transform_data );
141
+            }
142
+        } else {
143
+            return $this->make_single( $data );
144
+        }
145
+
146
+        return false;
147
+    }
148
+
149
+    /**
150
+     * Process all the nested properties.
151
+     *
152
+     * @param $nested_properties array
153
+     * @param $jsonld array
154
+     *
155
+     * @return array
156
+     */
157
+    public function process_nested_properties( $nested_properties, $jsonld, $post_id, &$references ) {
158
+        foreach ( $nested_properties as $property ) {
159
+            $property_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
160
+            if ( false === $property_data ) {
161
+                // No need to create nested levels.
162
+                continue;
163
+            }
164
+
165
+            $keys = explode( '/', $property['property_name'] );
166
+            // end is the last level of the nested property.
167
+            $end                      = array_pop( $keys );
168
+            $current_property_pointer = &$jsonld;
169
+
170
+            /**
171
+             * Once we find all the nested levels from the property name
172
+             * loop through it and create associative array if the levels
173
+             * didnt exist.
174
+             */
175
+            while ( count( $keys ) > 0 ) {
176
+                $key = array_shift( $keys );
177
+                if ( $key === "" ) {
178
+                    continue;
179
+                }
180
+                if ( ! array_key_exists( $key, $current_property_pointer ) ) {
181
+                    $current_property_pointer[ $key ] = array();
182
+                }
183
+                // We are setting the pointer to the current key, so that at the end
184
+                // we can add the data at last level.
185
+                $current_property_pointer = &$current_property_pointer[ $key ];
186
+            }
187
+            $current_property_pointer[ $end ] = $property_data;
188
+        }
189
+
190
+        return $jsonld;
191
+    }
192
+
193
+
194
+    /**
195
+     * Returns data from data source.
196
+     *
197
+     * @param int $post_id Id of the post.
198
+     * @param array $property_data The property data for the post_id.
199
+     *
200
+     * @return array Returns key, value array, if the value is not found, then it returns null.
201
+     */
202
+    final public function get_data_from_data_source( $post_id, $property_data ) {
203
+        $value = $property_data['field_name'];
204
+
205
+        // Do 1 to 1 mapping and return result.
206
+        switch ( $property_data['field_type'] ) {
207
+            case self::FIELD_TYPE_ACF:
208
+                if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) {
209
+                    return array();
210
+                }
211
+
212
+                return $this->get_data_for_acf_field( $property_data['field_name'], $post_id );
213
+
214
+            case self::FIELD_TYPE_CUSTOM_FIELD:
215
+
216
+                return array_map( 'wp_strip_all_tags', get_post_meta( $post_id, $value ) );
217
+
218
+            default:
219
+                return $value;
220
+        }
221
+
222
+    }
223
+
224
+    /**
225
+     * Gets data from acf, format the data if it is a repeater field.
226
+     *
227
+     * @param $field_name
228
+     * @param $post_id
229
+     *
230
+     * @return array|mixed
231
+     */
232
+    public function get_data_for_acf_field( $field_name, $post_id ) {
233
+        $field_data = get_field_object( $field_name, $post_id );
234
+        $data       = get_field( $field_name, $post_id );
235
+
236
+        // only process if it is a repeater field, else return the data.
237
+        if ( is_array( $field_data ) && array_key_exists( 'type', $field_data )
238
+             && $field_data['type'] === 'repeater' ) {
239
+            // check if we have only one sub field, currently we only support one subfield.
240
+            if ( is_array( $data ) && count( $data ) > 0 && count( array_keys( $data[0] ) === 1 ) ) {
241
+                $repeater_formatted_data = array();
242
+                foreach ( $data as $item ) {
243
+                    $repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) );
244
+                }
245
+                // Remove non unique values.
246
+                $repeater_formatted_data = array_unique( $repeater_formatted_data );
247
+                // Remove empty values
248
+                $repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' );
249
+
250
+                // re-index all the values.
251
+                return array_values( $repeater_formatted_data );
252
+            }
253
+        }
254
+
255
+        // Return normal acf data if it is not a repeater field.
256
+        return $data;
257
+    }
258
+
259
+    private function make_single( $value ) {
260
+
261
+        $values = (array) $value;
262
+
263
+        if ( empty( $values ) ) {
264
+            return null;
265
+        }
266
+
267
+        if ( 1 === count( $values ) && 0 === key( $values ) ) {
268
+            return current( $values );
269
+        }
270
+
271
+        return $values;
272
+    }
273 273
 
274 274
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	 * @param Mappings_Validator $validator A {@link Mappings_Validator} instance.
48 48
 	 * @param Mappings_Transform_Functions_Registry $transform_functions_registry
49 49
 	 */
50
-	public function __construct( $validator, $transform_functions_registry ) {
50
+	public function __construct($validator, $transform_functions_registry) {
51 51
 
52 52
 		$this->validator                    = $validator;
53 53
 		$this->transform_functions_registry = $transform_functions_registry;
54 54
 
55 55
 		// Hook to refactor the JSON-LD.
56
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
57
-		add_filter( 'wl_entity_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 3 );
56
+		add_filter('wl_post_jsonld_array', array($this, 'wl_post_jsonld_array'), 11, 2);
57
+		add_filter('wl_entity_jsonld_array', array($this, 'wl_post_jsonld_array'), 11, 3);
58 58
 
59 59
 	}
60 60
 
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return array An array with the updated JSON-LD and references.
77 77
 	 */
78
-	public function wl_post_jsonld_array( $value, $post_id ) {
78
+	public function wl_post_jsonld_array($value, $post_id) {
79 79
 
80 80
 		$jsonld     = $value['jsonld'];
81 81
 		$references = $value['references'];
82 82
 
83 83
 		return array(
84
-			'jsonld'     => $this->wl_post_jsonld( $jsonld, $post_id, $references ),
84
+			'jsonld'     => $this->wl_post_jsonld($jsonld, $post_id, $references),
85 85
 			'references' => $references,
86 86
 		);
87 87
 	}
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 	 * @return array the new refactored array structure.
97 97
 	 * @since 3.25.0
98 98
 	 */
99
-	private function wl_post_jsonld( $jsonld, $post_id, &$references ) {
99
+	private function wl_post_jsonld($jsonld, $post_id, &$references) {
100 100
 
101 101
 		// @@todo I think there's an issue here with the Validator, because you're changing the instance state and the
102 102
 		// instance may be reused afterwards.
103 103
 
104
-		$properties        = $this->validator->validate( $post_id );
104
+		$properties        = $this->validator->validate($post_id);
105 105
 		$nested_properties = array();
106 106
 
107
-		foreach ( $properties as $property ) {
107
+		foreach ($properties as $property) {
108 108
 			// If the property has the character '/' in the property name then it is a nested property.
109
-			if ( strpos( $property['property_name'], '/' ) !== false ) {
109
+			if (strpos($property['property_name'], '/') !== false) {
110 110
 				$nested_properties[] = $property;
111 111
 				continue;
112 112
 			}
113
-			$property_transformed_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
114
-			if ( false !== $property_transformed_data ) {
115
-				$jsonld[ $property['property_name'] ] = $property_transformed_data;
113
+			$property_transformed_data = $this->get_property_data($property, $jsonld, $post_id, $references);
114
+			if (false !== $property_transformed_data) {
115
+				$jsonld[$property['property_name']] = $property_transformed_data;
116 116
 			}
117 117
 		}
118 118
 
119
-		$jsonld = $this->process_nested_properties( $nested_properties, $jsonld, $post_id, $references );
119
+		$jsonld = $this->process_nested_properties($nested_properties, $jsonld, $post_id, $references);
120 120
 
121 121
 		return $jsonld;
122 122
 	}
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return array|bool|null
133 133
 	 */
134
-	public function get_property_data( $property, $jsonld, $post_id, &$references ) {
135
-		$transform_instance = $this->transform_functions_registry->get_transform_function( $property['transform_function'] );
136
-		$data               = $this->get_data_from_data_source( $post_id, $property );
137
-		if ( null !== $transform_instance ) {
138
-			$transform_data = $transform_instance->transform_data( $data, $jsonld, $references, $post_id );
139
-			if ( null !== $transform_data ) {
140
-				return $this->make_single( $transform_data );
134
+	public function get_property_data($property, $jsonld, $post_id, &$references) {
135
+		$transform_instance = $this->transform_functions_registry->get_transform_function($property['transform_function']);
136
+		$data               = $this->get_data_from_data_source($post_id, $property);
137
+		if (null !== $transform_instance) {
138
+			$transform_data = $transform_instance->transform_data($data, $jsonld, $references, $post_id);
139
+			if (null !== $transform_data) {
140
+				return $this->make_single($transform_data);
141 141
 			}
142 142
 		} else {
143
-			return $this->make_single( $data );
143
+			return $this->make_single($data);
144 144
 		}
145 145
 
146 146
 		return false;
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return array
156 156
 	 */
157
-	public function process_nested_properties( $nested_properties, $jsonld, $post_id, &$references ) {
158
-		foreach ( $nested_properties as $property ) {
159
-			$property_data = $this->get_property_data( $property, $jsonld, $post_id, $references );
160
-			if ( false === $property_data ) {
157
+	public function process_nested_properties($nested_properties, $jsonld, $post_id, &$references) {
158
+		foreach ($nested_properties as $property) {
159
+			$property_data = $this->get_property_data($property, $jsonld, $post_id, $references);
160
+			if (false === $property_data) {
161 161
 				// No need to create nested levels.
162 162
 				continue;
163 163
 			}
164 164
 
165
-			$keys = explode( '/', $property['property_name'] );
165
+			$keys = explode('/', $property['property_name']);
166 166
 			// end is the last level of the nested property.
167
-			$end                      = array_pop( $keys );
167
+			$end                      = array_pop($keys);
168 168
 			$current_property_pointer = &$jsonld;
169 169
 
170 170
 			/**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 			 * loop through it and create associative array if the levels
173 173
 			 * didnt exist.
174 174
 			 */
175
-			while ( count( $keys ) > 0 ) {
176
-				$key = array_shift( $keys );
177
-				if ( $key === "" ) {
175
+			while (count($keys) > 0) {
176
+				$key = array_shift($keys);
177
+				if ($key === "") {
178 178
 					continue;
179 179
 				}
180
-				if ( ! array_key_exists( $key, $current_property_pointer ) ) {
181
-					$current_property_pointer[ $key ] = array();
180
+				if ( ! array_key_exists($key, $current_property_pointer)) {
181
+					$current_property_pointer[$key] = array();
182 182
 				}
183 183
 				// We are setting the pointer to the current key, so that at the end
184 184
 				// we can add the data at last level.
185
-				$current_property_pointer = &$current_property_pointer[ $key ];
185
+				$current_property_pointer = &$current_property_pointer[$key];
186 186
 			}
187
-			$current_property_pointer[ $end ] = $property_data;
187
+			$current_property_pointer[$end] = $property_data;
188 188
 		}
189 189
 
190 190
 		return $jsonld;
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return array Returns key, value array, if the value is not found, then it returns null.
201 201
 	 */
202
-	final public function get_data_from_data_source( $post_id, $property_data ) {
202
+	final public function get_data_from_data_source($post_id, $property_data) {
203 203
 		$value = $property_data['field_name'];
204 204
 
205 205
 		// Do 1 to 1 mapping and return result.
206
-		switch ( $property_data['field_type'] ) {
206
+		switch ($property_data['field_type']) {
207 207
 			case self::FIELD_TYPE_ACF:
208
-				if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) {
208
+				if ( ! function_exists('get_field') || ! function_exists('get_field_object')) {
209 209
 					return array();
210 210
 				}
211 211
 
212
-				return $this->get_data_for_acf_field( $property_data['field_name'], $post_id );
212
+				return $this->get_data_for_acf_field($property_data['field_name'], $post_id);
213 213
 
214 214
 			case self::FIELD_TYPE_CUSTOM_FIELD:
215 215
 
216
-				return array_map( 'wp_strip_all_tags', get_post_meta( $post_id, $value ) );
216
+				return array_map('wp_strip_all_tags', get_post_meta($post_id, $value));
217 217
 
218 218
 			default:
219 219
 				return $value;
@@ -229,26 +229,26 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return array|mixed
231 231
 	 */
232
-	public function get_data_for_acf_field( $field_name, $post_id ) {
233
-		$field_data = get_field_object( $field_name, $post_id );
234
-		$data       = get_field( $field_name, $post_id );
232
+	public function get_data_for_acf_field($field_name, $post_id) {
233
+		$field_data = get_field_object($field_name, $post_id);
234
+		$data       = get_field($field_name, $post_id);
235 235
 
236 236
 		// only process if it is a repeater field, else return the data.
237
-		if ( is_array( $field_data ) && array_key_exists( 'type', $field_data )
238
-		     && $field_data['type'] === 'repeater' ) {
237
+		if (is_array($field_data) && array_key_exists('type', $field_data)
238
+		     && $field_data['type'] === 'repeater') {
239 239
 			// check if we have only one sub field, currently we only support one subfield.
240
-			if ( is_array( $data ) && count( $data ) > 0 && count( array_keys( $data[0] ) === 1 ) ) {
240
+			if (is_array($data) && count($data) > 0 && count(array_keys($data[0]) === 1)) {
241 241
 				$repeater_formatted_data = array();
242
-				foreach ( $data as $item ) {
243
-					$repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) );
242
+				foreach ($data as $item) {
243
+					$repeater_formatted_data = array_merge($repeater_formatted_data, array_values($item));
244 244
 				}
245 245
 				// Remove non unique values.
246
-				$repeater_formatted_data = array_unique( $repeater_formatted_data );
246
+				$repeater_formatted_data = array_unique($repeater_formatted_data);
247 247
 				// Remove empty values
248
-				$repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' );
248
+				$repeater_formatted_data = array_filter($repeater_formatted_data, 'strlen');
249 249
 
250 250
 				// re-index all the values.
251
-				return array_values( $repeater_formatted_data );
251
+				return array_values($repeater_formatted_data);
252 252
 			}
253 253
 		}
254 254
 
@@ -256,16 +256,16 @@  discard block
 block discarded – undo
256 256
 		return $data;
257 257
 	}
258 258
 
259
-	private function make_single( $value ) {
259
+	private function make_single($value) {
260 260
 
261 261
 		$values = (array) $value;
262 262
 
263
-		if ( empty( $values ) ) {
263
+		if (empty($values)) {
264 264
 			return null;
265 265
 		}
266 266
 
267
-		if ( 1 === count( $values ) && 0 === key( $values ) ) {
268
-			return current( $values );
267
+		if (1 === count($values) && 0 === key($values)) {
268
+			return current($values);
269 269
 		}
270 270
 
271 271
 		return $values;
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +582 added lines, -582 removed lines patch added patch discarded remove patch
@@ -16,506 +16,506 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Entity_Service {
18 18
 
19
-	/**
20
-	 * The Log service.
21
-	 *
22
-	 * @since  3.2.0
23
-	 * @access private
24
-	 * @var \Wordlift_Log_Service $log The Log service.
25
-	 */
26
-	private $log;
27
-
28
-	/**
29
-	 * The UI service.
30
-	 *
31
-	 * @since  3.2.0
32
-	 * @access private
33
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
34
-	 */
35
-	private $ui_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Relation_Service} instance.
39
-	 *
40
-	 * @since  3.15.0
41
-	 * @access private
42
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
43
-	 */
44
-	private $relation_service;
45
-
46
-	/**
47
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
48
-	 *
49
-	 * @since  3.16.3
50
-	 * @access private
51
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
52
-	 */
53
-	private $entity_uri_service;
54
-
55
-	/**
56
-	 * The entity post type name.
57
-	 *
58
-	 * @since 3.1.0
59
-	 */
60
-	const TYPE_NAME = 'entity';
61
-
62
-	/**
63
-	 * The alternative label meta key.
64
-	 *
65
-	 * @since 3.2.0
66
-	 */
67
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
68
-
69
-	/**
70
-	 * The alternative label input template.
71
-	 *
72
-	 * @since 3.2.0
73
-	 */
74
-	// TODO: this should be moved to a class that deals with HTML code.
75
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
19
+    /**
20
+     * The Log service.
21
+     *
22
+     * @since  3.2.0
23
+     * @access private
24
+     * @var \Wordlift_Log_Service $log The Log service.
25
+     */
26
+    private $log;
27
+
28
+    /**
29
+     * The UI service.
30
+     *
31
+     * @since  3.2.0
32
+     * @access private
33
+     * @var \Wordlift_UI_Service $ui_service The UI service.
34
+     */
35
+    private $ui_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Relation_Service} instance.
39
+     *
40
+     * @since  3.15.0
41
+     * @access private
42
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
43
+     */
44
+    private $relation_service;
45
+
46
+    /**
47
+     * The {@link Wordlift_Entity_Uri_Service} instance.
48
+     *
49
+     * @since  3.16.3
50
+     * @access private
51
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
52
+     */
53
+    private $entity_uri_service;
54
+
55
+    /**
56
+     * The entity post type name.
57
+     *
58
+     * @since 3.1.0
59
+     */
60
+    const TYPE_NAME = 'entity';
61
+
62
+    /**
63
+     * The alternative label meta key.
64
+     *
65
+     * @since 3.2.0
66
+     */
67
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
68
+
69
+    /**
70
+     * The alternative label input template.
71
+     *
72
+     * @since 3.2.0
73
+     */
74
+    // TODO: this should be moved to a class that deals with HTML code.
75
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
76 76
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
77 77
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
78 78
                 <button class="button wl-delete-button">%s</button>
79 79
                 </div>';
80 80
 
81
-	/**
82
-	 * A singleton instance of the Entity service.
83
-	 *
84
-	 * @since  3.2.0
85
-	 * @access private
86
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
87
-	 */
88
-	private static $instance;
89
-
90
-	/**
91
-	 * Create a Wordlift_Entity_Service instance.
92
-	 *
93
-	 * @param \Wordlift_UI_Service $ui_service The UI service.
94
-	 * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
95
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
96
-	 *
97
-	 * @since 3.2.0
98
-	 *
99
-	 */
100
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
101
-
102
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
103
-
104
-		$this->ui_service         = $ui_service;
105
-		$this->relation_service   = $relation_service;
106
-		$this->entity_uri_service = $entity_uri_service;
107
-
108
-		// Set the singleton instance.
109
-		self::$instance = $this;
110
-	}
111
-
112
-	/**
113
-	 * Get the singleton instance of the Entity service.
114
-	 *
115
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
116
-	 * @since 3.2.0
117
-	 */
118
-	public static function get_instance() {
119
-
120
-		return self::$instance;
121
-	}
122
-
123
-	/**
124
-	 * Determines whether a post is an entity or not. Entity is in this context
125
-	 * something which is not an article.
126
-	 *
127
-	 * @param int $post_id A post id.
128
-	 *
129
-	 * @return bool Return true if the post is an entity otherwise false.
130
-	 * @since 3.1.0
131
-	 *
132
-	 */
133
-	public function is_entity( $post_id ) {
134
-
135
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
136
-
137
-		if ( is_wp_error( $terms ) ) {
138
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
139
-
140
-			return false;
141
-		}
142
-
143
-		if ( empty( $terms ) ) {
144
-			return false;
145
-		}
146
-
147
-		/*
81
+    /**
82
+     * A singleton instance of the Entity service.
83
+     *
84
+     * @since  3.2.0
85
+     * @access private
86
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
87
+     */
88
+    private static $instance;
89
+
90
+    /**
91
+     * Create a Wordlift_Entity_Service instance.
92
+     *
93
+     * @param \Wordlift_UI_Service $ui_service The UI service.
94
+     * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
95
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
96
+     *
97
+     * @since 3.2.0
98
+     *
99
+     */
100
+    public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
101
+
102
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
103
+
104
+        $this->ui_service         = $ui_service;
105
+        $this->relation_service   = $relation_service;
106
+        $this->entity_uri_service = $entity_uri_service;
107
+
108
+        // Set the singleton instance.
109
+        self::$instance = $this;
110
+    }
111
+
112
+    /**
113
+     * Get the singleton instance of the Entity service.
114
+     *
115
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
116
+     * @since 3.2.0
117
+     */
118
+    public static function get_instance() {
119
+
120
+        return self::$instance;
121
+    }
122
+
123
+    /**
124
+     * Determines whether a post is an entity or not. Entity is in this context
125
+     * something which is not an article.
126
+     *
127
+     * @param int $post_id A post id.
128
+     *
129
+     * @return bool Return true if the post is an entity otherwise false.
130
+     * @since 3.1.0
131
+     *
132
+     */
133
+    public function is_entity( $post_id ) {
134
+
135
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
136
+
137
+        if ( is_wp_error( $terms ) ) {
138
+            $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
139
+
140
+            return false;
141
+        }
142
+
143
+        if ( empty( $terms ) ) {
144
+            return false;
145
+        }
146
+
147
+        /*
148 148
 		 * We don't consider an `article` to be an entity.
149 149
 		 *
150 150
 		 * @since 3.20.0 At least one associated mustn't be an `article`.
151 151
 		 *
152 152
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
153 153
 		 */
154
-		foreach ( $terms as $term ) {
155
-			if ( 'article' !== $term->slug ) {
156
-				return true;
157
-			}
158
-		}
159
-
160
-		return false;
161
-	}
162
-
163
-	/**
164
-	 * Get the proper classification scope for a given entity post
165
-	 *
166
-	 * @param integer $post_id An entity post id.
167
-	 *
168
-	 * @param string $default The default classification scope, `what` if not
169
-	 *                         provided.
170
-	 *
171
-	 * @return string Returns a classification scope (e.g. 'what').
172
-	 * @since 3.5.0
173
-	 *
174
-	 */
175
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
176
-
177
-		if ( false === $this->is_entity( $post_id ) ) {
178
-			return $default;
179
-		}
180
-
181
-		// Retrieve the entity type
182
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
183
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
184
-		// Retrieve classification boxes configuration
185
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
186
-		foreach ( $classification_boxes as $cb ) {
187
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
188
-				return $cb['id'];
189
-			}
190
-		}
191
-
192
-		return $default;
193
-	}
194
-
195
-	/**
196
-	 * Check whether a {@link WP_Post} is used.
197
-	 *
198
-	 * @param int $post_id The {@link WP_Post}'s id.
199
-	 *
200
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
201
-	 */
202
-	public function is_used( $post_id ) {
203
-
204
-		if ( false === $this->is_entity( $post_id ) ) {
205
-			return null;
206
-		}
207
-		// Retrieve the post
208
-		$entity = get_post( $post_id );
209
-
210
-		global $wpdb;
211
-		// Retrieve Wordlift relation instances table name
212
-		$table_name = wl_core_get_relation_instances_table_name();
213
-
214
-		// Check is it's referenced / related to another post / entity
215
-		$stmt = $wpdb->prepare(
216
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
217
-			$entity->ID
218
-		);
219
-
220
-		// Perform the query
221
-		$relation_instances = (int) $wpdb->get_var( $stmt );
222
-		// If there is at least one relation instance for the current entity, then it's used
223
-		if ( 0 < $relation_instances ) {
224
-			return true;
225
-		}
226
-
227
-		// Check if the entity uri is used as meta_value
228
-		$stmt = $wpdb->prepare(
229
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
230
-			$entity->ID,
231
-			wl_get_entity_uri( $entity->ID )
232
-		);
233
-		// Perform the query
234
-		$meta_instances = (int) $wpdb->get_var( $stmt );
235
-
236
-		// If there is at least one meta that refers the current entity uri, then current entity is used
237
-		if ( 0 < $meta_instances ) {
238
-			return true;
239
-		}
240
-
241
-		// If we are here, it means the current entity is not used at the moment
242
-		return false;
243
-	}
244
-
245
-	/**
246
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
247
-	 *
248
-	 * @param string $uri The entity URI.
249
-	 *
250
-	 * @return WP_Post|null A WP_Post instance or null if not found.
251
-	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
252
-	 *
253
-	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
254
-	 * @since      3.2.0
255
-	 *
256
-	 */
257
-	public function get_entity_post_by_uri( $uri ) {
258
-
259
-		return $this->entity_uri_service->get_entity( $uri );
260
-	}
261
-
262
-	/**
263
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
264
-	 * we check that the post we're saving is the current post.
265
-	 *
266
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
267
-	 *
268
-	 * @since 3.2.0
269
-	 *
270
-	 * @param int $post_id Post ID.
271
-	 * @param WP_Post $post Post object.
272
-	 * @param bool $update Whether this is an existing post being updated or not.
273
-	 */
274
-	public function save_post( $post_id, $post, $update ) {
275
-
276
-		// Avoid doing anything if post is autosave or a revision.
277
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
278
-			return;
279
-		}
280
-
281
-		// We're setting the alternative label that have been provided via the UI
282
-		// (in fact we're using $_REQUEST), while save_post may be also called
283
-		// programmatically by some other function: we need to check therefore if
284
-		// the $post_id in the save_post call matches the post id set in the request.
285
-		//
286
-		// If this is not the current post being saved or if it's not an entity, return.
287
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
288
-			return;
289
-		}
290
-
291
-		// Get the alt labels from the request (or empty array).
292
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
293
-
294
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
295
-			// This is via classic editor, so set the alternative labels.
296
-			$this->set_alternative_labels( $post_id, $alt_labels );
297
-		}
298
-
299
-
300
-	}
301
-
302
-	/**
303
-	 * Set the alternative labels.
304
-	 *
305
-	 * @param int $post_id The post id.
306
-	 * @param array $alt_labels An array of labels.
307
-	 *
308
-	 * @since 3.2.0
309
-	 *
310
-	 */
311
-	public function set_alternative_labels( $post_id, $alt_labels ) {
312
-
313
-		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
314
-		// instead of post id.
315
-		if ( ! is_numeric( $post_id ) ) {
316
-			return;
317
-		}
318
-
319
-		// Force $alt_labels to be an array
320
-		if ( ! is_array( $alt_labels ) ) {
321
-			$alt_labels = array( $alt_labels );
322
-		}
323
-
324
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
325
-
326
-		// Delete all the existing alternate labels.
327
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
328
-
329
-		// Set the alternative labels.
330
-		foreach ( $alt_labels as $alt_label ) {
331
-			if ( ! empty( $alt_label ) ) {
332
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
333
-			}
334
-		}
335
-
336
-	}
337
-
338
-	/**
339
-	 * Retrieve the alternate labels.
340
-	 *
341
-	 * @param int $post_id Post id.
342
-	 *
343
-	 * @return mixed An array  of alternative labels.
344
-	 * @since 3.2.0
345
-	 *
346
-	 */
347
-	public function get_alternative_labels( $post_id ) {
348
-
349
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
350
-	}
351
-
352
-	/**
353
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
354
-	 *
355
-	 * @param int $post_id The entity {@link WP_Post} id.
356
-	 *
357
-	 * @return array An array with the entity title and labels.
358
-	 * @since 3.12.0
359
-	 *
360
-	 */
361
-	public function get_labels( $post_id ) {
362
-
363
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
364
-	}
365
-
366
-	/**
367
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
368
-	 *
369
-	 * @param WP_Post $post Post object.
370
-	 *
371
-	 * @since 3.2.0
372
-	 *
373
-	 */
374
-	public function edit_form_before_permalink( $post ) {
375
-
376
-		// If it's not an entity, return.
377
-		if ( ! $this->is_entity( $post->ID ) ) {
378
-			return;
379
-		}
380
-
381
-		// Print the input template.
382
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
383
-
384
-		// Print all the currently set alternative labels.
385
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
386
-
387
-			echo $this->get_alternative_label_input( $alt_label );
388
-
389
-		};
390
-
391
-		// Print the button.
392
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
393
-
394
-	}
395
-
396
-	/**
397
-	 * Get the URI for the entity with the specified post id.
398
-	 *
399
-	 * @param int $post_id The entity post id.
400
-	 *
401
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
402
-	 * @since 3.6.0
403
-	 *
404
-	 */
405
-	public function get_uri( $post_id ) {
406
-
407
-		// If a null is given, nothing to do
408
-		if ( null == $post_id ) {
409
-			return null;
410
-		}
411
-
412
-		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
413
-
414
-		// If the dataset uri is not properly configured, null is returned
415
-		if ( empty( $dataset_uri ) ) {
416
-			return null;
417
-		}
418
-
419
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
420
-
421
-		/*
154
+        foreach ( $terms as $term ) {
155
+            if ( 'article' !== $term->slug ) {
156
+                return true;
157
+            }
158
+        }
159
+
160
+        return false;
161
+    }
162
+
163
+    /**
164
+     * Get the proper classification scope for a given entity post
165
+     *
166
+     * @param integer $post_id An entity post id.
167
+     *
168
+     * @param string $default The default classification scope, `what` if not
169
+     *                         provided.
170
+     *
171
+     * @return string Returns a classification scope (e.g. 'what').
172
+     * @since 3.5.0
173
+     *
174
+     */
175
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
176
+
177
+        if ( false === $this->is_entity( $post_id ) ) {
178
+            return $default;
179
+        }
180
+
181
+        // Retrieve the entity type
182
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
183
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
184
+        // Retrieve classification boxes configuration
185
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
186
+        foreach ( $classification_boxes as $cb ) {
187
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
188
+                return $cb['id'];
189
+            }
190
+        }
191
+
192
+        return $default;
193
+    }
194
+
195
+    /**
196
+     * Check whether a {@link WP_Post} is used.
197
+     *
198
+     * @param int $post_id The {@link WP_Post}'s id.
199
+     *
200
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
201
+     */
202
+    public function is_used( $post_id ) {
203
+
204
+        if ( false === $this->is_entity( $post_id ) ) {
205
+            return null;
206
+        }
207
+        // Retrieve the post
208
+        $entity = get_post( $post_id );
209
+
210
+        global $wpdb;
211
+        // Retrieve Wordlift relation instances table name
212
+        $table_name = wl_core_get_relation_instances_table_name();
213
+
214
+        // Check is it's referenced / related to another post / entity
215
+        $stmt = $wpdb->prepare(
216
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
217
+            $entity->ID
218
+        );
219
+
220
+        // Perform the query
221
+        $relation_instances = (int) $wpdb->get_var( $stmt );
222
+        // If there is at least one relation instance for the current entity, then it's used
223
+        if ( 0 < $relation_instances ) {
224
+            return true;
225
+        }
226
+
227
+        // Check if the entity uri is used as meta_value
228
+        $stmt = $wpdb->prepare(
229
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
230
+            $entity->ID,
231
+            wl_get_entity_uri( $entity->ID )
232
+        );
233
+        // Perform the query
234
+        $meta_instances = (int) $wpdb->get_var( $stmt );
235
+
236
+        // If there is at least one meta that refers the current entity uri, then current entity is used
237
+        if ( 0 < $meta_instances ) {
238
+            return true;
239
+        }
240
+
241
+        // If we are here, it means the current entity is not used at the moment
242
+        return false;
243
+    }
244
+
245
+    /**
246
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
247
+     *
248
+     * @param string $uri The entity URI.
249
+     *
250
+     * @return WP_Post|null A WP_Post instance or null if not found.
251
+     * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
252
+     *
253
+     * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
254
+     * @since      3.2.0
255
+     *
256
+     */
257
+    public function get_entity_post_by_uri( $uri ) {
258
+
259
+        return $this->entity_uri_service->get_entity( $uri );
260
+    }
261
+
262
+    /**
263
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
264
+     * we check that the post we're saving is the current post.
265
+     *
266
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
267
+     *
268
+     * @since 3.2.0
269
+     *
270
+     * @param int $post_id Post ID.
271
+     * @param WP_Post $post Post object.
272
+     * @param bool $update Whether this is an existing post being updated or not.
273
+     */
274
+    public function save_post( $post_id, $post, $update ) {
275
+
276
+        // Avoid doing anything if post is autosave or a revision.
277
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
278
+            return;
279
+        }
280
+
281
+        // We're setting the alternative label that have been provided via the UI
282
+        // (in fact we're using $_REQUEST), while save_post may be also called
283
+        // programmatically by some other function: we need to check therefore if
284
+        // the $post_id in the save_post call matches the post id set in the request.
285
+        //
286
+        // If this is not the current post being saved or if it's not an entity, return.
287
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
288
+            return;
289
+        }
290
+
291
+        // Get the alt labels from the request (or empty array).
292
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
293
+
294
+        if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
295
+            // This is via classic editor, so set the alternative labels.
296
+            $this->set_alternative_labels( $post_id, $alt_labels );
297
+        }
298
+
299
+
300
+    }
301
+
302
+    /**
303
+     * Set the alternative labels.
304
+     *
305
+     * @param int $post_id The post id.
306
+     * @param array $alt_labels An array of labels.
307
+     *
308
+     * @since 3.2.0
309
+     *
310
+     */
311
+    public function set_alternative_labels( $post_id, $alt_labels ) {
312
+
313
+        // Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
314
+        // instead of post id.
315
+        if ( ! is_numeric( $post_id ) ) {
316
+            return;
317
+        }
318
+
319
+        // Force $alt_labels to be an array
320
+        if ( ! is_array( $alt_labels ) ) {
321
+            $alt_labels = array( $alt_labels );
322
+        }
323
+
324
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
325
+
326
+        // Delete all the existing alternate labels.
327
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
328
+
329
+        // Set the alternative labels.
330
+        foreach ( $alt_labels as $alt_label ) {
331
+            if ( ! empty( $alt_label ) ) {
332
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
333
+            }
334
+        }
335
+
336
+    }
337
+
338
+    /**
339
+     * Retrieve the alternate labels.
340
+     *
341
+     * @param int $post_id Post id.
342
+     *
343
+     * @return mixed An array  of alternative labels.
344
+     * @since 3.2.0
345
+     *
346
+     */
347
+    public function get_alternative_labels( $post_id ) {
348
+
349
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
350
+    }
351
+
352
+    /**
353
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
354
+     *
355
+     * @param int $post_id The entity {@link WP_Post} id.
356
+     *
357
+     * @return array An array with the entity title and labels.
358
+     * @since 3.12.0
359
+     *
360
+     */
361
+    public function get_labels( $post_id ) {
362
+
363
+        return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
364
+    }
365
+
366
+    /**
367
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
368
+     *
369
+     * @param WP_Post $post Post object.
370
+     *
371
+     * @since 3.2.0
372
+     *
373
+     */
374
+    public function edit_form_before_permalink( $post ) {
375
+
376
+        // If it's not an entity, return.
377
+        if ( ! $this->is_entity( $post->ID ) ) {
378
+            return;
379
+        }
380
+
381
+        // Print the input template.
382
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
383
+
384
+        // Print all the currently set alternative labels.
385
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
386
+
387
+            echo $this->get_alternative_label_input( $alt_label );
388
+
389
+        };
390
+
391
+        // Print the button.
392
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
393
+
394
+    }
395
+
396
+    /**
397
+     * Get the URI for the entity with the specified post id.
398
+     *
399
+     * @param int $post_id The entity post id.
400
+     *
401
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
402
+     * @since 3.6.0
403
+     *
404
+     */
405
+    public function get_uri( $post_id ) {
406
+
407
+        // If a null is given, nothing to do
408
+        if ( null == $post_id ) {
409
+            return null;
410
+        }
411
+
412
+        $dataset_uri = wl_configuration_get_redlink_dataset_uri();
413
+
414
+        // If the dataset uri is not properly configured, null is returned
415
+        if ( empty( $dataset_uri ) ) {
416
+            return null;
417
+        }
418
+
419
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
420
+
421
+        /*
422 422
 		 * Consider the URI invalid if it doesn't start with the dataset URI.
423 423
 		 *
424 424
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/996
425 425
 		 */
426
-		if ( 0 !== strpos( $uri, $dataset_uri ) ) {
427
-			$uri = null;
428
-		}
429
-
430
-		// Set the URI if it isn't set yet.
431
-		$post_status = get_post_status( $post_id );
432
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
433
-			$uri = wl_build_entity_uri( $post_id );
434
-			wl_set_entity_uri( $post_id, $uri );
435
-		}
436
-
437
-		return $uri;
438
-	}
439
-
440
-
441
-	/**
442
-	 * Get the alternative label input HTML code.
443
-	 *
444
-	 * @param string $value The input value.
445
-	 *
446
-	 * @return string The input HTML code.
447
-	 * @since 3.2.0
448
-	 *
449
-	 */
450
-	private function get_alternative_label_input( $value = '' ) {
451
-
452
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
453
-	}
454
-
455
-	/**
456
-	 * Get the number of entity posts published in this blog.
457
-	 *
458
-	 * @return int The number of published entity posts.
459
-	 * @since 3.6.0
460
-	 *
461
-	 */
462
-	public function count() {
463
-		global $wpdb;
464
-
465
-		// Try to get the count from the transient.
466
-		$count = get_transient( '_wl_entity_service__count' );
467
-		if ( false !== $count ) {
468
-			return $count;
469
-		}
470
-
471
-		// Query the count.
472
-		$count = $wpdb->get_var( $wpdb->prepare(
473
-			"SELECT COUNT( DISTINCT( tr.object_id ) )"
474
-			. " FROM {$wpdb->term_relationships} tr"
475
-			. " INNER JOIN {$wpdb->term_taxonomy} tt"
476
-			. "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
477
-			. " INNER JOIN {$wpdb->terms} t"
478
-			. "  ON t.term_id = tt.term_id AND t.name != %s",
479
-			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
480
-			'article'
481
-		) );
482
-
483
-		// Store the count in cache.
484
-		set_transient( '_wl_entity_service__count', $count, 900 );
485
-
486
-		return $count;
487
-	}
488
-
489
-	/**
490
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
491
-	 * call.
492
-	 *
493
-	 * @param array $args The arguments for a `get_posts` call.
494
-	 *
495
-	 * @return array The arguments for a `get_posts` call.
496
-	 * @since 3.15.0
497
-	 *
498
-	 */
499
-	public static function add_criterias( $args ) {
500
-
501
-		// Build an optimal tax-query.
502
-		$tax_query = array(
503
-			'relation' => 'AND',
504
-			array(
505
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
506
-				'operator' => 'EXISTS',
507
-			),
508
-			array(
509
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
510
-				'field'    => 'slug',
511
-				'terms'    => 'article',
512
-				'operator' => 'NOT IN',
513
-			),
514
-		);
515
-
516
-		return $args + array(
517
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
518
-				/*
426
+        if ( 0 !== strpos( $uri, $dataset_uri ) ) {
427
+            $uri = null;
428
+        }
429
+
430
+        // Set the URI if it isn't set yet.
431
+        $post_status = get_post_status( $post_id );
432
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
433
+            $uri = wl_build_entity_uri( $post_id );
434
+            wl_set_entity_uri( $post_id, $uri );
435
+        }
436
+
437
+        return $uri;
438
+    }
439
+
440
+
441
+    /**
442
+     * Get the alternative label input HTML code.
443
+     *
444
+     * @param string $value The input value.
445
+     *
446
+     * @return string The input HTML code.
447
+     * @since 3.2.0
448
+     *
449
+     */
450
+    private function get_alternative_label_input( $value = '' ) {
451
+
452
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
453
+    }
454
+
455
+    /**
456
+     * Get the number of entity posts published in this blog.
457
+     *
458
+     * @return int The number of published entity posts.
459
+     * @since 3.6.0
460
+     *
461
+     */
462
+    public function count() {
463
+        global $wpdb;
464
+
465
+        // Try to get the count from the transient.
466
+        $count = get_transient( '_wl_entity_service__count' );
467
+        if ( false !== $count ) {
468
+            return $count;
469
+        }
470
+
471
+        // Query the count.
472
+        $count = $wpdb->get_var( $wpdb->prepare(
473
+            "SELECT COUNT( DISTINCT( tr.object_id ) )"
474
+            . " FROM {$wpdb->term_relationships} tr"
475
+            . " INNER JOIN {$wpdb->term_taxonomy} tt"
476
+            . "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
477
+            . " INNER JOIN {$wpdb->terms} t"
478
+            . "  ON t.term_id = tt.term_id AND t.name != %s",
479
+            Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
480
+            'article'
481
+        ) );
482
+
483
+        // Store the count in cache.
484
+        set_transient( '_wl_entity_service__count', $count, 900 );
485
+
486
+        return $count;
487
+    }
488
+
489
+    /**
490
+     * Add the entity filtering criterias to the arguments for a `get_posts`
491
+     * call.
492
+     *
493
+     * @param array $args The arguments for a `get_posts` call.
494
+     *
495
+     * @return array The arguments for a `get_posts` call.
496
+     * @since 3.15.0
497
+     *
498
+     */
499
+    public static function add_criterias( $args ) {
500
+
501
+        // Build an optimal tax-query.
502
+        $tax_query = array(
503
+            'relation' => 'AND',
504
+            array(
505
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
506
+                'operator' => 'EXISTS',
507
+            ),
508
+            array(
509
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
510
+                'field'    => 'slug',
511
+                'terms'    => 'article',
512
+                'operator' => 'NOT IN',
513
+            ),
514
+        );
515
+
516
+        return $args + array(
517
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
518
+                /*
519 519
 				 * Ensure compatibility with Polylang.
520 520
 				 *
521 521
 				 * @see https://github.com/insideout10/wordlift-plugin/issues/855.
@@ -523,102 +523,102 @@  discard block
 block discarded – undo
523 523
 				 *
524 524
 				 * @since 3.19.5
525 525
 				 */
526
-				'lang'      => '',
527
-				'tax_query' => $tax_query,
528
-			);
529
-	}
530
-
531
-	/**
532
-	 * Create a new entity.
533
-	 *
534
-	 * @param string $name The entity name.
535
-	 * @param string $type_uri The entity's type URI.
536
-	 * @param null $logo The entity logo id (or NULL if none).
537
-	 * @param string $status The post status, by default 'publish'.
538
-	 *
539
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
540
-	 * @since 3.9.0
541
-	 *
542
-	 */
543
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
544
-
545
-		// Create an entity for the publisher.
546
-		$post_id = @wp_insert_post( array(
547
-			'post_type'    => self::TYPE_NAME,
548
-			'post_title'   => $name,
549
-			'post_status'  => $status,
550
-			'post_content' => '',
551
-		) );
552
-
553
-		// Return the error if any.
554
-		if ( is_wp_error( $post_id ) ) {
555
-			return $post_id;
556
-		}
557
-
558
-		// Set the entity logo.
559
-		if ( $logo && is_numeric( $logo ) ) {
560
-			set_post_thumbnail( $post_id, $logo );
561
-		}
562
-
563
-		// Set the entity type.
564
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
565
-
566
-		return $post_id;
567
-	}
568
-
569
-	/**
570
-	 * Get the entities related to the one with the specified id. By default only
571
-	 * published entities will be returned.
572
-	 *
573
-	 * @param int $id The post id.
574
-	 * @param string $post_status The target post status (default = publish).
575
-	 *
576
-	 * @return array An array of post ids.
577
-	 * @since 3.10.0
578
-	 *
579
-	 */
580
-	public function get_related_entities( $id, $post_status = 'publish' ) {
581
-
582
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
583
-	}
584
-
585
-	/**
586
-	 * Get the list of entities.
587
-	 *
588
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
589
-	 *
590
-	 * @return array An array of entity posts.
591
-	 * @since 3.12.2
592
-	 *
593
-	 */
594
-	public function get( $params = array() ) {
595
-
596
-		// Set the defaults.
597
-		$defaults = array( 'post_type' => 'entity' );
598
-
599
-		// Merge the defaults with the provided parameters.
600
-		$args = wp_parse_args( $params, $defaults );
601
-
602
-		// Call the `get_posts` function.
603
-		return get_posts( $args );
604
-	}
605
-
606
-	/**
607
-	 * The list of post type names which can be used for entities
608
-	 *
609
-	 * Criteria is that the post type is public. The list of valid post types
610
-	 * can be overridden with a filter.
611
-	 *
612
-	 * @return array Array containing the names of the valid post types.
613
-	 * @since 3.15.0
614
-	 *
615
-	 */
616
-	static function valid_entity_post_types() {
617
-
618
-		// Ignore builtins in the call to avoid getting attachments.
619
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
620
-
621
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
622
-	}
526
+                'lang'      => '',
527
+                'tax_query' => $tax_query,
528
+            );
529
+    }
530
+
531
+    /**
532
+     * Create a new entity.
533
+     *
534
+     * @param string $name The entity name.
535
+     * @param string $type_uri The entity's type URI.
536
+     * @param null $logo The entity logo id (or NULL if none).
537
+     * @param string $status The post status, by default 'publish'.
538
+     *
539
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
540
+     * @since 3.9.0
541
+     *
542
+     */
543
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
544
+
545
+        // Create an entity for the publisher.
546
+        $post_id = @wp_insert_post( array(
547
+            'post_type'    => self::TYPE_NAME,
548
+            'post_title'   => $name,
549
+            'post_status'  => $status,
550
+            'post_content' => '',
551
+        ) );
552
+
553
+        // Return the error if any.
554
+        if ( is_wp_error( $post_id ) ) {
555
+            return $post_id;
556
+        }
557
+
558
+        // Set the entity logo.
559
+        if ( $logo && is_numeric( $logo ) ) {
560
+            set_post_thumbnail( $post_id, $logo );
561
+        }
562
+
563
+        // Set the entity type.
564
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
565
+
566
+        return $post_id;
567
+    }
568
+
569
+    /**
570
+     * Get the entities related to the one with the specified id. By default only
571
+     * published entities will be returned.
572
+     *
573
+     * @param int $id The post id.
574
+     * @param string $post_status The target post status (default = publish).
575
+     *
576
+     * @return array An array of post ids.
577
+     * @since 3.10.0
578
+     *
579
+     */
580
+    public function get_related_entities( $id, $post_status = 'publish' ) {
581
+
582
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
583
+    }
584
+
585
+    /**
586
+     * Get the list of entities.
587
+     *
588
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
589
+     *
590
+     * @return array An array of entity posts.
591
+     * @since 3.12.2
592
+     *
593
+     */
594
+    public function get( $params = array() ) {
595
+
596
+        // Set the defaults.
597
+        $defaults = array( 'post_type' => 'entity' );
598
+
599
+        // Merge the defaults with the provided parameters.
600
+        $args = wp_parse_args( $params, $defaults );
601
+
602
+        // Call the `get_posts` function.
603
+        return get_posts( $args );
604
+    }
605
+
606
+    /**
607
+     * The list of post type names which can be used for entities
608
+     *
609
+     * Criteria is that the post type is public. The list of valid post types
610
+     * can be overridden with a filter.
611
+     *
612
+     * @return array Array containing the names of the valid post types.
613
+     * @since 3.15.0
614
+     *
615
+     */
616
+    static function valid_entity_post_types() {
617
+
618
+        // Ignore builtins in the call to avoid getting attachments.
619
+        $post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
620
+
621
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
622
+    }
623 623
 
624 624
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @since 3.2.0
98 98
 	 *
99 99
 	 */
100
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
100
+	public function __construct($ui_service, $relation_service, $entity_uri_service) {
101 101
 
102
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
102
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
103 103
 
104 104
 		$this->ui_service         = $ui_service;
105 105
 		$this->relation_service   = $relation_service;
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 	 * @since 3.1.0
131 131
 	 *
132 132
 	 */
133
-	public function is_entity( $post_id ) {
133
+	public function is_entity($post_id) {
134 134
 
135
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
135
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
136 136
 
137
-		if ( is_wp_error( $terms ) ) {
138
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
137
+		if (is_wp_error($terms)) {
138
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
139 139
 
140 140
 			return false;
141 141
 		}
142 142
 
143
-		if ( empty( $terms ) ) {
143
+		if (empty($terms)) {
144 144
 			return false;
145 145
 		}
146 146
 
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 		 *
152 152
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
153 153
 		 */
154
-		foreach ( $terms as $term ) {
155
-			if ( 'article' !== $term->slug ) {
154
+		foreach ($terms as $term) {
155
+			if ('article' !== $term->slug) {
156 156
 				return true;
157 157
 			}
158 158
 		}
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 	 * @since 3.5.0
173 173
 	 *
174 174
 	 */
175
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
175
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
176 176
 
177
-		if ( false === $this->is_entity( $post_id ) ) {
177
+		if (false === $this->is_entity($post_id)) {
178 178
 			return $default;
179 179
 		}
180 180
 
181 181
 		// Retrieve the entity type
182
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
183
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
182
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
183
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
184 184
 		// Retrieve classification boxes configuration
185
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
186
-		foreach ( $classification_boxes as $cb ) {
187
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
185
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
186
+		foreach ($classification_boxes as $cb) {
187
+			if (in_array($entity_type, $cb['registeredTypes'])) {
188 188
 				return $cb['id'];
189 189
 			}
190 190
 		}
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
201 201
 	 */
202
-	public function is_used( $post_id ) {
202
+	public function is_used($post_id) {
203 203
 
204
-		if ( false === $this->is_entity( $post_id ) ) {
204
+		if (false === $this->is_entity($post_id)) {
205 205
 			return null;
206 206
 		}
207 207
 		// Retrieve the post
208
-		$entity = get_post( $post_id );
208
+		$entity = get_post($post_id);
209 209
 
210 210
 		global $wpdb;
211 211
 		// Retrieve Wordlift relation instances table name
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 		);
219 219
 
220 220
 		// Perform the query
221
-		$relation_instances = (int) $wpdb->get_var( $stmt );
221
+		$relation_instances = (int) $wpdb->get_var($stmt);
222 222
 		// If there is at least one relation instance for the current entity, then it's used
223
-		if ( 0 < $relation_instances ) {
223
+		if (0 < $relation_instances) {
224 224
 			return true;
225 225
 		}
226 226
 
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 		$stmt = $wpdb->prepare(
229 229
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
230 230
 			$entity->ID,
231
-			wl_get_entity_uri( $entity->ID )
231
+			wl_get_entity_uri($entity->ID)
232 232
 		);
233 233
 		// Perform the query
234
-		$meta_instances = (int) $wpdb->get_var( $stmt );
234
+		$meta_instances = (int) $wpdb->get_var($stmt);
235 235
 
236 236
 		// If there is at least one meta that refers the current entity uri, then current entity is used
237
-		if ( 0 < $meta_instances ) {
237
+		if (0 < $meta_instances) {
238 238
 			return true;
239 239
 		}
240 240
 
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 	 * @since      3.2.0
255 255
 	 *
256 256
 	 */
257
-	public function get_entity_post_by_uri( $uri ) {
257
+	public function get_entity_post_by_uri($uri) {
258 258
 
259
-		return $this->entity_uri_service->get_entity( $uri );
259
+		return $this->entity_uri_service->get_entity($uri);
260 260
 	}
261 261
 
262 262
 	/**
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
 	 * @param WP_Post $post Post object.
272 272
 	 * @param bool $update Whether this is an existing post being updated or not.
273 273
 	 */
274
-	public function save_post( $post_id, $post, $update ) {
274
+	public function save_post($post_id, $post, $update) {
275 275
 
276 276
 		// Avoid doing anything if post is autosave or a revision.
277
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
277
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
278 278
 			return;
279 279
 		}
280 280
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
 		// the $post_id in the save_post call matches the post id set in the request.
285 285
 		//
286 286
 		// If this is not the current post being saved or if it's not an entity, return.
287
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
287
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
288 288
 			return;
289 289
 		}
290 290
 
291 291
 		// Get the alt labels from the request (or empty array).
292
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
292
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array();
293 293
 
294
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
294
+		if (( ! empty($_POST['content']) && ! empty($_POST['post_content'])) || isset($_REQUEST['wl_alternative_label'])) {
295 295
 			// This is via classic editor, so set the alternative labels.
296
-			$this->set_alternative_labels( $post_id, $alt_labels );
296
+			$this->set_alternative_labels($post_id, $alt_labels);
297 297
 		}
298 298
 
299 299
 
@@ -308,28 +308,28 @@  discard block
 block discarded – undo
308 308
 	 * @since 3.2.0
309 309
 	 *
310 310
 	 */
311
-	public function set_alternative_labels( $post_id, $alt_labels ) {
311
+	public function set_alternative_labels($post_id, $alt_labels) {
312 312
 
313 313
 		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
314 314
 		// instead of post id.
315
-		if ( ! is_numeric( $post_id ) ) {
315
+		if ( ! is_numeric($post_id)) {
316 316
 			return;
317 317
 		}
318 318
 
319 319
 		// Force $alt_labels to be an array
320
-		if ( ! is_array( $alt_labels ) ) {
321
-			$alt_labels = array( $alt_labels );
320
+		if ( ! is_array($alt_labels)) {
321
+			$alt_labels = array($alt_labels);
322 322
 		}
323 323
 
324
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
324
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
325 325
 
326 326
 		// Delete all the existing alternate labels.
327
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
327
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
328 328
 
329 329
 		// Set the alternative labels.
330
-		foreach ( $alt_labels as $alt_label ) {
331
-			if ( ! empty( $alt_label ) ) {
332
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
330
+		foreach ($alt_labels as $alt_label) {
331
+			if ( ! empty($alt_label)) {
332
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label);
333 333
 			}
334 334
 		}
335 335
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 	 * @since 3.2.0
345 345
 	 *
346 346
 	 */
347
-	public function get_alternative_labels( $post_id ) {
347
+	public function get_alternative_labels($post_id) {
348 348
 
349
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
349
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
350 350
 	}
351 351
 
352 352
 	/**
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
 	 * @since 3.12.0
359 359
 	 *
360 360
 	 */
361
-	public function get_labels( $post_id ) {
361
+	public function get_labels($post_id) {
362 362
 
363
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
363
+		return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
364 364
 	}
365 365
 
366 366
 	/**
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 	 * @since 3.2.0
372 372
 	 *
373 373
 	 */
374
-	public function edit_form_before_permalink( $post ) {
374
+	public function edit_form_before_permalink($post) {
375 375
 
376 376
 		// If it's not an entity, return.
377
-		if ( ! $this->is_entity( $post->ID ) ) {
377
+		if ( ! $this->is_entity($post->ID)) {
378 378
 			return;
379 379
 		}
380 380
 
381 381
 		// Print the input template.
382
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
382
+		$this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
383 383
 
384 384
 		// Print all the currently set alternative labels.
385
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
385
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
386 386
 
387
-			echo $this->get_alternative_label_input( $alt_label );
387
+			echo $this->get_alternative_label_input($alt_label);
388 388
 
389 389
 		};
390 390
 
391 391
 		// Print the button.
392
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
392
+		$this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
393 393
 
394 394
 	}
395 395
 
@@ -402,36 +402,36 @@  discard block
 block discarded – undo
402 402
 	 * @since 3.6.0
403 403
 	 *
404 404
 	 */
405
-	public function get_uri( $post_id ) {
405
+	public function get_uri($post_id) {
406 406
 
407 407
 		// If a null is given, nothing to do
408
-		if ( null == $post_id ) {
408
+		if (null == $post_id) {
409 409
 			return null;
410 410
 		}
411 411
 
412 412
 		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
413 413
 
414 414
 		// If the dataset uri is not properly configured, null is returned
415
-		if ( empty( $dataset_uri ) ) {
415
+		if (empty($dataset_uri)) {
416 416
 			return null;
417 417
 		}
418 418
 
419
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
419
+		$uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, true);
420 420
 
421 421
 		/*
422 422
 		 * Consider the URI invalid if it doesn't start with the dataset URI.
423 423
 		 *
424 424
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/996
425 425
 		 */
426
-		if ( 0 !== strpos( $uri, $dataset_uri ) ) {
426
+		if (0 !== strpos($uri, $dataset_uri)) {
427 427
 			$uri = null;
428 428
 		}
429 429
 
430 430
 		// Set the URI if it isn't set yet.
431
-		$post_status = get_post_status( $post_id );
432
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
433
-			$uri = wl_build_entity_uri( $post_id );
434
-			wl_set_entity_uri( $post_id, $uri );
431
+		$post_status = get_post_status($post_id);
432
+		if (empty($uri) && 'auto-draft' !== $post_status && 'revision' !== $post_status) {
433
+			$uri = wl_build_entity_uri($post_id);
434
+			wl_set_entity_uri($post_id, $uri);
435 435
 		}
436 436
 
437 437
 		return $uri;
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 	 * @since 3.2.0
448 448
 	 *
449 449
 	 */
450
-	private function get_alternative_label_input( $value = '' ) {
450
+	private function get_alternative_label_input($value = '') {
451 451
 
452
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
452
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
453 453
 	}
454 454
 
455 455
 	/**
@@ -463,13 +463,13 @@  discard block
 block discarded – undo
463 463
 		global $wpdb;
464 464
 
465 465
 		// Try to get the count from the transient.
466
-		$count = get_transient( '_wl_entity_service__count' );
467
-		if ( false !== $count ) {
466
+		$count = get_transient('_wl_entity_service__count');
467
+		if (false !== $count) {
468 468
 			return $count;
469 469
 		}
470 470
 
471 471
 		// Query the count.
472
-		$count = $wpdb->get_var( $wpdb->prepare(
472
+		$count = $wpdb->get_var($wpdb->prepare(
473 473
 			"SELECT COUNT( DISTINCT( tr.object_id ) )"
474 474
 			. " FROM {$wpdb->term_relationships} tr"
475 475
 			. " INNER JOIN {$wpdb->term_taxonomy} tt"
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 			. "  ON t.term_id = tt.term_id AND t.name != %s",
479 479
 			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
480 480
 			'article'
481
-		) );
481
+		));
482 482
 
483 483
 		// Store the count in cache.
484
-		set_transient( '_wl_entity_service__count', $count, 900 );
484
+		set_transient('_wl_entity_service__count', $count, 900);
485 485
 
486 486
 		return $count;
487 487
 	}
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	 * @since 3.15.0
497 497
 	 *
498 498
 	 */
499
-	public static function add_criterias( $args ) {
499
+	public static function add_criterias($args) {
500 500
 
501 501
 		// Build an optimal tax-query.
502 502
 		$tax_query = array(
@@ -540,28 +540,28 @@  discard block
 block discarded – undo
540 540
 	 * @since 3.9.0
541 541
 	 *
542 542
 	 */
543
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
543
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
544 544
 
545 545
 		// Create an entity for the publisher.
546
-		$post_id = @wp_insert_post( array(
546
+		$post_id = @wp_insert_post(array(
547 547
 			'post_type'    => self::TYPE_NAME,
548 548
 			'post_title'   => $name,
549 549
 			'post_status'  => $status,
550 550
 			'post_content' => '',
551
-		) );
551
+		));
552 552
 
553 553
 		// Return the error if any.
554
-		if ( is_wp_error( $post_id ) ) {
554
+		if (is_wp_error($post_id)) {
555 555
 			return $post_id;
556 556
 		}
557 557
 
558 558
 		// Set the entity logo.
559
-		if ( $logo && is_numeric( $logo ) ) {
560
-			set_post_thumbnail( $post_id, $logo );
559
+		if ($logo && is_numeric($logo)) {
560
+			set_post_thumbnail($post_id, $logo);
561 561
 		}
562 562
 
563 563
 		// Set the entity type.
564
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
564
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
565 565
 
566 566
 		return $post_id;
567 567
 	}
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 	 * @since 3.10.0
578 578
 	 *
579 579
 	 */
580
-	public function get_related_entities( $id, $post_status = 'publish' ) {
580
+	public function get_related_entities($id, $post_status = 'publish') {
581 581
 
582
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
582
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
583 583
 	}
584 584
 
585 585
 	/**
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 * @since 3.12.2
592 592
 	 *
593 593
 	 */
594
-	public function get( $params = array() ) {
594
+	public function get($params = array()) {
595 595
 
596 596
 		// Set the defaults.
597
-		$defaults = array( 'post_type' => 'entity' );
597
+		$defaults = array('post_type' => 'entity');
598 598
 
599 599
 		// Merge the defaults with the provided parameters.
600
-		$args = wp_parse_args( $params, $defaults );
600
+		$args = wp_parse_args($params, $defaults);
601 601
 
602 602
 		// Call the `get_posts` function.
603
-		return get_posts( $args );
603
+		return get_posts($args);
604 604
 	}
605 605
 
606 606
 	/**
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
 	static function valid_entity_post_types() {
617 617
 
618 618
 		// Ignore builtins in the call to avoid getting attachments.
619
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
619
+		$post_types = array('post', 'page', self::TYPE_NAME, 'product');
620 620
 
621
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
621
+		return apply_filters('wl_valid_entity_post_types', $post_types);
622 622
 	}
623 623
 
624 624
 }
Please login to merge, or discard this patch.
src/wordlift/mappings/class-acf-mappings.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -15,82 +15,82 @@
 block discarded – undo
15 15
  */
16 16
 class Acf_Mappings {
17 17
 
18
-	/**
19
-	 * Acf_Mappings constructor.
20
-	 *
21
-	 * Hooks `wl_mappings_field_types` to our own function to declare support for ACF fields.
22
-	 */
23
-	public function __construct() {
24
-
25
-		$that = $this;
26
-		add_action( 'plugins_loaded', function () use ( $that ) {
27
-			$that->add_acf_option_to_mappings_ui();
28
-		} );
29
-
30
-	}
31
-
32
-	private function add_acf_option_to_mappings_ui() {
33
-		// Bail out if ACF is not available.
34
-		if ( ! function_exists( 'acf_get_field_groups' ) ) {
35
-			return array();
36
-		}
37
-
38
-		add_filter( 'wl_mappings_field_types', array( $this, 'wl_mappings_field_types', ) );
39
-	}
40
-
41
-	/**
42
-	 * Hook to `wl_mappings_field_types` to declare support for ACF fields.
43
-	 *
44
-	 * @param array $field_types An array of field types.
45
-	 *
46
-	 * @return array The array with our ACF declaration.
47
-	 */
48
-	public function wl_mappings_field_types( $field_types ) {
49
-
50
-		$field_types[] = array(
51
-			'field_type' => 'acf',
52
-			'label'      => __( 'ACF', 'wordlift' ),
53
-			'value'      => self::get_acf_options(),
54
-		);
55
-
56
-		return $field_types;
57
-	}
58
-
59
-	/**
60
-	 * Returns array of acf options.
61
-	 *
62
-	 * The array is composed by all the ACF groups and their fields hierarchy.
63
-	 *
64
-	 * @return array ACF options array.
65
-	 */
66
-	private static function get_acf_options() {
67
-
68
-		$acf_options = array();
69
-
70
-		// Get all the ACF field groups.
71
-		$field_groups = acf_get_field_groups();
72
-
73
-		foreach ( $field_groups as $field_group ) {
74
-			$group_name = $field_group['title'];
75
-			$group_key  = $field_group['key'];
76
-
77
-			$group_fields = acf_get_fields( $group_key );
78
-
79
-			$group_options = array();
80
-			foreach ( $group_fields as $group_field ) {
81
-				$group_options[] = array(
82
-					'label' => $group_field['label'],
83
-					'value' => $group_field['key'],
84
-				);
85
-			}
86
-
87
-			$acf_options[] = array(
88
-				'group_name'    => $group_name,
89
-				'group_options' => $group_options,
90
-			);
91
-		}
92
-
93
-		return $acf_options;
94
-	}
18
+    /**
19
+     * Acf_Mappings constructor.
20
+     *
21
+     * Hooks `wl_mappings_field_types` to our own function to declare support for ACF fields.
22
+     */
23
+    public function __construct() {
24
+
25
+        $that = $this;
26
+        add_action( 'plugins_loaded', function () use ( $that ) {
27
+            $that->add_acf_option_to_mappings_ui();
28
+        } );
29
+
30
+    }
31
+
32
+    private function add_acf_option_to_mappings_ui() {
33
+        // Bail out if ACF is not available.
34
+        if ( ! function_exists( 'acf_get_field_groups' ) ) {
35
+            return array();
36
+        }
37
+
38
+        add_filter( 'wl_mappings_field_types', array( $this, 'wl_mappings_field_types', ) );
39
+    }
40
+
41
+    /**
42
+     * Hook to `wl_mappings_field_types` to declare support for ACF fields.
43
+     *
44
+     * @param array $field_types An array of field types.
45
+     *
46
+     * @return array The array with our ACF declaration.
47
+     */
48
+    public function wl_mappings_field_types( $field_types ) {
49
+
50
+        $field_types[] = array(
51
+            'field_type' => 'acf',
52
+            'label'      => __( 'ACF', 'wordlift' ),
53
+            'value'      => self::get_acf_options(),
54
+        );
55
+
56
+        return $field_types;
57
+    }
58
+
59
+    /**
60
+     * Returns array of acf options.
61
+     *
62
+     * The array is composed by all the ACF groups and their fields hierarchy.
63
+     *
64
+     * @return array ACF options array.
65
+     */
66
+    private static function get_acf_options() {
67
+
68
+        $acf_options = array();
69
+
70
+        // Get all the ACF field groups.
71
+        $field_groups = acf_get_field_groups();
72
+
73
+        foreach ( $field_groups as $field_group ) {
74
+            $group_name = $field_group['title'];
75
+            $group_key  = $field_group['key'];
76
+
77
+            $group_fields = acf_get_fields( $group_key );
78
+
79
+            $group_options = array();
80
+            foreach ( $group_fields as $group_field ) {
81
+                $group_options[] = array(
82
+                    'label' => $group_field['label'],
83
+                    'value' => $group_field['key'],
84
+                );
85
+            }
86
+
87
+            $acf_options[] = array(
88
+                'group_name'    => $group_name,
89
+                'group_options' => $group_options,
90
+            );
91
+        }
92
+
93
+        return $acf_options;
94
+    }
95 95
 
96 96
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	public function __construct() {
24 24
 
25 25
 		$that = $this;
26
-		add_action( 'plugins_loaded', function () use ( $that ) {
26
+		add_action('plugins_loaded', function() use ($that) {
27 27
 			$that->add_acf_option_to_mappings_ui();
28 28
 		} );
29 29
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
 	private function add_acf_option_to_mappings_ui() {
33 33
 		// Bail out if ACF is not available.
34
-		if ( ! function_exists( 'acf_get_field_groups' ) ) {
34
+		if ( ! function_exists('acf_get_field_groups')) {
35 35
 			return array();
36 36
 		}
37 37
 
38
-		add_filter( 'wl_mappings_field_types', array( $this, 'wl_mappings_field_types', ) );
38
+		add_filter('wl_mappings_field_types', array($this, 'wl_mappings_field_types',));
39 39
 	}
40 40
 
41 41
 	/**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return array The array with our ACF declaration.
47 47
 	 */
48
-	public function wl_mappings_field_types( $field_types ) {
48
+	public function wl_mappings_field_types($field_types) {
49 49
 
50 50
 		$field_types[] = array(
51 51
 			'field_type' => 'acf',
52
-			'label'      => __( 'ACF', 'wordlift' ),
52
+			'label'      => __('ACF', 'wordlift'),
53 53
 			'value'      => self::get_acf_options(),
54 54
 		);
55 55
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 		// Get all the ACF field groups.
71 71
 		$field_groups = acf_get_field_groups();
72 72
 
73
-		foreach ( $field_groups as $field_group ) {
73
+		foreach ($field_groups as $field_group) {
74 74
 			$group_name = $field_group['title'];
75 75
 			$group_key  = $field_group['key'];
76 76
 
77
-			$group_fields = acf_get_fields( $group_key );
77
+			$group_fields = acf_get_fields($group_key);
78 78
 
79 79
 			$group_options = array();
80
-			foreach ( $group_fields as $group_field ) {
80
+			foreach ($group_fields as $group_field) {
81 81
 				$group_options[] = array(
82 82
 					'label' => $group_field['label'],
83 83
 					'value' => $group_field['key'],
Please login to merge, or discard this patch.
src/wordlift/jsonld/class-jsonld-endpoint.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -22,160 +22,160 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Jsonld_Endpoint {
24 24
 
25
-	/**
26
-	 * The {@link Wordlift_Jsonld_Service} instance.
27
-	 *
28
-	 * @var Wordlift_Jsonld_Service The {@link Wordlift_Jsonld_Service} instance.
29
-	 */
30
-	private $jsonld_service;
31
-	/**
32
-	 * @var \Wordlift_Entity_Uri_Service
33
-	 */
34
-	private $entity_uri_service;
35
-
36
-	/**
37
-	 * Jsonld_Endpoint constructor.
38
-	 *
39
-	 * @param \Wordlift_Jsonld_Service $jsonld_service
40
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service
41
-	 */
42
-	public function __construct( $jsonld_service, $entity_uri_service ) {
43
-
44
-		$this->jsonld_service     = $jsonld_service;
45
-		$this->entity_uri_service = $entity_uri_service;
46
-
47
-		// PHP 5.3 compatibility.
48
-		$that = $this;
49
-		add_action( 'rest_api_init', function () use ( $that ) {
50
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<id>\d+)', array(
51
-				'methods'  => 'GET',
52
-				'callback' => array( $that, 'jsonld_using_post_id' ),
53
-				'args'     => array(
54
-					'id' => array(
55
-						'validate_callback' => function ( $param, $request, $key ) {
56
-							return is_numeric( $param );
57
-						},
58
-						'sanitize_callback' => 'absint',
59
-					),
60
-				)
61
-			) );
62
-
63
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/http/(?P<item_id>.*)', array(
64
-				'methods'  => 'GET',
65
-				'callback' => array( $that, 'jsonld_using_item_id' ),
66
-			) );
67
-
68
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/post-meta/(?P<meta_key>[^/]+)', array(
69
-				'methods'  => 'GET',
70
-				'callback' => array( $that, 'jsonld_using_post_meta' ),
71
-			) );
72
-
73
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<post_type>.*)/(?P<post_name>.*)', array(
74
-				'methods'  => 'GET',
75
-				'callback' => array( $that, 'jsonld_using_get_page_by_path' ),
76
-			) );
77
-
78
-		} );
79
-
80
-	}
81
-
82
-	/**
83
-	 * Callback for the JSON-LD request.
84
-	 *
85
-	 * @param array $request {
86
-	 *  The request array.
87
-	 *
88
-	 * @type int $id The post id.
89
-	 * }
90
-	 *
91
-	 * @return WP_REST_Response
92
-	 * @throws \Exception
93
-	 */
94
-	public function jsonld_using_post_id( $request ) {
95
-
96
-		$post_id     = $request['id'];
97
-		$is_homepage = ( 0 === $post_id );
98
-
99
-		// Send the generated JSON-LD.
100
-		$data     = $this->jsonld_service->get_jsonld( $is_homepage, $post_id );
101
-		$response = new WP_REST_Response( $data );
102
-
103
-		$cache_in_seconds = 86400;
104
-		$date_timezone    = new DateTimeZone( 'GMT' );
105
-		$date_now         = new DateTime( 'now', $date_timezone );
106
-		$date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
107
-		$expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
108
-
109
-		$response->set_headers( array(
110
-			'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
111
-			'Cache-Control' => "max-age=$cache_in_seconds",
112
-			'Expires'       => $expires
113
-		) );
114
-
115
-		return $response;
116
-	}
117
-
118
-	/**
119
-	 * Provide a JSON-LD given the itemId.
120
-	 *
121
-	 * @param array $request {
122
-	 *  The request array.
123
-	 *
124
-	 * @type string $item_id The entity item id.
125
-	 * }
126
-	 *
127
-	 * @return WP_REST_Response
128
-	 * @throws \Exception
129
-	 */
130
-	public function jsonld_using_item_id( $request ) {
131
-
132
-		$item_id = 'http://' . $request['item_id'];
133
-		$post    = $this->entity_uri_service->get_entity( $item_id );
134
-
135
-		if ( ! is_a( $post, 'WP_Post' ) ) {
136
-			return new WP_REST_Response( esc_html( "$item_id not found." ), 404, array( 'Content-Type' => 'text/html' ) );
137
-		}
138
-
139
-		return $this->jsonld_using_post_id( array( 'id' => $post->ID, ) );
140
-	}
141
-
142
-	public function jsonld_using_get_page_by_path( $request ) {
143
-
144
-		$post_name = $request['post_name'];
145
-		$post_type = $request['post_type'];
146
-
147
-		global $wpdb;
148
-
149
-		$sql = "
25
+    /**
26
+     * The {@link Wordlift_Jsonld_Service} instance.
27
+     *
28
+     * @var Wordlift_Jsonld_Service The {@link Wordlift_Jsonld_Service} instance.
29
+     */
30
+    private $jsonld_service;
31
+    /**
32
+     * @var \Wordlift_Entity_Uri_Service
33
+     */
34
+    private $entity_uri_service;
35
+
36
+    /**
37
+     * Jsonld_Endpoint constructor.
38
+     *
39
+     * @param \Wordlift_Jsonld_Service $jsonld_service
40
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service
41
+     */
42
+    public function __construct( $jsonld_service, $entity_uri_service ) {
43
+
44
+        $this->jsonld_service     = $jsonld_service;
45
+        $this->entity_uri_service = $entity_uri_service;
46
+
47
+        // PHP 5.3 compatibility.
48
+        $that = $this;
49
+        add_action( 'rest_api_init', function () use ( $that ) {
50
+            register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<id>\d+)', array(
51
+                'methods'  => 'GET',
52
+                'callback' => array( $that, 'jsonld_using_post_id' ),
53
+                'args'     => array(
54
+                    'id' => array(
55
+                        'validate_callback' => function ( $param, $request, $key ) {
56
+                            return is_numeric( $param );
57
+                        },
58
+                        'sanitize_callback' => 'absint',
59
+                    ),
60
+                )
61
+            ) );
62
+
63
+            register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/http/(?P<item_id>.*)', array(
64
+                'methods'  => 'GET',
65
+                'callback' => array( $that, 'jsonld_using_item_id' ),
66
+            ) );
67
+
68
+            register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/post-meta/(?P<meta_key>[^/]+)', array(
69
+                'methods'  => 'GET',
70
+                'callback' => array( $that, 'jsonld_using_post_meta' ),
71
+            ) );
72
+
73
+            register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<post_type>.*)/(?P<post_name>.*)', array(
74
+                'methods'  => 'GET',
75
+                'callback' => array( $that, 'jsonld_using_get_page_by_path' ),
76
+            ) );
77
+
78
+        } );
79
+
80
+    }
81
+
82
+    /**
83
+     * Callback for the JSON-LD request.
84
+     *
85
+     * @param array $request {
86
+     *  The request array.
87
+     *
88
+     * @type int $id The post id.
89
+     * }
90
+     *
91
+     * @return WP_REST_Response
92
+     * @throws \Exception
93
+     */
94
+    public function jsonld_using_post_id( $request ) {
95
+
96
+        $post_id     = $request['id'];
97
+        $is_homepage = ( 0 === $post_id );
98
+
99
+        // Send the generated JSON-LD.
100
+        $data     = $this->jsonld_service->get_jsonld( $is_homepage, $post_id );
101
+        $response = new WP_REST_Response( $data );
102
+
103
+        $cache_in_seconds = 86400;
104
+        $date_timezone    = new DateTimeZone( 'GMT' );
105
+        $date_now         = new DateTime( 'now', $date_timezone );
106
+        $date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
107
+        $expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
108
+
109
+        $response->set_headers( array(
110
+            'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
111
+            'Cache-Control' => "max-age=$cache_in_seconds",
112
+            'Expires'       => $expires
113
+        ) );
114
+
115
+        return $response;
116
+    }
117
+
118
+    /**
119
+     * Provide a JSON-LD given the itemId.
120
+     *
121
+     * @param array $request {
122
+     *  The request array.
123
+     *
124
+     * @type string $item_id The entity item id.
125
+     * }
126
+     *
127
+     * @return WP_REST_Response
128
+     * @throws \Exception
129
+     */
130
+    public function jsonld_using_item_id( $request ) {
131
+
132
+        $item_id = 'http://' . $request['item_id'];
133
+        $post    = $this->entity_uri_service->get_entity( $item_id );
134
+
135
+        if ( ! is_a( $post, 'WP_Post' ) ) {
136
+            return new WP_REST_Response( esc_html( "$item_id not found." ), 404, array( 'Content-Type' => 'text/html' ) );
137
+        }
138
+
139
+        return $this->jsonld_using_post_id( array( 'id' => $post->ID, ) );
140
+    }
141
+
142
+    public function jsonld_using_get_page_by_path( $request ) {
143
+
144
+        $post_name = $request['post_name'];
145
+        $post_type = $request['post_type'];
146
+
147
+        global $wpdb;
148
+
149
+        $sql = "
150 150
 			SELECT ID
151 151
 			FROM $wpdb->posts
152 152
 			WHERE post_name = %s
153 153
 			 AND post_type = %s
154 154
 		";
155 155
 
156
-		$post_id = $wpdb->get_var( $wpdb->prepare( $sql, $post_name, $post_type ) );
156
+        $post_id = $wpdb->get_var( $wpdb->prepare( $sql, $post_name, $post_type ) );
157 157
 
158
-		if ( is_null( $post_id ) ) {
159
-			return new WP_REST_Response( esc_html( "$post_name of type $post_type not found." ), 404, array( 'Content-Type' => 'text/html' ) );
160
-		}
158
+        if ( is_null( $post_id ) ) {
159
+            return new WP_REST_Response( esc_html( "$post_name of type $post_type not found." ), 404, array( 'Content-Type' => 'text/html' ) );
160
+        }
161 161
 
162
-		return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
163
-	}
162
+        return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
163
+    }
164 164
 
165
-	/**
166
-	 * @param WP_REST_Request $request
167
-	 *
168
-	 * @return WP_REST_Response
169
-	 * @throws \Exception
170
-	 */
171
-	public function jsonld_using_post_meta( $request ) {
165
+    /**
166
+     * @param WP_REST_Request $request
167
+     *
168
+     * @return WP_REST_Response
169
+     * @throws \Exception
170
+     */
171
+    public function jsonld_using_post_meta( $request ) {
172 172
 
173
-		$meta_key   = $request['meta_key'];
174
-		$meta_value = current( $request->get_query_params( 'meta_value' ) );
173
+        $meta_key   = $request['meta_key'];
174
+        $meta_value = current( $request->get_query_params( 'meta_value' ) );
175 175
 
176
-		global $wpdb;
176
+        global $wpdb;
177 177
 
178
-		$sql = "
178
+        $sql = "
179 179
 			SELECT post_id AS ID
180 180
 			FROM $wpdb->postmeta
181 181
 			WHERE meta_key = %s
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			LIMIT 1
184 184
 		";
185 185
 
186
-		$post_id = $wpdb->get_var( $wpdb->prepare( $sql, $meta_key, $meta_value ) );
186
+        $post_id = $wpdb->get_var( $wpdb->prepare( $sql, $meta_key, $meta_value ) );
187 187
 
188
-		if ( is_null( $post_id ) ) {
189
-			return new WP_REST_Response( esc_html( "Post with meta key $meta_key and value $meta_value not found." ), 404, array( 'Content-Type' => 'text/html' ) );
190
-		}
188
+        if ( is_null( $post_id ) ) {
189
+            return new WP_REST_Response( esc_html( "Post with meta key $meta_key and value $meta_value not found." ), 404, array( 'Content-Type' => 'text/html' ) );
190
+        }
191 191
 
192
-		return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
193
-	}
192
+        return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
193
+    }
194 194
 
195 195
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -39,41 +39,41 @@  discard block
 block discarded – undo
39 39
 	 * @param \Wordlift_Jsonld_Service $jsonld_service
40 40
 	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service
41 41
 	 */
42
-	public function __construct( $jsonld_service, $entity_uri_service ) {
42
+	public function __construct($jsonld_service, $entity_uri_service) {
43 43
 
44 44
 		$this->jsonld_service     = $jsonld_service;
45 45
 		$this->entity_uri_service = $entity_uri_service;
46 46
 
47 47
 		// PHP 5.3 compatibility.
48 48
 		$that = $this;
49
-		add_action( 'rest_api_init', function () use ( $that ) {
50
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<id>\d+)', array(
49
+		add_action('rest_api_init', function() use ($that) {
50
+			register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<id>\d+)', array(
51 51
 				'methods'  => 'GET',
52
-				'callback' => array( $that, 'jsonld_using_post_id' ),
52
+				'callback' => array($that, 'jsonld_using_post_id'),
53 53
 				'args'     => array(
54 54
 					'id' => array(
55
-						'validate_callback' => function ( $param, $request, $key ) {
56
-							return is_numeric( $param );
55
+						'validate_callback' => function($param, $request, $key) {
56
+							return is_numeric($param);
57 57
 						},
58 58
 						'sanitize_callback' => 'absint',
59 59
 					),
60 60
 				)
61
-			) );
61
+			));
62 62
 
63
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/http/(?P<item_id>.*)', array(
63
+			register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/http/(?P<item_id>.*)', array(
64 64
 				'methods'  => 'GET',
65
-				'callback' => array( $that, 'jsonld_using_item_id' ),
66
-			) );
65
+				'callback' => array($that, 'jsonld_using_item_id'),
66
+			));
67 67
 
68
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/post-meta/(?P<meta_key>[^/]+)', array(
68
+			register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/post-meta/(?P<meta_key>[^/]+)', array(
69 69
 				'methods'  => 'GET',
70
-				'callback' => array( $that, 'jsonld_using_post_meta' ),
71
-			) );
70
+				'callback' => array($that, 'jsonld_using_post_meta'),
71
+			));
72 72
 
73
-			register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<post_type>.*)/(?P<post_name>.*)', array(
73
+			register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld/(?P<post_type>.*)/(?P<post_name>.*)', array(
74 74
 				'methods'  => 'GET',
75
-				'callback' => array( $that, 'jsonld_using_get_page_by_path' ),
76
-			) );
75
+				'callback' => array($that, 'jsonld_using_get_page_by_path'),
76
+			));
77 77
 
78 78
 		} );
79 79
 
@@ -91,26 +91,26 @@  discard block
 block discarded – undo
91 91
 	 * @return WP_REST_Response
92 92
 	 * @throws \Exception
93 93
 	 */
94
-	public function jsonld_using_post_id( $request ) {
94
+	public function jsonld_using_post_id($request) {
95 95
 
96 96
 		$post_id     = $request['id'];
97
-		$is_homepage = ( 0 === $post_id );
97
+		$is_homepage = (0 === $post_id);
98 98
 
99 99
 		// Send the generated JSON-LD.
100
-		$data     = $this->jsonld_service->get_jsonld( $is_homepage, $post_id );
101
-		$response = new WP_REST_Response( $data );
100
+		$data     = $this->jsonld_service->get_jsonld($is_homepage, $post_id);
101
+		$response = new WP_REST_Response($data);
102 102
 
103 103
 		$cache_in_seconds = 86400;
104
-		$date_timezone    = new DateTimeZone( 'GMT' );
105
-		$date_now         = new DateTime( 'now', $date_timezone );
106
-		$date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
107
-		$expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
104
+		$date_timezone    = new DateTimeZone('GMT');
105
+		$date_now         = new DateTime('now', $date_timezone);
106
+		$date_interval    = new DateInterval("PT{$cache_in_seconds}S");
107
+		$expires          = $date_now->add($date_interval)->format('D, j M Y H:i:s T');
108 108
 
109
-		$response->set_headers( array(
110
-			'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
109
+		$response->set_headers(array(
110
+			'Content-Type'  => 'application/ld+json; charset='.get_option('blog_charset'),
111 111
 			'Cache-Control' => "max-age=$cache_in_seconds",
112 112
 			'Expires'       => $expires
113
-		) );
113
+		));
114 114
 
115 115
 		return $response;
116 116
 	}
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
 	 * @return WP_REST_Response
128 128
 	 * @throws \Exception
129 129
 	 */
130
-	public function jsonld_using_item_id( $request ) {
130
+	public function jsonld_using_item_id($request) {
131 131
 
132
-		$item_id = 'http://' . $request['item_id'];
133
-		$post    = $this->entity_uri_service->get_entity( $item_id );
132
+		$item_id = 'http://'.$request['item_id'];
133
+		$post    = $this->entity_uri_service->get_entity($item_id);
134 134
 
135
-		if ( ! is_a( $post, 'WP_Post' ) ) {
136
-			return new WP_REST_Response( esc_html( "$item_id not found." ), 404, array( 'Content-Type' => 'text/html' ) );
135
+		if ( ! is_a($post, 'WP_Post')) {
136
+			return new WP_REST_Response(esc_html("$item_id not found."), 404, array('Content-Type' => 'text/html'));
137 137
 		}
138 138
 
139
-		return $this->jsonld_using_post_id( array( 'id' => $post->ID, ) );
139
+		return $this->jsonld_using_post_id(array('id' => $post->ID,));
140 140
 	}
141 141
 
142
-	public function jsonld_using_get_page_by_path( $request ) {
142
+	public function jsonld_using_get_page_by_path($request) {
143 143
 
144 144
 		$post_name = $request['post_name'];
145 145
 		$post_type = $request['post_type'];
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 			 AND post_type = %s
154 154
 		";
155 155
 
156
-		$post_id = $wpdb->get_var( $wpdb->prepare( $sql, $post_name, $post_type ) );
156
+		$post_id = $wpdb->get_var($wpdb->prepare($sql, $post_name, $post_type));
157 157
 
158
-		if ( is_null( $post_id ) ) {
159
-			return new WP_REST_Response( esc_html( "$post_name of type $post_type not found." ), 404, array( 'Content-Type' => 'text/html' ) );
158
+		if (is_null($post_id)) {
159
+			return new WP_REST_Response(esc_html("$post_name of type $post_type not found."), 404, array('Content-Type' => 'text/html'));
160 160
 		}
161 161
 
162
-		return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
162
+		return $this->jsonld_using_post_id(array('id' => $post_id,));
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 * @return WP_REST_Response
169 169
 	 * @throws \Exception
170 170
 	 */
171
-	public function jsonld_using_post_meta( $request ) {
171
+	public function jsonld_using_post_meta($request) {
172 172
 
173 173
 		$meta_key   = $request['meta_key'];
174
-		$meta_value = current( $request->get_query_params( 'meta_value' ) );
174
+		$meta_value = current($request->get_query_params('meta_value'));
175 175
 
176 176
 		global $wpdb;
177 177
 
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			LIMIT 1
184 184
 		";
185 185
 
186
-		$post_id = $wpdb->get_var( $wpdb->prepare( $sql, $meta_key, $meta_value ) );
186
+		$post_id = $wpdb->get_var($wpdb->prepare($sql, $meta_key, $meta_value));
187 187
 
188
-		if ( is_null( $post_id ) ) {
189
-			return new WP_REST_Response( esc_html( "Post with meta key $meta_key and value $meta_value not found." ), 404, array( 'Content-Type' => 'text/html' ) );
188
+		if (is_null($post_id)) {
189
+			return new WP_REST_Response(esc_html("Post with meta key $meta_key and value $meta_value not found."), 404, array('Content-Type' => 'text/html'));
190 190
 		}
191 191
 
192
-		return $this->jsonld_using_post_id( array( 'id' => $post_id, ) );
192
+		return $this->jsonld_using_post_id(array('id' => $post_id,));
193 193
 	}
194 194
 
195 195
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 1 patch
Indentation   +1606 added lines, -1606 removed lines patch added patch discarded remove patch
@@ -48,1495 +48,1495 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class Wordlift {
50 50
 
51
-	//<editor-fold desc="## FIELDS">
52
-
53
-	/**
54
-	 * The loader that's responsible for maintaining and registering all hooks that power
55
-	 * the plugin.
56
-	 *
57
-	 * @since    1.0.0
58
-	 * @access   protected
59
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
60
-	 */
61
-	protected $loader;
62
-
63
-	/**
64
-	 * The unique identifier of this plugin.
65
-	 *
66
-	 * @since    1.0.0
67
-	 * @access   protected
68
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
69
-	 */
70
-	protected $plugin_name;
71
-
72
-	/**
73
-	 * The current version of the plugin.
74
-	 *
75
-	 * @since    1.0.0
76
-	 * @access   protected
77
-	 * @var      string $version The current version of the plugin.
78
-	 */
79
-	protected $version;
80
-
81
-	/**
82
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
83
-	 *
84
-	 * @since  3.12.0
85
-	 * @access protected
86
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
87
-	 */
88
-	protected $tinymce_adapter;
89
-
90
-	/**
91
-	 * The Thumbnail service.
92
-	 *
93
-	 * @since  3.1.5
94
-	 * @access private
95
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
96
-	 */
97
-	private $thumbnail_service;
98
-
99
-	/**
100
-	 * The UI service.
101
-	 *
102
-	 * @since  3.2.0
103
-	 * @access private
104
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
105
-	 */
106
-	private $ui_service;
107
-
108
-	/**
109
-	 * The Schema service.
110
-	 *
111
-	 * @since  3.3.0
112
-	 * @access protected
113
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
114
-	 */
115
-	protected $schema_service;
116
-
117
-	/**
118
-	 * The Entity service.
119
-	 *
120
-	 * @since  3.1.0
121
-	 * @access protected
122
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
123
-	 */
124
-	protected $entity_service;
125
-
126
-	/**
127
-	 * The Topic Taxonomy service.
128
-	 *
129
-	 * @since  3.5.0
130
-	 * @access private
131
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
132
-	 */
133
-	private $topic_taxonomy_service;
134
-
135
-	/**
136
-	 * The Entity Types Taxonomy service.
137
-	 *
138
-	 * @since  3.18.0
139
-	 * @access private
140
-	 * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
141
-	 */
142
-	private $entity_types_taxonomy_service;
143
-
144
-	/**
145
-	 * The User service.
146
-	 *
147
-	 * @since  3.1.7
148
-	 * @access protected
149
-	 * @var \Wordlift_User_Service $user_service The User service.
150
-	 */
151
-	protected $user_service;
152
-
153
-	/**
154
-	 * The Timeline service.
155
-	 *
156
-	 * @since  3.1.0
157
-	 * @access private
158
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
159
-	 */
160
-	private $timeline_service;
161
-
162
-	/**
163
-	 * The Redirect service.
164
-	 *
165
-	 * @since  3.2.0
166
-	 * @access private
167
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
168
-	 */
169
-	private $redirect_service;
170
-
171
-	/**
172
-	 * The Notice service.
173
-	 *
174
-	 * @since  3.3.0
175
-	 * @access private
176
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
177
-	 */
178
-	private $notice_service;
179
-
180
-	/**
181
-	 * The Entity list customization.
182
-	 *
183
-	 * @since  3.3.0
184
-	 * @access protected
185
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
186
-	 */
187
-	protected $entity_list_service;
188
-
189
-	/**
190
-	 * The Entity Types Taxonomy Walker.
191
-	 *
192
-	 * @since  3.1.0
193
-	 * @access private
194
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
195
-	 */
196
-	private $entity_types_taxonomy_walker;
197
-
198
-	/**
199
-	 * The ShareThis service.
200
-	 *
201
-	 * @since  3.2.0
202
-	 * @access private
203
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
204
-	 */
205
-	private $sharethis_service;
206
-
207
-	/**
208
-	 * The PrimaShop adapter.
209
-	 *
210
-	 * @since  3.2.3
211
-	 * @access private
212
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
213
-	 */
214
-	private $primashop_adapter;
215
-
216
-	/**
217
-	 * The WordLift Dashboard adapter.
218
-	 *
219
-	 * @since  3.4.0
220
-	 * @access private
221
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
222
-	 */
223
-	private $dashboard_service;
224
-
225
-	/**
226
-	 * The entity type service.
227
-	 *
228
-	 * @since  3.6.0
229
-	 * @access private
230
-	 * @var \Wordlift_Entity_Post_Type_Service
231
-	 */
232
-	private $entity_post_type_service;
233
-
234
-	/**
235
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
236
-	 *
237
-	 * @since  3.6.0
238
-	 * @access private
239
-	 * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
240
-	 */
241
-	private $entity_link_service;
242
-
243
-	/**
244
-	 * A {@link Wordlift_Sparql_Service} instance.
245
-	 *
246
-	 * @since    3.6.0
247
-	 * @access   protected
248
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
249
-	 */
250
-	protected $sparql_service;
251
-
252
-	/**
253
-	 * A {@link Wordlift_Import_Service} instance.
254
-	 *
255
-	 * @since  3.6.0
256
-	 * @access private
257
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
258
-	 */
259
-	private $import_service;
260
-
261
-	/**
262
-	 * A {@link Wordlift_Rebuild_Service} instance.
263
-	 *
264
-	 * @since  3.6.0
265
-	 * @access private
266
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
267
-	 */
268
-	private $rebuild_service;
269
-
270
-	/**
271
-	 * A {@link Wordlift_Jsonld_Service} instance.
272
-	 *
273
-	 * @since  3.7.0
274
-	 * @access protected
275
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
276
-	 */
277
-	protected $jsonld_service;
278
-
279
-	/**
280
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
281
-	 *
282
-	 * @since  3.14.0
283
-	 * @access protected
284
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
285
-	 */
286
-	protected $jsonld_website_converter;
287
-
288
-	/**
289
-	 * A {@link Wordlift_Property_Factory} instance.
290
-	 *
291
-	 * @since  3.7.0
292
-	 * @access private
293
-	 * @var \Wordlift_Property_Factory $property_factory
294
-	 */
295
-	private $property_factory;
296
-
297
-	/**
298
-	 * The 'Download Your Data' page.
299
-	 *
300
-	 * @since  3.6.0
301
-	 * @access private
302
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
303
-	 */
304
-	private $download_your_data_page;
305
-
306
-	/**
307
-	 * The 'WordLift Settings' page.
308
-	 *
309
-	 * @since  3.11.0
310
-	 * @access protected
311
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
312
-	 */
313
-	protected $settings_page;
314
-
315
-	/**
316
-	 * The install wizard page.
317
-	 *
318
-	 * @since  3.9.0
319
-	 * @access private
320
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
321
-	 */
322
-	private $admin_setup;
323
-
324
-	/**
325
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
326
-	 * linking of entities to their pages.
327
-	 *
328
-	 * @since  3.8.0
329
-	 * @access private
330
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
331
-	 */
332
-	private $content_filter_service;
333
-
334
-	/**
335
-	 * A {@link Wordlift_Key_Validation_Service} instance.
336
-	 *
337
-	 * @since  3.9.0
338
-	 * @access private
339
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
340
-	 */
341
-	private $key_validation_service;
342
-
343
-	/**
344
-	 * A {@link Wordlift_Rating_Service} instance.
345
-	 *
346
-	 * @since  3.10.0
347
-	 * @access private
348
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
349
-	 */
350
-	private $rating_service;
351
-
352
-	/**
353
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
354
-	 *
355
-	 * @since  3.10.0
356
-	 * @access protected
357
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
358
-	 */
359
-	protected $post_to_jsonld_converter;
360
-
361
-	/**
362
-	 * A {@link Wordlift_Configuration_Service} instance.
363
-	 *
364
-	 * @since  3.10.0
365
-	 * @access protected
366
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
367
-	 */
368
-	protected $configuration_service;
369
-
370
-	/**
371
-	 * A {@link Wordlift_Install_Service} instance.
372
-	 *
373
-	 * @since  3.18.0
374
-	 * @access protected
375
-	 * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
376
-	 */
377
-	protected $install_service;
378
-
379
-	/**
380
-	 * A {@link Wordlift_Entity_Type_Service} instance.
381
-	 *
382
-	 * @since  3.10.0
383
-	 * @access protected
384
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
385
-	 */
386
-	protected $entity_type_service;
387
-
388
-	/**
389
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
390
-	 *
391
-	 * @since  3.10.0
392
-	 * @access protected
393
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
394
-	 */
395
-	protected $entity_post_to_jsonld_converter;
396
-
397
-	/**
398
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
399
-	 *
400
-	 * @since  3.10.0
401
-	 * @access protected
402
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
403
-	 */
404
-	protected $postid_to_jsonld_converter;
405
-
406
-	/**
407
-	 * The {@link Wordlift_Admin_Status_Page} class.
408
-	 *
409
-	 * @since  3.9.8
410
-	 * @access private
411
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
412
-	 */
413
-	private $status_page;
414
-
415
-	/**
416
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
417
-	 *
418
-	 * @since  3.11.0
419
-	 * @access protected
420
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
421
-	 */
422
-	protected $category_taxonomy_service;
423
-
424
-	/**
425
-	 * The {@link Wordlift_Entity_Page_Service} instance.
426
-	 *
427
-	 * @since  3.11.0
428
-	 * @access protected
429
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
430
-	 */
431
-	protected $entity_page_service;
432
-
433
-	/**
434
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
435
-	 *
436
-	 * @since  3.11.0
437
-	 * @access protected
438
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
439
-	 */
440
-	protected $settings_page_action_link;
441
-
442
-	/**
443
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
444
-	 *
445
-	 * @since  3.11.0
446
-	 * @access protected
447
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
448
-	 */
449
-	protected $analytics_settings_page_action_link;
450
-
451
-	/**
452
-	 * The {@link Wordlift_Analytics_Connect} class.
453
-	 *
454
-	 * @since  3.11.0
455
-	 * @access protected
456
-	 * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
457
-	 */
458
-	protected $analytics_connect;
459
-
460
-	/**
461
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
462
-	 *
463
-	 * @since  3.11.0
464
-	 * @access protected
465
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
466
-	 */
467
-	protected $publisher_ajax_adapter;
468
-
469
-	/**
470
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
471
-	 *
472
-	 * @since  3.11.0
473
-	 * @access protected
474
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
475
-	 */
476
-	protected $input_element;
477
-
478
-	/**
479
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
480
-	 *
481
-	 * @since  3.13.0
482
-	 * @access protected
483
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
484
-	 */
485
-	protected $radio_input_element;
486
-
487
-	/**
488
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
489
-	 *
490
-	 * @since  3.11.0
491
-	 * @access protected
492
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
493
-	 */
494
-	protected $language_select_element;
495
-
496
-	/**
497
-	 * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
498
-	 *
499
-	 * @since  3.18.0
500
-	 * @access protected
501
-	 * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
502
-	 */
503
-	protected $country_select_element;
504
-
505
-	/**
506
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
507
-	 *
508
-	 * @since  3.11.0
509
-	 * @access protected
510
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
511
-	 */
512
-	protected $publisher_element;
513
-
514
-	/**
515
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
516
-	 *
517
-	 * @since  3.11.0
518
-	 * @access protected
519
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
520
-	 */
521
-	protected $select2_element;
522
-
523
-	/**
524
-	 * The controller for the entity type list admin page
525
-	 *
526
-	 * @since  3.11.0
527
-	 * @access private
528
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
529
-	 */
530
-	private $entity_type_admin_page;
531
-
532
-	/**
533
-	 * The controller for the entity type settings admin page
534
-	 *
535
-	 * @since  3.11.0
536
-	 * @access private
537
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
538
-	 */
539
-	private $entity_type_settings_admin_page;
540
-
541
-	/**
542
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
543
-	 *
544
-	 * @since  3.11.0
545
-	 * @access protected
546
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
547
-	 */
548
-	protected $related_entities_cloud_widget;
549
-
550
-	/**
551
-	 * The {@link Wordlift_Admin_Author_Element} instance.
552
-	 *
553
-	 * @since  3.14.0
554
-	 * @access protected
555
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
556
-	 */
557
-	protected $author_element;
558
-
559
-	/**
560
-	 * The {@link Wordlift_Sample_Data_Service} instance.
561
-	 *
562
-	 * @since  3.12.0
563
-	 * @access protected
564
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
565
-	 */
566
-	protected $sample_data_service;
567
-
568
-	/**
569
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
570
-	 *
571
-	 * @since  3.12.0
572
-	 * @access protected
573
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
574
-	 */
575
-	protected $sample_data_ajax_adapter;
576
-
577
-	/**
578
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
579
-	 *
580
-	 * @since  3.14.3
581
-	 * @access private
582
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
583
-	 */
584
-	private $relation_rebuild_service;
585
-
586
-	/**
587
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
588
-	 *
589
-	 * @since  3.14.3
590
-	 * @access private
591
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
592
-	 */
593
-	private $relation_rebuild_adapter;
594
-
595
-	/**
596
-	 * The {@link Wordlift_Reference_Rebuild_Service} instance.
597
-	 *
598
-	 * @since  3.18.0
599
-	 * @access private
600
-	 * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance.
601
-	 */
602
-	private $reference_rebuild_service;
603
-
604
-	/**
605
-	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
606
-	 *
607
-	 * @since  3.16.0
608
-	 * @access protected
609
-	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
610
-	 */
611
-	protected $google_analytics_export_service;
612
-
613
-	/**
614
-	 * {@link Wordlift}'s singleton instance.
615
-	 *
616
-	 * @since  3.15.0
617
-	 * @access protected
618
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
619
-	 */
620
-	protected $entity_type_adapter;
621
-
622
-	/**
623
-	 * The {@link Wordlift_Linked_Data_Service} instance.
624
-	 *
625
-	 * @since  3.15.0
626
-	 * @access protected
627
-	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
628
-	 */
629
-	protected $linked_data_service;
630
-
631
-	/**
632
-	 * The {@link Wordlift_Storage_Factory} instance.
633
-	 *
634
-	 * @since  3.15.0
635
-	 * @access protected
636
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
637
-	 */
638
-	protected $storage_factory;
639
-
640
-	/**
641
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
642
-	 *
643
-	 * @since  3.15.0
644
-	 * @access protected
645
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
646
-	 */
647
-	protected $rendition_factory;
648
-
649
-	/**
650
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
651
-	 *
652
-	 * @since  3.15.0
653
-	 * @access private
654
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
655
-	 */
656
-	private $autocomplete_adapter;
657
-
658
-	/**
659
-	 * The {@link Wordlift_Relation_Service} instance.
660
-	 *
661
-	 * @since  3.15.0
662
-	 * @access protected
663
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
664
-	 */
665
-	protected $relation_service;
666
-
667
-	/**
668
-	 * The {@link Wordlift_Cached_Post_Converter} instance.
669
-	 *
670
-	 * @since  3.16.0
671
-	 * @access protected
672
-	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
673
-	 *
674
-	 */
675
-	protected $cached_postid_to_jsonld_converter;
676
-
677
-	/**
678
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
679
-	 *
680
-	 * @since  3.16.3
681
-	 * @access protected
682
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
683
-	 */
684
-	protected $entity_uri_service;
685
-
686
-	/**
687
-	 * The {@link Wordlift_Publisher_Service} instance.
688
-	 *
689
-	 * @since  3.19.0
690
-	 * @access protected
691
-	 * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
692
-	 */
693
-	protected $publisher_service;
694
-
695
-	/**
696
-	 * The {@link Wordlift_Context_Cards_Service} instance.
697
-	 *
698
-	 * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
699
-	 */
700
-	protected $context_cards_service;
701
-
702
-	/**
703
-	 * {@link Wordlift}'s singleton instance.
704
-	 *
705
-	 * @since  3.11.2
706
-	 * @access private
707
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
708
-	 */
709
-	private static $instance;
710
-
711
-	//</editor-fold>
712
-
713
-	/**
714
-	 * Define the core functionality of the plugin.
715
-	 *
716
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
717
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
718
-	 * the public-facing side of the site.
719
-	 *
720
-	 * @since    1.0.0
721
-	 */
722
-	public function __construct() {
723
-
724
-		self::$instance = $this;
725
-
726
-		$this->plugin_name = 'wordlift';
727
-		$this->version     = '3.25.5';
728
-		$this->load_dependencies();
729
-		$this->set_locale();
730
-		$this->define_admin_hooks();
731
-		$this->define_public_hooks();
732
-
733
-		// If we're in `WP_CLI` load the related files.
734
-		if ( class_exists( 'WP_CLI' ) ) {
735
-			$this->load_cli_dependencies();
736
-		}
737
-
738
-	}
739
-
740
-	/**
741
-	 * Get the singleton instance.
742
-	 *
743
-	 * @return Wordlift The {@link Wordlift} singleton instance.
744
-	 * @since 3.11.2
745
-	 *
746
-	 */
747
-	public static function get_instance() {
748
-
749
-		return self::$instance;
750
-	}
751
-
752
-	/**
753
-	 * Load the required dependencies for this plugin.
754
-	 *
755
-	 * Include the following files that make up the plugin:
756
-	 *
757
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
758
-	 * - Wordlift_i18n. Defines internationalization functionality.
759
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
760
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
761
-	 *
762
-	 * Create an instance of the loader which will be used to register the hooks
763
-	 * with WordPress.
764
-	 *
765
-	 * @throws Exception
766
-	 * @since    1.0.0
767
-	 * @access   private
768
-	 */
769
-	private function load_dependencies() {
770
-
771
-		/**
772
-		 * The class responsible for orchestrating the actions and filters of the
773
-		 * core plugin.
774
-		 */
775
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
776
-
777
-		// The class responsible for plugin uninstall.
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
779
-
780
-		/**
781
-		 * The class responsible for defining internationalization functionality
782
-		 * of the plugin.
783
-		 */
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
785
-
786
-		/**
787
-		 * WordLift's supported languages.
788
-		 */
789
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
790
-
791
-		/**
792
-		 * WordLift's supported countries.
793
-		 */
794
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
795
-
796
-		/**
797
-		 * Provide support functions to sanitize data.
798
-		 */
799
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
800
-
801
-		/** Services. */
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
803
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
804
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
805
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
806
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
807
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
808
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
809
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
810
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
811
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
812
-
813
-		/**
814
-		 * The Query builder.
815
-		 */
816
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
817
-
818
-		/**
819
-		 * The Schema service.
820
-		 */
821
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
822
-
823
-		/**
824
-		 * The schema:url property service.
825
-		 */
826
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
827
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
828
-
829
-		/**
830
-		 * The UI service.
831
-		 */
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
833
-
834
-		/**
835
-		 * The Thumbnail service.
836
-		 */
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
838
-
839
-		/**
840
-		 * The Entity Types Taxonomy service.
841
-		 */
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
843
-
844
-		/**
845
-		 * The Entity service.
846
-		 */
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
848
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
849
-
850
-		// Add the entity rating service.
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
852
-
853
-		/**
854
-		 * The User service.
855
-		 */
856
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
857
-
858
-		/**
859
-		 * The Timeline service.
860
-		 */
861
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
862
-
863
-		/**
864
-		 * The Topic Taxonomy service.
865
-		 */
866
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
867
-
868
-		/**
869
-		 * The SPARQL service.
870
-		 */
871
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
872
-
873
-		/**
874
-		 * The WordLift import service.
875
-		 */
876
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
877
-
878
-		/**
879
-		 * The WordLift URI service.
880
-		 */
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
883
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
884
-
885
-		/**
886
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
887
-		 */
888
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
889
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
890
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
893
-
894
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
895
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
896
-
897
-		/**
898
-		 * Load the converters.
899
-		 */
900
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
901
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
902
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
903
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
904
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
905
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
906
-
907
-		/**
908
-		 * Load cache-related files.
909
-		 */
910
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
911
-
912
-		/**
913
-		 * Load the content filter.
914
-		 */
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
916
-
917
-		/*
51
+    //<editor-fold desc="## FIELDS">
52
+
53
+    /**
54
+     * The loader that's responsible for maintaining and registering all hooks that power
55
+     * the plugin.
56
+     *
57
+     * @since    1.0.0
58
+     * @access   protected
59
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
60
+     */
61
+    protected $loader;
62
+
63
+    /**
64
+     * The unique identifier of this plugin.
65
+     *
66
+     * @since    1.0.0
67
+     * @access   protected
68
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
69
+     */
70
+    protected $plugin_name;
71
+
72
+    /**
73
+     * The current version of the plugin.
74
+     *
75
+     * @since    1.0.0
76
+     * @access   protected
77
+     * @var      string $version The current version of the plugin.
78
+     */
79
+    protected $version;
80
+
81
+    /**
82
+     * The {@link Wordlift_Tinymce_Adapter} instance.
83
+     *
84
+     * @since  3.12.0
85
+     * @access protected
86
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
87
+     */
88
+    protected $tinymce_adapter;
89
+
90
+    /**
91
+     * The Thumbnail service.
92
+     *
93
+     * @since  3.1.5
94
+     * @access private
95
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
96
+     */
97
+    private $thumbnail_service;
98
+
99
+    /**
100
+     * The UI service.
101
+     *
102
+     * @since  3.2.0
103
+     * @access private
104
+     * @var \Wordlift_UI_Service $ui_service The UI service.
105
+     */
106
+    private $ui_service;
107
+
108
+    /**
109
+     * The Schema service.
110
+     *
111
+     * @since  3.3.0
112
+     * @access protected
113
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
114
+     */
115
+    protected $schema_service;
116
+
117
+    /**
118
+     * The Entity service.
119
+     *
120
+     * @since  3.1.0
121
+     * @access protected
122
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
123
+     */
124
+    protected $entity_service;
125
+
126
+    /**
127
+     * The Topic Taxonomy service.
128
+     *
129
+     * @since  3.5.0
130
+     * @access private
131
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
132
+     */
133
+    private $topic_taxonomy_service;
134
+
135
+    /**
136
+     * The Entity Types Taxonomy service.
137
+     *
138
+     * @since  3.18.0
139
+     * @access private
140
+     * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
141
+     */
142
+    private $entity_types_taxonomy_service;
143
+
144
+    /**
145
+     * The User service.
146
+     *
147
+     * @since  3.1.7
148
+     * @access protected
149
+     * @var \Wordlift_User_Service $user_service The User service.
150
+     */
151
+    protected $user_service;
152
+
153
+    /**
154
+     * The Timeline service.
155
+     *
156
+     * @since  3.1.0
157
+     * @access private
158
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
159
+     */
160
+    private $timeline_service;
161
+
162
+    /**
163
+     * The Redirect service.
164
+     *
165
+     * @since  3.2.0
166
+     * @access private
167
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
168
+     */
169
+    private $redirect_service;
170
+
171
+    /**
172
+     * The Notice service.
173
+     *
174
+     * @since  3.3.0
175
+     * @access private
176
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
177
+     */
178
+    private $notice_service;
179
+
180
+    /**
181
+     * The Entity list customization.
182
+     *
183
+     * @since  3.3.0
184
+     * @access protected
185
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
186
+     */
187
+    protected $entity_list_service;
188
+
189
+    /**
190
+     * The Entity Types Taxonomy Walker.
191
+     *
192
+     * @since  3.1.0
193
+     * @access private
194
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
195
+     */
196
+    private $entity_types_taxonomy_walker;
197
+
198
+    /**
199
+     * The ShareThis service.
200
+     *
201
+     * @since  3.2.0
202
+     * @access private
203
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
204
+     */
205
+    private $sharethis_service;
206
+
207
+    /**
208
+     * The PrimaShop adapter.
209
+     *
210
+     * @since  3.2.3
211
+     * @access private
212
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
213
+     */
214
+    private $primashop_adapter;
215
+
216
+    /**
217
+     * The WordLift Dashboard adapter.
218
+     *
219
+     * @since  3.4.0
220
+     * @access private
221
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
222
+     */
223
+    private $dashboard_service;
224
+
225
+    /**
226
+     * The entity type service.
227
+     *
228
+     * @since  3.6.0
229
+     * @access private
230
+     * @var \Wordlift_Entity_Post_Type_Service
231
+     */
232
+    private $entity_post_type_service;
233
+
234
+    /**
235
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
236
+     *
237
+     * @since  3.6.0
238
+     * @access private
239
+     * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
240
+     */
241
+    private $entity_link_service;
242
+
243
+    /**
244
+     * A {@link Wordlift_Sparql_Service} instance.
245
+     *
246
+     * @since    3.6.0
247
+     * @access   protected
248
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
249
+     */
250
+    protected $sparql_service;
251
+
252
+    /**
253
+     * A {@link Wordlift_Import_Service} instance.
254
+     *
255
+     * @since  3.6.0
256
+     * @access private
257
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
258
+     */
259
+    private $import_service;
260
+
261
+    /**
262
+     * A {@link Wordlift_Rebuild_Service} instance.
263
+     *
264
+     * @since  3.6.0
265
+     * @access private
266
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
267
+     */
268
+    private $rebuild_service;
269
+
270
+    /**
271
+     * A {@link Wordlift_Jsonld_Service} instance.
272
+     *
273
+     * @since  3.7.0
274
+     * @access protected
275
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
276
+     */
277
+    protected $jsonld_service;
278
+
279
+    /**
280
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
281
+     *
282
+     * @since  3.14.0
283
+     * @access protected
284
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
285
+     */
286
+    protected $jsonld_website_converter;
287
+
288
+    /**
289
+     * A {@link Wordlift_Property_Factory} instance.
290
+     *
291
+     * @since  3.7.0
292
+     * @access private
293
+     * @var \Wordlift_Property_Factory $property_factory
294
+     */
295
+    private $property_factory;
296
+
297
+    /**
298
+     * The 'Download Your Data' page.
299
+     *
300
+     * @since  3.6.0
301
+     * @access private
302
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
303
+     */
304
+    private $download_your_data_page;
305
+
306
+    /**
307
+     * The 'WordLift Settings' page.
308
+     *
309
+     * @since  3.11.0
310
+     * @access protected
311
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
312
+     */
313
+    protected $settings_page;
314
+
315
+    /**
316
+     * The install wizard page.
317
+     *
318
+     * @since  3.9.0
319
+     * @access private
320
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
321
+     */
322
+    private $admin_setup;
323
+
324
+    /**
325
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
326
+     * linking of entities to their pages.
327
+     *
328
+     * @since  3.8.0
329
+     * @access private
330
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
331
+     */
332
+    private $content_filter_service;
333
+
334
+    /**
335
+     * A {@link Wordlift_Key_Validation_Service} instance.
336
+     *
337
+     * @since  3.9.0
338
+     * @access private
339
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
340
+     */
341
+    private $key_validation_service;
342
+
343
+    /**
344
+     * A {@link Wordlift_Rating_Service} instance.
345
+     *
346
+     * @since  3.10.0
347
+     * @access private
348
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
349
+     */
350
+    private $rating_service;
351
+
352
+    /**
353
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
354
+     *
355
+     * @since  3.10.0
356
+     * @access protected
357
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
358
+     */
359
+    protected $post_to_jsonld_converter;
360
+
361
+    /**
362
+     * A {@link Wordlift_Configuration_Service} instance.
363
+     *
364
+     * @since  3.10.0
365
+     * @access protected
366
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
367
+     */
368
+    protected $configuration_service;
369
+
370
+    /**
371
+     * A {@link Wordlift_Install_Service} instance.
372
+     *
373
+     * @since  3.18.0
374
+     * @access protected
375
+     * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
376
+     */
377
+    protected $install_service;
378
+
379
+    /**
380
+     * A {@link Wordlift_Entity_Type_Service} instance.
381
+     *
382
+     * @since  3.10.0
383
+     * @access protected
384
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
385
+     */
386
+    protected $entity_type_service;
387
+
388
+    /**
389
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
390
+     *
391
+     * @since  3.10.0
392
+     * @access protected
393
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
394
+     */
395
+    protected $entity_post_to_jsonld_converter;
396
+
397
+    /**
398
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
399
+     *
400
+     * @since  3.10.0
401
+     * @access protected
402
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
403
+     */
404
+    protected $postid_to_jsonld_converter;
405
+
406
+    /**
407
+     * The {@link Wordlift_Admin_Status_Page} class.
408
+     *
409
+     * @since  3.9.8
410
+     * @access private
411
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
412
+     */
413
+    private $status_page;
414
+
415
+    /**
416
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
417
+     *
418
+     * @since  3.11.0
419
+     * @access protected
420
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
421
+     */
422
+    protected $category_taxonomy_service;
423
+
424
+    /**
425
+     * The {@link Wordlift_Entity_Page_Service} instance.
426
+     *
427
+     * @since  3.11.0
428
+     * @access protected
429
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
430
+     */
431
+    protected $entity_page_service;
432
+
433
+    /**
434
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
435
+     *
436
+     * @since  3.11.0
437
+     * @access protected
438
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
439
+     */
440
+    protected $settings_page_action_link;
441
+
442
+    /**
443
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
444
+     *
445
+     * @since  3.11.0
446
+     * @access protected
447
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
448
+     */
449
+    protected $analytics_settings_page_action_link;
450
+
451
+    /**
452
+     * The {@link Wordlift_Analytics_Connect} class.
453
+     *
454
+     * @since  3.11.0
455
+     * @access protected
456
+     * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
457
+     */
458
+    protected $analytics_connect;
459
+
460
+    /**
461
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
462
+     *
463
+     * @since  3.11.0
464
+     * @access protected
465
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
466
+     */
467
+    protected $publisher_ajax_adapter;
468
+
469
+    /**
470
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
471
+     *
472
+     * @since  3.11.0
473
+     * @access protected
474
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
475
+     */
476
+    protected $input_element;
477
+
478
+    /**
479
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
480
+     *
481
+     * @since  3.13.0
482
+     * @access protected
483
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
484
+     */
485
+    protected $radio_input_element;
486
+
487
+    /**
488
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
489
+     *
490
+     * @since  3.11.0
491
+     * @access protected
492
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
493
+     */
494
+    protected $language_select_element;
495
+
496
+    /**
497
+     * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
498
+     *
499
+     * @since  3.18.0
500
+     * @access protected
501
+     * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
502
+     */
503
+    protected $country_select_element;
504
+
505
+    /**
506
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
507
+     *
508
+     * @since  3.11.0
509
+     * @access protected
510
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
511
+     */
512
+    protected $publisher_element;
513
+
514
+    /**
515
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
516
+     *
517
+     * @since  3.11.0
518
+     * @access protected
519
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
520
+     */
521
+    protected $select2_element;
522
+
523
+    /**
524
+     * The controller for the entity type list admin page
525
+     *
526
+     * @since  3.11.0
527
+     * @access private
528
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
529
+     */
530
+    private $entity_type_admin_page;
531
+
532
+    /**
533
+     * The controller for the entity type settings admin page
534
+     *
535
+     * @since  3.11.0
536
+     * @access private
537
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
538
+     */
539
+    private $entity_type_settings_admin_page;
540
+
541
+    /**
542
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
543
+     *
544
+     * @since  3.11.0
545
+     * @access protected
546
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
547
+     */
548
+    protected $related_entities_cloud_widget;
549
+
550
+    /**
551
+     * The {@link Wordlift_Admin_Author_Element} instance.
552
+     *
553
+     * @since  3.14.0
554
+     * @access protected
555
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
556
+     */
557
+    protected $author_element;
558
+
559
+    /**
560
+     * The {@link Wordlift_Sample_Data_Service} instance.
561
+     *
562
+     * @since  3.12.0
563
+     * @access protected
564
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
565
+     */
566
+    protected $sample_data_service;
567
+
568
+    /**
569
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
570
+     *
571
+     * @since  3.12.0
572
+     * @access protected
573
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
574
+     */
575
+    protected $sample_data_ajax_adapter;
576
+
577
+    /**
578
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
579
+     *
580
+     * @since  3.14.3
581
+     * @access private
582
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
583
+     */
584
+    private $relation_rebuild_service;
585
+
586
+    /**
587
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
588
+     *
589
+     * @since  3.14.3
590
+     * @access private
591
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
592
+     */
593
+    private $relation_rebuild_adapter;
594
+
595
+    /**
596
+     * The {@link Wordlift_Reference_Rebuild_Service} instance.
597
+     *
598
+     * @since  3.18.0
599
+     * @access private
600
+     * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance.
601
+     */
602
+    private $reference_rebuild_service;
603
+
604
+    /**
605
+     * The {@link Wordlift_Google_Analytics_Export_Service} instance.
606
+     *
607
+     * @since  3.16.0
608
+     * @access protected
609
+     * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
610
+     */
611
+    protected $google_analytics_export_service;
612
+
613
+    /**
614
+     * {@link Wordlift}'s singleton instance.
615
+     *
616
+     * @since  3.15.0
617
+     * @access protected
618
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
619
+     */
620
+    protected $entity_type_adapter;
621
+
622
+    /**
623
+     * The {@link Wordlift_Linked_Data_Service} instance.
624
+     *
625
+     * @since  3.15.0
626
+     * @access protected
627
+     * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
628
+     */
629
+    protected $linked_data_service;
630
+
631
+    /**
632
+     * The {@link Wordlift_Storage_Factory} instance.
633
+     *
634
+     * @since  3.15.0
635
+     * @access protected
636
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
637
+     */
638
+    protected $storage_factory;
639
+
640
+    /**
641
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
642
+     *
643
+     * @since  3.15.0
644
+     * @access protected
645
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
646
+     */
647
+    protected $rendition_factory;
648
+
649
+    /**
650
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
651
+     *
652
+     * @since  3.15.0
653
+     * @access private
654
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
655
+     */
656
+    private $autocomplete_adapter;
657
+
658
+    /**
659
+     * The {@link Wordlift_Relation_Service} instance.
660
+     *
661
+     * @since  3.15.0
662
+     * @access protected
663
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
664
+     */
665
+    protected $relation_service;
666
+
667
+    /**
668
+     * The {@link Wordlift_Cached_Post_Converter} instance.
669
+     *
670
+     * @since  3.16.0
671
+     * @access protected
672
+     * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
673
+     *
674
+     */
675
+    protected $cached_postid_to_jsonld_converter;
676
+
677
+    /**
678
+     * The {@link Wordlift_Entity_Uri_Service} instance.
679
+     *
680
+     * @since  3.16.3
681
+     * @access protected
682
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
683
+     */
684
+    protected $entity_uri_service;
685
+
686
+    /**
687
+     * The {@link Wordlift_Publisher_Service} instance.
688
+     *
689
+     * @since  3.19.0
690
+     * @access protected
691
+     * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
692
+     */
693
+    protected $publisher_service;
694
+
695
+    /**
696
+     * The {@link Wordlift_Context_Cards_Service} instance.
697
+     *
698
+     * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
699
+     */
700
+    protected $context_cards_service;
701
+
702
+    /**
703
+     * {@link Wordlift}'s singleton instance.
704
+     *
705
+     * @since  3.11.2
706
+     * @access private
707
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
708
+     */
709
+    private static $instance;
710
+
711
+    //</editor-fold>
712
+
713
+    /**
714
+     * Define the core functionality of the plugin.
715
+     *
716
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
717
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
718
+     * the public-facing side of the site.
719
+     *
720
+     * @since    1.0.0
721
+     */
722
+    public function __construct() {
723
+
724
+        self::$instance = $this;
725
+
726
+        $this->plugin_name = 'wordlift';
727
+        $this->version     = '3.25.5';
728
+        $this->load_dependencies();
729
+        $this->set_locale();
730
+        $this->define_admin_hooks();
731
+        $this->define_public_hooks();
732
+
733
+        // If we're in `WP_CLI` load the related files.
734
+        if ( class_exists( 'WP_CLI' ) ) {
735
+            $this->load_cli_dependencies();
736
+        }
737
+
738
+    }
739
+
740
+    /**
741
+     * Get the singleton instance.
742
+     *
743
+     * @return Wordlift The {@link Wordlift} singleton instance.
744
+     * @since 3.11.2
745
+     *
746
+     */
747
+    public static function get_instance() {
748
+
749
+        return self::$instance;
750
+    }
751
+
752
+    /**
753
+     * Load the required dependencies for this plugin.
754
+     *
755
+     * Include the following files that make up the plugin:
756
+     *
757
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
758
+     * - Wordlift_i18n. Defines internationalization functionality.
759
+     * - Wordlift_Admin. Defines all hooks for the admin area.
760
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
761
+     *
762
+     * Create an instance of the loader which will be used to register the hooks
763
+     * with WordPress.
764
+     *
765
+     * @throws Exception
766
+     * @since    1.0.0
767
+     * @access   private
768
+     */
769
+    private function load_dependencies() {
770
+
771
+        /**
772
+         * The class responsible for orchestrating the actions and filters of the
773
+         * core plugin.
774
+         */
775
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
776
+
777
+        // The class responsible for plugin uninstall.
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
779
+
780
+        /**
781
+         * The class responsible for defining internationalization functionality
782
+         * of the plugin.
783
+         */
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
785
+
786
+        /**
787
+         * WordLift's supported languages.
788
+         */
789
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
790
+
791
+        /**
792
+         * WordLift's supported countries.
793
+         */
794
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
795
+
796
+        /**
797
+         * Provide support functions to sanitize data.
798
+         */
799
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
800
+
801
+        /** Services. */
802
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
803
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
804
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
805
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
806
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
807
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
808
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
809
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
810
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
811
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
812
+
813
+        /**
814
+         * The Query builder.
815
+         */
816
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
817
+
818
+        /**
819
+         * The Schema service.
820
+         */
821
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
822
+
823
+        /**
824
+         * The schema:url property service.
825
+         */
826
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
827
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
828
+
829
+        /**
830
+         * The UI service.
831
+         */
832
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
833
+
834
+        /**
835
+         * The Thumbnail service.
836
+         */
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
838
+
839
+        /**
840
+         * The Entity Types Taxonomy service.
841
+         */
842
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
843
+
844
+        /**
845
+         * The Entity service.
846
+         */
847
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
848
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
849
+
850
+        // Add the entity rating service.
851
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
852
+
853
+        /**
854
+         * The User service.
855
+         */
856
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
857
+
858
+        /**
859
+         * The Timeline service.
860
+         */
861
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
862
+
863
+        /**
864
+         * The Topic Taxonomy service.
865
+         */
866
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
867
+
868
+        /**
869
+         * The SPARQL service.
870
+         */
871
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
872
+
873
+        /**
874
+         * The WordLift import service.
875
+         */
876
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
877
+
878
+        /**
879
+         * The WordLift URI service.
880
+         */
881
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
882
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
883
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
884
+
885
+        /**
886
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
887
+         */
888
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
889
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
890
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
891
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
892
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
893
+
894
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
895
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
896
+
897
+        /**
898
+         * Load the converters.
899
+         */
900
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
901
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
902
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
903
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
904
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
905
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
906
+
907
+        /**
908
+         * Load cache-related files.
909
+         */
910
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
911
+
912
+        /**
913
+         * Load the content filter.
914
+         */
915
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
916
+
917
+        /*
918 918
 		 * Load the excerpt helper.
919 919
 		 */
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
921
-
922
-		/**
923
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
920
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
921
+
922
+        /**
923
+         * Load the JSON-LD service to publish entities using JSON-LD.s
924
+         *
925
+         * @since 3.8.0
926
+         */
927
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
928
+
929
+        // The Publisher Service and the AJAX adapter.
930
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
931
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
932
+
933
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
934
+
935
+        /**
936
+         * Load the WordLift key validation service.
937
+         */
938
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
939
+
940
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
941
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
942
+
943
+        // Load the `Wordlift_Entity_Page_Service` class definition.
944
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
945
+
946
+        /** Linked Data. */
947
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
948
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
949
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
950
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
951
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
952
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
953
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
954
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
955
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
956
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
957
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
958
+
959
+        /** Linked Data Rendition. */
960
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
961
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
962
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
963
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
964
+
965
+        /** Services. */
966
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
967
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
968
+
969
+        /** Adapters. */
970
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
971
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
972
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
973
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
974
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
975
+
976
+        /** Async Tasks. */
977
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
978
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
979
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
980
+
981
+        /** Autocomplete. */
982
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
983
+
984
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
985
+
986
+        /** Analytics */
987
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
988
+
989
+        /**
990
+         * The class responsible for defining all actions that occur in the admin area.
991
+         */
992
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
993
+
994
+        /**
995
+         * The class to customize the entity list admin page.
996
+         */
997
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
998
+
999
+        /**
1000
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
1001
+         */
1002
+        global $wp_version;
1003
+        if ( version_compare( $wp_version, '5.3', '<' ) ) {
1004
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
1005
+        } else {
1006
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1007
+        }
1008
+
1009
+        /**
1010
+         * The Notice service.
1011
+         */
1012
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1013
+
1014
+        /**
1015
+         * The PrimaShop adapter.
1016
+         */
1017
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1018
+
1019
+        /**
1020
+         * The WordLift Dashboard service.
1021
+         */
1022
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1023
+
1024
+        /**
1025
+         * The admin 'Install wizard' page.
1026
+         */
1027
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1028
+
1029
+        /**
1030
+         * The WordLift entity type list admin page controller.
1031
+         */
1032
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1033
+
1034
+        /**
1035
+         * The WordLift entity type settings admin page controller.
1036
+         */
1037
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1038
+
1039
+        /**
1040
+         * The admin 'Download Your Data' page.
1041
+         */
1042
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1043
+
1044
+        /**
1045
+         * The admin 'WordLift Settings' page.
1046
+         */
1047
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
1048
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
1049
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
1050
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
1051
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
1052
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
1053
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
1054
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
1055
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
1056
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
1057
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1058
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1059
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
1060
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1061
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1062
+
1063
+        /** Admin Pages */
1064
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1065
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1066
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php';
1067
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1068
+
1069
+        /**
1070
+         * The class responsible for defining all actions that occur in the public-facing
1071
+         * side of the site.
1072
+         */
1073
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1074
+
1075
+        /**
1076
+         * The shortcode abstract class.
1077
+         */
1078
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1079
+
1080
+        /**
1081
+         * The Timeline shortcode.
1082
+         */
1083
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1084
+
1085
+        /**
1086
+         * The Navigator shortcode.
1087
+         */
1088
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1089
+
1090
+        /**
1091
+         * The chord shortcode.
1092
+         */
1093
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1094
+
1095
+        /**
1096
+         * The geomap shortcode.
1097
+         */
1098
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1099
+
1100
+        /**
1101
+         * The entity cloud shortcode.
1102
+         */
1103
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1104
+
1105
+        /**
1106
+         * The entity glossary shortcode.
1107
+         */
1108
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1109
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1110
+
1111
+        /**
1112
+         * Faceted Search shortcode.
1113
+         */
1114
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
1115
+
1116
+        /**
1117
+         * The ShareThis service.
1118
+         */
1119
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1120
+
1121
+        /**
1122
+         * The SEO service.
1123
+         */
1124
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1125
+
1126
+        /**
1127
+         * The AMP service.
1128
+         */
1129
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1130
+
1131
+        /** Widgets */
1132
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1133
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1134
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1135
+
1136
+        /*
1137
+		 * Schema.org Services.
924 1138
 		 *
925
-		 * @since 3.8.0
926
-		 */
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
928
-
929
-		// The Publisher Service and the AJAX adapter.
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
931
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
932
-
933
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
934
-
935
-		/**
936
-		 * Load the WordLift key validation service.
937
-		 */
938
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
939
-
940
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
941
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
942
-
943
-		// Load the `Wordlift_Entity_Page_Service` class definition.
944
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
945
-
946
-		/** Linked Data. */
947
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
948
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
950
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
951
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
952
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
953
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
954
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
956
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
957
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
958
-
959
-		/** Linked Data Rendition. */
960
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
961
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
962
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
963
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
964
-
965
-		/** Services. */
966
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
967
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
968
-
969
-		/** Adapters. */
970
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
971
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
972
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
973
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
974
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
975
-
976
-		/** Async Tasks. */
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
980
-
981
-		/** Autocomplete. */
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
983
-
984
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
985
-
986
-		/** Analytics */
987
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
988
-
989
-		/**
990
-		 * The class responsible for defining all actions that occur in the admin area.
991
-		 */
992
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
993
-
994
-		/**
995
-		 * The class to customize the entity list admin page.
1139
+		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
996 1140
 		 */
997
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
1141
+        if ( WL_ALL_ENTITY_TYPES ) {
1142
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1143
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1144
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1145
+            new Wordlift_Schemaorg_Sync_Service();
1146
+            $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service();
1147
+            new Wordlift_Schemaorg_Class_Service();
1148
+        } else {
1149
+            $schemaorg_property_service = null;
1150
+        }
998 1151
 
999
-		/**
1000
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
1001
-		 */
1002
-		global $wp_version;
1003
-		if ( version_compare( $wp_version, '5.3', '<' ) ) {
1004
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
1005
-		} else {
1006
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
1007
-		}
1008
-
1009
-		/**
1010
-		 * The Notice service.
1011
-		 */
1012
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1152
+        $this->loader = new Wordlift_Loader();
1013 1153
 
1014
-		/**
1015
-		 * The PrimaShop adapter.
1016
-		 */
1017
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1154
+        // Instantiate a global logger.
1155
+        global $wl_logger;
1156
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1018 1157
 
1019
-		/**
1020
-		 * The WordLift Dashboard service.
1021
-		 */
1022
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1158
+        // Load the `wl-api` end-point.
1159
+        new Wordlift_Http_Api();
1023 1160
 
1024
-		/**
1025
-		 * The admin 'Install wizard' page.
1026
-		 */
1027
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1161
+        // Load the Install Service.
1162
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1163
+        $this->install_service = new Wordlift_Install_Service();
1028 1164
 
1029
-		/**
1030
-		 * The WordLift entity type list admin page controller.
1031
-		 */
1032
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1165
+        /** Services. */
1166
+        // Create the configuration service.
1167
+        $this->configuration_service = new Wordlift_Configuration_Service();
1168
+        $api_service                 = new Wordlift_Api_Service( $this->configuration_service );
1033 1169
 
1034
-		/**
1035
-		 * The WordLift entity type settings admin page controller.
1036
-		 */
1037
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1170
+        // Create an entity type service instance. It'll be later bound to the init action.
1171
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1038 1172
 
1039
-		/**
1040
-		 * The admin 'Download Your Data' page.
1041
-		 */
1042
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1173
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1174
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1043 1175
 
1044
-		/**
1045
-		 * The admin 'WordLift Settings' page.
1046
-		 */
1047
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
1048
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
1049
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
1050
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
1051
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
1053
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
1054
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
1055
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
1056
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
1057
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1058
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1059
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
1060
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1061
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
1062
-
1063
-		/** Admin Pages */
1064
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1065
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1066
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php';
1067
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1068
-
1069
-		/**
1070
-		 * The class responsible for defining all actions that occur in the public-facing
1071
-		 * side of the site.
1072
-		 */
1073
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1176
+        // Create an instance of the UI service.
1177
+        $this->ui_service = new Wordlift_UI_Service();
1074 1178
 
1075
-		/**
1076
-		 * The shortcode abstract class.
1077
-		 */
1078
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1179
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1180
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1079 1181
 
1080
-		/**
1081
-		 * The Timeline shortcode.
1082
-		 */
1083
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1182
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1183
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1184
+        $this->notice_service        = new Wordlift_Notice_Service();
1185
+        $this->relation_service      = new Wordlift_Relation_Service();
1084 1186
 
1085
-		/**
1086
-		 * The Navigator shortcode.
1087
-		 */
1088
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1187
+        $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1188
+        $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1189
+        $this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1190
+        $this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1089 1191
 
1090
-		/**
1091
-		 * The chord shortcode.
1092
-		 */
1093
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1192
+        // Instantiate the JSON-LD service.
1193
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1094 1194
 
1095
-		/**
1096
-		 * The geomap shortcode.
1097
-		 */
1098
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1195
+        /** Linked Data. */
1196
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1197
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1099 1198
 
1100
-		/**
1101
-		 * The entity cloud shortcode.
1102
-		 */
1103
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1199
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1104 1200
 
1105
-		/**
1106
-		 * The entity glossary shortcode.
1107
-		 */
1108
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1109
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1201
+        // Create a new instance of the Redirect service.
1202
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_uri_service );
1203
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1204
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1110 1205
 
1111
-		/**
1112
-		 * Faceted Search shortcode.
1113
-		 */
1114
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
1206
+        // Create a new instance of the Timeline service and Timeline shortcode.
1207
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1115 1208
 
1116
-		/**
1117
-		 * The ShareThis service.
1118
-		 */
1119
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1209
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1120 1210
 
1121
-		/**
1122
-		 * The SEO service.
1123
-		 */
1124
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1211
+        $this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1212
+        $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1125 1213
 
1126
-		/**
1127
-		 * The AMP service.
1128
-		 */
1129
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1130
-
1131
-		/** Widgets */
1132
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1133
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1134
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1214
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1215
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1135 1216
 
1136
-		/*
1137
-		 * Schema.org Services.
1138
-		 *
1139
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1140
-		 */
1141
-		if ( WL_ALL_ENTITY_TYPES ) {
1142
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1143
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1144
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1145
-			new Wordlift_Schemaorg_Sync_Service();
1146
-			$schemaorg_property_service = new Wordlift_Schemaorg_Property_Service();
1147
-			new Wordlift_Schemaorg_Class_Service();
1148
-		} else {
1149
-			$schemaorg_property_service = null;
1150
-		}
1217
+        // Create an instance of the PrimaShop adapter.
1218
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1151 1219
 
1152
-		$this->loader = new Wordlift_Loader();
1220
+        // Create an import service instance to hook later to WP's import function.
1221
+        $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() );
1153 1222
 
1154
-		// Instantiate a global logger.
1155
-		global $wl_logger;
1156
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1223
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1157 1224
 
1158
-		// Load the `wl-api` end-point.
1159
-		new Wordlift_Http_Api();
1225
+        // Create the entity rating service.
1226
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1160 1227
 
1161
-		// Load the Install Service.
1162
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1163
-		$this->install_service = new Wordlift_Install_Service();
1228
+        // Create entity list customization (wp-admin/edit.php).
1229
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1164 1230
 
1165
-		/** Services. */
1166
-		// Create the configuration service.
1167
-		$this->configuration_service = new Wordlift_Configuration_Service();
1168
-		$api_service                 = new Wordlift_Api_Service( $this->configuration_service );
1169
-
1170
-		// Create an entity type service instance. It'll be later bound to the init action.
1171
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1172
-
1173
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1174
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1231
+        // Create a new instance of the Redirect service.
1232
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1175 1233
 
1176
-		// Create an instance of the UI service.
1177
-		$this->ui_service = new Wordlift_UI_Service();
1234
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1235
+        $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1236
+        $this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1237
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1178 1238
 
1179
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1180
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1239
+        $attachment_service = new Wordlift_Attachment_Service();
1181 1240
 
1182
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1183
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1184
-		$this->notice_service        = new Wordlift_Notice_Service();
1185
-		$this->relation_service      = new Wordlift_Relation_Service();
1241
+        // Instantiate the JSON-LD service.
1242
+        $property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1243
+        $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 );
1244
+        $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 );
1245
+        $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 );
1246
+        $this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1186 1247
 
1187
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1188
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1189
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1190
-		$this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1248
+        $jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1249
+        $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache );
1250
+        $this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1251
+        new Jsonld_Endpoint( $this->jsonld_service, $this->entity_uri_service );
1252
+        // Prints the JSON-LD in the head.
1253
+        new Jsonld_Adapter( $this->jsonld_service );
1191 1254
 
1192
-		// Instantiate the JSON-LD service.
1193
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1255
+        $this->key_validation_service    = new Wordlift_Key_Validation_Service( $this->configuration_service );
1256
+        $this->content_filter_service    = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1257
+        $this->relation_rebuild_service  = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1258
+        $this->sample_data_service       = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1259
+        $this->sample_data_ajax_adapter  = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1260
+        $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->linked_data_service, $this->entity_service, $this->relation_service );
1194 1261
 
1195
-		/** Linked Data. */
1196
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1197
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1262
+        // Initialize the short-codes.
1263
+        new Wordlift_Navigator_Shortcode();
1264
+        new Wordlift_Chord_Shortcode();
1265
+        new Wordlift_Geomap_Shortcode();
1266
+        new Wordlift_Timeline_Shortcode();
1267
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1268
+        new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1269
+        new Wordlift_Faceted_Search_Shortcode();
1198 1270
 
1199
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1271
+        // Initialize the SEO service.
1272
+        new Wordlift_Seo_Service();
1200 1273
 
1201
-		// Create a new instance of the Redirect service.
1202
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_uri_service );
1203
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1204
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1274
+        // Initialize the AMP service.
1275
+        new Wordlift_AMP_Service( $this->jsonld_service );
1205 1276
 
1206
-		// Create a new instance of the Timeline service and Timeline shortcode.
1207
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1277
+        /** Services. */
1278
+        $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1279
+        new Wordlift_Image_Service();
1208 1280
 
1209
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1281
+        /** Adapters. */
1282
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1283
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1284
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1285
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1210 1286
 
1211
-		$this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1212
-		$this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1213
-
1214
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1215
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1216
-
1217
-		// Create an instance of the PrimaShop adapter.
1218
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1219
-
1220
-		// Create an import service instance to hook later to WP's import function.
1221
-		$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() );
1222
-
1223
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1224
-
1225
-		// Create the entity rating service.
1226
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1227
-
1228
-		// Create entity list customization (wp-admin/edit.php).
1229
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1230
-
1231
-		// Create a new instance of the Redirect service.
1232
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1233
-
1234
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1235
-		$this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1236
-		$this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1237
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1238
-
1239
-		$attachment_service = new Wordlift_Attachment_Service();
1240
-
1241
-		// Instantiate the JSON-LD service.
1242
-		$property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1243
-		$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 );
1244
-		$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 );
1245
-		$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 );
1246
-		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1247
-
1248
-		$jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1249
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache );
1250
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1251
-		new Jsonld_Endpoint( $this->jsonld_service, $this->entity_uri_service );
1252
-		// Prints the JSON-LD in the head.
1253
-		new Jsonld_Adapter( $this->jsonld_service );
1287
+        /*
1288
+		 * Exclude our public js from WP-Rocket.
1289
+		 *
1290
+		 * @since 3.19.4
1291
+		 *
1292
+		 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
1293
+		 */
1294
+        new Wordlift_WpRocket_Adapter();
1254 1295
 
1255
-		$this->key_validation_service    = new Wordlift_Key_Validation_Service( $this->configuration_service );
1256
-		$this->content_filter_service    = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1257
-		$this->relation_rebuild_service  = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1258
-		$this->sample_data_service       = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1259
-		$this->sample_data_ajax_adapter  = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1260
-		$this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->linked_data_service, $this->entity_service, $this->relation_service );
1296
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1297
+        $this->rebuild_service = new Wordlift_Rebuild_Service(
1298
+            $this->sparql_service,
1299
+            $uri_service
1300
+        );
1261 1301
 
1262
-		// Initialize the short-codes.
1263
-		new Wordlift_Navigator_Shortcode();
1264
-		new Wordlift_Chord_Shortcode();
1265
-		new Wordlift_Geomap_Shortcode();
1266
-		new Wordlift_Timeline_Shortcode();
1267
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1268
-		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1269
-		new Wordlift_Faceted_Search_Shortcode();
1302
+        /** Async Tasks. */
1303
+        new Wordlift_Sparql_Query_Async_Task();
1304
+        new Wordlift_Push_References_Async_Task();
1270 1305
 
1271
-		// Initialize the SEO service.
1272
-		new Wordlift_Seo_Service();
1306
+        /** WordPress Admin UI. */
1273 1307
 
1274
-		// Initialize the AMP service.
1275
-		new Wordlift_AMP_Service( $this->jsonld_service );
1308
+        // UI elements.
1309
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1310
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1311
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1312
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1313
+        $this->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1314
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1315
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1316
+        $this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1276 1317
 
1277
-		/** Services. */
1278
-		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1279
-		new Wordlift_Image_Service();
1318
+        $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 );
1319
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1280 1320
 
1281
-		/** Adapters. */
1282
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1283
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1284
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1285
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1321
+        $this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element );
1322
+        $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page );
1323
+        $this->analytics_connect                   = new Wordlift_Analytics_Connect();
1286 1324
 
1287
-		/*
1288
-		 * Exclude our public js from WP-Rocket.
1289
-		 *
1290
-		 * @since 3.19.4
1291
-		 *
1292
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
1293
-		 */
1294
-		new Wordlift_WpRocket_Adapter();
1295
-
1296
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1297
-		$this->rebuild_service = new Wordlift_Rebuild_Service(
1298
-			$this->sparql_service,
1299
-			$uri_service
1300
-		);
1301
-
1302
-		/** Async Tasks. */
1303
-		new Wordlift_Sparql_Query_Async_Task();
1304
-		new Wordlift_Push_References_Async_Task();
1305
-
1306
-		/** WordPress Admin UI. */
1307
-
1308
-		// UI elements.
1309
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1310
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1311
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1312
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1313
-		$this->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1314
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1315
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1316
-		$this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1317
-
1318
-		$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 );
1319
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1320
-
1321
-		$this->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element );
1322
-		$this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page );
1323
-		$this->analytics_connect                   = new Wordlift_Analytics_Connect();
1324
-
1325
-		// Pages.
1326
-		/*
1325
+        // Pages.
1326
+        /*
1327 1327
 		 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
1328 1328
 		 *
1329 1329
 		 * @since 3.20.3
1330 1330
 		 *
1331 1331
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/914
1332 1332
 		 */
1333
-		if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1334
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1335
-			new Wordlift_Admin_Post_Edit_Page( $this );
1336
-		}
1337
-		new Wordlift_Entity_Type_Admin_Service();
1333
+        if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1334
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1335
+            new Wordlift_Admin_Post_Edit_Page( $this );
1336
+        }
1337
+        new Wordlift_Entity_Type_Admin_Service();
1338 1338
 
1339
-		// create an instance of the entity type list admin page controller.
1340
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1339
+        // create an instance of the entity type list admin page controller.
1340
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1341 1341
 
1342
-		// create an instance of the entity type setting admin page controller.
1343
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1342
+        // create an instance of the entity type setting admin page controller.
1343
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1344 1344
 
1345
-		/** Widgets */
1346
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1345
+        /** Widgets */
1346
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1347 1347
 
1348
-		/* WordPress Admin. */
1349
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1350
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1348
+        /* WordPress Admin. */
1349
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1350
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1351 1351
 
1352
-		// Create an instance of the install wizard.
1353
-		$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 );
1352
+        // Create an instance of the install wizard.
1353
+        $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 );
1354 1354
 
1355
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1355
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1356 1356
 
1357
-		// User Profile.
1358
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1357
+        // User Profile.
1358
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1359 1359
 
1360
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1360
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1361 1361
 
1362
-		// Load the debug service if WP is in debug mode.
1363
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1364
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1365
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1366
-		}
1362
+        // Load the debug service if WP is in debug mode.
1363
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1364
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1365
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1366
+        }
1367 1367
 
1368
-		// Remote Image Service.
1369
-		new Wordlift_Remote_Image_Service();
1368
+        // Remote Image Service.
1369
+        new Wordlift_Remote_Image_Service();
1370 1370
 
1371
-		/*
1371
+        /*
1372 1372
 		 * Provides mappings between post types and entity types.
1373 1373
 		 *
1374 1374
 		 * @since 3.20.0
1375 1375
 		 *
1376 1376
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/852.
1377 1377
 		 */
1378
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1379
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1380
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1378
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1379
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1380
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1381 1381
 
1382
-		// Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1383
-		new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1382
+        // Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1383
+        new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1384 1384
 
1385
-		/*
1385
+        /*
1386 1386
 		 * Batch Operations. They're similar to Batch Actions but do not require working on post types.
1387 1387
 		 *
1388 1388
 		 * Eventually Batch Actions will become Batch Operations.
1389 1389
 		 *
1390 1390
 		 * @since 3.20.0
1391 1391
 		 */
1392
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1393
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1392
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1393
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1394 1394
 
1395
-		/*
1395
+        /*
1396 1396
 		 * Add the Search Keywords taxonomy to manage the Search Keywords on WLS.
1397 1397
 		 *
1398 1398
 		 * @link https://github.com/insideout10/wordlift-plugin/issues/761
1399 1399
 		 *
1400 1400
 		 * @since 3.20.0
1401 1401
 		 */
1402
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1403
-		new Wordlift_Search_Keyword_Taxonomy( $api_service );
1402
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php';
1403
+        new Wordlift_Search_Keyword_Taxonomy( $api_service );
1404 1404
 
1405
-		/*
1405
+        /*
1406 1406
 		 * Load dependencies for the front-end.
1407 1407
 		 *
1408 1408
 		 * @since 3.20.0
1409 1409
 		 */
1410
-		if ( ! is_admin() ) {
1411
-			/*
1410
+        if ( ! is_admin() ) {
1411
+            /*
1412 1412
 			 * Load the `Wordlift_Term_JsonLd_Adapter`.
1413 1413
 			 *
1414 1414
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/892
1415 1415
 			 *
1416 1416
 			 * @since 3.20.0
1417 1417
 			 */
1418
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1419
-			new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service );
1420
-		}
1418
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1419
+            new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service );
1420
+        }
1421 1421
 
1422
-		/*
1422
+        /*
1423 1423
 		 * Initialize the Context Cards Service
1424 1424
 		 *
1425 1425
 		 * @link https://github.com/insideout10/wordlift-plugin/issues/934
1426 1426
 		 *
1427 1427
 		 * @since 3.22.0
1428 1428
 		 */
1429
-		$this->context_cards_service = new Wordlift_Context_Cards_Service();
1429
+        $this->context_cards_service = new Wordlift_Context_Cards_Service();
1430 1430
 
1431
-		/*
1431
+        /*
1432 1432
 		 * Load the Mappings JSON-LD post processing.
1433 1433
 		 *
1434 1434
 		 * @since 3.25.0
1435 1435
 		 */
1436 1436
 
1437
-		$mappings_dbo           = new Mappings_DBO();
1438
-		$default_rule_validator = new Taxonomy_Rule_Validator();
1439
-		new Post_Type_Rule_Validator();
1440
-		$rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1441
-		$rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1442
-		$mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1437
+        $mappings_dbo           = new Mappings_DBO();
1438
+        $default_rule_validator = new Taxonomy_Rule_Validator();
1439
+        new Post_Type_Rule_Validator();
1440
+        $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1441
+        $rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1442
+        $mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1443 1443
 
1444
-		new Url_To_Entity_Transform_Function( $this->entity_uri_service );
1445
-		new Taxonomy_To_Terms_Transform_Function();
1446
-		$mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1444
+        new Url_To_Entity_Transform_Function( $this->entity_uri_service );
1445
+        new Taxonomy_To_Terms_Transform_Function();
1446
+        $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1447 1447
 
1448
-		new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1448
+        new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1449 1449
 
1450
-		/*
1450
+        /*
1451 1451
 		 * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php
1452 1452
 		 * end-point.
1453 1453
 		 *
1454 1454
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/834
1455 1455
 		 * @since 3.24.4
1456 1456
 		 */
1457
-		new Templates_Ajax_Endpoint();
1457
+        new Templates_Ajax_Endpoint();
1458 1458
 
1459
-		/*
1459
+        /*
1460 1460
 		 * Create a singleton for the Analysis_Response_Ops_Factory.
1461 1461
 		 */
1462
-		$entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service );
1463
-		new Analysis_Response_Ops_Factory(
1464
-			$this->entity_uri_service,
1465
-			$this->entity_service,
1466
-			$this->entity_type_service,
1467
-			$this->storage_factory->post_images(),
1468
-			$entity_helper
1469
-		);
1470
-
1471
-		/** WL Autocomplete. */
1472
-		$autocomplete_service       = new All_Autocomplete_Service( array(
1473
-			new Local_Autocomplete_Service(),
1474
-			new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ),
1475
-		) );
1476
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1477
-
1478
-	}
1479
-
1480
-	/**
1481
-	 * Define the locale for this plugin for internationalization.
1482
-	 *
1483
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1484
-	 * with WordPress.
1485
-	 *
1486
-	 * @since    1.0.0
1487
-	 * @access   private
1488
-	 */
1489
-	private function set_locale() {
1490
-
1491
-		$plugin_i18n = new Wordlift_i18n();
1492
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1493
-
1494
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1495
-
1496
-	}
1497
-
1498
-	/**
1499
-	 * Register all of the hooks related to the admin area functionality
1500
-	 * of the plugin.
1501
-	 *
1502
-	 * @since    1.0.0
1503
-	 * @access   private
1504
-	 */
1505
-	private function define_admin_hooks() {
1506
-
1507
-		$plugin_admin = new Wordlift_Admin(
1508
-			$this->get_plugin_name(),
1509
-			$this->get_version(),
1510
-			$this->configuration_service,
1511
-			$this->notice_service,
1512
-			$this->user_service
1513
-		);
1514
-
1515
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1516
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1517
-
1518
-		// Hook the init action to taxonomy services.
1519
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1520
-		$this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1521
-
1522
-		// Hook the deleted_post_meta action to the Thumbnail service.
1523
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1524
-
1525
-		// Hook the added_post_meta action to the Thumbnail service.
1526
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1527
-
1528
-		// Hook the updated_post_meta action to the Thumbnail service.
1529
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1530
-
1531
-		// Hook the AJAX wl_timeline action to the Timeline service.
1532
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1533
-
1534
-		// Register custom allowed redirect hosts.
1535
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1536
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1537
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1538
-
1539
-		/*
1462
+        $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service );
1463
+        new Analysis_Response_Ops_Factory(
1464
+            $this->entity_uri_service,
1465
+            $this->entity_service,
1466
+            $this->entity_type_service,
1467
+            $this->storage_factory->post_images(),
1468
+            $entity_helper
1469
+        );
1470
+
1471
+        /** WL Autocomplete. */
1472
+        $autocomplete_service       = new All_Autocomplete_Service( array(
1473
+            new Local_Autocomplete_Service(),
1474
+            new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ),
1475
+        ) );
1476
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1477
+
1478
+    }
1479
+
1480
+    /**
1481
+     * Define the locale for this plugin for internationalization.
1482
+     *
1483
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1484
+     * with WordPress.
1485
+     *
1486
+     * @since    1.0.0
1487
+     * @access   private
1488
+     */
1489
+    private function set_locale() {
1490
+
1491
+        $plugin_i18n = new Wordlift_i18n();
1492
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1493
+
1494
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1495
+
1496
+    }
1497
+
1498
+    /**
1499
+     * Register all of the hooks related to the admin area functionality
1500
+     * of the plugin.
1501
+     *
1502
+     * @since    1.0.0
1503
+     * @access   private
1504
+     */
1505
+    private function define_admin_hooks() {
1506
+
1507
+        $plugin_admin = new Wordlift_Admin(
1508
+            $this->get_plugin_name(),
1509
+            $this->get_version(),
1510
+            $this->configuration_service,
1511
+            $this->notice_service,
1512
+            $this->user_service
1513
+        );
1514
+
1515
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1516
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1517
+
1518
+        // Hook the init action to taxonomy services.
1519
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1520
+        $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1521
+
1522
+        // Hook the deleted_post_meta action to the Thumbnail service.
1523
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1524
+
1525
+        // Hook the added_post_meta action to the Thumbnail service.
1526
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1527
+
1528
+        // Hook the updated_post_meta action to the Thumbnail service.
1529
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1530
+
1531
+        // Hook the AJAX wl_timeline action to the Timeline service.
1532
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1533
+
1534
+        // Register custom allowed redirect hosts.
1535
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1536
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1537
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1538
+
1539
+        /*
1540 1540
 		 * The old dashboard is replaced with dashboard v2.
1541 1541
 		 *
1542 1542
 		 * The old dashboard service is still loaded because its functions are used.
@@ -1545,306 +1545,306 @@  discard block
 block discarded – undo
1545 1545
 		 *
1546 1546
 		 * @since 3.20.0
1547 1547
 		 */
1548
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1549
-		// $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1550
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1551
-		// $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1552
-
1553
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1554
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1555
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1556
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1557
-
1558
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1559
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1560
-
1561
-		// Entity listing customization (wp-admin/edit.php)
1562
-		// Add custom columns.
1563
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1564
-		// no explicit entity as it prevents handling of other post types.
1565
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1566
-		// Add 4W selection.
1567
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1568
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1569
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1570
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1571
-
1572
-		/*
1548
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1549
+        // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1550
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1551
+        // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1552
+
1553
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1554
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1555
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1556
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1557
+
1558
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1559
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1560
+
1561
+        // Entity listing customization (wp-admin/edit.php)
1562
+        // Add custom columns.
1563
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1564
+        // no explicit entity as it prevents handling of other post types.
1565
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1566
+        // Add 4W selection.
1567
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1568
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1569
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1570
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1571
+
1572
+        /*
1573 1573
 		 * If `All Entity Types` is disable, use the radio button Walker.
1574 1574
 		 *
1575 1575
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1576 1576
 		 */
1577
-		if ( ! WL_ALL_ENTITY_TYPES ) {
1578
-			$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1579
-		}
1577
+        if ( ! WL_ALL_ENTITY_TYPES ) {
1578
+            $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1579
+        }
1580 1580
 
1581
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1582
-		// entities.
1583
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1581
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1582
+        // entities.
1583
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1584 1584
 
1585
-		// Filter imported post meta.
1586
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1585
+        // Filter imported post meta.
1586
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1587 1587
 
1588
-		// Notify the import service when an import starts and ends.
1589
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1590
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1588
+        // Notify the import service when an import starts and ends.
1589
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1590
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1591 1591
 
1592
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1593
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1594
-		$this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1592
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1593
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1594
+        $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1595 1595
 
1596
-		// Hook the menu to the Download Your Data page.
1597
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1598
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1599
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1596
+        // Hook the menu to the Download Your Data page.
1597
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1598
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1599
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1600 1600
 
1601
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1602
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1601
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1602
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1603 1603
 
1604
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1605
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1606
-		$this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1607
-		$this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1604
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1605
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1606
+        $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1607
+        $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1608 1608
 
1609
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1610
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1609
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1610
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1611 1611
 
1612
-		// Hook the AJAX wl_update_country_options action to the countries.
1613
-		$this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' );
1612
+        // Hook the AJAX wl_update_country_options action to the countries.
1613
+        $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' );
1614 1614
 
1615
-		// Hook the `admin_init` function to the Admin Setup.
1616
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1615
+        // Hook the `admin_init` function to the Admin Setup.
1616
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1617 1617
 
1618
-		// Hook the admin_init to the settings page.
1619
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1620
-		$this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' );
1618
+        // Hook the admin_init to the settings page.
1619
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1620
+        $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' );
1621 1621
 
1622
-		$this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1622
+        $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1623 1623
 
1624
-		// Hook the menu creation on the general wordlift menu creation.
1625
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1624
+        // Hook the menu creation on the general wordlift menu creation.
1625
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1626 1626
 
1627
-		/*
1627
+        /*
1628 1628
 		 * Display the `Wordlift_Admin_Search_Rankings_Page` page.
1629 1629
 		 *
1630 1630
 		 * @link https://github.com/insideout10/wordlift-plugin/issues/761
1631 1631
 		 *
1632 1632
 		 * @since 3.20.0
1633 1633
 		 */
1634
-		if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) {
1635
-			$admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page();
1636
-			$this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' );
1637
-		}
1634
+        if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) {
1635
+            $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page();
1636
+            $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' );
1637
+        }
1638 1638
 
1639
-		// Hook key update.
1640
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1641
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1639
+        // Hook key update.
1640
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1641
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1642 1642
 
1643
-		// Add additional action links to the WordLift plugin in the plugins page.
1644
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1643
+        // Add additional action links to the WordLift plugin in the plugins page.
1644
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1645 1645
 
1646
-		/*
1646
+        /*
1647 1647
 		 * Remove the Analytics Settings link from the plugin page.
1648 1648
 		 *
1649 1649
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/932
1650 1650
 		 * @since 3.21.1
1651 1651
 		 */
1652
-		// $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 );
1652
+        // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 );
1653 1653
 
1654
-		// Hook the AJAX `wl_publisher` action name.
1655
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1654
+        // Hook the AJAX `wl_publisher` action name.
1655
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1656 1656
 
1657
-		// Hook row actions for the entity type list admin.
1658
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1657
+        // Hook row actions for the entity type list admin.
1658
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1659 1659
 
1660
-		/** Ajax actions. */
1661
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1660
+        /** Ajax actions. */
1661
+        $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1662 1662
 
1663
-		// Hook capabilities manipulation to allow access to entity type admin
1664
-		// page  on WordPress versions before 4.7.
1665
-		global $wp_version;
1666
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1667
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1668
-		}
1663
+        // Hook capabilities manipulation to allow access to entity type admin
1664
+        // page  on WordPress versions before 4.7.
1665
+        global $wp_version;
1666
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1667
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1668
+        }
1669 1669
 
1670
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1670
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1671 1671
 
1672
-		/** Adapters. */
1673
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1674
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1672
+        /** Adapters. */
1673
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1674
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1675 1675
 
1676
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1677
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1676
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1677
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1678 1678
 
1679 1679
 
1680
-		$this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1681
-		$this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1680
+        $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1681
+        $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1682 1682
 
1683
-		// Handle the autocomplete request.
1684
-		add_action( 'wp_ajax_wl_autocomplete', array(
1685
-			$this->autocomplete_adapter,
1686
-			'wl_autocomplete',
1687
-		) );
1688
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1689
-			$this->autocomplete_adapter,
1690
-			'wl_autocomplete',
1691
-		) );
1683
+        // Handle the autocomplete request.
1684
+        add_action( 'wp_ajax_wl_autocomplete', array(
1685
+            $this->autocomplete_adapter,
1686
+            'wl_autocomplete',
1687
+        ) );
1688
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1689
+            $this->autocomplete_adapter,
1690
+            'wl_autocomplete',
1691
+        ) );
1692 1692
 
1693
-		// Hooks to restrict multisite super admin from manipulating entity types.
1694
-		if ( is_multisite() ) {
1695
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1696
-		}
1693
+        // Hooks to restrict multisite super admin from manipulating entity types.
1694
+        if ( is_multisite() ) {
1695
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1696
+        }
1697 1697
 
1698
-		$deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1698
+        $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1699 1699
 
1700
-		add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1701
-		add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1702
-		add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1703
-
1704
-		/**
1705
-		 * Always allow the `wordlift/classification` block.
1706
-		 *
1707
-		 * @since 3.23.0
1708
-		 */
1709
-		add_filter( 'allowed_block_types', function ( $value ) {
1700
+        add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1701
+        add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1702
+        add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1710 1703
 
1711
-			if ( true === $value ) {
1712
-				return $value;
1713
-			}
1704
+        /**
1705
+         * Always allow the `wordlift/classification` block.
1706
+         *
1707
+         * @since 3.23.0
1708
+         */
1709
+        add_filter( 'allowed_block_types', function ( $value ) {
1714 1710
 
1715
-			return array_merge( (array) $value, array( 'wordlift/classification' ) );
1716
-		}, PHP_INT_MAX );
1711
+            if ( true === $value ) {
1712
+                return $value;
1713
+            }
1717 1714
 
1718
-	}
1715
+            return array_merge( (array) $value, array( 'wordlift/classification' ) );
1716
+        }, PHP_INT_MAX );
1719 1717
 
1720
-	/**
1721
-	 * Register all of the hooks related to the public-facing functionality
1722
-	 * of the plugin.
1723
-	 *
1724
-	 * @since    1.0.0
1725
-	 * @access   private
1726
-	 */
1727
-	private function define_public_hooks() {
1718
+    }
1728 1719
 
1729
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1720
+    /**
1721
+     * Register all of the hooks related to the public-facing functionality
1722
+     * of the plugin.
1723
+     *
1724
+     * @since    1.0.0
1725
+     * @access   private
1726
+     */
1727
+    private function define_public_hooks() {
1730 1728
 
1731
-		// Register the entity post type.
1732
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1729
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1733 1730
 
1734
-		// Bind the link generation and handling hooks to the entity link service.
1735
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1736
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1737
-		$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 );
1738
-		$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 );
1731
+        // Register the entity post type.
1732
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1739 1733
 
1740
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1741
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1742
-		$this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' );
1734
+        // Bind the link generation and handling hooks to the entity link service.
1735
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1736
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1737
+        $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 );
1738
+        $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 );
1743 1739
 
1744
-		// Hook the content filter service to add entity links.
1745
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1746
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1747
-		}
1740
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1741
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1742
+        $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' );
1748 1743
 
1749
-		// Hook the AJAX wl_timeline action to the Timeline service.
1750
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1744
+        // Hook the content filter service to add entity links.
1745
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1746
+            $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1747
+        }
1751 1748
 
1752
-		// Hook the ShareThis service.
1753
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1754
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1749
+        // Hook the AJAX wl_timeline action to the Timeline service.
1750
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1755 1751
 
1756
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1757
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1752
+        // Hook the ShareThis service.
1753
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1754
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1758 1755
 
1759
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1760
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1761
-		// to categories.
1762
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1756
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1757
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1763 1758
 
1764
-		/*
1759
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1760
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1761
+        // to categories.
1762
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1763
+
1764
+        /*
1765 1765
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1766 1766
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1767 1767
 		 * order of start time.
1768 1768
 		 */
1769
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1770
-
1771
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1772
-
1773
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1774
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1775
-
1776
-		// Analytics Script Frontend.
1777
-		if ( $this->configuration_service->is_analytics_enable() ) {
1778
-			$this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 );
1779
-		}
1780
-
1781
-	}
1782
-
1783
-	/**
1784
-	 * Run the loader to execute all of the hooks with WordPress.
1785
-	 *
1786
-	 * @since    1.0.0
1787
-	 */
1788
-	public function run() {
1789
-		$this->loader->run();
1790
-	}
1791
-
1792
-	/**
1793
-	 * The name of the plugin used to uniquely identify it within the context of
1794
-	 * WordPress and to define internationalization functionality.
1795
-	 *
1796
-	 * @return    string    The name of the plugin.
1797
-	 * @since     1.0.0
1798
-	 */
1799
-	public function get_plugin_name() {
1800
-		return $this->plugin_name;
1801
-	}
1802
-
1803
-	/**
1804
-	 * The reference to the class that orchestrates the hooks with the plugin.
1805
-	 *
1806
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1807
-	 * @since     1.0.0
1808
-	 */
1809
-	public function get_loader() {
1810
-		return $this->loader;
1811
-	}
1812
-
1813
-	/**
1814
-	 * Retrieve the version number of the plugin.
1815
-	 *
1816
-	 * @return    string    The version number of the plugin.
1817
-	 * @since     1.0.0
1818
-	 */
1819
-	public function get_version() {
1820
-		return $this->version;
1821
-	}
1822
-
1823
-	/**
1824
-	 * Load dependencies for WP-CLI.
1825
-	 *
1826
-	 * @throws Exception
1827
-	 * @since 3.18.0
1828
-	 */
1829
-	private function load_cli_dependencies() {
1830
-
1831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1832
-
1833
-		$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 );
1834
-
1835
-		WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1836
-
1837
-	}
1838
-
1839
-	/**
1840
-	 * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions.
1841
-	 *
1842
-	 * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance.
1843
-	 * @since 3.20.0
1844
-	 */
1845
-	public function get_dashboard_service() {
1846
-
1847
-		return $this->dashboard_service;
1848
-	}
1769
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1770
+
1771
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1772
+
1773
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1774
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1775
+
1776
+        // Analytics Script Frontend.
1777
+        if ( $this->configuration_service->is_analytics_enable() ) {
1778
+            $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 );
1779
+        }
1780
+
1781
+    }
1782
+
1783
+    /**
1784
+     * Run the loader to execute all of the hooks with WordPress.
1785
+     *
1786
+     * @since    1.0.0
1787
+     */
1788
+    public function run() {
1789
+        $this->loader->run();
1790
+    }
1791
+
1792
+    /**
1793
+     * The name of the plugin used to uniquely identify it within the context of
1794
+     * WordPress and to define internationalization functionality.
1795
+     *
1796
+     * @return    string    The name of the plugin.
1797
+     * @since     1.0.0
1798
+     */
1799
+    public function get_plugin_name() {
1800
+        return $this->plugin_name;
1801
+    }
1802
+
1803
+    /**
1804
+     * The reference to the class that orchestrates the hooks with the plugin.
1805
+     *
1806
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1807
+     * @since     1.0.0
1808
+     */
1809
+    public function get_loader() {
1810
+        return $this->loader;
1811
+    }
1812
+
1813
+    /**
1814
+     * Retrieve the version number of the plugin.
1815
+     *
1816
+     * @return    string    The version number of the plugin.
1817
+     * @since     1.0.0
1818
+     */
1819
+    public function get_version() {
1820
+        return $this->version;
1821
+    }
1822
+
1823
+    /**
1824
+     * Load dependencies for WP-CLI.
1825
+     *
1826
+     * @throws Exception
1827
+     * @since 3.18.0
1828
+     */
1829
+    private function load_cli_dependencies() {
1830
+
1831
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1832
+
1833
+        $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 );
1834
+
1835
+        WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1836
+
1837
+    }
1838
+
1839
+    /**
1840
+     * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions.
1841
+     *
1842
+     * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance.
1843
+     * @since 3.20.0
1844
+     */
1845
+    public function get_dashboard_service() {
1846
+
1847
+        return $this->dashboard_service;
1848
+    }
1849 1849
 
1850 1850
 }
Please login to merge, or discard this patch.