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