PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / extensions / blocks / paypal-payment-buttons / paypal-payment-buttons.php

paypal-payment-buttons.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-beta, at extensions/blocks/paypal-payment-buttons/paypal-payment-buttons.php

50 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PayPal Payment Buttons block.
4 *
5 * @since 14.9
6 *
7 * @package automattic/jetpack
8 */
9
10 use Automattic\Jetpack\PaypalPayments\PayPal_Payment_Buttons;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit( 0 );
14 }
15
16 // The API-managed buttons ship behind a flag; register it before anything reads it.
17 PayPal_Payment_Buttons::register_feature_flags();
18 add_filter( 'jetpack_block_editor_feature_flags', array( PayPal_Payment_Buttons::class, 'add_editor_feature_flags' ) );
19
20 // Register the block.
21 add_action( 'init', array( PayPal_Payment_Buttons::class, 'register_block' ), 9 );
22
23 /*
24 * Register the PayPal REST routes (wpcom/v2/paypal/*) that the block editor calls
25 * to connect an account and manage payment links. Without them the block renders
26 * but every request the editor makes -- onboarding, connect, button CRUD -- 404s.
27 *
28 * Only the routes: init_api() also hooks sharing and the email sender, neither of
29 * which is wired up on Jetpack today. Both this and init_admin() no-op while the
30 * flag is off.
31 */
32 PayPal_Payment_Buttons::init_rest_api();
33
34 /*
35 * Register the Payment Links admin page. The standalone plugin wires this up in
36 * its own bootstrap; the Jetpack loader has to do the same or PayPal_Admin_Page
37 * never runs and the page does not exist in wp-admin.
38 */
39 if ( is_admin() ) {
40 PayPal_Payment_Buttons::init_admin();
41 }
42
43 // Load scripts for the editing interface
44 add_action( 'enqueue_block_editor_assets', array( PayPal_Payment_Buttons::class, 'load_editor_scripts' ), 9 );
45
46 // Load styles in the editor iframe context
47 if ( is_admin() ) {
48 add_action( 'enqueue_block_assets', array( PayPal_Payment_Buttons::class, 'load_editor_styles' ), 9 );
49 }
50