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/toggle.php +12 -71 2.1.13.0.2 View file →
@@ -1,86 +1,27 @@
1 1 <?php
2 2
3 3 namespace Getwid\Blocks;
4 4
5 -class Toggle extends \Getwid\Blocks\AbstractBlock {
5 +class Toggle extends AbstractBlock {
6 6
7 - protected static $blockName = 'getwid/toggle';
7 + public function __construct() {
8 8
9 - public function __construct() {
9 + parent::__construct( 'getwid/toggle' );
10 10
11 - parent::__construct( self::$blockName );
11 + register_block_type(
12 + getwid_get_plugin_path( 'assets/blocks/toggle/toggle' )
13 + );
12 14
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');
15 + register_block_type(
16 + getwid_get_plugin_path( 'assets/blocks/toggle/toggle-item' )
17 + );
29 18 }
30 19
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;
20 + public function get_label() {
21 + return __( 'Toggle', 'getwid' );
42 22 }
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 23 }
83 24
84 25 getwid()->blocksManager()->addBlock(
85 - new \Getwid\Blocks\Toggle()
26 + new Toggle()
86 27 );