PluginProbe
Getwid – Gutenberg Blocks / 2.1.3
Getwid – Gutenberg Blocks v2.1.3
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 / toggle.php

toggle.php in Getwid – Gutenberg Blocks 2.1.3, at includes/blocks/toggle.php

87 lines 1.8 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 Toggle extends \Getwid\Blocks\AbstractBlock {
6
7 protected static $blockName = 'getwid/toggle';
8
9 public function __construct() {
10
11 parent::__construct( self::$blockName );
12
13 register_block_type(
14 'getwid/toggle',
15 array(
16 'render_callback' => [ $this, 'render_callback' ]
17 )
18 );
19
20 if ( $this->isEnabled() ) {
21
22 add_filter( 'getwid/editor_blocks_js/dependencies', [ $this, 'block_editor_scripts'] );
23 add_filter( 'getwid/blocks_style_css/dependencies', [ $this, 'block_frontend_styles' ] );
24 }
25 }
26
27 public function getLabel() {
28 return __('Toggle', 'getwid');
29 }
30
31 public function block_editor_scripts($scripts) {
32
33 return $scripts;
34 }
35
36 public function block_frontend_styles($styles) {
37
38 //fontawesome
39 $styles = getwid()->fontIconsManager()->enqueueFonts( $styles );
40
41 return $styles;
42 }
43
44 public function block_frontend_assets() {
45
46 if ( is_admin() ) {
47 return;
48 }
49
50 if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
51 return;
52 }
53
54 //fontawesome
55 $deps = getwid()->fontIconsManager()->enqueueFonts( [] );
56
57 $rtl = is_rtl() ? '.rtl' : '';
58
59 wp_enqueue_style(
60 self::$blockName,
61 getwid_get_plugin_url( 'assets/blocks/toggle/style' . $rtl . '.css' ),
62 $deps,
63 getwid()->settings()->getVersion()
64 );
65
66 wp_enqueue_script(
67 self::$blockName,
68 getwid_get_plugin_url( 'assets/blocks/toggle/frontend.js' ),
69 [ 'jquery' ],
70 getwid()->settings()->getVersion(),
71 true
72 );
73
74 }
75
76 public function render_callback( $attributes, $content ) {
77
78 $this->block_frontend_assets();
79
80 return $content;
81 }
82 }
83
84 getwid()->blocksManager()->addBlock(
85 new \Getwid\Blocks\Toggle()
86 );
87