PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.8
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.8
2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 All 108 releases
b-blocks / includes / EnqueueScripts.php

EnqueueScripts.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 2.1.8, at includes/EnqueueScripts.php

84 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) { exit; }
3
4 if( !class_exists('BBlocksEnqueueScripts') ){
5 class BBlocksEnqueueScripts{
6 function __construct(){
7 add_action( 'enqueue_block_editor_assets', [$this, 'enqueueBlockEditorAssets'] );
8 add_action( 'enqueue_block_assets', [$this, 'enqueueBockAssets'] );
9 add_action( 'wp_enqueue_scripts', [$this, 'enqueueScripts'] );
10 add_filter( 'script_loader_tag', [$this, 'scriptLoaderTag'], 10, 3 );
11 }
12
13 function enqueueBlockEditorAssets(){
14 wp_enqueue_script( 'b-blocks-template-library-script', B_BLOCKS_BUILD . 'template-library.js', [ 'wp-api', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-i18n', 'wp-util', 'react', 'react-dom' ], B_BLOCKS_VERSION, false );
15 wp_set_script_translations( 'b-blocks-template-library-script', 'b-blocks', B_BLOCKS_DIR_PATH . 'languages' );
16
17 wp_enqueue_style( 'b-blocks-template-library-style', B_BLOCKS_BUILD . 'template-library.css', [], B_BLOCKS_VERSION );
18
19 wp_enqueue_script( 'b-blocks-index-script', B_BLOCKS_BUILD . 'index.js', [ 'wp-api', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n', 'wp-rich-text', 'wp-util', 'jquery', 'jquery-ui-draggable', 'aos', 'modelViewer', 'easyTicker', 'swiper', 'dotLottiePlayer', 'lottieInteractivity', 'chartJS', 'plyr', 'textillate', 'goodShare' ], B_BLOCKS_VERSION, false );
20 wp_set_script_translations( 'b-blocks-index-script', 'b-blocks', B_BLOCKS_DIR_PATH . 'languages' );
21
22 $disabledBlocks = get_option( 'bBlocksDisabledBlocks', [] );
23 $disabledBlocks = is_array( $disabledBlocks ) ? $disabledBlocks : [];
24 wp_localize_script( 'b-blocks-index-script', 'bBlocksDisabledBlocks', $disabledBlocks );
25
26 // `canUnfilteredHtml` gates the HTML block's script activation in the
27 // editor preview (see src/html/Components/hooks/useRunJs.js). Note
28 // that wp_localize_script() casts scalars to strings, so this
29 // arrives in JS as '1' or '' - read it for truthiness, not === true.
30 wp_localize_script( 'b-blocks-index-script', 'bBlocksGlobal', [
31 'assetsUrl' => B_BLOCKS_ASSETS,
32 'canUnfilteredHtml' => current_user_can( 'unfiltered_html' ),
33 ] );
34
35 wp_enqueue_style( 'b-blocks-index-style', B_BLOCKS_BUILD . 'index.css', [ 'fontAwesome', 'b-blocks-style' ], B_BLOCKS_VERSION );
36
37 wp_add_inline_script('b-blocks-index-script', 'const bBlocksPremiumChecker = ' . wp_json_encode( BBlocks\Inc\Utils::isPro() ) . '; ', 'before' );
38 }
39
40 function enqueueBockAssets(){
41 wp_register_script( 'easyTicker', B_BLOCKS_ASSETS . 'js/easy-ticker.min.js', [ 'jquery' ], '3.2.1', true ); // Posts
42 wp_register_script( 'swiper', B_BLOCKS_ASSETS . 'js/swiper.min.js', [], '8.0.7', true ); // Slider
43 wp_register_script( 'dotLottiePlayer', B_BLOCKS_ASSETS . 'js/dotlottie-player.js', [], '1.5.7', true ); // Lottie Player
44 wp_register_script( 'lottieInteractivity', B_BLOCKS_ASSETS . 'js/lottie-interactivity.min.js', [ 'dotLottiePlayer' ], '1.5.2', true ); // Lottie Player
45 wp_register_script( 'chartJS', B_BLOCKS_ASSETS . 'js/chart.min.js', [], '3.5.1', true ); // Chart
46 wp_register_script( 'plyr', B_BLOCKS_ASSETS . 'js/plyr.js', [], '3.7.2', true ); // Video
47 wp_register_script( 'textillate', B_BLOCKS_ASSETS . 'js/jquery.textillate.min.js', [ 'jquery' ], '0.6.1', true ); // Animated Text
48 wp_register_script( 'goodShare', B_BLOCKS_ASSETS . 'js/goodshare.min.js', [], B_BLOCKS_VERSION, true ); // Social Share
49 wp_register_script( 'modelViewer', B_BLOCKS_ASSETS . 'js/model-viewer.min.js', [], B_BLOCKS_VERSION, true ); // 3D Viewer
50 wp_register_script( 'aos', B_BLOCKS_ASSETS . 'js/aos.js', [], '3.0.0', true ); // Button
51 wp_register_script( 'fancybox', B_BLOCKS_ASSETS . 'js/fancybox.min.js', [], '4.0', true ); // Image Gallery
52 wp_register_script( 'mailtoui', B_BLOCKS_ASSETS . 'js/mailtoui-min.js', [], '1.0.3', true ); // Mailto
53 // wp_register_script( 'facebookEmbbed', B_BLOCKS_ASSETS . 'js/facebook-embbed.js', [], B_BLOCKS_VERSION, true ); // Facebook Embbed
54 // wp_register_script( 'facebookPage', B_BLOCKS_ASSETS . 'js/facebook-page.js', [], B_BLOCKS_VERSION, true ); // Facebook Page
55
56 //Accordion
57 wp_register_script('zebra_accordion', B_BLOCKS_ASSETS . 'js/zebra_accordion.min.js', ['jquery'], B_BLOCKS_VERSION, true);
58
59 wp_register_style( 'fontAwesome', B_BLOCKS_ASSETS . 'css/font-awesome.min.css', [], '6.4.2' ); // Icon
60 wp_register_style( 'swiper', B_BLOCKS_ASSETS . 'css/swiper.min.css', [], '8.0.7' ); // Slider
61 wp_register_style( 'animate', B_BLOCKS_ASSETS . 'css/animate.min.css', [], '4.1.1' ); // Animated Text
62 wp_register_style( 'plyr', B_BLOCKS_ASSETS . 'css/plyr.css', [], '3.7.2' ); // Video
63 wp_register_style( 'aos', B_BLOCKS_ASSETS . 'css/aos.css', [], '3.0.0' ); // Button
64 wp_register_style( 'fancybox', B_BLOCKS_ASSETS . 'css/fancybox.min.css', '', '4.0', 'all' ); // Image Gallery
65
66 wp_enqueue_style( 'b-blocks-style', B_BLOCKS_BUILD . 'script.css', [], B_BLOCKS_VERSION ); // Style
67 }
68
69 function enqueueScripts(){
70 wp_enqueue_script( 'b-blocks-advanced-script', B_BLOCKS_BUILD . 'advanced.js', [], B_BLOCKS_VERSION, true );
71 wp_enqueue_script( 'b-blocks-script', B_BLOCKS_BUILD . 'script.js', [], B_BLOCKS_VERSION, true );
72 wp_add_inline_script('b-blocks-script', 'const bBlocksPremiumChecker = ' . wp_json_encode( BBlocks\Inc\Utils::isPro() ) . '; ', 'before' );
73 }
74
75 function scriptLoaderTag( $tag, $handle, $src ){
76 if ( 'modelViewer' !== $handle ) {
77 return $tag;
78 }
79 $tag = '<script type="module" src="' . esc_url( $src ) . '"></script>';
80 return $tag;
81 }
82 }
83 new BBlocksEnqueueScripts();
84 }