Completed
Pull Request — develop (#740)
by David
03:26
created
src/admin/partials/wordlift-admin-setup.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	<!-- Defining responsive ambient. -->
13 13
 	<meta name="viewport" content="width=device-width, initial-scale=1">
14 14
 
15
-	<title><?php esc_html_e( 'WordLift Setup', 'wordlift' ); ?></title>
15
+	<title><?php esc_html_e('WordLift Setup', 'wordlift'); ?></title>
16 16
 
17 17
 	<?php
18 18
 
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
 	wp_enqueue_media();
21 21
 
22 22
 	// Enqueue styles and scripts.
23
-	wp_enqueue_style( 'wl-font-awesome', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'css/font-awesome.min.css' );
24
-	wp_enqueue_style( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-admin-setup.css', array(
23
+	wp_enqueue_style('wl-font-awesome', plugin_dir_url(dirname(dirname(__FILE__))).'css/font-awesome.min.css');
24
+	wp_enqueue_style('wordlift-admin-setup', plugin_dir_url(dirname(__FILE__)).'css/wordlift-admin-setup.css', array(
25 25
 		'wp-admin',
26 26
 		'wl-font-awesome',
27
-	) );
28
-	wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'js/wordlift-admin-setup.js', array( 'jquery' ) );
27
+	));
28
+	wp_enqueue_script('wordlift-admin-setup', plugin_dir_url(dirname(__FILE__)).'js/wordlift-admin-setup.js', array('jquery'));
29 29
 
30 30
 	//Get wp_permalink structure
31
-	$permalink_structure = get_option( 'permalink_structure' );
31
+	$permalink_structure = get_option('permalink_structure');
32 32
 	
33 33
 	// Set configuration settings.
34
-	wp_localize_script( 'wordlift-admin-setup', '_wlAdminSetup', array(
35
-		'ajaxUrl'   => parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ),
34
+	wp_localize_script('wordlift-admin-setup', '_wlAdminSetup', array(
35
+		'ajaxUrl'   => parse_url(self_admin_url('admin-ajax.php'), PHP_URL_PATH),
36 36
 		'action'    => 'wl_validate_key',
37 37
 		'permalink' => $permalink_structure,
38 38
 		'media'     => array(
39
-			'title'  => __( 'WordLift Choose Logo', 'wordlift' ),
40
-			'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
39
+			'title'  => __('WordLift Choose Logo', 'wordlift'),
40
+			'button' => array('text' => __('Choose Logo', 'wordlift')),
41 41
 		),
42
-	) );
42
+	));
43 43
 
44 44
 	// Finally print styles and scripts.
45 45
 	wp_print_styles();
@@ -51,56 +51,56 @@  discard block
 block discarded – undo
51 51
 
52 52
 	<!-- Pane 1 content -->
53 53
 	<script type="text/html" id="page-0">
54
-		<h2 class="page-title"><?php esc_html_e( 'Welcome', 'wordlift' ); ?></h2>
54
+		<h2 class="page-title"><?php esc_html_e('Welcome', 'wordlift'); ?></h2>
55 55
 		<p class="page-txt">
56
-			<?php esc_html_e( 'Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift' ); ?>
56
+			<?php esc_html_e('Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift'); ?>
57 57
 		</p>
58 58
 		<ul class="page-list">
59 59
 			<li>
60 60
 				<span class="fa fa-university"></span>
61
-				<?php esc_html_e( 'Trustworthiness', 'wordlift' ); ?>
61
+				<?php esc_html_e('Trustworthiness', 'wordlift'); ?>
62 62
 			</li>
63 63
 
64 64
 			<li>
65 65
 				<span class="fa fa-map-marker"></span>
66
-				<?php esc_html_e( 'Enrichment', 'wordlift' ); ?>
66
+				<?php esc_html_e('Enrichment', 'wordlift'); ?>
67 67
 			</li>
68 68
 
69 69
 			<li>
70 70
 				<span class="fa fa-heart"></span>
71
-				<?php esc_html_e( 'Engagement', 'wordlift' ); ?>
71
+				<?php esc_html_e('Engagement', 'wordlift'); ?>
72 72
 			</li>
73 73
 
74 74
 			<li>
75 75
 				<span class="fa fa-hand-o-right"></span>
76
-				<?php esc_html_e( 'Smart Navigation', 'wordlift' ); ?>
76
+				<?php esc_html_e('Smart Navigation', 'wordlift'); ?>
77 77
 			</li>
78 78
 
79 79
 			<li>
80 80
 				<span class="fa fa-google"></span>
81
-				<?php esc_html_e( 'SEO Optimization', 'wordlift' ); ?>
81
+				<?php esc_html_e('SEO Optimization', 'wordlift'); ?>
82 82
 			</li>
83 83
 
84 84
 			<li>
85 85
 				<span class="fa fa-group"></span>
86
-				<?php esc_html_e( 'Content Marketing', 'wordlift' ); ?>
86
+				<?php esc_html_e('Content Marketing', 'wordlift'); ?>
87 87
 			</li>
88 88
 		</ul>
89 89
 		<div class="btn-wrapper">
90 90
 			<a href="https://wordlift.io/blogger/?utm_campaign=wl_activation_learn_more"
91 91
 			   target="_tab"
92
-			   class="button"><?php esc_html_e( 'Learn More', 'wordlift' ); ?></a>
92
+			   class="button"><?php esc_html_e('Learn More', 'wordlift'); ?></a>
93 93
 			<input type="button" data-wl-next="wl-next"
94 94
 			       class="wl-default-action"
95
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
95
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
96 96
 		</div>
97 97
 	</script>
98 98
 
99 99
 	<!-- Pane 2 content -->
100 100
 	<script type="text/html" id="page-1">
101
-		<h2 class="page-title"><?php esc_html_e( 'License Key', 'wordlift' ); ?></h2>
101
+		<h2 class="page-title"><?php esc_html_e('License Key', 'wordlift'); ?></h2>
102 102
 		<p class="page-txt">
103
-			<?php esc_html_e( 'If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift' ); ?>
103
+			<?php esc_html_e('If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift'); ?>
104 104
 		</p>
105 105
 		<input type="text" data-wl-key="wl-key" class="invalid untouched"
106 106
 		       id="key" name="key" value=""
@@ -109,40 +109,40 @@  discard block
 block discarded – undo
109 109
 			<a id="btn-grab-a-key"
110 110
 				href="https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key"
111 111
 				target="_tab"
112
-				class="button wl-default-action"><?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?></a><input
112
+				class="button wl-default-action"><?php esc_html_e('Grab a Key!', 'wordlift'); ?></a><input
113 113
 				id="btn-license-key-next"
114 114
 				type="button" data-wl-next="wl-next" class="button"
115
-				value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
115
+				value="<?php esc_attr_e('Next', 'wordlift'); ?>">
116 116
 		</div>
117 117
 	</script>
118 118
 
119 119
 	<!-- Pane 3 content -->
120 120
 	<script type="text/html" id="page-2">
121
-		<h2 class="page-title"><?php esc_html_e( 'Vocabulary', 'wordlift' ); ?></h2>
121
+		<h2 class="page-title"><?php esc_html_e('Vocabulary', 'wordlift'); ?></h2>
122 122
 		<p class="page-txt">
123
-			<?php esc_html_e( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift' ); ?>
123
+			<?php esc_html_e('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift'); ?>
124 124
 		</p>
125 125
 		<input type="text" id="vocabulary" name="vocabulary" autocomplete="off"
126 126
 		       value="vocabulary"
127 127
 		       class="valid untouched" data-wl-vocabulary="wl-vocabulary">
128 128
 		<p class="page-det">
129
-			<?php esc_html_e( 'Leave it empty to place your entities in the root folder of your website', 'wordlift' ); ?>
129
+			<?php esc_html_e('Leave it empty to place your entities in the root folder of your website', 'wordlift'); ?>
130 130
 		</p>
131 131
 		<div class="btn-wrapper">
132 132
 			<input type="button" data-wl-next="wl-next"
133 133
 			       class="wl-default-action"
134
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
134
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
135 135
 		</div>
136 136
 	</script>
137 137
 
138 138
 	<!-- Pane 4 content -->
139 139
 	<script type="text/html" id="page-3">
140
-		<h2 class="page-title"><?php esc_html_e( 'Language', 'wordlift' ); ?></h2>
140
+		<h2 class="page-title"><?php esc_html_e('Language', 'wordlift'); ?></h2>
141 141
 		<p class="page-txt">
142
-			<?php esc_html_e( 'Each WordLift key can be used only in one language. Pick yours.', 'wordlift' ); ?>
142
+			<?php esc_html_e('Each WordLift key can be used only in one language. Pick yours.', 'wordlift'); ?>
143 143
 		</p>
144 144
 		<select id="language" name="language"
145
-		        placeholder="<?php esc_attr_e( 'Choose your language', 'wordlift' ); ?>">
145
+		        placeholder="<?php esc_attr_e('Choose your language', 'wordlift'); ?>">
146 146
 			<?php
147 147
 
148 148
 			// Get WordLift's supported languages.
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 			$locale = get_locale();
153 153
 
154 154
 			// Get the language locale part.
155
-			$parts = explode( '_', $locale );
155
+			$parts = explode('_', $locale);
156 156
 
157 157
 			// If we support WP's configured language, then use that, otherwise use English by default.
158
-			$language = isset( $languages[ $parts[0] ] ) ? $parts[0] : 'en';
158
+			$language = isset($languages[$parts[0]]) ? $parts[0] : 'en';
159 159
 
160 160
 			// Print all the supported language, preselecting the one configured in WP (or English if not supported).
161
-			foreach ( $languages as $code => $label ) { ?>
161
+			foreach ($languages as $code => $label) { ?>
162 162
 				<option
163
-					value="<?php echo esc_attr( $code ) ?>" <?php echo selected( $code, $language, false ) ?>><?php echo esc_html( $label ) ?></option>
163
+					value="<?php echo esc_attr($code) ?>" <?php echo selected($code, $language, false) ?>><?php echo esc_html($label) ?></option>
164 164
 			<?php } ?>
165 165
 		</select>
166 166
 
167 167
 		<div class="btn-wrapper">
168 168
 			<input type="button" data-wl-next="wl-next"
169 169
 			       class="wl-default-action"
170
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
170
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
171 171
 		</div>
172 172
 	</script>
173 173
 
174 174
 	<!-- Pane 5 content -->
175 175
 	<script type="text/html" id="page-4">
176
-		<h2 class="page-title"><?php esc_html_e( 'Publisher', 'wordlift' ); ?></h2>
176
+		<h2 class="page-title"><?php esc_html_e('Publisher', 'wordlift'); ?></h2>
177 177
 		<p class="page-txt">
178
-			<?php esc_html_e( 'Are you going to publish as an individual or as a company?', 'wordlift' ); ?>
178
+			<?php esc_html_e('Are you going to publish as an individual or as a company?', 'wordlift'); ?>
179 179
 		</p>
180 180
 		<div class="radio-wrapper">
181 181
 			<label for="personal">
@@ -183,20 +183,20 @@  discard block
 block discarded – undo
183 183
 				       value="person" checked>
184 184
 				<span class="radio"><span class="check"></span></span>
185 185
 				<span
186
-					class="label"><?php esc_html_e( 'Personal', 'wordlift' ); ?></span>
186
+					class="label"><?php esc_html_e('Personal', 'wordlift'); ?></span>
187 187
 			</label>
188 188
 			<label for="company">
189 189
 				<input id="company" type="radio" name="user_type"
190 190
 				       value="organization">
191 191
 				<span class="radio"><span class="check"></span></span>
192 192
 				<span
193
-					class="label"><?php esc_html_e( 'Company', 'wordlift' ); ?></span>
193
+					class="label"><?php esc_html_e('Company', 'wordlift'); ?></span>
194 194
 			</label>
195 195
 		</div>
196 196
 		<input type="text" id="name" name="name" data-wl-name="wl-name" value=""
197 197
 		       autocomplete="off"
198 198
 		       class="untouched invalid"
199
-		       placeholder="<?php esc_attr_e( "What's your name?", 'wordlift' ); ?>">
199
+		       placeholder="<?php esc_attr_e("What's your name?", 'wordlift'); ?>">
200 200
 
201 201
 		<div data-wl-logo="wl-logo">
202 202
 			<input type="hidden" name="logo" />
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			</div>
207 207
 			<a data-wl-add-logo="wl-add-logo" class="add-logo"
208 208
 			   href="javascript:void(0);">
209
-				<?php esc_html_e( 'Add your logo', 'wordlift' ); ?>
209
+				<?php esc_html_e('Add your logo', 'wordlift'); ?>
210 210
 			</a>
211 211
 		</div>
212 212
 		<div class="btn-wrapper">
213 213
 			<input type="submit" id="btn-finish" class="wl-default-action"
214
-			       value="<?php esc_attr_e( 'Finish', 'wordlift' ); ?>">
214
+			       value="<?php esc_attr_e('Finish', 'wordlift'); ?>">
215 215
 		</div>
216 216
 	</script>
217 217
 
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 
221 221
 <div class="wl-container">
222 222
 
223
-	<a href="<?php echo esc_url( admin_url() ); ?> "
223
+	<a href="<?php echo esc_url(admin_url()); ?> "
224 224
 	   class="fa fa-times wl-close"></a>
225 225
 
226 226
 	<header>
227
-		<h1><img class="wizard-logo" src="<?php echo plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/logo-wl-transparent-240x90.png'; ?>" /></h1>
228
-		<img class="shapes" src="<?php echo plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/shapes.png'; ?>" />
227
+		<h1><img class="wizard-logo" src="<?php echo plugin_dir_url(dirname(dirname(__FILE__))).'images/logo-wl-transparent-240x90.png'; ?>" /></h1>
228
+		<img class="shapes" src="<?php echo plugin_dir_url(dirname(dirname(__FILE__))).'images/shapes.png'; ?>" />
229 229
 	</header>
230 230
 
231 231
 
232 232
 	<form method="post">
233
-		<?php wp_nonce_field( 'wl-save-configuration' ); ?>
233
+		<?php wp_nonce_field('wl-save-configuration'); ?>
234 234
 		<input type="hidden" name="action" value="wl-save-configuration" />
235 235
 		<div class="viewport"></div>
236 236
 	</form>
237 237
 
238 238
 </div>
239 239
 
240
-<?php do_action( 'admin_footer' ); ?>
240
+<?php do_action('admin_footer'); ?>
241 241
 
242 242
 </body>
243 243
 </html>
Please login to merge, or discard this patch.
src/includes/class-wordlift-content-filter-service.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -18,296 +18,296 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Content_Filter_Service {
20 20
 
21
-	/**
22
-	 * The pattern to find entities in text.
23
-	 *
24
-	 * @since 3.8.0
25
-	 */
26
-	const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
-
28
-	/**
29
-	 * A {@link Wordlift_Entity_Service} instance.
30
-	 *
31
-	 * @since  3.8.0
32
-	 * @access private
33
-	 * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
-	 */
35
-	private $entity_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Configuration_Service} instance.
39
-	 *
40
-	 * @since  3.13.0
41
-	 * @access private
42
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
-	 */
44
-	private $configuration_service;
45
-
46
-	/**
47
-	 * The `link by default` setting.
48
-	 *
49
-	 * @since  3.13.0
50
-	 * @access private
51
-	 * @var bool True if link by default is enabled otherwise false.
52
-	 */
53
-	private $is_link_by_default;
54
-
55
-	private $entity_post_ids_linked_from_post_content = array();
56
-
57
-	/**
58
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
59
-	 *
60
-	 * @since  3.16.3
61
-	 * @access private
62
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
63
-	 */
64
-	private $entity_uri_service;
65
-
66
-	/**
67
-	 * A {@link Wordlift_Log_Service} instance.
68
-	 *
69
-	 * @since 3.16.0
70
-	 *
71
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
72
-	 */
73
-	private $log;
74
-
75
-	/**
76
-	 * The {@link Wordlift_Content_Filter_Service} singleton instance.
77
-	 *
78
-	 * @since  3.14.2
79
-	 * @access private
80
-	 * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
81
-	 */
82
-	private static $instance;
83
-
84
-	/**
85
-	 * Create a {@link Wordlift_Content_Filter_Service} instance.
86
-	 *
87
-	 * @since 3.8.0
88
-	 *
89
-	 * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
90
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91
-	 * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92
-	 */
93
-	public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
94
-
95
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
96
-
97
-		$this->entity_service        = $entity_service;
98
-		$this->configuration_service = $configuration_service;
99
-		$this->entity_uri_service    = $entity_uri_service;
100
-
101
-		self::$instance = $this;
102
-
103
-	}
104
-
105
-	/**
106
-	 * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
107
-	 *
108
-	 * @since 3.14.2
109
-	 * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
110
-	 */
111
-	public static function get_instance() {
112
-
113
-		return self::$instance;
114
-	}
115
-
116
-	/**
117
-	 * Mangle the content by adding links to the entity pages. This function is
118
-	 * hooked to the 'the_content' WP's filter.
119
-	 *
120
-	 * @since 3.8.0
121
-	 *
122
-	 * @param string $content The content being filtered.
123
-	 *
124
-	 * @return string The filtered content.
125
-	 */
126
-	public function the_content( $content ) {
127
-
128
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
129
-
130
-		// Links should be added only on the front end and not for RSS.
131
-		if ( is_feed() ) {
132
-			return $content;
133
-		}
134
-
135
-		// Preload the `link by default` setting.
136
-		$this->is_link_by_default = $this->configuration_service->is_link_by_default();
137
-
138
-		// Reset the array of of entity post ids linked from the post content.
139
-		// This is used to avoid linking more the once the same post.
140
-		$this->entity_post_ids_linked_from_post_content = array();
141
-
142
-		// Preload URIs.
143
-		$matches = array();
144
-		preg_match_all( self::PATTERN, $content, $matches );
145
-
146
-		// Bail out if there are no URIs.
147
-		if ( 0 === count( $matches[3] ) ) {
148
-			return $content;
149
-		}
150
-
151
-		// Preload the URIs.
152
-		$this->entity_uri_service->preload_uris( $matches[3] );
153
-
154
-		// Replace each match of the entity tag with the entity link. If an error
155
-		// occurs fail silently returning the original content.
156
-		$result = preg_replace_callback( self::PATTERN, array(
157
-			$this,
158
-			'link',
159
-		), $content ) ?: $content;
160
-
161
-		$this->entity_uri_service->reset_uris();
162
-
163
-		return $result;
164
-	}
165
-
166
-	/**
167
-	 * Get the entity match and replace it with a page link.
168
-	 *
169
-	 * @since 3.8.0
170
-	 *
171
-	 * @param array $matches An array of matches.
172
-	 *
173
-	 * @return string The replaced text with the link to the entity page.
174
-	 */
175
-	private function link( $matches ) {
176
-
177
-		// Get the entity itemid URI and label.
178
-		$css_class = $matches[2];
179
-		$uri       = $matches[3];
180
-		$label     = $matches[4];
181
-
182
-		// Get the entity post by URI.
183
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
184
-
185
-		// @todo: revise the `test-content-filter-service.php` before switching
186
-		// to the `entity_uri_service`. This is required, because the test injects
187
-		// itself as `entity_service` to mock the requests to get a post by
188
-		// entity uri.
189
-		//
190
-		// $post = $this->entity_uri_service->get_entity( $uri );
191
-
192
-		if ( null === $post ) {
193
-
194
-			// If the entity post is not found return the label w/o the markup
195
-			// around it.
196
-			//
197
-			// See https://github.com/insideout10/wordlift-plugin/issues/461.
198
-			return $label;
199
-		}
200
-
201
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
202
-				   // Do not link if already linked.
203
-				   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
-		$link = - 1 < strpos( $css_class, 'wl-link' );
205
-
206
-		// Don't link if links are disabled and the entity is not link or the
207
-		// entity is do not link.
208
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
209
-
210
-		// Return the label if it's don't link.
211
-		if ( $dont_link ) {
212
-			return $label;
213
-		}
214
-
215
-		// Add the entity post id to the array of already linked entities, so that
216
-		// only the first entity occurrence is linked.
217
-		$this->entity_post_ids_linked_from_post_content[] = $post->ID;
218
-
219
-		// Get the link.
220
-		$href = get_permalink( $post );
221
-
222
-		// Get an alternative title attribute.
223
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
224
-
225
-		// Return the link.
226
-		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
227
-	}
228
-
229
-	/**
230
-	 * Get a `title` attribute with an alternative label for the link.
231
-	 *
232
-	 * If an alternative title isn't available an empty string is returned.
233
-	 *
234
-	 * @since 3.15.0
235
-	 *
236
-	 * @param int    $post_id The {@link WP_Post}'s id.
237
-	 * @param string $label   The main link label.
238
-	 *
239
-	 * @return string A `title` attribute with an alternative label or an empty
240
-	 *                string if none available.
241
-	 */
242
-	private function get_title_attribute( $post_id, $label ) {
243
-
244
-		// Get an alternative title.
245
-		$title = $this->get_link_title( $post_id, $label );
246
-		if ( ! empty( $title ) ) {
247
-			return 'title="' . esc_attr( $title ) . '"';
248
-		}
249
-
250
-		return '';
251
-	}
252
-
253
-	/**
254
-	 * Get a string to be used as a title attribute in links to a post
255
-	 *
256
-	 * @since 3.15.0
257
-	 *
258
-	 * @param int    $post_id      The post id of the post being linked.
259
-	 * @param string $ignore_label A label to ignore.
260
-	 *
261
-	 * @return string    The title to be used in the link. An empty string when
262
-	 *                    there is no alternative that is not the $ignore_label.
263
-	 */
264
-	function get_link_title( $post_id, $ignore_label ) {
265
-
266
-		// Get possible alternative labels we can select from.
267
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
268
-
269
-		/*
21
+    /**
22
+     * The pattern to find entities in text.
23
+     *
24
+     * @since 3.8.0
25
+     */
26
+    const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
+
28
+    /**
29
+     * A {@link Wordlift_Entity_Service} instance.
30
+     *
31
+     * @since  3.8.0
32
+     * @access private
33
+     * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
+     */
35
+    private $entity_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Configuration_Service} instance.
39
+     *
40
+     * @since  3.13.0
41
+     * @access private
42
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
+     */
44
+    private $configuration_service;
45
+
46
+    /**
47
+     * The `link by default` setting.
48
+     *
49
+     * @since  3.13.0
50
+     * @access private
51
+     * @var bool True if link by default is enabled otherwise false.
52
+     */
53
+    private $is_link_by_default;
54
+
55
+    private $entity_post_ids_linked_from_post_content = array();
56
+
57
+    /**
58
+     * The {@link Wordlift_Entity_Uri_Service} instance.
59
+     *
60
+     * @since  3.16.3
61
+     * @access private
62
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
63
+     */
64
+    private $entity_uri_service;
65
+
66
+    /**
67
+     * A {@link Wordlift_Log_Service} instance.
68
+     *
69
+     * @since 3.16.0
70
+     *
71
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
72
+     */
73
+    private $log;
74
+
75
+    /**
76
+     * The {@link Wordlift_Content_Filter_Service} singleton instance.
77
+     *
78
+     * @since  3.14.2
79
+     * @access private
80
+     * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
81
+     */
82
+    private static $instance;
83
+
84
+    /**
85
+     * Create a {@link Wordlift_Content_Filter_Service} instance.
86
+     *
87
+     * @since 3.8.0
88
+     *
89
+     * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
90
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91
+     * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92
+     */
93
+    public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
94
+
95
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
96
+
97
+        $this->entity_service        = $entity_service;
98
+        $this->configuration_service = $configuration_service;
99
+        $this->entity_uri_service    = $entity_uri_service;
100
+
101
+        self::$instance = $this;
102
+
103
+    }
104
+
105
+    /**
106
+     * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
107
+     *
108
+     * @since 3.14.2
109
+     * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
110
+     */
111
+    public static function get_instance() {
112
+
113
+        return self::$instance;
114
+    }
115
+
116
+    /**
117
+     * Mangle the content by adding links to the entity pages. This function is
118
+     * hooked to the 'the_content' WP's filter.
119
+     *
120
+     * @since 3.8.0
121
+     *
122
+     * @param string $content The content being filtered.
123
+     *
124
+     * @return string The filtered content.
125
+     */
126
+    public function the_content( $content ) {
127
+
128
+        $this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
129
+
130
+        // Links should be added only on the front end and not for RSS.
131
+        if ( is_feed() ) {
132
+            return $content;
133
+        }
134
+
135
+        // Preload the `link by default` setting.
136
+        $this->is_link_by_default = $this->configuration_service->is_link_by_default();
137
+
138
+        // Reset the array of of entity post ids linked from the post content.
139
+        // This is used to avoid linking more the once the same post.
140
+        $this->entity_post_ids_linked_from_post_content = array();
141
+
142
+        // Preload URIs.
143
+        $matches = array();
144
+        preg_match_all( self::PATTERN, $content, $matches );
145
+
146
+        // Bail out if there are no URIs.
147
+        if ( 0 === count( $matches[3] ) ) {
148
+            return $content;
149
+        }
150
+
151
+        // Preload the URIs.
152
+        $this->entity_uri_service->preload_uris( $matches[3] );
153
+
154
+        // Replace each match of the entity tag with the entity link. If an error
155
+        // occurs fail silently returning the original content.
156
+        $result = preg_replace_callback( self::PATTERN, array(
157
+            $this,
158
+            'link',
159
+        ), $content ) ?: $content;
160
+
161
+        $this->entity_uri_service->reset_uris();
162
+
163
+        return $result;
164
+    }
165
+
166
+    /**
167
+     * Get the entity match and replace it with a page link.
168
+     *
169
+     * @since 3.8.0
170
+     *
171
+     * @param array $matches An array of matches.
172
+     *
173
+     * @return string The replaced text with the link to the entity page.
174
+     */
175
+    private function link( $matches ) {
176
+
177
+        // Get the entity itemid URI and label.
178
+        $css_class = $matches[2];
179
+        $uri       = $matches[3];
180
+        $label     = $matches[4];
181
+
182
+        // Get the entity post by URI.
183
+        $post = $this->entity_service->get_entity_post_by_uri( $uri );
184
+
185
+        // @todo: revise the `test-content-filter-service.php` before switching
186
+        // to the `entity_uri_service`. This is required, because the test injects
187
+        // itself as `entity_service` to mock the requests to get a post by
188
+        // entity uri.
189
+        //
190
+        // $post = $this->entity_uri_service->get_entity( $uri );
191
+
192
+        if ( null === $post ) {
193
+
194
+            // If the entity post is not found return the label w/o the markup
195
+            // around it.
196
+            //
197
+            // See https://github.com/insideout10/wordlift-plugin/issues/461.
198
+            return $label;
199
+        }
200
+
201
+        $no_link = - 1 < strpos( $css_class, 'wl-no-link' )
202
+                    // Do not link if already linked.
203
+                   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
+        $link = - 1 < strpos( $css_class, 'wl-link' );
205
+
206
+        // Don't link if links are disabled and the entity is not link or the
207
+        // entity is do not link.
208
+        $dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
209
+
210
+        // Return the label if it's don't link.
211
+        if ( $dont_link ) {
212
+            return $label;
213
+        }
214
+
215
+        // Add the entity post id to the array of already linked entities, so that
216
+        // only the first entity occurrence is linked.
217
+        $this->entity_post_ids_linked_from_post_content[] = $post->ID;
218
+
219
+        // Get the link.
220
+        $href = get_permalink( $post );
221
+
222
+        // Get an alternative title attribute.
223
+        $title_attribute = $this->get_title_attribute( $post->ID, $label );
224
+
225
+        // Return the link.
226
+        return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
227
+    }
228
+
229
+    /**
230
+     * Get a `title` attribute with an alternative label for the link.
231
+     *
232
+     * If an alternative title isn't available an empty string is returned.
233
+     *
234
+     * @since 3.15.0
235
+     *
236
+     * @param int    $post_id The {@link WP_Post}'s id.
237
+     * @param string $label   The main link label.
238
+     *
239
+     * @return string A `title` attribute with an alternative label or an empty
240
+     *                string if none available.
241
+     */
242
+    private function get_title_attribute( $post_id, $label ) {
243
+
244
+        // Get an alternative title.
245
+        $title = $this->get_link_title( $post_id, $label );
246
+        if ( ! empty( $title ) ) {
247
+            return 'title="' . esc_attr( $title ) . '"';
248
+        }
249
+
250
+        return '';
251
+    }
252
+
253
+    /**
254
+     * Get a string to be used as a title attribute in links to a post
255
+     *
256
+     * @since 3.15.0
257
+     *
258
+     * @param int    $post_id      The post id of the post being linked.
259
+     * @param string $ignore_label A label to ignore.
260
+     *
261
+     * @return string    The title to be used in the link. An empty string when
262
+     *                    there is no alternative that is not the $ignore_label.
263
+     */
264
+    function get_link_title( $post_id, $ignore_label ) {
265
+
266
+        // Get possible alternative labels we can select from.
267
+        $labels = $this->entity_service->get_alternative_labels( $post_id );
268
+
269
+        /*
270 270
 		 * Since the original text might use an alternative label than the
271 271
 		 * Entity title, add the title itself which is not returned by the api.
272 272
 		 */
273
-		$labels[] = get_the_title( $post_id );
274
-
275
-		// Add some randomness to the label selection.
276
-		shuffle( $labels );
277
-
278
-		// Select the first label which is not to be ignored.
279
-		$title = '';
280
-		foreach ( $labels as $label ) {
281
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
282
-				$title = $label;
283
-				break;
284
-			}
285
-		}
286
-
287
-		return $title;
288
-	}
289
-
290
-	/**
291
-	 * Get the entity URIs (configured in the `itemid` attribute) contained in
292
-	 * the provided content.
293
-	 *
294
-	 * @since 3.14.2
295
-	 *
296
-	 * @param string $content The content.
297
-	 *
298
-	 * @return array An array of URIs.
299
-	 */
300
-	public function get_entity_uris( $content ) {
301
-
302
-		$matches = array();
303
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
304
-
305
-		// We need to use `array_values` here in order to avoid further `json_encode`
306
-		// to turn it into an object (since if the 3rd match isn't found the index
307
-		// is not sequential.
308
-		//
309
-		// See https://github.com/insideout10/wordlift-plugin/issues/646.
310
-		return array_values( array_unique( $matches[3] ) );
311
-	}
273
+        $labels[] = get_the_title( $post_id );
274
+
275
+        // Add some randomness to the label selection.
276
+        shuffle( $labels );
277
+
278
+        // Select the first label which is not to be ignored.
279
+        $title = '';
280
+        foreach ( $labels as $label ) {
281
+            if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
282
+                $title = $label;
283
+                break;
284
+            }
285
+        }
286
+
287
+        return $title;
288
+    }
289
+
290
+    /**
291
+     * Get the entity URIs (configured in the `itemid` attribute) contained in
292
+     * the provided content.
293
+     *
294
+     * @since 3.14.2
295
+     *
296
+     * @param string $content The content.
297
+     *
298
+     * @return array An array of URIs.
299
+     */
300
+    public function get_entity_uris( $content ) {
301
+
302
+        $matches = array();
303
+        preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
304
+
305
+        // We need to use `array_values` here in order to avoid further `json_encode`
306
+        // to turn it into an object (since if the 3rd match isn't found the index
307
+        // is not sequential.
308
+        //
309
+        // See https://github.com/insideout10/wordlift-plugin/issues/646.
310
+        return array_values( array_unique( $matches[3] ) );
311
+    }
312 312
 
313 313
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91 91
 	 * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92 92
 	 */
93
-	public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
93
+	public function __construct($entity_service, $configuration_service, $entity_uri_service) {
94 94
 
95
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
95
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
96 96
 
97 97
 		$this->entity_service        = $entity_service;
98 98
 		$this->configuration_service = $configuration_service;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return string The filtered content.
125 125
 	 */
126
-	public function the_content( $content ) {
126
+	public function the_content($content) {
127 127
 
128
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
128
+		$this->log->trace("Filtering content [ ".(is_singular() ? 'yes' : 'no')." ]...");
129 129
 
130 130
 		// Links should be added only on the front end and not for RSS.
131
-		if ( is_feed() ) {
131
+		if (is_feed()) {
132 132
 			return $content;
133 133
 		}
134 134
 
@@ -141,22 +141,22 @@  discard block
 block discarded – undo
141 141
 
142 142
 		// Preload URIs.
143 143
 		$matches = array();
144
-		preg_match_all( self::PATTERN, $content, $matches );
144
+		preg_match_all(self::PATTERN, $content, $matches);
145 145
 
146 146
 		// Bail out if there are no URIs.
147
-		if ( 0 === count( $matches[3] ) ) {
147
+		if (0 === count($matches[3])) {
148 148
 			return $content;
149 149
 		}
150 150
 
151 151
 		// Preload the URIs.
152
-		$this->entity_uri_service->preload_uris( $matches[3] );
152
+		$this->entity_uri_service->preload_uris($matches[3]);
153 153
 
154 154
 		// Replace each match of the entity tag with the entity link. If an error
155 155
 		// occurs fail silently returning the original content.
156
-		$result = preg_replace_callback( self::PATTERN, array(
156
+		$result = preg_replace_callback(self::PATTERN, array(
157 157
 			$this,
158 158
 			'link',
159
-		), $content ) ?: $content;
159
+		), $content) ?: $content;
160 160
 
161 161
 		$this->entity_uri_service->reset_uris();
162 162
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string The replaced text with the link to the entity page.
174 174
 	 */
175
-	private function link( $matches ) {
175
+	private function link($matches) {
176 176
 
177 177
 		// Get the entity itemid URI and label.
178 178
 		$css_class = $matches[2];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		$label     = $matches[4];
181 181
 
182 182
 		// Get the entity post by URI.
183
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
183
+		$post = $this->entity_service->get_entity_post_by_uri($uri);
184 184
 
185 185
 		// @todo: revise the `test-content-filter-service.php` before switching
186 186
 		// to the `entity_uri_service`. This is required, because the test injects
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		//
190 190
 		// $post = $this->entity_uri_service->get_entity( $uri );
191 191
 
192
-		if ( null === $post ) {
192
+		if (null === $post) {
193 193
 
194 194
 			// If the entity post is not found return the label w/o the markup
195 195
 			// around it.
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 			return $label;
199 199
 		}
200 200
 
201
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
201
+		$no_link = - 1 < strpos($css_class, 'wl-no-link')
202 202
 				   // Do not link if already linked.
203
-				   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
-		$link = - 1 < strpos( $css_class, 'wl-link' );
203
+				   || in_array($post->ID, $this->entity_post_ids_linked_from_post_content);
204
+		$link = - 1 < strpos($css_class, 'wl-link');
205 205
 
206 206
 		// Don't link if links are disabled and the entity is not link or the
207 207
 		// entity is do not link.
208
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
208
+		$dont_link = ( ! $this->is_link_by_default && ! $link) || $no_link;
209 209
 
210 210
 		// Return the label if it's don't link.
211
-		if ( $dont_link ) {
211
+		if ($dont_link) {
212 212
 			return $label;
213 213
 		}
214 214
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 		$this->entity_post_ids_linked_from_post_content[] = $post->ID;
218 218
 
219 219
 		// Get the link.
220
-		$href = get_permalink( $post );
220
+		$href = get_permalink($post);
221 221
 
222 222
 		// Get an alternative title attribute.
223
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
223
+		$title_attribute = $this->get_title_attribute($post->ID, $label);
224 224
 
225 225
 		// Return the link.
226 226
 		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 	 * @return string A `title` attribute with an alternative label or an empty
240 240
 	 *                string if none available.
241 241
 	 */
242
-	private function get_title_attribute( $post_id, $label ) {
242
+	private function get_title_attribute($post_id, $label) {
243 243
 
244 244
 		// Get an alternative title.
245
-		$title = $this->get_link_title( $post_id, $label );
246
-		if ( ! empty( $title ) ) {
247
-			return 'title="' . esc_attr( $title ) . '"';
245
+		$title = $this->get_link_title($post_id, $label);
246
+		if ( ! empty($title)) {
247
+			return 'title="'.esc_attr($title).'"';
248 248
 		}
249 249
 
250 250
 		return '';
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 * @return string    The title to be used in the link. An empty string when
262 262
 	 *                    there is no alternative that is not the $ignore_label.
263 263
 	 */
264
-	function get_link_title( $post_id, $ignore_label ) {
264
+	function get_link_title($post_id, $ignore_label) {
265 265
 
266 266
 		// Get possible alternative labels we can select from.
267
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
267
+		$labels = $this->entity_service->get_alternative_labels($post_id);
268 268
 
269 269
 		/*
270 270
 		 * Since the original text might use an alternative label than the
271 271
 		 * Entity title, add the title itself which is not returned by the api.
272 272
 		 */
273
-		$labels[] = get_the_title( $post_id );
273
+		$labels[] = get_the_title($post_id);
274 274
 
275 275
 		// Add some randomness to the label selection.
276
-		shuffle( $labels );
276
+		shuffle($labels);
277 277
 
278 278
 		// Select the first label which is not to be ignored.
279 279
 		$title = '';
280
-		foreach ( $labels as $label ) {
281
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
280
+		foreach ($labels as $label) {
281
+			if (0 !== strcasecmp($label, $ignore_label)) {
282 282
 				$title = $label;
283 283
 				break;
284 284
 			}
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return array An array of URIs.
299 299
 	 */
300
-	public function get_entity_uris( $content ) {
300
+	public function get_entity_uris($content) {
301 301
 
302 302
 		$matches = array();
303
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
303
+		preg_match_all(Wordlift_Content_Filter_Service::PATTERN, $content, $matches);
304 304
 
305 305
 		// We need to use `array_values` here in order to avoid further `json_encode`
306 306
 		// to turn it into an object (since if the 3rd match isn't found the index
307 307
 		// is not sequential.
308 308
 		//
309 309
 		// See https://github.com/insideout10/wordlift-plugin/issues/646.
310
-		return array_values( array_unique( $matches[3] ) );
310
+		return array_values(array_unique($matches[3]));
311 311
 	}
312 312
 
313 313
 }
Please login to merge, or discard this patch.
src/public/class-wordlift-public.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -22,113 +22,113 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Public {
24 24
 
25
-	/**
26
-	 * The ID of this plugin.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   private
30
-	 * @var      string $plugin_name The ID of this plugin.
31
-	 */
32
-	private $plugin_name;
33
-
34
-	/**
35
-	 * The version of this plugin.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   private
39
-	 * @var      string $version The current version of this plugin.
40
-	 */
41
-	private $version;
42
-
43
-	/**
44
-	 * Initialize the class and set its properties.
45
-	 *
46
-	 * @since    1.0.0
47
-	 *
48
-	 * @param      string $plugin_name The name of the plugin.
49
-	 * @param      string $version     The version of this plugin.
50
-	 */
51
-	public function __construct( $plugin_name, $version ) {
52
-
53
-		$this->plugin_name = $plugin_name;
54
-		$this->version     = $version;
55
-
56
-	}
57
-
58
-	/**
59
-	 * Register the stylesheets for the public-facing side of the site.
60
-	 *
61
-	 * @since    1.0.0
62
-	 */
63
-	public function enqueue_styles() {
64
-
65
-		/**
66
-		 * This function is provided for demonstration purposes only.
67
-		 *
68
-		 * An instance of this class should be passed to the run() function
69
-		 * defined in Wordlift_Loader as all of the hooks are defined
70
-		 * in that particular class.
71
-		 *
72
-		 * The Wordlift_Loader will then create the relationship
73
-		 * between the defined hooks and the functions defined in this
74
-		 * class.
75
-		 */
76
-
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
-
79
-	}
80
-
81
-	/**
82
-	 * Register the stylesheets for the public-facing side of the site.
83
-	 *
84
-	 * @since    1.0.0
85
-	 */
86
-	public function enqueue_scripts() {
87
-
88
-		/**
89
-		 * This function is provided for demonstration purposes only.
90
-		 *
91
-		 * An instance of this class should be passed to the run() function
92
-		 * defined in Wordlift_Loader as all of the hooks are defined
93
-		 * in that particular class.
94
-		 *
95
-		 * The Wordlift_Loader will then create the relationship
96
-		 * between the defined hooks and the functions defined in this
97
-		 * class.
98
-		 */
99
-
100
-		// Prepare a settings array for client-side functions.
101
-		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
-		);
104
-
105
-		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
107
-			$settings['postId'] = get_the_ID();
108
-		}
109
-
110
-		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
112
-			$settings['isHome'] = true;
113
-		}
114
-
115
-		// By default only enable JSON-LD on supported entity pages (includes
116
-		// `page`, `post` and `entity` by default) and on the home page.
117
-		//
118
-		// @see https://github.com/insideout10/wordlift-plugin/issues/733
119
-		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
120
-
121
-		// Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122
-		// be loaded.
123
-		//
124
-		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
126
-
127
-		// Note that we switched the js to be loaded in footer, since it is loading
128
-		// the json-ld representation.
129
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
131
-
132
-	}
25
+    /**
26
+     * The ID of this plugin.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   private
30
+     * @var      string $plugin_name The ID of this plugin.
31
+     */
32
+    private $plugin_name;
33
+
34
+    /**
35
+     * The version of this plugin.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   private
39
+     * @var      string $version The current version of this plugin.
40
+     */
41
+    private $version;
42
+
43
+    /**
44
+     * Initialize the class and set its properties.
45
+     *
46
+     * @since    1.0.0
47
+     *
48
+     * @param      string $plugin_name The name of the plugin.
49
+     * @param      string $version     The version of this plugin.
50
+     */
51
+    public function __construct( $plugin_name, $version ) {
52
+
53
+        $this->plugin_name = $plugin_name;
54
+        $this->version     = $version;
55
+
56
+    }
57
+
58
+    /**
59
+     * Register the stylesheets for the public-facing side of the site.
60
+     *
61
+     * @since    1.0.0
62
+     */
63
+    public function enqueue_styles() {
64
+
65
+        /**
66
+         * This function is provided for demonstration purposes only.
67
+         *
68
+         * An instance of this class should be passed to the run() function
69
+         * defined in Wordlift_Loader as all of the hooks are defined
70
+         * in that particular class.
71
+         *
72
+         * The Wordlift_Loader will then create the relationship
73
+         * between the defined hooks and the functions defined in this
74
+         * class.
75
+         */
76
+
77
+        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
+
79
+    }
80
+
81
+    /**
82
+     * Register the stylesheets for the public-facing side of the site.
83
+     *
84
+     * @since    1.0.0
85
+     */
86
+    public function enqueue_scripts() {
87
+
88
+        /**
89
+         * This function is provided for demonstration purposes only.
90
+         *
91
+         * An instance of this class should be passed to the run() function
92
+         * defined in Wordlift_Loader as all of the hooks are defined
93
+         * in that particular class.
94
+         *
95
+         * The Wordlift_Loader will then create the relationship
96
+         * between the defined hooks and the functions defined in this
97
+         * class.
98
+         */
99
+
100
+        // Prepare a settings array for client-side functions.
101
+        $settings = array(
102
+            'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
+        );
104
+
105
+        // If we're in a single page, then print out the post id.
106
+        if ( is_singular() ) {
107
+            $settings['postId'] = get_the_ID();
108
+        }
109
+
110
+        // Add flag that we are on home/blog page.
111
+        if ( is_home() || is_front_page() ) {
112
+            $settings['isHome'] = true;
113
+        }
114
+
115
+        // By default only enable JSON-LD on supported entity pages (includes
116
+        // `page`, `post` and `entity` by default) and on the home page.
117
+        //
118
+        // @see https://github.com/insideout10/wordlift-plugin/issues/733
119
+        $jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
120
+
121
+        // Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122
+        // be loaded.
123
+        //
124
+        // @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
+        $settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
126
+
127
+        // Note that we switched the js to be loaded in footer, since it is loading
128
+        // the json-ld representation.
129
+        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
+        wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
131
+
132
+    }
133 133
 
134 134
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param      string $plugin_name The name of the plugin.
49 49
 	 * @param      string $version     The version of this plugin.
50 50
 	 */
51
-	public function __construct( $plugin_name, $version ) {
51
+	public function __construct($plugin_name, $version) {
52 52
 
53 53
 		$this->plugin_name = $plugin_name;
54 54
 		$this->version     = $version;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * class.
75 75
 		 */
76 76
 
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
77
+		wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-public.css', array(), $this->version, 'all');
78 78
 
79 79
 	}
80 80
 
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Prepare a settings array for client-side functions.
101 101
 		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
102
+			'ajaxUrl' => admin_url('admin-ajax.php'),
103 103
 		);
104 104
 
105 105
 		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
106
+		if (is_singular()) {
107 107
 			$settings['postId'] = get_the_ID();
108 108
 		}
109 109
 
110 110
 		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
111
+		if (is_home() || is_front_page()) {
112 112
 			$settings['isHome'] = true;
113 113
 		}
114 114
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		// `page`, `post` and `entity` by default) and on the home page.
117 117
 		//
118 118
 		// @see https://github.com/insideout10/wordlift-plugin/issues/733
119
-		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
119
+		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type(get_post_type());
120 120
 
121 121
 		// Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122 122
 		// be loaded.
123 123
 		//
124 124
 		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
125
+		$settings['jsonld_enabled'] = apply_filters('wl_jsonld_enabled', $jsonld_enabled);
126 126
 
127 127
 		// Note that we switched the js to be loaded in footer, since it is loading
128 128
 		// the json-ld representation.
129
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
129
+		wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wordlift-public.js', array('jquery'), $this->version, true);
130
+		wp_localize_script($this->plugin_name, 'wlSettings', $settings);
131 131
 
132 132
 	}
133 133
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +548 added lines, -548 removed lines patch added patch discarded remove patch
@@ -7,467 +7,467 @@  discard block
 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 The Log service.
16
-	 */
17
-	private $log;
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 {@link Wordlift_Relation_Service} instance.
30
-	 *
31
-	 * @since  3.15.0
32
-	 * @access private
33
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
-	 */
35
-	private $relation_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
39
-	 *
40
-	 * @since  3.16.3
41
-	 * @access private
42
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
-	 */
44
-	private $entity_uri_service;
45
-
46
-	/**
47
-	 * The entity post type name.
48
-	 *
49
-	 * @since 3.1.0
50
-	 */
51
-	const TYPE_NAME = 'entity';
52
-
53
-	/**
54
-	 * The alternative label meta key.
55
-	 *
56
-	 * @since 3.2.0
57
-	 */
58
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
59
-
60
-	/**
61
-	 * The alternative label input template.
62
-	 *
63
-	 * @since 3.2.0
64
-	 */
65
-	// TODO: this should be moved to a class that deals with HTML code.
66
-	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 The Log service.
16
+     */
17
+    private $log;
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 {@link Wordlift_Relation_Service} instance.
30
+     *
31
+     * @since  3.15.0
32
+     * @access private
33
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
+     */
35
+    private $relation_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Entity_Uri_Service} instance.
39
+     *
40
+     * @since  3.16.3
41
+     * @access private
42
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
+     */
44
+    private $entity_uri_service;
45
+
46
+    /**
47
+     * The entity post type name.
48
+     *
49
+     * @since 3.1.0
50
+     */
51
+    const TYPE_NAME = 'entity';
52
+
53
+    /**
54
+     * The alternative label meta key.
55
+     *
56
+     * @since 3.2.0
57
+     */
58
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
59
+
60
+    /**
61
+     * The alternative label input template.
62
+     *
63
+     * @since 3.2.0
64
+     */
65
+    // TODO: this should be moved to a class that deals with HTML code.
66
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
67 67
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
68 68
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
69 69
                 <button class="button wl-delete-button">%s</button>
70 70
                 </div>';
71 71
 
72
-	/**
73
-	 * A singleton instance of the Entity service.
74
-	 *
75
-	 * @since  3.2.0
76
-	 * @access private
77
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
78
-	 */
79
-	private static $instance;
80
-
81
-	/**
82
-	 * Create a Wordlift_Entity_Service instance.
83
-	 *
84
-	 * @since 3.2.0
85
-	 *
86
-	 * @param \Wordlift_UI_Service         $ui_service         The UI service.
87
-	 * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89
-	 */
90
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
91
-
92
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
93
-
94
-		$this->ui_service         = $ui_service;
95
-		$this->relation_service   = $relation_service;
96
-		$this->entity_uri_service = $entity_uri_service;
97
-
98
-		// Set the singleton instance.
99
-		self::$instance = $this;
100
-	}
101
-
102
-	/**
103
-	 * Get the singleton instance of the Entity service.
104
-	 *
105
-	 * @since 3.2.0
106
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
107
-	 */
108
-	public static function get_instance() {
109
-
110
-		return self::$instance;
111
-	}
112
-
113
-	/**
114
-	 * Determines whether a post is an entity or not. Entity is in this context
115
-	 * something which is not an article.
116
-	 *
117
-	 * @since 3.1.0
118
-	 *
119
-	 * @param int $post_id A post id.
120
-	 *
121
-	 * @return bool Return true if the post is an entity otherwise false.
122
-	 */
123
-	public function is_entity( $post_id ) {
124
-
125
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
126
-
127
-		if ( is_wp_error( $terms ) ) {
128
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
129
-
130
-			return false;
131
-		}
132
-
133
-		if ( 0 === count( $terms ) ) {
134
-			return false;
135
-		}
136
-
137
-		// We don't consider an `article` to be an entity.
138
-		if ( 'article' !== $terms[0]->slug ) {
139
-			return true;
140
-		}
141
-
142
-		return false;
143
-	}
144
-
145
-	/**
146
-	 * Get the proper classification scope for a given entity post
147
-	 *
148
-	 * @since 3.5.0
149
-	 *
150
-	 * @param integer $post_id An entity post id.
151
-	 *
152
-	 * @param string  $default The default classification scope, `what` if not
153
-	 *                         provided.
154
-	 *
155
-	 * @return string Returns a classification scope (e.g. 'what').
156
-	 */
157
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
158
-
159
-		if ( false === $this->is_entity( $post_id ) ) {
160
-			return $default;
161
-		}
162
-
163
-		// Retrieve the entity type
164
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
166
-		// Retrieve classification boxes configuration
167
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
-		foreach ( $classification_boxes as $cb ) {
169
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
170
-				return $cb['id'];
171
-			}
172
-		}
173
-
174
-		return $default;
175
-	}
176
-
177
-	/**
178
-	 * Check whether a {@link WP_Post} is used.
179
-	 *
180
-	 * @param int $post_id The {@link WP_Post}'s id.
181
-	 *
182
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
183
-	 */
184
-	public function is_used( $post_id ) {
185
-
186
-		if ( false === $this->is_entity( $post_id ) ) {
187
-			return null;
188
-		}
189
-		// Retrieve the post
190
-		$entity = get_post( $post_id );
191
-
192
-		global $wpdb;
193
-		// Retrieve Wordlift relation instances table name
194
-		$table_name = wl_core_get_relation_instances_table_name();
195
-
196
-		// Check is it's referenced / related to another post / entity
197
-		$stmt = $wpdb->prepare(
198
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
199
-			$entity->ID
200
-		);
201
-
202
-		// Perform the query
203
-		$relation_instances = (int) $wpdb->get_var( $stmt );
204
-		// If there is at least one relation instance for the current entity, then it's used
205
-		if ( 0 < $relation_instances ) {
206
-			return true;
207
-		}
208
-
209
-		// Check if the entity uri is used as meta_value
210
-		$stmt = $wpdb->prepare(
211
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212
-			$entity->ID,
213
-			wl_get_entity_uri( $entity->ID )
214
-		);
215
-		// Perform the query
216
-		$meta_instances = (int) $wpdb->get_var( $stmt );
217
-
218
-		// If there is at least one meta that refers the current entity uri, then current entity is used
219
-		if ( 0 < $meta_instances ) {
220
-			return true;
221
-		}
222
-
223
-		// If we are here, it means the current entity is not used at the moment
224
-		return false;
225
-	}
226
-
227
-	/**
228
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
229
-	 *
230
-	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
231
-	 * @since      3.2.0
232
-	 *
233
-	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
234
-	 *
235
-	 * @param string $uri The entity URI.
236
-	 *
237
-	 * @return WP_Post|null A WP_Post instance or null if not found.
238
-	 */
239
-	public function get_entity_post_by_uri( $uri ) {
240
-
241
-		return $this->entity_uri_service->get_entity( $uri );
242
-	}
243
-
244
-	/**
245
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
246
-	 * we check that the post we're saving is the current post.
247
-	 *
248
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
249
-	 *
250
-	 * @since 3.2.0
251
-	 *
252
-	 * @param int     $post_id Post ID.
253
-	 * @param WP_Post $post    Post object.
254
-	 * @param bool    $update  Whether this is an existing post being updated or not.
255
-	 */
256
-	public function save_post( $post_id, $post, $update ) {
257
-
258
-		// Avoid doing anything if post is autosave or a revision.
259
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
260
-			return;
261
-		}
262
-
263
-		// We're setting the alternative label that have been provided via the UI
264
-		// (in fact we're using $_REQUEST), while save_post may be also called
265
-		// programmatically by some other function: we need to check therefore if
266
-		// the $post_id in the save_post call matches the post id set in the request.
267
-		//
268
-		// If this is not the current post being saved or if it's not an entity, return.
269
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
270
-			return;
271
-		}
272
-
273
-		// Get the alt labels from the request (or empty array).
274
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
275
-
276
-		// Set the alternative labels.
277
-		$this->set_alternative_labels( $post_id, $alt_labels );
278
-
279
-	}
280
-
281
-	/**
282
-	 * Set the alternative labels.
283
-	 *
284
-	 * @since 3.2.0
285
-	 *
286
-	 * @param int   $post_id    The post id.
287
-	 * @param array $alt_labels An array of labels.
288
-	 */
289
-	public function set_alternative_labels( $post_id, $alt_labels ) {
290
-
291
-		// Force $alt_labels to be an array
292
-		if ( ! is_array( $alt_labels ) ) {
293
-			$alt_labels = array( $alt_labels );
294
-		}
295
-
296
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
297
-
298
-		// Delete all the existing alternate labels.
299
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
300
-
301
-		// Set the alternative labels.
302
-		foreach ( $alt_labels as $alt_label ) {
303
-			if ( ! empty( $alt_label ) ) {
304
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
305
-			}
306
-		}
307
-
308
-	}
309
-
310
-	/**
311
-	 * Retrieve the alternate labels.
312
-	 *
313
-	 * @since 3.2.0
314
-	 *
315
-	 * @param int $post_id Post id.
316
-	 *
317
-	 * @return mixed An array  of alternative labels.
318
-	 */
319
-	public function get_alternative_labels( $post_id ) {
320
-
321
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
322
-	}
323
-
324
-	/**
325
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
326
-	 *
327
-	 * @since 3.12.0
328
-	 *
329
-	 * @param int $post_id The entity {@link WP_Post} id.
330
-	 *
331
-	 * @return array An array with the entity title and labels.
332
-	 */
333
-	public function get_labels( $post_id ) {
334
-
335
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
336
-	}
337
-
338
-	/**
339
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
340
-	 *
341
-	 * @since 3.2.0
342
-	 *
343
-	 * @param WP_Post $post Post object.
344
-	 */
345
-	public function edit_form_before_permalink( $post ) {
346
-
347
-		// If it's not an entity, return.
348
-		if ( ! $this->is_entity( $post->ID ) ) {
349
-			return;
350
-		}
351
-
352
-		// Print the input template.
353
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
354
-
355
-		// Print all the currently set alternative labels.
356
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
357
-
358
-			echo $this->get_alternative_label_input( $alt_label );
359
-
360
-		};
361
-
362
-		// Print the button.
363
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
364
-
365
-	}
366
-
367
-	/**
368
-	 * Get the URI for the entity with the specified post id.
369
-	 *
370
-	 * @since 3.6.0
371
-	 *
372
-	 * @param int $post_id The entity post id.
373
-	 *
374
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375
-	 */
376
-	public function get_uri( $post_id ) {
377
-
378
-		// If a null is given, nothing to do
379
-		if ( null == $post_id ) {
380
-			return null;
381
-		}
382
-
383
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
384
-
385
-		// If the dataset uri is not properly configured, null is returned
386
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
387
-			return null;
388
-		}
389
-
390
-		// Set the URI if it isn't set yet.
391
-		$post_status = get_post_status( $post_id );
392
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
-			$uri = wl_build_entity_uri( $post_id );
394
-			wl_set_entity_uri( $post_id, $uri );
395
-		}
396
-
397
-		return $uri;
398
-	}
399
-
400
-
401
-	/**
402
-	 * Get the alternative label input HTML code.
403
-	 *
404
-	 * @since 3.2.0
405
-	 *
406
-	 * @param string $value The input value.
407
-	 *
408
-	 * @return string The input HTML code.
409
-	 */
410
-	private function get_alternative_label_input( $value = '' ) {
411
-
412
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
413
-	}
414
-
415
-	/**
416
-	 * Get the number of entity posts published in this blog.
417
-	 *
418
-	 * @since 3.6.0
419
-	 *
420
-	 * @return int The number of published entity posts.
421
-	 */
422
-	public function count() {
423
-
424
-		$posts = get_posts( $this->add_criterias( array(
425
-			'post_status' => 'any',
426
-			'numberposts' => - 1,
427
-		) ) );
428
-
429
-		return count( $posts );
430
-	}
431
-
432
-	/**
433
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
434
-	 * call.
435
-	 *
436
-	 * @since 3.15.0
437
-	 *
438
-	 * @param array $args The arguments for a `get_posts` call.
439
-	 *
440
-	 * @return array The arguments for a `get_posts` call.
441
-	 */
442
-	public static function add_criterias( $args ) {
443
-
444
-		// Build an optimal tax-query.
445
-		$tax_query = array(
446
-			'relation' => 'AND',
447
-			array(
448
-				'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
-				'operator' => 'EXISTS',
450
-			),
451
-			array(
452
-				'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
453
-				'field'    => 'slug',
454
-				'terms'    => 'article',
455
-				'operator' => 'NOT IN',
456
-			),
457
-		);
458
-
459
-		return $args + array(
460
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
461
-				// Since 3.17.0: should this be faster?
462
-				'tax_query' => $tax_query,
463
-				//				'tax_query' => array(
464
-				//					array(
465
-				//						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
466
-				//						'terms'    => self::get_entity_terms(),
467
-				//					),
468
-				//				),
469
-			);
470
-	}
72
+    /**
73
+     * A singleton instance of the Entity service.
74
+     *
75
+     * @since  3.2.0
76
+     * @access private
77
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
78
+     */
79
+    private static $instance;
80
+
81
+    /**
82
+     * Create a Wordlift_Entity_Service instance.
83
+     *
84
+     * @since 3.2.0
85
+     *
86
+     * @param \Wordlift_UI_Service         $ui_service         The UI service.
87
+     * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89
+     */
90
+    public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
91
+
92
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
93
+
94
+        $this->ui_service         = $ui_service;
95
+        $this->relation_service   = $relation_service;
96
+        $this->entity_uri_service = $entity_uri_service;
97
+
98
+        // Set the singleton instance.
99
+        self::$instance = $this;
100
+    }
101
+
102
+    /**
103
+     * Get the singleton instance of the Entity service.
104
+     *
105
+     * @since 3.2.0
106
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
107
+     */
108
+    public static function get_instance() {
109
+
110
+        return self::$instance;
111
+    }
112
+
113
+    /**
114
+     * Determines whether a post is an entity or not. Entity is in this context
115
+     * something which is not an article.
116
+     *
117
+     * @since 3.1.0
118
+     *
119
+     * @param int $post_id A post id.
120
+     *
121
+     * @return bool Return true if the post is an entity otherwise false.
122
+     */
123
+    public function is_entity( $post_id ) {
124
+
125
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
126
+
127
+        if ( is_wp_error( $terms ) ) {
128
+            $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
129
+
130
+            return false;
131
+        }
132
+
133
+        if ( 0 === count( $terms ) ) {
134
+            return false;
135
+        }
136
+
137
+        // We don't consider an `article` to be an entity.
138
+        if ( 'article' !== $terms[0]->slug ) {
139
+            return true;
140
+        }
141
+
142
+        return false;
143
+    }
144
+
145
+    /**
146
+     * Get the proper classification scope for a given entity post
147
+     *
148
+     * @since 3.5.0
149
+     *
150
+     * @param integer $post_id An entity post id.
151
+     *
152
+     * @param string  $default The default classification scope, `what` if not
153
+     *                         provided.
154
+     *
155
+     * @return string Returns a classification scope (e.g. 'what').
156
+     */
157
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
158
+
159
+        if ( false === $this->is_entity( $post_id ) ) {
160
+            return $default;
161
+        }
162
+
163
+        // Retrieve the entity type
164
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
166
+        // Retrieve classification boxes configuration
167
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
+        foreach ( $classification_boxes as $cb ) {
169
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
170
+                return $cb['id'];
171
+            }
172
+        }
173
+
174
+        return $default;
175
+    }
176
+
177
+    /**
178
+     * Check whether a {@link WP_Post} is used.
179
+     *
180
+     * @param int $post_id The {@link WP_Post}'s id.
181
+     *
182
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
183
+     */
184
+    public function is_used( $post_id ) {
185
+
186
+        if ( false === $this->is_entity( $post_id ) ) {
187
+            return null;
188
+        }
189
+        // Retrieve the post
190
+        $entity = get_post( $post_id );
191
+
192
+        global $wpdb;
193
+        // Retrieve Wordlift relation instances table name
194
+        $table_name = wl_core_get_relation_instances_table_name();
195
+
196
+        // Check is it's referenced / related to another post / entity
197
+        $stmt = $wpdb->prepare(
198
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
199
+            $entity->ID
200
+        );
201
+
202
+        // Perform the query
203
+        $relation_instances = (int) $wpdb->get_var( $stmt );
204
+        // If there is at least one relation instance for the current entity, then it's used
205
+        if ( 0 < $relation_instances ) {
206
+            return true;
207
+        }
208
+
209
+        // Check if the entity uri is used as meta_value
210
+        $stmt = $wpdb->prepare(
211
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212
+            $entity->ID,
213
+            wl_get_entity_uri( $entity->ID )
214
+        );
215
+        // Perform the query
216
+        $meta_instances = (int) $wpdb->get_var( $stmt );
217
+
218
+        // If there is at least one meta that refers the current entity uri, then current entity is used
219
+        if ( 0 < $meta_instances ) {
220
+            return true;
221
+        }
222
+
223
+        // If we are here, it means the current entity is not used at the moment
224
+        return false;
225
+    }
226
+
227
+    /**
228
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
229
+     *
230
+     * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
231
+     * @since      3.2.0
232
+     *
233
+     * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
234
+     *
235
+     * @param string $uri The entity URI.
236
+     *
237
+     * @return WP_Post|null A WP_Post instance or null if not found.
238
+     */
239
+    public function get_entity_post_by_uri( $uri ) {
240
+
241
+        return $this->entity_uri_service->get_entity( $uri );
242
+    }
243
+
244
+    /**
245
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
246
+     * we check that the post we're saving is the current post.
247
+     *
248
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
249
+     *
250
+     * @since 3.2.0
251
+     *
252
+     * @param int     $post_id Post ID.
253
+     * @param WP_Post $post    Post object.
254
+     * @param bool    $update  Whether this is an existing post being updated or not.
255
+     */
256
+    public function save_post( $post_id, $post, $update ) {
257
+
258
+        // Avoid doing anything if post is autosave or a revision.
259
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
260
+            return;
261
+        }
262
+
263
+        // We're setting the alternative label that have been provided via the UI
264
+        // (in fact we're using $_REQUEST), while save_post may be also called
265
+        // programmatically by some other function: we need to check therefore if
266
+        // the $post_id in the save_post call matches the post id set in the request.
267
+        //
268
+        // If this is not the current post being saved or if it's not an entity, return.
269
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
270
+            return;
271
+        }
272
+
273
+        // Get the alt labels from the request (or empty array).
274
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
275
+
276
+        // Set the alternative labels.
277
+        $this->set_alternative_labels( $post_id, $alt_labels );
278
+
279
+    }
280
+
281
+    /**
282
+     * Set the alternative labels.
283
+     *
284
+     * @since 3.2.0
285
+     *
286
+     * @param int   $post_id    The post id.
287
+     * @param array $alt_labels An array of labels.
288
+     */
289
+    public function set_alternative_labels( $post_id, $alt_labels ) {
290
+
291
+        // Force $alt_labels to be an array
292
+        if ( ! is_array( $alt_labels ) ) {
293
+            $alt_labels = array( $alt_labels );
294
+        }
295
+
296
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
297
+
298
+        // Delete all the existing alternate labels.
299
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
300
+
301
+        // Set the alternative labels.
302
+        foreach ( $alt_labels as $alt_label ) {
303
+            if ( ! empty( $alt_label ) ) {
304
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
305
+            }
306
+        }
307
+
308
+    }
309
+
310
+    /**
311
+     * Retrieve the alternate labels.
312
+     *
313
+     * @since 3.2.0
314
+     *
315
+     * @param int $post_id Post id.
316
+     *
317
+     * @return mixed An array  of alternative labels.
318
+     */
319
+    public function get_alternative_labels( $post_id ) {
320
+
321
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
322
+    }
323
+
324
+    /**
325
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
326
+     *
327
+     * @since 3.12.0
328
+     *
329
+     * @param int $post_id The entity {@link WP_Post} id.
330
+     *
331
+     * @return array An array with the entity title and labels.
332
+     */
333
+    public function get_labels( $post_id ) {
334
+
335
+        return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
336
+    }
337
+
338
+    /**
339
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
340
+     *
341
+     * @since 3.2.0
342
+     *
343
+     * @param WP_Post $post Post object.
344
+     */
345
+    public function edit_form_before_permalink( $post ) {
346
+
347
+        // If it's not an entity, return.
348
+        if ( ! $this->is_entity( $post->ID ) ) {
349
+            return;
350
+        }
351
+
352
+        // Print the input template.
353
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
354
+
355
+        // Print all the currently set alternative labels.
356
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
357
+
358
+            echo $this->get_alternative_label_input( $alt_label );
359
+
360
+        };
361
+
362
+        // Print the button.
363
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
364
+
365
+    }
366
+
367
+    /**
368
+     * Get the URI for the entity with the specified post id.
369
+     *
370
+     * @since 3.6.0
371
+     *
372
+     * @param int $post_id The entity post id.
373
+     *
374
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375
+     */
376
+    public function get_uri( $post_id ) {
377
+
378
+        // If a null is given, nothing to do
379
+        if ( null == $post_id ) {
380
+            return null;
381
+        }
382
+
383
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
384
+
385
+        // If the dataset uri is not properly configured, null is returned
386
+        if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
387
+            return null;
388
+        }
389
+
390
+        // Set the URI if it isn't set yet.
391
+        $post_status = get_post_status( $post_id );
392
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
+            $uri = wl_build_entity_uri( $post_id );
394
+            wl_set_entity_uri( $post_id, $uri );
395
+        }
396
+
397
+        return $uri;
398
+    }
399
+
400
+
401
+    /**
402
+     * Get the alternative label input HTML code.
403
+     *
404
+     * @since 3.2.0
405
+     *
406
+     * @param string $value The input value.
407
+     *
408
+     * @return string The input HTML code.
409
+     */
410
+    private function get_alternative_label_input( $value = '' ) {
411
+
412
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
413
+    }
414
+
415
+    /**
416
+     * Get the number of entity posts published in this blog.
417
+     *
418
+     * @since 3.6.0
419
+     *
420
+     * @return int The number of published entity posts.
421
+     */
422
+    public function count() {
423
+
424
+        $posts = get_posts( $this->add_criterias( array(
425
+            'post_status' => 'any',
426
+            'numberposts' => - 1,
427
+        ) ) );
428
+
429
+        return count( $posts );
430
+    }
431
+
432
+    /**
433
+     * Add the entity filtering criterias to the arguments for a `get_posts`
434
+     * call.
435
+     *
436
+     * @since 3.15.0
437
+     *
438
+     * @param array $args The arguments for a `get_posts` call.
439
+     *
440
+     * @return array The arguments for a `get_posts` call.
441
+     */
442
+    public static function add_criterias( $args ) {
443
+
444
+        // Build an optimal tax-query.
445
+        $tax_query = array(
446
+            'relation' => 'AND',
447
+            array(
448
+                'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
+                'operator' => 'EXISTS',
450
+            ),
451
+            array(
452
+                'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
453
+                'field'    => 'slug',
454
+                'terms'    => 'article',
455
+                'operator' => 'NOT IN',
456
+            ),
457
+        );
458
+
459
+        return $args + array(
460
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
461
+                // Since 3.17.0: should this be faster?
462
+                'tax_query' => $tax_query,
463
+                //				'tax_query' => array(
464
+                //					array(
465
+                //						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
466
+                //						'terms'    => self::get_entity_terms(),
467
+                //					),
468
+                //				),
469
+            );
470
+    }
471 471
 
472 472
 //	/**
473 473
 //	 * Get the entity terms IDs which represent an entity.
@@ -497,97 +497,97 @@  discard block
 block discarded – undo
497 497
 //		} ) );
498 498
 //	}
499 499
 
500
-	/**
501
-	 * Create a new entity.
502
-	 *
503
-	 * @since 3.9.0
504
-	 *
505
-	 * @param string $name     The entity name.
506
-	 * @param string $type_uri The entity's type URI.
507
-	 * @param null   $logo     The entity logo id (or NULL if none).
508
-	 * @param string $status   The post status, by default 'publish'.
509
-	 *
510
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511
-	 */
512
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
513
-
514
-		// Create an entity for the publisher.
515
-		$post_id = wp_insert_post( array(
516
-			'post_type'    => self::TYPE_NAME,
517
-			'post_title'   => $name,
518
-			'post_status'  => $status,
519
-			'post_content' => '',
520
-		) );
521
-
522
-		// Return the error if any.
523
-		if ( is_wp_error( $post_id ) ) {
524
-			return $post_id;
525
-		}
526
-
527
-		// Set the entity logo.
528
-		if ( $logo && is_numeric( $logo ) ) {
529
-			set_post_thumbnail( $post_id, $logo );
530
-		}
531
-
532
-		// Set the entity type.
533
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
534
-
535
-		return $post_id;
536
-	}
537
-
538
-	/**
539
-	 * Get the entities related to the one with the specified id. By default only
540
-	 * published entities will be returned.
541
-	 *
542
-	 * @since 3.10.0
543
-	 *
544
-	 * @param int    $id          The post id.
545
-	 * @param string $post_status The target post status (default = publish).
546
-	 *
547
-	 * @return array An array of post ids.
548
-	 */
549
-	public function get_related_entities( $id, $post_status = 'publish' ) {
550
-
551
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
552
-	}
553
-
554
-	/**
555
-	 * Get the list of entities.
556
-	 *
557
-	 * @since 3.12.2
558
-	 *
559
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
560
-	 *
561
-	 * @return array An array of entity posts.
562
-	 */
563
-	public function get( $params = array() ) {
564
-
565
-		// Set the defaults.
566
-		$defaults = array( 'post_type' => 'entity' );
567
-
568
-		// Merge the defaults with the provided parameters.
569
-		$args = wp_parse_args( $params, $defaults );
570
-
571
-		// Call the `get_posts` function.
572
-		return get_posts( $args );
573
-	}
574
-
575
-	/**
576
-	 * The list of post type names which can be used for entities
577
-	 *
578
-	 * Criteria is that the post type is public. The list of valid post types
579
-	 * can be overridden with a filter.
580
-	 *
581
-	 * @since 3.15.0
582
-	 *
583
-	 * @return array Array containing the names of the valid post types.
584
-	 */
585
-	static function valid_entity_post_types() {
586
-
587
-		// Ignore builtins in the call to avoid getting attachments.
588
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
589
-
590
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
591
-	}
500
+    /**
501
+     * Create a new entity.
502
+     *
503
+     * @since 3.9.0
504
+     *
505
+     * @param string $name     The entity name.
506
+     * @param string $type_uri The entity's type URI.
507
+     * @param null   $logo     The entity logo id (or NULL if none).
508
+     * @param string $status   The post status, by default 'publish'.
509
+     *
510
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511
+     */
512
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
513
+
514
+        // Create an entity for the publisher.
515
+        $post_id = wp_insert_post( array(
516
+            'post_type'    => self::TYPE_NAME,
517
+            'post_title'   => $name,
518
+            'post_status'  => $status,
519
+            'post_content' => '',
520
+        ) );
521
+
522
+        // Return the error if any.
523
+        if ( is_wp_error( $post_id ) ) {
524
+            return $post_id;
525
+        }
526
+
527
+        // Set the entity logo.
528
+        if ( $logo && is_numeric( $logo ) ) {
529
+            set_post_thumbnail( $post_id, $logo );
530
+        }
531
+
532
+        // Set the entity type.
533
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
534
+
535
+        return $post_id;
536
+    }
537
+
538
+    /**
539
+     * Get the entities related to the one with the specified id. By default only
540
+     * published entities will be returned.
541
+     *
542
+     * @since 3.10.0
543
+     *
544
+     * @param int    $id          The post id.
545
+     * @param string $post_status The target post status (default = publish).
546
+     *
547
+     * @return array An array of post ids.
548
+     */
549
+    public function get_related_entities( $id, $post_status = 'publish' ) {
550
+
551
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
552
+    }
553
+
554
+    /**
555
+     * Get the list of entities.
556
+     *
557
+     * @since 3.12.2
558
+     *
559
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
560
+     *
561
+     * @return array An array of entity posts.
562
+     */
563
+    public function get( $params = array() ) {
564
+
565
+        // Set the defaults.
566
+        $defaults = array( 'post_type' => 'entity' );
567
+
568
+        // Merge the defaults with the provided parameters.
569
+        $args = wp_parse_args( $params, $defaults );
570
+
571
+        // Call the `get_posts` function.
572
+        return get_posts( $args );
573
+    }
574
+
575
+    /**
576
+     * The list of post type names which can be used for entities
577
+     *
578
+     * Criteria is that the post type is public. The list of valid post types
579
+     * can be overridden with a filter.
580
+     *
581
+     * @since 3.15.0
582
+     *
583
+     * @return array Array containing the names of the valid post types.
584
+     */
585
+    static function valid_entity_post_types() {
586
+
587
+        // Ignore builtins in the call to avoid getting attachments.
588
+        $post_types = array( 'post', 'page', self::TYPE_NAME );
589
+
590
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
591
+    }
592 592
 
593 593
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88 88
 	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89 89
 	 */
90
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
90
+	public function __construct($ui_service, $relation_service, $entity_uri_service) {
91 91
 
92
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
92
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
93 93
 
94 94
 		$this->ui_service         = $ui_service;
95 95
 		$this->relation_service   = $relation_service;
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return bool Return true if the post is an entity otherwise false.
122 122
 	 */
123
-	public function is_entity( $post_id ) {
123
+	public function is_entity($post_id) {
124 124
 
125
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
125
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
126 126
 
127
-		if ( is_wp_error( $terms ) ) {
128
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
127
+		if (is_wp_error($terms)) {
128
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
129 129
 
130 130
 			return false;
131 131
 		}
132 132
 
133
-		if ( 0 === count( $terms ) ) {
133
+		if (0 === count($terms)) {
134 134
 			return false;
135 135
 		}
136 136
 
137 137
 		// We don't consider an `article` to be an entity.
138
-		if ( 'article' !== $terms[0]->slug ) {
138
+		if ('article' !== $terms[0]->slug) {
139 139
 			return true;
140 140
 		}
141 141
 
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return string Returns a classification scope (e.g. 'what').
156 156
 	 */
157
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
157
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
158 158
 
159
-		if ( false === $this->is_entity( $post_id ) ) {
159
+		if (false === $this->is_entity($post_id)) {
160 160
 			return $default;
161 161
 		}
162 162
 
163 163
 		// Retrieve the entity type
164
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
164
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
165
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
166 166
 		// Retrieve classification boxes configuration
167
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
-		foreach ( $classification_boxes as $cb ) {
169
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
167
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
168
+		foreach ($classification_boxes as $cb) {
169
+			if (in_array($entity_type, $cb['registeredTypes'])) {
170 170
 				return $cb['id'];
171 171
 			}
172 172
 		}
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
183 183
 	 */
184
-	public function is_used( $post_id ) {
184
+	public function is_used($post_id) {
185 185
 
186
-		if ( false === $this->is_entity( $post_id ) ) {
186
+		if (false === $this->is_entity($post_id)) {
187 187
 			return null;
188 188
 		}
189 189
 		// Retrieve the post
190
-		$entity = get_post( $post_id );
190
+		$entity = get_post($post_id);
191 191
 
192 192
 		global $wpdb;
193 193
 		// Retrieve Wordlift relation instances table name
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 		);
201 201
 
202 202
 		// Perform the query
203
-		$relation_instances = (int) $wpdb->get_var( $stmt );
203
+		$relation_instances = (int) $wpdb->get_var($stmt);
204 204
 		// If there is at least one relation instance for the current entity, then it's used
205
-		if ( 0 < $relation_instances ) {
205
+		if (0 < $relation_instances) {
206 206
 			return true;
207 207
 		}
208 208
 
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 		$stmt = $wpdb->prepare(
211 211
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212 212
 			$entity->ID,
213
-			wl_get_entity_uri( $entity->ID )
213
+			wl_get_entity_uri($entity->ID)
214 214
 		);
215 215
 		// Perform the query
216
-		$meta_instances = (int) $wpdb->get_var( $stmt );
216
+		$meta_instances = (int) $wpdb->get_var($stmt);
217 217
 
218 218
 		// If there is at least one meta that refers the current entity uri, then current entity is used
219
-		if ( 0 < $meta_instances ) {
219
+		if (0 < $meta_instances) {
220 220
 			return true;
221 221
 		}
222 222
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return WP_Post|null A WP_Post instance or null if not found.
238 238
 	 */
239
-	public function get_entity_post_by_uri( $uri ) {
239
+	public function get_entity_post_by_uri($uri) {
240 240
 
241
-		return $this->entity_uri_service->get_entity( $uri );
241
+		return $this->entity_uri_service->get_entity($uri);
242 242
 	}
243 243
 
244 244
 	/**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 * @param WP_Post $post    Post object.
254 254
 	 * @param bool    $update  Whether this is an existing post being updated or not.
255 255
 	 */
256
-	public function save_post( $post_id, $post, $update ) {
256
+	public function save_post($post_id, $post, $update) {
257 257
 
258 258
 		// Avoid doing anything if post is autosave or a revision.
259
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
259
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
260 260
 			return;
261 261
 		}
262 262
 
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 		// the $post_id in the save_post call matches the post id set in the request.
267 267
 		//
268 268
 		// If this is not the current post being saved or if it's not an entity, return.
269
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
269
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
270 270
 			return;
271 271
 		}
272 272
 
273 273
 		// Get the alt labels from the request (or empty array).
274
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
274
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array();
275 275
 
276 276
 		// Set the alternative labels.
277
-		$this->set_alternative_labels( $post_id, $alt_labels );
277
+		$this->set_alternative_labels($post_id, $alt_labels);
278 278
 
279 279
 	}
280 280
 
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
 	 * @param int   $post_id    The post id.
287 287
 	 * @param array $alt_labels An array of labels.
288 288
 	 */
289
-	public function set_alternative_labels( $post_id, $alt_labels ) {
289
+	public function set_alternative_labels($post_id, $alt_labels) {
290 290
 
291 291
 		// Force $alt_labels to be an array
292
-		if ( ! is_array( $alt_labels ) ) {
293
-			$alt_labels = array( $alt_labels );
292
+		if ( ! is_array($alt_labels)) {
293
+			$alt_labels = array($alt_labels);
294 294
 		}
295 295
 
296
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
296
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
297 297
 
298 298
 		// Delete all the existing alternate labels.
299
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
299
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
300 300
 
301 301
 		// Set the alternative labels.
302
-		foreach ( $alt_labels as $alt_label ) {
303
-			if ( ! empty( $alt_label ) ) {
304
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
302
+		foreach ($alt_labels as $alt_label) {
303
+			if ( ! empty($alt_label)) {
304
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label);
305 305
 			}
306 306
 		}
307 307
 
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return mixed An array  of alternative labels.
318 318
 	 */
319
-	public function get_alternative_labels( $post_id ) {
319
+	public function get_alternative_labels($post_id) {
320 320
 
321
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
321
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
322 322
 	}
323 323
 
324 324
 	/**
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return array An array with the entity title and labels.
332 332
 	 */
333
-	public function get_labels( $post_id ) {
333
+	public function get_labels($post_id) {
334 334
 
335
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
335
+		return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @param WP_Post $post Post object.
344 344
 	 */
345
-	public function edit_form_before_permalink( $post ) {
345
+	public function edit_form_before_permalink($post) {
346 346
 
347 347
 		// If it's not an entity, return.
348
-		if ( ! $this->is_entity( $post->ID ) ) {
348
+		if ( ! $this->is_entity($post->ID)) {
349 349
 			return;
350 350
 		}
351 351
 
352 352
 		// Print the input template.
353
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
353
+		$this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
354 354
 
355 355
 		// Print all the currently set alternative labels.
356
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
356
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
357 357
 
358
-			echo $this->get_alternative_label_input( $alt_label );
358
+			echo $this->get_alternative_label_input($alt_label);
359 359
 
360 360
 		};
361 361
 
362 362
 		// Print the button.
363
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
363
+		$this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
364 364
 
365 365
 	}
366 366
 
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375 375
 	 */
376
-	public function get_uri( $post_id ) {
376
+	public function get_uri($post_id) {
377 377
 
378 378
 		// If a null is given, nothing to do
379
-		if ( null == $post_id ) {
379
+		if (null == $post_id) {
380 380
 			return null;
381 381
 		}
382 382
 
383
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
383
+		$uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, true);
384 384
 
385 385
 		// If the dataset uri is not properly configured, null is returned
386
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
386
+		if ('' === wl_configuration_get_redlink_dataset_uri()) {
387 387
 			return null;
388 388
 		}
389 389
 
390 390
 		// Set the URI if it isn't set yet.
391
-		$post_status = get_post_status( $post_id );
392
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
-			$uri = wl_build_entity_uri( $post_id );
394
-			wl_set_entity_uri( $post_id, $uri );
391
+		$post_status = get_post_status($post_id);
392
+		if (empty($uri) && 'auto-draft' !== $post_status && 'revision' !== $post_status) {
393
+			$uri = wl_build_entity_uri($post_id);
394
+			wl_set_entity_uri($post_id, $uri);
395 395
 		}
396 396
 
397 397
 		return $uri;
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 	 *
408 408
 	 * @return string The input HTML code.
409 409
 	 */
410
-	private function get_alternative_label_input( $value = '' ) {
410
+	private function get_alternative_label_input($value = '') {
411 411
 
412
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
412
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
413 413
 	}
414 414
 
415 415
 	/**
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 */
422 422
 	public function count() {
423 423
 
424
-		$posts = get_posts( $this->add_criterias( array(
424
+		$posts = get_posts($this->add_criterias(array(
425 425
 			'post_status' => 'any',
426
-			'numberposts' => - 1,
427
-		) ) );
426
+			'numberposts' => -1,
427
+		)));
428 428
 
429
-		return count( $posts );
429
+		return count($posts);
430 430
 	}
431 431
 
432 432
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * @return array The arguments for a `get_posts` call.
441 441
 	 */
442
-	public static function add_criterias( $args ) {
442
+	public static function add_criterias($args) {
443 443
 
444 444
 		// Build an optimal tax-query.
445 445
 		$tax_query = array(
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
 	 *
510 510
 	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511 511
 	 */
512
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
512
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
513 513
 
514 514
 		// Create an entity for the publisher.
515
-		$post_id = wp_insert_post( array(
515
+		$post_id = wp_insert_post(array(
516 516
 			'post_type'    => self::TYPE_NAME,
517 517
 			'post_title'   => $name,
518 518
 			'post_status'  => $status,
519 519
 			'post_content' => '',
520
-		) );
520
+		));
521 521
 
522 522
 		// Return the error if any.
523
-		if ( is_wp_error( $post_id ) ) {
523
+		if (is_wp_error($post_id)) {
524 524
 			return $post_id;
525 525
 		}
526 526
 
527 527
 		// Set the entity logo.
528
-		if ( $logo && is_numeric( $logo ) ) {
529
-			set_post_thumbnail( $post_id, $logo );
528
+		if ($logo && is_numeric($logo)) {
529
+			set_post_thumbnail($post_id, $logo);
530 530
 		}
531 531
 
532 532
 		// Set the entity type.
533
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
533
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
534 534
 
535 535
 		return $post_id;
536 536
 	}
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 	 *
547 547
 	 * @return array An array of post ids.
548 548
 	 */
549
-	public function get_related_entities( $id, $post_status = 'publish' ) {
549
+	public function get_related_entities($id, $post_status = 'publish') {
550 550
 
551
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
551
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
552 552
 	}
553 553
 
554 554
 	/**
@@ -560,16 +560,16 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @return array An array of entity posts.
562 562
 	 */
563
-	public function get( $params = array() ) {
563
+	public function get($params = array()) {
564 564
 
565 565
 		// Set the defaults.
566
-		$defaults = array( 'post_type' => 'entity' );
566
+		$defaults = array('post_type' => 'entity');
567 567
 
568 568
 		// Merge the defaults with the provided parameters.
569
-		$args = wp_parse_args( $params, $defaults );
569
+		$args = wp_parse_args($params, $defaults);
570 570
 
571 571
 		// Call the `get_posts` function.
572
-		return get_posts( $args );
572
+		return get_posts($args);
573 573
 	}
574 574
 
575 575
 	/**
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 	static function valid_entity_post_types() {
586 586
 
587 587
 		// Ignore builtins in the call to avoid getting attachments.
588
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
588
+		$post_types = array('post', 'page', self::TYPE_NAME);
589 589
 
590
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
590
+		return apply_filters('wl_valid_entity_post_types', $post_types);
591 591
 	}
592 592
 
593 593
 }
Please login to merge, or discard this patch.
src/wordlift_constants.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 
8 8
 // Define the basic options for HTTP calls to REDLINK.
9 9
 define( 'WL_REDLINK_API_HTTP_OPTIONS', serialize( array(
10
-	'timeout'         => 300,
11
-	'redirection'     => 5,
12
-	'httpversion'     => '1.1',
13
-	'blocking'        => true,
14
-	'cookies'         => array(),
15
-	'sslverify'       => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true,
16
-	'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt',
17
-	'decompress'      => false,
10
+    'timeout'         => 300,
11
+    'redirection'     => 5,
12
+    'httpversion'     => '1.1',
13
+    'blocking'        => true,
14
+    'cookies'         => array(),
15
+    'sslverify'       => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true,
16
+    'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt',
17
+    'decompress'      => false,
18 18
 ) ) );
19 19
 
20 20
 // Create a unique ID for this request, useful to hook async HTTP requests.
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 
28 28
 function wl_is_sparql_update_queries_buffering_enabled() {
29 29
 
30
-	if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) {
31
-		return false;
32
-	}
30
+    if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) {
31
+        return false;
32
+    }
33 33
 
34
-	return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' );
34
+    return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' );
35 35
 }
36 36
 
37 37
 // Define the meta name used to store the entity URL.
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 // Use the WordLift API URL set on the command line.
44 44
 if ( false !== getenv( 'WORDLIFT_API_URL' ) && ! defined( 'WORDLIFT_API_URL' ) ) {
45
-	define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) );
45
+    define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) );
46 46
 }
47 47
 
48 48
 // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function wl_prefixes() {
65 65
 
66
-	$items    = wl_prefixes_list();
67
-	$prefixes = array();
66
+    $items    = wl_prefixes_list();
67
+    $prefixes = array();
68 68
 
69
-	foreach ( $items as $item ) {
70
-		$prefixes[ $item['prefix'] ] = $item['namespace'];
71
-	}
69
+    foreach ( $items as $item ) {
70
+        $prefixes[ $item['prefix'] ] = $item['namespace'];
71
+    }
72 72
 
73
-	return $prefixes;
73
+    return $prefixes;
74 74
 
75 75
 }
76 76
 
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
  * @return string The path to the temp directory for the specific site.
87 87
  */
88 88
 function wl_temp_dir() {
89
-	$tempdir = get_temp_dir();
90
-	$unique = md5( site_url() . get_current_blog_id() );
91
-	$unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash.
89
+    $tempdir = get_temp_dir();
90
+    $unique = md5( site_url() . get_current_blog_id() );
91
+    $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash.
92 92
 
93
-	// If directory do not exist, create it.
94
-	if ( ! file_exists( $unique_temp_dir ) ) {
95
-		mkdir( $unique_temp_dir );
96
-	}
93
+    // If directory do not exist, create it.
94
+    if ( ! file_exists( $unique_temp_dir ) ) {
95
+        mkdir( $unique_temp_dir );
96
+    }
97 97
 
98
-	return $unique_temp_dir . '/';
98
+    return $unique_temp_dir . '/';
99 99
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,54 +6,54 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Define the basic options for HTTP calls to REDLINK.
9
-define( 'WL_REDLINK_API_HTTP_OPTIONS', serialize( array(
9
+define('WL_REDLINK_API_HTTP_OPTIONS', serialize(array(
10 10
 	'timeout'         => 300,
11 11
 	'redirection'     => 5,
12 12
 	'httpversion'     => '1.1',
13 13
 	'blocking'        => true,
14 14
 	'cookies'         => array(),
15
-	'sslverify'       => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true,
16
-	'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt',
15
+	'sslverify'       => ('false' === getenv('WL_SSL_VERIFY_ENABLED')) ? false : true,
16
+	'sslcertificates' => dirname(__FILE__).'/ssl/ca-bundle.crt',
17 17
 	'decompress'      => false,
18
-) ) );
18
+)));
19 19
 
20 20
 // Create a unique ID for this request, useful to hook async HTTP requests.
21
-define( 'WL_REQUEST_ID', uniqid( true ) );
21
+define('WL_REQUEST_ID', uniqid(true));
22 22
 
23 23
 // Set the temporary files folder.
24
-defined( 'WL_TEMP_DIR' ) || define( 'WL_TEMP_DIR', wl_temp_dir() );
24
+defined('WL_TEMP_DIR') || define('WL_TEMP_DIR', wl_temp_dir());
25 25
 
26
-define( 'WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', wl_is_sparql_update_queries_buffering_enabled() );
26
+define('WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', wl_is_sparql_update_queries_buffering_enabled());
27 27
 
28 28
 function wl_is_sparql_update_queries_buffering_enabled() {
29 29
 
30
-	if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) {
30
+	if (isset($_REQUEST['wl-async']) && 'false' === $_REQUEST['wl-async']) {
31 31
 		return false;
32 32
 	}
33 33
 
34
-	return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' );
34
+	return 'true' !== getenv('WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING');
35 35
 }
36 36
 
37 37
 // Define the meta name used to store the entity URL.
38
-define( 'WL_ENTITY_URL_META_NAME', 'entity_url' );
38
+define('WL_ENTITY_URL_META_NAME', 'entity_url');
39 39
 
40 40
 // Max number of recursions when printing microdata.
41
-define( 'WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3 );
41
+define('WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3);
42 42
 
43 43
 // Use the WordLift API URL set on the command line.
44
-if ( false !== getenv( 'WORDLIFT_API_URL' ) && ! defined( 'WORDLIFT_API_URL' ) ) {
45
-	define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) );
44
+if (false !== getenv('WORDLIFT_API_URL') && ! defined('WORDLIFT_API_URL')) {
45
+	define('WORDLIFT_API_URL', getenv('WORDLIFT_API_URL'));
46 46
 }
47 47
 
48 48
 // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster
49 49
 // chunked analysis.
50
-define( 'WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined( 'WORDLIFT_API_URL' ) ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.it/' );
50
+define('WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined('WORDLIFT_API_URL') ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.it/');
51 51
 
52
-define( 'WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url=' );
52
+define('WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url=');
53 53
 
54 54
 // If is set to true, there will be additional button in 'Download Your Data' page
55 55
 // that will allow users to download their data in JSON-LD format.
56
-defined( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA' ) || define( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false );
56
+defined('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA') || define('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false);
57 57
 
58 58
 
59 59
 /**
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	$items    = wl_prefixes_list();
67 67
 	$prefixes = array();
68 68
 
69
-	foreach ( $items as $item ) {
70
-		$prefixes[ $item['prefix'] ] = $item['namespace'];
69
+	foreach ($items as $item) {
70
+		$prefixes[$item['prefix']] = $item['namespace'];
71 71
 	}
72 72
 
73 73
 	return $prefixes;
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
  */
88 88
 function wl_temp_dir() {
89 89
 	$tempdir = get_temp_dir();
90
-	$unique = md5( site_url() . get_current_blog_id() );
91
-	$unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash.
90
+	$unique = md5(site_url().get_current_blog_id());
91
+	$unique_temp_dir = $tempdir.'wl_'.$unique; // $tempdir should have a trailing slash.
92 92
 
93 93
 	// If directory do not exist, create it.
94
-	if ( ! file_exists( $unique_temp_dir ) ) {
95
-		mkdir( $unique_temp_dir );
94
+	if ( ! file_exists($unique_temp_dir)) {
95
+		mkdir($unique_temp_dir);
96 96
 	}
97 97
 
98
-	return $unique_temp_dir . '/';
98
+	return $unique_temp_dir.'/';
99 99
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-configuration-service.php 2 patches
Indentation   +477 added lines, -477 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,481 +21,481 @@  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 dataset URI option name
61
-	 *
62
-	 * @since 3.10.0
63
-	 */
64
-	const DATASET_URI = 'redlink_dataset_uri';
65
-
66
-	/**
67
-	 * The link by default option name.
68
-	 *
69
-	 * @since 3.11.0
70
-	 */
71
-	const LINK_BY_DEFAULT = 'link_by_default';
72
-
73
-	/**
74
-	 * The {@link Wordlift_Log_Service} instance.
75
-	 *
76
-	 * @since 3.16.0
77
-	 *
78
-	 * @var \Wordlift_Log_Service $log The {@link Wordlift_Log_Service} instance.
79
-	 */
80
-	private $log;
81
-
82
-	/**
83
-	 * The Wordlift_Configuration_Service's singleton instance.
84
-	 *
85
-	 * @since  3.6.0
86
-	 *
87
-	 * @access private
88
-	 * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance.
89
-	 */
90
-	private static $instance;
91
-
92
-	/**
93
-	 * Create a Wordlift_Configuration_Service's instance.
94
-	 *
95
-	 * @since 3.6.0
96
-	 */
97
-	public function __construct() {
98
-
99
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
100
-
101
-		self::$instance = $this;
102
-
103
-	}
104
-
105
-	/**
106
-	 * Get the singleton instance.
107
-	 *
108
-	 * @since 3.6.0
109
-	 *
110
-	 * @return \Wordlift_Configuration_Service
111
-	 */
112
-	public static function get_instance() {
113
-
114
-		return self::$instance;
115
-	}
116
-
117
-	/**
118
-	 * Get a configuration given the option name and a key. The option value is
119
-	 * expected to be an array.
120
-	 *
121
-	 * @since 3.6.0
122
-	 *
123
-	 * @param string $option  The option name.
124
-	 * @param string $key     A key in the option value array.
125
-	 * @param string $default The default value in case the key is not found (by default an empty string).
126
-	 *
127
-	 * @return mixed The configuration value or the default value if not found.
128
-	 */
129
-	private function get( $option, $key, $default = '' ) {
130
-
131
-		$options = get_option( $option, array() );
132
-
133
-		return isset( $options[ $key ] ) ? $options[ $key ] : $default;
134
-	}
135
-
136
-	/**
137
-	 * Set a configuration parameter.
138
-	 *
139
-	 * @since 3.9.0
140
-	 *
141
-	 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
142
-	 * @param string $key    The value key.
143
-	 * @param mixed  $value  The value.
144
-	 */
145
-	private function set( $option, $key, $value ) {
146
-
147
-		$values         = get_option( $option );
148
-		$values         = isset( $values ) ? $values : array();
149
-		$values[ $key ] = $value;
150
-		update_option( $option, $values );
151
-
152
-	}
153
-
154
-	/**
155
-	 * Get the entity base path, by default 'entity'.
156
-	 *
157
-	 * @since 3.6.0
158
-	 *
159
-	 * @return string The entity base path.
160
-	 */
161
-	public function get_entity_base_path() {
162
-
163
-		return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
164
-	}
165
-
166
-	/**
167
-	 * Get the entity base path.
168
-	 *
169
-	 * @since 3.9.0
170
-	 *
171
-	 * @param string $value The entity base path.
172
-	 */
173
-	public function set_entity_base_path( $value ) {
174
-
175
-		$this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
176
-
177
-	}
178
-
179
-	/**
180
-	 * Whether the installation skip wizard should be skipped.
181
-	 *
182
-	 * @since 3.9.0
183
-	 *
184
-	 * @return bool True if it should be skipped otherwise false.
185
-	 */
186
-	public function is_skip_wizard() {
187
-
188
-		return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false );
189
-	}
190
-
191
-	/**
192
-	 * Set the skip wizard parameter.
193
-	 *
194
-	 * @since 3.9.0
195
-	 *
196
-	 * @param bool $value True to skip the wizard. We expect a boolean value.
197
-	 */
198
-	public function set_skip_wizard( $value ) {
199
-
200
-		$this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value );
201
-
202
-	}
203
-
204
-	/**
205
-	 * Get WordLift's key.
206
-	 *
207
-	 * @since 3.9.0
208
-	 *
209
-	 * @return string WordLift's key or an empty string if not set.
210
-	 */
211
-	public function get_key() {
212
-
213
-		return $this->get( 'wl_general_settings', self::KEY, '' );
214
-	}
215
-
216
-	/**
217
-	 * Set WordLift's key.
218
-	 *
219
-	 * @since 3.9.0
220
-	 *
221
-	 * @param string $value WordLift's key.
222
-	 */
223
-	public function set_key( $value ) {
224
-
225
-		$this->set( 'wl_general_settings', self::KEY, $value );
226
-	}
227
-
228
-	/**
229
-	 * Get WordLift's configured language, by default 'en'.
230
-	 *
231
-	 * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis.
232
-	 *
233
-	 * @since 3.9.0
234
-	 *
235
-	 * @return string WordLift's configured language code ('en' by default).
236
-	 */
237
-	public function get_language_code() {
238
-
239
-		return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
240
-	}
241
-
242
-	/**
243
-	 * Set WordLift's language code, used when storing strings to the Linked Data dataset.
244
-	 *
245
-	 * @since 3.9.0
246
-	 *
247
-	 * @param string $value WordLift's language code.
248
-	 */
249
-	public function set_language_code( $value ) {
250
-
251
-		$this->set( 'wl_general_settings', self::LANGUAGE, $value );
252
-
253
-	}
254
-
255
-	/**
256
-	 * Get the publisher entity post id.
257
-	 *
258
-	 * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org
259
-	 * Article markup.
260
-	 *
261
-	 * @since 3.9.0
262
-	 *
263
-	 * @return int|NULL The publisher entity post id or NULL if not set.
264
-	 */
265
-	public function get_publisher_id() {
266
-
267
-		return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null );
268
-	}
269
-
270
-	/**
271
-	 * Set the publisher entity post id.
272
-	 *
273
-	 * @since 3.9.0
274
-	 *
275
-	 * @param int $value The publisher entity post id.
276
-	 */
277
-	public function set_publisher_id( $value ) {
278
-
279
-		$this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
280
-
281
-	}
282
-
283
-	/**
284
-	 * Get the dataset URI.
285
-	 *
286
-	 * @since 3.10.0
287
-	 *
288
-	 * @return string The dataset URI or an empty string if not set.
289
-	 */
290
-	public function get_dataset_uri() {
291
-
292
-		return $this->get( 'wl_advanced_settings', self::DATASET_URI, null );
293
-	}
294
-
295
-	/**
296
-	 * Set the dataset URI.
297
-	 *
298
-	 * @since 3.10.0
299
-	 *
300
-	 * @param string $value The dataset URI.
301
-	 */
302
-	public function set_dataset_uri( $value ) {
303
-
304
-		$this->set( 'wl_advanced_settings', self::DATASET_URI, $value );
305
-	}
306
-
307
-	/**
308
-	 * Intercept the change of the WordLift key in order to set the dataset URI.
309
-	 *
310
-	 * @since 3.11.0
311
-	 *
312
-	 * @param array $old_value The old settings.
313
-	 * @param array $new_value The new settings.
314
-	 */
315
-	public function update_key( $old_value, $new_value ) {
316
-
317
-		// Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed.
318
-		$old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
319
-		$new_key = isset( $new_value['key'] ) ? $new_value['key'] : '';
320
-
321
-		// If the key hasn't changed, don't do anything.
322
-		// WARN The 'update_option' hook is fired only if the new and old value are not equal.
323
-		if ( $old_key === $new_key ) {
324
-			return;
325
-		}
326
-
327
-		// If the key is empty, empty the dataset URI.
328
-		if ( '' === $new_key ) {
329
-			$this->set_dataset_uri( '' );
330
-		}
331
-
332
-		// make the request to the remote server.
333
-		$this->get_remote_dataset_uri( $new_key );
334
-	}
335
-
336
-	/**
337
-	 * Handle retrieving the dataset uri from the remote server.
338
-	 *
339
-	 * If a valid dataset uri is returned it is stored in the appropriate option,
340
-	 * otherwise the option is set to empty string.
341
-	 *
342
-	 * @since 3.17.0 send the site URL and get the dataset URI.
343
-	 * @since 3.12.0
344
-	 *
345
-	 * @param string $key The key to be used.
346
-	 */
347
-	public function get_remote_dataset_uri( $key ) {
348
-
349
-		$this->log->trace( 'Getting the remote dataset URI...' );
350
-
351
-		// Build the URL.
352
-		$url = $this->get_accounts()
353
-			   . '?key=' . rawurlencode( $key )
354
-			   . '&url=' . rawurlencode( site_url() );
355
-
356
-		$args     = wp_parse_args( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
357
-			'method' => 'PUT',
358
-		) );
359
-		$response = wp_remote_request( $url, $args );
360
-
361
-		// Request the dataset URI.
362
-		// $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
363
-
364
-		// The response is an error.
365
-		if ( is_wp_error( $response ) ) {
366
-			$this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() );
367
-
368
-			$this->set_dataset_uri( '' );
369
-
370
-			return;
371
-		}
372
-
373
-		// The response is not OK.
374
-		if ( 200 !== (int) $response['response']['code'] ) {
375
-			$this->log->error( "Unexpected status code when opening URL $url: " . $response['response']['code'] );
376
-
377
-			$this->set_dataset_uri( '' );
378
-
379
-			return;
380
-		}
381
-
382
-		$json        = json_decode( $response['body'] );
383
-		$dataset_uri = $json->datasetURI;
384
-
385
-		$this->log->info( "Setting the dataset URI to $dataset_uri..." );
386
-
387
-		$this->set_dataset_uri( $dataset_uri );
388
-
389
-	}
390
-
391
-	/**
392
-	 * Handle the edge case where a user submits the same key again
393
-	 * when he does not have the dataset uri to regain it.
394
-	 *
395
-	 * This can not be handled in the normal option update hook because
396
-	 * it is not being triggered when the save value equals to the one already
397
-	 * in the DB.
398
-	 *
399
-	 * @since 3.12.0
400
-	 *
401
-	 * @param mixed $value     The new, unserialized option value.
402
-	 * @param mixed $old_value The old option value.
403
-	 *
404
-	 * @return mixed The same value in the $value parameter
405
-	 */
406
-	function maybe_update_dataset_uri( $value, $old_value ) {
407
-
408
-		// Check the old key value and the new one. Here we're only handling the
409
-		// case where the key hasn't changed and the dataset URI isn't set. The
410
-		// other case, i.e. a new key is inserted, is handled at `update_key`.
411
-		$old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
412
-		$new_key = isset( $value['key'] ) ? $value['key'] : '';
413
-
414
-		$dataset_uri = $this->get_dataset_uri();
415
-
416
-		if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) {
417
-
418
-			// make the request to the remote server to try to get the dataset uri.
419
-			$this->get_remote_dataset_uri( $new_key );
420
-		}
421
-
422
-		return $value;
423
-	}
424
-
425
-	/**
426
-	 * Get the API URI to retrieve the dataset URI using the WordLift Key.
427
-	 *
428
-	 * @since 3.11.0
429
-	 *
430
-	 * @param string $key The WordLift key to use.
431
-	 *
432
-	 * @return string The API URI.
433
-	 */
434
-	public function get_accounts_by_key_dataset_uri( $key ) {
435
-
436
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri";
437
-	}
438
-
439
-	/**
440
-	 * Get the `accounts` end point.
441
-	 *
442
-	 * @since 3.16.0
443
-	 *
444
-	 * @return string The `accounts` end point.
445
-	 */
446
-	public function get_accounts() {
447
-
448
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts';
449
-	}
450
-
451
-	/**
452
-	 * Get the `link by default` option.
453
-	 *
454
-	 * @since 3.13.0
455
-	 *
456
-	 * @return bool True if entities must be linked by default otherwise false.
457
-	 */
458
-	public function is_link_by_default() {
459
-
460
-		return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' );
461
-	}
462
-
463
-	/**
464
-	 * Set the `link by default` option.
465
-	 *
466
-	 * @since 3.13.0
467
-	 *
468
-	 * @param bool $value True to enabling linking by default, otherwise false.
469
-	 */
470
-	public function set_link_by_default( $value ) {
471
-
472
-		$this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' );
473
-	}
474
-
475
-	/**
476
-	 * Get the URL to perform batch analyses.
477
-	 *
478
-	 * @since 3.14.0
479
-	 *
480
-	 * @return string The URL to call to perform the batch analyzes.
481
-	 */
482
-	public function get_batch_analysis_url() {
483
-
484
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'batch-analyses';
485
-
486
-	}
487
-
488
-	/**
489
-	 * Get the URL to perform autocomplete request.
490
-	 *
491
-	 * @since 3.15.0
492
-	 *
493
-	 * @return string The URL to call to perform the batch analyzes.
494
-	 */
495
-	public function get_autocomplete_url() {
496
-
497
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete';
498
-
499
-	}
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 dataset URI option name
61
+     *
62
+     * @since 3.10.0
63
+     */
64
+    const DATASET_URI = 'redlink_dataset_uri';
65
+
66
+    /**
67
+     * The link by default option name.
68
+     *
69
+     * @since 3.11.0
70
+     */
71
+    const LINK_BY_DEFAULT = 'link_by_default';
72
+
73
+    /**
74
+     * The {@link Wordlift_Log_Service} instance.
75
+     *
76
+     * @since 3.16.0
77
+     *
78
+     * @var \Wordlift_Log_Service $log The {@link Wordlift_Log_Service} instance.
79
+     */
80
+    private $log;
81
+
82
+    /**
83
+     * The Wordlift_Configuration_Service's singleton instance.
84
+     *
85
+     * @since  3.6.0
86
+     *
87
+     * @access private
88
+     * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance.
89
+     */
90
+    private static $instance;
91
+
92
+    /**
93
+     * Create a Wordlift_Configuration_Service's instance.
94
+     *
95
+     * @since 3.6.0
96
+     */
97
+    public function __construct() {
98
+
99
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
100
+
101
+        self::$instance = $this;
102
+
103
+    }
104
+
105
+    /**
106
+     * Get the singleton instance.
107
+     *
108
+     * @since 3.6.0
109
+     *
110
+     * @return \Wordlift_Configuration_Service
111
+     */
112
+    public static function get_instance() {
113
+
114
+        return self::$instance;
115
+    }
116
+
117
+    /**
118
+     * Get a configuration given the option name and a key. The option value is
119
+     * expected to be an array.
120
+     *
121
+     * @since 3.6.0
122
+     *
123
+     * @param string $option  The option name.
124
+     * @param string $key     A key in the option value array.
125
+     * @param string $default The default value in case the key is not found (by default an empty string).
126
+     *
127
+     * @return mixed The configuration value or the default value if not found.
128
+     */
129
+    private function get( $option, $key, $default = '' ) {
130
+
131
+        $options = get_option( $option, array() );
132
+
133
+        return isset( $options[ $key ] ) ? $options[ $key ] : $default;
134
+    }
135
+
136
+    /**
137
+     * Set a configuration parameter.
138
+     *
139
+     * @since 3.9.0
140
+     *
141
+     * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
142
+     * @param string $key    The value key.
143
+     * @param mixed  $value  The value.
144
+     */
145
+    private function set( $option, $key, $value ) {
146
+
147
+        $values         = get_option( $option );
148
+        $values         = isset( $values ) ? $values : array();
149
+        $values[ $key ] = $value;
150
+        update_option( $option, $values );
151
+
152
+    }
153
+
154
+    /**
155
+     * Get the entity base path, by default 'entity'.
156
+     *
157
+     * @since 3.6.0
158
+     *
159
+     * @return string The entity base path.
160
+     */
161
+    public function get_entity_base_path() {
162
+
163
+        return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
164
+    }
165
+
166
+    /**
167
+     * Get the entity base path.
168
+     *
169
+     * @since 3.9.0
170
+     *
171
+     * @param string $value The entity base path.
172
+     */
173
+    public function set_entity_base_path( $value ) {
174
+
175
+        $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
176
+
177
+    }
178
+
179
+    /**
180
+     * Whether the installation skip wizard should be skipped.
181
+     *
182
+     * @since 3.9.0
183
+     *
184
+     * @return bool True if it should be skipped otherwise false.
185
+     */
186
+    public function is_skip_wizard() {
187
+
188
+        return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false );
189
+    }
190
+
191
+    /**
192
+     * Set the skip wizard parameter.
193
+     *
194
+     * @since 3.9.0
195
+     *
196
+     * @param bool $value True to skip the wizard. We expect a boolean value.
197
+     */
198
+    public function set_skip_wizard( $value ) {
199
+
200
+        $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value );
201
+
202
+    }
203
+
204
+    /**
205
+     * Get WordLift's key.
206
+     *
207
+     * @since 3.9.0
208
+     *
209
+     * @return string WordLift's key or an empty string if not set.
210
+     */
211
+    public function get_key() {
212
+
213
+        return $this->get( 'wl_general_settings', self::KEY, '' );
214
+    }
215
+
216
+    /**
217
+     * Set WordLift's key.
218
+     *
219
+     * @since 3.9.0
220
+     *
221
+     * @param string $value WordLift's key.
222
+     */
223
+    public function set_key( $value ) {
224
+
225
+        $this->set( 'wl_general_settings', self::KEY, $value );
226
+    }
227
+
228
+    /**
229
+     * Get WordLift's configured language, by default 'en'.
230
+     *
231
+     * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis.
232
+     *
233
+     * @since 3.9.0
234
+     *
235
+     * @return string WordLift's configured language code ('en' by default).
236
+     */
237
+    public function get_language_code() {
238
+
239
+        return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
240
+    }
241
+
242
+    /**
243
+     * Set WordLift's language code, used when storing strings to the Linked Data dataset.
244
+     *
245
+     * @since 3.9.0
246
+     *
247
+     * @param string $value WordLift's language code.
248
+     */
249
+    public function set_language_code( $value ) {
250
+
251
+        $this->set( 'wl_general_settings', self::LANGUAGE, $value );
252
+
253
+    }
254
+
255
+    /**
256
+     * Get the publisher entity post id.
257
+     *
258
+     * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org
259
+     * Article markup.
260
+     *
261
+     * @since 3.9.0
262
+     *
263
+     * @return int|NULL The publisher entity post id or NULL if not set.
264
+     */
265
+    public function get_publisher_id() {
266
+
267
+        return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null );
268
+    }
269
+
270
+    /**
271
+     * Set the publisher entity post id.
272
+     *
273
+     * @since 3.9.0
274
+     *
275
+     * @param int $value The publisher entity post id.
276
+     */
277
+    public function set_publisher_id( $value ) {
278
+
279
+        $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
280
+
281
+    }
282
+
283
+    /**
284
+     * Get the dataset URI.
285
+     *
286
+     * @since 3.10.0
287
+     *
288
+     * @return string The dataset URI or an empty string if not set.
289
+     */
290
+    public function get_dataset_uri() {
291
+
292
+        return $this->get( 'wl_advanced_settings', self::DATASET_URI, null );
293
+    }
294
+
295
+    /**
296
+     * Set the dataset URI.
297
+     *
298
+     * @since 3.10.0
299
+     *
300
+     * @param string $value The dataset URI.
301
+     */
302
+    public function set_dataset_uri( $value ) {
303
+
304
+        $this->set( 'wl_advanced_settings', self::DATASET_URI, $value );
305
+    }
306
+
307
+    /**
308
+     * Intercept the change of the WordLift key in order to set the dataset URI.
309
+     *
310
+     * @since 3.11.0
311
+     *
312
+     * @param array $old_value The old settings.
313
+     * @param array $new_value The new settings.
314
+     */
315
+    public function update_key( $old_value, $new_value ) {
316
+
317
+        // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed.
318
+        $old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
319
+        $new_key = isset( $new_value['key'] ) ? $new_value['key'] : '';
320
+
321
+        // If the key hasn't changed, don't do anything.
322
+        // WARN The 'update_option' hook is fired only if the new and old value are not equal.
323
+        if ( $old_key === $new_key ) {
324
+            return;
325
+        }
326
+
327
+        // If the key is empty, empty the dataset URI.
328
+        if ( '' === $new_key ) {
329
+            $this->set_dataset_uri( '' );
330
+        }
331
+
332
+        // make the request to the remote server.
333
+        $this->get_remote_dataset_uri( $new_key );
334
+    }
335
+
336
+    /**
337
+     * Handle retrieving the dataset uri from the remote server.
338
+     *
339
+     * If a valid dataset uri is returned it is stored in the appropriate option,
340
+     * otherwise the option is set to empty string.
341
+     *
342
+     * @since 3.17.0 send the site URL and get the dataset URI.
343
+     * @since 3.12.0
344
+     *
345
+     * @param string $key The key to be used.
346
+     */
347
+    public function get_remote_dataset_uri( $key ) {
348
+
349
+        $this->log->trace( 'Getting the remote dataset URI...' );
350
+
351
+        // Build the URL.
352
+        $url = $this->get_accounts()
353
+                . '?key=' . rawurlencode( $key )
354
+                . '&url=' . rawurlencode( site_url() );
355
+
356
+        $args     = wp_parse_args( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
357
+            'method' => 'PUT',
358
+        ) );
359
+        $response = wp_remote_request( $url, $args );
360
+
361
+        // Request the dataset URI.
362
+        // $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
363
+
364
+        // The response is an error.
365
+        if ( is_wp_error( $response ) ) {
366
+            $this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() );
367
+
368
+            $this->set_dataset_uri( '' );
369
+
370
+            return;
371
+        }
372
+
373
+        // The response is not OK.
374
+        if ( 200 !== (int) $response['response']['code'] ) {
375
+            $this->log->error( "Unexpected status code when opening URL $url: " . $response['response']['code'] );
376
+
377
+            $this->set_dataset_uri( '' );
378
+
379
+            return;
380
+        }
381
+
382
+        $json        = json_decode( $response['body'] );
383
+        $dataset_uri = $json->datasetURI;
384
+
385
+        $this->log->info( "Setting the dataset URI to $dataset_uri..." );
386
+
387
+        $this->set_dataset_uri( $dataset_uri );
388
+
389
+    }
390
+
391
+    /**
392
+     * Handle the edge case where a user submits the same key again
393
+     * when he does not have the dataset uri to regain it.
394
+     *
395
+     * This can not be handled in the normal option update hook because
396
+     * it is not being triggered when the save value equals to the one already
397
+     * in the DB.
398
+     *
399
+     * @since 3.12.0
400
+     *
401
+     * @param mixed $value     The new, unserialized option value.
402
+     * @param mixed $old_value The old option value.
403
+     *
404
+     * @return mixed The same value in the $value parameter
405
+     */
406
+    function maybe_update_dataset_uri( $value, $old_value ) {
407
+
408
+        // Check the old key value and the new one. Here we're only handling the
409
+        // case where the key hasn't changed and the dataset URI isn't set. The
410
+        // other case, i.e. a new key is inserted, is handled at `update_key`.
411
+        $old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
412
+        $new_key = isset( $value['key'] ) ? $value['key'] : '';
413
+
414
+        $dataset_uri = $this->get_dataset_uri();
415
+
416
+        if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) {
417
+
418
+            // make the request to the remote server to try to get the dataset uri.
419
+            $this->get_remote_dataset_uri( $new_key );
420
+        }
421
+
422
+        return $value;
423
+    }
424
+
425
+    /**
426
+     * Get the API URI to retrieve the dataset URI using the WordLift Key.
427
+     *
428
+     * @since 3.11.0
429
+     *
430
+     * @param string $key The WordLift key to use.
431
+     *
432
+     * @return string The API URI.
433
+     */
434
+    public function get_accounts_by_key_dataset_uri( $key ) {
435
+
436
+        return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri";
437
+    }
438
+
439
+    /**
440
+     * Get the `accounts` end point.
441
+     *
442
+     * @since 3.16.0
443
+     *
444
+     * @return string The `accounts` end point.
445
+     */
446
+    public function get_accounts() {
447
+
448
+        return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts';
449
+    }
450
+
451
+    /**
452
+     * Get the `link by default` option.
453
+     *
454
+     * @since 3.13.0
455
+     *
456
+     * @return bool True if entities must be linked by default otherwise false.
457
+     */
458
+    public function is_link_by_default() {
459
+
460
+        return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' );
461
+    }
462
+
463
+    /**
464
+     * Set the `link by default` option.
465
+     *
466
+     * @since 3.13.0
467
+     *
468
+     * @param bool $value True to enabling linking by default, otherwise false.
469
+     */
470
+    public function set_link_by_default( $value ) {
471
+
472
+        $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' );
473
+    }
474
+
475
+    /**
476
+     * Get the URL to perform batch analyses.
477
+     *
478
+     * @since 3.14.0
479
+     *
480
+     * @return string The URL to call to perform the batch analyzes.
481
+     */
482
+    public function get_batch_analysis_url() {
483
+
484
+        return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'batch-analyses';
485
+
486
+    }
487
+
488
+    /**
489
+     * Get the URL to perform autocomplete request.
490
+     *
491
+     * @since 3.15.0
492
+     *
493
+     * @return string The URL to call to perform the batch analyzes.
494
+     */
495
+    public function get_autocomplete_url() {
496
+
497
+        return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete';
498
+
499
+    }
500 500
 
501 501
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 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
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function __construct() {
98 98
 
99
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
99
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
100 100
 
101 101
 		self::$instance = $this;
102 102
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return mixed The configuration value or the default value if not found.
128 128
 	 */
129
-	private function get( $option, $key, $default = '' ) {
129
+	private function get($option, $key, $default = '') {
130 130
 
131
-		$options = get_option( $option, array() );
131
+		$options = get_option($option, array());
132 132
 
133
-		return isset( $options[ $key ] ) ? $options[ $key ] : $default;
133
+		return isset($options[$key]) ? $options[$key] : $default;
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	 * @param string $key    The value key.
143 143
 	 * @param mixed  $value  The value.
144 144
 	 */
145
-	private function set( $option, $key, $value ) {
145
+	private function set($option, $key, $value) {
146 146
 
147
-		$values         = get_option( $option );
148
-		$values         = isset( $values ) ? $values : array();
149
-		$values[ $key ] = $value;
150
-		update_option( $option, $values );
147
+		$values         = get_option($option);
148
+		$values         = isset($values) ? $values : array();
149
+		$values[$key] = $value;
150
+		update_option($option, $values);
151 151
 
152 152
 	}
153 153
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_entity_base_path() {
162 162
 
163
-		return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' );
163
+		return $this->get('wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity');
164 164
 	}
165 165
 
166 166
 	/**
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param string $value The entity base path.
172 172
 	 */
173
-	public function set_entity_base_path( $value ) {
173
+	public function set_entity_base_path($value) {
174 174
 
175
-		$this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value );
175
+		$this->set('wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value);
176 176
 
177 177
 	}
178 178
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function is_skip_wizard() {
187 187
 
188
-		return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false );
188
+		return $this->get('wl_general_settings', self::SKIP_WIZARD, false);
189 189
 	}
190 190
 
191 191
 	/**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @param bool $value True to skip the wizard. We expect a boolean value.
197 197
 	 */
198
-	public function set_skip_wizard( $value ) {
198
+	public function set_skip_wizard($value) {
199 199
 
200
-		$this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value );
200
+		$this->set('wl_general_settings', self::SKIP_WIZARD, true === $value);
201 201
 
202 202
 	}
203 203
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function get_key() {
212 212
 
213
-		return $this->get( 'wl_general_settings', self::KEY, '' );
213
+		return $this->get('wl_general_settings', self::KEY, '');
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @param string $value WordLift's key.
222 222
 	 */
223
-	public function set_key( $value ) {
223
+	public function set_key($value) {
224 224
 
225
-		$this->set( 'wl_general_settings', self::KEY, $value );
225
+		$this->set('wl_general_settings', self::KEY, $value);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function get_language_code() {
238 238
 
239
-		return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' );
239
+		return $this->get('wl_general_settings', self::LANGUAGE, 'en');
240 240
 	}
241 241
 
242 242
 	/**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @param string $value WordLift's language code.
248 248
 	 */
249
-	public function set_language_code( $value ) {
249
+	public function set_language_code($value) {
250 250
 
251
-		$this->set( 'wl_general_settings', self::LANGUAGE, $value );
251
+		$this->set('wl_general_settings', self::LANGUAGE, $value);
252 252
 
253 253
 	}
254 254
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public function get_publisher_id() {
266 266
 
267
-		return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null );
267
+		return $this->get('wl_general_settings', self::PUBLISHER_ID, null);
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $value The publisher entity post id.
276 276
 	 */
277
-	public function set_publisher_id( $value ) {
277
+	public function set_publisher_id($value) {
278 278
 
279
-		$this->set( 'wl_general_settings', self::PUBLISHER_ID, $value );
279
+		$this->set('wl_general_settings', self::PUBLISHER_ID, $value);
280 280
 
281 281
 	}
282 282
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function get_dataset_uri() {
291 291
 
292
-		return $this->get( 'wl_advanced_settings', self::DATASET_URI, null );
292
+		return $this->get('wl_advanced_settings', self::DATASET_URI, null);
293 293
 	}
294 294
 
295 295
 	/**
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @param string $value The dataset URI.
301 301
 	 */
302
-	public function set_dataset_uri( $value ) {
302
+	public function set_dataset_uri($value) {
303 303
 
304
-		$this->set( 'wl_advanced_settings', self::DATASET_URI, $value );
304
+		$this->set('wl_advanced_settings', self::DATASET_URI, $value);
305 305
 	}
306 306
 
307 307
 	/**
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
 	 * @param array $old_value The old settings.
313 313
 	 * @param array $new_value The new settings.
314 314
 	 */
315
-	public function update_key( $old_value, $new_value ) {
315
+	public function update_key($old_value, $new_value) {
316 316
 
317 317
 		// Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed.
318
-		$old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
319
-		$new_key = isset( $new_value['key'] ) ? $new_value['key'] : '';
318
+		$old_key = isset($old_value['key']) ? $old_value['key'] : '';
319
+		$new_key = isset($new_value['key']) ? $new_value['key'] : '';
320 320
 
321 321
 		// If the key hasn't changed, don't do anything.
322 322
 		// WARN The 'update_option' hook is fired only if the new and old value are not equal.
323
-		if ( $old_key === $new_key ) {
323
+		if ($old_key === $new_key) {
324 324
 			return;
325 325
 		}
326 326
 
327 327
 		// If the key is empty, empty the dataset URI.
328
-		if ( '' === $new_key ) {
329
-			$this->set_dataset_uri( '' );
328
+		if ('' === $new_key) {
329
+			$this->set_dataset_uri('');
330 330
 		}
331 331
 
332 332
 		// make the request to the remote server.
333
-		$this->get_remote_dataset_uri( $new_key );
333
+		$this->get_remote_dataset_uri($new_key);
334 334
 	}
335 335
 
336 336
 	/**
@@ -344,47 +344,47 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @param string $key The key to be used.
346 346
 	 */
347
-	public function get_remote_dataset_uri( $key ) {
347
+	public function get_remote_dataset_uri($key) {
348 348
 
349
-		$this->log->trace( 'Getting the remote dataset URI...' );
349
+		$this->log->trace('Getting the remote dataset URI...');
350 350
 
351 351
 		// Build the URL.
352 352
 		$url = $this->get_accounts()
353
-			   . '?key=' . rawurlencode( $key )
354
-			   . '&url=' . rawurlencode( site_url() );
353
+			   . '?key='.rawurlencode($key)
354
+			   . '&url='.rawurlencode(site_url());
355 355
 
356
-		$args     = wp_parse_args( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
356
+		$args     = wp_parse_args(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array(
357 357
 			'method' => 'PUT',
358
-		) );
359
-		$response = wp_remote_request( $url, $args );
358
+		));
359
+		$response = wp_remote_request($url, $args);
360 360
 
361 361
 		// Request the dataset URI.
362 362
 		// $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
363 363
 
364 364
 		// The response is an error.
365
-		if ( is_wp_error( $response ) ) {
366
-			$this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() );
365
+		if (is_wp_error($response)) {
366
+			$this->log->error('An error occurred setting the dataset URI: '.$response->get_error_message());
367 367
 
368
-			$this->set_dataset_uri( '' );
368
+			$this->set_dataset_uri('');
369 369
 
370 370
 			return;
371 371
 		}
372 372
 
373 373
 		// The response is not OK.
374
-		if ( 200 !== (int) $response['response']['code'] ) {
375
-			$this->log->error( "Unexpected status code when opening URL $url: " . $response['response']['code'] );
374
+		if (200 !== (int) $response['response']['code']) {
375
+			$this->log->error("Unexpected status code when opening URL $url: ".$response['response']['code']);
376 376
 
377
-			$this->set_dataset_uri( '' );
377
+			$this->set_dataset_uri('');
378 378
 
379 379
 			return;
380 380
 		}
381 381
 
382
-		$json        = json_decode( $response['body'] );
382
+		$json        = json_decode($response['body']);
383 383
 		$dataset_uri = $json->datasetURI;
384 384
 
385
-		$this->log->info( "Setting the dataset URI to $dataset_uri..." );
385
+		$this->log->info("Setting the dataset URI to $dataset_uri...");
386 386
 
387
-		$this->set_dataset_uri( $dataset_uri );
387
+		$this->set_dataset_uri($dataset_uri);
388 388
 
389 389
 	}
390 390
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return mixed The same value in the $value parameter
405 405
 	 */
406
-	function maybe_update_dataset_uri( $value, $old_value ) {
406
+	function maybe_update_dataset_uri($value, $old_value) {
407 407
 
408 408
 		// Check the old key value and the new one. Here we're only handling the
409 409
 		// case where the key hasn't changed and the dataset URI isn't set. The
410 410
 		// other case, i.e. a new key is inserted, is handled at `update_key`.
411
-		$old_key = isset( $old_value['key'] ) ? $old_value['key'] : '';
412
-		$new_key = isset( $value['key'] ) ? $value['key'] : '';
411
+		$old_key = isset($old_value['key']) ? $old_value['key'] : '';
412
+		$new_key = isset($value['key']) ? $value['key'] : '';
413 413
 
414 414
 		$dataset_uri = $this->get_dataset_uri();
415 415
 
416
-		if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) {
416
+		if ( ! empty($new_key) && $new_key === $old_key && empty($dataset_uri)) {
417 417
 
418 418
 			// make the request to the remote server to try to get the dataset uri.
419
-			$this->get_remote_dataset_uri( $new_key );
419
+			$this->get_remote_dataset_uri($new_key);
420 420
 		}
421 421
 
422 422
 		return $value;
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 	 *
432 432
 	 * @return string The API URI.
433 433
 	 */
434
-	public function get_accounts_by_key_dataset_uri( $key ) {
434
+	public function get_accounts_by_key_dataset_uri($key) {
435 435
 
436
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri";
436
+		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE."accounts/key=$key/dataset_uri";
437 437
 	}
438 438
 
439 439
 	/**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public function get_accounts() {
447 447
 
448
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts';
448
+		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'accounts';
449 449
 	}
450 450
 
451 451
 	/**
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	public function is_link_by_default() {
459 459
 
460
-		return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' );
460
+		return 'yes' === $this->get('wl_general_settings', self::LINK_BY_DEFAULT, 'yes');
461 461
 	}
462 462
 
463 463
 	/**
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param bool $value True to enabling linking by default, otherwise false.
469 469
 	 */
470
-	public function set_link_by_default( $value ) {
470
+	public function set_link_by_default($value) {
471 471
 
472
-		$this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' );
472
+		$this->set('wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no');
473 473
 	}
474 474
 
475 475
 	/**
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 */
482 482
 	public function get_batch_analysis_url() {
483 483
 
484
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'batch-analyses';
484
+		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'batch-analyses';
485 485
 
486 486
 	}
487 487
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	 */
495 495
 	public function get_autocomplete_url() {
496 496
 
497
-		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete';
497
+		return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'autocomplete';
498 498
 
499 499
 	}
500 500
 
Please login to merge, or discard this patch.
src/includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Wordlift_Batch_Analysis_Sql_Helper {
13 13
 
14
-	/**
15
-	 * Get the base SQL statement to submit a post for Batch Analysis.
16
-	 *
17
-	 * Functions may use this base SQL and add their own filters. This function
18
-	 * should be `private` and only used by the {@link Wordlift_Batch_Analysis_Service}
19
-	 * `submit` function. But since we want to maintain compatibility with PHP 5.3
20
-	 * and we couldn't use traits to hide the function from the Wordlift_Batch_Analysis_Service
21
-	 * we used a Helper function.
22
-	 *
23
-	 * @since 3.14.2
24
-	 *
25
-	 * @param array $args An array of parameters, see {@link submit}.
26
-	 *
27
-	 * @return string The base SQL.
28
-	 */
29
-	public static function get_sql( $args ) {
30
-
31
-		/*
14
+    /**
15
+     * Get the base SQL statement to submit a post for Batch Analysis.
16
+     *
17
+     * Functions may use this base SQL and add their own filters. This function
18
+     * should be `private` and only used by the {@link Wordlift_Batch_Analysis_Service}
19
+     * `submit` function. But since we want to maintain compatibility with PHP 5.3
20
+     * and we couldn't use traits to hide the function from the Wordlift_Batch_Analysis_Service
21
+     * we used a Helper function.
22
+     *
23
+     * @since 3.14.2
24
+     *
25
+     * @param array $args An array of parameters, see {@link submit}.
26
+     *
27
+     * @return string The base SQL.
28
+     */
29
+    public static function get_sql( $args ) {
30
+
31
+        /*
32 32
 		Prepare the statement:
33 33
 			1. Insert into `postmeta` the meta keys and values:
34 34
 				a) state meta, with value of SUBMIT (0),
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
 			9. Filter by `post_id` where `exclude` is the posts id to exclude.
45 45
 		*/
46 46
 
47
-		// @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
48
-		return self::get_base_query( $args )
49
-			   . " WHERE p.post_type IN ('" . join( "', '", array_map( 'esc_sql', (array) $args['post_type'] ) ) . "')"
50
-			   . "  AND p.post_status = 'publish'"
51
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_include_annotated( $args['include_annotated'] )
52
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_from( $args['from'] )
53
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_to( $args['to'] )
54
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_exclude_posts( $args['exclude'] );
55
-		// @codingStandardsIgnoreEnd
56
-	}
47
+        // @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
48
+        return self::get_base_query( $args )
49
+                . " WHERE p.post_type IN ('" . join( "', '", array_map( 'esc_sql', (array) $args['post_type'] ) ) . "')"
50
+                . "  AND p.post_status = 'publish'"
51
+                . Wordlift_Batch_Analysis_Sql_Helper::and_include_annotated( $args['include_annotated'] )
52
+                . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_from( $args['from'] )
53
+                . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_to( $args['to'] )
54
+                . Wordlift_Batch_Analysis_Sql_Helper::and_exclude_posts( $args['exclude'] );
55
+        // @codingStandardsIgnoreEnd
56
+    }
57 57
 
58
-	public static function get_sql_for_ids( $args ) {
58
+    public static function get_sql_for_ids( $args ) {
59 59
 
60
-		/*
60
+        /*
61 61
 		Prepare the statement:
62 62
 			1. Insert into `postmeta` the meta keys and values:
63 63
 				a) state meta, with value of SUBMIT (0),
@@ -73,178 +73,178 @@  discard block
 block discarded – undo
73 73
 			9. Filter by `post_id` where `exclude` is the posts id to exclude.
74 74
 		*/
75 75
 
76
-		// @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
77
-
78
-		return self::get_base_query( $args )
79
-			   . ' WHERE p.id IN (' . implode( ', ', wp_parse_id_list( $args['ids'] ) ) . ')';
80
-		// @codingStandardsIgnoreEnd
81
-	}
82
-
83
-	private static function get_base_query( $args ) {
84
-		global $wpdb;
85
-
86
-		// Get the link options.
87
-		$link_options = serialize( array(
88
-			'link'            => $args['link'],
89
-			'min_occurrences' => $args['min_occurrences'],
90
-		) );
91
-
92
-		return $wpdb->prepare(
93
-			"INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value )"
94
-			// Populate 3 metas for the batch analysis request using a SQL
95
-			// statement: each meta contains a state for the batch analysis
96
-			// request.
97
-			. ' SELECT p.ID, metas.* FROM ('
98
-			. '  SELECT %s, 0 FROM dual'                // STATE_META_KEY.
99
-			. '   UNION'
100
-			. '	 SELECT %s, UTC_TIMESTAMP() FROM dual'  // SUBMIT_TIMESTAMP_META_KEY.
101
-			. '	  UNION'
102
-			. '	 SELECT %s, %s FROM dual'               // LINK_META_KEY.
103
-			. '	) metas'
104
-			. ", $wpdb->posts p",
105
-			Wordlift_Batch_Analysis_Service::STATE_META_KEY,
106
-			Wordlift_Batch_Analysis_Service::SUBMIT_TIMESTAMP_META_KEY,
107
-			Wordlift_Batch_Analysis_Service::BATCH_ANALYSIS_OPTIONS_META_KEY,
108
-			$link_options
109
-		);
110
-	}
111
-
112
-	/**
113
-	 * Add a clause to analyze all auto selected posts, i.e. non annotated posts.
114
-	 *
115
-	 * @param bool $include Whether to include annotated posts in selection.
116
-	 *
117
-	 * @since  3.17.0
118
-	 *
119
-	 * @return string The `post_content` clause.
120
-	 */
121
-	private static function and_include_annotated( $include ) {
122
-
123
-		// Bail out with an empty string if we include all the posts.
124
-		if ( true === $include ) {
125
-			return '';
126
-		}
127
-
128
-		// Filter out already annotated posts.
129
-		return " AND p.post_content NOT REGEXP '<[a-z]+ id=\"urn:[^\"]+\" class=\"[^\"]+\" itemid=\"[^\"]+\">'";
130
-	}
131
-
132
-	/**
133
-	 * Add the start date clause.
134
-	 *
135
-	 * @param  DateTime|null $value The date where the analysis should start.
136
-	 *
137
-	 * @since  3.17.0
138
-	 *
139
-	 * @return string The start `post_date_gmt` clause
140
-	 */
141
-	private static function and_post_date_from( $value ) {
142
-
143
-		// Bail out if the `from` isn't specified.
144
-		if ( null === $value ) {
145
-			return '';
146
-		}
147
-
148
-		// Try to convert the value to a date, GMT timezone.
149
-		$date = self::get_mysql_date_string( $value );
150
-
151
-		// Return the clause.
152
-		return " AND p.post_date_gmt >= '$date'";
153
-	}
154
-
155
-	/**
156
-	 * Add the `to` date clause.
157
-	 *
158
-	 * @param  DateTime|null $value The `to` date clause.
159
-	 *
160
-	 * @since  3.17.0
161
-	 *
162
-	 * @return string The end `post_date_gmt` clause
163
-	 */
164
-	private static function and_post_date_to( $value ) {
165
-
166
-		// Bail out if the `from` isn't specified.
167
-		if ( null === $value ) {
168
-			return '';
169
-		}
170
-
171
-		// Try to convert the value to a date, GMT timezone.
172
-		$date = self::get_mysql_date_string( $value );
173
-
174
-		// Return the clause.
175
-		return " AND p.post_date_gmt <= '$date'";
176
-	}
177
-
178
-	/**
179
-	 * Include specific posts by their id in the analysis.
180
-	 *
181
-	 * @param array $include Array of post ids to include.
182
-	 *
183
-	 * @since  3.17.0
184
-	 *
185
-	 * @return string The posts IN clause.
186
-	 */
187
-	private static function and_include_posts( $include ) {
188
-
189
-		// Bail if the param is not set.
190
-		if ( empty( $include ) ) {
191
-			return '';
192
-		}
193
-
194
-		return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
195
-	}
196
-
197
-	/**
198
-	 * Exclude specific posts by ids.
199
-	 *
200
-	 * @param array $exclude Array of post ids to exclude.
201
-	 *
202
-	 * @since  3.17.0
203
-	 *
204
-	 * @return string The posts NOT IN clause.
205
-	 */
206
-	private static function and_exclude_posts( $exclude ) {
207
-
208
-		// Bail if the param is not set.
209
-		if ( empty( $exclude ) ) {
210
-			return '';
211
-		}
212
-
213
-		return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
214
-	}
215
-
216
-
217
-	/**
218
-	 * Convert a `Y-m-d'T'H:i:sT` string representation of a date to a MySQL
219
-	 * date string, taking into consideration the time zone.
220
-	 *
221
-	 * If the date string cannot be converted, the processing is stopped.
222
-	 *
223
-	 * @since 3.17.0
224
-	 *
225
-	 * @param string $value A date represented as `Y-m-d'T'H:i:sT`.
226
-	 *
227
-	 * @return string A MySQL string representation of the date.
228
-	 */
229
-	private static function get_mysql_date_string( $value ) {
230
-
231
-		// Try to convert the value to a date, GMT timezone.
232
-		$date = date_create_from_format( 'Y-m-d\TH:i:sT', $value );
233
-
234
-		if ( false === $date ) {
235
-			wp_die( "Invalid date format, use `Y-m-d'T'H:i:sT`." );
236
-		}
237
-
238
-		// Convert the DateTime timezone to `GMT`.
239
-		$date->setTimezone( timezone_open( 'GMT' ) );
240
-
241
-		// Stop if the conversion failed.
242
-		if ( false === $date ) {
243
-			wp_die( "Invalid date format, date must be in Y-m-d'T'H:i:sT format." );
244
-		}
245
-
246
-		// Return the clause.
247
-		return $date->format( 'Y-m-d H:i:s' );
248
-	}
76
+        // @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
77
+
78
+        return self::get_base_query( $args )
79
+                . ' WHERE p.id IN (' . implode( ', ', wp_parse_id_list( $args['ids'] ) ) . ')';
80
+        // @codingStandardsIgnoreEnd
81
+    }
82
+
83
+    private static function get_base_query( $args ) {
84
+        global $wpdb;
85
+
86
+        // Get the link options.
87
+        $link_options = serialize( array(
88
+            'link'            => $args['link'],
89
+            'min_occurrences' => $args['min_occurrences'],
90
+        ) );
91
+
92
+        return $wpdb->prepare(
93
+            "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value )"
94
+            // Populate 3 metas for the batch analysis request using a SQL
95
+            // statement: each meta contains a state for the batch analysis
96
+            // request.
97
+            . ' SELECT p.ID, metas.* FROM ('
98
+            . '  SELECT %s, 0 FROM dual'                // STATE_META_KEY.
99
+            . '   UNION'
100
+            . '	 SELECT %s, UTC_TIMESTAMP() FROM dual'  // SUBMIT_TIMESTAMP_META_KEY.
101
+            . '	  UNION'
102
+            . '	 SELECT %s, %s FROM dual'               // LINK_META_KEY.
103
+            . '	) metas'
104
+            . ", $wpdb->posts p",
105
+            Wordlift_Batch_Analysis_Service::STATE_META_KEY,
106
+            Wordlift_Batch_Analysis_Service::SUBMIT_TIMESTAMP_META_KEY,
107
+            Wordlift_Batch_Analysis_Service::BATCH_ANALYSIS_OPTIONS_META_KEY,
108
+            $link_options
109
+        );
110
+    }
111
+
112
+    /**
113
+     * Add a clause to analyze all auto selected posts, i.e. non annotated posts.
114
+     *
115
+     * @param bool $include Whether to include annotated posts in selection.
116
+     *
117
+     * @since  3.17.0
118
+     *
119
+     * @return string The `post_content` clause.
120
+     */
121
+    private static function and_include_annotated( $include ) {
122
+
123
+        // Bail out with an empty string if we include all the posts.
124
+        if ( true === $include ) {
125
+            return '';
126
+        }
127
+
128
+        // Filter out already annotated posts.
129
+        return " AND p.post_content NOT REGEXP '<[a-z]+ id=\"urn:[^\"]+\" class=\"[^\"]+\" itemid=\"[^\"]+\">'";
130
+    }
131
+
132
+    /**
133
+     * Add the start date clause.
134
+     *
135
+     * @param  DateTime|null $value The date where the analysis should start.
136
+     *
137
+     * @since  3.17.0
138
+     *
139
+     * @return string The start `post_date_gmt` clause
140
+     */
141
+    private static function and_post_date_from( $value ) {
142
+
143
+        // Bail out if the `from` isn't specified.
144
+        if ( null === $value ) {
145
+            return '';
146
+        }
147
+
148
+        // Try to convert the value to a date, GMT timezone.
149
+        $date = self::get_mysql_date_string( $value );
150
+
151
+        // Return the clause.
152
+        return " AND p.post_date_gmt >= '$date'";
153
+    }
154
+
155
+    /**
156
+     * Add the `to` date clause.
157
+     *
158
+     * @param  DateTime|null $value The `to` date clause.
159
+     *
160
+     * @since  3.17.0
161
+     *
162
+     * @return string The end `post_date_gmt` clause
163
+     */
164
+    private static function and_post_date_to( $value ) {
165
+
166
+        // Bail out if the `from` isn't specified.
167
+        if ( null === $value ) {
168
+            return '';
169
+        }
170
+
171
+        // Try to convert the value to a date, GMT timezone.
172
+        $date = self::get_mysql_date_string( $value );
173
+
174
+        // Return the clause.
175
+        return " AND p.post_date_gmt <= '$date'";
176
+    }
177
+
178
+    /**
179
+     * Include specific posts by their id in the analysis.
180
+     *
181
+     * @param array $include Array of post ids to include.
182
+     *
183
+     * @since  3.17.0
184
+     *
185
+     * @return string The posts IN clause.
186
+     */
187
+    private static function and_include_posts( $include ) {
188
+
189
+        // Bail if the param is not set.
190
+        if ( empty( $include ) ) {
191
+            return '';
192
+        }
193
+
194
+        return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
195
+    }
196
+
197
+    /**
198
+     * Exclude specific posts by ids.
199
+     *
200
+     * @param array $exclude Array of post ids to exclude.
201
+     *
202
+     * @since  3.17.0
203
+     *
204
+     * @return string The posts NOT IN clause.
205
+     */
206
+    private static function and_exclude_posts( $exclude ) {
207
+
208
+        // Bail if the param is not set.
209
+        if ( empty( $exclude ) ) {
210
+            return '';
211
+        }
212
+
213
+        return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
214
+    }
215
+
216
+
217
+    /**
218
+     * Convert a `Y-m-d'T'H:i:sT` string representation of a date to a MySQL
219
+     * date string, taking into consideration the time zone.
220
+     *
221
+     * If the date string cannot be converted, the processing is stopped.
222
+     *
223
+     * @since 3.17.0
224
+     *
225
+     * @param string $value A date represented as `Y-m-d'T'H:i:sT`.
226
+     *
227
+     * @return string A MySQL string representation of the date.
228
+     */
229
+    private static function get_mysql_date_string( $value ) {
230
+
231
+        // Try to convert the value to a date, GMT timezone.
232
+        $date = date_create_from_format( 'Y-m-d\TH:i:sT', $value );
233
+
234
+        if ( false === $date ) {
235
+            wp_die( "Invalid date format, use `Y-m-d'T'H:i:sT`." );
236
+        }
237
+
238
+        // Convert the DateTime timezone to `GMT`.
239
+        $date->setTimezone( timezone_open( 'GMT' ) );
240
+
241
+        // Stop if the conversion failed.
242
+        if ( false === $date ) {
243
+            wp_die( "Invalid date format, date must be in Y-m-d'T'H:i:sT format." );
244
+        }
245
+
246
+        // Return the clause.
247
+        return $date->format( 'Y-m-d H:i:s' );
248
+    }
249 249
 
250 250
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return string The base SQL.
28 28
 	 */
29
-	public static function get_sql( $args ) {
29
+	public static function get_sql($args) {
30 30
 
31 31
 		/*
32 32
 		Prepare the statement:
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 		*/
46 46
 
47 47
 		// @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
48
-		return self::get_base_query( $args )
49
-			   . " WHERE p.post_type IN ('" . join( "', '", array_map( 'esc_sql', (array) $args['post_type'] ) ) . "')"
48
+		return self::get_base_query($args)
49
+			   . " WHERE p.post_type IN ('".join("', '", array_map('esc_sql', (array) $args['post_type']))."')"
50 50
 			   . "  AND p.post_status = 'publish'"
51
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_include_annotated( $args['include_annotated'] )
52
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_from( $args['from'] )
53
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_to( $args['to'] )
54
-			   . Wordlift_Batch_Analysis_Sql_Helper::and_exclude_posts( $args['exclude'] );
51
+			   . Wordlift_Batch_Analysis_Sql_Helper::and_include_annotated($args['include_annotated'])
52
+			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_from($args['from'])
53
+			   . Wordlift_Batch_Analysis_Sql_Helper::and_post_date_to($args['to'])
54
+			   . Wordlift_Batch_Analysis_Sql_Helper::and_exclude_posts($args['exclude']);
55 55
 		// @codingStandardsIgnoreEnd
56 56
 	}
57 57
 
58
-	public static function get_sql_for_ids( $args ) {
58
+	public static function get_sql_for_ids($args) {
59 59
 
60 60
 		/*
61 61
 		Prepare the statement:
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 
76 76
 		// @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
77 77
 
78
-		return self::get_base_query( $args )
79
-			   . ' WHERE p.id IN (' . implode( ', ', wp_parse_id_list( $args['ids'] ) ) . ')';
78
+		return self::get_base_query($args)
79
+			   . ' WHERE p.id IN ('.implode(', ', wp_parse_id_list($args['ids'])).')';
80 80
 		// @codingStandardsIgnoreEnd
81 81
 	}
82 82
 
83
-	private static function get_base_query( $args ) {
83
+	private static function get_base_query($args) {
84 84
 		global $wpdb;
85 85
 
86 86
 		// Get the link options.
87
-		$link_options = serialize( array(
87
+		$link_options = serialize(array(
88 88
 			'link'            => $args['link'],
89 89
 			'min_occurrences' => $args['min_occurrences'],
90
-		) );
90
+		));
91 91
 
92 92
 		return $wpdb->prepare(
93 93
 			"INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value )"
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return string The `post_content` clause.
120 120
 	 */
121
-	private static function and_include_annotated( $include ) {
121
+	private static function and_include_annotated($include) {
122 122
 
123 123
 		// Bail out with an empty string if we include all the posts.
124
-		if ( true === $include ) {
124
+		if (true === $include) {
125 125
 			return '';
126 126
 		}
127 127
 
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return string The start `post_date_gmt` clause
140 140
 	 */
141
-	private static function and_post_date_from( $value ) {
141
+	private static function and_post_date_from($value) {
142 142
 
143 143
 		// Bail out if the `from` isn't specified.
144
-		if ( null === $value ) {
144
+		if (null === $value) {
145 145
 			return '';
146 146
 		}
147 147
 
148 148
 		// Try to convert the value to a date, GMT timezone.
149
-		$date = self::get_mysql_date_string( $value );
149
+		$date = self::get_mysql_date_string($value);
150 150
 
151 151
 		// Return the clause.
152 152
 		return " AND p.post_date_gmt >= '$date'";
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return string The end `post_date_gmt` clause
163 163
 	 */
164
-	private static function and_post_date_to( $value ) {
164
+	private static function and_post_date_to($value) {
165 165
 
166 166
 		// Bail out if the `from` isn't specified.
167
-		if ( null === $value ) {
167
+		if (null === $value) {
168 168
 			return '';
169 169
 		}
170 170
 
171 171
 		// Try to convert the value to a date, GMT timezone.
172
-		$date = self::get_mysql_date_string( $value );
172
+		$date = self::get_mysql_date_string($value);
173 173
 
174 174
 		// Return the clause.
175 175
 		return " AND p.post_date_gmt <= '$date'";
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @return string The posts IN clause.
186 186
 	 */
187
-	private static function and_include_posts( $include ) {
187
+	private static function and_include_posts($include) {
188 188
 
189 189
 		// Bail if the param is not set.
190
-		if ( empty( $include ) ) {
190
+		if (empty($include)) {
191 191
 			return '';
192 192
 		}
193 193
 
194
-		return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
194
+		return ' AND p.ID IN ( '.implode(',', wp_parse_id_list($include)).' )';
195 195
 	}
196 196
 
197 197
 	/**
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return string The posts NOT IN clause.
205 205
 	 */
206
-	private static function and_exclude_posts( $exclude ) {
206
+	private static function and_exclude_posts($exclude) {
207 207
 
208 208
 		// Bail if the param is not set.
209
-		if ( empty( $exclude ) ) {
209
+		if (empty($exclude)) {
210 210
 			return '';
211 211
 		}
212 212
 
213
-		return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
213
+		return ' AND p.ID NOT IN ( '.implode(',', wp_parse_id_list($exclude)).' )';
214 214
 	}
215 215
 
216 216
 
@@ -226,25 +226,25 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return string A MySQL string representation of the date.
228 228
 	 */
229
-	private static function get_mysql_date_string( $value ) {
229
+	private static function get_mysql_date_string($value) {
230 230
 
231 231
 		// Try to convert the value to a date, GMT timezone.
232
-		$date = date_create_from_format( 'Y-m-d\TH:i:sT', $value );
232
+		$date = date_create_from_format('Y-m-d\TH:i:sT', $value);
233 233
 
234
-		if ( false === $date ) {
235
-			wp_die( "Invalid date format, use `Y-m-d'T'H:i:sT`." );
234
+		if (false === $date) {
235
+			wp_die("Invalid date format, use `Y-m-d'T'H:i:sT`.");
236 236
 		}
237 237
 
238 238
 		// Convert the DateTime timezone to `GMT`.
239
-		$date->setTimezone( timezone_open( 'GMT' ) );
239
+		$date->setTimezone(timezone_open('GMT'));
240 240
 
241 241
 		// Stop if the conversion failed.
242
-		if ( false === $date ) {
243
-			wp_die( "Invalid date format, date must be in Y-m-d'T'H:i:sT format." );
242
+		if (false === $date) {
243
+			wp_die("Invalid date format, date must be in Y-m-d'T'H:i:sT format.");
244 244
 		}
245 245
 
246 246
 		// Return the clause.
247
-		return $date->format( 'Y-m-d H:i:s' );
247
+		return $date->format('Y-m-d H:i:s');
248 248
 	}
249 249
 
250 250
 }
Please login to merge, or discard this patch.
src/includes/batch-analysis/class-wordlift-batch-analysis-service.php 2 patches
Indentation   +703 added lines, -703 removed lines patch added patch discarded remove patch
@@ -51,504 +51,504 @@  discard block
 block discarded – undo
51 51
  */
52 52
 class Wordlift_Batch_Analysis_Service {
53 53
 
54
-	/**
55
-	 * The list of states for the Batch Analysis:
56
-	 *  - STATE_META_KEY: the batch analysis state meta key,
57
-	 *  - STATE_SUBMIT: a post/page has been submitted for analysis,
58
-	 *  - STATE_REQUEST: the plugin requested an analysis for the submitted
59
-	 *      post/page,
60
-	 *  - STATE_SUCCESS: the analysis has completed successfully,
61
-	 *  - STATE_ERROR: the analysis returned an error.
62
-	 *
63
-	 * @since 3.14.2
64
-	 */
65
-	const STATE_META_KEY = '_wl_batch_analysis_state';
66
-	const STATE_SUBMIT = 0;
67
-	const STATE_REQUEST = 1;
68
-	// ### COMPLETE states.
69
-	const STATE_SUCCESS = 2;
70
-	const STATE_ERROR = 2;
71
-
72
-	/**
73
-	 * The submit timestamp meta key. A post may have more than one timestamp.
74
-	 *
75
-	 * @since 3.14.2
76
-	 */
77
-	const SUBMIT_TIMESTAMP_META_KEY = '_wl_batch_analysis_submit_timestamp';
78
-
79
-	/**
80
-	 * The request timestamp meta key. A post may have more than one timestamp.
81
-	 *
82
-	 * @since 3.14.2
83
-	 */
84
-	const REQUEST_TIMESTAMP_META_KEY = '_wl_batch_analysis_request_timestamp';
85
-
86
-	/**
87
-	 * The complete (success or error) timestamp meta key. A post may have more
88
-	 * than one timestamp.
89
-	 *
90
-	 * @since 3.14.2
91
-	 */
92
-	const COMPLETE_TIMESTAMP_META_KEY = '_wl_batch_analysis_complete_timestamp';
93
-
94
-	/**
95
-	 * The options setting meta key. A post may have more than one setting.
96
-	 *
97
-	 * @since 3.14.2
98
-	 */
99
-	const BATCH_ANALYSIS_OPTIONS_META_KEY = '_wl_batch_analysis_options';
100
-
101
-	/**
102
-	 * The warning timestamp meta key. A post has only zero/one value.
103
-	 *
104
-	 * @since 3.14.2
105
-	 */
106
-	const WARNING_META_KEY = '_wl_batch_analysis_warning';
107
-
108
-	/**
109
-	 * Option name.
110
-	 *
111
-	 * @since  3.14.0
112
-	 */
113
-	const OPTION_NAME = 'wl_analyze_batch';
114
-
115
-	/**
116
-	 * Name of waiting to be processed queue array inside the option.
117
-	 *
118
-	 * @since  3.14.0
119
-	 */
120
-	const ANALYZE_QUEUE = 'queue';
121
-
122
-	/**
123
-	 * Name of waiting for response queue array inside the option.
124
-	 *
125
-	 * @since  3.14.0
126
-	 */
127
-	const RESPONSE_QUEUE = 'processing';
128
-
129
-	/**
130
-	 * Regular expressions that match interpolation errors.
131
-	 *
132
-	 * @since  3.17.0
133
-	 */
134
-	const INTERPOLATION_PATTERNS = array(
135
-		// Matches word before the annotation.
136
-		'~(\w)<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>~',
137
-		// Matches word after the annotation.
138
-		'~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>(\w)~',
139
-		// Matches space in the beginning of annotation name.
140
-		'~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(\s)(.*?)<\/[a-z]+>~',
141
-	);
142
-
143
-	/**
144
-	 * The {@link Wordlift} plugin instance.
145
-	 *
146
-	 * @since  3.14.0
147
-	 * @access private
148
-	 * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
149
-	 */
150
-	private $plugin;
151
-
152
-	/**
153
-	 * The {@link Wordlift_Configuration_Service} instance.
154
-	 *
155
-	 * @since  3.14.0
156
-	 * @access private
157
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
158
-	 */
159
-	private $configuration_service;
160
-
161
-	/**
162
-	 * A {@link Wordlift_Log_Service} instance.
163
-	 *
164
-	 * @since  3.14.2
165
-	 * @access private
166
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
167
-	 */
168
-	private $log;
169
-
170
-	/**
171
-	 * The {@link Class_Wordlift_Batch_Analys_Service} instance.
172
-	 *
173
-	 * @since 3.14.0
174
-	 *
175
-	 * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
176
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
177
-	 */
178
-	public function __construct( $plugin, $configuration_service ) {
179
-
180
-		$this->plugin                = $plugin;
181
-		$this->configuration_service = $configuration_service;
182
-		$this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
183
-
184
-		add_action( 'wl_async_wl_batch_analysis_request', array(
185
-			$this,
186
-			'request',
187
-		) );
188
-		add_action( 'wl_async_wl_batch_analysis_complete', array(
189
-			$this,
190
-			'complete',
191
-		) );
192
-
193
-	}
194
-
195
-	/**
196
-	 * Submit posts for Batch Analysis.
197
-	 *
198
-	 * @since 3.14.2
199
-	 *
200
-	 * @param array       $args               {
201
-	 *                                        A list of options for the Batch Analysis.
202
-	 *
203
-	 * @type string       $link               Either `default`, `no` or `yes` (`default` is used if not specified):
204
-	 *                                        * `default` doesn't set the link option - entities
205
-	 *                                           will be linked if configured so in WordLift settings.
206
-	 *                                        * `yes` links the entities.
207
-	 *                                        * `no` doesn't link the entities.
208
-	 *                                        This value is forwarded to WLS' Batch Analysis end-point.
209
-	 * @type int          $min_occurrences    The minimum number of occurrences to select
210
-	 *                                        an entity. Default `1`.
211
-	 * @type bool         $include_annotated  Whether to include annotated posts in selection.
212
-	 *                                        Default `false`.
213
-	 * @type array|int    $include            Explicitly include the specified {@link WP_Post}s.
214
-	 * @type array|int    $exclude            Explicitly exclude the specified {@link WP_Post}s.
215
-	 * @type string|null  $from               An optional date from filter (used in `post_date_gmt`).
216
-	 * @type string|null  $to                 An optional date from filter (used in `post_date_gmt`).
217
-	 * @type array|string $post_type          Specify the post type(s), by default only `post`.
218
-	 *                      }
219
-	 *
220
-	 * @return int The number of submitted {@link WP_Post}s or false on error.
221
-	 */
222
-	public function submit( $args ) {
223
-		global $wpdb;
224
-
225
-		// Parse the parameters.
226
-		$params = wp_parse_args( $args, array(
227
-			'link'              => 'default',
228
-			'min_occurrences'   => 1,
229
-			'include_annotated' => false,
230
-			'exclude'           => array(),
231
-			'from'              => null,
232
-			'to'                => null,
233
-			'post_type'         => 'post',
234
-		) );
235
-
236
-		// Validation.
237
-		if ( ! in_array( $params['link'], array( 'default', 'yes', 'no' ) ) ) {
238
-			wp_die( '`link` must be one of the following: `default`, `yes` or `no`.' );
239
-		}
240
-
241
-		if ( ! is_numeric( $params['min_occurrences'] ) || 1 > $params['min_occurrences'] ) {
242
-			wp_die( '`min_occurrences` must greater or equal 1.' );
243
-		}
244
-
245
-		// Submit the posts/pages and return the number of affected results.
246
-		// We're using a SQL query here because we could have potentially
247
-		// thousands of rows.
248
-		$count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql( $params ) ); // WPCS: cache ok, db call ok.
249
-
250
-		// Request Batch Analysis (the operation is handled asynchronously).
251
-		do_action( 'wl_batch_analysis_request' );
252
-
253
-		// Divide the count by 3 to get the number of posts/pages queued.
254
-		return $count / 3;
255
-	}
256
-
257
-	/**
258
-	 * Submit one or more {@link WP_Posts} for Batch Analysis.
259
-	 *
260
-	 * @param array    $args            {
261
-	 *                                  An array of arguments.
262
-	 *
263
-	 * @type string    $link            The link option: `default`, `yes` or
264
-	 *                                  `no`. If not set `default`.
265
-	 * @type int       $min_occurrences The minimum number of occurrences. If
266
-	 *                                  not set `1`.
267
-	 * @type array|int $ids             An array of {@link WP_Post}s' ids or one
268
-	 *                                  single numeric {@link WP_Post} id.
269
-	 *                    }
270
-	 *
271
-	 * @return float|int
272
-	 */
273
-	public function submit_posts( $args ) {
274
-		global $wpdb;
275
-
276
-		// Parse the parameters.
277
-		$params = wp_parse_args( $args, array(
278
-			'link'            => 'default',
279
-			'min_occurrences' => 1,
280
-			'ids'             => array(),
281
-		) );
282
-
283
-		// Validation.
284
-		if ( empty( $params['ids'] ) ) {
285
-			wp_die( '`ids` cannot be empty.' );
286
-		}
287
-
288
-		// Submit the posts/pages and return the number of affected results.
289
-		// We're using a SQL query here because we could have potentially
290
-		// thousands of rows.
291
-		$count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql_for_ids( $params ) ); // WPCS: cache ok, db call ok.
292
-
293
-		// Request Batch Analysis (the operation is handled asynchronously).
294
-		do_action( 'wl_batch_analysis_request' );
295
-
296
-		// Divide the count by 3 to get the number of posts/pages queued.
297
-		return $count / 3;
298
-	}
299
-
300
-	/**
301
-	 * Cancel the Batch Analysis request for the specified {@link WP_Post}s.
302
-	 *
303
-	 * @since 3.14.2
304
-	 *
305
-	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
306
-	 *                            {@link WP_Post}s' ids.
307
-	 *
308
-	 * @return false|int The number of cancelled {@link WP_Post}s or false on
309
-	 *                   error.
310
-	 */
311
-	public function cancel( $post_ids ) {
312
-		global $wpdb;
313
-
314
-		return $wpdb->query( $wpdb->prepare(
315
-			"
54
+    /**
55
+     * The list of states for the Batch Analysis:
56
+     *  - STATE_META_KEY: the batch analysis state meta key,
57
+     *  - STATE_SUBMIT: a post/page has been submitted for analysis,
58
+     *  - STATE_REQUEST: the plugin requested an analysis for the submitted
59
+     *      post/page,
60
+     *  - STATE_SUCCESS: the analysis has completed successfully,
61
+     *  - STATE_ERROR: the analysis returned an error.
62
+     *
63
+     * @since 3.14.2
64
+     */
65
+    const STATE_META_KEY = '_wl_batch_analysis_state';
66
+    const STATE_SUBMIT = 0;
67
+    const STATE_REQUEST = 1;
68
+    // ### COMPLETE states.
69
+    const STATE_SUCCESS = 2;
70
+    const STATE_ERROR = 2;
71
+
72
+    /**
73
+     * The submit timestamp meta key. A post may have more than one timestamp.
74
+     *
75
+     * @since 3.14.2
76
+     */
77
+    const SUBMIT_TIMESTAMP_META_KEY = '_wl_batch_analysis_submit_timestamp';
78
+
79
+    /**
80
+     * The request timestamp meta key. A post may have more than one timestamp.
81
+     *
82
+     * @since 3.14.2
83
+     */
84
+    const REQUEST_TIMESTAMP_META_KEY = '_wl_batch_analysis_request_timestamp';
85
+
86
+    /**
87
+     * The complete (success or error) timestamp meta key. A post may have more
88
+     * than one timestamp.
89
+     *
90
+     * @since 3.14.2
91
+     */
92
+    const COMPLETE_TIMESTAMP_META_KEY = '_wl_batch_analysis_complete_timestamp';
93
+
94
+    /**
95
+     * The options setting meta key. A post may have more than one setting.
96
+     *
97
+     * @since 3.14.2
98
+     */
99
+    const BATCH_ANALYSIS_OPTIONS_META_KEY = '_wl_batch_analysis_options';
100
+
101
+    /**
102
+     * The warning timestamp meta key. A post has only zero/one value.
103
+     *
104
+     * @since 3.14.2
105
+     */
106
+    const WARNING_META_KEY = '_wl_batch_analysis_warning';
107
+
108
+    /**
109
+     * Option name.
110
+     *
111
+     * @since  3.14.0
112
+     */
113
+    const OPTION_NAME = 'wl_analyze_batch';
114
+
115
+    /**
116
+     * Name of waiting to be processed queue array inside the option.
117
+     *
118
+     * @since  3.14.0
119
+     */
120
+    const ANALYZE_QUEUE = 'queue';
121
+
122
+    /**
123
+     * Name of waiting for response queue array inside the option.
124
+     *
125
+     * @since  3.14.0
126
+     */
127
+    const RESPONSE_QUEUE = 'processing';
128
+
129
+    /**
130
+     * Regular expressions that match interpolation errors.
131
+     *
132
+     * @since  3.17.0
133
+     */
134
+    const INTERPOLATION_PATTERNS = array(
135
+        // Matches word before the annotation.
136
+        '~(\w)<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>~',
137
+        // Matches word after the annotation.
138
+        '~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>(\w)~',
139
+        // Matches space in the beginning of annotation name.
140
+        '~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(\s)(.*?)<\/[a-z]+>~',
141
+    );
142
+
143
+    /**
144
+     * The {@link Wordlift} plugin instance.
145
+     *
146
+     * @since  3.14.0
147
+     * @access private
148
+     * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
149
+     */
150
+    private $plugin;
151
+
152
+    /**
153
+     * The {@link Wordlift_Configuration_Service} instance.
154
+     *
155
+     * @since  3.14.0
156
+     * @access private
157
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
158
+     */
159
+    private $configuration_service;
160
+
161
+    /**
162
+     * A {@link Wordlift_Log_Service} instance.
163
+     *
164
+     * @since  3.14.2
165
+     * @access private
166
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
167
+     */
168
+    private $log;
169
+
170
+    /**
171
+     * The {@link Class_Wordlift_Batch_Analys_Service} instance.
172
+     *
173
+     * @since 3.14.0
174
+     *
175
+     * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
176
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
177
+     */
178
+    public function __construct( $plugin, $configuration_service ) {
179
+
180
+        $this->plugin                = $plugin;
181
+        $this->configuration_service = $configuration_service;
182
+        $this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
183
+
184
+        add_action( 'wl_async_wl_batch_analysis_request', array(
185
+            $this,
186
+            'request',
187
+        ) );
188
+        add_action( 'wl_async_wl_batch_analysis_complete', array(
189
+            $this,
190
+            'complete',
191
+        ) );
192
+
193
+    }
194
+
195
+    /**
196
+     * Submit posts for Batch Analysis.
197
+     *
198
+     * @since 3.14.2
199
+     *
200
+     * @param array       $args               {
201
+     *                                        A list of options for the Batch Analysis.
202
+     *
203
+     * @type string       $link               Either `default`, `no` or `yes` (`default` is used if not specified):
204
+     *                                        * `default` doesn't set the link option - entities
205
+     *                                           will be linked if configured so in WordLift settings.
206
+     *                                        * `yes` links the entities.
207
+     *                                        * `no` doesn't link the entities.
208
+     *                                        This value is forwarded to WLS' Batch Analysis end-point.
209
+     * @type int          $min_occurrences    The minimum number of occurrences to select
210
+     *                                        an entity. Default `1`.
211
+     * @type bool         $include_annotated  Whether to include annotated posts in selection.
212
+     *                                        Default `false`.
213
+     * @type array|int    $include            Explicitly include the specified {@link WP_Post}s.
214
+     * @type array|int    $exclude            Explicitly exclude the specified {@link WP_Post}s.
215
+     * @type string|null  $from               An optional date from filter (used in `post_date_gmt`).
216
+     * @type string|null  $to                 An optional date from filter (used in `post_date_gmt`).
217
+     * @type array|string $post_type          Specify the post type(s), by default only `post`.
218
+     *                      }
219
+     *
220
+     * @return int The number of submitted {@link WP_Post}s or false on error.
221
+     */
222
+    public function submit( $args ) {
223
+        global $wpdb;
224
+
225
+        // Parse the parameters.
226
+        $params = wp_parse_args( $args, array(
227
+            'link'              => 'default',
228
+            'min_occurrences'   => 1,
229
+            'include_annotated' => false,
230
+            'exclude'           => array(),
231
+            'from'              => null,
232
+            'to'                => null,
233
+            'post_type'         => 'post',
234
+        ) );
235
+
236
+        // Validation.
237
+        if ( ! in_array( $params['link'], array( 'default', 'yes', 'no' ) ) ) {
238
+            wp_die( '`link` must be one of the following: `default`, `yes` or `no`.' );
239
+        }
240
+
241
+        if ( ! is_numeric( $params['min_occurrences'] ) || 1 > $params['min_occurrences'] ) {
242
+            wp_die( '`min_occurrences` must greater or equal 1.' );
243
+        }
244
+
245
+        // Submit the posts/pages and return the number of affected results.
246
+        // We're using a SQL query here because we could have potentially
247
+        // thousands of rows.
248
+        $count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql( $params ) ); // WPCS: cache ok, db call ok.
249
+
250
+        // Request Batch Analysis (the operation is handled asynchronously).
251
+        do_action( 'wl_batch_analysis_request' );
252
+
253
+        // Divide the count by 3 to get the number of posts/pages queued.
254
+        return $count / 3;
255
+    }
256
+
257
+    /**
258
+     * Submit one or more {@link WP_Posts} for Batch Analysis.
259
+     *
260
+     * @param array    $args            {
261
+     *                                  An array of arguments.
262
+     *
263
+     * @type string    $link            The link option: `default`, `yes` or
264
+     *                                  `no`. If not set `default`.
265
+     * @type int       $min_occurrences The minimum number of occurrences. If
266
+     *                                  not set `1`.
267
+     * @type array|int $ids             An array of {@link WP_Post}s' ids or one
268
+     *                                  single numeric {@link WP_Post} id.
269
+     *                    }
270
+     *
271
+     * @return float|int
272
+     */
273
+    public function submit_posts( $args ) {
274
+        global $wpdb;
275
+
276
+        // Parse the parameters.
277
+        $params = wp_parse_args( $args, array(
278
+            'link'            => 'default',
279
+            'min_occurrences' => 1,
280
+            'ids'             => array(),
281
+        ) );
282
+
283
+        // Validation.
284
+        if ( empty( $params['ids'] ) ) {
285
+            wp_die( '`ids` cannot be empty.' );
286
+        }
287
+
288
+        // Submit the posts/pages and return the number of affected results.
289
+        // We're using a SQL query here because we could have potentially
290
+        // thousands of rows.
291
+        $count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql_for_ids( $params ) ); // WPCS: cache ok, db call ok.
292
+
293
+        // Request Batch Analysis (the operation is handled asynchronously).
294
+        do_action( 'wl_batch_analysis_request' );
295
+
296
+        // Divide the count by 3 to get the number of posts/pages queued.
297
+        return $count / 3;
298
+    }
299
+
300
+    /**
301
+     * Cancel the Batch Analysis request for the specified {@link WP_Post}s.
302
+     *
303
+     * @since 3.14.2
304
+     *
305
+     * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
306
+     *                            {@link WP_Post}s' ids.
307
+     *
308
+     * @return false|int The number of cancelled {@link WP_Post}s or false on
309
+     *                   error.
310
+     */
311
+    public function cancel( $post_ids ) {
312
+        global $wpdb;
313
+
314
+        return $wpdb->query( $wpdb->prepare(
315
+            "
316 316
 			DELETE FROM $wpdb->postmeta
317 317
 			WHERE meta_key = %s
318 318
 				AND meta_value IN ( %d, %d )
319 319
 				AND post_id IN( " . implode( ',', wp_parse_id_list( $post_ids ) ) . " )
320 320
 			",
321
-			self::STATE_META_KEY,
322
-			self::STATE_SUBMIT,
323
-			self::STATE_REQUEST
324
-		) ); // WPCS: cache ok, db call ok.
321
+            self::STATE_META_KEY,
322
+            self::STATE_SUBMIT,
323
+            self::STATE_REQUEST
324
+        ) ); // WPCS: cache ok, db call ok.
325 325
 
326
-	}
326
+    }
327 327
 
328
-	/**
329
-	 * Request the batch analysis for submitted posts.
330
-	 *
331
-	 * @since 3.14.2
332
-	 */
333
-	public function request() {
328
+    /**
329
+     * Request the batch analysis for submitted posts.
330
+     *
331
+     * @since 3.14.2
332
+     */
333
+    public function request() {
334 334
 
335
-		$this->log->debug( 'Requesting analysis...' );
335
+        $this->log->debug( 'Requesting analysis...' );
336 336
 
337
-		// By default 5 posts of any post type are returned.
338
-		$posts = get_posts( array(
339
-			'fields'     => 'ids',
340
-			'meta_key'   => self::STATE_META_KEY,
341
-			'meta_value' => self::STATE_SUBMIT,
342
-			'orderby'    => 'ID',
343
-			'post_type'  => 'any',
344
-		) );
337
+        // By default 5 posts of any post type are returned.
338
+        $posts = get_posts( array(
339
+            'fields'     => 'ids',
340
+            'meta_key'   => self::STATE_META_KEY,
341
+            'meta_value' => self::STATE_SUBMIT,
342
+            'orderby'    => 'ID',
343
+            'post_type'  => 'any',
344
+        ) );
345 345
 
346
-		// Bail out if there are no submitted posts.
347
-		if ( empty( $posts ) ) {
348
-			$this->log->debug( 'No posts to submit found, checking for completed requests...' );
349
-
350
-			do_action( 'wl_batch_analysis_complete' );
346
+        // Bail out if there are no submitted posts.
347
+        if ( empty( $posts ) ) {
348
+            $this->log->debug( 'No posts to submit found, checking for completed requests...' );
349
+
350
+            do_action( 'wl_batch_analysis_complete' );
351 351
 
352
-			return;
353
-		}
352
+            return;
353
+        }
354 354
 
355
-		// Send a request for each post.
356
-		foreach ( $posts as $id ) {
355
+        // Send a request for each post.
356
+        foreach ( $posts as $id ) {
357 357
 
358
-			$this->log->debug( "Requesting analysis for post $id..." );
358
+            $this->log->debug( "Requesting analysis for post $id..." );
359 359
 
360
-			// Send the actual request to the remote service.
361
-			$result = $this->do_request( $id );
360
+            // Send the actual request to the remote service.
361
+            $result = $this->do_request( $id );
362 362
 
363
-			// Set an error if we received an error.
364
-			if ( is_wp_error( $result ) ) {
365
-				$this->log->error( "An error occurred while requesting a batch analysis for post $id: " . $result->get_error_message() );
363
+            // Set an error if we received an error.
364
+            if ( is_wp_error( $result ) ) {
365
+                $this->log->error( "An error occurred while requesting a batch analysis for post $id: " . $result->get_error_message() );
366 366
 
367
-				$this->set_state( $id, self::STATE_ERROR );
368
-			}
367
+                $this->set_state( $id, self::STATE_ERROR );
368
+            }
369 369
 
370
-		}
370
+        }
371 371
 
372
-		// Call the `wl_batch_analysis_request` action again. This is going
373
-		// to be handled by the async task.
374
-		do_action( 'wl_batch_analysis_request' );
372
+        // Call the `wl_batch_analysis_request` action again. This is going
373
+        // to be handled by the async task.
374
+        do_action( 'wl_batch_analysis_request' );
375 375
 
376
-	}
377
-
378
-	/**
379
-	 * Get the results for the Batch Analysis.
380
-	 *
381
-	 * @since 3.14.2
382
-	 */
383
-	public function complete() {
384
-
385
-		$this->log->debug( 'Requesting results...' );
386
-
387
-		// By default 5 posts of any post type are returned.
388
-		$posts = get_posts( array(
389
-			'fields'     => 'ids',
390
-			'meta_key'   => self::STATE_META_KEY,
391
-			'meta_value' => self::STATE_REQUEST,
392
-			'orderby'    => 'ID',
393
-			'post_type'  => 'any',
394
-		) );
376
+    }
377
+
378
+    /**
379
+     * Get the results for the Batch Analysis.
380
+     *
381
+     * @since 3.14.2
382
+     */
383
+    public function complete() {
384
+
385
+        $this->log->debug( 'Requesting results...' );
386
+
387
+        // By default 5 posts of any post type are returned.
388
+        $posts = get_posts( array(
389
+            'fields'     => 'ids',
390
+            'meta_key'   => self::STATE_META_KEY,
391
+            'meta_value' => self::STATE_REQUEST,
392
+            'orderby'    => 'ID',
393
+            'post_type'  => 'any',
394
+        ) );
395 395
 
396
-		// Bail out if there are no submitted posts.
397
-		if ( empty( $posts ) ) {
398
-			$this->log->debug( 'No posts in request state found.' );
396
+        // Bail out if there are no submitted posts.
397
+        if ( empty( $posts ) ) {
398
+            $this->log->debug( 'No posts in request state found.' );
399 399
 
400
-			return;
401
-		}
402
-
403
-		// Send a request for each post.
404
-		foreach ( $posts as $id ) {
405
-			$this->log->debug( "Requesting results for post $id..." );
406
-
407
-			// Send the actual request to the remote service.
408
-			$response = $this->do_complete( $id );
409
-
410
-			// Move to the next item if we don't have a reply for this one.
411
-			if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) {
412
-				continue;
413
-			}
414
-
415
-			$this->log->debug( "Results received for post $id." );
416
-
417
-			// Save the returned content as new revision.
418
-			$json = json_decode( $response['body'] );
419
-
420
-			// Continue if the content isn't set.
421
-			if ( empty( $json->content ) ) {
422
-				// The post content is empty, so is should be marked as completed.
423
-				$this->log->error( "An error occurred while decoding the batch analysis response for post $id." );
424
-
425
-				$this->set_state( $id, self::STATE_ERROR );
426
-				continue;
427
-			}
428
-
429
-			// Set the warning flag if needed.
430
-			$this->set_warning_based_on_content( $json->content, $id );
431
-
432
-			// Get the content, cleaned up if there are interpolation errors.
433
-			$pre_content = $this->fix_interpolation_errors( $json->content, $id );
434
-
435
-			/**
436
-			 * Filter: 'wl_batch_analysis_update_post_content' - Allow third
437
-			 * parties to perform additional actions when the post content is
438
-			 * updated.
439
-			 *
440
-			 * @since  3.17.0
441
-			 * @api    string $data The {@link WP_Post}'s content.
442
-			 * @api    int    $id   The {@link WP_Post}'s id.
443
-			 */
444
-			$content = apply_filters( 'wl_batch_analysis_update_post_content', $pre_content, $id );
445
-
446
-			// Update the post content.
447
-			wp_update_post( array(
448
-				'ID'           => $id,
449
-				'post_content' => wp_slash( $content ),
450
-			) );
451
-
452
-			// Update the status.
453
-			$this->set_state( $id, self::STATE_SUCCESS );
454
-
455
-			$this->log->debug( "Post $id updated with batch analysis results." );
456
-
457
-			// Set default entity type term for posts that didn't have any.
458
-			$this->maybe_set_default_term( $id );
459
-
460
-			// @todo: implement a kind of timeout that sets an error if the
461
-			// results haven't been received after a long time.
462
-		}
463
-
464
-		// Call the `wl_batch_analysis_request` action again. This is going
465
-		// to be handled by the async task.
466
-		do_action( 'wl_batch_analysis_complete' );
467
-
468
-	}
469
-
470
-	/**
471
-	 * Set a warning flag on the {@link WP_Post} if its content has suspicious
472
-	 * interpolations.
473
-	 *
474
-	 * @since 3.14.2
475
-	 *
476
-	 * @param string $content The {@link WP_Post}'s content.
477
-	 * @param int    $post_id The {@link WP_Post}'s id.
478
-	 *
479
-	 * @return string The content (for chaining operations).
480
-	 */
481
-	protected function set_warning_based_on_content( $content, $post_id ) {
482
-
483
-		// Check for suspicious interpolations.
484
-		$is_warning = $this->has_interpolation_errors( $content );
485
-
486
-		// Set the warning flag accordingly.
487
-		$this->set_warning( $post_id, $is_warning );
488
-
489
-	}
490
-
491
-	private function has_interpolation_errors( $content ) {
492
-		$matches = array();
493
-
494
-		return 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement - [^"]+" class="[^"]+ " itemid="[^"]+" >/', $content, $matches )
495
-			   || 0 < preg_match_all( ' /<[ a - z ] + id = "urn:enhancement-[^"]+ " class="[^"]+" itemid = "[^"]+ ">\s/', $content, $matches );
496
-	}
497
-
498
-	/**
499
-	 * Fix interpolation errors raised by Batch Analysis
500
-	 *
501
-	 * @param string $content The {@link WP_Post}'s content.
502
-	 * @param int    $id      The {@link WP_Post}'s id.
503
-	 *
504
-	 * @since 3.17.0
505
-	 *
506
-	 * @return string Post content without interpolations.
507
-	 */
508
-	private function fix_interpolation_errors( $content, $id ) {
509
-
510
-		// Bail out if there are no interpolation errors.
511
-		if ( ! $this->has_interpolation_errors( $content ) ) {
512
-			return $content;
513
-		}
514
-
515
-		$this->log->debug( "Fixing post $id interpolations..." );
516
-
517
-		// Remove all interpolations from the content.
518
-		return preg_replace( self::INTERPOLATION_PATTERNS, '$1$2', $content );
519
-	}
520
-
521
-	/**
522
-	 * Clear the warning flag for the specified {@link WP_Post}s.
523
-	 *
524
-	 * @since 3.14.2
525
-	 *
526
-	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
527
-	 *                            {@link WP_Post}s' ids.
528
-	 */
529
-	public function clear_warning( $post_ids ) {
530
-
531
-		foreach ( (array) $post_ids as $post_id ) {
532
-			delete_post_meta( $post_id, self::WARNING_META_KEY );
533
-		}
534
-
535
-	}
536
-
537
-	/**
538
-	 * Set the warning flag for the specified {@link WP_Post}.
539
-	 *
540
-	 * @since 3.14.2
541
-	 *
542
-	 * @param int  $post_id The {@link WP_Post}'s id.
543
-	 * @param bool $value   The flag's value.
544
-	 *
545
-	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
546
-	 *                  false on failure.
547
-	 */
548
-	private function set_warning( $post_id, $value ) {
549
-
550
-		return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
551
-	}
400
+            return;
401
+        }
402
+
403
+        // Send a request for each post.
404
+        foreach ( $posts as $id ) {
405
+            $this->log->debug( "Requesting results for post $id..." );
406
+
407
+            // Send the actual request to the remote service.
408
+            $response = $this->do_complete( $id );
409
+
410
+            // Move to the next item if we don't have a reply for this one.
411
+            if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) {
412
+                continue;
413
+            }
414
+
415
+            $this->log->debug( "Results received for post $id." );
416
+
417
+            // Save the returned content as new revision.
418
+            $json = json_decode( $response['body'] );
419
+
420
+            // Continue if the content isn't set.
421
+            if ( empty( $json->content ) ) {
422
+                // The post content is empty, so is should be marked as completed.
423
+                $this->log->error( "An error occurred while decoding the batch analysis response for post $id." );
424
+
425
+                $this->set_state( $id, self::STATE_ERROR );
426
+                continue;
427
+            }
428
+
429
+            // Set the warning flag if needed.
430
+            $this->set_warning_based_on_content( $json->content, $id );
431
+
432
+            // Get the content, cleaned up if there are interpolation errors.
433
+            $pre_content = $this->fix_interpolation_errors( $json->content, $id );
434
+
435
+            /**
436
+             * Filter: 'wl_batch_analysis_update_post_content' - Allow third
437
+             * parties to perform additional actions when the post content is
438
+             * updated.
439
+             *
440
+             * @since  3.17.0
441
+             * @api    string $data The {@link WP_Post}'s content.
442
+             * @api    int    $id   The {@link WP_Post}'s id.
443
+             */
444
+            $content = apply_filters( 'wl_batch_analysis_update_post_content', $pre_content, $id );
445
+
446
+            // Update the post content.
447
+            wp_update_post( array(
448
+                'ID'           => $id,
449
+                'post_content' => wp_slash( $content ),
450
+            ) );
451
+
452
+            // Update the status.
453
+            $this->set_state( $id, self::STATE_SUCCESS );
454
+
455
+            $this->log->debug( "Post $id updated with batch analysis results." );
456
+
457
+            // Set default entity type term for posts that didn't have any.
458
+            $this->maybe_set_default_term( $id );
459
+
460
+            // @todo: implement a kind of timeout that sets an error if the
461
+            // results haven't been received after a long time.
462
+        }
463
+
464
+        // Call the `wl_batch_analysis_request` action again. This is going
465
+        // to be handled by the async task.
466
+        do_action( 'wl_batch_analysis_complete' );
467
+
468
+    }
469
+
470
+    /**
471
+     * Set a warning flag on the {@link WP_Post} if its content has suspicious
472
+     * interpolations.
473
+     *
474
+     * @since 3.14.2
475
+     *
476
+     * @param string $content The {@link WP_Post}'s content.
477
+     * @param int    $post_id The {@link WP_Post}'s id.
478
+     *
479
+     * @return string The content (for chaining operations).
480
+     */
481
+    protected function set_warning_based_on_content( $content, $post_id ) {
482
+
483
+        // Check for suspicious interpolations.
484
+        $is_warning = $this->has_interpolation_errors( $content );
485
+
486
+        // Set the warning flag accordingly.
487
+        $this->set_warning( $post_id, $is_warning );
488
+
489
+    }
490
+
491
+    private function has_interpolation_errors( $content ) {
492
+        $matches = array();
493
+
494
+        return 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement - [^"]+" class="[^"]+ " itemid="[^"]+" >/', $content, $matches )
495
+               || 0 < preg_match_all( ' /<[ a - z ] + id = "urn:enhancement-[^"]+ " class="[^"]+" itemid = "[^"]+ ">\s/', $content, $matches );
496
+    }
497
+
498
+    /**
499
+     * Fix interpolation errors raised by Batch Analysis
500
+     *
501
+     * @param string $content The {@link WP_Post}'s content.
502
+     * @param int    $id      The {@link WP_Post}'s id.
503
+     *
504
+     * @since 3.17.0
505
+     *
506
+     * @return string Post content without interpolations.
507
+     */
508
+    private function fix_interpolation_errors( $content, $id ) {
509
+
510
+        // Bail out if there are no interpolation errors.
511
+        if ( ! $this->has_interpolation_errors( $content ) ) {
512
+            return $content;
513
+        }
514
+
515
+        $this->log->debug( "Fixing post $id interpolations..." );
516
+
517
+        // Remove all interpolations from the content.
518
+        return preg_replace( self::INTERPOLATION_PATTERNS, '$1$2', $content );
519
+    }
520
+
521
+    /**
522
+     * Clear the warning flag for the specified {@link WP_Post}s.
523
+     *
524
+     * @since 3.14.2
525
+     *
526
+     * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
527
+     *                            {@link WP_Post}s' ids.
528
+     */
529
+    public function clear_warning( $post_ids ) {
530
+
531
+        foreach ( (array) $post_ids as $post_id ) {
532
+            delete_post_meta( $post_id, self::WARNING_META_KEY );
533
+        }
534
+
535
+    }
536
+
537
+    /**
538
+     * Set the warning flag for the specified {@link WP_Post}.
539
+     *
540
+     * @since 3.14.2
541
+     *
542
+     * @param int  $post_id The {@link WP_Post}'s id.
543
+     * @param bool $value   The flag's value.
544
+     *
545
+     * @return int|bool Meta ID if the key didn't exist, true on successful update,
546
+     *                  false on failure.
547
+     */
548
+    private function set_warning( $post_id, $value ) {
549
+
550
+        return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
551
+    }
552 552
 
553 553
 //	/**
554 554
 //	 * Get the post/page batch analysis state.
@@ -564,231 +564,231 @@  discard block
 block discarded – undo
564 564
 //		return get_post_meta( $post_id, self::STATE_META_KEY, true );
565 565
 //	}
566 566
 
567
-	/**
568
-	 * Set the post/page batch analysis state.
569
-	 *
570
-	 * @since 3.14.2
571
-	 *
572
-	 * @param int $post_id The {@link WP_Post}'s id.
573
-	 * @param int $value   The new state.
574
-	 *
575
-	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
576
-	 *                  false on failure.
577
-	 */
578
-	private function set_state( $post_id, $value ) {
579
-
580
-		// Update the state.
581
-		$result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
582
-
583
-		// Update timestamps as required.
584
-		switch ( $value ) {
585
-
586
-			// ### REQUEST state.
587
-			case self::STATE_REQUEST:
588
-				add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
589
-				break;
590
-
591
-			// ### SUCCESS/ERROR state.
592
-			case self::STATE_SUCCESS:
593
-			case self::STATE_ERROR:
594
-				add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
595
-				break;
596
-		}
597
-
598
-		// Finally return the result.
599
-		return $result;
600
-	}
601
-
602
-	/**
603
-	 * Get the options setting for a {@link WP_Post}.
604
-	 *
605
-	 * If there are multiple link settings, only the last one is returned.
606
-	 *
607
-	 * @since 3.14.2
608
-	 *
609
-	 * @param int $post_id The {@link WP_Post}'s id.
610
-	 *
611
-	 * @return array The link settings.
612
-	 */
613
-	private function get_options( $post_id ) {
614
-
615
-		$values = get_post_meta( $post_id, self::BATCH_ANALYSIS_OPTIONS_META_KEY );
616
-
617
-		return end( $values ) ?: array(
618
-			'links'           => 'default',
619
-			'min_occurrences' => 1,
620
-		);
621
-	}
622
-
623
-	/**
624
-	 * Get the array of post IDS waiting in the queue to start processing.
625
-	 *
626
-	 * @since 3.14.0
627
-	 *
628
-	 * @return array The waiting to be processed post ids queue.
629
-	 */
630
-	public function waiting_for_analysis() {
631
-
632
-		return get_posts( array(
633
-			'posts_per_page' => - 1,
634
-			'fields'         => 'ids',
635
-			'post_status'    => 'any',
636
-			'meta_key'       => self::STATE_META_KEY,
637
-			'meta_value'     => self::STATE_SUBMIT,
638
-			'orderby'        => 'ID',
639
-			'post_type'      => 'any',
640
-			// Add any because posts from multiple posts types may be waiting.
641
-		) );
642
-	}
643
-
644
-	/**
645
-	 * Get the array of post IDS waiting for response.
646
-	 *
647
-	 * @deprecated
648
-	 * @since 3.14.0
649
-	 *
650
-	 * @return array The waiting for response post ids queue.
651
-	 */
652
-	public function waiting_for_response() {
653
-
654
-		return get_posts( array(
655
-			'posts_per_page' => - 1,
656
-			'fields'         => 'ids',
657
-			'post_status'    => 'any',
658
-			'meta_key'       => self::STATE_META_KEY,
659
-			'meta_value'     => self::STATE_REQUEST,
660
-			'orderby'        => 'ID',
661
-			'post_type'      => 'any',
662
-			// Add any because posts from multiple posts types may be waiting.
663
-		) );
664
-	}
665
-
666
-	/**
667
-	 * Request the analysis for the specified {@link WP_Post}.
668
-	 *
669
-	 * @since 3.14.2
670
-	 *
671
-	 * @param int $post_id The {@link WP_Post}'s id.
672
-	 *
673
-	 * @return WP_Error|array The response or WP_Error on failure.
674
-	 */
675
-	private function do_request( $post_id ) {
676
-
677
-		// Change the state to `REQUEST`.
678
-		$this->set_state( $post_id, self::STATE_REQUEST );
679
-
680
-		// Get the post.
681
-		$post = get_post( $post_id );
682
-
683
-		// Bail out if the post isn't found.
684
-		if ( null === $post ) {
685
-			$this->log->warn( "Post $post_id not found." );
686
-
687
-			return new WP_Error( 0, "Cannot find post $post_id." );
688
-		}
689
-
690
-		// Get the link setting.
691
-		$options = $this->get_options( $post_id );
692
-
693
-		$this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $options['link'] . ', min_occurrences :: ' . $options['min_occurrences'] . ' ] ...' );
694
-
695
-		// Get the batch analysis URL.
696
-		$url = $this->configuration_service->get_batch_analysis_url();
697
-
698
-		// Prepare the POST parameters.
699
-		$params = array(
700
-			'id'              => $post->ID,
701
-			'key'             => $this->configuration_service->get_key(),
702
-			'content'         => $post->post_content,
703
-			'contentLanguage' => $this->configuration_service->get_language_code(),
704
-			'version'         => $this->plugin->get_version(),
705
-			'scope'           => 'local',
706
-			'link'            => $options['link'],
707
-			'minOccurrences'  => $options['min_occurrences'],
708
-		);
709
-
710
-		// Get the HTTP options.
711
-		$args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
712
-			'method'      => 'POST',
713
-			'headers'     => array(
714
-				'Accept'       => 'application/json',
715
-				'Content-type' => 'application/json; charset=UTF-8',
716
-			),
717
-			// we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
718
-			'httpversion' => '1.0',
719
-			'body'        => wp_json_encode( $params ),
720
-		) );
721
-
722
-		$this->log->debug( "Posting analysis request for post $post_id to $url..." );
723
-
724
-		// Post the parameter.
725
-		return wp_remote_post( $url, $args );
726
-	}
727
-
728
-	/**
729
-	 * Get the Batch Analysis results for the specified {@link WP_Post}.
730
-	 *
731
-	 * @since 3.14.2
732
-	 *
733
-	 * @param int $post_id The {@link WP_Post}'s id.
734
-	 *
735
-	 * @return WP_Error|array The response or WP_Error on failure.
736
-	 */
737
-	private function do_complete( $post_id ) {
738
-
739
-		$post = get_post( $post_id );
740
-
741
-		if ( null === $post ) {
742
-			// Post was possibly deleted, just bailout.
743
-			return new WP_Error( 0, "Post $post_id not found . " );
744
-		}
745
-
746
-		$url = $this->configuration_service->get_batch_analysis_url();
747
-		$key = $this->configuration_service->get_key();
748
-		$url = $url . '/' . $post->ID . '?key=' . $key;
749
-
750
-		return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
751
-	}
752
-
753
-	/**
754
-	 * Get the {@link WP_Post}s' ids flagged with warnings.
755
-	 *
756
-	 * @since 3.14.2
757
-	 *
758
-	 * @return array An array of {@link WP_Post}s' ids.
759
-	 */
760
-	public function get_warnings() {
761
-
762
-		return get_posts( array(
763
-			'fields'      => 'ids',
764
-			'numberposts' => - 1,
765
-			'post_status' => 'any',
766
-			'meta_key'    => self::WARNING_META_KEY,
767
-			'meta_value'  => 'yes',
768
-			'post_type'   => 'any',
769
-			// Add any because posts from multiple posts types may be waiting.
770
-		) );
771
-	}
772
-
773
-	/**
774
-	 * Check whether the term has entity type associated and set default term if it hasn't.
775
-	 *
776
-	 * @since 3.17.0
777
-	 *
778
-	 * @param int $id The {@link WP_Post}'s id.
779
-	 */
780
-	private function maybe_set_default_term( $id ) {
781
-		// Check whether the post has any of the WordLift entity types.
782
-		$has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
783
-
784
-		// Bail if the term is associated with entity types already.
785
-		if ( ! empty( $has_term ) ) {
786
-			return;
787
-		}
788
-
789
-		// Set the default `article` term.
790
-		wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
791
-
792
-	}
567
+    /**
568
+     * Set the post/page batch analysis state.
569
+     *
570
+     * @since 3.14.2
571
+     *
572
+     * @param int $post_id The {@link WP_Post}'s id.
573
+     * @param int $value   The new state.
574
+     *
575
+     * @return int|bool Meta ID if the key didn't exist, true on successful update,
576
+     *                  false on failure.
577
+     */
578
+    private function set_state( $post_id, $value ) {
579
+
580
+        // Update the state.
581
+        $result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
582
+
583
+        // Update timestamps as required.
584
+        switch ( $value ) {
585
+
586
+            // ### REQUEST state.
587
+            case self::STATE_REQUEST:
588
+                add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
589
+                break;
590
+
591
+            // ### SUCCESS/ERROR state.
592
+            case self::STATE_SUCCESS:
593
+            case self::STATE_ERROR:
594
+                add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
595
+                break;
596
+        }
597
+
598
+        // Finally return the result.
599
+        return $result;
600
+    }
601
+
602
+    /**
603
+     * Get the options setting for a {@link WP_Post}.
604
+     *
605
+     * If there are multiple link settings, only the last one is returned.
606
+     *
607
+     * @since 3.14.2
608
+     *
609
+     * @param int $post_id The {@link WP_Post}'s id.
610
+     *
611
+     * @return array The link settings.
612
+     */
613
+    private function get_options( $post_id ) {
614
+
615
+        $values = get_post_meta( $post_id, self::BATCH_ANALYSIS_OPTIONS_META_KEY );
616
+
617
+        return end( $values ) ?: array(
618
+            'links'           => 'default',
619
+            'min_occurrences' => 1,
620
+        );
621
+    }
622
+
623
+    /**
624
+     * Get the array of post IDS waiting in the queue to start processing.
625
+     *
626
+     * @since 3.14.0
627
+     *
628
+     * @return array The waiting to be processed post ids queue.
629
+     */
630
+    public function waiting_for_analysis() {
631
+
632
+        return get_posts( array(
633
+            'posts_per_page' => - 1,
634
+            'fields'         => 'ids',
635
+            'post_status'    => 'any',
636
+            'meta_key'       => self::STATE_META_KEY,
637
+            'meta_value'     => self::STATE_SUBMIT,
638
+            'orderby'        => 'ID',
639
+            'post_type'      => 'any',
640
+            // Add any because posts from multiple posts types may be waiting.
641
+        ) );
642
+    }
643
+
644
+    /**
645
+     * Get the array of post IDS waiting for response.
646
+     *
647
+     * @deprecated
648
+     * @since 3.14.0
649
+     *
650
+     * @return array The waiting for response post ids queue.
651
+     */
652
+    public function waiting_for_response() {
653
+
654
+        return get_posts( array(
655
+            'posts_per_page' => - 1,
656
+            'fields'         => 'ids',
657
+            'post_status'    => 'any',
658
+            'meta_key'       => self::STATE_META_KEY,
659
+            'meta_value'     => self::STATE_REQUEST,
660
+            'orderby'        => 'ID',
661
+            'post_type'      => 'any',
662
+            // Add any because posts from multiple posts types may be waiting.
663
+        ) );
664
+    }
665
+
666
+    /**
667
+     * Request the analysis for the specified {@link WP_Post}.
668
+     *
669
+     * @since 3.14.2
670
+     *
671
+     * @param int $post_id The {@link WP_Post}'s id.
672
+     *
673
+     * @return WP_Error|array The response or WP_Error on failure.
674
+     */
675
+    private function do_request( $post_id ) {
676
+
677
+        // Change the state to `REQUEST`.
678
+        $this->set_state( $post_id, self::STATE_REQUEST );
679
+
680
+        // Get the post.
681
+        $post = get_post( $post_id );
682
+
683
+        // Bail out if the post isn't found.
684
+        if ( null === $post ) {
685
+            $this->log->warn( "Post $post_id not found." );
686
+
687
+            return new WP_Error( 0, "Cannot find post $post_id." );
688
+        }
689
+
690
+        // Get the link setting.
691
+        $options = $this->get_options( $post_id );
692
+
693
+        $this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $options['link'] . ', min_occurrences :: ' . $options['min_occurrences'] . ' ] ...' );
694
+
695
+        // Get the batch analysis URL.
696
+        $url = $this->configuration_service->get_batch_analysis_url();
697
+
698
+        // Prepare the POST parameters.
699
+        $params = array(
700
+            'id'              => $post->ID,
701
+            'key'             => $this->configuration_service->get_key(),
702
+            'content'         => $post->post_content,
703
+            'contentLanguage' => $this->configuration_service->get_language_code(),
704
+            'version'         => $this->plugin->get_version(),
705
+            'scope'           => 'local',
706
+            'link'            => $options['link'],
707
+            'minOccurrences'  => $options['min_occurrences'],
708
+        );
709
+
710
+        // Get the HTTP options.
711
+        $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
712
+            'method'      => 'POST',
713
+            'headers'     => array(
714
+                'Accept'       => 'application/json',
715
+                'Content-type' => 'application/json; charset=UTF-8',
716
+            ),
717
+            // we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
718
+            'httpversion' => '1.0',
719
+            'body'        => wp_json_encode( $params ),
720
+        ) );
721
+
722
+        $this->log->debug( "Posting analysis request for post $post_id to $url..." );
723
+
724
+        // Post the parameter.
725
+        return wp_remote_post( $url, $args );
726
+    }
727
+
728
+    /**
729
+     * Get the Batch Analysis results for the specified {@link WP_Post}.
730
+     *
731
+     * @since 3.14.2
732
+     *
733
+     * @param int $post_id The {@link WP_Post}'s id.
734
+     *
735
+     * @return WP_Error|array The response or WP_Error on failure.
736
+     */
737
+    private function do_complete( $post_id ) {
738
+
739
+        $post = get_post( $post_id );
740
+
741
+        if ( null === $post ) {
742
+            // Post was possibly deleted, just bailout.
743
+            return new WP_Error( 0, "Post $post_id not found . " );
744
+        }
745
+
746
+        $url = $this->configuration_service->get_batch_analysis_url();
747
+        $key = $this->configuration_service->get_key();
748
+        $url = $url . '/' . $post->ID . '?key=' . $key;
749
+
750
+        return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
751
+    }
752
+
753
+    /**
754
+     * Get the {@link WP_Post}s' ids flagged with warnings.
755
+     *
756
+     * @since 3.14.2
757
+     *
758
+     * @return array An array of {@link WP_Post}s' ids.
759
+     */
760
+    public function get_warnings() {
761
+
762
+        return get_posts( array(
763
+            'fields'      => 'ids',
764
+            'numberposts' => - 1,
765
+            'post_status' => 'any',
766
+            'meta_key'    => self::WARNING_META_KEY,
767
+            'meta_value'  => 'yes',
768
+            'post_type'   => 'any',
769
+            // Add any because posts from multiple posts types may be waiting.
770
+        ) );
771
+    }
772
+
773
+    /**
774
+     * Check whether the term has entity type associated and set default term if it hasn't.
775
+     *
776
+     * @since 3.17.0
777
+     *
778
+     * @param int $id The {@link WP_Post}'s id.
779
+     */
780
+    private function maybe_set_default_term( $id ) {
781
+        // Check whether the post has any of the WordLift entity types.
782
+        $has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
783
+
784
+        // Bail if the term is associated with entity types already.
785
+        if ( ! empty( $has_term ) ) {
786
+            return;
787
+        }
788
+
789
+        // Set the default `article` term.
790
+        wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
791
+
792
+    }
793 793
 
794 794
 }
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -175,20 +175,20 @@  discard block
 block discarded – undo
175 175
 	 * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
176 176
 	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
177 177
 	 */
178
-	public function __construct( $plugin, $configuration_service ) {
178
+	public function __construct($plugin, $configuration_service) {
179 179
 
180 180
 		$this->plugin                = $plugin;
181 181
 		$this->configuration_service = $configuration_service;
182
-		$this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
182
+		$this->log                   = Wordlift_Log_Service::get_logger('Wordlift_Batch_Analysis_Service');
183 183
 
184
-		add_action( 'wl_async_wl_batch_analysis_request', array(
184
+		add_action('wl_async_wl_batch_analysis_request', array(
185 185
 			$this,
186 186
 			'request',
187
-		) );
188
-		add_action( 'wl_async_wl_batch_analysis_complete', array(
187
+		));
188
+		add_action('wl_async_wl_batch_analysis_complete', array(
189 189
 			$this,
190 190
 			'complete',
191
-		) );
191
+		));
192 192
 
193 193
 	}
194 194
 
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @return int The number of submitted {@link WP_Post}s or false on error.
221 221
 	 */
222
-	public function submit( $args ) {
222
+	public function submit($args) {
223 223
 		global $wpdb;
224 224
 
225 225
 		// Parse the parameters.
226
-		$params = wp_parse_args( $args, array(
226
+		$params = wp_parse_args($args, array(
227 227
 			'link'              => 'default',
228 228
 			'min_occurrences'   => 1,
229 229
 			'include_annotated' => false,
@@ -231,24 +231,24 @@  discard block
 block discarded – undo
231 231
 			'from'              => null,
232 232
 			'to'                => null,
233 233
 			'post_type'         => 'post',
234
-		) );
234
+		));
235 235
 
236 236
 		// Validation.
237
-		if ( ! in_array( $params['link'], array( 'default', 'yes', 'no' ) ) ) {
238
-			wp_die( '`link` must be one of the following: `default`, `yes` or `no`.' );
237
+		if ( ! in_array($params['link'], array('default', 'yes', 'no'))) {
238
+			wp_die('`link` must be one of the following: `default`, `yes` or `no`.');
239 239
 		}
240 240
 
241
-		if ( ! is_numeric( $params['min_occurrences'] ) || 1 > $params['min_occurrences'] ) {
242
-			wp_die( '`min_occurrences` must greater or equal 1.' );
241
+		if ( ! is_numeric($params['min_occurrences']) || 1 > $params['min_occurrences']) {
242
+			wp_die('`min_occurrences` must greater or equal 1.');
243 243
 		}
244 244
 
245 245
 		// Submit the posts/pages and return the number of affected results.
246 246
 		// We're using a SQL query here because we could have potentially
247 247
 		// thousands of rows.
248
-		$count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql( $params ) ); // WPCS: cache ok, db call ok.
248
+		$count = $wpdb->query(Wordlift_Batch_Analysis_Sql_Helper::get_sql($params)); // WPCS: cache ok, db call ok.
249 249
 
250 250
 		// Request Batch Analysis (the operation is handled asynchronously).
251
-		do_action( 'wl_batch_analysis_request' );
251
+		do_action('wl_batch_analysis_request');
252 252
 
253 253
 		// Divide the count by 3 to get the number of posts/pages queued.
254 254
 		return $count / 3;
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return float|int
272 272
 	 */
273
-	public function submit_posts( $args ) {
273
+	public function submit_posts($args) {
274 274
 		global $wpdb;
275 275
 
276 276
 		// Parse the parameters.
277
-		$params = wp_parse_args( $args, array(
277
+		$params = wp_parse_args($args, array(
278 278
 			'link'            => 'default',
279 279
 			'min_occurrences' => 1,
280 280
 			'ids'             => array(),
281
-		) );
281
+		));
282 282
 
283 283
 		// Validation.
284
-		if ( empty( $params['ids'] ) ) {
285
-			wp_die( '`ids` cannot be empty.' );
284
+		if (empty($params['ids'])) {
285
+			wp_die('`ids` cannot be empty.');
286 286
 		}
287 287
 
288 288
 		// Submit the posts/pages and return the number of affected results.
289 289
 		// We're using a SQL query here because we could have potentially
290 290
 		// thousands of rows.
291
-		$count = $wpdb->query( Wordlift_Batch_Analysis_Sql_Helper::get_sql_for_ids( $params ) ); // WPCS: cache ok, db call ok.
291
+		$count = $wpdb->query(Wordlift_Batch_Analysis_Sql_Helper::get_sql_for_ids($params)); // WPCS: cache ok, db call ok.
292 292
 
293 293
 		// Request Batch Analysis (the operation is handled asynchronously).
294
-		do_action( 'wl_batch_analysis_request' );
294
+		do_action('wl_batch_analysis_request');
295 295
 
296 296
 		// Divide the count by 3 to get the number of posts/pages queued.
297 297
 		return $count / 3;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	 * @return false|int The number of cancelled {@link WP_Post}s or false on
309 309
 	 *                   error.
310 310
 	 */
311
-	public function cancel( $post_ids ) {
311
+	public function cancel($post_ids) {
312 312
 		global $wpdb;
313 313
 
314
-		return $wpdb->query( $wpdb->prepare(
314
+		return $wpdb->query($wpdb->prepare(
315 315
 			"
316 316
 			DELETE FROM $wpdb->postmeta
317 317
 			WHERE meta_key = %s
318 318
 				AND meta_value IN ( %d, %d )
319
-				AND post_id IN( " . implode( ',', wp_parse_id_list( $post_ids ) ) . " )
319
+				AND post_id IN( ".implode(',', wp_parse_id_list($post_ids))." )
320 320
 			",
321 321
 			self::STATE_META_KEY,
322 322
 			self::STATE_SUBMIT,
323 323
 			self::STATE_REQUEST
324
-		) ); // WPCS: cache ok, db call ok.
324
+		)); // WPCS: cache ok, db call ok.
325 325
 
326 326
 	}
327 327
 
@@ -332,46 +332,46 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	public function request() {
334 334
 
335
-		$this->log->debug( 'Requesting analysis...' );
335
+		$this->log->debug('Requesting analysis...');
336 336
 
337 337
 		// By default 5 posts of any post type are returned.
338
-		$posts = get_posts( array(
338
+		$posts = get_posts(array(
339 339
 			'fields'     => 'ids',
340 340
 			'meta_key'   => self::STATE_META_KEY,
341 341
 			'meta_value' => self::STATE_SUBMIT,
342 342
 			'orderby'    => 'ID',
343 343
 			'post_type'  => 'any',
344
-		) );
344
+		));
345 345
 
346 346
 		// Bail out if there are no submitted posts.
347
-		if ( empty( $posts ) ) {
348
-			$this->log->debug( 'No posts to submit found, checking for completed requests...' );
347
+		if (empty($posts)) {
348
+			$this->log->debug('No posts to submit found, checking for completed requests...');
349 349
 
350
-			do_action( 'wl_batch_analysis_complete' );
350
+			do_action('wl_batch_analysis_complete');
351 351
 
352 352
 			return;
353 353
 		}
354 354
 
355 355
 		// Send a request for each post.
356
-		foreach ( $posts as $id ) {
356
+		foreach ($posts as $id) {
357 357
 
358
-			$this->log->debug( "Requesting analysis for post $id..." );
358
+			$this->log->debug("Requesting analysis for post $id...");
359 359
 
360 360
 			// Send the actual request to the remote service.
361
-			$result = $this->do_request( $id );
361
+			$result = $this->do_request($id);
362 362
 
363 363
 			// Set an error if we received an error.
364
-			if ( is_wp_error( $result ) ) {
365
-				$this->log->error( "An error occurred while requesting a batch analysis for post $id: " . $result->get_error_message() );
364
+			if (is_wp_error($result)) {
365
+				$this->log->error("An error occurred while requesting a batch analysis for post $id: ".$result->get_error_message());
366 366
 
367
-				$this->set_state( $id, self::STATE_ERROR );
367
+				$this->set_state($id, self::STATE_ERROR);
368 368
 			}
369 369
 
370 370
 		}
371 371
 
372 372
 		// Call the `wl_batch_analysis_request` action again. This is going
373 373
 		// to be handled by the async task.
374
-		do_action( 'wl_batch_analysis_request' );
374
+		do_action('wl_batch_analysis_request');
375 375
 
376 376
 	}
377 377
 
@@ -382,55 +382,55 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	public function complete() {
384 384
 
385
-		$this->log->debug( 'Requesting results...' );
385
+		$this->log->debug('Requesting results...');
386 386
 
387 387
 		// By default 5 posts of any post type are returned.
388
-		$posts = get_posts( array(
388
+		$posts = get_posts(array(
389 389
 			'fields'     => 'ids',
390 390
 			'meta_key'   => self::STATE_META_KEY,
391 391
 			'meta_value' => self::STATE_REQUEST,
392 392
 			'orderby'    => 'ID',
393 393
 			'post_type'  => 'any',
394
-		) );
394
+		));
395 395
 
396 396
 		// Bail out if there are no submitted posts.
397
-		if ( empty( $posts ) ) {
398
-			$this->log->debug( 'No posts in request state found.' );
397
+		if (empty($posts)) {
398
+			$this->log->debug('No posts in request state found.');
399 399
 
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		// Send a request for each post.
404
-		foreach ( $posts as $id ) {
405
-			$this->log->debug( "Requesting results for post $id..." );
404
+		foreach ($posts as $id) {
405
+			$this->log->debug("Requesting results for post $id...");
406 406
 
407 407
 			// Send the actual request to the remote service.
408
-			$response = $this->do_complete( $id );
408
+			$response = $this->do_complete($id);
409 409
 
410 410
 			// Move to the next item if we don't have a reply for this one.
411
-			if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) {
411
+			if (is_wp_error($response) || ! isset($response['body'])) {
412 412
 				continue;
413 413
 			}
414 414
 
415
-			$this->log->debug( "Results received for post $id." );
415
+			$this->log->debug("Results received for post $id.");
416 416
 
417 417
 			// Save the returned content as new revision.
418
-			$json = json_decode( $response['body'] );
418
+			$json = json_decode($response['body']);
419 419
 
420 420
 			// Continue if the content isn't set.
421
-			if ( empty( $json->content ) ) {
421
+			if (empty($json->content)) {
422 422
 				// The post content is empty, so is should be marked as completed.
423
-				$this->log->error( "An error occurred while decoding the batch analysis response for post $id." );
423
+				$this->log->error("An error occurred while decoding the batch analysis response for post $id.");
424 424
 
425
-				$this->set_state( $id, self::STATE_ERROR );
425
+				$this->set_state($id, self::STATE_ERROR);
426 426
 				continue;
427 427
 			}
428 428
 
429 429
 			// Set the warning flag if needed.
430
-			$this->set_warning_based_on_content( $json->content, $id );
430
+			$this->set_warning_based_on_content($json->content, $id);
431 431
 
432 432
 			// Get the content, cleaned up if there are interpolation errors.
433
-			$pre_content = $this->fix_interpolation_errors( $json->content, $id );
433
+			$pre_content = $this->fix_interpolation_errors($json->content, $id);
434 434
 
435 435
 			/**
436 436
 			 * Filter: 'wl_batch_analysis_update_post_content' - Allow third
@@ -441,21 +441,21 @@  discard block
 block discarded – undo
441 441
 			 * @api    string $data The {@link WP_Post}'s content.
442 442
 			 * @api    int    $id   The {@link WP_Post}'s id.
443 443
 			 */
444
-			$content = apply_filters( 'wl_batch_analysis_update_post_content', $pre_content, $id );
444
+			$content = apply_filters('wl_batch_analysis_update_post_content', $pre_content, $id);
445 445
 
446 446
 			// Update the post content.
447
-			wp_update_post( array(
447
+			wp_update_post(array(
448 448
 				'ID'           => $id,
449
-				'post_content' => wp_slash( $content ),
450
-			) );
449
+				'post_content' => wp_slash($content),
450
+			));
451 451
 
452 452
 			// Update the status.
453
-			$this->set_state( $id, self::STATE_SUCCESS );
453
+			$this->set_state($id, self::STATE_SUCCESS);
454 454
 
455
-			$this->log->debug( "Post $id updated with batch analysis results." );
455
+			$this->log->debug("Post $id updated with batch analysis results.");
456 456
 
457 457
 			// Set default entity type term for posts that didn't have any.
458
-			$this->maybe_set_default_term( $id );
458
+			$this->maybe_set_default_term($id);
459 459
 
460 460
 			// @todo: implement a kind of timeout that sets an error if the
461 461
 			// results haven't been received after a long time.
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 
464 464
 		// Call the `wl_batch_analysis_request` action again. This is going
465 465
 		// to be handled by the async task.
466
-		do_action( 'wl_batch_analysis_complete' );
466
+		do_action('wl_batch_analysis_complete');
467 467
 
468 468
 	}
469 469
 
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
 	 *
479 479
 	 * @return string The content (for chaining operations).
480 480
 	 */
481
-	protected function set_warning_based_on_content( $content, $post_id ) {
481
+	protected function set_warning_based_on_content($content, $post_id) {
482 482
 
483 483
 		// Check for suspicious interpolations.
484
-		$is_warning = $this->has_interpolation_errors( $content );
484
+		$is_warning = $this->has_interpolation_errors($content);
485 485
 
486 486
 		// Set the warning flag accordingly.
487
-		$this->set_warning( $post_id, $is_warning );
487
+		$this->set_warning($post_id, $is_warning);
488 488
 
489 489
 	}
490 490
 
491
-	private function has_interpolation_errors( $content ) {
491
+	private function has_interpolation_errors($content) {
492 492
 		$matches = array();
493 493
 
494
-		return 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement - [^"]+" class="[^"]+ " itemid="[^"]+" >/', $content, $matches )
495
-			   || 0 < preg_match_all( ' /<[ a - z ] + id = "urn:enhancement-[^"]+ " class="[^"]+" itemid = "[^"]+ ">\s/', $content, $matches );
494
+		return 0 < preg_match_all('/\w<[a-z]+ id="urn:enhancement - [^"]+" class="[^"]+ " itemid="[^"]+" >/', $content, $matches)
495
+			   || 0 < preg_match_all(' /<[ a - z ] + id = "urn:enhancement-[^"]+ " class="[^"]+" itemid = "[^"]+ ">\s/', $content, $matches);
496 496
 	}
497 497
 
498 498
 	/**
@@ -505,17 +505,17 @@  discard block
 block discarded – undo
505 505
 	 *
506 506
 	 * @return string Post content without interpolations.
507 507
 	 */
508
-	private function fix_interpolation_errors( $content, $id ) {
508
+	private function fix_interpolation_errors($content, $id) {
509 509
 
510 510
 		// Bail out if there are no interpolation errors.
511
-		if ( ! $this->has_interpolation_errors( $content ) ) {
511
+		if ( ! $this->has_interpolation_errors($content)) {
512 512
 			return $content;
513 513
 		}
514 514
 
515
-		$this->log->debug( "Fixing post $id interpolations..." );
515
+		$this->log->debug("Fixing post $id interpolations...");
516 516
 
517 517
 		// Remove all interpolations from the content.
518
-		return preg_replace( self::INTERPOLATION_PATTERNS, '$1$2', $content );
518
+		return preg_replace(self::INTERPOLATION_PATTERNS, '$1$2', $content);
519 519
 	}
520 520
 
521 521
 	/**
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
527 527
 	 *                            {@link WP_Post}s' ids.
528 528
 	 */
529
-	public function clear_warning( $post_ids ) {
529
+	public function clear_warning($post_ids) {
530 530
 
531
-		foreach ( (array) $post_ids as $post_id ) {
532
-			delete_post_meta( $post_id, self::WARNING_META_KEY );
531
+		foreach ((array) $post_ids as $post_id) {
532
+			delete_post_meta($post_id, self::WARNING_META_KEY);
533 533
 		}
534 534
 
535 535
 	}
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
546 546
 	 *                  false on failure.
547 547
 	 */
548
-	private function set_warning( $post_id, $value ) {
548
+	private function set_warning($post_id, $value) {
549 549
 
550
-		return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
550
+		return update_post_meta($post_id, self::WARNING_META_KEY, (true === $value ? 'yes' : 'no'));
551 551
 	}
552 552
 
553 553
 //	/**
@@ -575,23 +575,23 @@  discard block
 block discarded – undo
575 575
 	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
576 576
 	 *                  false on failure.
577 577
 	 */
578
-	private function set_state( $post_id, $value ) {
578
+	private function set_state($post_id, $value) {
579 579
 
580 580
 		// Update the state.
581
-		$result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
581
+		$result = update_post_meta($post_id, self::STATE_META_KEY, $value);
582 582
 
583 583
 		// Update timestamps as required.
584
-		switch ( $value ) {
584
+		switch ($value) {
585 585
 
586 586
 			// ### REQUEST state.
587 587
 			case self::STATE_REQUEST:
588
-				add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
588
+				add_post_meta($post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time('mysql', true));
589 589
 				break;
590 590
 
591 591
 			// ### SUCCESS/ERROR state.
592 592
 			case self::STATE_SUCCESS:
593 593
 			case self::STATE_ERROR:
594
-				add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
594
+				add_post_meta($post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time('mysql', true));
595 595
 				break;
596 596
 		}
597 597
 
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
 	 *
611 611
 	 * @return array The link settings.
612 612
 	 */
613
-	private function get_options( $post_id ) {
613
+	private function get_options($post_id) {
614 614
 
615
-		$values = get_post_meta( $post_id, self::BATCH_ANALYSIS_OPTIONS_META_KEY );
615
+		$values = get_post_meta($post_id, self::BATCH_ANALYSIS_OPTIONS_META_KEY);
616 616
 
617
-		return end( $values ) ?: array(
617
+		return end($values) ?: array(
618 618
 			'links'           => 'default',
619 619
 			'min_occurrences' => 1,
620 620
 		);
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 */
630 630
 	public function waiting_for_analysis() {
631 631
 
632
-		return get_posts( array(
633
-			'posts_per_page' => - 1,
632
+		return get_posts(array(
633
+			'posts_per_page' => -1,
634 634
 			'fields'         => 'ids',
635 635
 			'post_status'    => 'any',
636 636
 			'meta_key'       => self::STATE_META_KEY,
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			'orderby'        => 'ID',
639 639
 			'post_type'      => 'any',
640 640
 			// Add any because posts from multiple posts types may be waiting.
641
-		) );
641
+		));
642 642
 	}
643 643
 
644 644
 	/**
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 	 */
652 652
 	public function waiting_for_response() {
653 653
 
654
-		return get_posts( array(
655
-			'posts_per_page' => - 1,
654
+		return get_posts(array(
655
+			'posts_per_page' => -1,
656 656
 			'fields'         => 'ids',
657 657
 			'post_status'    => 'any',
658 658
 			'meta_key'       => self::STATE_META_KEY,
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			'orderby'        => 'ID',
661 661
 			'post_type'      => 'any',
662 662
 			// Add any because posts from multiple posts types may be waiting.
663
-		) );
663
+		));
664 664
 	}
665 665
 
666 666
 	/**
@@ -672,25 +672,25 @@  discard block
 block discarded – undo
672 672
 	 *
673 673
 	 * @return WP_Error|array The response or WP_Error on failure.
674 674
 	 */
675
-	private function do_request( $post_id ) {
675
+	private function do_request($post_id) {
676 676
 
677 677
 		// Change the state to `REQUEST`.
678
-		$this->set_state( $post_id, self::STATE_REQUEST );
678
+		$this->set_state($post_id, self::STATE_REQUEST);
679 679
 
680 680
 		// Get the post.
681
-		$post = get_post( $post_id );
681
+		$post = get_post($post_id);
682 682
 
683 683
 		// Bail out if the post isn't found.
684
-		if ( null === $post ) {
685
-			$this->log->warn( "Post $post_id not found." );
684
+		if (null === $post) {
685
+			$this->log->warn("Post $post_id not found.");
686 686
 
687
-			return new WP_Error( 0, "Cannot find post $post_id." );
687
+			return new WP_Error(0, "Cannot find post $post_id.");
688 688
 		}
689 689
 
690 690
 		// Get the link setting.
691
-		$options = $this->get_options( $post_id );
691
+		$options = $this->get_options($post_id);
692 692
 
693
-		$this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $options['link'] . ', min_occurrences :: ' . $options['min_occurrences'] . ' ] ...' );
693
+		$this->log->debug('Sending analysis request for post $post_id [ link :: '.$options['link'].', min_occurrences :: '.$options['min_occurrences'].' ] ...');
694 694
 
695 695
 		// Get the batch analysis URL.
696 696
 		$url = $this->configuration_service->get_batch_analysis_url();
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 		);
709 709
 
710 710
 		// Get the HTTP options.
711
-		$args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
711
+		$args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array(
712 712
 			'method'      => 'POST',
713 713
 			'headers'     => array(
714 714
 				'Accept'       => 'application/json',
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 			),
717 717
 			// we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
718 718
 			'httpversion' => '1.0',
719
-			'body'        => wp_json_encode( $params ),
720
-		) );
719
+			'body'        => wp_json_encode($params),
720
+		));
721 721
 
722
-		$this->log->debug( "Posting analysis request for post $post_id to $url..." );
722
+		$this->log->debug("Posting analysis request for post $post_id to $url...");
723 723
 
724 724
 		// Post the parameter.
725
-		return wp_remote_post( $url, $args );
725
+		return wp_remote_post($url, $args);
726 726
 	}
727 727
 
728 728
 	/**
@@ -734,20 +734,20 @@  discard block
 block discarded – undo
734 734
 	 *
735 735
 	 * @return WP_Error|array The response or WP_Error on failure.
736 736
 	 */
737
-	private function do_complete( $post_id ) {
737
+	private function do_complete($post_id) {
738 738
 
739
-		$post = get_post( $post_id );
739
+		$post = get_post($post_id);
740 740
 
741
-		if ( null === $post ) {
741
+		if (null === $post) {
742 742
 			// Post was possibly deleted, just bailout.
743
-			return new WP_Error( 0, "Post $post_id not found . " );
743
+			return new WP_Error(0, "Post $post_id not found . ");
744 744
 		}
745 745
 
746 746
 		$url = $this->configuration_service->get_batch_analysis_url();
747 747
 		$key = $this->configuration_service->get_key();
748
-		$url = $url . '/' . $post->ID . '?key=' . $key;
748
+		$url = $url.'/'.$post->ID.'?key='.$key;
749 749
 
750
-		return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
750
+		return wp_remote_get($url, unserialize(WL_REDLINK_API_HTTP_OPTIONS));
751 751
 	}
752 752
 
753 753
 	/**
@@ -759,15 +759,15 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function get_warnings() {
761 761
 
762
-		return get_posts( array(
762
+		return get_posts(array(
763 763
 			'fields'      => 'ids',
764
-			'numberposts' => - 1,
764
+			'numberposts' => -1,
765 765
 			'post_status' => 'any',
766 766
 			'meta_key'    => self::WARNING_META_KEY,
767 767
 			'meta_value'  => 'yes',
768 768
 			'post_type'   => 'any',
769 769
 			// Add any because posts from multiple posts types may be waiting.
770
-		) );
770
+		));
771 771
 	}
772 772
 
773 773
 	/**
@@ -777,17 +777,17 @@  discard block
 block discarded – undo
777 777
 	 *
778 778
 	 * @param int $id The {@link WP_Post}'s id.
779 779
 	 */
780
-	private function maybe_set_default_term( $id ) {
780
+	private function maybe_set_default_term($id) {
781 781
 		// Check whether the post has any of the WordLift entity types.
782
-		$has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
782
+		$has_term = has_term('', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id);
783 783
 
784 784
 		// Bail if the term is associated with entity types already.
785
-		if ( ! empty( $has_term ) ) {
785
+		if ( ! empty($has_term)) {
786 786
 			return;
787 787
 		}
788 788
 
789 789
 		// Set the default `article` term.
790
-		wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
790
+		wp_set_object_terms($id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
791 791
 
792 792
 	}
793 793
 
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 2 patches
Indentation   +1445 added lines, -1445 removed lines patch added patch discarded remove patch
@@ -28,1489 +28,1489 @@
 block discarded – undo
28 28
  */
29 29
 class Wordlift {
30 30
 
31
-	/**
32
-	 * The loader that's responsible for maintaining and registering all hooks that power
33
-	 * the plugin.
34
-	 *
35
-	 * @since    1.0.0
36
-	 * @access   protected
37
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
38
-	 */
39
-	protected $loader;
40
-
41
-	/**
42
-	 * The unique identifier of this plugin.
43
-	 *
44
-	 * @since    1.0.0
45
-	 * @access   protected
46
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
47
-	 */
48
-	protected $plugin_name;
49
-
50
-	/**
51
-	 * The current version of the plugin.
52
-	 *
53
-	 * @since    1.0.0
54
-	 * @access   protected
55
-	 * @var      string $version The current version of the plugin.
56
-	 */
57
-	protected $version;
58
-
59
-	/**
60
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
61
-	 *
62
-	 * @since  3.12.0
63
-	 * @access protected
64
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
65
-	 */
66
-	protected $tinymce_adapter;
67
-
68
-	/**
69
-	 * The Thumbnail service.
70
-	 *
71
-	 * @since  3.1.5
72
-	 * @access private
73
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
74
-	 */
75
-	private $thumbnail_service;
76
-
77
-	/**
78
-	 * The UI service.
79
-	 *
80
-	 * @since  3.2.0
81
-	 * @access private
82
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
83
-	 */
84
-	private $ui_service;
85
-
86
-	/**
87
-	 * The Schema service.
88
-	 *
89
-	 * @since  3.3.0
90
-	 * @access protected
91
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
92
-	 */
93
-	protected $schema_service;
94
-
95
-	/**
96
-	 * The Entity service.
97
-	 *
98
-	 * @since  3.1.0
99
-	 * @access protected
100
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
101
-	 */
102
-	protected $entity_service;
103
-
104
-	/**
105
-	 * The Topic Taxonomy service.
106
-	 *
107
-	 * @since  3.5.0
108
-	 * @access private
109
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
110
-	 */
111
-	private $topic_taxonomy_service;
112
-
113
-	/**
114
-	 * The User service.
115
-	 *
116
-	 * @since  3.1.7
117
-	 * @access protected
118
-	 * @var \Wordlift_User_Service $user_service The User service.
119
-	 */
120
-	protected $user_service;
121
-
122
-	/**
123
-	 * The Timeline service.
124
-	 *
125
-	 * @since  3.1.0
126
-	 * @access private
127
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
128
-	 */
129
-	private $timeline_service;
130
-
131
-	/**
132
-	 * The Redirect service.
133
-	 *
134
-	 * @since  3.2.0
135
-	 * @access private
136
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
137
-	 */
138
-	private $redirect_service;
139
-
140
-	/**
141
-	 * The Notice service.
142
-	 *
143
-	 * @since  3.3.0
144
-	 * @access private
145
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
146
-	 */
147
-	private $notice_service;
148
-
149
-	/**
150
-	 * The Entity list customization.
151
-	 *
152
-	 * @since  3.3.0
153
-	 * @access protected
154
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
155
-	 */
156
-	protected $entity_list_service;
157
-
158
-	/**
159
-	 * The Entity Types Taxonomy Walker.
160
-	 *
161
-	 * @since  3.1.0
162
-	 * @access private
163
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
164
-	 */
165
-	private $entity_types_taxonomy_walker;
166
-
167
-	/**
168
-	 * The ShareThis service.
169
-	 *
170
-	 * @since  3.2.0
171
-	 * @access private
172
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
173
-	 */
174
-	private $sharethis_service;
175
-
176
-	/**
177
-	 * The PrimaShop adapter.
178
-	 *
179
-	 * @since  3.2.3
180
-	 * @access private
181
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
182
-	 */
183
-	private $primashop_adapter;
184
-
185
-	/**
186
-	 * The WordLift Dashboard adapter.
187
-	 *
188
-	 * @since  3.4.0
189
-	 * @access private
190
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
191
-	 */
192
-	private $dashboard_service;
193
-
194
-	/**
195
-	 * The entity type service.
196
-	 *
197
-	 * @since  3.6.0
198
-	 * @access private
199
-	 * @var \Wordlift_Entity_Post_Type_Service
200
-	 */
201
-	private $entity_post_type_service;
202
-
203
-	/**
204
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
205
-	 *
206
-	 * @since  3.6.0
207
-	 * @access private
208
-	 * @var \Wordlift_Entity_Link_Service
209
-	 */
210
-	private $entity_link_service;
211
-
212
-	/**
213
-	 * A {@link Wordlift_Sparql_Service} instance.
214
-	 *
215
-	 * @since    3.6.0
216
-	 * @access   protected
217
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
218
-	 */
219
-	protected $sparql_service;
220
-
221
-	/**
222
-	 * A {@link Wordlift_Import_Service} instance.
223
-	 *
224
-	 * @since  3.6.0
225
-	 * @access private
226
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
227
-	 */
228
-	private $import_service;
229
-
230
-	/**
231
-	 * A {@link Wordlift_Rebuild_Service} instance.
232
-	 *
233
-	 * @since  3.6.0
234
-	 * @access private
235
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
236
-	 */
237
-	private $rebuild_service;
238
-
239
-	/**
240
-	 * A {@link Wordlift_Jsonld_Service} instance.
241
-	 *
242
-	 * @since  3.7.0
243
-	 * @access protected
244
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
245
-	 */
246
-	protected $jsonld_service;
247
-
248
-	/**
249
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
250
-	 *
251
-	 * @since  3.14.0
252
-	 * @access protected
253
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
254
-	 */
255
-	protected $jsonld_website_converter;
256
-
257
-	/**
258
-	 * A {@link Wordlift_Property_Factory} instance.
259
-	 *
260
-	 * @since  3.7.0
261
-	 * @access private
262
-	 * @var \Wordlift_Property_Factory $property_factory
263
-	 */
264
-	private $property_factory;
265
-
266
-	/**
267
-	 * The 'Download Your Data' page.
268
-	 *
269
-	 * @since  3.6.0
270
-	 * @access private
271
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
-	 */
273
-	private $download_your_data_page;
274
-
275
-	/**
276
-	 * The 'WordLift Settings' page.
277
-	 *
278
-	 * @since  3.11.0
279
-	 * @access protected
280
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
-	 */
282
-	protected $settings_page;
283
-
284
-	/**
285
-	 * The 'WordLift Batch analysis' page.
286
-	 *
287
-	 * @since  3.14.0
288
-	 * @access protected
289
-	 * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
-	 */
291
-	protected $batch_analysis_page;
292
-
293
-	/**
294
-	 * The install wizard page.
295
-	 *
296
-	 * @since  3.9.0
297
-	 * @access private
298
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
-	 */
300
-	private $admin_setup;
301
-
302
-	/**
303
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
304
-	 * linking of entities to their pages.
305
-	 *
306
-	 * @since  3.8.0
307
-	 * @access private
308
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
-	 */
310
-	private $content_filter_service;
311
-
312
-	/**
313
-	 * A {@link Wordlift_Key_Validation_Service} instance.
314
-	 *
315
-	 * @since  3.9.0
316
-	 * @access private
317
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
-	 */
319
-	private $key_validation_service;
320
-
321
-	/**
322
-	 * A {@link Wordlift_Rating_Service} instance.
323
-	 *
324
-	 * @since  3.10.0
325
-	 * @access private
326
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
-	 */
328
-	private $rating_service;
329
-
330
-	/**
331
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
-	 *
333
-	 * @since  3.10.0
334
-	 * @access protected
335
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
-	 */
337
-	protected $post_to_jsonld_converter;
338
-
339
-	/**
340
-	 * A {@link Wordlift_Configuration_Service} instance.
341
-	 *
342
-	 * @since  3.10.0
343
-	 * @access protected
344
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
-	 */
346
-	protected $configuration_service;
347
-
348
-	/**
349
-	 * A {@link Wordlift_Entity_Type_Service} instance.
350
-	 *
351
-	 * @since  3.10.0
352
-	 * @access protected
353
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
-	 */
355
-	protected $entity_type_service;
356
-
357
-	/**
358
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
-	 *
360
-	 * @since  3.10.0
361
-	 * @access protected
362
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
-	 */
364
-	protected $entity_post_to_jsonld_converter;
365
-
366
-	/**
367
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
-	 *
369
-	 * @since  3.10.0
370
-	 * @access protected
371
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
-	 */
373
-	protected $postid_to_jsonld_converter;
374
-
375
-	/**
376
-	 * The {@link Wordlift_Admin_Status_Page} class.
377
-	 *
378
-	 * @since  3.9.8
379
-	 * @access private
380
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
-	 */
382
-	private $status_page;
383
-
384
-	/**
385
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
-	 *
387
-	 * @since  3.11.0
388
-	 * @access protected
389
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
-	 */
391
-	protected $category_taxonomy_service;
392
-
393
-	/**
394
-	 * The {@link Wordlift_Entity_Page_Service} instance.
395
-	 *
396
-	 * @since  3.11.0
397
-	 * @access protected
398
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
-	 */
400
-	protected $entity_page_service;
401
-
402
-	/**
403
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
-	 *
405
-	 * @since  3.11.0
406
-	 * @access protected
407
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
-	 */
409
-	protected $settings_page_action_link;
410
-
411
-	/**
412
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
-	 *
414
-	 * @since  3.11.0
415
-	 * @access protected
416
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
-	 */
418
-	protected $publisher_ajax_adapter;
419
-
420
-	/**
421
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
422
-	 *
423
-	 * @since  3.11.0
424
-	 * @access protected
425
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
-	 */
427
-	protected $input_element;
428
-
429
-	/**
430
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
-	 *
432
-	 * @since  3.13.0
433
-	 * @access protected
434
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
-	 */
436
-	protected $radio_input_element;
437
-
438
-	/**
439
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
-	 *
441
-	 * @since  3.11.0
442
-	 * @access protected
443
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
-	 */
445
-	protected $language_select_element;
446
-
447
-	/**
448
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
-	 *
450
-	 * @since  3.11.0
451
-	 * @access protected
452
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
-	 */
454
-	protected $publisher_element;
455
-
456
-	/**
457
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
-	 *
459
-	 * @since  3.11.0
460
-	 * @access protected
461
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
-	 */
463
-	protected $select2_element;
464
-
465
-	/**
466
-	 * The controller for the entity type list admin page
467
-	 *
468
-	 * @since  3.11.0
469
-	 * @access private
470
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
-	 */
472
-	private $entity_type_admin_page;
473
-
474
-	/**
475
-	 * The controller for the entity type settings admin page
476
-	 *
477
-	 * @since  3.11.0
478
-	 * @access private
479
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
-	 */
481
-	private $entity_type_settings_admin_page;
482
-
483
-	/**
484
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
-	 *
486
-	 * @since  3.11.0
487
-	 * @access protected
488
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
-	 */
490
-	protected $related_entities_cloud_widget;
491
-
492
-	/**
493
-	 * The {@link Wordlift_Admin_Author_Element} instance.
494
-	 *
495
-	 * @since  3.14.0
496
-	 * @access protected
497
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
-	 */
499
-	protected $author_element;
500
-
501
-	/**
502
-	 * The {@link Wordlift_Batch_Analysis_Service} instance.
503
-	 *
504
-	 * @since  3.14.0
505
-	 * @access protected
506
-	 * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
-	 */
508
-	protected $batch_analysis_service;
509
-
510
-	/**
511
-	 * The {@link Wordlift_Sample_Data_Service} instance.
512
-	 *
513
-	 * @since  3.12.0
514
-	 * @access protected
515
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
-	 */
517
-	protected $sample_data_service;
518
-
519
-	/**
520
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
-	 *
522
-	 * @since  3.12.0
523
-	 * @access protected
524
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
-	 */
526
-	protected $sample_data_ajax_adapter;
527
-
528
-	/**
529
-	 * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
-	 *
531
-	 * @since  3.14.2
532
-	 * @access protected
533
-	 * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
-	 */
535
-	private $batch_analysis_adapter;
536
-
537
-	/**
538
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
-	 *
540
-	 * @since  3.14.3
541
-	 * @access private
542
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
-	 */
544
-	private $relation_rebuild_service;
545
-
546
-	/**
547
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
-	 *
549
-	 * @since  3.14.3
550
-	 * @access private
551
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
-	 */
553
-	private $relation_rebuild_adapter;
554
-
555
-	/**
556
-	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
557
-	 *
558
-	 * @since  3.16.0
559
-	 * @access protected
560
-	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
561
-	 */
562
-	protected $google_analytics_export_service;
563
-
564
-	/**
565
-	 * {@link Wordlift}'s singleton instance.
566
-	 *
567
-	 * @since  3.15.0
568
-	 * @access protected
569
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
570
-	 */
571
-	protected $entity_type_adapter;
572
-
573
-	/**
574
-	 * The {@link Wordlift_Linked_Data_Service} instance.
575
-	 *
576
-	 * @since  3.15.0
577
-	 * @access protected
578
-	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
579
-	 */
580
-	protected $linked_data_service;
581
-
582
-	/**
583
-	 * The {@link Wordlift_Storage_Factory} instance.
584
-	 *
585
-	 * @since  3.15.0
586
-	 * @access protected
587
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
588
-	 */
589
-	protected $storage_factory;
590
-
591
-	/**
592
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
593
-	 *
594
-	 * @since  3.15.0
595
-	 * @access protected
596
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
597
-	 */
598
-	protected $rendition_factory;
599
-
600
-	/**
601
-	 * The {@link Wordlift_Autocomplete_Service} instance.
602
-	 *
603
-	 * @since  3.15.0
604
-	 * @access private
605
-	 * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
606
-	 */
607
-	private $autocomplete_service;
608
-
609
-	/**
610
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
611
-	 *
612
-	 * @since  3.15.0
613
-	 * @access private
614
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
615
-	 */
616
-	private $autocomplete_adapter;
617
-
618
-	/**
619
-	 * The {@link Wordlift_Relation_Service} instance.
620
-	 *
621
-	 * @since  3.15.0
622
-	 * @access protected
623
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
624
-	 */
625
-	protected $relation_service;
626
-
627
-	/**
628
-	 * The {@link Wordlift_Cached_Post_Converter} instance.
629
-	 *
630
-	 * @since  3.16.0
631
-	 * @access protected
632
-	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
633
-	 *
634
-	 */
635
-	protected $cached_postid_to_jsonld_converter;
636
-
637
-	/**
638
-	 * The {@link Wordlift_File_Cache_Service} instance.
639
-	 *
640
-	 * @since  3.16.0
641
-	 * @access protected
642
-	 * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance.
643
-	 */
644
-	protected $file_cache_service;
645
-
646
-	/**
647
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
648
-	 *
649
-	 * @since  3.16.3
650
-	 * @access protected
651
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
652
-	 */
653
-	protected $entity_uri_service;
654
-
655
-	/**
656
-	 * {@link Wordlift}'s singleton instance.
657
-	 *
658
-	 * @since  3.11.2
659
-	 * @access private
660
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
661
-	 */
662
-	private static $instance;
663
-
664
-	/**
665
-	 * Define the core functionality of the plugin.
666
-	 *
667
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
668
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
669
-	 * the public-facing side of the site.
670
-	 *
671
-	 * @since    1.0.0
672
-	 */
673
-	public function __construct() {
674
-
675
-		$this->plugin_name = 'wordlift';
676
-		$this->version     = '3.17.0-dev';
677
-		$this->load_dependencies();
678
-		$this->set_locale();
679
-		$this->define_admin_hooks();
680
-		$this->define_public_hooks();
681
-
682
-		self::$instance = $this;
683
-
684
-	}
685
-
686
-	/**
687
-	 * Get the singleton instance.
688
-	 *
689
-	 * @since 3.11.2
690
-	 *
691
-	 * @return Wordlift The {@link Wordlift} singleton instance.
692
-	 */
693
-	public static function get_instance() {
694
-
695
-		return self::$instance;
696
-	}
697
-
698
-	/**
699
-	 * Load the required dependencies for this plugin.
700
-	 *
701
-	 * Include the following files that make up the plugin:
702
-	 *
703
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
704
-	 * - Wordlift_i18n. Defines internationalization functionality.
705
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
706
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
707
-	 *
708
-	 * Create an instance of the loader which will be used to register the hooks
709
-	 * with WordPress.
710
-	 *
711
-	 * @since    1.0.0
712
-	 * @access   private
713
-	 */
714
-	private function load_dependencies() {
715
-
716
-		/**
717
-		 * The class responsible for orchestrating the actions and filters of the
718
-		 * core plugin.
719
-		 */
720
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
721
-
722
-		/**
723
-		 * The class responsible for defining internationalization functionality
724
-		 * of the plugin.
725
-		 */
726
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
727
-
728
-		/**
729
-		 * WordLift's supported languages.
730
-		 */
731
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
732
-
733
-		/**
734
-		 * Provide support functions to sanitize data.
735
-		 */
736
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
737
-
738
-		/** Services. */
739
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
748
-
749
-		/**
750
-		 * The Query builder.
751
-		 */
752
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
753
-
754
-		/**
755
-		 * The Schema service.
756
-		 */
757
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
758
-
759
-		/**
760
-		 * The schema:url property service.
761
-		 */
762
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
764
-
765
-		/**
766
-		 * The UI service.
767
-		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
769
-
770
-		/**
771
-		 * The Thumbnail service.
772
-		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
774
-
775
-		/**
776
-		 * The Entity Types Taxonomy service.
777
-		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
779
-
780
-		/**
781
-		 * The Entity service.
782
-		 */
783
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
785
-
786
-		// Add the entity rating service.
787
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
788
-
789
-		/**
790
-		 * The User service.
791
-		 */
792
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
793
-
794
-		/**
795
-		 * The Timeline service.
796
-		 */
797
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
798
-
799
-		/**
800
-		 * The Topic Taxonomy service.
801
-		 */
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
803
-
804
-		/**
805
-		 * The SPARQL service.
806
-		 */
807
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
808
-
809
-		/**
810
-		 * The WordLift import service.
811
-		 */
812
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
813
-
814
-		/**
815
-		 * The WordLift URI service.
816
-		 */
817
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
818
-
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
820
-
821
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
822
-
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
824
-
825
-		/**
826
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827
-		 */
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
829
-
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
831
-
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
833
-
834
-		/**
835
-		 * Load the converters.
836
-		 */
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
843
-
844
-		/**
845
-		 * Load cache-related files.
846
-		 */
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
848
-
849
-		/**
850
-		 * Load the content filter.
851
-		 */
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
853
-
854
-		/*
31
+    /**
32
+     * The loader that's responsible for maintaining and registering all hooks that power
33
+     * the plugin.
34
+     *
35
+     * @since    1.0.0
36
+     * @access   protected
37
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
38
+     */
39
+    protected $loader;
40
+
41
+    /**
42
+     * The unique identifier of this plugin.
43
+     *
44
+     * @since    1.0.0
45
+     * @access   protected
46
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
47
+     */
48
+    protected $plugin_name;
49
+
50
+    /**
51
+     * The current version of the plugin.
52
+     *
53
+     * @since    1.0.0
54
+     * @access   protected
55
+     * @var      string $version The current version of the plugin.
56
+     */
57
+    protected $version;
58
+
59
+    /**
60
+     * The {@link Wordlift_Tinymce_Adapter} instance.
61
+     *
62
+     * @since  3.12.0
63
+     * @access protected
64
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
65
+     */
66
+    protected $tinymce_adapter;
67
+
68
+    /**
69
+     * The Thumbnail service.
70
+     *
71
+     * @since  3.1.5
72
+     * @access private
73
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
74
+     */
75
+    private $thumbnail_service;
76
+
77
+    /**
78
+     * The UI service.
79
+     *
80
+     * @since  3.2.0
81
+     * @access private
82
+     * @var \Wordlift_UI_Service $ui_service The UI service.
83
+     */
84
+    private $ui_service;
85
+
86
+    /**
87
+     * The Schema service.
88
+     *
89
+     * @since  3.3.0
90
+     * @access protected
91
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
92
+     */
93
+    protected $schema_service;
94
+
95
+    /**
96
+     * The Entity service.
97
+     *
98
+     * @since  3.1.0
99
+     * @access protected
100
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
101
+     */
102
+    protected $entity_service;
103
+
104
+    /**
105
+     * The Topic Taxonomy service.
106
+     *
107
+     * @since  3.5.0
108
+     * @access private
109
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
110
+     */
111
+    private $topic_taxonomy_service;
112
+
113
+    /**
114
+     * The User service.
115
+     *
116
+     * @since  3.1.7
117
+     * @access protected
118
+     * @var \Wordlift_User_Service $user_service The User service.
119
+     */
120
+    protected $user_service;
121
+
122
+    /**
123
+     * The Timeline service.
124
+     *
125
+     * @since  3.1.0
126
+     * @access private
127
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
128
+     */
129
+    private $timeline_service;
130
+
131
+    /**
132
+     * The Redirect service.
133
+     *
134
+     * @since  3.2.0
135
+     * @access private
136
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
137
+     */
138
+    private $redirect_service;
139
+
140
+    /**
141
+     * The Notice service.
142
+     *
143
+     * @since  3.3.0
144
+     * @access private
145
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
146
+     */
147
+    private $notice_service;
148
+
149
+    /**
150
+     * The Entity list customization.
151
+     *
152
+     * @since  3.3.0
153
+     * @access protected
154
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
155
+     */
156
+    protected $entity_list_service;
157
+
158
+    /**
159
+     * The Entity Types Taxonomy Walker.
160
+     *
161
+     * @since  3.1.0
162
+     * @access private
163
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
164
+     */
165
+    private $entity_types_taxonomy_walker;
166
+
167
+    /**
168
+     * The ShareThis service.
169
+     *
170
+     * @since  3.2.0
171
+     * @access private
172
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
173
+     */
174
+    private $sharethis_service;
175
+
176
+    /**
177
+     * The PrimaShop adapter.
178
+     *
179
+     * @since  3.2.3
180
+     * @access private
181
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
182
+     */
183
+    private $primashop_adapter;
184
+
185
+    /**
186
+     * The WordLift Dashboard adapter.
187
+     *
188
+     * @since  3.4.0
189
+     * @access private
190
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
191
+     */
192
+    private $dashboard_service;
193
+
194
+    /**
195
+     * The entity type service.
196
+     *
197
+     * @since  3.6.0
198
+     * @access private
199
+     * @var \Wordlift_Entity_Post_Type_Service
200
+     */
201
+    private $entity_post_type_service;
202
+
203
+    /**
204
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
205
+     *
206
+     * @since  3.6.0
207
+     * @access private
208
+     * @var \Wordlift_Entity_Link_Service
209
+     */
210
+    private $entity_link_service;
211
+
212
+    /**
213
+     * A {@link Wordlift_Sparql_Service} instance.
214
+     *
215
+     * @since    3.6.0
216
+     * @access   protected
217
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
218
+     */
219
+    protected $sparql_service;
220
+
221
+    /**
222
+     * A {@link Wordlift_Import_Service} instance.
223
+     *
224
+     * @since  3.6.0
225
+     * @access private
226
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
227
+     */
228
+    private $import_service;
229
+
230
+    /**
231
+     * A {@link Wordlift_Rebuild_Service} instance.
232
+     *
233
+     * @since  3.6.0
234
+     * @access private
235
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
236
+     */
237
+    private $rebuild_service;
238
+
239
+    /**
240
+     * A {@link Wordlift_Jsonld_Service} instance.
241
+     *
242
+     * @since  3.7.0
243
+     * @access protected
244
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
245
+     */
246
+    protected $jsonld_service;
247
+
248
+    /**
249
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
250
+     *
251
+     * @since  3.14.0
252
+     * @access protected
253
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
254
+     */
255
+    protected $jsonld_website_converter;
256
+
257
+    /**
258
+     * A {@link Wordlift_Property_Factory} instance.
259
+     *
260
+     * @since  3.7.0
261
+     * @access private
262
+     * @var \Wordlift_Property_Factory $property_factory
263
+     */
264
+    private $property_factory;
265
+
266
+    /**
267
+     * The 'Download Your Data' page.
268
+     *
269
+     * @since  3.6.0
270
+     * @access private
271
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
+     */
273
+    private $download_your_data_page;
274
+
275
+    /**
276
+     * The 'WordLift Settings' page.
277
+     *
278
+     * @since  3.11.0
279
+     * @access protected
280
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
+     */
282
+    protected $settings_page;
283
+
284
+    /**
285
+     * The 'WordLift Batch analysis' page.
286
+     *
287
+     * @since  3.14.0
288
+     * @access protected
289
+     * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
+     */
291
+    protected $batch_analysis_page;
292
+
293
+    /**
294
+     * The install wizard page.
295
+     *
296
+     * @since  3.9.0
297
+     * @access private
298
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
+     */
300
+    private $admin_setup;
301
+
302
+    /**
303
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
304
+     * linking of entities to their pages.
305
+     *
306
+     * @since  3.8.0
307
+     * @access private
308
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
+     */
310
+    private $content_filter_service;
311
+
312
+    /**
313
+     * A {@link Wordlift_Key_Validation_Service} instance.
314
+     *
315
+     * @since  3.9.0
316
+     * @access private
317
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
+     */
319
+    private $key_validation_service;
320
+
321
+    /**
322
+     * A {@link Wordlift_Rating_Service} instance.
323
+     *
324
+     * @since  3.10.0
325
+     * @access private
326
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
+     */
328
+    private $rating_service;
329
+
330
+    /**
331
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
+     *
333
+     * @since  3.10.0
334
+     * @access protected
335
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
+     */
337
+    protected $post_to_jsonld_converter;
338
+
339
+    /**
340
+     * A {@link Wordlift_Configuration_Service} instance.
341
+     *
342
+     * @since  3.10.0
343
+     * @access protected
344
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
+     */
346
+    protected $configuration_service;
347
+
348
+    /**
349
+     * A {@link Wordlift_Entity_Type_Service} instance.
350
+     *
351
+     * @since  3.10.0
352
+     * @access protected
353
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
+     */
355
+    protected $entity_type_service;
356
+
357
+    /**
358
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
+     *
360
+     * @since  3.10.0
361
+     * @access protected
362
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
+     */
364
+    protected $entity_post_to_jsonld_converter;
365
+
366
+    /**
367
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
+     *
369
+     * @since  3.10.0
370
+     * @access protected
371
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
+     */
373
+    protected $postid_to_jsonld_converter;
374
+
375
+    /**
376
+     * The {@link Wordlift_Admin_Status_Page} class.
377
+     *
378
+     * @since  3.9.8
379
+     * @access private
380
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
+     */
382
+    private $status_page;
383
+
384
+    /**
385
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
+     *
387
+     * @since  3.11.0
388
+     * @access protected
389
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
+     */
391
+    protected $category_taxonomy_service;
392
+
393
+    /**
394
+     * The {@link Wordlift_Entity_Page_Service} instance.
395
+     *
396
+     * @since  3.11.0
397
+     * @access protected
398
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
+     */
400
+    protected $entity_page_service;
401
+
402
+    /**
403
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
+     *
405
+     * @since  3.11.0
406
+     * @access protected
407
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
+     */
409
+    protected $settings_page_action_link;
410
+
411
+    /**
412
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
+     *
414
+     * @since  3.11.0
415
+     * @access protected
416
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
+     */
418
+    protected $publisher_ajax_adapter;
419
+
420
+    /**
421
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
422
+     *
423
+     * @since  3.11.0
424
+     * @access protected
425
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
+     */
427
+    protected $input_element;
428
+
429
+    /**
430
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
+     *
432
+     * @since  3.13.0
433
+     * @access protected
434
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
+     */
436
+    protected $radio_input_element;
437
+
438
+    /**
439
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
+     *
441
+     * @since  3.11.0
442
+     * @access protected
443
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
+     */
445
+    protected $language_select_element;
446
+
447
+    /**
448
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
+     *
450
+     * @since  3.11.0
451
+     * @access protected
452
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
+     */
454
+    protected $publisher_element;
455
+
456
+    /**
457
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
+     *
459
+     * @since  3.11.0
460
+     * @access protected
461
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
+     */
463
+    protected $select2_element;
464
+
465
+    /**
466
+     * The controller for the entity type list admin page
467
+     *
468
+     * @since  3.11.0
469
+     * @access private
470
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
+     */
472
+    private $entity_type_admin_page;
473
+
474
+    /**
475
+     * The controller for the entity type settings admin page
476
+     *
477
+     * @since  3.11.0
478
+     * @access private
479
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
+     */
481
+    private $entity_type_settings_admin_page;
482
+
483
+    /**
484
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
+     *
486
+     * @since  3.11.0
487
+     * @access protected
488
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
+     */
490
+    protected $related_entities_cloud_widget;
491
+
492
+    /**
493
+     * The {@link Wordlift_Admin_Author_Element} instance.
494
+     *
495
+     * @since  3.14.0
496
+     * @access protected
497
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
+     */
499
+    protected $author_element;
500
+
501
+    /**
502
+     * The {@link Wordlift_Batch_Analysis_Service} instance.
503
+     *
504
+     * @since  3.14.0
505
+     * @access protected
506
+     * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
+     */
508
+    protected $batch_analysis_service;
509
+
510
+    /**
511
+     * The {@link Wordlift_Sample_Data_Service} instance.
512
+     *
513
+     * @since  3.12.0
514
+     * @access protected
515
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
+     */
517
+    protected $sample_data_service;
518
+
519
+    /**
520
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
+     *
522
+     * @since  3.12.0
523
+     * @access protected
524
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
+     */
526
+    protected $sample_data_ajax_adapter;
527
+
528
+    /**
529
+     * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
+     *
531
+     * @since  3.14.2
532
+     * @access protected
533
+     * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
+     */
535
+    private $batch_analysis_adapter;
536
+
537
+    /**
538
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
+     *
540
+     * @since  3.14.3
541
+     * @access private
542
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
+     */
544
+    private $relation_rebuild_service;
545
+
546
+    /**
547
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
+     *
549
+     * @since  3.14.3
550
+     * @access private
551
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
+     */
553
+    private $relation_rebuild_adapter;
554
+
555
+    /**
556
+     * The {@link Wordlift_Google_Analytics_Export_Service} instance.
557
+     *
558
+     * @since  3.16.0
559
+     * @access protected
560
+     * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
561
+     */
562
+    protected $google_analytics_export_service;
563
+
564
+    /**
565
+     * {@link Wordlift}'s singleton instance.
566
+     *
567
+     * @since  3.15.0
568
+     * @access protected
569
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
570
+     */
571
+    protected $entity_type_adapter;
572
+
573
+    /**
574
+     * The {@link Wordlift_Linked_Data_Service} instance.
575
+     *
576
+     * @since  3.15.0
577
+     * @access protected
578
+     * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
579
+     */
580
+    protected $linked_data_service;
581
+
582
+    /**
583
+     * The {@link Wordlift_Storage_Factory} instance.
584
+     *
585
+     * @since  3.15.0
586
+     * @access protected
587
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
588
+     */
589
+    protected $storage_factory;
590
+
591
+    /**
592
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
593
+     *
594
+     * @since  3.15.0
595
+     * @access protected
596
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
597
+     */
598
+    protected $rendition_factory;
599
+
600
+    /**
601
+     * The {@link Wordlift_Autocomplete_Service} instance.
602
+     *
603
+     * @since  3.15.0
604
+     * @access private
605
+     * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
606
+     */
607
+    private $autocomplete_service;
608
+
609
+    /**
610
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
611
+     *
612
+     * @since  3.15.0
613
+     * @access private
614
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
615
+     */
616
+    private $autocomplete_adapter;
617
+
618
+    /**
619
+     * The {@link Wordlift_Relation_Service} instance.
620
+     *
621
+     * @since  3.15.0
622
+     * @access protected
623
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
624
+     */
625
+    protected $relation_service;
626
+
627
+    /**
628
+     * The {@link Wordlift_Cached_Post_Converter} instance.
629
+     *
630
+     * @since  3.16.0
631
+     * @access protected
632
+     * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
633
+     *
634
+     */
635
+    protected $cached_postid_to_jsonld_converter;
636
+
637
+    /**
638
+     * The {@link Wordlift_File_Cache_Service} instance.
639
+     *
640
+     * @since  3.16.0
641
+     * @access protected
642
+     * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance.
643
+     */
644
+    protected $file_cache_service;
645
+
646
+    /**
647
+     * The {@link Wordlift_Entity_Uri_Service} instance.
648
+     *
649
+     * @since  3.16.3
650
+     * @access protected
651
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
652
+     */
653
+    protected $entity_uri_service;
654
+
655
+    /**
656
+     * {@link Wordlift}'s singleton instance.
657
+     *
658
+     * @since  3.11.2
659
+     * @access private
660
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
661
+     */
662
+    private static $instance;
663
+
664
+    /**
665
+     * Define the core functionality of the plugin.
666
+     *
667
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
668
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
669
+     * the public-facing side of the site.
670
+     *
671
+     * @since    1.0.0
672
+     */
673
+    public function __construct() {
674
+
675
+        $this->plugin_name = 'wordlift';
676
+        $this->version     = '3.17.0-dev';
677
+        $this->load_dependencies();
678
+        $this->set_locale();
679
+        $this->define_admin_hooks();
680
+        $this->define_public_hooks();
681
+
682
+        self::$instance = $this;
683
+
684
+    }
685
+
686
+    /**
687
+     * Get the singleton instance.
688
+     *
689
+     * @since 3.11.2
690
+     *
691
+     * @return Wordlift The {@link Wordlift} singleton instance.
692
+     */
693
+    public static function get_instance() {
694
+
695
+        return self::$instance;
696
+    }
697
+
698
+    /**
699
+     * Load the required dependencies for this plugin.
700
+     *
701
+     * Include the following files that make up the plugin:
702
+     *
703
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
704
+     * - Wordlift_i18n. Defines internationalization functionality.
705
+     * - Wordlift_Admin. Defines all hooks for the admin area.
706
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
707
+     *
708
+     * Create an instance of the loader which will be used to register the hooks
709
+     * with WordPress.
710
+     *
711
+     * @since    1.0.0
712
+     * @access   private
713
+     */
714
+    private function load_dependencies() {
715
+
716
+        /**
717
+         * The class responsible for orchestrating the actions and filters of the
718
+         * core plugin.
719
+         */
720
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
721
+
722
+        /**
723
+         * The class responsible for defining internationalization functionality
724
+         * of the plugin.
725
+         */
726
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
727
+
728
+        /**
729
+         * WordLift's supported languages.
730
+         */
731
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
732
+
733
+        /**
734
+         * Provide support functions to sanitize data.
735
+         */
736
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
737
+
738
+        /** Services. */
739
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
748
+
749
+        /**
750
+         * The Query builder.
751
+         */
752
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
753
+
754
+        /**
755
+         * The Schema service.
756
+         */
757
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
758
+
759
+        /**
760
+         * The schema:url property service.
761
+         */
762
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
764
+
765
+        /**
766
+         * The UI service.
767
+         */
768
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
769
+
770
+        /**
771
+         * The Thumbnail service.
772
+         */
773
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
774
+
775
+        /**
776
+         * The Entity Types Taxonomy service.
777
+         */
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
779
+
780
+        /**
781
+         * The Entity service.
782
+         */
783
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
785
+
786
+        // Add the entity rating service.
787
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
788
+
789
+        /**
790
+         * The User service.
791
+         */
792
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
793
+
794
+        /**
795
+         * The Timeline service.
796
+         */
797
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
798
+
799
+        /**
800
+         * The Topic Taxonomy service.
801
+         */
802
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
803
+
804
+        /**
805
+         * The SPARQL service.
806
+         */
807
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
808
+
809
+        /**
810
+         * The WordLift import service.
811
+         */
812
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
813
+
814
+        /**
815
+         * The WordLift URI service.
816
+         */
817
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
818
+
819
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
820
+
821
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
822
+
823
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
824
+
825
+        /**
826
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827
+         */
828
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
829
+
830
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
831
+
832
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
833
+
834
+        /**
835
+         * Load the converters.
836
+         */
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
843
+
844
+        /**
845
+         * Load cache-related files.
846
+         */
847
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
848
+
849
+        /**
850
+         * Load the content filter.
851
+         */
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
853
+
854
+        /*
855 855
 		 * Load the excerpt helper.
856 856
 		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
858
-
859
-		/**
860
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
861
-		 *
862
-		 * @since 3.8.0
863
-		 */
864
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
865
-
866
-		// The Publisher Service and the AJAX adapter.
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
869
-
870
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
871
-
872
-		/**
873
-		 * Load the WordLift key validation service.
874
-		 */
875
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
876
-
877
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
879
-
880
-		// Load the `Wordlift_Entity_Page_Service` class definition.
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php';
883
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-service.php';
884
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
885
-
886
-		/** Linked Data. */
887
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
888
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
889
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
890
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
893
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
894
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
895
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
896
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
897
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
898
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
899
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
900
-
901
-		/** Services. */
902
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
903
-
904
-		/** Adapters. */
905
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
906
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
908
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
909
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-adapter.php';
910
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
911
-
912
-		/** Async Tasks. */
913
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
914
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
916
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
917
-
918
-		/** Async Tasks. */
919
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
921
-
922
-		/**
923
-		 * The class responsible for defining all actions that occur in the admin area.
924
-		 */
925
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
926
-
927
-		/**
928
-		 * The class to customize the entity list admin page.
929
-		 */
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
931
-
932
-		/**
933
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
934
-		 */
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
936
-
937
-		/**
938
-		 * The Notice service.
939
-		 */
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
941
-
942
-		/**
943
-		 * The PrimaShop adapter.
944
-		 */
945
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
946
-
947
-		/**
948
-		 * The WordLift Dashboard service.
949
-		 */
950
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
951
-
952
-		/**
953
-		 * The admin 'Install wizard' page.
954
-		 */
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
956
-
957
-		/**
958
-		 * The WordLift entity type list admin page controller.
959
-		 */
960
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
961
-
962
-		/**
963
-		 * The WordLift entity type settings admin page controller.
964
-		 */
965
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
966
-
967
-		/**
968
-		 * The admin 'Download Your Data' page.
969
-		 */
970
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
971
-
972
-		/**
973
-		 * The admin 'WordLift Settings' page.
974
-		 */
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
976
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
981
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
983
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
984
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
986
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
987
-
988
-		/** Admin Pages */
989
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
991
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
992
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
993
-
994
-		/**
995
-		 * The class responsible for defining all actions that occur in the public-facing
996
-		 * side of the site.
997
-		 */
998
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
999
-
1000
-		/**
1001
-		 * The shortcode abstract class.
1002
-		 */
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1004
-
1005
-		/**
1006
-		 * The Timeline shortcode.
1007
-		 */
1008
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1009
-
1010
-		/**
1011
-		 * The Navigator shortcode.
1012
-		 */
1013
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1014
-
1015
-		/**
1016
-		 * The chord shortcode.
1017
-		 */
1018
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1019
-
1020
-		/**
1021
-		 * The geomap shortcode.
1022
-		 */
1023
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1024
-
1025
-		/**
1026
-		 * The entity cloud shortcode.
1027
-		 */
1028
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1029
-
1030
-		/**
1031
-		 * The entity glossary shortcode.
1032
-		 */
1033
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1034
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1035
-
1036
-		/**
1037
-		 * The ShareThis service.
1038
-		 */
1039
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1040
-
1041
-		/**
1042
-		 * The SEO service.
1043
-		 */
1044
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1045
-
1046
-		/**
1047
-		 * The AMP service.
1048
-		 */
1049
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1050
-
1051
-		/** Widgets */
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1053
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1054
-
1055
-		$this->loader = new Wordlift_Loader();
1056
-
1057
-		// Instantiate a global logger.
1058
-		global $wl_logger;
1059
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1060
-
1061
-		// Load the `wl-api` end-point.
1062
-		new Wordlift_Http_Api();
1063
-
1064
-		/** Services. */
1065
-		// Create the configuration service.
1066
-		$this->configuration_service = new Wordlift_Configuration_Service();
1067
-
1068
-		// Create an entity type service instance. It'll be later bound to the init action.
1069
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1070
-
1071
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1072
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1073
-
1074
-		// Create an instance of the UI service.
1075
-		$this->ui_service = new Wordlift_UI_Service();
1076
-
1077
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1078
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1079
-
1080
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1081
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1082
-		$this->notice_service        = new Wordlift_Notice_Service();
1083
-		$this->relation_service      = new Wordlift_Relation_Service();
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
858
+
859
+        /**
860
+         * Load the JSON-LD service to publish entities using JSON-LD.s
861
+         *
862
+         * @since 3.8.0
863
+         */
864
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
865
+
866
+        // The Publisher Service and the AJAX adapter.
867
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
869
+
870
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
871
+
872
+        /**
873
+         * Load the WordLift key validation service.
874
+         */
875
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
876
+
877
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
879
+
880
+        // Load the `Wordlift_Entity_Page_Service` class definition.
881
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php';
883
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-service.php';
884
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
885
+
886
+        /** Linked Data. */
887
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
888
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
889
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
890
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
891
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
892
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
893
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
894
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
895
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
896
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
897
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
898
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
899
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
900
+
901
+        /** Services. */
902
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
903
+
904
+        /** Adapters. */
905
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
906
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
907
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
908
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
909
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-adapter.php';
910
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
911
+
912
+        /** Async Tasks. */
913
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
914
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
915
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
916
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
917
+
918
+        /** Async Tasks. */
919
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
920
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
921
+
922
+        /**
923
+         * The class responsible for defining all actions that occur in the admin area.
924
+         */
925
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
926
+
927
+        /**
928
+         * The class to customize the entity list admin page.
929
+         */
930
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
931
+
932
+        /**
933
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
934
+         */
935
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
936
+
937
+        /**
938
+         * The Notice service.
939
+         */
940
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
941
+
942
+        /**
943
+         * The PrimaShop adapter.
944
+         */
945
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
946
+
947
+        /**
948
+         * The WordLift Dashboard service.
949
+         */
950
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
951
+
952
+        /**
953
+         * The admin 'Install wizard' page.
954
+         */
955
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
956
+
957
+        /**
958
+         * The WordLift entity type list admin page controller.
959
+         */
960
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
961
+
962
+        /**
963
+         * The WordLift entity type settings admin page controller.
964
+         */
965
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
966
+
967
+        /**
968
+         * The admin 'Download Your Data' page.
969
+         */
970
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
971
+
972
+        /**
973
+         * The admin 'WordLift Settings' page.
974
+         */
975
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
976
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
977
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
978
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
979
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
980
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
981
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
982
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
983
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
984
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
986
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
987
+
988
+        /** Admin Pages */
989
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
990
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
991
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
992
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
993
+
994
+        /**
995
+         * The class responsible for defining all actions that occur in the public-facing
996
+         * side of the site.
997
+         */
998
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
999
+
1000
+        /**
1001
+         * The shortcode abstract class.
1002
+         */
1003
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1004
+
1005
+        /**
1006
+         * The Timeline shortcode.
1007
+         */
1008
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1009
+
1010
+        /**
1011
+         * The Navigator shortcode.
1012
+         */
1013
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1014
+
1015
+        /**
1016
+         * The chord shortcode.
1017
+         */
1018
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1019
+
1020
+        /**
1021
+         * The geomap shortcode.
1022
+         */
1023
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1024
+
1025
+        /**
1026
+         * The entity cloud shortcode.
1027
+         */
1028
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1029
+
1030
+        /**
1031
+         * The entity glossary shortcode.
1032
+         */
1033
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1034
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1035
+
1036
+        /**
1037
+         * The ShareThis service.
1038
+         */
1039
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1040
+
1041
+        /**
1042
+         * The SEO service.
1043
+         */
1044
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1045
+
1046
+        /**
1047
+         * The AMP service.
1048
+         */
1049
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1050
+
1051
+        /** Widgets */
1052
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1053
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1054
+
1055
+        $this->loader = new Wordlift_Loader();
1056
+
1057
+        // Instantiate a global logger.
1058
+        global $wl_logger;
1059
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1060
+
1061
+        // Load the `wl-api` end-point.
1062
+        new Wordlift_Http_Api();
1063
+
1064
+        /** Services. */
1065
+        // Create the configuration service.
1066
+        $this->configuration_service = new Wordlift_Configuration_Service();
1067
+
1068
+        // Create an entity type service instance. It'll be later bound to the init action.
1069
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1070
+
1071
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1072
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1073
+
1074
+        // Create an instance of the UI service.
1075
+        $this->ui_service = new Wordlift_UI_Service();
1076
+
1077
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1078
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1079
+
1080
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1081
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1082
+        $this->notice_service        = new Wordlift_Notice_Service();
1083
+        $this->relation_service      = new Wordlift_Relation_Service();
1084 1084
 
1085
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1086
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1087
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1088
-		$this->user_service       = new Wordlift_User_Service();
1085
+        $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1086
+        $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1087
+        $this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1088
+        $this->user_service       = new Wordlift_User_Service();
1089 1089
 
1090
-		// Instantiate the JSON-LD service.
1091
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
+        // Instantiate the JSON-LD service.
1091
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1092 1092
 
1093
-		/** Linked Data. */
1094
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1095
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1093
+        /** Linked Data. */
1094
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1095
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1096 1096
 
1097
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1097
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1098 1098
 
1099
-		// Create a new instance of the Redirect service.
1100
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1101
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1102
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1099
+        // Create a new instance of the Redirect service.
1100
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1101
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1102
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1103 1103
 
1104
-		// Create a new instance of the Timeline service and Timeline shortcode.
1105
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1104
+        // Create a new instance of the Timeline service and Timeline shortcode.
1105
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1106 1106
 
1107
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1107
+        $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1108 1108
 
1109
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1109
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1110 1110
 
1111
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1111
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1112 1112
 
1113
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1114
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1113
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1114
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1115 1115
 
1116
-		// Create an instance of the PrimaShop adapter.
1117
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1116
+        // Create an instance of the PrimaShop adapter.
1117
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1118 1118
 
1119
-		// Create an import service instance to hook later to WP's import function.
1120
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1119
+        // Create an import service instance to hook later to WP's import function.
1120
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1121 1121
 
1122
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1122
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1123 1123
 
1124
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1125
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1124
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1125
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1126 1126
 
1127
-		// Create the entity rating service.
1128
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1127
+        // Create the entity rating service.
1128
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1129 1129
 
1130
-		// Create entity list customization (wp-admin/edit.php).
1131
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1130
+        // Create entity list customization (wp-admin/edit.php).
1131
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1132 1132
 
1133
-		// Create a new instance of the Redirect service.
1134
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1133
+        // Create a new instance of the Redirect service.
1134
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1135 1135
 
1136
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1137
-		$publisher_service      = new Wordlift_Publisher_Service();
1138
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1139
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1136
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1137
+        $publisher_service      = new Wordlift_Publisher_Service();
1138
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1139
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1140 1140
 
1141
-		$attachment_service = new Wordlift_Attachment_Service();
1141
+        $attachment_service = new Wordlift_Attachment_Service();
1142 1142
 
1143
-		// Instantiate the JSON-LD service.
1144
-		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1145
-		$this->entity_post_to_jsonld_converter   = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1146
-		$this->post_to_jsonld_converter          = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1147
-		$this->postid_to_jsonld_converter        = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1148
-		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1149
-		$this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1150
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1151
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1143
+        // Instantiate the JSON-LD service.
1144
+        $property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1145
+        $this->entity_post_to_jsonld_converter   = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1146
+        $this->post_to_jsonld_converter          = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1147
+        $this->postid_to_jsonld_converter        = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1148
+        $this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1149
+        $this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1150
+        $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1151
+        $this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1152 1152
 
1153 1153
 
1154
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1155
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1156
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1157
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1158
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1154
+        $this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1155
+        $this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1156
+        $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1157
+        $this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1158
+        $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1159 1159
 
1160
-		// Initialize the shortcodes.
1161
-		new Wordlift_Navigator_Shortcode();
1162
-		new Wordlift_Chord_Shortcode();
1163
-		new Wordlift_Geomap_Shortcode();
1164
-		new Wordlift_Timeline_Shortcode();
1165
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1166
-		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1160
+        // Initialize the shortcodes.
1161
+        new Wordlift_Navigator_Shortcode();
1162
+        new Wordlift_Chord_Shortcode();
1163
+        new Wordlift_Geomap_Shortcode();
1164
+        new Wordlift_Timeline_Shortcode();
1165
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1166
+        new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1167 1167
 
1168
-		// Initialize the SEO service.
1169
-		new Wordlift_Seo_Service();
1168
+        // Initialize the SEO service.
1169
+        new Wordlift_Seo_Service();
1170 1170
 
1171
-		// Initialize the AMP service.
1172
-		new Wordlift_AMP_Service();
1171
+        // Initialize the AMP service.
1172
+        new Wordlift_AMP_Service();
1173 1173
 
1174
-		/** Services. */
1175
-		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1174
+        /** Services. */
1175
+        $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1176 1176
 
1177
-		/** Adapters. */
1178
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1179
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1180
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1181
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1182
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1177
+        /** Adapters. */
1178
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1179
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1180
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1181
+        $this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1182
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1183 1183
 
1184
-		/** Async Tasks. */
1185
-		new Wordlift_Sparql_Query_Async_Task();
1186
-		new Wordlift_Batch_Analysis_Request_Async_Task();
1187
-		new Wordlift_Batch_Analysis_Complete_Async_Task();
1184
+        /** Async Tasks. */
1185
+        new Wordlift_Sparql_Query_Async_Task();
1186
+        new Wordlift_Batch_Analysis_Request_Async_Task();
1187
+        new Wordlift_Batch_Analysis_Complete_Async_Task();
1188 1188
 
1189
-		/** WL Autocomplete. */
1190
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1191
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1189
+        /** WL Autocomplete. */
1190
+        $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1191
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1192 1192
 
1193
-		/** WordPress Admin UI. */
1193
+        /** WordPress Admin UI. */
1194 1194
 
1195
-		// UI elements.
1196
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1197
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1198
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1199
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1200
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1201
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1202
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1195
+        // UI elements.
1196
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1197
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1198
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1199
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1200
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1201
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1202
+        $this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1203 1203
 
1204
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1205
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1206
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1204
+        $this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1205
+        $this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1206
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1207 1207
 
1208
-		// Pages.
1209
-		new Wordlift_Admin_Post_Edit_Page( $this );
1210
-		new Wordlift_Entity_Type_Admin_Service();
1211
-
1212
-		// create an instance of the entity type list admin page controller.
1213
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1214
-
1215
-		// create an instance of the entity type etting admin page controller.
1216
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1217
-
1218
-		/** Widgets */
1219
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1220
-
1221
-		/* WordPress Admin. */
1222
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1223
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1224
-
1225
-		// Create an instance of the install wizard.
1226
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1227
-
1228
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1229
-
1230
-		// User Profile.
1231
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1232
-
1233
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1234
-
1235
-		// Load the debug service if WP is in debug mode.
1236
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1237
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1238
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1239
-		}
1240
-
1241
-	}
1242
-
1243
-	/**
1244
-	 * Define the locale for this plugin for internationalization.
1245
-	 *
1246
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1247
-	 * with WordPress.
1248
-	 *
1249
-	 * @since    1.0.0
1250
-	 * @access   private
1251
-	 */
1252
-	private function set_locale() {
1253
-
1254
-		$plugin_i18n = new Wordlift_i18n();
1255
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1256
-
1257
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1258
-
1259
-	}
1260
-
1261
-	/**
1262
-	 * Register all of the hooks related to the admin area functionality
1263
-	 * of the plugin.
1264
-	 *
1265
-	 * @since    1.0.0
1266
-	 * @access   private
1267
-	 */
1268
-	private function define_admin_hooks() {
1269
-
1270
-		$plugin_admin = new Wordlift_Admin(
1271
-			$this->get_plugin_name(),
1272
-			$this->get_version(),
1273
-			$this->configuration_service,
1274
-			$this->notice_service,
1275
-			$this->user_service
1276
-		);
1277
-
1278
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1279
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1280
-
1281
-		// Hook the init action to the Topic Taxonomy service.
1282
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1283
-
1284
-		// Hook the deleted_post_meta action to the Thumbnail service.
1285
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1286
-
1287
-		// Hook the added_post_meta action to the Thumbnail service.
1288
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1289
-
1290
-		// Hook the updated_post_meta action to the Thumbnail service.
1291
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1292
-
1293
-		// Hook the AJAX wl_timeline action to the Timeline service.
1294
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1295
-
1296
-		// Register custom allowed redirect hosts.
1297
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1298
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1299
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1300
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1301
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1302
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1303
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1304
-
1305
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1306
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1307
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1308
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1309
-
1310
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1311
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1312
-
1313
-		// Entity listing customization (wp-admin/edit.php)
1314
-		// Add custom columns.
1315
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1316
-		// no explicit entity as it prevents handling of other post types.
1317
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1318
-		// Add 4W selection.
1319
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1320
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1321
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1322
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1323
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1324
-
1325
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1326
-		// entities.
1327
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1328
-
1329
-		// Filter imported post meta.
1330
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1331
-
1332
-		// Notify the import service when an import starts and ends.
1333
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1334
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1335
-
1336
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1337
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1338
-
1339
-		// Hook the menu to the Download Your Data page.
1340
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1341
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1342
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1343
-
1344
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1345
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1346
-
1347
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1348
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1349
-
1350
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1351
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1352
-
1353
-		// Hook the `admin_init` function to the Admin Setup.
1354
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1355
-
1356
-		// Hook the admin_init to the settings page.
1357
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1358
-
1359
-		// Hook the menu creation on the general wordlift menu creation.
1360
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1361
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1362
-			// Add the functionality only if a flag is set in wp-config.php .
1363
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1364
-		}
1365
-
1366
-		// Hook key update.
1367
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1368
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1369
-
1370
-		// Add additional action links to the WordLift plugin in the plugins page.
1371
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1372
-
1373
-		// Hook the AJAX `wl_publisher` action name.
1374
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1375
-
1376
-		// Hook row actions for the entity type list admin.
1377
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1378
-
1379
-		/** Ajax actions. */
1380
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1381
-
1382
-		// Hook capabilities manipulation to allow access to entity type admin
1383
-		// page  on WordPress versions before 4.7.
1384
-		global $wp_version;
1385
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1386
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1387
-		}
1388
-
1389
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1390
-
1391
-		/** Adapters. */
1392
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1393
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1394
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_posts', $this->batch_analysis_adapter, 'submit_posts', 10 );
1395
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1396
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1397
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1398
-
1399
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1400
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1401
-
1402
-		// Handle the autocomplete request.
1403
-		add_action( 'wp_ajax_wl_autocomplete', array(
1404
-			$this->autocomplete_adapter,
1405
-			'wl_autocomplete',
1406
-		) );
1407
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1408
-			$this->autocomplete_adapter,
1409
-			'wl_autocomplete',
1410
-		) );
1411
-
1412
-		// Hooks to restrict multisite super admin from manipulating entity types.
1413
-		if ( is_multisite() ) {
1414
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1415
-		}
1416
-
1417
-	}
1418
-
1419
-	/**
1420
-	 * Register all of the hooks related to the public-facing functionality
1421
-	 * of the plugin.
1422
-	 *
1423
-	 * @since    1.0.0
1424
-	 * @access   private
1425
-	 */
1426
-	private function define_public_hooks() {
1427
-
1428
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1429
-
1430
-		// Register the entity post type.
1431
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1432
-
1433
-		// Bind the link generation and handling hooks to the entity link service.
1434
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1435
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1436
-		$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 );
1437
-		$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 );
1438
-
1439
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1440
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1441
-
1442
-		// Hook the content filter service to add entity links.
1443
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1444
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1445
-		}
1446
-
1447
-		// Hook the AJAX wl_timeline action to the Timeline service.
1448
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1449
-
1450
-		// Hook the ShareThis service.
1451
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1452
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1453
-
1454
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1455
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1456
-
1457
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1458
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1459
-		// to categories.
1460
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1461
-
1462
-		/*
1208
+        // Pages.
1209
+        new Wordlift_Admin_Post_Edit_Page( $this );
1210
+        new Wordlift_Entity_Type_Admin_Service();
1211
+
1212
+        // create an instance of the entity type list admin page controller.
1213
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1214
+
1215
+        // create an instance of the entity type etting admin page controller.
1216
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1217
+
1218
+        /** Widgets */
1219
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1220
+
1221
+        /* WordPress Admin. */
1222
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1223
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1224
+
1225
+        // Create an instance of the install wizard.
1226
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1227
+
1228
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1229
+
1230
+        // User Profile.
1231
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1232
+
1233
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1234
+
1235
+        // Load the debug service if WP is in debug mode.
1236
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1237
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1238
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1239
+        }
1240
+
1241
+    }
1242
+
1243
+    /**
1244
+     * Define the locale for this plugin for internationalization.
1245
+     *
1246
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1247
+     * with WordPress.
1248
+     *
1249
+     * @since    1.0.0
1250
+     * @access   private
1251
+     */
1252
+    private function set_locale() {
1253
+
1254
+        $plugin_i18n = new Wordlift_i18n();
1255
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1256
+
1257
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1258
+
1259
+    }
1260
+
1261
+    /**
1262
+     * Register all of the hooks related to the admin area functionality
1263
+     * of the plugin.
1264
+     *
1265
+     * @since    1.0.0
1266
+     * @access   private
1267
+     */
1268
+    private function define_admin_hooks() {
1269
+
1270
+        $plugin_admin = new Wordlift_Admin(
1271
+            $this->get_plugin_name(),
1272
+            $this->get_version(),
1273
+            $this->configuration_service,
1274
+            $this->notice_service,
1275
+            $this->user_service
1276
+        );
1277
+
1278
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1279
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1280
+
1281
+        // Hook the init action to the Topic Taxonomy service.
1282
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1283
+
1284
+        // Hook the deleted_post_meta action to the Thumbnail service.
1285
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1286
+
1287
+        // Hook the added_post_meta action to the Thumbnail service.
1288
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1289
+
1290
+        // Hook the updated_post_meta action to the Thumbnail service.
1291
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1292
+
1293
+        // Hook the AJAX wl_timeline action to the Timeline service.
1294
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1295
+
1296
+        // Register custom allowed redirect hosts.
1297
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1298
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1299
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1300
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1301
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1302
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1303
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1304
+
1305
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1306
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1307
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1308
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1309
+
1310
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1311
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1312
+
1313
+        // Entity listing customization (wp-admin/edit.php)
1314
+        // Add custom columns.
1315
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1316
+        // no explicit entity as it prevents handling of other post types.
1317
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1318
+        // Add 4W selection.
1319
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1320
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1321
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1322
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1323
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1324
+
1325
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1326
+        // entities.
1327
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1328
+
1329
+        // Filter imported post meta.
1330
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1331
+
1332
+        // Notify the import service when an import starts and ends.
1333
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1334
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1335
+
1336
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1337
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1338
+
1339
+        // Hook the menu to the Download Your Data page.
1340
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1341
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1342
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1343
+
1344
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1345
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1346
+
1347
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1348
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1349
+
1350
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1351
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1352
+
1353
+        // Hook the `admin_init` function to the Admin Setup.
1354
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1355
+
1356
+        // Hook the admin_init to the settings page.
1357
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1358
+
1359
+        // Hook the menu creation on the general wordlift menu creation.
1360
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1361
+        if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1362
+            // Add the functionality only if a flag is set in wp-config.php .
1363
+            $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1364
+        }
1365
+
1366
+        // Hook key update.
1367
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1368
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1369
+
1370
+        // Add additional action links to the WordLift plugin in the plugins page.
1371
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1372
+
1373
+        // Hook the AJAX `wl_publisher` action name.
1374
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1375
+
1376
+        // Hook row actions for the entity type list admin.
1377
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1378
+
1379
+        /** Ajax actions. */
1380
+        $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1381
+
1382
+        // Hook capabilities manipulation to allow access to entity type admin
1383
+        // page  on WordPress versions before 4.7.
1384
+        global $wp_version;
1385
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1386
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1387
+        }
1388
+
1389
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1390
+
1391
+        /** Adapters. */
1392
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1393
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1394
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_posts', $this->batch_analysis_adapter, 'submit_posts', 10 );
1395
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1396
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1397
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1398
+
1399
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1400
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1401
+
1402
+        // Handle the autocomplete request.
1403
+        add_action( 'wp_ajax_wl_autocomplete', array(
1404
+            $this->autocomplete_adapter,
1405
+            'wl_autocomplete',
1406
+        ) );
1407
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1408
+            $this->autocomplete_adapter,
1409
+            'wl_autocomplete',
1410
+        ) );
1411
+
1412
+        // Hooks to restrict multisite super admin from manipulating entity types.
1413
+        if ( is_multisite() ) {
1414
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1415
+        }
1416
+
1417
+    }
1418
+
1419
+    /**
1420
+     * Register all of the hooks related to the public-facing functionality
1421
+     * of the plugin.
1422
+     *
1423
+     * @since    1.0.0
1424
+     * @access   private
1425
+     */
1426
+    private function define_public_hooks() {
1427
+
1428
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1429
+
1430
+        // Register the entity post type.
1431
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1432
+
1433
+        // Bind the link generation and handling hooks to the entity link service.
1434
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1435
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1436
+        $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 );
1437
+        $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 );
1438
+
1439
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1440
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1441
+
1442
+        // Hook the content filter service to add entity links.
1443
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1444
+            $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1445
+        }
1446
+
1447
+        // Hook the AJAX wl_timeline action to the Timeline service.
1448
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1449
+
1450
+        // Hook the ShareThis service.
1451
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1452
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1453
+
1454
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1455
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1456
+
1457
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1458
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1459
+        // to categories.
1460
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1461
+
1462
+        /*
1463 1463
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1464 1464
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1465 1465
 		 * order of start time.
1466 1466
 		 */
1467
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1468
-
1469
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1470
-
1471
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1472
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1473
-
1474
-	}
1475
-
1476
-	/**
1477
-	 * Run the loader to execute all of the hooks with WordPress.
1478
-	 *
1479
-	 * @since    1.0.0
1480
-	 */
1481
-	public function run() {
1482
-		$this->loader->run();
1483
-	}
1484
-
1485
-	/**
1486
-	 * The name of the plugin used to uniquely identify it within the context of
1487
-	 * WordPress and to define internationalization functionality.
1488
-	 *
1489
-	 * @since     1.0.0
1490
-	 * @return    string    The name of the plugin.
1491
-	 */
1492
-	public function get_plugin_name() {
1493
-		return $this->plugin_name;
1494
-	}
1495
-
1496
-	/**
1497
-	 * The reference to the class that orchestrates the hooks with the plugin.
1498
-	 *
1499
-	 * @since     1.0.0
1500
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1501
-	 */
1502
-	public function get_loader() {
1503
-		return $this->loader;
1504
-	}
1505
-
1506
-	/**
1507
-	 * Retrieve the version number of the plugin.
1508
-	 *
1509
-	 * @since     1.0.0
1510
-	 * @return    string    The version number of the plugin.
1511
-	 */
1512
-	public function get_version() {
1513
-		return $this->version;
1514
-	}
1467
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1468
+
1469
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1470
+
1471
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1472
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1473
+
1474
+    }
1475
+
1476
+    /**
1477
+     * Run the loader to execute all of the hooks with WordPress.
1478
+     *
1479
+     * @since    1.0.0
1480
+     */
1481
+    public function run() {
1482
+        $this->loader->run();
1483
+    }
1484
+
1485
+    /**
1486
+     * The name of the plugin used to uniquely identify it within the context of
1487
+     * WordPress and to define internationalization functionality.
1488
+     *
1489
+     * @since     1.0.0
1490
+     * @return    string    The name of the plugin.
1491
+     */
1492
+    public function get_plugin_name() {
1493
+        return $this->plugin_name;
1494
+    }
1495
+
1496
+    /**
1497
+     * The reference to the class that orchestrates the hooks with the plugin.
1498
+     *
1499
+     * @since     1.0.0
1500
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1501
+     */
1502
+    public function get_loader() {
1503
+        return $this->loader;
1504
+    }
1505
+
1506
+    /**
1507
+     * Retrieve the version number of the plugin.
1508
+     *
1509
+     * @since     1.0.0
1510
+     * @return    string    The version number of the plugin.
1511
+     */
1512
+    public function get_version() {
1513
+        return $this->version;
1514
+    }
1515 1515
 
1516 1516
 }
Please login to merge, or discard this patch.
Spacing   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -717,346 +717,346 @@  discard block
 block discarded – undo
717 717
 		 * The class responsible for orchestrating the actions and filters of the
718 718
 		 * core plugin.
719 719
 		 */
720
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
720
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php';
721 721
 
722 722
 		/**
723 723
 		 * The class responsible for defining internationalization functionality
724 724
 		 * of the plugin.
725 725
 		 */
726
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
726
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php';
727 727
 
728 728
 		/**
729 729
 		 * WordLift's supported languages.
730 730
 		 */
731
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
731
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php';
732 732
 
733 733
 		/**
734 734
 		 * Provide support functions to sanitize data.
735 735
 		 */
736
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
736
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php';
737 737
 
738 738
 		/** Services. */
739
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
739
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php';
740
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php';
741
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php';
742
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php';
743
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php';
744
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php';
745
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php';
746
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php';
747
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php';
748 748
 
749 749
 		/**
750 750
 		 * The Query builder.
751 751
 		 */
752
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
752
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php';
753 753
 
754 754
 		/**
755 755
 		 * The Schema service.
756 756
 		 */
757
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
757
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php';
758 758
 
759 759
 		/**
760 760
 		 * The schema:url property service.
761 761
 		 */
762
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
762
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php';
763
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php';
764 764
 
765 765
 		/**
766 766
 		 * The UI service.
767 767
 		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
768
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php';
769 769
 
770 770
 		/**
771 771
 		 * The Thumbnail service.
772 772
 		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
773
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php';
774 774
 
775 775
 		/**
776 776
 		 * The Entity Types Taxonomy service.
777 777
 		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
778
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php';
779 779
 
780 780
 		/**
781 781
 		 * The Entity service.
782 782
 		 */
783
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
783
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-service.php';
784
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php';
785 785
 
786 786
 		// Add the entity rating service.
787
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
787
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php';
788 788
 
789 789
 		/**
790 790
 		 * The User service.
791 791
 		 */
792
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
792
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php';
793 793
 
794 794
 		/**
795 795
 		 * The Timeline service.
796 796
 		 */
797
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
797
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php';
798 798
 
799 799
 		/**
800 800
 		 * The Topic Taxonomy service.
801 801
 		 */
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
802
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php';
803 803
 
804 804
 		/**
805 805
 		 * The SPARQL service.
806 806
 		 */
807
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
807
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php';
808 808
 
809 809
 		/**
810 810
 		 * The WordLift import service.
811 811
 		 */
812
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
812
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php';
813 813
 
814 814
 		/**
815 815
 		 * The WordLift URI service.
816 816
 		 */
817
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
817
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php';
818 818
 
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
819
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php';
820 820
 
821
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
821
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php';
822 822
 
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
823
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php';
824 824
 
825 825
 		/**
826 826
 		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827 827
 		 */
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
828
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php';
829 829
 
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
830
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php';
831 831
 
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
832
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php';
833 833
 
834 834
 		/**
835 835
 		 * Load the converters.
836 836
 		 */
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
837
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php';
838
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php';
840
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php';
842
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php';
843 843
 
844 844
 		/**
845 845
 		 * Load cache-related files.
846 846
 		 */
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
847
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php';
848 848
 
849 849
 		/**
850 850
 		 * Load the content filter.
851 851
 		 */
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
852
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php';
853 853
 
854 854
 		/*
855 855
 		 * Load the excerpt helper.
856 856
 		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
857
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php';
858 858
 
859 859
 		/**
860 860
 		 * Load the JSON-LD service to publish entities using JSON-LD.s
861 861
 		 *
862 862
 		 * @since 3.8.0
863 863
 		 */
864
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
864
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php';
865 865
 
866 866
 		// The Publisher Service and the AJAX adapter.
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
867
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php';
868
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php';
869 869
 
870
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
870
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php';
871 871
 
872 872
 		/**
873 873
 		 * Load the WordLift key validation service.
874 874
 		 */
875
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
875
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php';
876 876
 
877 877
 		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
878
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php';
879 879
 
880 880
 		// Load the `Wordlift_Entity_Page_Service` class definition.
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php';
883
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-service.php';
884
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
881
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php';
882
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php';
883
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/batch-analysis/class-wordlift-batch-analysis-service.php';
884
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-rebuild-service.php';
885 885
 
886 886
 		/** Linked Data. */
887
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
888
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
889
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
890
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
893
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
894
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
895
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
896
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
897
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
898
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
899
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
887
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage.php';
888
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
889
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-property-storage.php';
890
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
891
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
892
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-author-storage.php';
893
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
894
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-image-storage.php';
895
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-related-storage.php';
896
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-url-property-storage.php';
897
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage-factory.php';
898
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
899
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
900 900
 
901 901
 		/** Services. */
902
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
902
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php';
903 903
 
904 904
 		/** Adapters. */
905
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
906
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
908
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
909
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-adapter.php';
910
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
905
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php';
906
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php';
907
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-ajax-adapter.php';
908
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-adapter.php';
909
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/batch-analysis/class-wordlift-batch-analysis-adapter.php';
910
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-rebuild-adapter.php';
911 911
 
912 912
 		/** Async Tasks. */
913
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
914
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
916
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
913
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-async-task.php';
914
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
915
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
916
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
917 917
 
918 918
 		/** Async Tasks. */
919
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
919
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-service.php';
920
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-adapter.php';
921 921
 
922 922
 		/**
923 923
 		 * The class responsible for defining all actions that occur in the admin area.
924 924
 		 */
925
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
925
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php';
926 926
 
927 927
 		/**
928 928
 		 * The class to customize the entity list admin page.
929 929
 		 */
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
930
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php';
931 931
 
932 932
 		/**
933 933
 		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
934 934
 		 */
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
935
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php';
936 936
 
937 937
 		/**
938 938
 		 * The Notice service.
939 939
 		 */
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
940
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php';
941 941
 
942 942
 		/**
943 943
 		 * The PrimaShop adapter.
944 944
 		 */
945
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
945
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php';
946 946
 
947 947
 		/**
948 948
 		 * The WordLift Dashboard service.
949 949
 		 */
950
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
950
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php';
951 951
 
952 952
 		/**
953 953
 		 * The admin 'Install wizard' page.
954 954
 		 */
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
955
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php';
956 956
 
957 957
 		/**
958 958
 		 * The WordLift entity type list admin page controller.
959 959
 		 */
960
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
960
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
961 961
 
962 962
 		/**
963 963
 		 * The WordLift entity type settings admin page controller.
964 964
 		 */
965
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
965
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php';
966 966
 
967 967
 		/**
968 968
 		 * The admin 'Download Your Data' page.
969 969
 		 */
970
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
970
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php';
971 971
 
972 972
 		/**
973 973
 		 * The admin 'WordLift Settings' page.
974 974
 		 */
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
976
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
981
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
983
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
984
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
986
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
975
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/intf-wordlift-admin-element.php';
976
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-element.php';
977
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-radio-element.php';
978
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-select2-element.php';
979
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-language-select-element.php';
980
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-tabs-element.php';
981
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-author-element.php';
982
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-publisher-element.php';
983
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php';
984
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php';
985
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-batch-analysis-page.php';
986
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php';
987 987
 
988 988
 		/** Admin Pages */
989
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
991
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
992
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
989
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php';
990
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-user-profile-page.php';
991
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php';
992
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-admin-service.php';
993 993
 
994 994
 		/**
995 995
 		 * The class responsible for defining all actions that occur in the public-facing
996 996
 		 * side of the site.
997 997
 		 */
998
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
998
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php';
999 999
 
1000 1000
 		/**
1001 1001
 		 * The shortcode abstract class.
1002 1002
 		 */
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1003
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php';
1004 1004
 
1005 1005
 		/**
1006 1006
 		 * The Timeline shortcode.
1007 1007
 		 */
1008
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1008
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php';
1009 1009
 
1010 1010
 		/**
1011 1011
 		 * The Navigator shortcode.
1012 1012
 		 */
1013
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1013
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php';
1014 1014
 
1015 1015
 		/**
1016 1016
 		 * The chord shortcode.
1017 1017
 		 */
1018
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1018
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php';
1019 1019
 
1020 1020
 		/**
1021 1021
 		 * The geomap shortcode.
1022 1022
 		 */
1023
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1023
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php';
1024 1024
 
1025 1025
 		/**
1026 1026
 		 * The entity cloud shortcode.
1027 1027
 		 */
1028
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1028
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php';
1029 1029
 
1030 1030
 		/**
1031 1031
 		 * The entity glossary shortcode.
1032 1032
 		 */
1033
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1034
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1033
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-alphabet-service.php';
1034
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-vocabulary-shortcode.php';
1035 1035
 
1036 1036
 		/**
1037 1037
 		 * The ShareThis service.
1038 1038
 		 */
1039
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1039
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php';
1040 1040
 
1041 1041
 		/**
1042 1042
 		 * The SEO service.
1043 1043
 		 */
1044
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1044
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php';
1045 1045
 
1046 1046
 		/**
1047 1047
 		 * The AMP service.
1048 1048
 		 */
1049
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1049
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php';
1050 1050
 
1051 1051
 		/** Widgets */
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1053
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1052
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php';
1053
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php';
1054 1054
 
1055 1055
 		$this->loader = new Wordlift_Loader();
1056 1056
 
1057 1057
 		// Instantiate a global logger.
1058 1058
 		global $wl_logger;
1059
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1059
+		$wl_logger = Wordlift_Log_Service::get_logger('WordLift');
1060 1060
 
1061 1061
 		// Load the `wl-api` end-point.
1062 1062
 		new Wordlift_Http_Api();
@@ -1066,10 +1066,10 @@  discard block
 block discarded – undo
1066 1066
 		$this->configuration_service = new Wordlift_Configuration_Service();
1067 1067
 
1068 1068
 		// Create an entity type service instance. It'll be later bound to the init action.
1069
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1069
+		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path());
1070 1070
 
1071 1071
 		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1072
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1072
+		$this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path());
1073 1073
 
1074 1074
 		// Create an instance of the UI service.
1075 1075
 		$this->ui_service = new Wordlift_UI_Service();
@@ -1078,33 +1078,33 @@  discard block
 block discarded – undo
1078 1078
 		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1079 1079
 
1080 1080
 		$this->sparql_service        = new Wordlift_Sparql_Service();
1081
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1081
+		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service);
1082 1082
 		$this->notice_service        = new Wordlift_Notice_Service();
1083 1083
 		$this->relation_service      = new Wordlift_Relation_Service();
1084 1084
 
1085
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1086
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1087
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1085
+		$entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/');
1086
+		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service($this->configuration_service, $entity_uri_cache_service);
1087
+		$this->entity_service     = new Wordlift_Entity_Service($this->ui_service, $this->relation_service, $this->entity_uri_service);
1088 1088
 		$this->user_service       = new Wordlift_User_Service();
1089 1089
 
1090 1090
 		// Instantiate the JSON-LD service.
1091
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1091
+		$property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service);
1092 1092
 
1093 1093
 		/** Linked Data. */
1094
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1095
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1094
+		$this->storage_factory   = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter);
1095
+		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service);
1096 1096
 
1097
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1097
+		$this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service);
1098 1098
 
1099 1099
 		// Create a new instance of the Redirect service.
1100
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1101
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1102
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1100
+		$this->redirect_service    = new Wordlift_Redirect_Service($this->entity_service);
1101
+		$this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service);
1102
+		$this->linked_data_service = new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service);
1103 1103
 
1104 1104
 		// Create a new instance of the Timeline service and Timeline shortcode.
1105
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1105
+		$this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service);
1106 1106
 
1107
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1107
+		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service($this, $this->configuration_service);
1108 1108
 
1109 1109
 		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1110 1110
 
@@ -1117,53 +1117,53 @@  discard block
 block discarded – undo
1117 1117
 		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1118 1118
 
1119 1119
 		// Create an import service instance to hook later to WP's import function.
1120
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1120
+		$this->import_service = new Wordlift_Import_Service($this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri());
1121 1121
 
1122
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1122
+		$uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']);
1123 1123
 
1124 1124
 		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1125
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1125
+		$this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service);
1126 1126
 
1127 1127
 		// Create the entity rating service.
1128
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1128
+		$this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service);
1129 1129
 
1130 1130
 		// Create entity list customization (wp-admin/edit.php).
1131
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1131
+		$this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service);
1132 1132
 
1133 1133
 		// Create a new instance of the Redirect service.
1134
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1134
+		$this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service);
1135 1135
 
1136 1136
 		// Create an instance of the Publisher Service and the AJAX Adapter.
1137 1137
 		$publisher_service      = new Wordlift_Publisher_Service();
1138
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1139
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1138
+		$this->property_factory = new Wordlift_Property_Factory($schema_url_property_service);
1139
+		$this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service);
1140 1140
 
1141 1141
 		$attachment_service = new Wordlift_Attachment_Service();
1142 1142
 
1143 1143
 		// Instantiate the JSON-LD service.
1144
-		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1145
-		$this->entity_post_to_jsonld_converter   = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1146
-		$this->post_to_jsonld_converter          = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1147
-		$this->postid_to_jsonld_converter        = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1148
-		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1149
-		$this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1150
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1151
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1152
-
1153
-
1154
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1155
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1156
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1157
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1158
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1144
+		$property_getter                         = Wordlift_Property_Getter_Factory::create($this->entity_service);
1145
+		$this->entity_post_to_jsonld_converter   = new Wordlift_Entity_Post_To_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter);
1146
+		$this->post_to_jsonld_converter          = new Wordlift_Post_To_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service);
1147
+		$this->postid_to_jsonld_converter        = new Wordlift_Postid_To_Jsonld_Converter($this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter);
1148
+		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service);
1149
+		$this->file_cache_service                = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'converter/');
1150
+		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service);
1151
+		$this->jsonld_service                    = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter);
1152
+
1153
+
1154
+		$this->key_validation_service   = new Wordlift_Key_Validation_Service($this->configuration_service);
1155
+		$this->content_filter_service   = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service, $this->entity_uri_service);
1156
+		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service);
1157
+		$this->sample_data_service      = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service, $this->user_service);
1158
+		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service);
1159 1159
 
1160 1160
 		// Initialize the shortcodes.
1161 1161
 		new Wordlift_Navigator_Shortcode();
1162 1162
 		new Wordlift_Chord_Shortcode();
1163 1163
 		new Wordlift_Geomap_Shortcode();
1164 1164
 		new Wordlift_Timeline_Shortcode();
1165
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1166
-		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1165
+		new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service);
1166
+		new Wordlift_Vocabulary_Shortcode($this->configuration_service);
1167 1167
 
1168 1168
 		// Initialize the SEO service.
1169 1169
 		new Wordlift_Seo_Service();
@@ -1175,11 +1175,11 @@  discard block
 block discarded – undo
1175 1175
 		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1176 1176
 
1177 1177
 		/** Adapters. */
1178
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1179
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1180
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1181
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1182
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1178
+		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter($this->entity_type_service);
1179
+		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter($publisher_service);
1180
+		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter($this);
1181
+		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter($this->batch_analysis_service);
1182
+		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service);
1183 1183
 
1184 1184
 		/** Async Tasks. */
1185 1185
 		new Wordlift_Sparql_Query_Async_Task();
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 		new Wordlift_Batch_Analysis_Complete_Async_Task();
1188 1188
 
1189 1189
 		/** WL Autocomplete. */
1190
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1191
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1190
+		$this->autocomplete_service = new Wordlift_Autocomplete_Service($this->configuration_service);
1191
+		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($this->autocomplete_service);
1192 1192
 
1193 1193
 		/** WordPress Admin UI. */
1194 1194
 
@@ -1198,15 +1198,15 @@  discard block
 block discarded – undo
1198 1198
 		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1199 1199
 		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1200 1200
 		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1201
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1202
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1201
+		$this->publisher_element       = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element);
1202
+		$this->author_element          = new Wordlift_Admin_Author_Element($publisher_service, $this->select2_element);
1203 1203
 
1204
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1205
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1206
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1204
+		$this->settings_page             = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element);
1205
+		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page($this->batch_analysis_service);
1206
+		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page);
1207 1207
 
1208 1208
 		// Pages.
1209
-		new Wordlift_Admin_Post_Edit_Page( $this );
1209
+		new Wordlift_Admin_Post_Edit_Page($this);
1210 1210
 		new Wordlift_Entity_Type_Admin_Service();
1211 1211
 
1212 1212
 		// create an instance of the entity type list admin page controller.
@@ -1219,23 +1219,23 @@  discard block
 block discarded – undo
1219 1219
 		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1220 1220
 
1221 1221
 		/* WordPress Admin. */
1222
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1223
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1222
+		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service);
1223
+		$this->status_page             = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service);
1224 1224
 
1225 1225
 		// Create an instance of the install wizard.
1226
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1226
+		$this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service);
1227 1227
 
1228
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1228
+		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service);
1229 1229
 
1230 1230
 		// User Profile.
1231
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1231
+		new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service);
1232 1232
 
1233 1233
 		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1234 1234
 
1235 1235
 		// Load the debug service if WP is in debug mode.
1236
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1237
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1238
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1236
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1237
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php';
1238
+			new Wordlift_Debug_Service($this->entity_service, $uri_service);
1239 1239
 		}
1240 1240
 
1241 1241
 	}
@@ -1252,9 +1252,9 @@  discard block
 block discarded – undo
1252 1252
 	private function set_locale() {
1253 1253
 
1254 1254
 		$plugin_i18n = new Wordlift_i18n();
1255
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1255
+		$plugin_i18n->set_domain($this->get_plugin_name());
1256 1256
 
1257
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1257
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
1258 1258
 
1259 1259
 	}
1260 1260
 
@@ -1275,143 +1275,143 @@  discard block
 block discarded – undo
1275 1275
 			$this->user_service
1276 1276
 		);
1277 1277
 
1278
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1279
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1278
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
1279
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
1280 1280
 
1281 1281
 		// Hook the init action to the Topic Taxonomy service.
1282
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1282
+		$this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0);
1283 1283
 
1284 1284
 		// Hook the deleted_post_meta action to the Thumbnail service.
1285
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1285
+		$this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4);
1286 1286
 
1287 1287
 		// Hook the added_post_meta action to the Thumbnail service.
1288
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1288
+		$this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1289 1289
 
1290 1290
 		// Hook the updated_post_meta action to the Thumbnail service.
1291
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1291
+		$this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1292 1292
 
1293 1293
 		// Hook the AJAX wl_timeline action to the Timeline service.
1294
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1294
+		$this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline');
1295 1295
 
1296 1296
 		// Register custom allowed redirect hosts.
1297
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1297
+		$this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts');
1298 1298
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1299
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1299
+		$this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect');
1300 1300
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1301
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1301
+		$this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats');
1302 1302
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1303
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1303
+		$this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets');
1304 1304
 
1305 1305
 		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1306 1306
 		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1307
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1308
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1307
+		$this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3);
1308
+		$this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1);
1309 1309
 
1310
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1311
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1310
+		$this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1);
1311
+		$this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header');
1312 1312
 
1313 1313
 		// Entity listing customization (wp-admin/edit.php)
1314 1314
 		// Add custom columns.
1315
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1315
+		$this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns');
1316 1316
 		// no explicit entity as it prevents handling of other post types.
1317
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1317
+		$this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2);
1318 1318
 		// Add 4W selection.
1319
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1320
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1321
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1322
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1323
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1319
+		$this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope');
1320
+		$this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope');
1321
+		$this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts');
1322
+		$this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit');
1323
+		$this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args');
1324 1324
 
1325 1325
 		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1326 1326
 		// entities.
1327
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1327
+		$this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2);
1328 1328
 
1329 1329
 		// Filter imported post meta.
1330
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1330
+		$this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3);
1331 1331
 
1332 1332
 		// Notify the import service when an import starts and ends.
1333
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1334
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1333
+		$this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0);
1334
+		$this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0);
1335 1335
 
1336 1336
 		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1337
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1337
+		$this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild');
1338 1338
 
1339 1339
 		// Hook the menu to the Download Your Data page.
1340
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1341
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1342
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1340
+		$this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0);
1341
+		$this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0);
1342
+		$this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0);
1343 1343
 
1344 1344
 		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1345
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1345
+		$this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10);
1346 1346
 
1347 1347
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1348
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1348
+		$this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get');
1349 1349
 
1350 1350
 		// Hook the AJAX wl_validate_key action to the Key Validation service.
1351
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1351
+		$this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key');
1352 1352
 
1353 1353
 		// Hook the `admin_init` function to the Admin Setup.
1354
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1354
+		$this->loader->add_action('admin_init', $this->admin_setup, 'admin_init');
1355 1355
 
1356 1356
 		// Hook the admin_init to the settings page.
1357
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1357
+		$this->loader->add_action('admin_init', $this->settings_page, 'admin_init');
1358 1358
 
1359 1359
 		// Hook the menu creation on the general wordlift menu creation.
1360
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1361
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1360
+		$this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2);
1361
+		if (defined('WORDLIFT_BATCH') && WORDLIFT_BATCH) {
1362 1362
 			// Add the functionality only if a flag is set in wp-config.php .
1363
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1363
+			$this->loader->add_action('wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2);
1364 1364
 		}
1365 1365
 
1366 1366
 		// Hook key update.
1367
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1368
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1367
+		$this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2);
1368
+		$this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2);
1369 1369
 
1370 1370
 		// Add additional action links to the WordLift plugin in the plugins page.
1371
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1371
+		$this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1);
1372 1372
 
1373 1373
 		// Hook the AJAX `wl_publisher` action name.
1374
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1374
+		$this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher');
1375 1375
 
1376 1376
 		// Hook row actions for the entity type list admin.
1377
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1377
+		$this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2);
1378 1378
 
1379 1379
 		/** Ajax actions. */
1380
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1380
+		$this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export');
1381 1381
 
1382 1382
 		// Hook capabilities manipulation to allow access to entity type admin
1383 1383
 		// page  on WordPress versions before 4.7.
1384 1384
 		global $wp_version;
1385
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1386
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1385
+		if (version_compare($wp_version, '4.7', '<')) {
1386
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4);
1387 1387
 		}
1388 1388
 
1389
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1389
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1390 1390
 
1391 1391
 		/** Adapters. */
1392
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1393
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1394
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_posts', $this->batch_analysis_adapter, 'submit_posts', 10 );
1395
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1396
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1397
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1392
+		$this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1);
1393
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10);
1394
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_submit_posts', $this->batch_analysis_adapter, 'submit_posts', 10);
1395
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10);
1396
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10);
1397
+		$this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10);
1398 1398
 
1399
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1400
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1399
+		$this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create');
1400
+		$this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete');
1401 1401
 
1402 1402
 		// Handle the autocomplete request.
1403
-		add_action( 'wp_ajax_wl_autocomplete', array(
1403
+		add_action('wp_ajax_wl_autocomplete', array(
1404 1404
 			$this->autocomplete_adapter,
1405 1405
 			'wl_autocomplete',
1406
-		) );
1407
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1406
+		));
1407
+		add_action('wp_ajax_nopriv_wl_autocomplete', array(
1408 1408
 			$this->autocomplete_adapter,
1409 1409
 			'wl_autocomplete',
1410
-		) );
1410
+		));
1411 1411
 
1412 1412
 		// Hooks to restrict multisite super admin from manipulating entity types.
1413
-		if ( is_multisite() ) {
1414
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1413
+		if (is_multisite()) {
1414
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4);
1415 1415
 		}
1416 1416
 
1417 1417
 	}
@@ -1425,51 +1425,51 @@  discard block
 block discarded – undo
1425 1425
 	 */
1426 1426
 	private function define_public_hooks() {
1427 1427
 
1428
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1428
+		$plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version());
1429 1429
 
1430 1430
 		// Register the entity post type.
1431
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1431
+		$this->loader->add_action('init', $this->entity_post_type_service, 'register');
1432 1432
 
1433 1433
 		// Bind the link generation and handling hooks to the entity link service.
1434
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1435
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1436
-		$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 );
1437
-		$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 );
1434
+		$this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4);
1435
+		$this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1);
1436
+		$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);
1437
+		$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);
1438 1438
 
1439
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1440
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1439
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
1440
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
1441 1441
 
1442 1442
 		// Hook the content filter service to add entity links.
1443
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1444
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1443
+		if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) {
1444
+			$this->loader->add_filter('the_content', $this->content_filter_service, 'the_content');
1445 1445
 		}
1446 1446
 
1447 1447
 		// Hook the AJAX wl_timeline action to the Timeline service.
1448
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1448
+		$this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline');
1449 1449
 
1450 1450
 		// Hook the ShareThis service.
1451
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1452
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1451
+		$this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99);
1452
+		$this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99);
1453 1453
 
1454 1454
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1455
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1455
+		$this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get');
1456 1456
 
1457 1457
 		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1458 1458
 		// in order to tweak WP's `WP_Query` to include entities in queries related
1459 1459
 		// to categories.
1460
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1460
+		$this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1);
1461 1461
 
1462 1462
 		/*
1463 1463
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1464 1464
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1465 1465
 		 * order of start time.
1466 1466
 		 */
1467
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1467
+		$this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1);
1468 1468
 
1469
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1469
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1470 1470
 
1471 1471
 		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1472
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1472
+		$this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3);
1473 1473
 
1474 1474
 	}
1475 1475
 
Please login to merge, or discard this patch.