Completed
Pull Request — develop (#1576)
by Naveen
01:08
created
src/includes/class-wordlift-schema-service.php 2 patches
Indentation   +1239 added lines, -1239 removed lines patch added patch discarded remove patch
@@ -18,1244 +18,1244 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Schema_Service {
20 20
 
21
-	/**
22
-	 * The 'location created' field name.
23
-	 *
24
-	 * @since 3.5.0
25
-	 */
26
-	const FIELD_LOCATION_CREATED = 'wl_location_created';
27
-
28
-	/**
29
-	 * The 'topic' field name.
30
-	 *
31
-	 * @since 3.5.0
32
-	 */
33
-	const FIELD_TOPIC = 'wl_topic';
34
-
35
-	/**
36
-	 * The 'author' field name.
37
-	 *
38
-	 * @since 3.1.0
39
-	 */
40
-	const FIELD_AUTHOR = 'wl_author';
41
-
42
-	/**
43
-	 * The 'same as' field name.
44
-	 *
45
-	 * @since 3.1.0
46
-	 */
47
-	const FIELD_SAME_AS = 'entity_same_as';
48
-
49
-	/**
50
-	 * The 'date start' field name.
51
-	 *
52
-	 * @since 3.1.0
53
-	 */
54
-	const FIELD_DATE_START = 'wl_cal_date_start';
55
-
56
-	/**
57
-	 * The 'date end' field name.
58
-	 *
59
-	 * @since 3.1.0
60
-	 */
61
-	const FIELD_DATE_END = 'wl_cal_date_end';
62
-
63
-	/**
64
-	 * The 'location' field name.
65
-	 *
66
-	 * @since 3.1.0
67
-	 */
68
-	const FIELD_LOCATION = 'wl_location';
69
-
70
-	/**
71
-	 * The 'founder' field name.
72
-	 *
73
-	 * @since 3.1.0
74
-	 */
75
-	const FIELD_FOUNDER = 'wl_founder';
76
-
77
-	/**
78
-	 * The 'knows' field name.
79
-	 *
80
-	 * @since 3.1.0
81
-	 */
82
-	const FIELD_KNOWS = 'wl_knows';
83
-
84
-	/**
85
-	 * The 'birth date' field name.
86
-	 *
87
-	 * @since 3.1.0
88
-	 */
89
-	const FIELD_BIRTH_DATE = 'wl_birth_date';
90
-
91
-	/**
92
-	 * The 'birth place' field name.
93
-	 *
94
-	 * @since 3.1.0
95
-	 */
96
-	const FIELD_BIRTH_PLACE = 'wl_birth_place';
97
-
98
-	/**
99
-	 * The 'latitude' field name.
100
-	 *
101
-	 * @since 3.1.0
102
-	 */
103
-	const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
104
-
105
-	/**
106
-	 * The 'longitude' field name.
107
-	 *
108
-	 * @since 3.1.0
109
-	 */
110
-	const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
111
-
112
-	/**
113
-	 * The 'streetAddress' field name.
114
-	 *
115
-	 * @since 3.1.0
116
-	 */
117
-	const FIELD_ADDRESS = 'wl_address';
118
-
119
-	/**
120
-	 * The 'postOfficeBoxNumber' field name.
121
-	 *
122
-	 * @since 3.3.0
123
-	 */
124
-	const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box';
125
-
126
-	/**
127
-	 * The 'postalCode' field name.
128
-	 *
129
-	 * @since 3.3.0
130
-	 */
131
-	const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code';
132
-
133
-	/**
134
-	 * The 'addressLocality' field name.
135
-	 *
136
-	 * @since 3.3.0
137
-	 */
138
-	const FIELD_ADDRESS_LOCALITY = 'wl_address_locality';
139
-	/**
140
-	 * The 'addressRegion' field name.
141
-	 *
142
-	 * @since 3.3.0
143
-	 */
144
-	const FIELD_ADDRESS_REGION = 'wl_address_region';
145
-
146
-	/**
147
-	 * The 'addressCountry' field name.
148
-	 *
149
-	 * @since 3.3.0
150
-	 */
151
-	const FIELD_ADDRESS_COUNTRY = 'wl_address_country';
152
-
153
-	/**
154
-	 * The 'entity type' field name.
155
-	 *
156
-	 * @since 3.1.0
157
-	 */
158
-	const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
159
-
160
-	/**
161
-	 * The 'email' field name.
162
-	 *
163
-	 * @since 3.2.0
164
-	 */
165
-	const FIELD_EMAIL = 'wl_email';
166
-
167
-	/**
168
-	 * The 'affiliation' field name.
169
-	 *
170
-	 * @since 3.2.0
171
-	 */
172
-	const FIELD_AFFILIATION = 'wl_affiliation';
173
-
174
-	/**
175
-	 * The 'telephone' field name.
176
-	 *
177
-	 * @since 3.8.0
178
-	 */
179
-	const FIELD_TELEPHONE = 'wl_schema_telephone';
180
-
181
-	/**
182
-	 * The 'legalName' field name.
183
-	 *
184
-	 * @since 3.12.0
185
-	 */
186
-	const FIELD_LEGAL_NAME = 'wl_schema_legal_name';
187
-
188
-	/**
189
-	 * The 'recipeCuisine' field name.
190
-	 *
191
-	 * @since 3.14.0
192
-	 */
193
-	const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine';
194
-
195
-	/**
196
-	 * The 'recipeIngredient' field name.
197
-	 *
198
-	 * @since 3.14.0
199
-	 */
200
-	const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient';
201
-
202
-	/**
203
-	 * The 'calories' field name.
204
-	 *
205
-	 * @since 3.14.0
206
-	 */
207
-	const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories';
208
-
209
-	/**
210
-	 * The 'recipeInstructions' field name.
211
-	 *
212
-	 * @since 3.14.0
213
-	 */
214
-	const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions';
215
-
216
-	/**
217
-	 * The 'recipeYield' field name.
218
-	 *
219
-	 * @since 3.14.0
220
-	 */
221
-	const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield';
222
-
223
-	/**
224
-	 * The 'prepTime' field name.
225
-	 *
226
-	 * @since 3.14.0
227
-	 */
228
-	const FIELD_PREP_TIME = 'wl_schema_prep_time';
229
-
230
-	/**
231
-	 * The 'cookTime' field name.
232
-	 *
233
-	 * @since 3.14.0
234
-	 */
235
-	const FIELD_COOK_TIME = 'wl_schema_cook_time';
236
-
237
-	/**
238
-	 * The 'totalTime' field name.
239
-	 *
240
-	 * @since 3.14.0
241
-	 */
242
-	const FIELD_TOTAL_TIME = 'wl_schema_total_time';
243
-
244
-	/**
245
-	 * The 'performer' field name.
246
-	 *
247
-	 * @since 3.18.0
248
-	 */
249
-	const FIELD_PERFORMER = 'wl_schema_performer';
250
-
251
-	/**
252
-	 * The 'offers' field name.
253
-	 *
254
-	 * @since 3.18.0
255
-	 */
256
-	const FIELD_OFFERS = 'wl_schema_offers';
257
-
258
-	/**
259
-	 * The 'availablity' field name.
260
-	 *
261
-	 * @since 3.18.0
262
-	 */
263
-	const FIELD_AVAILABILITY = 'wl_schema_availability';
264
-
265
-	/**
266
-	 * The 'inventoryLevel' field name.
267
-	 *
268
-	 * @since 3.18.0
269
-	 */
270
-	const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level';
271
-
272
-	/**
273
-	 * The 'price' field name.
274
-	 *
275
-	 * @since 3.18.0
276
-	 */
277
-	const FIELD_PRICE = 'wl_schema_price';
278
-
279
-	/**
280
-	 * The 'priceCurrency' field name.
281
-	 *
282
-	 * @since 3.18.0
283
-	 */
284
-	const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency';
285
-
286
-	/**
287
-	 * The 'availabilityStarts' field name.
288
-	 *
289
-	 * @since 3.18.0
290
-	 */
291
-	const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts';
292
-
293
-	/**
294
-	 * The 'availabilityEnds' field name.
295
-	 *
296
-	 * @since 3.18.0
297
-	 */
298
-	const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends';
299
-
300
-	/**
301
-	 * The 'validFrom' field name.
302
-	 *
303
-	 * @since 3.18.0
304
-	 */
305
-	const FIELD_VALID_FROM = 'wl_schema_valid_from';
306
-
307
-	/**
308
-	 * The 'priceValidUntil' field name.
309
-	 *
310
-	 * @since 3.18.0
311
-	 */
312
-	const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until';
313
-
314
-	/**
315
-	 * The 'itemOffered' field name.
316
-	 *
317
-	 * @since 3.18.0
318
-	 */
319
-	const FIELD_ITEM_OFFERED = 'wl_schema_item_offered';
320
-
321
-	/**
322
-	 * The 'URI' data type name.
323
-	 *
324
-	 * @since 3.1.0
325
-	 */
326
-	const DATA_TYPE_URI = 'uri';
327
-
328
-	/**
329
-	 * The 'date' data type name.
330
-	 *
331
-	 * @since 3.1.0
332
-	 */
333
-	const DATA_TYPE_DATE = 'date';
334
-
335
-	/**
336
-	 * The 'time' data type name.
337
-	 *
338
-	 * @since 3.14.0
339
-	 */
340
-	const DATA_TYPE_DURATION = 'duration';
341
-
342
-	/**
343
-	 * The 'double' data type name.
344
-	 *
345
-	 * @since 3.1.0
346
-	 */
347
-	const DATA_TYPE_DOUBLE = 'double';
348
-
349
-	/**
350
-	 * The 'string' data type name.
351
-	 *
352
-	 * @since 3.1.0
353
-	 */
354
-	const DATA_TYPE_STRING = 'string';
355
-
356
-	/**
357
-	 * The multiline text data type name.
358
-	 *
359
-	 * @since 3.14.0
360
-	 */
361
-	const DATA_TYPE_MULTILINE = 'multiline';
362
-
363
-	/**
364
-	 * The schema.org Event type URI.
365
-	 *
366
-	 * @since 3.1.0
367
-	 */
368
-	const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
369
-
370
-	/**
371
-	 * The schema.org Offer type URI.
372
-	 *
373
-	 * @since 3.18.0
374
-	 */
375
-	const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer';
376
-
377
-	/**
378
-	 * WordLift's schema.
379
-	 *
380
-	 * @since  3.1.0
381
-	 * @access private
382
-	 * @var array $schema WordLift's schema.
383
-	 */
384
-	private $schema;
385
-
386
-	/**
387
-	 * The Log service.
388
-	 *
389
-	 * @since  3.1.0
390
-	 * @access private
391
-	 * @var \Wordlift_Log_Service $log The Log service.
392
-	 */
393
-	private $log;
394
-
395
-	/**
396
-	 * Wordlift_Schema_Service constructor.
397
-	 *
398
-	 * @since 3.1.0
399
-	 */
400
-	protected function __construct() {
401
-
402
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
403
-
404
-		/**
405
-		 * Alter the configured schemas.
406
-		 *
407
-		 * Enable 3rd parties to alter WordLift's schemas array.
408
-		 *
409
-		 * @param array $schemas The array of schemas.
410
-		 *
411
-		 * @since  3.19.1
412
-		 */
413
-		$this->schema = apply_filters(
414
-			'wl_schemas',
415
-			array(
416
-				'article'        => $this->get_article_schema(),
417
-				'thing'          => $this->get_thing_schema(),
418
-				'creative-work'  => $this->get_creative_work_schema(),
419
-				'event'          => $this->get_event_schema(),
420
-				'organization'   => $this->get_organization_schema(),
421
-				'person'         => $this->get_person_schema(),
422
-				'place'          => $this->get_place_schema(),
423
-				'local-business' => $this->get_local_business_schema(),
424
-				'recipe'         => $this->get_recipe_schema(),
425
-				'web-page'       => $this->get_web_page_schema(),
426
-				'offer'          => $this->get_offer_schema(),
427
-			)
428
-		);
429
-
430
-		// Create a singleton instance of the Schema service, useful to provide static functions to global functions.
431
-		self::$instance = $this;
432
-
433
-	}
434
-
435
-	public function get_all_schema_slugs() {
436
-		return array_keys( $this->schema );
437
-	}
438
-
439
-	/**
440
-	 * The Schema service singleton instance.
441
-	 *
442
-	 * @since  3.1.0
443
-	 * @access private
444
-	 * @var Wordlift_Schema_Service $instance The Schema service singleton instance.
445
-	 */
446
-	private static $instance = null;
447
-
448
-	/**
449
-	 * Get a reference to the Schema service.
450
-	 *
451
-	 * @return Wordlift_Schema_Service A reference to the Schema service.
452
-	 * @since 3.1.0
453
-	 */
454
-	public static function get_instance() {
455
-		if ( ! isset( self::$instance ) ) {
456
-			self::$instance = new self();
457
-		}
458
-
459
-		return self::$instance;
460
-	}
461
-
462
-	/**
463
-	 * Get the properties for a field with the specified key. The key is used as
464
-	 * meta key when the field's value is stored in WordPress meta data table.
465
-	 *
466
-	 * @param string $key The field's key.
467
-	 *
468
-	 * @return null|array An array of field's properties or null if the field is not found.
469
-	 * @since 3.6.0
470
-	 */
471
-	public function get_field( $key ) {
472
-
473
-		// Parse each schema's fields until we find the one we're looking for, then
474
-		// return its properties.
475
-		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
476
-		foreach ( $this->schema as $_ => $schema ) {
477
-
478
-			if ( ! isset( $schema['custom_fields'] ) ) {
479
-				break;
480
-			}
481
-
482
-			foreach ( $schema['custom_fields'] as $field => $props ) {
483
-				if ( $key === $field ) {
484
-					return $props;
485
-				}
486
-			}
487
-		}
488
-
489
-		return null;
490
-	}
491
-
492
-	/**
493
-	 * Get the WordLift's schema.
494
-	 *
495
-	 * @param string $name The schema name.
496
-	 *
497
-	 * @return array|null An array with the schema configuration or NULL if the schema is not found.
498
-	 *
499
-	 * @since 3.1.0
500
-	 */
501
-	public function get_schema( $name ) {
502
-		// Check if the schema exists and, if not, return NULL.
503
-		if ( ! isset( $this->schema[ $name ] ) ) {
504
-			return null;
505
-		}
506
-
507
-		// Return the requested schema.
508
-		return $this->schema[ $name ];
509
-	}
510
-
511
-	/**
512
-	 * Get the WordLift's schema trough schema type uri.
513
-	 *
514
-	 * @param string $uri The schema uri.
515
-	 *
516
-	 * @return array|null An array with the schema configuration or NULL if the schema is not found.
517
-	 *
518
-	 * @since 3.3.0
519
-	 */
520
-	public function get_schema_by_uri( $uri ) {
521
-
522
-		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
523
-		foreach ( $this->schema as $name => $schema ) {
524
-			if ( $schema['uri'] === $uri ) {
525
-				return $schema;
526
-			}
527
-		}
528
-
529
-		return null;
530
-	}
531
-
532
-	/**
533
-	 * Get the 'thing' schema.
534
-	 *
535
-	 * @return array An array with the schema configuration.
536
-	 *
537
-	 * @since 3.1.0
538
-	 */
539
-	private function get_thing_schema() {
540
-
541
-		return array(
542
-			'css_class'     => 'wl-thing',
543
-			'uri'           => 'http://schema.org/Thing',
544
-			'same_as'       => array( '*' ),
545
-			// set as default.
546
-			'custom_fields' => array(
547
-				self::FIELD_SAME_AS => array(
548
-					'predicate'   => 'http://schema.org/sameAs',
549
-					'type'        => self::DATA_TYPE_URI,
550
-					'export_type' => 'http://schema.org/Thing',
551
-					'constraints' => array(
552
-						'cardinality' => INF,
553
-					),
554
-					// We need a custom metabox.
555
-					'input_field' => 'sameas',
556
-				),
557
-				// Add the schema:url property.
558
-				Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance()
559
-																									  ->get_compat_definition(),
560
-			),
561
-			// {{sameAs}} not present in the microdata template,
562
-			// because it is treated separately in *wl_content_embed_item_microdata*
563
-			'templates'     => array(
564
-				'subtitle' => '{{id}}',
565
-			),
566
-		);
567
-
568
-	}
569
-
570
-	/**
571
-	 * Get the 'web-page' schema.
572
-	 *
573
-	 * @return array An array with the schema configuration.
574
-	 *
575
-	 * @since 3.18.0
576
-	 */
577
-	private function get_web_page_schema() {
578
-
579
-		return array(
580
-			'css_class' => 'wl-webpage',
581
-			'uri'       => 'http://schema.org/WebPage',
582
-		);
583
-
584
-	}
585
-
586
-	/**
587
-	 * Get the 'creative work' schema.
588
-	 *
589
-	 * @return array An array with the schema configuration.
590
-	 *
591
-	 * @since 3.1.0
592
-	 */
593
-	private function get_creative_work_schema() {
594
-
595
-		$schema = array(
596
-			'label'         => 'CreativeWork',
597
-			'description'   => 'A creative work (or a Music Album).',
598
-			'parents'       => array( 'thing' ),
599
-			// Give term slug as parent.
600
-			'css_class'     => 'wl-creative-work',
601
-			'uri'           => 'http://schema.org/CreativeWork',
602
-			'same_as'       => array(
603
-				'http://schema.org/MusicAlbum',
604
-				'http://schema.org/Product',
605
-			),
606
-			'custom_fields' => array(
607
-				self::FIELD_AUTHOR => array(
608
-					'predicate'   => 'http://schema.org/author',
609
-					'type'        => self::DATA_TYPE_URI,
610
-					'export_type' => 'http://schema.org/Person',
611
-					'constraints' => array(
612
-						'uri_type'    => array( 'Person', 'Organization' ),
613
-						'cardinality' => INF,
614
-					),
615
-				),
616
-			),
617
-			'templates'     => array(
618
-				'subtitle' => '{{id}}',
619
-			),
620
-		);
621
-
622
-		// Merge the custom fields with those provided by the thing schema.
623
-		$parent_schema           = $this->get_thing_schema();
624
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
625
-
626
-		return $schema;
627
-	}
628
-
629
-	/**
630
-	 * Get the 'event' schema.
631
-	 *
632
-	 * @return array An array with the schema configuration.
633
-	 *
634
-	 * @since 3.1.0
635
-	 */
636
-	private function get_event_schema() {
637
-
638
-		$schema = array(
639
-			'label'         => 'Event',
640
-			'description'   => 'An event . ',
641
-			'parents'       => array( 'thing' ),
642
-			'css_class'     => 'wl-event',
643
-			'uri'           => self::SCHEMA_EVENT_TYPE,
644
-			'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
645
-			'custom_fields' => array(
646
-				self::FIELD_DATE_START => array(
647
-					'predicate'   => 'http://schema.org/startDate',
648
-					'type'        => self::DATA_TYPE_DATE,
649
-					'export_type' => 'xsd:dateTime',
650
-					'constraints' => '',
651
-				),
652
-				self::FIELD_DATE_END   => array(
653
-					'predicate'   => 'http://schema.org/endDate',
654
-					'type'        => self::DATA_TYPE_DATE,
655
-					'export_type' => 'xsd:dateTime',
656
-					'constraints' => '',
657
-				),
658
-				self::FIELD_LOCATION   => array(
659
-					'predicate'   => 'http://schema.org/location',
660
-					'type'        => self::DATA_TYPE_URI,
661
-					'export_type' => 'http://schema.org/PostalAddress',
662
-					'constraints' => array(
663
-						'uri_type'    => array( 'Place', 'LocalBusiness' ),
664
-						'cardinality' => INF,
665
-					),
666
-				),
667
-				self::FIELD_PERFORMER  => array(
668
-					'predicate'   => 'http://schema.org/performer',
669
-					'type'        => self::DATA_TYPE_URI,
670
-					'export_type' => 'http://schema.org/Person',
671
-					'constraints' => array(
672
-						'uri_type'    => array( 'Person', 'Organization' ),
673
-						'cardinality' => INF,
674
-					),
675
-				),
676
-				self::FIELD_OFFERS     => array(
677
-					'predicate'   => 'http://schema.org/offers',
678
-					'type'        => self::DATA_TYPE_URI,
679
-					'export_type' => 'http://schema.org/Offer',
680
-					'constraints' => array(
681
-						'uri_type'    => array( 'Offer' ),
682
-						'cardinality' => INF,
683
-					),
684
-				),
685
-			),
686
-			'templates'     => array(
687
-				'subtitle' => '{{id}}',
688
-			),
689
-		);
690
-
691
-		// Merge the custom fields with those provided by the thing schema.
692
-		$parent_schema           = $this->get_thing_schema();
693
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
694
-
695
-		return $schema;
696
-	}
697
-
698
-	/**
699
-	 * Get the 'organization' schema.
700
-	 *
701
-	 * @return array An array with the schema configuration.
702
-	 *
703
-	 * @since 3.1.0
704
-	 */
705
-	private function get_organization_schema() {
706
-
707
-		$schema = array(
708
-			'label'         => 'Organization',
709
-			'description'   => 'An organization, including a government or a newspaper.',
710
-			'parents'       => array( 'thing' ),
711
-			'css_class'     => 'wl-organization',
712
-			'uri'           => 'http://schema.org/Organization',
713
-			'same_as'       => array(
714
-				'http://rdf.freebase.com/ns/organization.organization',
715
-				'http://rdf.freebase.com/ns/government.government',
716
-				'http://schema.org/Newspaper',
717
-			),
718
-			'custom_fields' => array(
719
-				self::FIELD_LEGAL_NAME          => array(
720
-					'predicate'   => 'http://schema.org/legalName',
721
-					'type'        => self::DATA_TYPE_STRING,
722
-					'export_type' => 'xsd:string',
723
-					'constraints' => '',
724
-				),
725
-				self::FIELD_FOUNDER             => array(
726
-					'predicate'   => 'http://schema.org/founder',
727
-					'type'        => self::DATA_TYPE_URI,
728
-					'export_type' => 'http://schema.org/Person',
729
-					'constraints' => array(
730
-						'uri_type'    => 'Person',
731
-						'cardinality' => INF,
732
-					),
733
-				),
734
-				self::FIELD_ADDRESS             => array(
735
-					'predicate'   => 'http://schema.org/streetAddress',
736
-					'type'        => self::DATA_TYPE_STRING,
737
-					'export_type' => 'xsd:string',
738
-					'constraints' => '',
739
-					// To build custom metabox.
740
-					'input_field' => 'address',
741
-				),
742
-				self::FIELD_ADDRESS_PO_BOX      => array(
743
-					'predicate'   => 'http://schema.org/postOfficeBoxNumber',
744
-					'type'        => self::DATA_TYPE_STRING,
745
-					'export_type' => 'xsd:string',
746
-					'constraints' => '',
747
-					// To build custom metabox.
748
-					'input_field' => 'address',
749
-				),
750
-				self::FIELD_ADDRESS_POSTAL_CODE => array(
751
-					'predicate'   => 'http://schema.org/postalCode',
752
-					'type'        => self::DATA_TYPE_STRING,
753
-					'export_type' => 'xsd:string',
754
-					'constraints' => '',
755
-					// To build custom metabox.
756
-					'input_field' => 'address',
757
-				),
758
-				self::FIELD_ADDRESS_LOCALITY    => array(
759
-					'predicate'   => 'http://schema.org/addressLocality',
760
-					'type'        => self::DATA_TYPE_STRING,
761
-					'export_type' => 'xsd:string',
762
-					'constraints' => '',
763
-					// To build custom metabox.
764
-					'input_field' => 'address',
765
-				),
766
-				self::FIELD_ADDRESS_REGION      => array(
767
-					'predicate'   => 'http://schema.org/addressRegion',
768
-					'type'        => self::DATA_TYPE_STRING,
769
-					'export_type' => 'xsd:string',
770
-					'constraints' => '',
771
-					// To build custom metabox.
772
-					'input_field' => 'address',
773
-				),
774
-				self::FIELD_ADDRESS_COUNTRY     => array(
775
-					'predicate'   => 'http://schema.org/addressCountry',
776
-					'type'        => self::DATA_TYPE_STRING,
777
-					'export_type' => 'xsd:string',
778
-					'constraints' => '',
779
-					// To build custom metabox.
780
-					'input_field' => 'address',
781
-				),
782
-				self::FIELD_EMAIL               => array(
783
-					'predicate'   => 'http://schema.org/email',
784
-					'type'        => self::DATA_TYPE_STRING,
785
-					'export_type' => 'xsd:string',
786
-					'constraints' => '',
787
-				),
788
-				self::FIELD_TELEPHONE           => array(
789
-					'predicate'   => 'http://schema.org/telephone',
790
-					'type'        => self::DATA_TYPE_STRING,
791
-					'export_type' => 'xsd:string',
792
-					'constraints' => '',
793
-				),
794
-			),
795
-			'templates'     => array(
796
-				'subtitle' => '{{id}}',
797
-			),
798
-		);
799
-
800
-		// Merge the custom fields with those provided by the thing schema.
801
-		$parent_schema           = $this->get_thing_schema();
802
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
803
-
804
-		return $schema;
805
-	}
806
-
807
-	/**
808
-	 * Get the 'person' schema.
809
-	 *
810
-	 * @return array An array with the schema configuration.
811
-	 *
812
-	 * @since 3.1.0
813
-	 */
814
-	private function get_person_schema() {
815
-
816
-		$schema = array(
817
-			'label'         => 'Person',
818
-			'description'   => 'A person (or a music artist).',
819
-			'parents'       => array( 'thing' ),
820
-			'css_class'     => 'wl-person',
821
-			'uri'           => 'http://schema.org/Person',
822
-			'same_as'       => array(
823
-				'http://rdf.freebase.com/ns/people.person',
824
-				'http://rdf.freebase.com/ns/music.artist',
825
-				'http://dbpedia.org/class/yago/LivingPeople',
826
-			),
827
-			'custom_fields' => array(
828
-				self::FIELD_KNOWS       => array(
829
-					'predicate'   => 'http://schema.org/knows',
830
-					'type'        => self::DATA_TYPE_URI,
831
-					'export_type' => 'http://schema.org/Person',
832
-					'constraints' => array(
833
-						'uri_type'    => 'Person',
834
-						'cardinality' => INF,
835
-					),
836
-				),
837
-				self::FIELD_BIRTH_DATE  => array(
838
-					'predicate'   => 'http://schema.org/birthDate',
839
-					'type'        => self::DATA_TYPE_DATE,
840
-					'export_type' => 'xsd:date',
841
-					'constraints' => '',
842
-				),
843
-				self::FIELD_BIRTH_PLACE => array(
844
-					'predicate'   => 'http://schema.org/birthPlace',
845
-					'type'        => self::DATA_TYPE_URI,
846
-					'export_type' => 'http://schema.org/Place',
847
-					'constraints' => array(
848
-						'uri_type' => 'Place',
849
-					),
850
-				),
851
-				self::FIELD_AFFILIATION => array(
852
-					'predicate'   => 'http://schema.org/affiliation',
853
-					'type'        => self::DATA_TYPE_URI,
854
-					'export_type' => 'http://schema.org/Organization',
855
-					'constraints' => array(
856
-						'uri_type'    => array(
857
-							'Organization',
858
-							'LocalBusiness',
859
-						),
860
-						'cardinality' => INF,
861
-					),
862
-				),
863
-				self::FIELD_EMAIL       => array(
864
-					'predicate'   => 'http://schema.org/email',
865
-					'type'        => self::DATA_TYPE_STRING,
866
-					'export_type' => 'xsd:string',
867
-					'constraints' => array(
868
-						'cardinality' => INF,
869
-					),
870
-				),
871
-			),
872
-			'templates'     => array(
873
-				'subtitle' => '{{id}}',
874
-			),
875
-		);
876
-
877
-		// Merge the custom fields with those provided by the thing schema.
878
-		$parent_schema           = $this->get_thing_schema();
879
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
880
-
881
-		return $schema;
882
-
883
-	}
884
-
885
-	/**
886
-	 * Get the 'place' schema.
887
-	 *
888
-	 * @return array An array with the schema configuration.
889
-	 *
890
-	 * @since 3.1.0
891
-	 */
892
-	private function get_place_schema() {
893
-
894
-		$schema = array(
895
-			'label'         => 'Place',
896
-			'description'   => 'A place.',
897
-			'parents'       => array( 'thing' ),
898
-			'css_class'     => 'wl-place',
899
-			'uri'           => 'http://schema.org/Place',
900
-			'same_as'       => array(
901
-				'http://rdf.freebase.com/ns/location.location',
902
-				'http://www.opengis.net/gml/_Feature',
903
-			),
904
-			'custom_fields' => array(
905
-				self::FIELD_GEO_LATITUDE        => array(
906
-					'predicate'   => 'http://schema.org/latitude',
907
-					'type'        => self::DATA_TYPE_DOUBLE,
908
-					'export_type' => 'xsd:double',
909
-					'constraints' => '',
910
-					// To build custom metabox.
911
-					'input_field' => 'coordinates',
912
-				),
913
-				self::FIELD_GEO_LONGITUDE       => array(
914
-					'predicate'   => 'http://schema.org/longitude',
915
-					'type'        => self::DATA_TYPE_DOUBLE,
916
-					'export_type' => 'xsd:double',
917
-					'constraints' => '',
918
-					// To build custom metabox.
919
-					'input_field' => 'coordinates',
920
-				),
921
-				self::FIELD_ADDRESS             => array(
922
-					'predicate'   => 'http://schema.org/streetAddress',
923
-					'type'        => self::DATA_TYPE_STRING,
924
-					'export_type' => 'xsd:string',
925
-					'constraints' => '',
926
-					// To build custom metabox.
927
-					'input_field' => 'address',
928
-				),
929
-				self::FIELD_ADDRESS_PO_BOX      => array(
930
-					'predicate'   => 'http://schema.org/postOfficeBoxNumber',
931
-					'type'        => self::DATA_TYPE_STRING,
932
-					'export_type' => 'xsd:string',
933
-					'constraints' => '',
934
-					// To build custom metabox.
935
-					'input_field' => 'address',
936
-				),
937
-				self::FIELD_ADDRESS_POSTAL_CODE => array(
938
-					'predicate'   => 'http://schema.org/postalCode',
939
-					'type'        => self::DATA_TYPE_STRING,
940
-					'export_type' => 'xsd:string',
941
-					'constraints' => '',
942
-					// To build custom metabox.
943
-					'input_field' => 'address',
944
-				),
945
-				self::FIELD_ADDRESS_LOCALITY    => array(
946
-					'predicate'   => 'http://schema.org/addressLocality',
947
-					'type'        => self::DATA_TYPE_STRING,
948
-					'export_type' => 'xsd:string',
949
-					'constraints' => '',
950
-					// To build custom metabox.
951
-					'input_field' => 'address',
952
-				),
953
-				self::FIELD_ADDRESS_REGION      => array(
954
-					'predicate'   => 'http://schema.org/addressRegion',
955
-					'type'        => self::DATA_TYPE_STRING,
956
-					'export_type' => 'xsd:string',
957
-					'constraints' => '',
958
-					// To build custom metabox.
959
-					'input_field' => 'address',
960
-				),
961
-				self::FIELD_ADDRESS_COUNTRY     => array(
962
-					'predicate'   => 'http://schema.org/addressCountry',
963
-					'type'        => self::DATA_TYPE_STRING,
964
-					'export_type' => 'xsd:string',
965
-					'constraints' => '',
966
-					// To build custom metabox.
967
-					'input_field' => 'address',
968
-				),
969
-			),
970
-			'templates'     => array(
971
-				'subtitle' => '{{id}}',
972
-			),
973
-		);
974
-
975
-		// Merge the custom fields with those provided by the thing schema.
976
-		$parent_schema           = $this->get_thing_schema();
977
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
978
-
979
-		return $schema;
980
-	}
981
-
982
-	/**
983
-	 * Get the 'local business' schema.
984
-	 *
985
-	 * @return array An array with the schema configuration.
986
-	 *
987
-	 * @since 3.1.0
988
-	 */
989
-	private function get_local_business_schema() {
990
-
991
-		$schema = array(
992
-			'label'         => 'LocalBusiness',
993
-			'description'   => 'A local business.',
994
-			'parents'       => array( 'place', 'organization' ),
995
-			'css_class'     => 'wl-local-business',
996
-			'uri'           => 'http://schema.org/LocalBusiness',
997
-			'same_as'       => array(
998
-				'http://rdf.freebase.com/ns/business/business_location',
999
-				'https://schema.org/Store',
1000
-			),
1001
-			'custom_fields' => array(),
1002
-			'templates'     => array(
1003
-				'subtitle' => '{{id}}',
1004
-			),
1005
-		);
1006
-
1007
-		// Merge the custom fields with those provided by the place and organization schema.
1008
-		$place_schema            = $this->get_place_schema();
1009
-		$organization_schema     = $this->get_organization_schema();
1010
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1011
-
1012
-		return $schema;
1013
-	}
1014
-
1015
-	/**
1016
-	 * Get the 'recipe' schema.
1017
-	 *
1018
-	 * @return array An array with the schema configuration.
1019
-	 *
1020
-	 * @since 3.14.0
1021
-	 */
1022
-	private function get_recipe_schema() {
1023
-
1024
-		$schema = array(
1025
-			'label'         => 'Recipe',
1026
-			'description'   => 'A Recipe.',
1027
-			'parents'       => array( 'CreativeWork' ),
1028
-			'css_class'     => 'wl-recipe',
1029
-			'uri'           => 'http://schema.org/Recipe',
1030
-			'same_as'       => array(),
1031
-			'templates'     => array(
1032
-				'subtitle' => '{{id}}',
1033
-			),
1034
-			'custom_fields' => array(
1035
-				self::FIELD_RECIPE_CUISINE          => array(
1036
-					'predicate'   => 'http://schema.org/recipeCuisine',
1037
-					'type'        => self::DATA_TYPE_STRING,
1038
-					'export_type' => 'xsd:string',
1039
-					'constraints' => '',
1040
-					'metabox'     => array(
1041
-						'label' => __( 'Recipe cuisine', 'wordlift' ),
1042
-					),
1043
-				),
1044
-				self::FIELD_RECIPE_INGREDIENT       => array(
1045
-					'predicate'   => 'http://schema.org/recipeIngredient',
1046
-					'type'        => self::DATA_TYPE_STRING,
1047
-					'export_type' => 'xsd:string',
1048
-					'constraints' => array(
1049
-						'cardinality' => INF,
1050
-					),
1051
-					'metabox'     => array(
1052
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1053
-					),
1054
-				),
1055
-				self::FIELD_RECIPE_INSTRUCTIONS     => array(
1056
-					'predicate'   => 'http://schema.org/recipeInstructions',
1057
-					'type'        => self::DATA_TYPE_MULTILINE,
1058
-					'export_type' => 'xsd:string',
1059
-					'constraints' => '',
1060
-					'metabox'     => array(
1061
-						'class' => 'Wordlift_Metabox_Field_Multiline',
1062
-						'label' => __( 'Recipe instructions', 'wordlift' ),
1063
-					),
1064
-				),
1065
-				self::FIELD_RECIPE_YIELD            => array(
1066
-					'predicate'   => 'http://schema.org/recipeYield',
1067
-					'type'        => self::DATA_TYPE_STRING,
1068
-					'export_type' => 'xsd:string',
1069
-					'constraints' => '',
1070
-					'metabox'     => array(
1071
-						'label' => __( 'Recipe number of servings', 'wordlift' ),
1072
-					),
1073
-				),
1074
-				self::FIELD_RECIPE_INGREDIENT       => array(
1075
-					'predicate'   => 'http://schema.org/recipeIngredient',
1076
-					'type'        => self::DATA_TYPE_STRING,
1077
-					'export_type' => 'xsd:string',
1078
-					'constraints' => array(
1079
-						'cardinality' => INF,
1080
-					),
1081
-					'metabox'     => array(
1082
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1083
-					),
1084
-				),
1085
-				self::FIELD_NUTRITION_INFO_CALORIES => array(
1086
-					'predicate'   => 'http://schema.org/calories',
1087
-					'type'        => self::DATA_TYPE_STRING,
1088
-					'export_type' => 'xsd:string',
1089
-					'constraints' => '',
1090
-					'metabox'     => array(
1091
-						'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1092
-					),
1093
-				),
1094
-				self::FIELD_PREP_TIME               => array(
1095
-					'predicate'   => 'http://schema.org/prepTime',
1096
-					'type'        => self::DATA_TYPE_DURATION,
1097
-					'export_type' => 'xsd:time',
1098
-					'constraints' => '',
1099
-					'metabox'     => array(
1100
-						'class' => 'Wordlift_Metabox_Field_Duration',
1101
-						'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1102
-					),
1103
-				),
1104
-				self::FIELD_COOK_TIME               => array(
1105
-					'predicate'   => 'http://schema.org/cookTime',
1106
-					'type'        => self::DATA_TYPE_DURATION,
1107
-					'export_type' => 'xsd:time',
1108
-					'constraints' => '',
1109
-					'metabox'     => array(
1110
-						'class' => 'Wordlift_Metabox_Field_Duration',
1111
-						'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1112
-					),
1113
-				),
1114
-				self::FIELD_TOTAL_TIME              => array(
1115
-					'predicate'   => 'http://schema.org/totalTime',
1116
-					'type'        => self::DATA_TYPE_DURATION,
1117
-					'export_type' => 'xsd:time',
1118
-					'constraints' => '',
1119
-					'metabox'     => array(
1120
-						'class' => 'Wordlift_Metabox_Field_Duration',
1121
-						'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1122
-					),
1123
-				),
1124
-			),
1125
-		);
1126
-
1127
-		// Merge the custom fields with those provided by the parent schema.
1128
-		$parent_schema           = $this->get_creative_work_schema();
1129
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1130
-
1131
-		return $schema;
1132
-	}
1133
-
1134
-	/**
1135
-	 * Get the 'offer' schema.
1136
-	 *
1137
-	 * @return array An array with the schema configuration.
1138
-	 *
1139
-	 * @since 3.18.0
1140
-	 */
1141
-	private function get_offer_schema() {
1142
-
1143
-		$schema = array(
1144
-			'label'         => 'Offer',
1145
-			'description'   => 'An offer. ',
1146
-			'parents'       => array( 'thing' ),
1147
-			'css_class'     => 'wl-offer',
1148
-			'uri'           => self::SCHEMA_OFFER_TYPE,
1149
-			'same_as'       => array(),
1150
-			'templates'     => array(
1151
-				'subtitle' => '{{id}}',
1152
-			),
1153
-			'custom_fields' => array(
1154
-				self::FIELD_AVAILABILITY        => array(
1155
-					'predicate'   => 'http://schema.org/availability',
1156
-					'type'        => self::DATA_TYPE_STRING,
1157
-					'export_type' => 'xsd:string',
1158
-					'metabox'     => array(
1159
-						'class' => 'Wordlift_Metabox_Field_Select',
1160
-					),
1161
-					'options'     => array(
1162
-						'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1163
-						'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1164
-						'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1165
-						'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1166
-						'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1167
-						'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1168
-						'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1169
-						'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1170
-						'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1171
-					),
1172
-				),
1173
-				self::FIELD_PRICE               => array(
1174
-					'predicate'   => 'http://schema.org/price',
1175
-					'type'        => self::DATA_TYPE_STRING,
1176
-					'export_type' => 'xsd:integer',
1177
-					'metabox'     => array(
1178
-						'class' => 'Wordlift_Metabox_Field_Integer',
1179
-					),
1180
-				),
1181
-				self::FIELD_PRICE_CURRENCY      => array(
1182
-					'predicate'   => 'http://schema.org/priceCurrency',
1183
-					'type'        => self::DATA_TYPE_STRING,
1184
-					'export_type' => 'xsd:string',
1185
-				),
1186
-				self::FIELD_AVAILABILITY_STARTS => array(
1187
-					'predicate'   => 'http://schema.org/availabilityStarts',
1188
-					'type'        => self::DATA_TYPE_DATE,
1189
-					'export_type' => 'xsd:dateTime',
1190
-				),
1191
-				self::FIELD_AVAILABILITY_ENDS   => array(
1192
-					'predicate'   => 'http://schema.org/availabilityEnds',
1193
-					'type'        => self::DATA_TYPE_DATE,
1194
-					'export_type' => 'xsd:dateTime',
1195
-				),
1196
-				self::FIELD_INVENTORY_LEVEL     => array(
1197
-					'predicate'   => 'http://schema.org/inventoryLevel',
1198
-					'type'        => self::DATA_TYPE_STRING,
1199
-					'export_type' => 'xsd:integer',
1200
-					'metabox'     => array(
1201
-						'class' => 'Wordlift_Metabox_Field_Integer',
1202
-					),
1203
-				),
1204
-				self::FIELD_VALID_FROM          => array(
1205
-					'predicate'   => 'http://schema.org/validFrom',
1206
-					'type'        => self::DATA_TYPE_DATE,
1207
-					'export_type' => 'xsd:dateTime',
1208
-				),
1209
-				self::FIELD_PRICE_VALID_UNTIL   => array(
1210
-					'predicate'   => 'http://schema.org/priceValidUntil',
1211
-					'type'        => self::DATA_TYPE_DATE,
1212
-					'export_type' => 'xsd:dateTime',
1213
-				),
1214
-				self::FIELD_ITEM_OFFERED        => array(
1215
-					'predicate'   => 'http://schema.org/itemOffered',
1216
-					'type'        => self::DATA_TYPE_URI,
1217
-					'export_type' => 'http://schema.org/Thing',
1218
-					'constraints' => array(
1219
-						'uri_type'    => array(
1220
-							'Event',
1221
-							'Thing',
1222
-						),
1223
-						'cardinality' => INF,
1224
-					),
1225
-				),
1226
-			),
1227
-		);
1228
-
1229
-		// Merge the custom fields with those provided by the thing schema.
1230
-		$parent_schema           = $this->get_thing_schema();
1231
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1232
-
1233
-		return $schema;
1234
-	}
1235
-
1236
-	/**
1237
-	 * Get the 'article' schema.
1238
-	 *
1239
-	 * @return array An array with the schema configuration.
1240
-	 *
1241
-	 * @since 3.15.0
1242
-	 */
1243
-	private function get_article_schema() {
1244
-
1245
-		$schema = array(
1246
-			'label'         => 'Article',
1247
-			'description'   => 'An Article.',
1248
-			'parents'       => array(),
1249
-			'css_class'     => 'wl-article',
1250
-			'uri'           => 'http://schema.org/Article',
1251
-			'same_as'       => array(),
1252
-			'templates'     => array(
1253
-				'subtitle' => '{{id}}',
1254
-			),
1255
-			'custom_fields' => array(),
1256
-		);
1257
-
1258
-		return $schema;
1259
-	}
21
+    /**
22
+     * The 'location created' field name.
23
+     *
24
+     * @since 3.5.0
25
+     */
26
+    const FIELD_LOCATION_CREATED = 'wl_location_created';
27
+
28
+    /**
29
+     * The 'topic' field name.
30
+     *
31
+     * @since 3.5.0
32
+     */
33
+    const FIELD_TOPIC = 'wl_topic';
34
+
35
+    /**
36
+     * The 'author' field name.
37
+     *
38
+     * @since 3.1.0
39
+     */
40
+    const FIELD_AUTHOR = 'wl_author';
41
+
42
+    /**
43
+     * The 'same as' field name.
44
+     *
45
+     * @since 3.1.0
46
+     */
47
+    const FIELD_SAME_AS = 'entity_same_as';
48
+
49
+    /**
50
+     * The 'date start' field name.
51
+     *
52
+     * @since 3.1.0
53
+     */
54
+    const FIELD_DATE_START = 'wl_cal_date_start';
55
+
56
+    /**
57
+     * The 'date end' field name.
58
+     *
59
+     * @since 3.1.0
60
+     */
61
+    const FIELD_DATE_END = 'wl_cal_date_end';
62
+
63
+    /**
64
+     * The 'location' field name.
65
+     *
66
+     * @since 3.1.0
67
+     */
68
+    const FIELD_LOCATION = 'wl_location';
69
+
70
+    /**
71
+     * The 'founder' field name.
72
+     *
73
+     * @since 3.1.0
74
+     */
75
+    const FIELD_FOUNDER = 'wl_founder';
76
+
77
+    /**
78
+     * The 'knows' field name.
79
+     *
80
+     * @since 3.1.0
81
+     */
82
+    const FIELD_KNOWS = 'wl_knows';
83
+
84
+    /**
85
+     * The 'birth date' field name.
86
+     *
87
+     * @since 3.1.0
88
+     */
89
+    const FIELD_BIRTH_DATE = 'wl_birth_date';
90
+
91
+    /**
92
+     * The 'birth place' field name.
93
+     *
94
+     * @since 3.1.0
95
+     */
96
+    const FIELD_BIRTH_PLACE = 'wl_birth_place';
97
+
98
+    /**
99
+     * The 'latitude' field name.
100
+     *
101
+     * @since 3.1.0
102
+     */
103
+    const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
104
+
105
+    /**
106
+     * The 'longitude' field name.
107
+     *
108
+     * @since 3.1.0
109
+     */
110
+    const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
111
+
112
+    /**
113
+     * The 'streetAddress' field name.
114
+     *
115
+     * @since 3.1.0
116
+     */
117
+    const FIELD_ADDRESS = 'wl_address';
118
+
119
+    /**
120
+     * The 'postOfficeBoxNumber' field name.
121
+     *
122
+     * @since 3.3.0
123
+     */
124
+    const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box';
125
+
126
+    /**
127
+     * The 'postalCode' field name.
128
+     *
129
+     * @since 3.3.0
130
+     */
131
+    const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code';
132
+
133
+    /**
134
+     * The 'addressLocality' field name.
135
+     *
136
+     * @since 3.3.0
137
+     */
138
+    const FIELD_ADDRESS_LOCALITY = 'wl_address_locality';
139
+    /**
140
+     * The 'addressRegion' field name.
141
+     *
142
+     * @since 3.3.0
143
+     */
144
+    const FIELD_ADDRESS_REGION = 'wl_address_region';
145
+
146
+    /**
147
+     * The 'addressCountry' field name.
148
+     *
149
+     * @since 3.3.0
150
+     */
151
+    const FIELD_ADDRESS_COUNTRY = 'wl_address_country';
152
+
153
+    /**
154
+     * The 'entity type' field name.
155
+     *
156
+     * @since 3.1.0
157
+     */
158
+    const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
159
+
160
+    /**
161
+     * The 'email' field name.
162
+     *
163
+     * @since 3.2.0
164
+     */
165
+    const FIELD_EMAIL = 'wl_email';
166
+
167
+    /**
168
+     * The 'affiliation' field name.
169
+     *
170
+     * @since 3.2.0
171
+     */
172
+    const FIELD_AFFILIATION = 'wl_affiliation';
173
+
174
+    /**
175
+     * The 'telephone' field name.
176
+     *
177
+     * @since 3.8.0
178
+     */
179
+    const FIELD_TELEPHONE = 'wl_schema_telephone';
180
+
181
+    /**
182
+     * The 'legalName' field name.
183
+     *
184
+     * @since 3.12.0
185
+     */
186
+    const FIELD_LEGAL_NAME = 'wl_schema_legal_name';
187
+
188
+    /**
189
+     * The 'recipeCuisine' field name.
190
+     *
191
+     * @since 3.14.0
192
+     */
193
+    const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine';
194
+
195
+    /**
196
+     * The 'recipeIngredient' field name.
197
+     *
198
+     * @since 3.14.0
199
+     */
200
+    const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient';
201
+
202
+    /**
203
+     * The 'calories' field name.
204
+     *
205
+     * @since 3.14.0
206
+     */
207
+    const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories';
208
+
209
+    /**
210
+     * The 'recipeInstructions' field name.
211
+     *
212
+     * @since 3.14.0
213
+     */
214
+    const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions';
215
+
216
+    /**
217
+     * The 'recipeYield' field name.
218
+     *
219
+     * @since 3.14.0
220
+     */
221
+    const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield';
222
+
223
+    /**
224
+     * The 'prepTime' field name.
225
+     *
226
+     * @since 3.14.0
227
+     */
228
+    const FIELD_PREP_TIME = 'wl_schema_prep_time';
229
+
230
+    /**
231
+     * The 'cookTime' field name.
232
+     *
233
+     * @since 3.14.0
234
+     */
235
+    const FIELD_COOK_TIME = 'wl_schema_cook_time';
236
+
237
+    /**
238
+     * The 'totalTime' field name.
239
+     *
240
+     * @since 3.14.0
241
+     */
242
+    const FIELD_TOTAL_TIME = 'wl_schema_total_time';
243
+
244
+    /**
245
+     * The 'performer' field name.
246
+     *
247
+     * @since 3.18.0
248
+     */
249
+    const FIELD_PERFORMER = 'wl_schema_performer';
250
+
251
+    /**
252
+     * The 'offers' field name.
253
+     *
254
+     * @since 3.18.0
255
+     */
256
+    const FIELD_OFFERS = 'wl_schema_offers';
257
+
258
+    /**
259
+     * The 'availablity' field name.
260
+     *
261
+     * @since 3.18.0
262
+     */
263
+    const FIELD_AVAILABILITY = 'wl_schema_availability';
264
+
265
+    /**
266
+     * The 'inventoryLevel' field name.
267
+     *
268
+     * @since 3.18.0
269
+     */
270
+    const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level';
271
+
272
+    /**
273
+     * The 'price' field name.
274
+     *
275
+     * @since 3.18.0
276
+     */
277
+    const FIELD_PRICE = 'wl_schema_price';
278
+
279
+    /**
280
+     * The 'priceCurrency' field name.
281
+     *
282
+     * @since 3.18.0
283
+     */
284
+    const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency';
285
+
286
+    /**
287
+     * The 'availabilityStarts' field name.
288
+     *
289
+     * @since 3.18.0
290
+     */
291
+    const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts';
292
+
293
+    /**
294
+     * The 'availabilityEnds' field name.
295
+     *
296
+     * @since 3.18.0
297
+     */
298
+    const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends';
299
+
300
+    /**
301
+     * The 'validFrom' field name.
302
+     *
303
+     * @since 3.18.0
304
+     */
305
+    const FIELD_VALID_FROM = 'wl_schema_valid_from';
306
+
307
+    /**
308
+     * The 'priceValidUntil' field name.
309
+     *
310
+     * @since 3.18.0
311
+     */
312
+    const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until';
313
+
314
+    /**
315
+     * The 'itemOffered' field name.
316
+     *
317
+     * @since 3.18.0
318
+     */
319
+    const FIELD_ITEM_OFFERED = 'wl_schema_item_offered';
320
+
321
+    /**
322
+     * The 'URI' data type name.
323
+     *
324
+     * @since 3.1.0
325
+     */
326
+    const DATA_TYPE_URI = 'uri';
327
+
328
+    /**
329
+     * The 'date' data type name.
330
+     *
331
+     * @since 3.1.0
332
+     */
333
+    const DATA_TYPE_DATE = 'date';
334
+
335
+    /**
336
+     * The 'time' data type name.
337
+     *
338
+     * @since 3.14.0
339
+     */
340
+    const DATA_TYPE_DURATION = 'duration';
341
+
342
+    /**
343
+     * The 'double' data type name.
344
+     *
345
+     * @since 3.1.0
346
+     */
347
+    const DATA_TYPE_DOUBLE = 'double';
348
+
349
+    /**
350
+     * The 'string' data type name.
351
+     *
352
+     * @since 3.1.0
353
+     */
354
+    const DATA_TYPE_STRING = 'string';
355
+
356
+    /**
357
+     * The multiline text data type name.
358
+     *
359
+     * @since 3.14.0
360
+     */
361
+    const DATA_TYPE_MULTILINE = 'multiline';
362
+
363
+    /**
364
+     * The schema.org Event type URI.
365
+     *
366
+     * @since 3.1.0
367
+     */
368
+    const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
369
+
370
+    /**
371
+     * The schema.org Offer type URI.
372
+     *
373
+     * @since 3.18.0
374
+     */
375
+    const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer';
376
+
377
+    /**
378
+     * WordLift's schema.
379
+     *
380
+     * @since  3.1.0
381
+     * @access private
382
+     * @var array $schema WordLift's schema.
383
+     */
384
+    private $schema;
385
+
386
+    /**
387
+     * The Log service.
388
+     *
389
+     * @since  3.1.0
390
+     * @access private
391
+     * @var \Wordlift_Log_Service $log The Log service.
392
+     */
393
+    private $log;
394
+
395
+    /**
396
+     * Wordlift_Schema_Service constructor.
397
+     *
398
+     * @since 3.1.0
399
+     */
400
+    protected function __construct() {
401
+
402
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
403
+
404
+        /**
405
+         * Alter the configured schemas.
406
+         *
407
+         * Enable 3rd parties to alter WordLift's schemas array.
408
+         *
409
+         * @param array $schemas The array of schemas.
410
+         *
411
+         * @since  3.19.1
412
+         */
413
+        $this->schema = apply_filters(
414
+            'wl_schemas',
415
+            array(
416
+                'article'        => $this->get_article_schema(),
417
+                'thing'          => $this->get_thing_schema(),
418
+                'creative-work'  => $this->get_creative_work_schema(),
419
+                'event'          => $this->get_event_schema(),
420
+                'organization'   => $this->get_organization_schema(),
421
+                'person'         => $this->get_person_schema(),
422
+                'place'          => $this->get_place_schema(),
423
+                'local-business' => $this->get_local_business_schema(),
424
+                'recipe'         => $this->get_recipe_schema(),
425
+                'web-page'       => $this->get_web_page_schema(),
426
+                'offer'          => $this->get_offer_schema(),
427
+            )
428
+        );
429
+
430
+        // Create a singleton instance of the Schema service, useful to provide static functions to global functions.
431
+        self::$instance = $this;
432
+
433
+    }
434
+
435
+    public function get_all_schema_slugs() {
436
+        return array_keys( $this->schema );
437
+    }
438
+
439
+    /**
440
+     * The Schema service singleton instance.
441
+     *
442
+     * @since  3.1.0
443
+     * @access private
444
+     * @var Wordlift_Schema_Service $instance The Schema service singleton instance.
445
+     */
446
+    private static $instance = null;
447
+
448
+    /**
449
+     * Get a reference to the Schema service.
450
+     *
451
+     * @return Wordlift_Schema_Service A reference to the Schema service.
452
+     * @since 3.1.0
453
+     */
454
+    public static function get_instance() {
455
+        if ( ! isset( self::$instance ) ) {
456
+            self::$instance = new self();
457
+        }
458
+
459
+        return self::$instance;
460
+    }
461
+
462
+    /**
463
+     * Get the properties for a field with the specified key. The key is used as
464
+     * meta key when the field's value is stored in WordPress meta data table.
465
+     *
466
+     * @param string $key The field's key.
467
+     *
468
+     * @return null|array An array of field's properties or null if the field is not found.
469
+     * @since 3.6.0
470
+     */
471
+    public function get_field( $key ) {
472
+
473
+        // Parse each schema's fields until we find the one we're looking for, then
474
+        // return its properties.
475
+        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
476
+        foreach ( $this->schema as $_ => $schema ) {
477
+
478
+            if ( ! isset( $schema['custom_fields'] ) ) {
479
+                break;
480
+            }
481
+
482
+            foreach ( $schema['custom_fields'] as $field => $props ) {
483
+                if ( $key === $field ) {
484
+                    return $props;
485
+                }
486
+            }
487
+        }
488
+
489
+        return null;
490
+    }
491
+
492
+    /**
493
+     * Get the WordLift's schema.
494
+     *
495
+     * @param string $name The schema name.
496
+     *
497
+     * @return array|null An array with the schema configuration or NULL if the schema is not found.
498
+     *
499
+     * @since 3.1.0
500
+     */
501
+    public function get_schema( $name ) {
502
+        // Check if the schema exists and, if not, return NULL.
503
+        if ( ! isset( $this->schema[ $name ] ) ) {
504
+            return null;
505
+        }
506
+
507
+        // Return the requested schema.
508
+        return $this->schema[ $name ];
509
+    }
510
+
511
+    /**
512
+     * Get the WordLift's schema trough schema type uri.
513
+     *
514
+     * @param string $uri The schema uri.
515
+     *
516
+     * @return array|null An array with the schema configuration or NULL if the schema is not found.
517
+     *
518
+     * @since 3.3.0
519
+     */
520
+    public function get_schema_by_uri( $uri ) {
521
+
522
+        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
523
+        foreach ( $this->schema as $name => $schema ) {
524
+            if ( $schema['uri'] === $uri ) {
525
+                return $schema;
526
+            }
527
+        }
528
+
529
+        return null;
530
+    }
531
+
532
+    /**
533
+     * Get the 'thing' schema.
534
+     *
535
+     * @return array An array with the schema configuration.
536
+     *
537
+     * @since 3.1.0
538
+     */
539
+    private function get_thing_schema() {
540
+
541
+        return array(
542
+            'css_class'     => 'wl-thing',
543
+            'uri'           => 'http://schema.org/Thing',
544
+            'same_as'       => array( '*' ),
545
+            // set as default.
546
+            'custom_fields' => array(
547
+                self::FIELD_SAME_AS => array(
548
+                    'predicate'   => 'http://schema.org/sameAs',
549
+                    'type'        => self::DATA_TYPE_URI,
550
+                    'export_type' => 'http://schema.org/Thing',
551
+                    'constraints' => array(
552
+                        'cardinality' => INF,
553
+                    ),
554
+                    // We need a custom metabox.
555
+                    'input_field' => 'sameas',
556
+                ),
557
+                // Add the schema:url property.
558
+                Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance()
559
+                                                                                                        ->get_compat_definition(),
560
+            ),
561
+            // {{sameAs}} not present in the microdata template,
562
+            // because it is treated separately in *wl_content_embed_item_microdata*
563
+            'templates'     => array(
564
+                'subtitle' => '{{id}}',
565
+            ),
566
+        );
567
+
568
+    }
569
+
570
+    /**
571
+     * Get the 'web-page' schema.
572
+     *
573
+     * @return array An array with the schema configuration.
574
+     *
575
+     * @since 3.18.0
576
+     */
577
+    private function get_web_page_schema() {
578
+
579
+        return array(
580
+            'css_class' => 'wl-webpage',
581
+            'uri'       => 'http://schema.org/WebPage',
582
+        );
583
+
584
+    }
585
+
586
+    /**
587
+     * Get the 'creative work' schema.
588
+     *
589
+     * @return array An array with the schema configuration.
590
+     *
591
+     * @since 3.1.0
592
+     */
593
+    private function get_creative_work_schema() {
594
+
595
+        $schema = array(
596
+            'label'         => 'CreativeWork',
597
+            'description'   => 'A creative work (or a Music Album).',
598
+            'parents'       => array( 'thing' ),
599
+            // Give term slug as parent.
600
+            'css_class'     => 'wl-creative-work',
601
+            'uri'           => 'http://schema.org/CreativeWork',
602
+            'same_as'       => array(
603
+                'http://schema.org/MusicAlbum',
604
+                'http://schema.org/Product',
605
+            ),
606
+            'custom_fields' => array(
607
+                self::FIELD_AUTHOR => array(
608
+                    'predicate'   => 'http://schema.org/author',
609
+                    'type'        => self::DATA_TYPE_URI,
610
+                    'export_type' => 'http://schema.org/Person',
611
+                    'constraints' => array(
612
+                        'uri_type'    => array( 'Person', 'Organization' ),
613
+                        'cardinality' => INF,
614
+                    ),
615
+                ),
616
+            ),
617
+            'templates'     => array(
618
+                'subtitle' => '{{id}}',
619
+            ),
620
+        );
621
+
622
+        // Merge the custom fields with those provided by the thing schema.
623
+        $parent_schema           = $this->get_thing_schema();
624
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
625
+
626
+        return $schema;
627
+    }
628
+
629
+    /**
630
+     * Get the 'event' schema.
631
+     *
632
+     * @return array An array with the schema configuration.
633
+     *
634
+     * @since 3.1.0
635
+     */
636
+    private function get_event_schema() {
637
+
638
+        $schema = array(
639
+            'label'         => 'Event',
640
+            'description'   => 'An event . ',
641
+            'parents'       => array( 'thing' ),
642
+            'css_class'     => 'wl-event',
643
+            'uri'           => self::SCHEMA_EVENT_TYPE,
644
+            'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
645
+            'custom_fields' => array(
646
+                self::FIELD_DATE_START => array(
647
+                    'predicate'   => 'http://schema.org/startDate',
648
+                    'type'        => self::DATA_TYPE_DATE,
649
+                    'export_type' => 'xsd:dateTime',
650
+                    'constraints' => '',
651
+                ),
652
+                self::FIELD_DATE_END   => array(
653
+                    'predicate'   => 'http://schema.org/endDate',
654
+                    'type'        => self::DATA_TYPE_DATE,
655
+                    'export_type' => 'xsd:dateTime',
656
+                    'constraints' => '',
657
+                ),
658
+                self::FIELD_LOCATION   => array(
659
+                    'predicate'   => 'http://schema.org/location',
660
+                    'type'        => self::DATA_TYPE_URI,
661
+                    'export_type' => 'http://schema.org/PostalAddress',
662
+                    'constraints' => array(
663
+                        'uri_type'    => array( 'Place', 'LocalBusiness' ),
664
+                        'cardinality' => INF,
665
+                    ),
666
+                ),
667
+                self::FIELD_PERFORMER  => array(
668
+                    'predicate'   => 'http://schema.org/performer',
669
+                    'type'        => self::DATA_TYPE_URI,
670
+                    'export_type' => 'http://schema.org/Person',
671
+                    'constraints' => array(
672
+                        'uri_type'    => array( 'Person', 'Organization' ),
673
+                        'cardinality' => INF,
674
+                    ),
675
+                ),
676
+                self::FIELD_OFFERS     => array(
677
+                    'predicate'   => 'http://schema.org/offers',
678
+                    'type'        => self::DATA_TYPE_URI,
679
+                    'export_type' => 'http://schema.org/Offer',
680
+                    'constraints' => array(
681
+                        'uri_type'    => array( 'Offer' ),
682
+                        'cardinality' => INF,
683
+                    ),
684
+                ),
685
+            ),
686
+            'templates'     => array(
687
+                'subtitle' => '{{id}}',
688
+            ),
689
+        );
690
+
691
+        // Merge the custom fields with those provided by the thing schema.
692
+        $parent_schema           = $this->get_thing_schema();
693
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
694
+
695
+        return $schema;
696
+    }
697
+
698
+    /**
699
+     * Get the 'organization' schema.
700
+     *
701
+     * @return array An array with the schema configuration.
702
+     *
703
+     * @since 3.1.0
704
+     */
705
+    private function get_organization_schema() {
706
+
707
+        $schema = array(
708
+            'label'         => 'Organization',
709
+            'description'   => 'An organization, including a government or a newspaper.',
710
+            'parents'       => array( 'thing' ),
711
+            'css_class'     => 'wl-organization',
712
+            'uri'           => 'http://schema.org/Organization',
713
+            'same_as'       => array(
714
+                'http://rdf.freebase.com/ns/organization.organization',
715
+                'http://rdf.freebase.com/ns/government.government',
716
+                'http://schema.org/Newspaper',
717
+            ),
718
+            'custom_fields' => array(
719
+                self::FIELD_LEGAL_NAME          => array(
720
+                    'predicate'   => 'http://schema.org/legalName',
721
+                    'type'        => self::DATA_TYPE_STRING,
722
+                    'export_type' => 'xsd:string',
723
+                    'constraints' => '',
724
+                ),
725
+                self::FIELD_FOUNDER             => array(
726
+                    'predicate'   => 'http://schema.org/founder',
727
+                    'type'        => self::DATA_TYPE_URI,
728
+                    'export_type' => 'http://schema.org/Person',
729
+                    'constraints' => array(
730
+                        'uri_type'    => 'Person',
731
+                        'cardinality' => INF,
732
+                    ),
733
+                ),
734
+                self::FIELD_ADDRESS             => array(
735
+                    'predicate'   => 'http://schema.org/streetAddress',
736
+                    'type'        => self::DATA_TYPE_STRING,
737
+                    'export_type' => 'xsd:string',
738
+                    'constraints' => '',
739
+                    // To build custom metabox.
740
+                    'input_field' => 'address',
741
+                ),
742
+                self::FIELD_ADDRESS_PO_BOX      => array(
743
+                    'predicate'   => 'http://schema.org/postOfficeBoxNumber',
744
+                    'type'        => self::DATA_TYPE_STRING,
745
+                    'export_type' => 'xsd:string',
746
+                    'constraints' => '',
747
+                    // To build custom metabox.
748
+                    'input_field' => 'address',
749
+                ),
750
+                self::FIELD_ADDRESS_POSTAL_CODE => array(
751
+                    'predicate'   => 'http://schema.org/postalCode',
752
+                    'type'        => self::DATA_TYPE_STRING,
753
+                    'export_type' => 'xsd:string',
754
+                    'constraints' => '',
755
+                    // To build custom metabox.
756
+                    'input_field' => 'address',
757
+                ),
758
+                self::FIELD_ADDRESS_LOCALITY    => array(
759
+                    'predicate'   => 'http://schema.org/addressLocality',
760
+                    'type'        => self::DATA_TYPE_STRING,
761
+                    'export_type' => 'xsd:string',
762
+                    'constraints' => '',
763
+                    // To build custom metabox.
764
+                    'input_field' => 'address',
765
+                ),
766
+                self::FIELD_ADDRESS_REGION      => array(
767
+                    'predicate'   => 'http://schema.org/addressRegion',
768
+                    'type'        => self::DATA_TYPE_STRING,
769
+                    'export_type' => 'xsd:string',
770
+                    'constraints' => '',
771
+                    // To build custom metabox.
772
+                    'input_field' => 'address',
773
+                ),
774
+                self::FIELD_ADDRESS_COUNTRY     => array(
775
+                    'predicate'   => 'http://schema.org/addressCountry',
776
+                    'type'        => self::DATA_TYPE_STRING,
777
+                    'export_type' => 'xsd:string',
778
+                    'constraints' => '',
779
+                    // To build custom metabox.
780
+                    'input_field' => 'address',
781
+                ),
782
+                self::FIELD_EMAIL               => array(
783
+                    'predicate'   => 'http://schema.org/email',
784
+                    'type'        => self::DATA_TYPE_STRING,
785
+                    'export_type' => 'xsd:string',
786
+                    'constraints' => '',
787
+                ),
788
+                self::FIELD_TELEPHONE           => array(
789
+                    'predicate'   => 'http://schema.org/telephone',
790
+                    'type'        => self::DATA_TYPE_STRING,
791
+                    'export_type' => 'xsd:string',
792
+                    'constraints' => '',
793
+                ),
794
+            ),
795
+            'templates'     => array(
796
+                'subtitle' => '{{id}}',
797
+            ),
798
+        );
799
+
800
+        // Merge the custom fields with those provided by the thing schema.
801
+        $parent_schema           = $this->get_thing_schema();
802
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
803
+
804
+        return $schema;
805
+    }
806
+
807
+    /**
808
+     * Get the 'person' schema.
809
+     *
810
+     * @return array An array with the schema configuration.
811
+     *
812
+     * @since 3.1.0
813
+     */
814
+    private function get_person_schema() {
815
+
816
+        $schema = array(
817
+            'label'         => 'Person',
818
+            'description'   => 'A person (or a music artist).',
819
+            'parents'       => array( 'thing' ),
820
+            'css_class'     => 'wl-person',
821
+            'uri'           => 'http://schema.org/Person',
822
+            'same_as'       => array(
823
+                'http://rdf.freebase.com/ns/people.person',
824
+                'http://rdf.freebase.com/ns/music.artist',
825
+                'http://dbpedia.org/class/yago/LivingPeople',
826
+            ),
827
+            'custom_fields' => array(
828
+                self::FIELD_KNOWS       => array(
829
+                    'predicate'   => 'http://schema.org/knows',
830
+                    'type'        => self::DATA_TYPE_URI,
831
+                    'export_type' => 'http://schema.org/Person',
832
+                    'constraints' => array(
833
+                        'uri_type'    => 'Person',
834
+                        'cardinality' => INF,
835
+                    ),
836
+                ),
837
+                self::FIELD_BIRTH_DATE  => array(
838
+                    'predicate'   => 'http://schema.org/birthDate',
839
+                    'type'        => self::DATA_TYPE_DATE,
840
+                    'export_type' => 'xsd:date',
841
+                    'constraints' => '',
842
+                ),
843
+                self::FIELD_BIRTH_PLACE => array(
844
+                    'predicate'   => 'http://schema.org/birthPlace',
845
+                    'type'        => self::DATA_TYPE_URI,
846
+                    'export_type' => 'http://schema.org/Place',
847
+                    'constraints' => array(
848
+                        'uri_type' => 'Place',
849
+                    ),
850
+                ),
851
+                self::FIELD_AFFILIATION => array(
852
+                    'predicate'   => 'http://schema.org/affiliation',
853
+                    'type'        => self::DATA_TYPE_URI,
854
+                    'export_type' => 'http://schema.org/Organization',
855
+                    'constraints' => array(
856
+                        'uri_type'    => array(
857
+                            'Organization',
858
+                            'LocalBusiness',
859
+                        ),
860
+                        'cardinality' => INF,
861
+                    ),
862
+                ),
863
+                self::FIELD_EMAIL       => array(
864
+                    'predicate'   => 'http://schema.org/email',
865
+                    'type'        => self::DATA_TYPE_STRING,
866
+                    'export_type' => 'xsd:string',
867
+                    'constraints' => array(
868
+                        'cardinality' => INF,
869
+                    ),
870
+                ),
871
+            ),
872
+            'templates'     => array(
873
+                'subtitle' => '{{id}}',
874
+            ),
875
+        );
876
+
877
+        // Merge the custom fields with those provided by the thing schema.
878
+        $parent_schema           = $this->get_thing_schema();
879
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
880
+
881
+        return $schema;
882
+
883
+    }
884
+
885
+    /**
886
+     * Get the 'place' schema.
887
+     *
888
+     * @return array An array with the schema configuration.
889
+     *
890
+     * @since 3.1.0
891
+     */
892
+    private function get_place_schema() {
893
+
894
+        $schema = array(
895
+            'label'         => 'Place',
896
+            'description'   => 'A place.',
897
+            'parents'       => array( 'thing' ),
898
+            'css_class'     => 'wl-place',
899
+            'uri'           => 'http://schema.org/Place',
900
+            'same_as'       => array(
901
+                'http://rdf.freebase.com/ns/location.location',
902
+                'http://www.opengis.net/gml/_Feature',
903
+            ),
904
+            'custom_fields' => array(
905
+                self::FIELD_GEO_LATITUDE        => array(
906
+                    'predicate'   => 'http://schema.org/latitude',
907
+                    'type'        => self::DATA_TYPE_DOUBLE,
908
+                    'export_type' => 'xsd:double',
909
+                    'constraints' => '',
910
+                    // To build custom metabox.
911
+                    'input_field' => 'coordinates',
912
+                ),
913
+                self::FIELD_GEO_LONGITUDE       => array(
914
+                    'predicate'   => 'http://schema.org/longitude',
915
+                    'type'        => self::DATA_TYPE_DOUBLE,
916
+                    'export_type' => 'xsd:double',
917
+                    'constraints' => '',
918
+                    // To build custom metabox.
919
+                    'input_field' => 'coordinates',
920
+                ),
921
+                self::FIELD_ADDRESS             => array(
922
+                    'predicate'   => 'http://schema.org/streetAddress',
923
+                    'type'        => self::DATA_TYPE_STRING,
924
+                    'export_type' => 'xsd:string',
925
+                    'constraints' => '',
926
+                    // To build custom metabox.
927
+                    'input_field' => 'address',
928
+                ),
929
+                self::FIELD_ADDRESS_PO_BOX      => array(
930
+                    'predicate'   => 'http://schema.org/postOfficeBoxNumber',
931
+                    'type'        => self::DATA_TYPE_STRING,
932
+                    'export_type' => 'xsd:string',
933
+                    'constraints' => '',
934
+                    // To build custom metabox.
935
+                    'input_field' => 'address',
936
+                ),
937
+                self::FIELD_ADDRESS_POSTAL_CODE => array(
938
+                    'predicate'   => 'http://schema.org/postalCode',
939
+                    'type'        => self::DATA_TYPE_STRING,
940
+                    'export_type' => 'xsd:string',
941
+                    'constraints' => '',
942
+                    // To build custom metabox.
943
+                    'input_field' => 'address',
944
+                ),
945
+                self::FIELD_ADDRESS_LOCALITY    => array(
946
+                    'predicate'   => 'http://schema.org/addressLocality',
947
+                    'type'        => self::DATA_TYPE_STRING,
948
+                    'export_type' => 'xsd:string',
949
+                    'constraints' => '',
950
+                    // To build custom metabox.
951
+                    'input_field' => 'address',
952
+                ),
953
+                self::FIELD_ADDRESS_REGION      => array(
954
+                    'predicate'   => 'http://schema.org/addressRegion',
955
+                    'type'        => self::DATA_TYPE_STRING,
956
+                    'export_type' => 'xsd:string',
957
+                    'constraints' => '',
958
+                    // To build custom metabox.
959
+                    'input_field' => 'address',
960
+                ),
961
+                self::FIELD_ADDRESS_COUNTRY     => array(
962
+                    'predicate'   => 'http://schema.org/addressCountry',
963
+                    'type'        => self::DATA_TYPE_STRING,
964
+                    'export_type' => 'xsd:string',
965
+                    'constraints' => '',
966
+                    // To build custom metabox.
967
+                    'input_field' => 'address',
968
+                ),
969
+            ),
970
+            'templates'     => array(
971
+                'subtitle' => '{{id}}',
972
+            ),
973
+        );
974
+
975
+        // Merge the custom fields with those provided by the thing schema.
976
+        $parent_schema           = $this->get_thing_schema();
977
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
978
+
979
+        return $schema;
980
+    }
981
+
982
+    /**
983
+     * Get the 'local business' schema.
984
+     *
985
+     * @return array An array with the schema configuration.
986
+     *
987
+     * @since 3.1.0
988
+     */
989
+    private function get_local_business_schema() {
990
+
991
+        $schema = array(
992
+            'label'         => 'LocalBusiness',
993
+            'description'   => 'A local business.',
994
+            'parents'       => array( 'place', 'organization' ),
995
+            'css_class'     => 'wl-local-business',
996
+            'uri'           => 'http://schema.org/LocalBusiness',
997
+            'same_as'       => array(
998
+                'http://rdf.freebase.com/ns/business/business_location',
999
+                'https://schema.org/Store',
1000
+            ),
1001
+            'custom_fields' => array(),
1002
+            'templates'     => array(
1003
+                'subtitle' => '{{id}}',
1004
+            ),
1005
+        );
1006
+
1007
+        // Merge the custom fields with those provided by the place and organization schema.
1008
+        $place_schema            = $this->get_place_schema();
1009
+        $organization_schema     = $this->get_organization_schema();
1010
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1011
+
1012
+        return $schema;
1013
+    }
1014
+
1015
+    /**
1016
+     * Get the 'recipe' schema.
1017
+     *
1018
+     * @return array An array with the schema configuration.
1019
+     *
1020
+     * @since 3.14.0
1021
+     */
1022
+    private function get_recipe_schema() {
1023
+
1024
+        $schema = array(
1025
+            'label'         => 'Recipe',
1026
+            'description'   => 'A Recipe.',
1027
+            'parents'       => array( 'CreativeWork' ),
1028
+            'css_class'     => 'wl-recipe',
1029
+            'uri'           => 'http://schema.org/Recipe',
1030
+            'same_as'       => array(),
1031
+            'templates'     => array(
1032
+                'subtitle' => '{{id}}',
1033
+            ),
1034
+            'custom_fields' => array(
1035
+                self::FIELD_RECIPE_CUISINE          => array(
1036
+                    'predicate'   => 'http://schema.org/recipeCuisine',
1037
+                    'type'        => self::DATA_TYPE_STRING,
1038
+                    'export_type' => 'xsd:string',
1039
+                    'constraints' => '',
1040
+                    'metabox'     => array(
1041
+                        'label' => __( 'Recipe cuisine', 'wordlift' ),
1042
+                    ),
1043
+                ),
1044
+                self::FIELD_RECIPE_INGREDIENT       => array(
1045
+                    'predicate'   => 'http://schema.org/recipeIngredient',
1046
+                    'type'        => self::DATA_TYPE_STRING,
1047
+                    'export_type' => 'xsd:string',
1048
+                    'constraints' => array(
1049
+                        'cardinality' => INF,
1050
+                    ),
1051
+                    'metabox'     => array(
1052
+                        'label' => __( 'Recipe ingredient', 'wordlift' ),
1053
+                    ),
1054
+                ),
1055
+                self::FIELD_RECIPE_INSTRUCTIONS     => array(
1056
+                    'predicate'   => 'http://schema.org/recipeInstructions',
1057
+                    'type'        => self::DATA_TYPE_MULTILINE,
1058
+                    'export_type' => 'xsd:string',
1059
+                    'constraints' => '',
1060
+                    'metabox'     => array(
1061
+                        'class' => 'Wordlift_Metabox_Field_Multiline',
1062
+                        'label' => __( 'Recipe instructions', 'wordlift' ),
1063
+                    ),
1064
+                ),
1065
+                self::FIELD_RECIPE_YIELD            => array(
1066
+                    'predicate'   => 'http://schema.org/recipeYield',
1067
+                    'type'        => self::DATA_TYPE_STRING,
1068
+                    'export_type' => 'xsd:string',
1069
+                    'constraints' => '',
1070
+                    'metabox'     => array(
1071
+                        'label' => __( 'Recipe number of servings', 'wordlift' ),
1072
+                    ),
1073
+                ),
1074
+                self::FIELD_RECIPE_INGREDIENT       => array(
1075
+                    'predicate'   => 'http://schema.org/recipeIngredient',
1076
+                    'type'        => self::DATA_TYPE_STRING,
1077
+                    'export_type' => 'xsd:string',
1078
+                    'constraints' => array(
1079
+                        'cardinality' => INF,
1080
+                    ),
1081
+                    'metabox'     => array(
1082
+                        'label' => __( 'Recipe ingredient', 'wordlift' ),
1083
+                    ),
1084
+                ),
1085
+                self::FIELD_NUTRITION_INFO_CALORIES => array(
1086
+                    'predicate'   => 'http://schema.org/calories',
1087
+                    'type'        => self::DATA_TYPE_STRING,
1088
+                    'export_type' => 'xsd:string',
1089
+                    'constraints' => '',
1090
+                    'metabox'     => array(
1091
+                        'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1092
+                    ),
1093
+                ),
1094
+                self::FIELD_PREP_TIME               => array(
1095
+                    'predicate'   => 'http://schema.org/prepTime',
1096
+                    'type'        => self::DATA_TYPE_DURATION,
1097
+                    'export_type' => 'xsd:time',
1098
+                    'constraints' => '',
1099
+                    'metabox'     => array(
1100
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1101
+                        'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1102
+                    ),
1103
+                ),
1104
+                self::FIELD_COOK_TIME               => array(
1105
+                    'predicate'   => 'http://schema.org/cookTime',
1106
+                    'type'        => self::DATA_TYPE_DURATION,
1107
+                    'export_type' => 'xsd:time',
1108
+                    'constraints' => '',
1109
+                    'metabox'     => array(
1110
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1111
+                        'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1112
+                    ),
1113
+                ),
1114
+                self::FIELD_TOTAL_TIME              => array(
1115
+                    'predicate'   => 'http://schema.org/totalTime',
1116
+                    'type'        => self::DATA_TYPE_DURATION,
1117
+                    'export_type' => 'xsd:time',
1118
+                    'constraints' => '',
1119
+                    'metabox'     => array(
1120
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1121
+                        'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1122
+                    ),
1123
+                ),
1124
+            ),
1125
+        );
1126
+
1127
+        // Merge the custom fields with those provided by the parent schema.
1128
+        $parent_schema           = $this->get_creative_work_schema();
1129
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1130
+
1131
+        return $schema;
1132
+    }
1133
+
1134
+    /**
1135
+     * Get the 'offer' schema.
1136
+     *
1137
+     * @return array An array with the schema configuration.
1138
+     *
1139
+     * @since 3.18.0
1140
+     */
1141
+    private function get_offer_schema() {
1142
+
1143
+        $schema = array(
1144
+            'label'         => 'Offer',
1145
+            'description'   => 'An offer. ',
1146
+            'parents'       => array( 'thing' ),
1147
+            'css_class'     => 'wl-offer',
1148
+            'uri'           => self::SCHEMA_OFFER_TYPE,
1149
+            'same_as'       => array(),
1150
+            'templates'     => array(
1151
+                'subtitle' => '{{id}}',
1152
+            ),
1153
+            'custom_fields' => array(
1154
+                self::FIELD_AVAILABILITY        => array(
1155
+                    'predicate'   => 'http://schema.org/availability',
1156
+                    'type'        => self::DATA_TYPE_STRING,
1157
+                    'export_type' => 'xsd:string',
1158
+                    'metabox'     => array(
1159
+                        'class' => 'Wordlift_Metabox_Field_Select',
1160
+                    ),
1161
+                    'options'     => array(
1162
+                        'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1163
+                        'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1164
+                        'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1165
+                        'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1166
+                        'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1167
+                        'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1168
+                        'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1169
+                        'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1170
+                        'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1171
+                    ),
1172
+                ),
1173
+                self::FIELD_PRICE               => array(
1174
+                    'predicate'   => 'http://schema.org/price',
1175
+                    'type'        => self::DATA_TYPE_STRING,
1176
+                    'export_type' => 'xsd:integer',
1177
+                    'metabox'     => array(
1178
+                        'class' => 'Wordlift_Metabox_Field_Integer',
1179
+                    ),
1180
+                ),
1181
+                self::FIELD_PRICE_CURRENCY      => array(
1182
+                    'predicate'   => 'http://schema.org/priceCurrency',
1183
+                    'type'        => self::DATA_TYPE_STRING,
1184
+                    'export_type' => 'xsd:string',
1185
+                ),
1186
+                self::FIELD_AVAILABILITY_STARTS => array(
1187
+                    'predicate'   => 'http://schema.org/availabilityStarts',
1188
+                    'type'        => self::DATA_TYPE_DATE,
1189
+                    'export_type' => 'xsd:dateTime',
1190
+                ),
1191
+                self::FIELD_AVAILABILITY_ENDS   => array(
1192
+                    'predicate'   => 'http://schema.org/availabilityEnds',
1193
+                    'type'        => self::DATA_TYPE_DATE,
1194
+                    'export_type' => 'xsd:dateTime',
1195
+                ),
1196
+                self::FIELD_INVENTORY_LEVEL     => array(
1197
+                    'predicate'   => 'http://schema.org/inventoryLevel',
1198
+                    'type'        => self::DATA_TYPE_STRING,
1199
+                    'export_type' => 'xsd:integer',
1200
+                    'metabox'     => array(
1201
+                        'class' => 'Wordlift_Metabox_Field_Integer',
1202
+                    ),
1203
+                ),
1204
+                self::FIELD_VALID_FROM          => array(
1205
+                    'predicate'   => 'http://schema.org/validFrom',
1206
+                    'type'        => self::DATA_TYPE_DATE,
1207
+                    'export_type' => 'xsd:dateTime',
1208
+                ),
1209
+                self::FIELD_PRICE_VALID_UNTIL   => array(
1210
+                    'predicate'   => 'http://schema.org/priceValidUntil',
1211
+                    'type'        => self::DATA_TYPE_DATE,
1212
+                    'export_type' => 'xsd:dateTime',
1213
+                ),
1214
+                self::FIELD_ITEM_OFFERED        => array(
1215
+                    'predicate'   => 'http://schema.org/itemOffered',
1216
+                    'type'        => self::DATA_TYPE_URI,
1217
+                    'export_type' => 'http://schema.org/Thing',
1218
+                    'constraints' => array(
1219
+                        'uri_type'    => array(
1220
+                            'Event',
1221
+                            'Thing',
1222
+                        ),
1223
+                        'cardinality' => INF,
1224
+                    ),
1225
+                ),
1226
+            ),
1227
+        );
1228
+
1229
+        // Merge the custom fields with those provided by the thing schema.
1230
+        $parent_schema           = $this->get_thing_schema();
1231
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1232
+
1233
+        return $schema;
1234
+    }
1235
+
1236
+    /**
1237
+     * Get the 'article' schema.
1238
+     *
1239
+     * @return array An array with the schema configuration.
1240
+     *
1241
+     * @since 3.15.0
1242
+     */
1243
+    private function get_article_schema() {
1244
+
1245
+        $schema = array(
1246
+            'label'         => 'Article',
1247
+            'description'   => 'An Article.',
1248
+            'parents'       => array(),
1249
+            'css_class'     => 'wl-article',
1250
+            'uri'           => 'http://schema.org/Article',
1251
+            'same_as'       => array(),
1252
+            'templates'     => array(
1253
+                'subtitle' => '{{id}}',
1254
+            ),
1255
+            'custom_fields' => array(),
1256
+        );
1257
+
1258
+        return $schema;
1259
+    }
1260 1260
 
1261 1261
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 */
400 400
 	protected function __construct() {
401 401
 
402
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
402
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Schema_Service');
403 403
 
404 404
 		/**
405 405
 		 * Alter the configured schemas.
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	}
434 434
 
435 435
 	public function get_all_schema_slugs() {
436
-		return array_keys( $this->schema );
436
+		return array_keys($this->schema);
437 437
 	}
438 438
 
439 439
 	/**
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @since 3.1.0
453 453
 	 */
454 454
 	public static function get_instance() {
455
-		if ( ! isset( self::$instance ) ) {
455
+		if ( ! isset(self::$instance)) {
456 456
 			self::$instance = new self();
457 457
 		}
458 458
 
@@ -468,19 +468,19 @@  discard block
 block discarded – undo
468 468
 	 * @return null|array An array of field's properties or null if the field is not found.
469 469
 	 * @since 3.6.0
470 470
 	 */
471
-	public function get_field( $key ) {
471
+	public function get_field($key) {
472 472
 
473 473
 		// Parse each schema's fields until we find the one we're looking for, then
474 474
 		// return its properties.
475 475
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
476
-		foreach ( $this->schema as $_ => $schema ) {
476
+		foreach ($this->schema as $_ => $schema) {
477 477
 
478
-			if ( ! isset( $schema['custom_fields'] ) ) {
478
+			if ( ! isset($schema['custom_fields'])) {
479 479
 				break;
480 480
 			}
481 481
 
482
-			foreach ( $schema['custom_fields'] as $field => $props ) {
483
-				if ( $key === $field ) {
482
+			foreach ($schema['custom_fields'] as $field => $props) {
483
+				if ($key === $field) {
484 484
 					return $props;
485 485
 				}
486 486
 			}
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 * @since 3.1.0
500 500
 	 */
501
-	public function get_schema( $name ) {
501
+	public function get_schema($name) {
502 502
 		// Check if the schema exists and, if not, return NULL.
503
-		if ( ! isset( $this->schema[ $name ] ) ) {
503
+		if ( ! isset($this->schema[$name])) {
504 504
 			return null;
505 505
 		}
506 506
 
507 507
 		// Return the requested schema.
508
-		return $this->schema[ $name ];
508
+		return $this->schema[$name];
509 509
 	}
510 510
 
511 511
 	/**
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @since 3.3.0
519 519
 	 */
520
-	public function get_schema_by_uri( $uri ) {
520
+	public function get_schema_by_uri($uri) {
521 521
 
522 522
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
523
-		foreach ( $this->schema as $name => $schema ) {
524
-			if ( $schema['uri'] === $uri ) {
523
+		foreach ($this->schema as $name => $schema) {
524
+			if ($schema['uri'] === $uri) {
525 525
 				return $schema;
526 526
 			}
527 527
 		}
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		return array(
542 542
 			'css_class'     => 'wl-thing',
543 543
 			'uri'           => 'http://schema.org/Thing',
544
-			'same_as'       => array( '*' ),
544
+			'same_as'       => array('*'),
545 545
 			// set as default.
546 546
 			'custom_fields' => array(
547 547
 				self::FIELD_SAME_AS => array(
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 		$schema = array(
596 596
 			'label'         => 'CreativeWork',
597 597
 			'description'   => 'A creative work (or a Music Album).',
598
-			'parents'       => array( 'thing' ),
598
+			'parents'       => array('thing'),
599 599
 			// Give term slug as parent.
600 600
 			'css_class'     => 'wl-creative-work',
601 601
 			'uri'           => 'http://schema.org/CreativeWork',
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 					'type'        => self::DATA_TYPE_URI,
610 610
 					'export_type' => 'http://schema.org/Person',
611 611
 					'constraints' => array(
612
-						'uri_type'    => array( 'Person', 'Organization' ),
612
+						'uri_type'    => array('Person', 'Organization'),
613 613
 						'cardinality' => INF,
614 614
 					),
615 615
 				),
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 
622 622
 		// Merge the custom fields with those provided by the thing schema.
623 623
 		$parent_schema           = $this->get_thing_schema();
624
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
624
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
625 625
 
626 626
 		return $schema;
627 627
 	}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 		$schema = array(
639 639
 			'label'         => 'Event',
640 640
 			'description'   => 'An event . ',
641
-			'parents'       => array( 'thing' ),
641
+			'parents'       => array('thing'),
642 642
 			'css_class'     => 'wl-event',
643 643
 			'uri'           => self::SCHEMA_EVENT_TYPE,
644
-			'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
644
+			'same_as'       => array('http://dbpedia.org/ontology/Event'),
645 645
 			'custom_fields' => array(
646 646
 				self::FIELD_DATE_START => array(
647 647
 					'predicate'   => 'http://schema.org/startDate',
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 					'type'        => self::DATA_TYPE_URI,
661 661
 					'export_type' => 'http://schema.org/PostalAddress',
662 662
 					'constraints' => array(
663
-						'uri_type'    => array( 'Place', 'LocalBusiness' ),
663
+						'uri_type'    => array('Place', 'LocalBusiness'),
664 664
 						'cardinality' => INF,
665 665
 					),
666 666
 				),
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 					'type'        => self::DATA_TYPE_URI,
670 670
 					'export_type' => 'http://schema.org/Person',
671 671
 					'constraints' => array(
672
-						'uri_type'    => array( 'Person', 'Organization' ),
672
+						'uri_type'    => array('Person', 'Organization'),
673 673
 						'cardinality' => INF,
674 674
 					),
675 675
 				),
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 					'type'        => self::DATA_TYPE_URI,
679 679
 					'export_type' => 'http://schema.org/Offer',
680 680
 					'constraints' => array(
681
-						'uri_type'    => array( 'Offer' ),
681
+						'uri_type'    => array('Offer'),
682 682
 						'cardinality' => INF,
683 683
 					),
684 684
 				),
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 
691 691
 		// Merge the custom fields with those provided by the thing schema.
692 692
 		$parent_schema           = $this->get_thing_schema();
693
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
693
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
694 694
 
695 695
 		return $schema;
696 696
 	}
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		$schema = array(
708 708
 			'label'         => 'Organization',
709 709
 			'description'   => 'An organization, including a government or a newspaper.',
710
-			'parents'       => array( 'thing' ),
710
+			'parents'       => array('thing'),
711 711
 			'css_class'     => 'wl-organization',
712 712
 			'uri'           => 'http://schema.org/Organization',
713 713
 			'same_as'       => array(
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
 		// Merge the custom fields with those provided by the thing schema.
801 801
 		$parent_schema           = $this->get_thing_schema();
802
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
802
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
803 803
 
804 804
 		return $schema;
805 805
 	}
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		$schema = array(
817 817
 			'label'         => 'Person',
818 818
 			'description'   => 'A person (or a music artist).',
819
-			'parents'       => array( 'thing' ),
819
+			'parents'       => array('thing'),
820 820
 			'css_class'     => 'wl-person',
821 821
 			'uri'           => 'http://schema.org/Person',
822 822
 			'same_as'       => array(
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 
877 877
 		// Merge the custom fields with those provided by the thing schema.
878 878
 		$parent_schema           = $this->get_thing_schema();
879
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
879
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
880 880
 
881 881
 		return $schema;
882 882
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 		$schema = array(
895 895
 			'label'         => 'Place',
896 896
 			'description'   => 'A place.',
897
-			'parents'       => array( 'thing' ),
897
+			'parents'       => array('thing'),
898 898
 			'css_class'     => 'wl-place',
899 899
 			'uri'           => 'http://schema.org/Place',
900 900
 			'same_as'       => array(
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 
975 975
 		// Merge the custom fields with those provided by the thing schema.
976 976
 		$parent_schema           = $this->get_thing_schema();
977
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
977
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
978 978
 
979 979
 		return $schema;
980 980
 	}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 		$schema = array(
992 992
 			'label'         => 'LocalBusiness',
993 993
 			'description'   => 'A local business.',
994
-			'parents'       => array( 'place', 'organization' ),
994
+			'parents'       => array('place', 'organization'),
995 995
 			'css_class'     => 'wl-local-business',
996 996
 			'uri'           => 'http://schema.org/LocalBusiness',
997 997
 			'same_as'       => array(
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 		// Merge the custom fields with those provided by the place and organization schema.
1008 1008
 		$place_schema            = $this->get_place_schema();
1009 1009
 		$organization_schema     = $this->get_organization_schema();
1010
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1010
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields']);
1011 1011
 
1012 1012
 		return $schema;
1013 1013
 	}
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 		$schema = array(
1025 1025
 			'label'         => 'Recipe',
1026 1026
 			'description'   => 'A Recipe.',
1027
-			'parents'       => array( 'CreativeWork' ),
1027
+			'parents'       => array('CreativeWork'),
1028 1028
 			'css_class'     => 'wl-recipe',
1029 1029
 			'uri'           => 'http://schema.org/Recipe',
1030 1030
 			'same_as'       => array(),
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 					'export_type' => 'xsd:string',
1039 1039
 					'constraints' => '',
1040 1040
 					'metabox'     => array(
1041
-						'label' => __( 'Recipe cuisine', 'wordlift' ),
1041
+						'label' => __('Recipe cuisine', 'wordlift'),
1042 1042
 					),
1043 1043
 				),
1044 1044
 				self::FIELD_RECIPE_INGREDIENT       => array(
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 						'cardinality' => INF,
1050 1050
 					),
1051 1051
 					'metabox'     => array(
1052
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1052
+						'label' => __('Recipe ingredient', 'wordlift'),
1053 1053
 					),
1054 1054
 				),
1055 1055
 				self::FIELD_RECIPE_INSTRUCTIONS     => array(
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 					'constraints' => '',
1060 1060
 					'metabox'     => array(
1061 1061
 						'class' => 'Wordlift_Metabox_Field_Multiline',
1062
-						'label' => __( 'Recipe instructions', 'wordlift' ),
1062
+						'label' => __('Recipe instructions', 'wordlift'),
1063 1063
 					),
1064 1064
 				),
1065 1065
 				self::FIELD_RECIPE_YIELD            => array(
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 					'export_type' => 'xsd:string',
1069 1069
 					'constraints' => '',
1070 1070
 					'metabox'     => array(
1071
-						'label' => __( 'Recipe number of servings', 'wordlift' ),
1071
+						'label' => __('Recipe number of servings', 'wordlift'),
1072 1072
 					),
1073 1073
 				),
1074 1074
 				self::FIELD_RECIPE_INGREDIENT       => array(
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 						'cardinality' => INF,
1080 1080
 					),
1081 1081
 					'metabox'     => array(
1082
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1082
+						'label' => __('Recipe ingredient', 'wordlift'),
1083 1083
 					),
1084 1084
 				),
1085 1085
 				self::FIELD_NUTRITION_INFO_CALORIES => array(
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 					'export_type' => 'xsd:string',
1089 1089
 					'constraints' => '',
1090 1090
 					'metabox'     => array(
1091
-						'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1091
+						'label' => __('Calories (e.g. 240 calories)', 'wordlift'),
1092 1092
 					),
1093 1093
 				),
1094 1094
 				self::FIELD_PREP_TIME               => array(
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 					'constraints' => '',
1099 1099
 					'metabox'     => array(
1100 1100
 						'class' => 'Wordlift_Metabox_Field_Duration',
1101
-						'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1101
+						'label' => __('Recipe preparation time (e.g. 1:30)', 'wordlift'),
1102 1102
 					),
1103 1103
 				),
1104 1104
 				self::FIELD_COOK_TIME               => array(
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 					'constraints' => '',
1109 1109
 					'metabox'     => array(
1110 1110
 						'class' => 'Wordlift_Metabox_Field_Duration',
1111
-						'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1111
+						'label' => __('Recipe cook time (e.g. 1:30)', 'wordlift'),
1112 1112
 					),
1113 1113
 				),
1114 1114
 				self::FIELD_TOTAL_TIME              => array(
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 					'constraints' => '',
1119 1119
 					'metabox'     => array(
1120 1120
 						'class' => 'Wordlift_Metabox_Field_Duration',
1121
-						'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1121
+						'label' => __('Recipe total time (e.g. 1:30)', 'wordlift'),
1122 1122
 					),
1123 1123
 				),
1124 1124
 			),
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 
1127 1127
 		// Merge the custom fields with those provided by the parent schema.
1128 1128
 		$parent_schema           = $this->get_creative_work_schema();
1129
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1129
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1130 1130
 
1131 1131
 		return $schema;
1132 1132
 	}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		$schema = array(
1144 1144
 			'label'         => 'Offer',
1145 1145
 			'description'   => 'An offer. ',
1146
-			'parents'       => array( 'thing' ),
1146
+			'parents'       => array('thing'),
1147 1147
 			'css_class'     => 'wl-offer',
1148 1148
 			'uri'           => self::SCHEMA_OFFER_TYPE,
1149 1149
 			'same_as'       => array(),
@@ -1159,15 +1159,15 @@  discard block
 block discarded – undo
1159 1159
 						'class' => 'Wordlift_Metabox_Field_Select',
1160 1160
 					),
1161 1161
 					'options'     => array(
1162
-						'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1163
-						'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1164
-						'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1165
-						'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1166
-						'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1167
-						'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1168
-						'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1169
-						'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1170
-						'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1162
+						'Discontinued'        => esc_html__('Discontinued', 'wordlift'),
1163
+						'InStock'             => esc_html__('In Stock', 'wordlift'),
1164
+						'InStoreOnly'         => esc_html__('In Store Only', 'wordlift'),
1165
+						'LimitedAvailability' => esc_html__('Limited Availability', 'wordlift'),
1166
+						'OnlineOnly'          => esc_html__('Online Only', 'wordlift'),
1167
+						'OutOfStock'          => esc_html__('Out of Stock', 'wordlift'),
1168
+						'PreOrder'            => esc_html__('Pre Order', 'wordlift'),
1169
+						'PreSale'             => esc_html__('Pre Sale', 'wordlift'),
1170
+						'SoldOut'             => esc_html__('Sold Out', 'wordlift'),
1171 1171
 					),
1172 1172
 				),
1173 1173
 				self::FIELD_PRICE               => array(
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 
1229 1229
 		// Merge the custom fields with those provided by the thing schema.
1230 1230
 		$parent_schema           = $this->get_thing_schema();
1231
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1231
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1232 1232
 
1233 1233
 		return $schema;
1234 1234
 	}
Please login to merge, or discard this patch.
src/wordlift/metabox/class-wl-metabox.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,36 +21,36 @@
 block discarded – undo
21 21
  */
22 22
 class Wl_Metabox extends Wl_Abstract_Metabox {
23 23
 
24
-	/**
25
-	 * WL_Metabox constructor.
26
-	 *
27
-	 * @since 3.1.0
28
-	 */
29
-	public function __construct() {
30
-		parent::__construct();
31
-		/**
32
-		 * Filter: wl_feature__enable__metabox.
33
-		 *
34
-		 * @param bool whether the metabox should be shown, defaults to true.
35
-		 *
36
-		 * @return bool
37
-		 * @since 3.28.1
38
-		 */
39
-		if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
40
-
41
-			// Add hooks to print metaboxes and save submitted data.
42
-			add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) );
43
-			add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) );
44
-
45
-			// Enqueue js and css.
46
-			$this->enqueue_scripts_and_styles();
47
-
48
-		}
49
-
50
-	}
51
-
52
-	public function save_form( $post_id ) {
53
-		$this->save_form_data( $post_id, Object_Type_Enum::POST );
54
-	}
24
+    /**
25
+     * WL_Metabox constructor.
26
+     *
27
+     * @since 3.1.0
28
+     */
29
+    public function __construct() {
30
+        parent::__construct();
31
+        /**
32
+         * Filter: wl_feature__enable__metabox.
33
+         *
34
+         * @param bool whether the metabox should be shown, defaults to true.
35
+         *
36
+         * @return bool
37
+         * @since 3.28.1
38
+         */
39
+        if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
40
+
41
+            // Add hooks to print metaboxes and save submitted data.
42
+            add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) );
43
+            add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) );
44
+
45
+            // Enqueue js and css.
46
+            $this->enqueue_scripts_and_styles();
47
+
48
+        }
49
+
50
+    }
51
+
52
+    public function save_form( $post_id ) {
53
+        $this->save_form_data( $post_id, Object_Type_Enum::POST );
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 		 * @return bool
37 37
 		 * @since 3.28.1
38 38
 		 */
39
-		if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
39
+		if (apply_filters('wl_feature__enable__metabox', true) && ! apply_filters('wl_feature__enable__pods-integration', false)) {
40 40
 
41 41
 			// Add hooks to print metaboxes and save submitted data.
42
-			add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) );
43
-			add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) );
42
+			add_action('add_meta_boxes', array($this, 'add_main_metabox'));
43
+			add_action('wl_linked_data_save_post', array($this, 'save_form'));
44 44
 
45 45
 			// Enqueue js and css.
46 46
 			$this->enqueue_scripts_and_styles();
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 
50 50
 	}
51 51
 
52
-	public function save_form( $post_id ) {
53
-		$this->save_form_data( $post_id, Object_Type_Enum::POST );
52
+	public function save_form($post_id) {
53
+		$this->save_form_data($post_id, Object_Type_Enum::POST);
54 54
 	}
55 55
 
56 56
 }
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/class-entity-type.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -14,114 +14,114 @@
 block discarded – undo
14 14
 
15 15
 class Entity_Type {
16 16
 
17
-	public function __construct() {
18
-
19
-		$that = $this;
20
-
21
-		add_action(
22
-			'init',
23
-			function () use ( $that ) {
24
-				$that->init_ui_and_save_handlers();
25
-			}
26
-		);
27
-	}
28
-
29
-	/**
30
-	 * @param $term  \WP_Term
31
-	 */
32
-	public function render_ui( $term ) {
33
-
34
-		$selected_entity_types = get_term_meta( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
35
-
36
-		/**
37
-		 * Thing should be the default selected entity type
38
-		 * when this feature is activated.
39
-		 */
40
-		if ( count( $selected_entity_types ) === 0 ) {
41
-			$selected_entity_types[] = 'thing';
42
-		}
43
-
44
-		$entity_type_taxonomy = Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME;
45
-		$types                = Terms_Compat::get_terms(
46
-			$entity_type_taxonomy,
47
-			array(
48
-				'taxonomy'   => $entity_type_taxonomy,
49
-				'parent'     => 0,
50
-				'hide_empty' => false,
51
-			)
52
-		);
53
-		?>
17
+    public function __construct() {
18
+
19
+        $that = $this;
20
+
21
+        add_action(
22
+            'init',
23
+            function () use ( $that ) {
24
+                $that->init_ui_and_save_handlers();
25
+            }
26
+        );
27
+    }
28
+
29
+    /**
30
+     * @param $term  \WP_Term
31
+     */
32
+    public function render_ui( $term ) {
33
+
34
+        $selected_entity_types = get_term_meta( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
35
+
36
+        /**
37
+         * Thing should be the default selected entity type
38
+         * when this feature is activated.
39
+         */
40
+        if ( count( $selected_entity_types ) === 0 ) {
41
+            $selected_entity_types[] = 'thing';
42
+        }
43
+
44
+        $entity_type_taxonomy = Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME;
45
+        $types                = Terms_Compat::get_terms(
46
+            $entity_type_taxonomy,
47
+            array(
48
+                'taxonomy'   => $entity_type_taxonomy,
49
+                'parent'     => 0,
50
+                'hide_empty' => false,
51
+            )
52
+        );
53
+        ?>
54 54
 		<?php wp_nonce_field( 'wordlift_vocabulary_terms_entity_type', 'wordlift_vocabulary_terms_entity_type_nonce' ); ?>
55 55
 		<tr class="form-field term-name-wrap">
56 56
 			<th scope="row"><label for="wl-entity-type__checklist"><?php esc_html_e( 'Entity Types', 'wordlift' ); ?></label></th>
57 57
 			<td>
58 58
 				<div id="wl-entity-type__checklist">
59 59
 					<?php
60
-					echo wp_kses(
61
-						Term_Checklist::render( 'tax_input[wl_entity_type]', $types, $selected_entity_types ),
62
-						array(
63
-							'li'    => array( 'id' => array() ),
64
-							'ul'    => array( 'id' => array() ),
65
-							'label' => array( 'class' => array() ),
66
-							'input' => array(
67
-								'value'       => array(),
68
-								'type'        => array(),
69
-								'name'        => array(),
70
-								'id'          => array(),
71
-								'placeholder' => array(),
72
-								'checked'     => array(),
73
-							),
74
-						)
75
-					);
76
-					?>
60
+                    echo wp_kses(
61
+                        Term_Checklist::render( 'tax_input[wl_entity_type]', $types, $selected_entity_types ),
62
+                        array(
63
+                            'li'    => array( 'id' => array() ),
64
+                            'ul'    => array( 'id' => array() ),
65
+                            'label' => array( 'class' => array() ),
66
+                            'input' => array(
67
+                                'value'       => array(),
68
+                                'type'        => array(),
69
+                                'name'        => array(),
70
+                                'id'          => array(),
71
+                                'placeholder' => array(),
72
+                                'checked'     => array(),
73
+                            ),
74
+                        )
75
+                    );
76
+                    ?>
77 77
 				</div>
78 78
 			</td>
79 79
 		</tr>
80 80
 		<?php
81
-		$this->enqueue_script_and_style();
82
-	}
83
-
84
-	public function save_field( $term_id ) {
85
-
86
-		if ( ! isset( $_REQUEST['tax_input'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
87
-			return;
88
-		}
89
-		$entity_types = array();
90
-		if ( isset( $_REQUEST['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
91
-			$entity_types_data = filter_var_array( $_REQUEST, array( 'tax_input' => array( 'flags' => FILTER_REQUIRE_ARRAY ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
92
-			$entity_types      = $entity_types_data['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ];
93
-		}
94
-
95
-		if ( isset( $entity_types ) && is_array( $entity_types ) ) {
96
-			// Save the taxonomies.
97
-			delete_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
98
-			foreach ( $entity_types as $entity_type ) {
99
-				add_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type );
100
-			}
101
-		}
102
-	}
103
-
104
-	public function init_ui_and_save_handlers() {
105
-		$taxonomies = Terms_Compat::get_public_taxonomies();
106
-		foreach ( $taxonomies as $taxonomy ) {
107
-			add_action( "${taxonomy}_edit_form_fields", array( $this, 'render_ui' ), 1 );
108
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
109
-		}
110
-	}
111
-
112
-	private function enqueue_script_and_style() {
113
-
114
-		Scripts_Helper::enqueue_based_on_wordpress_version(
115
-			'wl-vocabulary-term',
116
-			plugin_dir_url( dirname( __DIR__ ) ) . '/js/dist/vocabulary-term',
117
-			array( 'wp-polyfill' )
118
-		);
119
-		wp_enqueue_style(
120
-			'wl-vocabulary-term',
121
-			plugin_dir_url( dirname( __DIR__ ) ) . '/js/dist/vocabulary-term.css',
122
-			array(),
123
-			WORDLIFT_VERSION
124
-		);
125
-	}
81
+        $this->enqueue_script_and_style();
82
+    }
83
+
84
+    public function save_field( $term_id ) {
85
+
86
+        if ( ! isset( $_REQUEST['tax_input'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
87
+            return;
88
+        }
89
+        $entity_types = array();
90
+        if ( isset( $_REQUEST['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
91
+            $entity_types_data = filter_var_array( $_REQUEST, array( 'tax_input' => array( 'flags' => FILTER_REQUIRE_ARRAY ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
92
+            $entity_types      = $entity_types_data['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ];
93
+        }
94
+
95
+        if ( isset( $entity_types ) && is_array( $entity_types ) ) {
96
+            // Save the taxonomies.
97
+            delete_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
98
+            foreach ( $entity_types as $entity_type ) {
99
+                add_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type );
100
+            }
101
+        }
102
+    }
103
+
104
+    public function init_ui_and_save_handlers() {
105
+        $taxonomies = Terms_Compat::get_public_taxonomies();
106
+        foreach ( $taxonomies as $taxonomy ) {
107
+            add_action( "${taxonomy}_edit_form_fields", array( $this, 'render_ui' ), 1 );
108
+            add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
109
+        }
110
+    }
111
+
112
+    private function enqueue_script_and_style() {
113
+
114
+        Scripts_Helper::enqueue_based_on_wordpress_version(
115
+            'wl-vocabulary-term',
116
+            plugin_dir_url( dirname( __DIR__ ) ) . '/js/dist/vocabulary-term',
117
+            array( 'wp-polyfill' )
118
+        );
119
+        wp_enqueue_style(
120
+            'wl-vocabulary-term',
121
+            plugin_dir_url( dirname( __DIR__ ) ) . '/js/dist/vocabulary-term.css',
122
+            array(),
123
+            WORDLIFT_VERSION
124
+        );
125
+    }
126 126
 
127 127
 }
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/jsonld/class-jsonld-generator.php 2 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -13,176 +13,176 @@
 block discarded – undo
13 13
 
14 14
 class Jsonld_Generator {
15 15
 
16
-	/**
17
-	 * @var \Wordlift_Entity_Type_Service
18
-	 */
19
-	private $entity_type_service;
20
-	/**
21
-	 * @var \Wordlift_Property_Getter
22
-	 */
23
-	private $property_getter;
24
-	/**
25
-	 * @var Type_Service
26
-	 */
27
-	private $term_entity_type_service;
28
-	/**
29
-	 * @var \Wordlift_Entity_Service
30
-	 */
31
-	private $entity_service;
32
-
33
-	public function __construct( $entity_type_service, $property_getter ) {
34
-		$this->entity_type_service      = $entity_type_service;
35
-		$this->property_getter          = $property_getter;
36
-		$this->term_entity_type_service = Type_Service::get_instance();
37
-		$this->entity_service           = \Wordlift_Entity_Service::get_instance();
38
-	}
39
-
40
-	public function init() {
41
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
42
-	}
43
-
44
-	public function wl_term_jsonld_array( $data, $term_id ) {
45
-		$jsonld     = $data['jsonld'];
46
-		$references = $data['references'];
47
-
48
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
49
-
50
-		// Return early if we dont have the entity data
51
-		// for the term.
52
-		if ( ! $term_jsonld_data ) {
53
-			return $data;
54
-		}
55
-
56
-		$term_jsonld = $term_jsonld_data['jsonld'];
57
-
58
-		$references = array_merge( $references, $term_jsonld_data['references'] );
59
-
60
-		array_unshift( $jsonld, $term_jsonld );
61
-
62
-		return array(
63
-			'jsonld'     => $jsonld,
64
-			'references' => $references,
65
-		);
66
-	}
67
-
68
-	private function get_jsonld_data_for_term( $term_id ) {
69
-
70
-		$id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
71
-
72
-		// If we don't have a dataset  URI, then don't publish the term data
73
-		// on this page.
74
-		if ( ! $id ) {
75
-			return false;
76
-		}
77
-
78
-		$references = array();
79
-		$term       = get_term( $term_id );
80
-		$permalink  = get_term_link( $term );
81
-
82
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
-		$term          = get_term( $term_id );
84
-		$jsonld        = array(
85
-			'@context'    => 'http://schema.org',
86
-			'name'        => $term->name,
87
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
88
-			'@id'         => $id,
89
-			'description' => $term->description,
90
-		);
91
-
92
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
93
-			return $jsonld;
94
-		}
95
-
96
-		foreach ( $custom_fields as $key => $value ) {
97
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
98
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
-			$value = $this->process_value( $value, $references );
100
-			if ( ! isset( $value ) ||
101
-				 is_array( $value ) && empty( $value ) ||
102
-				 is_string( $value ) && empty( $value ) ) {
103
-				continue;
104
-			}
105
-			$jsonld[ $name ] = $value;
106
-
107
-		}
108
-
109
-		if ( $permalink ) {
110
-			$jsonld['mainEntityOfPage'] = $permalink;
111
-		}
112
-
113
-		return apply_filters(
114
-			'wl_no_vocabulary_term_jsonld_array',
115
-			array(
116
-				'jsonld'     => $jsonld,
117
-				'references' => $references,
118
-			),
119
-			$term_id
120
-		);
121
-
122
-	}
123
-
124
-	private function relative_to_schema_context( $predicate ) {
125
-		return str_replace( 'http://schema.org/', '', $predicate );
126
-	}
127
-
128
-	private function process_value( $value, &$references ) {
129
-
130
-		if ( is_array( $value )
131
-			 && count( $value ) > 0
132
-			 && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
133
-
134
-			// All of the references from the custom fields are post references.
135
-			$references = array_merge(
136
-				$references,
137
-				array_map(
138
-					function ( $property_entity_reference ) {
139
-						/**
140
-						 * @var $property_entity_reference \Wordlift_Property_Entity_Reference
141
-						 */
142
-						return new Post_Reference( $property_entity_reference->get_id() );
143
-					},
144
-					$value
145
-				)
146
-			);
147
-
148
-			$that = $this;
149
-
150
-			return array_map(
151
-				function ( $reference ) use ( $that ) {
152
-					/**
153
-					 * @var $reference \Wordlift_Property_Entity_Reference
154
-					 */
155
-					return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
156
-				},
157
-				$value
158
-			);
159
-
160
-		}
161
-
162
-
163
-		if (  is_array( $value )
164
-		      && count( $value ) > 0
165
-		      && $value[0] instanceof Reference ) {
166
-			$references = array_merge(
167
-				$references,
168
-				$value
169
-			);
170
-
171
-
172
-			$that = $this;
173
-			return array_map(
174
-				function ( $reference ) use ( $that ) {
175
-					/**
176
-					 * @var $reference Reference
177
-					 */
178
-					return array( '@id' => $that->entity_service->get_uri( $reference->get_id(), $reference->get_type() ) );
179
-				},
180
-				$value
181
-			);
182
-		}
183
-
184
-
185
-		return $value;
186
-	}
16
+    /**
17
+     * @var \Wordlift_Entity_Type_Service
18
+     */
19
+    private $entity_type_service;
20
+    /**
21
+     * @var \Wordlift_Property_Getter
22
+     */
23
+    private $property_getter;
24
+    /**
25
+     * @var Type_Service
26
+     */
27
+    private $term_entity_type_service;
28
+    /**
29
+     * @var \Wordlift_Entity_Service
30
+     */
31
+    private $entity_service;
32
+
33
+    public function __construct( $entity_type_service, $property_getter ) {
34
+        $this->entity_type_service      = $entity_type_service;
35
+        $this->property_getter          = $property_getter;
36
+        $this->term_entity_type_service = Type_Service::get_instance();
37
+        $this->entity_service           = \Wordlift_Entity_Service::get_instance();
38
+    }
39
+
40
+    public function init() {
41
+        add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
42
+    }
43
+
44
+    public function wl_term_jsonld_array( $data, $term_id ) {
45
+        $jsonld     = $data['jsonld'];
46
+        $references = $data['references'];
47
+
48
+        $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
49
+
50
+        // Return early if we dont have the entity data
51
+        // for the term.
52
+        if ( ! $term_jsonld_data ) {
53
+            return $data;
54
+        }
55
+
56
+        $term_jsonld = $term_jsonld_data['jsonld'];
57
+
58
+        $references = array_merge( $references, $term_jsonld_data['references'] );
59
+
60
+        array_unshift( $jsonld, $term_jsonld );
61
+
62
+        return array(
63
+            'jsonld'     => $jsonld,
64
+            'references' => $references,
65
+        );
66
+    }
67
+
68
+    private function get_jsonld_data_for_term( $term_id ) {
69
+
70
+        $id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
71
+
72
+        // If we don't have a dataset  URI, then don't publish the term data
73
+        // on this page.
74
+        if ( ! $id ) {
75
+            return false;
76
+        }
77
+
78
+        $references = array();
79
+        $term       = get_term( $term_id );
80
+        $permalink  = get_term_link( $term );
81
+
82
+        $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
+        $term          = get_term( $term_id );
84
+        $jsonld        = array(
85
+            '@context'    => 'http://schema.org',
86
+            'name'        => $term->name,
87
+            '@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
88
+            '@id'         => $id,
89
+            'description' => $term->description,
90
+        );
91
+
92
+        if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
93
+            return $jsonld;
94
+        }
95
+
96
+        foreach ( $custom_fields as $key => $value ) {
97
+            $name  = $this->relative_to_schema_context( $value['predicate'] );
98
+            $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
+            $value = $this->process_value( $value, $references );
100
+            if ( ! isset( $value ) ||
101
+                 is_array( $value ) && empty( $value ) ||
102
+                 is_string( $value ) && empty( $value ) ) {
103
+                continue;
104
+            }
105
+            $jsonld[ $name ] = $value;
106
+
107
+        }
108
+
109
+        if ( $permalink ) {
110
+            $jsonld['mainEntityOfPage'] = $permalink;
111
+        }
112
+
113
+        return apply_filters(
114
+            'wl_no_vocabulary_term_jsonld_array',
115
+            array(
116
+                'jsonld'     => $jsonld,
117
+                'references' => $references,
118
+            ),
119
+            $term_id
120
+        );
121
+
122
+    }
123
+
124
+    private function relative_to_schema_context( $predicate ) {
125
+        return str_replace( 'http://schema.org/', '', $predicate );
126
+    }
127
+
128
+    private function process_value( $value, &$references ) {
129
+
130
+        if ( is_array( $value )
131
+             && count( $value ) > 0
132
+             && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
133
+
134
+            // All of the references from the custom fields are post references.
135
+            $references = array_merge(
136
+                $references,
137
+                array_map(
138
+                    function ( $property_entity_reference ) {
139
+                        /**
140
+                         * @var $property_entity_reference \Wordlift_Property_Entity_Reference
141
+                         */
142
+                        return new Post_Reference( $property_entity_reference->get_id() );
143
+                    },
144
+                    $value
145
+                )
146
+            );
147
+
148
+            $that = $this;
149
+
150
+            return array_map(
151
+                function ( $reference ) use ( $that ) {
152
+                    /**
153
+                     * @var $reference \Wordlift_Property_Entity_Reference
154
+                     */
155
+                    return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
156
+                },
157
+                $value
158
+            );
159
+
160
+        }
161
+
162
+
163
+        if (  is_array( $value )
164
+              && count( $value ) > 0
165
+              && $value[0] instanceof Reference ) {
166
+            $references = array_merge(
167
+                $references,
168
+                $value
169
+            );
170
+
171
+
172
+            $that = $this;
173
+            return array_map(
174
+                function ( $reference ) use ( $that ) {
175
+                    /**
176
+                     * @var $reference Reference
177
+                     */
178
+                    return array( '@id' => $that->entity_service->get_uri( $reference->get_id(), $reference->get_type() ) );
179
+                },
180
+                $value
181
+            );
182
+        }
183
+
184
+
185
+        return $value;
186
+    }
187 187
 
188 188
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	private $entity_service;
32 32
 
33
-	public function __construct( $entity_type_service, $property_getter ) {
33
+	public function __construct($entity_type_service, $property_getter) {
34 34
 		$this->entity_type_service      = $entity_type_service;
35 35
 		$this->property_getter          = $property_getter;
36 36
 		$this->term_entity_type_service = Type_Service::get_instance();
@@ -38,26 +38,26 @@  discard block
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	public function init() {
41
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
41
+		add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2);
42 42
 	}
43 43
 
44
-	public function wl_term_jsonld_array( $data, $term_id ) {
44
+	public function wl_term_jsonld_array($data, $term_id) {
45 45
 		$jsonld     = $data['jsonld'];
46 46
 		$references = $data['references'];
47 47
 
48
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
48
+		$term_jsonld_data = $this->get_jsonld_data_for_term($term_id);
49 49
 
50 50
 		// Return early if we dont have the entity data
51 51
 		// for the term.
52
-		if ( ! $term_jsonld_data ) {
52
+		if ( ! $term_jsonld_data) {
53 53
 			return $data;
54 54
 		}
55 55
 
56 56
 		$term_jsonld = $term_jsonld_data['jsonld'];
57 57
 
58
-		$references = array_merge( $references, $term_jsonld_data['references'] );
58
+		$references = array_merge($references, $term_jsonld_data['references']);
59 59
 
60
-		array_unshift( $jsonld, $term_jsonld );
60
+		array_unshift($jsonld, $term_jsonld);
61 61
 
62 62
 		return array(
63 63
 			'jsonld'     => $jsonld,
@@ -65,48 +65,48 @@  discard block
 block discarded – undo
65 65
 		);
66 66
 	}
67 67
 
68
-	private function get_jsonld_data_for_term( $term_id ) {
68
+	private function get_jsonld_data_for_term($term_id) {
69 69
 
70
-		$id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
70
+		$id = $this->entity_service->get_uri($term_id, Object_Type_Enum::TERM);
71 71
 
72 72
 		// If we don't have a dataset  URI, then don't publish the term data
73 73
 		// on this page.
74
-		if ( ! $id ) {
74
+		if ( ! $id) {
75 75
 			return false;
76 76
 		}
77 77
 
78 78
 		$references = array();
79
-		$term       = get_term( $term_id );
80
-		$permalink  = get_term_link( $term );
79
+		$term       = get_term($term_id);
80
+		$permalink  = get_term_link($term);
81 81
 
82
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
-		$term          = get_term( $term_id );
82
+		$custom_fields = $this->entity_type_service->get_custom_fields_for_term($term_id);
83
+		$term          = get_term($term_id);
84 84
 		$jsonld        = array(
85 85
 			'@context'    => 'http://schema.org',
86 86
 			'name'        => $term->name,
87
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
87
+			'@type'       => $this->term_entity_type_service->get_entity_types_labels($term_id),
88 88
 			'@id'         => $id,
89 89
 			'description' => $term->description,
90 90
 		);
91 91
 
92
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
92
+		if ( ! $custom_fields || ! is_array($custom_fields)) {
93 93
 			return $jsonld;
94 94
 		}
95 95
 
96
-		foreach ( $custom_fields as $key => $value ) {
97
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
98
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
-			$value = $this->process_value( $value, $references );
100
-			if ( ! isset( $value ) ||
101
-				 is_array( $value ) && empty( $value ) ||
102
-				 is_string( $value ) && empty( $value ) ) {
96
+		foreach ($custom_fields as $key => $value) {
97
+			$name  = $this->relative_to_schema_context($value['predicate']);
98
+			$value = $this->property_getter->get($term_id, $key, Object_Type_Enum::TERM);
99
+			$value = $this->process_value($value, $references);
100
+			if ( ! isset($value) ||
101
+				 is_array($value) && empty($value) ||
102
+				 is_string($value) && empty($value)) {
103 103
 				continue;
104 104
 			}
105
-			$jsonld[ $name ] = $value;
105
+			$jsonld[$name] = $value;
106 106
 
107 107
 		}
108 108
 
109
-		if ( $permalink ) {
109
+		if ($permalink) {
110 110
 			$jsonld['mainEntityOfPage'] = $permalink;
111 111
 		}
112 112
 
@@ -121,25 +121,25 @@  discard block
 block discarded – undo
121 121
 
122 122
 	}
123 123
 
124
-	private function relative_to_schema_context( $predicate ) {
125
-		return str_replace( 'http://schema.org/', '', $predicate );
124
+	private function relative_to_schema_context($predicate) {
125
+		return str_replace('http://schema.org/', '', $predicate);
126 126
 	}
127 127
 
128
-	private function process_value( $value, &$references ) {
128
+	private function process_value($value, &$references) {
129 129
 
130
-		if ( is_array( $value )
131
-			 && count( $value ) > 0
132
-			 && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
130
+		if (is_array($value)
131
+			 && count($value) > 0
132
+			 && $value[0] instanceof \Wordlift_Property_Entity_Reference) {
133 133
 
134 134
 			// All of the references from the custom fields are post references.
135 135
 			$references = array_merge(
136 136
 				$references,
137 137
 				array_map(
138
-					function ( $property_entity_reference ) {
138
+					function($property_entity_reference) {
139 139
 						/**
140 140
 						 * @var $property_entity_reference \Wordlift_Property_Entity_Reference
141 141
 						 */
142
-						return new Post_Reference( $property_entity_reference->get_id() );
142
+						return new Post_Reference($property_entity_reference->get_id());
143 143
 					},
144 144
 					$value
145 145
 				)
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 			$that = $this;
149 149
 
150 150
 			return array_map(
151
-				function ( $reference ) use ( $that ) {
151
+				function($reference) use ($that) {
152 152
 					/**
153 153
 					 * @var $reference \Wordlift_Property_Entity_Reference
154 154
 					 */
155
-					return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
155
+					return array('@id' => $that->entity_service->get_uri($reference->get_id()));
156 156
 				},
157 157
 				$value
158 158
 			);
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 		}
161 161
 
162 162
 
163
-		if (  is_array( $value )
164
-		      && count( $value ) > 0
165
-		      && $value[0] instanceof Reference ) {
163
+		if (is_array($value)
164
+		      && count($value) > 0
165
+		      && $value[0] instanceof Reference) {
166 166
 			$references = array_merge(
167 167
 				$references,
168 168
 				$value
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
 			$that = $this;
173 173
 			return array_map(
174
-				function ( $reference ) use ( $that ) {
174
+				function($reference) use ($that) {
175 175
 					/**
176 176
 					 * @var $reference Reference
177 177
 					 */
178
-					return array( '@id' => $that->entity_service->get_uri( $reference->get_id(), $reference->get_type() ) );
178
+					return array('@id' => $that->entity_service->get_uri($reference->get_id(), $reference->get_type()));
179 179
 				},
180 180
 				$value
181 181
 			);
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/class-term-metabox.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
 
13 13
 class Term_Metabox extends Wl_Abstract_Metabox {
14 14
 
15
-	public function __construct() {
16
-		parent::__construct();
17
-		if ( ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
18
-			add_action( 'init', array( $this, 'init_all_custom_fields' ) );
19
-		}
15
+    public function __construct() {
16
+        parent::__construct();
17
+        if ( ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
18
+            add_action( 'init', array( $this, 'init_all_custom_fields' ) );
19
+        }
20 20
 
21
-	}
21
+    }
22 22
 
23
-	/**
24
-	 * @param $term \WP_Term
25
-	 */
26
-	public function render_ui( $term ) {
23
+    /**
24
+     * @param $term \WP_Term
25
+     */
26
+    public function render_ui( $term ) {
27 27
 
28 28
 
29 29
 
30
-		$this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
31
-		$this->html();
32
-		$this->enqueue_scripts_and_styles();
33
-		$plugin = \Wordlift::get_instance();
30
+        $this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
31
+        $this->html();
32
+        $this->enqueue_scripts_and_styles();
33
+        $plugin = \Wordlift::get_instance();
34 34
 
35
-		// Enqueue this scripts for sameas fields.
36
-		wp_enqueue_script(
37
-			'wl-autocomplete-select',
38
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js',
39
-			array(),
40
-			$plugin->get_version(),
41
-			true
42
-		);
35
+        // Enqueue this scripts for sameas fields.
36
+        wp_enqueue_script(
37
+            'wl-autocomplete-select',
38
+            plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js',
39
+            array(),
40
+            $plugin->get_version(),
41
+            true
42
+        );
43 43
 
44
-		wp_enqueue_style(
45
-			'wl-autocomplete-select',
46
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css',
47
-			array(),
48
-			$plugin->get_version()
49
-		);
50
-	}
44
+        wp_enqueue_style(
45
+            'wl-autocomplete-select',
46
+            plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css',
47
+            array(),
48
+            $plugin->get_version()
49
+        );
50
+    }
51 51
 
52
-	public function save_field( $term_id ) {
53
-		$this->save_form_data( $term_id, Object_Type_Enum::TERM );
54
-	}
52
+    public function save_field( $term_id ) {
53
+        $this->save_form_data( $term_id, Object_Type_Enum::TERM );
54
+    }
55 55
 
56
-	public function init_all_custom_fields() {
57
-		$taxonomies = Terms_Compat::get_public_taxonomies();
58
-		foreach ( $taxonomies as $taxonomy ) {
59
-			add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
60
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
61
-		}
62
-	}
56
+    public function init_all_custom_fields() {
57
+        $taxonomies = Terms_Compat::get_public_taxonomies();
58
+        foreach ( $taxonomies as $taxonomy ) {
59
+            add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
60
+            add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
61
+        }
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public function __construct() {
16 16
 		parent::__construct();
17
-		if ( ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) {
18
-			add_action( 'init', array( $this, 'init_all_custom_fields' ) );
17
+		if ( ! apply_filters('wl_feature__enable__pods-integration', false)) {
18
+			add_action('init', array($this, 'init_all_custom_fields'));
19 19
 		}
20 20
 
21 21
 	}
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @param $term \WP_Term
25 25
 	 */
26
-	public function render_ui( $term ) {
26
+	public function render_ui($term) {
27 27
 
28 28
 
29 29
 
30
-		$this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
30
+		$this->instantiate_fields($term->term_id, Object_Type_Enum::TERM);
31 31
 		$this->html();
32 32
 		$this->enqueue_scripts_and_styles();
33 33
 		$plugin = \Wordlift::get_instance();
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		// Enqueue this scripts for sameas fields.
36 36
 		wp_enqueue_script(
37 37
 			'wl-autocomplete-select',
38
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js',
38
+			plugin_dir_url(dirname(__DIR__)).'js/dist/autocomplete-select.js',
39 39
 			array(),
40 40
 			$plugin->get_version(),
41 41
 			true
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 
44 44
 		wp_enqueue_style(
45 45
 			'wl-autocomplete-select',
46
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css',
46
+			plugin_dir_url(dirname(__DIR__)).'js/dist/autocomplete-select.css',
47 47
 			array(),
48 48
 			$plugin->get_version()
49 49
 		);
50 50
 	}
51 51
 
52
-	public function save_field( $term_id ) {
53
-		$this->save_form_data( $term_id, Object_Type_Enum::TERM );
52
+	public function save_field($term_id) {
53
+		$this->save_form_data($term_id, Object_Type_Enum::TERM);
54 54
 	}
55 55
 
56 56
 	public function init_all_custom_fields() {
57 57
 		$taxonomies = Terms_Compat::get_public_taxonomies();
58
-		foreach ( $taxonomies as $taxonomy ) {
59
-			add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
60
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
58
+		foreach ($taxonomies as $taxonomy) {
59
+			add_action("${taxonomy}_edit_form", array($this, 'render_ui'), 1);
60
+			add_action("edited_${taxonomy}", array($this, 'save_field'));
61 61
 		}
62 62
 	}
63 63
 
Please login to merge, or discard this patch.
src/wordlift/entity/query/class-entity-query-service.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -15,115 +15,115 @@
 block discarded – undo
15 15
 class Entity_Query_Service {
16 16
 
17 17
 
18
-	private static $instance = null;
19
-
20
-	/**
21
-	 * The singleton instance.
22
-	 *
23
-	 * @return Entity_Query_Service
24
-	 */
25
-	public static function get_instance() {
26
-		if ( ! isset( self::$instance ) ) {
27
-			self::$instance = new self();
28
-		}
29
-
30
-		return self::$instance;
31
-	}
32
-
33
-
34
-	private function query_posts( $query, $schema_types, $limit ) {
35
-		return wl_entity_get_by_title( $query, true, true, $limit, $schema_types );
36
-	}
37
-
38
-	private function query_terms( $query, $schema_types, $limit ) {
39
-		global $wpdb;
40
-		$schema_types = join(
41
-			',',
42
-			array_map(
43
-				function ( $schema_type ) {
44
-					return "'" . esc_sql( strtolower( $schema_type ) ) . "'";
45
-				},
46
-				$schema_types
47
-			)
48
-		);
49
-
50
-		return $wpdb->get_results(
51
-			$wpdb->prepare(
52
-				"SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm
18
+    private static $instance = null;
19
+
20
+    /**
21
+     * The singleton instance.
22
+     *
23
+     * @return Entity_Query_Service
24
+     */
25
+    public static function get_instance() {
26
+        if ( ! isset( self::$instance ) ) {
27
+            self::$instance = new self();
28
+        }
29
+
30
+        return self::$instance;
31
+    }
32
+
33
+
34
+    private function query_posts( $query, $schema_types, $limit ) {
35
+        return wl_entity_get_by_title( $query, true, true, $limit, $schema_types );
36
+    }
37
+
38
+    private function query_terms( $query, $schema_types, $limit ) {
39
+        global $wpdb;
40
+        $schema_types = join(
41
+            ',',
42
+            array_map(
43
+                function ( $schema_type ) {
44
+                    return "'" . esc_sql( strtolower( $schema_type ) ) . "'";
45
+                },
46
+                $schema_types
47
+            )
48
+        );
49
+
50
+        return $wpdb->get_results(
51
+            $wpdb->prepare(
52
+                "SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm
53 53
     ON t.term_id=tm.term_id WHERE t.name LIKE %s AND (tm.meta_key = %s AND tm.meta_value IN ($schema_types)) LIMIT %d",
54
-				'%' . $wpdb->esc_like( $query ) . '%',
55
-				\Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
56
-				$limit
57
-			)
58
-		);
59
-
60
-	}
61
-
62
-	/**
63
-	 * @param $results
64
-	 * @param $object_type
65
-	 *
66
-	 * @return  Entity[]
67
-	 */
68
-	private function transform_posts( $results ) {
69
-		return array_map(
70
-			function ( $item ) {
71
-				return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) );
72
-			},
73
-			$results
74
-		);
75
-	}
76
-
77
-	private function transform_terms( $results ) {
78
-		return array_map(
79
-			function ( $item ) {
80
-				return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
81
-			},
82
-			$results
83
-		);
84
-	}
85
-
86
-
87
-	/**
88
-	 * @param $query
89
-	 * @param $schema_types
90
-	 * @param $limit
91
-	 *
92
-	 * @return Entity[]
93
-	 */
94
-	public function query( $query, $schema_types = array(), $limit = 10 ) {
95
-
96
-		$results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) );
97
-
98
-		if ( count( $results ) >= $limit ) {
99
-			return $results;
100
-		}
101
-
102
-		$results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) );
103
-
104
-		return $results;
105
-
106
-	}
107
-
108
-	public function get( $linked_entities ) {
109
-		return array_filter( array_map(
110
-			function ( $item ) {
111
-				$parts      = explode( '_', $item );
112
-				$type       = Object_Type_Enum::from_string( $parts[0] );
113
-				$identifier = $parts[1];
114
-
115
-				if ( $type === Object_Type_Enum::POST ) {
116
-					return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) );
117
-				} elseif ( $type === Object_Type_Enum::TERM ) {
118
-					return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) );
119
-				}
120
-
121
-				//return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
122
-			},
123
-			$linked_entities
124
-		) );
125
-
126
-	}
54
+                '%' . $wpdb->esc_like( $query ) . '%',
55
+                \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
56
+                $limit
57
+            )
58
+        );
59
+
60
+    }
61
+
62
+    /**
63
+     * @param $results
64
+     * @param $object_type
65
+     *
66
+     * @return  Entity[]
67
+     */
68
+    private function transform_posts( $results ) {
69
+        return array_map(
70
+            function ( $item ) {
71
+                return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) );
72
+            },
73
+            $results
74
+        );
75
+    }
76
+
77
+    private function transform_terms( $results ) {
78
+        return array_map(
79
+            function ( $item ) {
80
+                return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
81
+            },
82
+            $results
83
+        );
84
+    }
85
+
86
+
87
+    /**
88
+     * @param $query
89
+     * @param $schema_types
90
+     * @param $limit
91
+     *
92
+     * @return Entity[]
93
+     */
94
+    public function query( $query, $schema_types = array(), $limit = 10 ) {
95
+
96
+        $results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) );
97
+
98
+        if ( count( $results ) >= $limit ) {
99
+            return $results;
100
+        }
101
+
102
+        $results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) );
103
+
104
+        return $results;
105
+
106
+    }
107
+
108
+    public function get( $linked_entities ) {
109
+        return array_filter( array_map(
110
+            function ( $item ) {
111
+                $parts      = explode( '_', $item );
112
+                $type       = Object_Type_Enum::from_string( $parts[0] );
113
+                $identifier = $parts[1];
114
+
115
+                if ( $type === Object_Type_Enum::POST ) {
116
+                    return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) );
117
+                } elseif ( $type === Object_Type_Enum::TERM ) {
118
+                    return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) );
119
+                }
120
+
121
+                //return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
122
+            },
123
+            $linked_entities
124
+        ) );
125
+
126
+    }
127 127
 
128 128
 
129 129
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @return Entity_Query_Service
24 24
 	 */
25 25
 	public static function get_instance() {
26
-		if ( ! isset( self::$instance ) ) {
26
+		if ( ! isset(self::$instance)) {
27 27
 			self::$instance = new self();
28 28
 		}
29 29
 
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 
33 33
 
34
-	private function query_posts( $query, $schema_types, $limit ) {
35
-		return wl_entity_get_by_title( $query, true, true, $limit, $schema_types );
34
+	private function query_posts($query, $schema_types, $limit) {
35
+		return wl_entity_get_by_title($query, true, true, $limit, $schema_types);
36 36
 	}
37 37
 
38
-	private function query_terms( $query, $schema_types, $limit ) {
38
+	private function query_terms($query, $schema_types, $limit) {
39 39
 		global $wpdb;
40 40
 		$schema_types = join(
41 41
 			',',
42 42
 			array_map(
43
-				function ( $schema_type ) {
44
-					return "'" . esc_sql( strtolower( $schema_type ) ) . "'";
43
+				function($schema_type) {
44
+					return "'".esc_sql(strtolower($schema_type))."'";
45 45
 				},
46 46
 				$schema_types
47 47
 			)
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			$wpdb->prepare(
52 52
 				"SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm
53 53
     ON t.term_id=tm.term_id WHERE t.name LIKE %s AND (tm.meta_key = %s AND tm.meta_value IN ($schema_types)) LIMIT %d",
54
-				'%' . $wpdb->esc_like( $query ) . '%',
54
+				'%'.$wpdb->esc_like($query).'%',
55 55
 				\Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
56 56
 				$limit
57 57
 			)
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return  Entity[]
67 67
 	 */
68
-	private function transform_posts( $results ) {
68
+	private function transform_posts($results) {
69 69
 		return array_map(
70
-			function ( $item ) {
71
-				return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) );
70
+			function($item) {
71
+				return new Entity($item->schema_type_name, new Wordpress_Content(get_post($item->id)));
72 72
 			},
73 73
 			$results
74 74
 		);
75 75
 	}
76 76
 
77
-	private function transform_terms( $results ) {
77
+	private function transform_terms($results) {
78 78
 		return array_map(
79
-			function ( $item ) {
80
-				return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
79
+			function($item) {
80
+				return new Entity($item->schema_type_name, new Wordpress_Content(get_term($item->id)));
81 81
 			},
82 82
 			$results
83 83
 		);
@@ -91,37 +91,37 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return Entity[]
93 93
 	 */
94
-	public function query( $query, $schema_types = array(), $limit = 10 ) {
94
+	public function query($query, $schema_types = array(), $limit = 10) {
95 95
 
96
-		$results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) );
96
+		$results = $this->transform_posts($this->query_posts($query, $schema_types, $limit));
97 97
 
98
-		if ( count( $results ) >= $limit ) {
98
+		if (count($results) >= $limit) {
99 99
 			return $results;
100 100
 		}
101 101
 
102
-		$results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) );
102
+		$results = array_merge($results, $this->transform_terms($this->query_terms($query, $schema_types, $limit)));
103 103
 
104 104
 		return $results;
105 105
 
106 106
 	}
107 107
 
108
-	public function get( $linked_entities ) {
109
-		return array_filter( array_map(
110
-			function ( $item ) {
111
-				$parts      = explode( '_', $item );
112
-				$type       = Object_Type_Enum::from_string( $parts[0] );
108
+	public function get($linked_entities) {
109
+		return array_filter(array_map(
110
+			function($item) {
111
+				$parts      = explode('_', $item);
112
+				$type       = Object_Type_Enum::from_string($parts[0]);
113 113
 				$identifier = $parts[1];
114 114
 
115
-				if ( $type === Object_Type_Enum::POST ) {
116
-					return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) );
117
-				} elseif ( $type === Object_Type_Enum::TERM ) {
118
-					return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) );
115
+				if ($type === Object_Type_Enum::POST) {
116
+					return new Entity('Thing', new Wordpress_Content(get_post($identifier)));
117
+				} elseif ($type === Object_Type_Enum::TERM) {
118
+					return new Entity('Thing', new Wordpress_Content(get_term($identifier)));
119 119
 				}
120 120
 
121 121
 				//return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) );
122 122
 			},
123 123
 			$linked_entities
124
-		) );
124
+		));
125 125
 
126 126
 	}
127 127
 
Please login to merge, or discard this patch.
src/wordlift/entity/query/class-entity.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,42 +7,42 @@
 block discarded – undo
7 7
 
8 8
 class Entity {
9 9
 
10
-	private $schema_type;
11
-	/**
12
-	 * @var Wordpress_Content
13
-	 */
14
-	private $content;
15
-
16
-
17
-	/**
18
-	 * @param $schema_type
19
-	 * @param $content Wordpress_Content
20
-	 */
21
-	public function __construct( $schema_type, $content ) {
22
-		$this->schema_type = $schema_type;
23
-		$this->content     = $content;
24
-	}
25
-
26
-	/**
27
-	 * @return Wordpress_Content
28
-	 */
29
-	public function get_content() {
30
-		return $this->content;
31
-	}
32
-
33
-	public function get_schema_type() {
34
-		return $this->schema_type;
35
-	}
36
-
37
-	public function get_title() {
38
-		if ( Object_Type_Enum::POST === $this->content->get_object_type_enum() ) {
39
-			return $this->content->get_bag()->post_title;
40
-		}
41
-		if ( Object_Type_Enum::TERM === $this->content->get_object_type_enum() ) {
42
-			return $this->content->get_bag()->name;
43
-		}
44
-		return '';
45
-	}
10
+    private $schema_type;
11
+    /**
12
+     * @var Wordpress_Content
13
+     */
14
+    private $content;
15
+
16
+
17
+    /**
18
+     * @param $schema_type
19
+     * @param $content Wordpress_Content
20
+     */
21
+    public function __construct( $schema_type, $content ) {
22
+        $this->schema_type = $schema_type;
23
+        $this->content     = $content;
24
+    }
25
+
26
+    /**
27
+     * @return Wordpress_Content
28
+     */
29
+    public function get_content() {
30
+        return $this->content;
31
+    }
32
+
33
+    public function get_schema_type() {
34
+        return $this->schema_type;
35
+    }
36
+
37
+    public function get_title() {
38
+        if ( Object_Type_Enum::POST === $this->content->get_object_type_enum() ) {
39
+            return $this->content->get_bag()->post_title;
40
+        }
41
+        if ( Object_Type_Enum::TERM === $this->content->get_object_type_enum() ) {
42
+            return $this->content->get_bag()->name;
43
+        }
44
+        return '';
45
+    }
46 46
 
47 47
 
48 48
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param $schema_type
19 19
 	 * @param $content Wordpress_Content
20 20
 	 */
21
-	public function __construct( $schema_type, $content ) {
21
+	public function __construct($schema_type, $content) {
22 22
 		$this->schema_type = $schema_type;
23 23
 		$this->content     = $content;
24 24
 	}
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 	}
36 36
 
37 37
 	public function get_title() {
38
-		if ( Object_Type_Enum::POST === $this->content->get_object_type_enum() ) {
38
+		if (Object_Type_Enum::POST === $this->content->get_object_type_enum()) {
39 39
 			return $this->content->get_bag()->post_title;
40 40
 		}
41
-		if ( Object_Type_Enum::TERM === $this->content->get_object_type_enum() ) {
41
+		if (Object_Type_Enum::TERM === $this->content->get_object_type_enum()) {
42 42
 			return $this->content->get_bag()->name;
43 43
 		}
44 44
 		return '';
Please login to merge, or discard this patch.
src/wordlift.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -32,26 +32,26 @@  discard block
 block discarded – undo
32 32
 use Wordlift\Post\Post_Adapter;
33 33
 
34 34
 // @TODO: remove this before merging the code.
35
-add_filter('wl_feature__enable__pods-integration', '__return_true' );
35
+add_filter('wl_feature__enable__pods-integration', '__return_true');
36 36
 
37 37
 
38 38
 // If this file is called directly, abort.
39
-if ( ! defined( 'WPINC' ) ) {
39
+if ( ! defined('WPINC')) {
40 40
 	die;
41 41
 }
42 42
 
43
-define( 'WORDLIFT_VERSION', '3.38.0' );
43
+define('WORDLIFT_VERSION', '3.38.0');
44 44
 
45 45
 /**
46 46
  * Filter to disable WLP on any request, defaults to true.
47 47
  *
48 48
  * @since 3.33.6
49 49
  */
50
-if ( ! apply_filters( 'wl_is_enabled', true ) ) {
50
+if ( ! apply_filters('wl_is_enabled', true)) {
51 51
 	return;
52 52
 }
53 53
 
54
-require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
54
+require_once plugin_dir_path(__FILE__).'vendor/autoload.php';
55 55
 
56 56
 /*
57 57
 	 * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
 wordlift_plugin_autoload_register();
62 62
 
63 63
 // Include WordLift constants.
64
-require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php';
64
+require_once plugin_dir_path(__FILE__).'wordlift-constants.php';
65 65
 
66 66
 // Load modules.
67
-require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php';
67
+require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php';
68 68
 
69
-require_once plugin_dir_path( __FILE__ ) . 'deprecations.php';
69
+require_once plugin_dir_path(__FILE__).'deprecations.php';
70 70
 
71 71
 // Load early to enable/disable features.
72
-require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php';
72
+require_once plugin_dir_path(__FILE__).'wordlift/features/index.php';
73 73
 
74 74
 /**
75 75
  * The code that runs during plugin activation.
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function activate_wordlift() {
79 79
 
80
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
80
+	$log = Wordlift_Log_Service::get_logger('activate_wordlift');
81 81
 
82
-	$log->info( 'Activating WordLift...' );
82
+	$log->info('Activating WordLift...');
83 83
 
84
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
84
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
85 85
 	Wordlift_Activator::activate();
86 86
 
87 87
 	/**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function deactivate_wordlift() {
110 110
 
111
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
111
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
112 112
 	Wordlift_Deactivator::deactivate();
113 113
 	Wordlift_Http_Api::deactivate();
114 114
 	Ttl_Cache_Cleaner::deactivate();
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 
127 127
 }
128 128
 
129
-register_activation_hook( __FILE__, 'activate_wordlift' );
130
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
129
+register_activation_hook(__FILE__, 'activate_wordlift');
130
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
131 131
 
132 132
 /**
133 133
  * The core plugin class that is used to define internationalization,
134 134
  * admin-specific hooks, and public-facing site hooks.
135 135
  */
136
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
136
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
137 137
 
138 138
 /**
139 139
  * Begins execution of the plugin.
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	 * @return bool
154 154
 	 * @since 3.27.6
155 155
 	 */
156
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
157
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
158
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
159
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
156
+	if (apply_filters('wl_feature__enable__widgets', true)) {
157
+		add_action('widgets_init', 'wl_register_chord_widget');
158
+		add_action('widgets_init', 'wl_register_geo_widget');
159
+		add_action('widgets_init', 'wl_register_timeline_widget');
160 160
 	}
161
-	add_filter( 'widget_text', 'do_shortcode' );
161
+	add_filter('widget_text', 'do_shortcode');
162 162
 
163 163
 	/**
164 164
 	 * Filter: wl_feature__enable__analysis
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 * @return bool
169 169
 	 * @since 3.27.6
170 170
 	 */
171
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
172
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
171
+	if (apply_filters('wl_feature__enable__analysis', true)) {
172
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action');
173 173
 	} else {
174
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
174
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action');
175 175
 	}
176 176
 
177 177
 	$plugin = new Wordlift();
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
 	add_action(
190 190
 		'plugins_loaded',
191
-		function () {
191
+		function() {
192 192
 			// All features from registry should be initialized here.
193 193
 			$features_registry = Features_Registry::get_instance();
194 194
 			$features_registry->initialize_all_features();
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 	add_action(
200 200
 		'plugins_loaded',
201 201
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
202
-		function () use ( $plugin ) {
202
+		function() use ($plugin) {
203 203
 
204 204
 			new Wordlift_Products_Navigator_Shortcode_REST();
205 205
 
206 206
 			// Register the Dataset module, requires `$api_service`.
207
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php';
208
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php';
207
+			require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php';
208
+			require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php';
209 209
 
210 210
 			/*
211 211
 			* Require the Entity annotation cleanup module.
212 212
 			*
213 213
 			* @since 3.34.6
214 214
 			*/
215
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php';
215
+			require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php';
216 216
 
217 217
 			/*
218 218
 			* Import LOD entities.
219 219
 			*
220 220
 			* @since 3.35.0
221 221
 			*/
222
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php';
222
+			require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php';
223 223
 
224 224
 		}
225 225
 	);
@@ -237,23 +237,23 @@  discard block
 block discarded – undo
237 237
 function wordlift_plugin_autoload_register() {
238 238
 
239 239
 	spl_autoload_register(
240
-		function ( $class_name ) {
240
+		function($class_name) {
241 241
 
242 242
 			// Bail out if these are not our classes.
243
-			if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
243
+			if (0 !== strpos($class_name, 'Wordlift\\')) {
244 244
 				return false;
245 245
 			}
246 246
 
247
-			$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
247
+			$class_name_lc = strtolower(str_replace('_', '-', $class_name));
248 248
 
249
-			preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
249
+			preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches);
250 250
 
251
-			$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
252
-			$file = 'class-' . $matches[2] . '.php';
251
+			$path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]);
252
+			$file = 'class-'.$matches[2].'.php';
253 253
 
254
-			$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
254
+			$full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file;
255 255
 
256
-			if ( ! file_exists( $full_path ) ) {
256
+			if ( ! file_exists($full_path)) {
257 257
 				return false;
258 258
 			}
259 259
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 
266 266
 }
267 267
 
268
-function wl_block_categories( $categories ) {
268
+function wl_block_categories($categories) {
269 269
 	return array_merge(
270 270
 		$categories,
271 271
 		array(
272 272
 			array(
273 273
 				'slug'  => 'wordlift',
274
-				'title' => __( 'WordLift', 'wordlift' ),
274
+				'title' => __('WordLift', 'wordlift'),
275 275
 			),
276 276
 		)
277 277
 	);
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
  * This function is created temporarily to handle the legacy library,
282 282
  * this has to be removed when removing the legacy fields from the ui.
283 283
  */
284
-function wl_enqueue_leaflet( $in_footer = false ) {
284
+function wl_enqueue_leaflet($in_footer = false) {
285 285
 	// Leaflet.
286
-	wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' );
287
-	wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer );
286
+	wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0');
287
+	wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer);
288 288
 }
289 289
 
290
-add_filter( 'block_categories', 'wl_block_categories', 10 );
290
+add_filter('block_categories', 'wl_block_categories', 10);
291 291
 
292 292
 // Temporary fix for a typo in WooCommerce Extension.
293 293
 add_filter(
294 294
 	'wl_feature__enable__dataset',
295
-	function ( $value ) {
296
-		return apply_filters( 'wl_features__enable__dataset', $value );
295
+	function($value) {
296
+		return apply_filters('wl_features__enable__dataset', $value);
297 297
 	}
298 298
 );
299 299
 
300
-require_once __DIR__ . '/modules/food-kg/load.php';
301
-require_once __DIR__ . '/modules/acf4so/load.php';
302
-require_once __DIR__ . '/modules/pods/load.php';
300
+require_once __DIR__.'/modules/food-kg/load.php';
301
+require_once __DIR__.'/modules/acf4so/load.php';
302
+require_once __DIR__.'/modules/pods/load.php';
Please login to merge, or discard this patch.