| 1 |  |  | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  * @package Jetpack | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Automattic\Jetpack\Blocks; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Jetpack_Simple_Payments | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class Jetpack_Simple_Payments { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	// These have to be under 20 chars because that is CPT limit. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	static $post_type_order = 'jp_pay_order'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	static $post_type_product = 'jp_pay_product'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	static $shortcode = 'simple-payment'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	static $css_classname_prefix = 'jetpack-simple-payments'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	static $required_plan; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	// Increase this number each time there's a change in CSS or JS to bust cache. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	static $version = '0.25'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	// Classic singleton pattern: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	private static $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	private function __construct() {} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 32 |  | View Code Duplication | 	static function getInstance() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		if ( ! self::$instance ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 			self::$instance = new self(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 			self::$instance->register_init_hooks(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 			self::$required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? 'value_bundle' : 'jetpack_premium'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		return self::$instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	private function register_scripts_and_styles() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		 * Paypal heavily discourages putting that script in your own server: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		 * @see https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		wp_register_script( 'paypal-express-checkout', plugins_url( '/paypal-express-checkout.js', __FILE__ ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			array( 'jquery', 'paypal-checkout-js' ), self::$version ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		wp_register_style( 'jetpack-simple-payments', plugins_url( '/simple-payments.css', __FILE__ ), array( 'dashicons' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	private function register_init_hooks() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		add_action( 'init', array( $this, 'init_hook_action' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		add_action( 'rest_api_init', array( $this, 'register_meta_fields_in_rest_api' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	private function register_shortcode() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		add_shortcode( self::$shortcode, array( $this, 'parse_shortcode' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	public function init_hook_action() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_rest_api_types' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		add_filter( 'jetpack_sync_post_meta_whitelist', array( $this, 'allow_sync_post_meta' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		if ( ! is_admin() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			$this->register_scripts_and_styles(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		$this->register_shortcode(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		$this->setup_cpts(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		add_filter( 'the_content', array( $this, 'remove_auto_paragraph_from_product_description' ), 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * Enqueue the static assets needed in the frontend. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	public function enqueue_frontend_assets() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		if ( ! wp_style_is( 'jetpack-simple-payments', 'enqueued' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			wp_enqueue_style( 'jetpack-simple-payments' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		if ( ! wp_script_is( 'paypal-express-checkout', 'enqueued' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			wp_enqueue_script( 'paypal-express-checkout' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	 * Add an inline script for setting up the PayPal checkout button. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * @param int     $id Product ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * @param int     $dom_id ID of the DOM element with the purchase message. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * @param boolean $is_multiple Whether multiple items of the same product can be purchased. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	public function setup_paypal_checkout_button( $id, $dom_id, $is_multiple ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		wp_add_inline_script( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 			'paypal-express-checkout', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 			sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 				"try{PaypalExpressCheckout.renderButton( '%d', '%d', '%s', '%d' );}catch(e){}", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 				esc_js( $this->get_blog_id() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 				esc_js( $id ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 				esc_js( $dom_id ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 				esc_js( $is_multiple ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	function remove_auto_paragraph_from_product_description( $content ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		if ( get_post_type() === self::$post_type_product ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			remove_filter( 'the_content', 'wpautop' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		return $content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	function get_blog_id() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			return get_current_blog_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		return Jetpack_Options::get_option( 'id' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	 * Used to check whether Simple Payments are enabled for given site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	 * @return bool True if Simple Payments are enabled, false otherwise. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	function is_enabled_jetpack_simple_payments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		 * Can be used by plugin authors to disable the conflicting output of Simple Payments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		 * @since 6.3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		 * @param bool True if Simple Payments should be disabled, false otherwise. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 		if ( apply_filters( 'jetpack_disable_simple_payments', false ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 		// For WPCOM sites | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 140 |  | View Code Duplication | 		if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'has_any_blog_stickers' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 			$site_id = $this->get_blog_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 			return has_any_blog_stickers( array( 'premium-plan', 'business-plan', 'ecommerce-plan' ), $site_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		// For all Jetpack sites | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		return Jetpack::is_active() && Jetpack_Plan::supports( 'simple-payments'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	function parse_shortcode( $attrs, $content = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		if ( empty( $attrs['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		$product = get_post( $attrs['id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		if ( ! $product || is_wp_error( $product ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		if ( $product->post_type !== self::$post_type_product || 'publish' !== $product->post_status ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		// We allow for overriding the presentation labels | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		$data = shortcode_atts( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 			'blog_id'     => $this->get_blog_id(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 			'dom_id'      => uniqid( self::$css_classname_prefix . '-' . $product->ID . '_', true ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 			'class'       => self::$css_classname_prefix . '-' . $product->ID, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 			'title'       => get_the_title( $product ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 			'description' => $product->post_content, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 			'cta'         => get_post_meta( $product->ID, 'spay_cta', true ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			'multiple'    => get_post_meta( $product->ID, 'spay_multiple', true ) || '0' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		), $attrs ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		$data['price'] = $this->format_price( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			get_post_meta( $product->ID, 'spay_price', true ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 			get_post_meta( $product->ID, 'spay_currency', true ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		$data['id'] = $attrs['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 			require_once WP_CONTENT_DIR . '/lib/display-context.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 			$context = \A8C\Display_Context\get_current_context(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 			if ( \A8C\Display_Context\EMAIL === $context ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 				// Avoid enqueueing unsupported files by emails. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 				return $this->output_shortcode( $data ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		if ( ! $this->is_enabled_jetpack_simple_payments() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 			if ( ! is_feed() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 				return $this->output_admin_warning( $data ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		$this->enqueue_frontend_assets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 		$this->setup_paypal_checkout_button( $attrs['id'], $data['dom_id'], $data['multiple'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 		return $this->output_shortcode( $data ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	function output_admin_warning( $data ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 		if ( ! current_user_can( 'manage_options' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		jetpack_require_lib( 'components' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 		return Jetpack_Components::render_upgrade_nudge( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 			'plan' => self::$required_plan | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 	 * Get the HTML output to use as PayPal purchase box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 	 * @param string  $dom_id ID of the DOM element with the purchase message. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 	 * @param boolean $is_multiple Whether multiple items of the same product can be purchased. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	public function output_purchase_box( $dom_id, $is_multiple ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		$items = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		$css_prefix = self::$css_classname_prefix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 		if ( $is_multiple ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 			$items = sprintf( ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 				<div class="%1$s"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 					<input class="%2$s" type="number" value="1" min="1" id="%3$s" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 				</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 				', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 				esc_attr( "${css_prefix}-items" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 				esc_attr( "${css_prefix}-items-number" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 				esc_attr( "{$dom_id}_number" ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 		return sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 			'<div class="%1$s" id="%2$s"></div><div class="%3$s">%4$s<div class="%5$s" id="%6$s"></div></div>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 			esc_attr( "${css_prefix}-purchase-message" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 			esc_attr( "{$dom_id}-message-container" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			esc_attr( "${css_prefix}-purchase-box" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			$items, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 			esc_attr( "${css_prefix}-button" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 			esc_attr( "{$dom_id}_button" ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 	 * Get the HTML output to replace the `simple-payments` shortcode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	 * @param array $data Product data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 	public function output_shortcode( $data ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		$css_prefix = self::$css_classname_prefix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		$image = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 		if( has_post_thumbnail( $data['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 			$image = sprintf( '<div class="%1$s"><div class="%2$s">%3$s</div></div>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 				esc_attr( "${css_prefix}-product-image" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 				esc_attr( "${css_prefix}-image" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 				get_the_post_thumbnail( $data['id'], 'full' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 		return sprintf( ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | <div class="%1$s"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 	<div class="%2$s"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		%3$s | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		<div class="%4$s"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 			<div class="%5$s"><p>%6$s</p></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 			<div class="%7$s"><p>%8$s</p></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 			<div class="%9$s"><p>%10$s</p></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 			%11$s | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 		</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | </div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 			esc_attr( "{$data['class']} ${css_prefix}-wrapper" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 			esc_attr( "${css_prefix}-product" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 			$image, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 			esc_attr( "${css_prefix}-details" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 			esc_attr( "${css_prefix}-title" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 			esc_html( $data['title'] ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 			esc_attr( "${css_prefix}-description" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 			wp_kses( $data['description'], wp_kses_allowed_html( 'post' ) ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 			esc_attr( "${css_prefix}-price" ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 			esc_html( $data['price'] ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 			$this->output_purchase_box( $data['dom_id'], $data['multiple'] ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 	 * Format a price with currency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 	 * Uses currency-aware formatting to output a formatted price with a simple fallback. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 	 * Largely inspired by WordPress.com's Store_Price::display_currency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 	 * @param  string $price    Price. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 	 * @param  string $currency Currency. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 	 * @return string           Formatted price. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 	private function format_price( $price, $currency ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		$currency_details = self::get_currency( $currency ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 		if ( $currency_details ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 			// Ensure USD displays as 1234.56 even in non-US locales. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 			$amount = 'USD' === $currency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 				? number_format( $price, $currency_details['decimal'], '.', ',' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 				: number_format_i18n( $price, $currency_details['decimal'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			return sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 				$currency_details['format'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 				$currency_details['symbol'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 				$amount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 		// Fall back to unspecified currency symbol like `¤1,234.05`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 		// @link https://en.wikipedia.org/wiki/Currency_sign_(typography). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 		if ( ! $currency ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 			return '¤' . number_format_i18n( $price, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 		return number_format_i18n( $price, 2 ) . ' ' . $currency; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 	 * Allows custom post types to be used by REST API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 	 * @param $post_types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 	 * @see hook 'rest_api_allowed_post_types' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 	function allow_rest_api_types( $post_types ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		$post_types[] = self::$post_type_order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		$post_types[] = self::$post_type_product; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		return $post_types; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 	function allow_sync_post_meta( $post_meta ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 		return array_merge( $post_meta, array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 			'spay_paypal_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 			'spay_status', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 			'spay_product_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 			'spay_quantity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 			'spay_price', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 			'spay_customer_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 			'spay_currency', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 			'spay_cta', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 			'spay_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 			'spay_multiple', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 			'spay_formatted_price', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 	 * Enable Simple payments custom meta values for access through the REST API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 	 * Field’s value will be exposed on a .meta key in the endpoint response, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 	 * and WordPress will handle setting up the callbacks for reading and writing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 	 * to that meta key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 	 * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 	public function register_meta_fields_in_rest_api() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 		register_meta( 'post', 'spay_price', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 			'description'       => esc_html__( 'Simple payments; price.', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			'object_subtype'    => self::$post_type_product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 			'sanitize_callback' => array( $this, 'sanitize_price' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 			'type'              => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 		register_meta( 'post', 'spay_currency', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 			'description'       => esc_html__( 'Simple payments; currency code.', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 			'object_subtype'    => self::$post_type_product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 			'sanitize_callback' => array( $this, 'sanitize_currency' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 			'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		register_meta( 'post', 'spay_cta', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 			'description'       => esc_html__( 'Simple payments; text with "Buy" or other CTA', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 			'object_subtype'    => self::$post_type_product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 			'sanitize_callback' => 'sanitize_text_field', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 			'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 		register_meta( 'post', 'spay_multiple', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 			'description'       => esc_html__( 'Simple payments; allow multiple items', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 			'object_subtype'    => self::$post_type_product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 			'sanitize_callback' => 'rest_sanitize_boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			'type'              => 'boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		register_meta( 'post', 'spay_email', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 			'description'       => esc_html__( 'Simple payments button; paypal email.', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 			'sanitize_callback' => 'sanitize_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 			'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		register_meta( 'post', 'spay_status', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 			'description'       => esc_html__( 'Simple payments; status.', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 			'object_subtype'    => self::$post_type_product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 			'sanitize_callback' => 'sanitize_text_field', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 			'show_in_rest'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 			'single'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 			'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	 * Sanitize three-character ISO-4217 Simple payments currency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 	 * List has to be in sync with list at the block's client side and widget's backend side: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 	 * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/extensions/blocks/simple-payments/constants.js#L9-L39 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 	 * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/modules/widgets/simple-payments.php#L19-L44 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 	 * Currencies should be supported by PayPal: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 	 * @link https://developer.paypal.com/docs/api/reference/currency-codes/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 	 * Indian Rupee (INR) not supported because at the time of the creation of this file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 	 * because it's limited to in-country PayPal India accounts only. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 	 * Discussion: https://github.com/Automattic/wp-calypso/pull/28236 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 432 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 433 |  |  | 	public static function sanitize_currency( $currency ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 434 |  |  | 		$valid_currencies = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 435 |  |  | 			'USD', | 
            
                                                                        
                            
            
                                    
            
            
                | 436 |  |  | 			'EUR', | 
            
                                                                        
                            
            
                                    
            
            
                | 437 |  |  | 			'AUD', | 
            
                                                                        
                            
            
                                    
            
            
                | 438 |  |  | 			'BRL', | 
            
                                                                        
                            
            
                                    
            
            
                | 439 |  |  | 			'CAD', | 
            
                                                                        
                            
            
                                    
            
            
                | 440 |  |  | 			'CZK', | 
            
                                                                        
                            
            
                                    
            
            
                | 441 |  |  | 			'DKK', | 
            
                                                                        
                            
            
                                    
            
            
                | 442 |  |  | 			'HKD', | 
            
                                                                        
                            
            
                                    
            
            
                | 443 |  |  | 			'HUF', | 
            
                                                                        
                            
            
                                    
            
            
                | 444 |  |  | 			'ILS', | 
            
                                                                        
                            
            
                                    
            
            
                | 445 |  |  | 			'JPY', | 
            
                                                                        
                            
            
                                    
            
            
                | 446 |  |  | 			'MYR', | 
            
                                                                        
                            
            
                                    
            
            
                | 447 |  |  | 			'MXN', | 
            
                                                                        
                            
            
                                    
            
            
                | 448 |  |  | 			'TWD', | 
            
                                                                        
                            
            
                                    
            
            
                | 449 |  |  | 			'NZD', | 
            
                                                                        
                            
            
                                    
            
            
                | 450 |  |  | 			'NOK', | 
            
                                                                        
                            
            
                                    
            
            
                | 451 |  |  | 			'PHP', | 
            
                                                                        
                            
            
                                    
            
            
                | 452 |  |  | 			'PLN', | 
            
                                                                        
                            
            
                                    
            
            
                | 453 |  |  | 			'GBP', | 
            
                                                                        
                            
            
                                    
            
            
                | 454 |  |  | 			'RUB', | 
            
                                                                        
                            
            
                                    
            
            
                | 455 |  |  | 			'SGD', | 
            
                                                                        
                            
            
                                    
            
            
                | 456 |  |  | 			'SEK', | 
            
                                                                        
                            
            
                                    
            
            
                | 457 |  |  | 			'CHF', | 
            
                                                                        
                            
            
                                    
            
            
                | 458 |  |  | 			'THB', | 
            
                                                                        
                            
            
                                    
            
            
                | 459 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 460 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 461 |  |  | 		return in_array( $currency, $valid_currencies ) ? $currency : false; | 
            
                                                                        
                            
            
                                    
            
            
                | 462 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 	 * Sanitize price: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 	 * Positive integers and floats | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 	 * Supports two decimal places. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 	 * Maximum length: 10. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 	 * See `price` from PayPal docs: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 	 * @link https://developer.paypal.com/docs/api/orders/v1/#definition-item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 	 * @param      $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	 * @return null|string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 	public static function sanitize_price( $price ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 		return preg_match( '/^[0-9]{0,10}(\.[0-9]{0,2})?$/', $price ) ? $price : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 	 * Sets up the custom post types for the module. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 	function setup_cpts() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 		 * ORDER data structure. holds: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 		 * title = customer_name | 4xproduct_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 		 * excerpt = customer_name + customer contact info + customer notes from paypal form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 		 * metadata: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 		 * spay_paypal_id - paypal id of transaction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 		 * spay_status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 		 * spay_product_id - post_id of bought product | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 		 * spay_quantity - quantity of product | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 		 * spay_price - item price at the time of purchase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 		 * spay_customer_email - customer email | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 		 * ... (WIP) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		$order_capabilities = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 			'edit_post'             => 'edit_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 			'read_post'             => 'read_private_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 			'delete_post'           => 'delete_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 			'edit_posts'            => 'edit_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 			'edit_others_posts'     => 'edit_others_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 			'publish_posts'         => 'publish_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 			'read_private_posts'    => 'read_private_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 		$order_args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 			'label'                 => esc_html_x( 'Order', 'noun: a quantity of goods or items purchased or sold', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 			'description'           => esc_html__( 'Simple Payments orders', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 			'supports'              => array( 'custom-fields', 'excerpt' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			'hierarchical'          => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 			'public'                => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 			'show_ui'               => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 			'show_in_menu'          => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 			'show_in_admin_bar'     => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 			'show_in_nav_menus'     => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 			'can_export'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 			'has_archive'           => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 			'exclude_from_search'   => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 			'publicly_queryable'    => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 			'rewrite'               => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 			'capabilities'          => $order_capabilities, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 			'show_in_rest'          => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		register_post_type( self::$post_type_order, $order_args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 		 * PRODUCT data structure. Holds: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 		 * title - title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 		 * content - description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 		 * thumbnail - image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 		 * metadata: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 		 * spay_price - price | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 		 * spay_formatted_price | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		 * spay_currency - currency code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		 * spay_cta - text with "Buy" or other CTA | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		 * spay_email - paypal email | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 		 * spay_multiple - allow for multiple items | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 		 * spay_status - status. { enabled | disabled } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 		$product_capabilities = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 			'edit_post'             => 'edit_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 			'read_post'             => 'read_private_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 			'delete_post'           => 'delete_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 			'edit_posts'            => 'publish_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 			'edit_others_posts'     => 'edit_others_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 			'publish_posts'         => 'publish_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 			'read_private_posts'    => 'read_private_posts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 		$product_args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			'label'                 => esc_html__( 'Product', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 			'description'           => esc_html__( 'Simple Payments products', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			'supports'              => array( 'title', 'editor','thumbnail', 'custom-fields', 'author' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 			'hierarchical'          => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 			'public'                => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 			'show_ui'               => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 			'show_in_menu'          => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			'show_in_admin_bar'     => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			'show_in_nav_menus'     => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 			'can_export'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 			'has_archive'           => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 			'exclude_from_search'   => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 			'publicly_queryable'    => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 			'rewrite'               => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			'capabilities'          => $product_capabilities, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 			'show_in_rest'          => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		register_post_type( self::$post_type_product, $product_args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 	 * Format a price for display | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 	 * Largely taken from WordPress.com Store_Price class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 	 * The currency array will have the shape: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 	 *   format  => string sprintf format with placeholders `%1$s`: Symbol `%2$s`: Price. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 	 *   symbol  => string Symbol string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 	 *   desc    => string Text description of currency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 	 *   decimal => int    Number of decimal places | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 	 * @param  string $the_currency The desired currency, e.g. 'USD'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 	 * @return ?array               Currency object or null if not found. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 	private static function get_currency( $the_currency ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 		$currencies = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 			'USD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 				'symbol'  => '$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			'GBP' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 				'symbol'  => '£', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 			'JPY' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 				'symbol'  => '¥', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 				'decimal' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 			'BRL' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 				'symbol'  => 'R$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 			'EUR' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 				'symbol'  => '€', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 			'NZD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 				'symbol'  => 'NZ$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 			'AUD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 				'symbol'  => 'A$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 			'CAD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 				'symbol'  => 'C$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 			'ILS' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 				'symbol'  => '₪', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 			'RUB' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 				'symbol'  => '₽', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 			'MXN' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 				'symbol'  => 'MX$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 			'MYR' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 				'format'  => '%2$s%1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 				'symbol'  => 'RM', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 			'SEK' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 				'symbol'  => 'Skr', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 			'HUF' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 				'symbol'  => 'Ft', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 				'decimal' => 0, // Decimals are supported by Stripe but not by PayPal. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 			'CHF' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 				'symbol'  => 'CHF', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 			'CZK' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 				'symbol'  => 'Kč', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 			'DKK' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 				'symbol'  => 'Dkr', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 			'HKD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 				'symbol'  => 'HK$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 			'NOK' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 				'symbol'  => 'Kr', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 			'PHP' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 				'symbol'  => '₱', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 			'PLN' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 				'format'  => '%2$s %1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 				'symbol'  => 'PLN', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 			'SGD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 				'symbol'  => 'S$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			'TWD' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 				'format'  => '%1$s%2$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 				'symbol'  => 'NT$', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 				'decimal' => 0, // Decimals are supported by Stripe but not by PayPal. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 			'THB' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 				'format'  => '%2$s%1$s', // 1: Symbol 2: currency value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 				'symbol'  => '฿', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 				'decimal' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 		if ( isset( $currencies[ $the_currency ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 			return $currencies[ $the_currency ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 		return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 716 |  |  | Jetpack_Simple_Payments::getInstance(); | 
            
                                                        
            
                                    
            
            
                | 717 |  |  |  | 
            
                        
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.