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