'jetpack_mailchimp_block_load_assets', ) ); } /** * Mailchimp block registration/dependency declaration. * * @param array $attr - Array containing the map block attributes. * * @return string */ function jetpack_mailchimp_block_load_assets( $attr ) { if ( ! jetpack_mailchimp_verify_connection() ) { return null; } $values = array(); $blog_id = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? get_current_blog_id() : Jetpack_Options::get_option( 'id' ); Jetpack_Gutenberg::load_assets_as_required( 'mailchimp' ); $defaults = array( 'emailPlaceholder' => esc_html__( 'Enter your email', 'jetpack' ), 'submitButtonText' => esc_html__( 'Join my email list', 'jetpack' ), 'consentText' => esc_html__( 'By clicking submit, you agree to share your email address with the site owner and Mailchimp to receive marketing, updates, and other emails from the site owner. Use the unsubscribe link in those emails to opt out at any time.', 'jetpack' ), 'processingLabel' => esc_html__( 'Processing…', 'jetpack' ), 'successLabel' => esc_html__( 'Success! You\'re on the list.', 'jetpack' ), 'errorLabel' => esc_html__( 'Whoops! There was an error and we couldn\'t process your subscription. Please reload the page and try again.', 'jetpack' ), 'interests' => array(), 'signupFieldTag' => '', 'signupFieldValue' => '', ); foreach ( $defaults as $id => $default ) { $values[ $id ] = isset( $attr[ $id ] ) ? $attr[ $id ] : $default; } $values['submitButtonText'] = empty( $values['submitButtonText'] ) ? $defaults['submitButtonText'] : $values['submitButtonText']; $classes = Jetpack_Gutenberg::block_classes( 'mailchimp', $attr ); $button_styles = array(); if ( ! empty( $attr['customBackgroundButtonColor'] ) ) { array_push( $button_styles, sprintf( 'background-color: %s', sanitize_hex_color( $attr['customBackgroundButtonColor'] ) ) ); } if ( ! empty( $attr['customTextButtonColor'] ) ) { array_push( $button_styles, sprintf( 'color: %s', sanitize_hex_color( $attr['customTextButtonColor'] ) ) ); } $button_styles = implode( ';', $button_styles ); $amp_form_action = sprintf( 'https://public-api.wordpress.com/rest/v1.1/sites/%s/email_follow/amp/subscribe/', $blog_id ); $is_amp_request = class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request(); ob_start(); ?>
action-xhr="" method="post" id="mailchimp_form" target="_top" on="submit-success:AMP.setState( { mailing_list_status: 'subscribed', mailing_list_email: event.response.email } )" >