Completed
Push — develop ( e8678c...83daff )
by David
05:40
created
src/includes/class-wordlift-schema-service.php 1 patch
Indentation   +578 added lines, -578 removed lines patch added patch discarded remove patch
@@ -7,600 +7,600 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Schema_Service {
9 9
 
10
-	/**
11
-	 * The 'author' field name.
12
-	 *
13
-	 * @since 3.1.0
14
-	 */
15
-	const FIELD_AUTHOR = 'wl_author';
16
-
17
-	/**
18
-	 * The 'same as' field name.
19
-	 *
20
-	 * @since 3.1.0
21
-	 */
22
-	const FIELD_SAME_AS = 'entity_same_as';
23
-
24
-	/**
25
-	 * The 'date start' field name.
26
-	 *
27
-	 * @since 3.1.0
28
-	 */
29
-	const FIELD_DATE_START = 'wl_cal_date_start';
30
-
31
-	/**
32
-	 * The 'date end' field name.
33
-	 *
34
-	 * @since 3.1.0
35
-	 */
36
-	const FIELD_DATE_END = 'wl_cal_date_end';
37
-
38
-	/**
39
-	 * The 'location' field name.
40
-	 *
41
-	 * @since 3.1.0
42
-	 */
43
-	const FIELD_LOCATION = 'wl_location';
44
-
45
-	/**
46
-	 * The 'founder' field name.
47
-	 *
48
-	 * @since 3.1.0
49
-	 */
50
-	const FIELD_FOUNDER = 'wl_founder';
51
-
52
-	/**
53
-	 * The 'knows' field name.
54
-	 *
55
-	 * @since 3.1.0
56
-	 */
57
-	const FIELD_KNOWS = 'wl_knows';
58
-
59
-	/**
60
-	 * The 'birth date' field name.
61
-	 *
62
-	 * @since 3.1.0
63
-	 */
64
-	const FIELD_BIRTH_DATE = 'wl_birth_date';
65
-
66
-	/**
67
-	 * The 'birth place' field name.
68
-	 *
69
-	 * @since 3.1.0
70
-	 */
71
-	const FIELD_BIRTH_PLACE = 'wl_birth_place';
72
-
73
-	/**
74
-	 * The 'latitude' field name.
75
-	 *
76
-	 * @since 3.1.0
77
-	 */
78
-	const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
79
-
80
-	/**
81
-	 * The 'longitude' field name.
82
-	 *
83
-	 * @since 3.1.0
84
-	 */
85
-	const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
86
-
87
-	/**
88
-	 * The 'address' field name.
89
-	 *
90
-	 * @since 3.1.0
91
-	 */
92
-	const FIELD_ADDRESS = 'wl_address';
93
-
94
-	/**
95
-	 * The 'entity type' field name.
96
-	 *
97
-	 * @since 3.1.0
98
-	 */
99
-	const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
10
+    /**
11
+     * The 'author' field name.
12
+     *
13
+     * @since 3.1.0
14
+     */
15
+    const FIELD_AUTHOR = 'wl_author';
16
+
17
+    /**
18
+     * The 'same as' field name.
19
+     *
20
+     * @since 3.1.0
21
+     */
22
+    const FIELD_SAME_AS = 'entity_same_as';
23
+
24
+    /**
25
+     * The 'date start' field name.
26
+     *
27
+     * @since 3.1.0
28
+     */
29
+    const FIELD_DATE_START = 'wl_cal_date_start';
30
+
31
+    /**
32
+     * The 'date end' field name.
33
+     *
34
+     * @since 3.1.0
35
+     */
36
+    const FIELD_DATE_END = 'wl_cal_date_end';
37
+
38
+    /**
39
+     * The 'location' field name.
40
+     *
41
+     * @since 3.1.0
42
+     */
43
+    const FIELD_LOCATION = 'wl_location';
44
+
45
+    /**
46
+     * The 'founder' field name.
47
+     *
48
+     * @since 3.1.0
49
+     */
50
+    const FIELD_FOUNDER = 'wl_founder';
51
+
52
+    /**
53
+     * The 'knows' field name.
54
+     *
55
+     * @since 3.1.0
56
+     */
57
+    const FIELD_KNOWS = 'wl_knows';
58
+
59
+    /**
60
+     * The 'birth date' field name.
61
+     *
62
+     * @since 3.1.0
63
+     */
64
+    const FIELD_BIRTH_DATE = 'wl_birth_date';
65
+
66
+    /**
67
+     * The 'birth place' field name.
68
+     *
69
+     * @since 3.1.0
70
+     */
71
+    const FIELD_BIRTH_PLACE = 'wl_birth_place';
72
+
73
+    /**
74
+     * The 'latitude' field name.
75
+     *
76
+     * @since 3.1.0
77
+     */
78
+    const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
79
+
80
+    /**
81
+     * The 'longitude' field name.
82
+     *
83
+     * @since 3.1.0
84
+     */
85
+    const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
86
+
87
+    /**
88
+     * The 'address' field name.
89
+     *
90
+     * @since 3.1.0
91
+     */
92
+    const FIELD_ADDRESS = 'wl_address';
93
+
94
+    /**
95
+     * The 'entity type' field name.
96
+     *
97
+     * @since 3.1.0
98
+     */
99
+    const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
100 100
 	
101
-	/**
102
-	 * The 'email' field name.
103
-	 *
104
-	 * @since 3.2.0
105
-	 */
106
-	const FIELD_EMAIL = 'wl_email';
101
+    /**
102
+     * The 'email' field name.
103
+     *
104
+     * @since 3.2.0
105
+     */
106
+    const FIELD_EMAIL = 'wl_email';
107 107
 	
108
-	/**
109
-	 * The 'affiliation' field name.
110
-	 *
111
-	 * @since 3.2.0
112
-	 */
113
-	const FIELD_AFFILIATION = 'wl_affiliation';
114
-
115
-	/**
116
-	 * The 'URI' data type name.
117
-	 *
118
-	 * @since 3.1.0
119
-	 */
120
-	const DATA_TYPE_URI = 'uri';
121
-
122
-	/**
123
-	 * The 'date' data type name.
124
-	 *
125
-	 * @since 3.1.0
126
-	 */
127
-	const DATA_TYPE_DATE = 'date';
128
-
129
-	/**
130
-	 * The 'double' data type name.
131
-	 *
132
-	 * @since 3.1.0
133
-	 */
134
-	const DATA_TYPE_DOUBLE = 'double';
135
-
136
-	/**
137
-	 * The 'string' data type name.
138
-	 *
139
-	 * @since 3.1.0
140
-	 */
141
-	const DATA_TYPE_STRING = 'string';
142
-
143
-	/**
144
-	 * The 'integer' data type name.
145
-	 *
146
-	 * @since 3.1.0
147
-	 */
148
-	const DATA_TYPE_INTEGER = 'int';
149
-
150
-	/**
151
-	 * The 'boolean' data type name.
152
-	 *
153
-	 * @since 3.1.0
154
-	 */
155
-	const DATA_TYPE_BOOLEAN = 'bool';
156
-
157
-	/**
158
-	 * The schema.org Event type URI.
159
-	 *
160
-	 * @since 3.1.0
161
-	 */
162
-	const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
163
-
164
-	/**
165
-	 * The Schema service singleton instance.
166
-	 *
167
-	 * @since 3.1.0
168
-	 * @access private
169
-	 * @var \Wordlift_Schema_Service $instance The Schema service singleton instance.
170
-	 */
171
-	private static $instance;
172
-
173
-	/**
174
-	 * WordLift's schema.
175
-	 *
176
-	 * @since 3.1.0
177
-	 * @access private
178
-	 * @var array $schema WordLift's schema.
179
-	 */
180
-	private $schema;
181
-
182
-	/**
183
-	 * The Log service.
184
-	 *
185
-	 * @since 3.1.0
186
-	 * @access private
187
-	 * @var \Wordlift_Log_Service $log_service The Log service.
188
-	 */
189
-	private $log_service;
190
-
191
-	/**
192
-	 * Wordlift_Schema_Service constructor.
193
-	 *
194
-	 * @since 3.1.0
195
-	 */
196
-	public function __construct() {
197
-
198
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
199
-
200
-		// Create a singleton instance of the Schema service, useful to provide static functions to global functions.
201
-		self::$instance = $this;
202
-
203
-		// Set the taxonomy data.
204
-		// Note: parent types must be defined before child types.
205
-		$this->schema = array(
206
-			'thing'         => $this->get_thing_schema(),
207
-			'creative-work' => $this->get_creative_work_schema(),
208
-			'event'         => $this->get_event_schema(),
209
-			'organization'  => $this->get_organization_schema(),
210
-			'person'        => $this->get_person_schema(),
211
-			'place'         => $this->get_place_schema(),
212
-			'localbusiness' => $this->get_local_business_schema()
213
-		);
214
-
215
-	}
216
-
217
-	/**
218
-	 * Get a reference to the Schema service.
219
-	 *
220
-	 * @since 3.1.0
221
-	 *
222
-	 * @return Wordlift_Schema_Service A reference to the Schema service.
223
-	 */
224
-	public static function get_instance() {
225
-
226
-		return self::$instance;
227
-	}
228
-
229
-	/**
230
-	 * Get the WordLift's schema.
231
-	 *
232
-	 * @param string $name The schema name.
233
-	 *
234
-	 * @return array|null An array with the schema configuration or NULL if the schema is not found.
235
-	 *
236
-	 * @since 3.1.0
237
-	 */
238
-	public function get_schema( $name ) {
239
-
240
-		// $this->log_service->trace( "Get schema [ name :: $name ]" );
241
-
242
-		// Check if the schema exists and, if not, return NULL.
243
-		if ( ! isset( $this->schema[ $name ] ) ) {
244
-			return null;
245
-		}
246
-
247
-		// Return the requested schema.
248
-		return $this->schema[ $name ];
249
-	}
250
-
251
-	/**
252
-	 * Get the 'thing' schema.
253
-	 *
254
-	 * @return array An array with the schema configuration.
255
-	 *
256
-	 * @since 3.1.0
257
-	 */
258
-	private function get_thing_schema() {
259
-
260
-		return array(
261
-			'css_class'          => 'wl-thing',
262
-			'uri'                => 'http://schema.org/Thing',
263
-			'same_as'            => array( '*' ), // set as default.
264
-			'custom_fields'      => array(
265
-				self::FIELD_SAME_AS => array(
266
-					'predicate'   => 'http://schema.org/sameAs',
267
-					'type'        => self::DATA_TYPE_URI,
268
-					'export_type' => 'http://schema.org/Thing',
269
-					'constraints' => array(
270
-						'cardinality' => INF
271
-					),
272
-					'input_field' => 'sameas'   // we need a custom metabox
273
-				)
274
-			),
275
-			// {{sameAs}} not present in the microdata template,
276
-			// because it is treated separately in *wl_content_embed_item_microdata*
277
-			'microdata_template' => '',
278
-			'templates'          => array(
279
-				'subtitle' => '{{id}}'
280
-			)
281
-		);
282
-
283
-	}
284
-
285
-	/**
286
-	 * Get the 'creative work' schema.
287
-	 *
288
-	 * @return array An array with the schema configuration.
289
-	 *
290
-	 * @since 3.1.0
291
-	 */
292
-	private function get_creative_work_schema() {
293
-
294
-		$schema = array(
295
-			'label'              => 'CreativeWork',
296
-			'description'        => 'A creative work (or a Music Album).',
297
-			'parents'            => array( 'thing' ), // give term slug as parent
298
-			'css_class'          => 'wl-creative-work',
299
-			'uri'                => 'http://schema.org/CreativeWork',
300
-			'same_as'            => array(
301
-				'http://schema.org/MusicAlbum',
302
-				'http://schema.org/Product'
303
-			),
304
-			'custom_fields'      => array(
305
-				self::FIELD_AUTHOR => array(
306
-					'predicate'   => 'http://schema.org/author',
307
-					'type'        => self::DATA_TYPE_URI,
308
-					'export_type' => 'http://schema.org/Person',
309
-					'constraints' => array(
310
-						'uri_type'    => array( 'Person', 'Organization' ),
311
-						'cardinality' => INF
312
-					)
313
-				),
314
-			),
315
-			'microdata_template' => '{{author}}',
316
-			'templates'          => array(
317
-				'subtitle' => '{{id}}'
318
-			)
319
-		);
320
-
321
-		// Merge the custom fields with those provided by the thing schema.
322
-		$thing_schema            = $this->get_thing_schema();
323
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
324
-
325
-		return $schema;
326
-	}
327
-
328
-	/**
329
-	 * Get the 'event' schema.
330
-	 *
331
-	 * @return array An array with the schema configuration.
332
-	 *
333
-	 * @since 3.1.0
334
-	 */
335
-	private function get_event_schema() {
336
-
337
-		$schema = array(
338
-			'label'              => 'Event',
339
-			'description'        => 'An event . ',
340
-			'parents'            => array( 'thing' ),
341
-			'css_class'          => 'wl-event',
342
-			'uri'                => self::SCHEMA_EVENT_TYPE,
343
-			'same_as'            => array( 'http://dbpedia.org/ontology/Event' ),
344
-			'custom_fields'      => array(
345
-				self::FIELD_DATE_START => array(
346
-					'predicate'   => 'http://schema.org/startDate',
347
-					'type'        => self::DATA_TYPE_DATE,
348
-					'export_type' => 'xsd:datetime',
349
-					'constraints' => ''
350
-				),
351
-				self::FIELD_DATE_END   => array(
352
-					'predicate'   => 'http://schema.org/endDate',
353
-					'type'        => self::DATA_TYPE_DATE,
354
-					'export_type' => 'xsd:datetime',
355
-					'constraints' => ''
356
-				),
357
-				self::FIELD_LOCATION   => array(
358
-					'predicate'   => 'http://schema.org/location',
359
-					'type'        => self::DATA_TYPE_URI,
360
-					'export_type' => 'http://schema.org/PostalAddress',
361
-					'constraints' => array(
362
-						'uri_type'    => 'Place',
363
-						'cardinality' => INF
364
-					)
365
-				)
366
-			),
367
-			'microdata_template' =>
368
-				'{{startDate}}
108
+    /**
109
+     * The 'affiliation' field name.
110
+     *
111
+     * @since 3.2.0
112
+     */
113
+    const FIELD_AFFILIATION = 'wl_affiliation';
114
+
115
+    /**
116
+     * The 'URI' data type name.
117
+     *
118
+     * @since 3.1.0
119
+     */
120
+    const DATA_TYPE_URI = 'uri';
121
+
122
+    /**
123
+     * The 'date' data type name.
124
+     *
125
+     * @since 3.1.0
126
+     */
127
+    const DATA_TYPE_DATE = 'date';
128
+
129
+    /**
130
+     * The 'double' data type name.
131
+     *
132
+     * @since 3.1.0
133
+     */
134
+    const DATA_TYPE_DOUBLE = 'double';
135
+
136
+    /**
137
+     * The 'string' data type name.
138
+     *
139
+     * @since 3.1.0
140
+     */
141
+    const DATA_TYPE_STRING = 'string';
142
+
143
+    /**
144
+     * The 'integer' data type name.
145
+     *
146
+     * @since 3.1.0
147
+     */
148
+    const DATA_TYPE_INTEGER = 'int';
149
+
150
+    /**
151
+     * The 'boolean' data type name.
152
+     *
153
+     * @since 3.1.0
154
+     */
155
+    const DATA_TYPE_BOOLEAN = 'bool';
156
+
157
+    /**
158
+     * The schema.org Event type URI.
159
+     *
160
+     * @since 3.1.0
161
+     */
162
+    const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
163
+
164
+    /**
165
+     * The Schema service singleton instance.
166
+     *
167
+     * @since 3.1.0
168
+     * @access private
169
+     * @var \Wordlift_Schema_Service $instance The Schema service singleton instance.
170
+     */
171
+    private static $instance;
172
+
173
+    /**
174
+     * WordLift's schema.
175
+     *
176
+     * @since 3.1.0
177
+     * @access private
178
+     * @var array $schema WordLift's schema.
179
+     */
180
+    private $schema;
181
+
182
+    /**
183
+     * The Log service.
184
+     *
185
+     * @since 3.1.0
186
+     * @access private
187
+     * @var \Wordlift_Log_Service $log_service The Log service.
188
+     */
189
+    private $log_service;
190
+
191
+    /**
192
+     * Wordlift_Schema_Service constructor.
193
+     *
194
+     * @since 3.1.0
195
+     */
196
+    public function __construct() {
197
+
198
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
199
+
200
+        // Create a singleton instance of the Schema service, useful to provide static functions to global functions.
201
+        self::$instance = $this;
202
+
203
+        // Set the taxonomy data.
204
+        // Note: parent types must be defined before child types.
205
+        $this->schema = array(
206
+            'thing'         => $this->get_thing_schema(),
207
+            'creative-work' => $this->get_creative_work_schema(),
208
+            'event'         => $this->get_event_schema(),
209
+            'organization'  => $this->get_organization_schema(),
210
+            'person'        => $this->get_person_schema(),
211
+            'place'         => $this->get_place_schema(),
212
+            'localbusiness' => $this->get_local_business_schema()
213
+        );
214
+
215
+    }
216
+
217
+    /**
218
+     * Get a reference to the Schema service.
219
+     *
220
+     * @since 3.1.0
221
+     *
222
+     * @return Wordlift_Schema_Service A reference to the Schema service.
223
+     */
224
+    public static function get_instance() {
225
+
226
+        return self::$instance;
227
+    }
228
+
229
+    /**
230
+     * Get the WordLift's schema.
231
+     *
232
+     * @param string $name The schema name.
233
+     *
234
+     * @return array|null An array with the schema configuration or NULL if the schema is not found.
235
+     *
236
+     * @since 3.1.0
237
+     */
238
+    public function get_schema( $name ) {
239
+
240
+        // $this->log_service->trace( "Get schema [ name :: $name ]" );
241
+
242
+        // Check if the schema exists and, if not, return NULL.
243
+        if ( ! isset( $this->schema[ $name ] ) ) {
244
+            return null;
245
+        }
246
+
247
+        // Return the requested schema.
248
+        return $this->schema[ $name ];
249
+    }
250
+
251
+    /**
252
+     * Get the 'thing' schema.
253
+     *
254
+     * @return array An array with the schema configuration.
255
+     *
256
+     * @since 3.1.0
257
+     */
258
+    private function get_thing_schema() {
259
+
260
+        return array(
261
+            'css_class'          => 'wl-thing',
262
+            'uri'                => 'http://schema.org/Thing',
263
+            'same_as'            => array( '*' ), // set as default.
264
+            'custom_fields'      => array(
265
+                self::FIELD_SAME_AS => array(
266
+                    'predicate'   => 'http://schema.org/sameAs',
267
+                    'type'        => self::DATA_TYPE_URI,
268
+                    'export_type' => 'http://schema.org/Thing',
269
+                    'constraints' => array(
270
+                        'cardinality' => INF
271
+                    ),
272
+                    'input_field' => 'sameas'   // we need a custom metabox
273
+                )
274
+            ),
275
+            // {{sameAs}} not present in the microdata template,
276
+            // because it is treated separately in *wl_content_embed_item_microdata*
277
+            'microdata_template' => '',
278
+            'templates'          => array(
279
+                'subtitle' => '{{id}}'
280
+            )
281
+        );
282
+
283
+    }
284
+
285
+    /**
286
+     * Get the 'creative work' schema.
287
+     *
288
+     * @return array An array with the schema configuration.
289
+     *
290
+     * @since 3.1.0
291
+     */
292
+    private function get_creative_work_schema() {
293
+
294
+        $schema = array(
295
+            'label'              => 'CreativeWork',
296
+            'description'        => 'A creative work (or a Music Album).',
297
+            'parents'            => array( 'thing' ), // give term slug as parent
298
+            'css_class'          => 'wl-creative-work',
299
+            'uri'                => 'http://schema.org/CreativeWork',
300
+            'same_as'            => array(
301
+                'http://schema.org/MusicAlbum',
302
+                'http://schema.org/Product'
303
+            ),
304
+            'custom_fields'      => array(
305
+                self::FIELD_AUTHOR => array(
306
+                    'predicate'   => 'http://schema.org/author',
307
+                    'type'        => self::DATA_TYPE_URI,
308
+                    'export_type' => 'http://schema.org/Person',
309
+                    'constraints' => array(
310
+                        'uri_type'    => array( 'Person', 'Organization' ),
311
+                        'cardinality' => INF
312
+                    )
313
+                ),
314
+            ),
315
+            'microdata_template' => '{{author}}',
316
+            'templates'          => array(
317
+                'subtitle' => '{{id}}'
318
+            )
319
+        );
320
+
321
+        // Merge the custom fields with those provided by the thing schema.
322
+        $thing_schema            = $this->get_thing_schema();
323
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
324
+
325
+        return $schema;
326
+    }
327
+
328
+    /**
329
+     * Get the 'event' schema.
330
+     *
331
+     * @return array An array with the schema configuration.
332
+     *
333
+     * @since 3.1.0
334
+     */
335
+    private function get_event_schema() {
336
+
337
+        $schema = array(
338
+            'label'              => 'Event',
339
+            'description'        => 'An event . ',
340
+            'parents'            => array( 'thing' ),
341
+            'css_class'          => 'wl-event',
342
+            'uri'                => self::SCHEMA_EVENT_TYPE,
343
+            'same_as'            => array( 'http://dbpedia.org/ontology/Event' ),
344
+            'custom_fields'      => array(
345
+                self::FIELD_DATE_START => array(
346
+                    'predicate'   => 'http://schema.org/startDate',
347
+                    'type'        => self::DATA_TYPE_DATE,
348
+                    'export_type' => 'xsd:datetime',
349
+                    'constraints' => ''
350
+                ),
351
+                self::FIELD_DATE_END   => array(
352
+                    'predicate'   => 'http://schema.org/endDate',
353
+                    'type'        => self::DATA_TYPE_DATE,
354
+                    'export_type' => 'xsd:datetime',
355
+                    'constraints' => ''
356
+                ),
357
+                self::FIELD_LOCATION   => array(
358
+                    'predicate'   => 'http://schema.org/location',
359
+                    'type'        => self::DATA_TYPE_URI,
360
+                    'export_type' => 'http://schema.org/PostalAddress',
361
+                    'constraints' => array(
362
+                        'uri_type'    => 'Place',
363
+                        'cardinality' => INF
364
+                    )
365
+                )
366
+            ),
367
+            'microdata_template' =>
368
+                '{{startDate}}
369 369
                                 {{endDate}}
370 370
                                 {{location}}',
371
-			'templates'          => array(
372
-				'subtitle' => '{{id}}'
373
-			)
374
-		);
375
-
376
-		// Merge the custom fields with those provided by the thing schema.
377
-		$thing_schema            = $this->get_thing_schema();
378
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
379
-
380
-		return $schema;
381
-	}
382
-
383
-	/**
384
-	 * Get the 'organization' schema.
385
-	 *
386
-	 * @return array An array with the schema configuration.
387
-	 *
388
-	 * @since 3.1.0
389
-	 */
390
-	private function get_organization_schema() {
391
-
392
-		$schema = array(
393
-			'label'              => 'Organization',
394
-			'description'        => 'An organization, including a government or a newspaper.',
395
-			'parents'            => array( 'thing' ),
396
-			'css_class'          => 'wl-organization',
397
-			'uri'                => 'http://schema.org/Organization',
398
-			'same_as'            => array(
399
-				'http://rdf.freebase.com/ns/organization.organization',
400
-				'http://rdf.freebase.com/ns/government.government',
401
-				'http://schema.org/Newspaper'
402
-			),
403
-			'custom_fields'      => array(
404
-				self::FIELD_FOUNDER => array(
405
-					'predicate'   => 'http://schema.org/founder',
406
-					'type'        => self::DATA_TYPE_URI,
407
-					'export_type' => 'http://schema.org/Person',
408
-					'constraints' => array(
409
-						'uri_type'    => 'Person',
410
-						'cardinality' => INF
411
-					)
412
-				),
413
-			),
414
-			'microdata_template' => '{{founder}}',
415
-			'templates'          => array(
416
-				'subtitle' => '{{id}}'
417
-			)
418
-		);
419
-
420
-		// Merge the custom fields with those provided by the thing schema.
421
-		$thing_schema            = $this->get_thing_schema();
422
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
423
-
424
-		return $schema;
425
-	}
426
-
427
-	/**
428
-	 * Get the 'person' schema.
429
-	 *
430
-	 * @return array An array with the schema configuration.
431
-	 *
432
-	 * @since 3.1.0
433
-	 */
434
-	private function get_person_schema() {
435
-
436
-		$schema = array(
437
-			'label'              => 'Person',
438
-			'description'        => 'A person (or a music artist).',
439
-			'parents'            => array( 'thing' ),
440
-			'css_class'          => 'wl-person',
441
-			'uri'                => 'http://schema.org/Person',
442
-			'same_as'            => array(
443
-				'http://rdf.freebase.com/ns/people.person',
444
-				'http://rdf.freebase.com/ns/music.artist',
445
-				'http://dbpedia.org/class/yago/LivingPeople'
446
-			),
447
-			'custom_fields'      => array(
448
-				self::FIELD_KNOWS       => array(
449
-					'predicate'   => 'http://schema.org/knows',
450
-					'type'        => self::DATA_TYPE_URI,
451
-					'export_type' => 'http://schema.org/Person',
452
-					'constraints' => array(
453
-						'uri_type'    => 'Person',
454
-						'cardinality' => INF
455
-					)
456
-				),
457
-				self::FIELD_BIRTH_DATE  => array(
458
-					'predicate'   => 'http://schema.org/birthDate',
459
-					'type'        => self::DATA_TYPE_DATE,
460
-					'export_type' => 'xsd:date',
461
-					'constraints' => ''
462
-				),
463
-				self::FIELD_BIRTH_PLACE => array(
464
-					'predicate'   => 'http://schema.org/birthPlace',
465
-					'type'        => self::DATA_TYPE_URI,
466
-					'export_type' => 'http://schema.org/Place',
467
-					'constraints' => array(
468
-						'uri_type' => 'Place'
469
-					)
470
-				),
471
-				self::FIELD_AFFILIATION => array(
472
-					'predicate'   => 'http://schema.org/affiliation',
473
-					'type'        => self::DATA_TYPE_URI,
474
-					'export_type' => 'http://schema.org/Organization',
475
-					'constraints' => array(
476
-						'uri_type' => 'Organization',
477
-						'cardinality' => INF
478
-					)
479
-				),
480
-				self::FIELD_EMAIL => array(
481
-					'predicate'   => 'http://schema.org/email',
482
-					'type'        => self::DATA_TYPE_STRING,
483
-					'export_type' => 'xsd:string',
484
-					'constraints' => array(
485
-						'cardinality' => INF
486
-					)
487
-				)
488
-			),
489
-			'microdata_template' =>
490
-				'{{birthDate}}
371
+            'templates'          => array(
372
+                'subtitle' => '{{id}}'
373
+            )
374
+        );
375
+
376
+        // Merge the custom fields with those provided by the thing schema.
377
+        $thing_schema            = $this->get_thing_schema();
378
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
379
+
380
+        return $schema;
381
+    }
382
+
383
+    /**
384
+     * Get the 'organization' schema.
385
+     *
386
+     * @return array An array with the schema configuration.
387
+     *
388
+     * @since 3.1.0
389
+     */
390
+    private function get_organization_schema() {
391
+
392
+        $schema = array(
393
+            'label'              => 'Organization',
394
+            'description'        => 'An organization, including a government or a newspaper.',
395
+            'parents'            => array( 'thing' ),
396
+            'css_class'          => 'wl-organization',
397
+            'uri'                => 'http://schema.org/Organization',
398
+            'same_as'            => array(
399
+                'http://rdf.freebase.com/ns/organization.organization',
400
+                'http://rdf.freebase.com/ns/government.government',
401
+                'http://schema.org/Newspaper'
402
+            ),
403
+            'custom_fields'      => array(
404
+                self::FIELD_FOUNDER => array(
405
+                    'predicate'   => 'http://schema.org/founder',
406
+                    'type'        => self::DATA_TYPE_URI,
407
+                    'export_type' => 'http://schema.org/Person',
408
+                    'constraints' => array(
409
+                        'uri_type'    => 'Person',
410
+                        'cardinality' => INF
411
+                    )
412
+                ),
413
+            ),
414
+            'microdata_template' => '{{founder}}',
415
+            'templates'          => array(
416
+                'subtitle' => '{{id}}'
417
+            )
418
+        );
419
+
420
+        // Merge the custom fields with those provided by the thing schema.
421
+        $thing_schema            = $this->get_thing_schema();
422
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
423
+
424
+        return $schema;
425
+    }
426
+
427
+    /**
428
+     * Get the 'person' schema.
429
+     *
430
+     * @return array An array with the schema configuration.
431
+     *
432
+     * @since 3.1.0
433
+     */
434
+    private function get_person_schema() {
435
+
436
+        $schema = array(
437
+            'label'              => 'Person',
438
+            'description'        => 'A person (or a music artist).',
439
+            'parents'            => array( 'thing' ),
440
+            'css_class'          => 'wl-person',
441
+            'uri'                => 'http://schema.org/Person',
442
+            'same_as'            => array(
443
+                'http://rdf.freebase.com/ns/people.person',
444
+                'http://rdf.freebase.com/ns/music.artist',
445
+                'http://dbpedia.org/class/yago/LivingPeople'
446
+            ),
447
+            'custom_fields'      => array(
448
+                self::FIELD_KNOWS       => array(
449
+                    'predicate'   => 'http://schema.org/knows',
450
+                    'type'        => self::DATA_TYPE_URI,
451
+                    'export_type' => 'http://schema.org/Person',
452
+                    'constraints' => array(
453
+                        'uri_type'    => 'Person',
454
+                        'cardinality' => INF
455
+                    )
456
+                ),
457
+                self::FIELD_BIRTH_DATE  => array(
458
+                    'predicate'   => 'http://schema.org/birthDate',
459
+                    'type'        => self::DATA_TYPE_DATE,
460
+                    'export_type' => 'xsd:date',
461
+                    'constraints' => ''
462
+                ),
463
+                self::FIELD_BIRTH_PLACE => array(
464
+                    'predicate'   => 'http://schema.org/birthPlace',
465
+                    'type'        => self::DATA_TYPE_URI,
466
+                    'export_type' => 'http://schema.org/Place',
467
+                    'constraints' => array(
468
+                        'uri_type' => 'Place'
469
+                    )
470
+                ),
471
+                self::FIELD_AFFILIATION => array(
472
+                    'predicate'   => 'http://schema.org/affiliation',
473
+                    'type'        => self::DATA_TYPE_URI,
474
+                    'export_type' => 'http://schema.org/Organization',
475
+                    'constraints' => array(
476
+                        'uri_type' => 'Organization',
477
+                        'cardinality' => INF
478
+                    )
479
+                ),
480
+                self::FIELD_EMAIL => array(
481
+                    'predicate'   => 'http://schema.org/email',
482
+                    'type'        => self::DATA_TYPE_STRING,
483
+                    'export_type' => 'xsd:string',
484
+                    'constraints' => array(
485
+                        'cardinality' => INF
486
+                    )
487
+                )
488
+            ),
489
+            'microdata_template' =>
490
+                '{{birthDate}}
491 491
                  {{birthPlace}}
492 492
                  {{knows}}
493 493
 				 {{affiliation}}
494 494
 				 {{email}}',
495
-			'templates'          => array(
496
-				'subtitle' => '{{id}}'
497
-			)
498
-		);
499
-
500
-		// Merge the custom fields with those provided by the thing schema.
501
-		$thing_schema            = $this->get_thing_schema();
502
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
503
-
504
-		return $schema;
505
-
506
-	}
507
-
508
-	/**
509
-	 * Get the 'place' schema.
510
-	 *
511
-	 * @return array An array with the schema configuration.
512
-	 *
513
-	 * @since 3.1.0
514
-	 */
515
-	private function get_place_schema() {
516
-
517
-		$schema = array(
518
-			'label'              => 'Place',
519
-			'description'        => 'A place.',
520
-			'parents'            => array( 'thing' ),
521
-			'css_class'          => 'wl-place',
522
-			'uri'                => 'http://schema.org/Place',
523
-			'same_as'            => array(
524
-				'http://rdf.freebase.com/ns/location.location',
525
-				'http://www.opengis.net/gml/_Feature'
526
-			),
527
-			'custom_fields'      => array(
528
-				self::FIELD_GEO_LATITUDE  => array(
529
-					'predicate'   => 'http://schema.org/latitude',
530
-					'type'        => self::DATA_TYPE_DOUBLE,
531
-					'export_type' => 'xsd:double',
532
-					'constraints' => '',
533
-					'input_field' => 'coordinates'   // to build custom metabox
534
-				),
535
-				self::FIELD_GEO_LONGITUDE => array(
536
-					'predicate'   => 'http://schema.org/longitude',
537
-					'type'        => self::DATA_TYPE_DOUBLE,
538
-					'export_type' => 'xsd:double',
539
-					'constraints' => '',
540
-					'input_field' => 'coordinates'   // to build custom metabox
541
-				),
542
-				self::FIELD_ADDRESS       => array(
543
-					'predicate'   => 'http://schema.org/address',
544
-					'type'        => self::DATA_TYPE_STRING,
545
-					'export_type' => 'xsd:string',
546
-					'constraints' => ''
547
-				)
548
-			),
549
-			'microdata_template' =>
550
-				'<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
495
+            'templates'          => array(
496
+                'subtitle' => '{{id}}'
497
+            )
498
+        );
499
+
500
+        // Merge the custom fields with those provided by the thing schema.
501
+        $thing_schema            = $this->get_thing_schema();
502
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
503
+
504
+        return $schema;
505
+
506
+    }
507
+
508
+    /**
509
+     * Get the 'place' schema.
510
+     *
511
+     * @return array An array with the schema configuration.
512
+     *
513
+     * @since 3.1.0
514
+     */
515
+    private function get_place_schema() {
516
+
517
+        $schema = array(
518
+            'label'              => 'Place',
519
+            'description'        => 'A place.',
520
+            'parents'            => array( 'thing' ),
521
+            'css_class'          => 'wl-place',
522
+            'uri'                => 'http://schema.org/Place',
523
+            'same_as'            => array(
524
+                'http://rdf.freebase.com/ns/location.location',
525
+                'http://www.opengis.net/gml/_Feature'
526
+            ),
527
+            'custom_fields'      => array(
528
+                self::FIELD_GEO_LATITUDE  => array(
529
+                    'predicate'   => 'http://schema.org/latitude',
530
+                    'type'        => self::DATA_TYPE_DOUBLE,
531
+                    'export_type' => 'xsd:double',
532
+                    'constraints' => '',
533
+                    'input_field' => 'coordinates'   // to build custom metabox
534
+                ),
535
+                self::FIELD_GEO_LONGITUDE => array(
536
+                    'predicate'   => 'http://schema.org/longitude',
537
+                    'type'        => self::DATA_TYPE_DOUBLE,
538
+                    'export_type' => 'xsd:double',
539
+                    'constraints' => '',
540
+                    'input_field' => 'coordinates'   // to build custom metabox
541
+                ),
542
+                self::FIELD_ADDRESS       => array(
543
+                    'predicate'   => 'http://schema.org/address',
544
+                    'type'        => self::DATA_TYPE_STRING,
545
+                    'export_type' => 'xsd:string',
546
+                    'constraints' => ''
547
+                )
548
+            ),
549
+            'microdata_template' =>
550
+                '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
551 551
                                     {{latitude}}
552 552
                                     {{longitude}}
553 553
                                 </span>
554 554
                                 {{address}}',
555
-			'templates'          => array(
556
-				'subtitle' => '{{id}}'
557
-			)
558
-		);
559
-
560
-		// Merge the custom fields with those provided by the thing schema.
561
-		$thing_schema            = $this->get_thing_schema();
562
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
563
-
564
-		return $schema;
565
-	}
566
-
567
-	/**
568
-	 * Get the 'local business' schema.
569
-	 *
570
-	 * @return array An array with the schema configuration.
571
-	 *
572
-	 * @since 3.1.0
573
-	 */
574
-	private function get_local_business_schema() {
575
-
576
-		$schema = array(
577
-			'label'              => 'LocalBusiness',
578
-			'description'        => 'A local business.',
579
-			'parents'            => array( 'place', 'organization' ),
580
-			'css_class'          => 'wl-local-business',
581
-			'uri'                => 'http://schema.org/LocalBusiness',
582
-			'same_as'            => array(
583
-				'http://rdf.freebase.com/ns/business/business_location',
584
-				'https://schema.org/Store'
585
-			),
586
-			'custom_fields'      => array(),
587
-			'microdata_template' => '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
555
+            'templates'          => array(
556
+                'subtitle' => '{{id}}'
557
+            )
558
+        );
559
+
560
+        // Merge the custom fields with those provided by the thing schema.
561
+        $thing_schema            = $this->get_thing_schema();
562
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $thing_schema['custom_fields'] );
563
+
564
+        return $schema;
565
+    }
566
+
567
+    /**
568
+     * Get the 'local business' schema.
569
+     *
570
+     * @return array An array with the schema configuration.
571
+     *
572
+     * @since 3.1.0
573
+     */
574
+    private function get_local_business_schema() {
575
+
576
+        $schema = array(
577
+            'label'              => 'LocalBusiness',
578
+            'description'        => 'A local business.',
579
+            'parents'            => array( 'place', 'organization' ),
580
+            'css_class'          => 'wl-local-business',
581
+            'uri'                => 'http://schema.org/LocalBusiness',
582
+            'same_as'            => array(
583
+                'http://rdf.freebase.com/ns/business/business_location',
584
+                'https://schema.org/Store'
585
+            ),
586
+            'custom_fields'      => array(),
587
+            'microdata_template' => '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
588 588
                                     {{latitude}}
589 589
                                     {{longitude}}
590 590
                                 </span>
591 591
                                 {{address}}
592 592
                                 {{founder}}',
593
-			'templates'          => array(
594
-				'subtitle' => '{{id}}'
595
-			)
596
-		);
597
-
598
-		// Merge the custom fields with those provided by the place and organization schema.
599
-		$place_schema            = $this->get_place_schema();
600
-		$organization_schema     = $this->get_organization_schema();
601
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
602
-
603
-		return $schema;
604
-	}
593
+            'templates'          => array(
594
+                'subtitle' => '{{id}}'
595
+            )
596
+        );
597
+
598
+        // Merge the custom fields with those provided by the place and organization schema.
599
+        $place_schema            = $this->get_place_schema();
600
+        $organization_schema     = $this->get_organization_schema();
601
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
602
+
603
+        return $schema;
604
+    }
605 605
 
606 606
 }
Please login to merge, or discard this patch.