Completed
Push — master ( c2ab66...fc2fb1 )
by David
03:14
created

Wordlift   B

Complexity

Total Complexity 20

Size/Duplication

Total Lines 1601
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 100

Importance

Changes 0
Metric Value
dl 0
loc 1601
rs 8.8
c 0
b 0
f 0
wmc 20
lcom 1
cbo 100

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
A get_instance() 0 4 1
B load_dependencies() 0 558 3
A set_locale() 0 8 1
B define_admin_hooks() 0 165 5
B define_public_hooks() 0 57 3
A run() 0 3 1
A get_plugin_name() 0 3 1
A get_loader() 0 3 1
A get_version() 0 3 1
A load_cli_dependencies() 0 9 1
1
<?php
2
/**
3
 * The file that defines the core plugin class
4
 *
5
 * A class definition that includes attributes and functions used across both the
6
 * public-facing side of the site and the admin area.
7
 *
8
 * @link       https://wordlift.io
9
 * @since      1.0.0
10
 *
11
 * @package    Wordlift
12
 * @subpackage Wordlift/includes
13
 */
14
15
/**
16
 * The core plugin class.
17
 *
18
 * This is used to define internationalization, admin-specific hooks, and
19
 * public-facing site hooks.
20
 *
21
 * Also maintains the unique identifier of this plugin as well as the current
22
 * version of the plugin.
23
 *
24
 * @since      1.0.0
25
 * @package    Wordlift
26
 * @subpackage Wordlift/includes
27
 * @author     WordLift <[email protected]>
28
 */
29
class Wordlift {
30
31
	//<editor-fold desc="## FIELDS">
32
33
	/**
34
	 * The loader that's responsible for maintaining and registering all hooks that power
35
	 * the plugin.
36
	 *
37
	 * @since    1.0.0
38
	 * @access   protected
39
	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
40
	 */
41
	protected $loader;
42
43
	/**
44
	 * The unique identifier of this plugin.
45
	 *
46
	 * @since    1.0.0
47
	 * @access   protected
48
	 * @var      string $plugin_name The string used to uniquely identify this plugin.
49
	 */
50
	protected $plugin_name;
51
52
	/**
53
	 * The current version of the plugin.
54
	 *
55
	 * @since    1.0.0
56
	 * @access   protected
57
	 * @var      string $version The current version of the plugin.
58
	 */
59
	protected $version;
60
61
	/**
62
	 * The {@link Wordlift_Tinymce_Adapter} instance.
63
	 *
64
	 * @since  3.12.0
65
	 * @access protected
66
	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
67
	 */
68
	protected $tinymce_adapter;
69
70
	/**
71
	 * The Thumbnail service.
72
	 *
73
	 * @since  3.1.5
74
	 * @access private
75
	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
76
	 */
77
	private $thumbnail_service;
78
79
	/**
80
	 * The UI service.
81
	 *
82
	 * @since  3.2.0
83
	 * @access private
84
	 * @var \Wordlift_UI_Service $ui_service The UI service.
85
	 */
86
	private $ui_service;
87
88
	/**
89
	 * The Schema service.
90
	 *
91
	 * @since  3.3.0
92
	 * @access protected
93
	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
94
	 */
95
	protected $schema_service;
96
97
	/**
98
	 * The Entity service.
99
	 *
100
	 * @since  3.1.0
101
	 * @access protected
102
	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
103
	 */
104
	protected $entity_service;
105
106
	/**
107
	 * The Topic Taxonomy service.
108
	 *
109
	 * @since  3.5.0
110
	 * @access private
111
	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
112
	 */
113
	private $topic_taxonomy_service;
114
115
	/**
116
	 * The Entity Types Taxonomy service.
117
	 *
118
	 * @since  3.18.0
119
	 * @access private
120
	 * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
121
	 */
122
	private $entity_types_taxonomy_service;
123
124
	/**
125
	 * The User service.
126
	 *
127
	 * @since  3.1.7
128
	 * @access protected
129
	 * @var \Wordlift_User_Service $user_service The User service.
130
	 */
131
	protected $user_service;
132
133
	/**
134
	 * The Timeline service.
135
	 *
136
	 * @since  3.1.0
137
	 * @access private
138
	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
139
	 */
140
	private $timeline_service;
141
142
	/**
143
	 * The Redirect service.
144
	 *
145
	 * @since  3.2.0
146
	 * @access private
147
	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
148
	 */
149
	private $redirect_service;
150
151
	/**
152
	 * The Notice service.
153
	 *
154
	 * @since  3.3.0
155
	 * @access private
156
	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
157
	 */
158
	private $notice_service;
159
160
	/**
161
	 * The Entity list customization.
162
	 *
163
	 * @since  3.3.0
164
	 * @access protected
165
	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
166
	 */
167
	protected $entity_list_service;
168
169
	/**
170
	 * The Entity Types Taxonomy Walker.
171
	 *
172
	 * @since  3.1.0
173
	 * @access private
174
	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
175
	 */
176
	private $entity_types_taxonomy_walker;
177
178
	/**
179
	 * The ShareThis service.
180
	 *
181
	 * @since  3.2.0
182
	 * @access private
183
	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
184
	 */
185
	private $sharethis_service;
186
187
	/**
188
	 * The PrimaShop adapter.
189
	 *
190
	 * @since  3.2.3
191
	 * @access private
192
	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
193
	 */
194
	private $primashop_adapter;
195
196
	/**
197
	 * The WordLift Dashboard adapter.
198
	 *
199
	 * @since  3.4.0
200
	 * @access private
201
	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
202
	 */
203
	private $dashboard_service;
204
205
	/**
206
	 * The entity type service.
207
	 *
208
	 * @since  3.6.0
209
	 * @access private
210
	 * @var \Wordlift_Entity_Post_Type_Service
211
	 */
212
	private $entity_post_type_service;
213
214
	/**
215
	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
216
	 *
217
	 * @since  3.6.0
218
	 * @access private
219
	 * @var \Wordlift_Entity_Link_Service
220
	 */
221
	private $entity_link_service;
222
223
	/**
224
	 * A {@link Wordlift_Sparql_Service} instance.
225
	 *
226
	 * @since    3.6.0
227
	 * @access   protected
228
	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
229
	 */
230
	protected $sparql_service;
231
232
	/**
233
	 * A {@link Wordlift_Import_Service} instance.
234
	 *
235
	 * @since  3.6.0
236
	 * @access private
237
	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
238
	 */
239
	private $import_service;
240
241
	/**
242
	 * A {@link Wordlift_Rebuild_Service} instance.
243
	 *
244
	 * @since  3.6.0
245
	 * @access private
246
	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
247
	 */
248
	private $rebuild_service;
249
250
	/**
251
	 * A {@link Wordlift_Jsonld_Service} instance.
252
	 *
253
	 * @since  3.7.0
254
	 * @access protected
255
	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
256
	 */
257
	protected $jsonld_service;
258
259
	/**
260
	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
261
	 *
262
	 * @since  3.14.0
263
	 * @access protected
264
	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
265
	 */
266
	protected $jsonld_website_converter;
267
268
	/**
269
	 * A {@link Wordlift_Property_Factory} instance.
270
	 *
271
	 * @since  3.7.0
272
	 * @access private
273
	 * @var \Wordlift_Property_Factory $property_factory
274
	 */
275
	private $property_factory;
276
277
	/**
278
	 * The 'Download Your Data' page.
279
	 *
280
	 * @since  3.6.0
281
	 * @access private
282
	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
283
	 */
284
	private $download_your_data_page;
285
286
	/**
287
	 * The 'WordLift Settings' page.
288
	 *
289
	 * @since  3.11.0
290
	 * @access protected
291
	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
292
	 */
293
	protected $settings_page;
294
295
	/**
296
	 * The 'WordLift Batch analysis' page.
297
	 *
298
	 * @since  3.14.0
299
	 * @access protected
300
	 * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
301
	 */
302
	protected $batch_analysis_page;
303
304
	/**
305
	 * The install wizard page.
306
	 *
307
	 * @since  3.9.0
308
	 * @access private
309
	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
310
	 */
311
	private $admin_setup;
312
313
	/**
314
	 * The Content Filter Service hooks up to the 'the_content' filter and provides
315
	 * linking of entities to their pages.
316
	 *
317
	 * @since  3.8.0
318
	 * @access private
319
	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
320
	 */
321
	private $content_filter_service;
322
323
	/**
324
	 * A {@link Wordlift_Key_Validation_Service} instance.
325
	 *
326
	 * @since  3.9.0
327
	 * @access private
328
	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
329
	 */
330
	private $key_validation_service;
331
332
	/**
333
	 * A {@link Wordlift_Rating_Service} instance.
334
	 *
335
	 * @since  3.10.0
336
	 * @access private
337
	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
338
	 */
339
	private $rating_service;
340
341
	/**
342
	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
343
	 *
344
	 * @since  3.10.0
345
	 * @access protected
346
	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
347
	 */
348
	protected $post_to_jsonld_converter;
349
350
	/**
351
	 * A {@link Wordlift_Configuration_Service} instance.
352
	 *
353
	 * @since  3.10.0
354
	 * @access protected
355
	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
356
	 */
357
	protected $configuration_service;
358
359
	/**
360
	 * A {@link Wordlift_Install_Service} instance.
361
	 *
362
	 * @since  3.18.0
363
	 * @access protected
364
	 * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
365
	 */
366
	protected $install_service;
367
368
	/**
369
	 * A {@link Wordlift_Entity_Type_Service} instance.
370
	 *
371
	 * @since  3.10.0
372
	 * @access protected
373
	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
374
	 */
375
	protected $entity_type_service;
376
377
	/**
378
	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
379
	 *
380
	 * @since  3.10.0
381
	 * @access protected
382
	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
383
	 */
384
	protected $entity_post_to_jsonld_converter;
385
386
	/**
387
	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
388
	 *
389
	 * @since  3.10.0
390
	 * @access protected
391
	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
392
	 */
393
	protected $postid_to_jsonld_converter;
394
395
	/**
396
	 * The {@link Wordlift_Admin_Status_Page} class.
397
	 *
398
	 * @since  3.9.8
399
	 * @access private
400
	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
401
	 */
402
	private $status_page;
403
404
	/**
405
	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
406
	 *
407
	 * @since  3.11.0
408
	 * @access protected
409
	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
410
	 */
411
	protected $category_taxonomy_service;
412
413
	/**
414
	 * The {@link Wordlift_Entity_Page_Service} instance.
415
	 *
416
	 * @since  3.11.0
417
	 * @access protected
418
	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
419
	 */
420
	protected $entity_page_service;
421
422
	/**
423
	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
424
	 *
425
	 * @since  3.11.0
426
	 * @access protected
427
	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
428
	 */
429
	protected $settings_page_action_link;
430
431
	/**
432
	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
433
	 *
434
	 * @since  3.11.0
435
	 * @access protected
436
	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
437
	 */
438
	protected $publisher_ajax_adapter;
439
440
	/**
441
	 * The {@link Wordlift_Admin_Input_Element} element renderer.
442
	 *
443
	 * @since  3.11.0
444
	 * @access protected
445
	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
446
	 */
447
	protected $input_element;
448
449
	/**
450
	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
451
	 *
452
	 * @since  3.13.0
453
	 * @access protected
454
	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
455
	 */
456
	protected $radio_input_element;
457
458
	/**
459
	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
460
	 *
461
	 * @since  3.11.0
462
	 * @access protected
463
	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
464
	 */
465
	protected $language_select_element;
466
467
	/**
468
	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
469
	 *
470
	 * @since  3.11.0
471
	 * @access protected
472
	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
473
	 */
474
	protected $publisher_element;
475
476
	/**
477
	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
478
	 *
479
	 * @since  3.11.0
480
	 * @access protected
481
	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
482
	 */
483
	protected $select2_element;
484
485
	/**
486
	 * The controller for the entity type list admin page
487
	 *
488
	 * @since  3.11.0
489
	 * @access private
490
	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
491
	 */
492
	private $entity_type_admin_page;
493
494
	/**
495
	 * The controller for the entity type settings admin page
496
	 *
497
	 * @since  3.11.0
498
	 * @access private
499
	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
500
	 */
501
	private $entity_type_settings_admin_page;
502
503
	/**
504
	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
505
	 *
506
	 * @since  3.11.0
507
	 * @access protected
508
	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
509
	 */
510
	protected $related_entities_cloud_widget;
511
512
	/**
513
	 * The {@link Wordlift_Admin_Author_Element} instance.
514
	 *
515
	 * @since  3.14.0
516
	 * @access protected
517
	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
518
	 */
519
	protected $author_element;
520
521
	/**
522
	 * The {@link Wordlift_Batch_Analysis_Service} instance.
523
	 *
524
	 * @since  3.14.0
525
	 * @access protected
526
	 * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
527
	 */
528
	protected $batch_analysis_service;
529
530
	/**
531
	 * The {@link Wordlift_Sample_Data_Service} instance.
532
	 *
533
	 * @since  3.12.0
534
	 * @access protected
535
	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
536
	 */
537
	protected $sample_data_service;
538
539
	/**
540
	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
541
	 *
542
	 * @since  3.12.0
543
	 * @access protected
544
	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
545
	 */
546
	protected $sample_data_ajax_adapter;
547
548
	/**
549
	 * The {@link Wordlift_Batch_Analysis_Adapter} instance.
550
	 *
551
	 * @since  3.14.2
552
	 * @access protected
553
	 * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
554
	 */
555
	private $batch_analysis_adapter;
556
557
	/**
558
	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
559
	 *
560
	 * @since  3.14.3
561
	 * @access private
562
	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
563
	 */
564
	private $relation_rebuild_service;
565
566
	/**
567
	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
568
	 *
569
	 * @since  3.14.3
570
	 * @access private
571
	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
572
	 */
573
	private $relation_rebuild_adapter;
574
575
	/**
576
	 * The {@link Wordlift_Reference_Rebuild_Service} instance.
577
	 *
578
	 * @since  3.18.0
579
	 * @access private
580
	 * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance.
581
	 */
582
	private $reference_rebuild_service;
583
584
	/**
585
	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
586
	 *
587
	 * @since  3.16.0
588
	 * @access protected
589
	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
590
	 */
591
	protected $google_analytics_export_service;
592
593
	/**
594
	 * {@link Wordlift}'s singleton instance.
595
	 *
596
	 * @since  3.15.0
597
	 * @access protected
598
	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
599
	 */
600
	protected $entity_type_adapter;
601
602
	/**
603
	 * The {@link Wordlift_Linked_Data_Service} instance.
604
	 *
605
	 * @since  3.15.0
606
	 * @access protected
607
	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
608
	 */
609
	protected $linked_data_service;
610
611
	/**
612
	 * The {@link Wordlift_Storage_Factory} instance.
613
	 *
614
	 * @since  3.15.0
615
	 * @access protected
616
	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
617
	 */
618
	protected $storage_factory;
619
620
	/**
621
	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
622
	 *
623
	 * @since  3.15.0
624
	 * @access protected
625
	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
626
	 */
627
	protected $rendition_factory;
628
629
	/**
630
	 * The {@link Wordlift_Autocomplete_Service} instance.
631
	 *
632
	 * @since  3.15.0
633
	 * @access private
634
	 * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
635
	 */
636
	private $autocomplete_service;
637
638
	/**
639
	 * The {@link Wordlift_Autocomplete_Adapter} instance.
640
	 *
641
	 * @since  3.15.0
642
	 * @access private
643
	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
644
	 */
645
	private $autocomplete_adapter;
646
647
	/**
648
	 * The {@link Wordlift_Relation_Service} instance.
649
	 *
650
	 * @since  3.15.0
651
	 * @access protected
652
	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
653
	 */
654
	protected $relation_service;
655
656
	/**
657
	 * The {@link Wordlift_Cached_Post_Converter} instance.
658
	 *
659
	 * @since  3.16.0
660
	 * @access protected
661
	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
662
	 *
663
	 */
664
	protected $cached_postid_to_jsonld_converter;
665
666
	/**
667
	 * The {@link Wordlift_File_Cache_Service} instance.
668
	 *
669
	 * @since  3.16.0
670
	 * @access protected
671
	 * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance.
672
	 */
673
	protected $file_cache_service;
674
675
	/**
676
	 * The {@link Wordlift_Entity_Uri_Service} instance.
677
	 *
678
	 * @since  3.16.3
679
	 * @access protected
680
	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
681
	 */
682
	protected $entity_uri_service;
683
684
	/**
685
	 * The {@link Wordlift_Publisher_Service} instance.
686
	 *
687
	 * @since  3.19.0
688
	 * @access protected
689
	 * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
690
	 */
691
	protected $publisher_service;
692
693
	/**
694
	 * {@link Wordlift}'s singleton instance.
695
	 *
696
	 * @since  3.11.2
697
	 * @access private
698
	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
699
	 */
700
	private static $instance;
701
	//</editor-fold>
702
703
	/**
704
	 * Define the core functionality of the plugin.
705
	 *
706
	 * Set the plugin name and the plugin version that can be used throughout the plugin.
707
	 * Load the dependencies, define the locale, and set the hooks for the admin area and
708
	 * the public-facing side of the site.
709
	 *
710
	 * @since    1.0.0
711
	 */
712
	public function __construct() {
713
714
		$this->plugin_name = 'wordlift';
715
		$this->version     = '3.19.2';
716
		$this->load_dependencies();
717
		$this->set_locale();
718
		$this->define_admin_hooks();
719
		$this->define_public_hooks();
720
721
		// If we're in `WP_CLI` load the related files.
722
		if ( class_exists( 'WP_CLI' ) ) {
723
			$this->load_cli_dependencies();
724
		}
725
726
		self::$instance = $this;
727
728
	}
729
730
	/**
731
	 * Get the singleton instance.
732
	 *
733
	 * @since 3.11.2
734
	 *
735
	 * @return Wordlift The {@link Wordlift} singleton instance.
736
	 */
737
	public static function get_instance() {
738
739
		return self::$instance;
740
	}
741
742
	/**
743
	 * Load the required dependencies for this plugin.
744
	 *
745
	 * Include the following files that make up the plugin:
746
	 *
747
	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
748
	 * - Wordlift_i18n. Defines internationalization functionality.
749
	 * - Wordlift_Admin. Defines all hooks for the admin area.
750
	 * - Wordlift_Public. Defines all hooks for the public side of the site.
751
	 *
752
	 * Create an instance of the loader which will be used to register the hooks
753
	 * with WordPress.
754
	 *
755
	 * @since    1.0.0
756
	 * @access   private
757
	 */
758
	private function load_dependencies() {
0 ignored issues
show
Coding Style introduced by
load_dependencies uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
759
760
		/**
761
		 * The class responsible for orchestrating the actions and filters of the
762
		 * core plugin.
763
		 */
764
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
765
766
		// The class responsible for plugin uninstall.
767
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
768
769
		/**
770
		 * The class responsible for defining internationalization functionality
771
		 * of the plugin.
772
		 */
773
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
774
775
		/**
776
		 * WordLift's supported languages.
777
		 */
778
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
779
780
		/**
781
		 * Provide support functions to sanitize data.
782
		 */
783
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
784
785
		/** Installs. */
786
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install.php';
787
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
788
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-1-0-0.php';
789
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-10-0.php';
790
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-12-0.php';
791
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-14-0.php';
792
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-15-0.php';
793
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-18-0.php';
794
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-3-18-3.php';
795
796
		/** Services. */
797
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
798
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
799
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
800
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
801
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
802
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
803
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
804
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
805
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
806
807
		/**
808
		 * The Query builder.
809
		 */
810
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
811
812
		/**
813
		 * The Schema service.
814
		 */
815
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
816
817
		/**
818
		 * The schema:url property service.
819
		 */
820
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
821
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
822
823
		/**
824
		 * The UI service.
825
		 */
826
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
827
828
		/**
829
		 * The Thumbnail service.
830
		 */
831
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
832
833
		/**
834
		 * The Entity Types Taxonomy service.
835
		 */
836
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
837
838
		/**
839
		 * The Entity service.
840
		 */
841
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
842
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
843
844
		// Add the entity rating service.
845
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
846
847
		/**
848
		 * The User service.
849
		 */
850
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
851
852
		/**
853
		 * The Timeline service.
854
		 */
855
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
856
857
		/**
858
		 * The Topic Taxonomy service.
859
		 */
860
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
861
862
		/**
863
		 * The SPARQL service.
864
		 */
865
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
866
867
		/**
868
		 * The WordLift import service.
869
		 */
870
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
871
872
		/**
873
		 * The WordLift URI service.
874
		 */
875
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
876
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
877
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
878
879
		/**
880
		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
881
		 */
882
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php';
883
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php';
884
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php';
885
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php';
886
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php';
887
888
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
889
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
890
891
		/**
892
		 * Load the converters.
893
		 */
894
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
895
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
896
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
897
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
898
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
899
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
900
901
		/**
902
		 * Load cache-related files.
903
		 */
904
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
905
906
		/**
907
		 * Load the content filter.
908
		 */
909
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
910
911
		/*
912
		 * Load the excerpt helper.
913
		 */
914
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
915
916
		/**
917
		 * Load the JSON-LD service to publish entities using JSON-LD.s
918
		 *
919
		 * @since 3.8.0
920
		 */
921
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
922
923
		// The Publisher Service and the AJAX adapter.
924
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
925
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
926
927
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
928
929
		/**
930
		 * Load the WordLift key validation service.
931
		 */
932
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
933
934
		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
935
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
936
937
		// Load the `Wordlift_Entity_Page_Service` class definition.
938
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
939
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-sql-helper.php';
940
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-service.php';
941
942
		/** Linked Data. */
943
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
944
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
945
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
946
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
947
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
948
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
949
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
950
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
951
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
952
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
953
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
954
955
		/** Linked Data Rendition. */
956
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php';
957
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php';
958
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php';
959
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
960
961
		/** Services. */
962
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
963
964
		/** Adapters. */
965
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
966
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
967
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
968
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
969
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch-analysis/class-wordlift-batch-analysis-adapter.php';
970
971
		/** Async Tasks. */
972
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php';
973
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
974
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
975
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
976
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php';
977
978
		/** Async Tasks. */
979
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
980
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
981
982
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
983
984
		/**
985
		 * The class responsible for defining all actions that occur in the admin area.
986
		 */
987
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
988
989
		/**
990
		 * The class to customize the entity list admin page.
991
		 */
992
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
993
994
		/**
995
		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
996
		 */
997
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
998
999
		/**
1000
		 * The Notice service.
1001
		 */
1002
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
1003
1004
		/**
1005
		 * The PrimaShop adapter.
1006
		 */
1007
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
1008
1009
		/**
1010
		 * The WordLift Dashboard service.
1011
		 */
1012
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
1013
1014
		/**
1015
		 * The admin 'Install wizard' page.
1016
		 */
1017
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
1018
1019
		/**
1020
		 * The WordLift entity type list admin page controller.
1021
		 */
1022
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
1023
1024
		/**
1025
		 * The WordLift entity type settings admin page controller.
1026
		 */
1027
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
1028
1029
		/**
1030
		 * The admin 'Download Your Data' page.
1031
		 */
1032
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
1033
1034
		/**
1035
		 * The admin 'WordLift Settings' page.
1036
		 */
1037
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
1038
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
1039
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
1040
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
1041
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
1042
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
1043
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
1044
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
1045
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
1046
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
1047
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
1048
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
1049
1050
		/** Admin Pages */
1051
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1052
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
1053
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
1054
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
1055
1056
		/**
1057
		 * The class responsible for defining all actions that occur in the public-facing
1058
		 * side of the site.
1059
		 */
1060
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
1061
1062
		/**
1063
		 * The shortcode abstract class.
1064
		 */
1065
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
1066
1067
		/**
1068
		 * The Timeline shortcode.
1069
		 */
1070
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
1071
1072
		/**
1073
		 * The Navigator shortcode.
1074
		 */
1075
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
1076
1077
		/**
1078
		 * The chord shortcode.
1079
		 */
1080
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
1081
1082
		/**
1083
		 * The geomap shortcode.
1084
		 */
1085
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
1086
1087
		/**
1088
		 * The entity cloud shortcode.
1089
		 */
1090
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
1091
1092
		/**
1093
		 * The entity glossary shortcode.
1094
		 */
1095
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
1096
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
1097
1098
		/**
1099
		 * The ShareThis service.
1100
		 */
1101
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
1102
1103
		/**
1104
		 * The SEO service.
1105
		 */
1106
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1107
1108
		/**
1109
		 * The AMP service.
1110
		 */
1111
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1112
1113
		/** Widgets */
1114
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1115
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1116
1117
		$this->loader = new Wordlift_Loader();
1118
1119
		// Instantiate a global logger.
1120
		global $wl_logger;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1121
		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1122
1123
		// Load the `wl-api` end-point.
1124
		new Wordlift_Http_Api();
1125
1126
		// Load the Install Service.
1127
		$this->install_service = new Wordlift_Install_Service();
1128
1129
		/** Services. */
1130
		// Create the configuration service.
1131
		$this->configuration_service = new Wordlift_Configuration_Service();
1132
1133
		// Create an entity type service instance. It'll be later bound to the init action.
1134
		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1135
1136
		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1137
		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1138
1139
		// Create an instance of the UI service.
1140
		$this->ui_service = new Wordlift_UI_Service();
1141
1142
		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1143
		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1144
1145
		$this->sparql_service        = new Wordlift_Sparql_Service();
1146
		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1147
		$this->notice_service        = new Wordlift_Notice_Service();
1148
		$this->relation_service      = new Wordlift_Relation_Service();
1149
1150
		$entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' );
1151
		$this->file_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' );
1152
		$this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service );
1153
		$this->entity_service     = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service );
1154
		$this->user_service       = new Wordlift_User_Service( $this->sparql_service, $this->entity_service );
1155
1156
		// Instantiate the JSON-LD service.
1157
		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1158
1159
		/** Linked Data. */
1160
		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1161
		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1162
1163
		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1164
1165
		// Create a new instance of the Redirect service.
1166
		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1167
		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1168
		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1169
1170
		// Create a new instance of the Timeline service and Timeline shortcode.
1171
		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1172
1173
		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service, $this->file_cache_service );
1174
1175
		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1176
1177
		$this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1178
		$this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1179
1180
		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1181
		$this->sharethis_service = new Wordlift_ShareThis_Service();
1182
1183
		// Create an instance of the PrimaShop adapter.
1184
		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1185
1186
		// Create an import service instance to hook later to WP's import function.
1187
		$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() );
1188
1189
		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1190
1191
		// Create the entity rating service.
1192
		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1193
1194
		// Create entity list customization (wp-admin/edit.php).
1195
		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1196
1197
		// Create a new instance of the Redirect service.
1198
		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1199
1200
		// Create an instance of the Publisher Service and the AJAX Adapter.
1201
		$this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service );
1202
		$this->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1203
		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1204
1205
		$attachment_service = new Wordlift_Attachment_Service();
1206
1207
		// Instantiate the JSON-LD service.
1208
		$property_getter                         = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1209
		$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 );
1210
		$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 );
1211
		$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 );
1212
		$this->jsonld_website_converter          = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service );
1213
		$this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service, $this->configuration_service );
1214
		$this->jsonld_service                    = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter );
1215
1216
1217
		$this->key_validation_service    = new Wordlift_Key_Validation_Service( $this->configuration_service );
1218
		$this->content_filter_service    = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service );
1219
		$this->relation_rebuild_service  = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1220
		$this->sample_data_service       = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service );
1221
		$this->sample_data_ajax_adapter  = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1222
		$this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->linked_data_service, $this->entity_service, $this->relation_service );
1223
1224
		// Initialize the shortcodes.
1225
		new Wordlift_Navigator_Shortcode();
1226
		new Wordlift_Chord_Shortcode();
1227
		new Wordlift_Geomap_Shortcode();
1228
		new Wordlift_Timeline_Shortcode();
1229
		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1230
		new Wordlift_Vocabulary_Shortcode( $this->configuration_service );
1231
1232
		// Initialize the SEO service.
1233
		new Wordlift_Seo_Service();
1234
1235
		// Initialize the AMP service.
1236
		new Wordlift_AMP_Service( $this->jsonld_service );
1237
1238
		/** Services. */
1239
		$this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1240
1241
		/** Adapters. */
1242
		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1243
		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service );
1244
		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1245
		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1246
		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1247
1248
		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1249
		$this->rebuild_service = new Wordlift_Rebuild_Service(
1250
			$this->sparql_service,
1251
			$uri_service
1252
		);
1253
1254
		/** Async Tasks. */
1255
		new Wordlift_Sparql_Query_Async_Task();
1256
		new Wordlift_Batch_Analysis_Request_Async_Task();
1257
		new Wordlift_Batch_Analysis_Complete_Async_Task();
1258
		new Wordlift_Batch_Analysis_Complete_Async_Task();
1259
		new Wordlift_Push_References_Async_Task();
1260
1261
		/** WL Autocomplete. */
1262
		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1263
		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1264
1265
		/** WordPress Admin UI. */
1266
1267
		// UI elements.
1268
		$this->input_element           = new Wordlift_Admin_Input_Element();
1269
		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1270
		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1271
		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1272
		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1273
		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element );
1274
		$this->author_element          = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element );
1275
1276
		$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 );
1277
		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1278
		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1279
1280
		// Pages.
1281
		new Wordlift_Admin_Post_Edit_Page( $this );
1282
		new Wordlift_Entity_Type_Admin_Service();
1283
1284
		// create an instance of the entity type list admin page controller.
1285
		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1286
1287
		// create an instance of the entity type etting admin page controller.
1288
		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1289
1290
		/** Widgets */
1291
		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1292
1293
		/* WordPress Admin. */
1294
		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1295
		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1296
1297
		// Create an instance of the install wizard.
1298
		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1299
1300
		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1301
1302
		// User Profile.
1303
		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1304
1305
		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1306
1307
		// Load the debug service if WP is in debug mode.
1308
		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1309
			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1310
			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1311
		}
1312
1313
		// Remote Image Service.
1314
		new Wordlift_Remote_Image_Service();
1315
	}
1316
1317
	/**
1318
	 * Define the locale for this plugin for internationalization.
1319
	 *
1320
	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1321
	 * with WordPress.
1322
	 *
1323
	 * @since    1.0.0
1324
	 * @access   private
1325
	 */
1326
	private function set_locale() {
1327
1328
		$plugin_i18n = new Wordlift_i18n();
1329
		$plugin_i18n->set_domain( $this->get_plugin_name() );
1330
1331
		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1332
1333
	}
1334
1335
	/**
1336
	 * Register all of the hooks related to the admin area functionality
1337
	 * of the plugin.
1338
	 *
1339
	 * @since    1.0.0
1340
	 * @access   private
1341
	 */
1342
	private function define_admin_hooks() {
1343
1344
		$plugin_admin = new Wordlift_Admin(
1345
			$this->get_plugin_name(),
1346
			$this->get_version(),
1347
			$this->configuration_service,
1348
			$this->notice_service,
1349
			$this->user_service
1350
		);
1351
1352
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1353
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1354
1355
		// Hook the init action to taxonomy services.
1356
		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1357
		$this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 );
1358
1359
		// Hook the deleted_post_meta action to the Thumbnail service.
1360
		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1361
1362
		// Hook the added_post_meta action to the Thumbnail service.
1363
		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1364
1365
		// Hook the updated_post_meta action to the Thumbnail service.
1366
		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1367
1368
		// Hook the AJAX wl_timeline action to the Timeline service.
1369
		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1370
1371
		// Register custom allowed redirect hosts.
1372
		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1373
		// Hook the AJAX wordlift_redirect action to the Redirect service.
1374
		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1375
		// Hook the AJAX wordlift_redirect action to the Redirect service.
1376
		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1377
		// Hook the AJAX wordlift_redirect action to the Redirect service.
1378
		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1379
1380
		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1381
		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1382
		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1383
		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1384
1385
		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1386
		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1387
1388
		// Entity listing customization (wp-admin/edit.php)
1389
		// Add custom columns.
1390
		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1391
		// no explicit entity as it prevents handling of other post types.
1392
		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1393
		// Add 4W selection.
1394
		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1395
		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1396
		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1397
		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1398
		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1399
1400
		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1401
		// entities.
1402
		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1403
1404
		// Filter imported post meta.
1405
		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1406
1407
		// Notify the import service when an import starts and ends.
1408
		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1409
		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1410
1411
		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1412
		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1413
		$this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' );
1414
1415
		// Hook the menu to the Download Your Data page.
1416
		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1417
		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1418
		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1419
1420
		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1421
		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1422
1423
		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1424
		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1425
		$this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' );
1426
		$this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1427
1428
		// Hook the AJAX wl_validate_key action to the Key Validation service.
1429
		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1430
1431
		// Hook the `admin_init` function to the Admin Setup.
1432
		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1433
1434
		// Hook the admin_init to the settings page.
1435
		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1436
1437
		$this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' );
1438
1439
		// Hook the menu creation on the general wordlift menu creation.
1440
		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1441
		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1442
			// Add the functionality only if a flag is set in wp-config.php .
1443
			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1444
		}
1445
1446
		// Hook key update.
1447
		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1448
		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1449
1450
		// Add additional action links to the WordLift plugin in the plugins page.
1451
		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1452
1453
		// Hook the AJAX `wl_publisher` action name.
1454
		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1455
1456
		// Hook row actions for the entity type list admin.
1457
		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1458
1459
		/** Ajax actions. */
1460
		$this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' );
1461
1462
		// Hook capabilities manipulation to allow access to entity type admin
1463
		// page  on WordPress versions before 4.7.
1464
		global $wp_version;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1465
		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1466
			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1467
		}
1468
1469
		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1470
1471
		/** Adapters. */
1472
		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1473
		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit' );
1474
		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_posts', $this->batch_analysis_adapter, 'submit_posts' );
1475
		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel' );
1476
		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning' );
1477
		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' );
1478
1479
		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1480
		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1481
1482
1483
		$this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 );
1484
		$this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 );
1485
1486
		// Handle the autocomplete request.
1487
		add_action( 'wp_ajax_wl_autocomplete', array(
1488
			$this->autocomplete_adapter,
1489
			'wl_autocomplete',
1490
		) );
1491
		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1492
			$this->autocomplete_adapter,
1493
			'wl_autocomplete',
1494
		) );
1495
1496
		// Hooks to restrict multisite super admin from manipulating entity types.
1497
		if ( is_multisite() ) {
1498
			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1499
		}
1500
1501
		$deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service );
1502
1503
		add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1504
		add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1505
		add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) );
1506
	}
1507
1508
	/**
1509
	 * Register all of the hooks related to the public-facing functionality
1510
	 * of the plugin.
1511
	 *
1512
	 * @since    1.0.0
1513
	 * @access   private
1514
	 */
1515
	private function define_public_hooks() {
1516
1517
		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1518
1519
		// Register the entity post type.
1520
		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1521
		$this->loader->add_action( 'init', $this->install_service, 'install' );
1522
1523
		// Bind the link generation and handling hooks to the entity link service.
1524
		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1525
		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1526
		$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 );
1527
		$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 );
1528
1529
		/**
1530
		 * Disable the `enqueue_styles` call since we don't have styles to load.
1531
		 *
1532
		 * @see https://github.com/insideout10/wordlift-plugin/issues/821 related issue.
1533
		 * @since 3.19.2
1534
		 */
1535
		// $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1536
1537
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1538
1539
		// Hook the content filter service to add entity links.
1540
		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1541
			$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1542
		}
1543
1544
		// Hook the AJAX wl_timeline action to the Timeline service.
1545
		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1546
1547
		// Hook the ShareThis service.
1548
		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1549
		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1550
1551
		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1552
		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1553
1554
		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1555
		// in order to tweak WP's `WP_Query` to include entities in queries related
1556
		// to categories.
1557
		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1558
1559
		/*
1560
		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1561
		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1562
		 * order of start time.
1563
		 */
1564
		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1565
1566
		$this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1567
1568
		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1569
		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1570
1571
	}
1572
1573
	/**
1574
	 * Run the loader to execute all of the hooks with WordPress.
1575
	 *
1576
	 * @since    1.0.0
1577
	 */
1578
	public function run() {
1579
		$this->loader->run();
1580
	}
1581
1582
	/**
1583
	 * The name of the plugin used to uniquely identify it within the context of
1584
	 * WordPress and to define internationalization functionality.
1585
	 *
1586
	 * @since     1.0.0
1587
	 * @return    string    The name of the plugin.
1588
	 */
1589
	public function get_plugin_name() {
1590
		return $this->plugin_name;
1591
	}
1592
1593
	/**
1594
	 * The reference to the class that orchestrates the hooks with the plugin.
1595
	 *
1596
	 * @since     1.0.0
1597
	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1598
	 */
1599
	public function get_loader() {
1600
		return $this->loader;
1601
	}
1602
1603
	/**
1604
	 * Retrieve the version number of the plugin.
1605
	 *
1606
	 * @since     1.0.0
1607
	 * @return    string    The version number of the plugin.
1608
	 */
1609
	public function get_version() {
1610
		return $this->version;
1611
	}
1612
1613
	/**
1614
	 * Load dependencies for WP-CLI.
1615
	 *
1616
	 * @since 3.18.0
1617
	 * @throws Exception
1618
	 */
1619
	private function load_cli_dependencies() {
1620
1621
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php';
1622
1623
		$push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service );
1624
1625
		WP_CLI::add_command( 'wl references push', $push_reference_data_command );
1626
1627
	}
1628
1629
}
1630