PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
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 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | extensions/blocks/payment-buttons/payment-buttons.php +32 -14 12.0.3 → 16.3-a.1 View file →
@@ -10,10 +10,11 @@
10 10 namespace Automattic\Jetpack\Extensions\PaymentButtons;
11 11
12 12 use Automattic\Jetpack\Blocks;
13 13
14 -const FEATURE_NAME = 'payment-buttons';
15 -const BLOCK_NAME = 'jetpack/' . FEATURE_NAME;
14 +if ( ! defined( 'ABSPATH' ) ) {
15 + exit( 0 );
16 +}
16 17
17 18 /**
18 19 * Registers the block for use in Gutenberg
19 20 * This is done via an action so that we can disable
@@ -19,20 +20,18 @@
19 20 * This is done via an action so that we can disable
20 21 * registration if we need to.
21 22 */
22 23 function register_block() {
23 - if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && ! \Jetpack::is_connection_ready() ) {
24 - return;
25 - }
26 -
27 24 require_once JETPACK__PLUGIN_DIR . '/modules/memberships/class-jetpack-memberships.php';
28 - if ( \Jetpack_Memberships::is_enabled_jetpack_recurring_payments() ) {
25 + if ( \Jetpack_Memberships::should_enable_monetize_blocks_in_editor() ) {
29 26 Blocks::jetpack_register_block(
30 - BLOCK_NAME,
27 + __DIR__,
31 28 array(
32 - 'render_callback' => __NAMESPACE__ . '\render_block',
33 - 'supports' => array(
34 - '__experimentalLayout' => array(
29 + 'render_callback' => __NAMESPACE__ . '\render_block',
30 + 'render_email_callback' => __NAMESPACE__ . '\render_block_email',
31 + 'plan_check' => true,
32 + 'supports' => array(
33 + 'layout' => array(
35 34 'allowSwitching' => false,
36 35 'allowInheriting' => false,
37 36 'default' => array(
38 37 'type' => 'flex',
@@ -43,9 +42,9 @@
43 42 );
44 43 } else {
45 44 $required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? 'personal-bundle' : 'jetpack_personal';
46 45 \Jetpack_Gutenberg::set_extension_unavailable(
47 - BLOCK_NAME,
46 + 'payment-buttons',
48 47 'missing_plan',
49 48 array(
50 49 'required_feature' => 'memberships',
51 50 'required_plan' => $required_plan,
@@ -57,8 +56,11 @@
57 56
58 57 /**
59 58 * Render callback.
60 59 *
60 + * The render implementation lives in render.php and is only loaded when the
61 + * block is actually rendered, keeping it out of the eager front-end path.
62 + *
61 63 * @param array $attributes Array containing the block attributes.
62 64 * @param string $content String containing the block content.
63 65 *
64 66 * @return string
@@ -63,8 +65,24 @@
63 65 *
64 66 * @return string
65 67 */
66 68 function render_block( $attributes, $content ) {
67 - \Jetpack_Gutenberg::load_styles_as_required( FEATURE_NAME );
69 + require_once __DIR__ . '/render.php';
70 + return render_block_implementation( $attributes, $content );
71 +}
68 72
69 - return $content;
73 +/**
74 + * Render email callback.
75 + *
76 + * The render implementation lives in render.php and is only loaded when the
77 + * block is actually rendered, keeping it out of the eager front-end path.
78 + *
79 + * @param string $block_content The block content.
80 + * @param array $parsed_block The parsed block data.
81 + * @param object $rendering_context The email rendering context.
82 + *
83 + * @return string
84 + */
85 +function render_block_email( $block_content, array $parsed_block, $rendering_context ) {
86 + require_once __DIR__ . '/render.php';
87 + return render_block_email_implementation( $block_content, $parsed_block, $rendering_context );
70 88 }