@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public static function getVersionRanges($packageName) |
138 | 138 | { |
139 | 139 | foreach (self::getInstalled() as $installed) { |
140 | - if (!isset($installed['versions'][$packageName])) { |
|
140 | + if ( ! isset($installed['versions'][$packageName])) { |
|
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return implode(' || ', $ranges); |
159 | 159 | } |
160 | 160 | |
161 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
161 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | public static function getVersion($packageName) |
169 | 169 | { |
170 | 170 | foreach (self::getInstalled() as $installed) { |
171 | - if (!isset($installed['versions'][$packageName])) { |
|
171 | + if ( ! isset($installed['versions'][$packageName])) { |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | - if (!isset($installed['versions'][$packageName]['version'])) { |
|
175 | + if ( ! isset($installed['versions'][$packageName]['version'])) { |
|
176 | 176 | return null; |
177 | 177 | } |
178 | 178 | |
179 | 179 | return $installed['versions'][$packageName]['version']; |
180 | 180 | } |
181 | 181 | |
182 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
182 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | public static function getPrettyVersion($packageName) |
190 | 190 | { |
191 | 191 | foreach (self::getInstalled() as $installed) { |
192 | - if (!isset($installed['versions'][$packageName])) { |
|
192 | + if ( ! isset($installed['versions'][$packageName])) { |
|
193 | 193 | continue; |
194 | 194 | } |
195 | 195 | |
196 | - if (!isset($installed['versions'][$packageName]['pretty_version'])) { |
|
196 | + if ( ! isset($installed['versions'][$packageName]['pretty_version'])) { |
|
197 | 197 | return null; |
198 | 198 | } |
199 | 199 | |
200 | 200 | return $installed['versions'][$packageName]['pretty_version']; |
201 | 201 | } |
202 | 202 | |
203 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
203 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,18 +210,18 @@ discard block |
||
210 | 210 | public static function getReference($packageName) |
211 | 211 | { |
212 | 212 | foreach (self::getInstalled() as $installed) { |
213 | - if (!isset($installed['versions'][$packageName])) { |
|
213 | + if ( ! isset($installed['versions'][$packageName])) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | - if (!isset($installed['versions'][$packageName]['reference'])) { |
|
217 | + if ( ! isset($installed['versions'][$packageName]['reference'])) { |
|
218 | 218 | return null; |
219 | 219 | } |
220 | 220 | |
221 | 221 | return $installed['versions'][$packageName]['reference']; |
222 | 222 | } |
223 | 223 | |
224 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
224 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | public static function getInstallPath($packageName) |
232 | 232 | { |
233 | 233 | foreach (self::getInstalled() as $installed) { |
234 | - if (!isset($installed['versions'][$packageName])) { |
|
234 | + if ( ! isset($installed['versions'][$packageName])) { |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | |
238 | 238 | return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; |
239 | 239 | } |
240 | 240 | |
241 | - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
241 | + throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | // only require the installed.php file if this file is loaded from its dumped location, |
268 | 268 | // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
269 | 269 | if (substr(__DIR__, -8, 1) !== 'C') { |
270 | - self::$installed = include __DIR__ . '/installed.php'; |
|
270 | + self::$installed = include __DIR__.'/installed.php'; |
|
271 | 271 | } else { |
272 | 272 | self::$installed = array(); |
273 | 273 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | // only require the installed.php file if this file is loaded from its dumped location, |
341 | 341 | // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 |
342 | 342 | if (substr(__DIR__, -8, 1) !== 'C') { |
343 | - self::$installed = require __DIR__ . '/installed.php'; |
|
343 | + self::$installed = require __DIR__.'/installed.php'; |
|
344 | 344 | } else { |
345 | 345 | self::$installed = array(); |
346 | 346 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit1fa7477671b8ce4e96024c7b54cda86e |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'W' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'Wordlift\\Modules\\Pods\\' => 22, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'Wordlift\\Modules\\Pods\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/../..' . '/includes', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/../..'.'/includes', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | public static function getInitializer(ClassLoader $loader) |
28 | 28 | { |
29 | - return \Closure::bind(function () use ($loader) { |
|
29 | + return \Closure::bind(function() use ($loader) { |
|
30 | 30 | $loader->prefixLengthsPsr4 = ComposerStaticInit1fa7477671b8ce4e96024c7b54cda86e::$prefixLengthsPsr4; |
31 | 31 | $loader->prefixDirsPsr4 = ComposerStaticInit1fa7477671b8ce4e96024c7b54cda86e::$prefixDirsPsr4; |
32 | 32 | $loader->classMap = ComposerStaticInit1fa7477671b8ce4e96024c7b54cda86e::$classMap; |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
10 | 10 | ); |
@@ -18,1244 +18,1244 @@ |
||
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 | } |
@@ -399,7 +399,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | private $schema; |
14 | 14 | |
15 | - public function __construct( $schema ) { |
|
15 | + public function __construct($schema) { |
|
16 | 16 | $this->schema = $schema; |
17 | 17 | } |
18 | 18 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | $context_type = $this->schema->get_context_type(); |
23 | 23 | |
24 | - switch ( $context_type ) { |
|
24 | + switch ($context_type) { |
|
25 | 25 | case Context::POST: |
26 | - return new PostTypeDefinition( $this->schema ); |
|
26 | + return new PostTypeDefinition($this->schema); |
|
27 | 27 | case Context::TERM: |
28 | - return new TaxonomyDefinition( $this->schema ); |
|
28 | + return new TaxonomyDefinition($this->schema); |
|
29 | 29 | default: |
30 | - return new AllPodsDefiniton( $this->schema ); |
|
30 | + return new AllPodsDefiniton($this->schema); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 |
@@ -7,27 +7,27 @@ |
||
7 | 7 | |
8 | 8 | class FieldDefinitionFactory { |
9 | 9 | |
10 | - /** |
|
11 | - * @var $schema Schema |
|
12 | - */ |
|
13 | - private $schema; |
|
14 | - |
|
15 | - public function __construct( $schema ) { |
|
16 | - $this->schema = $schema; |
|
17 | - } |
|
18 | - |
|
19 | - public function get_field_definition() { |
|
20 | - |
|
21 | - $context_type = $this->schema->get_context_type(); |
|
22 | - |
|
23 | - switch ( $context_type ) { |
|
24 | - case Context::POST: |
|
25 | - return new PostTypeDefinition( $this->schema ); |
|
26 | - case Context::TERM: |
|
27 | - return new TaxonomyDefinition( $this->schema ); |
|
28 | - default: |
|
29 | - return new AllPodsDefiniton( $this->schema ); |
|
30 | - } |
|
31 | - } |
|
10 | + /** |
|
11 | + * @var $schema Schema |
|
12 | + */ |
|
13 | + private $schema; |
|
14 | + |
|
15 | + public function __construct( $schema ) { |
|
16 | + $this->schema = $schema; |
|
17 | + } |
|
18 | + |
|
19 | + public function get_field_definition() { |
|
20 | + |
|
21 | + $context_type = $this->schema->get_context_type(); |
|
22 | + |
|
23 | + switch ( $context_type ) { |
|
24 | + case Context::POST: |
|
25 | + return new PostTypeDefinition( $this->schema ); |
|
26 | + case Context::TERM: |
|
27 | + return new TaxonomyDefinition( $this->schema ); |
|
28 | + default: |
|
29 | + return new AllPodsDefiniton( $this->schema ); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | class PostTypeDefinition extends AbstractFieldDefiniton { |
6 | 6 | |
7 | - public function register() { |
|
8 | - $that = $this; |
|
9 | - add_action( |
|
10 | - 'init', |
|
11 | - function () use ( $that ) { |
|
12 | - $context = $that->schema->get(); |
|
13 | - $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
14 | - } |
|
15 | - ); |
|
16 | - } |
|
7 | + public function register() { |
|
8 | + $that = $this; |
|
9 | + add_action( |
|
10 | + 'init', |
|
11 | + function () use ( $that ) { |
|
12 | + $context = $that->schema->get(); |
|
13 | + $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
14 | + } |
|
15 | + ); |
|
16 | + } |
|
17 | 17 | } |
@@ -8,9 +8,9 @@ |
||
8 | 8 | $that = $this; |
9 | 9 | add_action( |
10 | 10 | 'init', |
11 | - function () use ( $that ) { |
|
11 | + function() use ($that) { |
|
12 | 12 | $context = $that->schema->get(); |
13 | - $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
13 | + $that->register_pod($context->get_pod_name(), $context->get_pod_type(), $context); |
|
14 | 14 | } |
15 | 15 | ); |
16 | 16 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | class TaxonomyDefinition extends AbstractFieldDefiniton { |
6 | 6 | |
7 | - public function register() { |
|
8 | - $that = $this; |
|
9 | - add_action( |
|
10 | - 'setup_theme', |
|
11 | - function () use ( $that ) { |
|
12 | - $context = $that->schema->get(); |
|
13 | - $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
14 | - } |
|
15 | - ); |
|
16 | - } |
|
7 | + public function register() { |
|
8 | + $that = $this; |
|
9 | + add_action( |
|
10 | + 'setup_theme', |
|
11 | + function () use ( $that ) { |
|
12 | + $context = $that->schema->get(); |
|
13 | + $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
14 | + } |
|
15 | + ); |
|
16 | + } |
|
17 | 17 | } |
@@ -8,9 +8,9 @@ |
||
8 | 8 | $that = $this; |
9 | 9 | add_action( |
10 | 10 | 'setup_theme', |
11 | - function () use ( $that ) { |
|
11 | + function() use ($that) { |
|
12 | 12 | $context = $that->schema->get(); |
13 | - $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context ); |
|
13 | + $that->register_pod($context->get_pod_name(), $context->get_pod_type(), $context); |
|
14 | 14 | } |
15 | 15 | ); |
16 | 16 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | */ |
10 | 10 | private $pods_plugin; |
11 | 11 | |
12 | - public function __construct( Plugin $plugin ) { |
|
12 | + public function __construct(Plugin $plugin) { |
|
13 | 13 | $this->pods_plugin = $plugin; |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function register_hooks() { |
17 | - add_action( 'wl_metabox_before_html', array( $this, 'admin_notices' ) ); |
|
17 | + add_action('wl_metabox_before_html', array($this, 'admin_notices')); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function admin_notices() { |
@@ -22,29 +22,29 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * When pods not installed or activated then the notice should appear. |
24 | 24 | */ |
25 | - if ( ! $this->pods_plugin->is_plugin_installed() ) { |
|
25 | + if ( ! $this->pods_plugin->is_plugin_installed()) { |
|
26 | 26 | $this->display_notice( |
27 | - __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is not installed.', 'wordlift' ), |
|
28 | - __( 'Reinstall & Activate', 'wordlift' ) |
|
27 | + __('WordLift detected that <b>Pods – Custom Content Types and Fields</b> is not installed.', 'wordlift'), |
|
28 | + __('Reinstall & Activate', 'wordlift') |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | // Dont display notice. |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if ( ! $this->pods_plugin->is_plugin_activated() ) { |
|
35 | + if ( ! $this->pods_plugin->is_plugin_activated()) { |
|
36 | 36 | $this->display_notice( |
37 | - __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is deactivated.', 'wordlift' ), |
|
38 | - __( 'Reactivate', 'wordlift' ) |
|
37 | + __('WordLift detected that <b>Pods – Custom Content Types and Fields</b> is deactivated.', 'wordlift'), |
|
38 | + __('Reactivate', 'wordlift') |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | return; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - private function display_notice( $message, $button_text ) { |
|
45 | + private function display_notice($message, $button_text) { |
|
46 | 46 | |
47 | - $kses_options = array( |
|
47 | + $kses_options = array( |
|
48 | 48 | 'p' => array(), |
49 | 49 | 'b' => array(), |
50 | 50 | 'button' => array( |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | 'wordlift' |
58 | 58 | ); |
59 | 59 | |
60 | - $installing_message = __( 'Installing', 'wordlift' ) . ' <span class="spinner is-active"></span>'; |
|
61 | - $installation_failed_message = '<p>' . |
|
62 | - __( 'Wordlift: Pods – Custom Content Types and Fields installation failed, please retry or contact [email protected]', 'wordlift' ) |
|
60 | + $installing_message = __('Installing', 'wordlift').' <span class="spinner is-active"></span>'; |
|
61 | + $installation_failed_message = '<p>'. |
|
62 | + __('Wordlift: Pods – Custom Content Types and Fields installation failed, please retry or contact [email protected]', 'wordlift') |
|
63 | 63 | . '</p><button class="button action" onclick="wordliftInstallPods(this)">' |
64 | - . __( 'Retry', 'wordlift' ) |
|
64 | + . __('Retry', 'wordlift') |
|
65 | 65 | . '</button>'; |
66 | 66 | ?> |
67 | 67 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | const pluginInstallationNotice = document.getElementById("wordlift_pods_plugin_installation_notice") |
71 | 71 | const installPlugin = (ajaxUrl) => fetch(`${ajaxUrl}?action=wl_install_and_activate_pods`) |
72 | 72 | .then(response => response.ok ? response.json() : Promise.reject()) |
73 | - const ajaxUrl = "<?php echo esc_html( wp_parse_url( admin_url( 'admin-ajax.php' ), PHP_URL_PATH ) ); ?>" |
|
73 | + const ajaxUrl = "<?php echo esc_html(wp_parse_url(admin_url('admin-ajax.php'), PHP_URL_PATH)); ?>" |
|
74 | 74 | window.wordliftInstallPods = function (installBtn) { |
75 | - installBtn.innerHTML = `<?php echo wp_kses( $installing_message, array( 'span' => array( 'class' => array() ) ) ); ?>` |
|
75 | + installBtn.innerHTML = `<?php echo wp_kses($installing_message, array('span' => array('class' => array()))); ?>` |
|
76 | 76 | installPlugin(ajaxUrl) |
77 | 77 | .catch(e => { |
78 | - pluginInstallationNotice.innerHTML = `<?php echo wp_kses( $installation_failed_message, $kses_options ); ?>` |
|
78 | + pluginInstallationNotice.innerHTML = `<?php echo wp_kses($installation_failed_message, $kses_options); ?>` |
|
79 | 79 | }) |
80 | 80 | .then(() => { |
81 | - pluginInstallationNotice.innerHTML = `<?php echo wp_kses( $installation_success_message, $kses_options ); ?>` |
|
81 | + pluginInstallationNotice.innerHTML = `<?php echo wp_kses($installation_success_message, $kses_options); ?>` |
|
82 | 82 | pluginInstallationNotice.classList.remove('notice-error') |
83 | 83 | pluginInstallationNotice.classList.add('notice-success') |
84 | 84 | }) |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | |
91 | 91 | <div class="wl-notice notice-error" id="wordlift_pods_plugin_installation_notice"> |
92 | 92 | <p> |
93 | - <?php echo wp_kses( $message, array( 'b' => array() ) ); ?> |
|
93 | + <?php echo wp_kses($message, array('b' => array())); ?> |
|
94 | 94 | <button class="button action right" onclick="wordliftInstallPods(this)"> |
95 | - <?php echo esc_html( $button_text ); ?> |
|
95 | + <?php echo esc_html($button_text); ?> |
|
96 | 96 | </button> |
97 | 97 | </p> |
98 | 98 | <br/> |
@@ -6,66 +6,66 @@ discard block |
||
6 | 6 | |
7 | 7 | class Notices { |
8 | 8 | |
9 | - /** |
|
10 | - * @var Plugin |
|
11 | - */ |
|
12 | - private $pods_plugin; |
|
13 | - |
|
14 | - public function __construct( Plugin $plugin ) { |
|
15 | - $this->pods_plugin = $plugin; |
|
16 | - } |
|
17 | - |
|
18 | - public function register_hooks() { |
|
19 | - add_action( 'wl_metabox_before_html', array( $this, 'admin_notices' ) ); |
|
20 | - } |
|
21 | - |
|
22 | - public function admin_notices() { |
|
23 | - |
|
24 | - /** |
|
25 | - * When pods not installed or activated then the notice should appear. |
|
26 | - */ |
|
27 | - if ( ! $this->pods_plugin->is_plugin_installed() ) { |
|
28 | - $this->display_notice( |
|
29 | - __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is not installed.', 'wordlift' ), |
|
30 | - __( 'Reinstall & Activate', 'wordlift' ) |
|
31 | - ); |
|
32 | - |
|
33 | - // Dont display notice. |
|
34 | - return; |
|
35 | - } |
|
36 | - |
|
37 | - if ( ! $this->pods_plugin->is_plugin_activated() ) { |
|
38 | - $this->display_notice( |
|
39 | - __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is deactivated.', 'wordlift' ), |
|
40 | - __( 'Reactivate', 'wordlift' ) |
|
41 | - ); |
|
42 | - |
|
43 | - return; |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - private function display_notice( $message, $button_text ) { |
|
48 | - |
|
49 | - $kses_options = array( |
|
50 | - 'p' => array(), |
|
51 | - 'b' => array(), |
|
52 | - 'button' => array( |
|
53 | - 'class' => array(), |
|
54 | - 'onclick' => array(), |
|
55 | - ), |
|
56 | - ); |
|
57 | - $installation_success_message = __( |
|
58 | - '<p>WordLift: <b>Pods – Custom Content Types and Fields</b> plugin installed and activated.</p>', // phpcs:ignore WordPress.WP.I18n.NoHtmlWrappedStrings |
|
59 | - 'wordlift' |
|
60 | - ); |
|
61 | - |
|
62 | - $installing_message = __( 'Installing', 'wordlift' ) . ' <span class="spinner is-active"></span>'; |
|
63 | - $installation_failed_message = '<p>' . |
|
64 | - __( 'Wordlift: Pods – Custom Content Types and Fields installation failed, please retry or contact [email protected]', 'wordlift' ) |
|
65 | - . '</p><button class="button action" onclick="wordliftInstallPods(this)">' |
|
66 | - . __( 'Retry', 'wordlift' ) |
|
67 | - . '</button>'; |
|
68 | - ?> |
|
9 | + /** |
|
10 | + * @var Plugin |
|
11 | + */ |
|
12 | + private $pods_plugin; |
|
13 | + |
|
14 | + public function __construct( Plugin $plugin ) { |
|
15 | + $this->pods_plugin = $plugin; |
|
16 | + } |
|
17 | + |
|
18 | + public function register_hooks() { |
|
19 | + add_action( 'wl_metabox_before_html', array( $this, 'admin_notices' ) ); |
|
20 | + } |
|
21 | + |
|
22 | + public function admin_notices() { |
|
23 | + |
|
24 | + /** |
|
25 | + * When pods not installed or activated then the notice should appear. |
|
26 | + */ |
|
27 | + if ( ! $this->pods_plugin->is_plugin_installed() ) { |
|
28 | + $this->display_notice( |
|
29 | + __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is not installed.', 'wordlift' ), |
|
30 | + __( 'Reinstall & Activate', 'wordlift' ) |
|
31 | + ); |
|
32 | + |
|
33 | + // Dont display notice. |
|
34 | + return; |
|
35 | + } |
|
36 | + |
|
37 | + if ( ! $this->pods_plugin->is_plugin_activated() ) { |
|
38 | + $this->display_notice( |
|
39 | + __( 'WordLift detected that <b>Pods – Custom Content Types and Fields</b> is deactivated.', 'wordlift' ), |
|
40 | + __( 'Reactivate', 'wordlift' ) |
|
41 | + ); |
|
42 | + |
|
43 | + return; |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + private function display_notice( $message, $button_text ) { |
|
48 | + |
|
49 | + $kses_options = array( |
|
50 | + 'p' => array(), |
|
51 | + 'b' => array(), |
|
52 | + 'button' => array( |
|
53 | + 'class' => array(), |
|
54 | + 'onclick' => array(), |
|
55 | + ), |
|
56 | + ); |
|
57 | + $installation_success_message = __( |
|
58 | + '<p>WordLift: <b>Pods – Custom Content Types and Fields</b> plugin installed and activated.</p>', // phpcs:ignore WordPress.WP.I18n.NoHtmlWrappedStrings |
|
59 | + 'wordlift' |
|
60 | + ); |
|
61 | + |
|
62 | + $installing_message = __( 'Installing', 'wordlift' ) . ' <span class="spinner is-active"></span>'; |
|
63 | + $installation_failed_message = '<p>' . |
|
64 | + __( 'Wordlift: Pods – Custom Content Types and Fields installation failed, please retry or contact [email protected]', 'wordlift' ) |
|
65 | + . '</p><button class="button action" onclick="wordliftInstallPods(this)">' |
|
66 | + . __( 'Retry', 'wordlift' ) |
|
67 | + . '</button>'; |
|
68 | + ?> |
|
69 | 69 | |
70 | 70 | <script> |
71 | 71 | window.addEventListener("load", function () { |
@@ -100,5 +100,5 @@ discard block |
||
100 | 100 | <br/> |
101 | 101 | </div> |
102 | 102 | <?php |
103 | - } |
|
103 | + } |
|
104 | 104 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | /** |
16 | 16 | * {@inheritdoc} |
17 | 17 | */ |
18 | - public function get( $id, $meta_key, $type ) { |
|
18 | + public function get($id, $meta_key, $type) { |
|
19 | 19 | |
20 | 20 | $entity_service = Wordlift_Entity_Service::get_instance(); |
21 | 21 | |
22 | 22 | // Map each returned value to a Wordlift_Property_Entity_Reference. |
23 | 23 | $result = array_map( |
24 | - function ( $item ) use ( $entity_service ) { |
|
24 | + function($item) use ($entity_service) { |
|
25 | 25 | |
26 | 26 | $regex = '/^(post|term)_(\d+)$/m'; |
27 | - if ( preg_match( $regex, $item, $matches ) ) { |
|
28 | - $object_type = Object_Type_Enum::from_string( $matches[1] ); |
|
27 | + if (preg_match($regex, $item, $matches)) { |
|
28 | + $object_type = Object_Type_Enum::from_string($matches[1]); |
|
29 | 29 | $identifier = (int) $matches[2]; |
30 | - if ( Object_Type_Enum::POST === $object_type ) { |
|
31 | - return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier ), $identifier ); |
|
32 | - } elseif ( Object_Type_Enum::TERM === $object_type ) { |
|
33 | - return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier, Object_Type_Enum::TERM ), $identifier, false, Object_Type_Enum::TERM ); |
|
30 | + if (Object_Type_Enum::POST === $object_type) { |
|
31 | + return new Wordlift_Property_Entity_Reference($entity_service->get_uri($identifier), $identifier); |
|
32 | + } elseif (Object_Type_Enum::TERM === $object_type) { |
|
33 | + return new Wordlift_Property_Entity_Reference($entity_service->get_uri($identifier, Object_Type_Enum::TERM), $identifier, false, Object_Type_Enum::TERM); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | // If the $item is a number and it's an existing post, return the |
38 | 38 | // URI of the referenced entity. Otherwise return the value. |
39 | - return is_numeric( $item ) && null !== get_post( $item ) |
|
40 | - ? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item ) |
|
39 | + return is_numeric($item) && null !== get_post($item) |
|
40 | + ? new Wordlift_Property_Entity_Reference($entity_service->get_uri($item), (int) $item) |
|
41 | 41 | : $item; |
42 | 42 | }, |
43 | - parent::get( $id, $meta_key, $type ) |
|
43 | + parent::get($id, $meta_key, $type) |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | return $result; |
@@ -10,38 +10,38 @@ |
||
10 | 10 | */ |
11 | 11 | class Wordlift_Entity_Property_Service extends Wordlift_Simple_Property_Service { |
12 | 12 | |
13 | - /** |
|
14 | - * {@inheritdoc} |
|
15 | - */ |
|
16 | - public function get( $id, $meta_key, $type ) { |
|
17 | - |
|
18 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
19 | - |
|
20 | - // Map each returned value to a Wordlift_Property_Entity_Reference. |
|
21 | - $result = array_map( |
|
22 | - function ( $item ) use ( $entity_service ) { |
|
23 | - |
|
24 | - $regex = '/^(post|term)_(\d+)$/m'; |
|
25 | - if ( preg_match( $regex, $item, $matches ) ) { |
|
26 | - $object_type = Object_Type_Enum::from_string( $matches[1] ); |
|
27 | - $identifier = (int) $matches[2]; |
|
28 | - if ( Object_Type_Enum::POST === $object_type ) { |
|
29 | - return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier ), $identifier ); |
|
30 | - } elseif ( Object_Type_Enum::TERM === $object_type ) { |
|
31 | - return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier, Object_Type_Enum::TERM ), $identifier, false, Object_Type_Enum::TERM ); |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - // If the $item is a number and it's an existing post, return the |
|
36 | - // URI of the referenced entity. Otherwise return the value. |
|
37 | - return is_numeric( $item ) && null !== get_post( $item ) |
|
38 | - ? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item ) |
|
39 | - : $item; |
|
40 | - }, |
|
41 | - parent::get( $id, $meta_key, $type ) |
|
42 | - ); |
|
43 | - |
|
44 | - return $result; |
|
45 | - } |
|
13 | + /** |
|
14 | + * {@inheritdoc} |
|
15 | + */ |
|
16 | + public function get( $id, $meta_key, $type ) { |
|
17 | + |
|
18 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
19 | + |
|
20 | + // Map each returned value to a Wordlift_Property_Entity_Reference. |
|
21 | + $result = array_map( |
|
22 | + function ( $item ) use ( $entity_service ) { |
|
23 | + |
|
24 | + $regex = '/^(post|term)_(\d+)$/m'; |
|
25 | + if ( preg_match( $regex, $item, $matches ) ) { |
|
26 | + $object_type = Object_Type_Enum::from_string( $matches[1] ); |
|
27 | + $identifier = (int) $matches[2]; |
|
28 | + if ( Object_Type_Enum::POST === $object_type ) { |
|
29 | + return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier ), $identifier ); |
|
30 | + } elseif ( Object_Type_Enum::TERM === $object_type ) { |
|
31 | + return new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $identifier, Object_Type_Enum::TERM ), $identifier, false, Object_Type_Enum::TERM ); |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + // If the $item is a number and it's an existing post, return the |
|
36 | + // URI of the referenced entity. Otherwise return the value. |
|
37 | + return is_numeric( $item ) && null !== get_post( $item ) |
|
38 | + ? new Wordlift_Property_Entity_Reference( $entity_service->get_uri( $item ), (int) $item ) |
|
39 | + : $item; |
|
40 | + }, |
|
41 | + parent::get( $id, $meta_key, $type ) |
|
42 | + ); |
|
43 | + |
|
44 | + return $result; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |