PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / blocks / player / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.13.0, at includes/blocks/player/block.php

174 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Player;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGeneratorV2;
10 use ABlocks\Controls\CssFilter;
11 use ABlocks\Controls\Color;
12
13 class Block extends BlockBaseAbstract {
14 protected $block_name = 'player';
15 protected $style_depends = [ 'ablocks-plyr-style' ];
16 protected $script_depends = [ 'ablocks-plyr-script' ];
17
18 public function build_css( $attributes ) {
19
20 // Generate CSS start
21 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
22
23 $css_generator->add_class_styles(
24 '{{WRAPPER}} .ablocks-block-youtube-container > .plyr--video > .plyr__controls',
25 $this->get_youtube_progress_style_css( $attributes ),
26 $this->get_youtube_progress_style_css( $attributes, 'Tablet' ),
27 $this->get_youtube_progress_style_css( $attributes, 'Mobile' )
28 );
29 $css_generator->add_class_styles(
30 '{{WRAPPER}} .ablocks-block-youtube-container > .plyr--youtube > .plyr__control--overlaid',
31 $this->get_youtube_play_pause__button_style_css( $attributes ),
32 $this->get_youtube_play_pause__button_style_css( $attributes, 'Tablet' ),
33 $this->get_youtube_play_pause__button_style_css( $attributes, 'Mobile' )
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ablocks-block-selfhosted-container > .plyr--video > .plyr__controls',
37 $this->get_self_video_style_css( $attributes ),
38 $this->get_self_video_style_css( $attributes, 'Tablet' ),
39 $this->get_self_video_style_css( $attributes, 'Mobile' )
40 );
41 $css_generator->add_class_styles(
42 '{{WRAPPER}} .ablocks-block-selfhosted-container > .plyr--html5 > .plyr__control--overlaid',
43 $this->get_self_host_control_style_css( $attributes ),
44 $this->get_self_host_control_style_css( $attributes, 'Tablet' ),
45 $this->get_self_host_control_style_css( $attributes, 'Mobile' )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .ablocks-block-vimeo-container > .plyr--video > .plyr__controls',
49 $this->get_vimeo_video_style_css( $attributes ),
50 $this->get_vimeo_video_style_css( $attributes, 'Tablet' ),
51 $this->get_vimeo_video_style_css( $attributes, 'Mobile' )
52 );
53 $css_generator->add_class_styles(
54 '{{WRAPPER}} .ablocks-block-vimeo-container > .plyr--vimeo > .plyr__control--overlaid',
55 $this->get_vimeo_player_control_style_css( $attributes ),
56 $this->get_vimeo_player_control_style_css( $attributes, 'Tablet' ),
57 $this->get_vimeo_player_control_style_css( $attributes, 'Mobile' )
58 );
59 $css_generator->add_class_styles(
60 '{{WRAPPER}} .plyr__poster',
61 $this->get_poster_image( $attributes ),
62 $this->get_poster_image( $attributes, 'Tablet' ),
63 $this->get_poster_image( $attributes, 'Mobile' )
64 );
65
66 return $css_generator->generate_css();
67 // Generate CSS end
68 }
69 public function get_youtube_progress_style_css( $attributes, $device = '' ) {
70 $css = [];
71
72 if ( isset( $attributes['youtubeIconSize'] ) ) {
73 $css['--plyr-control-icon-size'] = $attributes['youtubeIconSize'] . 'px';
74 }
75 $css['padding'] = '0';
76 return array_merge(
77 [ '--plyr-color-main' => Color::get_css( isset( $attributes['youtubeProgressColor'] ) ? $attributes['youtubeProgressColor'] : '' ) ],
78 [ '--plyr-video-controls-background' => Color::get_css( isset( $attributes['playerbgColor'] ) ? $attributes['playerbgColor'] : '' ) ],
79 $css
80 );
81 }
82 public function get_youtube_play_pause__button_style_css( $attributes, $device = '' ) {
83 $css = [];
84
85 if ( isset( $attributes['youtubeUiColor'] ) ) {
86 $css['--plyr-color-main'] = Color::get_css(
87 isset( $attributes['youtubeUiColor'] ) ? $attributes['youtubeUiColor'] : '');
88
89 }
90
91 if ( isset( $attributes['youtubePlayPauseIconSize'] ) ) {
92 $css['--plyr-control-icon-size'] = $attributes['youtubePlayPauseIconSize'] . 'px';
93 }
94
95 return $css;
96 }
97 public function get_self_video_style_css( $attributes, $device = '' ) {
98 $css = [];
99
100 if ( isset( $attributes['selfVideoProgressUiColor'] ) ) {
101 $css['--plyr-color-main'] = Color::get_css(
102 isset( $attributes['selfVideoProgressUiColor'] ) ? $attributes['selfVideoProgressUiColor'] : '');
103 }
104
105 if ( isset( $attributes['selfHostedPlayIconSize'] ) ) {
106 $css['--plyr-control-icon-size'] = $attributes['selfHostedPlayIconSize'] . 'px';
107 }
108 if ( isset( $attributes['selfVideobgColor'] ) ) {
109 $css['--plyr-video-controls-background'] = Color::get_css(
110 isset( $attributes['selfVideobgColor'] ) ? $attributes['selfVideobgColor'] : '');
111 }
112 $css['padding'] = '0';
113
114 return $css;
115 }
116 public function get_self_host_control_style_css( $attributes, $device = '' ) {
117 $css = [];
118
119 if ( isset( $attributes['selfVideoUiColor'] ) ) {
120 $css['--plyr-color-main'] = Color::get_css(
121 isset( $attributes['selfVideoUiColor'] ) ? $attributes['selfVideoUiColor'] : '');
122
123 }
124
125 if ( isset( $attributes['selfHostedIconSize'] ) ) {
126 $css['--plyr-control-icon-size'] = $attributes['selfHostedIconSize'] . 'px';
127 }
128
129 return $css;
130 }
131 public function get_vimeo_video_style_css( $attributes, $device = '' ) {
132 $css = [];
133
134 if ( isset( $attributes['vimeoProgressUiColor'] ) ) {
135 $css['--plyr-color-main'] = Color::get_css(
136 isset( $attributes['vimeoProgressUiColor'] ) ? $attributes['vimeoProgressUiColor'] : '');
137
138 }
139
140 if ( isset( $attributes['vimeoPlayIconSize'] ) ) {
141 $css['--plyr-control-icon-size'] = $attributes['vimeoPlayIconSize'] . 'px';
142 }
143 if ( isset( $attributes['vimeobgColor'] ) ) {
144 $css['--plyr-video-controls-background'] = Color::get_css(
145 isset( $attributes['vimeobgColor'] ) ? $attributes['vimeobgColor'] : '');
146 }
147 $css['padding'] = '0';
148
149 return $css;
150 }
151 public function get_vimeo_player_control_style_css( $attributes, $device = '' ) {
152 $css = [];
153 $css['--plyr-color-main'] = Color::get_css(
154 isset( $attributes['vimeoUiColor'] ) ? $attributes['vimeoUiColor'] : '');
155
156 if ( isset( $attributes['vimeoIconSize'] ) ) {
157 $css['--plyr-control-icon-size'] = $attributes['vimeoIconSize'] . 'px';
158 }
159
160 return $css;
161 }
162 public function get_poster_image( $attributes, $device = '' ) {
163 $css = [];
164
165 if ( ! empty( $attributes['posterImage'] ) ) {
166 $css['background-image'] = 'url(' . esc_url( $attributes['posterImage'] ) . ') !important';
167 }
168
169 $css['background-size'] = 'cover';
170
171 return $css;
172 }
173 }
174