diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
commit | 10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch) | |
tree | b4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/modules/simple-payments/simple-payments.php | |
parent | Updating script for Update (diff) | |
download | blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2 blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip |
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/simple-payments/simple-payments.php')
-rw-r--r-- | plugins/jetpack/modules/simple-payments/simple-payments.php | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/plugins/jetpack/modules/simple-payments/simple-payments.php b/plugins/jetpack/modules/simple-payments/simple-payments.php index e1b7f8d7..c68381de 100644 --- a/plugins/jetpack/modules/simple-payments/simple-payments.php +++ b/plugins/jetpack/modules/simple-payments/simple-payments.php @@ -13,6 +13,8 @@ class Jetpack_Simple_Payments { static $css_classname_prefix = 'jetpack-simple-payments'; + static $required_plan; + // Increase this number each time there's a change in CSS or JS to bust cache. static $version = '0.25'; @@ -23,6 +25,7 @@ class Jetpack_Simple_Payments { if ( ! self::$instance ) { self::$instance = new self(); self::$instance->register_init_hooks(); + self::$required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? 'value_bundle' : 'jetpack_premium'; } return self::$instance; } @@ -64,7 +67,14 @@ class Jetpack_Simple_Payments { if ( $this->is_enabled_jetpack_simple_payments() ) { jetpack_register_block( 'jetpack/simple-payments' ); } else { - Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/simple-payments', 'missing_plan' ); + Jetpack_Gutenberg::set_extension_unavailable( + 'jetpack/simple-payments', + 'missing_plan', + array( + 'required_feature' => 'simple-payments', + 'required_plan' => self::$required_plan, + ) + ); } } @@ -146,7 +156,10 @@ class Jetpack_Simple_Payments { } if ( ! $this->is_enabled_jetpack_simple_payments() ) { - return $this->output_admin_warning( $data ); + if ( ! is_feed() ) { + $this->output_admin_warning( $data ); + } + return; } if ( ! wp_script_is( 'paypal-express-checkout', 'enqueued' ) ) { @@ -168,38 +181,11 @@ class Jetpack_Simple_Payments { if ( ! current_user_can( 'manage_options' ) ) { return; } - $css_prefix = self::$css_classname_prefix; - - $support_url = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) - ? 'https://support.wordpress.com/simple-payments/' - : 'https://jetpack.com/support/simple-payment-button/'; - return sprintf( ' -<div class="%1$s"> - <div class="%2$s"> - <div class="%3$s"> - <div class="%4$s" id="%5$s"> - <p>%6$s</p> - <p>%7$s</p> - </div> - </div> - </div> -</div> -', - esc_attr( "{$data['class']} ${css_prefix}-wrapper" ), - esc_attr( "${css_prefix}-product" ), - esc_attr( "${css_prefix}-details" ), - esc_attr( "${css_prefix}-purchase-message show error" ), - esc_attr( "{$data['dom_id']}-message-container" ), - sprintf( - wp_kses( - __( 'Your plan doesn\'t include Simple Payments. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more and upgrade</a>.', 'jetpack' ), - array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array() ) ) - ), - esc_url( $support_url ) - ), - esc_html__( '(Only administrators will see this message.)', 'jetpack' ) - ); + jetpack_require_lib( 'components' ); + return Jetpack_Components::render_upgrade_nudge( array( + 'plan' => self::$required_plan + ) ); } function output_shortcode( $data ) { @@ -247,9 +233,9 @@ class Jetpack_Simple_Payments { $image, esc_attr( "${css_prefix}-details" ), esc_attr( "${css_prefix}-title" ), - $data['title'], + esc_html( $data['title'] ), esc_attr( "${css_prefix}-description" ), - $data['description'], + wp_kses( $data['description'], wp_kses_allowed_html( 'post' ) ), esc_attr( "${css_prefix}-price" ), esc_html( $data['price'] ), esc_attr( "${css_prefix}-purchase-message" ), @@ -391,11 +377,16 @@ class Jetpack_Simple_Payments { /** * Sanitize three-character ISO-4217 Simple payments currency * - * List has to be in sync with list at the client side: - * @link https://github.com/Automattic/wp-calypso/blob/6d02ffe73cc073dea7270a22dc30881bff17d8fb/client/lib/simple-payments/constants.js + * List has to be in sync with list at the block's client side and widget's backend side: + * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/extensions/blocks/simple-payments/constants.js#L9-L39 + * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/modules/widgets/simple-payments.php#L19-L44 * * Currencies should be supported by PayPal: - * @link https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ + * @link https://developer.paypal.com/docs/api/reference/currency-codes/ + * + * Indian Rupee (INR) not supported because at the time of the creation of this file + * because it's limited to in-country PayPal India accounts only. + * Discussion: https://github.com/Automattic/wp-calypso/pull/28236 */ public static function sanitize_currency( $currency ) { $valid_currencies = array( |