PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.7.8
Post Grid Gutenberg Blocks – PostX v2.7.8
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / addons / builder / blocks / Post_Video.php

Post_Video.php in Post Grid Gutenberg Blocks – PostX 2.7.8, at addons/builder/blocks/Post_Video.php

366 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP\blocks;
3
4 defined('ABSPATH') || exit;
5
6 class Post_Video{
7 public function __construct() {
8 add_action('init', array($this, 'register'));
9 }
10 public function get_attributes($default = false) {
11
12 $attributes = array(
13 'blockId' => [
14 'type' => 'string',
15 'default' => '',
16 ],
17
18
19 /*============================
20 Post Video Settings
21 ============================*/
22 // 'previews' => [
23 // 'type' => 'string',
24 // 'default' => ''
25 // ],
26 'videoWidth' => [
27 'type' => 'object',
28 'default' => (object)['lg' =>'100', 'unit' =>'%'],
29 'style' => [
30 (object)[
31 'selector' => '{{ULTP}} .ultp-builder-video video, {{ULTP}} .ultp-embaded-video {max-width:{{videoWidth}};}'
32 ],
33 ],
34 ],
35 'vdAutoPlay' => [
36 'type' => 'boolean',
37 'default' => false,
38 ],
39 'vdLoop' => [
40 'type' => 'boolean',
41 'default' => false,
42 ],
43 'vdMute' => [
44 'type' => 'boolean',
45 'default' => false,
46 ],
47 'vdPlayback' => [
48 'type' => 'boolean',
49 'default' => false,
50 ],
51 'vdInline' => [
52 'type' => 'boolean',
53 'default' => false,
54 ],
55 'vdPreload' => [
56 "type" => "string",
57 "default" => "auto"
58 ],
59 'vdPosterImg' => [
60 "type" => "object",
61 "default" => "",
62 ],
63 'videoAlign' => [
64 'type' => 'object',
65 'default' => (object)['lg' =>'center'],
66 'style' => [
67 (object)[
68 'selector'=>'{{ULTP}} .ultp-builder-video {text-align:{{videoAlign}};}'
69 ],
70 ],
71 ],
72
73 //--------------------------
74 // Advanced Style
75 //--------------------------
76 'wrapBg' => [
77 'type' => 'object',
78 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#f5f5f5'],
79 'style' => [
80 (object)[
81 'selector'=>'{{ULTP}} .ultp-block-wrapper'
82 ],
83 ],
84 ],
85 'wrapBorder' => [
86 'type' => 'object',
87 'default' => (object)['openBorder'=>0, 'width' =>(object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
88 'style' => [
89 (object)[
90 'selector'=>'{{ULTP}} .ultp-block-wrapper'
91 ],
92 ],
93 ],
94 'wrapShadow' => [
95 'type' => 'object',
96 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
97 'style' => [
98 (object)[
99 'selector'=>'{{ULTP}} .ultp-block-wrapper'
100 ],
101 ],
102 ],
103 'wrapRadius' => [
104 'type' => 'object',
105 'default' => (object)['lg' =>'', 'unit' =>'px'],
106 'style' => [
107 (object)[
108 'selector'=>'{{ULTP}} .ultp-block-wrapper { border-radius:{{wrapRadius}}; }'
109 ],
110 ],
111 ],
112 'wrapHoverBackground' => [
113 'type' => 'object',
114 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#037fff'],
115 'style' => [
116 (object)[
117 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
118 ],
119 ],
120 ],
121 'wrapHoverBorder' => [
122 'type' => 'object',
123 'default' => (object)['openBorder'=>0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
124 'style' => [
125 (object)[
126 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
127 ],
128 ],
129 ],
130 'wrapHoverRadius' => [
131 'type' => 'object',
132 'default' => (object)['lg' =>'', 'unit' =>'px'],
133 'style' => [
134 (object)[
135 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover { border-radius:{{wrapHoverRadius}}; }'
136 ],
137 ],
138 ],
139 'wrapHoverShadow' => [
140 'type' => 'object',
141 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
142 'style' => [
143 (object)[
144 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
145 ],
146 ],
147 ],
148 'wrapMargin' => [
149 'type' => 'object',
150 'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']],
151 'style' => [
152 (object)[
153 'selector'=>'{{ULTP}} .ultp-block-wrapper { margin:{{wrapMargin}}; }'
154 ],
155 ],
156 ],
157 'wrapOuterPadding' => [
158 'type' => 'object',
159 'default' => (object)['lg' =>(object)['top' => '','bottom' => '','left' => '', 'right' => '', 'unit' =>'px']],
160 'style' => [
161 (object)[
162 'selector'=>'{{ULTP}} .ultp-block-wrapper { padding:{{wrapOuterPadding}}; }'
163 ],
164 ],
165 ],
166
167
168 //--------------------------
169 // Advanced Settings
170 //--------------------------
171 'advanceId' => [
172 'type' => 'string',
173 'default' => '',
174 ],
175 'advanceZindex' => [
176 'type' => 'number',
177 'default' => '',
178 'style' => [
179 (object)[
180 'selector' => '{{ULTP}} {z-index:{{advanceZindex}};}'
181 ],
182 ],
183 ],
184 'wrapMargin' => [
185 'type' => 'object',
186 'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']],
187 'style' => [
188 (object)[
189 'selector'=>'{{ULTP}} .ultp-block-wrapper { margin:{{wrapMargin}}; }'
190 ],
191 ],
192 ],
193 'wrapOuterPadding' => [
194 'type' => 'object',
195 'default' => (object)['lg' =>(object)['top' => '','bottom' => '','left' => '', 'right' => '', 'unit' =>'px']],
196 'style' => [
197 (object)[
198 'selector'=>'{{ULTP}} .ultp-block-wrapper { padding:{{wrapOuterPadding}}; }'
199 ],
200 ],
201 ],
202 'wrapBg' => [
203 'type' => 'object',
204 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#f5f5f5'],
205 'style' => [
206 (object)[
207 'selector'=>'{{ULTP}} .ultp-block-wrapper'
208 ],
209 ],
210 ],
211 'wrapBorder' => [
212 'type' => 'object',
213 'default' => (object)['openBorder'=>0, 'width' =>(object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
214 'style' => [
215 (object)[
216 'selector'=>'{{ULTP}} .ultp-block-wrapper'
217 ],
218 ],
219 ],
220 'wrapShadow' => [
221 'type' => 'object',
222 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
223 'style' => [
224 (object)[
225 'selector'=>'{{ULTP}} .ultp-block-wrapper'
226 ],
227 ],
228 ],
229 'wrapRadius' => [
230 'type' => 'object',
231 'default' => (object)['lg' =>'', 'unit' =>'px'],
232 'style' => [
233 (object)[
234 'selector'=>'{{ULTP}} .ultp-block-wrapper { border-radius:{{wrapRadius}}; }'
235 ],
236 ],
237 ],
238 'wrapHoverBackground' => [
239 'type' => 'object',
240 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#037fff'],
241 'style' => [
242 (object)[
243 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
244 ],
245 ],
246 ],
247 'wrapHoverBorder' => [
248 'type' => 'object',
249 'default' => (object)['openBorder'=>0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
250 'style' => [
251 (object)[
252 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
253 ],
254 ],
255 ],
256 'wrapHoverRadius' => [
257 'type' => 'object',
258 'default' => (object)['lg' =>'', 'unit' =>'px'],
259 'style' => [
260 (object)[
261 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover { border-radius:{{wrapHoverRadius}}; }'
262 ],
263 ],
264 ],
265 'wrapHoverShadow' => [
266 'type' => 'object',
267 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
268 'style' => [
269 (object)[
270 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
271 ],
272 ],
273 ],
274 'hideExtraLarge' => [
275 'type' => 'boolean',
276 'default' => false,
277 'style' => [
278 (object)[
279 'selector' => '{{ULTP}} {display:none;}'
280 ],
281 ],
282 ],
283 'hideDesktop' => [
284 'type' => 'boolean',
285 'default' => false,
286 'style' => [
287 (object)[
288 'selector' => '{{ULTP}} {display:none;}'
289 ],
290 ],
291 ],
292 'hideTablet' => [
293 'type' => 'boolean',
294 'default' => false,
295 'style' => [
296 (object)[
297 'selector' => '{{ULTP}} {display:none;}'
298 ],
299 ],
300 ],
301 'hideMobile' => [
302 'type' => 'boolean',
303 'default' => false,
304 'style' => [
305 (object)[
306 'selector' => '{{ULTP}} {display:none;}'
307 ],
308 ],
309 ],
310 'advanceCss' => [
311 'type' => 'string',
312 'default' => '',
313 'style' => [
314 (object)[
315 'selector' => '{{ULTP}} {display:none;}'
316 ],
317 ],
318 ],
319 );
320
321 if ($default) {
322 $temp = array();
323 foreach ($attributes as $key => $value) {
324 if (isset($value['default'])) {
325 $temp[$key] = $value['default'];
326 }
327 }
328 return $temp;
329 } else {
330 return $attributes;
331 }
332 }
333
334
335 public function register() {
336 register_block_type( 'ultimate-post/post-video',
337 array(
338 'editor_script' => 'ultp-blocks-editor-script',
339 'editor_style' => 'ultp-blocks-editor-css',
340 'attributes' => $this->get_attributes(),
341 'render_callback' => array($this, 'content')
342 )
343 );
344 }
345
346
347 public function content($attr, $noAjax) {
348 $block_name = 'post-video';
349 $wrapper_before = $wrapper_after = $wrapper_content = '';
350 $post_video = get_post_meta(get_the_ID(), '__builder_feature_video', true);
351
352 $embeded = $post_video ? ultimate_post()->get_embeded_video($post_video, $attr["vdAutoPlay"], $attr["vdLoop"], $attr["vdMute"], $attr["vdPlayback"], $attr["vdPreload"], $attr["vdPosterImg"], $attr["vdInline"], array('width' => $attr["videoWidth"]) ) : '';
353
354 if ($embeded) {
355 $wrapper_before .= '<div '.($attr['advanceId']?'id="'.$attr['advanceId'].'" ':'').' class="wp-block-ultimate-post-'.$block_name.' ultp-block-'.$attr["blockId"].(isset($attr["className"])?' '.$attr["className"]:'').'">';
356 $wrapper_before .= '<div class="ultp-block-wrapper">';
357 $wrapper_content .= '<div class="ultp-builder-video">';
358 $wrapper_content .= $embeded;
359 $wrapper_content .= '</div>';
360 $wrapper_after .= '</div>';
361 $wrapper_after .= '</div>';
362 }
363
364 return $wrapper_before.$wrapper_content.$wrapper_after;
365 }
366 }