PluginProbe
Flexible Table Block / trunk
Flexible Table Block vtrunk
3.9.0 trunk 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.2.0 2.3.0 2.3.1 2.4.0 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 All 38 releases
flexible-table-block / classes / class-enqueue.php

class-enqueue.php in Flexible Table Block trunk, at classes/class-enqueue.php

83 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Flexible_Table_Block;
4 * @author Aki Hamano
5 * @license GPL-2.0+
6 */
7
8 namespace Flexible_Table_Block;
9
10 class Enqueue {
11
12 /**
13 * Constructor
14 */
15 public function __construct() {
16 // Register block.
17 add_action( 'init', array( $this, 'register_block' ) );
18
19 // Enqueue front-end scripts.
20 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
21
22 // Enqueue block-editor assets.
23 if ( is_admin() ) {
24 add_action( 'enqueue_block_assets', array( $this, 'enqueue_block_editor_assets' ) );
25 }
26 }
27
28 /**
29 * Register block
30 */
31 public function register_block() {
32 register_block_type( FTB_PATH . '/build' );
33 }
34
35 /**
36 * Enqueue front-end scripts
37 */
38 public function enqueue_scripts() {
39 wp_register_style(
40 'flexible-table-block',
41 FTB_URL . '/build/style-index.css',
42 array(),
43 filemtime( FTB_PATH . '/build/style-index.css' ),
44 );
45
46 $responsive_css = Helper::get_responsive_css();
47 $block_css = Helper::get_block_css( '.' . FTB_BLOCK_CLASS );
48 $css = Helper::minify_css( $block_css . $responsive_css );
49
50 wp_add_inline_style( 'flexible-table-block', $css );
51 }
52
53 /**
54 * Enqueue block-editor assets
55 */
56 public function enqueue_block_editor_assets() {
57 $asset_file = include FTB_PATH . '/build/index.asset.php';
58
59 wp_register_script(
60 'flexible-table-block-editor',
61 FTB_URL . '/build/index.js',
62 $asset_file['dependencies'],
63 filemtime( FTB_PATH . '/build/index.js' ),
64 );
65
66 wp_set_script_translations( 'flexible-table-block-editor', FTB_NAMESPACE );
67
68 wp_register_style(
69 'flexible-table-block-editor',
70 FTB_URL . '/build/index.css',
71 array(),
72 filemtime( FTB_PATH . '/build/index.css' ),
73 );
74
75 $block_css = Helper::get_block_css( '.editor-styles-wrapper ' );
76 $css = Helper::minify_css( $block_css );
77
78 wp_add_inline_style( 'flexible-table-block-editor', $css );
79 }
80 }
81
82 new Enqueue();
83