Completed
Push — master ( 5988f5...27f032 )
by David
02:42
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.php 1 patch
Indentation   +1438 added lines, -1438 removed lines patch added patch discarded remove patch
@@ -28,1482 +28,1482 @@
 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.16.4';
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.16.4';
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/class-wordlift-batch-analysis-service.php';
883
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
884
-
885
-		/** Linked Data. */
886
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
887
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
888
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
889
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
890
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
891
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
893
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
894
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
895
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
896
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
897
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
898
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
899
-
900
-		/** Services. */
901
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
902
-
903
-		/** Adapters. */
904
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
905
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
906
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
908
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
909
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
910
-
911
-		/** Async Tasks. */
912
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
913
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
914
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
916
-
917
-		/** Async Tasks. */
918
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
919
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
920
-
921
-		/**
922
-		 * The class responsible for defining all actions that occur in the admin area.
923
-		 */
924
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
925
-
926
-		/**
927
-		 * The class to customize the entity list admin page.
928
-		 */
929
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
930
-
931
-		/**
932
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
933
-		 */
934
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
935
-
936
-		/**
937
-		 * The Notice service.
938
-		 */
939
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
940
-
941
-		/**
942
-		 * The PrimaShop adapter.
943
-		 */
944
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
945
-
946
-		/**
947
-		 * The WordLift Dashboard service.
948
-		 */
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
950
-
951
-		/**
952
-		 * The admin 'Install wizard' page.
953
-		 */
954
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
955
-
956
-		/**
957
-		 * The WordLift entity type list admin page controller.
958
-		 */
959
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
960
-
961
-		/**
962
-		 * The WordLift entity type settings admin page controller.
963
-		 */
964
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
965
-
966
-		/**
967
-		 * The admin 'Download Your Data' page.
968
-		 */
969
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
970
-
971
-		/**
972
-		 * The admin 'WordLift Settings' page.
973
-		 */
974
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
976
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
977
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
978
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
981
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
982
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
983
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
984
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
986
-
987
-		/** Admin Pages */
988
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
989
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
991
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
992
-
993
-		/**
994
-		 * The class responsible for defining all actions that occur in the public-facing
995
-		 * side of the site.
996
-		 */
997
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
998
-
999
-		/**
1000
-		 * The shortcode abstract class.
1001
-		 */
1002
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1003
-
1004
-		/**
1005
-		 * The Timeline shortcode.
1006
-		 */
1007
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1008
-
1009
-		/**
1010
-		 * The Navigator shortcode.
1011
-		 */
1012
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1013
-
1014
-		/**
1015
-		 * The chord shortcode.
1016
-		 */
1017
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1018
-
1019
-		/**
1020
-		 * The geomap shortcode.
1021
-		 */
1022
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1023
-
1024
-		/**
1025
-		 * The entity cloud shortcode.
1026
-		 */
1027
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1028
-
1029
-		/**
1030
-		 * The ShareThis service.
1031
-		 */
1032
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1033
-
1034
-		/**
1035
-		 * The SEO service.
1036
-		 */
1037
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1038
-
1039
-		/**
1040
-		 * The AMP service.
1041
-		 */
1042
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1043
-
1044
-		/** Widgets */
1045
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1046
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1047
-
1048
-		$this->loader = new Wordlift_Loader();
1049
-
1050
-		// Instantiate a global logger.
1051
-		global $wl_logger;
1052
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1053
-
1054
-		// Load the `wl-api` end-point.
1055
-		new Wordlift_Http_Api();
1056
-
1057
-		/** Services. */
1058
-		// Create the configuration service.
1059
-		$this->configuration_service = new Wordlift_Configuration_Service();
1060
-
1061
-		// Create an entity type service instance. It'll be later bound to the init action.
1062
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1063
-
1064
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1065
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1066
-
1067
-		// Create an instance of the UI service.
1068
-		$this->ui_service = new Wordlift_UI_Service();
1069
-
1070
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1071
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1072
-
1073
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1074
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1075
-		$this->notice_service        = new Wordlift_Notice_Service();
1076
-		$this->relation_service      = new Wordlift_Relation_Service();
1077
-
1078
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1079
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1080
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1081
-		$this->user_service       = new Wordlift_User_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/class-wordlift-batch-analysis-service.php';
883
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
884
+
885
+        /** Linked Data. */
886
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
887
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
888
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
889
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
890
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
891
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
892
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
893
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
894
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
895
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
896
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
897
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
898
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
899
+
900
+        /** Services. */
901
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
902
+
903
+        /** Adapters. */
904
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
905
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
906
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
907
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
908
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
909
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
910
+
911
+        /** Async Tasks. */
912
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
913
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
914
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
915
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
916
+
917
+        /** Async Tasks. */
918
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
919
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
920
+
921
+        /**
922
+         * The class responsible for defining all actions that occur in the admin area.
923
+         */
924
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
925
+
926
+        /**
927
+         * The class to customize the entity list admin page.
928
+         */
929
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
930
+
931
+        /**
932
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
933
+         */
934
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
935
+
936
+        /**
937
+         * The Notice service.
938
+         */
939
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
940
+
941
+        /**
942
+         * The PrimaShop adapter.
943
+         */
944
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
945
+
946
+        /**
947
+         * The WordLift Dashboard service.
948
+         */
949
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
950
+
951
+        /**
952
+         * The admin 'Install wizard' page.
953
+         */
954
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
955
+
956
+        /**
957
+         * The WordLift entity type list admin page controller.
958
+         */
959
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
960
+
961
+        /**
962
+         * The WordLift entity type settings admin page controller.
963
+         */
964
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
965
+
966
+        /**
967
+         * The admin 'Download Your Data' page.
968
+         */
969
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
970
+
971
+        /**
972
+         * The admin 'WordLift Settings' page.
973
+         */
974
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
975
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
976
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
977
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
978
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
979
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
980
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
981
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
982
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
983
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
984
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
986
+
987
+        /** Admin Pages */
988
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
989
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
990
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
991
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
992
+
993
+        /**
994
+         * The class responsible for defining all actions that occur in the public-facing
995
+         * side of the site.
996
+         */
997
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
998
+
999
+        /**
1000
+         * The shortcode abstract class.
1001
+         */
1002
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1003
+
1004
+        /**
1005
+         * The Timeline shortcode.
1006
+         */
1007
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1008
+
1009
+        /**
1010
+         * The Navigator shortcode.
1011
+         */
1012
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1013
+
1014
+        /**
1015
+         * The chord shortcode.
1016
+         */
1017
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1018
+
1019
+        /**
1020
+         * The geomap shortcode.
1021
+         */
1022
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1023
+
1024
+        /**
1025
+         * The entity cloud shortcode.
1026
+         */
1027
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1028
+
1029
+        /**
1030
+         * The ShareThis service.
1031
+         */
1032
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1033
+
1034
+        /**
1035
+         * The SEO service.
1036
+         */
1037
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1038
+
1039
+        /**
1040
+         * The AMP service.
1041
+         */
1042
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1043
+
1044
+        /** Widgets */
1045
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1046
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1047
+
1048
+        $this->loader = new Wordlift_Loader();
1049
+
1050
+        // Instantiate a global logger.
1051
+        global $wl_logger;
1052
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1053
+
1054
+        // Load the `wl-api` end-point.
1055
+        new Wordlift_Http_Api();
1056
+
1057
+        /** Services. */
1058
+        // Create the configuration service.
1059
+        $this->configuration_service = new Wordlift_Configuration_Service();
1060
+
1061
+        // Create an entity type service instance. It'll be later bound to the init action.
1062
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1063
+
1064
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1065
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1066
+
1067
+        // Create an instance of the UI service.
1068
+        $this->ui_service = new Wordlift_UI_Service();
1069
+
1070
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1071
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1072
+
1073
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1074
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1075
+        $this->notice_service        = new Wordlift_Notice_Service();
1076
+        $this->relation_service      = new Wordlift_Relation_Service();
1077
+
1078
+        $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1079
+        $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1080
+        $this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1081
+        $this->user_service       = new Wordlift_User_Service();
1082 1082
 
1083
-		// Instantiate the JSON-LD service.
1084
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1083
+        // Instantiate the JSON-LD service.
1084
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1085 1085
 
1086
-		/** Linked Data. */
1087
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1088
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1086
+        /** Linked Data. */
1087
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1088
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1089 1089
 
1090
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1090
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1091 1091
 
1092
-		// Create a new instance of the Redirect service.
1093
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1094
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1095
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1092
+        // Create a new instance of the Redirect service.
1093
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1094
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1095
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1096 1096
 
1097
-		// Create a new instance of the Timeline service and Timeline shortcode.
1098
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1097
+        // Create a new instance of the Timeline service and Timeline shortcode.
1098
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1099 1099
 
1100
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1100
+        $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1101 1101
 
1102
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1102
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1103 1103
 
1104
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1104
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1105 1105
 
1106
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1107
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1106
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1107
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1108 1108
 
1109
-		// Create an instance of the PrimaShop adapter.
1110
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1109
+        // Create an instance of the PrimaShop adapter.
1110
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1111 1111
 
1112
-		// Create an import service instance to hook later to WP's import function.
1113
-		$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() );
1112
+        // Create an import service instance to hook later to WP's import function.
1113
+        $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() );
1114 1114
 
1115
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1115
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1116 1116
 
1117
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1118
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1117
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1118
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1119 1119
 
1120
-		// Create the entity rating service.
1121
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1120
+        // Create the entity rating service.
1121
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1122 1122
 
1123
-		// Create entity list customization (wp-admin/edit.php).
1124
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1123
+        // Create entity list customization (wp-admin/edit.php).
1124
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1125 1125
 
1126
-		// Create a new instance of the Redirect service.
1127
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1126
+        // Create a new instance of the Redirect service.
1127
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1128 1128
 
1129
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1130
-		$publisher_service      = new Wordlift_Publisher_Service();
1131
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1132
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1129
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1130
+        $publisher_service      = new Wordlift_Publisher_Service();
1131
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1132
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1133 1133
 
1134
-		$attachment_service = new Wordlift_Attachment_Service();
1134
+        $attachment_service = new Wordlift_Attachment_Service();
1135 1135
 
1136
-		// Instantiate the JSON-LD service.
1137
-		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1138
-		$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 );
1139
-		$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 );
1140
-		$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 );
1141
-		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1142
-		$this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1143
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1144
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1136
+        // Instantiate the JSON-LD service.
1137
+        $property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1138
+        $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 );
1139
+        $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 );
1140
+        $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 );
1141
+        $this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1142
+        $this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1143
+        $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1144
+        $this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1145 1145
 
1146 1146
 
1147
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1148
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1149
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1150
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1151
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1147
+        $this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1148
+        $this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1149
+        $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1150
+        $this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1151
+        $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1152 1152
 
1153
-		// Initialize the shortcodes.
1154
-		new Wordlift_Navigator_Shortcode();
1155
-		new Wordlift_Chord_Shortcode();
1156
-		new Wordlift_Geomap_Shortcode();
1157
-		new Wordlift_Timeline_Shortcode();
1158
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1153
+        // Initialize the shortcodes.
1154
+        new Wordlift_Navigator_Shortcode();
1155
+        new Wordlift_Chord_Shortcode();
1156
+        new Wordlift_Geomap_Shortcode();
1157
+        new Wordlift_Timeline_Shortcode();
1158
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1159 1159
 
1160
-		// Initialize the SEO service.
1161
-		new Wordlift_Seo_Service();
1160
+        // Initialize the SEO service.
1161
+        new Wordlift_Seo_Service();
1162 1162
 
1163
-		// Initialize the AMP service.
1164
-		new Wordlift_AMP_Service();
1163
+        // Initialize the AMP service.
1164
+        new Wordlift_AMP_Service();
1165 1165
 
1166
-		/** Services. */
1167
-		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1166
+        /** Services. */
1167
+        $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1168 1168
 
1169
-		/** Adapters. */
1170
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1171
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1172
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1173
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1174
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1169
+        /** Adapters. */
1170
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1171
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1172
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1173
+        $this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1174
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1175 1175
 
1176
-		/** Async Tasks. */
1177
-		new Wordlift_Sparql_Query_Async_Task();
1178
-		new Wordlift_Batch_Analysis_Request_Async_Task();
1179
-		new Wordlift_Batch_Analysis_Complete_Async_Task();
1176
+        /** Async Tasks. */
1177
+        new Wordlift_Sparql_Query_Async_Task();
1178
+        new Wordlift_Batch_Analysis_Request_Async_Task();
1179
+        new Wordlift_Batch_Analysis_Complete_Async_Task();
1180 1180
 
1181
-		/** WL Autocomplete. */
1182
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1183
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1181
+        /** WL Autocomplete. */
1182
+        $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1183
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1184 1184
 
1185
-		/** WordPress Admin UI. */
1185
+        /** WordPress Admin UI. */
1186 1186
 
1187
-		// UI elements.
1188
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1189
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1190
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1191
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1192
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1193
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1194
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1187
+        // UI elements.
1188
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1189
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1190
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1191
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1192
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1193
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1194
+        $this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1195 1195
 
1196
-		$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 );
1197
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1198
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1196
+        $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 );
1197
+        $this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1198
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1199 1199
 
1200
-		// Pages.
1201
-		new Wordlift_Admin_Post_Edit_Page( $this );
1202
-		new Wordlift_Entity_Type_Admin_Service();
1200
+        // Pages.
1201
+        new Wordlift_Admin_Post_Edit_Page( $this );
1202
+        new Wordlift_Entity_Type_Admin_Service();
1203 1203
 
1204
-		// create an instance of the entity type list admin page controller.
1205
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1206
-
1207
-		// create an instance of the entity type etting admin page controller.
1208
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1209
-
1210
-		/** Widgets */
1211
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1212
-
1213
-		/* WordPress Admin. */
1214
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1215
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1216
-
1217
-		// Create an instance of the install wizard.
1218
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1219
-
1220
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1221
-
1222
-		// User Profile.
1223
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1224
-
1225
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1226
-
1227
-		// Load the debug service if WP is in debug mode.
1228
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1229
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1230
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1231
-		}
1232
-
1233
-	}
1234
-
1235
-	/**
1236
-	 * Define the locale for this plugin for internationalization.
1237
-	 *
1238
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1239
-	 * with WordPress.
1240
-	 *
1241
-	 * @since    1.0.0
1242
-	 * @access   private
1243
-	 */
1244
-	private function set_locale() {
1245
-
1246
-		$plugin_i18n = new Wordlift_i18n();
1247
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1248
-
1249
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1250
-
1251
-	}
1252
-
1253
-	/**
1254
-	 * Register all of the hooks related to the admin area functionality
1255
-	 * of the plugin.
1256
-	 *
1257
-	 * @since    1.0.0
1258
-	 * @access   private
1259
-	 */
1260
-	private function define_admin_hooks() {
1261
-
1262
-		$plugin_admin = new Wordlift_Admin(
1263
-			$this->get_plugin_name(),
1264
-			$this->get_version(),
1265
-			$this->configuration_service,
1266
-			$this->notice_service,
1267
-			$this->user_service
1268
-		);
1269
-
1270
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1271
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1272
-
1273
-		// Hook the init action to the Topic Taxonomy service.
1274
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1275
-
1276
-		// Hook the deleted_post_meta action to the Thumbnail service.
1277
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1278
-
1279
-		// Hook the added_post_meta action to the Thumbnail service.
1280
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1281
-
1282
-		// Hook the updated_post_meta action to the Thumbnail service.
1283
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1284
-
1285
-		// Hook the AJAX wl_timeline action to the Timeline service.
1286
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1287
-
1288
-		// Register custom allowed redirect hosts.
1289
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1290
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1291
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1292
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1293
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1294
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1295
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1296
-
1297
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1298
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1299
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1300
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1301
-
1302
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1303
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1304
-
1305
-		// Entity listing customization (wp-admin/edit.php)
1306
-		// Add custom columns.
1307
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1308
-		// no explicit entity as it prevents handling of other post types.
1309
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1310
-		// Add 4W selection.
1311
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1312
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1313
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1314
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1315
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1316
-
1317
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1318
-		// entities.
1319
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1320
-
1321
-		// Filter imported post meta.
1322
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1323
-
1324
-		// Notify the import service when an import starts and ends.
1325
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1326
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1327
-
1328
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1329
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1330
-
1331
-		// Hook the menu to the Download Your Data page.
1332
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1333
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1334
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1335
-
1336
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1337
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1338
-
1339
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1340
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1341
-
1342
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1343
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1344
-
1345
-		// Hook the `admin_init` function to the Admin Setup.
1346
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1347
-
1348
-		// Hook the admin_init to the settings page.
1349
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1350
-
1351
-		// Hook the menu creation on the general wordlift menu creation.
1352
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1353
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1354
-			// Add the functionality only if a flag is set in wp-config.php .
1355
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1356
-		}
1357
-
1358
-		// Hook key update.
1359
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1360
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1361
-
1362
-		// Add additional action links to the WordLift plugin in the plugins page.
1363
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1364
-
1365
-		// Hook the AJAX `wl_publisher` action name.
1366
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1367
-
1368
-		// Hook row actions for the entity type list admin.
1369
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1370
-
1371
-		/** Ajax actions. */
1372
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1373
-
1374
-		// Hook capabilities manipulation to allow access to entity type admin
1375
-		// page  on WordPress versions before 4.7.
1376
-		global $wp_version;
1377
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1378
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1379
-		}
1380
-
1381
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1382
-
1383
-		/** Adapters. */
1384
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1385
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1386
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1387
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1388
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1389
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1390
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1391
-
1392
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1393
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1394
-
1395
-		// Handle the autocomplete request.
1396
-		add_action( 'wp_ajax_wl_autocomplete', array(
1397
-			$this->autocomplete_adapter,
1398
-			'wl_autocomplete',
1399
-		) );
1400
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1401
-			$this->autocomplete_adapter,
1402
-			'wl_autocomplete',
1403
-		) );
1404
-
1405
-		// Hooks to restrict multisite super admin from manipulating entity types.
1406
-		if ( is_multisite() ) {
1407
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1408
-		}
1409
-
1410
-	}
1411
-
1412
-	/**
1413
-	 * Register all of the hooks related to the public-facing functionality
1414
-	 * of the plugin.
1415
-	 *
1416
-	 * @since    1.0.0
1417
-	 * @access   private
1418
-	 */
1419
-	private function define_public_hooks() {
1420
-
1421
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1422
-
1423
-		// Register the entity post type.
1424
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1425
-
1426
-		// Bind the link generation and handling hooks to the entity link service.
1427
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1428
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1429
-		$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 );
1430
-		$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 );
1431
-
1432
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1433
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1434
-
1435
-		// Hook the content filter service to add entity links.
1436
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1437
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1438
-		}
1439
-
1440
-		// Hook the AJAX wl_timeline action to the Timeline service.
1441
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1442
-
1443
-		// Hook the ShareThis service.
1444
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1445
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1446
-
1447
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1448
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1449
-
1450
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1451
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1452
-		// to categories.
1453
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1454
-
1455
-		/*
1204
+        // create an instance of the entity type list admin page controller.
1205
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1206
+
1207
+        // create an instance of the entity type etting admin page controller.
1208
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1209
+
1210
+        /** Widgets */
1211
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1212
+
1213
+        /* WordPress Admin. */
1214
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1215
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1216
+
1217
+        // Create an instance of the install wizard.
1218
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1219
+
1220
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1221
+
1222
+        // User Profile.
1223
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1224
+
1225
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1226
+
1227
+        // Load the debug service if WP is in debug mode.
1228
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1229
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1230
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1231
+        }
1232
+
1233
+    }
1234
+
1235
+    /**
1236
+     * Define the locale for this plugin for internationalization.
1237
+     *
1238
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1239
+     * with WordPress.
1240
+     *
1241
+     * @since    1.0.0
1242
+     * @access   private
1243
+     */
1244
+    private function set_locale() {
1245
+
1246
+        $plugin_i18n = new Wordlift_i18n();
1247
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1248
+
1249
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1250
+
1251
+    }
1252
+
1253
+    /**
1254
+     * Register all of the hooks related to the admin area functionality
1255
+     * of the plugin.
1256
+     *
1257
+     * @since    1.0.0
1258
+     * @access   private
1259
+     */
1260
+    private function define_admin_hooks() {
1261
+
1262
+        $plugin_admin = new Wordlift_Admin(
1263
+            $this->get_plugin_name(),
1264
+            $this->get_version(),
1265
+            $this->configuration_service,
1266
+            $this->notice_service,
1267
+            $this->user_service
1268
+        );
1269
+
1270
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1271
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1272
+
1273
+        // Hook the init action to the Topic Taxonomy service.
1274
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1275
+
1276
+        // Hook the deleted_post_meta action to the Thumbnail service.
1277
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1278
+
1279
+        // Hook the added_post_meta action to the Thumbnail service.
1280
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1281
+
1282
+        // Hook the updated_post_meta action to the Thumbnail service.
1283
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1284
+
1285
+        // Hook the AJAX wl_timeline action to the Timeline service.
1286
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1287
+
1288
+        // Register custom allowed redirect hosts.
1289
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1290
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1291
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1292
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1293
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1294
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1295
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1296
+
1297
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1298
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1299
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1300
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1301
+
1302
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1303
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1304
+
1305
+        // Entity listing customization (wp-admin/edit.php)
1306
+        // Add custom columns.
1307
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1308
+        // no explicit entity as it prevents handling of other post types.
1309
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1310
+        // Add 4W selection.
1311
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1312
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1313
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1314
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1315
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1316
+
1317
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1318
+        // entities.
1319
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1320
+
1321
+        // Filter imported post meta.
1322
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1323
+
1324
+        // Notify the import service when an import starts and ends.
1325
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1326
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1327
+
1328
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1329
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1330
+
1331
+        // Hook the menu to the Download Your Data page.
1332
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1333
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1334
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1335
+
1336
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1337
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1338
+
1339
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1340
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1341
+
1342
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1343
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1344
+
1345
+        // Hook the `admin_init` function to the Admin Setup.
1346
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1347
+
1348
+        // Hook the admin_init to the settings page.
1349
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1350
+
1351
+        // Hook the menu creation on the general wordlift menu creation.
1352
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1353
+        if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1354
+            // Add the functionality only if a flag is set in wp-config.php .
1355
+            $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1356
+        }
1357
+
1358
+        // Hook key update.
1359
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1360
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1361
+
1362
+        // Add additional action links to the WordLift plugin in the plugins page.
1363
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1364
+
1365
+        // Hook the AJAX `wl_publisher` action name.
1366
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1367
+
1368
+        // Hook row actions for the entity type list admin.
1369
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1370
+
1371
+        /** Ajax actions. */
1372
+        $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1373
+
1374
+        // Hook capabilities manipulation to allow access to entity type admin
1375
+        // page  on WordPress versions before 4.7.
1376
+        global $wp_version;
1377
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1378
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1379
+        }
1380
+
1381
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1382
+
1383
+        /** Adapters. */
1384
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1385
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1386
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1387
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1388
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1389
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1390
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1391
+
1392
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1393
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1394
+
1395
+        // Handle the autocomplete request.
1396
+        add_action( 'wp_ajax_wl_autocomplete', array(
1397
+            $this->autocomplete_adapter,
1398
+            'wl_autocomplete',
1399
+        ) );
1400
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1401
+            $this->autocomplete_adapter,
1402
+            'wl_autocomplete',
1403
+        ) );
1404
+
1405
+        // Hooks to restrict multisite super admin from manipulating entity types.
1406
+        if ( is_multisite() ) {
1407
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1408
+        }
1409
+
1410
+    }
1411
+
1412
+    /**
1413
+     * Register all of the hooks related to the public-facing functionality
1414
+     * of the plugin.
1415
+     *
1416
+     * @since    1.0.0
1417
+     * @access   private
1418
+     */
1419
+    private function define_public_hooks() {
1420
+
1421
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1422
+
1423
+        // Register the entity post type.
1424
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1425
+
1426
+        // Bind the link generation and handling hooks to the entity link service.
1427
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1428
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1429
+        $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 );
1430
+        $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 );
1431
+
1432
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1433
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1434
+
1435
+        // Hook the content filter service to add entity links.
1436
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1437
+            $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1438
+        }
1439
+
1440
+        // Hook the AJAX wl_timeline action to the Timeline service.
1441
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1442
+
1443
+        // Hook the ShareThis service.
1444
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1445
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1446
+
1447
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1448
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1449
+
1450
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1451
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1452
+        // to categories.
1453
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1454
+
1455
+        /*
1456 1456
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1457 1457
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1458 1458
 		 * order of start time.
1459 1459
 		 */
1460
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1461
-
1462
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1463
-
1464
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1465
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1466
-
1467
-	}
1468
-
1469
-	/**
1470
-	 * Run the loader to execute all of the hooks with WordPress.
1471
-	 *
1472
-	 * @since    1.0.0
1473
-	 */
1474
-	public function run() {
1475
-		$this->loader->run();
1476
-	}
1477
-
1478
-	/**
1479
-	 * The name of the plugin used to uniquely identify it within the context of
1480
-	 * WordPress and to define internationalization functionality.
1481
-	 *
1482
-	 * @since     1.0.0
1483
-	 * @return    string    The name of the plugin.
1484
-	 */
1485
-	public function get_plugin_name() {
1486
-		return $this->plugin_name;
1487
-	}
1488
-
1489
-	/**
1490
-	 * The reference to the class that orchestrates the hooks with the plugin.
1491
-	 *
1492
-	 * @since     1.0.0
1493
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1494
-	 */
1495
-	public function get_loader() {
1496
-		return $this->loader;
1497
-	}
1498
-
1499
-	/**
1500
-	 * Retrieve the version number of the plugin.
1501
-	 *
1502
-	 * @since     1.0.0
1503
-	 * @return    string    The version number of the plugin.
1504
-	 */
1505
-	public function get_version() {
1506
-		return $this->version;
1507
-	}
1460
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1461
+
1462
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1463
+
1464
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1465
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1466
+
1467
+    }
1468
+
1469
+    /**
1470
+     * Run the loader to execute all of the hooks with WordPress.
1471
+     *
1472
+     * @since    1.0.0
1473
+     */
1474
+    public function run() {
1475
+        $this->loader->run();
1476
+    }
1477
+
1478
+    /**
1479
+     * The name of the plugin used to uniquely identify it within the context of
1480
+     * WordPress and to define internationalization functionality.
1481
+     *
1482
+     * @since     1.0.0
1483
+     * @return    string    The name of the plugin.
1484
+     */
1485
+    public function get_plugin_name() {
1486
+        return $this->plugin_name;
1487
+    }
1488
+
1489
+    /**
1490
+     * The reference to the class that orchestrates the hooks with the plugin.
1491
+     *
1492
+     * @since     1.0.0
1493
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1494
+     */
1495
+    public function get_loader() {
1496
+        return $this->loader;
1497
+    }
1498
+
1499
+    /**
1500
+     * Retrieve the version number of the plugin.
1501
+     *
1502
+     * @since     1.0.0
1503
+     * @return    string    The version number of the plugin.
1504
+     */
1505
+    public function get_version() {
1506
+        return $this->version;
1507
+    }
1508 1508
 
1509 1509
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +558 added lines, -558 removed lines patch added patch discarded remove patch
@@ -7,568 +7,568 @@
 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
-		return $args + array(
445
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
446
-				'tax_query' => array(
447
-					array(
448
-						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
-						'terms'    => self::get_entity_terms(),
450
-					),
451
-				),
452
-			);
453
-	}
454
-
455
-	/**
456
-	 * Get the entity terms IDs which represent an entity.
457
-	 *
458
-	 * @since 3.15.0
459
-	 *
460
-	 * @return array An array of terms' ids.
461
-	 */
462
-	public static function get_entity_terms() {
463
-
464
-		$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
465
-			'hide_empty' => false,
466
-			// Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
467
-			// An issue has been opened with the AAM plugin author as well.
468
-			//
469
-			// see https://github.com/insideout10/wordlift-plugin/issues/334
470
-			// see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
471
-			'fields'     => 'all',
472
-		) );
473
-
474
-		return array_map( function ( $term ) {
475
-			return $term->term_id;
476
-		}, array_filter( $terms, function ( $term ) {
477
-			return 'article' !== $term->slug;
478
-		} ) );
479
-	}
480
-
481
-	/**
482
-	 * Create a new entity.
483
-	 *
484
-	 * @since 3.9.0
485
-	 *
486
-	 * @param string $name     The entity name.
487
-	 * @param string $type_uri The entity's type URI.
488
-	 * @param null   $logo     The entity logo id (or NULL if none).
489
-	 * @param string $status   The post status, by default 'publish'.
490
-	 *
491
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
492
-	 */
493
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
494
-
495
-		// Create an entity for the publisher.
496
-		$post_id = wp_insert_post( array(
497
-			'post_type'    => self::TYPE_NAME,
498
-			'post_title'   => $name,
499
-			'post_status'  => $status,
500
-			'post_content' => '',
501
-		) );
502
-
503
-		// Return the error if any.
504
-		if ( is_wp_error( $post_id ) ) {
505
-			return $post_id;
506
-		}
507
-
508
-		// Set the entity logo.
509
-		if ( $logo && is_numeric( $logo ) ) {
510
-			set_post_thumbnail( $post_id, $logo );
511
-		}
512
-
513
-		// Set the entity type.
514
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
515
-
516
-		return $post_id;
517
-	}
518
-
519
-	/**
520
-	 * Get the entities related to the one with the specified id. By default only
521
-	 * published entities will be returned.
522
-	 *
523
-	 * @since 3.10.0
524
-	 *
525
-	 * @param int    $id          The post id.
526
-	 * @param string $post_status The target post status (default = publish).
527
-	 *
528
-	 * @return array An array of post ids.
529
-	 */
530
-	public function get_related_entities( $id, $post_status = 'publish' ) {
531
-
532
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
533
-	}
534
-
535
-	/**
536
-	 * Get the list of entities.
537
-	 *
538
-	 * @since 3.12.2
539
-	 *
540
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
541
-	 *
542
-	 * @return array An array of entity posts.
543
-	 */
544
-	public function get( $params = array() ) {
545
-
546
-		// Set the defaults.
547
-		$defaults = array( 'post_type' => 'entity' );
548
-
549
-		// Merge the defaults with the provided parameters.
550
-		$args = wp_parse_args( $params, $defaults );
551
-
552
-		// Call the `get_posts` function.
553
-		return get_posts( $args );
554
-	}
555
-
556
-	/**
557
-	 * The list of post type names which can be used for entities
558
-	 *
559
-	 * Criteria is that the post type is public. The list of valid post types
560
-	 * can be overridden with a filter.
561
-	 *
562
-	 * @since 3.15.0
563
-	 *
564
-	 * @return array Array containing the names of the valid post types.
565
-	 */
566
-	static function valid_entity_post_types() {
567
-
568
-		// Ignore builtins in the call to avoid getting attachments.
569
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
570
-
571
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
572
-	}
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
+        return $args + array(
445
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
446
+                'tax_query' => array(
447
+                    array(
448
+                        'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
+                        'terms'    => self::get_entity_terms(),
450
+                    ),
451
+                ),
452
+            );
453
+    }
454
+
455
+    /**
456
+     * Get the entity terms IDs which represent an entity.
457
+     *
458
+     * @since 3.15.0
459
+     *
460
+     * @return array An array of terms' ids.
461
+     */
462
+    public static function get_entity_terms() {
463
+
464
+        $terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
465
+            'hide_empty' => false,
466
+            // Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
467
+            // An issue has been opened with the AAM plugin author as well.
468
+            //
469
+            // see https://github.com/insideout10/wordlift-plugin/issues/334
470
+            // see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
471
+            'fields'     => 'all',
472
+        ) );
473
+
474
+        return array_map( function ( $term ) {
475
+            return $term->term_id;
476
+        }, array_filter( $terms, function ( $term ) {
477
+            return 'article' !== $term->slug;
478
+        } ) );
479
+    }
480
+
481
+    /**
482
+     * Create a new entity.
483
+     *
484
+     * @since 3.9.0
485
+     *
486
+     * @param string $name     The entity name.
487
+     * @param string $type_uri The entity's type URI.
488
+     * @param null   $logo     The entity logo id (or NULL if none).
489
+     * @param string $status   The post status, by default 'publish'.
490
+     *
491
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
492
+     */
493
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
494
+
495
+        // Create an entity for the publisher.
496
+        $post_id = wp_insert_post( array(
497
+            'post_type'    => self::TYPE_NAME,
498
+            'post_title'   => $name,
499
+            'post_status'  => $status,
500
+            'post_content' => '',
501
+        ) );
502
+
503
+        // Return the error if any.
504
+        if ( is_wp_error( $post_id ) ) {
505
+            return $post_id;
506
+        }
507
+
508
+        // Set the entity logo.
509
+        if ( $logo && is_numeric( $logo ) ) {
510
+            set_post_thumbnail( $post_id, $logo );
511
+        }
512
+
513
+        // Set the entity type.
514
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
515
+
516
+        return $post_id;
517
+    }
518
+
519
+    /**
520
+     * Get the entities related to the one with the specified id. By default only
521
+     * published entities will be returned.
522
+     *
523
+     * @since 3.10.0
524
+     *
525
+     * @param int    $id          The post id.
526
+     * @param string $post_status The target post status (default = publish).
527
+     *
528
+     * @return array An array of post ids.
529
+     */
530
+    public function get_related_entities( $id, $post_status = 'publish' ) {
531
+
532
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
533
+    }
534
+
535
+    /**
536
+     * Get the list of entities.
537
+     *
538
+     * @since 3.12.2
539
+     *
540
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
541
+     *
542
+     * @return array An array of entity posts.
543
+     */
544
+    public function get( $params = array() ) {
545
+
546
+        // Set the defaults.
547
+        $defaults = array( 'post_type' => 'entity' );
548
+
549
+        // Merge the defaults with the provided parameters.
550
+        $args = wp_parse_args( $params, $defaults );
551
+
552
+        // Call the `get_posts` function.
553
+        return get_posts( $args );
554
+    }
555
+
556
+    /**
557
+     * The list of post type names which can be used for entities
558
+     *
559
+     * Criteria is that the post type is public. The list of valid post types
560
+     * can be overridden with a filter.
561
+     *
562
+     * @since 3.15.0
563
+     *
564
+     * @return array Array containing the names of the valid post types.
565
+     */
566
+    static function valid_entity_post_types() {
567
+
568
+        // Ignore builtins in the call to avoid getting attachments.
569
+        $post_types = array( 'post', 'page', self::TYPE_NAME );
570
+
571
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
572
+    }
573 573
 
574 574
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 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
 		return $args + array(
445 445
 				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 */
462 462
 	public static function get_entity_terms() {
463 463
 
464
-		$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
464
+		$terms = get_terms(Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
465 465
 			'hide_empty' => false,
466 466
 			// Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
467 467
 			// An issue has been opened with the AAM plugin author as well.
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 			// see https://github.com/insideout10/wordlift-plugin/issues/334
470 470
 			// see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
471 471
 			'fields'     => 'all',
472
-		) );
472
+		));
473 473
 
474
-		return array_map( function ( $term ) {
474
+		return array_map(function($term) {
475 475
 			return $term->term_id;
476
-		}, array_filter( $terms, function ( $term ) {
476
+		}, array_filter($terms, function($term) {
477 477
 			return 'article' !== $term->slug;
478
-		} ) );
478
+		} ));
479 479
 	}
480 480
 
481 481
 	/**
@@ -490,28 +490,28 @@  discard block
 block discarded – undo
490 490
 	 *
491 491
 	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
492 492
 	 */
493
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
493
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
494 494
 
495 495
 		// Create an entity for the publisher.
496
-		$post_id = wp_insert_post( array(
496
+		$post_id = wp_insert_post(array(
497 497
 			'post_type'    => self::TYPE_NAME,
498 498
 			'post_title'   => $name,
499 499
 			'post_status'  => $status,
500 500
 			'post_content' => '',
501
-		) );
501
+		));
502 502
 
503 503
 		// Return the error if any.
504
-		if ( is_wp_error( $post_id ) ) {
504
+		if (is_wp_error($post_id)) {
505 505
 			return $post_id;
506 506
 		}
507 507
 
508 508
 		// Set the entity logo.
509
-		if ( $logo && is_numeric( $logo ) ) {
510
-			set_post_thumbnail( $post_id, $logo );
509
+		if ($logo && is_numeric($logo)) {
510
+			set_post_thumbnail($post_id, $logo);
511 511
 		}
512 512
 
513 513
 		// Set the entity type.
514
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
514
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
515 515
 
516 516
 		return $post_id;
517 517
 	}
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	 *
528 528
 	 * @return array An array of post ids.
529 529
 	 */
530
-	public function get_related_entities( $id, $post_status = 'publish' ) {
530
+	public function get_related_entities($id, $post_status = 'publish') {
531 531
 
532
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
532
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
533 533
 	}
534 534
 
535 535
 	/**
@@ -541,16 +541,16 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @return array An array of entity posts.
543 543
 	 */
544
-	public function get( $params = array() ) {
544
+	public function get($params = array()) {
545 545
 
546 546
 		// Set the defaults.
547
-		$defaults = array( 'post_type' => 'entity' );
547
+		$defaults = array('post_type' => 'entity');
548 548
 
549 549
 		// Merge the defaults with the provided parameters.
550
-		$args = wp_parse_args( $params, $defaults );
550
+		$args = wp_parse_args($params, $defaults);
551 551
 
552 552
 		// Call the `get_posts` function.
553
-		return get_posts( $args );
553
+		return get_posts($args);
554 554
 	}
555 555
 
556 556
 	/**
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 	static function valid_entity_post_types() {
567 567
 
568 568
 		// Ignore builtins in the call to avoid getting attachments.
569
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
569
+		$post_types = array('post', 'page', self::TYPE_NAME);
570 570
 
571
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
571
+		return apply_filters('wl_valid_entity_post_types', $post_types);
572 572
 	}
573 573
 
574 574
 }
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.