You appear to be a bot. Output may be restricted
Description
Calendly block registration/dependency declaration.
Usage
$string = load_assets( $attr, $content );
Parameters
- $attr
- ( array ) required – Array containing the Calendly block attributes.
- $content
- ( string ) required – String containing the Calendly block content.
Returns
string
Source
File name: jetpack/extensions/blocks/calendly/calendly.php
Lines:
1 to 86 of 86
function load_assets( $attr, $content ) { if ( is_admin() ) { return; } $url = Jetpack_Gutenberg::validate_block_embed_url( get_attribute( $attr, 'url' ), array( 'calendly.com' ) ); if ( empty( $url ) ) { return; } /* * Enqueue necessary scripts and styles. */ Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); $style = get_attribute( $attr, 'style' ); $hide_event_type_details = get_attribute( $attr, 'hideEventTypeDetails' ); $background_color = get_attribute( $attr, 'backgroundColor' ); $text_color = get_attribute( $attr, 'textColor' ); $primary_color = get_attribute( $attr, 'primaryColor' ); $classes = Blocks::classes( FEATURE_NAME, $attr, array( 'calendly-style-' . $style ) ); $block_id = wp_unique_id( 'calendly-block-' ); $is_amp_request = Blocks::is_amp_request(); if ( ! wp_script_is( 'jetpack-calendly-external-js' ) && ! $is_amp_request ) { enqueue_calendly_js(); } $base_url = $url; $url = add_query_arg( array( 'hide_event_type_details' => (int) $hide_event_type_details, 'background_color' => sanitize_hex_color_no_hash( $background_color ), 'text_color' => sanitize_hex_color_no_hash( $text_color ), 'primary_color' => sanitize_hex_color_no_hash( $primary_color ), ), $url ); if ( 'link' === $style ) { if ( ! wp_style_is( 'jetpack-calendly-external-css' ) ) { wp_enqueue_style( 'jetpack-calendly-external-css', 'https://assets.calendly.com/assets/external/widget.css', null, JETPACK__VERSION ); } // Render deprecated version of Calendly block if needed. New markup block button class before rendering here. if ( false === strpos( $content, 'wp-block-jetpack-button' ) ) { $content = deprecated_render_button_v1( $attr, $block_id, $classes, $url ); } else { $content = str_replace( 'calendly-widget-id', esc_attr( $block_id ), $content ); $content = str_replace( $base_url, $url, $content ); } if ( ! $is_amp_request ) { wp_add_inline_script( 'jetpack-calendly-external-js', sprintf( "calendly_attach_link_events( '%s' )", esc_js( $block_id ) ) ); } } else { // Inline style. if ( $is_amp_request ) { $content = sprintf( '<div class="%1$s" id="%2$s"><a href="%3$s" role="button" target="_blank">%4$s</a></div>', esc_attr( Blocks::classes( FEATURE_NAME, $attr ) ), esc_attr( $block_id ), esc_js( $url ), wp_kses_post( get_attribute( $attr, 'submitButtonText' ) ) ); } else { $content = sprintf( '<div class="%1$s" id="%2$s"></div>', esc_attr( $classes ), esc_attr( $block_id ) ); $script = <<<JS_END jetpackInitCalendly( '%s', '%s' ); JS_END; wp_add_inline_script( 'jetpack-calendly-external-js', sprintf( $script, esc_url( $url ), esc_js( $block_id ) ) ); } } return $content; }