to_array(); $options = options(); // Register our block, and explicitly define the attributes we accept. register_block_type( PLUGIN_DIR . '/build/block/block.json', array( 'render_callback' => __NAMESPACE__ . '\gutenberg_block', ) ); $block_inline_data = [ 'settings' => $settings, 'options' => $options, 'settingPageUrl' => admin_url( 'options-general.php?page=nextgenthemes_arve' ), ]; wp_add_inline_script( 'nextgenthemes-arve-block-editor-script', 'var ArveBlockJsBefore = ' . wp_json_encode( $block_inline_data ) . ';', 'before' ); endif; } /** * Adds async attribute to script module tags. * * @param string $tag The script tag HTML. * @param string $handle The script handle. * @return string The modified script tag. */ function add_async_to_script_modules( string $tag, string $handle ): string { if ( 'arve' === $handle ) { $tag = str_replace( 'type="module"', 'type="module" async', $tag ); } return $tag; } /** * Adds style URLs for VIEW_SCRIPT_HANDLES to the TinyMCE editor instance. * * @param string $mce_css Comma-separated string of style URLs to append to. * * @return string Modified string of style URLs. */ function add_styles_to_mce( string $mce_css ): string { $wp_styles = wp_styles(); // Array to store the style URLs $style_urls = []; // Loop through target handles and get their source URLs foreach ( VIEW_SCRIPT_HANDLES as $handle ) { if ( empty( $wp_styles->registered[ $handle ]->src ) ) { continue; } $src = $wp_styles->registered[ $handle ]->src; $ver = $wp_styles->registered[ $handle ]->ver; // Append version parameter for cache busting (if set) if ( $ver ) { $src = add_query_arg( 'ver', $ver, $src ); } $style_urls[] = $src; } if ( ! empty( $mce_css ) ) { $mce_css .= ','; } $mce_css .= implode( ',', $style_urls ); return $mce_css; } function action_wp_enqueue_scripts(): void { $options = options(); foreach ( VIEW_SCRIPT_HANDLES as $handle ) { if ( ! is_gutenberg() ) { wp_enqueue_style( $handle ); } if ( $options['always_enqueue_assets'] ) { wp_enqueue_style( $handle ); wp_enqueue_script( $handle ); wp_enqueue_script_module( $handle ); } } } /** * @param array> $attr GB attr. * * @return string Block HTML. */ function gutenberg_block( array $attr ): string { if ( empty( $attr['url'] ) && empty( $attr['random_video_url'] ) && empty( $attr['random_video_urls'] ) ) { ob_start(); ?>
ARVE Video Embed
Please paste Video URL / iframe Embed Code in the Sidebar for this Block.