← All changes
|
extensions/blocks/paypal-payment-buttons/paypal-payment-buttons.php
+24
-0
16.2
→
16.3
View file →
| @@ -12,10 +12,34 @@ | ||
| 12 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | 13 | exit( 0 ); |
| 14 | 14 | } |
| 15 | 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 | + | |
| 16 | 20 | // Register the block. |
| 17 | 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 | +} | |
| 18 | 42 | |
| 19 | 43 | // Load scripts for the editing interface |
| 20 | 44 | add_action( 'enqueue_block_editor_assets', array( PayPal_Payment_Buttons::class, 'load_editor_scripts' ), 9 ); |
| 21 | 45 | |