__NAMESPACE__ . '\load_assets', ) ); } add_action( 'init', __NAMESPACE__ . '\register_block' ); /** * Google Calendar block registration/dependency declaration. * * @param array $attr Array containing the Google Calendar block attributes. * @return string */ function load_assets( $attr ) { $height = isset( $attr['height'] ) ? $attr['height'] : '600'; $url = isset( $attr['url'] ) ? Jetpack_Gutenberg::validate_block_embed_url( $attr['url'], array( 'calendar.google.com' ) ) : ''; $classes = Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ); Jetpack_Gutenberg::load_assets_as_required( __DIR__ ); if ( empty( $url ) ) { return ''; } $sandbox = 'allow-scripts allow-same-origin allow-popups'; if ( Blocks::is_amp_request() ) { $noscript_src = str_replace( '//calendar.google.com/calendar/embed', '//calendar.google.com/calendar/htmlembed', $url ); $iframe = sprintf( '%4$s%5$s', esc_url( $url ), absint( $height ), esc_attr( $sandbox ), sprintf( '%s', esc_url( $url ), esc_html__( 'Google Calendar', 'jetpack' ) ), sprintf( '', esc_url( $noscript_src ), esc_attr( $sandbox ) ) ); } else { $iframe = sprintf( '', esc_url( $url ), absint( $height ), esc_attr( $sandbox ) ); } return sprintf( '
%s
', esc_attr( $classes ), $iframe ); }