Completed
Push — develop ( 73c132...baaab2 )
by David
03:02
created
src/admin/wordlift_admin_menu.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
  */
12 12
 function wl_admin_menu() {
13 13
 
14
-	$menu_slug  = 'wl_admin_menu';
15
-	$capability = 'manage_options';
16
-
17
-	// see http://codex.wordpress.org/Function_Reference/add_menu_page
18
-	add_menu_page(
19
-		__( 'WordLift', 'wordlift' ), // page title
20
-		__( 'WordLift', 'wordlift' ), // menu title
21
-		$capability,                 // capabilities
22
-		$menu_slug,                  // menu slug
23
-		//'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
24
-		'wl_configuration_admin_menu_callback',
25
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px	
14
+    $menu_slug  = 'wl_admin_menu';
15
+    $capability = 'manage_options';
16
+
17
+    // see http://codex.wordpress.org/Function_Reference/add_menu_page
18
+    add_menu_page(
19
+        __( 'WordLift', 'wordlift' ), // page title
20
+        __( 'WordLift', 'wordlift' ), // menu title
21
+        $capability,                 // capabilities
22
+        $menu_slug,                  // menu slug
23
+        //'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
24
+        'wl_configuration_admin_menu_callback',
25
+        WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px	
26 26
 	
27
-	// Call hooked functions.
28
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
27
+    // Call hooked functions.
28
+    do_action( 'wl_admin_menu', $menu_slug, $capability );
29 29
 	
30
-	// Remove duplicate 'WordLift' subpage created by WordPress. 
31
-	remove_submenu_page( $menu_slug, $menu_slug );
30
+    // Remove duplicate 'WordLift' subpage created by WordPress. 
31
+    remove_submenu_page( $menu_slug, $menu_slug );
32 32
 	
33 33
 }
34 34
 
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function wl_admin_menu_callback() {
43 43
 
44
-	if ( ! current_user_can( 'manage_options' ) ) {
45
-		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
46
-	}
44
+    if ( ! current_user_can( 'manage_options' ) ) {
45
+        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
46
+    }
47 47
 
48
-	echo '<div class="wrap">';
49
-	echo '<p>Here is where the form would go if I actually had options.</p>';
50
-	echo '</div>';
48
+    echo '<div class="wrap">';
49
+    echo '<p>Here is where the form would go if I actually had options.</p>';
50
+    echo '</div>';
51 51
 
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-download-your-data.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
15 15
 
16 16
 <div class="wrap">
17
-	<h2><?php _ex( 'Download Your Data', 'Page title', 'wordlift' ); ?></h2>
18
-	<p><?php esc_html_e( 'Choose the format to download your data:', 'wordlift' ); ?></p>
17
+	<h2><?php _ex('Download Your Data', 'Page title', 'wordlift'); ?></h2>
18
+	<p><?php esc_html_e('Choose the format to download your data:', 'wordlift'); ?></p>
19 19
 
20
-	<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=wl_download_your_data&out=json' ) ); ?>"
21
-	   class="button wl-add-input wl-button"><?php esc_html_e( 'JSON-LD', 'wordlift' ); ?></a>
22
-	<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=wl_download_your_data&out=rdf' ) ); ?>"
23
-	   class="button wl-add-input wl-button"><?php esc_html_e( 'RDF/XML', 'wordlift' ); ?></a>
24
-	<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=wl_download_your_data&out=ttl' ) ); ?>"
25
-	   class="button wl-add-input wl-button"><?php _ex( 'Turtle', 'File format, not the animal', 'wordlift' ); ?></a>
26
-	<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=wl_download_your_data&out=n3' ) ); ?>"
27
-	   class="button wl-add-input wl-button"><?php esc_html_e( 'N3', 'wordlift' ); ?></a>
20
+	<a href="<?php echo esc_url(admin_url('admin-ajax.php?action=wl_download_your_data&out=json')); ?>"
21
+	   class="button wl-add-input wl-button"><?php esc_html_e('JSON-LD', 'wordlift'); ?></a>
22
+	<a href="<?php echo esc_url(admin_url('admin-ajax.php?action=wl_download_your_data&out=rdf')); ?>"
23
+	   class="button wl-add-input wl-button"><?php esc_html_e('RDF/XML', 'wordlift'); ?></a>
24
+	<a href="<?php echo esc_url(admin_url('admin-ajax.php?action=wl_download_your_data&out=ttl')); ?>"
25
+	   class="button wl-add-input wl-button"><?php _ex('Turtle', 'File format, not the animal', 'wordlift'); ?></a>
26
+	<a href="<?php echo esc_url(admin_url('admin-ajax.php?action=wl_download_your_data&out=n3')); ?>"
27
+	   class="button wl-add-input wl-button"><?php esc_html_e('N3', 'wordlift'); ?></a>
28 28
 </div>
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,6 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @since 3.2.0
155 155
 	 *
156 156
 	 * @param \Wordlift_UI_Service $ui_service The UI service.
157
+	 * @param Wordlift_Schema_Service $schema_service
158
+	 * @param Wordlift_Notice_Service $notice_service
157 159
 	 */
158 160
 	public function __construct( $ui_service, $schema_service, $notice_service ) {
159 161
 
@@ -386,7 +388,7 @@  discard block
 block discarded – undo
386 388
 	 *
387 389
 	 * @param int $uri An uri.
388 390
 	 *
389
-	 * @return true if the uri internal to the current dataset otherwise false.
391
+	 * @return boolean if the uri internal to the current dataset otherwise false.
390 392
 	 */
391 393
 	public function is_internal_uri( $uri ) {
392 394
 
@@ -558,7 +560,6 @@  discard block
 block discarded – undo
558 560
 	 *
559 561
 	 * @since 3.3.0
560 562
 	 *
561
-	 * @param WP_Post $post Post object.
562 563
 	 */
563 564
 	public function in_admin_header() {
564 565
 
@@ -626,7 +627,6 @@  discard block
 block discarded – undo
626 627
 	 * @since 3.3.0
627 628
 	 *
628 629
 	 * @param int $post_id      The entity post id.
629
-	 * @param     $force_reload $warnings_needed If true, detailed warnings collection is provided with the rating obj.
630 630
 	 *
631 631
 	 * @return int An array representing the rating obj.
632 632
 	 */
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 *
814 814
 	 * @param int $score The rating score for a given entity.
815 815
 	 *
816
-	 * @return string The input HTML code.
816
+	 * @return double The input HTML code.
817 817
 	 */
818 818
 	public function convert_raw_score_to_percentage( $score ) {
819 819
 		// RATING_MAX : $score = 100 : x 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 * @param null   $logo     The entity logo id (or NULL if none).
859 859
 	 * @param string $status   The post status, by default 'publish'.
860 860
 	 *
861
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
861
+	 * @return integer The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
862 862
 	 */
863 863
 	public function create( $name, $type_uri, $logo = NULL, $status = 'publish' ) {
864 864
 
Please login to merge, or discard this patch.
Indentation   +873 added lines, -873 removed lines patch added patch discarded remove patch
@@ -7,883 +7,883 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Entity_Service {
9 9
 
10
-	/**
11
-	 * The Log service.
12
-	 *
13
-	 * @since  3.2.0
14
-	 * @access private
15
-	 * @var \Wordlift_Log_Service $log_service The Log service.
16
-	 */
17
-	private $log_service;
18
-
19
-	/**
20
-	 * The UI service.
21
-	 *
22
-	 * @since  3.2.0
23
-	 * @access private
24
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
25
-	 */
26
-	private $ui_service;
27
-
28
-	/**
29
-	 * The Schema service.
30
-	 *
31
-	 * @since  3.3.0
32
-	 * @access private
33
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
34
-	 */
35
-	private $schema_service;
36
-
37
-	/**
38
-	 * The Notice service.
39
-	 *
40
-	 * @since  3.3.0
41
-	 * @access private
42
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
43
-	 */
44
-	private $notice_service;
45
-
46
-	/**
47
-	 * The entity post type name.
48
-	 *
49
-	 * @since 3.1.0
50
-	 */
51
-	const TYPE_NAME = 'entity';
52
-
53
-	/**
54
-	 * Entity rating max.
55
-	 *
56
-	 * @since 3.3.0
57
-	 */
58
-	const RATING_MAX = 7;
59
-
60
-	/**
61
-	 * Entity rating score meta key.
62
-	 *
63
-	 * @since 3.3.0
64
-	 */
65
-	const RATING_RAW_SCORE_META_KEY = '_wl_entity_rating_raw_score';
66
-
67
-	/**
68
-	 * Entity rating warnings meta key.
69
-	 *
70
-	 * @since 3.3.0
71
-	 */
72
-	const RATING_WARNINGS_META_KEY = '_wl_entity_rating_warnings';
73
-
74
-	/**
75
-	 * Entity warning has related post identifier.
76
-	 *
77
-	 * @since 3.3.0
78
-	 */
79
-	const RATING_WARNING_HAS_RELATED_POSTS = 'There are no related posts for the current entity.';
80
-
81
-	/**
82
-	 * Entity warning has content post identifier.
83
-	 *
84
-	 * @since 3.3.0
85
-	 */
86
-	const RATING_WARNING_HAS_CONTENT_POST = 'This entity has not description.';
87
-
88
-	/**
89
-	 * Entity warning has related entities identifier.
90
-	 *
91
-	 * @since 3.3.0
92
-	 */
93
-	const RATING_WARNING_HAS_RELATED_ENTITIES = 'There are no related entities for the current entity.';
94
-
95
-	/**
96
-	 * Entity warning is published identifier.
97
-	 *
98
-	 * @since 3.3.0
99
-	 */
100
-	const RATING_WARNING_IS_PUBLISHED = 'This entity is not published. It will not appear within analysis results.';
101
-
102
-	/**
103
-	 * Entity warning has thumbnail identifier.
104
-	 *
105
-	 * @since 3.3.0
106
-	 */
107
-	const RATING_WARNING_HAS_THUMBNAIL = 'This entity has no featured image yet.';
108
-
109
-	/**
110
-	 * Entity warning has same as identifier.
111
-	 *
112
-	 * @since 3.3.0
113
-	 */
114
-	const RATING_WARNING_HAS_SAME_AS = 'There are no sameAs configured for this entity.';
115
-
116
-	/**
117
-	 * Entity warning has completed metadata identifier.
118
-	 *
119
-	 * @since 3.3.0
120
-	 */
121
-	const RATING_WARNING_HAS_COMPLETED_METADATA = 'Schema.org metadata for this entity are not completed.';
122
-
123
-	/**
124
-	 * The alternative label meta key.
125
-	 *
126
-	 * @since 3.2.0
127
-	 */
128
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
129
-
130
-	/**
131
-	 * The alternative label input template.
132
-	 *
133
-	 * @since 3.2.0
134
-	 */
135
-	// TODO: this should be moved to a class that deals with HTML code.
136
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
10
+    /**
11
+     * The Log service.
12
+     *
13
+     * @since  3.2.0
14
+     * @access private
15
+     * @var \Wordlift_Log_Service $log_service The Log service.
16
+     */
17
+    private $log_service;
18
+
19
+    /**
20
+     * The UI service.
21
+     *
22
+     * @since  3.2.0
23
+     * @access private
24
+     * @var \Wordlift_UI_Service $ui_service The UI service.
25
+     */
26
+    private $ui_service;
27
+
28
+    /**
29
+     * The Schema service.
30
+     *
31
+     * @since  3.3.0
32
+     * @access private
33
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
34
+     */
35
+    private $schema_service;
36
+
37
+    /**
38
+     * The Notice service.
39
+     *
40
+     * @since  3.3.0
41
+     * @access private
42
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
43
+     */
44
+    private $notice_service;
45
+
46
+    /**
47
+     * The entity post type name.
48
+     *
49
+     * @since 3.1.0
50
+     */
51
+    const TYPE_NAME = 'entity';
52
+
53
+    /**
54
+     * Entity rating max.
55
+     *
56
+     * @since 3.3.0
57
+     */
58
+    const RATING_MAX = 7;
59
+
60
+    /**
61
+     * Entity rating score meta key.
62
+     *
63
+     * @since 3.3.0
64
+     */
65
+    const RATING_RAW_SCORE_META_KEY = '_wl_entity_rating_raw_score';
66
+
67
+    /**
68
+     * Entity rating warnings meta key.
69
+     *
70
+     * @since 3.3.0
71
+     */
72
+    const RATING_WARNINGS_META_KEY = '_wl_entity_rating_warnings';
73
+
74
+    /**
75
+     * Entity warning has related post identifier.
76
+     *
77
+     * @since 3.3.0
78
+     */
79
+    const RATING_WARNING_HAS_RELATED_POSTS = 'There are no related posts for the current entity.';
80
+
81
+    /**
82
+     * Entity warning has content post identifier.
83
+     *
84
+     * @since 3.3.0
85
+     */
86
+    const RATING_WARNING_HAS_CONTENT_POST = 'This entity has not description.';
87
+
88
+    /**
89
+     * Entity warning has related entities identifier.
90
+     *
91
+     * @since 3.3.0
92
+     */
93
+    const RATING_WARNING_HAS_RELATED_ENTITIES = 'There are no related entities for the current entity.';
94
+
95
+    /**
96
+     * Entity warning is published identifier.
97
+     *
98
+     * @since 3.3.0
99
+     */
100
+    const RATING_WARNING_IS_PUBLISHED = 'This entity is not published. It will not appear within analysis results.';
101
+
102
+    /**
103
+     * Entity warning has thumbnail identifier.
104
+     *
105
+     * @since 3.3.0
106
+     */
107
+    const RATING_WARNING_HAS_THUMBNAIL = 'This entity has no featured image yet.';
108
+
109
+    /**
110
+     * Entity warning has same as identifier.
111
+     *
112
+     * @since 3.3.0
113
+     */
114
+    const RATING_WARNING_HAS_SAME_AS = 'There are no sameAs configured for this entity.';
115
+
116
+    /**
117
+     * Entity warning has completed metadata identifier.
118
+     *
119
+     * @since 3.3.0
120
+     */
121
+    const RATING_WARNING_HAS_COMPLETED_METADATA = 'Schema.org metadata for this entity are not completed.';
122
+
123
+    /**
124
+     * The alternative label meta key.
125
+     *
126
+     * @since 3.2.0
127
+     */
128
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
129
+
130
+    /**
131
+     * The alternative label input template.
132
+     *
133
+     * @since 3.2.0
134
+     */
135
+    // TODO: this should be moved to a class that deals with HTML code.
136
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
137 137
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
138 138
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
139 139
                 <button class="button wl-delete-button">%s</button>
140 140
                 </div>';
141 141
 
142
-	/**
143
-	 * A singleton instance of the Entity service.
144
-	 *
145
-	 * @since  3.2.0
146
-	 * @access private
147
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
148
-	 */
149
-	private static $instance;
150
-
151
-	/**
152
-	 * Create a Wordlift_Entity_Service instance.
153
-	 *
154
-	 * @since 3.2.0
155
-	 *
156
-	 * @param \Wordlift_UI_Service $ui_service The UI service.
157
-	 */
158
-	public function __construct( $ui_service, $schema_service, $notice_service ) {
159
-
160
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
161
-
162
-		// Set the UI service.
163
-		$this->ui_service = $ui_service;
164
-
165
-		// Set the Schema service.
166
-		$this->schema_service = $schema_service;
167
-
168
-		// Set the Schema service.
169
-		$this->notice_service = $notice_service;
170
-
171
-		// Set the singleton instance.
172
-		self::$instance = $this;
173
-
174
-	}
175
-
176
-	/**
177
-	 * Get the singleton instance of the Entity service.
178
-	 *
179
-	 * @since 3.2.0
180
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
181
-	 */
182
-	public static function get_instance() {
183
-
184
-		return self::$instance;
185
-	}
186
-
187
-	/**
188
-	 * Get rating max
189
-	 *
190
-	 * @since 3.3.0
191
-	 *
192
-	 * @return int Max rating according to performed checks.
193
-	 */
194
-	public static function get_rating_max() {
195
-		return self::RATING_MAX;
196
-	}
197
-
198
-	/**
199
-	 * Get the entities related to the last 50 posts published on this blog (we're keeping a long function name due to
200
-	 * its specific function).
201
-	 *
202
-	 * @since 3.1.0
203
-	 *
204
-	 * @return array An array of post IDs.
205
-	 */
206
-	public function get_all_related_to_last_50_published_posts() {
207
-
208
-		// Global timeline. Get entities from the latest posts.
209
-		$latest_posts_ids = get_posts( array(
210
-			'numberposts' => 50,
211
-			'fields'      => 'ids', //only get post IDs
212
-			'post_type'   => 'post',
213
-			'post_status' => 'publish',
214
-		) );
215
-
216
-		if ( empty( $latest_posts_ids ) ) {
217
-			// There are no posts.
218
-			return array();
219
-		}
220
-
221
-		// Collect entities related to latest posts
222
-		$entity_ids = array();
223
-		foreach ( $latest_posts_ids as $id ) {
224
-			$entity_ids = array_merge( $entity_ids, wl_core_get_related_entity_ids( $id, array(
225
-				'status' => 'publish',
226
-			) ) );
227
-		}
228
-
229
-		return $entity_ids;
230
-	}
231
-
232
-	/**
233
-	 * Determines whether a post is an entity or not.
234
-	 *
235
-	 * @since 3.1.0
236
-	 *
237
-	 * @param int $post_id A post id.
238
-	 *
239
-	 * @return bool Return true if the post is an entity otherwise false.
240
-	 */
241
-	public function is_entity( $post_id ) {
242
-
243
-		return ( self::TYPE_NAME === get_post_type( $post_id ) );
244
-	}
245
-
246
-	/**
247
-	 * Get the proper classification scope for a given entity post
248
-	 *
249
-	 * @since 3.5.0
250
-	 *
251
-	 * @param integer $post_id An entity post id.
252
-	 *
253
-	 * @return string Returns an uri.
254
-	 */
255
-	public function get_classification_scope_for( $post_id ) {
256
-
257
-		if ( FALSE === $this->is_entity( $post_id ) ) {
258
-			return NULL;
259
-		}
260
-		// Retrieve the entity type
261
-		$entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id );
262
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
263
-		// Retrieve classification boxes configuration
264
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
265
-		foreach ( $classification_boxes as $cb ) {
266
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
267
-				return $cb['id'];
268
-			}
269
-		}
270
-
271
-		// or null
272
-		return NULL;
273
-
274
-	}
275
-
276
-	/**
277
-	 * Build an entity uri for a given title
278
-	 * The uri is composed using a given post_type and a title
279
-	 * If already exists an entity e2 with a given uri a numeric suffix is added
280
-	 * If a schema type is given entities with same label and same type are overridden
281
-	 *
282
-	 * @since 3.5.0
283
-	 *
284
-	 * @param string  $title           A post title.
285
-	 * @param string  $post_type       A post type. Default value is 'entity'
286
-	 * @param string  $schema_type     A schema org type.
287
-	 * @param integer $increment_digit A digit used to call recursively the same function.
288
-	 *
289
-	 * @return string Returns an uri.
290
-	 */
291
-	public function build_uri( $title, $post_type, $schema_type = NULL, $increment_digit = 0 ) {
292
-
293
-		// Get the entity slug suffix digit
294
-		$suffix_digit = $increment_digit + 1;
295
-		// Get a sanitized uri for a given title
296
-		$entity_slug = ( 0 == $increment_digit ) ?
297
-			wl_sanitize_uri_path( $title ) :
298
-			wl_sanitize_uri_path( $title . '_' . $suffix_digit );
299
-
300
-		// Compose a candidated uri
301
-		$new_entity_uri = sprintf( '%s/%s/%s',
302
-			wl_configuration_get_redlink_dataset_uri(),
303
-			$post_type,
304
-			$entity_slug
305
-		);
306
-
307
-		$this->log_service->trace( "Going to check if uri is used [ new_entity_uri :: $new_entity_uri ] [ increment_digit :: $increment_digit ]" );
308
-
309
-		global $wpdb;
310
-		// Check if the candidated uri already is used
311
-		$stmt = $wpdb->prepare(
312
-			"SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1",
313
-			WL_ENTITY_URL_META_NAME,
314
-			$new_entity_uri
315
-		);
316
-
317
-		// Perform the query
318
-		$post_id = $wpdb->get_var( $stmt );
319
-
320
-		// If the post does not exist, then the new uri is returned 	
321
-		if ( ! is_numeric( $post_id ) ) {
322
-			$this->log_service->trace( "Going to return uri [ new_entity_uri :: $new_entity_uri ]" );
323
-
324
-			return $new_entity_uri;
325
-		}
326
-		// If schema_type is equal to schema org type of post x, then the new uri is returned 
327
-		$schema_post_type = wl_entity_type_taxonomy_get_type( $post_id );
328
-
329
-		if ( $schema_type === $schema_post_type['css_class'] ) {
330
-			$this->log_service->trace( "An entity with the same title and type already exists! Return uri [ new_entity_uri :: $new_entity_uri ]" );
331
-
332
-			return $new_entity_uri;
333
-		}
334
-
335
-		// Otherwise the same function is called recorsively
336
-		return $this->build_uri( $title, $post_type, $schema_type, ++ $increment_digit );
337
-	}
338
-
339
-	public function is_used( $post_id ) {
340
-
341
-		if ( FALSE === $this->is_entity( $post_id ) ) {
342
-			return NULL;
343
-		}
344
-		// Retrieve the post
345
-		$entity = get_post( $post_id );
346
-
347
-		global $wpdb;
348
-		// Retrieve Wordlift relation instances table name
349
-		$table_name = wl_core_get_relation_instances_table_name();
350
-
351
-		// Check is it's referenced / related to another post / entity
352
-		$stmt = $wpdb->prepare(
353
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
354
-			$entity->ID
355
-		);
356
-
357
-		// Perform the query
358
-		$relation_instances = (int) $wpdb->get_var( $stmt );
359
-		// If there is at least one relation instance for the current entity, then it's used
360
-		if ( 0 < $relation_instances ) {
361
-			return TRUE;
362
-		}
363
-
364
-		// Check if the entity uri is used as meta_value
365
-		$stmt = $wpdb->prepare(
366
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
367
-			$entity->ID,
368
-			wl_get_entity_uri( $entity->ID )
369
-		);
370
-		// Perform the query
371
-		$meta_instances = (int) $wpdb->get_var( $stmt );
372
-
373
-		// If there is at least one meta that refers the current entity uri, then current entity is used
374
-		if ( 0 < $meta_instances ) {
375
-			return TRUE;
376
-		}
377
-
378
-		// If we are here, it means the current entity is not used at the moment
379
-		return FALSE;
380
-	}
381
-
382
-	/**
383
-	 * Determines whether a given uri is an internal uri or not.
384
-	 *
385
-	 * @since 3.3.2
386
-	 *
387
-	 * @param int $uri An uri.
388
-	 *
389
-	 * @return true if the uri internal to the current dataset otherwise false.
390
-	 */
391
-	public function is_internal_uri( $uri ) {
392
-
393
-		return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) );
394
-	}
395
-
396
-	/**
397
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
398
-	 *
399
-	 * @since 3.2.0
400
-	 *
401
-	 * @param string $uri The entity URI.
402
-	 *
403
-	 * @return WP_Post|null A WP_Post instance or null if not found.
404
-	 */
405
-	public function get_entity_post_by_uri( $uri ) {
406
-
407
-		// Check if we've been provided with a value otherwise return null.
408
-		if ( empty( $uri ) ) {
409
-			return NULL;
410
-		}
411
-
412
-		$query_args = array(
413
-			'posts_per_page' => 1,
414
-			'post_status'    => 'any',
415
-			'post_type'      => self::TYPE_NAME,
416
-			'meta_query'     => array(
417
-				array(
418
-					'key'     => WL_ENTITY_URL_META_NAME,
419
-					'value'   => $uri,
420
-					'compare' => '=',
421
-				),
422
-			),
423
-		);
424
-
425
-		// Only if the current uri is not an internal uri 
426
-		// entity search is performed also looking at sameAs values
427
-		// This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237
428
-		if ( ! $this->is_internal_uri( $uri ) ) {
429
-
430
-			$query_args['meta_query']['relation'] = 'OR';
431
-			$query_args['meta_query'][]           = array(
432
-				'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
433
-				'value'   => $uri,
434
-				'compare' => '=',
435
-			);
436
-		}
437
-
438
-		$query = new WP_Query( $query_args );
439
-
440
-		// Get the matching entity posts.
441
-		$posts = $query->get_posts();
442
-
443
-		// Return null if no post is found.
444
-		if ( 0 === count( $posts ) ) {
445
-			return NULL;
446
-		}
447
-
448
-		// Return the found post.
449
-		return $posts[0];
450
-	}
451
-
452
-	/**
453
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
454
-	 * we check that the post we're saving is the current post.
455
-	 *
456
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
457
-	 *
458
-	 * @since 3.2.0
459
-	 *
460
-	 * @param int     $post_id Post ID.
461
-	 * @param WP_Post $post    Post object.
462
-	 * @param bool    $update  Whether this is an existing post being updated or not.
463
-	 */
464
-	public function save_post( $post_id, $post, $update ) {
465
-
466
-		// We're setting the alternative label that have been provided via the UI
467
-		// (in fact we're using $_REQUEST), while save_post may be also called
468
-		// programmatically by some other function: we need to check therefore if
469
-		// the $post_id in the save_post call matches the post id set in the request.
470
-		//
471
-		// If this is not the current post being saved or if it's not an entity, return.
472
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
473
-			return;
474
-		}
475
-
476
-		// Get the alt labels from the request (or empty array).
477
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
478
-
479
-		// Set the alternative labels.
480
-		$this->set_alternative_labels( $post_id, $alt_labels );
481
-
482
-	}
483
-
484
-	/**
485
-	 * Set the alternative labels.
486
-	 *
487
-	 * @since 3.2.0
488
-	 *
489
-	 * @param int   $post_id    The post id.
490
-	 * @param array $alt_labels An array of labels.
491
-	 */
492
-	public function set_alternative_labels( $post_id, $alt_labels ) {
493
-
494
-		// Force $alt_labels to be an array
495
-		if ( ! is_array( $alt_labels ) ) {
496
-			$alt_labels = array( $alt_labels );
497
-		}
498
-
499
-		$this->log_service->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
500
-
501
-		// Delete all the existing alternate labels.
502
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
503
-
504
-		// Set the alternative labels.
505
-		foreach ( $alt_labels as $alt_label ) {
506
-			if ( ! empty( $alt_label ) ) {
507
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
508
-			}
509
-		}
510
-
511
-	}
512
-
513
-	/**
514
-	 * Retrieve the alternate labels.
515
-	 *
516
-	 * @since 3.2.0
517
-	 *
518
-	 * @param int $post_id Post id.
519
-	 *
520
-	 * @return mixed An array  of alternative labels.
521
-	 */
522
-	public function get_alternative_labels( $post_id ) {
523
-
524
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
525
-	}
526
-
527
-	/**
528
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
529
-	 *
530
-	 * @since 3.2.0
531
-	 *
532
-	 * @param WP_Post $post Post object.
533
-	 */
534
-	public function edit_form_before_permalink( $post ) {
535
-
536
-		// If it's not an entity, return.
537
-		if ( ! $this->is_entity( $post->ID ) ) {
538
-			return;
539
-		}
540
-
541
-		// Print the input template.
542
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
543
-
544
-		// Print all the currently set alternative labels.
545
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
546
-
547
-			echo $this->get_alternative_label_input( $alt_label );
548
-
549
-		};
550
-
551
-		// Print the button.
552
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
553
-
554
-	}
555
-
556
-	/**
557
-	 * Add admin notices for the current entity depending on the current rating.
558
-	 *
559
-	 * @since 3.3.0
560
-	 *
561
-	 * @param WP_Post $post Post object.
562
-	 */
563
-	public function in_admin_header() {
564
-
565
-		// Return safely if get_current_screen() is not defined (yet)
566
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
567
-			return;
568
-		}
569
-
570
-		$screen = get_current_screen();
571
-		// If there is any valid screen nothing to do
572
-		if ( NULL === $screen ) {
573
-			return $clauses;
574
-		}
575
-
576
-		// If you're not in the entity post edit page, return.
577
-		if ( self::TYPE_NAME !== $screen->id ) {
578
-			return;
579
-		}
580
-		// Retrieve the current global post
581
-		global $post;
582
-		// If it's not an entity, return.
583
-		if ( ! $this->is_entity( $post->ID ) ) {
584
-			return;
585
-		}
586
-		// Retrieve an updated rating for the current entity
587
-		$rating = $this->get_rating_for( $post->ID, TRUE );
588
-		// If there is at least 1 warning
589
-		if ( isset( $rating['warnings'] ) && 0 < count( $rating['warnings'] ) ) {
590
-			// TODO - Pass Wordlift_Notice_Service trough the service constructor 
591
-			$this->notice_service->add_suggestion( $rating['warnings'] );
592
-		}
593
-
594
-	}
595
-
596
-	/**
597
-	 * Set rating for a given entity
598
-	 *
599
-	 * @since 3.3.0
600
-	 *
601
-	 * @param int $post_id The entity post id.
602
-	 *
603
-	 * @return int An array representing the rating obj.
604
-	 */
605
-	public function set_rating_for( $post_id ) {
606
-
607
-		// Calculate rating for the given post
608
-		$rating = $this->calculate_rating_for( $post_id );
609
-		// Store the rating on db as post meta
610
-		// Please notice that RATING_RAW_SCORE_META_KEY 
611
-		// is saved on a different meta to allow score sorting
612
-		// Both meta are managed as unique
613
-		// https://codex.wordpress.org/Function_Reference/update_post_meta
614
-		update_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, $rating['raw_score'] );
615
-		update_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, $rating['warnings'] );
616
-
617
-		$this->log_service->trace( sprintf( "Rating set for [ post_id :: $post_id ] [ rating :: %s ]", $rating['raw_score'] ) );
618
-
619
-		// Finally returns the rating 
620
-		return $rating;
621
-	}
622
-
623
-	/**
624
-	 * Get or calculate rating for a given entity
625
-	 *
626
-	 * @since 3.3.0
627
-	 *
628
-	 * @param int $post_id      The entity post id.
629
-	 * @param     $force_reload $warnings_needed If true, detailed warnings collection is provided with the rating obj.
630
-	 *
631
-	 * @return int An array representing the rating obj.
632
-	 */
633
-	public function get_rating_for( $post_id, $force_reload = FALSE ) {
634
-
635
-		// If forced reload is required or rating is missing ..
636
-		if ( $force_reload ) {
637
-			$this->log_service->trace( "Force rating reload [ post_id :: $post_id ]" );
638
-
639
-			return $this->set_rating_for( $post_id );
640
-		}
641
-
642
-		$current_raw_score = get_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, TRUE );
643
-
644
-		if ( ! is_numeric( $current_raw_score ) ) {
645
-			$this->log_service->trace( "Rating missing for [ post_id :: $post_id ] [ current_raw_score :: $current_raw_score ]" );
646
-
647
-			return $this->set_rating_for( $post_id );
648
-		}
649
-		$current_warnings = get_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, TRUE );
650
-
651
-		// Finally return score and warnings
652
-		return array(
653
-			'raw_score'           => $current_raw_score,
654
-			'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $current_raw_score ),
655
-			'percentage_score'    => $this->convert_raw_score_to_percentage( $current_raw_score ),
656
-			'warnings'            => $current_warnings,
657
-		);
658
-
659
-	}
660
-
661
-	/**
662
-	 * Calculate rating for a given entity
663
-	 * Rating depends from following criteria
664
-	 *
665
-	 * 1. Is the current entity related to at least 1 post?
666
-	 * 2. Is the current entity content post not empty?
667
-	 * 3. Is the current entity related to at least 1 entity?
668
-	 * 4. Is the entity published?
669
-	 * 5. There is a a thumbnail associated to the entity?
670
-	 * 6. Has the entity a sameas defined?
671
-	 * 7. Are all schema.org required metadata compiled?
672
-	 *
673
-	 * Each positive check means +1 in terms of rating score
674
-	 *
675
-	 * @since 3.3.0
676
-	 *
677
-	 * @param int $post_id The entity post id.
678
-	 *
679
-	 * @return int An array representing the rating obj.
680
-	 */
681
-	public function calculate_rating_for( $post_id ) {
682
-
683
-		// If it's not an entity, return.
684
-		if ( ! $this->is_entity( $post_id ) ) {
685
-			return;
686
-		}
687
-		// Retrieve the post object
688
-		$post = get_post( $post_id );
689
-		// Rating value
690
-		$score = 0;
691
-		// Store warning messages
692
-		$warnings = array();
693
-
694
-		// Is the current entity related to at least 1 post?
695
-		( 0 < count( wl_core_get_related_post_ids( $post->ID ) ) ) ?
696
-			$score ++ :
697
-			array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_POSTS, 'wordlift' ) );
698
-
699
-		// Is the post content not empty?
700
-		( ! empty( $post->post_content ) ) ?
701
-			$score ++ :
702
-			array_push( $warnings, __( self::RATING_WARNING_HAS_CONTENT_POST, 'wordlift' ) );
703
-
704
-		// Is the current entity related to at least 1 entity?
705
-		// Was the current entity already disambiguated?
706
-		( 0 < count( wl_core_get_related_entity_ids( $post->ID ) ) ) ?
707
-			$score ++ :
708
-			array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_ENTITIES, 'wordlift' ) );
709
-
710
-		// Is the entity published?
711
-		( 'publish' === get_post_status( $post->ID ) ) ?
712
-			$score ++ :
713
-			array_push( $warnings, __( self::RATING_WARNING_IS_PUBLISHED, 'wordlift' ) );
714
-
715
-		// Has a thumbnail?
716
-		( has_post_thumbnail( $post->ID ) ) ?
717
-			$score ++ :
718
-			array_push( $warnings, __( self::RATING_WARNING_HAS_THUMBNAIL, 'wordlift' ) );
719
-
720
-		// Get all post meta keys for the current post		
721
-		global $wpdb;
722
-		$query = $wpdb->prepare(
723
-			"SELECT DISTINCT(meta_key) FROM $wpdb->postmeta  WHERE post_id = %d", $post->ID
724
-		);
725
-
726
-		// Check intersection between available meta keys 
727
-		// and expected ones arrays to detect missing values
728
-		$available_meta_keys = $wpdb->get_col( $query );
729
-
730
-		// If each expected key is contained in available keys array ...
731
-		( in_array( Wordlift_Schema_Service::FIELD_SAME_AS, $available_meta_keys ) ) ?
732
-			$score ++ :
733
-			array_push( $warnings, __( self::RATING_WARNING_HAS_SAME_AS, 'wordlift' ) );
734
-
735
-		$schema = wl_entity_type_taxonomy_get_type( $post_id );
736
-
737
-		$expected_meta_keys = ( NULL === $schema['custom_fields'] ) ?
738
-			array() :
739
-			array_keys( $schema['custom_fields'] );
740
-
741
-		$intersection = array_intersect( $expected_meta_keys, $available_meta_keys );
742
-		// If each expected key is contained in available keys array ...
743
-		( count( $intersection ) === count( $expected_meta_keys ) ) ?
744
-			$score ++ :
745
-			array_push( $warnings, __( self::RATING_WARNING_HAS_COMPLETED_METADATA, 'wordlift' ) );
746
-
747
-		// Finally return score and warnings
748
-		return array(
749
-			'raw_score'           => $score,
750
-			'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $score ),
751
-			'percentage_score'    => $this->convert_raw_score_to_percentage( $score ),
752
-			'warnings'            => $warnings,
753
-		);
754
-
755
-	}
756
-
757
-	/**
758
-	 * Get the URI for the entity with the specified post id.
759
-	 *
760
-	 * @since 3.6.0
761
-	 *
762
-	 * @param int $post_id The entity post id.
763
-	 *
764
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
765
-	 */
766
-	public function get_uri( $post_id ) {
767
-
768
-		// If a null is given, nothing to do
769
-		if ( NULL == $post_id ) {
770
-			return NULL;
771
-		}
772
-
773
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, TRUE );
774
-
775
-		// If the dataset uri is not properly configured, null is returned
776
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
777
-			return NULL;
778
-		}
779
-
780
-		// Set the URI if it isn't set yet.
781
-		$post_status = get_post_status( $post_id );
782
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
783
-			$uri = wl_build_entity_uri( $post_id );
784
-			wl_set_entity_uri( $post_id, $uri );
785
-		}
786
-
787
-		return $uri;
788
-	}
789
-
790
-	/**
791
-	 * Get as rating as input and convert in a traffic-light rating
792
-	 *
793
-	 * @since 3.3.0
794
-	 *
795
-	 * @param int $score The rating score for a given entity.
796
-	 *
797
-	 * @return string The input HTML code.
798
-	 */
799
-	private function convert_raw_score_to_traffic_light( $score ) {
800
-		// RATING_MAX : $score = 3 : x 
801
-		// See http://php.net/manual/en/function.round.php
802
-		$rating = round( ( $score * 3 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
803
-
804
-		// If rating is 0, return 1, otherwise return rating
805
-		return ( 0 == $rating ) ? 1 : $rating;
806
-
807
-	}
808
-
809
-	/**
810
-	 * Get as rating as input and convert in a traffic-light rating
811
-	 *
812
-	 * @since 3.3.0
813
-	 *
814
-	 * @param int $score The rating score for a given entity.
815
-	 *
816
-	 * @return string The input HTML code.
817
-	 */
818
-	public function convert_raw_score_to_percentage( $score ) {
819
-		// RATING_MAX : $score = 100 : x 
820
-		return round( ( $score * 100 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
821
-	}
822
-
823
-	/**
824
-	 * Get the alternative label input HTML code.
825
-	 *
826
-	 * @since 3.2.0
827
-	 *
828
-	 * @param string $value The input value.
829
-	 *
830
-	 * @return string The input HTML code.
831
-	 */
832
-	private function get_alternative_label_input( $value = '' ) {
833
-
834
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
835
-	}
836
-
837
-	/**
838
-	 * Get the number of entity posts published in this blog.
839
-	 *
840
-	 * @since 3.6.0
841
-	 *
842
-	 * @return int The number of published entity posts.
843
-	 */
844
-	public function count() {
845
-
846
-		$count = wp_count_posts( self::TYPE_NAME );
847
-
848
-		return $count->publish;
849
-	}
850
-
851
-	/**
852
-	 * Create a new entity.
853
-	 *
854
-	 * @since 3.9.0
855
-	 *
856
-	 * @param string $name     The entity name.
857
-	 * @param string $type_uri The entity's type URI.
858
-	 * @param null   $logo     The entity logo id (or NULL if none).
859
-	 * @param string $status   The post status, by default 'publish'.
860
-	 *
861
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
862
-	 */
863
-	public function create( $name, $type_uri, $logo = NULL, $status = 'publish' ) {
864
-
865
-		// Create an entity for the publisher.
866
-		$post_id = wp_insert_post( array(
867
-			'post_type'    => self::TYPE_NAME,
868
-			'post_title'   => $name,
869
-			'post_status'  => $status,
870
-			'post_content' => '',
871
-		) );
872
-
873
-		// Return the error if any.
874
-		if ( is_wp_error( $post_id ) ) {
875
-			return $post_id;
876
-		}
877
-
878
-		// Set the entity logo.
879
-		if ( $logo && is_numeric( $logo ) ) {
880
-			set_post_thumbnail( $post_id, $logo );
881
-		}
882
-
883
-		// Set the entity type.
884
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
885
-
886
-		return $post_id;
887
-	}
142
+    /**
143
+     * A singleton instance of the Entity service.
144
+     *
145
+     * @since  3.2.0
146
+     * @access private
147
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
148
+     */
149
+    private static $instance;
150
+
151
+    /**
152
+     * Create a Wordlift_Entity_Service instance.
153
+     *
154
+     * @since 3.2.0
155
+     *
156
+     * @param \Wordlift_UI_Service $ui_service The UI service.
157
+     */
158
+    public function __construct( $ui_service, $schema_service, $notice_service ) {
159
+
160
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
161
+
162
+        // Set the UI service.
163
+        $this->ui_service = $ui_service;
164
+
165
+        // Set the Schema service.
166
+        $this->schema_service = $schema_service;
167
+
168
+        // Set the Schema service.
169
+        $this->notice_service = $notice_service;
170
+
171
+        // Set the singleton instance.
172
+        self::$instance = $this;
173
+
174
+    }
175
+
176
+    /**
177
+     * Get the singleton instance of the Entity service.
178
+     *
179
+     * @since 3.2.0
180
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
181
+     */
182
+    public static function get_instance() {
183
+
184
+        return self::$instance;
185
+    }
186
+
187
+    /**
188
+     * Get rating max
189
+     *
190
+     * @since 3.3.0
191
+     *
192
+     * @return int Max rating according to performed checks.
193
+     */
194
+    public static function get_rating_max() {
195
+        return self::RATING_MAX;
196
+    }
197
+
198
+    /**
199
+     * Get the entities related to the last 50 posts published on this blog (we're keeping a long function name due to
200
+     * its specific function).
201
+     *
202
+     * @since 3.1.0
203
+     *
204
+     * @return array An array of post IDs.
205
+     */
206
+    public function get_all_related_to_last_50_published_posts() {
207
+
208
+        // Global timeline. Get entities from the latest posts.
209
+        $latest_posts_ids = get_posts( array(
210
+            'numberposts' => 50,
211
+            'fields'      => 'ids', //only get post IDs
212
+            'post_type'   => 'post',
213
+            'post_status' => 'publish',
214
+        ) );
215
+
216
+        if ( empty( $latest_posts_ids ) ) {
217
+            // There are no posts.
218
+            return array();
219
+        }
220
+
221
+        // Collect entities related to latest posts
222
+        $entity_ids = array();
223
+        foreach ( $latest_posts_ids as $id ) {
224
+            $entity_ids = array_merge( $entity_ids, wl_core_get_related_entity_ids( $id, array(
225
+                'status' => 'publish',
226
+            ) ) );
227
+        }
228
+
229
+        return $entity_ids;
230
+    }
231
+
232
+    /**
233
+     * Determines whether a post is an entity or not.
234
+     *
235
+     * @since 3.1.0
236
+     *
237
+     * @param int $post_id A post id.
238
+     *
239
+     * @return bool Return true if the post is an entity otherwise false.
240
+     */
241
+    public function is_entity( $post_id ) {
242
+
243
+        return ( self::TYPE_NAME === get_post_type( $post_id ) );
244
+    }
245
+
246
+    /**
247
+     * Get the proper classification scope for a given entity post
248
+     *
249
+     * @since 3.5.0
250
+     *
251
+     * @param integer $post_id An entity post id.
252
+     *
253
+     * @return string Returns an uri.
254
+     */
255
+    public function get_classification_scope_for( $post_id ) {
256
+
257
+        if ( FALSE === $this->is_entity( $post_id ) ) {
258
+            return NULL;
259
+        }
260
+        // Retrieve the entity type
261
+        $entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id );
262
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
263
+        // Retrieve classification boxes configuration
264
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
265
+        foreach ( $classification_boxes as $cb ) {
266
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
267
+                return $cb['id'];
268
+            }
269
+        }
270
+
271
+        // or null
272
+        return NULL;
273
+
274
+    }
275
+
276
+    /**
277
+     * Build an entity uri for a given title
278
+     * The uri is composed using a given post_type and a title
279
+     * If already exists an entity e2 with a given uri a numeric suffix is added
280
+     * If a schema type is given entities with same label and same type are overridden
281
+     *
282
+     * @since 3.5.0
283
+     *
284
+     * @param string  $title           A post title.
285
+     * @param string  $post_type       A post type. Default value is 'entity'
286
+     * @param string  $schema_type     A schema org type.
287
+     * @param integer $increment_digit A digit used to call recursively the same function.
288
+     *
289
+     * @return string Returns an uri.
290
+     */
291
+    public function build_uri( $title, $post_type, $schema_type = NULL, $increment_digit = 0 ) {
292
+
293
+        // Get the entity slug suffix digit
294
+        $suffix_digit = $increment_digit + 1;
295
+        // Get a sanitized uri for a given title
296
+        $entity_slug = ( 0 == $increment_digit ) ?
297
+            wl_sanitize_uri_path( $title ) :
298
+            wl_sanitize_uri_path( $title . '_' . $suffix_digit );
299
+
300
+        // Compose a candidated uri
301
+        $new_entity_uri = sprintf( '%s/%s/%s',
302
+            wl_configuration_get_redlink_dataset_uri(),
303
+            $post_type,
304
+            $entity_slug
305
+        );
306
+
307
+        $this->log_service->trace( "Going to check if uri is used [ new_entity_uri :: $new_entity_uri ] [ increment_digit :: $increment_digit ]" );
308
+
309
+        global $wpdb;
310
+        // Check if the candidated uri already is used
311
+        $stmt = $wpdb->prepare(
312
+            "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1",
313
+            WL_ENTITY_URL_META_NAME,
314
+            $new_entity_uri
315
+        );
316
+
317
+        // Perform the query
318
+        $post_id = $wpdb->get_var( $stmt );
319
+
320
+        // If the post does not exist, then the new uri is returned 	
321
+        if ( ! is_numeric( $post_id ) ) {
322
+            $this->log_service->trace( "Going to return uri [ new_entity_uri :: $new_entity_uri ]" );
323
+
324
+            return $new_entity_uri;
325
+        }
326
+        // If schema_type is equal to schema org type of post x, then the new uri is returned 
327
+        $schema_post_type = wl_entity_type_taxonomy_get_type( $post_id );
328
+
329
+        if ( $schema_type === $schema_post_type['css_class'] ) {
330
+            $this->log_service->trace( "An entity with the same title and type already exists! Return uri [ new_entity_uri :: $new_entity_uri ]" );
331
+
332
+            return $new_entity_uri;
333
+        }
334
+
335
+        // Otherwise the same function is called recorsively
336
+        return $this->build_uri( $title, $post_type, $schema_type, ++ $increment_digit );
337
+    }
338
+
339
+    public function is_used( $post_id ) {
340
+
341
+        if ( FALSE === $this->is_entity( $post_id ) ) {
342
+            return NULL;
343
+        }
344
+        // Retrieve the post
345
+        $entity = get_post( $post_id );
346
+
347
+        global $wpdb;
348
+        // Retrieve Wordlift relation instances table name
349
+        $table_name = wl_core_get_relation_instances_table_name();
350
+
351
+        // Check is it's referenced / related to another post / entity
352
+        $stmt = $wpdb->prepare(
353
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
354
+            $entity->ID
355
+        );
356
+
357
+        // Perform the query
358
+        $relation_instances = (int) $wpdb->get_var( $stmt );
359
+        // If there is at least one relation instance for the current entity, then it's used
360
+        if ( 0 < $relation_instances ) {
361
+            return TRUE;
362
+        }
363
+
364
+        // Check if the entity uri is used as meta_value
365
+        $stmt = $wpdb->prepare(
366
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
367
+            $entity->ID,
368
+            wl_get_entity_uri( $entity->ID )
369
+        );
370
+        // Perform the query
371
+        $meta_instances = (int) $wpdb->get_var( $stmt );
372
+
373
+        // If there is at least one meta that refers the current entity uri, then current entity is used
374
+        if ( 0 < $meta_instances ) {
375
+            return TRUE;
376
+        }
377
+
378
+        // If we are here, it means the current entity is not used at the moment
379
+        return FALSE;
380
+    }
381
+
382
+    /**
383
+     * Determines whether a given uri is an internal uri or not.
384
+     *
385
+     * @since 3.3.2
386
+     *
387
+     * @param int $uri An uri.
388
+     *
389
+     * @return true if the uri internal to the current dataset otherwise false.
390
+     */
391
+    public function is_internal_uri( $uri ) {
392
+
393
+        return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) );
394
+    }
395
+
396
+    /**
397
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
398
+     *
399
+     * @since 3.2.0
400
+     *
401
+     * @param string $uri The entity URI.
402
+     *
403
+     * @return WP_Post|null A WP_Post instance or null if not found.
404
+     */
405
+    public function get_entity_post_by_uri( $uri ) {
406
+
407
+        // Check if we've been provided with a value otherwise return null.
408
+        if ( empty( $uri ) ) {
409
+            return NULL;
410
+        }
411
+
412
+        $query_args = array(
413
+            'posts_per_page' => 1,
414
+            'post_status'    => 'any',
415
+            'post_type'      => self::TYPE_NAME,
416
+            'meta_query'     => array(
417
+                array(
418
+                    'key'     => WL_ENTITY_URL_META_NAME,
419
+                    'value'   => $uri,
420
+                    'compare' => '=',
421
+                ),
422
+            ),
423
+        );
424
+
425
+        // Only if the current uri is not an internal uri 
426
+        // entity search is performed also looking at sameAs values
427
+        // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237
428
+        if ( ! $this->is_internal_uri( $uri ) ) {
429
+
430
+            $query_args['meta_query']['relation'] = 'OR';
431
+            $query_args['meta_query'][]           = array(
432
+                'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
433
+                'value'   => $uri,
434
+                'compare' => '=',
435
+            );
436
+        }
437
+
438
+        $query = new WP_Query( $query_args );
439
+
440
+        // Get the matching entity posts.
441
+        $posts = $query->get_posts();
442
+
443
+        // Return null if no post is found.
444
+        if ( 0 === count( $posts ) ) {
445
+            return NULL;
446
+        }
447
+
448
+        // Return the found post.
449
+        return $posts[0];
450
+    }
451
+
452
+    /**
453
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
454
+     * we check that the post we're saving is the current post.
455
+     *
456
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
457
+     *
458
+     * @since 3.2.0
459
+     *
460
+     * @param int     $post_id Post ID.
461
+     * @param WP_Post $post    Post object.
462
+     * @param bool    $update  Whether this is an existing post being updated or not.
463
+     */
464
+    public function save_post( $post_id, $post, $update ) {
465
+
466
+        // We're setting the alternative label that have been provided via the UI
467
+        // (in fact we're using $_REQUEST), while save_post may be also called
468
+        // programmatically by some other function: we need to check therefore if
469
+        // the $post_id in the save_post call matches the post id set in the request.
470
+        //
471
+        // If this is not the current post being saved or if it's not an entity, return.
472
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
473
+            return;
474
+        }
475
+
476
+        // Get the alt labels from the request (or empty array).
477
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
478
+
479
+        // Set the alternative labels.
480
+        $this->set_alternative_labels( $post_id, $alt_labels );
481
+
482
+    }
483
+
484
+    /**
485
+     * Set the alternative labels.
486
+     *
487
+     * @since 3.2.0
488
+     *
489
+     * @param int   $post_id    The post id.
490
+     * @param array $alt_labels An array of labels.
491
+     */
492
+    public function set_alternative_labels( $post_id, $alt_labels ) {
493
+
494
+        // Force $alt_labels to be an array
495
+        if ( ! is_array( $alt_labels ) ) {
496
+            $alt_labels = array( $alt_labels );
497
+        }
498
+
499
+        $this->log_service->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
500
+
501
+        // Delete all the existing alternate labels.
502
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
503
+
504
+        // Set the alternative labels.
505
+        foreach ( $alt_labels as $alt_label ) {
506
+            if ( ! empty( $alt_label ) ) {
507
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
508
+            }
509
+        }
510
+
511
+    }
512
+
513
+    /**
514
+     * Retrieve the alternate labels.
515
+     *
516
+     * @since 3.2.0
517
+     *
518
+     * @param int $post_id Post id.
519
+     *
520
+     * @return mixed An array  of alternative labels.
521
+     */
522
+    public function get_alternative_labels( $post_id ) {
523
+
524
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
525
+    }
526
+
527
+    /**
528
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
529
+     *
530
+     * @since 3.2.0
531
+     *
532
+     * @param WP_Post $post Post object.
533
+     */
534
+    public function edit_form_before_permalink( $post ) {
535
+
536
+        // If it's not an entity, return.
537
+        if ( ! $this->is_entity( $post->ID ) ) {
538
+            return;
539
+        }
540
+
541
+        // Print the input template.
542
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
543
+
544
+        // Print all the currently set alternative labels.
545
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
546
+
547
+            echo $this->get_alternative_label_input( $alt_label );
548
+
549
+        };
550
+
551
+        // Print the button.
552
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
553
+
554
+    }
555
+
556
+    /**
557
+     * Add admin notices for the current entity depending on the current rating.
558
+     *
559
+     * @since 3.3.0
560
+     *
561
+     * @param WP_Post $post Post object.
562
+     */
563
+    public function in_admin_header() {
564
+
565
+        // Return safely if get_current_screen() is not defined (yet)
566
+        if ( FALSE === function_exists( 'get_current_screen' ) ) {
567
+            return;
568
+        }
569
+
570
+        $screen = get_current_screen();
571
+        // If there is any valid screen nothing to do
572
+        if ( NULL === $screen ) {
573
+            return $clauses;
574
+        }
575
+
576
+        // If you're not in the entity post edit page, return.
577
+        if ( self::TYPE_NAME !== $screen->id ) {
578
+            return;
579
+        }
580
+        // Retrieve the current global post
581
+        global $post;
582
+        // If it's not an entity, return.
583
+        if ( ! $this->is_entity( $post->ID ) ) {
584
+            return;
585
+        }
586
+        // Retrieve an updated rating for the current entity
587
+        $rating = $this->get_rating_for( $post->ID, TRUE );
588
+        // If there is at least 1 warning
589
+        if ( isset( $rating['warnings'] ) && 0 < count( $rating['warnings'] ) ) {
590
+            // TODO - Pass Wordlift_Notice_Service trough the service constructor 
591
+            $this->notice_service->add_suggestion( $rating['warnings'] );
592
+        }
593
+
594
+    }
595
+
596
+    /**
597
+     * Set rating for a given entity
598
+     *
599
+     * @since 3.3.0
600
+     *
601
+     * @param int $post_id The entity post id.
602
+     *
603
+     * @return int An array representing the rating obj.
604
+     */
605
+    public function set_rating_for( $post_id ) {
606
+
607
+        // Calculate rating for the given post
608
+        $rating = $this->calculate_rating_for( $post_id );
609
+        // Store the rating on db as post meta
610
+        // Please notice that RATING_RAW_SCORE_META_KEY 
611
+        // is saved on a different meta to allow score sorting
612
+        // Both meta are managed as unique
613
+        // https://codex.wordpress.org/Function_Reference/update_post_meta
614
+        update_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, $rating['raw_score'] );
615
+        update_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, $rating['warnings'] );
616
+
617
+        $this->log_service->trace( sprintf( "Rating set for [ post_id :: $post_id ] [ rating :: %s ]", $rating['raw_score'] ) );
618
+
619
+        // Finally returns the rating 
620
+        return $rating;
621
+    }
622
+
623
+    /**
624
+     * Get or calculate rating for a given entity
625
+     *
626
+     * @since 3.3.0
627
+     *
628
+     * @param int $post_id      The entity post id.
629
+     * @param     $force_reload $warnings_needed If true, detailed warnings collection is provided with the rating obj.
630
+     *
631
+     * @return int An array representing the rating obj.
632
+     */
633
+    public function get_rating_for( $post_id, $force_reload = FALSE ) {
634
+
635
+        // If forced reload is required or rating is missing ..
636
+        if ( $force_reload ) {
637
+            $this->log_service->trace( "Force rating reload [ post_id :: $post_id ]" );
638
+
639
+            return $this->set_rating_for( $post_id );
640
+        }
641
+
642
+        $current_raw_score = get_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, TRUE );
643
+
644
+        if ( ! is_numeric( $current_raw_score ) ) {
645
+            $this->log_service->trace( "Rating missing for [ post_id :: $post_id ] [ current_raw_score :: $current_raw_score ]" );
646
+
647
+            return $this->set_rating_for( $post_id );
648
+        }
649
+        $current_warnings = get_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, TRUE );
650
+
651
+        // Finally return score and warnings
652
+        return array(
653
+            'raw_score'           => $current_raw_score,
654
+            'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $current_raw_score ),
655
+            'percentage_score'    => $this->convert_raw_score_to_percentage( $current_raw_score ),
656
+            'warnings'            => $current_warnings,
657
+        );
658
+
659
+    }
660
+
661
+    /**
662
+     * Calculate rating for a given entity
663
+     * Rating depends from following criteria
664
+     *
665
+     * 1. Is the current entity related to at least 1 post?
666
+     * 2. Is the current entity content post not empty?
667
+     * 3. Is the current entity related to at least 1 entity?
668
+     * 4. Is the entity published?
669
+     * 5. There is a a thumbnail associated to the entity?
670
+     * 6. Has the entity a sameas defined?
671
+     * 7. Are all schema.org required metadata compiled?
672
+     *
673
+     * Each positive check means +1 in terms of rating score
674
+     *
675
+     * @since 3.3.0
676
+     *
677
+     * @param int $post_id The entity post id.
678
+     *
679
+     * @return int An array representing the rating obj.
680
+     */
681
+    public function calculate_rating_for( $post_id ) {
682
+
683
+        // If it's not an entity, return.
684
+        if ( ! $this->is_entity( $post_id ) ) {
685
+            return;
686
+        }
687
+        // Retrieve the post object
688
+        $post = get_post( $post_id );
689
+        // Rating value
690
+        $score = 0;
691
+        // Store warning messages
692
+        $warnings = array();
693
+
694
+        // Is the current entity related to at least 1 post?
695
+        ( 0 < count( wl_core_get_related_post_ids( $post->ID ) ) ) ?
696
+            $score ++ :
697
+            array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_POSTS, 'wordlift' ) );
698
+
699
+        // Is the post content not empty?
700
+        ( ! empty( $post->post_content ) ) ?
701
+            $score ++ :
702
+            array_push( $warnings, __( self::RATING_WARNING_HAS_CONTENT_POST, 'wordlift' ) );
703
+
704
+        // Is the current entity related to at least 1 entity?
705
+        // Was the current entity already disambiguated?
706
+        ( 0 < count( wl_core_get_related_entity_ids( $post->ID ) ) ) ?
707
+            $score ++ :
708
+            array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_ENTITIES, 'wordlift' ) );
709
+
710
+        // Is the entity published?
711
+        ( 'publish' === get_post_status( $post->ID ) ) ?
712
+            $score ++ :
713
+            array_push( $warnings, __( self::RATING_WARNING_IS_PUBLISHED, 'wordlift' ) );
714
+
715
+        // Has a thumbnail?
716
+        ( has_post_thumbnail( $post->ID ) ) ?
717
+            $score ++ :
718
+            array_push( $warnings, __( self::RATING_WARNING_HAS_THUMBNAIL, 'wordlift' ) );
719
+
720
+        // Get all post meta keys for the current post		
721
+        global $wpdb;
722
+        $query = $wpdb->prepare(
723
+            "SELECT DISTINCT(meta_key) FROM $wpdb->postmeta  WHERE post_id = %d", $post->ID
724
+        );
725
+
726
+        // Check intersection between available meta keys 
727
+        // and expected ones arrays to detect missing values
728
+        $available_meta_keys = $wpdb->get_col( $query );
729
+
730
+        // If each expected key is contained in available keys array ...
731
+        ( in_array( Wordlift_Schema_Service::FIELD_SAME_AS, $available_meta_keys ) ) ?
732
+            $score ++ :
733
+            array_push( $warnings, __( self::RATING_WARNING_HAS_SAME_AS, 'wordlift' ) );
734
+
735
+        $schema = wl_entity_type_taxonomy_get_type( $post_id );
736
+
737
+        $expected_meta_keys = ( NULL === $schema['custom_fields'] ) ?
738
+            array() :
739
+            array_keys( $schema['custom_fields'] );
740
+
741
+        $intersection = array_intersect( $expected_meta_keys, $available_meta_keys );
742
+        // If each expected key is contained in available keys array ...
743
+        ( count( $intersection ) === count( $expected_meta_keys ) ) ?
744
+            $score ++ :
745
+            array_push( $warnings, __( self::RATING_WARNING_HAS_COMPLETED_METADATA, 'wordlift' ) );
746
+
747
+        // Finally return score and warnings
748
+        return array(
749
+            'raw_score'           => $score,
750
+            'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $score ),
751
+            'percentage_score'    => $this->convert_raw_score_to_percentage( $score ),
752
+            'warnings'            => $warnings,
753
+        );
754
+
755
+    }
756
+
757
+    /**
758
+     * Get the URI for the entity with the specified post id.
759
+     *
760
+     * @since 3.6.0
761
+     *
762
+     * @param int $post_id The entity post id.
763
+     *
764
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
765
+     */
766
+    public function get_uri( $post_id ) {
767
+
768
+        // If a null is given, nothing to do
769
+        if ( NULL == $post_id ) {
770
+            return NULL;
771
+        }
772
+
773
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, TRUE );
774
+
775
+        // If the dataset uri is not properly configured, null is returned
776
+        if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
777
+            return NULL;
778
+        }
779
+
780
+        // Set the URI if it isn't set yet.
781
+        $post_status = get_post_status( $post_id );
782
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
783
+            $uri = wl_build_entity_uri( $post_id );
784
+            wl_set_entity_uri( $post_id, $uri );
785
+        }
786
+
787
+        return $uri;
788
+    }
789
+
790
+    /**
791
+     * Get as rating as input and convert in a traffic-light rating
792
+     *
793
+     * @since 3.3.0
794
+     *
795
+     * @param int $score The rating score for a given entity.
796
+     *
797
+     * @return string The input HTML code.
798
+     */
799
+    private function convert_raw_score_to_traffic_light( $score ) {
800
+        // RATING_MAX : $score = 3 : x 
801
+        // See http://php.net/manual/en/function.round.php
802
+        $rating = round( ( $score * 3 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
803
+
804
+        // If rating is 0, return 1, otherwise return rating
805
+        return ( 0 == $rating ) ? 1 : $rating;
806
+
807
+    }
808
+
809
+    /**
810
+     * Get as rating as input and convert in a traffic-light rating
811
+     *
812
+     * @since 3.3.0
813
+     *
814
+     * @param int $score The rating score for a given entity.
815
+     *
816
+     * @return string The input HTML code.
817
+     */
818
+    public function convert_raw_score_to_percentage( $score ) {
819
+        // RATING_MAX : $score = 100 : x 
820
+        return round( ( $score * 100 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
821
+    }
822
+
823
+    /**
824
+     * Get the alternative label input HTML code.
825
+     *
826
+     * @since 3.2.0
827
+     *
828
+     * @param string $value The input value.
829
+     *
830
+     * @return string The input HTML code.
831
+     */
832
+    private function get_alternative_label_input( $value = '' ) {
833
+
834
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
835
+    }
836
+
837
+    /**
838
+     * Get the number of entity posts published in this blog.
839
+     *
840
+     * @since 3.6.0
841
+     *
842
+     * @return int The number of published entity posts.
843
+     */
844
+    public function count() {
845
+
846
+        $count = wp_count_posts( self::TYPE_NAME );
847
+
848
+        return $count->publish;
849
+    }
850
+
851
+    /**
852
+     * Create a new entity.
853
+     *
854
+     * @since 3.9.0
855
+     *
856
+     * @param string $name     The entity name.
857
+     * @param string $type_uri The entity's type URI.
858
+     * @param null   $logo     The entity logo id (or NULL if none).
859
+     * @param string $status   The post status, by default 'publish'.
860
+     *
861
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
862
+     */
863
+    public function create( $name, $type_uri, $logo = NULL, $status = 'publish' ) {
864
+
865
+        // Create an entity for the publisher.
866
+        $post_id = wp_insert_post( array(
867
+            'post_type'    => self::TYPE_NAME,
868
+            'post_title'   => $name,
869
+            'post_status'  => $status,
870
+            'post_content' => '',
871
+        ) );
872
+
873
+        // Return the error if any.
874
+        if ( is_wp_error( $post_id ) ) {
875
+            return $post_id;
876
+        }
877
+
878
+        // Set the entity logo.
879
+        if ( $logo && is_numeric( $logo ) ) {
880
+            set_post_thumbnail( $post_id, $logo );
881
+        }
882
+
883
+        // Set the entity type.
884
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
885
+
886
+        return $post_id;
887
+    }
888 888
 
889 889
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -143 removed lines patch added patch discarded remove patch
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @param \Wordlift_UI_Service $ui_service The UI service.
157 157
 	 */
158
-	public function __construct( $ui_service, $schema_service, $notice_service ) {
158
+	public function __construct($ui_service, $schema_service, $notice_service) {
159 159
 
160
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
160
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
161 161
 
162 162
 		// Set the UI service.
163 163
 		$this->ui_service = $ui_service;
@@ -206,24 +206,24 @@  discard block
 block discarded – undo
206 206
 	public function get_all_related_to_last_50_published_posts() {
207 207
 
208 208
 		// Global timeline. Get entities from the latest posts.
209
-		$latest_posts_ids = get_posts( array(
209
+		$latest_posts_ids = get_posts(array(
210 210
 			'numberposts' => 50,
211 211
 			'fields'      => 'ids', //only get post IDs
212 212
 			'post_type'   => 'post',
213 213
 			'post_status' => 'publish',
214
-		) );
214
+		));
215 215
 
216
-		if ( empty( $latest_posts_ids ) ) {
216
+		if (empty($latest_posts_ids)) {
217 217
 			// There are no posts.
218 218
 			return array();
219 219
 		}
220 220
 
221 221
 		// Collect entities related to latest posts
222 222
 		$entity_ids = array();
223
-		foreach ( $latest_posts_ids as $id ) {
224
-			$entity_ids = array_merge( $entity_ids, wl_core_get_related_entity_ids( $id, array(
223
+		foreach ($latest_posts_ids as $id) {
224
+			$entity_ids = array_merge($entity_ids, wl_core_get_related_entity_ids($id, array(
225 225
 				'status' => 'publish',
226
-			) ) );
226
+			)));
227 227
 		}
228 228
 
229 229
 		return $entity_ids;
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return bool Return true if the post is an entity otherwise false.
240 240
 	 */
241
-	public function is_entity( $post_id ) {
241
+	public function is_entity($post_id) {
242 242
 
243
-		return ( self::TYPE_NAME === get_post_type( $post_id ) );
243
+		return (self::TYPE_NAME === get_post_type($post_id));
244 244
 	}
245 245
 
246 246
 	/**
@@ -252,18 +252,18 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return string Returns an uri.
254 254
 	 */
255
-	public function get_classification_scope_for( $post_id ) {
255
+	public function get_classification_scope_for($post_id) {
256 256
 
257
-		if ( FALSE === $this->is_entity( $post_id ) ) {
257
+		if (FALSE === $this->is_entity($post_id)) {
258 258
 			return NULL;
259 259
 		}
260 260
 		// Retrieve the entity type
261
-		$entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id );
262
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
261
+		$entity_type_arr = wl_entity_type_taxonomy_get_type($post_id);
262
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
263 263
 		// Retrieve classification boxes configuration
264
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
265
-		foreach ( $classification_boxes as $cb ) {
266
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
264
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
265
+		foreach ($classification_boxes as $cb) {
266
+			if (in_array($entity_type, $cb['registeredTypes'])) {
267 267
 				return $cb['id'];
268 268
 			}
269 269
 		}
@@ -288,23 +288,22 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return string Returns an uri.
290 290
 	 */
291
-	public function build_uri( $title, $post_type, $schema_type = NULL, $increment_digit = 0 ) {
291
+	public function build_uri($title, $post_type, $schema_type = NULL, $increment_digit = 0) {
292 292
 
293 293
 		// Get the entity slug suffix digit
294 294
 		$suffix_digit = $increment_digit + 1;
295 295
 		// Get a sanitized uri for a given title
296
-		$entity_slug = ( 0 == $increment_digit ) ?
297
-			wl_sanitize_uri_path( $title ) :
298
-			wl_sanitize_uri_path( $title . '_' . $suffix_digit );
296
+		$entity_slug = (0 == $increment_digit) ?
297
+			wl_sanitize_uri_path($title) : wl_sanitize_uri_path($title.'_'.$suffix_digit);
299 298
 
300 299
 		// Compose a candidated uri
301
-		$new_entity_uri = sprintf( '%s/%s/%s',
300
+		$new_entity_uri = sprintf('%s/%s/%s',
302 301
 			wl_configuration_get_redlink_dataset_uri(),
303 302
 			$post_type,
304 303
 			$entity_slug
305 304
 		);
306 305
 
307
-		$this->log_service->trace( "Going to check if uri is used [ new_entity_uri :: $new_entity_uri ] [ increment_digit :: $increment_digit ]" );
306
+		$this->log_service->trace("Going to check if uri is used [ new_entity_uri :: $new_entity_uri ] [ increment_digit :: $increment_digit ]");
308 307
 
309 308
 		global $wpdb;
310 309
 		// Check if the candidated uri already is used
@@ -315,34 +314,34 @@  discard block
 block discarded – undo
315 314
 		);
316 315
 
317 316
 		// Perform the query
318
-		$post_id = $wpdb->get_var( $stmt );
317
+		$post_id = $wpdb->get_var($stmt);
319 318
 
320 319
 		// If the post does not exist, then the new uri is returned 	
321
-		if ( ! is_numeric( $post_id ) ) {
322
-			$this->log_service->trace( "Going to return uri [ new_entity_uri :: $new_entity_uri ]" );
320
+		if ( ! is_numeric($post_id)) {
321
+			$this->log_service->trace("Going to return uri [ new_entity_uri :: $new_entity_uri ]");
323 322
 
324 323
 			return $new_entity_uri;
325 324
 		}
326 325
 		// If schema_type is equal to schema org type of post x, then the new uri is returned 
327
-		$schema_post_type = wl_entity_type_taxonomy_get_type( $post_id );
326
+		$schema_post_type = wl_entity_type_taxonomy_get_type($post_id);
328 327
 
329
-		if ( $schema_type === $schema_post_type['css_class'] ) {
330
-			$this->log_service->trace( "An entity with the same title and type already exists! Return uri [ new_entity_uri :: $new_entity_uri ]" );
328
+		if ($schema_type === $schema_post_type['css_class']) {
329
+			$this->log_service->trace("An entity with the same title and type already exists! Return uri [ new_entity_uri :: $new_entity_uri ]");
331 330
 
332 331
 			return $new_entity_uri;
333 332
 		}
334 333
 
335 334
 		// Otherwise the same function is called recorsively
336
-		return $this->build_uri( $title, $post_type, $schema_type, ++ $increment_digit );
335
+		return $this->build_uri($title, $post_type, $schema_type, ++ $increment_digit);
337 336
 	}
338 337
 
339
-	public function is_used( $post_id ) {
338
+	public function is_used($post_id) {
340 339
 
341
-		if ( FALSE === $this->is_entity( $post_id ) ) {
340
+		if (FALSE === $this->is_entity($post_id)) {
342 341
 			return NULL;
343 342
 		}
344 343
 		// Retrieve the post
345
-		$entity = get_post( $post_id );
344
+		$entity = get_post($post_id);
346 345
 
347 346
 		global $wpdb;
348 347
 		// Retrieve Wordlift relation instances table name
@@ -355,9 +354,9 @@  discard block
 block discarded – undo
355 354
 		);
356 355
 
357 356
 		// Perform the query
358
-		$relation_instances = (int) $wpdb->get_var( $stmt );
357
+		$relation_instances = (int) $wpdb->get_var($stmt);
359 358
 		// If there is at least one relation instance for the current entity, then it's used
360
-		if ( 0 < $relation_instances ) {
359
+		if (0 < $relation_instances) {
361 360
 			return TRUE;
362 361
 		}
363 362
 
@@ -365,13 +364,13 @@  discard block
 block discarded – undo
365 364
 		$stmt = $wpdb->prepare(
366 365
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
367 366
 			$entity->ID,
368
-			wl_get_entity_uri( $entity->ID )
367
+			wl_get_entity_uri($entity->ID)
369 368
 		);
370 369
 		// Perform the query
371
-		$meta_instances = (int) $wpdb->get_var( $stmt );
370
+		$meta_instances = (int) $wpdb->get_var($stmt);
372 371
 
373 372
 		// If there is at least one meta that refers the current entity uri, then current entity is used
374
-		if ( 0 < $meta_instances ) {
373
+		if (0 < $meta_instances) {
375 374
 			return TRUE;
376 375
 		}
377 376
 
@@ -388,9 +387,9 @@  discard block
 block discarded – undo
388 387
 	 *
389 388
 	 * @return true if the uri internal to the current dataset otherwise false.
390 389
 	 */
391
-	public function is_internal_uri( $uri ) {
390
+	public function is_internal_uri($uri) {
392 391
 
393
-		return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) );
392
+		return (0 === strrpos($uri, wl_configuration_get_redlink_dataset_uri()));
394 393
 	}
395 394
 
396 395
 	/**
@@ -402,10 +401,10 @@  discard block
 block discarded – undo
402 401
 	 *
403 402
 	 * @return WP_Post|null A WP_Post instance or null if not found.
404 403
 	 */
405
-	public function get_entity_post_by_uri( $uri ) {
404
+	public function get_entity_post_by_uri($uri) {
406 405
 
407 406
 		// Check if we've been provided with a value otherwise return null.
408
-		if ( empty( $uri ) ) {
407
+		if (empty($uri)) {
409 408
 			return NULL;
410 409
 		}
411 410
 
@@ -425,7 +424,7 @@  discard block
 block discarded – undo
425 424
 		// Only if the current uri is not an internal uri 
426 425
 		// entity search is performed also looking at sameAs values
427 426
 		// This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237
428
-		if ( ! $this->is_internal_uri( $uri ) ) {
427
+		if ( ! $this->is_internal_uri($uri)) {
429 428
 
430 429
 			$query_args['meta_query']['relation'] = 'OR';
431 430
 			$query_args['meta_query'][]           = array(
@@ -435,13 +434,13 @@  discard block
 block discarded – undo
435 434
 			);
436 435
 		}
437 436
 
438
-		$query = new WP_Query( $query_args );
437
+		$query = new WP_Query($query_args);
439 438
 
440 439
 		// Get the matching entity posts.
441 440
 		$posts = $query->get_posts();
442 441
 
443 442
 		// Return null if no post is found.
444
-		if ( 0 === count( $posts ) ) {
443
+		if (0 === count($posts)) {
445 444
 			return NULL;
446 445
 		}
447 446
 
@@ -461,7 +460,7 @@  discard block
 block discarded – undo
461 460
 	 * @param WP_Post $post    Post object.
462 461
 	 * @param bool    $update  Whether this is an existing post being updated or not.
463 462
 	 */
464
-	public function save_post( $post_id, $post, $update ) {
463
+	public function save_post($post_id, $post, $update) {
465 464
 
466 465
 		// We're setting the alternative label that have been provided via the UI
467 466
 		// (in fact we're using $_REQUEST), while save_post may be also called
@@ -469,15 +468,15 @@  discard block
 block discarded – undo
469 468
 		// the $post_id in the save_post call matches the post id set in the request.
470 469
 		//
471 470
 		// If this is not the current post being saved or if it's not an entity, return.
472
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
471
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
473 472
 			return;
474 473
 		}
475 474
 
476 475
 		// Get the alt labels from the request (or empty array).
477
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
476
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array();
478 477
 
479 478
 		// Set the alternative labels.
480
-		$this->set_alternative_labels( $post_id, $alt_labels );
479
+		$this->set_alternative_labels($post_id, $alt_labels);
481 480
 
482 481
 	}
483 482
 
@@ -489,22 +488,22 @@  discard block
 block discarded – undo
489 488
 	 * @param int   $post_id    The post id.
490 489
 	 * @param array $alt_labels An array of labels.
491 490
 	 */
492
-	public function set_alternative_labels( $post_id, $alt_labels ) {
491
+	public function set_alternative_labels($post_id, $alt_labels) {
493 492
 
494 493
 		// Force $alt_labels to be an array
495
-		if ( ! is_array( $alt_labels ) ) {
496
-			$alt_labels = array( $alt_labels );
494
+		if ( ! is_array($alt_labels)) {
495
+			$alt_labels = array($alt_labels);
497 496
 		}
498 497
 
499
-		$this->log_service->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
498
+		$this->log_service->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
500 499
 
501 500
 		// Delete all the existing alternate labels.
502
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
501
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
503 502
 
504 503
 		// Set the alternative labels.
505
-		foreach ( $alt_labels as $alt_label ) {
506
-			if ( ! empty( $alt_label ) ) {
507
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
504
+		foreach ($alt_labels as $alt_label) {
505
+			if ( ! empty($alt_label)) {
506
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label);
508 507
 			}
509 508
 		}
510 509
 
@@ -519,9 +518,9 @@  discard block
 block discarded – undo
519 518
 	 *
520 519
 	 * @return mixed An array  of alternative labels.
521 520
 	 */
522
-	public function get_alternative_labels( $post_id ) {
521
+	public function get_alternative_labels($post_id) {
523 522
 
524
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
523
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
525 524
 	}
526 525
 
527 526
 	/**
@@ -531,25 +530,25 @@  discard block
 block discarded – undo
531 530
 	 *
532 531
 	 * @param WP_Post $post Post object.
533 532
 	 */
534
-	public function edit_form_before_permalink( $post ) {
533
+	public function edit_form_before_permalink($post) {
535 534
 
536 535
 		// If it's not an entity, return.
537
-		if ( ! $this->is_entity( $post->ID ) ) {
536
+		if ( ! $this->is_entity($post->ID)) {
538 537
 			return;
539 538
 		}
540 539
 
541 540
 		// Print the input template.
542
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
541
+		$this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
543 542
 
544 543
 		// Print all the currently set alternative labels.
545
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
544
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
546 545
 
547
-			echo $this->get_alternative_label_input( $alt_label );
546
+			echo $this->get_alternative_label_input($alt_label);
548 547
 
549 548
 		};
550 549
 
551 550
 		// Print the button.
552
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
551
+		$this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
553 552
 
554 553
 	}
555 554
 
@@ -563,32 +562,32 @@  discard block
 block discarded – undo
563 562
 	public function in_admin_header() {
564 563
 
565 564
 		// Return safely if get_current_screen() is not defined (yet)
566
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
565
+		if (FALSE === function_exists('get_current_screen')) {
567 566
 			return;
568 567
 		}
569 568
 
570 569
 		$screen = get_current_screen();
571 570
 		// If there is any valid screen nothing to do
572
-		if ( NULL === $screen ) {
571
+		if (NULL === $screen) {
573 572
 			return $clauses;
574 573
 		}
575 574
 
576 575
 		// If you're not in the entity post edit page, return.
577
-		if ( self::TYPE_NAME !== $screen->id ) {
576
+		if (self::TYPE_NAME !== $screen->id) {
578 577
 			return;
579 578
 		}
580 579
 		// Retrieve the current global post
581 580
 		global $post;
582 581
 		// If it's not an entity, return.
583
-		if ( ! $this->is_entity( $post->ID ) ) {
582
+		if ( ! $this->is_entity($post->ID)) {
584 583
 			return;
585 584
 		}
586 585
 		// Retrieve an updated rating for the current entity
587
-		$rating = $this->get_rating_for( $post->ID, TRUE );
586
+		$rating = $this->get_rating_for($post->ID, TRUE);
588 587
 		// If there is at least 1 warning
589
-		if ( isset( $rating['warnings'] ) && 0 < count( $rating['warnings'] ) ) {
588
+		if (isset($rating['warnings']) && 0 < count($rating['warnings'])) {
590 589
 			// TODO - Pass Wordlift_Notice_Service trough the service constructor 
591
-			$this->notice_service->add_suggestion( $rating['warnings'] );
590
+			$this->notice_service->add_suggestion($rating['warnings']);
592 591
 		}
593 592
 
594 593
 	}
@@ -602,19 +601,19 @@  discard block
 block discarded – undo
602 601
 	 *
603 602
 	 * @return int An array representing the rating obj.
604 603
 	 */
605
-	public function set_rating_for( $post_id ) {
604
+	public function set_rating_for($post_id) {
606 605
 
607 606
 		// Calculate rating for the given post
608
-		$rating = $this->calculate_rating_for( $post_id );
607
+		$rating = $this->calculate_rating_for($post_id);
609 608
 		// Store the rating on db as post meta
610 609
 		// Please notice that RATING_RAW_SCORE_META_KEY 
611 610
 		// is saved on a different meta to allow score sorting
612 611
 		// Both meta are managed as unique
613 612
 		// https://codex.wordpress.org/Function_Reference/update_post_meta
614
-		update_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, $rating['raw_score'] );
615
-		update_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, $rating['warnings'] );
613
+		update_post_meta($post_id, self::RATING_RAW_SCORE_META_KEY, $rating['raw_score']);
614
+		update_post_meta($post_id, self::RATING_WARNINGS_META_KEY, $rating['warnings']);
616 615
 
617
-		$this->log_service->trace( sprintf( "Rating set for [ post_id :: $post_id ] [ rating :: %s ]", $rating['raw_score'] ) );
616
+		$this->log_service->trace(sprintf("Rating set for [ post_id :: $post_id ] [ rating :: %s ]", $rating['raw_score']));
618 617
 
619 618
 		// Finally returns the rating 
620 619
 		return $rating;
@@ -630,29 +629,29 @@  discard block
 block discarded – undo
630 629
 	 *
631 630
 	 * @return int An array representing the rating obj.
632 631
 	 */
633
-	public function get_rating_for( $post_id, $force_reload = FALSE ) {
632
+	public function get_rating_for($post_id, $force_reload = FALSE) {
634 633
 
635 634
 		// If forced reload is required or rating is missing ..
636
-		if ( $force_reload ) {
637
-			$this->log_service->trace( "Force rating reload [ post_id :: $post_id ]" );
635
+		if ($force_reload) {
636
+			$this->log_service->trace("Force rating reload [ post_id :: $post_id ]");
638 637
 
639
-			return $this->set_rating_for( $post_id );
638
+			return $this->set_rating_for($post_id);
640 639
 		}
641 640
 
642
-		$current_raw_score = get_post_meta( $post_id, self::RATING_RAW_SCORE_META_KEY, TRUE );
641
+		$current_raw_score = get_post_meta($post_id, self::RATING_RAW_SCORE_META_KEY, TRUE);
643 642
 
644
-		if ( ! is_numeric( $current_raw_score ) ) {
645
-			$this->log_service->trace( "Rating missing for [ post_id :: $post_id ] [ current_raw_score :: $current_raw_score ]" );
643
+		if ( ! is_numeric($current_raw_score)) {
644
+			$this->log_service->trace("Rating missing for [ post_id :: $post_id ] [ current_raw_score :: $current_raw_score ]");
646 645
 
647
-			return $this->set_rating_for( $post_id );
646
+			return $this->set_rating_for($post_id);
648 647
 		}
649
-		$current_warnings = get_post_meta( $post_id, self::RATING_WARNINGS_META_KEY, TRUE );
648
+		$current_warnings = get_post_meta($post_id, self::RATING_WARNINGS_META_KEY, TRUE);
650 649
 
651 650
 		// Finally return score and warnings
652 651
 		return array(
653 652
 			'raw_score'           => $current_raw_score,
654
-			'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $current_raw_score ),
655
-			'percentage_score'    => $this->convert_raw_score_to_percentage( $current_raw_score ),
653
+			'traffic_light_score' => $this->convert_raw_score_to_traffic_light($current_raw_score),
654
+			'percentage_score'    => $this->convert_raw_score_to_percentage($current_raw_score),
656 655
 			'warnings'            => $current_warnings,
657 656
 		);
658 657
 
@@ -678,44 +677,39 @@  discard block
 block discarded – undo
678 677
 	 *
679 678
 	 * @return int An array representing the rating obj.
680 679
 	 */
681
-	public function calculate_rating_for( $post_id ) {
680
+	public function calculate_rating_for($post_id) {
682 681
 
683 682
 		// If it's not an entity, return.
684
-		if ( ! $this->is_entity( $post_id ) ) {
683
+		if ( ! $this->is_entity($post_id)) {
685 684
 			return;
686 685
 		}
687 686
 		// Retrieve the post object
688
-		$post = get_post( $post_id );
687
+		$post = get_post($post_id);
689 688
 		// Rating value
690 689
 		$score = 0;
691 690
 		// Store warning messages
692 691
 		$warnings = array();
693 692
 
694 693
 		// Is the current entity related to at least 1 post?
695
-		( 0 < count( wl_core_get_related_post_ids( $post->ID ) ) ) ?
696
-			$score ++ :
697
-			array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_POSTS, 'wordlift' ) );
694
+		(0 < count(wl_core_get_related_post_ids($post->ID))) ?
695
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_RELATED_POSTS, 'wordlift'));
698 696
 
699 697
 		// Is the post content not empty?
700
-		( ! empty( $post->post_content ) ) ?
701
-			$score ++ :
702
-			array_push( $warnings, __( self::RATING_WARNING_HAS_CONTENT_POST, 'wordlift' ) );
698
+		( ! empty($post->post_content)) ?
699
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_CONTENT_POST, 'wordlift'));
703 700
 
704 701
 		// Is the current entity related to at least 1 entity?
705 702
 		// Was the current entity already disambiguated?
706
-		( 0 < count( wl_core_get_related_entity_ids( $post->ID ) ) ) ?
707
-			$score ++ :
708
-			array_push( $warnings, __( self::RATING_WARNING_HAS_RELATED_ENTITIES, 'wordlift' ) );
703
+		(0 < count(wl_core_get_related_entity_ids($post->ID))) ?
704
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_RELATED_ENTITIES, 'wordlift'));
709 705
 
710 706
 		// Is the entity published?
711
-		( 'publish' === get_post_status( $post->ID ) ) ?
712
-			$score ++ :
713
-			array_push( $warnings, __( self::RATING_WARNING_IS_PUBLISHED, 'wordlift' ) );
707
+		('publish' === get_post_status($post->ID)) ?
708
+			$score++ : array_push($warnings, __(self::RATING_WARNING_IS_PUBLISHED, 'wordlift'));
714 709
 
715 710
 		// Has a thumbnail?
716
-		( has_post_thumbnail( $post->ID ) ) ?
717
-			$score ++ :
718
-			array_push( $warnings, __( self::RATING_WARNING_HAS_THUMBNAIL, 'wordlift' ) );
711
+		(has_post_thumbnail($post->ID)) ?
712
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_THUMBNAIL, 'wordlift'));
719 713
 
720 714
 		// Get all post meta keys for the current post		
721 715
 		global $wpdb;
@@ -725,30 +719,27 @@  discard block
 block discarded – undo
725 719
 
726 720
 		// Check intersection between available meta keys 
727 721
 		// and expected ones arrays to detect missing values
728
-		$available_meta_keys = $wpdb->get_col( $query );
722
+		$available_meta_keys = $wpdb->get_col($query);
729 723
 
730 724
 		// If each expected key is contained in available keys array ...
731
-		( in_array( Wordlift_Schema_Service::FIELD_SAME_AS, $available_meta_keys ) ) ?
732
-			$score ++ :
733
-			array_push( $warnings, __( self::RATING_WARNING_HAS_SAME_AS, 'wordlift' ) );
725
+		(in_array(Wordlift_Schema_Service::FIELD_SAME_AS, $available_meta_keys)) ?
726
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_SAME_AS, 'wordlift'));
734 727
 
735
-		$schema = wl_entity_type_taxonomy_get_type( $post_id );
728
+		$schema = wl_entity_type_taxonomy_get_type($post_id);
736 729
 
737
-		$expected_meta_keys = ( NULL === $schema['custom_fields'] ) ?
738
-			array() :
739
-			array_keys( $schema['custom_fields'] );
730
+		$expected_meta_keys = (NULL === $schema['custom_fields']) ?
731
+			array() : array_keys($schema['custom_fields']);
740 732
 
741
-		$intersection = array_intersect( $expected_meta_keys, $available_meta_keys );
733
+		$intersection = array_intersect($expected_meta_keys, $available_meta_keys);
742 734
 		// If each expected key is contained in available keys array ...
743
-		( count( $intersection ) === count( $expected_meta_keys ) ) ?
744
-			$score ++ :
745
-			array_push( $warnings, __( self::RATING_WARNING_HAS_COMPLETED_METADATA, 'wordlift' ) );
735
+		(count($intersection) === count($expected_meta_keys)) ?
736
+			$score++ : array_push($warnings, __(self::RATING_WARNING_HAS_COMPLETED_METADATA, 'wordlift'));
746 737
 
747 738
 		// Finally return score and warnings
748 739
 		return array(
749 740
 			'raw_score'           => $score,
750
-			'traffic_light_score' => $this->convert_raw_score_to_traffic_light( $score ),
751
-			'percentage_score'    => $this->convert_raw_score_to_percentage( $score ),
741
+			'traffic_light_score' => $this->convert_raw_score_to_traffic_light($score),
742
+			'percentage_score'    => $this->convert_raw_score_to_percentage($score),
752 743
 			'warnings'            => $warnings,
753 744
 		);
754 745
 
@@ -763,25 +754,25 @@  discard block
 block discarded – undo
763 754
 	 *
764 755
 	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
765 756
 	 */
766
-	public function get_uri( $post_id ) {
757
+	public function get_uri($post_id) {
767 758
 
768 759
 		// If a null is given, nothing to do
769
-		if ( NULL == $post_id ) {
760
+		if (NULL == $post_id) {
770 761
 			return NULL;
771 762
 		}
772 763
 
773
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, TRUE );
764
+		$uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, TRUE);
774 765
 
775 766
 		// If the dataset uri is not properly configured, null is returned
776
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
767
+		if ('' === wl_configuration_get_redlink_dataset_uri()) {
777 768
 			return NULL;
778 769
 		}
779 770
 
780 771
 		// Set the URI if it isn't set yet.
781
-		$post_status = get_post_status( $post_id );
782
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
783
-			$uri = wl_build_entity_uri( $post_id );
784
-			wl_set_entity_uri( $post_id, $uri );
772
+		$post_status = get_post_status($post_id);
773
+		if (empty($uri) && 'auto-draft' !== $post_status && 'revision' !== $post_status) {
774
+			$uri = wl_build_entity_uri($post_id);
775
+			wl_set_entity_uri($post_id, $uri);
785 776
 		}
786 777
 
787 778
 		return $uri;
@@ -796,13 +787,13 @@  discard block
 block discarded – undo
796 787
 	 *
797 788
 	 * @return string The input HTML code.
798 789
 	 */
799
-	private function convert_raw_score_to_traffic_light( $score ) {
790
+	private function convert_raw_score_to_traffic_light($score) {
800 791
 		// RATING_MAX : $score = 3 : x 
801 792
 		// See http://php.net/manual/en/function.round.php
802
-		$rating = round( ( $score * 3 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
793
+		$rating = round(($score * 3) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP);
803 794
 
804 795
 		// If rating is 0, return 1, otherwise return rating
805
-		return ( 0 == $rating ) ? 1 : $rating;
796
+		return (0 == $rating) ? 1 : $rating;
806 797
 
807 798
 	}
808 799
 
@@ -815,9 +806,9 @@  discard block
 block discarded – undo
815 806
 	 *
816 807
 	 * @return string The input HTML code.
817 808
 	 */
818
-	public function convert_raw_score_to_percentage( $score ) {
809
+	public function convert_raw_score_to_percentage($score) {
819 810
 		// RATING_MAX : $score = 100 : x 
820
-		return round( ( $score * 100 ) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP );
811
+		return round(($score * 100) / self::get_rating_max(), 0, PHP_ROUND_HALF_UP);
821 812
 	}
822 813
 
823 814
 	/**
@@ -829,9 +820,9 @@  discard block
 block discarded – undo
829 820
 	 *
830 821
 	 * @return string The input HTML code.
831 822
 	 */
832
-	private function get_alternative_label_input( $value = '' ) {
823
+	private function get_alternative_label_input($value = '') {
833 824
 
834
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
825
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
835 826
 	}
836 827
 
837 828
 	/**
@@ -843,7 +834,7 @@  discard block
 block discarded – undo
843 834
 	 */
844 835
 	public function count() {
845 836
 
846
-		$count = wp_count_posts( self::TYPE_NAME );
837
+		$count = wp_count_posts(self::TYPE_NAME);
847 838
 
848 839
 		return $count->publish;
849 840
 	}
@@ -860,28 +851,28 @@  discard block
 block discarded – undo
860 851
 	 *
861 852
 	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
862 853
 	 */
863
-	public function create( $name, $type_uri, $logo = NULL, $status = 'publish' ) {
854
+	public function create($name, $type_uri, $logo = NULL, $status = 'publish') {
864 855
 
865 856
 		// Create an entity for the publisher.
866
-		$post_id = wp_insert_post( array(
857
+		$post_id = wp_insert_post(array(
867 858
 			'post_type'    => self::TYPE_NAME,
868 859
 			'post_title'   => $name,
869 860
 			'post_status'  => $status,
870 861
 			'post_content' => '',
871
-		) );
862
+		));
872 863
 
873 864
 		// Return the error if any.
874
-		if ( is_wp_error( $post_id ) ) {
865
+		if (is_wp_error($post_id)) {
875 866
 			return $post_id;
876 867
 		}
877 868
 
878 869
 		// Set the entity logo.
879
-		if ( $logo && is_numeric( $logo ) ) {
880
-			set_post_thumbnail( $post_id, $logo );
870
+		if ($logo && is_numeric($logo)) {
871
+			set_post_thumbnail($post_id, $logo);
881 872
 		}
882 873
 
883 874
 		// Set the entity type.
884
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
875
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
885 876
 
886 877
 		return $post_id;
887 878
 	}
Please login to merge, or discard this patch.
src/includes/class-wordlift-languages.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 // We need `format_code_lang` defined in the ms.php file. This file only contains function, we can require it once.
@@ -24,78 +24,78 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class Wordlift_Languages {
26 26
 
27
-	/**
28
-	 * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the
29
-	 * `get_languages` function.
30
-	 *
31
-	 * @since 3.9.0
32
-	 * @var array|null An array of language codes => language names pairs or NULL if not initialized yet.
33
-	 */
34
-	private static $languages = null;
27
+    /**
28
+     * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the
29
+     * `get_languages` function.
30
+     *
31
+     * @since 3.9.0
32
+     * @var array|null An array of language codes => language names pairs or NULL if not initialized yet.
33
+     */
34
+    private static $languages = null;
35 35
 
36
-	/**
37
-	 * The list of supported language codes.
38
-	 *
39
-	 * @since 3.9.0
40
-	 *
41
-	 * @var array An array of language codes.
42
-	 */
43
-	private static $codes = array(
44
-		'be',
45
-		'bg',
46
-		'ca',
47
-		'cs',
48
-		'da',
49
-		'en',
50
-		'es',
51
-		'et',
52
-		'fi',
53
-		'fr',
54
-		'hr',
55
-		'hu',
56
-		'id',
57
-		'is',
58
-		'it',
59
-		'lt',
60
-		'lv',
61
-		'nl',
62
-		'no',
63
-		'pl',
64
-		'pt',
65
-		'ro',
66
-		'ru',
67
-		'sk',
68
-		'sl',
69
-		'sq',
70
-		'sr',
71
-		'sv',
72
-		'tr',
73
-		'uk',
74
-		'zh',
75
-	);
36
+    /**
37
+     * The list of supported language codes.
38
+     *
39
+     * @since 3.9.0
40
+     *
41
+     * @var array An array of language codes.
42
+     */
43
+    private static $codes = array(
44
+        'be',
45
+        'bg',
46
+        'ca',
47
+        'cs',
48
+        'da',
49
+        'en',
50
+        'es',
51
+        'et',
52
+        'fi',
53
+        'fr',
54
+        'hr',
55
+        'hu',
56
+        'id',
57
+        'is',
58
+        'it',
59
+        'lt',
60
+        'lv',
61
+        'nl',
62
+        'no',
63
+        'pl',
64
+        'pt',
65
+        'ro',
66
+        'ru',
67
+        'sk',
68
+        'sl',
69
+        'sq',
70
+        'sr',
71
+        'sv',
72
+        'tr',
73
+        'uk',
74
+        'zh',
75
+    );
76 76
 
77
-	/**
78
-	 * Get the list of WordLift's supported languages in an array with language code => language name pairs.
79
-	 *
80
-	 * @since 3.9.0
81
-	 *
82
-	 * @return array An array with language code => language name pairs.
83
-	 */
84
-	public static function get_languages() {
77
+    /**
78
+     * Get the list of WordLift's supported languages in an array with language code => language name pairs.
79
+     *
80
+     * @since 3.9.0
81
+     *
82
+     * @return array An array with language code => language name pairs.
83
+     */
84
+    public static function get_languages() {
85 85
 
86
-		// Lazily load the languages.
87
-		if ( null === self::$languages ) {
86
+        // Lazily load the languages.
87
+        if ( null === self::$languages ) {
88 88
 
89
-			// Get the language names from WP's own (multisite) function.
90
-			foreach ( self::$codes as $key ) {
91
-				self::$languages[ $key ] = format_code_lang( $key );
92
-			}
89
+            // Get the language names from WP's own (multisite) function.
90
+            foreach ( self::$codes as $key ) {
91
+                self::$languages[ $key ] = format_code_lang( $key );
92
+            }
93 93
 
94
-			// Sort by language name.
95
-			asort( self::$languages );
96
-		}
94
+            // Sort by language name.
95
+            asort( self::$languages );
96
+        }
97 97
 
98
-		return self::$languages;
99
-	}
98
+        return self::$languages;
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
  * @since   3.9.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // We need `format_code_lang` defined in the ms.php file. This file only contains function, we can require it once.
18
-require_once( ABSPATH . 'wp-admin/includes/ms.php' );
18
+require_once(ABSPATH.'wp-admin/includes/ms.php');
19 19
 
20 20
 /**
21 21
  * Define the {@link Wordlift_Languages} class.
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
 	public static function get_languages() {
85 85
 
86 86
 		// Lazily load the languages.
87
-		if ( null === self::$languages ) {
87
+		if (null === self::$languages) {
88 88
 
89 89
 			// Get the language names from WP's own (multisite) function.
90
-			foreach ( self::$codes as $key ) {
91
-				self::$languages[ $key ] = format_code_lang( $key );
90
+			foreach (self::$codes as $key) {
91
+				self::$languages[$key] = format_code_lang($key);
92 92
 			}
93 93
 
94 94
 			// Sort by language name.
95
-			asort( self::$languages );
95
+			asort(self::$languages);
96 96
 		}
97 97
 
98 98
 		return self::$languages;
Please login to merge, or discard this patch.
src/includes/class-wordlift-configuration-service.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 /**
@@ -21,237 +21,237 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Wordlift_Configuration_Service {
23 23
 
24
-	/**
25
-	 * The entity base path option name.
26
-	 *
27
-	 * @since 3.6.0
28
-	 */
29
-	const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path';
30
-
31
-	/**
32
-	 * The skip wizard (admin installation wizard) option name.
33
-	 *
34
-	 * @since 3.9.0
35
-	 */
36
-	const SKIP_WIZARD = 'wl_skip_wizard';
37
-
38
-	/**
39
-	 * WordLift's key option name.
40
-	 *
41
-	 * @since 3.9.0
42
-	 */
43
-	const KEY = 'key';
44
-
45
-	/**
46
-	 * WordLift's configured language option name.
47
-	 *
48
-	 * @since 3.9.0
49
-	 */
50
-	const LANGUAGE = 'site_language';
51
-
52
-	/**
53
-	 * The publisher entity post ID option name.
54
-	 *
55
-	 * @since 3.9.0
56
-	 */
57
-	const PUBLISHER_ID = 'publisher_id';
58
-
59
-	/**
60
-	 * The Wordlift_Configuration_Service's singleton instance.
61
-	 *
62
-	 * @since  3.6.0
63
-	 *
64
-	 * @access private
65
-	 * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance.
66
-	 */
67
-	private static $instance;
68
-
69
-	/**
70
-	 * Create a Wordlift_Configuration_Service's instance.
71
-	 *
72
-	 * @since 3.6.0
73
-	 */
74
-	public function __construct() {
75
-
76
-		self::$instance = $this;
77
-
78
-	}
79
-
80
-	/**
81
-	 * Get the singleton instance.
82
-	 *
83
-	 * @since 3.6.0
84
-	 *
85
-	 * @return \Wordlift_Configuration_Service
86
-	 */
87
-	public static function get_instance() {
88
-
89
-		return self::$instance;
90
-	}
91
-
92
-	/**
93
-	 * Get a configuration given the option name and a key. The option value is
94
-	 * expected to be an array.
95
-	 *
96
-	 * @since 3.6.0
97
-	 *
98
-	 * @param string $option  The option name.
99
-	 * @param string $key     A key in the option value array.
100
-	 * @param string $default The default value in case the key is not found (by default an empty string).
101
-	 *
102
-	 * @return mixed The configuration value or the default value if not found.
103
-	 */
104
-	private function get( $option, $key, $default = '' ) {
105
-
106
-		$options = get_option( $option, array() );
107
-
108
-		return isset( $options[ $key ] ) ? $options[ $key ] : $default;
109
-	}
110
-
111
-	/**
112
-	 * Set a configuration parameter.
113
-	 *
114
-	 * @since 3.9.0
115
-	 *
116
-	 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
117
-	 * @param string $key    The value key.
118
-	 * @param mixed  $value  The value.
119
-	 */
120
-	private function set( $option, $key, $value ) {
121
-
122
-		$values         = get_option( $option );
123
-		$values         = isset( $values ) ? $values : array();
124
-		$values[ $key ] = $value;
125
-		update_option( $option, $values );
126
-
127
-	}
128
-
129
-	/**
130
-	 * Get the entity base path, by default 'entity'.
131
-	 *
132
-	 * @since 3.6.0
133
-	 *
134
-	 * @return string The entity base path.
135
-	 */
136
-	public function get_entity_base_path() {
137
-
138
-		return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
139
-	}
140
-
141
-	/**
142
-	 * Get the entity base path.
143
-	 *
144
-	 * @since 3.9.0
145
-	 *
146
-	 * @param string $value The entity base path.
147
-	 */
148
-	public function set_entity_base_path( $value ) {
149
-
150
-		$this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
151
-	}
152
-
153
-	/**
154
-	 * Whether the installation skip wizard should be skipped.
155
-	 *
156
-	 * @since 3.9.0
157
-	 *
158
-	 * @return bool True if it should be skipped otherwise false.
159
-	 */
160
-	public function is_skip_wizard() {
161
-
162
-		return $this->get( 'wl_general_settings', self::SKIP_WIZARD, FALSE );
163
-	}
164
-
165
-	/**
166
-	 * Set the skip wizard parameter.
167
-	 *
168
-	 * @since 3.9.0
169
-	 *
170
-	 * @param bool $value True to skip the wizard. We expect a boolean value.
171
-	 */
172
-	public function set_skip_wizard( $value ) {
173
-
174
-		$this->set( 'wl_general_settings', self::SKIP_WIZARD, $value === TRUE );
175
-
176
-	}
177
-
178
-	/**
179
-	 * Get WordLift's key.
180
-	 *
181
-	 * @since 3.9.0
182
-	 *
183
-	 * @return WordLift's key or an empty string if not set.
184
-	 */
185
-	public function get_key() {
186
-
187
-		return $this->get( 'wl_general_settings', self::KEY, '' );
188
-	}
189
-
190
-	/**
191
-	 * Set WordLift's key.
192
-	 *
193
-	 * @since 3.9.0
194
-	 *
195
-	 * @param string $value WordLift's key.
196
-	 */
197
-	public function set_key( $value ) {
198
-
199
-		$this->set( 'wl_general_settings', self::KEY, $value );
200
-	}
201
-
202
-	/**
203
-	 * Get WordLift's configured language, by default 'en'.
204
-	 *
205
-	 * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis.
206
-	 *
207
-	 * @since 3.9.0
208
-	 *
209
-	 * @return string WordLift's configured language code ('en' by default).
210
-	 */
211
-	public function get_language_code() {
212
-
213
-		return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
214
-	}
215
-
216
-	/**
217
-	 * Set WordLift's language code, used when storing strings to the Linked Data dataset.
218
-	 *
219
-	 * @since 3.9.0
220
-	 *
221
-	 * @param string $value WordLift's language code.
222
-	 */
223
-	public function set_language_code( $value ) {
224
-
225
-		$this->set( 'wl_general_settings', self::LANGUAGE, $value );
226
-
227
-	}
228
-
229
-	/**
230
-	 * Get the publisher entity post id.
231
-	 *
232
-	 * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org
233
-	 * Article markup.
234
-	 *
235
-	 * @since 3.9.0
236
-	 *
237
-	 * @return int|NULL The publisher entity post id or NULL if not set.
238
-	 */
239
-	public function get_publisher_id() {
240
-
241
-		return $this->get( 'wl_general_settings', self::PUBLISHER_ID, NULL );
242
-	}
243
-
244
-	/**
245
-	 * Set the publisher entity post id.
246
-	 *
247
-	 * @since 3.9.0
248
-	 *
249
-	 * @param int $value The publisher entity post id.
250
-	 */
251
-	public function set_publisher_id( $value ) {
252
-
253
-		$this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
254
-
255
-	}
24
+    /**
25
+     * The entity base path option name.
26
+     *
27
+     * @since 3.6.0
28
+     */
29
+    const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path';
30
+
31
+    /**
32
+     * The skip wizard (admin installation wizard) option name.
33
+     *
34
+     * @since 3.9.0
35
+     */
36
+    const SKIP_WIZARD = 'wl_skip_wizard';
37
+
38
+    /**
39
+     * WordLift's key option name.
40
+     *
41
+     * @since 3.9.0
42
+     */
43
+    const KEY = 'key';
44
+
45
+    /**
46
+     * WordLift's configured language option name.
47
+     *
48
+     * @since 3.9.0
49
+     */
50
+    const LANGUAGE = 'site_language';
51
+
52
+    /**
53
+     * The publisher entity post ID option name.
54
+     *
55
+     * @since 3.9.0
56
+     */
57
+    const PUBLISHER_ID = 'publisher_id';
58
+
59
+    /**
60
+     * The Wordlift_Configuration_Service's singleton instance.
61
+     *
62
+     * @since  3.6.0
63
+     *
64
+     * @access private
65
+     * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance.
66
+     */
67
+    private static $instance;
68
+
69
+    /**
70
+     * Create a Wordlift_Configuration_Service's instance.
71
+     *
72
+     * @since 3.6.0
73
+     */
74
+    public function __construct() {
75
+
76
+        self::$instance = $this;
77
+
78
+    }
79
+
80
+    /**
81
+     * Get the singleton instance.
82
+     *
83
+     * @since 3.6.0
84
+     *
85
+     * @return \Wordlift_Configuration_Service
86
+     */
87
+    public static function get_instance() {
88
+
89
+        return self::$instance;
90
+    }
91
+
92
+    /**
93
+     * Get a configuration given the option name and a key. The option value is
94
+     * expected to be an array.
95
+     *
96
+     * @since 3.6.0
97
+     *
98
+     * @param string $option  The option name.
99
+     * @param string $key     A key in the option value array.
100
+     * @param string $default The default value in case the key is not found (by default an empty string).
101
+     *
102
+     * @return mixed The configuration value or the default value if not found.
103
+     */
104
+    private function get( $option, $key, $default = '' ) {
105
+
106
+        $options = get_option( $option, array() );
107
+
108
+        return isset( $options[ $key ] ) ? $options[ $key ] : $default;
109
+    }
110
+
111
+    /**
112
+     * Set a configuration parameter.
113
+     *
114
+     * @since 3.9.0
115
+     *
116
+     * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
117
+     * @param string $key    The value key.
118
+     * @param mixed  $value  The value.
119
+     */
120
+    private function set( $option, $key, $value ) {
121
+
122
+        $values         = get_option( $option );
123
+        $values         = isset( $values ) ? $values : array();
124
+        $values[ $key ] = $value;
125
+        update_option( $option, $values );
126
+
127
+    }
128
+
129
+    /**
130
+     * Get the entity base path, by default 'entity'.
131
+     *
132
+     * @since 3.6.0
133
+     *
134
+     * @return string The entity base path.
135
+     */
136
+    public function get_entity_base_path() {
137
+
138
+        return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
139
+    }
140
+
141
+    /**
142
+     * Get the entity base path.
143
+     *
144
+     * @since 3.9.0
145
+     *
146
+     * @param string $value The entity base path.
147
+     */
148
+    public function set_entity_base_path( $value ) {
149
+
150
+        $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
151
+    }
152
+
153
+    /**
154
+     * Whether the installation skip wizard should be skipped.
155
+     *
156
+     * @since 3.9.0
157
+     *
158
+     * @return bool True if it should be skipped otherwise false.
159
+     */
160
+    public function is_skip_wizard() {
161
+
162
+        return $this->get( 'wl_general_settings', self::SKIP_WIZARD, FALSE );
163
+    }
164
+
165
+    /**
166
+     * Set the skip wizard parameter.
167
+     *
168
+     * @since 3.9.0
169
+     *
170
+     * @param bool $value True to skip the wizard. We expect a boolean value.
171
+     */
172
+    public function set_skip_wizard( $value ) {
173
+
174
+        $this->set( 'wl_general_settings', self::SKIP_WIZARD, $value === TRUE );
175
+
176
+    }
177
+
178
+    /**
179
+     * Get WordLift's key.
180
+     *
181
+     * @since 3.9.0
182
+     *
183
+     * @return WordLift's key or an empty string if not set.
184
+     */
185
+    public function get_key() {
186
+
187
+        return $this->get( 'wl_general_settings', self::KEY, '' );
188
+    }
189
+
190
+    /**
191
+     * Set WordLift's key.
192
+     *
193
+     * @since 3.9.0
194
+     *
195
+     * @param string $value WordLift's key.
196
+     */
197
+    public function set_key( $value ) {
198
+
199
+        $this->set( 'wl_general_settings', self::KEY, $value );
200
+    }
201
+
202
+    /**
203
+     * Get WordLift's configured language, by default 'en'.
204
+     *
205
+     * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis.
206
+     *
207
+     * @since 3.9.0
208
+     *
209
+     * @return string WordLift's configured language code ('en' by default).
210
+     */
211
+    public function get_language_code() {
212
+
213
+        return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
214
+    }
215
+
216
+    /**
217
+     * Set WordLift's language code, used when storing strings to the Linked Data dataset.
218
+     *
219
+     * @since 3.9.0
220
+     *
221
+     * @param string $value WordLift's language code.
222
+     */
223
+    public function set_language_code( $value ) {
224
+
225
+        $this->set( 'wl_general_settings', self::LANGUAGE, $value );
226
+
227
+    }
228
+
229
+    /**
230
+     * Get the publisher entity post id.
231
+     *
232
+     * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org
233
+     * Article markup.
234
+     *
235
+     * @since 3.9.0
236
+     *
237
+     * @return int|NULL The publisher entity post id or NULL if not set.
238
+     */
239
+    public function get_publisher_id() {
240
+
241
+        return $this->get( 'wl_general_settings', self::PUBLISHER_ID, NULL );
242
+    }
243
+
244
+    /**
245
+     * Set the publisher entity post id.
246
+     *
247
+     * @since 3.9.0
248
+     *
249
+     * @param int $value The publisher entity post id.
250
+     */
251
+    public function set_publisher_id( $value ) {
252
+
253
+        $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
254
+
255
+    }
256 256
 
257 257
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since      3.6.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return mixed The configuration value or the default value if not found.
103 103
 	 */
104
-	private function get( $option, $key, $default = '' ) {
104
+	private function get($option, $key, $default = '') {
105 105
 
106
-		$options = get_option( $option, array() );
106
+		$options = get_option($option, array());
107 107
 
108
-		return isset( $options[ $key ] ) ? $options[ $key ] : $default;
108
+		return isset($options[$key]) ? $options[$key] : $default;
109 109
 	}
110 110
 
111 111
 	/**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 	 * @param string $key    The value key.
118 118
 	 * @param mixed  $value  The value.
119 119
 	 */
120
-	private function set( $option, $key, $value ) {
120
+	private function set($option, $key, $value) {
121 121
 
122
-		$values         = get_option( $option );
123
-		$values         = isset( $values ) ? $values : array();
124
-		$values[ $key ] = $value;
125
-		update_option( $option, $values );
122
+		$values         = get_option($option);
123
+		$values         = isset($values) ? $values : array();
124
+		$values[$key] = $value;
125
+		update_option($option, $values);
126 126
 
127 127
 	}
128 128
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function get_entity_base_path() {
137 137
 
138
-		return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
138
+		return $this->get('wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity');
139 139
 	}
140 140
 
141 141
 	/**
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param string $value The entity base path.
147 147
 	 */
148
-	public function set_entity_base_path( $value ) {
148
+	public function set_entity_base_path($value) {
149 149
 
150
-		$this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
150
+		$this->set('wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value);
151 151
 	}
152 152
 
153 153
 	/**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function is_skip_wizard() {
161 161
 
162
-		return $this->get( 'wl_general_settings', self::SKIP_WIZARD, FALSE );
162
+		return $this->get('wl_general_settings', self::SKIP_WIZARD, FALSE);
163 163
 	}
164 164
 
165 165
 	/**
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param bool $value True to skip the wizard. We expect a boolean value.
171 171
 	 */
172
-	public function set_skip_wizard( $value ) {
172
+	public function set_skip_wizard($value) {
173 173
 
174
-		$this->set( 'wl_general_settings', self::SKIP_WIZARD, $value === TRUE );
174
+		$this->set('wl_general_settings', self::SKIP_WIZARD, $value === TRUE);
175 175
 
176 176
 	}
177 177
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function get_key() {
186 186
 
187
-		return $this->get( 'wl_general_settings', self::KEY, '' );
187
+		return $this->get('wl_general_settings', self::KEY, '');
188 188
 	}
189 189
 
190 190
 	/**
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @param string $value WordLift's key.
196 196
 	 */
197
-	public function set_key( $value ) {
197
+	public function set_key($value) {
198 198
 
199
-		$this->set( 'wl_general_settings', self::KEY, $value );
199
+		$this->set('wl_general_settings', self::KEY, $value);
200 200
 	}
201 201
 
202 202
 	/**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function get_language_code() {
212 212
 
213
-		return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
213
+		return $this->get('wl_general_settings', self::LANGUAGE, 'en');
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @param string $value WordLift's language code.
222 222
 	 */
223
-	public function set_language_code( $value ) {
223
+	public function set_language_code($value) {
224 224
 
225
-		$this->set( 'wl_general_settings', self::LANGUAGE, $value );
225
+		$this->set('wl_general_settings', self::LANGUAGE, $value);
226 226
 
227 227
 	}
228 228
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function get_publisher_id() {
240 240
 
241
-		return $this->get( 'wl_general_settings', self::PUBLISHER_ID, NULL );
241
+		return $this->get('wl_general_settings', self::PUBLISHER_ID, NULL);
242 242
 	}
243 243
 
244 244
 	/**
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param int $value The publisher entity post id.
250 250
 	 */
251
-	public function set_publisher_id( $value ) {
251
+	public function set_publisher_id($value) {
252 252
 
253
-		$this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
253
+		$this->set('wl_general_settings', self::PUBLISHER_ID, $value);
254 254
 
255 255
 	}
256 256
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-activator.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Activator {
24 24
 
25
-	/**
26
-	 * Short Description. (use period)
27
-	 *
28
-	 * Long Description.
29
-	 *
30
-	 * @since    1.0.0
31
-	 */
32
-	public static function activate() {
25
+    /**
26
+     * Short Description. (use period)
27
+     *
28
+     * Long Description.
29
+     *
30
+     * @since    1.0.0
31
+     */
32
+    public static function activate() {
33 33
 
34
-		// If WordLift's key is not set `_wl_activation_redirect` transient. We won't redirect here, because we can't give
35
-		// for granted that we're in a browser admin session.
36
-		if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() ) {
37
-			set_transient( '_wl_activation_redirect', TRUE, 30 );
38
-		}
34
+        // If WordLift's key is not set `_wl_activation_redirect` transient. We won't redirect here, because we can't give
35
+        // for granted that we're in a browser admin session.
36
+        if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() ) {
37
+            set_transient( '_wl_activation_redirect', TRUE, 30 );
38
+        }
39 39
 
40
-	}
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
 
34 34
 		// If WordLift's key is not set `_wl_activation_redirect` transient. We won't redirect here, because we can't give
35 35
 		// for granted that we're in a browser admin session.
36
-		if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() ) {
37
-			set_transient( '_wl_activation_redirect', TRUE, 30 );
36
+		if ('' === Wordlift_Configuration_Service::get_instance()->get_key()) {
37
+			set_transient('_wl_activation_redirect', TRUE, 30);
38 38
 		}
39 39
 
40 40
 	}
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 2 patches
Indentation   +765 added lines, -765 removed lines patch added patch discarded remove patch
@@ -29,829 +29,829 @@
 block discarded – undo
29 29
  */
30 30
 class Wordlift {
31 31
 
32
-	/**
33
-	 * The loader that's responsible for maintaining and registering all hooks that power
34
-	 * the plugin.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   protected
38
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
-	 */
40
-	protected $loader;
41
-
42
-	/**
43
-	 * The unique identifier of this plugin.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   protected
47
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
48
-	 */
49
-	protected $plugin_name;
50
-
51
-	/**
52
-	 * The current version of the plugin.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   protected
56
-	 * @var      string $version The current version of the plugin.
57
-	 */
58
-	protected $version;
59
-
60
-	/**
61
-	 * The Thumbnail service.
62
-	 *
63
-	 * @since  3.1.5
64
-	 * @access private
65
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
-	 */
67
-	private $thumbnail_service;
68
-
69
-	/**
70
-	 * The UI service.
71
-	 *
72
-	 * @since  3.2.0
73
-	 * @access private
74
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
75
-	 */
76
-	private $ui_service;
77
-
78
-	/**
79
-	 * The Schema service.
80
-	 *
81
-	 * @since  3.3.0
82
-	 * @access private
83
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
-	 */
85
-	private $schema_service;
86
-
87
-	/**
88
-	 * The Entity service.
89
-	 *
90
-	 * @since  3.1.0
91
-	 * @access private
92
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
-	 */
94
-	private $entity_service;
95
-
96
-	/**
97
-	 * The Topic Taxonomy service.
98
-	 *
99
-	 * @since  3.5.0
100
-	 * @access private
101
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
-	 */
103
-	private $topic_taxonomy_service;
104
-
105
-	/**
106
-	 * The User service.
107
-	 *
108
-	 * @since  3.1.7
109
-	 * @access private
110
-	 * @var \Wordlift_User_Service $user_service The User service.
111
-	 */
112
-	private $user_service;
113
-
114
-	/**
115
-	 * The Timeline service.
116
-	 *
117
-	 * @since  3.1.0
118
-	 * @access private
119
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
-	 */
121
-	private $timeline_service;
122
-
123
-	/**
124
-	 * The Redirect service.
125
-	 *
126
-	 * @since  3.2.0
127
-	 * @access private
128
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
-	 */
130
-	private $redirect_service;
131
-
132
-	/**
133
-	 * The Notice service.
134
-	 *
135
-	 * @since  3.3.0
136
-	 * @access private
137
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
-	 */
139
-	private $notice_service;
140
-
141
-	/**
142
-	 * The Entity list customization.
143
-	 *
144
-	 * @since  3.3.0
145
-	 * @access private
146
-	 * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
-	 */
148
-	private $entity_list_service;
149
-
150
-	/**
151
-	 * The Entity Types Taxonomy Walker.
152
-	 *
153
-	 * @since  3.1.0
154
-	 * @access private
155
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
-	 */
157
-	private $entity_types_taxonomy_walker;
158
-
159
-	/**
160
-	 * The ShareThis service.
161
-	 *
162
-	 * @since  3.2.0
163
-	 * @access private
164
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
-	 */
166
-	private $sharethis_service;
167
-
168
-	/**
169
-	 * The PrimaShop adapter.
170
-	 *
171
-	 * @since  3.2.3
172
-	 * @access private
173
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
-	 */
175
-	private $primashop_adapter;
176
-
177
-	/**
178
-	 * The WordLift Dashboard adapter.
179
-	 *
180
-	 * @since  3.4.0
181
-	 * @access private
182
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
-	 */
184
-	private $dashboard_service;
185
-
186
-	/**
187
-	 * The entity type service.
188
-	 *
189
-	 * @since  3.6.0
190
-	 * @access private
191
-	 * @var \Wordlift_Entity_Post_Type_Service
192
-	 */
193
-	private $entity_post_type_service;
194
-
195
-	/**
196
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
-	 *
198
-	 * @since  3.6.0
199
-	 * @access private
200
-	 * @var \Wordlift_Entity_Link_Service
201
-	 */
202
-	private $entity_link_service;
203
-
204
-	/**
205
-	 * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
-	 * correct page title to Google+.
207
-	 *
208
-	 * @since  3.5.3
209
-	 * @access private
210
-	 * @var \Wordlift_Page_Service
211
-	 */
212
-	private $page_service;
213
-
214
-	/**
215
-	 * A {@link Wordlift_Sparql_Service} instance.
216
-	 *
217
-	 * @var    3.6.0
218
-	 * @access private
219
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
220
-	 */
221
-	private $sparql_service;
222
-
223
-	/**
224
-	 * A {@link Wordlift_Import_Service} instance.
225
-	 *
226
-	 * @since  3.6.0
227
-	 * @access private
228
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
229
-	 */
230
-	private $import_service;
231
-
232
-	/**
233
-	 * A {@link Wordlift_Rebuild_Service} instance.
234
-	 *
235
-	 * @since  3.6.0
236
-	 * @access private
237
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
238
-	 */
239
-	private $rebuild_service;
240
-
241
-	/**
242
-	 * A {@link Wordlift_Jsonld_Service} instance.
243
-	 *
244
-	 * @since  3.7.0
245
-	 * @access private
246
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
-	 */
248
-	private $jsonld_service;
249
-
250
-	/**
251
-	 *
252
-	 * @since  3.7.0
253
-	 * @access private
254
-	 * @var \Wordlift_Property_Factory $property_factory
255
-	 */
256
-	private $property_factory;
257
-
258
-	/**
259
-	 * The 'Download Your Data' page.
260
-	 *
261
-	 * @since  3.6.0
262
-	 * @access private
263
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
264
-	 */
265
-	private $download_your_data_page;
266
-
267
-	/**
268
-	 * The install wizard page.
269
-	 *
270
-	 * @since  3.9.0
271
-	 * @access private
272
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
273
-	 */
274
-	private $admin_setup;
275
-
276
-	/**
277
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
278
-	 * linking of entities to their pages.
279
-	 *
280
-	 * @since  3.8.0
281
-	 * @access private
282
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
283
-	 */
284
-	private $content_filter_service;
285
-
286
-	/**
287
-	 * A {@link Wordlift_Key_Validation_Service} instance.
288
-	 *
289
-	 * @since  3.9.0
290
-	 * @access private
291
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
292
-	 */
293
-	private $key_validation_service;
294
-
295
-	/**
296
-	 * Define the core functionality of the plugin.
297
-	 *
298
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
299
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
300
-	 * the public-facing side of the site.
301
-	 *
302
-	 * @since    1.0.0
303
-	 */
304
-	public function __construct() {
305
-
306
-		$this->plugin_name = 'wordlift';
307
-		$this->version     = '3.9.0-dev';
308
-		$this->load_dependencies();
309
-		$this->set_locale();
310
-		$this->define_admin_hooks();
311
-		$this->define_public_hooks();
312
-
313
-	}
314
-
315
-	/**
316
-	 * Load the required dependencies for this plugin.
317
-	 *
318
-	 * Include the following files that make up the plugin:
319
-	 *
320
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
321
-	 * - Wordlift_i18n. Defines internationalization functionality.
322
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
323
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
324
-	 *
325
-	 * Create an instance of the loader which will be used to register the hooks
326
-	 * with WordPress.
327
-	 *
328
-	 * @since    1.0.0
329
-	 * @access   private
330
-	 */
331
-	private function load_dependencies() {
332
-
333
-		/**
334
-		 * The class responsible for orchestrating the actions and filters of the
335
-		 * core plugin.
336
-		 */
337
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
338
-
339
-		/**
340
-		 * The class responsible for defining internationalization functionality
341
-		 * of the plugin.
342
-		 */
343
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
344
-
345
-		/**
346
-		 * WordLift's supported languages.
347
-		 */
348
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
349
-
350
-		/**
351
-		 * Provide support functions to sanitize data.
352
-		 */
353
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
354
-
355
-		/**
356
-		 * The Redirect service.
357
-		 */
358
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
359
-
360
-		/**
361
-		 * The Log service.
362
-		 */
363
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
364
-
365
-		/**
366
-		 * The configuration service.
367
-		 */
368
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
369
-
370
-		/**
371
-		 * The entity post type service (this is the WordPress post type, not the entity schema type).
372
-		 */
373
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
374
-
375
-		/**
376
-		 * The entity type service (i.e. the schema type).
377
-		 */
378
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
379
-
380
-		/**
381
-		 * The entity link service.
382
-		 */
383
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
384
-
385
-		/**
386
-		 * The Query builder.
387
-		 */
388
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
389
-
390
-		/**
391
-		 * The Schema service.
392
-		 */
393
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
394
-
395
-		/**
396
-		 * The schema:url property service.
397
-		 */
398
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
399
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
400
-
401
-		/**
402
-		 * The UI service.
403
-		 */
404
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
405
-
406
-		/**
407
-		 * The Thumbnail service.
408
-		 */
409
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
410
-
411
-		/**
412
-		 * The Entity Types Taxonomy service.
413
-		 */
414
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
415
-
416
-		/**
417
-		 * The Entity service.
418
-		 */
419
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
420
-
421
-		/**
422
-		 * The User service.
423
-		 */
424
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
425
-
426
-		/**
427
-		 * The Timeline service.
428
-		 */
429
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
430
-
431
-		/**
432
-		 * The Topic Taxonomy service.
433
-		 */
434
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
435
-
436
-
437
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
438
-
439
-		/**
440
-		 * The SPARQL service.
441
-		 */
442
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
443
-
444
-		/**
445
-		 * The WordLift import service.
446
-		 */
447
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
448
-
449
-		/**
450
-		 * The WordLift URI service.
451
-		 */
452
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
453
-
454
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
455
-
456
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
457
-
458
-		/**
459
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
460
-		 */
461
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
462
-
463
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
464
-
465
-		/**
466
-		 * Load the converters.
467
-		 */
468
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
470
-
471
-		/**
472
-		 * Load the content filter.
473
-		 */
474
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
475
-
476
-		/**
477
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
478
-		 *
479
-		 * @since 3.8.0
480
-		 */
481
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
482
-
483
-		/**
484
-		 * Load the WordLift key validation service.
485
-		 */
486
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
487
-
488
-		/**
489
-		 * The class responsible for defining all actions that occur in the admin area.
490
-		 */
491
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
492
-
493
-		/**
494
-		 * The class to customize the entity list admin page.
495
-		 */
496
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
497
-
498
-		/**
499
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
500
-		 */
501
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
502
-
503
-		/**
504
-		 * The Notice service.
505
-		 */
506
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
507
-
508
-		/**
509
-		 * The PrimaShop adapter.
510
-		 */
511
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
512
-
513
-		/**
514
-		 * The WordLift Dashboard service.
515
-		 */
516
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
517
-
518
-		/**
519
-		 * The admin 'Install wizard' page.
520
-		 */
521
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
32
+    /**
33
+     * The loader that's responsible for maintaining and registering all hooks that power
34
+     * the plugin.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   protected
38
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
+     */
40
+    protected $loader;
41
+
42
+    /**
43
+     * The unique identifier of this plugin.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   protected
47
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
48
+     */
49
+    protected $plugin_name;
50
+
51
+    /**
52
+     * The current version of the plugin.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   protected
56
+     * @var      string $version The current version of the plugin.
57
+     */
58
+    protected $version;
59
+
60
+    /**
61
+     * The Thumbnail service.
62
+     *
63
+     * @since  3.1.5
64
+     * @access private
65
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
+     */
67
+    private $thumbnail_service;
68
+
69
+    /**
70
+     * The UI service.
71
+     *
72
+     * @since  3.2.0
73
+     * @access private
74
+     * @var \Wordlift_UI_Service $ui_service The UI service.
75
+     */
76
+    private $ui_service;
77
+
78
+    /**
79
+     * The Schema service.
80
+     *
81
+     * @since  3.3.0
82
+     * @access private
83
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
+     */
85
+    private $schema_service;
86
+
87
+    /**
88
+     * The Entity service.
89
+     *
90
+     * @since  3.1.0
91
+     * @access private
92
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
+     */
94
+    private $entity_service;
95
+
96
+    /**
97
+     * The Topic Taxonomy service.
98
+     *
99
+     * @since  3.5.0
100
+     * @access private
101
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
+     */
103
+    private $topic_taxonomy_service;
104
+
105
+    /**
106
+     * The User service.
107
+     *
108
+     * @since  3.1.7
109
+     * @access private
110
+     * @var \Wordlift_User_Service $user_service The User service.
111
+     */
112
+    private $user_service;
113
+
114
+    /**
115
+     * The Timeline service.
116
+     *
117
+     * @since  3.1.0
118
+     * @access private
119
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
+     */
121
+    private $timeline_service;
122
+
123
+    /**
124
+     * The Redirect service.
125
+     *
126
+     * @since  3.2.0
127
+     * @access private
128
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
+     */
130
+    private $redirect_service;
131
+
132
+    /**
133
+     * The Notice service.
134
+     *
135
+     * @since  3.3.0
136
+     * @access private
137
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
+     */
139
+    private $notice_service;
140
+
141
+    /**
142
+     * The Entity list customization.
143
+     *
144
+     * @since  3.3.0
145
+     * @access private
146
+     * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
+     */
148
+    private $entity_list_service;
149
+
150
+    /**
151
+     * The Entity Types Taxonomy Walker.
152
+     *
153
+     * @since  3.1.0
154
+     * @access private
155
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
+     */
157
+    private $entity_types_taxonomy_walker;
158
+
159
+    /**
160
+     * The ShareThis service.
161
+     *
162
+     * @since  3.2.0
163
+     * @access private
164
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
+     */
166
+    private $sharethis_service;
167
+
168
+    /**
169
+     * The PrimaShop adapter.
170
+     *
171
+     * @since  3.2.3
172
+     * @access private
173
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
+     */
175
+    private $primashop_adapter;
176
+
177
+    /**
178
+     * The WordLift Dashboard adapter.
179
+     *
180
+     * @since  3.4.0
181
+     * @access private
182
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
+     */
184
+    private $dashboard_service;
185
+
186
+    /**
187
+     * The entity type service.
188
+     *
189
+     * @since  3.6.0
190
+     * @access private
191
+     * @var \Wordlift_Entity_Post_Type_Service
192
+     */
193
+    private $entity_post_type_service;
194
+
195
+    /**
196
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
+     *
198
+     * @since  3.6.0
199
+     * @access private
200
+     * @var \Wordlift_Entity_Link_Service
201
+     */
202
+    private $entity_link_service;
203
+
204
+    /**
205
+     * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
+     * correct page title to Google+.
207
+     *
208
+     * @since  3.5.3
209
+     * @access private
210
+     * @var \Wordlift_Page_Service
211
+     */
212
+    private $page_service;
213
+
214
+    /**
215
+     * A {@link Wordlift_Sparql_Service} instance.
216
+     *
217
+     * @var    3.6.0
218
+     * @access private
219
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
220
+     */
221
+    private $sparql_service;
222
+
223
+    /**
224
+     * A {@link Wordlift_Import_Service} instance.
225
+     *
226
+     * @since  3.6.0
227
+     * @access private
228
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
229
+     */
230
+    private $import_service;
231
+
232
+    /**
233
+     * A {@link Wordlift_Rebuild_Service} instance.
234
+     *
235
+     * @since  3.6.0
236
+     * @access private
237
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
238
+     */
239
+    private $rebuild_service;
240
+
241
+    /**
242
+     * A {@link Wordlift_Jsonld_Service} instance.
243
+     *
244
+     * @since  3.7.0
245
+     * @access private
246
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
+     */
248
+    private $jsonld_service;
249
+
250
+    /**
251
+     *
252
+     * @since  3.7.0
253
+     * @access private
254
+     * @var \Wordlift_Property_Factory $property_factory
255
+     */
256
+    private $property_factory;
257
+
258
+    /**
259
+     * The 'Download Your Data' page.
260
+     *
261
+     * @since  3.6.0
262
+     * @access private
263
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
264
+     */
265
+    private $download_your_data_page;
266
+
267
+    /**
268
+     * The install wizard page.
269
+     *
270
+     * @since  3.9.0
271
+     * @access private
272
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
273
+     */
274
+    private $admin_setup;
275
+
276
+    /**
277
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
278
+     * linking of entities to their pages.
279
+     *
280
+     * @since  3.8.0
281
+     * @access private
282
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
283
+     */
284
+    private $content_filter_service;
285
+
286
+    /**
287
+     * A {@link Wordlift_Key_Validation_Service} instance.
288
+     *
289
+     * @since  3.9.0
290
+     * @access private
291
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
292
+     */
293
+    private $key_validation_service;
294
+
295
+    /**
296
+     * Define the core functionality of the plugin.
297
+     *
298
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
299
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
300
+     * the public-facing side of the site.
301
+     *
302
+     * @since    1.0.0
303
+     */
304
+    public function __construct() {
305
+
306
+        $this->plugin_name = 'wordlift';
307
+        $this->version     = '3.9.0-dev';
308
+        $this->load_dependencies();
309
+        $this->set_locale();
310
+        $this->define_admin_hooks();
311
+        $this->define_public_hooks();
312
+
313
+    }
314
+
315
+    /**
316
+     * Load the required dependencies for this plugin.
317
+     *
318
+     * Include the following files that make up the plugin:
319
+     *
320
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
321
+     * - Wordlift_i18n. Defines internationalization functionality.
322
+     * - Wordlift_Admin. Defines all hooks for the admin area.
323
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
324
+     *
325
+     * Create an instance of the loader which will be used to register the hooks
326
+     * with WordPress.
327
+     *
328
+     * @since    1.0.0
329
+     * @access   private
330
+     */
331
+    private function load_dependencies() {
332
+
333
+        /**
334
+         * The class responsible for orchestrating the actions and filters of the
335
+         * core plugin.
336
+         */
337
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
338
+
339
+        /**
340
+         * The class responsible for defining internationalization functionality
341
+         * of the plugin.
342
+         */
343
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
344
+
345
+        /**
346
+         * WordLift's supported languages.
347
+         */
348
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
349
+
350
+        /**
351
+         * Provide support functions to sanitize data.
352
+         */
353
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
354
+
355
+        /**
356
+         * The Redirect service.
357
+         */
358
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
359
+
360
+        /**
361
+         * The Log service.
362
+         */
363
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
364
+
365
+        /**
366
+         * The configuration service.
367
+         */
368
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
369
+
370
+        /**
371
+         * The entity post type service (this is the WordPress post type, not the entity schema type).
372
+         */
373
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
374
+
375
+        /**
376
+         * The entity type service (i.e. the schema type).
377
+         */
378
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
379
+
380
+        /**
381
+         * The entity link service.
382
+         */
383
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
384
+
385
+        /**
386
+         * The Query builder.
387
+         */
388
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
389
+
390
+        /**
391
+         * The Schema service.
392
+         */
393
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
394
+
395
+        /**
396
+         * The schema:url property service.
397
+         */
398
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
399
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
400
+
401
+        /**
402
+         * The UI service.
403
+         */
404
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
405
+
406
+        /**
407
+         * The Thumbnail service.
408
+         */
409
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
410
+
411
+        /**
412
+         * The Entity Types Taxonomy service.
413
+         */
414
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
415
+
416
+        /**
417
+         * The Entity service.
418
+         */
419
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
420
+
421
+        /**
422
+         * The User service.
423
+         */
424
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
425
+
426
+        /**
427
+         * The Timeline service.
428
+         */
429
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
430
+
431
+        /**
432
+         * The Topic Taxonomy service.
433
+         */
434
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
435
+
436
+
437
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
438
+
439
+        /**
440
+         * The SPARQL service.
441
+         */
442
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
443
+
444
+        /**
445
+         * The WordLift import service.
446
+         */
447
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
448
+
449
+        /**
450
+         * The WordLift URI service.
451
+         */
452
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
453
+
454
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
455
+
456
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
457
+
458
+        /**
459
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
460
+         */
461
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
462
+
463
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
464
+
465
+        /**
466
+         * Load the converters.
467
+         */
468
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
470
+
471
+        /**
472
+         * Load the content filter.
473
+         */
474
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
475
+
476
+        /**
477
+         * Load the JSON-LD service to publish entities using JSON-LD.s
478
+         *
479
+         * @since 3.8.0
480
+         */
481
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
482
+
483
+        /**
484
+         * Load the WordLift key validation service.
485
+         */
486
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
487
+
488
+        /**
489
+         * The class responsible for defining all actions that occur in the admin area.
490
+         */
491
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
492
+
493
+        /**
494
+         * The class to customize the entity list admin page.
495
+         */
496
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
497
+
498
+        /**
499
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
500
+         */
501
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
502
+
503
+        /**
504
+         * The Notice service.
505
+         */
506
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
507
+
508
+        /**
509
+         * The PrimaShop adapter.
510
+         */
511
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
512
+
513
+        /**
514
+         * The WordLift Dashboard service.
515
+         */
516
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
517
+
518
+        /**
519
+         * The admin 'Install wizard' page.
520
+         */
521
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
522 522
 
523
-		/**
524
-		 * The admin 'Download Your Data' page.
525
-		 */
526
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
523
+        /**
524
+         * The admin 'Download Your Data' page.
525
+         */
526
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
527 527
 
528
-		/**
529
-		 * The class responsible for defining all actions that occur in the public-facing
530
-		 * side of the site.
531
-		 */
532
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
528
+        /**
529
+         * The class responsible for defining all actions that occur in the public-facing
530
+         * side of the site.
531
+         */
532
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
533 533
 
534
-		/**
535
-		 * The shortcode abstract class.
536
-		 */
537
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
534
+        /**
535
+         * The shortcode abstract class.
536
+         */
537
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
538 538
 
539
-		/**
540
-		 * The Timeline shortcode.
541
-		 */
542
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
539
+        /**
540
+         * The Timeline shortcode.
541
+         */
542
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
543 543
 
544
-		/**
545
-		 * The Navigator shortcode.
546
-		 */
547
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
544
+        /**
545
+         * The Navigator shortcode.
546
+         */
547
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
548 548
 
549
-		/**
550
-		 * The chord shortcode.
551
-		 */
552
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
549
+        /**
550
+         * The chord shortcode.
551
+         */
552
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
553 553
 
554
-		/**
555
-		 * The geomap shortcode.
556
-		 */
557
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
554
+        /**
555
+         * The geomap shortcode.
556
+         */
557
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
558 558
 
559
-		/**
560
-		 * The ShareThis service.
561
-		 */
562
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
559
+        /**
560
+         * The ShareThis service.
561
+         */
562
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
563 563
 
564
-		$this->loader = new Wordlift_Loader();
564
+        $this->loader = new Wordlift_Loader();
565 565
 
566
-		// Instantiate a global logger.
567
-		global $wl_logger;
568
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
566
+        // Instantiate a global logger.
567
+        global $wl_logger;
568
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
569 569
 
570
-		// Create the configuration service.
571
-		$configuration_service = new Wordlift_Configuration_Service();
570
+        // Create the configuration service.
571
+        $configuration_service = new Wordlift_Configuration_Service();
572 572
 
573
-		// Create an entity type service instance. It'll be later bound to the init action.
574
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() );
573
+        // Create an entity type service instance. It'll be later bound to the init action.
574
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() );
575 575
 
576
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
577
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() );
576
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
577
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() );
578 578
 
579
-		// Create an instance of the UI service.
580
-		$this->ui_service = new Wordlift_UI_Service();
579
+        // Create an instance of the UI service.
580
+        $this->ui_service = new Wordlift_UI_Service();
581 581
 
582
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
583
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
582
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
583
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
584 584
 
585
-		$this->sparql_service = new Wordlift_Sparql_Service();
585
+        $this->sparql_service = new Wordlift_Sparql_Service();
586 586
 
587
-		// Create an instance of the Schema service.
588
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
589
-		$this->schema_service        = new Wordlift_Schema_Service();
587
+        // Create an instance of the Schema service.
588
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
589
+        $this->schema_service        = new Wordlift_Schema_Service();
590 590
 
591
-		// Create an instance of the Notice service.
592
-		$this->notice_service = new Wordlift_Notice_Service();
591
+        // Create an instance of the Notice service.
592
+        $this->notice_service = new Wordlift_Notice_Service();
593 593
 
594
-		// Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
595
-		$this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
594
+        // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
595
+        $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
596 596
 
597
-		// Create an instance of the User service.
598
-		$this->user_service = new Wordlift_User_Service();
597
+        // Create an instance of the User service.
598
+        $this->user_service = new Wordlift_User_Service();
599 599
 
600
-		// Create a new instance of the Timeline service and Timeline shortcode.
601
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
600
+        // Create a new instance of the Timeline service and Timeline shortcode.
601
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
602 602
 
603
-		// Create a new instance of the Redirect service.
604
-		$this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
603
+        // Create a new instance of the Redirect service.
604
+        $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
605 605
 
606
-		// Create a new instance of the Redirect service.
607
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
606
+        // Create a new instance of the Redirect service.
607
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
608 608
 
609
-		// Initialize the shortcodes.
610
-		new Wordlift_Navigator_Shortcode();
611
-		new Wordlift_Chord_Shortcode();
612
-		new Wordlift_Geomap_Shortcode();
613
-		new Wordlift_Timeline_Shortcode();
609
+        // Initialize the shortcodes.
610
+        new Wordlift_Navigator_Shortcode();
611
+        new Wordlift_Chord_Shortcode();
612
+        new Wordlift_Geomap_Shortcode();
613
+        new Wordlift_Timeline_Shortcode();
614 614
 
615
-		// Create entity list customization (wp-admin/edit.php)
616
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
615
+        // Create entity list customization (wp-admin/edit.php)
616
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
617 617
 
618
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
618
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
619 619
 
620
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
620
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
621 621
 
622
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
623
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
622
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
623
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
624 624
 
625
-		// Create an instance of the PrimaShop adapter.
626
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
625
+        // Create an instance of the PrimaShop adapter.
626
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
627 627
 
628
-		$this->page_service = new Wordlift_Page_Service();
628
+        $this->page_service = new Wordlift_Page_Service();
629 629
 
630
-		// Create an import service instance to hook later to WP's import function.
631
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() );
630
+        // Create an import service instance to hook later to WP's import function.
631
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() );
632 632
 
633
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
633
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
634 634
 
635
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
636
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
635
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
636
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
637 637
 
638
-		$entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
638
+        $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
639 639
 
640
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
641
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
640
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
641
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
642 642
 
643
-		// Instantiate the JSON-LD service.
644
-		$property_getter                = Wordlift_Property_Getter_Factory::create( $this->entity_service );
645
-		$entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter );
646
-		$this->jsonld_service           = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter );
643
+        // Instantiate the JSON-LD service.
644
+        $property_getter                = Wordlift_Property_Getter_Factory::create( $this->entity_service );
645
+        $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter );
646
+        $this->jsonld_service           = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter );
647 647
 
648
-		// Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins).
649
-		$this->key_validation_service = new Wordlift_Key_Validation_Service();
648
+        // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins).
649
+        $this->key_validation_service = new Wordlift_Key_Validation_Service();
650 650
 
651
-		//** WordPress Admin */
652
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
651
+        //** WordPress Admin */
652
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
653 653
 
654
-		// Create an instance of the install wizard.
655
-		$this->admin_setup = new Wordlift_Admin_Setup( $configuration_service, $this->key_validation_service, $this->entity_service );
654
+        // Create an instance of the install wizard.
655
+        $this->admin_setup = new Wordlift_Admin_Setup( $configuration_service, $this->key_validation_service, $this->entity_service );
656 656
 
657
-		// Create an instance of the content filter service.
658
-		$this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service );
657
+        // Create an instance of the content filter service.
658
+        $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service );
659 659
 
660
-		// Load the debug service if WP is in debug mode.
661
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
662
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
663
-			new Wordlift_Debug_Service( $this->entity_service );
664
-		}
660
+        // Load the debug service if WP is in debug mode.
661
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
662
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
663
+            new Wordlift_Debug_Service( $this->entity_service );
664
+        }
665 665
 
666
-	}
666
+    }
667 667
 
668
-	/**
669
-	 * Define the locale for this plugin for internationalization.
670
-	 *
671
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
672
-	 * with WordPress.
673
-	 *
674
-	 * @since    1.0.0
675
-	 * @access   private
676
-	 */
677
-	private function set_locale() {
668
+    /**
669
+     * Define the locale for this plugin for internationalization.
670
+     *
671
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
672
+     * with WordPress.
673
+     *
674
+     * @since    1.0.0
675
+     * @access   private
676
+     */
677
+    private function set_locale() {
678 678
 
679
-		$plugin_i18n = new Wordlift_i18n();
680
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
679
+        $plugin_i18n = new Wordlift_i18n();
680
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
681 681
 
682
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
682
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
683 683
 
684
-	}
684
+    }
685 685
 
686
-	/**
687
-	 * Register all of the hooks related to the admin area functionality
688
-	 * of the plugin.
689
-	 *
690
-	 * @since    1.0.0
691
-	 * @access   private
692
-	 */
693
-	private function define_admin_hooks() {
686
+    /**
687
+     * Register all of the hooks related to the admin area functionality
688
+     * of the plugin.
689
+     *
690
+     * @since    1.0.0
691
+     * @access   private
692
+     */
693
+    private function define_admin_hooks() {
694 694
 
695
-		$plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
695
+        $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
696 696
 
697
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
698
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
697
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
698
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
699 699
 
700
-		// Hook the init action to the Topic Taxonomy service.
701
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
700
+        // Hook the init action to the Topic Taxonomy service.
701
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
702 702
 
703
-		// Hook the deleted_post_meta action to the Thumbnail service.
704
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
703
+        // Hook the deleted_post_meta action to the Thumbnail service.
704
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
705 705
 
706
-		// Hook the added_post_meta action to the Thumbnail service.
707
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
706
+        // Hook the added_post_meta action to the Thumbnail service.
707
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
708 708
 
709
-		// Hook the updated_post_meta action to the Thumbnail service.
710
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
709
+        // Hook the updated_post_meta action to the Thumbnail service.
710
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
711 711
 
712
-		// Hook posts inserts (or updates) to the user service.
713
-		$this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
712
+        // Hook posts inserts (or updates) to the user service.
713
+        $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
714 714
 
715
-		// Hook the AJAX wl_timeline action to the Timeline service.
716
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
715
+        // Hook the AJAX wl_timeline action to the Timeline service.
716
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
717 717
 
718
-		// Register custom allowed redirect hosts.
719
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
720
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
721
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
722
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
723
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
724
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
725
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
718
+        // Register custom allowed redirect hosts.
719
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
720
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
721
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
722
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
723
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
724
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
725
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
726 726
 
727
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
728
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
729
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
730
-		$this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
727
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
728
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
729
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
730
+        $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
731 731
 
732
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
733
-		$this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
732
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
733
+        $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
734 734
 
735
-		// Entity listing customization (wp-admin/edit.php)
736
-		// Add custom columns
737
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
738
-		$this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
739
-		// Add 4W selection
740
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
741
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
742
-
743
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
744
-
745
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
746
-		// entities.
747
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
748
-
749
-		// Filter imported post meta.
750
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
751
-
752
-		// Notify the import service when an import starts and ends.
753
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
754
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
755
-
756
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
757
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
758
-
759
-		// Hook the menu to the Download Your Data page.
760
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
761
-
762
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
763
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
764
-
765
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
766
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
767
-
768
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
769
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
770
-
771
-		// Hook the `admin_init` function to the Admin Setup.
772
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
773
-
774
-	}
775
-
776
-	/**
777
-	 * Register all of the hooks related to the public-facing functionality
778
-	 * of the plugin.
779
-	 *
780
-	 * @since    1.0.0
781
-	 * @access   private
782
-	 */
783
-	private function define_public_hooks() {
784
-
785
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
786
-
787
-		// Register the entity post type.
788
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
789
-
790
-		// Bind the link generation and handling hooks to the entity link service.
791
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
792
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
793
-		$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 );
794
-		$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 );
795
-
796
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
797
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
798
-
799
-		// Hook the content filter service to add entity links.
800
-		$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
801
-
802
-		// Hook the AJAX wl_timeline action to the Timeline service.
803
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
804
-
805
-		// Hook the ShareThis service.
806
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
807
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
808
-
809
-		$this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
810
-		$this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX );
811
-
812
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
813
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
814
-
815
-	}
816
-
817
-	/**
818
-	 * Run the loader to execute all of the hooks with WordPress.
819
-	 *
820
-	 * @since    1.0.0
821
-	 */
822
-	public function run() {
823
-		$this->loader->run();
824
-	}
825
-
826
-	/**
827
-	 * The name of the plugin used to uniquely identify it within the context of
828
-	 * WordPress and to define internationalization functionality.
829
-	 *
830
-	 * @since     1.0.0
831
-	 * @return    string    The name of the plugin.
832
-	 */
833
-	public function get_plugin_name() {
834
-		return $this->plugin_name;
835
-	}
836
-
837
-	/**
838
-	 * The reference to the class that orchestrates the hooks with the plugin.
839
-	 *
840
-	 * @since     1.0.0
841
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
842
-	 */
843
-	public function get_loader() {
844
-		return $this->loader;
845
-	}
846
-
847
-	/**
848
-	 * Retrieve the version number of the plugin.
849
-	 *
850
-	 * @since     1.0.0
851
-	 * @return    string    The version number of the plugin.
852
-	 */
853
-	public function get_version() {
854
-		return $this->version;
855
-	}
735
+        // Entity listing customization (wp-admin/edit.php)
736
+        // Add custom columns
737
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
738
+        $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
739
+        // Add 4W selection
740
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
741
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
742
+
743
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
744
+
745
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
746
+        // entities.
747
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
748
+
749
+        // Filter imported post meta.
750
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
751
+
752
+        // Notify the import service when an import starts and ends.
753
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
754
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
755
+
756
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
757
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
758
+
759
+        // Hook the menu to the Download Your Data page.
760
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
761
+
762
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
763
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
764
+
765
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
766
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
767
+
768
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
769
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
770
+
771
+        // Hook the `admin_init` function to the Admin Setup.
772
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
773
+
774
+    }
775
+
776
+    /**
777
+     * Register all of the hooks related to the public-facing functionality
778
+     * of the plugin.
779
+     *
780
+     * @since    1.0.0
781
+     * @access   private
782
+     */
783
+    private function define_public_hooks() {
784
+
785
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
786
+
787
+        // Register the entity post type.
788
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
789
+
790
+        // Bind the link generation and handling hooks to the entity link service.
791
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
792
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
793
+        $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 );
794
+        $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 );
795
+
796
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
797
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
798
+
799
+        // Hook the content filter service to add entity links.
800
+        $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
801
+
802
+        // Hook the AJAX wl_timeline action to the Timeline service.
803
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
804
+
805
+        // Hook the ShareThis service.
806
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
807
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
808
+
809
+        $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
810
+        $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX );
811
+
812
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
813
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
814
+
815
+    }
816
+
817
+    /**
818
+     * Run the loader to execute all of the hooks with WordPress.
819
+     *
820
+     * @since    1.0.0
821
+     */
822
+    public function run() {
823
+        $this->loader->run();
824
+    }
825
+
826
+    /**
827
+     * The name of the plugin used to uniquely identify it within the context of
828
+     * WordPress and to define internationalization functionality.
829
+     *
830
+     * @since     1.0.0
831
+     * @return    string    The name of the plugin.
832
+     */
833
+    public function get_plugin_name() {
834
+        return $this->plugin_name;
835
+    }
836
+
837
+    /**
838
+     * The reference to the class that orchestrates the hooks with the plugin.
839
+     *
840
+     * @since     1.0.0
841
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
842
+     */
843
+    public function get_loader() {
844
+        return $this->loader;
845
+    }
846
+
847
+    /**
848
+     * Retrieve the version number of the plugin.
849
+     *
850
+     * @since     1.0.0
851
+     * @return    string    The version number of the plugin.
852
+     */
853
+    public function get_version() {
854
+        return $this->version;
855
+    }
856 856
 
857 857
 }
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -334,247 +334,247 @@  discard block
 block discarded – undo
334 334
 		 * The class responsible for orchestrating the actions and filters of the
335 335
 		 * core plugin.
336 336
 		 */
337
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
337
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php';
338 338
 
339 339
 		/**
340 340
 		 * The class responsible for defining internationalization functionality
341 341
 		 * of the plugin.
342 342
 		 */
343
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
343
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php';
344 344
 
345 345
 		/**
346 346
 		 * WordLift's supported languages.
347 347
 		 */
348
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
348
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php';
349 349
 
350 350
 		/**
351 351
 		 * Provide support functions to sanitize data.
352 352
 		 */
353
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
353
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php';
354 354
 
355 355
 		/**
356 356
 		 * The Redirect service.
357 357
 		 */
358
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
358
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php';
359 359
 
360 360
 		/**
361 361
 		 * The Log service.
362 362
 		 */
363
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
363
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php';
364 364
 
365 365
 		/**
366 366
 		 * The configuration service.
367 367
 		 */
368
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
368
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php';
369 369
 
370 370
 		/**
371 371
 		 * The entity post type service (this is the WordPress post type, not the entity schema type).
372 372
 		 */
373
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
373
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php';
374 374
 
375 375
 		/**
376 376
 		 * The entity type service (i.e. the schema type).
377 377
 		 */
378
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
378
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php';
379 379
 
380 380
 		/**
381 381
 		 * The entity link service.
382 382
 		 */
383
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
383
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php';
384 384
 
385 385
 		/**
386 386
 		 * The Query builder.
387 387
 		 */
388
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
388
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php';
389 389
 
390 390
 		/**
391 391
 		 * The Schema service.
392 392
 		 */
393
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
393
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php';
394 394
 
395 395
 		/**
396 396
 		 * The schema:url property service.
397 397
 		 */
398
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
399
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
398
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php';
399
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php';
400 400
 
401 401
 		/**
402 402
 		 * The UI service.
403 403
 		 */
404
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
404
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php';
405 405
 
406 406
 		/**
407 407
 		 * The Thumbnail service.
408 408
 		 */
409
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
409
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php';
410 410
 
411 411
 		/**
412 412
 		 * The Entity Types Taxonomy service.
413 413
 		 */
414
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
414
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php';
415 415
 
416 416
 		/**
417 417
 		 * The Entity service.
418 418
 		 */
419
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
419
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php';
420 420
 
421 421
 		/**
422 422
 		 * The User service.
423 423
 		 */
424
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
424
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php';
425 425
 
426 426
 		/**
427 427
 		 * The Timeline service.
428 428
 		 */
429
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
429
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php';
430 430
 
431 431
 		/**
432 432
 		 * The Topic Taxonomy service.
433 433
 		 */
434
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
434
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php';
435 435
 
436 436
 
437
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
437
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-page-service.php';
438 438
 
439 439
 		/**
440 440
 		 * The SPARQL service.
441 441
 		 */
442
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
442
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php';
443 443
 
444 444
 		/**
445 445
 		 * The WordLift import service.
446 446
 		 */
447
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
447
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php';
448 448
 
449 449
 		/**
450 450
 		 * The WordLift URI service.
451 451
 		 */
452
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
452
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php';
453 453
 
454
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
454
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php';
455 455
 
456
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
456
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php';
457 457
 
458 458
 		/**
459 459
 		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
460 460
 		 */
461
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
461
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php';
462 462
 
463
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
463
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php';
464 464
 
465 465
 		/**
466 466
 		 * Load the converters.
467 467
 		 */
468
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
468
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
470 470
 
471 471
 		/**
472 472
 		 * Load the content filter.
473 473
 		 */
474
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
474
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php';
475 475
 
476 476
 		/**
477 477
 		 * Load the JSON-LD service to publish entities using JSON-LD.s
478 478
 		 *
479 479
 		 * @since 3.8.0
480 480
 		 */
481
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
481
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php';
482 482
 
483 483
 		/**
484 484
 		 * Load the WordLift key validation service.
485 485
 		 */
486
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
486
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php';
487 487
 
488 488
 		/**
489 489
 		 * The class responsible for defining all actions that occur in the admin area.
490 490
 		 */
491
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
491
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php';
492 492
 
493 493
 		/**
494 494
 		 * The class to customize the entity list admin page.
495 495
 		 */
496
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
496
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php';
497 497
 
498 498
 		/**
499 499
 		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
500 500
 		 */
501
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
501
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php';
502 502
 
503 503
 		/**
504 504
 		 * The Notice service.
505 505
 		 */
506
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
506
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php';
507 507
 
508 508
 		/**
509 509
 		 * The PrimaShop adapter.
510 510
 		 */
511
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
511
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php';
512 512
 
513 513
 		/**
514 514
 		 * The WordLift Dashboard service.
515 515
 		 */
516
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
516
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php';
517 517
 
518 518
 		/**
519 519
 		 * The admin 'Install wizard' page.
520 520
 		 */
521
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
521
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php';
522 522
 
523 523
 		/**
524 524
 		 * The admin 'Download Your Data' page.
525 525
 		 */
526
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
526
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php';
527 527
 
528 528
 		/**
529 529
 		 * The class responsible for defining all actions that occur in the public-facing
530 530
 		 * side of the site.
531 531
 		 */
532
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
532
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php';
533 533
 
534 534
 		/**
535 535
 		 * The shortcode abstract class.
536 536
 		 */
537
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
537
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php';
538 538
 
539 539
 		/**
540 540
 		 * The Timeline shortcode.
541 541
 		 */
542
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
542
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php';
543 543
 
544 544
 		/**
545 545
 		 * The Navigator shortcode.
546 546
 		 */
547
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
547
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php';
548 548
 
549 549
 		/**
550 550
 		 * The chord shortcode.
551 551
 		 */
552
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
552
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php';
553 553
 
554 554
 		/**
555 555
 		 * The geomap shortcode.
556 556
 		 */
557
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
557
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php';
558 558
 
559 559
 		/**
560 560
 		 * The ShareThis service.
561 561
 		 */
562
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
562
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php';
563 563
 
564 564
 		$this->loader = new Wordlift_Loader();
565 565
 
566 566
 		// Instantiate a global logger.
567 567
 		global $wl_logger;
568
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
568
+		$wl_logger = Wordlift_Log_Service::get_logger('WordLift');
569 569
 
570 570
 		// Create the configuration service.
571 571
 		$configuration_service = new Wordlift_Configuration_Service();
572 572
 
573 573
 		// Create an entity type service instance. It'll be later bound to the init action.
574
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() );
574
+		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path());
575 575
 
576 576
 		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
577
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() );
577
+		$this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $configuration_service->get_entity_base_path());
578 578
 
579 579
 		// Create an instance of the UI service.
580 580
 		$this->ui_service = new Wordlift_UI_Service();
@@ -585,26 +585,26 @@  discard block
 block discarded – undo
585 585
 		$this->sparql_service = new Wordlift_Sparql_Service();
586 586
 
587 587
 		// Create an instance of the Schema service.
588
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
588
+		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service);
589 589
 		$this->schema_service        = new Wordlift_Schema_Service();
590 590
 
591 591
 		// Create an instance of the Notice service.
592 592
 		$this->notice_service = new Wordlift_Notice_Service();
593 593
 
594 594
 		// Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
595
-		$this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
595
+		$this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->schema_service, $this->notice_service);
596 596
 
597 597
 		// Create an instance of the User service.
598 598
 		$this->user_service = new Wordlift_User_Service();
599 599
 
600 600
 		// Create a new instance of the Timeline service and Timeline shortcode.
601
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
601
+		$this->timeline_service = new Wordlift_Timeline_Service($this->entity_service);
602 602
 
603 603
 		// Create a new instance of the Redirect service.
604
-		$this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
604
+		$this->redirect_service = new Wordlift_Redirect_Service($this->entity_service);
605 605
 
606 606
 		// Create a new instance of the Redirect service.
607
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
607
+		$this->dashboard_service = new Wordlift_Dashboard_Service($this->entity_service);
608 608
 
609 609
 		// Initialize the shortcodes.
610 610
 		new Wordlift_Navigator_Shortcode();
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		new Wordlift_Timeline_Shortcode();
614 614
 
615 615
 		// Create entity list customization (wp-admin/edit.php)
616
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
616
+		$this->entity_list_service = new Wordlift_Entity_List_Service($this->entity_service);
617 617
 
618 618
 		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
619 619
 
@@ -628,22 +628,22 @@  discard block
 block discarded – undo
628 628
 		$this->page_service = new Wordlift_Page_Service();
629 629
 
630 630
 		// Create an import service instance to hook later to WP's import function.
631
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() );
631
+		$this->import_service = new Wordlift_Import_Service($this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri());
632 632
 
633
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
633
+		$uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']);
634 634
 
635 635
 		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
636
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
636
+		$this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service);
637 637
 
638
-		$entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
638
+		$entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service);
639 639
 
640
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
641
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
640
+		$this->property_factory = new Wordlift_Property_Factory($schema_url_property_service);
641
+		$this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service);
642 642
 
643 643
 		// Instantiate the JSON-LD service.
644
-		$property_getter                = Wordlift_Property_Getter_Factory::create( $this->entity_service );
645
-		$entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter );
646
-		$this->jsonld_service           = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter );
644
+		$property_getter                = Wordlift_Property_Getter_Factory::create($this->entity_service);
645
+		$entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter($entity_type_service, $this->entity_service, $property_getter);
646
+		$this->jsonld_service           = new Wordlift_Jsonld_Service($this->entity_service, $entity_uri_to_jsonld_converter);
647 647
 
648 648
 		// Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins).
649 649
 		$this->key_validation_service = new Wordlift_Key_Validation_Service();
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
653 653
 
654 654
 		// Create an instance of the install wizard.
655
-		$this->admin_setup = new Wordlift_Admin_Setup( $configuration_service, $this->key_validation_service, $this->entity_service );
655
+		$this->admin_setup = new Wordlift_Admin_Setup($configuration_service, $this->key_validation_service, $this->entity_service);
656 656
 
657 657
 		// Create an instance of the content filter service.
658
-		$this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service );
658
+		$this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service);
659 659
 
660 660
 		// Load the debug service if WP is in debug mode.
661
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
662
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
663
-			new Wordlift_Debug_Service( $this->entity_service );
661
+		if (defined('WP_DEBUG') && WP_DEBUG) {
662
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php';
663
+			new Wordlift_Debug_Service($this->entity_service);
664 664
 		}
665 665
 
666 666
 	}
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 	private function set_locale() {
678 678
 
679 679
 		$plugin_i18n = new Wordlift_i18n();
680
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
680
+		$plugin_i18n->set_domain($this->get_plugin_name());
681 681
 
682
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
682
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
683 683
 
684 684
 	}
685 685
 
@@ -692,84 +692,84 @@  discard block
 block discarded – undo
692 692
 	 */
693 693
 	private function define_admin_hooks() {
694 694
 
695
-		$plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
695
+		$plugin_admin = new Wordlift_Admin($this->get_plugin_name(), $this->get_version());
696 696
 
697
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
698
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
697
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
698
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
699 699
 
700 700
 		// Hook the init action to the Topic Taxonomy service.
701
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
701
+		$this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0);
702 702
 
703 703
 		// Hook the deleted_post_meta action to the Thumbnail service.
704
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
704
+		$this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4);
705 705
 
706 706
 		// Hook the added_post_meta action to the Thumbnail service.
707
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
707
+		$this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
708 708
 
709 709
 		// Hook the updated_post_meta action to the Thumbnail service.
710
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
710
+		$this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
711 711
 
712 712
 		// Hook posts inserts (or updates) to the user service.
713
-		$this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
713
+		$this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3);
714 714
 
715 715
 		// Hook the AJAX wl_timeline action to the Timeline service.
716
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
716
+		$this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline');
717 717
 
718 718
 		// Register custom allowed redirect hosts.
719
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
719
+		$this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts');
720 720
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
721
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
721
+		$this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect');
722 722
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
723
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
723
+		$this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats');
724 724
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
725
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
725
+		$this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets');
726 726
 
727 727
 		// Hook save_post to the entity service to update custom fields (such as alternate labels).
728 728
 		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
729
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
730
-		$this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
729
+		$this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3);
730
+		$this->loader->add_action('save_post_entity', $this->entity_service, 'set_rating_for', 10, 1);
731 731
 
732
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
733
-		$this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
732
+		$this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1);
733
+		$this->loader->add_action('in_admin_header', $this->entity_service, 'in_admin_header');
734 734
 
735 735
 		// Entity listing customization (wp-admin/edit.php)
736 736
 		// Add custom columns
737
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
738
-		$this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
737
+		$this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns');
738
+		$this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2);
739 739
 		// Add 4W selection
740
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
741
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
740
+		$this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope');
741
+		$this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope');
742 742
 
743
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
743
+		$this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args');
744 744
 
745 745
 		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
746 746
 		// entities.
747
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
747
+		$this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2);
748 748
 
749 749
 		// Filter imported post meta.
750
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
750
+		$this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3);
751 751
 
752 752
 		// Notify the import service when an import starts and ends.
753
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
754
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
753
+		$this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0);
754
+		$this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0);
755 755
 
756 756
 		// Hook the AJAX wl_rebuild action to the Rebuild Service.
757
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
757
+		$this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild');
758 758
 
759 759
 		// Hook the menu to the Download Your Data page.
760
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
760
+		$this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0);
761 761
 
762 762
 		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
763
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
763
+		$this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10);
764 764
 
765 765
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
766
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
766
+		$this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get');
767 767
 
768 768
 		// Hook the AJAX wl_validate_key action to the Key Validation service.
769
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
769
+		$this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key');
770 770
 
771 771
 		// Hook the `admin_init` function to the Admin Setup.
772
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
772
+		$this->loader->add_action('admin_init', $this->admin_setup, 'admin_init');
773 773
 
774 774
 	}
775 775
 
@@ -782,35 +782,35 @@  discard block
 block discarded – undo
782 782
 	 */
783 783
 	private function define_public_hooks() {
784 784
 
785
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
785
+		$plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version());
786 786
 
787 787
 		// Register the entity post type.
788
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
788
+		$this->loader->add_action('init', $this->entity_post_type_service, 'register');
789 789
 
790 790
 		// Bind the link generation and handling hooks to the entity link service.
791
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
792
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
793
-		$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 );
794
-		$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 );
791
+		$this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4);
792
+		$this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1);
793
+		$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);
794
+		$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);
795 795
 
796
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
797
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
796
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
797
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
798 798
 
799 799
 		// Hook the content filter service to add entity links.
800
-		$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
800
+		$this->loader->add_filter('the_content', $this->content_filter_service, 'the_content');
801 801
 
802 802
 		// Hook the AJAX wl_timeline action to the Timeline service.
803
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
803
+		$this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline');
804 804
 
805 805
 		// Hook the ShareThis service.
806
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
807
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
806
+		$this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99);
807
+		$this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99);
808 808
 
809
-		$this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
810
-		$this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX );
809
+		$this->loader->add_action('wp_head', $this->page_service, 'wp_head', PHP_INT_MAX);
810
+		$this->loader->add_action('wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX);
811 811
 
812 812
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
813
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
813
+		$this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get');
814 814
 
815 815
 	}
816 816
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-key-validation-service.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,42 +17,42 @@
 block discarded – undo
17 17
  */
18 18
 class Wordlift_Key_Validation_Service {
19 19
 
20
-	/**
21
-	 * Validate the provided key.
22
-	 *
23
-	 * @since 3.9.0
24
-	 *
25
-	 * @param string $key WordLift's key to validate.
26
-	 *
27
-	 * @return bool True if the key is valid, otherwise false.
28
-	 */
29
-	public function is_valid( $key ) {
30
-
31
-		// Request the dataset URI as a way to validate the key
32
-		$response = wp_remote_get( wl_configuration_get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
33
-
34
-		// If the response is valid, the key is valid.
35
-		return ! is_wp_error( $response ) && 200 === (int) $response['response']['code'];
36
-	}
37
-
38
-	/**
39
-	 * This function is hooked to the `wl_validate_key` AJAX call.
40
-	 *
41
-	 * @since 3.9.0
42
-	 */
43
-	public function validate_key() {
44
-
45
-		// Ensure we don't have garbage before us.
46
-		ob_clean();
47
-
48
-		// Check if we have a key.
49
-		if ( ! isset( $_POST['key'] ) ) {
50
-			wp_send_json_error( 'The key parameter is required.' );
51
-		}
52
-
53
-		// Set a response with valid set to true or false according to the key validity.
54
-		wp_send_json( array( 'valid' => $this->is_valid( $_POST['key'] ) ) );
55
-
56
-	}
20
+    /**
21
+     * Validate the provided key.
22
+     *
23
+     * @since 3.9.0
24
+     *
25
+     * @param string $key WordLift's key to validate.
26
+     *
27
+     * @return bool True if the key is valid, otherwise false.
28
+     */
29
+    public function is_valid( $key ) {
30
+
31
+        // Request the dataset URI as a way to validate the key
32
+        $response = wp_remote_get( wl_configuration_get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
33
+
34
+        // If the response is valid, the key is valid.
35
+        return ! is_wp_error( $response ) && 200 === (int) $response['response']['code'];
36
+    }
37
+
38
+    /**
39
+     * This function is hooked to the `wl_validate_key` AJAX call.
40
+     *
41
+     * @since 3.9.0
42
+     */
43
+    public function validate_key() {
44
+
45
+        // Ensure we don't have garbage before us.
46
+        ob_clean();
47
+
48
+        // Check if we have a key.
49
+        if ( ! isset( $_POST['key'] ) ) {
50
+            wp_send_json_error( 'The key parameter is required.' );
51
+        }
52
+
53
+        // Set a response with valid set to true or false according to the key validity.
54
+        wp_send_json( array( 'valid' => $this->is_valid( $_POST['key'] ) ) );
55
+
56
+    }
57 57
 
58 58
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return bool True if the key is valid, otherwise false.
28 28
 	 */
29
-	public function is_valid( $key ) {
29
+	public function is_valid($key) {
30 30
 
31 31
 		// Request the dataset URI as a way to validate the key
32
-		$response = wp_remote_get( wl_configuration_get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
32
+		$response = wp_remote_get(wl_configuration_get_accounts_by_key_dataset_uri($key), unserialize(WL_REDLINK_API_HTTP_OPTIONS));
33 33
 
34 34
 		// If the response is valid, the key is valid.
35
-		return ! is_wp_error( $response ) && 200 === (int) $response['response']['code'];
35
+		return ! is_wp_error($response) && 200 === (int) $response['response']['code'];
36 36
 	}
37 37
 
38 38
 	/**
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 		ob_clean();
47 47
 
48 48
 		// Check if we have a key.
49
-		if ( ! isset( $_POST['key'] ) ) {
50
-			wp_send_json_error( 'The key parameter is required.' );
49
+		if ( ! isset($_POST['key'])) {
50
+			wp_send_json_error('The key parameter is required.');
51 51
 		}
52 52
 
53 53
 		// Set a response with valid set to true or false according to the key validity.
54
-		wp_send_json( array( 'valid' => $this->is_valid( $_POST['key'] ) ) );
54
+		wp_send_json(array('valid' => $this->is_valid($_POST['key'])));
55 55
 
56 56
 	}
57 57
 
Please login to merge, or discard this patch.
src/wordlift.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
  */
26 26
 
27 27
 // If this file is called directly, abort.
28
-if ( ! defined( 'WPINC' ) ) {
28
+if ( ! defined('WPINC')) {
29 29
 	die;
30 30
 }
31 31
 
32 32
 // Include WordLift constants.
33
-require_once( 'wordlift_constants.php' );
33
+require_once('wordlift_constants.php');
34 34
 
35 35
 // Load modules
36
-require_once( 'modules/core/wordlift_core.php' );
37
-require_once( 'modules/configuration/wordlift_configuration.php' );
36
+require_once('modules/core/wordlift_core.php');
37
+require_once('modules/configuration/wordlift_configuration.php');
38 38
 
39 39
 /**
40 40
  * Log to the debug.log file.
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
  *
46 46
  * @param string|mixed $log The log data.
47 47
  */
48
-function wl_write_log( $log ) {
48
+function wl_write_log($log) {
49 49
 
50
-	$handler = apply_filters( 'wl_write_log_handler', NULL );
50
+	$handler = apply_filters('wl_write_log_handler', NULL);
51 51
 
52 52
 	$callers         = debug_backtrace();
53 53
 	$caller_function = $callers[1]['function'];
54 54
 
55
-	if ( is_null( $handler ) ) {
56
-		wl_write_log_handler( $log, $caller_function );
55
+	if (is_null($handler)) {
56
+		wl_write_log_handler($log, $caller_function);
57 57
 
58 58
 		return;
59 59
 	}
60 60
 
61
-	call_user_func( $handler, $log, $caller_function );
61
+	call_user_func($handler, $log, $caller_function);
62 62
 }
63 63
 
64 64
 /**
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
  * @param string|array $log    The log data.
70 70
  * @param string       $caller The calling function.
71 71
  */
72
-function wl_write_log_handler( $log, $caller = NULL ) {
72
+function wl_write_log_handler($log, $caller = NULL) {
73 73
 
74 74
 	global $wl_logger;
75 75
 
76
-	if ( TRUE === WP_DEBUG ) {
76
+	if (TRUE === WP_DEBUG) {
77 77
 
78
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
79
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, TRUE ) : wl_write_log_hide_key( $log ) );
78
+		$message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : '').
79
+		           (is_array($log) || is_object($log) ? print_r($log, TRUE) : wl_write_log_hide_key($log));
80 80
 
81
-		if ( isset( $wl_logger ) ) {
82
-			$wl_logger->info( $message );
81
+		if (isset($wl_logger)) {
82
+			$wl_logger->info($message);
83 83
 		} else {
84
-			error_log( $message );
84
+			error_log($message);
85 85
 		}
86 86
 
87 87
 	}
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
  *
98 98
  * @return string A text with the key hidden.
99 99
  */
100
-function wl_write_log_hide_key( $text ) {
100
+function wl_write_log_hide_key($text) {
101 101
 
102
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
102
+	return str_ireplace(wl_configuration_get_key(), '<hidden>', $text);
103 103
 }
104 104
 
105 105
 /**
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
  *
110 110
  * @param string $query A SPARQL query.
111 111
  */
112
-function wl_queue_sparql_update_query( $query ) {
112
+function wl_queue_sparql_update_query($query) {
113 113
 
114
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
115
-	file_put_contents( $filename, $query . "\n", FILE_APPEND );
114
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
115
+	file_put_contents($filename, $query."\n", FILE_APPEND);
116 116
 
117
-	wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
117
+	wl_write_log("wl_queue_sparql_update_query [ filename :: $filename ]");
118 118
 }
119 119
 
120 120
 /**
@@ -122,33 +122,33 @@  discard block
 block discarded – undo
122 122
  *
123 123
  * @param int $request_id The request ID.
124 124
  */
125
-function wl_execute_saved_sparql_update_query( $request_id ) {
125
+function wl_execute_saved_sparql_update_query($request_id) {
126 126
 
127
-	$filename = WL_TEMP_DIR . $request_id . '.sparql';
127
+	$filename = WL_TEMP_DIR.$request_id.'.sparql';
128 128
 
129 129
 	// If the file doesn't exist, exit.
130
-	if ( ! file_exists( $filename ) ) {
131
-		wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
130
+	if ( ! file_exists($filename)) {
131
+		wl_write_log("wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]");
132 132
 
133 133
 		return;
134 134
 	}
135 135
 
136
-	wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
136
+	wl_write_log("wl_execute_saved_sparql_update_query [ filename :: $filename ]");
137 137
 
138 138
 	// Get the query saved in the file.
139
-	$query = file_get_contents( $filename );
139
+	$query = file_get_contents($filename);
140 140
 
141 141
 	// Execute the SPARQL query.
142
-	rl_execute_sparql_update_query( $query, FALSE );
142
+	rl_execute_sparql_update_query($query, FALSE);
143 143
 
144 144
 	// Reindex the triple store.
145 145
 	wordlift_reindex_triple_store();
146 146
 
147 147
 	// Delete the temporary file.
148
-	unlink( $filename );
148
+	unlink($filename);
149 149
 }
150 150
 
151
-add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 );
151
+add_action('wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1);
152 152
 
153 153
 /**
154 154
  * Add buttons hook for the TinyMCE editor. This method is called by the WP init hook.
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 function wordlift_buttonhooks() {
157 157
 
158 158
 	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
159
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
160
-		add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
159
+	if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
160
+		add_filter('mce_external_plugins', 'wordlift_register_tinymce_javascript');
161 161
 	}
162 162
 }
163 163
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return array The modified plugins array.
170 170
  */
171
-function wordlift_register_tinymce_javascript( $plugin_array ) {
171
+function wordlift_register_tinymce_javascript($plugin_array) {
172 172
 
173 173
 	// add the wordlift plugin.
174 174
 	// We can't use the minified version here.
175
-	$plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js';
175
+	$plugin_array['wordlift'] = plugin_dir_url(__FILE__).'js/wordlift-reloaded.js';
176 176
 
177 177
 	return $plugin_array;
178 178
 }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 function wordlift_allowed_post_tags() {
185 185
 	global $allowedposttags;
186 186
 
187
-	$tags           = array( 'span' );
187
+	$tags           = array('span');
188 188
 	$new_attributes = array(
189 189
 		'itemscope' => array(),
190 190
 		'itemtype'  => array(),
@@ -192,17 +192,17 @@  discard block
 block discarded – undo
192 192
 		'itemid'    => array(),
193 193
 	);
194 194
 
195
-	foreach ( $tags as $tag ) {
196
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
197
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
195
+	foreach ($tags as $tag) {
196
+		if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) {
197
+			$allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes);
198 198
 		}
199 199
 	}
200 200
 }
201 201
 
202 202
 // init process for button control
203
-add_action( 'init', 'wordlift_buttonhooks' );
203
+add_action('init', 'wordlift_buttonhooks');
204 204
 // add allowed post tags.
205
-add_action( 'init', 'wordlift_allowed_post_tags' );
205
+add_action('init', 'wordlift_allowed_post_tags');
206 206
 
207 207
 
208 208
 /**
@@ -211,30 +211,30 @@  discard block
 block discarded – undo
211 211
 function wordlift_admin_enqueue_scripts() {
212 212
 
213 213
 	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
214
-	wp_enqueue_script( 'wpdialogs' );
215
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
214
+	wp_enqueue_script('wpdialogs');
215
+	wp_enqueue_style('wp-jquery-ui-dialog');
216 216
 
217
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
217
+	wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css');
218 218
 
219
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
220
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
221
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
222
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
223
-	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
219
+	wp_enqueue_script('jquery-ui-autocomplete');
220
+	wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js');
221
+	wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js');
222
+	wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js');
223
+	wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js');
224 224
 
225 225
 	// Disable auto-save for custom entity posts only
226
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
227
-		wp_dequeue_script( 'autosave' );
226
+	if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) {
227
+		wp_dequeue_script('autosave');
228 228
 	}
229 229
 }
230 230
 
231
-add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
231
+add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts');
232 232
 
233 233
 function wl_enqueue_scripts() {
234
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
234
+	wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css');
235 235
 }
236 236
 
237
-add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
237
+add_action('wp_enqueue_scripts', 'wl_enqueue_scripts');
238 238
 
239 239
 /**
240 240
  * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
@@ -244,23 +244,23 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return array An array which contains allowed microdata attributes.
246 246
  */
247
-function wordlift_allowed_html( $allowedtags, $context ) {
247
+function wordlift_allowed_html($allowedtags, $context) {
248 248
 
249
-	if ( 'post' !== $context ) {
249
+	if ('post' !== $context) {
250 250
 		return $allowedtags;
251 251
 	}
252 252
 
253
-	return array_merge_recursive( $allowedtags, array(
253
+	return array_merge_recursive($allowedtags, array(
254 254
 		'span' => array(
255 255
 			'itemscope' => TRUE,
256 256
 			'itemtype'  => TRUE,
257 257
 			'itemid'    => TRUE,
258 258
 			'itemprop'  => TRUE,
259 259
 		),
260
-	) );
260
+	));
261 261
 }
262 262
 
263
-add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
263
+add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2);
264 264
 
265 265
 /**
266 266
  * Get the coordinates for the specified post ID.
@@ -269,16 +269,16 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return array|null An array of coordinates or null.
271 271
  */
272
-function wl_get_coordinates( $post_id ) {
272
+function wl_get_coordinates($post_id) {
273 273
 
274
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
275
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
274
+	$latitude  = wl_schema_get_value($post_id, 'latitude');
275
+	$longitude = wl_schema_get_value($post_id, 'longitude');
276 276
 
277 277
 	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
278 278
 	// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
279 279
 	return array(
280
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
281
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
280
+		'latitude'  => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '',
281
+		'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '',
282 282
 	);
283 283
 }
284 284
 
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
  *
290 290
  * @return string A datetime.
291 291
  */
292
-function wl_get_post_modified_time( $post ) {
292
+function wl_get_post_modified_time($post) {
293 293
 
294
-	$date_modified = get_post_modified_time( 'c', TRUE, $post );
294
+	$date_modified = get_post_modified_time('c', TRUE, $post);
295 295
 
296
-	if ( '-' === substr( $date_modified, 0, 1 ) ) {
297
-		return get_the_time( 'c', $post );
296
+	if ('-' === substr($date_modified, 0, 1)) {
297
+		return get_the_time('c', $post);
298 298
 	}
299 299
 
300 300
 	return $date_modified;
@@ -307,27 +307,27 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @return array An array of image URLs.
309 309
  */
310
-function wl_get_image_urls( $post_id ) {
310
+function wl_get_image_urls($post_id) {
311 311
 
312 312
 
313 313
 	// If there is a featured image it has the priority
314
-	$featured_image_id = get_post_thumbnail_id( $post_id );
315
-	if ( is_numeric( $featured_image_id ) ) {
316
-		$image_url = wp_get_attachment_url( $featured_image_id );
314
+	$featured_image_id = get_post_thumbnail_id($post_id);
315
+	if (is_numeric($featured_image_id)) {
316
+		$image_url = wp_get_attachment_url($featured_image_id);
317 317
 
318
-		return array( $image_url );
318
+		return array($image_url);
319 319
 	}
320 320
 
321 321
 	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
322 322
 
323
-	$images = get_children( array(
323
+	$images = get_children(array(
324 324
 		'post_parent'    => $post_id,
325 325
 		'post_type'      => 'attachment',
326 326
 		'post_mime_type' => 'image',
327
-	) );
327
+	));
328 328
 
329 329
 	// Return an empty array if no image is found.
330
-	if ( empty( $images ) ) {
330
+	if (empty($images)) {
331 331
 		return array();
332 332
 	}
333 333
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	$image_urls = array();
336 336
 
337 337
 	// Collect the URLs.
338
-	foreach ( $images as $attachment_id => $attachment ) {
339
-		$image_url = wp_get_attachment_url( $attachment_id );
338
+	foreach ($images as $attachment_id => $attachment) {
339
+		$image_url = wp_get_attachment_url($attachment_id);
340 340
 		// Ensure the URL isn't collected already.
341
-		if ( ! in_array( $image_url, $image_urls ) ) {
342
-			array_push( $image_urls, $image_url );
341
+		if ( ! in_array($image_url, $image_urls)) {
342
+			array_push($image_urls, $image_url);
343 343
 		}
344 344
 	}
345 345
 
@@ -356,17 +356,17 @@  discard block
 block discarded – undo
356 356
  *
357 357
  * @return string The SPARQL fragment.
358 358
  */
359
-function wl_get_sparql_images( $uri, $post_id ) {
359
+function wl_get_sparql_images($uri, $post_id) {
360 360
 
361 361
 	$sparql = '';
362 362
 
363 363
 	// Get the escaped URI.
364
-	$uri_e = esc_html( $uri );
364
+	$uri_e = esc_html($uri);
365 365
 
366 366
 	// Add SPARQL stmts to write the schema:image.
367
-	$image_urls = wl_get_image_urls( $post_id );
368
-	foreach ( $image_urls as $image_url ) {
369
-		$image_url_esc = wl_sparql_escape_uri( $image_url );
367
+	$image_urls = wl_get_image_urls($post_id);
368
+	foreach ($image_urls as $image_url) {
369
+		$image_url_esc = wl_sparql_escape_uri($image_url);
370 370
 		$sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
371 371
 	}
372 372
 
@@ -381,21 +381,21 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return WP_Post|null A post instance or null if not found.
383 383
  */
384
-function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
384
+function wl_get_attachment_for_source_url($parent_post_id, $source_url) {
385 385
 
386 386
 	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
387 387
 
388
-	$posts = get_posts( array(
388
+	$posts = get_posts(array(
389 389
 		'post_type'      => 'attachment',
390 390
 		'posts_per_page' => 1,
391 391
 		'post_status'    => 'any',
392 392
 		'post_parent'    => $parent_post_id,
393 393
 		'meta_key'       => 'wl_source_url',
394 394
 		'meta_value'     => $source_url,
395
-	) );
395
+	));
396 396
 
397 397
 	// Return the found post.
398
-	if ( 1 === count( $posts ) ) {
398
+	if (1 === count($posts)) {
399 399
 		return $posts[0];
400 400
 	}
401 401
 
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
  * @param int    $post_id    The post ID.
410 410
  * @param string $source_url The source URL.
411 411
  */
412
-function wl_set_source_url( $post_id, $source_url ) {
412
+function wl_set_source_url($post_id, $source_url) {
413 413
 
414
-	delete_post_meta( $post_id, 'wl_source_url' );
415
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
414
+	delete_post_meta($post_id, 'wl_source_url');
415
+	add_post_meta($post_id, 'wl_source_url', $source_url);
416 416
 }
417 417
 
418 418
 
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
  *
429 429
  * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
430 430
  */
431
-function wl_flush_rewrite_rules_hard( $hard ) {
431
+function wl_flush_rewrite_rules_hard($hard) {
432 432
 
433 433
 	// If WL is not yet configured, we cannot perform any update, so we exit.
434
-	if ( '' === wl_configuration_get_key() ) {
434
+	if ('' === wl_configuration_get_key()) {
435 435
 		return;
436 436
 	}
437 437
 
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 	$limit  = 100;
441 441
 
442 442
 	// Get more posts if the number of returned posts matches the limit.
443
-	while ( $limit === ( $posts = get_posts( array(
443
+	while ($limit === ($posts = get_posts(array(
444 444
 			'offset'      => $offset,
445 445
 			'numberposts' => $limit,
446 446
 			'orderby'     => 'ID',
447 447
 			'post_type'   => 'any',
448 448
 			'post_status' => 'publish',
449
-		) ) ) ) {
449
+		)))) {
450 450
 
451 451
 		// Holds the delete part of the query.
452 452
 		$delete_query = rl_sparql_prefixes();
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 		$insert_query = '';
456 456
 
457 457
 		// Cycle in each post to build the query.
458
-		foreach ( $posts as $post ) {
458
+		foreach ($posts as $post) {
459 459
 
460 460
 			// Ignore revisions.
461
-			if ( wp_is_post_revision( $post->ID ) ) {
461
+			if (wp_is_post_revision($post->ID)) {
462 462
 				continue;
463 463
 			}
464 464
 
465 465
 			// Get the entity URI.
466
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
467
-			                                                                 ->get_uri( $post->ID ) );
466
+			$s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance()
467
+			                                                                 ->get_uri($post->ID));
468 468
 
469 469
 			// Get the post URL.
470 470
 			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
@@ -473,13 +473,13 @@  discard block
 block discarded – undo
473 473
 			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
474 474
 
475 475
 			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
476
-			                                                     ->get_insert_query( $s, $post->ID );
476
+			                                                     ->get_insert_query($s, $post->ID);
477 477
 
478 478
 		}
479 479
 
480 480
 
481 481
 		// Execute the query.
482
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
482
+		rl_execute_sparql_update_query($delete_query.$insert_query);
483 483
 
484 484
 		// Advance to the next posts.
485 485
 		$offset += $limit;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
 }
497 497
 
498
-add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
498
+add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1);
499 499
 
500 500
 /**
501 501
  * Sanitizes an URI path by replacing the non allowed characters with an underscore.
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
  *
509 509
  * @return string The sanitized path.
510 510
  */
511
-function wl_sanitize_uri_path( $path, $char = '_' ) {
511
+function wl_sanitize_uri_path($path, $char = '_') {
512 512
 
513
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
513
+	return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char);
514 514
 }
515 515
 
516 516
 /**
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
  *
521 521
  * @return array Array containing $value (if $value was not an array)
522 522
  */
523
-function wl_force_to_array( $value ) {
523
+function wl_force_to_array($value) {
524 524
 
525
-	if ( ! is_array( $value ) ) {
526
-		return array( $value );
525
+	if ( ! is_array($value)) {
526
+		return array($value);
527 527
 	}
528 528
 
529 529
 	return $value;
@@ -535,28 +535,28 @@  discard block
 block discarded – undo
535 535
 function wl_shutdown() {
536 536
 
537 537
 	// Get the filename to the temporary SPARQL file.
538
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
538
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
539 539
 
540 540
 	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
541
-	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
541
+	if (WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists($filename)) {
542 542
 
543 543
 		// The request ID.
544
-		$args = array( WL_REQUEST_ID );
544
+		$args = array(WL_REQUEST_ID);
545 545
 
546 546
 		// Schedule the execution of the SPARQL query with the request ID.
547
-		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
547
+		wp_schedule_single_event(time(), 'wl_execute_saved_sparql_update_query', $args);
548 548
 
549 549
 		// Check that the request is scheduled.
550
-		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
550
+		$timestamp = wp_next_scheduled('wl_execute_saved_sparql_update_query', $args);
551 551
 
552 552
 		// Spawn the cron.
553 553
 		spawn_cron();
554 554
 
555
-		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
555
+		wl_write_log("wl_shutdown [ request id :: ".WL_REQUEST_ID." ][ timestamp :: $timestamp ]");
556 556
 	}
557 557
 }
558 558
 
559
-add_action( 'shutdown', 'wl_shutdown' );
559
+add_action('shutdown', 'wl_shutdown');
560 560
 
561 561
 /**
562 562
  * Replaces the *itemid* attributes URIs with the WordLift URIs.
@@ -565,112 +565,112 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @return string The updated post content.
567 567
  */
568
-function wl_replace_item_id_with_uri( $content ) {
568
+function wl_replace_item_id_with_uri($content) {
569 569
 
570 570
 	// wl_write_log( "wl_replace_item_id_with_uri" );
571 571
 
572 572
 	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
573
-	$content = stripslashes( $content );
573
+	$content = stripslashes($content);
574 574
 
575 575
 	// If any match are found.
576 576
 	$matches = array();
577
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
577
+	if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) {
578 578
 
579
-		foreach ( $matches as $match ) {
579
+		foreach ($matches as $match) {
580 580
 
581 581
 			// Get the item ID.
582 582
 			$item_id = $match[1];
583 583
 
584 584
 			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
585 585
 			$post = Wordlift_Entity_Service::get_instance()
586
-			                               ->get_entity_post_by_uri( $item_id );
586
+			                               ->get_entity_post_by_uri($item_id);
587 587
 
588 588
 			// If no entity is found, continue to the next one.
589
-			if ( NULL === $post ) {
589
+			if (NULL === $post) {
590 590
 				continue;
591 591
 			}
592 592
 
593 593
 			// Get the URI for that post.
594
-			$uri = wl_get_entity_uri( $post->ID );
594
+			$uri = wl_get_entity_uri($post->ID);
595 595
 
596 596
 			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
597 597
 
598 598
 			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
599
-			if ( $item_id !== $uri ) {
600
-				$uri_e   = esc_html( $uri );
601
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
599
+			if ($item_id !== $uri) {
600
+				$uri_e   = esc_html($uri);
601
+				$content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content);
602 602
 			}
603 603
 		}
604 604
 	}
605 605
 
606 606
 	// Reapply slashes.
607
-	$content = addslashes( $content );
607
+	$content = addslashes($content);
608 608
 
609 609
 	return $content;
610 610
 }
611 611
 
612
-add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
612
+add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1);
613 613
 
614
-require_once( 'wordlift_entity_functions.php' );
614
+require_once('wordlift_entity_functions.php');
615 615
 
616 616
 // add editor related methods.
617
-require_once( 'wordlift_editor.php' );
617
+require_once('wordlift_editor.php');
618 618
 
619 619
 // add the WordLift entity custom type.
620
-require_once( 'wordlift_entity_type.php' );
621
-require_once( 'wordlift_entity_type_taxonomy.php' );
620
+require_once('wordlift_entity_type.php');
621
+require_once('wordlift_entity_type_taxonomy.php');
622 622
 
623 623
 // add callbacks on post save to notify data changes from wp to redlink triple store
624
-require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
624
+require_once('wordlift_to_redlink_data_push_callbacks.php');
625 625
 
626 626
 // Load modules
627
-require_once( 'modules/analyzer/wordlift_analyzer.php' );
628
-require_once( 'modules/linked_data/wordlift_linked_data.php' );
629
-require_once( 'modules/prefixes/wordlift_prefixes.php' );
630
-require_once( 'modules/redirector/wordlift_redirector.php' );
631
-require_once( 'modules/freebase_image_proxy/wordlift_freebase_image_proxy.php' );
627
+require_once('modules/analyzer/wordlift_analyzer.php');
628
+require_once('modules/linked_data/wordlift_linked_data.php');
629
+require_once('modules/prefixes/wordlift_prefixes.php');
630
+require_once('modules/redirector/wordlift_redirector.php');
631
+require_once('modules/freebase_image_proxy/wordlift_freebase_image_proxy.php');
632 632
 
633 633
 // Shortcodes
634 634
 
635
-require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
636
-require_once( 'shortcodes/wordlift_shortcode_chord.php' );
637
-require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
638
-require_once( 'shortcodes/wordlift_shortcode_field.php' );
639
-require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
640
-require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
635
+require_once('modules/geo_widget/wordlift_geo_widget.php');
636
+require_once('shortcodes/wordlift_shortcode_chord.php');
637
+require_once('shortcodes/wordlift_shortcode_geomap.php');
638
+require_once('shortcodes/wordlift_shortcode_field.php');
639
+require_once('shortcodes/wordlift_shortcode_faceted_search.php');
640
+require_once('shortcodes/wordlift_shortcode_navigator.php');
641 641
 
642
-require_once( 'widgets/wordlift_widget_geo.php' );
643
-require_once( 'widgets/wordlift_widget_chord.php' );
644
-require_once( 'widgets/wordlift_widget_timeline.php' );
642
+require_once('widgets/wordlift_widget_geo.php');
643
+require_once('widgets/wordlift_widget_chord.php');
644
+require_once('widgets/wordlift_widget_timeline.php');
645 645
 
646
-require_once( 'wordlift_sparql.php' );
647
-require_once( 'wordlift_redlink.php' );
646
+require_once('wordlift_sparql.php');
647
+require_once('wordlift_redlink.php');
648 648
 
649 649
 // Add admin functions.
650 650
 // TODO: find a way to make 'admin' UI tests work.
651 651
 //if ( is_admin() ) {
652 652
 
653
-require_once( 'admin/wordlift_admin.php' );
654
-require_once( 'admin/wordlift_admin_edit_post.php' );
655
-require_once( 'admin/wordlift_admin_save_post.php' );
653
+require_once('admin/wordlift_admin.php');
654
+require_once('admin/wordlift_admin_edit_post.php');
655
+require_once('admin/wordlift_admin_save_post.php');
656 656
 
657 657
 // add the entities meta box.
658
-require_once( 'admin/wordlift_admin_meta_box_entities.php' );
658
+require_once('admin/wordlift_admin_meta_box_entities.php');
659 659
 
660 660
 // add the entity creation AJAX.
661
-require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
661
+require_once('admin/wordlift_admin_ajax_related_posts.php');
662 662
 
663 663
 // Load the wl_chord TinyMCE button and configuration dialog.
664
-require_once( 'admin/wordlift_admin_shortcodes.php' );
664
+require_once('admin/wordlift_admin_shortcodes.php');
665 665
 
666 666
 // Provide syncing features.
667
-require_once( 'admin/wordlift_admin_sync.php' );
667
+require_once('admin/wordlift_admin_sync.php');
668 668
 //}
669 669
 
670 670
 // load languages.
671 671
 // TODO: the following call gives for granted that the plugin is in the wordlift directory,
672 672
 //       we're currently doing this because wordlift is symbolic linked.
673
-load_plugin_textdomain( 'wordlift', FALSE, '/wordlift/languages' );
673
+load_plugin_textdomain('wordlift', FALSE, '/wordlift/languages');
674 674
 
675 675
 
676 676
 /**
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
  * This action is documented in includes/class-wordlift-activator.php
679 679
  */
680 680
 function activate_wordlift() {
681
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
681
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
682 682
 	Wordlift_Activator::activate();
683 683
 }
684 684
 
@@ -687,18 +687,18 @@  discard block
 block discarded – undo
687 687
  * This action is documented in includes/class-wordlift-deactivator.php
688 688
  */
689 689
 function deactivate_wordlift() {
690
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
690
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
691 691
 	Wordlift_Deactivator::deactivate();
692 692
 }
693 693
 
694
-register_activation_hook( __FILE__, 'activate_wordlift' );
695
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
694
+register_activation_hook(__FILE__, 'activate_wordlift');
695
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
696 696
 
697 697
 /**
698 698
  * The core plugin class that is used to define internationalization,
699 699
  * admin-specific hooks, and public-facing site hooks.
700 700
  */
701
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
701
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
702 702
 
703 703
 /**
704 704
  * Begins execution of the plugin.
Please login to merge, or discard this patch.