Completed
Push — develop ( baaab2...f613d5 )
by David
02:51
created
src/includes/class-wordlift.php 1 patch
Indentation   +765 added lines, -765 removed lines patch added patch discarded remove patch
@@ -29,829 +29,829 @@
 block discarded – undo
29 29
  */
30 30
 class Wordlift {
31 31
 
32
-	/**
33
-	 * The loader that's responsible for maintaining and registering all hooks that power
34
-	 * the plugin.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   protected
38
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
-	 */
40
-	protected $loader;
41
-
42
-	/**
43
-	 * The unique identifier of this plugin.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   protected
47
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
48
-	 */
49
-	protected $plugin_name;
50
-
51
-	/**
52
-	 * The current version of the plugin.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   protected
56
-	 * @var      string $version The current version of the plugin.
57
-	 */
58
-	protected $version;
59
-
60
-	/**
61
-	 * The Thumbnail service.
62
-	 *
63
-	 * @since  3.1.5
64
-	 * @access private
65
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
-	 */
67
-	private $thumbnail_service;
68
-
69
-	/**
70
-	 * The UI service.
71
-	 *
72
-	 * @since  3.2.0
73
-	 * @access private
74
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
75
-	 */
76
-	private $ui_service;
77
-
78
-	/**
79
-	 * The Schema service.
80
-	 *
81
-	 * @since  3.3.0
82
-	 * @access private
83
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
-	 */
85
-	private $schema_service;
86
-
87
-	/**
88
-	 * The Entity service.
89
-	 *
90
-	 * @since  3.1.0
91
-	 * @access private
92
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
-	 */
94
-	private $entity_service;
95
-
96
-	/**
97
-	 * The Topic Taxonomy service.
98
-	 *
99
-	 * @since  3.5.0
100
-	 * @access private
101
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
-	 */
103
-	private $topic_taxonomy_service;
104
-
105
-	/**
106
-	 * The User service.
107
-	 *
108
-	 * @since  3.1.7
109
-	 * @access private
110
-	 * @var \Wordlift_User_Service $user_service The User service.
111
-	 */
112
-	private $user_service;
113
-
114
-	/**
115
-	 * The Timeline service.
116
-	 *
117
-	 * @since  3.1.0
118
-	 * @access private
119
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
-	 */
121
-	private $timeline_service;
122
-
123
-	/**
124
-	 * The Redirect service.
125
-	 *
126
-	 * @since  3.2.0
127
-	 * @access private
128
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
-	 */
130
-	private $redirect_service;
131
-
132
-	/**
133
-	 * The Notice service.
134
-	 *
135
-	 * @since  3.3.0
136
-	 * @access private
137
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
-	 */
139
-	private $notice_service;
140
-
141
-	/**
142
-	 * The Entity list customization.
143
-	 *
144
-	 * @since  3.3.0
145
-	 * @access private
146
-	 * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
-	 */
148
-	private $entity_list_service;
149
-
150
-	/**
151
-	 * The Entity Types Taxonomy Walker.
152
-	 *
153
-	 * @since  3.1.0
154
-	 * @access private
155
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
-	 */
157
-	private $entity_types_taxonomy_walker;
158
-
159
-	/**
160
-	 * The ShareThis service.
161
-	 *
162
-	 * @since  3.2.0
163
-	 * @access private
164
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
-	 */
166
-	private $sharethis_service;
167
-
168
-	/**
169
-	 * The PrimaShop adapter.
170
-	 *
171
-	 * @since  3.2.3
172
-	 * @access private
173
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
-	 */
175
-	private $primashop_adapter;
176
-
177
-	/**
178
-	 * The WordLift Dashboard adapter.
179
-	 *
180
-	 * @since  3.4.0
181
-	 * @access private
182
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
-	 */
184
-	private $dashboard_service;
185
-
186
-	/**
187
-	 * The entity type service.
188
-	 *
189
-	 * @since  3.6.0
190
-	 * @access private
191
-	 * @var \Wordlift_Entity_Post_Type_Service
192
-	 */
193
-	private $entity_post_type_service;
194
-
195
-	/**
196
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
-	 *
198
-	 * @since  3.6.0
199
-	 * @access private
200
-	 * @var \Wordlift_Entity_Link_Service
201
-	 */
202
-	private $entity_link_service;
203
-
204
-	/**
205
-	 * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
-	 * correct page title to Google+.
207
-	 *
208
-	 * @since  3.5.3
209
-	 * @access private
210
-	 * @var \Wordlift_Page_Service
211
-	 */
212
-	private $page_service;
213
-
214
-	/**
215
-	 * A {@link Wordlift_Sparql_Service} instance.
216
-	 *
217
-	 * @var    3.6.0
218
-	 * @access private
219
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
220
-	 */
221
-	private $sparql_service;
222
-
223
-	/**
224
-	 * A {@link Wordlift_Import_Service} instance.
225
-	 *
226
-	 * @since  3.6.0
227
-	 * @access private
228
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
229
-	 */
230
-	private $import_service;
231
-
232
-	/**
233
-	 * A {@link Wordlift_Rebuild_Service} instance.
234
-	 *
235
-	 * @since  3.6.0
236
-	 * @access private
237
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
238
-	 */
239
-	private $rebuild_service;
240
-
241
-	/**
242
-	 * A {@link Wordlift_Jsonld_Service} instance.
243
-	 *
244
-	 * @since  3.7.0
245
-	 * @access private
246
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
-	 */
248
-	private $jsonld_service;
249
-
250
-	/**
251
-	 *
252
-	 * @since  3.7.0
253
-	 * @access private
254
-	 * @var \Wordlift_Property_Factory $property_factory
255
-	 */
256
-	private $property_factory;
257
-
258
-	/**
259
-	 * The 'Download Your Data' page.
260
-	 *
261
-	 * @since  3.6.0
262
-	 * @access private
263
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
264
-	 */
265
-	private $download_your_data_page;
266
-
267
-	/**
268
-	 * The install wizard page.
269
-	 *
270
-	 * @since  3.9.0
271
-	 * @access private
272
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
273
-	 */
274
-	private $admin_setup;
275
-
276
-	/**
277
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
278
-	 * linking of entities to their pages.
279
-	 *
280
-	 * @since  3.8.0
281
-	 * @access private
282
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
283
-	 */
284
-	private $content_filter_service;
285
-
286
-	/**
287
-	 * A {@link Wordlift_Key_Validation_Service} instance.
288
-	 *
289
-	 * @since  3.9.0
290
-	 * @access private
291
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
292
-	 */
293
-	private $key_validation_service;
294
-
295
-	/**
296
-	 * Define the core functionality of the plugin.
297
-	 *
298
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
299
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
300
-	 * the public-facing side of the site.
301
-	 *
302
-	 * @since    1.0.0
303
-	 */
304
-	public function __construct() {
305
-
306
-		$this->plugin_name = 'wordlift';
307
-		$this->version     = '3.10.0-dev';
308
-		$this->load_dependencies();
309
-		$this->set_locale();
310
-		$this->define_admin_hooks();
311
-		$this->define_public_hooks();
312
-
313
-	}
314
-
315
-	/**
316
-	 * Load the required dependencies for this plugin.
317
-	 *
318
-	 * Include the following files that make up the plugin:
319
-	 *
320
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
321
-	 * - Wordlift_i18n. Defines internationalization functionality.
322
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
323
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
324
-	 *
325
-	 * Create an instance of the loader which will be used to register the hooks
326
-	 * with WordPress.
327
-	 *
328
-	 * @since    1.0.0
329
-	 * @access   private
330
-	 */
331
-	private function load_dependencies() {
332
-
333
-		/**
334
-		 * The class responsible for orchestrating the actions and filters of the
335
-		 * core plugin.
336
-		 */
337
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
338
-
339
-		/**
340
-		 * The class responsible for defining internationalization functionality
341
-		 * of the plugin.
342
-		 */
343
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
344
-
345
-		/**
346
-		 * WordLift's supported languages.
347
-		 */
348
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
349
-
350
-		/**
351
-		 * Provide support functions to sanitize data.
352
-		 */
353
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
354
-
355
-		/**
356
-		 * The Redirect service.
357
-		 */
358
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
359
-
360
-		/**
361
-		 * The Log service.
362
-		 */
363
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
364
-
365
-		/**
366
-		 * The configuration service.
367
-		 */
368
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
369
-
370
-		/**
371
-		 * The entity post type service (this is the WordPress post type, not the entity schema type).
372
-		 */
373
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
374
-
375
-		/**
376
-		 * The entity type service (i.e. the schema type).
377
-		 */
378
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
379
-
380
-		/**
381
-		 * The entity link service.
382
-		 */
383
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
384
-
385
-		/**
386
-		 * The Query builder.
387
-		 */
388
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
389
-
390
-		/**
391
-		 * The Schema service.
392
-		 */
393
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
394
-
395
-		/**
396
-		 * The schema:url property service.
397
-		 */
398
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
399
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
400
-
401
-		/**
402
-		 * The UI service.
403
-		 */
404
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
405
-
406
-		/**
407
-		 * The Thumbnail service.
408
-		 */
409
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
410
-
411
-		/**
412
-		 * The Entity Types Taxonomy service.
413
-		 */
414
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
415
-
416
-		/**
417
-		 * The Entity service.
418
-		 */
419
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
420
-
421
-		/**
422
-		 * The User service.
423
-		 */
424
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
425
-
426
-		/**
427
-		 * The Timeline service.
428
-		 */
429
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
430
-
431
-		/**
432
-		 * The Topic Taxonomy service.
433
-		 */
434
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
435
-
436
-
437
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
438
-
439
-		/**
440
-		 * The SPARQL service.
441
-		 */
442
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
443
-
444
-		/**
445
-		 * The WordLift import service.
446
-		 */
447
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
448
-
449
-		/**
450
-		 * The WordLift URI service.
451
-		 */
452
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
453
-
454
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
455
-
456
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
457
-
458
-		/**
459
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
460
-		 */
461
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
462
-
463
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
464
-
465
-		/**
466
-		 * Load the converters.
467
-		 */
468
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
470
-
471
-		/**
472
-		 * Load the content filter.
473
-		 */
474
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
475
-
476
-		/**
477
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
478
-		 *
479
-		 * @since 3.8.0
480
-		 */
481
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
482
-
483
-		/**
484
-		 * Load the WordLift key validation service.
485
-		 */
486
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
487
-
488
-		/**
489
-		 * The class responsible for defining all actions that occur in the admin area.
490
-		 */
491
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
492
-
493
-		/**
494
-		 * The class to customize the entity list admin page.
495
-		 */
496
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
497
-
498
-		/**
499
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
500
-		 */
501
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
502
-
503
-		/**
504
-		 * The Notice service.
505
-		 */
506
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
507
-
508
-		/**
509
-		 * The PrimaShop adapter.
510
-		 */
511
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
512
-
513
-		/**
514
-		 * The WordLift Dashboard service.
515
-		 */
516
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
517
-
518
-		/**
519
-		 * The admin 'Install wizard' page.
520
-		 */
521
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
32
+    /**
33
+     * The loader that's responsible for maintaining and registering all hooks that power
34
+     * the plugin.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   protected
38
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
+     */
40
+    protected $loader;
41
+
42
+    /**
43
+     * The unique identifier of this plugin.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   protected
47
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
48
+     */
49
+    protected $plugin_name;
50
+
51
+    /**
52
+     * The current version of the plugin.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   protected
56
+     * @var      string $version The current version of the plugin.
57
+     */
58
+    protected $version;
59
+
60
+    /**
61
+     * The Thumbnail service.
62
+     *
63
+     * @since  3.1.5
64
+     * @access private
65
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
+     */
67
+    private $thumbnail_service;
68
+
69
+    /**
70
+     * The UI service.
71
+     *
72
+     * @since  3.2.0
73
+     * @access private
74
+     * @var \Wordlift_UI_Service $ui_service The UI service.
75
+     */
76
+    private $ui_service;
77
+
78
+    /**
79
+     * The Schema service.
80
+     *
81
+     * @since  3.3.0
82
+     * @access private
83
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
+     */
85
+    private $schema_service;
86
+
87
+    /**
88
+     * The Entity service.
89
+     *
90
+     * @since  3.1.0
91
+     * @access private
92
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
+     */
94
+    private $entity_service;
95
+
96
+    /**
97
+     * The Topic Taxonomy service.
98
+     *
99
+     * @since  3.5.0
100
+     * @access private
101
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
+     */
103
+    private $topic_taxonomy_service;
104
+
105
+    /**
106
+     * The User service.
107
+     *
108
+     * @since  3.1.7
109
+     * @access private
110
+     * @var \Wordlift_User_Service $user_service The User service.
111
+     */
112
+    private $user_service;
113
+
114
+    /**
115
+     * The Timeline service.
116
+     *
117
+     * @since  3.1.0
118
+     * @access private
119
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
+     */
121
+    private $timeline_service;
122
+
123
+    /**
124
+     * The Redirect service.
125
+     *
126
+     * @since  3.2.0
127
+     * @access private
128
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
+     */
130
+    private $redirect_service;
131
+
132
+    /**
133
+     * The Notice service.
134
+     *
135
+     * @since  3.3.0
136
+     * @access private
137
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
+     */
139
+    private $notice_service;
140
+
141
+    /**
142
+     * The Entity list customization.
143
+     *
144
+     * @since  3.3.0
145
+     * @access private
146
+     * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
+     */
148
+    private $entity_list_service;
149
+
150
+    /**
151
+     * The Entity Types Taxonomy Walker.
152
+     *
153
+     * @since  3.1.0
154
+     * @access private
155
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
+     */
157
+    private $entity_types_taxonomy_walker;
158
+
159
+    /**
160
+     * The ShareThis service.
161
+     *
162
+     * @since  3.2.0
163
+     * @access private
164
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
+     */
166
+    private $sharethis_service;
167
+
168
+    /**
169
+     * The PrimaShop adapter.
170
+     *
171
+     * @since  3.2.3
172
+     * @access private
173
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
+     */
175
+    private $primashop_adapter;
176
+
177
+    /**
178
+     * The WordLift Dashboard adapter.
179
+     *
180
+     * @since  3.4.0
181
+     * @access private
182
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
+     */
184
+    private $dashboard_service;
185
+
186
+    /**
187
+     * The entity type service.
188
+     *
189
+     * @since  3.6.0
190
+     * @access private
191
+     * @var \Wordlift_Entity_Post_Type_Service
192
+     */
193
+    private $entity_post_type_service;
194
+
195
+    /**
196
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
+     *
198
+     * @since  3.6.0
199
+     * @access private
200
+     * @var \Wordlift_Entity_Link_Service
201
+     */
202
+    private $entity_link_service;
203
+
204
+    /**
205
+     * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
+     * correct page title to Google+.
207
+     *
208
+     * @since  3.5.3
209
+     * @access private
210
+     * @var \Wordlift_Page_Service
211
+     */
212
+    private $page_service;
213
+
214
+    /**
215
+     * A {@link Wordlift_Sparql_Service} instance.
216
+     *
217
+     * @var    3.6.0
218
+     * @access private
219
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
220
+     */
221
+    private $sparql_service;
222
+
223
+    /**
224
+     * A {@link Wordlift_Import_Service} instance.
225
+     *
226
+     * @since  3.6.0
227
+     * @access private
228
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
229
+     */
230
+    private $import_service;
231
+
232
+    /**
233
+     * A {@link Wordlift_Rebuild_Service} instance.
234
+     *
235
+     * @since  3.6.0
236
+     * @access private
237
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
238
+     */
239
+    private $rebuild_service;
240
+
241
+    /**
242
+     * A {@link Wordlift_Jsonld_Service} instance.
243
+     *
244
+     * @since  3.7.0
245
+     * @access private
246
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
+     */
248
+    private $jsonld_service;
249
+
250
+    /**
251
+     *
252
+     * @since  3.7.0
253
+     * @access private
254
+     * @var \Wordlift_Property_Factory $property_factory
255
+     */
256
+    private $property_factory;
257
+
258
+    /**
259
+     * The 'Download Your Data' page.
260
+     *
261
+     * @since  3.6.0
262
+     * @access private
263
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
264
+     */
265
+    private $download_your_data_page;
266
+
267
+    /**
268
+     * The install wizard page.
269
+     *
270
+     * @since  3.9.0
271
+     * @access private
272
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
273
+     */
274
+    private $admin_setup;
275
+
276
+    /**
277
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
278
+     * linking of entities to their pages.
279
+     *
280
+     * @since  3.8.0
281
+     * @access private
282
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
283
+     */
284
+    private $content_filter_service;
285
+
286
+    /**
287
+     * A {@link Wordlift_Key_Validation_Service} instance.
288
+     *
289
+     * @since  3.9.0
290
+     * @access private
291
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
292
+     */
293
+    private $key_validation_service;
294
+
295
+    /**
296
+     * Define the core functionality of the plugin.
297
+     *
298
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
299
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
300
+     * the public-facing side of the site.
301
+     *
302
+     * @since    1.0.0
303
+     */
304
+    public function __construct() {
305
+
306
+        $this->plugin_name = 'wordlift';
307
+        $this->version     = '3.10.0-dev';
308
+        $this->load_dependencies();
309
+        $this->set_locale();
310
+        $this->define_admin_hooks();
311
+        $this->define_public_hooks();
312
+
313
+    }
314
+
315
+    /**
316
+     * Load the required dependencies for this plugin.
317
+     *
318
+     * Include the following files that make up the plugin:
319
+     *
320
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
321
+     * - Wordlift_i18n. Defines internationalization functionality.
322
+     * - Wordlift_Admin. Defines all hooks for the admin area.
323
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
324
+     *
325
+     * Create an instance of the loader which will be used to register the hooks
326
+     * with WordPress.
327
+     *
328
+     * @since    1.0.0
329
+     * @access   private
330
+     */
331
+    private function load_dependencies() {
332
+
333
+        /**
334
+         * The class responsible for orchestrating the actions and filters of the
335
+         * core plugin.
336
+         */
337
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
338
+
339
+        /**
340
+         * The class responsible for defining internationalization functionality
341
+         * of the plugin.
342
+         */
343
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
344
+
345
+        /**
346
+         * WordLift's supported languages.
347
+         */
348
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
349
+
350
+        /**
351
+         * Provide support functions to sanitize data.
352
+         */
353
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
354
+
355
+        /**
356
+         * The Redirect service.
357
+         */
358
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
359
+
360
+        /**
361
+         * The Log service.
362
+         */
363
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
364
+
365
+        /**
366
+         * The configuration service.
367
+         */
368
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
369
+
370
+        /**
371
+         * The entity post type service (this is the WordPress post type, not the entity schema type).
372
+         */
373
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
374
+
375
+        /**
376
+         * The entity type service (i.e. the schema type).
377
+         */
378
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
379
+
380
+        /**
381
+         * The entity link service.
382
+         */
383
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
384
+
385
+        /**
386
+         * The Query builder.
387
+         */
388
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
389
+
390
+        /**
391
+         * The Schema service.
392
+         */
393
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
394
+
395
+        /**
396
+         * The schema:url property service.
397
+         */
398
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
399
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
400
+
401
+        /**
402
+         * The UI service.
403
+         */
404
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
405
+
406
+        /**
407
+         * The Thumbnail service.
408
+         */
409
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
410
+
411
+        /**
412
+         * The Entity Types Taxonomy service.
413
+         */
414
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
415
+
416
+        /**
417
+         * The Entity service.
418
+         */
419
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
420
+
421
+        /**
422
+         * The User service.
423
+         */
424
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
425
+
426
+        /**
427
+         * The Timeline service.
428
+         */
429
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
430
+
431
+        /**
432
+         * The Topic Taxonomy service.
433
+         */
434
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
435
+
436
+
437
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
438
+
439
+        /**
440
+         * The SPARQL service.
441
+         */
442
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
443
+
444
+        /**
445
+         * The WordLift import service.
446
+         */
447
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
448
+
449
+        /**
450
+         * The WordLift URI service.
451
+         */
452
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
453
+
454
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
455
+
456
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
457
+
458
+        /**
459
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
460
+         */
461
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
462
+
463
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
464
+
465
+        /**
466
+         * Load the converters.
467
+         */
468
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
469
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php';
470
+
471
+        /**
472
+         * Load the content filter.
473
+         */
474
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
475
+
476
+        /**
477
+         * Load the JSON-LD service to publish entities using JSON-LD.s
478
+         *
479
+         * @since 3.8.0
480
+         */
481
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
482
+
483
+        /**
484
+         * Load the WordLift key validation service.
485
+         */
486
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
487
+
488
+        /**
489
+         * The class responsible for defining all actions that occur in the admin area.
490
+         */
491
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
492
+
493
+        /**
494
+         * The class to customize the entity list admin page.
495
+         */
496
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
497
+
498
+        /**
499
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
500
+         */
501
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
502
+
503
+        /**
504
+         * The Notice service.
505
+         */
506
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
507
+
508
+        /**
509
+         * The PrimaShop adapter.
510
+         */
511
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
512
+
513
+        /**
514
+         * The WordLift Dashboard service.
515
+         */
516
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
517
+
518
+        /**
519
+         * The admin 'Install wizard' page.
520
+         */
521
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
522 522
 
523
-		/**
524
-		 * The admin 'Download Your Data' page.
525
-		 */
526
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
523
+        /**
524
+         * The admin 'Download Your Data' page.
525
+         */
526
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
527 527
 
528
-		/**
529
-		 * The class responsible for defining all actions that occur in the public-facing
530
-		 * side of the site.
531
-		 */
532
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
528
+        /**
529
+         * The class responsible for defining all actions that occur in the public-facing
530
+         * side of the site.
531
+         */
532
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
533 533
 
534
-		/**
535
-		 * The shortcode abstract class.
536
-		 */
537
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
534
+        /**
535
+         * The shortcode abstract class.
536
+         */
537
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
538 538
 
539
-		/**
540
-		 * The Timeline shortcode.
541
-		 */
542
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
539
+        /**
540
+         * The Timeline shortcode.
541
+         */
542
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
543 543
 
544
-		/**
545
-		 * The Navigator shortcode.
546
-		 */
547
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
544
+        /**
545
+         * The Navigator shortcode.
546
+         */
547
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
548 548
 
549
-		/**
550
-		 * The chord shortcode.
551
-		 */
552
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
549
+        /**
550
+         * The chord shortcode.
551
+         */
552
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
553 553
 
554
-		/**
555
-		 * The geomap shortcode.
556
-		 */
557
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
554
+        /**
555
+         * The geomap shortcode.
556
+         */
557
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
558 558
 
559
-		/**
560
-		 * The ShareThis service.
561
-		 */
562
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
559
+        /**
560
+         * The ShareThis service.
561
+         */
562
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
563 563
 
564
-		$this->loader = new Wordlift_Loader();
564
+        $this->loader = new Wordlift_Loader();
565 565
 
566
-		// Instantiate a global logger.
567
-		global $wl_logger;
568
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
566
+        // Instantiate a global logger.
567
+        global $wl_logger;
568
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
569 569
 
570
-		// Create the configuration service.
571
-		$configuration_service = new Wordlift_Configuration_Service();
570
+        // Create the configuration service.
571
+        $configuration_service = new Wordlift_Configuration_Service();
572 572
 
573
-		// Create an entity type service instance. It'll be later bound to the init action.
574
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() );
573
+        // Create an entity type service instance. It'll be later bound to the init action.
574
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() );
575 575
 
576
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
577
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() );
576
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
577
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() );
578 578
 
579
-		// Create an instance of the UI service.
580
-		$this->ui_service = new Wordlift_UI_Service();
579
+        // Create an instance of the UI service.
580
+        $this->ui_service = new Wordlift_UI_Service();
581 581
 
582
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
583
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
582
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
583
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
584 584
 
585
-		$this->sparql_service = new Wordlift_Sparql_Service();
585
+        $this->sparql_service = new Wordlift_Sparql_Service();
586 586
 
587
-		// Create an instance of the Schema service.
588
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
589
-		$this->schema_service        = new Wordlift_Schema_Service();
587
+        // Create an instance of the Schema service.
588
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
589
+        $this->schema_service        = new Wordlift_Schema_Service();
590 590
 
591
-		// Create an instance of the Notice service.
592
-		$this->notice_service = new Wordlift_Notice_Service();
591
+        // Create an instance of the Notice service.
592
+        $this->notice_service = new Wordlift_Notice_Service();
593 593
 
594
-		// Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
595
-		$this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
594
+        // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
595
+        $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
596 596
 
597
-		// Create an instance of the User service.
598
-		$this->user_service = new Wordlift_User_Service();
597
+        // Create an instance of the User service.
598
+        $this->user_service = new Wordlift_User_Service();
599 599
 
600
-		// Create a new instance of the Timeline service and Timeline shortcode.
601
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
600
+        // Create a new instance of the Timeline service and Timeline shortcode.
601
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
602 602
 
603
-		// Create a new instance of the Redirect service.
604
-		$this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
603
+        // Create a new instance of the Redirect service.
604
+        $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
605 605
 
606
-		// Create a new instance of the Redirect service.
607
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
606
+        // Create a new instance of the Redirect service.
607
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
608 608
 
609
-		// Initialize the shortcodes.
610
-		new Wordlift_Navigator_Shortcode();
611
-		new Wordlift_Chord_Shortcode();
612
-		new Wordlift_Geomap_Shortcode();
613
-		new Wordlift_Timeline_Shortcode();
609
+        // Initialize the shortcodes.
610
+        new Wordlift_Navigator_Shortcode();
611
+        new Wordlift_Chord_Shortcode();
612
+        new Wordlift_Geomap_Shortcode();
613
+        new Wordlift_Timeline_Shortcode();
614 614
 
615
-		// Create entity list customization (wp-admin/edit.php)
616
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
615
+        // Create entity list customization (wp-admin/edit.php)
616
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
617 617
 
618
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
618
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
619 619
 
620
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
620
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
621 621
 
622
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
623
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
622
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
623
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
624 624
 
625
-		// Create an instance of the PrimaShop adapter.
626
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
625
+        // Create an instance of the PrimaShop adapter.
626
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
627 627
 
628
-		$this->page_service = new Wordlift_Page_Service();
628
+        $this->page_service = new Wordlift_Page_Service();
629 629
 
630
-		// Create an import service instance to hook later to WP's import function.
631
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() );
630
+        // Create an import service instance to hook later to WP's import function.
631
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() );
632 632
 
633
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
633
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
634 634
 
635
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
636
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
635
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
636
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
637 637
 
638
-		$entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
638
+        $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
639 639
 
640
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
641
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
640
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
641
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
642 642
 
643
-		// Instantiate the JSON-LD service.
644
-		$property_getter                = Wordlift_Property_Getter_Factory::create( $this->entity_service );
645
-		$entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter );
646
-		$this->jsonld_service           = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter );
643
+        // Instantiate the JSON-LD service.
644
+        $property_getter                = Wordlift_Property_Getter_Factory::create( $this->entity_service );
645
+        $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter );
646
+        $this->jsonld_service           = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter );
647 647
 
648
-		// Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins).
649
-		$this->key_validation_service = new Wordlift_Key_Validation_Service();
648
+        // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins).
649
+        $this->key_validation_service = new Wordlift_Key_Validation_Service();
650 650
 
651
-		//** WordPress Admin */
652
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
651
+        //** WordPress Admin */
652
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
653 653
 
654
-		// Create an instance of the install wizard.
655
-		$this->admin_setup = new Wordlift_Admin_Setup( $configuration_service, $this->key_validation_service, $this->entity_service );
654
+        // Create an instance of the install wizard.
655
+        $this->admin_setup = new Wordlift_Admin_Setup( $configuration_service, $this->key_validation_service, $this->entity_service );
656 656
 
657
-		// Create an instance of the content filter service.
658
-		$this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service );
657
+        // Create an instance of the content filter service.
658
+        $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service );
659 659
 
660
-		// Load the debug service if WP is in debug mode.
661
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
662
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
663
-			new Wordlift_Debug_Service( $this->entity_service );
664
-		}
660
+        // Load the debug service if WP is in debug mode.
661
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
662
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
663
+            new Wordlift_Debug_Service( $this->entity_service );
664
+        }
665 665
 
666
-	}
666
+    }
667 667
 
668
-	/**
669
-	 * Define the locale for this plugin for internationalization.
670
-	 *
671
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
672
-	 * with WordPress.
673
-	 *
674
-	 * @since    1.0.0
675
-	 * @access   private
676
-	 */
677
-	private function set_locale() {
668
+    /**
669
+     * Define the locale for this plugin for internationalization.
670
+     *
671
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
672
+     * with WordPress.
673
+     *
674
+     * @since    1.0.0
675
+     * @access   private
676
+     */
677
+    private function set_locale() {
678 678
 
679
-		$plugin_i18n = new Wordlift_i18n();
680
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
679
+        $plugin_i18n = new Wordlift_i18n();
680
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
681 681
 
682
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
682
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
683 683
 
684
-	}
684
+    }
685 685
 
686
-	/**
687
-	 * Register all of the hooks related to the admin area functionality
688
-	 * of the plugin.
689
-	 *
690
-	 * @since    1.0.0
691
-	 * @access   private
692
-	 */
693
-	private function define_admin_hooks() {
686
+    /**
687
+     * Register all of the hooks related to the admin area functionality
688
+     * of the plugin.
689
+     *
690
+     * @since    1.0.0
691
+     * @access   private
692
+     */
693
+    private function define_admin_hooks() {
694 694
 
695
-		$plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
695
+        $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
696 696
 
697
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
698
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
697
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
698
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
699 699
 
700
-		// Hook the init action to the Topic Taxonomy service.
701
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
700
+        // Hook the init action to the Topic Taxonomy service.
701
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
702 702
 
703
-		// Hook the deleted_post_meta action to the Thumbnail service.
704
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
703
+        // Hook the deleted_post_meta action to the Thumbnail service.
704
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
705 705
 
706
-		// Hook the added_post_meta action to the Thumbnail service.
707
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
706
+        // Hook the added_post_meta action to the Thumbnail service.
707
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
708 708
 
709
-		// Hook the updated_post_meta action to the Thumbnail service.
710
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
709
+        // Hook the updated_post_meta action to the Thumbnail service.
710
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
711 711
 
712
-		// Hook posts inserts (or updates) to the user service.
713
-		$this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
712
+        // Hook posts inserts (or updates) to the user service.
713
+        $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
714 714
 
715
-		// Hook the AJAX wl_timeline action to the Timeline service.
716
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
715
+        // Hook the AJAX wl_timeline action to the Timeline service.
716
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
717 717
 
718
-		// Register custom allowed redirect hosts.
719
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
720
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
721
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
722
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
723
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
724
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
725
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
718
+        // Register custom allowed redirect hosts.
719
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
720
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
721
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
722
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
723
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
724
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
725
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
726 726
 
727
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
728
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
729
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
730
-		$this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
727
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
728
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
729
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
730
+        $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
731 731
 
732
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
733
-		$this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
732
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
733
+        $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
734 734
 
735
-		// Entity listing customization (wp-admin/edit.php)
736
-		// Add custom columns
737
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
738
-		$this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
739
-		// Add 4W selection
740
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
741
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
742
-
743
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
744
-
745
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
746
-		// entities.
747
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
748
-
749
-		// Filter imported post meta.
750
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
751
-
752
-		// Notify the import service when an import starts and ends.
753
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
754
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
755
-
756
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
757
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
758
-
759
-		// Hook the menu to the Download Your Data page.
760
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
761
-
762
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
763
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
764
-
765
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
766
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
767
-
768
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
769
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
770
-
771
-		// Hook the `admin_init` function to the Admin Setup.
772
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
773
-
774
-	}
775
-
776
-	/**
777
-	 * Register all of the hooks related to the public-facing functionality
778
-	 * of the plugin.
779
-	 *
780
-	 * @since    1.0.0
781
-	 * @access   private
782
-	 */
783
-	private function define_public_hooks() {
784
-
785
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
786
-
787
-		// Register the entity post type.
788
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
789
-
790
-		// Bind the link generation and handling hooks to the entity link service.
791
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
792
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
793
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
794
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
795
-
796
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
797
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
798
-
799
-		// Hook the content filter service to add entity links.
800
-		$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
801
-
802
-		// Hook the AJAX wl_timeline action to the Timeline service.
803
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
804
-
805
-		// Hook the ShareThis service.
806
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
807
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
808
-
809
-		$this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
810
-		$this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX );
811
-
812
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
813
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
814
-
815
-	}
816
-
817
-	/**
818
-	 * Run the loader to execute all of the hooks with WordPress.
819
-	 *
820
-	 * @since    1.0.0
821
-	 */
822
-	public function run() {
823
-		$this->loader->run();
824
-	}
825
-
826
-	/**
827
-	 * The name of the plugin used to uniquely identify it within the context of
828
-	 * WordPress and to define internationalization functionality.
829
-	 *
830
-	 * @since     1.0.0
831
-	 * @return    string    The name of the plugin.
832
-	 */
833
-	public function get_plugin_name() {
834
-		return $this->plugin_name;
835
-	}
836
-
837
-	/**
838
-	 * The reference to the class that orchestrates the hooks with the plugin.
839
-	 *
840
-	 * @since     1.0.0
841
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
842
-	 */
843
-	public function get_loader() {
844
-		return $this->loader;
845
-	}
846
-
847
-	/**
848
-	 * Retrieve the version number of the plugin.
849
-	 *
850
-	 * @since     1.0.0
851
-	 * @return    string    The version number of the plugin.
852
-	 */
853
-	public function get_version() {
854
-		return $this->version;
855
-	}
735
+        // Entity listing customization (wp-admin/edit.php)
736
+        // Add custom columns
737
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
738
+        $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
739
+        // Add 4W selection
740
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
741
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
742
+
743
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
744
+
745
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
746
+        // entities.
747
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
748
+
749
+        // Filter imported post meta.
750
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
751
+
752
+        // Notify the import service when an import starts and ends.
753
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
754
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
755
+
756
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
757
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
758
+
759
+        // Hook the menu to the Download Your Data page.
760
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
761
+
762
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
763
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
764
+
765
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
766
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
767
+
768
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
769
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
770
+
771
+        // Hook the `admin_init` function to the Admin Setup.
772
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
773
+
774
+    }
775
+
776
+    /**
777
+     * Register all of the hooks related to the public-facing functionality
778
+     * of the plugin.
779
+     *
780
+     * @since    1.0.0
781
+     * @access   private
782
+     */
783
+    private function define_public_hooks() {
784
+
785
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
786
+
787
+        // Register the entity post type.
788
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
789
+
790
+        // Bind the link generation and handling hooks to the entity link service.
791
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
792
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
793
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
794
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
795
+
796
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
797
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
798
+
799
+        // Hook the content filter service to add entity links.
800
+        $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
801
+
802
+        // Hook the AJAX wl_timeline action to the Timeline service.
803
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
804
+
805
+        // Hook the ShareThis service.
806
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
807
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
808
+
809
+        $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
810
+        $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX );
811
+
812
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
813
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
814
+
815
+    }
816
+
817
+    /**
818
+     * Run the loader to execute all of the hooks with WordPress.
819
+     *
820
+     * @since    1.0.0
821
+     */
822
+    public function run() {
823
+        $this->loader->run();
824
+    }
825
+
826
+    /**
827
+     * The name of the plugin used to uniquely identify it within the context of
828
+     * WordPress and to define internationalization functionality.
829
+     *
830
+     * @since     1.0.0
831
+     * @return    string    The name of the plugin.
832
+     */
833
+    public function get_plugin_name() {
834
+        return $this->plugin_name;
835
+    }
836
+
837
+    /**
838
+     * The reference to the class that orchestrates the hooks with the plugin.
839
+     *
840
+     * @since     1.0.0
841
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
842
+     */
843
+    public function get_loader() {
844
+        return $this->loader;
845
+    }
846
+
847
+    /**
848
+     * Retrieve the version number of the plugin.
849
+     *
850
+     * @since     1.0.0
851
+     * @return    string    The version number of the plugin.
852
+     */
853
+    public function get_version() {
854
+        return $this->version;
855
+    }
856 856
 
857 857
 }
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-setup.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,34 +16,34 @@  discard block
 block discarded – undo
16 16
 
17 17
 	<?php
18 18
 
19
-	// Enqueue wp.media functions.
20
-	wp_enqueue_media();
21
-
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(
25
-		'common',
26
-		'wl-font-awesome',
27
-	) );
28
-	wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'js/wordlift-admin-setup.js', array( 'jquery' ) );
29
-
30
-	// Set configuration settings.
31
-	wp_localize_script( 'wordlift-admin-setup', '_wlAdminSetup', array(
32
-		'ajaxUrl' => parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ),
33
-		'action'  => 'wl_validate_key',
34
-		'media'   => array(
35
-			'title'  => __( 'WordLift Choose Logo', 'wordlift' ),
36
-			'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
37
-		),
38
-	) );
39
-
40
-	// Finally print styles and scripts.
41
-	wp_print_styles();
42
-	wp_print_scripts();
43
-	//	do_action( 'admin_print_styles' );
44
-	//	do_action( 'admin_print_scripts' );
45
-
46
-	?>
19
+    // Enqueue wp.media functions.
20
+    wp_enqueue_media();
21
+
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(
25
+        'common',
26
+        'wl-font-awesome',
27
+    ) );
28
+    wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( dirname( __FILE__ ) ) . 'js/wordlift-admin-setup.js', array( 'jquery' ) );
29
+
30
+    // Set configuration settings.
31
+    wp_localize_script( 'wordlift-admin-setup', '_wlAdminSetup', array(
32
+        'ajaxUrl' => parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ),
33
+        'action'  => 'wl_validate_key',
34
+        'media'   => array(
35
+            'title'  => __( 'WordLift Choose Logo', 'wordlift' ),
36
+            'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
37
+        ),
38
+    ) );
39
+
40
+    // Finally print styles and scripts.
41
+    wp_print_styles();
42
+    wp_print_scripts();
43
+    //	do_action( 'admin_print_styles' );
44
+    //	do_action( 'admin_print_scripts' );
45
+
46
+    ?>
47 47
 
48 48
 	<!-- Pane 1 content -->
49 49
 	<script type="text/html" id="page-0">
@@ -133,20 +133,20 @@  discard block
 block discarded – undo
133 133
 		<select id="language" name="language" placeholder="<?php esc_attr_e( 'Choose your language', 'wordlift' ); ?>">
134 134
 			<?php
135 135
 
136
-			// Get WordLift's supported languages.
137
-			$languages = Wordlift_Languages::get_languages();
136
+            // Get WordLift's supported languages.
137
+            $languages = Wordlift_Languages::get_languages();
138 138
 
139
-			// Get WP's locale.
140
-			$locale = get_locale();
139
+            // Get WP's locale.
140
+            $locale = get_locale();
141 141
 
142
-			// Get the language locale part.
143
-			$parts = explode( '_', $locale );
142
+            // Get the language locale part.
143
+            $parts = explode( '_', $locale );
144 144
 
145
-			// If we support WP's configured language, then use that, otherwise use English by default.
146
-			$language = isset( $languages[ $parts[0] ] ) ? $parts[0] : 'en';
145
+            // If we support WP's configured language, then use that, otherwise use English by default.
146
+            $language = isset( $languages[ $parts[0] ] ) ? $parts[0] : 'en';
147 147
 
148
-			// Print all the supported language, preselecting the one configured in WP (or English if not supported).
149
-			foreach ( $languages as $code => $label ) { ?>
148
+            // Print all the supported language, preselecting the one configured in WP (or English if not supported).
149
+            foreach ( $languages as $code => $label ) { ?>
150 150
 				<option
151 151
 					value="<?php esc_attr_e( $code ) ?>" <?php echo selected( $code, $language, FALSE ) ?>><?php esc_html_e( $label ) ?></option>
152 152
 			<?php } ?>
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 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,22 +20,22 @@  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
 		'common',
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
 	// Set configuration settings.
31
-	wp_localize_script( 'wordlift-admin-setup', '_wlAdminSetup', array(
32
-		'ajaxUrl' => parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ),
31
+	wp_localize_script('wordlift-admin-setup', '_wlAdminSetup', array(
32
+		'ajaxUrl' => parse_url(self_admin_url('admin-ajax.php'), PHP_URL_PATH),
33 33
 		'action'  => 'wl_validate_key',
34 34
 		'media'   => array(
35
-			'title'  => __( 'WordLift Choose Logo', 'wordlift' ),
36
-			'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
35
+			'title'  => __('WordLift Choose Logo', 'wordlift'),
36
+			'button' => array('text' => __('Choose Logo', 'wordlift')),
37 37
 		),
38
-	) );
38
+	));
39 39
 
40 40
 	// Finally print styles and scripts.
41 41
 	wp_print_styles();
@@ -47,90 +47,90 @@  discard block
 block discarded – undo
47 47
 
48 48
 	<!-- Pane 1 content -->
49 49
 	<script type="text/html" id="page-0">
50
-		<h2 class="page-title"><?php esc_html_e( 'Welcome', 'wordlift' ); ?></h2>
50
+		<h2 class="page-title"><?php esc_html_e('Welcome', 'wordlift'); ?></h2>
51 51
 		<p class="page-txt">
52
-			<?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' ); ?>
52
+			<?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'); ?>
53 53
 		</p>
54 54
 		<ul class="page-list">
55 55
 			<li>
56 56
 				<span class="fa fa-university"></span>
57
-				<?php esc_html_e( 'Trustworthiness', 'wordlift' ); ?>
57
+				<?php esc_html_e('Trustworthiness', 'wordlift'); ?>
58 58
 			</li>
59 59
 
60 60
 			<li>
61 61
 				<span class="fa fa-map-marker"></span>
62
-				<?php esc_html_e( 'Enrichment', 'wordlift' ); ?>
62
+				<?php esc_html_e('Enrichment', 'wordlift'); ?>
63 63
 			</li>
64 64
 
65 65
 			<li>
66 66
 				<span class="fa fa-heart"></span>
67
-				<?php esc_html_e( 'Engagement', 'wordlift' ); ?>
67
+				<?php esc_html_e('Engagement', 'wordlift'); ?>
68 68
 			</li>
69 69
 
70 70
 			<li>
71 71
 				<span class="fa fa-hand-o-right"></span>
72
-				<?php esc_html_e( 'Smart Navigation', 'wordlift' ); ?>
72
+				<?php esc_html_e('Smart Navigation', 'wordlift'); ?>
73 73
 			</li>
74 74
 
75 75
 			<li>
76 76
 				<span class="fa fa-google"></span>
77
-				<?php esc_html_e( 'SEO Optimization', 'wordlift' ); ?>
77
+				<?php esc_html_e('SEO Optimization', 'wordlift'); ?>
78 78
 			</li>
79 79
 
80 80
 			<li>
81 81
 				<span class="fa fa-group"></span>
82
-				<?php esc_html_e( 'Content Marketing', 'wordlift' ); ?>
82
+				<?php esc_html_e('Content Marketing', 'wordlift'); ?>
83 83
 			</li>
84 84
 		</ul>
85 85
 		<div class="btn-wrapper">
86 86
 			<a href="https://wordlift.io/blogger/?utm_campaign=wl_activation_learn_more" target="_tab"
87
-			   class="button"><?php esc_html_e( 'Learn More', 'wordlift' ); ?></a>
87
+			   class="button"><?php esc_html_e('Learn More', 'wordlift'); ?></a>
88 88
 			<input type="button" data-wl-next="wl-next" class="wl-default-action"
89
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
89
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
90 90
 		</div>
91 91
 	</script>
92 92
 
93 93
 	<!-- Pane 2 content -->
94 94
 	<script type="text/html" id="page-1">
95
-		<h2 class="page-title"><?php esc_html_e( 'License Key', 'wordlift' ); ?></h2>
95
+		<h2 class="page-title"><?php esc_html_e('License Key', 'wordlift'); ?></h2>
96 96
 		<p class="page-txt">
97
-			<?php esc_html_e( 'If you already puchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift' ); ?>
97
+			<?php esc_html_e('If you already puchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise ....', 'wordlift'); ?>
98 98
 		</p>
99 99
 		<input type="text" data-wl-key="wl-key" class="invalid untouched" id="key" name="key" value=""
100 100
 		       autocomplete="off" placeholder="Activation Key">
101 101
 		<div class="btn-wrapper">
102 102
 			<a
103 103
 				href="https://wordlift.io/?utm_campaign=wl_activation_grab_the_key#plan-and-price" target="_tab"
104
-				class="button"><?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?></a><input
104
+				class="button"><?php esc_html_e('Grab a Key!', 'wordlift'); ?></a><input
105 105
 				type="button" data-wl-next="wl-next" class="wl-default-action"
106
-				value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
106
+				value="<?php esc_attr_e('Next', 'wordlift'); ?>">
107 107
 		</div>
108 108
 	</script>
109 109
 
110 110
 	<!-- Pane 3 content -->
111 111
 	<script type="text/html" id="page-2">
112
-		<h2 class="page-title"><?php esc_html_e( 'Vocabulary', 'wordlift' ); ?></h2>
112
+		<h2 class="page-title"><?php esc_html_e('Vocabulary', 'wordlift'); ?></h2>
113 113
 		<p class="page-txt">
114
-			<?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' ); ?>
114
+			<?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'); ?>
115 115
 		</p>
116 116
 		<input type="text" id="vocabulary" name="vocabulary" autocomplete="off" value="vocabulary"
117 117
 		       class="valid untouched" data-wl-vocabulary="wl-vocabulary">
118 118
 		<p class="page-det">
119
-			<?php esc_html_e( 'Leave it empty to place your entities in the root folder of your website', 'wordlift' ); ?>
119
+			<?php esc_html_e('Leave it empty to place your entities in the root folder of your website', 'wordlift'); ?>
120 120
 		</p>
121 121
 		<div class="btn-wrapper">
122 122
 			<input type="button" data-wl-next="wl-next" class="wl-default-action"
123
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
123
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
124 124
 		</div>
125 125
 	</script>
126 126
 
127 127
 	<!-- Pane 4 content -->
128 128
 	<script type="text/html" id="page-3">
129
-		<h2 class="page-title"><?php esc_html_e( 'Language', 'wordlift' ); ?></h2>
129
+		<h2 class="page-title"><?php esc_html_e('Language', 'wordlift'); ?></h2>
130 130
 		<p class="page-txt">
131
-			<?php esc_html_e( 'Each WordLift key can be used only in one language. Pick yours.', 'wordlift' ); ?>
131
+			<?php esc_html_e('Each WordLift key can be used only in one language. Pick yours.', 'wordlift'); ?>
132 132
 		</p>
133
-		<select id="language" name="language" placeholder="<?php esc_attr_e( 'Choose your language', 'wordlift' ); ?>">
133
+		<select id="language" name="language" placeholder="<?php esc_attr_e('Choose your language', 'wordlift'); ?>">
134 134
 			<?php
135 135
 
136 136
 			// Get WordLift's supported languages.
@@ -140,45 +140,45 @@  discard block
 block discarded – undo
140 140
 			$locale = get_locale();
141 141
 
142 142
 			// Get the language locale part.
143
-			$parts = explode( '_', $locale );
143
+			$parts = explode('_', $locale);
144 144
 
145 145
 			// If we support WP's configured language, then use that, otherwise use English by default.
146
-			$language = isset( $languages[ $parts[0] ] ) ? $parts[0] : 'en';
146
+			$language = isset($languages[$parts[0]]) ? $parts[0] : 'en';
147 147
 
148 148
 			// Print all the supported language, preselecting the one configured in WP (or English if not supported).
149
-			foreach ( $languages as $code => $label ) { ?>
149
+			foreach ($languages as $code => $label) { ?>
150 150
 				<option
151
-					value="<?php esc_attr_e( $code ) ?>" <?php echo selected( $code, $language, FALSE ) ?>><?php esc_html_e( $label ) ?></option>
151
+					value="<?php esc_attr_e($code) ?>" <?php echo selected($code, $language, FALSE) ?>><?php esc_html_e($label) ?></option>
152 152
 			<?php } ?>
153 153
 		</select>
154 154
 
155 155
 		<div class="btn-wrapper">
156 156
 			<input type="button" data-wl-next="wl-next" class="wl-default-action"
157
-			       value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>">
157
+			       value="<?php esc_attr_e('Next', 'wordlift'); ?>">
158 158
 		</div>
159 159
 	</script>
160 160
 
161 161
 	<!-- Pane 5 content -->
162 162
 	<script type="text/html" id="page-4">
163
-		<h2 class="page-title"><?php esc_html_e( 'Publisher', 'wordlift' ); ?></h2>
163
+		<h2 class="page-title"><?php esc_html_e('Publisher', 'wordlift'); ?></h2>
164 164
 		<p class="page-txt">
165
-			<?php esc_html_e( 'Are you going to publish as an individual or as a company?', 'wordlift' ); ?>
165
+			<?php esc_html_e('Are you going to publish as an individual or as a company?', 'wordlift'); ?>
166 166
 		</p>
167 167
 		<div class="radio-wrapper">
168 168
 			<label for="personal">
169 169
 				<input id="personal" type="radio" name="user_type" value="person" checked>
170 170
 				<span class="radio"><span class="check"></span></span>
171
-				<span class="label"><?php esc_html_e( 'Personal', 'wordlift' ); ?></span>
171
+				<span class="label"><?php esc_html_e('Personal', 'wordlift'); ?></span>
172 172
 			</label>
173 173
 			<label for="company">
174 174
 				<input id="company" type="radio" name="user_type" value="organization">
175 175
 				<span class="radio"><span class="check"></span></span>
176
-				<span class="label"><?php esc_html_e( 'Company', 'wordlift' ); ?></span>
176
+				<span class="label"><?php esc_html_e('Company', 'wordlift'); ?></span>
177 177
 			</label>
178 178
 		</div>
179 179
 		<input type="text" id="name" name="name" data-wl-name="wl-name" value="" autocomplete="off"
180 180
 		       class="untouched invalid"
181
-		       placeholder="<?php esc_attr_e( "What's your name?", 'wordlift' ); ?>">
181
+		       placeholder="<?php esc_attr_e("What's your name?", 'wordlift'); ?>">
182 182
 
183 183
 		<div data-wl-logo="wl-logo">
184 184
 			<input type="hidden" name="logo"/>
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 				<a data-wl-remove-logo="wl-remove-logo" href="javascript:void(0);" class="fa fa-times"></a>
187 187
 			</div>
188 188
 			<a data-wl-add-logo="wl-add-logo" class="add-logo" href="javascript:void(0);">
189
-				<?php esc_html_e( 'Add your logo', 'wordlift' ); ?>
189
+				<?php esc_html_e('Add your logo', 'wordlift'); ?>
190 190
 			</a>
191 191
 		</div>
192 192
 		<div class="btn-wrapper">
193 193
 			<input type="submit" id="btn-finish" class="wl-default-action"
194
-			       value="<?php esc_attr_e( 'Finish', 'wordlift' ); ?>">
194
+			       value="<?php esc_attr_e('Finish', 'wordlift'); ?>">
195 195
 		</div>
196 196
 	</script>
197 197
 
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 
201 201
 <div class="wl-container">
202 202
 
203
-	<a href="<?php echo esc_url( admin_url() ); ?> " class="fa fa-times wl-close"></a>
203
+	<a href="<?php echo esc_url(admin_url()); ?> " class="fa fa-times wl-close"></a>
204 204
 
205 205
 	<header>
206 206
 		<h1><strong>Word</strong>Lift</h1>
207
-		<img src="<?php echo plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/shapes.png'; ?>"/>
207
+		<img src="<?php echo plugin_dir_url(dirname(dirname(__FILE__))).'images/shapes.png'; ?>"/>
208 208
 	</header>
209 209
 
210 210
 
211 211
 	<form method="post">
212
-		<?php wp_nonce_field( 'wl-save-configuration' ); ?>
212
+		<?php wp_nonce_field('wl-save-configuration'); ?>
213 213
 		<input type="hidden" name="action" value="wl-save-configuration"/>
214 214
 		<div class="viewport"></div>
215 215
 	</form>
216 216
 
217 217
 </div>
218 218
 
219
-<?php do_action( 'admin_footer' ); ?>
219
+<?php do_action('admin_footer'); ?>
220 220
 
221 221
 </body>
222 222
 </html>
223 223
\ No newline at end of file
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-entity-list.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -13,203 +13,203 @@
 block discarded – undo
13 13
  */
14 14
 class Wordlift_Entity_List_Service {
15 15
 
16
-	/**
17
-	 * Size of the entity thumbnail in pixels
18
-	 *
19
-	 * @since  3.3.0
20
-	 */
21
-	const THUMB_SIZE = 50;
22
-
23
-	/**
24
-	 * The Entity service.
25
-	 *
26
-	 * @since  3.3.0
27
-	 * @access private
28
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
29
-	 */
30
-	private $entity_service;
31
-
32
-	/**
33
-	 * Create a Wordlift_Entity_List_Service.
34
-	 *
35
-	 * @since 3.3.0
36
-	 *
37
-	 * @param \Wordlift_Entity_Service $entity_service The Entity service.
38
-	 */
39
-	public function __construct( $entity_service ) {
40
-
41
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_List_Service' );
42
-
43
-		$this->entity_service = $entity_service;
44
-
45
-	}
46
-
47
-	/**
48
-	 * Register custom columns for entity listing in backend.
49
-	 *
50
-	 * @see   https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column
51
-	 *
52
-	 * @since 3.3.0
53
-	 *
54
-	 * @param array $columns the default columns.
55
-	 *
56
-	 * @return array Enhanced columns array.
57
-	 */
58
-	public function register_custom_columns( $columns ) {
59
-
60
-		// Take away first column and keep a reference,
61
-		// so we can later insert the thumbnail between the first and the rest of columns.
62
-		$columns_cb = $columns['cb'];
63
-		unset( $columns['cb'] );
64
-
65
-		// Thumbnails column is inserted in second place, while the related posts on the end.
66
-		$columns = array_merge(
67
-			array( 'cb' => $columns_cb ),                      // re-add first column
68
-			array( 'wl_column_thumbnail' => __( 'Image', 'wordlift' ) ),        // thumb
69
-			$columns,                                                               // default columns (without the first)
70
-			array( 'wl_column_related_posts' => __( 'Related Posts', 'wordlift' ) ), // related posts
71
-			array( 'wl_column_rating' => __( 'Rating', 'wordlift' ) ) // related posts
72
-		);
73
-
74
-		return $columns;
75
-	}
76
-
77
-	/**
78
-	 * Render custom columns.
79
-	 *
80
-	 * @see   https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
81
-	 *
82
-	 * @since 3.3.0
83
-	 *
84
-	 * @param string $column    the current column.
85
-	 * @param int    $entity_id An entity post id.
86
-	 */
87
-	public function render_custom_columns( $column, $entity_id ) {
88
-
89
-		switch ( $column ) {
90
-
91
-			case 'wl_column_related_posts':
92
-				echo count( wl_core_get_related_post_ids( $entity_id ) );
93
-				break;
94
-
95
-			case 'wl_column_thumbnail':
96
-
97
-				$edit_link = get_edit_post_link( $entity_id );
98
-				$thumb     = get_the_post_thumbnail( $entity_id, array( self::THUMB_SIZE, self::THUMB_SIZE ) );
99
-
100
-				if ( ! $thumb ) {
101
-					$thumb = "<img src='" . WL_DEFAULT_THUMBNAIL_PATH . "' width='" . self::THUMB_SIZE . "' />";
102
-				}
103
-				echo "<a href='" . esc_url( $edit_link ) . "'>$thumb</a>";
104
-				break;
105
-
106
-			case 'wl_column_rating':
107
-
108
-				$rating = $this->entity_service->get_rating_for( $entity_id );
109
-				echo '<i class="wl-traffic-light wl-tl-' . $rating['traffic_light_score'] . '">' . $rating['percentage_score'] . '%</i>';
110
-				break;
111
-		}
112
-
113
-	}
114
-
115
-	/**
116
-	 * Add wl-classification-scope select box before the 'Filter' button.
117
-	 *
118
-	 * @since 3.3.0
119
-	 */
120
-	public function restrict_manage_posts_classification_scope() {
121
-
122
-		// Return safely if get_current_screen() is not defined (yet)
123
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
124
-			return;
125
-		}
126
-
127
-		$screen = get_current_screen();
128
-		// If there is any valid screen nothing to do
129
-		if ( NULL === $screen ) {
130
-			return;
131
-		}
132
-
133
-		if ( $screen->post_type !== Wordlift_Entity_Service::TYPE_NAME ) {
134
-			return;
135
-		}
136
-
137
-		// Was a W already selected?
138
-		$selected = isset( $_GET['wl-classification-scope'] ) ?
139
-			$_GET['wl-classification-scope'] : '';
140
-
141
-		// Print select box with the 4W
142
-		$all_w = array(
143
-			__( "All 'W'" ),
144
-			WL_WHAT_RELATION,
145
-			WL_WHO_RELATION,
146
-			WL_WHERE_RELATION,
147
-			WL_WHEN_RELATION,
148
-		);
149
-		echo '<select name="wl-classification-scope" id="wl-dropdown-classification-scope">';
150
-		foreach ( $all_w as $w ) {
151
-			$default = ( $selected === $w ) ? 'selected' : '';
152
-			echo sprintf( '<option value="%s" %s >%s</option>', $w, $default, __( $w ) );
153
-		}
154
-		echo '</select>';
155
-	}
156
-
157
-	/**
158
-	 * Server side response operations for the classification filter set in *restrict_manage_posts_classification_scope_filter*
159
-	 *
160
-	 * @since 3.3.0
161
-	 *
162
-	 * @param array $clauses WP main query clauses.
163
-	 *
164
-	 * @return array Modified clauses.
165
-	 */
166
-	public function posts_clauses_classification_scope( $clauses ) {
167
-
168
-		// Run only on admin page.
169
-		if ( ! is_admin() ) {
170
-			return $clauses;
171
-		}
172
-
173
-		// Return safely if get_current_screen() is not defined (yet).
174
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
175
-			return $clauses;
176
-		}
177
-
178
-		// Only apply on entity list page, only if this is the main query and if the wl-classification-scope query param is set.
179
-		$screen = get_current_screen();
180
-
181
-		// If there is any valid screen nothing to do.
182
-		if ( NULL === $screen ) {
183
-			return $clauses;
184
-		}
185
-
186
-		if ( ! ( $screen->post_type === Wordlift_Entity_Service::TYPE_NAME && is_main_query() && isset( $_GET['wl-classification-scope'] ) ) ) {
187
-			return $clauses;
188
-		}
189
-
190
-		// Check a valid W was requested.
191
-		$requested_w = $_GET['wl-classification-scope'];
192
-
193
-		$all_w = array(
194
-			WL_WHAT_RELATION,
195
-			WL_WHO_RELATION,
196
-			WL_WHERE_RELATION,
197
-			WL_WHEN_RELATION,
198
-		);
199
-
200
-		if ( ! in_array( $requested_w, $all_w ) ) {
201
-			return $clauses;
202
-		}
203
-
204
-		global $wpdb;
205
-		$wl_relation_table = wl_core_get_relation_instances_table_name();
206
-
207
-		// Change WP main query clauses.
208
-		$clauses['join'] .= "INNER JOIN {$wl_relation_table} ON {$wpdb->posts}.ID = {$wl_relation_table}.object_id";
209
-		$clauses['where'] .= $wpdb->prepare( "AND {$wl_relation_table}.predicate = %s", $requested_w );
210
-		$clauses['distinct'] .= "DISTINCT";
211
-
212
-		return $clauses;
213
-	}
16
+    /**
17
+     * Size of the entity thumbnail in pixels
18
+     *
19
+     * @since  3.3.0
20
+     */
21
+    const THUMB_SIZE = 50;
22
+
23
+    /**
24
+     * The Entity service.
25
+     *
26
+     * @since  3.3.0
27
+     * @access private
28
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
29
+     */
30
+    private $entity_service;
31
+
32
+    /**
33
+     * Create a Wordlift_Entity_List_Service.
34
+     *
35
+     * @since 3.3.0
36
+     *
37
+     * @param \Wordlift_Entity_Service $entity_service The Entity service.
38
+     */
39
+    public function __construct( $entity_service ) {
40
+
41
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_List_Service' );
42
+
43
+        $this->entity_service = $entity_service;
44
+
45
+    }
46
+
47
+    /**
48
+     * Register custom columns for entity listing in backend.
49
+     *
50
+     * @see   https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column
51
+     *
52
+     * @since 3.3.0
53
+     *
54
+     * @param array $columns the default columns.
55
+     *
56
+     * @return array Enhanced columns array.
57
+     */
58
+    public function register_custom_columns( $columns ) {
59
+
60
+        // Take away first column and keep a reference,
61
+        // so we can later insert the thumbnail between the first and the rest of columns.
62
+        $columns_cb = $columns['cb'];
63
+        unset( $columns['cb'] );
64
+
65
+        // Thumbnails column is inserted in second place, while the related posts on the end.
66
+        $columns = array_merge(
67
+            array( 'cb' => $columns_cb ),                      // re-add first column
68
+            array( 'wl_column_thumbnail' => __( 'Image', 'wordlift' ) ),        // thumb
69
+            $columns,                                                               // default columns (without the first)
70
+            array( 'wl_column_related_posts' => __( 'Related Posts', 'wordlift' ) ), // related posts
71
+            array( 'wl_column_rating' => __( 'Rating', 'wordlift' ) ) // related posts
72
+        );
73
+
74
+        return $columns;
75
+    }
76
+
77
+    /**
78
+     * Render custom columns.
79
+     *
80
+     * @see   https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
81
+     *
82
+     * @since 3.3.0
83
+     *
84
+     * @param string $column    the current column.
85
+     * @param int    $entity_id An entity post id.
86
+     */
87
+    public function render_custom_columns( $column, $entity_id ) {
88
+
89
+        switch ( $column ) {
90
+
91
+            case 'wl_column_related_posts':
92
+                echo count( wl_core_get_related_post_ids( $entity_id ) );
93
+                break;
94
+
95
+            case 'wl_column_thumbnail':
96
+
97
+                $edit_link = get_edit_post_link( $entity_id );
98
+                $thumb     = get_the_post_thumbnail( $entity_id, array( self::THUMB_SIZE, self::THUMB_SIZE ) );
99
+
100
+                if ( ! $thumb ) {
101
+                    $thumb = "<img src='" . WL_DEFAULT_THUMBNAIL_PATH . "' width='" . self::THUMB_SIZE . "' />";
102
+                }
103
+                echo "<a href='" . esc_url( $edit_link ) . "'>$thumb</a>";
104
+                break;
105
+
106
+            case 'wl_column_rating':
107
+
108
+                $rating = $this->entity_service->get_rating_for( $entity_id );
109
+                echo '<i class="wl-traffic-light wl-tl-' . $rating['traffic_light_score'] . '">' . $rating['percentage_score'] . '%</i>';
110
+                break;
111
+        }
112
+
113
+    }
114
+
115
+    /**
116
+     * Add wl-classification-scope select box before the 'Filter' button.
117
+     *
118
+     * @since 3.3.0
119
+     */
120
+    public function restrict_manage_posts_classification_scope() {
121
+
122
+        // Return safely if get_current_screen() is not defined (yet)
123
+        if ( FALSE === function_exists( 'get_current_screen' ) ) {
124
+            return;
125
+        }
126
+
127
+        $screen = get_current_screen();
128
+        // If there is any valid screen nothing to do
129
+        if ( NULL === $screen ) {
130
+            return;
131
+        }
132
+
133
+        if ( $screen->post_type !== Wordlift_Entity_Service::TYPE_NAME ) {
134
+            return;
135
+        }
136
+
137
+        // Was a W already selected?
138
+        $selected = isset( $_GET['wl-classification-scope'] ) ?
139
+            $_GET['wl-classification-scope'] : '';
140
+
141
+        // Print select box with the 4W
142
+        $all_w = array(
143
+            __( "All 'W'" ),
144
+            WL_WHAT_RELATION,
145
+            WL_WHO_RELATION,
146
+            WL_WHERE_RELATION,
147
+            WL_WHEN_RELATION,
148
+        );
149
+        echo '<select name="wl-classification-scope" id="wl-dropdown-classification-scope">';
150
+        foreach ( $all_w as $w ) {
151
+            $default = ( $selected === $w ) ? 'selected' : '';
152
+            echo sprintf( '<option value="%s" %s >%s</option>', $w, $default, __( $w ) );
153
+        }
154
+        echo '</select>';
155
+    }
156
+
157
+    /**
158
+     * Server side response operations for the classification filter set in *restrict_manage_posts_classification_scope_filter*
159
+     *
160
+     * @since 3.3.0
161
+     *
162
+     * @param array $clauses WP main query clauses.
163
+     *
164
+     * @return array Modified clauses.
165
+     */
166
+    public function posts_clauses_classification_scope( $clauses ) {
167
+
168
+        // Run only on admin page.
169
+        if ( ! is_admin() ) {
170
+            return $clauses;
171
+        }
172
+
173
+        // Return safely if get_current_screen() is not defined (yet).
174
+        if ( FALSE === function_exists( 'get_current_screen' ) ) {
175
+            return $clauses;
176
+        }
177
+
178
+        // Only apply on entity list page, only if this is the main query and if the wl-classification-scope query param is set.
179
+        $screen = get_current_screen();
180
+
181
+        // If there is any valid screen nothing to do.
182
+        if ( NULL === $screen ) {
183
+            return $clauses;
184
+        }
185
+
186
+        if ( ! ( $screen->post_type === Wordlift_Entity_Service::TYPE_NAME && is_main_query() && isset( $_GET['wl-classification-scope'] ) ) ) {
187
+            return $clauses;
188
+        }
189
+
190
+        // Check a valid W was requested.
191
+        $requested_w = $_GET['wl-classification-scope'];
192
+
193
+        $all_w = array(
194
+            WL_WHAT_RELATION,
195
+            WL_WHO_RELATION,
196
+            WL_WHERE_RELATION,
197
+            WL_WHEN_RELATION,
198
+        );
199
+
200
+        if ( ! in_array( $requested_w, $all_w ) ) {
201
+            return $clauses;
202
+        }
203
+
204
+        global $wpdb;
205
+        $wl_relation_table = wl_core_get_relation_instances_table_name();
206
+
207
+        // Change WP main query clauses.
208
+        $clauses['join'] .= "INNER JOIN {$wl_relation_table} ON {$wpdb->posts}.ID = {$wl_relation_table}.object_id";
209
+        $clauses['where'] .= $wpdb->prepare( "AND {$wl_relation_table}.predicate = %s", $requested_w );
210
+        $clauses['distinct'] .= "DISTINCT";
211
+
212
+        return $clauses;
213
+    }
214 214
 
215 215
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param \Wordlift_Entity_Service $entity_service The Entity service.
38 38
 	 */
39
-	public function __construct( $entity_service ) {
39
+	public function __construct($entity_service) {
40 40
 
41
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_List_Service' );
41
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Entity_List_Service');
42 42
 
43 43
 		$this->entity_service = $entity_service;
44 44
 
@@ -55,20 +55,20 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array Enhanced columns array.
57 57
 	 */
58
-	public function register_custom_columns( $columns ) {
58
+	public function register_custom_columns($columns) {
59 59
 
60 60
 		// Take away first column and keep a reference,
61 61
 		// so we can later insert the thumbnail between the first and the rest of columns.
62 62
 		$columns_cb = $columns['cb'];
63
-		unset( $columns['cb'] );
63
+		unset($columns['cb']);
64 64
 
65 65
 		// Thumbnails column is inserted in second place, while the related posts on the end.
66 66
 		$columns = array_merge(
67
-			array( 'cb' => $columns_cb ),                      // re-add first column
68
-			array( 'wl_column_thumbnail' => __( 'Image', 'wordlift' ) ),        // thumb
69
-			$columns,                                                               // default columns (without the first)
70
-			array( 'wl_column_related_posts' => __( 'Related Posts', 'wordlift' ) ), // related posts
71
-			array( 'wl_column_rating' => __( 'Rating', 'wordlift' ) ) // related posts
67
+			array('cb' => $columns_cb), // re-add first column
68
+			array('wl_column_thumbnail' => __('Image', 'wordlift')), // thumb
69
+			$columns, // default columns (without the first)
70
+			array('wl_column_related_posts' => __('Related Posts', 'wordlift')), // related posts
71
+			array('wl_column_rating' => __('Rating', 'wordlift')) // related posts
72 72
 		);
73 73
 
74 74
 		return $columns;
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
 	 * @param string $column    the current column.
85 85
 	 * @param int    $entity_id An entity post id.
86 86
 	 */
87
-	public function render_custom_columns( $column, $entity_id ) {
87
+	public function render_custom_columns($column, $entity_id) {
88 88
 
89
-		switch ( $column ) {
89
+		switch ($column) {
90 90
 
91 91
 			case 'wl_column_related_posts':
92
-				echo count( wl_core_get_related_post_ids( $entity_id ) );
92
+				echo count(wl_core_get_related_post_ids($entity_id));
93 93
 				break;
94 94
 
95 95
 			case 'wl_column_thumbnail':
96 96
 
97
-				$edit_link = get_edit_post_link( $entity_id );
98
-				$thumb     = get_the_post_thumbnail( $entity_id, array( self::THUMB_SIZE, self::THUMB_SIZE ) );
97
+				$edit_link = get_edit_post_link($entity_id);
98
+				$thumb     = get_the_post_thumbnail($entity_id, array(self::THUMB_SIZE, self::THUMB_SIZE));
99 99
 
100
-				if ( ! $thumb ) {
101
-					$thumb = "<img src='" . WL_DEFAULT_THUMBNAIL_PATH . "' width='" . self::THUMB_SIZE . "' />";
100
+				if ( ! $thumb) {
101
+					$thumb = "<img src='".WL_DEFAULT_THUMBNAIL_PATH."' width='".self::THUMB_SIZE."' />";
102 102
 				}
103
-				echo "<a href='" . esc_url( $edit_link ) . "'>$thumb</a>";
103
+				echo "<a href='".esc_url($edit_link)."'>$thumb</a>";
104 104
 				break;
105 105
 
106 106
 			case 'wl_column_rating':
107 107
 
108
-				$rating = $this->entity_service->get_rating_for( $entity_id );
109
-				echo '<i class="wl-traffic-light wl-tl-' . $rating['traffic_light_score'] . '">' . $rating['percentage_score'] . '%</i>';
108
+				$rating = $this->entity_service->get_rating_for($entity_id);
109
+				echo '<i class="wl-traffic-light wl-tl-'.$rating['traffic_light_score'].'">'.$rating['percentage_score'].'%</i>';
110 110
 				break;
111 111
 		}
112 112
 
@@ -120,36 +120,36 @@  discard block
 block discarded – undo
120 120
 	public function restrict_manage_posts_classification_scope() {
121 121
 
122 122
 		// Return safely if get_current_screen() is not defined (yet)
123
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
123
+		if (FALSE === function_exists('get_current_screen')) {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		$screen = get_current_screen();
128 128
 		// If there is any valid screen nothing to do
129
-		if ( NULL === $screen ) {
129
+		if (NULL === $screen) {
130 130
 			return;
131 131
 		}
132 132
 
133
-		if ( $screen->post_type !== Wordlift_Entity_Service::TYPE_NAME ) {
133
+		if ($screen->post_type !== Wordlift_Entity_Service::TYPE_NAME) {
134 134
 			return;
135 135
 		}
136 136
 
137 137
 		// Was a W already selected?
138
-		$selected = isset( $_GET['wl-classification-scope'] ) ?
138
+		$selected = isset($_GET['wl-classification-scope']) ?
139 139
 			$_GET['wl-classification-scope'] : '';
140 140
 
141 141
 		// Print select box with the 4W
142 142
 		$all_w = array(
143
-			__( "All 'W'" ),
143
+			__("All 'W'"),
144 144
 			WL_WHAT_RELATION,
145 145
 			WL_WHO_RELATION,
146 146
 			WL_WHERE_RELATION,
147 147
 			WL_WHEN_RELATION,
148 148
 		);
149 149
 		echo '<select name="wl-classification-scope" id="wl-dropdown-classification-scope">';
150
-		foreach ( $all_w as $w ) {
151
-			$default = ( $selected === $w ) ? 'selected' : '';
152
-			echo sprintf( '<option value="%s" %s >%s</option>', $w, $default, __( $w ) );
150
+		foreach ($all_w as $w) {
151
+			$default = ($selected === $w) ? 'selected' : '';
152
+			echo sprintf('<option value="%s" %s >%s</option>', $w, $default, __($w));
153 153
 		}
154 154
 		echo '</select>';
155 155
 	}
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return array Modified clauses.
165 165
 	 */
166
-	public function posts_clauses_classification_scope( $clauses ) {
166
+	public function posts_clauses_classification_scope($clauses) {
167 167
 
168 168
 		// Run only on admin page.
169
-		if ( ! is_admin() ) {
169
+		if ( ! is_admin()) {
170 170
 			return $clauses;
171 171
 		}
172 172
 
173 173
 		// Return safely if get_current_screen() is not defined (yet).
174
-		if ( FALSE === function_exists( 'get_current_screen' ) ) {
174
+		if (FALSE === function_exists('get_current_screen')) {
175 175
 			return $clauses;
176 176
 		}
177 177
 
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 		$screen = get_current_screen();
180 180
 
181 181
 		// If there is any valid screen nothing to do.
182
-		if ( NULL === $screen ) {
182
+		if (NULL === $screen) {
183 183
 			return $clauses;
184 184
 		}
185 185
 
186
-		if ( ! ( $screen->post_type === Wordlift_Entity_Service::TYPE_NAME && is_main_query() && isset( $_GET['wl-classification-scope'] ) ) ) {
186
+		if ( ! ($screen->post_type === Wordlift_Entity_Service::TYPE_NAME && is_main_query() && isset($_GET['wl-classification-scope']))) {
187 187
 			return $clauses;
188 188
 		}
189 189
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			WL_WHEN_RELATION,
198 198
 		);
199 199
 
200
-		if ( ! in_array( $requested_w, $all_w ) ) {
200
+		if ( ! in_array($requested_w, $all_w)) {
201 201
 			return $clauses;
202 202
 		}
203 203
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 		// Change WP main query clauses.
208 208
 		$clauses['join'] .= "INNER JOIN {$wl_relation_table} ON {$wpdb->posts}.ID = {$wl_relation_table}.object_id";
209
-		$clauses['where'] .= $wpdb->prepare( "AND {$wl_relation_table}.predicate = %s", $requested_w );
209
+		$clauses['where'] .= $wpdb->prepare("AND {$wl_relation_table}.predicate = %s", $requested_w);
210 210
 		$clauses['distinct'] .= "DISTINCT";
211 211
 
212 212
 		return $clauses;
Please login to merge, or discard this patch.
src/admin/WL_Metabox/WL_Metabox.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -14,269 +14,269 @@
 block discarded – undo
14 14
  */
15 15
 class WL_Metabox {
16 16
 
17
-	public $fields;
18
-
19
-	/**
20
-	 * WL_Metabox constructor.
21
-	 *
22
-	 * @since 3.1.0
23
-	 */
24
-	public function __construct() {
25
-
26
-		// Add hooks to print metaboxes and save submitted data.
27
-		add_action( 'add_meta_boxes', array( &$this, 'add_main_metabox' ) );
28
-		add_action( 'wl_linked_data_save_post', array(
29
-			&$this,
30
-			'save_form_data',
31
-		) );
32
-
33
-		// Enqueue js and css.
34
-		$this->enqueue_scripts_and_styles();
35
-
36
-	}
37
-
38
-	/**
39
-	 * Add a callback to print the metabox in page.
40
-	 * Wordpress will fire the $this->html() callback at the right time.
41
-	 */
42
-	public function add_main_metabox() {
43
-
44
-		// Add main metabox (will print also the inner fields).
45
-		$id    = uniqid( 'wl-metabox-' );
46
-		$title = get_the_title() . ' ' . __( 'properties', 'wordlift' );
47
-		add_meta_box( $id, $title, array(
48
-			$this,
49
-			'html',
50
-		), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high' );
51
-
52
-		// Add filter to change the metabox CSS class.
53
-		add_filter( "postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class' );
54
-	}
55
-
56
-	/**
57
-	 * Called from WP to print the metabox content in page.
58
-	 *
59
-	 * @since 3.1.0
60
-	 *
61
-	 * @param WP_Post $post The post.
62
-	 */
63
-	public function html( $post ) {
64
-
65
-		// Build the fields we need to print.
66
-		$this->instantiate_fields( $post->ID );
67
-
68
-		// Loop over the fields.
69
-		foreach ( $this->fields as $field ) {
70
-
71
-			// load data from DB (values will be available in $field->data).
72
-			$field->get_data();
73
-
74
-			// print field HTML (nonce included).
75
-			echo $field->html();
76
-		}
77
-
78
-	}
79
-
80
-	/**
81
-	 * Read the WL <-> Schema mapping and build the Fields for the entity being edited.
82
-	 *
83
-	 * Note: the first function that calls this method will instantiate the fields.
84
-	 * Why it isn't called from the constructor? Because we need to hook this process as late as possible.
85
-	 *
86
-	 * @since 3.1.0
87
-	 *
88
-	 * @param int $post_id The post id.
89
-	 */
90
-	public function instantiate_fields( $post_id ) {
91
-
92
-		// This function must be called only once. Not called from the constructor because WP hooks have a rococo ordering.
93
-		if ( isset( $this->fields ) ) {
94
-			return;
95
-		}
96
-
97
-		$entity_type = wl_entity_taxonomy_get_custom_fields( $post_id );
98
-
99
-		if ( isset( $entity_type ) ) {
100
-
101
-			/**
102
-			 * In some special case, properties must be grouped in one field (e.g. coordinates) or dealed with custom methods.
103
-			 * We must divide fields in two groups:
104
-			 * - simple: accept values for one property
105
-			 * - grouped: accept values for more properties, or for one property that needs a specific metabox.
106
-			 */
107
-			$metaboxes         = $this->group_properties_by_input_field( $entity_type );
108
-			$simple_metaboxes  = $metaboxes[0];
109
-			$grouped_metaboxes = $metaboxes[1];
17
+    public $fields;
18
+
19
+    /**
20
+     * WL_Metabox constructor.
21
+     *
22
+     * @since 3.1.0
23
+     */
24
+    public function __construct() {
25
+
26
+        // Add hooks to print metaboxes and save submitted data.
27
+        add_action( 'add_meta_boxes', array( &$this, 'add_main_metabox' ) );
28
+        add_action( 'wl_linked_data_save_post', array(
29
+            &$this,
30
+            'save_form_data',
31
+        ) );
32
+
33
+        // Enqueue js and css.
34
+        $this->enqueue_scripts_and_styles();
35
+
36
+    }
37
+
38
+    /**
39
+     * Add a callback to print the metabox in page.
40
+     * Wordpress will fire the $this->html() callback at the right time.
41
+     */
42
+    public function add_main_metabox() {
43
+
44
+        // Add main metabox (will print also the inner fields).
45
+        $id    = uniqid( 'wl-metabox-' );
46
+        $title = get_the_title() . ' ' . __( 'properties', 'wordlift' );
47
+        add_meta_box( $id, $title, array(
48
+            $this,
49
+            'html',
50
+        ), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high' );
51
+
52
+        // Add filter to change the metabox CSS class.
53
+        add_filter( "postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class' );
54
+    }
55
+
56
+    /**
57
+     * Called from WP to print the metabox content in page.
58
+     *
59
+     * @since 3.1.0
60
+     *
61
+     * @param WP_Post $post The post.
62
+     */
63
+    public function html( $post ) {
64
+
65
+        // Build the fields we need to print.
66
+        $this->instantiate_fields( $post->ID );
67
+
68
+        // Loop over the fields.
69
+        foreach ( $this->fields as $field ) {
70
+
71
+            // load data from DB (values will be available in $field->data).
72
+            $field->get_data();
73
+
74
+            // print field HTML (nonce included).
75
+            echo $field->html();
76
+        }
77
+
78
+    }
79
+
80
+    /**
81
+     * Read the WL <-> Schema mapping and build the Fields for the entity being edited.
82
+     *
83
+     * Note: the first function that calls this method will instantiate the fields.
84
+     * Why it isn't called from the constructor? Because we need to hook this process as late as possible.
85
+     *
86
+     * @since 3.1.0
87
+     *
88
+     * @param int $post_id The post id.
89
+     */
90
+    public function instantiate_fields( $post_id ) {
91
+
92
+        // This function must be called only once. Not called from the constructor because WP hooks have a rococo ordering.
93
+        if ( isset( $this->fields ) ) {
94
+            return;
95
+        }
96
+
97
+        $entity_type = wl_entity_taxonomy_get_custom_fields( $post_id );
98
+
99
+        if ( isset( $entity_type ) ) {
100
+
101
+            /**
102
+             * In some special case, properties must be grouped in one field (e.g. coordinates) or dealed with custom methods.
103
+             * We must divide fields in two groups:
104
+             * - simple: accept values for one property
105
+             * - grouped: accept values for more properties, or for one property that needs a specific metabox.
106
+             */
107
+            $metaboxes         = $this->group_properties_by_input_field( $entity_type );
108
+            $simple_metaboxes  = $metaboxes[0];
109
+            $grouped_metaboxes = $metaboxes[1];
110 110
 
111
-			// Loop over simple entity properties.
112
-			foreach ( $simple_metaboxes as $key => $property ) {
111
+            // Loop over simple entity properties.
112
+            foreach ( $simple_metaboxes as $key => $property ) {
113 113
 
114
-				// Info passed to the metabox.
115
-				$info         = array();
116
-				$info[ $key ] = $property;
114
+                // Info passed to the metabox.
115
+                $info         = array();
116
+                $info[ $key ] = $property;
117 117
 
118
-				// Build the requested field as WL_Metabox_Field_ object.
119
-				$this->add_field( $info );
120
-			}
118
+                // Build the requested field as WL_Metabox_Field_ object.
119
+                $this->add_field( $info );
120
+            }
121 121
 
122
-			// Loop over grouped properties.
123
-			foreach ( $grouped_metaboxes as $key => $property ) {
122
+            // Loop over grouped properties.
123
+            foreach ( $grouped_metaboxes as $key => $property ) {
124 124
 
125
-				// Info passed to the metabox.
126
-				$info         = array();
127
-				$info[ $key ] = $property;
125
+                // Info passed to the metabox.
126
+                $info         = array();
127
+                $info[ $key ] = $property;
128 128
 
129
-				// Build the requested field group as WL_Metabox_Field_ object.
130
-				$this->add_field( $info, TRUE );
131
-			}
129
+                // Build the requested field group as WL_Metabox_Field_ object.
130
+                $this->add_field( $info, TRUE );
131
+            }
132 132
 
133
-		}
134
-	}
133
+        }
134
+    }
135 135
 
136
-	/**
137
-	 * Separes metaboxes in simple and grouped.
138
-	 *
139
-	 * @param array $custom_fields Information on the entity type.
140
-	 */
141
-	public function group_properties_by_input_field( $custom_fields ) {
136
+    /**
137
+     * Separes metaboxes in simple and grouped.
138
+     *
139
+     * @param array $custom_fields Information on the entity type.
140
+     */
141
+    public function group_properties_by_input_field( $custom_fields ) {
142 142
 
143
-		$simple_properties  = array();
144
-		$grouped_properties = array();
143
+        $simple_properties  = array();
144
+        $grouped_properties = array();
145 145
 
146
-		// Loop over possible entity properties.
147
-		foreach ( $custom_fields as $key => $property ) {
146
+        // Loop over possible entity properties.
147
+        foreach ( $custom_fields as $key => $property ) {
148 148
 
149
-			// Check presence of predicate and type.
150
-			if ( isset( $property['predicate'] ) && isset( $property['type'] ) ) {
149
+            // Check presence of predicate and type.
150
+            if ( isset( $property['predicate'] ) && isset( $property['type'] ) ) {
151 151
 
152
-				// Check if input_field is defined.
153
-				if ( isset( $property['input_field'] ) && $property['input_field'] !== '' ) {
152
+                // Check if input_field is defined.
153
+                if ( isset( $property['input_field'] ) && $property['input_field'] !== '' ) {
154 154
 
155
-					$grouped_key = $property['input_field'];
155
+                    $grouped_key = $property['input_field'];
156 156
 
157
-					// Update list of grouped properties.
158
-					$grouped_properties[ $grouped_key ][ $key ] = $property;
157
+                    // Update list of grouped properties.
158
+                    $grouped_properties[ $grouped_key ][ $key ] = $property;
159 159
 
160
-				} else {
160
+                } else {
161 161
 
162
-					// input_field not defined, add simple metabox.
163
-					$simple_properties[ $key ] = $property;
164
-				}
165
-			}
166
-		}
162
+                    // input_field not defined, add simple metabox.
163
+                    $simple_properties[ $key ] = $property;
164
+                }
165
+            }
166
+        }
167 167
 
168
-		return array( $simple_properties, $grouped_properties );
169
-	}
168
+        return array( $simple_properties, $grouped_properties );
169
+    }
170 170
 
171
-	/**
172
-	 * Add a Field to the current Metabox, based on the description of the Field.
173
-	 * This method is a rude factory for Field objects.
174
-	 *
175
-	 * @param array $args
176
-	 * @param bool  $grouped Flag to distinguish between simple and grouped Fields
177
-	 */
178
-	public function add_field( $args, $grouped = FALSE ) {
171
+    /**
172
+     * Add a Field to the current Metabox, based on the description of the Field.
173
+     * This method is a rude factory for Field objects.
174
+     *
175
+     * @param array $args
176
+     * @param bool  $grouped Flag to distinguish between simple and grouped Fields
177
+     */
178
+    public function add_field( $args, $grouped = FALSE ) {
179 179
 
180
-		if ( $grouped ) {
181
-			// Special fields (sameas, coordinates, etc.).
180
+        if ( $grouped ) {
181
+            // Special fields (sameas, coordinates, etc.).
182 182
 
183
-			// Build Field with a custom class (e.g. WL_Metabox_Field_date).
184
-			$field_class = 'WL_Metabox_Field_' . key( $args );
183
+            // Build Field with a custom class (e.g. WL_Metabox_Field_date).
184
+            $field_class = 'WL_Metabox_Field_' . key( $args );
185 185
 
186
-		} else {
187
-			// Simple fields (string, uri, boolean, etc.).
186
+        } else {
187
+            // Simple fields (string, uri, boolean, etc.).
188 188
 
189
-			// Which field? We want to use the class that is specific for the field.
190
-			$meta      = key( $args );
191
-			$this_meta = $args[ $meta ];
189
+            // Which field? We want to use the class that is specific for the field.
190
+            $meta      = key( $args );
191
+            $this_meta = $args[ $meta ];
192 192
 
193
-			// If the field declares what metabox it wants, use that one.
194
-			if ( isset( $this_meta['metabox']['class'] ) ) {
193
+            // If the field declares what metabox it wants, use that one.
194
+            if ( isset( $this_meta['metabox']['class'] ) ) {
195 195
 
196
-				$field_class = $this_meta['metabox']['class'];
196
+                $field_class = $this_meta['metabox']['class'];
197 197
 
198
-			} elseif ( ! isset( $this_meta['type'] ) || ( $this_meta['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING ) ) {
198
+            } elseif ( ! isset( $this_meta['type'] ) || ( $this_meta['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING ) ) {
199 199
 
200
-				// TODO: all fields should explicitly declare the required WL_Metabox.
201
-				// When they will remove this.
200
+                // TODO: all fields should explicitly declare the required WL_Metabox.
201
+                // When they will remove this.
202 202
 
203
-				// Use default WL_Metabox_Field (manages strings).
204
-				$field_class = 'WL_Metabox_Field';
203
+                // Use default WL_Metabox_Field (manages strings).
204
+                $field_class = 'WL_Metabox_Field';
205 205
 
206
-			} else {
206
+            } else {
207 207
 
208
-				// TODO: all fields should explicitly declare the required WL_Metabox.
209
-				// When they will remove this.
208
+                // TODO: all fields should explicitly declare the required WL_Metabox.
209
+                // When they will remove this.
210 210
 
211
-				// Build Field with a custom class (e.g. WL_Metabox_Field_date).
212
-				$field_class = 'WL_Metabox_Field_' . $this_meta['type'];
211
+                // Build Field with a custom class (e.g. WL_Metabox_Field_date).
212
+                $field_class = 'WL_Metabox_Field_' . $this_meta['type'];
213 213
 
214
-			}
215
-		}
214
+            }
215
+        }
216 216
 
217
-		// Call apropriate constructor (e.g. WL_Metabox_Field_... ).
218
-		$this->fields[] = new $field_class( $args );
219
-	}
217
+        // Call apropriate constructor (e.g. WL_Metabox_Field_... ).
218
+        $this->fields[] = new $field_class( $args );
219
+    }
220 220
 
221
-	public function save_form_data( $entity_id ) {
221
+    public function save_form_data( $entity_id ) {
222 222
 
223
-		// Build Field objects.
224
-		$this->instantiate_fields( $entity_id );
223
+        // Build Field objects.
224
+        $this->instantiate_fields( $entity_id );
225 225
 
226
-		// Check if WL metabox form was posted.
227
-		if ( ! isset( $_POST['wl_metaboxes'] ) ) {
228
-			return;
229
-		}
226
+        // Check if WL metabox form was posted.
227
+        if ( ! isset( $_POST['wl_metaboxes'] ) ) {
228
+            return;
229
+        }
230 230
 
231
-		foreach ( $this->fields as $field ) {
231
+        foreach ( $this->fields as $field ) {
232 232
 
233
-			// Verify nonce.
234
-			$valid_nonce = $field->verify_nonce();
235
-			if ( $valid_nonce ) {
233
+            // Verify nonce.
234
+            $valid_nonce = $field->verify_nonce();
235
+            if ( $valid_nonce ) {
236 236
 
237
-				$posted_data = $_POST['wl_metaboxes'];
238
-				$field_name  = $field->meta_name;
237
+                $posted_data = $_POST['wl_metaboxes'];
238
+                $field_name  = $field->meta_name;
239 239
 
240
-				// Each Filed only deals with its values.
241
-				if ( isset( $posted_data[ $field_name ] ) ) {
240
+                // Each Filed only deals with its values.
241
+                if ( isset( $posted_data[ $field_name ] ) ) {
242 242
 
243
-					$values = $posted_data[ $field_name ];
244
-					if ( ! is_array( $values ) ) {
245
-						$values = array( $values );
246
-					}
243
+                    $values = $posted_data[ $field_name ];
244
+                    if ( ! is_array( $values ) ) {
245
+                        $values = array( $values );
246
+                    }
247 247
 
248
-					// Save data permanently
249
-					$field->save_data( $values );
250
-				}
251
-			}
252
-		}
248
+                    // Save data permanently
249
+                    $field->save_data( $values );
250
+                }
251
+            }
252
+        }
253 253
 
254
-		wl_linked_data_push_to_redlink( $entity_id );
255
-	}
254
+        wl_linked_data_push_to_redlink( $entity_id );
255
+    }
256 256
 
257
-	// print on page all the js and css the fields will need.
258
-	public function enqueue_scripts_and_styles() {
257
+    // print on page all the js and css the fields will need.
258
+    public function enqueue_scripts_and_styles() {
259 259
 
260
-		// dateTimePicker
261
-		wp_enqueue_style( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/css/jquery.datetimepicker.css' );
262
-		wp_enqueue_script( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.full.min.js', array( 'jquery' ) );
260
+        // dateTimePicker
261
+        wp_enqueue_style( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/css/jquery.datetimepicker.css' );
262
+        wp_enqueue_script( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.full.min.js', array( 'jquery' ) );
263 263
 
264
-		// We rename the xdsoft datetimepicker function name to avoid conflicts to the jQuery UI derived datetimepicker library.
265
-		// see https://github.com/insideout10/wordlift-plugin/issues/340 .
266
-		wp_enqueue_script( 'jquery-ui-timepicker-no-conflict', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.no-conflict.js', array( 'jquery-ui-timepicker' ) );
264
+        // We rename the xdsoft datetimepicker function name to avoid conflicts to the jQuery UI derived datetimepicker library.
265
+        // see https://github.com/insideout10/wordlift-plugin/issues/340 .
266
+        wp_enqueue_script( 'jquery-ui-timepicker-no-conflict', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.no-conflict.js', array( 'jquery-ui-timepicker' ) );
267 267
 
268
-		// Leaflet.
269
-		wp_enqueue_style( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' );
270
-		wp_enqueue_script( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js', __FILE__ );
268
+        // Leaflet.
269
+        wp_enqueue_style( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' );
270
+        wp_enqueue_script( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js', __FILE__ );
271 271
 
272
-		// Add AJAX autocomplete to facilitate metabox editing.
273
-		wp_enqueue_script( 'wl-entity-metabox-utility', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wl_entity_metabox_utilities.js' );
274
-		wp_localize_script( 'wl-entity-metabox-utility', 'wlEntityMetaboxParams', array(
275
-				'ajax_url' => admin_url( 'admin-ajax.php' ),
276
-				'action'   => 'entity_by_title',
277
-			)
278
-		);
272
+        // Add AJAX autocomplete to facilitate metabox editing.
273
+        wp_enqueue_script( 'wl-entity-metabox-utility', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wl_entity_metabox_utilities.js' );
274
+        wp_localize_script( 'wl-entity-metabox-utility', 'wlEntityMetaboxParams', array(
275
+                'ajax_url' => admin_url( 'admin-ajax.php' ),
276
+                'action'   => 'entity_by_title',
277
+            )
278
+        );
279 279
 
280
-	}
280
+    }
281 281
 
282 282
 }
Please login to merge, or discard this patch.
src/admin/WL_Metabox/WL_Metabox_Field.php 2 patches
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -7,258 +7,258 @@
 block discarded – undo
7 7
  */
8 8
 class WL_Metabox_Field {
9 9
 
10
-	public $meta_name;
11
-	public $raw_custom_field;
12
-	public $predicate;
13
-	public $label;
14
-	public $expected_wl_type;
15
-	public $expected_uri_type;
16
-	public $cardinality;
17
-	public $data;
18
-
19
-	/**
20
-	 * @param array $args
21
-	 */
22
-	public function __construct( $args ) {
23
-
24
-		if ( empty( $args ) ) {
25
-			return;
26
-		}
27
-
28
-		// Save a copy of the custom field's params.
29
-		$this->raw_custom_field = reset( $args );
30
-
31
-		// Extract meta name (post_meta key for the DB).
32
-		$this->meta_name = key( $args );
33
-
34
-		// Extract linked data predicate.
35
-		if ( isset( $this->raw_custom_field['predicate'] ) ) {
36
-			$this->predicate = $this->raw_custom_field['predicate'];
37
-		} else {
38
-			return;
39
-		}
40
-
41
-		// Extract human readable label.
42
-		$exploded_predicate = explode( '/', $this->predicate );
43
-
44
-		// Use the label defined for the property if set, otherwise the last part of the schema.org/xyz predicate.
45
-		$this->label = isset( $this->raw_custom_field['metabox']['label'] ) ? __( $this->raw_custom_field['metabox']['label'] ) : end( $exploded_predicate );
46
-
47
-		// Extract field constraints (numerosity, expected type).
48
-		// Default constaints: accept one string..
49
-		if ( isset( $this->raw_custom_field['type'] ) ) {
50
-			$this->expected_wl_type = $this->raw_custom_field['type'];
51
-		} else {
52
-			$this->expected_wl_type = Wordlift_Schema_Service::DATA_TYPE_STRING;
53
-		}
54
-
55
-		$this->cardinality = 1;
56
-		if ( isset( $this->raw_custom_field['constraints'] ) ) {
57
-
58
-			$constraints = $this->raw_custom_field['constraints'];
59
-
60
-			// Extract cardinality.
61
-			if ( isset( $constraints['cardinality'] ) ) {
62
-				$this->cardinality = $constraints['cardinality'];
63
-			}
64
-
65
-			// Which type of entity can we accept (e.g. Place, Event, ecc.)? .
66
-			if ( $this->expected_wl_type === Wordlift_Schema_Service::DATA_TYPE_URI && isset( $constraints['uri_type'] ) ) {
67
-				$this->expected_uri_type = is_array( $constraints['uri_type'] ) ? $constraints['uri_type'] : array( $constraints['uri_type'] );
68
-			}
69
-
70
-		}
71
-	}
72
-
73
-	/**
74
-	 * Return nonce HTML.
75
-	 * Overwrite this method in a child class to obtain custom behaviour.
76
-	 */
77
-	public function html_nonce() {
78
-
79
-		return wp_nonce_field( 'wordlift_' . $this->meta_name . '_entity_box', 'wordlift_' . $this->meta_name . '_entity_box_nonce', TRUE, FALSE );
80
-	}
81
-
82
-	/**
83
-	 * Verify nonce.
84
-	 * Overwrite this method in a child class to obtain custom behaviour.
85
-	 *
86
-	 * @return boolean Nonce verification
87
-	 */
88
-	public function verify_nonce() {
89
-
90
-		$nonce_name   = 'wordlift_' . $this->meta_name . '_entity_box_nonce';
91
-		$nonce_verify = 'wordlift_' . $this->meta_name . '_entity_box';
92
-
93
-		if ( ! isset( $_POST[ $nonce_name ] ) ) {
94
-			return FALSE;
95
-		}
96
-
97
-		// Verify that the nonce is valid.
98
-		return wp_verify_nonce( $_POST[ $nonce_name ], $nonce_verify );
99
-	}
100
-
101
-	/**
102
-	 * Load data from DB and store the resulting array in $this->data.
103
-	 * Overwrite this method in a child class to obtain custom behaviour.
104
-	 */
105
-	public function get_data() {
106
-
107
-		$data = get_post_meta( get_the_ID(), $this->meta_name );
108
-
109
-		// Values are always contained in an array (makes it easier to manage cardinality).
110
-		if ( ! is_array( $data ) ) {
111
-			$data = array( $data );
112
-		}
113
-
114
-		$this->data = $data;
115
-	}
116
-
117
-	/**
118
-	 * Sanitizes data before saving to DB. Default sanitization trashes empty values.
119
-	 * Stores the sanitized values into $this->data so they can be later processed.
120
-	 * Overwrite this method in a child class to obtain custom behaviour.
121
-	 *
122
-	 * @param array $values Array of values to be sanitized and then stored into $this->data
123
-	 *
124
-	 */
125
-	public function sanitize_data( $values ) {
126
-
127
-		$sanitized_data = array();
128
-
129
-		if ( ! is_array( $values ) ) {
130
-			$values = array( $values );
131
-		}
132
-
133
-		foreach ( $values as $value ) {
134
-			$sanitized_value = $this->sanitize_data_filter( $value );
135
-			if ( ! is_null( $sanitized_value ) ) {
136
-				$sanitized_data[] = $sanitized_value;
137
-			}
138
-		}
139
-
140
-		$this->data = $sanitized_data;
141
-	}
142
-
143
-	/**
144
-	 * Sanitize a single value. Called from $this->sanitize_data. Default sanitization excludes empty values.
145
-	 * Overwrite this method in a child class to obtain custom behaviour.
146
-	 *
147
-	 * @return mixed Returns sanitized value, or null.
148
-	 */
149
-	public function sanitize_data_filter( $value ) {
150
-
151
-		// TODO: all fields should provide their own sanitize which shouldn't be part of a UI class.
152
-		// If the field provides its own validation, use it.
153
-		if ( isset( $this->raw_custom_field['sanitize'] ) ) {
154
-			return call_user_func( $this->raw_custom_field['sanitize'], $value );
155
-		}
156
-
157
-		if ( ! is_null( $value ) && $value !== '' ) {         // do not use 'empty()' -> https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/ .
158
-			return $value;
159
-		}
160
-
161
-		return NULL;
162
-	}
163
-
164
-	/**
165
-	 * Save data to DB.
166
-	 * Overwrite this method in a child class to obtain custom behaviour.
167
-	 */
168
-	public function save_data( $values ) {
169
-
170
-		// Will sanitize data and store them in $field->data.
171
-		$this->sanitize_data( $values );
172
-
173
-		$entity_id = get_the_ID();
174
-
175
-		// Take away old values.
176
-		delete_post_meta( $entity_id, $this->meta_name );
177
-
178
-		// insert new values, respecting cardinality.
179
-		$single = ( $this->cardinality == 1 );
180
-		foreach ( $this->data as $value ) {
181
-			add_post_meta( $entity_id, $this->meta_name, $value, $single );
182
-		}
183
-	}
184
-
185
-	/**
186
-	 * Returns the HTML tag that will contain the Field. By default the we return a <div> with data- attributes on cardinality and expected types.
187
-	 * It is useful to provide data- attributes for the JS scripts.
188
-	 * Overwrite this method in a child class to obtain custom behaviour.
189
-	 */
190
-	public function html_wrapper_open() {
191
-
192
-		return "<div class='wl-field' data-cardinality='$this->cardinality'>";
193
-	}
194
-
195
-	/**
196
-	 * Returns Field HTML (nonce included).
197
-	 * Overwrite this method (or methods called from this method) in a child class to obtain custom behaviour.
198
-	 */
199
-	public function html() {
200
-
201
-		// Open main <div> for the Field.
202
-		$html = $this->html_wrapper_open();
203
-
204
-		// Label.
205
-		$html .= "<h3>$this->label</h3>";
206
-
207
-		// print nonce.
208
-		$html .= $this->html_nonce();
209
-
210
-		// print data loaded from DB.
211
-		$count = 0;
212
-		if ( $this->data ) {
213
-			foreach ( $this->data as $value ) {
214
-				if ( $count < $this->cardinality ) {
215
-					$html .= $this->html_input( $value );
216
-				}
217
-				$count ++;
218
-			}
219
-		}
220
-
221
-		// Print the empty <input> to add new values.
222
-		if ( $count === 0 ) { // } || $count < $this->cardinality ) { DO NOT print empty inputs unless requested by the editor since fields might support empty strings.
223
-			$html .= $this->html_input( '' );    // Will print an empty <input>
224
-			$count ++;
225
-		}
226
-
227
-		// If cardiality allows it, print button to add new values.
228
-		if ( $count < $this->cardinality ) {
229
-			$html .= '<button class="button wl-add-input wl-button" type="button">Add</button>';
230
-		}
231
-
232
-		// Close the HTML wrapper.
233
-		$html .= $this->html_wrapper_close();
234
-
235
-		return $html;
236
-	}
237
-
238
-	/**
239
-	 * Return a single <input> tag for the Field.
240
-	 *
241
-	 * @param mixed $value Input value
242
-	 *
243
-	 * @return string
244
-	 */
245
-	public function html_input( $value ) {
246
-		$html = <<<EOF
10
+    public $meta_name;
11
+    public $raw_custom_field;
12
+    public $predicate;
13
+    public $label;
14
+    public $expected_wl_type;
15
+    public $expected_uri_type;
16
+    public $cardinality;
17
+    public $data;
18
+
19
+    /**
20
+     * @param array $args
21
+     */
22
+    public function __construct( $args ) {
23
+
24
+        if ( empty( $args ) ) {
25
+            return;
26
+        }
27
+
28
+        // Save a copy of the custom field's params.
29
+        $this->raw_custom_field = reset( $args );
30
+
31
+        // Extract meta name (post_meta key for the DB).
32
+        $this->meta_name = key( $args );
33
+
34
+        // Extract linked data predicate.
35
+        if ( isset( $this->raw_custom_field['predicate'] ) ) {
36
+            $this->predicate = $this->raw_custom_field['predicate'];
37
+        } else {
38
+            return;
39
+        }
40
+
41
+        // Extract human readable label.
42
+        $exploded_predicate = explode( '/', $this->predicate );
43
+
44
+        // Use the label defined for the property if set, otherwise the last part of the schema.org/xyz predicate.
45
+        $this->label = isset( $this->raw_custom_field['metabox']['label'] ) ? __( $this->raw_custom_field['metabox']['label'] ) : end( $exploded_predicate );
46
+
47
+        // Extract field constraints (numerosity, expected type).
48
+        // Default constaints: accept one string..
49
+        if ( isset( $this->raw_custom_field['type'] ) ) {
50
+            $this->expected_wl_type = $this->raw_custom_field['type'];
51
+        } else {
52
+            $this->expected_wl_type = Wordlift_Schema_Service::DATA_TYPE_STRING;
53
+        }
54
+
55
+        $this->cardinality = 1;
56
+        if ( isset( $this->raw_custom_field['constraints'] ) ) {
57
+
58
+            $constraints = $this->raw_custom_field['constraints'];
59
+
60
+            // Extract cardinality.
61
+            if ( isset( $constraints['cardinality'] ) ) {
62
+                $this->cardinality = $constraints['cardinality'];
63
+            }
64
+
65
+            // Which type of entity can we accept (e.g. Place, Event, ecc.)? .
66
+            if ( $this->expected_wl_type === Wordlift_Schema_Service::DATA_TYPE_URI && isset( $constraints['uri_type'] ) ) {
67
+                $this->expected_uri_type = is_array( $constraints['uri_type'] ) ? $constraints['uri_type'] : array( $constraints['uri_type'] );
68
+            }
69
+
70
+        }
71
+    }
72
+
73
+    /**
74
+     * Return nonce HTML.
75
+     * Overwrite this method in a child class to obtain custom behaviour.
76
+     */
77
+    public function html_nonce() {
78
+
79
+        return wp_nonce_field( 'wordlift_' . $this->meta_name . '_entity_box', 'wordlift_' . $this->meta_name . '_entity_box_nonce', TRUE, FALSE );
80
+    }
81
+
82
+    /**
83
+     * Verify nonce.
84
+     * Overwrite this method in a child class to obtain custom behaviour.
85
+     *
86
+     * @return boolean Nonce verification
87
+     */
88
+    public function verify_nonce() {
89
+
90
+        $nonce_name   = 'wordlift_' . $this->meta_name . '_entity_box_nonce';
91
+        $nonce_verify = 'wordlift_' . $this->meta_name . '_entity_box';
92
+
93
+        if ( ! isset( $_POST[ $nonce_name ] ) ) {
94
+            return FALSE;
95
+        }
96
+
97
+        // Verify that the nonce is valid.
98
+        return wp_verify_nonce( $_POST[ $nonce_name ], $nonce_verify );
99
+    }
100
+
101
+    /**
102
+     * Load data from DB and store the resulting array in $this->data.
103
+     * Overwrite this method in a child class to obtain custom behaviour.
104
+     */
105
+    public function get_data() {
106
+
107
+        $data = get_post_meta( get_the_ID(), $this->meta_name );
108
+
109
+        // Values are always contained in an array (makes it easier to manage cardinality).
110
+        if ( ! is_array( $data ) ) {
111
+            $data = array( $data );
112
+        }
113
+
114
+        $this->data = $data;
115
+    }
116
+
117
+    /**
118
+     * Sanitizes data before saving to DB. Default sanitization trashes empty values.
119
+     * Stores the sanitized values into $this->data so they can be later processed.
120
+     * Overwrite this method in a child class to obtain custom behaviour.
121
+     *
122
+     * @param array $values Array of values to be sanitized and then stored into $this->data
123
+     *
124
+     */
125
+    public function sanitize_data( $values ) {
126
+
127
+        $sanitized_data = array();
128
+
129
+        if ( ! is_array( $values ) ) {
130
+            $values = array( $values );
131
+        }
132
+
133
+        foreach ( $values as $value ) {
134
+            $sanitized_value = $this->sanitize_data_filter( $value );
135
+            if ( ! is_null( $sanitized_value ) ) {
136
+                $sanitized_data[] = $sanitized_value;
137
+            }
138
+        }
139
+
140
+        $this->data = $sanitized_data;
141
+    }
142
+
143
+    /**
144
+     * Sanitize a single value. Called from $this->sanitize_data. Default sanitization excludes empty values.
145
+     * Overwrite this method in a child class to obtain custom behaviour.
146
+     *
147
+     * @return mixed Returns sanitized value, or null.
148
+     */
149
+    public function sanitize_data_filter( $value ) {
150
+
151
+        // TODO: all fields should provide their own sanitize which shouldn't be part of a UI class.
152
+        // If the field provides its own validation, use it.
153
+        if ( isset( $this->raw_custom_field['sanitize'] ) ) {
154
+            return call_user_func( $this->raw_custom_field['sanitize'], $value );
155
+        }
156
+
157
+        if ( ! is_null( $value ) && $value !== '' ) {         // do not use 'empty()' -> https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/ .
158
+            return $value;
159
+        }
160
+
161
+        return NULL;
162
+    }
163
+
164
+    /**
165
+     * Save data to DB.
166
+     * Overwrite this method in a child class to obtain custom behaviour.
167
+     */
168
+    public function save_data( $values ) {
169
+
170
+        // Will sanitize data and store them in $field->data.
171
+        $this->sanitize_data( $values );
172
+
173
+        $entity_id = get_the_ID();
174
+
175
+        // Take away old values.
176
+        delete_post_meta( $entity_id, $this->meta_name );
177
+
178
+        // insert new values, respecting cardinality.
179
+        $single = ( $this->cardinality == 1 );
180
+        foreach ( $this->data as $value ) {
181
+            add_post_meta( $entity_id, $this->meta_name, $value, $single );
182
+        }
183
+    }
184
+
185
+    /**
186
+     * Returns the HTML tag that will contain the Field. By default the we return a <div> with data- attributes on cardinality and expected types.
187
+     * It is useful to provide data- attributes for the JS scripts.
188
+     * Overwrite this method in a child class to obtain custom behaviour.
189
+     */
190
+    public function html_wrapper_open() {
191
+
192
+        return "<div class='wl-field' data-cardinality='$this->cardinality'>";
193
+    }
194
+
195
+    /**
196
+     * Returns Field HTML (nonce included).
197
+     * Overwrite this method (or methods called from this method) in a child class to obtain custom behaviour.
198
+     */
199
+    public function html() {
200
+
201
+        // Open main <div> for the Field.
202
+        $html = $this->html_wrapper_open();
203
+
204
+        // Label.
205
+        $html .= "<h3>$this->label</h3>";
206
+
207
+        // print nonce.
208
+        $html .= $this->html_nonce();
209
+
210
+        // print data loaded from DB.
211
+        $count = 0;
212
+        if ( $this->data ) {
213
+            foreach ( $this->data as $value ) {
214
+                if ( $count < $this->cardinality ) {
215
+                    $html .= $this->html_input( $value );
216
+                }
217
+                $count ++;
218
+            }
219
+        }
220
+
221
+        // Print the empty <input> to add new values.
222
+        if ( $count === 0 ) { // } || $count < $this->cardinality ) { DO NOT print empty inputs unless requested by the editor since fields might support empty strings.
223
+            $html .= $this->html_input( '' );    // Will print an empty <input>
224
+            $count ++;
225
+        }
226
+
227
+        // If cardiality allows it, print button to add new values.
228
+        if ( $count < $this->cardinality ) {
229
+            $html .= '<button class="button wl-add-input wl-button" type="button">Add</button>';
230
+        }
231
+
232
+        // Close the HTML wrapper.
233
+        $html .= $this->html_wrapper_close();
234
+
235
+        return $html;
236
+    }
237
+
238
+    /**
239
+     * Return a single <input> tag for the Field.
240
+     *
241
+     * @param mixed $value Input value
242
+     *
243
+     * @return string
244
+     */
245
+    public function html_input( $value ) {
246
+        $html = <<<EOF
247 247
 			<div class="wl-input-wrapper">
248 248
 				<input type="text" id="$this->meta_name" name="wl_metaboxes[$this->meta_name][]" value="$value" style="width:88%" />
249 249
 				<button class="button wl-remove-input wl-button" type="button" style="width:10 % ">Remove</button>
250 250
 			</div>
251 251
 EOF;
252 252
 
253
-		return $html;
254
-	}
253
+        return $html;
254
+    }
255 255
 
256
-	/**
257
-	 * Returns closing for the wrapper HTML tag.
258
-	 */
259
-	public function html_wrapper_close() {
256
+    /**
257
+     * Returns closing for the wrapper HTML tag.
258
+     */
259
+    public function html_wrapper_close() {
260 260
 
261
-		return '</div><hr>';
262
-	}
261
+        return '</div><hr>';
262
+    }
263 263
 
264 264
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -19,52 +19,52 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * @param array $args
21 21
 	 */
22
-	public function __construct( $args ) {
22
+	public function __construct($args) {
23 23
 
24
-		if ( empty( $args ) ) {
24
+		if (empty($args)) {
25 25
 			return;
26 26
 		}
27 27
 
28 28
 		// Save a copy of the custom field's params.
29
-		$this->raw_custom_field = reset( $args );
29
+		$this->raw_custom_field = reset($args);
30 30
 
31 31
 		// Extract meta name (post_meta key for the DB).
32
-		$this->meta_name = key( $args );
32
+		$this->meta_name = key($args);
33 33
 
34 34
 		// Extract linked data predicate.
35
-		if ( isset( $this->raw_custom_field['predicate'] ) ) {
35
+		if (isset($this->raw_custom_field['predicate'])) {
36 36
 			$this->predicate = $this->raw_custom_field['predicate'];
37 37
 		} else {
38 38
 			return;
39 39
 		}
40 40
 
41 41
 		// Extract human readable label.
42
-		$exploded_predicate = explode( '/', $this->predicate );
42
+		$exploded_predicate = explode('/', $this->predicate);
43 43
 
44 44
 		// Use the label defined for the property if set, otherwise the last part of the schema.org/xyz predicate.
45
-		$this->label = isset( $this->raw_custom_field['metabox']['label'] ) ? __( $this->raw_custom_field['metabox']['label'] ) : end( $exploded_predicate );
45
+		$this->label = isset($this->raw_custom_field['metabox']['label']) ? __($this->raw_custom_field['metabox']['label']) : end($exploded_predicate);
46 46
 
47 47
 		// Extract field constraints (numerosity, expected type).
48 48
 		// Default constaints: accept one string..
49
-		if ( isset( $this->raw_custom_field['type'] ) ) {
49
+		if (isset($this->raw_custom_field['type'])) {
50 50
 			$this->expected_wl_type = $this->raw_custom_field['type'];
51 51
 		} else {
52 52
 			$this->expected_wl_type = Wordlift_Schema_Service::DATA_TYPE_STRING;
53 53
 		}
54 54
 
55 55
 		$this->cardinality = 1;
56
-		if ( isset( $this->raw_custom_field['constraints'] ) ) {
56
+		if (isset($this->raw_custom_field['constraints'])) {
57 57
 
58 58
 			$constraints = $this->raw_custom_field['constraints'];
59 59
 
60 60
 			// Extract cardinality.
61
-			if ( isset( $constraints['cardinality'] ) ) {
61
+			if (isset($constraints['cardinality'])) {
62 62
 				$this->cardinality = $constraints['cardinality'];
63 63
 			}
64 64
 
65 65
 			// Which type of entity can we accept (e.g. Place, Event, ecc.)? .
66
-			if ( $this->expected_wl_type === Wordlift_Schema_Service::DATA_TYPE_URI && isset( $constraints['uri_type'] ) ) {
67
-				$this->expected_uri_type = is_array( $constraints['uri_type'] ) ? $constraints['uri_type'] : array( $constraints['uri_type'] );
66
+			if ($this->expected_wl_type === Wordlift_Schema_Service::DATA_TYPE_URI && isset($constraints['uri_type'])) {
67
+				$this->expected_uri_type = is_array($constraints['uri_type']) ? $constraints['uri_type'] : array($constraints['uri_type']);
68 68
 			}
69 69
 
70 70
 		}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function html_nonce() {
78 78
 
79
-		return wp_nonce_field( 'wordlift_' . $this->meta_name . '_entity_box', 'wordlift_' . $this->meta_name . '_entity_box_nonce', TRUE, FALSE );
79
+		return wp_nonce_field('wordlift_'.$this->meta_name.'_entity_box', 'wordlift_'.$this->meta_name.'_entity_box_nonce', TRUE, FALSE);
80 80
 	}
81 81
 
82 82
 	/**
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function verify_nonce() {
89 89
 
90
-		$nonce_name   = 'wordlift_' . $this->meta_name . '_entity_box_nonce';
91
-		$nonce_verify = 'wordlift_' . $this->meta_name . '_entity_box';
90
+		$nonce_name   = 'wordlift_'.$this->meta_name.'_entity_box_nonce';
91
+		$nonce_verify = 'wordlift_'.$this->meta_name.'_entity_box';
92 92
 
93
-		if ( ! isset( $_POST[ $nonce_name ] ) ) {
93
+		if ( ! isset($_POST[$nonce_name])) {
94 94
 			return FALSE;
95 95
 		}
96 96
 
97 97
 		// Verify that the nonce is valid.
98
-		return wp_verify_nonce( $_POST[ $nonce_name ], $nonce_verify );
98
+		return wp_verify_nonce($_POST[$nonce_name], $nonce_verify);
99 99
 	}
100 100
 
101 101
 	/**
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function get_data() {
106 106
 
107
-		$data = get_post_meta( get_the_ID(), $this->meta_name );
107
+		$data = get_post_meta(get_the_ID(), $this->meta_name);
108 108
 
109 109
 		// Values are always contained in an array (makes it easier to manage cardinality).
110
-		if ( ! is_array( $data ) ) {
111
-			$data = array( $data );
110
+		if ( ! is_array($data)) {
111
+			$data = array($data);
112 112
 		}
113 113
 
114 114
 		$this->data = $data;
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 	 * @param array $values Array of values to be sanitized and then stored into $this->data
123 123
 	 *
124 124
 	 */
125
-	public function sanitize_data( $values ) {
125
+	public function sanitize_data($values) {
126 126
 
127 127
 		$sanitized_data = array();
128 128
 
129
-		if ( ! is_array( $values ) ) {
130
-			$values = array( $values );
129
+		if ( ! is_array($values)) {
130
+			$values = array($values);
131 131
 		}
132 132
 
133
-		foreach ( $values as $value ) {
134
-			$sanitized_value = $this->sanitize_data_filter( $value );
135
-			if ( ! is_null( $sanitized_value ) ) {
133
+		foreach ($values as $value) {
134
+			$sanitized_value = $this->sanitize_data_filter($value);
135
+			if ( ! is_null($sanitized_value)) {
136 136
 				$sanitized_data[] = $sanitized_value;
137 137
 			}
138 138
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return mixed Returns sanitized value, or null.
148 148
 	 */
149
-	public function sanitize_data_filter( $value ) {
149
+	public function sanitize_data_filter($value) {
150 150
 
151 151
 		// TODO: all fields should provide their own sanitize which shouldn't be part of a UI class.
152 152
 		// If the field provides its own validation, use it.
153
-		if ( isset( $this->raw_custom_field['sanitize'] ) ) {
154
-			return call_user_func( $this->raw_custom_field['sanitize'], $value );
153
+		if (isset($this->raw_custom_field['sanitize'])) {
154
+			return call_user_func($this->raw_custom_field['sanitize'], $value);
155 155
 		}
156 156
 
157
-		if ( ! is_null( $value ) && $value !== '' ) {         // do not use 'empty()' -> https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/ .
157
+		if ( ! is_null($value) && $value !== '') {         // do not use 'empty()' -> https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/ .
158 158
 			return $value;
159 159
 		}
160 160
 
@@ -165,20 +165,20 @@  discard block
 block discarded – undo
165 165
 	 * Save data to DB.
166 166
 	 * Overwrite this method in a child class to obtain custom behaviour.
167 167
 	 */
168
-	public function save_data( $values ) {
168
+	public function save_data($values) {
169 169
 
170 170
 		// Will sanitize data and store them in $field->data.
171
-		$this->sanitize_data( $values );
171
+		$this->sanitize_data($values);
172 172
 
173 173
 		$entity_id = get_the_ID();
174 174
 
175 175
 		// Take away old values.
176
-		delete_post_meta( $entity_id, $this->meta_name );
176
+		delete_post_meta($entity_id, $this->meta_name);
177 177
 
178 178
 		// insert new values, respecting cardinality.
179
-		$single = ( $this->cardinality == 1 );
180
-		foreach ( $this->data as $value ) {
181
-			add_post_meta( $entity_id, $this->meta_name, $value, $single );
179
+		$single = ($this->cardinality == 1);
180
+		foreach ($this->data as $value) {
181
+			add_post_meta($entity_id, $this->meta_name, $value, $single);
182 182
 		}
183 183
 	}
184 184
 
@@ -209,23 +209,23 @@  discard block
 block discarded – undo
209 209
 
210 210
 		// print data loaded from DB.
211 211
 		$count = 0;
212
-		if ( $this->data ) {
213
-			foreach ( $this->data as $value ) {
214
-				if ( $count < $this->cardinality ) {
215
-					$html .= $this->html_input( $value );
212
+		if ($this->data) {
213
+			foreach ($this->data as $value) {
214
+				if ($count < $this->cardinality) {
215
+					$html .= $this->html_input($value);
216 216
 				}
217
-				$count ++;
217
+				$count++;
218 218
 			}
219 219
 		}
220 220
 
221 221
 		// Print the empty <input> to add new values.
222
-		if ( $count === 0 ) { // } || $count < $this->cardinality ) { DO NOT print empty inputs unless requested by the editor since fields might support empty strings.
223
-			$html .= $this->html_input( '' );    // Will print an empty <input>
224
-			$count ++;
222
+		if ($count === 0) { // } || $count < $this->cardinality ) { DO NOT print empty inputs unless requested by the editor since fields might support empty strings.
223
+			$html .= $this->html_input(''); // Will print an empty <input>
224
+			$count++;
225 225
 		}
226 226
 
227 227
 		// If cardiality allows it, print button to add new values.
228
-		if ( $count < $this->cardinality ) {
228
+		if ($count < $this->cardinality) {
229 229
 			$html .= '<button class="button wl-add-input wl-button" type="button">Add</button>';
230 230
 		}
231 231
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return string
244 244
 	 */
245
-	public function html_input( $value ) {
245
+	public function html_input($value) {
246 246
 		$html = <<<EOF
247 247
 			<div class="wl-input-wrapper">
248 248
 				<input type="text" id="$this->meta_name" name="wl_metaboxes[$this->meta_name][]" value="$value" style="width:88%" />
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-setup.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -28,106 +28,106 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class Wordlift_Admin_Setup {
30 30
 
31
-	/**
32
-	 * A {@link Wordlift_Configuration_Service} instance.
33
-	 *
34
-	 * @since  3.9.0
35
-	 * @access private
36
-	 * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance.
37
-	 */
38
-	private $configuration_service;
39
-
40
-	/**
41
-	 * A {@link Wordlift_Key_Validation_Service} instance.
42
-	 *
43
-	 * @since  3.9.0
44
-	 * @access private
45
-	 * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance.
46
-	 */
47
-	private $key_validation_service;
48
-
49
-	/**
50
-	 * A {@link Wordlift_Entity_Service} instance.
51
-	 *
52
-	 * @since  3.9.0
53
-	 * @access private
54
-	 * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
55
-	 */
56
-	private $entity_service;
57
-
58
-	/**
59
-	 * Initialize the class and set its properties.
60
-	 *
61
-	 * @since    3.9.0
62
-	 *
63
-	 * @param Wordlift_Configuration_Service  $configuration_service  A {@link Wordlift_Configuration_Service} instance.
64
-	 * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
65
-	 * @param Wordlift_Entity_Service         $entity_service         A {@link Wordlift_Entity_Service} instance.
66
-	 */
67
-	public function __construct( $configuration_service, $key_validation_service, $entity_service ) {
68
-
69
-		// Set a reference to the configuration service.
70
-		$this->configuration_service = $configuration_service;
71
-
72
-		// Set a reference to the key validation service.
73
-		$this->key_validation_service = $key_validation_service;
74
-
75
-		// Set a reference to the entity service.
76
-		$this->entity_service = $entity_service;
77
-
78
-		// Hook to some WP's events:
79
-		// When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up.
80
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
81
-
82
-		// Hook to `admin_menu` in order to add our own setup wizard page.
83
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
84
-
85
-		// Triggered when the user accesses the admin area, we decide whether to show our own wizard.
86
-		add_action( 'admin_init', array( $this, 'show_page' ) );
87
-
88
-		// Hook to `admin_notices` to display our notices.
89
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
90
-
91
-	}
92
-
93
-	/**
94
-	 * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set.
95
-	 *
96
-	 * @since 3.9.0
97
-	 */
98
-	public function admin_init() {
99
-
100
-		// If the `_wl_activation_redirect` is set, the redirect to the setup page.
101
-		if ( get_transient( '_wl_activation_redirect' ) ) {
102
-			delete_transient( '_wl_activation_redirect' );
103
-
104
-			// If the user asked to skip the wizard then comply.
105
-			if ( $this->configuration_service->is_skip_wizard() ) {
106
-				return;
107
-			}
108
-
109
-			// If we're already on the page or the user doesn't have permissions, return.
110
-			if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) {
111
-				return;
112
-			}
113
-
114
-			// Finally redirect to the setup page.
115
-			wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) );
116
-
117
-			exit;
118
-		}
119
-
120
-	}
121
-
122
-	/**
123
-	 * Generate an admin notice suggesting to start the wizard if there is no configuration.
124
-	 *
125
-	 * @since    3.9.0
126
-	 */
127
-	public function admin_notices() {
128
-
129
-		// Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard.
130
-		if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?>
31
+    /**
32
+     * A {@link Wordlift_Configuration_Service} instance.
33
+     *
34
+     * @since  3.9.0
35
+     * @access private
36
+     * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance.
37
+     */
38
+    private $configuration_service;
39
+
40
+    /**
41
+     * A {@link Wordlift_Key_Validation_Service} instance.
42
+     *
43
+     * @since  3.9.0
44
+     * @access private
45
+     * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance.
46
+     */
47
+    private $key_validation_service;
48
+
49
+    /**
50
+     * A {@link Wordlift_Entity_Service} instance.
51
+     *
52
+     * @since  3.9.0
53
+     * @access private
54
+     * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
55
+     */
56
+    private $entity_service;
57
+
58
+    /**
59
+     * Initialize the class and set its properties.
60
+     *
61
+     * @since    3.9.0
62
+     *
63
+     * @param Wordlift_Configuration_Service  $configuration_service  A {@link Wordlift_Configuration_Service} instance.
64
+     * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
65
+     * @param Wordlift_Entity_Service         $entity_service         A {@link Wordlift_Entity_Service} instance.
66
+     */
67
+    public function __construct( $configuration_service, $key_validation_service, $entity_service ) {
68
+
69
+        // Set a reference to the configuration service.
70
+        $this->configuration_service = $configuration_service;
71
+
72
+        // Set a reference to the key validation service.
73
+        $this->key_validation_service = $key_validation_service;
74
+
75
+        // Set a reference to the entity service.
76
+        $this->entity_service = $entity_service;
77
+
78
+        // Hook to some WP's events:
79
+        // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up.
80
+        add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
81
+
82
+        // Hook to `admin_menu` in order to add our own setup wizard page.
83
+        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
84
+
85
+        // Triggered when the user accesses the admin area, we decide whether to show our own wizard.
86
+        add_action( 'admin_init', array( $this, 'show_page' ) );
87
+
88
+        // Hook to `admin_notices` to display our notices.
89
+        add_action( 'admin_notices', array( $this, 'admin_notices' ) );
90
+
91
+    }
92
+
93
+    /**
94
+     * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set.
95
+     *
96
+     * @since 3.9.0
97
+     */
98
+    public function admin_init() {
99
+
100
+        // If the `_wl_activation_redirect` is set, the redirect to the setup page.
101
+        if ( get_transient( '_wl_activation_redirect' ) ) {
102
+            delete_transient( '_wl_activation_redirect' );
103
+
104
+            // If the user asked to skip the wizard then comply.
105
+            if ( $this->configuration_service->is_skip_wizard() ) {
106
+                return;
107
+            }
108
+
109
+            // If we're already on the page or the user doesn't have permissions, return.
110
+            if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) {
111
+                return;
112
+            }
113
+
114
+            // Finally redirect to the setup page.
115
+            wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) );
116
+
117
+            exit;
118
+        }
119
+
120
+    }
121
+
122
+    /**
123
+     * Generate an admin notice suggesting to start the wizard if there is no configuration.
124
+     *
125
+     * @since    3.9.0
126
+     */
127
+    public function admin_notices() {
128
+
129
+        // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard.
130
+        if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?>
131 131
 			<div id="wl-message" class="updated">
132 132
 				<p><?php esc_html_e( 'Welcome to WordLift &#8211; You&lsquo;re almost ready to start', 'wordlift' ); ?></p>
133 133
 				<p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>"
@@ -138,121 +138,121 @@  discard block
 block discarded – undo
138 138
 			</div>
139 139
 		<?php }
140 140
 
141
-	}
141
+    }
142 142
 
143
-	/**
144
-	 * Handle hiding the wizard notices by user request
145
-	 *
146
-	 * @since    3.9.0
147
-	 */
148
-	public function hide_notices() {
143
+    /**
144
+     * Handle hiding the wizard notices by user request
145
+     *
146
+     * @since    3.9.0
147
+     */
148
+    public function hide_notices() {
149 149
 
150
-		// If it's not a `wl-hide-notice` or the nonce is not set, return.
151
-		if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) {
152
-			return;
153
-		}
150
+        // If it's not a `wl-hide-notice` or the nonce is not set, return.
151
+        if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) {
152
+            return;
153
+        }
154 154
 
155
-		// If the nonce is invalid, return an error.
156
-		if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) {
157
-			wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) );
158
-		}
155
+        // If the nonce is invalid, return an error.
156
+        if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) {
157
+            wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) );
158
+        }
159 159
 
160
-		// If the user doesn't have the right privileges, return an error.
161
-		if ( ! current_user_can( 'manage_options' ) ) {
162
-			wp_die( __( 'Cheatin&#8217; huh?', 'wordlift' ) );
163
-		}
160
+        // If the user doesn't have the right privileges, return an error.
161
+        if ( ! current_user_can( 'manage_options' ) ) {
162
+            wp_die( __( 'Cheatin&#8217; huh?', 'wordlift' ) );
163
+        }
164 164
 
165
-		// Store a flag telling to skip the wizard.
166
-		$this->configuration_service->set_skip_wizard( TRUE );
165
+        // Store a flag telling to skip the wizard.
166
+        $this->configuration_service->set_skip_wizard( TRUE );
167 167
 
168
-	}
168
+    }
169 169
 
170
-	/**
171
-	 * Register the wizard page to be able to access it
172
-	 *
173
-	 * @since    3.9.0
174
-	 */
175
-	public function admin_menu() {
170
+    /**
171
+     * Register the wizard page to be able to access it
172
+     *
173
+     * @since    3.9.0
174
+     */
175
+    public function admin_menu() {
176 176
 
177
-		// @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu.
178
-		add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' );
177
+        // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu.
178
+        add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' );
179 179
 
180
-	}
180
+    }
181 181
 
182
-	/**
183
-	 * Displays the wizard page
184
-	 *
185
-	 * @since    3.9.0
186
-	 */
187
-	public function show_page() {
182
+    /**
183
+     * Displays the wizard page
184
+     *
185
+     * @since    3.9.0
186
+     */
187
+    public function show_page() {
188 188
 
189
-		// First check if we are in the wizard page at all, if not do nothing.
190
-		if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) {
191
-			return;
192
-		}
189
+        // First check if we are in the wizard page at all, if not do nothing.
190
+        if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) {
191
+            return;
192
+        }
193 193
 
194
-		// If it's a POST and the `wl-save-configuration` action is set, save the configuration.
195
-		if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) {
194
+        // If it's a POST and the `wl-save-configuration` action is set, save the configuration.
195
+        if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) {
196 196
 
197
-			// Check the nonce and the user capabilities.
198
-			check_admin_referer( 'wl-save-configuration' );
197
+            // Check the nonce and the user capabilities.
198
+            check_admin_referer( 'wl-save-configuration' );
199 199
 
200
-			// Check if the user has the right privileges.
201
-			if ( ! current_user_can( 'manage_options' ) ) {
202
-				wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) );
203
-			}
200
+            // Check if the user has the right privileges.
201
+            if ( ! current_user_can( 'manage_options' ) ) {
202
+                wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) );
203
+            }
204 204
 
205
-			// Save the configuration.
206
-			$this->save_configuration( $_POST );
205
+            // Save the configuration.
206
+            $this->save_configuration( $_POST );
207 207
 
208
-			// Redirect to the admin's page.
209
-			wp_redirect( admin_url() );
208
+            // Redirect to the admin's page.
209
+            wp_redirect( admin_url() );
210 210
 
211
-			exit;
212
-		}
211
+            exit;
212
+        }
213 213
 
214
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php';
214
+        include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php';
215 215
 
216
-		exit;
217
-	}
216
+        exit;
217
+    }
218 218
 
219
-	/**
220
-	 * Save WordLift's configuration using the provided parameters.
221
-	 *
222
-	 * @since 3.9.0
223
-	 *
224
-	 * @param array $params An array of configuration parameters.
225
-	 */
226
-	private function save_configuration( $params ) {
219
+    /**
220
+     * Save WordLift's configuration using the provided parameters.
221
+     *
222
+     * @since 3.9.0
223
+     *
224
+     * @param array $params An array of configuration parameters.
225
+     */
226
+    private function save_configuration( $params ) {
227 227
 
228
-		// We have the following parameters:
229
-		// `key`, holding WL's key,
230
-		// `vocabulary`, holding the vocabulary path,
231
-		// `language`, with the language code (e.g. `en`),
232
-		// `user_type`, the user type either `personal` or `company`,
233
-		// `name`, with the `personal` or `company`'s name,
234
-		// `logo`, the attachment id for the `personal` or `company` entity.
228
+        // We have the following parameters:
229
+        // `key`, holding WL's key,
230
+        // `vocabulary`, holding the vocabulary path,
231
+        // `language`, with the language code (e.g. `en`),
232
+        // `user_type`, the user type either `personal` or `company`,
233
+        // `name`, with the `personal` or `company`'s name,
234
+        // `logo`, the attachment id for the `personal` or `company` entity.
235 235
 
236
-		// Store the key:
237
-		$this->configuration_service->set_key( $params['key'] );
236
+        // Store the key:
237
+        $this->configuration_service->set_key( $params['key'] );
238 238
 
239
-		// Store the vocabulary path:
240
-		$this->configuration_service->set_entity_base_path( $params['vocabulary'] );
239
+        // Store the vocabulary path:
240
+        $this->configuration_service->set_entity_base_path( $params['vocabulary'] );
241 241
 
242
-		// Store the site's language:
243
-		$this->configuration_service->set_language_code( $params['language'] );
242
+        // Store the site's language:
243
+        $this->configuration_service->set_language_code( $params['language'] );
244 244
 
245
-		// Set the type URI, either http://schema.org/Person or http://schema.org/Organization.
246
-		$type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' );
245
+        // Set the type URI, either http://schema.org/Person or http://schema.org/Organization.
246
+        $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' );
247 247
 
248
-		// Create an entity for the publisher.
249
-		$publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' );
248
+        // Create an entity for the publisher.
249
+        $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' );
250 250
 
251
-		// Store the publisher entity post id in the configuration.
252
-		$this->configuration_service->set_publisher_id( $publisher_post_id );
251
+        // Store the publisher entity post id in the configuration.
252
+        $this->configuration_service->set_publisher_id( $publisher_post_id );
253 253
 
254
-		flush_rewrite_rules(); // Needed because of possible change to the entity base path.
254
+        flush_rewrite_rules(); // Needed because of possible change to the entity base path.
255 255
 
256
-	}
256
+    }
257 257
 
258 258
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since      3.9.0
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
65 65
 	 * @param Wordlift_Entity_Service         $entity_service         A {@link Wordlift_Entity_Service} instance.
66 66
 	 */
67
-	public function __construct( $configuration_service, $key_validation_service, $entity_service ) {
67
+	public function __construct($configuration_service, $key_validation_service, $entity_service) {
68 68
 
69 69
 		// Set a reference to the configuration service.
70 70
 		$this->configuration_service = $configuration_service;
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// Hook to some WP's events:
79 79
 		// When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up.
80
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
80
+		add_action('wp_loaded', array($this, 'hide_notices'));
81 81
 
82 82
 		// Hook to `admin_menu` in order to add our own setup wizard page.
83
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
83
+		add_action('admin_menu', array($this, 'admin_menu'));
84 84
 
85 85
 		// Triggered when the user accesses the admin area, we decide whether to show our own wizard.
86
-		add_action( 'admin_init', array( $this, 'show_page' ) );
86
+		add_action('admin_init', array($this, 'show_page'));
87 87
 
88 88
 		// Hook to `admin_notices` to display our notices.
89
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
89
+		add_action('admin_notices', array($this, 'admin_notices'));
90 90
 
91 91
 	}
92 92
 
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
 	public function admin_init() {
99 99
 
100 100
 		// If the `_wl_activation_redirect` is set, the redirect to the setup page.
101
-		if ( get_transient( '_wl_activation_redirect' ) ) {
102
-			delete_transient( '_wl_activation_redirect' );
101
+		if (get_transient('_wl_activation_redirect')) {
102
+			delete_transient('_wl_activation_redirect');
103 103
 
104 104
 			// If the user asked to skip the wizard then comply.
105
-			if ( $this->configuration_service->is_skip_wizard() ) {
105
+			if ($this->configuration_service->is_skip_wizard()) {
106 106
 				return;
107 107
 			}
108 108
 
109 109
 			// If we're already on the page or the user doesn't have permissions, return.
110
-			if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) {
110
+			if (( ! empty($_GET['page']) && 'wl-setup' === $_GET['page']) || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) {
111 111
 				return;
112 112
 			}
113 113
 
114 114
 			// Finally redirect to the setup page.
115
-			wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) );
115
+			wp_safe_redirect(admin_url('index.php?page=wl-setup'));
116 116
 
117 117
 			exit;
118 118
 		}
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	public function admin_notices() {
128 128
 
129 129
 		// Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard.
130
-		if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?>
130
+		if ('' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard()) { ?>
131 131
 			<div id="wl-message" class="updated">
132
-				<p><?php esc_html_e( 'Welcome to WordLift &#8211; You&lsquo;re almost ready to start', 'wordlift' ); ?></p>
133
-				<p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>"
134
-				                     class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'wordlift' ); ?></a>
132
+				<p><?php esc_html_e('Welcome to WordLift &#8211; You&lsquo;re almost ready to start', 'wordlift'); ?></p>
133
+				<p class="submit"><a href="<?php echo esc_url(admin_url('admin.php?page=wl-setup')); ?>"
134
+				                     class="button-primary"><?php esc_html_e('Run the Setup Wizard', 'wordlift'); ?></a>
135 135
 					<a class="button-secondary skip"
136
-					   href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wl-hide-notice', 'install' ), 'wordlift_hide_notices_nonce', '_wl_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip Setup', 'wordlift' ); ?></a>
136
+					   href="<?php echo esc_url(wp_nonce_url(add_query_arg('wl-hide-notice', 'install'), 'wordlift_hide_notices_nonce', '_wl_notice_nonce')); ?>"><?php esc_html_e('Skip Setup', 'wordlift'); ?></a>
137 137
 				</p>
138 138
 			</div>
139 139
 		<?php }
@@ -148,22 +148,22 @@  discard block
 block discarded – undo
148 148
 	public function hide_notices() {
149 149
 
150 150
 		// If it's not a `wl-hide-notice` or the nonce is not set, return.
151
-		if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) {
151
+		if ( ! isset($_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'])) {
152 152
 			return;
153 153
 		}
154 154
 
155 155
 		// If the nonce is invalid, return an error.
156
-		if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) {
157
-			wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) );
156
+		if ( ! wp_verify_nonce($_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce')) {
157
+			wp_die(__('Action failed. Please refresh the page and retry.', 'wordlift'));
158 158
 		}
159 159
 
160 160
 		// If the user doesn't have the right privileges, return an error.
161
-		if ( ! current_user_can( 'manage_options' ) ) {
162
-			wp_die( __( 'Cheatin&#8217; huh?', 'wordlift' ) );
161
+		if ( ! current_user_can('manage_options')) {
162
+			wp_die(__('Cheatin&#8217; huh?', 'wordlift'));
163 163
 		}
164 164
 
165 165
 		// Store a flag telling to skip the wizard.
166
-		$this->configuration_service->set_skip_wizard( TRUE );
166
+		$this->configuration_service->set_skip_wizard(TRUE);
167 167
 
168 168
 	}
169 169
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	public function admin_menu() {
176 176
 
177 177
 		// @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu.
178
-		add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' );
178
+		add_dashboard_page('', '', 'manage_options', 'wl-setup', '');
179 179
 
180 180
 	}
181 181
 
@@ -187,31 +187,31 @@  discard block
 block discarded – undo
187 187
 	public function show_page() {
188 188
 
189 189
 		// First check if we are in the wizard page at all, if not do nothing.
190
-		if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) {
190
+		if (empty($_GET['page']) || 'wl-setup' !== $_GET['page']) {
191 191
 			return;
192 192
 		}
193 193
 
194 194
 		// If it's a POST and the `wl-save-configuration` action is set, save the configuration.
195
-		if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) {
195
+		if (isset($_POST['action']) && 'wl-save-configuration' === $_POST['action']) {
196 196
 
197 197
 			// Check the nonce and the user capabilities.
198
-			check_admin_referer( 'wl-save-configuration' );
198
+			check_admin_referer('wl-save-configuration');
199 199
 
200 200
 			// Check if the user has the right privileges.
201
-			if ( ! current_user_can( 'manage_options' ) ) {
202
-				wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) );
201
+			if ( ! current_user_can('manage_options')) {
202
+				wp_die(__('Sorry, you do not have a permission to save the settings', 'wordlift'));
203 203
 			}
204 204
 
205 205
 			// Save the configuration.
206
-			$this->save_configuration( $_POST );
206
+			$this->save_configuration($_POST);
207 207
 
208 208
 			// Redirect to the admin's page.
209
-			wp_redirect( admin_url() );
209
+			wp_redirect(admin_url());
210 210
 
211 211
 			exit;
212 212
 		}
213 213
 
214
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php';
214
+		include plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-setup.php';
215 215
 
216 216
 		exit;
217 217
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @param array $params An array of configuration parameters.
225 225
 	 */
226
-	private function save_configuration( $params ) {
226
+	private function save_configuration($params) {
227 227
 
228 228
 		// We have the following parameters:
229 229
 		// `key`, holding WL's key,
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
 		// `logo`, the attachment id for the `personal` or `company` entity.
235 235
 
236 236
 		// Store the key:
237
-		$this->configuration_service->set_key( $params['key'] );
237
+		$this->configuration_service->set_key($params['key']);
238 238
 
239 239
 		// Store the vocabulary path:
240
-		$this->configuration_service->set_entity_base_path( $params['vocabulary'] );
240
+		$this->configuration_service->set_entity_base_path($params['vocabulary']);
241 241
 
242 242
 		// Store the site's language:
243
-		$this->configuration_service->set_language_code( $params['language'] );
243
+		$this->configuration_service->set_language_code($params['language']);
244 244
 
245 245
 		// Set the type URI, either http://schema.org/Person or http://schema.org/Organization.
246
-		$type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' );
246
+		$type_uri = sprintf('http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person');
247 247
 
248 248
 		// Create an entity for the publisher.
249
-		$publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' );
249
+		$publisher_post_id = $this->entity_service->create($params['name'], $type_uri, $params['logo'], 'publish');
250 250
 
251 251
 		// Store the publisher entity post id in the configuration.
252
-		$this->configuration_service->set_publisher_id( $publisher_post_id );
252
+		$this->configuration_service->set_publisher_id($publisher_post_id);
253 253
 
254 254
 		flush_rewrite_rules(); // Needed because of possible change to the entity base path.
255 255
 
Please login to merge, or discard this patch.