PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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 13.8.3 All 506 releases
jetpack / extensions / blocks / premium-content / _inc / legacy-buttons.php

legacy-buttons.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.5, at extensions/blocks/premium-content/_inc/legacy-buttons.php

63 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Create legacy buttons markup.
4 *
5 * @package Automattic\Jetpack\Extensions\Premium_Content
6 */
7
8 namespace Automattic\Jetpack\Extensions\Premium_Content;
9
10 /**
11 * Creates a subscribe/login buttons markup for legacy blocks.
12 *
13 * @param array $attributes Block attributes.
14 * @param string $content String containing the block content.
15 * @param object $block Legacy block.
16 *
17 * @return string Subscribe/login buttons markup.
18 */
19 function create_legacy_buttons_markup( $attributes, $content, $block ) {
20 $button_styles = array();
21 if ( ! empty( $attributes['customBackgroundButtonColor'] ) ) {
22 array_push(
23 $button_styles,
24 sprintf(
25 'background-color: %s',
26 isset( $attributes['customBackgroundButtonColor'] ) ? sanitize_hex_color( $attributes['customBackgroundButtonColor'] ) : 'transparent'
27 )
28 );
29 }
30 if ( ! empty( $attributes['customTextButtonColor'] ) ) {
31 array_push(
32 $button_styles,
33 sprintf(
34 'color: %s',
35 isset( $attributes['customTextButtonColor'] ) ? sanitize_hex_color( $attributes['customTextButtonColor'] ) : 'inherit'
36 )
37 );
38 }
39 $button_styles = implode( ';', $button_styles );
40
41 $login_button = sprintf(
42 '<div class="wp-block-button"><a role="button" href="%1$s" class="%2$s" style="%3$s">%4$s</a></div>',
43 esc_url( subscription_service()->access_url() ),
44 empty( $attributes['buttonClasses'] ) ? 'wp-block-button__link' : esc_attr( $attributes['buttonClasses'] ),
45 esc_attr( $button_styles ),
46 empty( $attributes['loginButtonText'] ) ? __( 'Log In', 'jetpack' ) : wp_kses_post( $attributes['loginButtonText'] )
47 );
48
49 $subscribe_button = \Jetpack_Memberships::get_instance()->render_button(
50 array(
51 'planId' => empty( $block->context['premium-content/planId'] ) ? 0 : $block->context['premium-content/planId'],
52 'submitButtonClasses' => empty( $attributes['buttonClasses'] ) ? 'wp-block-button__link' : esc_attr( $attributes['buttonClasses'] ),
53 'customTextButtonColor' => empty( $attributes['customTextButtonColor'] ) ? '' : esc_attr( $attributes['customTextButtonColor'] ),
54 'customBackgroundButtonColor' => empty( $attributes['customBackgroundButtonColor'] ) ? '' : esc_attr( $attributes['customBackgroundButtonColor'] ),
55 'submitButtonText' => empty( $attributes['subscribeButtonText'] ) ? __( 'Subscribe', 'jetpack' ) : esc_attr( $attributes['subscribeButtonText'] ),
56 ),
57 $content,
58 $block
59 );
60
61 return "<div class='wp-block-premium-content-logged-out-view__buttons'>{$subscribe_button}{$login_button}</div>";
62 }
63