Completed
Pull Request — develop (#740)
by David
02:49
created
src/includes/class-wordlift.php 2 patches
Indentation   +1441 added lines, -1441 removed lines patch added patch discarded remove patch
@@ -28,1487 +28,1487 @@
 block discarded – undo
28 28
  */
29 29
 class Wordlift {
30 30
 
31
-	/**
32
-	 * The loader that's responsible for maintaining and registering all hooks that power
33
-	 * the plugin.
34
-	 *
35
-	 * @since    1.0.0
36
-	 * @access   protected
37
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
38
-	 */
39
-	protected $loader;
40
-
41
-	/**
42
-	 * The unique identifier of this plugin.
43
-	 *
44
-	 * @since    1.0.0
45
-	 * @access   protected
46
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
47
-	 */
48
-	protected $plugin_name;
49
-
50
-	/**
51
-	 * The current version of the plugin.
52
-	 *
53
-	 * @since    1.0.0
54
-	 * @access   protected
55
-	 * @var      string $version The current version of the plugin.
56
-	 */
57
-	protected $version;
58
-
59
-	/**
60
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
61
-	 *
62
-	 * @since  3.12.0
63
-	 * @access protected
64
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
65
-	 */
66
-	protected $tinymce_adapter;
67
-
68
-	/**
69
-	 * The Thumbnail service.
70
-	 *
71
-	 * @since  3.1.5
72
-	 * @access private
73
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
74
-	 */
75
-	private $thumbnail_service;
76
-
77
-	/**
78
-	 * The UI service.
79
-	 *
80
-	 * @since  3.2.0
81
-	 * @access private
82
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
83
-	 */
84
-	private $ui_service;
85
-
86
-	/**
87
-	 * The Schema service.
88
-	 *
89
-	 * @since  3.3.0
90
-	 * @access protected
91
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
92
-	 */
93
-	protected $schema_service;
94
-
95
-	/**
96
-	 * The Entity service.
97
-	 *
98
-	 * @since  3.1.0
99
-	 * @access protected
100
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
101
-	 */
102
-	protected $entity_service;
103
-
104
-	/**
105
-	 * The Topic Taxonomy service.
106
-	 *
107
-	 * @since  3.5.0
108
-	 * @access private
109
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
110
-	 */
111
-	private $topic_taxonomy_service;
112
-
113
-	/**
114
-	 * The User service.
115
-	 *
116
-	 * @since  3.1.7
117
-	 * @access protected
118
-	 * @var \Wordlift_User_Service $user_service The User service.
119
-	 */
120
-	protected $user_service;
121
-
122
-	/**
123
-	 * The Timeline service.
124
-	 *
125
-	 * @since  3.1.0
126
-	 * @access private
127
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
128
-	 */
129
-	private $timeline_service;
130
-
131
-	/**
132
-	 * The Redirect service.
133
-	 *
134
-	 * @since  3.2.0
135
-	 * @access private
136
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
137
-	 */
138
-	private $redirect_service;
139
-
140
-	/**
141
-	 * The Notice service.
142
-	 *
143
-	 * @since  3.3.0
144
-	 * @access private
145
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
146
-	 */
147
-	private $notice_service;
148
-
149
-	/**
150
-	 * The Entity list customization.
151
-	 *
152
-	 * @since  3.3.0
153
-	 * @access protected
154
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
155
-	 */
156
-	protected $entity_list_service;
157
-
158
-	/**
159
-	 * The Entity Types Taxonomy Walker.
160
-	 *
161
-	 * @since  3.1.0
162
-	 * @access private
163
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
164
-	 */
165
-	private $entity_types_taxonomy_walker;
166
-
167
-	/**
168
-	 * The ShareThis service.
169
-	 *
170
-	 * @since  3.2.0
171
-	 * @access private
172
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
173
-	 */
174
-	private $sharethis_service;
175
-
176
-	/**
177
-	 * The PrimaShop adapter.
178
-	 *
179
-	 * @since  3.2.3
180
-	 * @access private
181
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
182
-	 */
183
-	private $primashop_adapter;
184
-
185
-	/**
186
-	 * The WordLift Dashboard adapter.
187
-	 *
188
-	 * @since  3.4.0
189
-	 * @access private
190
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
191
-	 */
192
-	private $dashboard_service;
193
-
194
-	/**
195
-	 * The entity type service.
196
-	 *
197
-	 * @since  3.6.0
198
-	 * @access private
199
-	 * @var \Wordlift_Entity_Post_Type_Service
200
-	 */
201
-	private $entity_post_type_service;
202
-
203
-	/**
204
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
205
-	 *
206
-	 * @since  3.6.0
207
-	 * @access private
208
-	 * @var \Wordlift_Entity_Link_Service
209
-	 */
210
-	private $entity_link_service;
211
-
212
-	/**
213
-	 * A {@link Wordlift_Sparql_Service} instance.
214
-	 *
215
-	 * @since    3.6.0
216
-	 * @access   protected
217
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
218
-	 */
219
-	protected $sparql_service;
220
-
221
-	/**
222
-	 * A {@link Wordlift_Import_Service} instance.
223
-	 *
224
-	 * @since  3.6.0
225
-	 * @access private
226
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
227
-	 */
228
-	private $import_service;
229
-
230
-	/**
231
-	 * A {@link Wordlift_Rebuild_Service} instance.
232
-	 *
233
-	 * @since  3.6.0
234
-	 * @access private
235
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
236
-	 */
237
-	private $rebuild_service;
238
-
239
-	/**
240
-	 * A {@link Wordlift_Jsonld_Service} instance.
241
-	 *
242
-	 * @since  3.7.0
243
-	 * @access protected
244
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
245
-	 */
246
-	protected $jsonld_service;
247
-
248
-	/**
249
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
250
-	 *
251
-	 * @since  3.14.0
252
-	 * @access protected
253
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
254
-	 */
255
-	protected $jsonld_website_converter;
256
-
257
-	/**
258
-	 * A {@link Wordlift_Property_Factory} instance.
259
-	 *
260
-	 * @since  3.7.0
261
-	 * @access private
262
-	 * @var \Wordlift_Property_Factory $property_factory
263
-	 */
264
-	private $property_factory;
265
-
266
-	/**
267
-	 * The 'Download Your Data' page.
268
-	 *
269
-	 * @since  3.6.0
270
-	 * @access private
271
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
-	 */
273
-	private $download_your_data_page;
274
-
275
-	/**
276
-	 * The 'WordLift Settings' page.
277
-	 *
278
-	 * @since  3.11.0
279
-	 * @access protected
280
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
-	 */
282
-	protected $settings_page;
283
-
284
-	/**
285
-	 * The 'WordLift Batch analysis' page.
286
-	 *
287
-	 * @since  3.14.0
288
-	 * @access protected
289
-	 * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
-	 */
291
-	protected $batch_analysis_page;
292
-
293
-	/**
294
-	 * The install wizard page.
295
-	 *
296
-	 * @since  3.9.0
297
-	 * @access private
298
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
-	 */
300
-	private $admin_setup;
301
-
302
-	/**
303
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
304
-	 * linking of entities to their pages.
305
-	 *
306
-	 * @since  3.8.0
307
-	 * @access private
308
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
-	 */
310
-	private $content_filter_service;
311
-
312
-	/**
313
-	 * A {@link Wordlift_Key_Validation_Service} instance.
314
-	 *
315
-	 * @since  3.9.0
316
-	 * @access private
317
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
-	 */
319
-	private $key_validation_service;
320
-
321
-	/**
322
-	 * A {@link Wordlift_Rating_Service} instance.
323
-	 *
324
-	 * @since  3.10.0
325
-	 * @access private
326
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
-	 */
328
-	private $rating_service;
329
-
330
-	/**
331
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
-	 *
333
-	 * @since  3.10.0
334
-	 * @access protected
335
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
-	 */
337
-	protected $post_to_jsonld_converter;
338
-
339
-	/**
340
-	 * A {@link Wordlift_Configuration_Service} instance.
341
-	 *
342
-	 * @since  3.10.0
343
-	 * @access protected
344
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
-	 */
346
-	protected $configuration_service;
347
-
348
-	/**
349
-	 * A {@link Wordlift_Entity_Type_Service} instance.
350
-	 *
351
-	 * @since  3.10.0
352
-	 * @access protected
353
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
-	 */
355
-	protected $entity_type_service;
356
-
357
-	/**
358
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
-	 *
360
-	 * @since  3.10.0
361
-	 * @access protected
362
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
-	 */
364
-	protected $entity_post_to_jsonld_converter;
365
-
366
-	/**
367
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
-	 *
369
-	 * @since  3.10.0
370
-	 * @access protected
371
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
-	 */
373
-	protected $postid_to_jsonld_converter;
374
-
375
-	/**
376
-	 * The {@link Wordlift_Admin_Status_Page} class.
377
-	 *
378
-	 * @since  3.9.8
379
-	 * @access private
380
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
-	 */
382
-	private $status_page;
383
-
384
-	/**
385
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
-	 *
387
-	 * @since  3.11.0
388
-	 * @access protected
389
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
-	 */
391
-	protected $category_taxonomy_service;
392
-
393
-	/**
394
-	 * The {@link Wordlift_Entity_Page_Service} instance.
395
-	 *
396
-	 * @since  3.11.0
397
-	 * @access protected
398
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
-	 */
400
-	protected $entity_page_service;
401
-
402
-	/**
403
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
-	 *
405
-	 * @since  3.11.0
406
-	 * @access protected
407
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
-	 */
409
-	protected $settings_page_action_link;
410
-
411
-	/**
412
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
-	 *
414
-	 * @since  3.11.0
415
-	 * @access protected
416
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
-	 */
418
-	protected $publisher_ajax_adapter;
419
-
420
-	/**
421
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
422
-	 *
423
-	 * @since  3.11.0
424
-	 * @access protected
425
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
-	 */
427
-	protected $input_element;
428
-
429
-	/**
430
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
-	 *
432
-	 * @since  3.13.0
433
-	 * @access protected
434
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
-	 */
436
-	protected $radio_input_element;
437
-
438
-	/**
439
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
-	 *
441
-	 * @since  3.11.0
442
-	 * @access protected
443
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
-	 */
445
-	protected $language_select_element;
446
-
447
-	/**
448
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
-	 *
450
-	 * @since  3.11.0
451
-	 * @access protected
452
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
-	 */
454
-	protected $publisher_element;
455
-
456
-	/**
457
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
-	 *
459
-	 * @since  3.11.0
460
-	 * @access protected
461
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
-	 */
463
-	protected $select2_element;
464
-
465
-	/**
466
-	 * The controller for the entity type list admin page
467
-	 *
468
-	 * @since  3.11.0
469
-	 * @access private
470
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
-	 */
472
-	private $entity_type_admin_page;
473
-
474
-	/**
475
-	 * The controller for the entity type settings admin page
476
-	 *
477
-	 * @since  3.11.0
478
-	 * @access private
479
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
-	 */
481
-	private $entity_type_settings_admin_page;
482
-
483
-	/**
484
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
-	 *
486
-	 * @since  3.11.0
487
-	 * @access protected
488
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
-	 */
490
-	protected $related_entities_cloud_widget;
491
-
492
-	/**
493
-	 * The {@link Wordlift_Admin_Author_Element} instance.
494
-	 *
495
-	 * @since  3.14.0
496
-	 * @access protected
497
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
-	 */
499
-	protected $author_element;
500
-
501
-	/**
502
-	 * The {@link Wordlift_Batch_Analysis_Service} instance.
503
-	 *
504
-	 * @since  3.14.0
505
-	 * @access protected
506
-	 * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
-	 */
508
-	protected $batch_analysis_service;
509
-
510
-	/**
511
-	 * The {@link Wordlift_Sample_Data_Service} instance.
512
-	 *
513
-	 * @since  3.12.0
514
-	 * @access protected
515
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
-	 */
517
-	protected $sample_data_service;
518
-
519
-	/**
520
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
-	 *
522
-	 * @since  3.12.0
523
-	 * @access protected
524
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
-	 */
526
-	protected $sample_data_ajax_adapter;
527
-
528
-	/**
529
-	 * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
-	 *
531
-	 * @since  3.14.2
532
-	 * @access protected
533
-	 * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
-	 */
535
-	private $batch_analysis_adapter;
536
-
537
-	/**
538
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
-	 *
540
-	 * @since  3.14.3
541
-	 * @access private
542
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
-	 */
544
-	private $relation_rebuild_service;
545
-
546
-	/**
547
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
-	 *
549
-	 * @since  3.14.3
550
-	 * @access private
551
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
-	 */
553
-	private $relation_rebuild_adapter;
554
-
555
-	/**
556
-	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
557
-	 *
558
-	 * @since  3.16.0
559
-	 * @access protected
560
-	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
561
-	 */
562
-	protected $google_analytics_export_service;
563
-
564
-	/**
565
-	 * {@link Wordlift}'s singleton instance.
566
-	 *
567
-	 * @since  3.15.0
568
-	 * @access protected
569
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
570
-	 */
571
-	protected $entity_type_adapter;
572
-
573
-	/**
574
-	 * The {@link Wordlift_Linked_Data_Service} instance.
575
-	 *
576
-	 * @since  3.15.0
577
-	 * @access protected
578
-	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
579
-	 */
580
-	protected $linked_data_service;
581
-
582
-	/**
583
-	 * The {@link Wordlift_Storage_Factory} instance.
584
-	 *
585
-	 * @since  3.15.0
586
-	 * @access protected
587
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
588
-	 */
589
-	protected $storage_factory;
590
-
591
-	/**
592
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
593
-	 *
594
-	 * @since  3.15.0
595
-	 * @access protected
596
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
597
-	 */
598
-	protected $rendition_factory;
599
-
600
-	/**
601
-	 * The {@link Wordlift_Autocomplete_Service} instance.
602
-	 *
603
-	 * @since  3.15.0
604
-	 * @access private
605
-	 * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
606
-	 */
607
-	private $autocomplete_service;
608
-
609
-	/**
610
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
611
-	 *
612
-	 * @since  3.15.0
613
-	 * @access private
614
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
615
-	 */
616
-	private $autocomplete_adapter;
617
-
618
-	/**
619
-	 * The {@link Wordlift_Relation_Service} instance.
620
-	 *
621
-	 * @since  3.15.0
622
-	 * @access protected
623
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
624
-	 */
625
-	protected $relation_service;
626
-
627
-	/**
628
-	 * The {@link Wordlift_Cached_Post_Converter} instance.
629
-	 *
630
-	 * @since  3.16.0
631
-	 * @access protected
632
-	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
633
-	 *
634
-	 */
635
-	protected $cached_postid_to_jsonld_converter;
636
-
637
-	/**
638
-	 * The {@link Wordlift_File_Cache_Service} instance.
639
-	 *
640
-	 * @since  3.16.0
641
-	 * @access protected
642
-	 * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance.
643
-	 */
644
-	protected $file_cache_service;
645
-
646
-	/**
647
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
648
-	 *
649
-	 * @since  3.16.3
650
-	 * @access protected
651
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
652
-	 */
653
-	protected $entity_uri_service;
654
-
655
-	/**
656
-	 * {@link Wordlift}'s singleton instance.
657
-	 *
658
-	 * @since  3.11.2
659
-	 * @access private
660
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
661
-	 */
662
-	private static $instance;
663
-
664
-	/**
665
-	 * Define the core functionality of the plugin.
666
-	 *
667
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
668
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
669
-	 * the public-facing side of the site.
670
-	 *
671
-	 * @since    1.0.0
672
-	 */
673
-	public function __construct() {
674
-
675
-		$this->plugin_name = 'wordlift';
676
-		$this->version     = '3.17.0-dev';
677
-		$this->load_dependencies();
678
-		$this->set_locale();
679
-		$this->define_admin_hooks();
680
-		$this->define_public_hooks();
681
-
682
-		self::$instance = $this;
683
-
684
-	}
685
-
686
-	/**
687
-	 * Get the singleton instance.
688
-	 *
689
-	 * @since 3.11.2
690
-	 *
691
-	 * @return Wordlift The {@link Wordlift} singleton instance.
692
-	 */
693
-	public static function get_instance() {
694
-
695
-		return self::$instance;
696
-	}
697
-
698
-	/**
699
-	 * Load the required dependencies for this plugin.
700
-	 *
701
-	 * Include the following files that make up the plugin:
702
-	 *
703
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
704
-	 * - Wordlift_i18n. Defines internationalization functionality.
705
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
706
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
707
-	 *
708
-	 * Create an instance of the loader which will be used to register the hooks
709
-	 * with WordPress.
710
-	 *
711
-	 * @since    1.0.0
712
-	 * @access   private
713
-	 */
714
-	private function load_dependencies() {
715
-
716
-		/**
717
-		 * The class responsible for orchestrating the actions and filters of the
718
-		 * core plugin.
719
-		 */
720
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
721
-
722
-		/**
723
-		 * The class responsible for defining internationalization functionality
724
-		 * of the plugin.
725
-		 */
726
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
727
-
728
-		/**
729
-		 * WordLift's supported languages.
730
-		 */
731
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
732
-
733
-		/**
734
-		 * Provide support functions to sanitize data.
735
-		 */
736
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
737
-
738
-		/** Services. */
739
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
748
-
749
-		/**
750
-		 * The Query builder.
751
-		 */
752
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
753
-
754
-		/**
755
-		 * The Schema service.
756
-		 */
757
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
758
-
759
-		/**
760
-		 * The schema:url property service.
761
-		 */
762
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
764
-
765
-		/**
766
-		 * The UI service.
767
-		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
769
-
770
-		/**
771
-		 * The Thumbnail service.
772
-		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
774
-
775
-		/**
776
-		 * The Entity Types Taxonomy service.
777
-		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
779
-
780
-		/**
781
-		 * The Entity service.
782
-		 */
783
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
785
-
786
-		// Add the entity rating service.
787
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
788
-
789
-		/**
790
-		 * The User service.
791
-		 */
792
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
793
-
794
-		/**
795
-		 * The Timeline service.
796
-		 */
797
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
798
-
799
-		/**
800
-		 * The Topic Taxonomy service.
801
-		 */
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
803
-
804
-		/**
805
-		 * The SPARQL service.
806
-		 */
807
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
808
-
809
-		/**
810
-		 * The WordLift import service.
811
-		 */
812
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
813
-
814
-		/**
815
-		 * The WordLift URI service.
816
-		 */
817
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
818
-
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
820
-
821
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
822
-
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
824
-
825
-		/**
826
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827
-		 */
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
829
-
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
831
-
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
833
-
834
-		/**
835
-		 * Load the converters.
836
-		 */
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
843
-
844
-		/**
845
-		 * Load cache-related files.
846
-		 */
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
848
-
849
-		/**
850
-		 * Load the content filter.
851
-		 */
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
853
-
854
-		/*
31
+    /**
32
+     * The loader that's responsible for maintaining and registering all hooks that power
33
+     * the plugin.
34
+     *
35
+     * @since    1.0.0
36
+     * @access   protected
37
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
38
+     */
39
+    protected $loader;
40
+
41
+    /**
42
+     * The unique identifier of this plugin.
43
+     *
44
+     * @since    1.0.0
45
+     * @access   protected
46
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
47
+     */
48
+    protected $plugin_name;
49
+
50
+    /**
51
+     * The current version of the plugin.
52
+     *
53
+     * @since    1.0.0
54
+     * @access   protected
55
+     * @var      string $version The current version of the plugin.
56
+     */
57
+    protected $version;
58
+
59
+    /**
60
+     * The {@link Wordlift_Tinymce_Adapter} instance.
61
+     *
62
+     * @since  3.12.0
63
+     * @access protected
64
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
65
+     */
66
+    protected $tinymce_adapter;
67
+
68
+    /**
69
+     * The Thumbnail service.
70
+     *
71
+     * @since  3.1.5
72
+     * @access private
73
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
74
+     */
75
+    private $thumbnail_service;
76
+
77
+    /**
78
+     * The UI service.
79
+     *
80
+     * @since  3.2.0
81
+     * @access private
82
+     * @var \Wordlift_UI_Service $ui_service The UI service.
83
+     */
84
+    private $ui_service;
85
+
86
+    /**
87
+     * The Schema service.
88
+     *
89
+     * @since  3.3.0
90
+     * @access protected
91
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
92
+     */
93
+    protected $schema_service;
94
+
95
+    /**
96
+     * The Entity service.
97
+     *
98
+     * @since  3.1.0
99
+     * @access protected
100
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
101
+     */
102
+    protected $entity_service;
103
+
104
+    /**
105
+     * The Topic Taxonomy service.
106
+     *
107
+     * @since  3.5.0
108
+     * @access private
109
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
110
+     */
111
+    private $topic_taxonomy_service;
112
+
113
+    /**
114
+     * The User service.
115
+     *
116
+     * @since  3.1.7
117
+     * @access protected
118
+     * @var \Wordlift_User_Service $user_service The User service.
119
+     */
120
+    protected $user_service;
121
+
122
+    /**
123
+     * The Timeline service.
124
+     *
125
+     * @since  3.1.0
126
+     * @access private
127
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
128
+     */
129
+    private $timeline_service;
130
+
131
+    /**
132
+     * The Redirect service.
133
+     *
134
+     * @since  3.2.0
135
+     * @access private
136
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
137
+     */
138
+    private $redirect_service;
139
+
140
+    /**
141
+     * The Notice service.
142
+     *
143
+     * @since  3.3.0
144
+     * @access private
145
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
146
+     */
147
+    private $notice_service;
148
+
149
+    /**
150
+     * The Entity list customization.
151
+     *
152
+     * @since  3.3.0
153
+     * @access protected
154
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
155
+     */
156
+    protected $entity_list_service;
157
+
158
+    /**
159
+     * The Entity Types Taxonomy Walker.
160
+     *
161
+     * @since  3.1.0
162
+     * @access private
163
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
164
+     */
165
+    private $entity_types_taxonomy_walker;
166
+
167
+    /**
168
+     * The ShareThis service.
169
+     *
170
+     * @since  3.2.0
171
+     * @access private
172
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
173
+     */
174
+    private $sharethis_service;
175
+
176
+    /**
177
+     * The PrimaShop adapter.
178
+     *
179
+     * @since  3.2.3
180
+     * @access private
181
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
182
+     */
183
+    private $primashop_adapter;
184
+
185
+    /**
186
+     * The WordLift Dashboard adapter.
187
+     *
188
+     * @since  3.4.0
189
+     * @access private
190
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
191
+     */
192
+    private $dashboard_service;
193
+
194
+    /**
195
+     * The entity type service.
196
+     *
197
+     * @since  3.6.0
198
+     * @access private
199
+     * @var \Wordlift_Entity_Post_Type_Service
200
+     */
201
+    private $entity_post_type_service;
202
+
203
+    /**
204
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
205
+     *
206
+     * @since  3.6.0
207
+     * @access private
208
+     * @var \Wordlift_Entity_Link_Service
209
+     */
210
+    private $entity_link_service;
211
+
212
+    /**
213
+     * A {@link Wordlift_Sparql_Service} instance.
214
+     *
215
+     * @since    3.6.0
216
+     * @access   protected
217
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
218
+     */
219
+    protected $sparql_service;
220
+
221
+    /**
222
+     * A {@link Wordlift_Import_Service} instance.
223
+     *
224
+     * @since  3.6.0
225
+     * @access private
226
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
227
+     */
228
+    private $import_service;
229
+
230
+    /**
231
+     * A {@link Wordlift_Rebuild_Service} instance.
232
+     *
233
+     * @since  3.6.0
234
+     * @access private
235
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
236
+     */
237
+    private $rebuild_service;
238
+
239
+    /**
240
+     * A {@link Wordlift_Jsonld_Service} instance.
241
+     *
242
+     * @since  3.7.0
243
+     * @access protected
244
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
245
+     */
246
+    protected $jsonld_service;
247
+
248
+    /**
249
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
250
+     *
251
+     * @since  3.14.0
252
+     * @access protected
253
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
254
+     */
255
+    protected $jsonld_website_converter;
256
+
257
+    /**
258
+     * A {@link Wordlift_Property_Factory} instance.
259
+     *
260
+     * @since  3.7.0
261
+     * @access private
262
+     * @var \Wordlift_Property_Factory $property_factory
263
+     */
264
+    private $property_factory;
265
+
266
+    /**
267
+     * The 'Download Your Data' page.
268
+     *
269
+     * @since  3.6.0
270
+     * @access private
271
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
+     */
273
+    private $download_your_data_page;
274
+
275
+    /**
276
+     * The 'WordLift Settings' page.
277
+     *
278
+     * @since  3.11.0
279
+     * @access protected
280
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
+     */
282
+    protected $settings_page;
283
+
284
+    /**
285
+     * The 'WordLift Batch analysis' page.
286
+     *
287
+     * @since  3.14.0
288
+     * @access protected
289
+     * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
+     */
291
+    protected $batch_analysis_page;
292
+
293
+    /**
294
+     * The install wizard page.
295
+     *
296
+     * @since  3.9.0
297
+     * @access private
298
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
+     */
300
+    private $admin_setup;
301
+
302
+    /**
303
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
304
+     * linking of entities to their pages.
305
+     *
306
+     * @since  3.8.0
307
+     * @access private
308
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
+     */
310
+    private $content_filter_service;
311
+
312
+    /**
313
+     * A {@link Wordlift_Key_Validation_Service} instance.
314
+     *
315
+     * @since  3.9.0
316
+     * @access private
317
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
+     */
319
+    private $key_validation_service;
320
+
321
+    /**
322
+     * A {@link Wordlift_Rating_Service} instance.
323
+     *
324
+     * @since  3.10.0
325
+     * @access private
326
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
+     */
328
+    private $rating_service;
329
+
330
+    /**
331
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
+     *
333
+     * @since  3.10.0
334
+     * @access protected
335
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
+     */
337
+    protected $post_to_jsonld_converter;
338
+
339
+    /**
340
+     * A {@link Wordlift_Configuration_Service} instance.
341
+     *
342
+     * @since  3.10.0
343
+     * @access protected
344
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
+     */
346
+    protected $configuration_service;
347
+
348
+    /**
349
+     * A {@link Wordlift_Entity_Type_Service} instance.
350
+     *
351
+     * @since  3.10.0
352
+     * @access protected
353
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
+     */
355
+    protected $entity_type_service;
356
+
357
+    /**
358
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
+     *
360
+     * @since  3.10.0
361
+     * @access protected
362
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
+     */
364
+    protected $entity_post_to_jsonld_converter;
365
+
366
+    /**
367
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
+     *
369
+     * @since  3.10.0
370
+     * @access protected
371
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
+     */
373
+    protected $postid_to_jsonld_converter;
374
+
375
+    /**
376
+     * The {@link Wordlift_Admin_Status_Page} class.
377
+     *
378
+     * @since  3.9.8
379
+     * @access private
380
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
+     */
382
+    private $status_page;
383
+
384
+    /**
385
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
+     *
387
+     * @since  3.11.0
388
+     * @access protected
389
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
+     */
391
+    protected $category_taxonomy_service;
392
+
393
+    /**
394
+     * The {@link Wordlift_Entity_Page_Service} instance.
395
+     *
396
+     * @since  3.11.0
397
+     * @access protected
398
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
+     */
400
+    protected $entity_page_service;
401
+
402
+    /**
403
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
+     *
405
+     * @since  3.11.0
406
+     * @access protected
407
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
+     */
409
+    protected $settings_page_action_link;
410
+
411
+    /**
412
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
+     *
414
+     * @since  3.11.0
415
+     * @access protected
416
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
+     */
418
+    protected $publisher_ajax_adapter;
419
+
420
+    /**
421
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
422
+     *
423
+     * @since  3.11.0
424
+     * @access protected
425
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
+     */
427
+    protected $input_element;
428
+
429
+    /**
430
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
+     *
432
+     * @since  3.13.0
433
+     * @access protected
434
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
+     */
436
+    protected $radio_input_element;
437
+
438
+    /**
439
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
+     *
441
+     * @since  3.11.0
442
+     * @access protected
443
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
+     */
445
+    protected $language_select_element;
446
+
447
+    /**
448
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
+     *
450
+     * @since  3.11.0
451
+     * @access protected
452
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
+     */
454
+    protected $publisher_element;
455
+
456
+    /**
457
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
+     *
459
+     * @since  3.11.0
460
+     * @access protected
461
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
+     */
463
+    protected $select2_element;
464
+
465
+    /**
466
+     * The controller for the entity type list admin page
467
+     *
468
+     * @since  3.11.0
469
+     * @access private
470
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
+     */
472
+    private $entity_type_admin_page;
473
+
474
+    /**
475
+     * The controller for the entity type settings admin page
476
+     *
477
+     * @since  3.11.0
478
+     * @access private
479
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
+     */
481
+    private $entity_type_settings_admin_page;
482
+
483
+    /**
484
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
+     *
486
+     * @since  3.11.0
487
+     * @access protected
488
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
+     */
490
+    protected $related_entities_cloud_widget;
491
+
492
+    /**
493
+     * The {@link Wordlift_Admin_Author_Element} instance.
494
+     *
495
+     * @since  3.14.0
496
+     * @access protected
497
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
+     */
499
+    protected $author_element;
500
+
501
+    /**
502
+     * The {@link Wordlift_Batch_Analysis_Service} instance.
503
+     *
504
+     * @since  3.14.0
505
+     * @access protected
506
+     * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
+     */
508
+    protected $batch_analysis_service;
509
+
510
+    /**
511
+     * The {@link Wordlift_Sample_Data_Service} instance.
512
+     *
513
+     * @since  3.12.0
514
+     * @access protected
515
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
+     */
517
+    protected $sample_data_service;
518
+
519
+    /**
520
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
+     *
522
+     * @since  3.12.0
523
+     * @access protected
524
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
+     */
526
+    protected $sample_data_ajax_adapter;
527
+
528
+    /**
529
+     * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
+     *
531
+     * @since  3.14.2
532
+     * @access protected
533
+     * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
+     */
535
+    private $batch_analysis_adapter;
536
+
537
+    /**
538
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
+     *
540
+     * @since  3.14.3
541
+     * @access private
542
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
+     */
544
+    private $relation_rebuild_service;
545
+
546
+    /**
547
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
+     *
549
+     * @since  3.14.3
550
+     * @access private
551
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
+     */
553
+    private $relation_rebuild_adapter;
554
+
555
+    /**
556
+     * The {@link Wordlift_Google_Analytics_Export_Service} instance.
557
+     *
558
+     * @since  3.16.0
559
+     * @access protected
560
+     * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
561
+     */
562
+    protected $google_analytics_export_service;
563
+
564
+    /**
565
+     * {@link Wordlift}'s singleton instance.
566
+     *
567
+     * @since  3.15.0
568
+     * @access protected
569
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
570
+     */
571
+    protected $entity_type_adapter;
572
+
573
+    /**
574
+     * The {@link Wordlift_Linked_Data_Service} instance.
575
+     *
576
+     * @since  3.15.0
577
+     * @access protected
578
+     * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
579
+     */
580
+    protected $linked_data_service;
581
+
582
+    /**
583
+     * The {@link Wordlift_Storage_Factory} instance.
584
+     *
585
+     * @since  3.15.0
586
+     * @access protected
587
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
588
+     */
589
+    protected $storage_factory;
590
+
591
+    /**
592
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
593
+     *
594
+     * @since  3.15.0
595
+     * @access protected
596
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
597
+     */
598
+    protected $rendition_factory;
599
+
600
+    /**
601
+     * The {@link Wordlift_Autocomplete_Service} instance.
602
+     *
603
+     * @since  3.15.0
604
+     * @access private
605
+     * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
606
+     */
607
+    private $autocomplete_service;
608
+
609
+    /**
610
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
611
+     *
612
+     * @since  3.15.0
613
+     * @access private
614
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
615
+     */
616
+    private $autocomplete_adapter;
617
+
618
+    /**
619
+     * The {@link Wordlift_Relation_Service} instance.
620
+     *
621
+     * @since  3.15.0
622
+     * @access protected
623
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
624
+     */
625
+    protected $relation_service;
626
+
627
+    /**
628
+     * The {@link Wordlift_Cached_Post_Converter} instance.
629
+     *
630
+     * @since  3.16.0
631
+     * @access protected
632
+     * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
633
+     *
634
+     */
635
+    protected $cached_postid_to_jsonld_converter;
636
+
637
+    /**
638
+     * The {@link Wordlift_File_Cache_Service} instance.
639
+     *
640
+     * @since  3.16.0
641
+     * @access protected
642
+     * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance.
643
+     */
644
+    protected $file_cache_service;
645
+
646
+    /**
647
+     * The {@link Wordlift_Entity_Uri_Service} instance.
648
+     *
649
+     * @since  3.16.3
650
+     * @access protected
651
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
652
+     */
653
+    protected $entity_uri_service;
654
+
655
+    /**
656
+     * {@link Wordlift}'s singleton instance.
657
+     *
658
+     * @since  3.11.2
659
+     * @access private
660
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
661
+     */
662
+    private static $instance;
663
+
664
+    /**
665
+     * Define the core functionality of the plugin.
666
+     *
667
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
668
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
669
+     * the public-facing side of the site.
670
+     *
671
+     * @since    1.0.0
672
+     */
673
+    public function __construct() {
674
+
675
+        $this->plugin_name = 'wordlift';
676
+        $this->version     = '3.17.0-dev';
677
+        $this->load_dependencies();
678
+        $this->set_locale();
679
+        $this->define_admin_hooks();
680
+        $this->define_public_hooks();
681
+
682
+        self::$instance = $this;
683
+
684
+    }
685
+
686
+    /**
687
+     * Get the singleton instance.
688
+     *
689
+     * @since 3.11.2
690
+     *
691
+     * @return Wordlift The {@link Wordlift} singleton instance.
692
+     */
693
+    public static function get_instance() {
694
+
695
+        return self::$instance;
696
+    }
697
+
698
+    /**
699
+     * Load the required dependencies for this plugin.
700
+     *
701
+     * Include the following files that make up the plugin:
702
+     *
703
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
704
+     * - Wordlift_i18n. Defines internationalization functionality.
705
+     * - Wordlift_Admin. Defines all hooks for the admin area.
706
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
707
+     *
708
+     * Create an instance of the loader which will be used to register the hooks
709
+     * with WordPress.
710
+     *
711
+     * @since    1.0.0
712
+     * @access   private
713
+     */
714
+    private function load_dependencies() {
715
+
716
+        /**
717
+         * The class responsible for orchestrating the actions and filters of the
718
+         * core plugin.
719
+         */
720
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
721
+
722
+        /**
723
+         * The class responsible for defining internationalization functionality
724
+         * of the plugin.
725
+         */
726
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
727
+
728
+        /**
729
+         * WordLift's supported languages.
730
+         */
731
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
732
+
733
+        /**
734
+         * Provide support functions to sanitize data.
735
+         */
736
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
737
+
738
+        /** Services. */
739
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
748
+
749
+        /**
750
+         * The Query builder.
751
+         */
752
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
753
+
754
+        /**
755
+         * The Schema service.
756
+         */
757
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
758
+
759
+        /**
760
+         * The schema:url property service.
761
+         */
762
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
764
+
765
+        /**
766
+         * The UI service.
767
+         */
768
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
769
+
770
+        /**
771
+         * The Thumbnail service.
772
+         */
773
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
774
+
775
+        /**
776
+         * The Entity Types Taxonomy service.
777
+         */
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
779
+
780
+        /**
781
+         * The Entity service.
782
+         */
783
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
785
+
786
+        // Add the entity rating service.
787
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
788
+
789
+        /**
790
+         * The User service.
791
+         */
792
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
793
+
794
+        /**
795
+         * The Timeline service.
796
+         */
797
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
798
+
799
+        /**
800
+         * The Topic Taxonomy service.
801
+         */
802
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
803
+
804
+        /**
805
+         * The SPARQL service.
806
+         */
807
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
808
+
809
+        /**
810
+         * The WordLift import service.
811
+         */
812
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
813
+
814
+        /**
815
+         * The WordLift URI service.
816
+         */
817
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
818
+
819
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
820
+
821
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
822
+
823
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
824
+
825
+        /**
826
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827
+         */
828
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
829
+
830
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
831
+
832
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
833
+
834
+        /**
835
+         * Load the converters.
836
+         */
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
843
+
844
+        /**
845
+         * Load cache-related files.
846
+         */
847
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
848
+
849
+        /**
850
+         * Load the content filter.
851
+         */
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
853
+
854
+        /*
855 855
 		 * Load the excerpt helper.
856 856
 		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
858
-
859
-		/**
860
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
861
-		 *
862
-		 * @since 3.8.0
863
-		 */
864
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
865
-
866
-		// The Publisher Service and the AJAX adapter.
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
869
-
870
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
871
-
872
-		/**
873
-		 * Load the WordLift key validation service.
874
-		 */
875
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
876
-
877
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
879
-
880
-		// Load the `Wordlift_Entity_Page_Service` class definition.
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/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 entity glossary shortcode.
1031
-		 */
1032
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1033
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1034
-
1035
-		/**
1036
-		 * The ShareThis service.
1037
-		 */
1038
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1039
-
1040
-		/**
1041
-		 * The SEO service.
1042
-		 */
1043
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1044
-
1045
-		/**
1046
-		 * The AMP service.
1047
-		 */
1048
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1049
-
1050
-		/** Widgets */
1051
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1053
-
1054
-		$this->loader = new Wordlift_Loader();
1055
-
1056
-		// Instantiate a global logger.
1057
-		global $wl_logger;
1058
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1059
-
1060
-		// Load the `wl-api` end-point.
1061
-		new Wordlift_Http_Api();
1062
-
1063
-		/** Services. */
1064
-		// Create the configuration service.
1065
-		$this->configuration_service = new Wordlift_Configuration_Service();
1066
-
1067
-		// Create an entity type service instance. It'll be later bound to the init action.
1068
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1069
-
1070
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1071
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1072
-
1073
-		// Create an instance of the UI service.
1074
-		$this->ui_service = new Wordlift_UI_Service();
1075
-
1076
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1077
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1078
-
1079
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1080
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1081
-		$this->notice_service        = new Wordlift_Notice_Service();
1082
-		$this->relation_service      = new Wordlift_Relation_Service();
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
858
+
859
+        /**
860
+         * Load the JSON-LD service to publish entities using JSON-LD.s
861
+         *
862
+         * @since 3.8.0
863
+         */
864
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
865
+
866
+        // The Publisher Service and the AJAX adapter.
867
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
869
+
870
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
871
+
872
+        /**
873
+         * Load the WordLift key validation service.
874
+         */
875
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
876
+
877
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
879
+
880
+        // Load the `Wordlift_Entity_Page_Service` class definition.
881
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/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 entity glossary shortcode.
1031
+         */
1032
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1033
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1034
+
1035
+        /**
1036
+         * The ShareThis service.
1037
+         */
1038
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1039
+
1040
+        /**
1041
+         * The SEO service.
1042
+         */
1043
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1044
+
1045
+        /**
1046
+         * The AMP service.
1047
+         */
1048
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1049
+
1050
+        /** Widgets */
1051
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1052
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1053
+
1054
+        $this->loader = new Wordlift_Loader();
1055
+
1056
+        // Instantiate a global logger.
1057
+        global $wl_logger;
1058
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1059
+
1060
+        // Load the `wl-api` end-point.
1061
+        new Wordlift_Http_Api();
1062
+
1063
+        /** Services. */
1064
+        // Create the configuration service.
1065
+        $this->configuration_service = new Wordlift_Configuration_Service();
1066
+
1067
+        // Create an entity type service instance. It'll be later bound to the init action.
1068
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1069
+
1070
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1071
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1072
+
1073
+        // Create an instance of the UI service.
1074
+        $this->ui_service = new Wordlift_UI_Service();
1075
+
1076
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1077
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1078
+
1079
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1080
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1081
+        $this->notice_service        = new Wordlift_Notice_Service();
1082
+        $this->relation_service      = new Wordlift_Relation_Service();
1083 1083
 
1084
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1085
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1086
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1087
-		$this->user_service       = new Wordlift_User_Service();
1084
+        $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1085
+        $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1086
+        $this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1087
+        $this->user_service       = new Wordlift_User_Service();
1088 1088
 
1089
-		// Instantiate the JSON-LD service.
1090
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1089
+        // Instantiate the JSON-LD service.
1090
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1091 1091
 
1092
-		/** Linked Data. */
1093
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1094
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1092
+        /** Linked Data. */
1093
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1094
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1095 1095
 
1096
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1096
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1097 1097
 
1098
-		// Create a new instance of the Redirect service.
1099
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1100
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1101
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1098
+        // Create a new instance of the Redirect service.
1099
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1100
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1101
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1102 1102
 
1103
-		// Create a new instance of the Timeline service and Timeline shortcode.
1104
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1103
+        // Create a new instance of the Timeline service and Timeline shortcode.
1104
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1105 1105
 
1106
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1106
+        $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1107 1107
 
1108
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1108
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1109 1109
 
1110
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1110
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1111 1111
 
1112
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1113
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1112
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1113
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1114 1114
 
1115
-		// Create an instance of the PrimaShop adapter.
1116
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1115
+        // Create an instance of the PrimaShop adapter.
1116
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1117 1117
 
1118
-		// Create an import service instance to hook later to WP's import function.
1119
-		$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() );
1118
+        // Create an import service instance to hook later to WP's import function.
1119
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1120 1120
 
1121
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1121
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1122 1122
 
1123
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1124
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1123
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1124
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1125 1125
 
1126
-		// Create the entity rating service.
1127
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1126
+        // Create the entity rating service.
1127
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1128 1128
 
1129
-		// Create entity list customization (wp-admin/edit.php).
1130
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1129
+        // Create entity list customization (wp-admin/edit.php).
1130
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1131 1131
 
1132
-		// Create a new instance of the Redirect service.
1133
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1132
+        // Create a new instance of the Redirect service.
1133
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1134 1134
 
1135
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1136
-		$publisher_service      = new Wordlift_Publisher_Service();
1137
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1138
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1135
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1136
+        $publisher_service      = new Wordlift_Publisher_Service();
1137
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1138
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1139 1139
 
1140
-		$attachment_service = new Wordlift_Attachment_Service();
1140
+        $attachment_service = new Wordlift_Attachment_Service();
1141 1141
 
1142
-		// Instantiate the JSON-LD service.
1143
-		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1144
-		$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 );
1145
-		$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 );
1146
-		$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 );
1147
-		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1148
-		$this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1149
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1150
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1142
+        // Instantiate the JSON-LD service.
1143
+        $property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1144
+        $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 );
1145
+        $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 );
1146
+        $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 );
1147
+        $this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1148
+        $this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1149
+        $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1150
+        $this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1151 1151
 
1152 1152
 
1153
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1154
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1155
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1156
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1157
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1153
+        $this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1154
+        $this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1155
+        $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1156
+        $this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1157
+        $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1158 1158
 
1159
-		// Initialize the shortcodes.
1160
-		new Wordlift_Navigator_Shortcode();
1161
-		new Wordlift_Chord_Shortcode();
1162
-		new Wordlift_Geomap_Shortcode();
1163
-		new Wordlift_Timeline_Shortcode();
1164
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1165
-		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1159
+        // Initialize the shortcodes.
1160
+        new Wordlift_Navigator_Shortcode();
1161
+        new Wordlift_Chord_Shortcode();
1162
+        new Wordlift_Geomap_Shortcode();
1163
+        new Wordlift_Timeline_Shortcode();
1164
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1165
+        new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1166 1166
 
1167
-		// Initialize the SEO service.
1168
-		new Wordlift_Seo_Service();
1167
+        // Initialize the SEO service.
1168
+        new Wordlift_Seo_Service();
1169 1169
 
1170
-		// Initialize the AMP service.
1171
-		new Wordlift_AMP_Service();
1170
+        // Initialize the AMP service.
1171
+        new Wordlift_AMP_Service();
1172 1172
 
1173
-		/** Services. */
1174
-		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1173
+        /** Services. */
1174
+        $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1175 1175
 
1176
-		/** Adapters. */
1177
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1178
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1179
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1180
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1181
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1176
+        /** Adapters. */
1177
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1178
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1179
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1180
+        $this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1181
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1182 1182
 
1183
-		/** Async Tasks. */
1184
-		new Wordlift_Sparql_Query_Async_Task();
1185
-		new Wordlift_Batch_Analysis_Request_Async_Task();
1186
-		new Wordlift_Batch_Analysis_Complete_Async_Task();
1183
+        /** Async Tasks. */
1184
+        new Wordlift_Sparql_Query_Async_Task();
1185
+        new Wordlift_Batch_Analysis_Request_Async_Task();
1186
+        new Wordlift_Batch_Analysis_Complete_Async_Task();
1187 1187
 
1188
-		/** WL Autocomplete. */
1189
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1190
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1188
+        /** WL Autocomplete. */
1189
+        $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1190
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1191 1191
 
1192
-		/** WordPress Admin UI. */
1192
+        /** WordPress Admin UI. */
1193 1193
 
1194
-		// UI elements.
1195
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1196
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1197
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1198
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1199
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1200
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1201
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1194
+        // UI elements.
1195
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1196
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1197
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1198
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1199
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1200
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1201
+        $this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1202 1202
 
1203
-		$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 );
1204
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1205
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1203
+        $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 );
1204
+        $this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1205
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1206 1206
 
1207
-		// Pages.
1208
-		new Wordlift_Admin_Post_Edit_Page( $this );
1209
-		new Wordlift_Entity_Type_Admin_Service();
1210
-
1211
-		// create an instance of the entity type list admin page controller.
1212
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1213
-
1214
-		// create an instance of the entity type etting admin page controller.
1215
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1216
-
1217
-		/** Widgets */
1218
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1219
-
1220
-		/* WordPress Admin. */
1221
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1222
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1223
-
1224
-		// Create an instance of the install wizard.
1225
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1226
-
1227
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1228
-
1229
-		// User Profile.
1230
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1231
-
1232
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1233
-
1234
-		// Load the debug service if WP is in debug mode.
1235
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1236
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1237
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1238
-		}
1239
-
1240
-	}
1241
-
1242
-	/**
1243
-	 * Define the locale for this plugin for internationalization.
1244
-	 *
1245
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1246
-	 * with WordPress.
1247
-	 *
1248
-	 * @since    1.0.0
1249
-	 * @access   private
1250
-	 */
1251
-	private function set_locale() {
1252
-
1253
-		$plugin_i18n = new Wordlift_i18n();
1254
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1255
-
1256
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1257
-
1258
-	}
1259
-
1260
-	/**
1261
-	 * Register all of the hooks related to the admin area functionality
1262
-	 * of the plugin.
1263
-	 *
1264
-	 * @since    1.0.0
1265
-	 * @access   private
1266
-	 */
1267
-	private function define_admin_hooks() {
1268
-
1269
-		$plugin_admin = new Wordlift_Admin(
1270
-			$this->get_plugin_name(),
1271
-			$this->get_version(),
1272
-			$this->configuration_service,
1273
-			$this->notice_service,
1274
-			$this->user_service
1275
-		);
1276
-
1277
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1278
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1279
-
1280
-		// Hook the init action to the Topic Taxonomy service.
1281
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1282
-
1283
-		// Hook the deleted_post_meta action to the Thumbnail service.
1284
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1285
-
1286
-		// Hook the added_post_meta action to the Thumbnail service.
1287
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1288
-
1289
-		// Hook the updated_post_meta action to the Thumbnail service.
1290
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1291
-
1292
-		// Hook the AJAX wl_timeline action to the Timeline service.
1293
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1294
-
1295
-		// Register custom allowed redirect hosts.
1296
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1297
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1298
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1299
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1300
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1301
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1302
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1303
-
1304
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1305
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1306
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1307
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1308
-
1309
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1310
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1311
-
1312
-		// Entity listing customization (wp-admin/edit.php)
1313
-		// Add custom columns.
1314
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1315
-		// no explicit entity as it prevents handling of other post types.
1316
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1317
-		// Add 4W selection.
1318
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1319
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1320
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1321
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1322
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1323
-
1324
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1325
-		// entities.
1326
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1327
-
1328
-		// Filter imported post meta.
1329
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1330
-
1331
-		// Notify the import service when an import starts and ends.
1332
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1333
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1334
-
1335
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1336
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1337
-
1338
-		// Hook the menu to the Download Your Data page.
1339
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1340
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1341
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1342
-
1343
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1344
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1345
-
1346
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1347
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1348
-
1349
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1350
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1351
-
1352
-		// Hook the `admin_init` function to the Admin Setup.
1353
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1354
-
1355
-		// Hook the admin_init to the settings page.
1356
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1357
-
1358
-		// Hook the menu creation on the general wordlift menu creation.
1359
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1360
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1361
-			// Add the functionality only if a flag is set in wp-config.php .
1362
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1363
-		}
1364
-
1365
-		// Hook key update.
1366
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1367
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1368
-
1369
-		// Add additional action links to the WordLift plugin in the plugins page.
1370
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1371
-
1372
-		// Hook the AJAX `wl_publisher` action name.
1373
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1374
-
1375
-		// Hook row actions for the entity type list admin.
1376
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1377
-
1378
-		/** Ajax actions. */
1379
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1380
-
1381
-		// Hook capabilities manipulation to allow access to entity type admin
1382
-		// page  on WordPress versions before 4.7.
1383
-		global $wp_version;
1384
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1385
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1386
-		}
1387
-
1388
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1389
-
1390
-		/** Adapters. */
1391
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1392
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1393
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1394
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1395
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1396
-
1397
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1398
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1399
-
1400
-		// Handle the autocomplete request.
1401
-		add_action( 'wp_ajax_wl_autocomplete', array(
1402
-			$this->autocomplete_adapter,
1403
-			'wl_autocomplete',
1404
-		) );
1405
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1406
-			$this->autocomplete_adapter,
1407
-			'wl_autocomplete',
1408
-		) );
1409
-
1410
-		// Hooks to restrict multisite super admin from manipulating entity types.
1411
-		if ( is_multisite() ) {
1412
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1413
-		}
1414
-
1415
-	}
1416
-
1417
-	/**
1418
-	 * Register all of the hooks related to the public-facing functionality
1419
-	 * of the plugin.
1420
-	 *
1421
-	 * @since    1.0.0
1422
-	 * @access   private
1423
-	 */
1424
-	private function define_public_hooks() {
1425
-
1426
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1207
+        // Pages.
1208
+        new Wordlift_Admin_Post_Edit_Page( $this );
1209
+        new Wordlift_Entity_Type_Admin_Service();
1210
+
1211
+        // create an instance of the entity type list admin page controller.
1212
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1213
+
1214
+        // create an instance of the entity type etting admin page controller.
1215
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1216
+
1217
+        /** Widgets */
1218
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1219
+
1220
+        /* WordPress Admin. */
1221
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1222
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1223
+
1224
+        // Create an instance of the install wizard.
1225
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1226
+
1227
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1228
+
1229
+        // User Profile.
1230
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1231
+
1232
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1233
+
1234
+        // Load the debug service if WP is in debug mode.
1235
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1236
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1237
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1238
+        }
1239
+
1240
+    }
1241
+
1242
+    /**
1243
+     * Define the locale for this plugin for internationalization.
1244
+     *
1245
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1246
+     * with WordPress.
1247
+     *
1248
+     * @since    1.0.0
1249
+     * @access   private
1250
+     */
1251
+    private function set_locale() {
1252
+
1253
+        $plugin_i18n = new Wordlift_i18n();
1254
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1255
+
1256
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1257
+
1258
+    }
1259
+
1260
+    /**
1261
+     * Register all of the hooks related to the admin area functionality
1262
+     * of the plugin.
1263
+     *
1264
+     * @since    1.0.0
1265
+     * @access   private
1266
+     */
1267
+    private function define_admin_hooks() {
1268
+
1269
+        $plugin_admin = new Wordlift_Admin(
1270
+            $this->get_plugin_name(),
1271
+            $this->get_version(),
1272
+            $this->configuration_service,
1273
+            $this->notice_service,
1274
+            $this->user_service
1275
+        );
1276
+
1277
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1278
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1279
+
1280
+        // Hook the init action to the Topic Taxonomy service.
1281
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1282
+
1283
+        // Hook the deleted_post_meta action to the Thumbnail service.
1284
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1285
+
1286
+        // Hook the added_post_meta action to the Thumbnail service.
1287
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1288
+
1289
+        // Hook the updated_post_meta action to the Thumbnail service.
1290
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1291
+
1292
+        // Hook the AJAX wl_timeline action to the Timeline service.
1293
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1294
+
1295
+        // Register custom allowed redirect hosts.
1296
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1297
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1298
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1299
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1300
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1301
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1302
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1303
+
1304
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1305
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1306
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1307
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1308
+
1309
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1310
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1311
+
1312
+        // Entity listing customization (wp-admin/edit.php)
1313
+        // Add custom columns.
1314
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1315
+        // no explicit entity as it prevents handling of other post types.
1316
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1317
+        // Add 4W selection.
1318
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1319
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1320
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1321
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1322
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1323
+
1324
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1325
+        // entities.
1326
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1327
+
1328
+        // Filter imported post meta.
1329
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1330
+
1331
+        // Notify the import service when an import starts and ends.
1332
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1333
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1334
+
1335
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1336
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1337
+
1338
+        // Hook the menu to the Download Your Data page.
1339
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1340
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1341
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1342
+
1343
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1344
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1345
+
1346
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1347
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1348
+
1349
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1350
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1351
+
1352
+        // Hook the `admin_init` function to the Admin Setup.
1353
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1354
+
1355
+        // Hook the admin_init to the settings page.
1356
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1357
+
1358
+        // Hook the menu creation on the general wordlift menu creation.
1359
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1360
+        if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1361
+            // Add the functionality only if a flag is set in wp-config.php .
1362
+            $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1363
+        }
1364
+
1365
+        // Hook key update.
1366
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1367
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1368
+
1369
+        // Add additional action links to the WordLift plugin in the plugins page.
1370
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1371
+
1372
+        // Hook the AJAX `wl_publisher` action name.
1373
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1374
+
1375
+        // Hook row actions for the entity type list admin.
1376
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1377
+
1378
+        /** Ajax actions. */
1379
+        $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1380
+
1381
+        // Hook capabilities manipulation to allow access to entity type admin
1382
+        // page  on WordPress versions before 4.7.
1383
+        global $wp_version;
1384
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1385
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1386
+        }
1387
+
1388
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1389
+
1390
+        /** Adapters. */
1391
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1392
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1393
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1394
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1395
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1396
+
1397
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1398
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1399
+
1400
+        // Handle the autocomplete request.
1401
+        add_action( 'wp_ajax_wl_autocomplete', array(
1402
+            $this->autocomplete_adapter,
1403
+            'wl_autocomplete',
1404
+        ) );
1405
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1406
+            $this->autocomplete_adapter,
1407
+            'wl_autocomplete',
1408
+        ) );
1409
+
1410
+        // Hooks to restrict multisite super admin from manipulating entity types.
1411
+        if ( is_multisite() ) {
1412
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1413
+        }
1414
+
1415
+    }
1416
+
1417
+    /**
1418
+     * Register all of the hooks related to the public-facing functionality
1419
+     * of the plugin.
1420
+     *
1421
+     * @since    1.0.0
1422
+     * @access   private
1423
+     */
1424
+    private function define_public_hooks() {
1425
+
1426
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1427 1427
 
1428
-		// Register the entity post type.
1429
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1428
+        // Register the entity post type.
1429
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1430 1430
 
1431
-		// Bind the link generation and handling hooks to the entity link service.
1432
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1433
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1434
-		$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 );
1435
-		$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 );
1436
-
1437
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1438
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1439
-
1440
-		// Hook the content filter service to add entity links.
1441
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1442
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1443
-		}
1444
-
1445
-		// Hook the AJAX wl_timeline action to the Timeline service.
1446
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1447
-
1448
-		// Hook the ShareThis service.
1449
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1450
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1451
-
1452
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1453
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1454
-
1455
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1456
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1457
-		// to categories.
1458
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1459
-
1460
-		/*
1431
+        // Bind the link generation and handling hooks to the entity link service.
1432
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1433
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1434
+        $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 );
1435
+        $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 );
1436
+
1437
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1438
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1439
+
1440
+        // Hook the content filter service to add entity links.
1441
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1442
+            $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1443
+        }
1444
+
1445
+        // Hook the AJAX wl_timeline action to the Timeline service.
1446
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1447
+
1448
+        // Hook the ShareThis service.
1449
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1450
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1451
+
1452
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1453
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1454
+
1455
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1456
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1457
+        // to categories.
1458
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1459
+
1460
+        /*
1461 1461
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1462 1462
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1463 1463
 		 * order of start time.
1464 1464
 		 */
1465
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1466
-
1467
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1468
-
1469
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1470
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1471
-
1472
-	}
1473
-
1474
-	/**
1475
-	 * Run the loader to execute all of the hooks with WordPress.
1476
-	 *
1477
-	 * @since    1.0.0
1478
-	 */
1479
-	public function run() {
1480
-		$this->loader->run();
1481
-	}
1482
-
1483
-	/**
1484
-	 * The name of the plugin used to uniquely identify it within the context of
1485
-	 * WordPress and to define internationalization functionality.
1486
-	 *
1487
-	 * @since     1.0.0
1488
-	 * @return    string    The name of the plugin.
1489
-	 */
1490
-	public function get_plugin_name() {
1491
-		return $this->plugin_name;
1492
-	}
1493
-
1494
-	/**
1495
-	 * The reference to the class that orchestrates the hooks with the plugin.
1496
-	 *
1497
-	 * @since     1.0.0
1498
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1499
-	 */
1500
-	public function get_loader() {
1501
-		return $this->loader;
1502
-	}
1503
-
1504
-	/**
1505
-	 * Retrieve the version number of the plugin.
1506
-	 *
1507
-	 * @since     1.0.0
1508
-	 * @return    string    The version number of the plugin.
1509
-	 */
1510
-	public function get_version() {
1511
-		return $this->version;
1512
-	}
1465
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1466
+
1467
+        $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1468
+
1469
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1470
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1471
+
1472
+    }
1473
+
1474
+    /**
1475
+     * Run the loader to execute all of the hooks with WordPress.
1476
+     *
1477
+     * @since    1.0.0
1478
+     */
1479
+    public function run() {
1480
+        $this->loader->run();
1481
+    }
1482
+
1483
+    /**
1484
+     * The name of the plugin used to uniquely identify it within the context of
1485
+     * WordPress and to define internationalization functionality.
1486
+     *
1487
+     * @since     1.0.0
1488
+     * @return    string    The name of the plugin.
1489
+     */
1490
+    public function get_plugin_name() {
1491
+        return $this->plugin_name;
1492
+    }
1493
+
1494
+    /**
1495
+     * The reference to the class that orchestrates the hooks with the plugin.
1496
+     *
1497
+     * @since     1.0.0
1498
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1499
+     */
1500
+    public function get_loader() {
1501
+        return $this->loader;
1502
+    }
1503
+
1504
+    /**
1505
+     * Retrieve the version number of the plugin.
1506
+     *
1507
+     * @since     1.0.0
1508
+     * @return    string    The version number of the plugin.
1509
+     */
1510
+    public function get_version() {
1511
+        return $this->version;
1512
+    }
1513 1513
 
1514 1514
 }
Please login to merge, or discard this patch.
Spacing   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -717,345 +717,345 @@  discard block
 block discarded – undo
717 717
 		 * The class responsible for orchestrating the actions and filters of the
718 718
 		 * core plugin.
719 719
 		 */
720
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
720
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php';
721 721
 
722 722
 		/**
723 723
 		 * The class responsible for defining internationalization functionality
724 724
 		 * of the plugin.
725 725
 		 */
726
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
726
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php';
727 727
 
728 728
 		/**
729 729
 		 * WordLift's supported languages.
730 730
 		 */
731
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
731
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php';
732 732
 
733 733
 		/**
734 734
 		 * Provide support functions to sanitize data.
735 735
 		 */
736
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
736
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php';
737 737
 
738 738
 		/** Services. */
739
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
741
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
742
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
743
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
744
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
746
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
747
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
739
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php';
740
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php';
741
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php';
742
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php';
743
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php';
744
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php';
745
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php';
746
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php';
747
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php';
748 748
 
749 749
 		/**
750 750
 		 * The Query builder.
751 751
 		 */
752
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
752
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php';
753 753
 
754 754
 		/**
755 755
 		 * The Schema service.
756 756
 		 */
757
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
757
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php';
758 758
 
759 759
 		/**
760 760
 		 * The schema:url property service.
761 761
 		 */
762
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
762
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php';
763
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php';
764 764
 
765 765
 		/**
766 766
 		 * The UI service.
767 767
 		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
768
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php';
769 769
 
770 770
 		/**
771 771
 		 * The Thumbnail service.
772 772
 		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
773
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php';
774 774
 
775 775
 		/**
776 776
 		 * The Entity Types Taxonomy service.
777 777
 		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
778
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php';
779 779
 
780 780
 		/**
781 781
 		 * The Entity service.
782 782
 		 */
783
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
783
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-service.php';
784
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php';
785 785
 
786 786
 		// Add the entity rating service.
787
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
787
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php';
788 788
 
789 789
 		/**
790 790
 		 * The User service.
791 791
 		 */
792
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
792
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php';
793 793
 
794 794
 		/**
795 795
 		 * The Timeline service.
796 796
 		 */
797
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
797
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php';
798 798
 
799 799
 		/**
800 800
 		 * The Topic Taxonomy service.
801 801
 		 */
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
802
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php';
803 803
 
804 804
 		/**
805 805
 		 * The SPARQL service.
806 806
 		 */
807
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
807
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php';
808 808
 
809 809
 		/**
810 810
 		 * The WordLift import service.
811 811
 		 */
812
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
812
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php';
813 813
 
814 814
 		/**
815 815
 		 * The WordLift URI service.
816 816
 		 */
817
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
817
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php';
818 818
 
819
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
819
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php';
820 820
 
821
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
821
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php';
822 822
 
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
823
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php';
824 824
 
825 825
 		/**
826 826
 		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
827 827
 		 */
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
828
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php';
829 829
 
830
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
830
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php';
831 831
 
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
832
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php';
833 833
 
834 834
 		/**
835 835
 		 * Load the converters.
836 836
 		 */
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
840
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
837
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php';
838
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
839
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php';
840
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php';
841
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php';
842
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php';
843 843
 
844 844
 		/**
845 845
 		 * Load cache-related files.
846 846
 		 */
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
847
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php';
848 848
 
849 849
 		/**
850 850
 		 * Load the content filter.
851 851
 		 */
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
852
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php';
853 853
 
854 854
 		/*
855 855
 		 * Load the excerpt helper.
856 856
 		 */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
857
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php';
858 858
 
859 859
 		/**
860 860
 		 * Load the JSON-LD service to publish entities using JSON-LD.s
861 861
 		 *
862 862
 		 * @since 3.8.0
863 863
 		 */
864
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
864
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php';
865 865
 
866 866
 		// The Publisher Service and the AJAX adapter.
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
867
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php';
868
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php';
869 869
 
870
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
870
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php';
871 871
 
872 872
 		/**
873 873
 		 * Load the WordLift key validation service.
874 874
 		 */
875
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
875
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php';
876 876
 
877 877
 		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
878
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
878
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php';
879 879
 
880 880
 		// Load the `Wordlift_Entity_Page_Service` class definition.
881
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php';
883
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
881
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php';
882
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-analysis-service.php';
883
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-rebuild-service.php';
884 884
 
885 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';
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 899
 
900 900
 		/** Services. */
901
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
901
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php';
902 902
 
903 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';
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 910
 
911 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';
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 916
 
917 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';
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 920
 
921 921
 		/**
922 922
 		 * The class responsible for defining all actions that occur in the admin area.
923 923
 		 */
924
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
924
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php';
925 925
 
926 926
 		/**
927 927
 		 * The class to customize the entity list admin page.
928 928
 		 */
929
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
929
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php';
930 930
 
931 931
 		/**
932 932
 		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
933 933
 		 */
934
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
934
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php';
935 935
 
936 936
 		/**
937 937
 		 * The Notice service.
938 938
 		 */
939
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
939
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php';
940 940
 
941 941
 		/**
942 942
 		 * The PrimaShop adapter.
943 943
 		 */
944
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
944
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php';
945 945
 
946 946
 		/**
947 947
 		 * The WordLift Dashboard service.
948 948
 		 */
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
949
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php';
950 950
 
951 951
 		/**
952 952
 		 * The admin 'Install wizard' page.
953 953
 		 */
954
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
954
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php';
955 955
 
956 956
 		/**
957 957
 		 * The WordLift entity type list admin page controller.
958 958
 		 */
959
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
959
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
960 960
 
961 961
 		/**
962 962
 		 * The WordLift entity type settings admin page controller.
963 963
 		 */
964
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
964
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php';
965 965
 
966 966
 		/**
967 967
 		 * The admin 'Download Your Data' page.
968 968
 		 */
969
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
969
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php';
970 970
 
971 971
 		/**
972 972
 		 * The admin 'WordLift Settings' page.
973 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';
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 986
 
987 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';
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 992
 
993 993
 		/**
994 994
 		 * The class responsible for defining all actions that occur in the public-facing
995 995
 		 * side of the site.
996 996
 		 */
997
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
997
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php';
998 998
 
999 999
 		/**
1000 1000
 		 * The shortcode abstract class.
1001 1001
 		 */
1002
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1002
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php';
1003 1003
 
1004 1004
 		/**
1005 1005
 		 * The Timeline shortcode.
1006 1006
 		 */
1007
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1007
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php';
1008 1008
 
1009 1009
 		/**
1010 1010
 		 * The Navigator shortcode.
1011 1011
 		 */
1012
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1012
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php';
1013 1013
 
1014 1014
 		/**
1015 1015
 		 * The chord shortcode.
1016 1016
 		 */
1017
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1017
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php';
1018 1018
 
1019 1019
 		/**
1020 1020
 		 * The geomap shortcode.
1021 1021
 		 */
1022
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1022
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php';
1023 1023
 
1024 1024
 		/**
1025 1025
 		 * The entity cloud shortcode.
1026 1026
 		 */
1027
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1027
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php';
1028 1028
 
1029 1029
 		/**
1030 1030
 		 * The entity glossary shortcode.
1031 1031
 		 */
1032
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1033
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1032
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-alphabet-service.php';
1033
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-vocabulary-shortcode.php';
1034 1034
 
1035 1035
 		/**
1036 1036
 		 * The ShareThis service.
1037 1037
 		 */
1038
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1038
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php';
1039 1039
 
1040 1040
 		/**
1041 1041
 		 * The SEO service.
1042 1042
 		 */
1043
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1043
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php';
1044 1044
 
1045 1045
 		/**
1046 1046
 		 * The AMP service.
1047 1047
 		 */
1048
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1048
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php';
1049 1049
 
1050 1050
 		/** Widgets */
1051
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1051
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php';
1052
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php';
1053 1053
 
1054 1054
 		$this->loader = new Wordlift_Loader();
1055 1055
 
1056 1056
 		// Instantiate a global logger.
1057 1057
 		global $wl_logger;
1058
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1058
+		$wl_logger = Wordlift_Log_Service::get_logger('WordLift');
1059 1059
 
1060 1060
 		// Load the `wl-api` end-point.
1061 1061
 		new Wordlift_Http_Api();
@@ -1065,10 +1065,10 @@  discard block
 block discarded – undo
1065 1065
 		$this->configuration_service = new Wordlift_Configuration_Service();
1066 1066
 
1067 1067
 		// Create an entity type service instance. It'll be later bound to the init action.
1068
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1068
+		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path());
1069 1069
 
1070 1070
 		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1071
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1071
+		$this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path());
1072 1072
 
1073 1073
 		// Create an instance of the UI service.
1074 1074
 		$this->ui_service = new Wordlift_UI_Service();
@@ -1077,33 +1077,33 @@  discard block
 block discarded – undo
1077 1077
 		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1078 1078
 
1079 1079
 		$this->sparql_service        = new Wordlift_Sparql_Service();
1080
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1080
+		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service);
1081 1081
 		$this->notice_service        = new Wordlift_Notice_Service();
1082 1082
 		$this->relation_service      = new Wordlift_Relation_Service();
1083 1083
 
1084
-		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1085
-		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1086
-		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1084
+		$entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/');
1085
+		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service($this->configuration_service, $entity_uri_cache_service);
1086
+		$this->entity_service     = new Wordlift_Entity_Service($this->ui_service, $this->relation_service, $this->entity_uri_service);
1087 1087
 		$this->user_service       = new Wordlift_User_Service();
1088 1088
 
1089 1089
 		// Instantiate the JSON-LD service.
1090
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
+		$property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service);
1091 1091
 
1092 1092
 		/** Linked Data. */
1093
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1094
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1093
+		$this->storage_factory   = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter);
1094
+		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service);
1095 1095
 
1096
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1096
+		$this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service);
1097 1097
 
1098 1098
 		// Create a new instance of the Redirect service.
1099
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1100
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1101
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1099
+		$this->redirect_service    = new Wordlift_Redirect_Service($this->entity_service);
1100
+		$this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service);
1101
+		$this->linked_data_service = new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service);
1102 1102
 
1103 1103
 		// Create a new instance of the Timeline service and Timeline shortcode.
1104
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1104
+		$this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service);
1105 1105
 
1106
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1106
+		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service($this, $this->configuration_service);
1107 1107
 
1108 1108
 		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1109 1109
 
@@ -1116,53 +1116,53 @@  discard block
 block discarded – undo
1116 1116
 		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1117 1117
 
1118 1118
 		// Create an import service instance to hook later to WP's import function.
1119
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1119
+		$this->import_service = new Wordlift_Import_Service($this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri());
1120 1120
 
1121
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1121
+		$uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']);
1122 1122
 
1123 1123
 		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1124
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1124
+		$this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service);
1125 1125
 
1126 1126
 		// Create the entity rating service.
1127
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1127
+		$this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service);
1128 1128
 
1129 1129
 		// Create entity list customization (wp-admin/edit.php).
1130
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1130
+		$this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service);
1131 1131
 
1132 1132
 		// Create a new instance of the Redirect service.
1133
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1133
+		$this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service);
1134 1134
 
1135 1135
 		// Create an instance of the Publisher Service and the AJAX Adapter.
1136 1136
 		$publisher_service      = new Wordlift_Publisher_Service();
1137
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1138
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1137
+		$this->property_factory = new Wordlift_Property_Factory($schema_url_property_service);
1138
+		$this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service);
1139 1139
 
1140 1140
 		$attachment_service = new Wordlift_Attachment_Service();
1141 1141
 
1142 1142
 		// Instantiate the JSON-LD service.
1143
-		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1144
-		$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 );
1145
-		$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 );
1146
-		$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 );
1147
-		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1148
-		$this->file_cache_service                = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1149
-		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1150
-		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1151
-
1152
-
1153
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1154
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1155
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1156
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1157
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1143
+		$property_getter                         = Wordlift_Property_Getter_Factory::create($this->entity_service);
1144
+		$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);
1145
+		$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);
1146
+		$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);
1147
+		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service);
1148
+		$this->file_cache_service                = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'converter/');
1149
+		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service);
1150
+		$this->jsonld_service                    = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter);
1151
+
1152
+
1153
+		$this->key_validation_service   = new Wordlift_Key_Validation_Service($this->configuration_service);
1154
+		$this->content_filter_service   = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service, $this->entity_uri_service);
1155
+		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service);
1156
+		$this->sample_data_service      = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service, $this->user_service);
1157
+		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service);
1158 1158
 
1159 1159
 		// Initialize the shortcodes.
1160 1160
 		new Wordlift_Navigator_Shortcode();
1161 1161
 		new Wordlift_Chord_Shortcode();
1162 1162
 		new Wordlift_Geomap_Shortcode();
1163 1163
 		new Wordlift_Timeline_Shortcode();
1164
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1165
-		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1164
+		new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service);
1165
+		new Wordlift_Vocabulary_Shortcode($this->configuration_service);
1166 1166
 
1167 1167
 		// Initialize the SEO service.
1168 1168
 		new Wordlift_Seo_Service();
@@ -1174,11 +1174,11 @@  discard block
 block discarded – undo
1174 1174
 		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1175 1175
 
1176 1176
 		/** Adapters. */
1177
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1178
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1179
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1180
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1181
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1177
+		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter($this->entity_type_service);
1178
+		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter($publisher_service);
1179
+		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter($this);
1180
+		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter($this->batch_analysis_service);
1181
+		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service);
1182 1182
 
1183 1183
 		/** Async Tasks. */
1184 1184
 		new Wordlift_Sparql_Query_Async_Task();
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 		new Wordlift_Batch_Analysis_Complete_Async_Task();
1187 1187
 
1188 1188
 		/** WL Autocomplete. */
1189
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1190
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1189
+		$this->autocomplete_service = new Wordlift_Autocomplete_Service($this->configuration_service);
1190
+		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($this->autocomplete_service);
1191 1191
 
1192 1192
 		/** WordPress Admin UI. */
1193 1193
 
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
 		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1198 1198
 		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1199 1199
 		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1200
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1201
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1200
+		$this->publisher_element       = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element);
1201
+		$this->author_element          = new Wordlift_Admin_Author_Element($publisher_service, $this->select2_element);
1202 1202
 
1203
-		$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 );
1204
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1205
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1203
+		$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);
1204
+		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page($this->batch_analysis_service);
1205
+		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page);
1206 1206
 
1207 1207
 		// Pages.
1208
-		new Wordlift_Admin_Post_Edit_Page( $this );
1208
+		new Wordlift_Admin_Post_Edit_Page($this);
1209 1209
 		new Wordlift_Entity_Type_Admin_Service();
1210 1210
 
1211 1211
 		// create an instance of the entity type list admin page controller.
@@ -1218,23 +1218,23 @@  discard block
 block discarded – undo
1218 1218
 		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1219 1219
 
1220 1220
 		/* WordPress Admin. */
1221
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1222
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1221
+		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service);
1222
+		$this->status_page             = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service);
1223 1223
 
1224 1224
 		// Create an instance of the install wizard.
1225
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1225
+		$this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service);
1226 1226
 
1227
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1227
+		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service);
1228 1228
 
1229 1229
 		// User Profile.
1230
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1230
+		new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service);
1231 1231
 
1232 1232
 		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1233 1233
 
1234 1234
 		// Load the debug service if WP is in debug mode.
1235
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1236
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1237
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1235
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1236
+			require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php';
1237
+			new Wordlift_Debug_Service($this->entity_service, $uri_service);
1238 1238
 		}
1239 1239
 
1240 1240
 	}
@@ -1251,9 +1251,9 @@  discard block
 block discarded – undo
1251 1251
 	private function set_locale() {
1252 1252
 
1253 1253
 		$plugin_i18n = new Wordlift_i18n();
1254
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1254
+		$plugin_i18n->set_domain($this->get_plugin_name());
1255 1255
 
1256
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1256
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
1257 1257
 
1258 1258
 	}
1259 1259
 
@@ -1274,142 +1274,142 @@  discard block
 block discarded – undo
1274 1274
 			$this->user_service
1275 1275
 		);
1276 1276
 
1277
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1278
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1277
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
1278
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
1279 1279
 
1280 1280
 		// Hook the init action to the Topic Taxonomy service.
1281
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1281
+		$this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0);
1282 1282
 
1283 1283
 		// Hook the deleted_post_meta action to the Thumbnail service.
1284
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1284
+		$this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4);
1285 1285
 
1286 1286
 		// Hook the added_post_meta action to the Thumbnail service.
1287
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1287
+		$this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1288 1288
 
1289 1289
 		// Hook the updated_post_meta action to the Thumbnail service.
1290
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1290
+		$this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
1291 1291
 
1292 1292
 		// Hook the AJAX wl_timeline action to the Timeline service.
1293
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1293
+		$this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline');
1294 1294
 
1295 1295
 		// Register custom allowed redirect hosts.
1296
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1296
+		$this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts');
1297 1297
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1298
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1298
+		$this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect');
1299 1299
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1300
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1300
+		$this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats');
1301 1301
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
1302
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1302
+		$this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets');
1303 1303
 
1304 1304
 		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1305 1305
 		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1306
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1307
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1306
+		$this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3);
1307
+		$this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1);
1308 1308
 
1309
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1310
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1309
+		$this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1);
1310
+		$this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header');
1311 1311
 
1312 1312
 		// Entity listing customization (wp-admin/edit.php)
1313 1313
 		// Add custom columns.
1314
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1314
+		$this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns');
1315 1315
 		// no explicit entity as it prevents handling of other post types.
1316
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1316
+		$this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2);
1317 1317
 		// Add 4W selection.
1318
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1319
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1320
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1321
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1322
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1318
+		$this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope');
1319
+		$this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope');
1320
+		$this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts');
1321
+		$this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit');
1322
+		$this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args');
1323 1323
 
1324 1324
 		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1325 1325
 		// entities.
1326
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1326
+		$this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2);
1327 1327
 
1328 1328
 		// Filter imported post meta.
1329
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1329
+		$this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3);
1330 1330
 
1331 1331
 		// Notify the import service when an import starts and ends.
1332
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1333
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1332
+		$this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0);
1333
+		$this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0);
1334 1334
 
1335 1335
 		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1336
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1336
+		$this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild');
1337 1337
 
1338 1338
 		// Hook the menu to the Download Your Data page.
1339
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1340
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1341
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1339
+		$this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0);
1340
+		$this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0);
1341
+		$this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0);
1342 1342
 
1343 1343
 		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1344
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1344
+		$this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10);
1345 1345
 
1346 1346
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1347
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1347
+		$this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get');
1348 1348
 
1349 1349
 		// Hook the AJAX wl_validate_key action to the Key Validation service.
1350
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1350
+		$this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key');
1351 1351
 
1352 1352
 		// Hook the `admin_init` function to the Admin Setup.
1353
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1353
+		$this->loader->add_action('admin_init', $this->admin_setup, 'admin_init');
1354 1354
 
1355 1355
 		// Hook the admin_init to the settings page.
1356
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1356
+		$this->loader->add_action('admin_init', $this->settings_page, 'admin_init');
1357 1357
 
1358 1358
 		// Hook the menu creation on the general wordlift menu creation.
1359
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1360
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1359
+		$this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2);
1360
+		if (defined('WORDLIFT_BATCH') && WORDLIFT_BATCH) {
1361 1361
 			// Add the functionality only if a flag is set in wp-config.php .
1362
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1362
+			$this->loader->add_action('wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2);
1363 1363
 		}
1364 1364
 
1365 1365
 		// Hook key update.
1366
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1367
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1366
+		$this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2);
1367
+		$this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2);
1368 1368
 
1369 1369
 		// Add additional action links to the WordLift plugin in the plugins page.
1370
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1370
+		$this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1);
1371 1371
 
1372 1372
 		// Hook the AJAX `wl_publisher` action name.
1373
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1373
+		$this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher');
1374 1374
 
1375 1375
 		// Hook row actions for the entity type list admin.
1376
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1376
+		$this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2);
1377 1377
 
1378 1378
 		/** Ajax actions. */
1379
-		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1379
+		$this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export');
1380 1380
 
1381 1381
 		// Hook capabilities manipulation to allow access to entity type admin
1382 1382
 		// page  on WordPress versions before 4.7.
1383 1383
 		global $wp_version;
1384
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1385
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1384
+		if (version_compare($wp_version, '4.7', '<')) {
1385
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4);
1386 1386
 		}
1387 1387
 
1388
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1388
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1389 1389
 
1390 1390
 		/** Adapters. */
1391
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1392
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1393
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1394
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1395
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1391
+		$this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1);
1392
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10);
1393
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10);
1394
+		$this->loader->add_action('wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10);
1395
+		$this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10);
1396 1396
 
1397
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1398
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1397
+		$this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create');
1398
+		$this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete');
1399 1399
 
1400 1400
 		// Handle the autocomplete request.
1401
-		add_action( 'wp_ajax_wl_autocomplete', array(
1401
+		add_action('wp_ajax_wl_autocomplete', array(
1402 1402
 			$this->autocomplete_adapter,
1403 1403
 			'wl_autocomplete',
1404
-		) );
1405
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1404
+		));
1405
+		add_action('wp_ajax_nopriv_wl_autocomplete', array(
1406 1406
 			$this->autocomplete_adapter,
1407 1407
 			'wl_autocomplete',
1408
-		) );
1408
+		));
1409 1409
 
1410 1410
 		// Hooks to restrict multisite super admin from manipulating entity types.
1411
-		if ( is_multisite() ) {
1412
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1411
+		if (is_multisite()) {
1412
+			$this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4);
1413 1413
 		}
1414 1414
 
1415 1415
 	}
@@ -1423,51 +1423,51 @@  discard block
 block discarded – undo
1423 1423
 	 */
1424 1424
 	private function define_public_hooks() {
1425 1425
 
1426
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1426
+		$plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version());
1427 1427
 
1428 1428
 		// Register the entity post type.
1429
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1429
+		$this->loader->add_action('init', $this->entity_post_type_service, 'register');
1430 1430
 
1431 1431
 		// Bind the link generation and handling hooks to the entity link service.
1432
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1433
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1434
-		$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 );
1435
-		$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 );
1432
+		$this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4);
1433
+		$this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1);
1434
+		$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);
1435
+		$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);
1436 1436
 
1437
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1438
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1437
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
1438
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
1439 1439
 
1440 1440
 		// Hook the content filter service to add entity links.
1441
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1442
-			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1441
+		if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) {
1442
+			$this->loader->add_filter('the_content', $this->content_filter_service, 'the_content');
1443 1443
 		}
1444 1444
 
1445 1445
 		// Hook the AJAX wl_timeline action to the Timeline service.
1446
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1446
+		$this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline');
1447 1447
 
1448 1448
 		// Hook the ShareThis service.
1449
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1450
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1449
+		$this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99);
1450
+		$this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99);
1451 1451
 
1452 1452
 		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1453
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1453
+		$this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get');
1454 1454
 
1455 1455
 		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1456 1456
 		// in order to tweak WP's `WP_Query` to include entities in queries related
1457 1457
 		// to categories.
1458
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1458
+		$this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1);
1459 1459
 
1460 1460
 		/*
1461 1461
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1462 1462
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1463 1463
 		 * order of start time.
1464 1464
 		 */
1465
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1465
+		$this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1);
1466 1466
 
1467
-		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1467
+		$this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1);
1468 1468
 
1469 1469
 		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1470
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1470
+		$this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3);
1471 1471
 
1472 1472
 	}
1473 1473
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-batch-analysis-adapter.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -16,88 +16,88 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Batch_Analysis_Adapter {
18 18
 
19
-	/**
20
-	 * @var Wordlift_Batch_Analysis_Service
21
-	 */
22
-	private $batch_analysis_service;
19
+    /**
20
+     * @var Wordlift_Batch_Analysis_Service
21
+     */
22
+    private $batch_analysis_service;
23 23
 
24 24
 
25
-	/**
26
-	 * Wordlift_Batch_Analysis_Adapter constructor.
27
-	 *
28
-	 * @since 3.14.2
29
-	 *
30
-	 * @param \Wordlift_Batch_Analysis_Service $batch_analysis_service
31
-	 */
32
-	public function __construct( $batch_analysis_service ) {
25
+    /**
26
+     * Wordlift_Batch_Analysis_Adapter constructor.
27
+     *
28
+     * @since 3.14.2
29
+     *
30
+     * @param \Wordlift_Batch_Analysis_Service $batch_analysis_service
31
+     */
32
+    public function __construct( $batch_analysis_service ) {
33 33
 
34
-		$this->batch_analysis_service = $batch_analysis_service;
34
+        $this->batch_analysis_service = $batch_analysis_service;
35 35
 
36
-	}
36
+    }
37 37
 
38
-	/**
39
-	 * Submit the posts for batch analysis.
40
-	 *
41
-	 * @since 3.14.2
42
-	 */
43
-	public function submit() {
38
+    /**
39
+     * Submit the posts for batch analysis.
40
+     *
41
+     * @since 3.14.2
42
+     */
43
+    public function submit() {
44 44
 
45
-		if ( ! isset( $_REQUEST['link'] ) ) {
46
-			wp_die( 'The `link` parameter is required.' );
47
-		}
45
+        if ( ! isset( $_REQUEST['link'] ) ) {
46
+            wp_die( 'The `link` parameter is required.' );
47
+        }
48 48
 
49
-		$this->batch_analysis_service->set_params( $_REQUEST );
49
+        $this->batch_analysis_service->set_params( $_REQUEST );
50 50
 
51
-		$count = $this->batch_analysis_service->submit();
51
+        $count = $this->batch_analysis_service->submit();
52 52
 
53
-		// Clear any buffer.
54
-		ob_clean();
53
+        // Clear any buffer.
54
+        ob_clean();
55 55
 
56
-		// Send the response.
57
-		wp_send_json_success( array( 'count' => $count ) );
56
+        // Send the response.
57
+        wp_send_json_success( array( 'count' => $count ) );
58 58
 
59
-	}
59
+    }
60 60
 
61
-	/**
62
-	 * Cancel the batch analysis for the specified post.
63
-	 *
64
-	 * @since 3.14.0
65
-	 */
66
-	public function cancel() {
61
+    /**
62
+     * Cancel the batch analysis for the specified post.
63
+     *
64
+     * @since 3.14.0
65
+     */
66
+    public function cancel() {
67 67
 
68
-		if ( ! isset( $_REQUEST['post'] ) ) {
69
-			wp_die( 'The `post` parameter is required.' );
70
-		}
68
+        if ( ! isset( $_REQUEST['post'] ) ) {
69
+            wp_die( 'The `post` parameter is required.' );
70
+        }
71 71
 
72
-		$count = $this->batch_analysis_service->cancel( (array) $_REQUEST['post'] );
72
+        $count = $this->batch_analysis_service->cancel( (array) $_REQUEST['post'] );
73 73
 
74
-		// Clear any buffer.
75
-		ob_clean();
74
+        // Clear any buffer.
75
+        ob_clean();
76 76
 
77
-		// Send the response.
78
-		wp_send_json_success( array( 'count' => $count ) );
77
+        // Send the response.
78
+        wp_send_json_success( array( 'count' => $count ) );
79 79
 
80
-	}
80
+    }
81 81
 
82
-	/**
83
-	 * Clear warnings for the specified post.
84
-	 *
85
-	 * @since 3.14.0
86
-	 */
87
-	public function clear_warning() {
82
+    /**
83
+     * Clear warnings for the specified post.
84
+     *
85
+     * @since 3.14.0
86
+     */
87
+    public function clear_warning() {
88 88
 
89
-		if ( ! isset( $_REQUEST['post'] ) ) {
90
-			wp_die( 'The `post` parameter is required.' );
91
-		}
89
+        if ( ! isset( $_REQUEST['post'] ) ) {
90
+            wp_die( 'The `post` parameter is required.' );
91
+        }
92 92
 
93
-		$this->batch_analysis_service->clear_warning( (array) $_REQUEST['post'] );
93
+        $this->batch_analysis_service->clear_warning( (array) $_REQUEST['post'] );
94 94
 
95
-		// Clear any buffer.
96
-		ob_clean();
95
+        // Clear any buffer.
96
+        ob_clean();
97 97
 
98
-		// Send the response.
99
-		wp_send_json_success();
98
+        // Send the response.
99
+        wp_send_json_success();
100 100
 
101
-	}
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param \Wordlift_Batch_Analysis_Service $batch_analysis_service
31 31
 	 */
32
-	public function __construct( $batch_analysis_service ) {
32
+	public function __construct($batch_analysis_service) {
33 33
 
34 34
 		$this->batch_analysis_service = $batch_analysis_service;
35 35
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function submit() {
44 44
 
45
-		if ( ! isset( $_REQUEST['link'] ) ) {
46
-			wp_die( 'The `link` parameter is required.' );
45
+		if ( ! isset($_REQUEST['link'])) {
46
+			wp_die('The `link` parameter is required.');
47 47
 		}
48 48
 
49
-		$this->batch_analysis_service->set_params( $_REQUEST );
49
+		$this->batch_analysis_service->set_params($_REQUEST);
50 50
 
51 51
 		$count = $this->batch_analysis_service->submit();
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		ob_clean();
55 55
 
56 56
 		// Send the response.
57
-		wp_send_json_success( array( 'count' => $count ) );
57
+		wp_send_json_success(array('count' => $count));
58 58
 
59 59
 	}
60 60
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function cancel() {
67 67
 
68
-		if ( ! isset( $_REQUEST['post'] ) ) {
69
-			wp_die( 'The `post` parameter is required.' );
68
+		if ( ! isset($_REQUEST['post'])) {
69
+			wp_die('The `post` parameter is required.');
70 70
 		}
71 71
 
72
-		$count = $this->batch_analysis_service->cancel( (array) $_REQUEST['post'] );
72
+		$count = $this->batch_analysis_service->cancel((array) $_REQUEST['post']);
73 73
 
74 74
 		// Clear any buffer.
75 75
 		ob_clean();
76 76
 
77 77
 		// Send the response.
78
-		wp_send_json_success( array( 'count' => $count ) );
78
+		wp_send_json_success(array('count' => $count));
79 79
 
80 80
 	}
81 81
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function clear_warning() {
88 88
 
89
-		if ( ! isset( $_REQUEST['post'] ) ) {
90
-			wp_die( 'The `post` parameter is required.' );
89
+		if ( ! isset($_REQUEST['post'])) {
90
+			wp_die('The `post` parameter is required.');
91 91
 		}
92 92
 
93
-		$this->batch_analysis_service->clear_warning( (array) $_REQUEST['post'] );
93
+		$this->batch_analysis_service->clear_warning((array) $_REQUEST['post']);
94 94
 
95 95
 		// Clear any buffer.
96 96
 		ob_clean();
Please login to merge, or discard this patch.
src/includes/class-wordlift-batch-analysis-service.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -916,7 +916,7 @@
 block discarded – undo
916 916
 	 *
917 917
 	 * @param int $min_occurrences Minimum occurrences to perform analysis
918 918
 	 *
919
-	 * @return array An array of link options.
919
+	 * @return string An array of link options.
920 920
 	 */
921 921
 	public function get_link_options( $link, $min_occurrences ) {
922 922
 		$link_options = array(
Please login to merge, or discard this patch.
Indentation   +827 added lines, -827 removed lines patch added patch discarded remove patch
@@ -51,185 +51,185 @@  discard block
 block discarded – undo
51 51
  */
52 52
 class Wordlift_Batch_Analysis_Service {
53 53
 
54
-	/**
55
-	 * The list of states for the Batch Analysis:
56
-	 *  - STATE_META_KEY: the batch analysis state meta key,
57
-	 *  - STATE_SUBMIT: a post/page has been submitted for analysis,
58
-	 *  - STATE_REQUEST: the plugin requested an analysis for the submitted
59
-	 *      post/page,
60
-	 *  - STATE_SUCCESS: the analysis has completed successfully,
61
-	 *  - STATE_ERROR: the analysis returned an error.
62
-	 *
63
-	 * @since 3.14.2
64
-	 */
65
-	const STATE_META_KEY = '_wl_batch_analysis_state';
66
-	const STATE_SUBMIT = 0;
67
-	const STATE_REQUEST = 1;
68
-	// ### COMPLETE states.
69
-	const STATE_SUCCESS = 2;
70
-	const STATE_ERROR = 2;
71
-
72
-	/**
73
-	 * The submit timestamp meta key. A post may have more than one timestamp.
74
-	 *
75
-	 * @since 3.14.2
76
-	 */
77
-	const SUBMIT_TIMESTAMP_META_KEY = '_wl_batch_analysis_submit_timestamp';
78
-
79
-	/**
80
-	 * The request timestamp meta key. A post may have more than one timestamp.
81
-	 *
82
-	 * @since 3.14.2
83
-	 */
84
-	const REQUEST_TIMESTAMP_META_KEY = '_wl_batch_analysis_request_timestamp';
85
-
86
-	/**
87
-	 * The complete (success or error) timestamp meta key. A post may have more
88
-	 * than one timestamp.
89
-	 *
90
-	 * @since 3.14.2
91
-	 */
92
-	const COMPLETE_TIMESTAMP_META_KEY = '_wl_batch_analysis_complete_timestamp';
93
-
94
-	/**
95
-	 * The link setting meta key. A post may have more than one setting.
96
-	 *
97
-	 * @since 3.14.2
98
-	 */
99
-	const LINK_META_KEY = '_wl_batch_analysis_link';
100
-
101
-	/**
102
-	 * The warning timestamp meta key. A post has only zero/one value.
103
-	 *
104
-	 * @since 3.14.2
105
-	 */
106
-	const WARNING_META_KEY = '_wl_batch_analysis_warning';
107
-
108
-	/**
109
-	 * Option name.
110
-	 *
111
-	 * @since  3.14.0
112
-	 */
113
-	const OPTION_NAME = 'wl_analyze_batch';
114
-
115
-	/**
116
-	 * Name of waiting to be processed queue array inside the option.
117
-	 *
118
-	 * @since  3.14.0
119
-	 */
120
-	const ANALYZE_QUEUE = 'queue';
121
-
122
-	/**
123
-	 * Name of waiting for response queue array inside the option.
124
-	 *
125
-	 * @since  3.14.0
126
-	 */
127
-	const RESPONSE_QUEUE = 'processing';
128
-
129
-	/**
130
-	 * Regular expressions that match interpolation errors.
131
-	 *
132
-	 * @since  3.17.0
133
-	 */
134
-	const INTERPOLATION_PATTERN = array(
135
-		// Matches word before the annotation.
136
-		'~\w<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>~',
137
-		// Matches word after the annotation.
138
-		'~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>\w~',
139
-		// Matches space in the beginning of annotation name.
140
-		'~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(\s.*?)<\/[a-z]+>~',
141
-	);
142
-
143
-	/**
144
-	 * The {@link Wordlift} plugin instance.
145
-	 *
146
-	 * @since  3.14.0
147
-	 * @access private
148
-	 * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
149
-	 */
150
-	private $plugin;
151
-
152
-	/**
153
-	 * The {@link Wordlift_Configuration_Service} instance.
154
-	 *
155
-	 * @since  3.14.0
156
-	 * @access private
157
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
158
-	 */
159
-	private $configuration_service;
160
-
161
-	/**
162
-	 * A {@link Wordlift_Log_Service} instance.
163
-	 *
164
-	 * @since  3.14.2
165
-	 * @access private
166
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
167
-	 */
168
-	private $log;
169
-
170
-	/**
171
-	 * Request params
172
-	 *
173
-	 * @since  3.17.0
174
-	 * @access private
175
-	 * @var array $params Request Params
176
-	 */
177
-	private $params;
178
-
179
-	/**
180
-	 * The {@link Class_Wordlift_Batch_Analys_Service} instance.
181
-	 *
182
-	 * @since 3.14.0
183
-	 *
184
-	 * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
185
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
186
-	 */
187
-	public function __construct( $plugin, $configuration_service ) {
188
-
189
-		$this->plugin                = $plugin;
190
-		$this->configuration_service = $configuration_service;
191
-		$this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
192
-
193
-		add_action( 'wl_async_wl_batch_analysis_request', array(
194
-			$this,
195
-			'request',
196
-		) );
197
-		add_action( 'wl_async_wl_batch_analysis_complete', array(
198
-			$this,
199
-			'complete',
200
-		) );
201
-
202
-		// Fix interpolation errors from Batch Analysis.
203
-		add_filter(
204
-			'wl_set_post_content_warning',
205
-			array(
206
-				$this,
207
-				'fix_interpolation_errors',
208
-			),
209
-			10,
210
-			2
211
-		);
212
-	}
213
-
214
-	/**
215
-	 * Get the base SQL statement to submit a post for Batch Analysis.
216
-	 *
217
-	 * Functions may use this base SQL and add their own filters.
218
-	 *
219
-	 * @since 3.14.2
220
-	 *
221
-	 * @return string The base SQL.
222
-	 */
223
-	private function get_sql() {
224
-		global $wpdb;
225
-
226
-		// Get the link options.
227
-		$link_options = $this->get_link_options(
228
-			$this->params['link'],
229
-			$this->params['minOccurrences']
230
-		);
231
-
232
-		/*
54
+    /**
55
+     * The list of states for the Batch Analysis:
56
+     *  - STATE_META_KEY: the batch analysis state meta key,
57
+     *  - STATE_SUBMIT: a post/page has been submitted for analysis,
58
+     *  - STATE_REQUEST: the plugin requested an analysis for the submitted
59
+     *      post/page,
60
+     *  - STATE_SUCCESS: the analysis has completed successfully,
61
+     *  - STATE_ERROR: the analysis returned an error.
62
+     *
63
+     * @since 3.14.2
64
+     */
65
+    const STATE_META_KEY = '_wl_batch_analysis_state';
66
+    const STATE_SUBMIT = 0;
67
+    const STATE_REQUEST = 1;
68
+    // ### COMPLETE states.
69
+    const STATE_SUCCESS = 2;
70
+    const STATE_ERROR = 2;
71
+
72
+    /**
73
+     * The submit timestamp meta key. A post may have more than one timestamp.
74
+     *
75
+     * @since 3.14.2
76
+     */
77
+    const SUBMIT_TIMESTAMP_META_KEY = '_wl_batch_analysis_submit_timestamp';
78
+
79
+    /**
80
+     * The request timestamp meta key. A post may have more than one timestamp.
81
+     *
82
+     * @since 3.14.2
83
+     */
84
+    const REQUEST_TIMESTAMP_META_KEY = '_wl_batch_analysis_request_timestamp';
85
+
86
+    /**
87
+     * The complete (success or error) timestamp meta key. A post may have more
88
+     * than one timestamp.
89
+     *
90
+     * @since 3.14.2
91
+     */
92
+    const COMPLETE_TIMESTAMP_META_KEY = '_wl_batch_analysis_complete_timestamp';
93
+
94
+    /**
95
+     * The link setting meta key. A post may have more than one setting.
96
+     *
97
+     * @since 3.14.2
98
+     */
99
+    const LINK_META_KEY = '_wl_batch_analysis_link';
100
+
101
+    /**
102
+     * The warning timestamp meta key. A post has only zero/one value.
103
+     *
104
+     * @since 3.14.2
105
+     */
106
+    const WARNING_META_KEY = '_wl_batch_analysis_warning';
107
+
108
+    /**
109
+     * Option name.
110
+     *
111
+     * @since  3.14.0
112
+     */
113
+    const OPTION_NAME = 'wl_analyze_batch';
114
+
115
+    /**
116
+     * Name of waiting to be processed queue array inside the option.
117
+     *
118
+     * @since  3.14.0
119
+     */
120
+    const ANALYZE_QUEUE = 'queue';
121
+
122
+    /**
123
+     * Name of waiting for response queue array inside the option.
124
+     *
125
+     * @since  3.14.0
126
+     */
127
+    const RESPONSE_QUEUE = 'processing';
128
+
129
+    /**
130
+     * Regular expressions that match interpolation errors.
131
+     *
132
+     * @since  3.17.0
133
+     */
134
+    const INTERPOLATION_PATTERN = array(
135
+        // Matches word before the annotation.
136
+        '~\w<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>~',
137
+        // Matches word after the annotation.
138
+        '~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(.*?)<\/[a-z]+>\w~',
139
+        // Matches space in the beginning of annotation name.
140
+        '~<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">(\s.*?)<\/[a-z]+>~',
141
+    );
142
+
143
+    /**
144
+     * The {@link Wordlift} plugin instance.
145
+     *
146
+     * @since  3.14.0
147
+     * @access private
148
+     * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
149
+     */
150
+    private $plugin;
151
+
152
+    /**
153
+     * The {@link Wordlift_Configuration_Service} instance.
154
+     *
155
+     * @since  3.14.0
156
+     * @access private
157
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
158
+     */
159
+    private $configuration_service;
160
+
161
+    /**
162
+     * A {@link Wordlift_Log_Service} instance.
163
+     *
164
+     * @since  3.14.2
165
+     * @access private
166
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
167
+     */
168
+    private $log;
169
+
170
+    /**
171
+     * Request params
172
+     *
173
+     * @since  3.17.0
174
+     * @access private
175
+     * @var array $params Request Params
176
+     */
177
+    private $params;
178
+
179
+    /**
180
+     * The {@link Class_Wordlift_Batch_Analys_Service} instance.
181
+     *
182
+     * @since 3.14.0
183
+     *
184
+     * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
185
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
186
+     */
187
+    public function __construct( $plugin, $configuration_service ) {
188
+
189
+        $this->plugin                = $plugin;
190
+        $this->configuration_service = $configuration_service;
191
+        $this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
192
+
193
+        add_action( 'wl_async_wl_batch_analysis_request', array(
194
+            $this,
195
+            'request',
196
+        ) );
197
+        add_action( 'wl_async_wl_batch_analysis_complete', array(
198
+            $this,
199
+            'complete',
200
+        ) );
201
+
202
+        // Fix interpolation errors from Batch Analysis.
203
+        add_filter(
204
+            'wl_set_post_content_warning',
205
+            array(
206
+                $this,
207
+                'fix_interpolation_errors',
208
+            ),
209
+            10,
210
+            2
211
+        );
212
+    }
213
+
214
+    /**
215
+     * Get the base SQL statement to submit a post for Batch Analysis.
216
+     *
217
+     * Functions may use this base SQL and add their own filters.
218
+     *
219
+     * @since 3.14.2
220
+     *
221
+     * @return string The base SQL.
222
+     */
223
+    private function get_sql() {
224
+        global $wpdb;
225
+
226
+        // Get the link options.
227
+        $link_options = $this->get_link_options(
228
+            $this->params['link'],
229
+            $this->params['minOccurrences']
230
+        );
231
+
232
+        /*
233 233
 		Prepare the statement:
234 234
 			1. Insert into `postmeta` the meta keys and values:
235 235
 				a) state meta, with value of SUBMIT (0),
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 			9. Filter by `post_id` where `exclude` is the posts id to exclude.
246 246
 		*/
247 247
 
248
-		// @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
249
-		return $wpdb->prepare(
250
-			"
248
+        // @codingStandardsIgnoreStart, Ignore phpcs sanitation errors.
249
+        return $wpdb->prepare(
250
+            "
251 251
 			INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value )
252 252
 			SELECT p.ID, metas.*
253 253
 			FROM (
@@ -263,676 +263,676 @@  discard block
 block discarded – undo
263 263
 			WHERE p.post_type = %s
264 264
 				AND p.post_status = 'publish'
265 265
 			"
266
-			. self::include_annotated( $this->params['include_annotated'] )
267
-			. self::and_post_date_from( $this->params['from'] )
268
-			. self::and_post_date_to( $this->params['to'] )
269
-			. self::include_posts( $this->params['include'] )
270
-			. self::exclude_posts( $this->params['exclude'] )
271
-			,
272
-			self::STATE_META_KEY,
273
-			self::SUBMIT_TIMESTAMP_META_KEY,
274
-			self::LINK_META_KEY,
275
-			$link_options,
276
-			self::STATE_META_KEY,
277
-			$this->params['post_type']
278
-		);
279
-		// @codingStandardsIgnoreEnd
280
-	}
281
-
282
-	/**
283
-	 * Submit posts for Batch Analysis.
284
-	 *
285
-	 * @since 3.14.2
286
-	 *
287
-	 * @return int The number of submitted {@link WP_Post}s or false on error.
288
-	 */
289
-	public function submit() {
290
-		global $wpdb;
291
-
292
-		// Submit the posts/pages and return the number of affected results.
293
-		// We're using a SQL query here because we could have potentially
294
-		// thousands of rows.
295
-		$count = $wpdb->query( $this->get_sql() ); // WPCS: cache ok, db call ok.
296
-
297
-		// Request Batch Analysis (the operation is handled asynchronously).
298
-		do_action( 'wl_batch_analysis_request' );
299
-
300
-		// Divide the count by 3 to get the number of posts/pages queued.
301
-		return $count / 3;
302
-	}
303
-
304
-	/**
305
-	 * Cancel the Batch Analysis request for the specified {@link WP_Post}s.
306
-	 *
307
-	 * @since 3.14.2
308
-	 *
309
-	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
310
-	 *                            {@link WP_Post}s' ids.
311
-	 *
312
-	 * @return false|int The number of cancelled {@link WP_Post}s or false on
313
-	 *                   error.
314
-	 */
315
-	public function cancel( $post_ids ) {
316
-		global $wpdb;
317
-
318
-		return $wpdb->query( $wpdb->prepare(
319
-			"
266
+            . self::include_annotated( $this->params['include_annotated'] )
267
+            . self::and_post_date_from( $this->params['from'] )
268
+            . self::and_post_date_to( $this->params['to'] )
269
+            . self::include_posts( $this->params['include'] )
270
+            . self::exclude_posts( $this->params['exclude'] )
271
+            ,
272
+            self::STATE_META_KEY,
273
+            self::SUBMIT_TIMESTAMP_META_KEY,
274
+            self::LINK_META_KEY,
275
+            $link_options,
276
+            self::STATE_META_KEY,
277
+            $this->params['post_type']
278
+        );
279
+        // @codingStandardsIgnoreEnd
280
+    }
281
+
282
+    /**
283
+     * Submit posts for Batch Analysis.
284
+     *
285
+     * @since 3.14.2
286
+     *
287
+     * @return int The number of submitted {@link WP_Post}s or false on error.
288
+     */
289
+    public function submit() {
290
+        global $wpdb;
291
+
292
+        // Submit the posts/pages and return the number of affected results.
293
+        // We're using a SQL query here because we could have potentially
294
+        // thousands of rows.
295
+        $count = $wpdb->query( $this->get_sql() ); // WPCS: cache ok, db call ok.
296
+
297
+        // Request Batch Analysis (the operation is handled asynchronously).
298
+        do_action( 'wl_batch_analysis_request' );
299
+
300
+        // Divide the count by 3 to get the number of posts/pages queued.
301
+        return $count / 3;
302
+    }
303
+
304
+    /**
305
+     * Cancel the Batch Analysis request for the specified {@link WP_Post}s.
306
+     *
307
+     * @since 3.14.2
308
+     *
309
+     * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
310
+     *                            {@link WP_Post}s' ids.
311
+     *
312
+     * @return false|int The number of cancelled {@link WP_Post}s or false on
313
+     *                   error.
314
+     */
315
+    public function cancel( $post_ids ) {
316
+        global $wpdb;
317
+
318
+        return $wpdb->query( $wpdb->prepare(
319
+            "
320 320
 			DELETE FROM $wpdb->postmeta
321 321
 			WHERE meta_key = %s
322 322
 				AND meta_value = %s
323 323
 				AND post_id IN ( " . implode( ',', wp_parse_id_list( $post_ids ) ) . " )
324 324
 			",
325
-			self::STATE_META_KEY,
326
-			self::STATE_REQUEST
327
-		) ); // WPCS: cache ok, db call ok.
325
+            self::STATE_META_KEY,
326
+            self::STATE_REQUEST
327
+        ) ); // WPCS: cache ok, db call ok.
328 328
 
329
-	}
329
+    }
330 330
 
331
-	/**
332
-	 * Request the batch analysis for submitted posts.
333
-	 *
334
-	 * @since 3.14.2
335
-	 */
336
-	public function request() {
331
+    /**
332
+     * Request the batch analysis for submitted posts.
333
+     *
334
+     * @since 3.14.2
335
+     */
336
+    public function request() {
337 337
 
338
-		$this->log->debug( 'Requesting analysis...' );
338
+        $this->log->debug( 'Requesting analysis...' );
339 339
 
340
-		// By default 5 posts of any post type are returned.
341
-		$posts = get_posts( array(
342
-			'fields'     => 'ids',
343
-			'meta_key'   => self::STATE_META_KEY,
344
-			'meta_value' => self::STATE_SUBMIT,
345
-			'orderby'    => 'ID',
346
-			'post_type'  => 'any',
347
-		) );
340
+        // By default 5 posts of any post type are returned.
341
+        $posts = get_posts( array(
342
+            'fields'     => 'ids',
343
+            'meta_key'   => self::STATE_META_KEY,
344
+            'meta_value' => self::STATE_SUBMIT,
345
+            'orderby'    => 'ID',
346
+            'post_type'  => 'any',
347
+        ) );
348 348
 
349
-		// Bail out if there are no submitted posts.
350
-		if ( empty( $posts ) ) {
351
-			$this->log->debug( 'No posts to submit found, checking for completed requests...' );
349
+        // Bail out if there are no submitted posts.
350
+        if ( empty( $posts ) ) {
351
+            $this->log->debug( 'No posts to submit found, checking for completed requests...' );
352 352
 
353
-			do_action( 'wl_batch_analysis_complete' );
353
+            do_action( 'wl_batch_analysis_complete' );
354 354
 
355
-			return;
356
-		}
355
+            return;
356
+        }
357 357
 
358
-		// Send a request for each post.
359
-		foreach ( $posts as $id ) {
360
-			$this->log->debug( "Requesting analysis for post $id..." );
358
+        // Send a request for each post.
359
+        foreach ( $posts as $id ) {
360
+            $this->log->debug( "Requesting analysis for post $id..." );
361 361
 
362
-			// Change the state to `REQUEST`.
363
-			$this->set_state( $id, self::STATE_REQUEST );
362
+            // Change the state to `REQUEST`.
363
+            $this->set_state( $id, self::STATE_REQUEST );
364 364
 
365
-			// Send the actual request to the remote service.
366
-			$result = $this->do_request( $id );
365
+            // Send the actual request to the remote service.
366
+            $result = $this->do_request( $id );
367 367
 
368
-			$this->log->debug( "Analysis requested for post $id." );
368
+            $this->log->debug( "Analysis requested for post $id." );
369 369
 
370
-			// Set an error if we received an error.
371
-			if ( is_wp_error( $result ) ) {
372
-				$this->log->error( "Analysis request for post $id returned {$result->get_error_message()}." );
370
+            // Set an error if we received an error.
371
+            if ( is_wp_error( $result ) ) {
372
+                $this->log->error( "Analysis request for post $id returned {$result->get_error_message()}." );
373 373
 
374
-				$this->set_state( $id, self::STATE_ERROR );
375
-			}
376
-		}
374
+                $this->set_state( $id, self::STATE_ERROR );
375
+            }
376
+        }
377 377
 
378
-		// Call the `wl_batch_analysis_request` action again. This is going
379
-		// to be handled by the async task.
380
-		do_action( 'wl_batch_analysis_request' );
378
+        // Call the `wl_batch_analysis_request` action again. This is going
379
+        // to be handled by the async task.
380
+        do_action( 'wl_batch_analysis_request' );
381 381
 
382
-	}
382
+    }
383 383
 
384
-	/**
385
-	 * Get the results for the Batch Analysis.
386
-	 *
387
-	 * @since 3.14.2
388
-	 */
389
-	public function complete() {
384
+    /**
385
+     * Get the results for the Batch Analysis.
386
+     *
387
+     * @since 3.14.2
388
+     */
389
+    public function complete() {
390 390
 
391
-		$this->log->debug( 'Requesting results...' );
391
+        $this->log->debug( 'Requesting results...' );
392 392
 
393
-		// By default 5 posts of any post type are returned.
394
-		$posts = get_posts( array(
395
-			'fields'     => 'ids',
396
-			'meta_key'   => self::STATE_META_KEY,
397
-			'meta_value' => self::STATE_REQUEST,
398
-			'orderby'    => 'ID',
399
-			'post_type'  => 'any',
400
-		) );
393
+        // By default 5 posts of any post type are returned.
394
+        $posts = get_posts( array(
395
+            'fields'     => 'ids',
396
+            'meta_key'   => self::STATE_META_KEY,
397
+            'meta_value' => self::STATE_REQUEST,
398
+            'orderby'    => 'ID',
399
+            'post_type'  => 'any',
400
+        ) );
401 401
 
402
-		// Bail out if there are no submitted posts.
403
-		if ( empty( $posts ) ) {
404
-			$this->log->debug( 'No posts in request state found.' );
405
-
406
-			return;
407
-		}
408
-
409
-		// Send a request for each post.
410
-		foreach ( $posts as $id ) {
411
-			$this->log->debug( "Requesting results for post $id..." );
412
-
413
-			// Send the actual request to the remote service.
414
-			$response = $this->do_complete( $id );
415
-
416
-			$this->log->debug( "Results requested for post $id." );
417
-
418
-			// Set an error if we received an error.
419
-			if ( ! is_wp_error( $response ) && isset( $response['body'] ) ) {
420
-
421
-				$this->log->debug( "Results received for post $id." );
422
-
423
-				// Save the returned content as new revision.
424
-				$json = json_decode( $response['body'] );
425
-
426
-				// Continue if the content isn't set.
427
-				if ( ! isset( $json->content ) || empty( $json->content ) ) {
428
-					// The post content is empty, so is should be marked as completed.
429
-					$this->set_state( $id, self::STATE_ERROR );
430
-					continue;
431
-				}
432
-
433
-				$content = $this->set_warning_based_on_content( $json->content, $id );
434
-
435
-				$content = wp_slash( $content );
436
-
437
-				// Post array with the new anotated content.
438
-				$data = array(
439
-					'ID'           => $id, // The post ID.
440
-					'post_content' => $content, // New annotated post content.
441
-				);
442
-
443
-				/**
444
-				 * Filter: 'wl_batch_analysis_update_post_content' - Allow third parties to perform additional actions when the post content is updated.
445
-				 *
446
-				 * @since  3.17.0
447
-				 * @api arr $data Postarr with post id and the new post content.
448
-				 * @api int $id Current post ID.
449
-				 */
450
-				$data = apply_filters( 'wl_batch_analysis_update_post_content', $data, $id );
451
-
452
-				// Update the post content.
453
-				wp_update_post( $data );
454
-
455
-				// Update the status.
456
-				$this->set_state( $id, self::STATE_SUCCESS );
457
-
458
-				$this->log->debug( "Post $id updated with batch analysis results." );
459
-
460
-				// Set default entity type term for posts that didn't have any.
461
-				$this->maybe_set_default_term( $id );
462
-
463
-				continue;
464
-			}
465
-
466
-			// @todo: implement a kind of timeout that sets an error if the
467
-			// results haven't been received after a long time.
468
-		}
469
-
470
-		// Call the `wl_batch_analysis_request` action again. This is going
471
-		// to be handled by the async task.
472
-		do_action( 'wl_batch_analysis_complete' );
473
-
474
-	}
475
-
476
-	/**
477
-	 * Set a warning flag on the {@link WP_Post} if its content has suspicious
478
-	 * interpolations.
479
-	 *
480
-	 * @since 3.14.2
481
-	 *
482
-	 * @param string $content The {@link WP_Post}'s content.
483
-	 * @param int    $post_id The {@link WP_Post}'s id.
484
-	 *
485
-	 * @return string The content (for chaining operations).
486
-	 */
487
-	private function set_warning_based_on_content( $content, $post_id ) {
488
-
489
-		$matches = array();
490
-
491
-		// Check for suspicious interpolations.
492
-		$warning = 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">/', $content, $matches )
493
-				   || 0 < preg_match_all( '/<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">\s/', $content, $matches );
494
-
495
-		// Set the warning flag accordingly.
496
-		$this->set_warning( $post_id, $warning );
497
-
498
-		/**
499
-		 * Filter: 'wl_set_post_content_warning' - Allow third parties to hook and modify the post content that has errors after the analysis
500
-		 *
501
-		 * @since  3.17.0
502
-		 * @api string $content Postarr with post id and the new post content.
503
-		 * @api int    $id      Post ID.
504
-		 */
505
-		return apply_filters( 'wl_set_post_content_warning', $content, $post_id );
506
-	}
507
-
508
-	/**
509
-	 * Fix interpolation errors raised by Batch Analysis
510
-	 *
511
-	 * @param string $content The {@link WP_Post}'s content.
512
-	 * @param int    $id      The {@link WP_Post}'s id.
513
-	 *
514
-	 * @since 3.17.0
515
-	 *
516
-	 * @return string Post content without interpolations.
517
-	 */
518
-	public function fix_interpolation_errors( $content, $id ) {
519
-
520
-		$this->log->debug( "Begin fixing post $id interpolations" );
521
-
522
-		// Remove all interpolations from the content.
523
-		return preg_replace( self::INTERPOLATION_PATTERN, '$1', $content );
524
-	}
525
-
526
-	/**
527
-	 * Clear the warning flag for the specified {@link WP_Post}s.
528
-	 *
529
-	 * @since 3.14.2
530
-	 *
531
-	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
532
-	 *                            {@link WP_Post}s' ids.
533
-	 */
534
-	public function clear_warning( $post_ids ) {
535
-
536
-		foreach ( (array) $post_ids as $post_id ) {
537
-			delete_post_meta( $post_id, self::WARNING_META_KEY );
538
-		}
539
-
540
-	}
541
-
542
-	/**
543
-	 * Set the warning flag for the specified {@link WP_Post}.
544
-	 *
545
-	 * @since 3.14.2
546
-	 *
547
-	 * @param int  $post_id The {@link WP_Post}'s id.
548
-	 * @param bool $value   The flag's value.
549
-	 *
550
-	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
551
-	 *                  false on failure.
552
-	 */
553
-	private function set_warning( $post_id, $value ) {
554
-
555
-		return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
556
-	}
557
-
558
-	/**
559
-	 * Get the post/page batch analysis state.
560
-	 *
561
-	 * @since 3.14.2
562
-	 *
563
-	 * @param int $post_id The {@link WP_Post}'s id.
564
-	 *
565
-	 * @return int|string The post state or an empty string if not set.
566
-	 */
567
-	public function get_state( $post_id ) {
568
-
569
-		return get_post_meta( $post_id, self::STATE_META_KEY, true );
570
-	}
571
-
572
-	/**
573
-	 * Set the post/page batch analysis state.
574
-	 *
575
-	 * @since 3.14.2
576
-	 *
577
-	 * @param int $post_id The {@link WP_Post}'s id.
578
-	 * @param int $value   The new state.
579
-	 *
580
-	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
581
-	 *                  false on failure.
582
-	 */
583
-	public function set_state( $post_id, $value ) {
584
-
585
-		// Update the state.
586
-		$result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
587
-
588
-		// Update timestamps as required.
589
-		switch ( $value ) {
590
-
591
-			// ### REQUEST state.
592
-			case self::STATE_REQUEST:
593
-				add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
594
-				break;
595
-
596
-			// ### SUCCESS/ERROR state.
597
-			case self::STATE_SUCCESS:
598
-			case self::STATE_ERROR:
599
-				add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
600
-				break;
601
-		}
602
-
603
-		// Finally return the result.
604
-		return $result;
605
-	}
606
-
607
-	/**
608
-	 * Get the link setting for a {@link WP_Post}.
609
-	 *
610
-	 * If there are multiple link settings, only the last one is returned.
611
-	 *
612
-	 * @since 3.14.2
613
-	 *
614
-	 * @param int $post_id The {@link WP_Post}'s id.
615
-	 *
616
-	 * @return array The link settings.
617
-	 */
618
-	public function get_post_link_options( $post_id ) {
619
-
620
-		$values = get_post_meta( $post_id, self::LINK_META_KEY );
621
-
622
-		return end( $values ) ?: array( 'links' => 'default', 'minOccurrences' => 1 );
623
-	}
624
-
625
-	/**
626
-	 * Get the array of post IDS waiting in the queue to start processing.
627
-	 *
628
-	 * @since 3.14.0
629
-	 *
630
-	 * @return array The waiting to be processed post ids queue.
631
-	 */
632
-	public function waiting_for_analysis() {
633
-
634
-		return get_posts( array(
635
-			'posts_per_page' => - 1,
636
-			'fields'         => 'ids',
637
-			'post_status'    => 'any',
638
-			'meta_key'       => self::STATE_META_KEY,
639
-			'meta_value'     => self::STATE_SUBMIT,
640
-			'orderby'        => 'ID',
641
-			'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
642
-		) );
643
-	}
644
-
645
-	/**
646
-	 * Get the array of post IDS waiting for response.
647
-	 *
648
-	 * @deprecated
649
-	 * @since 3.14.0
650
-	 *
651
-	 * @return array The waiting for response post ids queue.
652
-	 */
653
-	public function waiting_for_response() {
654
-
655
-		return get_posts( array(
656
-			'posts_per_page' => - 1,
657
-			'fields'         => 'ids',
658
-			'post_status'    => 'any',
659
-			'meta_key'       => self::STATE_META_KEY,
660
-			'meta_value'     => self::STATE_REQUEST,
661
-			'orderby'        => 'ID',
662
-			'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
663
-		) );
664
-	}
665
-
666
-	/**
667
-	 * Request the analysis for the specified {@link WP_Post}.
668
-	 *
669
-	 * @since 3.14.2
670
-	 *
671
-	 * @param int $post_id The {@link WP_Post}'s id.
672
-	 *
673
-	 * @return WP_Error|array The response or WP_Error on failure.
674
-	 */
675
-	private function do_request( $post_id ) {
676
-
677
-		// Get the post.
678
-		$post = get_post( $post_id );
679
-
680
-		// Bail out if the post isn't found.
681
-		if ( null === $post ) {
682
-			$this->log->warn( "Post $post_id not found." );
683
-
684
-			return new WP_Error( 0, "Cannot find post $post_id." );
685
-		}
686
-
687
-		// Get the link setting.
688
-		$link_options = $this->get_post_link_options( $post_id );
689
-
690
-		$this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $link_options['links'] . ', minOccurrences :: ' . $link_options['minOccurrences'] . ' ] ...' );
691
-
692
-		// Get the batch analysis URL.
693
-		$url = $this->configuration_service->get_batch_analysis_url();
694
-
695
-		// Prepare the POST parameters.
696
-		$param = array_merge(
697
-			array(
698
-				'id'              => $post->ID,
699
-				'key'             => $this->configuration_service->get_key(),
700
-				'content'         => $post->post_content,
701
-				'contentLanguage' => $this->configuration_service->get_language_code(),
702
-				'version'         => $this->plugin->get_version(),
703
-				'scope'           => 'local',
704
-			),
705
-			$link_options // Post link options.
706
-		);
707
-
708
-		// Get the HTTP options.
709
-		$args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
710
-			'method'      => 'POST',
711
-			'headers'     => array(
712
-				'Accept'       => 'application/json',
713
-				'Content-type' => 'application/json; charset=UTF-8',
714
-			),
715
-			// we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
716
-			'httpversion' => '1.0',
717
-			'body'        => wp_json_encode( $param ),
718
-		) );
719
-
720
-		$this->log->debug( "Posting analysis request for post $post_id to $url..." );
721
-
722
-		// Post the parameter.
723
-		return wp_remote_post( $url, $args );
724
-	}
725
-
726
-	/**
727
-	 * Get the Batch Analysis results for the specified {@link WP_Post}.
728
-	 *
729
-	 * @since 3.14.2
730
-	 *
731
-	 * @param int $post_id The {@link WP_Post}'s id.
732
-	 *
733
-	 * @return WP_Error|array The response or WP_Error on failure.
734
-	 */
735
-	private function do_complete( $post_id ) {
736
-
737
-		$post = get_post( $post_id );
738
-
739
-		if ( null === $post ) {
740
-			// Post was possibly deleted, just bailout.
741
-			return new WP_Error( 0, "Post $post_id not found." );
742
-		}
743
-
744
-		$url = $this->configuration_service->get_batch_analysis_url();
745
-		$key = $this->configuration_service->get_key();
746
-		$url = $url . '/' . $post->ID . '?key=' . $key;
747
-
748
-		return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
749
-	}
750
-
751
-	/**
752
-	 * Get the {@link WP_Post}s' ids flagged with warnings.
753
-	 *
754
-	 * @since 3.14.2
755
-	 *
756
-	 * @return array An array of {@link WP_Post}s' ids.
757
-	 */
758
-	public function get_warnings() {
759
-
760
-		return get_posts( array(
761
-			'fields'      => 'ids',
762
-			'numberposts' => - 1,
763
-			'post_status' => 'any',
764
-			'meta_key'    => self::WARNING_META_KEY,
765
-			'meta_value'  => 'yes',
766
-			'post_type'   => 'any', // Add any because posts from multiple posts types may be waiting.
767
-		) );
768
-	}
769
-
770
-	/**
771
-	 * Set the query params from users request.
772
-	 *
773
-	 * @param array $request Array of request params.
774
-	 *
775
-	 * @since 3.17.0
776
-	 */
777
-	public function set_params( $request ) {
778
-		// Build params array and check if param exists.
779
-		// @codingStandardsIgnoreStart, Ignore phpcs indentation errors.
780
-		$params = array(
781
-			'link'              => ( isset( $request['link'] ) )                ? $request['link']              : null,
782
-			'include_annotated' => ( isset( $request['include_annotated'] ) )   ? $request['include_annotated'] : null,
783
-			'include'           => ( isset( $request['include'] ) )             ? (array) $request['include']   : null,
784
-			'exclude'           => ( isset( $request['exclude'] ) )             ? (array) $request['exclude']   : null,
785
-			'from'              => ( isset( $request['from'] ) )                ? $request['from']              : null,
786
-			'to'                => ( isset( $request['to'] ) )                  ? $request['to']                : null,
787
-			'minOccurrences'    => ( isset( $request['min_occurrences'] ) )     ? $request['min_occurrences']   : 1,
788
-			'post_type'         => ( isset( $request['post_type'] ) )           ? $request['post_type']         : 'post',
789
-		);
790
-		// @codingStandardsIgnoreEnd
791
-
792
-		// Set the params.
793
-		$this->params = $params;
794
-	}
795
-
796
-	/**
797
-	 * Add the start date clause.
798
-	 *
799
-	 * @param  string $from The date where the analisys should start.
800
-	 *
801
-	 * @since  3.17.0
802
-	 *
803
-	 * @return string The start `post_date_gmt` clause
804
-	 */
805
-	public static function and_post_date_from( $from ) {
806
-		// Bail if the param is not set.
807
-		if ( null === $from ) {
808
-			return;
809
-		}
810
-
811
-		return " AND p.post_date_gmt > '" . $from . "'";
812
-	}
813
-
814
-	/**
815
-	 * Add the end date clause.
816
-	 *
817
-	 * @param  string $to The end date where the analysis should end.
818
-	 *
819
-	 * @since  3.17.0
820
-	 *
821
-	 * @return string The end `post_date_gmt` clause.
822
-	 */
823
-	public static function and_post_date_to( $to ) {
824
-		// Bail if the param is not set.
825
-		if ( null === $to ) {
826
-			return;
827
-		}
828
-
829
-		return " AND p.post_date_gmt < '" . $to . "'";
830
-	}
831
-
832
-	/**
833
-	 * Include specific posts by their id in the analysis.
834
-	 *
835
-	 * @param array $include Array of post ids to include.
836
-	 *
837
-	 * @since  3.17.0
838
-	 *
839
-	 * @return string The posts IN clause.
840
-	 */
841
-	public static function include_posts( $include ) {
842
-		// Bail if the param is not set.
843
-		if ( null === $include ) {
844
-			return;
845
-		}
846
-
847
-		return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
848
-	}
849
-
850
-	/**
851
-	 * Exclude specific posts by ids.
852
-	 *
853
-	 * @param array $exclude Array of post ids to exclude.
854
-	 *
855
-	 * @since  3.17.0
856
-	 *
857
-	 * @return string The posts NOT IN clause.
858
-	 */
859
-	public static function exclude_posts( $exclude ) {
860
-		// Bail if the param is not set.
861
-		if ( null === $exclude ) {
862
-			return;
863
-		}
864
-
865
-		return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
866
-	}
867
-
868
-	/**
869
-	 * Add a clause to analyze all auto selected posts, i.e. non annotated posts.
870
-	 *
871
-	 * @param string $include The include setting ('yes'/'no').
872
-	 *
873
-	 * @since  3.17.0
874
-	 *
875
-	 * @return string The autoselect clause.
876
-	 */
877
-	public static function include_annotated( $include ) {
878
-		// Bail if the param is not set or if it's set to `no`.
879
-		if (
880
-			! empty( $include ) &&
881
-			'yes' === $include
882
-		) {
883
-			return;
884
-		}
885
-
886
-		return "
402
+        // Bail out if there are no submitted posts.
403
+        if ( empty( $posts ) ) {
404
+            $this->log->debug( 'No posts in request state found.' );
405
+
406
+            return;
407
+        }
408
+
409
+        // Send a request for each post.
410
+        foreach ( $posts as $id ) {
411
+            $this->log->debug( "Requesting results for post $id..." );
412
+
413
+            // Send the actual request to the remote service.
414
+            $response = $this->do_complete( $id );
415
+
416
+            $this->log->debug( "Results requested for post $id." );
417
+
418
+            // Set an error if we received an error.
419
+            if ( ! is_wp_error( $response ) && isset( $response['body'] ) ) {
420
+
421
+                $this->log->debug( "Results received for post $id." );
422
+
423
+                // Save the returned content as new revision.
424
+                $json = json_decode( $response['body'] );
425
+
426
+                // Continue if the content isn't set.
427
+                if ( ! isset( $json->content ) || empty( $json->content ) ) {
428
+                    // The post content is empty, so is should be marked as completed.
429
+                    $this->set_state( $id, self::STATE_ERROR );
430
+                    continue;
431
+                }
432
+
433
+                $content = $this->set_warning_based_on_content( $json->content, $id );
434
+
435
+                $content = wp_slash( $content );
436
+
437
+                // Post array with the new anotated content.
438
+                $data = array(
439
+                    'ID'           => $id, // The post ID.
440
+                    'post_content' => $content, // New annotated post content.
441
+                );
442
+
443
+                /**
444
+                 * Filter: 'wl_batch_analysis_update_post_content' - Allow third parties to perform additional actions when the post content is updated.
445
+                 *
446
+                 * @since  3.17.0
447
+                 * @api arr $data Postarr with post id and the new post content.
448
+                 * @api int $id Current post ID.
449
+                 */
450
+                $data = apply_filters( 'wl_batch_analysis_update_post_content', $data, $id );
451
+
452
+                // Update the post content.
453
+                wp_update_post( $data );
454
+
455
+                // Update the status.
456
+                $this->set_state( $id, self::STATE_SUCCESS );
457
+
458
+                $this->log->debug( "Post $id updated with batch analysis results." );
459
+
460
+                // Set default entity type term for posts that didn't have any.
461
+                $this->maybe_set_default_term( $id );
462
+
463
+                continue;
464
+            }
465
+
466
+            // @todo: implement a kind of timeout that sets an error if the
467
+            // results haven't been received after a long time.
468
+        }
469
+
470
+        // Call the `wl_batch_analysis_request` action again. This is going
471
+        // to be handled by the async task.
472
+        do_action( 'wl_batch_analysis_complete' );
473
+
474
+    }
475
+
476
+    /**
477
+     * Set a warning flag on the {@link WP_Post} if its content has suspicious
478
+     * interpolations.
479
+     *
480
+     * @since 3.14.2
481
+     *
482
+     * @param string $content The {@link WP_Post}'s content.
483
+     * @param int    $post_id The {@link WP_Post}'s id.
484
+     *
485
+     * @return string The content (for chaining operations).
486
+     */
487
+    private function set_warning_based_on_content( $content, $post_id ) {
488
+
489
+        $matches = array();
490
+
491
+        // Check for suspicious interpolations.
492
+        $warning = 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">/', $content, $matches )
493
+                   || 0 < preg_match_all( '/<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">\s/', $content, $matches );
494
+
495
+        // Set the warning flag accordingly.
496
+        $this->set_warning( $post_id, $warning );
497
+
498
+        /**
499
+         * Filter: 'wl_set_post_content_warning' - Allow third parties to hook and modify the post content that has errors after the analysis
500
+         *
501
+         * @since  3.17.0
502
+         * @api string $content Postarr with post id and the new post content.
503
+         * @api int    $id      Post ID.
504
+         */
505
+        return apply_filters( 'wl_set_post_content_warning', $content, $post_id );
506
+    }
507
+
508
+    /**
509
+     * Fix interpolation errors raised by Batch Analysis
510
+     *
511
+     * @param string $content The {@link WP_Post}'s content.
512
+     * @param int    $id      The {@link WP_Post}'s id.
513
+     *
514
+     * @since 3.17.0
515
+     *
516
+     * @return string Post content without interpolations.
517
+     */
518
+    public function fix_interpolation_errors( $content, $id ) {
519
+
520
+        $this->log->debug( "Begin fixing post $id interpolations" );
521
+
522
+        // Remove all interpolations from the content.
523
+        return preg_replace( self::INTERPOLATION_PATTERN, '$1', $content );
524
+    }
525
+
526
+    /**
527
+     * Clear the warning flag for the specified {@link WP_Post}s.
528
+     *
529
+     * @since 3.14.2
530
+     *
531
+     * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
532
+     *                            {@link WP_Post}s' ids.
533
+     */
534
+    public function clear_warning( $post_ids ) {
535
+
536
+        foreach ( (array) $post_ids as $post_id ) {
537
+            delete_post_meta( $post_id, self::WARNING_META_KEY );
538
+        }
539
+
540
+    }
541
+
542
+    /**
543
+     * Set the warning flag for the specified {@link WP_Post}.
544
+     *
545
+     * @since 3.14.2
546
+     *
547
+     * @param int  $post_id The {@link WP_Post}'s id.
548
+     * @param bool $value   The flag's value.
549
+     *
550
+     * @return int|bool Meta ID if the key didn't exist, true on successful update,
551
+     *                  false on failure.
552
+     */
553
+    private function set_warning( $post_id, $value ) {
554
+
555
+        return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
556
+    }
557
+
558
+    /**
559
+     * Get the post/page batch analysis state.
560
+     *
561
+     * @since 3.14.2
562
+     *
563
+     * @param int $post_id The {@link WP_Post}'s id.
564
+     *
565
+     * @return int|string The post state or an empty string if not set.
566
+     */
567
+    public function get_state( $post_id ) {
568
+
569
+        return get_post_meta( $post_id, self::STATE_META_KEY, true );
570
+    }
571
+
572
+    /**
573
+     * Set the post/page batch analysis state.
574
+     *
575
+     * @since 3.14.2
576
+     *
577
+     * @param int $post_id The {@link WP_Post}'s id.
578
+     * @param int $value   The new state.
579
+     *
580
+     * @return int|bool Meta ID if the key didn't exist, true on successful update,
581
+     *                  false on failure.
582
+     */
583
+    public function set_state( $post_id, $value ) {
584
+
585
+        // Update the state.
586
+        $result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
587
+
588
+        // Update timestamps as required.
589
+        switch ( $value ) {
590
+
591
+            // ### REQUEST state.
592
+            case self::STATE_REQUEST:
593
+                add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
594
+                break;
595
+
596
+            // ### SUCCESS/ERROR state.
597
+            case self::STATE_SUCCESS:
598
+            case self::STATE_ERROR:
599
+                add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
600
+                break;
601
+        }
602
+
603
+        // Finally return the result.
604
+        return $result;
605
+    }
606
+
607
+    /**
608
+     * Get the link setting for a {@link WP_Post}.
609
+     *
610
+     * If there are multiple link settings, only the last one is returned.
611
+     *
612
+     * @since 3.14.2
613
+     *
614
+     * @param int $post_id The {@link WP_Post}'s id.
615
+     *
616
+     * @return array The link settings.
617
+     */
618
+    public function get_post_link_options( $post_id ) {
619
+
620
+        $values = get_post_meta( $post_id, self::LINK_META_KEY );
621
+
622
+        return end( $values ) ?: array( 'links' => 'default', 'minOccurrences' => 1 );
623
+    }
624
+
625
+    /**
626
+     * Get the array of post IDS waiting in the queue to start processing.
627
+     *
628
+     * @since 3.14.0
629
+     *
630
+     * @return array The waiting to be processed post ids queue.
631
+     */
632
+    public function waiting_for_analysis() {
633
+
634
+        return get_posts( array(
635
+            'posts_per_page' => - 1,
636
+            'fields'         => 'ids',
637
+            'post_status'    => 'any',
638
+            'meta_key'       => self::STATE_META_KEY,
639
+            'meta_value'     => self::STATE_SUBMIT,
640
+            'orderby'        => 'ID',
641
+            'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
642
+        ) );
643
+    }
644
+
645
+    /**
646
+     * Get the array of post IDS waiting for response.
647
+     *
648
+     * @deprecated
649
+     * @since 3.14.0
650
+     *
651
+     * @return array The waiting for response post ids queue.
652
+     */
653
+    public function waiting_for_response() {
654
+
655
+        return get_posts( array(
656
+            'posts_per_page' => - 1,
657
+            'fields'         => 'ids',
658
+            'post_status'    => 'any',
659
+            'meta_key'       => self::STATE_META_KEY,
660
+            'meta_value'     => self::STATE_REQUEST,
661
+            'orderby'        => 'ID',
662
+            'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
663
+        ) );
664
+    }
665
+
666
+    /**
667
+     * Request the analysis for the specified {@link WP_Post}.
668
+     *
669
+     * @since 3.14.2
670
+     *
671
+     * @param int $post_id The {@link WP_Post}'s id.
672
+     *
673
+     * @return WP_Error|array The response or WP_Error on failure.
674
+     */
675
+    private function do_request( $post_id ) {
676
+
677
+        // Get the post.
678
+        $post = get_post( $post_id );
679
+
680
+        // Bail out if the post isn't found.
681
+        if ( null === $post ) {
682
+            $this->log->warn( "Post $post_id not found." );
683
+
684
+            return new WP_Error( 0, "Cannot find post $post_id." );
685
+        }
686
+
687
+        // Get the link setting.
688
+        $link_options = $this->get_post_link_options( $post_id );
689
+
690
+        $this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $link_options['links'] . ', minOccurrences :: ' . $link_options['minOccurrences'] . ' ] ...' );
691
+
692
+        // Get the batch analysis URL.
693
+        $url = $this->configuration_service->get_batch_analysis_url();
694
+
695
+        // Prepare the POST parameters.
696
+        $param = array_merge(
697
+            array(
698
+                'id'              => $post->ID,
699
+                'key'             => $this->configuration_service->get_key(),
700
+                'content'         => $post->post_content,
701
+                'contentLanguage' => $this->configuration_service->get_language_code(),
702
+                'version'         => $this->plugin->get_version(),
703
+                'scope'           => 'local',
704
+            ),
705
+            $link_options // Post link options.
706
+        );
707
+
708
+        // Get the HTTP options.
709
+        $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
710
+            'method'      => 'POST',
711
+            'headers'     => array(
712
+                'Accept'       => 'application/json',
713
+                'Content-type' => 'application/json; charset=UTF-8',
714
+            ),
715
+            // we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
716
+            'httpversion' => '1.0',
717
+            'body'        => wp_json_encode( $param ),
718
+        ) );
719
+
720
+        $this->log->debug( "Posting analysis request for post $post_id to $url..." );
721
+
722
+        // Post the parameter.
723
+        return wp_remote_post( $url, $args );
724
+    }
725
+
726
+    /**
727
+     * Get the Batch Analysis results for the specified {@link WP_Post}.
728
+     *
729
+     * @since 3.14.2
730
+     *
731
+     * @param int $post_id The {@link WP_Post}'s id.
732
+     *
733
+     * @return WP_Error|array The response or WP_Error on failure.
734
+     */
735
+    private function do_complete( $post_id ) {
736
+
737
+        $post = get_post( $post_id );
738
+
739
+        if ( null === $post ) {
740
+            // Post was possibly deleted, just bailout.
741
+            return new WP_Error( 0, "Post $post_id not found." );
742
+        }
743
+
744
+        $url = $this->configuration_service->get_batch_analysis_url();
745
+        $key = $this->configuration_service->get_key();
746
+        $url = $url . '/' . $post->ID . '?key=' . $key;
747
+
748
+        return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
749
+    }
750
+
751
+    /**
752
+     * Get the {@link WP_Post}s' ids flagged with warnings.
753
+     *
754
+     * @since 3.14.2
755
+     *
756
+     * @return array An array of {@link WP_Post}s' ids.
757
+     */
758
+    public function get_warnings() {
759
+
760
+        return get_posts( array(
761
+            'fields'      => 'ids',
762
+            'numberposts' => - 1,
763
+            'post_status' => 'any',
764
+            'meta_key'    => self::WARNING_META_KEY,
765
+            'meta_value'  => 'yes',
766
+            'post_type'   => 'any', // Add any because posts from multiple posts types may be waiting.
767
+        ) );
768
+    }
769
+
770
+    /**
771
+     * Set the query params from users request.
772
+     *
773
+     * @param array $request Array of request params.
774
+     *
775
+     * @since 3.17.0
776
+     */
777
+    public function set_params( $request ) {
778
+        // Build params array and check if param exists.
779
+        // @codingStandardsIgnoreStart, Ignore phpcs indentation errors.
780
+        $params = array(
781
+            'link'              => ( isset( $request['link'] ) )                ? $request['link']              : null,
782
+            'include_annotated' => ( isset( $request['include_annotated'] ) )   ? $request['include_annotated'] : null,
783
+            'include'           => ( isset( $request['include'] ) )             ? (array) $request['include']   : null,
784
+            'exclude'           => ( isset( $request['exclude'] ) )             ? (array) $request['exclude']   : null,
785
+            'from'              => ( isset( $request['from'] ) )                ? $request['from']              : null,
786
+            'to'                => ( isset( $request['to'] ) )                  ? $request['to']                : null,
787
+            'minOccurrences'    => ( isset( $request['min_occurrences'] ) )     ? $request['min_occurrences']   : 1,
788
+            'post_type'         => ( isset( $request['post_type'] ) )           ? $request['post_type']         : 'post',
789
+        );
790
+        // @codingStandardsIgnoreEnd
791
+
792
+        // Set the params.
793
+        $this->params = $params;
794
+    }
795
+
796
+    /**
797
+     * Add the start date clause.
798
+     *
799
+     * @param  string $from The date where the analisys should start.
800
+     *
801
+     * @since  3.17.0
802
+     *
803
+     * @return string The start `post_date_gmt` clause
804
+     */
805
+    public static function and_post_date_from( $from ) {
806
+        // Bail if the param is not set.
807
+        if ( null === $from ) {
808
+            return;
809
+        }
810
+
811
+        return " AND p.post_date_gmt > '" . $from . "'";
812
+    }
813
+
814
+    /**
815
+     * Add the end date clause.
816
+     *
817
+     * @param  string $to The end date where the analysis should end.
818
+     *
819
+     * @since  3.17.0
820
+     *
821
+     * @return string The end `post_date_gmt` clause.
822
+     */
823
+    public static function and_post_date_to( $to ) {
824
+        // Bail if the param is not set.
825
+        if ( null === $to ) {
826
+            return;
827
+        }
828
+
829
+        return " AND p.post_date_gmt < '" . $to . "'";
830
+    }
831
+
832
+    /**
833
+     * Include specific posts by their id in the analysis.
834
+     *
835
+     * @param array $include Array of post ids to include.
836
+     *
837
+     * @since  3.17.0
838
+     *
839
+     * @return string The posts IN clause.
840
+     */
841
+    public static function include_posts( $include ) {
842
+        // Bail if the param is not set.
843
+        if ( null === $include ) {
844
+            return;
845
+        }
846
+
847
+        return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
848
+    }
849
+
850
+    /**
851
+     * Exclude specific posts by ids.
852
+     *
853
+     * @param array $exclude Array of post ids to exclude.
854
+     *
855
+     * @since  3.17.0
856
+     *
857
+     * @return string The posts NOT IN clause.
858
+     */
859
+    public static function exclude_posts( $exclude ) {
860
+        // Bail if the param is not set.
861
+        if ( null === $exclude ) {
862
+            return;
863
+        }
864
+
865
+        return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
866
+    }
867
+
868
+    /**
869
+     * Add a clause to analyze all auto selected posts, i.e. non annotated posts.
870
+     *
871
+     * @param string $include The include setting ('yes'/'no').
872
+     *
873
+     * @since  3.17.0
874
+     *
875
+     * @return string The autoselect clause.
876
+     */
877
+    public static function include_annotated( $include ) {
878
+        // Bail if the param is not set or if it's set to `no`.
879
+        if (
880
+            ! empty( $include ) &&
881
+            'yes' === $include
882
+        ) {
883
+            return;
884
+        }
885
+
886
+        return "
887 887
 			AND batch_analysis_state.meta_value IS NULL
888 888
 			AND p.post_content NOT REGEXP '<[a-z]+ id=\"urn:[^\"]+\" class=\"[^\"]+\" itemid=\"[^\"]+\">';
889 889
 		";
890
-	}
891
-
892
-	/**
893
-	 * Check whether the term has entity type associated and set default term if it hasn't.
894
-	 *
895
-	 * @since 3.17.0
896
-	 *
897
-	 * @param int $id The post id.
898
-	 */
899
-	public function maybe_set_default_term( $id ) {
900
-		// Check whether the post has any of the WordLift entity types.
901
-		$has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
902
-
903
-		// Bail if the term is associated with entity types already.
904
-		if ( ! empty( $has_term ) ) {
905
-			return;
906
-		}
907
-
908
-		// Set the default `article` term.
909
-		$response = wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
910
-	}
911
-
912
-	/**
913
-	 * Get the link options that will be used by WordLift server when doing the Batch Analysis.
914
-	 *
915
-	 * @param string $link The link setting ('yes'/'no').
916
-	 *
917
-	 * @param int $min_occurrences Minimum occurrences to perform analysis
918
-	 *
919
-	 * @return array An array of link options.
920
-	 */
921
-	public function get_link_options( $link, $min_occurrences ) {
922
-		$link_options = array(
923
-			'links'          => $link, // Link options.
924
-			'minOccurrences' => $min_occurrences, // Minimum occurrences
925
-		);
926
-
927
-		return serialize( $link_options );
928
-	}
929
-
930
-	/**
931
-	 * Returns configuration params.
932
-	 *
933
-	 * @return array Array of configuration params
934
-	 */
935
-	public function get_params() {
936
-		return $this->params;
937
-	}
890
+    }
891
+
892
+    /**
893
+     * Check whether the term has entity type associated and set default term if it hasn't.
894
+     *
895
+     * @since 3.17.0
896
+     *
897
+     * @param int $id The post id.
898
+     */
899
+    public function maybe_set_default_term( $id ) {
900
+        // Check whether the post has any of the WordLift entity types.
901
+        $has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
902
+
903
+        // Bail if the term is associated with entity types already.
904
+        if ( ! empty( $has_term ) ) {
905
+            return;
906
+        }
907
+
908
+        // Set the default `article` term.
909
+        $response = wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
910
+    }
911
+
912
+    /**
913
+     * Get the link options that will be used by WordLift server when doing the Batch Analysis.
914
+     *
915
+     * @param string $link The link setting ('yes'/'no').
916
+     *
917
+     * @param int $min_occurrences Minimum occurrences to perform analysis
918
+     *
919
+     * @return array An array of link options.
920
+     */
921
+    public function get_link_options( $link, $min_occurrences ) {
922
+        $link_options = array(
923
+            'links'          => $link, // Link options.
924
+            'minOccurrences' => $min_occurrences, // Minimum occurrences
925
+        );
926
+
927
+        return serialize( $link_options );
928
+    }
929
+
930
+    /**
931
+     * Returns configuration params.
932
+     *
933
+     * @return array Array of configuration params
934
+     */
935
+    public function get_params() {
936
+        return $this->params;
937
+    }
938 938
 }
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -184,20 +184,20 @@  discard block
 block discarded – undo
184 184
 	 * @param \Wordlift                       $plugin                The {@link Wordlift} plugin instance.
185 185
 	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
186 186
 	 */
187
-	public function __construct( $plugin, $configuration_service ) {
187
+	public function __construct($plugin, $configuration_service) {
188 188
 
189 189
 		$this->plugin                = $plugin;
190 190
 		$this->configuration_service = $configuration_service;
191
-		$this->log                   = Wordlift_Log_Service::get_logger( 'Wordlift_Batch_Analysis_Service' );
191
+		$this->log                   = Wordlift_Log_Service::get_logger('Wordlift_Batch_Analysis_Service');
192 192
 
193
-		add_action( 'wl_async_wl_batch_analysis_request', array(
193
+		add_action('wl_async_wl_batch_analysis_request', array(
194 194
 			$this,
195 195
 			'request',
196
-		) );
197
-		add_action( 'wl_async_wl_batch_analysis_complete', array(
196
+		));
197
+		add_action('wl_async_wl_batch_analysis_complete', array(
198 198
 			$this,
199 199
 			'complete',
200
-		) );
200
+		));
201 201
 
202 202
 		// Fix interpolation errors from Batch Analysis.
203 203
 		add_filter(
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 			WHERE p.post_type = %s
264 264
 				AND p.post_status = 'publish'
265 265
 			"
266
-			. self::include_annotated( $this->params['include_annotated'] )
267
-			. self::and_post_date_from( $this->params['from'] )
268
-			. self::and_post_date_to( $this->params['to'] )
269
-			. self::include_posts( $this->params['include'] )
270
-			. self::exclude_posts( $this->params['exclude'] )
266
+			. self::include_annotated($this->params['include_annotated'])
267
+			. self::and_post_date_from($this->params['from'])
268
+			. self::and_post_date_to($this->params['to'])
269
+			. self::include_posts($this->params['include'])
270
+			. self::exclude_posts($this->params['exclude'])
271 271
 			,
272 272
 			self::STATE_META_KEY,
273 273
 			self::SUBMIT_TIMESTAMP_META_KEY,
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 		// Submit the posts/pages and return the number of affected results.
293 293
 		// We're using a SQL query here because we could have potentially
294 294
 		// thousands of rows.
295
-		$count = $wpdb->query( $this->get_sql() ); // WPCS: cache ok, db call ok.
295
+		$count = $wpdb->query($this->get_sql()); // WPCS: cache ok, db call ok.
296 296
 
297 297
 		// Request Batch Analysis (the operation is handled asynchronously).
298
-		do_action( 'wl_batch_analysis_request' );
298
+		do_action('wl_batch_analysis_request');
299 299
 
300 300
 		// Divide the count by 3 to get the number of posts/pages queued.
301 301
 		return $count / 3;
@@ -312,19 +312,19 @@  discard block
 block discarded – undo
312 312
 	 * @return false|int The number of cancelled {@link WP_Post}s or false on
313 313
 	 *                   error.
314 314
 	 */
315
-	public function cancel( $post_ids ) {
315
+	public function cancel($post_ids) {
316 316
 		global $wpdb;
317 317
 
318
-		return $wpdb->query( $wpdb->prepare(
318
+		return $wpdb->query($wpdb->prepare(
319 319
 			"
320 320
 			DELETE FROM $wpdb->postmeta
321 321
 			WHERE meta_key = %s
322 322
 				AND meta_value = %s
323
-				AND post_id IN ( " . implode( ',', wp_parse_id_list( $post_ids ) ) . " )
323
+				AND post_id IN ( ".implode(',', wp_parse_id_list($post_ids))." )
324 324
 			",
325 325
 			self::STATE_META_KEY,
326 326
 			self::STATE_REQUEST
327
-		) ); // WPCS: cache ok, db call ok.
327
+		)); // WPCS: cache ok, db call ok.
328 328
 
329 329
 	}
330 330
 
@@ -335,49 +335,49 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	public function request() {
337 337
 
338
-		$this->log->debug( 'Requesting analysis...' );
338
+		$this->log->debug('Requesting analysis...');
339 339
 
340 340
 		// By default 5 posts of any post type are returned.
341
-		$posts = get_posts( array(
341
+		$posts = get_posts(array(
342 342
 			'fields'     => 'ids',
343 343
 			'meta_key'   => self::STATE_META_KEY,
344 344
 			'meta_value' => self::STATE_SUBMIT,
345 345
 			'orderby'    => 'ID',
346 346
 			'post_type'  => 'any',
347
-		) );
347
+		));
348 348
 
349 349
 		// Bail out if there are no submitted posts.
350
-		if ( empty( $posts ) ) {
351
-			$this->log->debug( 'No posts to submit found, checking for completed requests...' );
350
+		if (empty($posts)) {
351
+			$this->log->debug('No posts to submit found, checking for completed requests...');
352 352
 
353
-			do_action( 'wl_batch_analysis_complete' );
353
+			do_action('wl_batch_analysis_complete');
354 354
 
355 355
 			return;
356 356
 		}
357 357
 
358 358
 		// Send a request for each post.
359
-		foreach ( $posts as $id ) {
360
-			$this->log->debug( "Requesting analysis for post $id..." );
359
+		foreach ($posts as $id) {
360
+			$this->log->debug("Requesting analysis for post $id...");
361 361
 
362 362
 			// Change the state to `REQUEST`.
363
-			$this->set_state( $id, self::STATE_REQUEST );
363
+			$this->set_state($id, self::STATE_REQUEST);
364 364
 
365 365
 			// Send the actual request to the remote service.
366
-			$result = $this->do_request( $id );
366
+			$result = $this->do_request($id);
367 367
 
368
-			$this->log->debug( "Analysis requested for post $id." );
368
+			$this->log->debug("Analysis requested for post $id.");
369 369
 
370 370
 			// Set an error if we received an error.
371
-			if ( is_wp_error( $result ) ) {
372
-				$this->log->error( "Analysis request for post $id returned {$result->get_error_message()}." );
371
+			if (is_wp_error($result)) {
372
+				$this->log->error("Analysis request for post $id returned {$result->get_error_message()}.");
373 373
 
374
-				$this->set_state( $id, self::STATE_ERROR );
374
+				$this->set_state($id, self::STATE_ERROR);
375 375
 			}
376 376
 		}
377 377
 
378 378
 		// Call the `wl_batch_analysis_request` action again. This is going
379 379
 		// to be handled by the async task.
380
-		do_action( 'wl_batch_analysis_request' );
380
+		do_action('wl_batch_analysis_request');
381 381
 
382 382
 	}
383 383
 
@@ -388,51 +388,51 @@  discard block
 block discarded – undo
388 388
 	 */
389 389
 	public function complete() {
390 390
 
391
-		$this->log->debug( 'Requesting results...' );
391
+		$this->log->debug('Requesting results...');
392 392
 
393 393
 		// By default 5 posts of any post type are returned.
394
-		$posts = get_posts( array(
394
+		$posts = get_posts(array(
395 395
 			'fields'     => 'ids',
396 396
 			'meta_key'   => self::STATE_META_KEY,
397 397
 			'meta_value' => self::STATE_REQUEST,
398 398
 			'orderby'    => 'ID',
399 399
 			'post_type'  => 'any',
400
-		) );
400
+		));
401 401
 
402 402
 		// Bail out if there are no submitted posts.
403
-		if ( empty( $posts ) ) {
404
-			$this->log->debug( 'No posts in request state found.' );
403
+		if (empty($posts)) {
404
+			$this->log->debug('No posts in request state found.');
405 405
 
406 406
 			return;
407 407
 		}
408 408
 
409 409
 		// Send a request for each post.
410
-		foreach ( $posts as $id ) {
411
-			$this->log->debug( "Requesting results for post $id..." );
410
+		foreach ($posts as $id) {
411
+			$this->log->debug("Requesting results for post $id...");
412 412
 
413 413
 			// Send the actual request to the remote service.
414
-			$response = $this->do_complete( $id );
414
+			$response = $this->do_complete($id);
415 415
 
416
-			$this->log->debug( "Results requested for post $id." );
416
+			$this->log->debug("Results requested for post $id.");
417 417
 
418 418
 			// Set an error if we received an error.
419
-			if ( ! is_wp_error( $response ) && isset( $response['body'] ) ) {
419
+			if ( ! is_wp_error($response) && isset($response['body'])) {
420 420
 
421
-				$this->log->debug( "Results received for post $id." );
421
+				$this->log->debug("Results received for post $id.");
422 422
 
423 423
 				// Save the returned content as new revision.
424
-				$json = json_decode( $response['body'] );
424
+				$json = json_decode($response['body']);
425 425
 
426 426
 				// Continue if the content isn't set.
427
-				if ( ! isset( $json->content ) || empty( $json->content ) ) {
427
+				if ( ! isset($json->content) || empty($json->content)) {
428 428
 					// The post content is empty, so is should be marked as completed.
429
-					$this->set_state( $id, self::STATE_ERROR );
429
+					$this->set_state($id, self::STATE_ERROR);
430 430
 					continue;
431 431
 				}
432 432
 
433
-				$content = $this->set_warning_based_on_content( $json->content, $id );
433
+				$content = $this->set_warning_based_on_content($json->content, $id);
434 434
 
435
-				$content = wp_slash( $content );
435
+				$content = wp_slash($content);
436 436
 
437 437
 				// Post array with the new anotated content.
438 438
 				$data = array(
@@ -447,18 +447,18 @@  discard block
 block discarded – undo
447 447
 				 * @api arr $data Postarr with post id and the new post content.
448 448
 				 * @api int $id Current post ID.
449 449
 				 */
450
-				$data = apply_filters( 'wl_batch_analysis_update_post_content', $data, $id );
450
+				$data = apply_filters('wl_batch_analysis_update_post_content', $data, $id);
451 451
 
452 452
 				// Update the post content.
453
-				wp_update_post( $data );
453
+				wp_update_post($data);
454 454
 
455 455
 				// Update the status.
456
-				$this->set_state( $id, self::STATE_SUCCESS );
456
+				$this->set_state($id, self::STATE_SUCCESS);
457 457
 
458
-				$this->log->debug( "Post $id updated with batch analysis results." );
458
+				$this->log->debug("Post $id updated with batch analysis results.");
459 459
 
460 460
 				// Set default entity type term for posts that didn't have any.
461
-				$this->maybe_set_default_term( $id );
461
+				$this->maybe_set_default_term($id);
462 462
 
463 463
 				continue;
464 464
 			}
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 		// Call the `wl_batch_analysis_request` action again. This is going
471 471
 		// to be handled by the async task.
472
-		do_action( 'wl_batch_analysis_complete' );
472
+		do_action('wl_batch_analysis_complete');
473 473
 
474 474
 	}
475 475
 
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return string The content (for chaining operations).
486 486
 	 */
487
-	private function set_warning_based_on_content( $content, $post_id ) {
487
+	private function set_warning_based_on_content($content, $post_id) {
488 488
 
489 489
 		$matches = array();
490 490
 
491 491
 		// Check for suspicious interpolations.
492
-		$warning = 0 < preg_match_all( '/\w<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">/', $content, $matches )
493
-				   || 0 < preg_match_all( '/<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">\s/', $content, $matches );
492
+		$warning = 0 < preg_match_all('/\w<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">/', $content, $matches)
493
+				   || 0 < preg_match_all('/<[a-z]+ id="urn:enhancement-[^"]+" class="[^"]+" itemid="[^"]+">\s/', $content, $matches);
494 494
 
495 495
 		// Set the warning flag accordingly.
496
-		$this->set_warning( $post_id, $warning );
496
+		$this->set_warning($post_id, $warning);
497 497
 
498 498
 		/**
499 499
 		 * Filter: 'wl_set_post_content_warning' - Allow third parties to hook and modify the post content that has errors after the analysis
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		 * @api string $content Postarr with post id and the new post content.
503 503
 		 * @api int    $id      Post ID.
504 504
 		 */
505
-		return apply_filters( 'wl_set_post_content_warning', $content, $post_id );
505
+		return apply_filters('wl_set_post_content_warning', $content, $post_id);
506 506
 	}
507 507
 
508 508
 	/**
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @return string Post content without interpolations.
517 517
 	 */
518
-	public function fix_interpolation_errors( $content, $id ) {
518
+	public function fix_interpolation_errors($content, $id) {
519 519
 
520
-		$this->log->debug( "Begin fixing post $id interpolations" );
520
+		$this->log->debug("Begin fixing post $id interpolations");
521 521
 
522 522
 		// Remove all interpolations from the content.
523
-		return preg_replace( self::INTERPOLATION_PATTERN, '$1', $content );
523
+		return preg_replace(self::INTERPOLATION_PATTERN, '$1', $content);
524 524
 	}
525 525
 
526 526
 	/**
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
 	 * @param int|array $post_ids A single {@link WP_Post}'s id or an array of
532 532
 	 *                            {@link WP_Post}s' ids.
533 533
 	 */
534
-	public function clear_warning( $post_ids ) {
534
+	public function clear_warning($post_ids) {
535 535
 
536
-		foreach ( (array) $post_ids as $post_id ) {
537
-			delete_post_meta( $post_id, self::WARNING_META_KEY );
536
+		foreach ((array) $post_ids as $post_id) {
537
+			delete_post_meta($post_id, self::WARNING_META_KEY);
538 538
 		}
539 539
 
540 540
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
551 551
 	 *                  false on failure.
552 552
 	 */
553
-	private function set_warning( $post_id, $value ) {
553
+	private function set_warning($post_id, $value) {
554 554
 
555
-		return update_post_meta( $post_id, self::WARNING_META_KEY, ( true === $value ? 'yes' : 'no' ) );
555
+		return update_post_meta($post_id, self::WARNING_META_KEY, (true === $value ? 'yes' : 'no'));
556 556
 	}
557 557
 
558 558
 	/**
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 	 *
565 565
 	 * @return int|string The post state or an empty string if not set.
566 566
 	 */
567
-	public function get_state( $post_id ) {
567
+	public function get_state($post_id) {
568 568
 
569
-		return get_post_meta( $post_id, self::STATE_META_KEY, true );
569
+		return get_post_meta($post_id, self::STATE_META_KEY, true);
570 570
 	}
571 571
 
572 572
 	/**
@@ -580,23 +580,23 @@  discard block
 block discarded – undo
580 580
 	 * @return int|bool Meta ID if the key didn't exist, true on successful update,
581 581
 	 *                  false on failure.
582 582
 	 */
583
-	public function set_state( $post_id, $value ) {
583
+	public function set_state($post_id, $value) {
584 584
 
585 585
 		// Update the state.
586
-		$result = update_post_meta( $post_id, self::STATE_META_KEY, $value );
586
+		$result = update_post_meta($post_id, self::STATE_META_KEY, $value);
587 587
 
588 588
 		// Update timestamps as required.
589
-		switch ( $value ) {
589
+		switch ($value) {
590 590
 
591 591
 			// ### REQUEST state.
592 592
 			case self::STATE_REQUEST:
593
-				add_post_meta( $post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
593
+				add_post_meta($post_id, self::REQUEST_TIMESTAMP_META_KEY, current_time('mysql', true));
594 594
 				break;
595 595
 
596 596
 			// ### SUCCESS/ERROR state.
597 597
 			case self::STATE_SUCCESS:
598 598
 			case self::STATE_ERROR:
599
-				add_post_meta( $post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time( 'mysql', true ) );
599
+				add_post_meta($post_id, self::COMPLETE_TIMESTAMP_META_KEY, current_time('mysql', true));
600 600
 				break;
601 601
 		}
602 602
 
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @return array The link settings.
617 617
 	 */
618
-	public function get_post_link_options( $post_id ) {
618
+	public function get_post_link_options($post_id) {
619 619
 
620
-		$values = get_post_meta( $post_id, self::LINK_META_KEY );
620
+		$values = get_post_meta($post_id, self::LINK_META_KEY);
621 621
 
622
-		return end( $values ) ?: array( 'links' => 'default', 'minOccurrences' => 1 );
622
+		return end($values) ?: array('links' => 'default', 'minOccurrences' => 1);
623 623
 	}
624 624
 
625 625
 	/**
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 	 */
632 632
 	public function waiting_for_analysis() {
633 633
 
634
-		return get_posts( array(
635
-			'posts_per_page' => - 1,
634
+		return get_posts(array(
635
+			'posts_per_page' => -1,
636 636
 			'fields'         => 'ids',
637 637
 			'post_status'    => 'any',
638 638
 			'meta_key'       => self::STATE_META_KEY,
639 639
 			'meta_value'     => self::STATE_SUBMIT,
640 640
 			'orderby'        => 'ID',
641 641
 			'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
642
-		) );
642
+		));
643 643
 	}
644 644
 
645 645
 	/**
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 */
653 653
 	public function waiting_for_response() {
654 654
 
655
-		return get_posts( array(
656
-			'posts_per_page' => - 1,
655
+		return get_posts(array(
656
+			'posts_per_page' => -1,
657 657
 			'fields'         => 'ids',
658 658
 			'post_status'    => 'any',
659 659
 			'meta_key'       => self::STATE_META_KEY,
660 660
 			'meta_value'     => self::STATE_REQUEST,
661 661
 			'orderby'        => 'ID',
662 662
 			'post_type'      => 'any', // Add any because posts from multiple posts types may be waiting.
663
-		) );
663
+		));
664 664
 	}
665 665
 
666 666
 	/**
@@ -672,22 +672,22 @@  discard block
 block discarded – undo
672 672
 	 *
673 673
 	 * @return WP_Error|array The response or WP_Error on failure.
674 674
 	 */
675
-	private function do_request( $post_id ) {
675
+	private function do_request($post_id) {
676 676
 
677 677
 		// Get the post.
678
-		$post = get_post( $post_id );
678
+		$post = get_post($post_id);
679 679
 
680 680
 		// Bail out if the post isn't found.
681
-		if ( null === $post ) {
682
-			$this->log->warn( "Post $post_id not found." );
681
+		if (null === $post) {
682
+			$this->log->warn("Post $post_id not found.");
683 683
 
684
-			return new WP_Error( 0, "Cannot find post $post_id." );
684
+			return new WP_Error(0, "Cannot find post $post_id.");
685 685
 		}
686 686
 
687 687
 		// Get the link setting.
688
-		$link_options = $this->get_post_link_options( $post_id );
688
+		$link_options = $this->get_post_link_options($post_id);
689 689
 
690
-		$this->log->debug( 'Sending analysis request for post $post_id [ link :: ' . $link_options['links'] . ', minOccurrences :: ' . $link_options['minOccurrences'] . ' ] ...' );
690
+		$this->log->debug('Sending analysis request for post $post_id [ link :: '.$link_options['links'].', minOccurrences :: '.$link_options['minOccurrences'].' ] ...');
691 691
 
692 692
 		// Get the batch analysis URL.
693 693
 		$url = $this->configuration_service->get_batch_analysis_url();
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		);
707 707
 
708 708
 		// Get the HTTP options.
709
-		$args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array(
709
+		$args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array(
710 710
 			'method'      => 'POST',
711 711
 			'headers'     => array(
712 712
 				'Accept'       => 'application/json',
@@ -714,13 +714,13 @@  discard block
 block discarded – undo
714 714
 			),
715 715
 			// we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response.
716 716
 			'httpversion' => '1.0',
717
-			'body'        => wp_json_encode( $param ),
718
-		) );
717
+			'body'        => wp_json_encode($param),
718
+		));
719 719
 
720
-		$this->log->debug( "Posting analysis request for post $post_id to $url..." );
720
+		$this->log->debug("Posting analysis request for post $post_id to $url...");
721 721
 
722 722
 		// Post the parameter.
723
-		return wp_remote_post( $url, $args );
723
+		return wp_remote_post($url, $args);
724 724
 	}
725 725
 
726 726
 	/**
@@ -732,20 +732,20 @@  discard block
 block discarded – undo
732 732
 	 *
733 733
 	 * @return WP_Error|array The response or WP_Error on failure.
734 734
 	 */
735
-	private function do_complete( $post_id ) {
735
+	private function do_complete($post_id) {
736 736
 
737
-		$post = get_post( $post_id );
737
+		$post = get_post($post_id);
738 738
 
739
-		if ( null === $post ) {
739
+		if (null === $post) {
740 740
 			// Post was possibly deleted, just bailout.
741
-			return new WP_Error( 0, "Post $post_id not found." );
741
+			return new WP_Error(0, "Post $post_id not found.");
742 742
 		}
743 743
 
744 744
 		$url = $this->configuration_service->get_batch_analysis_url();
745 745
 		$key = $this->configuration_service->get_key();
746
-		$url = $url . '/' . $post->ID . '?key=' . $key;
746
+		$url = $url.'/'.$post->ID.'?key='.$key;
747 747
 
748
-		return wp_remote_get( $url, unserialize( WL_REDLINK_API_HTTP_OPTIONS ) );
748
+		return wp_remote_get($url, unserialize(WL_REDLINK_API_HTTP_OPTIONS));
749 749
 	}
750 750
 
751 751
 	/**
@@ -757,14 +757,14 @@  discard block
 block discarded – undo
757 757
 	 */
758 758
 	public function get_warnings() {
759 759
 
760
-		return get_posts( array(
760
+		return get_posts(array(
761 761
 			'fields'      => 'ids',
762
-			'numberposts' => - 1,
762
+			'numberposts' => -1,
763 763
 			'post_status' => 'any',
764 764
 			'meta_key'    => self::WARNING_META_KEY,
765 765
 			'meta_value'  => 'yes',
766 766
 			'post_type'   => 'any', // Add any because posts from multiple posts types may be waiting.
767
-		) );
767
+		));
768 768
 	}
769 769
 
770 770
 	/**
@@ -774,18 +774,18 @@  discard block
 block discarded – undo
774 774
 	 *
775 775
 	 * @since 3.17.0
776 776
 	 */
777
-	public function set_params( $request ) {
777
+	public function set_params($request) {
778 778
 		// Build params array and check if param exists.
779 779
 		// @codingStandardsIgnoreStart, Ignore phpcs indentation errors.
780 780
 		$params = array(
781
-			'link'              => ( isset( $request['link'] ) )                ? $request['link']              : null,
782
-			'include_annotated' => ( isset( $request['include_annotated'] ) )   ? $request['include_annotated'] : null,
783
-			'include'           => ( isset( $request['include'] ) )             ? (array) $request['include']   : null,
784
-			'exclude'           => ( isset( $request['exclude'] ) )             ? (array) $request['exclude']   : null,
785
-			'from'              => ( isset( $request['from'] ) )                ? $request['from']              : null,
786
-			'to'                => ( isset( $request['to'] ) )                  ? $request['to']                : null,
787
-			'minOccurrences'    => ( isset( $request['min_occurrences'] ) )     ? $request['min_occurrences']   : 1,
788
-			'post_type'         => ( isset( $request['post_type'] ) )           ? $request['post_type']         : 'post',
781
+			'link'              => (isset($request['link'])) ? $request['link'] : null,
782
+			'include_annotated' => (isset($request['include_annotated'])) ? $request['include_annotated'] : null,
783
+			'include'           => (isset($request['include'])) ? (array) $request['include'] : null,
784
+			'exclude'           => (isset($request['exclude'])) ? (array) $request['exclude'] : null,
785
+			'from'              => (isset($request['from'])) ? $request['from'] : null,
786
+			'to'                => (isset($request['to'])) ? $request['to'] : null,
787
+			'minOccurrences'    => (isset($request['min_occurrences'])) ? $request['min_occurrences'] : 1,
788
+			'post_type'         => (isset($request['post_type'])) ? $request['post_type'] : 'post',
789 789
 		);
790 790
 		// @codingStandardsIgnoreEnd
791 791
 
@@ -802,13 +802,13 @@  discard block
 block discarded – undo
802 802
 	 *
803 803
 	 * @return string The start `post_date_gmt` clause
804 804
 	 */
805
-	public static function and_post_date_from( $from ) {
805
+	public static function and_post_date_from($from) {
806 806
 		// Bail if the param is not set.
807
-		if ( null === $from ) {
807
+		if (null === $from) {
808 808
 			return;
809 809
 		}
810 810
 
811
-		return " AND p.post_date_gmt > '" . $from . "'";
811
+		return " AND p.post_date_gmt > '".$from."'";
812 812
 	}
813 813
 
814 814
 	/**
@@ -820,13 +820,13 @@  discard block
 block discarded – undo
820 820
 	 *
821 821
 	 * @return string The end `post_date_gmt` clause.
822 822
 	 */
823
-	public static function and_post_date_to( $to ) {
823
+	public static function and_post_date_to($to) {
824 824
 		// Bail if the param is not set.
825
-		if ( null === $to ) {
825
+		if (null === $to) {
826 826
 			return;
827 827
 		}
828 828
 
829
-		return " AND p.post_date_gmt < '" . $to . "'";
829
+		return " AND p.post_date_gmt < '".$to."'";
830 830
 	}
831 831
 
832 832
 	/**
@@ -838,13 +838,13 @@  discard block
 block discarded – undo
838 838
 	 *
839 839
 	 * @return string The posts IN clause.
840 840
 	 */
841
-	public static function include_posts( $include ) {
841
+	public static function include_posts($include) {
842 842
 		// Bail if the param is not set.
843
-		if ( null === $include ) {
843
+		if (null === $include) {
844 844
 			return;
845 845
 		}
846 846
 
847
-		return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( $include ) ) . ' )';
847
+		return ' AND p.ID IN ( '.implode(',', wp_parse_id_list($include)).' )';
848 848
 	}
849 849
 
850 850
 	/**
@@ -856,13 +856,13 @@  discard block
 block discarded – undo
856 856
 	 *
857 857
 	 * @return string The posts NOT IN clause.
858 858
 	 */
859
-	public static function exclude_posts( $exclude ) {
859
+	public static function exclude_posts($exclude) {
860 860
 		// Bail if the param is not set.
861
-		if ( null === $exclude ) {
861
+		if (null === $exclude) {
862 862
 			return;
863 863
 		}
864 864
 
865
-		return ' AND p.ID NOT IN ( ' . implode( ',', wp_parse_id_list( $exclude ) ) . ' )';
865
+		return ' AND p.ID NOT IN ( '.implode(',', wp_parse_id_list($exclude)).' )';
866 866
 	}
867 867
 
868 868
 	/**
@@ -874,10 +874,10 @@  discard block
 block discarded – undo
874 874
 	 *
875 875
 	 * @return string The autoselect clause.
876 876
 	 */
877
-	public static function include_annotated( $include ) {
877
+	public static function include_annotated($include) {
878 878
 		// Bail if the param is not set or if it's set to `no`.
879 879
 		if (
880
-			! empty( $include ) &&
880
+			! empty($include) &&
881 881
 			'yes' === $include
882 882
 		) {
883 883
 			return;
@@ -896,17 +896,17 @@  discard block
 block discarded – undo
896 896
 	 *
897 897
 	 * @param int $id The post id.
898 898
 	 */
899
-	public function maybe_set_default_term( $id ) {
899
+	public function maybe_set_default_term($id) {
900 900
 		// Check whether the post has any of the WordLift entity types.
901
-		$has_term = has_term( '', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id );
901
+		$has_term = has_term('', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, $id);
902 902
 
903 903
 		// Bail if the term is associated with entity types already.
904
-		if ( ! empty( $has_term ) ) {
904
+		if ( ! empty($has_term)) {
905 905
 			return;
906 906
 		}
907 907
 
908 908
 		// Set the default `article` term.
909
-		$response = wp_set_object_terms( $id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
909
+		$response = wp_set_object_terms($id, 'article', Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
910 910
 	}
911 911
 
912 912
 	/**
@@ -918,13 +918,13 @@  discard block
 block discarded – undo
918 918
 	 *
919 919
 	 * @return array An array of link options.
920 920
 	 */
921
-	public function get_link_options( $link, $min_occurrences ) {
921
+	public function get_link_options($link, $min_occurrences) {
922 922
 		$link_options = array(
923 923
 			'links'          => $link, // Link options.
924 924
 			'minOccurrences' => $min_occurrences, // Minimum occurrences
925 925
 		);
926 926
 
927
-		return serialize( $link_options );
927
+		return serialize($link_options);
928 928
 	}
929 929
 
930 930
 	/**
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-setup.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	<!-- Defining responsive ambient. -->
13 13
 	<meta name="viewport" content="width=device-width, initial-scale=1">
14 14
 
15
-	<title><?php esc_html_e( 'WordLift Setup', 'wordlift' ); ?></title>
15
+	<title><?php esc_html_e('WordLift Setup', 'wordlift'); ?></title>
16 16
 
17 17
 	<?php
18 18
 
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
 	wp_enqueue_media();
21 21
 
22 22
 	// Enqueue styles and scripts.
23
-	wp_enqueue_style( 'wl-font-awesome', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'css/font-awesome.min.css' );
24
-	wp_enqueue_style( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-admin-setup.css', array(
23
+	wp_enqueue_style('wl-font-awesome', plugin_dir_url(dirname(dirname(__FILE__))).'css/font-awesome.min.css');
24
+	wp_enqueue_style('wordlift-admin-setup', plugin_dir_url(dirname(__FILE__)).'css/wordlift-admin-setup.css', array(
25 25
 		'wp-admin',
26 26
 		'wl-font-awesome',
27
-	) );
28
-	wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'js/wordlift-admin-setup.js', array( 'jquery' ) );
27
+	));
28
+	wp_enqueue_script('wordlift-admin-setup', plugin_dir_url(dirname(__FILE__)).'js/wordlift-admin-setup.js', array('jquery'));
29 29
 
30 30
 	//Get wp_permalink structure
31
-	$permalink_structure = get_option( 'permalink_structure' );
31
+	$permalink_structure = get_option('permalink_structure');
32 32
 	
33 33
 	// Set configuration settings.
34
-	wp_localize_script( 'wordlift-admin-setup', '_wlAdminSetup', array(
35
-		'ajaxUrl'   => parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ),
34
+	wp_localize_script('wordlift-admin-setup', '_wlAdminSetup', array(
35
+		'ajaxUrl'   => parse_url(self_admin_url('admin-ajax.php'), PHP_URL_PATH),
36 36
 		'action'    => 'wl_validate_key',
37 37
 		'permalink' => $permalink_structure,
38 38
 		'media'     => array(
39
-			'title'  => __( 'WordLift Choose Logo', 'wordlift' ),
40
-			'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
39
+			'title'  => __('WordLift Choose Logo', 'wordlift'),
40
+			'button' => array('text' => __('Choose Logo', 'wordlift')),
41 41
 		),
42
-	) );
42
+	));
43 43
 
44 44
 	// Finally print styles and scripts.
45 45
 	wp_print_styles();
@@ -51,56 +51,56 @@  discard block
 block discarded – undo
51 51
 
52 52
 	<!-- Pane 1 content -->
53 53
 	<script type="text/html" id="page-0">
54
-		<h2 class="page-title"><?php esc_html_e( 'Welcome', 'wordlift' ); ?></h2>
54
+		<h2 class="page-title"><?php esc_html_e('Welcome', 'wordlift'); ?></h2>
55 55
 		<p class="page-txt">
56
-			<?php esc_html_e( 'Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift' ); ?>
56
+			<?php esc_html_e('Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift'); ?>
57 57
 		</p>
58 58
 		<ul class="page-list">
59 59
 			<li>
60 60
 				<span class="fa fa-university"></span>
61
-				<?php esc_html_e( 'Trustworthiness', 'wordlift' ); ?>
61
+				<?php esc_html_e('Trustworthiness', 'wordlift'); ?>
62 62
 			</li>
63 63
 
64 64
 			<li>
65 65
 				<span class="fa fa-map-marker"></span>
66
-				<?php esc_html_e( 'Enrichment', 'wordlift' ); ?>
66
+				<?php esc_html_e('Enrichment', 'wordlift'); ?>
67 67
 			</li>
68 68
 
69 69
 			<li>
70 70
 				<span class="fa fa-heart"></span>
71
-				<?php esc_html_e( 'Engagement', 'wordlift' ); ?>
71
+				<?php esc_html_e('Engagement', 'wordlift'); ?>
72 72
 			</li>
73 73
 
74 74
 			<li>
75 75
 				<span class="fa fa-hand-o-right"></span>
76
-				<?php esc_html_e( 'Smart Navigation', 'wordlift' ); ?>
76
+				<?php esc_html_e('Smart Navigation', 'wordlift'); ?>
77 77
 			</li>
78 78
 
79 79
 			<li>
80 80
 				<span class="fa fa-google"></span>
81
-				<?php esc_html_e( 'SEO Optimization', 'wordlift' ); ?>
81
+				<?php esc_html_e('SEO Optimization', 'wordlift'); ?>
82 82
 			</li>
83 83
 
84 84
 			<li>
85 85
 				<span class="fa fa-group"></span>
86
-				<?php esc_html_e( 'Content Marketing', 'wordlift' ); ?>
86
+				<?php esc_html_e('Content Marketing', 'wordlift'); ?>
87 87
 			</li>
88 88
 		</ul>
89 89
 		<div class="btn-wrapper">
90 90
 			<a href="https://wordlift.io/blogger/?utm_campaign=wl_activation_learn_more"
91 91
 			   target="_tab"
92
-			   class="button"><?php esc_html_e( 'Learn More', 'wordlift' ); ?></a>
92
+			   class="button"><?php esc_html_e('Learn More', 'wordlift'); ?></a>
93 93
 			<input type="button" data-wl-next="wl-next"
94 94
 			       class="wl-default-action"
95
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
95
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
96 96
 		</div>
97 97
 	</script>
98 98
 
99 99
 	<!-- Pane 2 content -->
100 100
 	<script type="text/html" id="page-1">
101
-		<h2 class="page-title"><?php esc_html_e( 'License Key', 'wordlift' ); ?></h2>
101
+		<h2 class="page-title"><?php esc_html_e('License Key', 'wordlift'); ?></h2>
102 102
 		<p class="page-txt">
103
-			<?php esc_html_e( 'If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift' ); ?>
103
+			<?php esc_html_e('If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift'); ?>
104 104
 		</p>
105 105
 		<input type="text" data-wl-key="wl-key" class="invalid untouched"
106 106
 		       id="key" name="key" value=""
@@ -109,40 +109,40 @@  discard block
 block discarded – undo
109 109
 			<a id="btn-grab-a-key"
110 110
 				href="https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key"
111 111
 				target="_tab"
112
-				class="button wl-default-action"><?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?></a><input
112
+				class="button wl-default-action"><?php esc_html_e('Grab a Key!', 'wordlift'); ?></a><input
113 113
 				id="btn-license-key-next"
114 114
 				type="button" data-wl-next="wl-next" class="button"
115
-				value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
115
+				value="<?php esc_attr_e('Next', 'wordlift'); ?>">
116 116
 		</div>
117 117
 	</script>
118 118
 
119 119
 	<!-- Pane 3 content -->
120 120
 	<script type="text/html" id="page-2">
121
-		<h2 class="page-title"><?php esc_html_e( 'Vocabulary', 'wordlift' ); ?></h2>
121
+		<h2 class="page-title"><?php esc_html_e('Vocabulary', 'wordlift'); ?></h2>
122 122
 		<p class="page-txt">
123
-			<?php esc_html_e( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift' ); ?>
123
+			<?php esc_html_e('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift'); ?>
124 124
 		</p>
125 125
 		<input type="text" id="vocabulary" name="vocabulary" autocomplete="off"
126 126
 		       value="vocabulary"
127 127
 		       class="valid untouched" data-wl-vocabulary="wl-vocabulary">
128 128
 		<p class="page-det">
129
-			<?php esc_html_e( 'Leave it empty to place your entities in the root folder of your website', 'wordlift' ); ?>
129
+			<?php esc_html_e('Leave it empty to place your entities in the root folder of your website', 'wordlift'); ?>
130 130
 		</p>
131 131
 		<div class="btn-wrapper">
132 132
 			<input type="button" data-wl-next="wl-next"
133 133
 			       class="wl-default-action"
134
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
134
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
135 135
 		</div>
136 136
 	</script>
137 137
 
138 138
 	<!-- Pane 4 content -->
139 139
 	<script type="text/html" id="page-3">
140
-		<h2 class="page-title"><?php esc_html_e( 'Language', 'wordlift' ); ?></h2>
140
+		<h2 class="page-title"><?php esc_html_e('Language', 'wordlift'); ?></h2>
141 141
 		<p class="page-txt">
142
-			<?php esc_html_e( 'Each WordLift key can be used only in one language. Pick yours.', 'wordlift' ); ?>
142
+			<?php esc_html_e('Each WordLift key can be used only in one language. Pick yours.', 'wordlift'); ?>
143 143
 		</p>
144 144
 		<select id="language" name="language"
145
-		        placeholder="<?php esc_attr_e( 'Choose your language', 'wordlift' ); ?>">
145
+		        placeholder="<?php esc_attr_e('Choose your language', 'wordlift'); ?>">
146 146
 			<?php
147 147
 
148 148
 			// Get WordLift's supported languages.
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 			$locale = get_locale();
153 153
 
154 154
 			// Get the language locale part.
155
-			$parts = explode( '_', $locale );
155
+			$parts = explode('_', $locale);
156 156
 
157 157
 			// If we support WP's configured language, then use that, otherwise use English by default.
158
-			$language = isset( $languages[ $parts[0] ] ) ? $parts[0] : 'en';
158
+			$language = isset($languages[$parts[0]]) ? $parts[0] : 'en';
159 159
 
160 160
 			// Print all the supported language, preselecting the one configured in WP (or English if not supported).
161
-			foreach ( $languages as $code => $label ) { ?>
161
+			foreach ($languages as $code => $label) { ?>
162 162
 				<option
163
-					value="<?php echo esc_attr( $code ) ?>" <?php echo selected( $code, $language, false ) ?>><?php echo esc_html( $label ) ?></option>
163
+					value="<?php echo esc_attr($code) ?>" <?php echo selected($code, $language, false) ?>><?php echo esc_html($label) ?></option>
164 164
 			<?php } ?>
165 165
 		</select>
166 166
 
167 167
 		<div class="btn-wrapper">
168 168
 			<input type="button" data-wl-next="wl-next"
169 169
 			       class="wl-default-action"
170
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
170
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
171 171
 		</div>
172 172
 	</script>
173 173
 
174 174
 	<!-- Pane 5 content -->
175 175
 	<script type="text/html" id="page-4">
176
-		<h2 class="page-title"><?php esc_html_e( 'Publisher', 'wordlift' ); ?></h2>
176
+		<h2 class="page-title"><?php esc_html_e('Publisher', 'wordlift'); ?></h2>
177 177
 		<p class="page-txt">
178
-			<?php esc_html_e( 'Are you going to publish as an individual or as a company?', 'wordlift' ); ?>
178
+			<?php esc_html_e('Are you going to publish as an individual or as a company?', 'wordlift'); ?>
179 179
 		</p>
180 180
 		<div class="radio-wrapper">
181 181
 			<label for="personal">
@@ -183,20 +183,20 @@  discard block
 block discarded – undo
183 183
 				       value="person" checked>
184 184
 				<span class="radio"><span class="check"></span></span>
185 185
 				<span
186
-					class="label"><?php esc_html_e( 'Personal', 'wordlift' ); ?></span>
186
+					class="label"><?php esc_html_e('Personal', 'wordlift'); ?></span>
187 187
 			</label>
188 188
 			<label for="company">
189 189
 				<input id="company" type="radio" name="user_type"
190 190
 				       value="organization">
191 191
 				<span class="radio"><span class="check"></span></span>
192 192
 				<span
193
-					class="label"><?php esc_html_e( 'Company', 'wordlift' ); ?></span>
193
+					class="label"><?php esc_html_e('Company', 'wordlift'); ?></span>
194 194
 			</label>
195 195
 		</div>
196 196
 		<input type="text" id="name" name="name" data-wl-name="wl-name" value=""
197 197
 		       autocomplete="off"
198 198
 		       class="untouched invalid"
199
-		       placeholder="<?php esc_attr_e( "What's your name?", 'wordlift' ); ?>">
199
+		       placeholder="<?php esc_attr_e("What's your name?", 'wordlift'); ?>">
200 200
 
201 201
 		<div data-wl-logo="wl-logo">
202 202
 			<input type="hidden" name="logo" />
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			</div>
207 207
 			<a data-wl-add-logo="wl-add-logo" class="add-logo"
208 208
 			   href="javascript:void(0);">
209
-				<?php esc_html_e( 'Add your logo', 'wordlift' ); ?>
209
+				<?php esc_html_e('Add your logo', 'wordlift'); ?>
210 210
 			</a>
211 211
 		</div>
212 212
 		<div class="btn-wrapper">
213 213
 			<input type="submit" id="btn-finish" class="wl-default-action"
214
-			       value="<?php esc_attr_e( 'Finish', 'wordlift' ); ?>">
214
+			       value="<?php esc_attr_e('Finish', 'wordlift'); ?>">
215 215
 		</div>
216 216
 	</script>
217 217
 
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 
221 221
 <div class="wl-container">
222 222
 
223
-	<a href="<?php echo esc_url( admin_url() ); ?> "
223
+	<a href="<?php echo esc_url(admin_url()); ?> "
224 224
 	   class="fa fa-times wl-close"></a>
225 225
 
226 226
 	<header>
227
-		<h1><img class="wizard-logo" src="<?php echo plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/logo-wl-transparent-240x90.png'; ?>" /></h1>
228
-		<img class="shapes" src="<?php echo plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/shapes.png'; ?>" />
227
+		<h1><img class="wizard-logo" src="<?php echo plugin_dir_url(dirname(dirname(__FILE__))).'images/logo-wl-transparent-240x90.png'; ?>" /></h1>
228
+		<img class="shapes" src="<?php echo plugin_dir_url(dirname(dirname(__FILE__))).'images/shapes.png'; ?>" />
229 229
 	</header>
230 230
 
231 231
 
232 232
 	<form method="post">
233
-		<?php wp_nonce_field( 'wl-save-configuration' ); ?>
233
+		<?php wp_nonce_field('wl-save-configuration'); ?>
234 234
 		<input type="hidden" name="action" value="wl-save-configuration" />
235 235
 		<div class="viewport"></div>
236 236
 	</form>
237 237
 
238 238
 </div>
239 239
 
240
-<?php do_action( 'admin_footer' ); ?>
240
+<?php do_action('admin_footer'); ?>
241 241
 
242 242
 </body>
243 243
 </html>
Please login to merge, or discard this patch.
src/includes/class-wordlift-content-filter-service.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -18,296 +18,296 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Content_Filter_Service {
20 20
 
21
-	/**
22
-	 * The pattern to find entities in text.
23
-	 *
24
-	 * @since 3.8.0
25
-	 */
26
-	const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
-
28
-	/**
29
-	 * A {@link Wordlift_Entity_Service} instance.
30
-	 *
31
-	 * @since  3.8.0
32
-	 * @access private
33
-	 * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
-	 */
35
-	private $entity_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Configuration_Service} instance.
39
-	 *
40
-	 * @since  3.13.0
41
-	 * @access private
42
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
-	 */
44
-	private $configuration_service;
45
-
46
-	/**
47
-	 * The `link by default` setting.
48
-	 *
49
-	 * @since  3.13.0
50
-	 * @access private
51
-	 * @var bool True if link by default is enabled otherwise false.
52
-	 */
53
-	private $is_link_by_default;
54
-
55
-	private $entity_post_ids_linked_from_post_content = array();
56
-
57
-	/**
58
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
59
-	 *
60
-	 * @since  3.16.3
61
-	 * @access private
62
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
63
-	 */
64
-	private $entity_uri_service;
65
-
66
-	/**
67
-	 * A {@link Wordlift_Log_Service} instance.
68
-	 *
69
-	 * @since 3.16.0
70
-	 *
71
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
72
-	 */
73
-	private $log;
74
-
75
-	/**
76
-	 * The {@link Wordlift_Content_Filter_Service} singleton instance.
77
-	 *
78
-	 * @since  3.14.2
79
-	 * @access private
80
-	 * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
81
-	 */
82
-	private static $instance;
83
-
84
-	/**
85
-	 * Create a {@link Wordlift_Content_Filter_Service} instance.
86
-	 *
87
-	 * @since 3.8.0
88
-	 *
89
-	 * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
90
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91
-	 * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92
-	 */
93
-	public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
94
-
95
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
96
-
97
-		$this->entity_service        = $entity_service;
98
-		$this->configuration_service = $configuration_service;
99
-		$this->entity_uri_service    = $entity_uri_service;
100
-
101
-		self::$instance = $this;
102
-
103
-	}
104
-
105
-	/**
106
-	 * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
107
-	 *
108
-	 * @since 3.14.2
109
-	 * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
110
-	 */
111
-	public static function get_instance() {
112
-
113
-		return self::$instance;
114
-	}
115
-
116
-	/**
117
-	 * Mangle the content by adding links to the entity pages. This function is
118
-	 * hooked to the 'the_content' WP's filter.
119
-	 *
120
-	 * @since 3.8.0
121
-	 *
122
-	 * @param string $content The content being filtered.
123
-	 *
124
-	 * @return string The filtered content.
125
-	 */
126
-	public function the_content( $content ) {
127
-
128
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
129
-
130
-		// Links should be added only on the front end and not for RSS.
131
-		if ( is_feed() ) {
132
-			return $content;
133
-		}
134
-
135
-		// Preload the `link by default` setting.
136
-		$this->is_link_by_default = $this->configuration_service->is_link_by_default();
137
-
138
-		// Reset the array of of entity post ids linked from the post content.
139
-		// This is used to avoid linking more the once the same post.
140
-		$this->entity_post_ids_linked_from_post_content = array();
141
-
142
-		// Preload URIs.
143
-		$matches = array();
144
-		preg_match_all( self::PATTERN, $content, $matches );
145
-
146
-		// Bail out if there are no URIs.
147
-		if ( 0 === count( $matches[3] ) ) {
148
-			return $content;
149
-		}
150
-
151
-		// Preload the URIs.
152
-		$this->entity_uri_service->preload_uris( $matches[3] );
153
-
154
-		// Replace each match of the entity tag with the entity link. If an error
155
-		// occurs fail silently returning the original content.
156
-		$result = preg_replace_callback( self::PATTERN, array(
157
-			$this,
158
-			'link',
159
-		), $content ) ?: $content;
160
-
161
-		$this->entity_uri_service->reset_uris();
162
-
163
-		return $result;
164
-	}
165
-
166
-	/**
167
-	 * Get the entity match and replace it with a page link.
168
-	 *
169
-	 * @since 3.8.0
170
-	 *
171
-	 * @param array $matches An array of matches.
172
-	 *
173
-	 * @return string The replaced text with the link to the entity page.
174
-	 */
175
-	private function link( $matches ) {
176
-
177
-		// Get the entity itemid URI and label.
178
-		$css_class = $matches[2];
179
-		$uri       = $matches[3];
180
-		$label     = $matches[4];
181
-
182
-		// Get the entity post by URI.
183
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
184
-
185
-		// @todo: revise the `test-content-filter-service.php` before switching
186
-		// to the `entity_uri_service`. This is required, because the test injects
187
-		// itself as `entity_service` to mock the requests to get a post by
188
-		// entity uri.
189
-		//
190
-		// $post = $this->entity_uri_service->get_entity( $uri );
191
-
192
-		if ( null === $post ) {
193
-
194
-			// If the entity post is not found return the label w/o the markup
195
-			// around it.
196
-			//
197
-			// See https://github.com/insideout10/wordlift-plugin/issues/461.
198
-			return $label;
199
-		}
200
-
201
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
202
-				   // Do not link if already linked.
203
-				   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
-		$link = - 1 < strpos( $css_class, 'wl-link' );
205
-
206
-		// Don't link if links are disabled and the entity is not link or the
207
-		// entity is do not link.
208
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
209
-
210
-		// Return the label if it's don't link.
211
-		if ( $dont_link ) {
212
-			return $label;
213
-		}
214
-
215
-		// Add the entity post id to the array of already linked entities, so that
216
-		// only the first entity occurrence is linked.
217
-		$this->entity_post_ids_linked_from_post_content[] = $post->ID;
218
-
219
-		// Get the link.
220
-		$href = get_permalink( $post );
221
-
222
-		// Get an alternative title attribute.
223
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
224
-
225
-		// Return the link.
226
-		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
227
-	}
228
-
229
-	/**
230
-	 * Get a `title` attribute with an alternative label for the link.
231
-	 *
232
-	 * If an alternative title isn't available an empty string is returned.
233
-	 *
234
-	 * @since 3.15.0
235
-	 *
236
-	 * @param int    $post_id The {@link WP_Post}'s id.
237
-	 * @param string $label   The main link label.
238
-	 *
239
-	 * @return string A `title` attribute with an alternative label or an empty
240
-	 *                string if none available.
241
-	 */
242
-	private function get_title_attribute( $post_id, $label ) {
243
-
244
-		// Get an alternative title.
245
-		$title = $this->get_link_title( $post_id, $label );
246
-		if ( ! empty( $title ) ) {
247
-			return 'title="' . esc_attr( $title ) . '"';
248
-		}
249
-
250
-		return '';
251
-	}
252
-
253
-	/**
254
-	 * Get a string to be used as a title attribute in links to a post
255
-	 *
256
-	 * @since 3.15.0
257
-	 *
258
-	 * @param int    $post_id      The post id of the post being linked.
259
-	 * @param string $ignore_label A label to ignore.
260
-	 *
261
-	 * @return string    The title to be used in the link. An empty string when
262
-	 *                    there is no alternative that is not the $ignore_label.
263
-	 */
264
-	function get_link_title( $post_id, $ignore_label ) {
265
-
266
-		// Get possible alternative labels we can select from.
267
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
268
-
269
-		/*
21
+    /**
22
+     * The pattern to find entities in text.
23
+     *
24
+     * @since 3.8.0
25
+     */
26
+    const PATTERN = '/<(\\w+)[^<]*class="([^"]*)"\\sitemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27
+
28
+    /**
29
+     * A {@link Wordlift_Entity_Service} instance.
30
+     *
31
+     * @since  3.8.0
32
+     * @access private
33
+     * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
+     */
35
+    private $entity_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Configuration_Service} instance.
39
+     *
40
+     * @since  3.13.0
41
+     * @access private
42
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
43
+     */
44
+    private $configuration_service;
45
+
46
+    /**
47
+     * The `link by default` setting.
48
+     *
49
+     * @since  3.13.0
50
+     * @access private
51
+     * @var bool True if link by default is enabled otherwise false.
52
+     */
53
+    private $is_link_by_default;
54
+
55
+    private $entity_post_ids_linked_from_post_content = array();
56
+
57
+    /**
58
+     * The {@link Wordlift_Entity_Uri_Service} instance.
59
+     *
60
+     * @since  3.16.3
61
+     * @access private
62
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
63
+     */
64
+    private $entity_uri_service;
65
+
66
+    /**
67
+     * A {@link Wordlift_Log_Service} instance.
68
+     *
69
+     * @since 3.16.0
70
+     *
71
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
72
+     */
73
+    private $log;
74
+
75
+    /**
76
+     * The {@link Wordlift_Content_Filter_Service} singleton instance.
77
+     *
78
+     * @since  3.14.2
79
+     * @access private
80
+     * @var \Wordlift_Content_Filter_Service $instance The {@link Wordlift_Content_Filter_Service} singleton instance.
81
+     */
82
+    private static $instance;
83
+
84
+    /**
85
+     * Create a {@link Wordlift_Content_Filter_Service} instance.
86
+     *
87
+     * @since 3.8.0
88
+     *
89
+     * @param \Wordlift_Entity_Service        $entity_service        The {@link Wordlift_Entity_Service} instance.
90
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91
+     * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92
+     */
93
+    public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
94
+
95
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
96
+
97
+        $this->entity_service        = $entity_service;
98
+        $this->configuration_service = $configuration_service;
99
+        $this->entity_uri_service    = $entity_uri_service;
100
+
101
+        self::$instance = $this;
102
+
103
+    }
104
+
105
+    /**
106
+     * Get the {@link Wordlift_Content_Filter_Service} singleton instance.
107
+     *
108
+     * @since 3.14.2
109
+     * @return \Wordlift_Content_Filter_Service The {@link Wordlift_Content_Filter_Service} singleton instance.
110
+     */
111
+    public static function get_instance() {
112
+
113
+        return self::$instance;
114
+    }
115
+
116
+    /**
117
+     * Mangle the content by adding links to the entity pages. This function is
118
+     * hooked to the 'the_content' WP's filter.
119
+     *
120
+     * @since 3.8.0
121
+     *
122
+     * @param string $content The content being filtered.
123
+     *
124
+     * @return string The filtered content.
125
+     */
126
+    public function the_content( $content ) {
127
+
128
+        $this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
129
+
130
+        // Links should be added only on the front end and not for RSS.
131
+        if ( is_feed() ) {
132
+            return $content;
133
+        }
134
+
135
+        // Preload the `link by default` setting.
136
+        $this->is_link_by_default = $this->configuration_service->is_link_by_default();
137
+
138
+        // Reset the array of of entity post ids linked from the post content.
139
+        // This is used to avoid linking more the once the same post.
140
+        $this->entity_post_ids_linked_from_post_content = array();
141
+
142
+        // Preload URIs.
143
+        $matches = array();
144
+        preg_match_all( self::PATTERN, $content, $matches );
145
+
146
+        // Bail out if there are no URIs.
147
+        if ( 0 === count( $matches[3] ) ) {
148
+            return $content;
149
+        }
150
+
151
+        // Preload the URIs.
152
+        $this->entity_uri_service->preload_uris( $matches[3] );
153
+
154
+        // Replace each match of the entity tag with the entity link. If an error
155
+        // occurs fail silently returning the original content.
156
+        $result = preg_replace_callback( self::PATTERN, array(
157
+            $this,
158
+            'link',
159
+        ), $content ) ?: $content;
160
+
161
+        $this->entity_uri_service->reset_uris();
162
+
163
+        return $result;
164
+    }
165
+
166
+    /**
167
+     * Get the entity match and replace it with a page link.
168
+     *
169
+     * @since 3.8.0
170
+     *
171
+     * @param array $matches An array of matches.
172
+     *
173
+     * @return string The replaced text with the link to the entity page.
174
+     */
175
+    private function link( $matches ) {
176
+
177
+        // Get the entity itemid URI and label.
178
+        $css_class = $matches[2];
179
+        $uri       = $matches[3];
180
+        $label     = $matches[4];
181
+
182
+        // Get the entity post by URI.
183
+        $post = $this->entity_service->get_entity_post_by_uri( $uri );
184
+
185
+        // @todo: revise the `test-content-filter-service.php` before switching
186
+        // to the `entity_uri_service`. This is required, because the test injects
187
+        // itself as `entity_service` to mock the requests to get a post by
188
+        // entity uri.
189
+        //
190
+        // $post = $this->entity_uri_service->get_entity( $uri );
191
+
192
+        if ( null === $post ) {
193
+
194
+            // If the entity post is not found return the label w/o the markup
195
+            // around it.
196
+            //
197
+            // See https://github.com/insideout10/wordlift-plugin/issues/461.
198
+            return $label;
199
+        }
200
+
201
+        $no_link = - 1 < strpos( $css_class, 'wl-no-link' )
202
+                    // Do not link if already linked.
203
+                   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
+        $link = - 1 < strpos( $css_class, 'wl-link' );
205
+
206
+        // Don't link if links are disabled and the entity is not link or the
207
+        // entity is do not link.
208
+        $dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
209
+
210
+        // Return the label if it's don't link.
211
+        if ( $dont_link ) {
212
+            return $label;
213
+        }
214
+
215
+        // Add the entity post id to the array of already linked entities, so that
216
+        // only the first entity occurrence is linked.
217
+        $this->entity_post_ids_linked_from_post_content[] = $post->ID;
218
+
219
+        // Get the link.
220
+        $href = get_permalink( $post );
221
+
222
+        // Get an alternative title attribute.
223
+        $title_attribute = $this->get_title_attribute( $post->ID, $label );
224
+
225
+        // Return the link.
226
+        return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
227
+    }
228
+
229
+    /**
230
+     * Get a `title` attribute with an alternative label for the link.
231
+     *
232
+     * If an alternative title isn't available an empty string is returned.
233
+     *
234
+     * @since 3.15.0
235
+     *
236
+     * @param int    $post_id The {@link WP_Post}'s id.
237
+     * @param string $label   The main link label.
238
+     *
239
+     * @return string A `title` attribute with an alternative label or an empty
240
+     *                string if none available.
241
+     */
242
+    private function get_title_attribute( $post_id, $label ) {
243
+
244
+        // Get an alternative title.
245
+        $title = $this->get_link_title( $post_id, $label );
246
+        if ( ! empty( $title ) ) {
247
+            return 'title="' . esc_attr( $title ) . '"';
248
+        }
249
+
250
+        return '';
251
+    }
252
+
253
+    /**
254
+     * Get a string to be used as a title attribute in links to a post
255
+     *
256
+     * @since 3.15.0
257
+     *
258
+     * @param int    $post_id      The post id of the post being linked.
259
+     * @param string $ignore_label A label to ignore.
260
+     *
261
+     * @return string    The title to be used in the link. An empty string when
262
+     *                    there is no alternative that is not the $ignore_label.
263
+     */
264
+    function get_link_title( $post_id, $ignore_label ) {
265
+
266
+        // Get possible alternative labels we can select from.
267
+        $labels = $this->entity_service->get_alternative_labels( $post_id );
268
+
269
+        /*
270 270
 		 * Since the original text might use an alternative label than the
271 271
 		 * Entity title, add the title itself which is not returned by the api.
272 272
 		 */
273
-		$labels[] = get_the_title( $post_id );
274
-
275
-		// Add some randomness to the label selection.
276
-		shuffle( $labels );
277
-
278
-		// Select the first label which is not to be ignored.
279
-		$title = '';
280
-		foreach ( $labels as $label ) {
281
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
282
-				$title = $label;
283
-				break;
284
-			}
285
-		}
286
-
287
-		return $title;
288
-	}
289
-
290
-	/**
291
-	 * Get the entity URIs (configured in the `itemid` attribute) contained in
292
-	 * the provided content.
293
-	 *
294
-	 * @since 3.14.2
295
-	 *
296
-	 * @param string $content The content.
297
-	 *
298
-	 * @return array An array of URIs.
299
-	 */
300
-	public function get_entity_uris( $content ) {
301
-
302
-		$matches = array();
303
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
304
-
305
-		// We need to use `array_values` here in order to avoid further `json_encode`
306
-		// to turn it into an object (since if the 3rd match isn't found the index
307
-		// is not sequential.
308
-		//
309
-		// See https://github.com/insideout10/wordlift-plugin/issues/646.
310
-		return array_values( array_unique( $matches[3] ) );
311
-	}
273
+        $labels[] = get_the_title( $post_id );
274
+
275
+        // Add some randomness to the label selection.
276
+        shuffle( $labels );
277
+
278
+        // Select the first label which is not to be ignored.
279
+        $title = '';
280
+        foreach ( $labels as $label ) {
281
+            if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
282
+                $title = $label;
283
+                break;
284
+            }
285
+        }
286
+
287
+        return $title;
288
+    }
289
+
290
+    /**
291
+     * Get the entity URIs (configured in the `itemid` attribute) contained in
292
+     * the provided content.
293
+     *
294
+     * @since 3.14.2
295
+     *
296
+     * @param string $content The content.
297
+     *
298
+     * @return array An array of URIs.
299
+     */
300
+    public function get_entity_uris( $content ) {
301
+
302
+        $matches = array();
303
+        preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
304
+
305
+        // We need to use `array_values` here in order to avoid further `json_encode`
306
+        // to turn it into an object (since if the 3rd match isn't found the index
307
+        // is not sequential.
308
+        //
309
+        // See https://github.com/insideout10/wordlift-plugin/issues/646.
310
+        return array_values( array_unique( $matches[3] ) );
311
+    }
312 312
 
313 313
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
91 91
 	 * @param \Wordlift_Entity_Uri_Service    $entity_uri_service    The {@link Wordlift_Entity_Uri_Service} instance.
92 92
 	 */
93
-	public function __construct( $entity_service, $configuration_service, $entity_uri_service ) {
93
+	public function __construct($entity_service, $configuration_service, $entity_uri_service) {
94 94
 
95
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
95
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
96 96
 
97 97
 		$this->entity_service        = $entity_service;
98 98
 		$this->configuration_service = $configuration_service;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return string The filtered content.
125 125
 	 */
126
-	public function the_content( $content ) {
126
+	public function the_content($content) {
127 127
 
128
-		$this->log->trace( "Filtering content [ " . ( is_singular() ? 'yes' : 'no' ) . " ]..." );
128
+		$this->log->trace("Filtering content [ ".(is_singular() ? 'yes' : 'no')." ]...");
129 129
 
130 130
 		// Links should be added only on the front end and not for RSS.
131
-		if ( is_feed() ) {
131
+		if (is_feed()) {
132 132
 			return $content;
133 133
 		}
134 134
 
@@ -141,22 +141,22 @@  discard block
 block discarded – undo
141 141
 
142 142
 		// Preload URIs.
143 143
 		$matches = array();
144
-		preg_match_all( self::PATTERN, $content, $matches );
144
+		preg_match_all(self::PATTERN, $content, $matches);
145 145
 
146 146
 		// Bail out if there are no URIs.
147
-		if ( 0 === count( $matches[3] ) ) {
147
+		if (0 === count($matches[3])) {
148 148
 			return $content;
149 149
 		}
150 150
 
151 151
 		// Preload the URIs.
152
-		$this->entity_uri_service->preload_uris( $matches[3] );
152
+		$this->entity_uri_service->preload_uris($matches[3]);
153 153
 
154 154
 		// Replace each match of the entity tag with the entity link. If an error
155 155
 		// occurs fail silently returning the original content.
156
-		$result = preg_replace_callback( self::PATTERN, array(
156
+		$result = preg_replace_callback(self::PATTERN, array(
157 157
 			$this,
158 158
 			'link',
159
-		), $content ) ?: $content;
159
+		), $content) ?: $content;
160 160
 
161 161
 		$this->entity_uri_service->reset_uris();
162 162
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string The replaced text with the link to the entity page.
174 174
 	 */
175
-	private function link( $matches ) {
175
+	private function link($matches) {
176 176
 
177 177
 		// Get the entity itemid URI and label.
178 178
 		$css_class = $matches[2];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		$label     = $matches[4];
181 181
 
182 182
 		// Get the entity post by URI.
183
-		$post = $this->entity_service->get_entity_post_by_uri( $uri );
183
+		$post = $this->entity_service->get_entity_post_by_uri($uri);
184 184
 
185 185
 		// @todo: revise the `test-content-filter-service.php` before switching
186 186
 		// to the `entity_uri_service`. This is required, because the test injects
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		//
190 190
 		// $post = $this->entity_uri_service->get_entity( $uri );
191 191
 
192
-		if ( null === $post ) {
192
+		if (null === $post) {
193 193
 
194 194
 			// If the entity post is not found return the label w/o the markup
195 195
 			// around it.
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 			return $label;
199 199
 		}
200 200
 
201
-		$no_link = - 1 < strpos( $css_class, 'wl-no-link' )
201
+		$no_link = - 1 < strpos($css_class, 'wl-no-link')
202 202
 				   // Do not link if already linked.
203
-				   || in_array( $post->ID, $this->entity_post_ids_linked_from_post_content );
204
-		$link = - 1 < strpos( $css_class, 'wl-link' );
203
+				   || in_array($post->ID, $this->entity_post_ids_linked_from_post_content);
204
+		$link = - 1 < strpos($css_class, 'wl-link');
205 205
 
206 206
 		// Don't link if links are disabled and the entity is not link or the
207 207
 		// entity is do not link.
208
-		$dont_link = ( ! $this->is_link_by_default && ! $link ) || $no_link;
208
+		$dont_link = ( ! $this->is_link_by_default && ! $link) || $no_link;
209 209
 
210 210
 		// Return the label if it's don't link.
211
-		if ( $dont_link ) {
211
+		if ($dont_link) {
212 212
 			return $label;
213 213
 		}
214 214
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 		$this->entity_post_ids_linked_from_post_content[] = $post->ID;
218 218
 
219 219
 		// Get the link.
220
-		$href = get_permalink( $post );
220
+		$href = get_permalink($post);
221 221
 
222 222
 		// Get an alternative title attribute.
223
-		$title_attribute = $this->get_title_attribute( $post->ID, $label );
223
+		$title_attribute = $this->get_title_attribute($post->ID, $label);
224 224
 
225 225
 		// Return the link.
226 226
 		return "<a class='wl-entity-page-link' $title_attribute href='$href'>$label</a>";
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 	 * @return string A `title` attribute with an alternative label or an empty
240 240
 	 *                string if none available.
241 241
 	 */
242
-	private function get_title_attribute( $post_id, $label ) {
242
+	private function get_title_attribute($post_id, $label) {
243 243
 
244 244
 		// Get an alternative title.
245
-		$title = $this->get_link_title( $post_id, $label );
246
-		if ( ! empty( $title ) ) {
247
-			return 'title="' . esc_attr( $title ) . '"';
245
+		$title = $this->get_link_title($post_id, $label);
246
+		if ( ! empty($title)) {
247
+			return 'title="'.esc_attr($title).'"';
248 248
 		}
249 249
 
250 250
 		return '';
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 * @return string    The title to be used in the link. An empty string when
262 262
 	 *                    there is no alternative that is not the $ignore_label.
263 263
 	 */
264
-	function get_link_title( $post_id, $ignore_label ) {
264
+	function get_link_title($post_id, $ignore_label) {
265 265
 
266 266
 		// Get possible alternative labels we can select from.
267
-		$labels = $this->entity_service->get_alternative_labels( $post_id );
267
+		$labels = $this->entity_service->get_alternative_labels($post_id);
268 268
 
269 269
 		/*
270 270
 		 * Since the original text might use an alternative label than the
271 271
 		 * Entity title, add the title itself which is not returned by the api.
272 272
 		 */
273
-		$labels[] = get_the_title( $post_id );
273
+		$labels[] = get_the_title($post_id);
274 274
 
275 275
 		// Add some randomness to the label selection.
276
-		shuffle( $labels );
276
+		shuffle($labels);
277 277
 
278 278
 		// Select the first label which is not to be ignored.
279 279
 		$title = '';
280
-		foreach ( $labels as $label ) {
281
-			if ( 0 !== strcasecmp( $label, $ignore_label ) ) {
280
+		foreach ($labels as $label) {
281
+			if (0 !== strcasecmp($label, $ignore_label)) {
282 282
 				$title = $label;
283 283
 				break;
284 284
 			}
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return array An array of URIs.
299 299
 	 */
300
-	public function get_entity_uris( $content ) {
300
+	public function get_entity_uris($content) {
301 301
 
302 302
 		$matches = array();
303
-		preg_match_all( Wordlift_Content_Filter_Service::PATTERN, $content, $matches );
303
+		preg_match_all(Wordlift_Content_Filter_Service::PATTERN, $content, $matches);
304 304
 
305 305
 		// We need to use `array_values` here in order to avoid further `json_encode`
306 306
 		// to turn it into an object (since if the 3rd match isn't found the index
307 307
 		// is not sequential.
308 308
 		//
309 309
 		// See https://github.com/insideout10/wordlift-plugin/issues/646.
310
-		return array_values( array_unique( $matches[3] ) );
310
+		return array_values(array_unique($matches[3]));
311 311
 	}
312 312
 
313 313
 }
Please login to merge, or discard this patch.
src/public/class-wordlift-public.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -22,113 +22,113 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Public {
24 24
 
25
-	/**
26
-	 * The ID of this plugin.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   private
30
-	 * @var      string $plugin_name The ID of this plugin.
31
-	 */
32
-	private $plugin_name;
33
-
34
-	/**
35
-	 * The version of this plugin.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   private
39
-	 * @var      string $version The current version of this plugin.
40
-	 */
41
-	private $version;
42
-
43
-	/**
44
-	 * Initialize the class and set its properties.
45
-	 *
46
-	 * @since    1.0.0
47
-	 *
48
-	 * @param      string $plugin_name The name of the plugin.
49
-	 * @param      string $version     The version of this plugin.
50
-	 */
51
-	public function __construct( $plugin_name, $version ) {
52
-
53
-		$this->plugin_name = $plugin_name;
54
-		$this->version     = $version;
55
-
56
-	}
57
-
58
-	/**
59
-	 * Register the stylesheets for the public-facing side of the site.
60
-	 *
61
-	 * @since    1.0.0
62
-	 */
63
-	public function enqueue_styles() {
64
-
65
-		/**
66
-		 * This function is provided for demonstration purposes only.
67
-		 *
68
-		 * An instance of this class should be passed to the run() function
69
-		 * defined in Wordlift_Loader as all of the hooks are defined
70
-		 * in that particular class.
71
-		 *
72
-		 * The Wordlift_Loader will then create the relationship
73
-		 * between the defined hooks and the functions defined in this
74
-		 * class.
75
-		 */
76
-
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
-
79
-	}
80
-
81
-	/**
82
-	 * Register the stylesheets for the public-facing side of the site.
83
-	 *
84
-	 * @since    1.0.0
85
-	 */
86
-	public function enqueue_scripts() {
87
-
88
-		/**
89
-		 * This function is provided for demonstration purposes only.
90
-		 *
91
-		 * An instance of this class should be passed to the run() function
92
-		 * defined in Wordlift_Loader as all of the hooks are defined
93
-		 * in that particular class.
94
-		 *
95
-		 * The Wordlift_Loader will then create the relationship
96
-		 * between the defined hooks and the functions defined in this
97
-		 * class.
98
-		 */
99
-
100
-		// Prepare a settings array for client-side functions.
101
-		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
-		);
104
-
105
-		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
107
-			$settings['postId'] = get_the_ID();
108
-		}
109
-
110
-		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
112
-			$settings['isHome'] = true;
113
-		}
114
-
115
-		// By default only enable JSON-LD on supported entity pages (includes
116
-		// `page`, `post` and `entity` by default) and on the home page.
117
-		//
118
-		// @see https://github.com/insideout10/wordlift-plugin/issues/733
119
-		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
120
-
121
-		// Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122
-		// be loaded.
123
-		//
124
-		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
126
-
127
-		// Note that we switched the js to be loaded in footer, since it is loading
128
-		// the json-ld representation.
129
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
131
-
132
-	}
25
+    /**
26
+     * The ID of this plugin.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   private
30
+     * @var      string $plugin_name The ID of this plugin.
31
+     */
32
+    private $plugin_name;
33
+
34
+    /**
35
+     * The version of this plugin.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   private
39
+     * @var      string $version The current version of this plugin.
40
+     */
41
+    private $version;
42
+
43
+    /**
44
+     * Initialize the class and set its properties.
45
+     *
46
+     * @since    1.0.0
47
+     *
48
+     * @param      string $plugin_name The name of the plugin.
49
+     * @param      string $version     The version of this plugin.
50
+     */
51
+    public function __construct( $plugin_name, $version ) {
52
+
53
+        $this->plugin_name = $plugin_name;
54
+        $this->version     = $version;
55
+
56
+    }
57
+
58
+    /**
59
+     * Register the stylesheets for the public-facing side of the site.
60
+     *
61
+     * @since    1.0.0
62
+     */
63
+    public function enqueue_styles() {
64
+
65
+        /**
66
+         * This function is provided for demonstration purposes only.
67
+         *
68
+         * An instance of this class should be passed to the run() function
69
+         * defined in Wordlift_Loader as all of the hooks are defined
70
+         * in that particular class.
71
+         *
72
+         * The Wordlift_Loader will then create the relationship
73
+         * between the defined hooks and the functions defined in this
74
+         * class.
75
+         */
76
+
77
+        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
78
+
79
+    }
80
+
81
+    /**
82
+     * Register the stylesheets for the public-facing side of the site.
83
+     *
84
+     * @since    1.0.0
85
+     */
86
+    public function enqueue_scripts() {
87
+
88
+        /**
89
+         * This function is provided for demonstration purposes only.
90
+         *
91
+         * An instance of this class should be passed to the run() function
92
+         * defined in Wordlift_Loader as all of the hooks are defined
93
+         * in that particular class.
94
+         *
95
+         * The Wordlift_Loader will then create the relationship
96
+         * between the defined hooks and the functions defined in this
97
+         * class.
98
+         */
99
+
100
+        // Prepare a settings array for client-side functions.
101
+        $settings = array(
102
+            'ajaxUrl' => admin_url( 'admin-ajax.php' ),
103
+        );
104
+
105
+        // If we're in a single page, then print out the post id.
106
+        if ( is_singular() ) {
107
+            $settings['postId'] = get_the_ID();
108
+        }
109
+
110
+        // Add flag that we are on home/blog page.
111
+        if ( is_home() || is_front_page() ) {
112
+            $settings['isHome'] = true;
113
+        }
114
+
115
+        // By default only enable JSON-LD on supported entity pages (includes
116
+        // `page`, `post` and `entity` by default) and on the home page.
117
+        //
118
+        // @see https://github.com/insideout10/wordlift-plugin/issues/733
119
+        $jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
120
+
121
+        // Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122
+        // be loaded.
123
+        //
124
+        // @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
+        $settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
126
+
127
+        // Note that we switched the js to be loaded in footer, since it is loading
128
+        // the json-ld representation.
129
+        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
+        wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
131
+
132
+    }
133 133
 
134 134
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param      string $plugin_name The name of the plugin.
49 49
 	 * @param      string $version     The version of this plugin.
50 50
 	 */
51
-	public function __construct( $plugin_name, $version ) {
51
+	public function __construct($plugin_name, $version) {
52 52
 
53 53
 		$this->plugin_name = $plugin_name;
54 54
 		$this->version     = $version;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * class.
75 75
 		 */
76 76
 
77
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
77
+		wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-public.css', array(), $this->version, 'all');
78 78
 
79 79
 	}
80 80
 
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Prepare a settings array for client-side functions.
101 101
 		$settings = array(
102
-			'ajaxUrl' => admin_url( 'admin-ajax.php' ),
102
+			'ajaxUrl' => admin_url('admin-ajax.php'),
103 103
 		);
104 104
 
105 105
 		// If we're in a single page, then print out the post id.
106
-		if ( is_singular() ) {
106
+		if (is_singular()) {
107 107
 			$settings['postId'] = get_the_ID();
108 108
 		}
109 109
 
110 110
 		// Add flag that we are on home/blog page.
111
-		if ( is_home() || is_front_page() ) {
111
+		if (is_home() || is_front_page()) {
112 112
 			$settings['isHome'] = true;
113 113
 		}
114 114
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		// `page`, `post` and `entity` by default) and on the home page.
117 117
 		//
118 118
 		// @see https://github.com/insideout10/wordlift-plugin/issues/733
119
-		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
119
+		$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type(get_post_type());
120 120
 
121 121
 		// Add the JSON-LD enabled flag, when set to false, the JSON-lD won't
122 122
 		// be loaded.
123 123
 		//
124 124
 		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
125
-		$settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
125
+		$settings['jsonld_enabled'] = apply_filters('wl_jsonld_enabled', $jsonld_enabled);
126 126
 
127 127
 		// Note that we switched the js to be loaded in footer, since it is loading
128 128
 		// the json-ld representation.
129
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-public.js', array( 'jquery' ), $this->version, true );
130
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
129
+		wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wordlift-public.js', array('jquery'), $this->version, true);
130
+		wp_localize_script($this->plugin_name, 'wlSettings', $settings);
131 131
 
132 132
 	}
133 133
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +548 added lines, -548 removed lines patch added patch discarded remove patch
@@ -7,467 +7,467 @@  discard block
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Entity_Service {
9 9
 
10
-	/**
11
-	 * The Log service.
12
-	 *
13
-	 * @since  3.2.0
14
-	 * @access private
15
-	 * @var \Wordlift_Log_Service $log The Log service.
16
-	 */
17
-	private $log;
18
-
19
-	/**
20
-	 * The UI service.
21
-	 *
22
-	 * @since  3.2.0
23
-	 * @access private
24
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
25
-	 */
26
-	private $ui_service;
27
-
28
-	/**
29
-	 * The {@link Wordlift_Relation_Service} instance.
30
-	 *
31
-	 * @since  3.15.0
32
-	 * @access private
33
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
-	 */
35
-	private $relation_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
39
-	 *
40
-	 * @since  3.16.3
41
-	 * @access private
42
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
-	 */
44
-	private $entity_uri_service;
45
-
46
-	/**
47
-	 * The entity post type name.
48
-	 *
49
-	 * @since 3.1.0
50
-	 */
51
-	const TYPE_NAME = 'entity';
52
-
53
-	/**
54
-	 * The alternative label meta key.
55
-	 *
56
-	 * @since 3.2.0
57
-	 */
58
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
59
-
60
-	/**
61
-	 * The alternative label input template.
62
-	 *
63
-	 * @since 3.2.0
64
-	 */
65
-	// TODO: this should be moved to a class that deals with HTML code.
66
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
10
+    /**
11
+     * The Log service.
12
+     *
13
+     * @since  3.2.0
14
+     * @access private
15
+     * @var \Wordlift_Log_Service $log The Log service.
16
+     */
17
+    private $log;
18
+
19
+    /**
20
+     * The UI service.
21
+     *
22
+     * @since  3.2.0
23
+     * @access private
24
+     * @var \Wordlift_UI_Service $ui_service The UI service.
25
+     */
26
+    private $ui_service;
27
+
28
+    /**
29
+     * The {@link Wordlift_Relation_Service} instance.
30
+     *
31
+     * @since  3.15.0
32
+     * @access private
33
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
+     */
35
+    private $relation_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Entity_Uri_Service} instance.
39
+     *
40
+     * @since  3.16.3
41
+     * @access private
42
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
43
+     */
44
+    private $entity_uri_service;
45
+
46
+    /**
47
+     * The entity post type name.
48
+     *
49
+     * @since 3.1.0
50
+     */
51
+    const TYPE_NAME = 'entity';
52
+
53
+    /**
54
+     * The alternative label meta key.
55
+     *
56
+     * @since 3.2.0
57
+     */
58
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
59
+
60
+    /**
61
+     * The alternative label input template.
62
+     *
63
+     * @since 3.2.0
64
+     */
65
+    // TODO: this should be moved to a class that deals with HTML code.
66
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
67 67
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
68 68
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
69 69
                 <button class="button wl-delete-button">%s</button>
70 70
                 </div>';
71 71
 
72
-	/**
73
-	 * A singleton instance of the Entity service.
74
-	 *
75
-	 * @since  3.2.0
76
-	 * @access private
77
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
78
-	 */
79
-	private static $instance;
80
-
81
-	/**
82
-	 * Create a Wordlift_Entity_Service instance.
83
-	 *
84
-	 * @since 3.2.0
85
-	 *
86
-	 * @param \Wordlift_UI_Service         $ui_service         The UI service.
87
-	 * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89
-	 */
90
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
91
-
92
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
93
-
94
-		$this->ui_service         = $ui_service;
95
-		$this->relation_service   = $relation_service;
96
-		$this->entity_uri_service = $entity_uri_service;
97
-
98
-		// Set the singleton instance.
99
-		self::$instance = $this;
100
-	}
101
-
102
-	/**
103
-	 * Get the singleton instance of the Entity service.
104
-	 *
105
-	 * @since 3.2.0
106
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
107
-	 */
108
-	public static function get_instance() {
109
-
110
-		return self::$instance;
111
-	}
112
-
113
-	/**
114
-	 * Determines whether a post is an entity or not. Entity is in this context
115
-	 * something which is not an article.
116
-	 *
117
-	 * @since 3.1.0
118
-	 *
119
-	 * @param int $post_id A post id.
120
-	 *
121
-	 * @return bool Return true if the post is an entity otherwise false.
122
-	 */
123
-	public function is_entity( $post_id ) {
124
-
125
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
126
-
127
-		if ( is_wp_error( $terms ) ) {
128
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
129
-
130
-			return false;
131
-		}
132
-
133
-		if ( 0 === count( $terms ) ) {
134
-			return false;
135
-		}
136
-
137
-		// We don't consider an `article` to be an entity.
138
-		if ( 'article' !== $terms[0]->slug ) {
139
-			return true;
140
-		}
141
-
142
-		return false;
143
-	}
144
-
145
-	/**
146
-	 * Get the proper classification scope for a given entity post
147
-	 *
148
-	 * @since 3.5.0
149
-	 *
150
-	 * @param integer $post_id An entity post id.
151
-	 *
152
-	 * @param string  $default The default classification scope, `what` if not
153
-	 *                         provided.
154
-	 *
155
-	 * @return string Returns a classification scope (e.g. 'what').
156
-	 */
157
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
158
-
159
-		if ( false === $this->is_entity( $post_id ) ) {
160
-			return $default;
161
-		}
162
-
163
-		// Retrieve the entity type
164
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
166
-		// Retrieve classification boxes configuration
167
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
-		foreach ( $classification_boxes as $cb ) {
169
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
170
-				return $cb['id'];
171
-			}
172
-		}
173
-
174
-		return $default;
175
-	}
176
-
177
-	/**
178
-	 * Check whether a {@link WP_Post} is used.
179
-	 *
180
-	 * @param int $post_id The {@link WP_Post}'s id.
181
-	 *
182
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
183
-	 */
184
-	public function is_used( $post_id ) {
185
-
186
-		if ( false === $this->is_entity( $post_id ) ) {
187
-			return null;
188
-		}
189
-		// Retrieve the post
190
-		$entity = get_post( $post_id );
191
-
192
-		global $wpdb;
193
-		// Retrieve Wordlift relation instances table name
194
-		$table_name = wl_core_get_relation_instances_table_name();
195
-
196
-		// Check is it's referenced / related to another post / entity
197
-		$stmt = $wpdb->prepare(
198
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
199
-			$entity->ID
200
-		);
201
-
202
-		// Perform the query
203
-		$relation_instances = (int) $wpdb->get_var( $stmt );
204
-		// If there is at least one relation instance for the current entity, then it's used
205
-		if ( 0 < $relation_instances ) {
206
-			return true;
207
-		}
208
-
209
-		// Check if the entity uri is used as meta_value
210
-		$stmt = $wpdb->prepare(
211
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212
-			$entity->ID,
213
-			wl_get_entity_uri( $entity->ID )
214
-		);
215
-		// Perform the query
216
-		$meta_instances = (int) $wpdb->get_var( $stmt );
217
-
218
-		// If there is at least one meta that refers the current entity uri, then current entity is used
219
-		if ( 0 < $meta_instances ) {
220
-			return true;
221
-		}
222
-
223
-		// If we are here, it means the current entity is not used at the moment
224
-		return false;
225
-	}
226
-
227
-	/**
228
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
229
-	 *
230
-	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
231
-	 * @since      3.2.0
232
-	 *
233
-	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
234
-	 *
235
-	 * @param string $uri The entity URI.
236
-	 *
237
-	 * @return WP_Post|null A WP_Post instance or null if not found.
238
-	 */
239
-	public function get_entity_post_by_uri( $uri ) {
240
-
241
-		return $this->entity_uri_service->get_entity( $uri );
242
-	}
243
-
244
-	/**
245
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
246
-	 * we check that the post we're saving is the current post.
247
-	 *
248
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
249
-	 *
250
-	 * @since 3.2.0
251
-	 *
252
-	 * @param int     $post_id Post ID.
253
-	 * @param WP_Post $post    Post object.
254
-	 * @param bool    $update  Whether this is an existing post being updated or not.
255
-	 */
256
-	public function save_post( $post_id, $post, $update ) {
257
-
258
-		// Avoid doing anything if post is autosave or a revision.
259
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
260
-			return;
261
-		}
262
-
263
-		// We're setting the alternative label that have been provided via the UI
264
-		// (in fact we're using $_REQUEST), while save_post may be also called
265
-		// programmatically by some other function: we need to check therefore if
266
-		// the $post_id in the save_post call matches the post id set in the request.
267
-		//
268
-		// If this is not the current post being saved or if it's not an entity, return.
269
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
270
-			return;
271
-		}
272
-
273
-		// Get the alt labels from the request (or empty array).
274
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
275
-
276
-		// Set the alternative labels.
277
-		$this->set_alternative_labels( $post_id, $alt_labels );
278
-
279
-	}
280
-
281
-	/**
282
-	 * Set the alternative labels.
283
-	 *
284
-	 * @since 3.2.0
285
-	 *
286
-	 * @param int   $post_id    The post id.
287
-	 * @param array $alt_labels An array of labels.
288
-	 */
289
-	public function set_alternative_labels( $post_id, $alt_labels ) {
290
-
291
-		// Force $alt_labels to be an array
292
-		if ( ! is_array( $alt_labels ) ) {
293
-			$alt_labels = array( $alt_labels );
294
-		}
295
-
296
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
297
-
298
-		// Delete all the existing alternate labels.
299
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
300
-
301
-		// Set the alternative labels.
302
-		foreach ( $alt_labels as $alt_label ) {
303
-			if ( ! empty( $alt_label ) ) {
304
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
305
-			}
306
-		}
307
-
308
-	}
309
-
310
-	/**
311
-	 * Retrieve the alternate labels.
312
-	 *
313
-	 * @since 3.2.0
314
-	 *
315
-	 * @param int $post_id Post id.
316
-	 *
317
-	 * @return mixed An array  of alternative labels.
318
-	 */
319
-	public function get_alternative_labels( $post_id ) {
320
-
321
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
322
-	}
323
-
324
-	/**
325
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
326
-	 *
327
-	 * @since 3.12.0
328
-	 *
329
-	 * @param int $post_id The entity {@link WP_Post} id.
330
-	 *
331
-	 * @return array An array with the entity title and labels.
332
-	 */
333
-	public function get_labels( $post_id ) {
334
-
335
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
336
-	}
337
-
338
-	/**
339
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
340
-	 *
341
-	 * @since 3.2.0
342
-	 *
343
-	 * @param WP_Post $post Post object.
344
-	 */
345
-	public function edit_form_before_permalink( $post ) {
346
-
347
-		// If it's not an entity, return.
348
-		if ( ! $this->is_entity( $post->ID ) ) {
349
-			return;
350
-		}
351
-
352
-		// Print the input template.
353
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
354
-
355
-		// Print all the currently set alternative labels.
356
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
357
-
358
-			echo $this->get_alternative_label_input( $alt_label );
359
-
360
-		};
361
-
362
-		// Print the button.
363
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
364
-
365
-	}
366
-
367
-	/**
368
-	 * Get the URI for the entity with the specified post id.
369
-	 *
370
-	 * @since 3.6.0
371
-	 *
372
-	 * @param int $post_id The entity post id.
373
-	 *
374
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375
-	 */
376
-	public function get_uri( $post_id ) {
377
-
378
-		// If a null is given, nothing to do
379
-		if ( null == $post_id ) {
380
-			return null;
381
-		}
382
-
383
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
384
-
385
-		// If the dataset uri is not properly configured, null is returned
386
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
387
-			return null;
388
-		}
389
-
390
-		// Set the URI if it isn't set yet.
391
-		$post_status = get_post_status( $post_id );
392
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
-			$uri = wl_build_entity_uri( $post_id );
394
-			wl_set_entity_uri( $post_id, $uri );
395
-		}
396
-
397
-		return $uri;
398
-	}
399
-
400
-
401
-	/**
402
-	 * Get the alternative label input HTML code.
403
-	 *
404
-	 * @since 3.2.0
405
-	 *
406
-	 * @param string $value The input value.
407
-	 *
408
-	 * @return string The input HTML code.
409
-	 */
410
-	private function get_alternative_label_input( $value = '' ) {
411
-
412
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
413
-	}
414
-
415
-	/**
416
-	 * Get the number of entity posts published in this blog.
417
-	 *
418
-	 * @since 3.6.0
419
-	 *
420
-	 * @return int The number of published entity posts.
421
-	 */
422
-	public function count() {
423
-
424
-		$posts = get_posts( $this->add_criterias( array(
425
-			'post_status' => 'any',
426
-			'numberposts' => - 1,
427
-		) ) );
428
-
429
-		return count( $posts );
430
-	}
431
-
432
-	/**
433
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
434
-	 * call.
435
-	 *
436
-	 * @since 3.15.0
437
-	 *
438
-	 * @param array $args The arguments for a `get_posts` call.
439
-	 *
440
-	 * @return array The arguments for a `get_posts` call.
441
-	 */
442
-	public static function add_criterias( $args ) {
443
-
444
-		// Build an optimal tax-query.
445
-		$tax_query = array(
446
-			'relation' => 'AND',
447
-			array(
448
-				'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
-				'operator' => 'EXISTS',
450
-			),
451
-			array(
452
-				'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
453
-				'field'    => 'slug',
454
-				'terms'    => 'article',
455
-				'operator' => 'NOT IN',
456
-			),
457
-		);
458
-
459
-		return $args + array(
460
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
461
-				// Since 3.17.0: should this be faster?
462
-				'tax_query' => $tax_query,
463
-				//				'tax_query' => array(
464
-				//					array(
465
-				//						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
466
-				//						'terms'    => self::get_entity_terms(),
467
-				//					),
468
-				//				),
469
-			);
470
-	}
72
+    /**
73
+     * A singleton instance of the Entity service.
74
+     *
75
+     * @since  3.2.0
76
+     * @access private
77
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
78
+     */
79
+    private static $instance;
80
+
81
+    /**
82
+     * Create a Wordlift_Entity_Service instance.
83
+     *
84
+     * @since 3.2.0
85
+     *
86
+     * @param \Wordlift_UI_Service         $ui_service         The UI service.
87
+     * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89
+     */
90
+    public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
91
+
92
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
93
+
94
+        $this->ui_service         = $ui_service;
95
+        $this->relation_service   = $relation_service;
96
+        $this->entity_uri_service = $entity_uri_service;
97
+
98
+        // Set the singleton instance.
99
+        self::$instance = $this;
100
+    }
101
+
102
+    /**
103
+     * Get the singleton instance of the Entity service.
104
+     *
105
+     * @since 3.2.0
106
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
107
+     */
108
+    public static function get_instance() {
109
+
110
+        return self::$instance;
111
+    }
112
+
113
+    /**
114
+     * Determines whether a post is an entity or not. Entity is in this context
115
+     * something which is not an article.
116
+     *
117
+     * @since 3.1.0
118
+     *
119
+     * @param int $post_id A post id.
120
+     *
121
+     * @return bool Return true if the post is an entity otherwise false.
122
+     */
123
+    public function is_entity( $post_id ) {
124
+
125
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
126
+
127
+        if ( is_wp_error( $terms ) ) {
128
+            $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
129
+
130
+            return false;
131
+        }
132
+
133
+        if ( 0 === count( $terms ) ) {
134
+            return false;
135
+        }
136
+
137
+        // We don't consider an `article` to be an entity.
138
+        if ( 'article' !== $terms[0]->slug ) {
139
+            return true;
140
+        }
141
+
142
+        return false;
143
+    }
144
+
145
+    /**
146
+     * Get the proper classification scope for a given entity post
147
+     *
148
+     * @since 3.5.0
149
+     *
150
+     * @param integer $post_id An entity post id.
151
+     *
152
+     * @param string  $default The default classification scope, `what` if not
153
+     *                         provided.
154
+     *
155
+     * @return string Returns a classification scope (e.g. 'what').
156
+     */
157
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
158
+
159
+        if ( false === $this->is_entity( $post_id ) ) {
160
+            return $default;
161
+        }
162
+
163
+        // Retrieve the entity type
164
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
166
+        // Retrieve classification boxes configuration
167
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
+        foreach ( $classification_boxes as $cb ) {
169
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
170
+                return $cb['id'];
171
+            }
172
+        }
173
+
174
+        return $default;
175
+    }
176
+
177
+    /**
178
+     * Check whether a {@link WP_Post} is used.
179
+     *
180
+     * @param int $post_id The {@link WP_Post}'s id.
181
+     *
182
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
183
+     */
184
+    public function is_used( $post_id ) {
185
+
186
+        if ( false === $this->is_entity( $post_id ) ) {
187
+            return null;
188
+        }
189
+        // Retrieve the post
190
+        $entity = get_post( $post_id );
191
+
192
+        global $wpdb;
193
+        // Retrieve Wordlift relation instances table name
194
+        $table_name = wl_core_get_relation_instances_table_name();
195
+
196
+        // Check is it's referenced / related to another post / entity
197
+        $stmt = $wpdb->prepare(
198
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
199
+            $entity->ID
200
+        );
201
+
202
+        // Perform the query
203
+        $relation_instances = (int) $wpdb->get_var( $stmt );
204
+        // If there is at least one relation instance for the current entity, then it's used
205
+        if ( 0 < $relation_instances ) {
206
+            return true;
207
+        }
208
+
209
+        // Check if the entity uri is used as meta_value
210
+        $stmt = $wpdb->prepare(
211
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212
+            $entity->ID,
213
+            wl_get_entity_uri( $entity->ID )
214
+        );
215
+        // Perform the query
216
+        $meta_instances = (int) $wpdb->get_var( $stmt );
217
+
218
+        // If there is at least one meta that refers the current entity uri, then current entity is used
219
+        if ( 0 < $meta_instances ) {
220
+            return true;
221
+        }
222
+
223
+        // If we are here, it means the current entity is not used at the moment
224
+        return false;
225
+    }
226
+
227
+    /**
228
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
229
+     *
230
+     * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
231
+     * @since      3.2.0
232
+     *
233
+     * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
234
+     *
235
+     * @param string $uri The entity URI.
236
+     *
237
+     * @return WP_Post|null A WP_Post instance or null if not found.
238
+     */
239
+    public function get_entity_post_by_uri( $uri ) {
240
+
241
+        return $this->entity_uri_service->get_entity( $uri );
242
+    }
243
+
244
+    /**
245
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
246
+     * we check that the post we're saving is the current post.
247
+     *
248
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
249
+     *
250
+     * @since 3.2.0
251
+     *
252
+     * @param int     $post_id Post ID.
253
+     * @param WP_Post $post    Post object.
254
+     * @param bool    $update  Whether this is an existing post being updated or not.
255
+     */
256
+    public function save_post( $post_id, $post, $update ) {
257
+
258
+        // Avoid doing anything if post is autosave or a revision.
259
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
260
+            return;
261
+        }
262
+
263
+        // We're setting the alternative label that have been provided via the UI
264
+        // (in fact we're using $_REQUEST), while save_post may be also called
265
+        // programmatically by some other function: we need to check therefore if
266
+        // the $post_id in the save_post call matches the post id set in the request.
267
+        //
268
+        // If this is not the current post being saved or if it's not an entity, return.
269
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
270
+            return;
271
+        }
272
+
273
+        // Get the alt labels from the request (or empty array).
274
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
275
+
276
+        // Set the alternative labels.
277
+        $this->set_alternative_labels( $post_id, $alt_labels );
278
+
279
+    }
280
+
281
+    /**
282
+     * Set the alternative labels.
283
+     *
284
+     * @since 3.2.0
285
+     *
286
+     * @param int   $post_id    The post id.
287
+     * @param array $alt_labels An array of labels.
288
+     */
289
+    public function set_alternative_labels( $post_id, $alt_labels ) {
290
+
291
+        // Force $alt_labels to be an array
292
+        if ( ! is_array( $alt_labels ) ) {
293
+            $alt_labels = array( $alt_labels );
294
+        }
295
+
296
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
297
+
298
+        // Delete all the existing alternate labels.
299
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
300
+
301
+        // Set the alternative labels.
302
+        foreach ( $alt_labels as $alt_label ) {
303
+            if ( ! empty( $alt_label ) ) {
304
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
305
+            }
306
+        }
307
+
308
+    }
309
+
310
+    /**
311
+     * Retrieve the alternate labels.
312
+     *
313
+     * @since 3.2.0
314
+     *
315
+     * @param int $post_id Post id.
316
+     *
317
+     * @return mixed An array  of alternative labels.
318
+     */
319
+    public function get_alternative_labels( $post_id ) {
320
+
321
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
322
+    }
323
+
324
+    /**
325
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
326
+     *
327
+     * @since 3.12.0
328
+     *
329
+     * @param int $post_id The entity {@link WP_Post} id.
330
+     *
331
+     * @return array An array with the entity title and labels.
332
+     */
333
+    public function get_labels( $post_id ) {
334
+
335
+        return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
336
+    }
337
+
338
+    /**
339
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
340
+     *
341
+     * @since 3.2.0
342
+     *
343
+     * @param WP_Post $post Post object.
344
+     */
345
+    public function edit_form_before_permalink( $post ) {
346
+
347
+        // If it's not an entity, return.
348
+        if ( ! $this->is_entity( $post->ID ) ) {
349
+            return;
350
+        }
351
+
352
+        // Print the input template.
353
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
354
+
355
+        // Print all the currently set alternative labels.
356
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
357
+
358
+            echo $this->get_alternative_label_input( $alt_label );
359
+
360
+        };
361
+
362
+        // Print the button.
363
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
364
+
365
+    }
366
+
367
+    /**
368
+     * Get the URI for the entity with the specified post id.
369
+     *
370
+     * @since 3.6.0
371
+     *
372
+     * @param int $post_id The entity post id.
373
+     *
374
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375
+     */
376
+    public function get_uri( $post_id ) {
377
+
378
+        // If a null is given, nothing to do
379
+        if ( null == $post_id ) {
380
+            return null;
381
+        }
382
+
383
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
384
+
385
+        // If the dataset uri is not properly configured, null is returned
386
+        if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
387
+            return null;
388
+        }
389
+
390
+        // Set the URI if it isn't set yet.
391
+        $post_status = get_post_status( $post_id );
392
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
+            $uri = wl_build_entity_uri( $post_id );
394
+            wl_set_entity_uri( $post_id, $uri );
395
+        }
396
+
397
+        return $uri;
398
+    }
399
+
400
+
401
+    /**
402
+     * Get the alternative label input HTML code.
403
+     *
404
+     * @since 3.2.0
405
+     *
406
+     * @param string $value The input value.
407
+     *
408
+     * @return string The input HTML code.
409
+     */
410
+    private function get_alternative_label_input( $value = '' ) {
411
+
412
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
413
+    }
414
+
415
+    /**
416
+     * Get the number of entity posts published in this blog.
417
+     *
418
+     * @since 3.6.0
419
+     *
420
+     * @return int The number of published entity posts.
421
+     */
422
+    public function count() {
423
+
424
+        $posts = get_posts( $this->add_criterias( array(
425
+            'post_status' => 'any',
426
+            'numberposts' => - 1,
427
+        ) ) );
428
+
429
+        return count( $posts );
430
+    }
431
+
432
+    /**
433
+     * Add the entity filtering criterias to the arguments for a `get_posts`
434
+     * call.
435
+     *
436
+     * @since 3.15.0
437
+     *
438
+     * @param array $args The arguments for a `get_posts` call.
439
+     *
440
+     * @return array The arguments for a `get_posts` call.
441
+     */
442
+    public static function add_criterias( $args ) {
443
+
444
+        // Build an optimal tax-query.
445
+        $tax_query = array(
446
+            'relation' => 'AND',
447
+            array(
448
+                'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
449
+                'operator' => 'EXISTS',
450
+            ),
451
+            array(
452
+                'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
453
+                'field'    => 'slug',
454
+                'terms'    => 'article',
455
+                'operator' => 'NOT IN',
456
+            ),
457
+        );
458
+
459
+        return $args + array(
460
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
461
+                // Since 3.17.0: should this be faster?
462
+                'tax_query' => $tax_query,
463
+                //				'tax_query' => array(
464
+                //					array(
465
+                //						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
466
+                //						'terms'    => self::get_entity_terms(),
467
+                //					),
468
+                //				),
469
+            );
470
+    }
471 471
 
472 472
 //	/**
473 473
 //	 * Get the entity terms IDs which represent an entity.
@@ -497,97 +497,97 @@  discard block
 block discarded – undo
497 497
 //		} ) );
498 498
 //	}
499 499
 
500
-	/**
501
-	 * Create a new entity.
502
-	 *
503
-	 * @since 3.9.0
504
-	 *
505
-	 * @param string $name     The entity name.
506
-	 * @param string $type_uri The entity's type URI.
507
-	 * @param null   $logo     The entity logo id (or NULL if none).
508
-	 * @param string $status   The post status, by default 'publish'.
509
-	 *
510
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511
-	 */
512
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
513
-
514
-		// Create an entity for the publisher.
515
-		$post_id = wp_insert_post( array(
516
-			'post_type'    => self::TYPE_NAME,
517
-			'post_title'   => $name,
518
-			'post_status'  => $status,
519
-			'post_content' => '',
520
-		) );
521
-
522
-		// Return the error if any.
523
-		if ( is_wp_error( $post_id ) ) {
524
-			return $post_id;
525
-		}
526
-
527
-		// Set the entity logo.
528
-		if ( $logo && is_numeric( $logo ) ) {
529
-			set_post_thumbnail( $post_id, $logo );
530
-		}
531
-
532
-		// Set the entity type.
533
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
534
-
535
-		return $post_id;
536
-	}
537
-
538
-	/**
539
-	 * Get the entities related to the one with the specified id. By default only
540
-	 * published entities will be returned.
541
-	 *
542
-	 * @since 3.10.0
543
-	 *
544
-	 * @param int    $id          The post id.
545
-	 * @param string $post_status The target post status (default = publish).
546
-	 *
547
-	 * @return array An array of post ids.
548
-	 */
549
-	public function get_related_entities( $id, $post_status = 'publish' ) {
550
-
551
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
552
-	}
553
-
554
-	/**
555
-	 * Get the list of entities.
556
-	 *
557
-	 * @since 3.12.2
558
-	 *
559
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
560
-	 *
561
-	 * @return array An array of entity posts.
562
-	 */
563
-	public function get( $params = array() ) {
564
-
565
-		// Set the defaults.
566
-		$defaults = array( 'post_type' => 'entity' );
567
-
568
-		// Merge the defaults with the provided parameters.
569
-		$args = wp_parse_args( $params, $defaults );
570
-
571
-		// Call the `get_posts` function.
572
-		return get_posts( $args );
573
-	}
574
-
575
-	/**
576
-	 * The list of post type names which can be used for entities
577
-	 *
578
-	 * Criteria is that the post type is public. The list of valid post types
579
-	 * can be overridden with a filter.
580
-	 *
581
-	 * @since 3.15.0
582
-	 *
583
-	 * @return array Array containing the names of the valid post types.
584
-	 */
585
-	static function valid_entity_post_types() {
586
-
587
-		// Ignore builtins in the call to avoid getting attachments.
588
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
589
-
590
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
591
-	}
500
+    /**
501
+     * Create a new entity.
502
+     *
503
+     * @since 3.9.0
504
+     *
505
+     * @param string $name     The entity name.
506
+     * @param string $type_uri The entity's type URI.
507
+     * @param null   $logo     The entity logo id (or NULL if none).
508
+     * @param string $status   The post status, by default 'publish'.
509
+     *
510
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511
+     */
512
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
513
+
514
+        // Create an entity for the publisher.
515
+        $post_id = wp_insert_post( array(
516
+            'post_type'    => self::TYPE_NAME,
517
+            'post_title'   => $name,
518
+            'post_status'  => $status,
519
+            'post_content' => '',
520
+        ) );
521
+
522
+        // Return the error if any.
523
+        if ( is_wp_error( $post_id ) ) {
524
+            return $post_id;
525
+        }
526
+
527
+        // Set the entity logo.
528
+        if ( $logo && is_numeric( $logo ) ) {
529
+            set_post_thumbnail( $post_id, $logo );
530
+        }
531
+
532
+        // Set the entity type.
533
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
534
+
535
+        return $post_id;
536
+    }
537
+
538
+    /**
539
+     * Get the entities related to the one with the specified id. By default only
540
+     * published entities will be returned.
541
+     *
542
+     * @since 3.10.0
543
+     *
544
+     * @param int    $id          The post id.
545
+     * @param string $post_status The target post status (default = publish).
546
+     *
547
+     * @return array An array of post ids.
548
+     */
549
+    public function get_related_entities( $id, $post_status = 'publish' ) {
550
+
551
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
552
+    }
553
+
554
+    /**
555
+     * Get the list of entities.
556
+     *
557
+     * @since 3.12.2
558
+     *
559
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
560
+     *
561
+     * @return array An array of entity posts.
562
+     */
563
+    public function get( $params = array() ) {
564
+
565
+        // Set the defaults.
566
+        $defaults = array( 'post_type' => 'entity' );
567
+
568
+        // Merge the defaults with the provided parameters.
569
+        $args = wp_parse_args( $params, $defaults );
570
+
571
+        // Call the `get_posts` function.
572
+        return get_posts( $args );
573
+    }
574
+
575
+    /**
576
+     * The list of post type names which can be used for entities
577
+     *
578
+     * Criteria is that the post type is public. The list of valid post types
579
+     * can be overridden with a filter.
580
+     *
581
+     * @since 3.15.0
582
+     *
583
+     * @return array Array containing the names of the valid post types.
584
+     */
585
+    static function valid_entity_post_types() {
586
+
587
+        // Ignore builtins in the call to avoid getting attachments.
588
+        $post_types = array( 'post', 'page', self::TYPE_NAME );
589
+
590
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
591
+    }
592 592
 
593 593
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @param \Wordlift_Relation_Service   $relation_service   The {@link Wordlift_Relation_Service} instance.
88 88
 	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
89 89
 	 */
90
-	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
90
+	public function __construct($ui_service, $relation_service, $entity_uri_service) {
91 91
 
92
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
92
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
93 93
 
94 94
 		$this->ui_service         = $ui_service;
95 95
 		$this->relation_service   = $relation_service;
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return bool Return true if the post is an entity otherwise false.
122 122
 	 */
123
-	public function is_entity( $post_id ) {
123
+	public function is_entity($post_id) {
124 124
 
125
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
125
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
126 126
 
127
-		if ( is_wp_error( $terms ) ) {
128
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
127
+		if (is_wp_error($terms)) {
128
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
129 129
 
130 130
 			return false;
131 131
 		}
132 132
 
133
-		if ( 0 === count( $terms ) ) {
133
+		if (0 === count($terms)) {
134 134
 			return false;
135 135
 		}
136 136
 
137 137
 		// We don't consider an `article` to be an entity.
138
-		if ( 'article' !== $terms[0]->slug ) {
138
+		if ('article' !== $terms[0]->slug) {
139 139
 			return true;
140 140
 		}
141 141
 
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @return string Returns a classification scope (e.g. 'what').
156 156
 	 */
157
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
157
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
158 158
 
159
-		if ( false === $this->is_entity( $post_id ) ) {
159
+		if (false === $this->is_entity($post_id)) {
160 160
 			return $default;
161 161
 		}
162 162
 
163 163
 		// Retrieve the entity type
164
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
165
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
164
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
165
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
166 166
 		// Retrieve classification boxes configuration
167
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
168
-		foreach ( $classification_boxes as $cb ) {
169
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
167
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
168
+		foreach ($classification_boxes as $cb) {
169
+			if (in_array($entity_type, $cb['registeredTypes'])) {
170 170
 				return $cb['id'];
171 171
 			}
172 172
 		}
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
183 183
 	 */
184
-	public function is_used( $post_id ) {
184
+	public function is_used($post_id) {
185 185
 
186
-		if ( false === $this->is_entity( $post_id ) ) {
186
+		if (false === $this->is_entity($post_id)) {
187 187
 			return null;
188 188
 		}
189 189
 		// Retrieve the post
190
-		$entity = get_post( $post_id );
190
+		$entity = get_post($post_id);
191 191
 
192 192
 		global $wpdb;
193 193
 		// Retrieve Wordlift relation instances table name
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 		);
201 201
 
202 202
 		// Perform the query
203
-		$relation_instances = (int) $wpdb->get_var( $stmt );
203
+		$relation_instances = (int) $wpdb->get_var($stmt);
204 204
 		// If there is at least one relation instance for the current entity, then it's used
205
-		if ( 0 < $relation_instances ) {
205
+		if (0 < $relation_instances) {
206 206
 			return true;
207 207
 		}
208 208
 
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 		$stmt = $wpdb->prepare(
211 211
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
212 212
 			$entity->ID,
213
-			wl_get_entity_uri( $entity->ID )
213
+			wl_get_entity_uri($entity->ID)
214 214
 		);
215 215
 		// Perform the query
216
-		$meta_instances = (int) $wpdb->get_var( $stmt );
216
+		$meta_instances = (int) $wpdb->get_var($stmt);
217 217
 
218 218
 		// If there is at least one meta that refers the current entity uri, then current entity is used
219
-		if ( 0 < $meta_instances ) {
219
+		if (0 < $meta_instances) {
220 220
 			return true;
221 221
 		}
222 222
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return WP_Post|null A WP_Post instance or null if not found.
238 238
 	 */
239
-	public function get_entity_post_by_uri( $uri ) {
239
+	public function get_entity_post_by_uri($uri) {
240 240
 
241
-		return $this->entity_uri_service->get_entity( $uri );
241
+		return $this->entity_uri_service->get_entity($uri);
242 242
 	}
243 243
 
244 244
 	/**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 * @param WP_Post $post    Post object.
254 254
 	 * @param bool    $update  Whether this is an existing post being updated or not.
255 255
 	 */
256
-	public function save_post( $post_id, $post, $update ) {
256
+	public function save_post($post_id, $post, $update) {
257 257
 
258 258
 		// Avoid doing anything if post is autosave or a revision.
259
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
259
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
260 260
 			return;
261 261
 		}
262 262
 
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 		// the $post_id in the save_post call matches the post id set in the request.
267 267
 		//
268 268
 		// If this is not the current post being saved or if it's not an entity, return.
269
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
269
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
270 270
 			return;
271 271
 		}
272 272
 
273 273
 		// Get the alt labels from the request (or empty array).
274
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
274
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array();
275 275
 
276 276
 		// Set the alternative labels.
277
-		$this->set_alternative_labels( $post_id, $alt_labels );
277
+		$this->set_alternative_labels($post_id, $alt_labels);
278 278
 
279 279
 	}
280 280
 
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
 	 * @param int   $post_id    The post id.
287 287
 	 * @param array $alt_labels An array of labels.
288 288
 	 */
289
-	public function set_alternative_labels( $post_id, $alt_labels ) {
289
+	public function set_alternative_labels($post_id, $alt_labels) {
290 290
 
291 291
 		// Force $alt_labels to be an array
292
-		if ( ! is_array( $alt_labels ) ) {
293
-			$alt_labels = array( $alt_labels );
292
+		if ( ! is_array($alt_labels)) {
293
+			$alt_labels = array($alt_labels);
294 294
 		}
295 295
 
296
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
296
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
297 297
 
298 298
 		// Delete all the existing alternate labels.
299
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
299
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
300 300
 
301 301
 		// Set the alternative labels.
302
-		foreach ( $alt_labels as $alt_label ) {
303
-			if ( ! empty( $alt_label ) ) {
304
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
302
+		foreach ($alt_labels as $alt_label) {
303
+			if ( ! empty($alt_label)) {
304
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label);
305 305
 			}
306 306
 		}
307 307
 
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return mixed An array  of alternative labels.
318 318
 	 */
319
-	public function get_alternative_labels( $post_id ) {
319
+	public function get_alternative_labels($post_id) {
320 320
 
321
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
321
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
322 322
 	}
323 323
 
324 324
 	/**
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return array An array with the entity title and labels.
332 332
 	 */
333
-	public function get_labels( $post_id ) {
333
+	public function get_labels($post_id) {
334 334
 
335
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
335
+		return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @param WP_Post $post Post object.
344 344
 	 */
345
-	public function edit_form_before_permalink( $post ) {
345
+	public function edit_form_before_permalink($post) {
346 346
 
347 347
 		// If it's not an entity, return.
348
-		if ( ! $this->is_entity( $post->ID ) ) {
348
+		if ( ! $this->is_entity($post->ID)) {
349 349
 			return;
350 350
 		}
351 351
 
352 352
 		// Print the input template.
353
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
353
+		$this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
354 354
 
355 355
 		// Print all the currently set alternative labels.
356
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
356
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
357 357
 
358
-			echo $this->get_alternative_label_input( $alt_label );
358
+			echo $this->get_alternative_label_input($alt_label);
359 359
 
360 360
 		};
361 361
 
362 362
 		// Print the button.
363
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
363
+		$this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
364 364
 
365 365
 	}
366 366
 
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
375 375
 	 */
376
-	public function get_uri( $post_id ) {
376
+	public function get_uri($post_id) {
377 377
 
378 378
 		// If a null is given, nothing to do
379
-		if ( null == $post_id ) {
379
+		if (null == $post_id) {
380 380
 			return null;
381 381
 		}
382 382
 
383
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
383
+		$uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, true);
384 384
 
385 385
 		// If the dataset uri is not properly configured, null is returned
386
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
386
+		if ('' === wl_configuration_get_redlink_dataset_uri()) {
387 387
 			return null;
388 388
 		}
389 389
 
390 390
 		// Set the URI if it isn't set yet.
391
-		$post_status = get_post_status( $post_id );
392
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
393
-			$uri = wl_build_entity_uri( $post_id );
394
-			wl_set_entity_uri( $post_id, $uri );
391
+		$post_status = get_post_status($post_id);
392
+		if (empty($uri) && 'auto-draft' !== $post_status && 'revision' !== $post_status) {
393
+			$uri = wl_build_entity_uri($post_id);
394
+			wl_set_entity_uri($post_id, $uri);
395 395
 		}
396 396
 
397 397
 		return $uri;
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 	 *
408 408
 	 * @return string The input HTML code.
409 409
 	 */
410
-	private function get_alternative_label_input( $value = '' ) {
410
+	private function get_alternative_label_input($value = '') {
411 411
 
412
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
412
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
413 413
 	}
414 414
 
415 415
 	/**
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 */
422 422
 	public function count() {
423 423
 
424
-		$posts = get_posts( $this->add_criterias( array(
424
+		$posts = get_posts($this->add_criterias(array(
425 425
 			'post_status' => 'any',
426
-			'numberposts' => - 1,
427
-		) ) );
426
+			'numberposts' => -1,
427
+		)));
428 428
 
429
-		return count( $posts );
429
+		return count($posts);
430 430
 	}
431 431
 
432 432
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * @return array The arguments for a `get_posts` call.
441 441
 	 */
442
-	public static function add_criterias( $args ) {
442
+	public static function add_criterias($args) {
443 443
 
444 444
 		// Build an optimal tax-query.
445 445
 		$tax_query = array(
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
 	 *
510 510
 	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
511 511
 	 */
512
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
512
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
513 513
 
514 514
 		// Create an entity for the publisher.
515
-		$post_id = wp_insert_post( array(
515
+		$post_id = wp_insert_post(array(
516 516
 			'post_type'    => self::TYPE_NAME,
517 517
 			'post_title'   => $name,
518 518
 			'post_status'  => $status,
519 519
 			'post_content' => '',
520
-		) );
520
+		));
521 521
 
522 522
 		// Return the error if any.
523
-		if ( is_wp_error( $post_id ) ) {
523
+		if (is_wp_error($post_id)) {
524 524
 			return $post_id;
525 525
 		}
526 526
 
527 527
 		// Set the entity logo.
528
-		if ( $logo && is_numeric( $logo ) ) {
529
-			set_post_thumbnail( $post_id, $logo );
528
+		if ($logo && is_numeric($logo)) {
529
+			set_post_thumbnail($post_id, $logo);
530 530
 		}
531 531
 
532 532
 		// Set the entity type.
533
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
533
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
534 534
 
535 535
 		return $post_id;
536 536
 	}
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 	 *
547 547
 	 * @return array An array of post ids.
548 548
 	 */
549
-	public function get_related_entities( $id, $post_status = 'publish' ) {
549
+	public function get_related_entities($id, $post_status = 'publish') {
550 550
 
551
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
551
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
552 552
 	}
553 553
 
554 554
 	/**
@@ -560,16 +560,16 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @return array An array of entity posts.
562 562
 	 */
563
-	public function get( $params = array() ) {
563
+	public function get($params = array()) {
564 564
 
565 565
 		// Set the defaults.
566
-		$defaults = array( 'post_type' => 'entity' );
566
+		$defaults = array('post_type' => 'entity');
567 567
 
568 568
 		// Merge the defaults with the provided parameters.
569
-		$args = wp_parse_args( $params, $defaults );
569
+		$args = wp_parse_args($params, $defaults);
570 570
 
571 571
 		// Call the `get_posts` function.
572
-		return get_posts( $args );
572
+		return get_posts($args);
573 573
 	}
574 574
 
575 575
 	/**
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 	static function valid_entity_post_types() {
586 586
 
587 587
 		// Ignore builtins in the call to avoid getting attachments.
588
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
588
+		$post_types = array('post', 'page', self::TYPE_NAME);
589 589
 
590
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
590
+		return apply_filters('wl_valid_entity_post_types', $post_types);
591 591
 	}
592 592
 
593 593
 }
Please login to merge, or discard this patch.