print_link()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
c 0
b 0
f 0
nc 8
nop 1
dl 0
loc 21
rs 9.9
1
<?php
2
3
$matrix = array();
4
5
$components = array(
6
	'id'                    => 'ID',
7
	'number'                => 'Number',
8
	'reference'             => 'Reference',
9
	'sku'                   => array(
10
		'label' => 'SKU',
11
		'link'  => 'https://en.wikipedia.org/wiki/Stock_keeping_unit',
12
	),
13
	'name'                  => 'Name',
14
	'label'                 => 'Label',
15
	'description'           => 'Description',
16
	'quantity'              => 'Quantity',
17
	'quantity_unit'         => 'Quantity Unit',
18
	'price'                 => 'Price',
19
	'unit_price'            => 'Unit Price',
20
	'net_price'             => 'Net Price',
21
	'item_price'            => 'Item Price',
22
	'item_tax'              => 'Item Tax',
23
	'total'                 => 'Total',
24
	'total_amount'          => 'Total Amount',
25
	'total_discount_amount' => 'Total Discount Amount',
26
	'total_tax_amount'      => 'Total Tax Amount',
27
	'subtotal'              => 'Subtotal',
28
	'net_total'             => 'Net Total',
29
	'amount'                => 'Amount',
30
	'currency'              => 'Currency',
31
	'tax'                   => 'Tax',
32
	'tax_amount'            => 'Tax Amount',
33
	'tax_class'             => 'Tax Class',
34
	'tax_percentage'        => 'Tax Percentage',
35
	'tax_rate'              => 'Tax Rate',
36
	'vat'                   => array(
37
		'label' => 'VAT',
38
		'link'  => 'https://euvatrates.com/rates.json',
39
	),
40
	'vat_code'       => array(
41
		'label' => 'VAT Code',
42
		'link'  => 'https://euvatrates.com/rates.json',
43
	),
44
	'vat_category'   => array(
45
		'label' => 'VAT Category',
46
		'link'  => 'https://euvatrates.com/rates.json',
47
	),
48
	'shipping'             => 'Shipping',
49
	'type'                 => 'Type',
50
	'url'                  => 'URL',
51
	'image_url'            => 'Image URL',
52
	'status'               => 'Status',
53
	'stock'                => 'Stock',
54
	'discount'             => 'Discount',
55
	'pending'              => 'Pending',
56
	'category'             => 'Category',
57
	'discount'             => 'Discount',
58
	'product_id'           => 'Product ID',
59
	'product_url'          => 'Product URL',
60
	'price_id'             => 'Price ID',
61
);
62
63
$sources = array(
64
	'adyen'    => array(
65
		'label'      => 'Adyen',
66
		'link'       => 'https://docs.adyen.com/developers/api-reference/common-api#address',
67
		'components' => array(
68
69
		),
70
	),
71
	'ingenico' => array(
72
		'label'      => 'Ingenico',
73
		'link'       => 'https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/java/payments/create.html#payments-create-request-example',
74
		'components' => array(
75
76
		),
77
	),
78
	'klarna' => array(
79
		'label'      => 'Klarna',
80
		'link'       => 'https://developers.klarna.com/api/#payments-api-create-a-new-order',
81
		'components' => array(
82
			'type'  => array(
83
				'name'        => 'type',
84
				'description' => 'Order line type. Possible values:
85
physical
86
discount
87
shipping_fee
88
sales_tax
89
digital
90
gift_card
91
store_credit
92
surcharge',
93
			),
94
			'reference'  => array(
95
				'name'        => 'reference',
96
				'description' => 'Article number, SKU or similar. Max length is 64 characters.',
97
			),
98
			'name'  => array(
99
				'name'        => 'name',
100
				'description' => 'Descriptive item name.',
101
				'required'    => true,
102
			),
103
			'quantity'  => array(
104
				'name'        => 'quantity',
105
				'description' => 'Non-negative. The item quantity.',
106
				'required'    => true,
107
			),
108
			'quantity_unit'  => array(
109
				'name'        => 'quantity_unit',
110
				'description' => 'Unit used to describe the quantity, e.g. kg, pcs... If defined has to be 1-8 characters.',
111
			),
112
			'unit_price'  => array(
113
				'name'        => 'unit_price',
114
				'description' => 'Minor units. Includes tax, excludes discount. (max value: 100000000)',
115
				'required'    => true,
116
			),
117
			'tax_rate'  => array(
118
				'name'        => 'tax_rate',
119
				'description' => 'Non-negative. In percent, two implicit decimals. I.e 2500 = 25%.',
120
			),
121
			'total_amount'  => array(
122
				'name'        => 'total_amount',
123
				'description' => 'Includes tax and discount. Must match (quantity unit_price) - total_discount_amount within ±quantity. (max value: 100000000)',
124
				'required'    => true,
125
			),
126
			'total_discount_amount' => array(
127
				'name'        => 'total_discount_amount',
128
				'description' => 'Non-negative minor units. Includes tax.',
129
			),
130
			'total_tax_amount'  => array(
131
				'name'        => 'total_tax_amount',
132
				'description' => 'Must be within ±1 of total_amount - total_amount 10000 / (10000 + tax_rate). Negative when type is discount.',
133
			),
134
			'product_url'  => array(
135
				'name'        => 'product_url',
136
				'description' => 'URL to an image that can be later embedded in communications between Klarna and the customer. (max 1024 characters)',
137
			),
138
			'image_url'  => array(
139
				'name'        => 'image_url',
140
				'description' => 'URL to an image that can be later embedded in communications between Klarna and the customer. (max 1024 characters)',
141
			),
142
		),
143
	),
144
	'mollie' => array(
145
		'label'      => 'Mollie',
146
		'link'       => 'https://docs.mollie.com/guides/common-data-types#address-object',
147
		'components' => array(
148
149
		),
150
	),
151
	'multisafepay' => array(
152
		'label'      => 'MultiSafepay',
153
		'link'       => 'https://github.com/wp-pay-gateways/multisafepay',
154
		'components' => array(
155
156
		),
157
	),
158
	'omnikassa-2' => array(
159
		'label'      => 'OmniKassa 2.0',
160
		'link'       => 'https://github.com/wp-pay-gateways/omnikassa-2/blob/master/documentation/handleiding-api-koppeling-rabo-smartpin-en_29970886.pdf',
161
		'components' => array(
162
			'id'  => array(
163
				'name'        => 'id',
164
				'description' => 'Item id',
165
				'example'     => 'A1000',
166
			),
167
			'name' => array(
168
				'name'        => 'name',
169
				'description' => 'Item name',
170
				'required'    => true,
171
				'example'     => 'Jackie O Round Sunglasses',
172
			),
173
			'description'   => array(
174
				'name'        => 'description',
175
				'description' => 'Item description',
176
				'example'     => 'These distinct, feminine frames balance a classic Jackie-O styling with a modern look.',
177
			),
178
			'quantity'  => array(
179
				'name'        => 'quantity',
180
				'description' => 'number: 1-2147483647',
181
				'required'    => true,
182
				'example'     => '1',
183
			),
184
			'amount'  => array(
185
				'name'        => 'amount',
186
				'description' => 'The amount in cents, including VAT, of the item each, see below for more details.',
187
				'required'    => true,
188
				'example'     => 'If the piece price of an order item (excluding VAT) is € 12.98 and a VAT rate of 21% is applied. The piece price including VAT € 12.98 + 21% = € 15.71',
189
			),
190
			'tax'  => array(
191
				'name'        => 'tax',
192
				'description' => 'The VAT of the item each, see below for more details',
193
			),
194
			'category'  => array(
195
				'name'        => 'category',
196
				'description' => 'Product category: PHYSICAL or DIGITAL',
197
				'required'    => true,
198
				'example'     => 'PHYSICAL',
199
			),
200
			'vat_category'  => array(
201
				'name'        => 'vatCategory',
202
				'description' => 'The VAT category of the product. The values refer to the different rates that are used in the Netherlands: 1 = High (currently 21%), 2 = Low (currently 6%), 3 = Zero (0%), 4 = None (exempt from VAT)',
203
				'example'     => '1',
204
			),
205
		),
206
	),
207
	'paypal' => array(
208
		'label'      => 'PayPal',
209
		'link'       => 'https://developer.paypal.com/docs/api/payments/v1/#definition-item',
210
		'components' => array(
211
212
		),
213
	),
214
	'pay.nl' => array(
215
		'label'      => 'Pay.nl',
216
		'link'       => 'https://www.pay.nl/docs/developers.php',
217
		'components' => array(
218
			'id'  => array(
219
				'name'        => 'productId',
220
				'type'        => 'integer',
221
				'description' => 'Het interne product id binnen uw systeem',
222
			),
223
			'description' => array(
224
				'name'        => 'description',
225
				'type'        => 'string',
226
				'description' => 'Omschrijving van het bestelde product',
227
			),
228
			'price'  => array(
229
				'name'        => 'price',
230
				'type'        => 'integer',
231
				'description' => 'Productprijs in centen, dus €3,50 is 350',
232
			),
233
			'quantity'  => array(
234
				'name'        => 'quantity',
235
				'type'        => 'integer',
236
				'description' => 'Aantal bestelde producten met het betreffende product id',
237
			),
238
			'vat_code'  => array(
239
				'name'        => 'vatCode',
240
				'type'        => 'string',
241
				'description' => 'BTW code, mogelijke waarden: H: high, N: zero, L: low',
242
			),
243
			'vat_percentage'  => array(
244
				'name'        => 'vatPercentage',
245
			),
246
			'discount'        => array(
247
				'name'        => 'discount',
248
			),
249
		),
250
	),
251
	'sisow' => array(
252
		'label'      => 'Sisow',
253
		'link'       => 'https://www.sisow.nl/implementatie-api',
254
		'components' => array(
255
			'id'  => array(
256
				'name'        => 'product_id_x',
257
				'description' => 'Product code',
258
			),
259
			'description'  => array(
260
				'name'        => 'product_description_x',
261
				'description' => 'Omschrijving van het product',
262
			),
263
			'quantity'  => array(
264
				'name'        => 'product_quantity_x',
265
				'description' => 'Aantal besteld',
266
			),
267
			'net_price'  => array(
268
				'name'        => 'product_netprice_x',
269
				'description' => 'Netto prijs van het product',
270
			),
271
			'total'  => array(
272
				'name'        => 'product_total_x',
273
				'description' => 'Totaal bedrag van de orderregel inclusief BTW',
274
			),
275
			'net_total'  => array(
276
				'name'        => 'product_nettotal_x',
277
				'description' => 'Totaal bedrag van de orderregel exclusief BTW',
278
			),
279
			'tax'  => array(
280
				'name'        => 'product_tax_x',
281
				'description' => 'BTW bedrag in centen van de orderregel',
282
			),
283
			'tax_rate'  => array(
284
				'name'        => 'product_taxrate_x',
285
				'description' => 'BTW percentage (21% doorgeven als 2100)',
286
			),
287
		),
288
	),
289
	'easy-digital-downloads' => array(
290
		'label'      => 'Easy Digital Downloads',
291
		'links'      => array(
292
			'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/reporting/class-export-payments.php',
293
			'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L388-L396',
294
		),
295
		'components' => array(
296
			'id'  => array(
297
				'name'        => 'item_id',
298
				'description' => '$cart_item[\'id\']',
299
				'links'       => array(
300
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L389',
301
				),
302
			),
303
			'price'  => array(
304
				'name'        => 'price',
305
				'description' => '$cart_item[\'price\']',
306
				'links'       => array(
307
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L390',
308
				),
309
			),
310
			'item_price'  => array(
311
				'name'        => 'item_price',
312
				'description' => '$cart_item[\'item_price\']',
313
				'links'       => array(
314
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L391',
315
				),
316
			),
317
			'subtotal'  => array(
318
				'name'        => 'subtotal',
319
				'description' => '$cart_item[\'subtotal\']',
320
				'links'       => array(
321
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L392',
322
				),
323
			),
324
			'item_tax'  => array(
325
				'name'        => 'item_tax',
326
				'description' => '$cart_item[\'item_tax\']',
327
				'links'       => array(
328
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L393',
329
				),
330
			),
331
			'price_id'  => array(
332
				'name'        => 'price_id',
333
				'description' => '$cart_item[\'price_id\']',
334
				'links'       => array(
335
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L394',
336
				),
337
			),
338
			'quantity'  => array(
339
				'name'        => 'quantity',
340
				'description' => '$cart_item[\'quantity\']',
341
				'links'       => array(
342
					'https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.7/includes/admin/payments/view-order-details.php#L395',
343
				),
344
			),
345
		),
346
	),
347
	'gravityforms' => array(
348
		'label'      => 'Gravity Forms',
349
		'link'       => 'https://github.com/wp-premium/gravityforms/blob/2.3.2/includes/fields/class-gf-field-address.php#L48-L52',
350
		'components' => array(
351
352
		),
353
	),
354
	'memberpress' => array(
355
		'label'      => 'MemberPress',
356
		'link'       => 'https://github.com/wp-premium/memberpress-business/blob/1.3.36/app/models/MeprUser.php#L1296-L1317',
357
		'components' => array(
358
359
		),
360
	),
361
	'restrict-content-pro' => array(
362
		'label'      => 'Restrict Content Pro',
363
		'link'       => 'https://github.com/restrictcontentpro/restrict-content',
364
		'components' => array(
365
366
		),
367
	),
368
	'woocommerce' => array(
369
		'label'      => 'WooCommerce',
370
		'links'      => array(
371
			'https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-order-item.php',
372
			'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/api/legacy/v1/class-wc-api-orders.php#L98-L234'
373
		),
374
		'components' => array(
375
			'id'  => array(
376
				'name'        => 'id',
377
			),
378
			'subtotal'  => array(
379
				'name'        => 'subtotal',
380
				'description' => array(
381
					'Get line subtotal - this is the cost before discount.',
382
					'wc_format_decimal( $order->get_line_subtotal( $item ), 2 )',
383
					'public function get_line_subtotal( $item, $inc_tax = false, $round = true )',
384
				),
385
				'links'       => array(
386
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/api/legacy/v1/class-wc-api-orders.php#L181',
387
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/abstracts/abstract-wc-order.php#L1511-L1533',
388
				),
389
			),
390
			'total'  => array(
391
				'name'        => 'total',
392
				'description' => array(
393
					'Calculate line total - useful for gateways.',
394
					'wc_format_decimal( $order->get_line_total( $item ), 2 )',
395
					'public function get_line_total( $item, $inc_tax = false, $round = true )',
396
				),
397
				'links'       => array(
398
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/api/legacy/v1/class-wc-api-orders.php#L182',
399
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/abstracts/abstract-wc-order.php#L1559-L1579',
400
				),
401
			),
402
			'total_tax'  => array(
403
				'name'        => 'total_tax',
404
				'description' => array(
405
					'Get line tax - useful for gateways.',
406
					'wc_format_decimal( $order->get_line_tax( $item ), 2 )',
407
					'public function get_line_tax( $item )',
408
					'public function get_total_tax( $context = \'view\' )',
409
				),
410
				'links'       => array(
411
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/api/legacy/v1/class-wc-api-orders.php#L183',
412
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/abstracts/abstract-wc-order.php#L1599-L1607',
413
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/abstracts/abstract-wc-order.php#L363-L371',
414
				),
415
			),
416
			'price'  => array(
417
				'name'        => 'price',
418
				'description' => array(
419
					'Calculate item cost - useful for gateways.',
420
					'wc_format_decimal( $order->get_item_total( $item ), 2 )',
421
					'public function get_item_total( $item, $inc_tax = false, $round = true )',
422
				),
423
				'links'       => array(
424
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/api/legacy/v1/class-wc-api-orders.php#L184',
425
					'https://github.com/woocommerce/woocommerce/blob/3.4.5/includes/abstracts/abstract-wc-order.php#L1535-L1557',
426
				),
427
			),
428
			'quantity'  => array(
429
				'name'        => 'quantity',
430
			),
431
			'tax_class'  => array(
432
				'name'        => 'tax_class',
433
			),
434
			'name'  => array(
435
				'name'        => 'name',
436
			),
437
			'product_id'  => array(
438
				'name'        => 'product_id',
439
			),
440
			'sku'  => array(
441
				'name'        => 'sku',
442
			),
443
		),
444
	),
445
	'google-analytics' => array(
446
		'label'      => 'Google Analytics',
447
		'link'       => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce',
448
		'components' => array(
449
			'id'  => array(
450
				'name'        => 'id',
451
				'description' => 'The transaction ID. This ID is what links items to the transactions to which they belong. (e.g. 1234)',
452
				'required'    => true,
453
			),
454
			'name'  => array(
455
				'name'        => 'name',
456
				'description' => 'The item name. (e.g. Fluffy Pink Bunnies)',
457
				'required'    => true,
458
			),
459
			'sku'  => array(
460
				'name'        => 'sku',
461
				'description' => 'Specifies the SKU or item code. (e.g. SKU47)',
462
			),
463
			'category'  => array(
464
				'name'        => 'category',
465
				'description' => 'The category to which the item belongs (e.g. Party Toys)',
466
			),
467
			'price'  => array(
468
				'name'        => 'price',
469
				'description' => 'The individual, unit, price for each item. (e.g. 11.99)',
470
			),
471
			'quantity'  => array(
472
				'name'        => 'quantity',
473
				'description' => 'The number of units purchased in the transaction. If a non-integer value is passed into this field (e.g. 1.5), it will be rounded to the closest integer value.',
474
			),
475
		),
476
	),
477
	'mailchimp' => array(
478
		'label'      => 'MailChimp',
479
		'link'       => 'https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/',
480
		'components' => array(
481
			'id'  => array(
482
				'name'        => 'id',
483
				'description' => 'A unique identifier for the cart line item.',
484
			),
485
			'quantity'  => array(
486
				'name'        => 'quantity',
487
				'description' => 'The quantity of a cart line item.',
488
			),
489
			'price'  => array(
490
				'name'        => 'price',
491
				'description' => 'The price of a cart line item.',
492
			),
493
		),
494
	),
495
	'apple-pay' => array(
496
		'label'      => 'Apple Pay',
497
		'link'       => 'https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitem',
498
		'components' => array(
499
			'label'  => array(
500
				'name'        => 'label',
501
				'description' => 'A short, localized description of the line item.',
502
				'required'    => true,
503
			),
504
			'amount' => array(
505
				'name'        => 'amount',
506
				'description' => 'The monetary amount of the line item.',
507
				'required'    => true,
508
			),
509
			'type'   => array(
510
				'name'        => 'type',
511
				'description' => 'A value that indicates whether the line item is final or pending.',
512
			),
513
		),
514
	),
515
	'schema.org' => array(
516
		'label'      => 'Schema.org',
517
		'link'       => 'https://schema.org/OrderItem',
518
		'components' => array(
519
			'number'       => array(
520
				'name'        => 'orderItemNumber',
521
				'description' => 'The identifier of the order item',
522
			),
523
			'status'       => array(
524
				'name'        => 'orderItemStatus',
525
				'description' => 'The current status of the order item.',
526
			),
527
			'quantity'     => array(
528
				'name'        => 'orderQuantity',
529
				'description' => 'The number of the item ordered. If the property is not set, assume the quantity is one.',
530
			),
531
		),
532
	),
533
	'payment-request' => array(
534
		'label'      => 'Payment Request API',
535
		'link'       => 'https://www.w3.org/TR/payment-request/#dom-paymentitem',
536
		'components' => array(
537
			'label'       => array(
538
				'name'        => 'label',
539
				'description' => 'A human-readable description of the item. The user agent may display this to the user.',
540
				'required'    => true,
541
			),
542
			'amount'       => array(
543
				'name'        => 'amount',
544
				'description' => 'A PaymentCurrencyAmount containing the monetary amount for the item.',
545
				'required'    => true,
546
			),
547
			'pending'       => array(
548
				'name'        => 'pending',
549
				'description' => 'A boolean. When set to true it means that the amount member is not final. This is commonly used to show items such as shipping or tax amounts that depend upon selection of shipping address or shipping option. User agents MAY indicate pending fields in the user interface for the payment request.',
550
				'required'    => true,
551
			),
552
		),
553
	),
554
);
555
556
function print_link( $array ) {
557
	$links = array();
558
559
	if ( array_key_exists( 'links', $array ) ) {
560
		$links = $array['links'];
561
	}
562
563
	if ( array_key_exists( 'link', $array ) ) {
564
		$links[] = $array['link'];
565
	}
566
567
	$html = array();
568
569
	foreach ( $links as $link ) {
570
		$html[] = sprintf(
571
			'<a href="%s"><i class="fas fa-info-circle"></i></a>',
572
			$link
573
		);
574
	}
575
576
	echo implode( ' ', $html );
577
}
578
579
?>
580
<!doctype html>
581
582
<html lang="en">
583
	<head>
584
		<meta charset="utf-8">
585
586
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
587
588
		<!-- Bootstrap CSS -->
589
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
590
591
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
592
593
		<title>Pronamic Pay - Payment Items</title>
594
	</head>
595
596
	<body>
597
		<h1>Pronamic Pay - Payment Items</h1>
598
599
		<table class="table table-sm table-striped table-hover">
600
			<thead>
601
				<tr>
602
					<th scope="col">Component</th>
603
604
					<?php foreach ( $sources as $source ) : ?>
605
606
						<th scope="col">
607
							<?php
608
609
							echo $source['label'];
610
611
							echo ' ';
612
613
							print_link( $source );
614
615
							?>
616
						</th>
617
618
					<?php endforeach; ?>
619
620
				</tr>
621
			</thead>
622
623
			<tbody>
624
				
625
				<?php foreach ( $components as $key => $data ) : ?>
626
627
					<tr>
628
						<th scope="row">
629
							<?php
630
631
							if ( is_array( $data ) ) {
632
								echo $data['label'];
633
634
								echo ' ';
635
636
								print_link( $data );
637
							} else {
638
								echo $data;
639
							}
640
641
							?>
642
						</th>
643
644
						<?php foreach ( $sources as $source ) : ?>
645
646
							<td>
647
								<?php
648
649
								if ( isset( $source['components'][ $key ] ) ) {
650
									$component = $source['components'][ $key ];
651
652
									$name     = null;
653
									$tip      = null;
654
									$optional = null;
655
									$warning  = null;
656
657
									if ( is_array( $component ) ) {
658
										$name     = $component['name'];
659
660
										if ( array_key_exists( 'description', $component ) ) {
661
											$description = $component['description'];
662
											$description = is_array( $description ) ? $description : array( $description );
663
664
											$tip = implode( "\r\n", $description );
665
										}
666
667
										if ( array_key_exists( 'optional', $component ) ) {
668
											$optional = $component['optional'];
669
										}
670
671
										if ( array_key_exists( 'required', $component ) ) {
672
											$optional = ! $component['required'];
673
										}
674
675
										if ( array_key_exists( 'warning', $component ) ) {
676
											$warning = $component['warning'];
677
										}
678
									} else {
679
										$name = $component;
680
									}
681
682
									printf(
683
										'<code>%s</code>',
684
										$name
685
									);
686
687
									if ( ! empty( $tip ) ) {
688
										echo ' ';
689
690
										printf(
691
											'<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="top" title="%s"></i>',
692
											$tip
693
										);
694
									}
695
696
									if ( null !== $optional ) {
697
										echo ' ';
698
699
										printf(
700
											'<i class="fas %s" data-toggle="tooltip" data-placement="top" title="%s"></i>',
701
											$optional ? 'fa-dot-circle' : 'fa-circle',
702
											$optional ? 'Optional' : 'Required'
703
										);
704
									}
705
706
									if ( null !== $warning ) {
707
										echo ' ';
708
709
										printf(
710
											'<i class="fas fa-exclamation-triangle" data-toggle="tooltip" data-placement="top" title="%s"></i>',
711
											$warning
712
										);
713
									}
714
715
									echo ' ';
716
717
									print_link( $component );
718
								}
719
720
								?>
721
							</td>
722
723
						<?php endforeach; ?>
724
					</tr>
725
726
				<?php endforeach; ?>
727
728
			</tbody>
729
		</table>
730
731
		<h2>Links</h2>
732
733
		<table class="table table-striped">
734
			<thead>
735
				<tr>
736
					<th scope="col">Title</th>
737
					<th scope="col">URL</th>
738
					<th scope="col">Description</th>
739
				</tr>
740
			</thead>
741
742
			<tbody>
743
				<tr>
744
					<td>
745
						Payment Request API - `PaymentItem` dictionary
746
					</td>
747
					<td>
748
						<a href="https://www.w3.org/TR/payment-request/#dom-paymentitem">https://www.w3.org/TR/payment-request/#dom-paymentitem</a>						
749
					</td>
750
					<td></td>
751
				</tr>
752
			</tbody>
753
		</table>
754
755
		<!-- Optional JavaScript -->
756
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
757
		<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
758
		<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
759
		<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
760
761
		<script type="text/javascript">
762
			jQuery( document ).ready( function( $ ) {
763
				$( '[data-toggle="tooltip"]' ).tooltip();
764
			} );
765
		</script>
766
	</body>
767
</html>
768