PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.7.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.7.1
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / Gutenberg / plugin.php
embedpress / Gutenberg Last commit date
block-backend 3 years ago dist 3 years ago plugin.php 3 years ago
plugin.php
680 lines
1 <?php
2
3 /**
4 * Blocks Initializer
5 *
6 * Enqueue CSS/JS of all the blocks.
7 *
8 * @since 1.0.0
9 * @package CGB
10 */
11
12 // Exit if accessed directly.
13 use EmbedPress\Includes\Classes\Helper;
14
15 if (!defined('ABSPATH')) {
16 exit;
17 }
18
19
20 /**
21 * Enqueue Gutenberg block assets for both frontend + backend.
22 *
23 * @uses {wp-editor} for WP editor styles.
24 * @since 1.0.0
25 */
26 function embedpress_blocks_cgb_block_assets()
27 { // phpcs:ignore
28 // Styles.
29 wp_enqueue_style(
30 'embedpress_blocks-cgb-style-css', // Handle.
31 EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.style.build.css', // Block style CSS.
32 is_admin() ? array('wp-editor') : null, // Dependency to include the CSS after it.
33 filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.style.build.css') // Version: File modification time.
34 );
35 }
36
37 // Hook: Frontend assets.
38 add_action('enqueue_block_assets', 'embedpress_blocks_cgb_block_assets');
39
40 /**
41 * Enqueue Gutenberg block assets for backend editor.
42 *
43 * @uses {wp-blocks} for block type registration & related functions.
44 * @uses {wp-element} for WP Element abstraction — structure of blocks.
45 * @uses {wp-i18n} to internationalize the block's text.
46 * @uses {wp-editor} for WP editor styles.
47 * @since 1.0.0
48 */
49
50 function embedpress_blocks_cgb_editor_assets()
51 { // phpcs:ignore
52 // Scripts.
53 if (!wp_script_is('embedpress-pdfobject')) {
54 wp_enqueue_script(
55 'embedpress-pdfobject',
56 EMBEDPRESS_URL_ASSETS . 'js/pdfobject.min.js',
57 [],
58 EMBEDPRESS_VERSION
59 );
60 }
61
62 wp_enqueue_script(
63 'embedpress_blocks-cgb-block-js', // Handle.
64 EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.build.js', // Block.build.js: We register the block here. Built with Webpack.
65 array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-api-fetch', 'wp-is-shallow-equal', 'wp-editor', 'wp-components', 'embedpress-pdfobject'), // Dependencies, defined above.
66 filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.build.js'), // Version: File modification time.
67 true // Enqueue the script in the footer.
68 );
69 $wistia_labels = array(
70 'watch_from_beginning' => __('Watch from the beginning', 'embedpress'),
71 'skip_to_where_you_left_off' => __('Skip to where you left off', 'embedpress'),
72 'you_have_watched_it_before' => __('It looks like you\'ve watched<br />part of this video before!', 'embedpress'),
73 );
74 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
75 $active_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
76
77 $wistia_labels = json_encode($wistia_labels);
78 $wistia_options = null;
79 if (function_exists('embedpress_wisita_pro_get_options')) :
80 $wistia_options = embedpress_wisita_pro_get_options();
81 endif;
82 $pars_url = wp_parse_url(get_site_url());
83 $documents_cta_options = (array) get_option(EMBEDPRESS_PLG_NAME . ':document');
84 wp_localize_script('embedpress_blocks-cgb-block-js', 'embedpressObj', array(
85 'wistia_labels' => $wistia_labels,
86 'wisita_options' => $wistia_options,
87 'embedpress_powered_by' => apply_filters('embedpress_document_block_powered_by', true),
88 'embedpress_pro' => defined('EMBEDPRESS_PRO_PLUGIN_FILE'),
89 'twitch_host' => !empty($pars_url['host']) ? $pars_url['host'] : '',
90 'site_url' => site_url(),
91 'active_blocks' => $active_blocks,
92 'document_cta' => $documents_cta_options,
93 'pdf_renderer' => Helper::get_pdf_renderer(),
94 'is_pro_plugin_active' => defined('EMBEDPRESS_SL_ITEM_SLUG'),
95 'ajaxurl' => admin_url('admin-ajax.php')
96 ));
97
98 // Styles.
99 wp_enqueue_style(
100 'embedpress_blocks-cgb-block-editor-css', // Handle.
101 EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.editor.build.css', // Block editor CSS.
102 array('wp-edit-blocks'), // Dependency to include the CSS after it.
103 filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.editor.build.css') // Version: File modification time.
104 );
105 }
106
107 // Hook: Editor assets.
108 add_action('enqueue_block_editor_assets', 'embedpress_blocks_cgb_editor_assets');
109
110
111 function embedpress_block_category($categories, $post)
112 {
113 return array_merge(
114 $categories,
115 array(
116 array(
117 'slug' => 'embedpress',
118 'title' => 'EmbedPress',
119 'icon' => '',
120 ),
121 )
122 );
123 }
124 $wp_version = get_bloginfo('version', 'display');
125 if (version_compare($wp_version, '5.8', '>=')) {
126 add_filter('block_categories_all', 'embedpress_block_category', 10, 2);
127 } else {
128 add_filter('block_categories', 'embedpress_block_category', 10, 2);
129 }
130
131
132
133
134 foreach (glob(EMBEDPRESS_GUTENBERG_DIR_PATH . 'block-backend/*.php') as $block_logic) {
135 require_once $block_logic;
136 }
137
138 /**
139 * Registers the embedpress gutneberg block on server.
140 */
141
142 function embedpress_gutenberg_register_all_block()
143 {
144 if (function_exists('register_block_type')) :
145
146 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
147 $g_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
148 $blocks_to_registers = ['twitch-block', 'google-slides-block', 'google-sheets-block', 'google-maps-block', 'google-forms-block', 'google-drawings-block', 'google-docs-block', 'embedpress', 'embedpress-pdf', 'embedpress-calendar', 'document'];
149
150 foreach ($blocks_to_registers as $blocks_to_register) {
151 if (!empty($g_blocks[$blocks_to_register])) {
152 if ('embedpress' === $blocks_to_register) {
153 register_block_type('embedpress/embedpress', [
154 'render_callback' => 'embedpress_render_block',
155 'attributes' => array(
156 'clientId' => [
157 'type' => 'string',
158 ],
159 'height' => [
160 'type' => 'string',
161 'default' => '450'
162 ],
163 'width' => [
164 'type' => 'string',
165 'default' => '600'
166 ],
167 'lockContent' => [
168 'type' => 'boolean',
169 'default' => false
170 ],
171 'lockHeading' => [
172 'type' => 'string',
173 'default' => 'Content Locked'
174 ],
175 'lockSubHeading' => [
176 'type' => 'string',
177 'default' => 'Content is locked and requires password to access it.'
178 ],
179 'lockErrorMessage' => [
180 'type' => 'string',
181 'default' => 'Oops, that wasn\'t the right password. Try again.'
182 ],
183 'passwordPlaceholder' => [
184 'type' => 'string',
185 'default' => 'Password'
186 ],
187 'submitButtonText' => [
188 'type' => 'string',
189 'default' => 'Unlock'
190 ],
191 'submitUnlockingText' => [
192 'type' => 'string',
193 'default' => 'Unlocking'
194 ],
195 'enableFooterMessage' => [
196 'type' => 'boolean',
197 'default' => false
198 ],
199 'footerMessage' => [
200 'type' => 'string',
201 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
202 ],
203 'contentPassword' => [
204 'type' => 'string',
205 'default' => '',
206 ],
207 'contentShare' => [
208 'type' => 'boolean',
209 'default' => false
210 ],
211 'sharePosition' => [
212 'type' => 'string',
213 'default' => 'right'
214 ],
215 'customTitle' => [
216 'type' => 'string',
217 'default' => ''
218 ],
219 'customDescription' => [
220 'type' => 'string',
221 'default' => ''
222 ],
223 'customThumbnail' => [
224 'type' => 'string',
225 'default' => ''
226 ],
227
228 'videosize' => [
229 'type' => 'string',
230 'default' => 'fixed'
231 ],
232
233 'loadmore' => [
234 'type' => 'boolean',
235 'default' => false
236 ],
237 //Youtube Attributes
238 'starttime' => [
239 'type' => 'string',
240 ],
241 'endtime' => [
242 'type' => 'string',
243 ],
244 'autoplay' => [
245 'type' => 'boolean',
246 'default' => false
247 ],
248 'controls' => [
249 'type' => 'string',
250 ],
251 'progressbarcolor' => [
252 'type' => 'string',
253 ],
254 'videoannotations' => [
255 'type' => 'string',
256 ],
257 'closedcaptions' => [
258 'type' => 'boolean',
259 'default' => true
260 ],
261 'relatedvideos' => [
262 'type' => 'boolean',
263 'default' => true
264 ],
265 'fullscreen' => [
266 'type' => 'boolean',
267 'default' => true
268 ],
269
270 'modestbranding' => [
271 'type' => 'string',
272 ],
273 //Wistia Attributes
274 'wstarttime' => [
275 'type' => 'string',
276 ],
277 'wautoplay' => [
278 'type' => 'boolean',
279 'default' => true
280 ],
281 'scheme' => [
282 'type' => 'string',
283 ],
284 'captions' => [
285 'type' => 'boolean',
286 'default' => true
287 ],
288 'playbutton' => [
289 'type' => 'boolean',
290 'default' => true
291 ],
292 'smallplaybutton' => [
293 'type' => 'boolean',
294 'default' => true
295 ],
296 'playbar' => [
297 'type' => 'boolean',
298 'default' => true
299 ],
300 'resumable' => [
301 'type' => 'boolean',
302 'default' => true
303 ],
304 'wistiafocus' => [
305 'type' => 'boolean',
306 'default' => true
307 ],
308 'volumecontrol' => [
309 'type' => 'boolean',
310 'default' => true
311 ],
312 'volume' => [
313 'type' => 'number',
314 'default' => 100
315 ],
316 'rewind' => [
317 'type' => 'boolean',
318 'default' => false
319 ],
320 'wfullscreen' => [
321 'type' => 'boolean',
322 'default' => true
323 ],
324
325 // Vimeo attributes
326 'vstarttime' => [
327 'type' => 'string',
328 ],
329 'vautoplay' => [
330 'type' => 'boolean',
331 'default' => false
332 ],
333 'vscheme' => [
334 'type' => 'string',
335 ],
336 'vtitle' => [
337 'type' => 'boolean',
338 'default' => true
339 ],
340 'vauthor' => [
341 'type' => 'boolean',
342 'default' => true
343 ],
344 'vavatar' => [
345 'type' => 'boolean',
346 'default' => true
347 ],
348 'vloop' => [
349 'type' => 'boolean',
350 'default' => false
351 ],
352 'vautopause' => [
353 'type' => 'boolean',
354 'default' => false
355 ],
356 'vdnt' => [
357 'type' => 'boolean',
358 'default' => false
359 ],
360
361 ),
362 ]);
363 } elseif ('embedpress-pdf' === $blocks_to_register) {
364 register_block_type('embedpress/embedpress-pdf', [
365 'attributes' => array(
366 'powered_by' => [
367 'type' => 'boolean',
368 'default' => true
369 ],
370 'lockContent' => [
371 'type' => 'boolean',
372 'default' => false
373 ],
374 'lockHeading' => [
375 'type' => 'string',
376 'default' => 'Content Locked'
377 ],
378 'lockSubHeading' => [
379 'type' => 'string',
380 'default' => 'Content is locked and requires password to access it.'
381 ],
382 'passwordPlaceholder' => [
383 'type' => 'string',
384 'default' => 'Password'
385 ],
386 'submitButtonText' => [
387 'type' => 'string',
388 'default' => 'Unlock'
389 ],
390 'submitUnlockingText' => [
391 'type' => 'string',
392 'default' => 'Unlocking'
393 ],
394 'lockErrorMessage' => [
395 'type' => 'string',
396 'default' => 'Oops, that wasn\'t the right password. Try again.'
397 ],
398 'enableFooterMessage' => [
399 'type' => 'boolean',
400 'default' => false
401 ],
402 'footerMessage' => [
403 'type' => 'string',
404 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
405 ],
406 'contentPassword' => [
407 'type' => 'string',
408 'default' => ''
409 ],
410 'contentShare' => [
411 'type' => 'boolean',
412 'default' => false
413 ],
414 'sharePosition' => [
415 'type' => 'string',
416 'default' => 'right'
417 ],
418 'presentation' => [
419 'type' => "boolean",
420 'default' => true,
421 ],
422
423 'position' => [
424 'type' => "string",
425 'default' => 'top',
426 ],
427
428 'print' => [
429 'type' => "boolean",
430 'default' => true,
431 ],
432
433 'download' => [
434 'type' => "boolean",
435 'default' => true,
436 ],
437 'open' => [
438 'type' => "boolean",
439 'default' => true,
440 ],
441 'copy_text' => [
442 'type' => "boolean",
443 'default' => true,
444 ],
445 'add_text' => [
446 'type' => "boolean",
447 'default' => true,
448 ],
449 'draw' => [
450 'type' => "boolean",
451 'default' => true,
452 ],
453 'toolbar' => [
454 'type' => "boolean",
455 'default' => true,
456 ],
457 'doc_details' => [
458 'type' => "boolean",
459 'default' => true,
460 ],
461 'doc_rotation' => [
462 'type' => "boolean",
463 'default' => true,
464 ],
465 'unitoption' => [
466 'type' => "string",
467 'default' => 'px',
468 ],
469 ),
470 'render_callback' => 'embedpress_pdf_render_block',
471 ]);
472 } elseif ('embedpress-calendar' === $blocks_to_register) {
473 register_block_type('embedpress/embedpress-calendar', [
474 'render_callback' => 'embedpress_calendar_render_block',
475 ]);
476 } else {
477 register_block_type('embedpress/' . $blocks_to_register);
478 }
479 } else {
480
481 if (WP_Block_Type_Registry::get_instance()->is_registered('embedpress/' . $blocks_to_register)) {
482 unregister_block_type('embedpress/' . $blocks_to_register);
483 }
484 }
485 }
486
487 endif;
488 }
489
490 add_action('init', 'embedpress_gutenberg_register_all_block');
491
492 function getParamData($attributes)
493 {
494
495 $urlParamData = array(
496 'themeMode' => !empty($attributes['themeMode']) ? $attributes['themeMode'] : 'default',
497 'toolbar' => !empty($attributes['toolbar']) ? 'true' : 'false',
498 'position' => $attributes['position'],
499 'presentation' => !empty($attributes['presentation']) ? 'true' : 'false',
500 'download' => !empty($attributes['download']) ? 'true' : 'false',
501 'copy_text' => !empty($attributes['copy_text']) ? 'true' : 'false',
502 'add_text' => !empty($attributes['add_text']) ? 'true' : 'false',
503 'draw' => !empty($attributes['draw']) ? 'true' : 'false',
504 'doc_rotation' => !empty($attributes['doc_rotation']) ? 'true' : 'false',
505 'doc_details' => !empty($attributes['doc_details']) ? 'true' : 'false',
506 );
507
508 if($urlParamData['themeMode'] == 'custom') {
509 $urlParamData['customColor'] = !empty($attributes['customColor']) ? $attributes['customColor'] : '#403A81';
510 }
511
512 return "#" . http_build_query($urlParamData);
513 }
514
515 function embedpress_pdf_render_block($attributes)
516 {
517
518
519 if (!empty($attributes['href'])) {
520 $renderer = Helper::get_pdf_renderer();
521 $pdf_url = $attributes['href'];
522 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-pdf-' . rand(100, 10000);
523 $client_id = md5($id);
524
525 $hash_pass = hash('sha256', wp_salt(32) . md5(isset($attributes['contentPassword']) ? $attributes['contentPassword'] : ''));
526
527 $unitoption = !empty($attributes['unitoption']) ? $attributes['unitoption'] : 'px';
528 $width = !empty($attributes['width']) ? $attributes['width'] . $unitoption : '600px';
529
530 if($unitoption == '%'){
531 $width_class = ' ep-percentage-width';
532 }
533 else{
534 $width_class = 'ep-fixed-width';
535 }
536 $content_share_class = '';
537 $share_position_class = '';
538 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
539
540 if(!empty($attributes['contentShare'])) {
541 $content_share_class = 'ep-content-share-enabled';
542 $share_position_class = 'ep-share-position-'.$share_position;
543 }
544
545 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
546
547 $content_protection_class = 'ep-content-protection-enabled';
548 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || $hash_pass === $password_correct) {
549 $content_protection_class = 'ep-content-protection-disabled';
550 }
551
552
553
554 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
555 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
556
557 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
558 if (isset($attributes['powered_by'])) {
559 $powered_by = $attributes['powered_by'];
560 }
561
562 $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($attributes['href']) . getParamData($attributes);
563
564 $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): '';
565
566 $aligns = [
567 'left' => 'ep-alignleft',
568 'right' => 'ep-alignright',
569 'center' => 'ep-aligncenter',
570 'wide' => 'ep-alignwide',
571 'full' => 'ep-alignfull'
572 ];
573 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
574 $dimension = "width:$width;height:$height";
575 ob_start();
576 ?>
577
578
579 <?php
580
581 $embed_code = '<iframe title="' . esc_attr(Helper::get_file_title($attributes['href'])) . '" class="embedpress-embed-document-pdf ' . esc_attr($id) . '" style="' . esc_attr($dimension) . '; max-width:100%; display: inline-block" src="' . esc_attr($src) . '" frameborder="0" oncontextmenu="return false;"></iframe> ';
582
583
584 if ($powered_by) {
585 $embed_code .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
586 }
587
588
589 $url = !empty($attributes['href']) ? $attributes['href'] : '';
590 ?>
591
592 <div id="ep-gutenberg-content-<?php echo esc_attr( $client_id )?>" class="ep-gutenberg-content <?php echo esc_attr( $alignment.' '.$width_class.' '.$content_share_class.' '.$share_position_class.' '.$content_protection_class); ?> ">
593 <div class="embedpress-inner-iframe <?php if ($unitoption === '%') { echo esc_attr('emebedpress-unit-percent'); } ?> ep-doc-<?php echo esc_attr($client_id); ?>"<?php if ($unitoption === '%' && !empty($attributes['width'])) { $style_attr = 'max-width:' . $attributes['width'] . '%'; } else { $style_attr = 'max-width:100%'; } ?> style="<?php echo esc_attr($style_attr); ?>" id="<?php echo esc_attr($id); ?>">
594
595 <?php
596 do_action('embedpress_pdf_gutenberg_after_embed', $client_id, 'pdf', $attributes, $pdf_url);
597 $embed = $embed_code;
598 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
599
600 $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : '';
601
602 echo '<div class="ep-embed-content-wraper">';
603 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
604 $embed .= $embed_code;
605 $embed.= '</div>';
606
607 if(!empty($attributes['contentShare'])) {
608 $content_id = $attributes['id'];
609 $embed .= Helper::embed_content_share($content_id, $attributes);
610 }
611 echo $embed;
612 echo '</div>';
613 } else {
614 if(!empty($attributes['contentShare'])) {
615 $content_id = $attributes['clientId'];
616 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
617 $embed .= $embed_code;
618 $embed.= '</div>';
619 $embed .= Helper::embed_content_share($content_id, $attributes);
620 }
621 echo '<div class="ep-embed-content-wraper">';
622 Helper::display_password_form($client_id, $embed, $pass_hash_key, $attributes);
623 echo '</div>';
624 }
625 ?>
626
627 </div>
628 </div>
629 <?php
630 return ob_get_clean();
631 }
632 }
633
634 function embedpress_calendar_render_block($attributes)
635 {
636
637 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-calendar-' . rand(100, 10000);
638 $url = !empty($attributes['url']) ? $attributes['url'] : '';
639 $is_private = isset($attributes['is_public']);
640 $client_id = md5($id);
641 $width = !empty($attributes['width']) ? $attributes['width'] . 'px' : '600px';
642 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
643 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
644 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
645 if (isset($attributes['powered_by'])) {
646 $powered_by = $attributes['powered_by'];
647 }
648
649 $aligns = [
650 'left' => 'alignleft',
651 'right' => 'alignright',
652 'wide' => 'alignwide',
653 'full' => 'alignfull'
654 ];
655 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
656 $dimension = "width:$width;height:$height";
657 ob_start();
658 ?>
659 <div class="embedpress-calendar-gutenberg embedpress-calendar ose-calendar <?php echo esc_attr($alignment) ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%;">
660
661 <?php
662 if (!empty($url) && !$is_private) {
663 ?>
664 <iframe title="<?php echo esc_attr(Helper::get_file_title($url)); ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block" src="<?php echo esc_attr($url); ?>"></iframe>
665 <?php } else {
666 if (is_embedpress_pro_active()) {
667 echo Embedpress_Google_Helper::shortcode();
668 }
669 } ?>
670 <?php do_action('embedpress_calendar_gutenberg_after_embed', $client_id, 'calendar', $attributes); ?>
671
672 <?php
673 if ($powered_by) {
674 printf('<p class="embedpress-el-powered" style="width:' . esc_attr($width) . '" >%s</p>', __('Powered By EmbedPress', 'embedpress'));
675 } ?>
676
677 </div>
678 <?php
679 return ob_get_clean();
680 }