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/image-box.php +24 -101 1.8.73.0.2 View file →
@@ -1,101 +1,24 @@
1 -<?php
2 -
3 -namespace Getwid\Blocks;
4 -
5 -class ImageBox extends \Getwid\Blocks\AbstractBlock {
6 -
7 - protected static $blockName = 'getwid/image-box';
8 -
9 - public function __construct() {
10 -
11 - parent::__construct( self::$blockName );
12 -
13 - register_block_type(
14 - 'getwid/image-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 - //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 __('Image Box', 'getwid');
36 - }
37 -
38 - public function block_frontend_styles($styles) {
39 -
40 - //animate.min.css
41 - if ( is_admin() && ! in_array( 'animate', $styles ) ) {
42 - array_push( $styles, 'animate' );
43 - }
44 -
45 - return $styles;
46 - }
47 -
48 - public function block_frontend_assets() {
49 -
50 - if ( is_admin() ) {
51 - return;
52 - }
53 -
54 - if ( ! wp_style_is( 'animate', 'enqueued' ) ) {
55 - wp_enqueue_style('animate');
56 - }
57 -
58 - if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
59 - return;
60 - }
61 -
62 - add_filter( 'getwid/optimize/assets',
63 - function ( $assets ) {
64 - $assets[] = getwid()->settings()->getPrefix() . '-blocks-common';
65 -
66 - return $assets;
67 - }
68 - );
69 -
70 - add_filter( 'getwid/optimize/should_load_common_css', '__return_true' );
71 -
72 - $rtl = is_rtl() ? '.rtl' : '';
73 -
74 - wp_enqueue_style(
75 - self::$blockName,
76 - getwid_get_plugin_url( 'assets/blocks/image-box/style' . $rtl . '.css' ),
77 - [ 'animate' ],
78 - getwid()->settings()->getVersion()
79 - );
80 -
81 - wp_enqueue_script(
82 - self::$blockName,
83 - getwid_get_plugin_url( 'assets/blocks/image-box/frontend.js' ),
84 - [ 'jquery' ],
85 - getwid()->settings()->getVersion(),
86 - true
87 - );
88 -
89 - }
90 -
91 - public function render_callback( $attributes, $content ) {
92 -
93 - $this->block_frontend_assets();
94 -
95 - return $content;
96 - }
97 -}
98 -
99 -getwid()->blocksManager()->addBlock(
100 - new \Getwid\Blocks\ImageBox()
101 -);
1 +<?php
2 +
3 +namespace Getwid\Blocks;
4 +
5 +class ImageBox extends AbstractBlock {
6 +
7 + public function __construct() {
8 +
9 + parent::__construct( 'getwid/image-box' );
10 +
11 + register_block_type(
12 + getwid_get_plugin_path( 'assets/blocks/image-box' )
13 + );
14 + }
15 +
16 + public function get_label() {
17 + return __( 'Image Box', 'getwid' );
18 + }
19 +}
20 +
21 +
22 +getwid()->blocksManager()->addBlock(
23 + new ImageBox()
24 +);