1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Simple Payments lets users embed a PayPal button fully integrated with wpcom to sell products on the site. |
4
|
|
|
* This is not a proper module yet, because not all the pieces are in place. Until everything is shipped, it can be turned |
5
|
|
|
* into module that can be enabled/disabled. |
6
|
|
|
*/ |
7
|
|
|
class Jetpack_Simple_Payments { |
8
|
|
|
// These have to be under 20 chars because that is CPT limit. |
9
|
|
|
static $post_type_order = 'jp_pay_order'; |
10
|
|
|
static $post_type_product = 'jp_pay_product'; |
11
|
|
|
|
12
|
|
|
static $shortcode = 'simple-payment'; |
13
|
|
|
|
14
|
|
|
static $css_classname_prefix = 'jetpack-simple-payments'; |
15
|
|
|
|
16
|
|
|
// Increase this number each time there's a change in CSS or JS to bust cache. |
17
|
|
|
static $version = '0.25'; |
18
|
|
|
|
19
|
|
|
// Classic singleton pattern: |
20
|
|
|
private static $instance; |
21
|
|
|
private function __construct() {} |
22
|
|
|
static function getInstance() { |
23
|
|
|
if ( ! self::$instance ) { |
24
|
|
|
self::$instance = new self(); |
25
|
|
|
self::$instance->register_init_hook(); |
26
|
|
|
} |
27
|
|
|
return self::$instance; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
private function register_scripts_and_styles() { |
31
|
|
|
/** |
32
|
|
|
* Paypal heavily discourages putting that script in your own server: |
33
|
|
|
* @see https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/ |
34
|
|
|
*/ |
35
|
|
|
wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true ); |
36
|
|
|
wp_register_script( 'paypal-express-checkout', plugins_url( '/paypal-express-checkout.js', __FILE__ ), |
37
|
|
|
array( 'jquery', 'paypal-checkout-js' ), self::$version ); |
38
|
|
|
wp_register_style( 'jetpack-simple-payments', plugins_url( '/simple-payments.css', __FILE__ ), array( 'dashicons' ) ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
private function register_init_hook() { |
42
|
|
|
add_action( 'init', array( $this, 'init_hook_action' ) ); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
private function register_shortcode() { |
46
|
|
|
add_shortcode( self::$shortcode, array( $this, 'parse_shortcode' ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function init_hook_action() { |
50
|
|
|
add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_rest_api_types' ) ); |
51
|
|
|
add_filter( 'jetpack_sync_post_meta_whitelist', array( $this, 'allow_sync_post_meta' ) ); |
52
|
|
|
$this->register_scripts_and_styles(); |
53
|
|
|
$this->register_shortcode(); |
54
|
|
|
$this->setup_cpts(); |
55
|
|
|
|
56
|
|
|
add_filter( 'the_content', array( $this, 'remove_auto_paragraph_from_product_description' ), 0 ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function remove_auto_paragraph_from_product_description( $content ) { |
60
|
|
|
if ( get_post_type() === self::$post_type_product ) { |
61
|
|
|
remove_filter( 'the_content', 'wpautop' ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $content; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function get_blog_id() { |
68
|
|
|
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
69
|
|
|
return get_current_blog_id(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return Jetpack_Options::get_option( 'id' ); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Used to check whether Simple Payments are enabled for given site. |
77
|
|
|
* |
78
|
|
|
* @return bool True if Simple Payments are enabled, false otherwise. |
79
|
|
|
*/ |
80
|
|
|
function is_enabled_jetpack_simple_payments() { |
81
|
|
|
/** |
82
|
|
|
* Can be used by plugin authors to disable the conflicting output of Simple Payments. |
83
|
|
|
* |
84
|
|
|
* @since 6.3.0 |
85
|
|
|
* |
86
|
|
|
* @param bool True if Simple Payments should be disabled, false otherwise. |
87
|
|
|
*/ |
88
|
|
|
if ( apply_filters( 'jetpack_disable_simple_payments', false ) ) { |
89
|
|
|
return false; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// For WPCOM sites |
93
|
|
|
if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'has_blog_sticker' ) ) { |
94
|
|
|
$site_id = $this->get_blog_id(); |
95
|
|
|
return has_blog_sticker( 'premium-plan', $site_id ) || has_blog_sticker( 'business-plan', $site_id ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
// For all Jetpack sites |
99
|
|
|
return Jetpack::is_active() && Jetpack::active_plan_supports( 'simple-payments'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
function parse_shortcode( $attrs, $content = false ) { |
103
|
|
|
if ( empty( $attrs['id'] ) ) { |
104
|
|
|
return; |
105
|
|
|
} |
106
|
|
|
$product = get_post( $attrs['id'] ); |
107
|
|
|
if ( ! $product || is_wp_error( $product ) ) { |
108
|
|
|
return; |
109
|
|
|
} |
110
|
|
|
if ( $product->post_type !== self::$post_type_product || 'trash' === $product->post_status ) { |
111
|
|
|
return; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
// We allow for overriding the presentation labels |
115
|
|
|
$data = shortcode_atts( array( |
116
|
|
|
'blog_id' => $this->get_blog_id(), |
117
|
|
|
'dom_id' => uniqid( self::$css_classname_prefix . '-' . $product->ID . '_', true ), |
118
|
|
|
'class' => self::$css_classname_prefix . '-' . $product->ID, |
119
|
|
|
'title' => get_the_title( $product ), |
120
|
|
|
'description' => $product->post_content, |
121
|
|
|
'cta' => get_post_meta( $product->ID, 'spay_cta', true ), |
122
|
|
|
'multiple' => get_post_meta( $product->ID, 'spay_multiple', true ) || '0' |
123
|
|
|
), $attrs ); |
124
|
|
|
|
125
|
|
|
$data['price'] = $this->format_price( |
126
|
|
|
get_post_meta( $product->ID, 'spay_price', true ), |
127
|
|
|
get_post_meta( $product->ID, 'spay_currency', true ) |
128
|
|
|
); |
129
|
|
|
|
130
|
|
|
$data['id'] = $attrs['id']; |
131
|
|
|
|
132
|
|
|
if( ! wp_style_is( 'jetpack-simple-payments', 'enqueue' ) ) { |
133
|
|
|
wp_enqueue_style( 'jetpack-simple-payments' ); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
if ( ! $this->is_enabled_jetpack_simple_payments() ) { |
137
|
|
|
return $this->output_admin_warning( $data ); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
if ( ! wp_script_is( 'paypal-express-checkout', 'enqueued' ) ) { |
141
|
|
|
wp_enqueue_script( 'paypal-express-checkout' ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
wp_add_inline_script( 'paypal-express-checkout', sprintf( |
145
|
|
|
"try{PaypalExpressCheckout.renderButton( '%d', '%d', '%s', '%d' );}catch(e){}", |
146
|
|
|
esc_js( $data['blog_id'] ), |
147
|
|
|
esc_js( $attrs['id'] ), |
148
|
|
|
esc_js( $data['dom_id'] ), |
149
|
|
|
esc_js( $data['multiple'] ) |
150
|
|
|
) ); |
151
|
|
|
|
152
|
|
|
return $this->output_shortcode( $data ); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
function output_admin_warning( $data ) { |
156
|
|
|
if ( ! current_user_can( 'manage_options' ) ) { |
157
|
|
|
return; |
158
|
|
|
} |
159
|
|
|
$css_prefix = self::$css_classname_prefix; |
160
|
|
|
|
161
|
|
|
$support_url = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) |
162
|
|
|
? 'https://support.wordpress.com/simple-payments/' |
163
|
|
|
: 'https://jetpack.com/support/simple-payment-button/'; |
164
|
|
|
|
165
|
|
|
return sprintf( ' |
166
|
|
|
<div class="%1$s"> |
167
|
|
|
<div class="%2$s"> |
168
|
|
|
<div class="%3$s"> |
169
|
|
|
<div class="%4$s" id="%5$s"> |
170
|
|
|
<p>%6$s</p> |
171
|
|
|
<p>%7$s</p> |
172
|
|
|
</div> |
173
|
|
|
</div> |
174
|
|
|
</div> |
175
|
|
|
</div> |
176
|
|
|
', |
177
|
|
|
esc_attr( "{$data['class']} ${css_prefix}-wrapper" ), |
178
|
|
|
esc_attr( "${css_prefix}-product" ), |
179
|
|
|
esc_attr( "${css_prefix}-details" ), |
180
|
|
|
esc_attr( "${css_prefix}-purchase-message show error" ), |
181
|
|
|
esc_attr( "{$data['dom_id']}-message-container" ), |
182
|
|
|
sprintf( |
183
|
|
|
wp_kses( |
184
|
|
|
__( 'Your plan doesn\'t include Simple Payments. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more and upgrade</a>.', 'jetpack' ), |
185
|
|
|
array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array() ) ) |
186
|
|
|
), |
187
|
|
|
esc_url( $support_url ) |
188
|
|
|
), |
189
|
|
|
esc_html__( '(Only administrators will see this message.)', 'jetpack' ) |
190
|
|
|
); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
function output_shortcode( $data ) { |
194
|
|
|
$items = ''; |
195
|
|
|
$css_prefix = self::$css_classname_prefix; |
196
|
|
|
|
197
|
|
|
if ( $data['multiple'] ) { |
198
|
|
|
$items = sprintf( ' |
199
|
|
|
<div class="%1$s"> |
200
|
|
|
<input class="%2$s" type="number" value="1" min="1" id="%3$s" /> |
201
|
|
|
</div> |
202
|
|
|
', |
203
|
|
|
esc_attr( "${css_prefix}-items" ), |
204
|
|
|
esc_attr( "${css_prefix}-items-number" ), |
205
|
|
|
esc_attr( "{$data['dom_id']}_number" ) |
206
|
|
|
); |
207
|
|
|
} |
208
|
|
|
$image = ""; |
209
|
|
|
if( has_post_thumbnail( $data['id'] ) ) { |
210
|
|
|
$image = sprintf( '<div class="%1$s"><div class="%2$s">%3$s</div></div>', |
211
|
|
|
esc_attr( "${css_prefix}-product-image" ), |
212
|
|
|
esc_attr( "${css_prefix}-image" ), |
213
|
|
|
get_the_post_thumbnail( $data['id'], 'full' ) |
214
|
|
|
); |
215
|
|
|
} |
216
|
|
|
return sprintf( ' |
217
|
|
|
<div class="%1$s"> |
218
|
|
|
<div class="%2$s"> |
219
|
|
|
%3$s |
220
|
|
|
<div class="%4$s"> |
221
|
|
|
<div class="%5$s"><p>%6$s</p></div> |
222
|
|
|
<div class="%7$s"><p>%8$s</p></div> |
223
|
|
|
<div class="%9$s"><p>%10$s</p></div> |
224
|
|
|
<div class="%11$s" id="%12$s"></div> |
225
|
|
|
<div class="%13$s"> |
226
|
|
|
%14$s |
227
|
|
|
<div class="%15$s" id="%16$s"></div> |
228
|
|
|
</div> |
229
|
|
|
</div> |
230
|
|
|
</div> |
231
|
|
|
</div> |
232
|
|
|
', |
233
|
|
|
esc_attr( "{$data['class']} ${css_prefix}-wrapper" ), |
234
|
|
|
esc_attr( "${css_prefix}-product" ), |
235
|
|
|
$image, |
236
|
|
|
esc_attr( "${css_prefix}-details" ), |
237
|
|
|
esc_attr( "${css_prefix}-title" ), |
238
|
|
|
$data['title'], |
239
|
|
|
esc_attr( "${css_prefix}-description" ), |
240
|
|
|
$data['description'], |
241
|
|
|
esc_attr( "${css_prefix}-price" ), |
242
|
|
|
$data['price'], // Escaped by format_price |
243
|
|
|
esc_attr( "${css_prefix}-purchase-message" ), |
244
|
|
|
esc_attr( "{$data['dom_id']}-message-container" ), |
245
|
|
|
esc_attr( "${css_prefix}-purchase-box" ), |
246
|
|
|
$items, |
247
|
|
|
esc_attr( "${css_prefix}-button" ), |
248
|
|
|
esc_attr( "{$data['dom_id']}_button" ) |
249
|
|
|
); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* HTML format price for display |
254
|
|
|
* |
255
|
|
|
* Uses currency-aware formatting to output a formatted price for HTML with a simple fallback. |
256
|
|
|
* |
257
|
|
|
* Largely inspired by WordPress.com's Store_Price::display_currency |
258
|
|
|
* |
259
|
|
|
* @param string $price Price. |
260
|
|
|
* @param string $currency Currency. |
261
|
|
|
* @return string HTML-ready price to display |
262
|
|
|
*/ |
263
|
|
|
private function format_price( $price, $currency ) { |
264
|
|
|
$currency_details = self::get_currency( $currency ); |
265
|
|
|
|
266
|
|
|
if ( $currency_details ) { |
267
|
|
|
$symbol = sprintf( |
268
|
|
|
'<abbr title="%s">%s</abbr>', |
269
|
|
|
esc_attr( $currency_details['desc'] ), |
270
|
|
|
esc_html( $currency_details['symbol'] ) |
271
|
|
|
); |
272
|
|
|
|
273
|
|
|
// Ensure USD displays as 1234.56 even in non-US locales. |
274
|
|
|
$amount = 'USD' === $currency |
275
|
|
|
? number_format( $price, $currency_details['decimal'], '.', ',' ) |
276
|
|
|
: number_format_i18n( $price, $currency_details['decimal'] ); |
277
|
|
|
|
278
|
|
|
return sprintf( |
279
|
|
|
$currency_details['format'], |
280
|
|
|
$symbol, |
281
|
|
|
esc_html( $amount ) |
282
|
|
|
); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
return esc_html( "$price $currency" ); |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Allows custom post types to be used by REST API. |
290
|
|
|
* @param $post_types |
291
|
|
|
* @see hook 'rest_api_allowed_post_types' |
292
|
|
|
* @return array |
293
|
|
|
*/ |
294
|
|
|
function allow_rest_api_types( $post_types ) { |
295
|
|
|
$post_types[] = self::$post_type_order; |
296
|
|
|
$post_types[] = self::$post_type_product; |
297
|
|
|
return $post_types; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
function allow_sync_post_meta( $post_meta ) { |
301
|
|
|
return array_merge( $post_meta, array( |
302
|
|
|
'spay_paypal_id', |
303
|
|
|
'spay_status', |
304
|
|
|
'spay_product_id', |
305
|
|
|
'spay_quantity', |
306
|
|
|
'spay_price', |
307
|
|
|
'spay_customer_email', |
308
|
|
|
'spay_currency', |
309
|
|
|
'spay_cta', |
310
|
|
|
'spay_email', |
311
|
|
|
'spay_multiple', |
312
|
|
|
'spay_formatted_price', |
313
|
|
|
) ); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Sets up the custom post types for the module. |
318
|
|
|
*/ |
319
|
|
|
function setup_cpts() { |
320
|
|
|
|
321
|
|
|
/* |
322
|
|
|
* ORDER data structure. holds: |
323
|
|
|
* title = customer_name | 4xproduct_name |
324
|
|
|
* excerpt = customer_name + customer contact info + customer notes from paypal form |
325
|
|
|
* metadata: |
326
|
|
|
* spay_paypal_id - paypal id of transaction |
327
|
|
|
* spay_status |
328
|
|
|
* spay_product_id - post_id of bought product |
329
|
|
|
* spay_quantity - quantity of product |
330
|
|
|
* spay_price - item price at the time of purchase |
331
|
|
|
* spay_customer_email - customer email |
332
|
|
|
* ... (WIP) |
333
|
|
|
*/ |
334
|
|
|
$order_capabilities = array( |
335
|
|
|
'edit_post' => 'edit_posts', |
336
|
|
|
'read_post' => 'read_private_posts', |
337
|
|
|
'delete_post' => 'delete_posts', |
338
|
|
|
'edit_posts' => 'edit_posts', |
339
|
|
|
'edit_others_posts' => 'edit_others_posts', |
340
|
|
|
'publish_posts' => 'publish_posts', |
341
|
|
|
'read_private_posts' => 'read_private_posts', |
342
|
|
|
); |
343
|
|
|
$order_args = array( |
344
|
|
|
'label' => esc_html_x( 'Order', 'noun: a quantity of goods or items purchased or sold', 'jetpack' ), |
345
|
|
|
'description' => esc_html__( 'Simple Payments orders', 'jetpack' ), |
346
|
|
|
'supports' => array( 'custom-fields', 'excerpt' ), |
347
|
|
|
'hierarchical' => false, |
348
|
|
|
'public' => false, |
349
|
|
|
'show_ui' => false, |
350
|
|
|
'show_in_menu' => false, |
351
|
|
|
'show_in_admin_bar' => false, |
352
|
|
|
'show_in_nav_menus' => false, |
353
|
|
|
'can_export' => true, |
354
|
|
|
'has_archive' => false, |
355
|
|
|
'exclude_from_search' => true, |
356
|
|
|
'publicly_queryable' => false, |
357
|
|
|
'rewrite' => false, |
358
|
|
|
'capabilities' => $order_capabilities, |
359
|
|
|
'show_in_rest' => true, |
360
|
|
|
); |
361
|
|
|
register_post_type( self::$post_type_order, $order_args ); |
362
|
|
|
|
363
|
|
|
/* |
364
|
|
|
* PRODUCT data structure. Holds: |
365
|
|
|
* title - title |
366
|
|
|
* content - description |
367
|
|
|
* thumbnail - image |
368
|
|
|
* metadata: |
369
|
|
|
* spay_price - price |
370
|
|
|
* spay_formatted_price |
371
|
|
|
* spay_currency - currency code |
372
|
|
|
* spay_cta - text with "Buy" or other CTA |
373
|
|
|
* spay_email - paypal email |
374
|
|
|
* spay_multiple - allow for multiple items |
375
|
|
|
* spay_status - status. { enabled | disabled } |
376
|
|
|
*/ |
377
|
|
|
$product_capabilities = array( |
378
|
|
|
'edit_post' => 'edit_posts', |
379
|
|
|
'read_post' => 'read_private_posts', |
380
|
|
|
'delete_post' => 'delete_posts', |
381
|
|
|
'edit_posts' => 'publish_posts', |
382
|
|
|
'edit_others_posts' => 'edit_others_posts', |
383
|
|
|
'publish_posts' => 'publish_posts', |
384
|
|
|
'read_private_posts' => 'read_private_posts', |
385
|
|
|
); |
386
|
|
|
$product_args = array( |
387
|
|
|
'label' => esc_html__( 'Product', 'jetpack' ), |
388
|
|
|
'description' => esc_html__( 'Simple Payments products', 'jetpack' ), |
389
|
|
|
'supports' => array( 'title', 'editor','thumbnail', 'custom-fields', 'author' ), |
390
|
|
|
'hierarchical' => false, |
391
|
|
|
'public' => false, |
392
|
|
|
'show_ui' => false, |
393
|
|
|
'show_in_menu' => false, |
394
|
|
|
'show_in_admin_bar' => false, |
395
|
|
|
'show_in_nav_menus' => false, |
396
|
|
|
'can_export' => true, |
397
|
|
|
'has_archive' => false, |
398
|
|
|
'exclude_from_search' => true, |
399
|
|
|
'publicly_queryable' => false, |
400
|
|
|
'rewrite' => false, |
401
|
|
|
'capabilities' => $product_capabilities, |
402
|
|
|
'show_in_rest' => true, |
403
|
|
|
); |
404
|
|
|
register_post_type( self::$post_type_product, $product_args ); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* Format a price for display |
409
|
|
|
* |
410
|
|
|
* Largely taken from WordPress.com Store_Price class |
411
|
|
|
* |
412
|
|
|
* The currency array will have the shape: |
413
|
|
|
* format => string sprintf format with placeholders `%1$s`: Symbol `%2$s`: Price. |
414
|
|
|
* symbol => string Symbol string |
415
|
|
|
* desc => string Text description of currency |
416
|
|
|
* decimal => int Number of decimal places |
417
|
|
|
* |
418
|
|
|
* @param string $the_currency The desired currency, e.g. 'USD'. |
419
|
|
|
* @return ?array Currency object or null if not found. |
|
|
|
|
420
|
|
|
*/ |
421
|
|
|
private static function get_currency( $the_currency ) { |
422
|
|
|
$currencies = array( |
423
|
|
|
'USD' => array( |
424
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
425
|
|
|
'symbol' => '$', |
426
|
|
|
'desc' => _x( 'United States Dollars', 'currency', 'jetpack' ), |
427
|
|
|
'decimal' => 2, |
428
|
|
|
), |
429
|
|
|
'GBP' => array( |
430
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
431
|
|
|
'symbol' => '£', |
432
|
|
|
'desc' => _x( 'British Pounds', 'currency', 'jetpack' ), |
433
|
|
|
'decimal' => 2, |
434
|
|
|
), |
435
|
|
|
'JPY' => array( |
436
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
437
|
|
|
'symbol' => '¥', |
438
|
|
|
'desc' => _x( 'Japanese Yen', 'currency', 'jetpack' ), |
439
|
|
|
'decimal' => 0, |
440
|
|
|
), |
441
|
|
|
'BRL' => array( |
442
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
443
|
|
|
'symbol' => 'R$', |
444
|
|
|
'desc' => _x( 'Brazilian real', 'currency', 'jetpack' ), |
445
|
|
|
'decimal' => 2, |
446
|
|
|
), |
447
|
|
|
'EUR' => array( |
448
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
449
|
|
|
'symbol' => '€', |
450
|
|
|
'desc' => _x( 'Euro', 'currency', 'jetpack' ), |
451
|
|
|
'decimal' => 2, |
452
|
|
|
), |
453
|
|
|
'NZD' => array( |
454
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
455
|
|
|
'symbol' => 'NZ$', |
456
|
|
|
'desc' => _x( 'New Zealand Dollars', 'currency', 'jetpack' ), |
457
|
|
|
'decimal' => 2, |
458
|
|
|
), |
459
|
|
|
'AUD' => array( |
460
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
461
|
|
|
'symbol' => 'A$', |
462
|
|
|
'desc' => _x( 'Australian Dollars', 'currency', 'jetpack' ), |
463
|
|
|
'decimal' => 2, |
464
|
|
|
), |
465
|
|
|
'CAD' => array( |
466
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
467
|
|
|
'symbol' => 'C$', |
468
|
|
|
'desc' => _x( 'Canadian Dollars', 'currency', 'jetpack' ), |
469
|
|
|
'decimal' => 2, |
470
|
|
|
), |
471
|
|
|
'INR' => array( |
472
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
473
|
|
|
'symbol' => '₹', |
474
|
|
|
'desc' => _x( 'Indian Rupees', 'currency', 'jetpack' ), |
475
|
|
|
'decimal' => 0, |
476
|
|
|
), |
477
|
|
|
'ILS' => array( |
478
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
479
|
|
|
'symbol' => '₪', |
480
|
|
|
'desc' => _x( 'New Israeli Shekels', 'currency', 'jetpack' ), |
481
|
|
|
'decimal' => 2, |
482
|
|
|
), |
483
|
|
|
'RUB' => array( |
484
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
485
|
|
|
'symbol' => '₽', |
486
|
|
|
'desc' => _x( 'Russian Rubles', 'currency', 'jetpack' ), |
487
|
|
|
'decimal' => 2, |
488
|
|
|
), |
489
|
|
|
'MXN' => array( |
490
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
491
|
|
|
'symbol' => 'MX$', |
492
|
|
|
'desc' => _x( 'Mexican Pesos', 'currency', 'jetpack' ), |
493
|
|
|
'decimal' => 2, |
494
|
|
|
), |
495
|
|
|
'SEK' => array( |
496
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
497
|
|
|
'symbol' => 'Skr', |
498
|
|
|
'desc' => _x( 'Swedish Kronor', 'currency', 'jetpack' ), |
499
|
|
|
'decimal' => 2, |
500
|
|
|
), |
501
|
|
|
'HUF' => array( |
502
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
503
|
|
|
'symbol' => 'Ft', |
504
|
|
|
'desc' => _x( 'Hungarian Forints', 'currency', 'jetpack' ), |
505
|
|
|
'decimal' => 0, // Decimals are supported by Stripe but not by PayPal. |
506
|
|
|
), |
507
|
|
|
'CHF' => array( |
508
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
509
|
|
|
'symbol' => 'CHF', |
510
|
|
|
'desc' => _x( 'Swiss Francs', 'currency', 'jetpack' ), |
511
|
|
|
'decimal' => 2, |
512
|
|
|
), |
513
|
|
|
'CZK' => array( |
514
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
515
|
|
|
'symbol' => 'Kč', |
516
|
|
|
'desc' => _x( 'Czech Koruna', 'currency', 'jetpack' ), |
517
|
|
|
'decimal' => 2, |
518
|
|
|
), |
519
|
|
|
'DKK' => array( |
520
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
521
|
|
|
'symbol' => 'Dkr', |
522
|
|
|
'desc' => _x( 'Denmark Kroner', 'currency', 'jetpack' ), |
523
|
|
|
'decimal' => 2, |
524
|
|
|
), |
525
|
|
|
'HKD' => array( |
526
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
527
|
|
|
'symbol' => 'HK$', |
528
|
|
|
'desc' => _x( 'Hong Kong Dollars', 'currency', 'jetpack' ), |
529
|
|
|
'decimal' => 2, |
530
|
|
|
), |
531
|
|
|
'NOK' => array( |
532
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
533
|
|
|
'symbol' => 'Kr', |
534
|
|
|
'desc' => _x( 'Norway Kroner', 'currency', 'jetpack' ), |
535
|
|
|
'decimal' => 2, |
536
|
|
|
), |
537
|
|
|
'PHP' => array( |
538
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
539
|
|
|
'symbol' => '₱', |
540
|
|
|
'desc' => _x( 'Philippine Peso', 'currency', 'jetpack' ), |
541
|
|
|
'decimal' => 2, |
542
|
|
|
), |
543
|
|
|
'PLN' => array( |
544
|
|
|
'format' => '%2$s %1$s', // 1: Symbol 2: currency value |
545
|
|
|
'symbol' => 'PLN', |
546
|
|
|
'desc' => _x( 'Polish Zloty', 'currency', 'jetpack' ), |
547
|
|
|
'decimal' => 2, |
548
|
|
|
), |
549
|
|
|
'SGD' => array( |
550
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
551
|
|
|
'symbol' => 'S$', |
552
|
|
|
'desc' => _x( 'Singapore Dollars', 'currency', 'jetpack' ), |
553
|
|
|
'decimal' => 2, |
554
|
|
|
), |
555
|
|
|
'TWD' => array( |
556
|
|
|
'format' => '%1$s%2$s', // 1: Symbol 2: currency value |
557
|
|
|
'symbol' => 'NT$', |
558
|
|
|
'desc' => _x( 'New Taiwan Dollars', 'currency', 'jetpack' ), |
559
|
|
|
'decimal' => 0, // Decimals are supported by Stripe but not by PayPal. |
560
|
|
|
), |
561
|
|
|
'THB' => array( |
562
|
|
|
'format' => '%2$s%1$s', // 1: Symbol 2: currency value |
563
|
|
|
'symbol' => '฿', |
564
|
|
|
'desc' => _x( 'Thai Baht', 'currency', 'jetpack' ), |
565
|
|
|
'decimal' => 2, |
566
|
|
|
), |
567
|
|
|
|
568
|
|
|
); |
569
|
|
|
|
570
|
|
|
if ( isset( $currencies[ $the_currency ] ) ) { |
571
|
|
|
return $currencies[ $the_currency ]; |
572
|
|
|
} |
573
|
|
|
return null; |
574
|
|
|
} |
575
|
|
|
} |
576
|
|
|
Jetpack_Simple_Payments::getInstance(); |
577
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.