PluginProbe
Getwid – Gutenberg Blocks / 2.1.1
Getwid – Gutenberg Blocks v2.1.1
3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
getwid / includes / blocks / icon-box.php

icon-box.php in Getwid – Gutenberg Blocks 2.1.1, at includes/blocks/icon-box.php

111 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Getwid\Blocks;
4
5 class IconBox extends \Getwid\Blocks\AbstractBlock {
6
7 protected static $blockName = 'getwid/icon-box';
8
9 public function __construct() {
10
11 parent::__construct( self::$blockName );
12
13 register_block_type(
14 'getwid/icon-box',
15 array(
16 'render_callback' => [ $this, 'render_callback' ]
17 )
18 );
19
20 if ( $this->isEnabled() ) {
21
22 add_filter( 'getwid/blocks_style_css/dependencies', [ $this, 'block_frontend_styles' ] );
23
24 wp_register_style(
25 'animate',
26 getwid_get_plugin_url( 'vendors/animate.css/animate.min.css' ),
27 [],
28 '3.7.0'
29 );
30 }
31 }
32
33 public function getLabel() {
34 return __('Icon Box', 'getwid');
35 }
36
37 public function block_frontend_styles($styles) {
38
39 //fontawesome
40 $styles = getwid()->fontIconsManager()->enqueueFonts( $styles );
41
42 //animate.min.css
43 if ( is_admin() && ! in_array( 'animate', $styles ) ) {
44 array_push( $styles, 'animate' );
45 }
46
47 return $styles;
48 }
49
50 public function block_frontend_assets() {
51
52 if ( is_admin() ) {
53 return;
54 }
55
56 if ( ! wp_style_is( 'animate', 'enqueued' ) ) {
57 wp_enqueue_style('animate');
58 }
59
60 if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
61 return;
62 }
63
64 $deps = [
65 'animate'
66 ];
67
68 add_filter( 'getwid/optimize/assets',
69 function ( $assets ) {
70 $assets[] = getwid()->settings()->getPrefix() . '-blocks-common';
71
72 return $assets;
73 }
74 );
75
76 add_filter( 'getwid/optimize/should_load_common_css', '__return_true' );
77
78 //fontawesome
79 $deps = getwid()->fontIconsManager()->enqueueFonts( $deps );
80
81 $rtl = is_rtl() ? '.rtl' : '';
82
83 wp_enqueue_style(
84 self::$blockName,
85 getwid_get_plugin_url( 'assets/blocks/icon-box/style' . $rtl . '.css' ),
86 $deps,
87 getwid()->settings()->getVersion()
88 );
89
90 wp_enqueue_script(
91 self::$blockName,
92 getwid_get_plugin_url( 'assets/blocks/icon-box/frontend.js' ),
93 [ 'jquery' ],
94 getwid()->settings()->getVersion(),
95 true
96 );
97
98 }
99
100 public function render_callback( $attributes, $content ) {
101
102 $this->block_frontend_assets();
103
104 return $content;
105 }
106 }
107
108 getwid()->blocksManager()->addBlock(
109 new \Getwid\Blocks\IconBox()
110 );
111