__NAMESPACE__ . '\render_block' )
);
}
add_action( 'init', __NAMESPACE__ . '\register_block' );
/**
* Revue block render callback.
*
* @param array $attributes Array containing the Revue block attributes.
* @param string $content The Revue block content.
*
* @return string
*/
function render_block( $attributes, $content ) {
if ( ! array_key_exists( 'revueUsername', $attributes ) ) {
return '';
}
$email_label = get_revue_attribute( 'emailLabel', $attributes );
$email_placeholder = get_revue_attribute( 'emailPlaceholder', $attributes );
$first_name_label = get_revue_attribute( 'firstNameLabel', $attributes );
$first_name_placeholder = get_revue_attribute( 'firstNamePlaceholder', $attributes );
$first_name_show = get_revue_attribute( 'firstNameShow', $attributes );
$last_name_label = get_revue_attribute( 'lastNameLabel', $attributes );
$last_name_placeholder = get_revue_attribute( 'lastNamePlaceholder', $attributes );
$last_name_show = get_revue_attribute( 'lastNameShow', $attributes );
$url = sprintf( 'https://www.getrevue.co/profile/%s/add_subscriber', $attributes['revueUsername'] );
$base_class = Blocks::classes( FEATURE_NAME, array() ) . '__';
$classes = Blocks::classes( FEATURE_NAME, $attributes );
Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME );
ob_start();
?>
__( 'Subscribe', 'jetpack' ),
'emailLabel' => __( 'Email address', 'jetpack' ),
'emailPlaceholder' => __( 'Enter your email address', 'jetpack' ),
'firstNameLabel' => __( 'First name', 'jetpack' ),
'firstNamePlaceholder' => __( 'Enter your first name', 'jetpack' ),
'firstNameShow' => true,
'lastNameLabel' => __( 'Last name', 'jetpack' ),
'lastNamePlaceholder' => __( 'Enter your last name', 'jetpack' ),
'lastNameShow' => true,
);
if ( array_key_exists( $attribute, $default_attributes ) ) {
return $default_attributes[ $attribute ];
}
}
/**
* DEPRECATED V1
*/
/**
* Create the Revue subscribe button.
*
* @param array $attributes Array containing the Revue block attributes.
*
* @return string
*/
function get_deprecated_v1_revue_button( $attributes ) {
$classes = array( 'wp-block-button__link' );
$styles = array();
$text = get_revue_attribute( 'text', $attributes );
$has_class_name = array_key_exists( 'className', $attributes );
$has_named_text_color = array_key_exists( 'textColor', $attributes );
$has_custom_text_color = array_key_exists( 'customTextColor', $attributes );
$has_named_background_color = array_key_exists( 'backgroundColor', $attributes );
$has_custom_background_color = array_key_exists( 'customBackgroundColor', $attributes );
$has_named_gradient = array_key_exists( 'gradient', $attributes );
$has_custom_gradient = array_key_exists( 'customGradient', $attributes );
$has_border_radius = array_key_exists( 'borderRadius', $attributes );
if ( $has_class_name ) {
$classes[] = $attributes['className'];
}
if ( $has_named_text_color || $has_custom_text_color ) {
$classes[] = 'has-text-color';
}
if ( $has_named_text_color ) {
$classes[] = sprintf( 'has-%s-color', $attributes['textColor'] );
} elseif ( $has_custom_text_color ) {
$styles[] = sprintf( 'color: %s;', $attributes['customTextColor'] );
}
if (
$has_named_background_color ||
$has_custom_background_color ||
$has_named_gradient ||
$has_custom_gradient
) {
$classes[] = 'has-background';
}
if ( $has_named_background_color && ! $has_custom_gradient ) {
$classes[] = sprintf( 'has-%s-background-color', $attributes['backgroundColor'] );
}
if ( $has_named_gradient ) {
$classes[] = sprintf( 'has-%s-gradient-background', $attributes['gradient'] );
} elseif ( $has_custom_gradient ) {
$styles[] = sprintf( 'background: %s;', $attributes['customGradient'] );
}
if (
$has_custom_background_color &&
! $has_named_background_color &&
! $has_named_gradient &&
! $has_custom_gradient
) {
$styles[] = sprintf( 'background-color: %s;', $attributes['customBackgroundColor'] );
}
if ( $has_border_radius ) {
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
if ( 0 == $attributes['borderRadius'] ) {
$classes[] = 'no-border-radius';
} else {
$styles[] = sprintf( 'border-radius: %spx;', $attributes['borderRadius'] );
}
}
ob_start();
?>