PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.8.0
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.8.0
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
737 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
70 wp_enqueue_script(
71 'embedpress_documents_viewer_script', EMBEDPRESS_PLUGIN_DIR_URL . 'assets/js/documents-viewer-script.js', array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ), EMBEDPRESS_PLUGIN_VERSION, true
72 );
73
74 $wistia_labels = array(
75 'watch_from_beginning' => __('Watch from the beginning', 'embedpress'),
76 'skip_to_where_you_left_off' => __('Skip to where you left off', 'embedpress'),
77 'you_have_watched_it_before' => __('It looks like you\'ve watched<br />part of this video before!', 'embedpress'),
78 );
79 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
80 $active_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
81
82 $wistia_labels = json_encode($wistia_labels);
83 $wistia_options = null;
84 if (function_exists('embedpress_wisita_pro_get_options')) :
85 $wistia_options = embedpress_wisita_pro_get_options();
86 endif;
87 $pars_url = wp_parse_url(get_site_url());
88 $documents_cta_options = (array) get_option(EMBEDPRESS_PLG_NAME . ':document');
89 wp_localize_script('embedpress_blocks-cgb-block-js', 'embedpressObj', array(
90 'wistia_labels' => $wistia_labels,
91 'wisita_options' => $wistia_options,
92 'embedpress_powered_by' => apply_filters('embedpress_document_block_powered_by', true),
93 'embedpress_pro' => defined('EMBEDPRESS_PRO_PLUGIN_FILE'),
94 'twitch_host' => !empty($pars_url['host']) ? $pars_url['host'] : '',
95 'site_url' => site_url(),
96 'active_blocks' => $active_blocks,
97 'document_cta' => $documents_cta_options,
98 'pdf_renderer' => Helper::get_pdf_renderer(),
99 'is_pro_plugin_active' => defined('EMBEDPRESS_SL_ITEM_SLUG'),
100 'ajaxurl' => admin_url('admin-ajax.php')
101 ));
102
103 // Styles.
104 wp_enqueue_style(
105 'embedpress_blocks-cgb-block-editor-css', // Handle.
106 EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.editor.build.css', // Block editor CSS.
107 array('wp-edit-blocks'), // Dependency to include the CSS after it.
108 filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.editor.build.css') // Version: File modification time.
109 );
110 }
111
112 // Hook: Editor assets.
113 add_action('enqueue_block_editor_assets', 'embedpress_blocks_cgb_editor_assets');
114
115
116 function embedpress_block_category($categories, $post)
117 {
118 return array_merge(
119 $categories,
120 array(
121 array(
122 'slug' => 'embedpress',
123 'title' => 'EmbedPress',
124 'icon' => '',
125 ),
126 )
127 );
128 }
129 $wp_version = get_bloginfo('version', 'display');
130 if (version_compare($wp_version, '5.8', '>=')) {
131 add_filter('block_categories_all', 'embedpress_block_category', 10, 2);
132 } else {
133 add_filter('block_categories', 'embedpress_block_category', 10, 2);
134 }
135
136
137
138
139 foreach (glob(EMBEDPRESS_GUTENBERG_DIR_PATH . 'block-backend/*.php') as $block_logic) {
140 require_once $block_logic;
141 }
142
143 /**
144 * Registers the embedpress gutneberg block on server.
145 */
146
147 function embedpress_gutenberg_register_all_block()
148 {
149 if (function_exists('register_block_type')) :
150
151 $elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
152 $g_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
153 $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'];
154
155 foreach ($blocks_to_registers as $blocks_to_register) {
156 if (!empty($g_blocks[$blocks_to_register])) {
157 if ('embedpress' === $blocks_to_register) {
158 register_block_type('embedpress/embedpress', [
159 'render_callback' => 'embedpress_render_block',
160 'attributes' => array(
161 'clientId' => [
162 'type' => 'string',
163 ],
164 'height' => [
165 'type' => 'string',
166 'default' => '450'
167 ],
168 'width' => [
169 'type' => 'string',
170 'default' => '600'
171 ],
172 'lockContent' => [
173 'type' => 'boolean',
174 'default' => false
175 ],
176 'lockHeading' => [
177 'type' => 'string',
178 'default' => 'Content Locked'
179 ],
180 'lockSubHeading' => [
181 'type' => 'string',
182 'default' => 'Content is locked and requires password to access it.'
183 ],
184 'lockErrorMessage' => [
185 'type' => 'string',
186 'default' => 'Oops, that wasn\'t the right password. Try again.'
187 ],
188 'passwordPlaceholder' => [
189 'type' => 'string',
190 'default' => 'Password'
191 ],
192 'submitButtonText' => [
193 'type' => 'string',
194 'default' => 'Unlock'
195 ],
196 'submitUnlockingText' => [
197 'type' => 'string',
198 'default' => 'Unlocking'
199 ],
200 'enableFooterMessage' => [
201 'type' => 'boolean',
202 'default' => false
203 ],
204 'footerMessage' => [
205 'type' => 'string',
206 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
207 ],
208 'contentPassword' => [
209 'type' => 'string',
210 'default' => '',
211 ],
212 'contentShare' => [
213 'type' => 'boolean',
214 'default' => false
215 ],
216 'sharePosition' => [
217 'type' => 'string',
218 'default' => 'right'
219 ],
220 'customTitle' => [
221 'type' => 'string',
222 'default' => ''
223 ],
224 'customDescription' => [
225 'type' => 'string',
226 'default' => ''
227 ],
228 'customThumbnail' => [
229 'type' => 'string',
230 'default' => ''
231 ],
232
233 'videosize' => [
234 'type' => 'string',
235 'default' => 'fixed'
236 ],
237
238 'loadmore' => [
239 'type' => 'boolean',
240 'default' => false
241 ],
242 //Youtube Attributes
243 'starttime' => [
244 'type' => 'string',
245 ],
246 'endtime' => [
247 'type' => 'string',
248 ],
249 'autoplay' => [
250 'type' => 'boolean',
251 'default' => false
252 ],
253 'controls' => [
254 'type' => 'string',
255 ],
256 'progressbarcolor' => [
257 'type' => 'string',
258 ],
259 'videoannotations' => [
260 'type' => 'string',
261 ],
262 'closedcaptions' => [
263 'type' => 'boolean',
264 'default' => true
265 ],
266 'relatedvideos' => [
267 'type' => 'boolean',
268 'default' => true
269 ],
270 'fullscreen' => [
271 'type' => 'boolean',
272 'default' => true
273 ],
274
275 'modestbranding' => [
276 'type' => 'string',
277 ],
278 // custom player attributes
279 'customPlayer' => [
280 'type' => 'boolean',
281 'default' => false
282 ],
283
284 'posterThumbnail' => [
285 'type' => 'string',
286 'default' => ''
287 ],
288
289 'playerPreset' => [
290 'type' => 'string',
291 'default' => ''
292 ],
293
294 'playerColor' => [
295 'type' => 'string',
296 'default' => '#2e2e99'
297 ],
298
299 'playerPip' => [
300 'type' => 'boolean',
301 'default' => false
302 ],
303
304 'playerRestart' => [
305 'type' => 'boolean',
306 'default' => true
307 ],
308
309 'playerRewind' => [
310 'type' => 'boolean',
311 'default' => true
312 ],
313
314 'playerFastForward' => [
315 'type' => 'boolean',
316 'default' => true
317 ],
318 'playerTooltip' => [
319 'type' => 'boolean',
320 'default' => true
321 ],
322 'playerHideControls' => [
323 'type' => 'boolean',
324 'default' => true
325 ],
326 'playerDownload' => [
327 'type' => 'boolean',
328 'default' => true
329 ],
330 //Wistia Attributes
331 'wstarttime' => [
332 'type' => 'string',
333 ],
334 'wautoplay' => [
335 'type' => 'boolean',
336 'default' => true
337 ],
338 'scheme' => [
339 'type' => 'string',
340 ],
341 'captions' => [
342 'type' => 'boolean',
343 'default' => true
344 ],
345 'playbutton' => [
346 'type' => 'boolean',
347 'default' => true
348 ],
349 'smallplaybutton' => [
350 'type' => 'boolean',
351 'default' => true
352 ],
353 'playbar' => [
354 'type' => 'boolean',
355 'default' => true
356 ],
357 'resumable' => [
358 'type' => 'boolean',
359 'default' => true
360 ],
361 'wistiafocus' => [
362 'type' => 'boolean',
363 'default' => true
364 ],
365 'volumecontrol' => [
366 'type' => 'boolean',
367 'default' => true
368 ],
369 'volume' => [
370 'type' => 'number',
371 'default' => 100
372 ],
373 'rewind' => [
374 'type' => 'boolean',
375 'default' => false
376 ],
377 'wfullscreen' => [
378 'type' => 'boolean',
379 'default' => true
380 ],
381
382 // Vimeo attributes
383 'vstarttime' => [
384 'type' => 'string',
385 ],
386 'vautoplay' => [
387 'type' => 'boolean',
388 'default' => false
389 ],
390 'vscheme' => [
391 'type' => 'string',
392 ],
393 'vtitle' => [
394 'type' => 'boolean',
395 'default' => true
396 ],
397 'vauthor' => [
398 'type' => 'boolean',
399 'default' => true
400 ],
401 'vavatar' => [
402 'type' => 'boolean',
403 'default' => true
404 ],
405 'vloop' => [
406 'type' => 'boolean',
407 'default' => false
408 ],
409 'vautopause' => [
410 'type' => 'boolean',
411 'default' => false
412 ],
413 'vdnt' => [
414 'type' => 'boolean',
415 'default' => false
416 ],
417
418 ),
419 ]);
420 } elseif ('embedpress-pdf' === $blocks_to_register) {
421 register_block_type('embedpress/embedpress-pdf', [
422 'attributes' => array(
423 'powered_by' => [
424 'type' => 'boolean',
425 'default' => true
426 ],
427 'lockContent' => [
428 'type' => 'boolean',
429 'default' => false
430 ],
431 'lockHeading' => [
432 'type' => 'string',
433 'default' => 'Content Locked'
434 ],
435 'lockSubHeading' => [
436 'type' => 'string',
437 'default' => 'Content is locked and requires password to access it.'
438 ],
439 'passwordPlaceholder' => [
440 'type' => 'string',
441 'default' => 'Password'
442 ],
443 'submitButtonText' => [
444 'type' => 'string',
445 'default' => 'Unlock'
446 ],
447 'submitUnlockingText' => [
448 'type' => 'string',
449 'default' => 'Unlocking'
450 ],
451 'lockErrorMessage' => [
452 'type' => 'string',
453 'default' => 'Oops, that wasn\'t the right password. Try again.'
454 ],
455 'enableFooterMessage' => [
456 'type' => 'boolean',
457 'default' => false
458 ],
459 'footerMessage' => [
460 'type' => 'string',
461 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
462 ],
463 'contentPassword' => [
464 'type' => 'string',
465 'default' => ''
466 ],
467 'contentShare' => [
468 'type' => 'boolean',
469 'default' => false
470 ],
471 'sharePosition' => [
472 'type' => 'string',
473 'default' => 'right'
474 ],
475 'presentation' => [
476 'type' => "boolean",
477 'default' => true,
478 ],
479
480 'position' => [
481 'type' => "string",
482 'default' => 'top',
483 ],
484
485 'print' => [
486 'type' => "boolean",
487 'default' => true,
488 ],
489
490 'download' => [
491 'type' => "boolean",
492 'default' => true,
493 ],
494 'open' => [
495 'type' => "boolean",
496 'default' => true,
497 ],
498 'copy_text' => [
499 'type' => "boolean",
500 'default' => true,
501 ],
502 'add_text' => [
503 'type' => "boolean",
504 'default' => true,
505 ],
506 'draw' => [
507 'type' => "boolean",
508 'default' => true,
509 ],
510 'toolbar' => [
511 'type' => "boolean",
512 'default' => true,
513 ],
514 'doc_details' => [
515 'type' => "boolean",
516 'default' => true,
517 ],
518 'doc_rotation' => [
519 'type' => "boolean",
520 'default' => true,
521 ],
522 'unitoption' => [
523 'type' => "string",
524 'default' => 'px',
525 ],
526 ),
527 'render_callback' => 'embedpress_pdf_render_block',
528 ]);
529 } elseif ('embedpress-calendar' === $blocks_to_register) {
530 register_block_type('embedpress/embedpress-calendar', [
531 'render_callback' => 'embedpress_calendar_render_block',
532 ]);
533 } else {
534 register_block_type('embedpress/' . $blocks_to_register);
535 }
536 } else {
537
538 if (WP_Block_Type_Registry::get_instance()->is_registered('embedpress/' . $blocks_to_register)) {
539 unregister_block_type('embedpress/' . $blocks_to_register);
540 }
541 }
542 }
543
544 endif;
545 }
546
547 add_action('init', 'embedpress_gutenberg_register_all_block');
548
549 function getParamData($attributes)
550 {
551
552 $urlParamData = array(
553 'themeMode' => !empty($attributes['themeMode']) ? $attributes['themeMode'] : 'default',
554 'toolbar' => !empty($attributes['toolbar']) ? 'true' : 'false',
555 'position' => $attributes['position'],
556 'presentation' => !empty($attributes['presentation']) ? 'true' : 'false',
557 'download' => !empty($attributes['download']) ? 'true' : 'false',
558 'copy_text' => !empty($attributes['copy_text']) ? 'true' : 'false',
559 'add_text' => !empty($attributes['add_text']) ? 'true' : 'false',
560 'draw' => !empty($attributes['draw']) ? 'true' : 'false',
561 'doc_rotation' => !empty($attributes['doc_rotation']) ? 'true' : 'false',
562 'doc_details' => !empty($attributes['doc_details']) ? 'true' : 'false',
563 );
564
565 if($urlParamData['themeMode'] == 'custom') {
566 $urlParamData['customColor'] = !empty($attributes['customColor']) ? $attributes['customColor'] : '#403A81';
567 }
568
569 return "#key=" . base64_encode(utf8_encode(http_build_query($urlParamData)));
570 }
571
572 function embedpress_pdf_render_block($attributes)
573 {
574
575
576 if (!empty($attributes['href'])) {
577 $renderer = Helper::get_pdf_renderer();
578 $pdf_url = $attributes['href'];
579 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-pdf-' . rand(100, 10000);
580 $client_id = md5($id);
581
582 $hash_pass = hash('sha256', wp_salt(32) . md5(isset($attributes['contentPassword']) ? $attributes['contentPassword'] : ''));
583
584 $unitoption = !empty($attributes['unitoption']) ? $attributes['unitoption'] : 'px';
585 $width = !empty($attributes['width']) ? $attributes['width'] . $unitoption : '600px';
586
587 if($unitoption == '%'){
588 $width_class = ' ep-percentage-width';
589 }
590 else{
591 $width_class = 'ep-fixed-width';
592 }
593 $content_share_class = '';
594 $share_position_class = '';
595 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
596
597 if(!empty($attributes['contentShare'])) {
598 $content_share_class = 'ep-content-share-enabled';
599 $share_position_class = 'ep-share-position-'.$share_position;
600 }
601
602 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
603
604 $content_protection_class = 'ep-content-protection-enabled';
605 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || $hash_pass === $password_correct) {
606 $content_protection_class = 'ep-content-protection-disabled';
607 }
608
609
610
611 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
612 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
613
614 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
615 if (isset($attributes['powered_by'])) {
616 $powered_by = $attributes['powered_by'];
617 }
618
619 $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($attributes['href']) . getParamData($attributes);
620
621 $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): '';
622
623 $aligns = [
624 'left' => 'ep-alignleft',
625 'right' => 'ep-alignright',
626 'center' => 'ep-aligncenter',
627 'wide' => 'ep-alignwide',
628 'full' => 'ep-alignfull'
629 ];
630 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
631 $dimension = "width:$width;height:$height";
632 ob_start();
633 ?>
634
635
636 <?php
637
638 $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> ';
639
640
641 if ($powered_by) {
642 $embed_code .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
643 }
644
645
646 $url = !empty($attributes['href']) ? $attributes['href'] : '';
647 ?>
648
649 <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); ?> ">
650 <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); ?>">
651
652 <?php
653 do_action('embedpress_pdf_gutenberg_after_embed', $client_id, 'pdf', $attributes, $pdf_url);
654 $embed = $embed_code;
655 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
656
657 $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : '';
658
659 echo '<div class="ep-embed-content-wraper">';
660 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
661 $embed .= $embed_code;
662 $embed.= '</div>';
663
664 if(!empty($attributes['contentShare'])) {
665 $content_id = $attributes['id'];
666 $embed .= Helper::embed_content_share($content_id, $attributes);
667 }
668 echo $embed;
669 echo '</div>';
670 } else {
671 if(!empty($attributes['contentShare'])) {
672 $content_id = $attributes['clientId'];
673 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
674 $embed .= $embed_code;
675 $embed.= '</div>';
676 $embed .= Helper::embed_content_share($content_id, $attributes);
677 }
678 echo '<div class="ep-embed-content-wraper">';
679 Helper::display_password_form($client_id, $embed, $pass_hash_key, $attributes);
680 echo '</div>';
681 }
682 ?>
683
684 </div>
685 </div>
686 <?php
687 return ob_get_clean();
688 }
689 }
690
691 function embedpress_calendar_render_block($attributes)
692 {
693
694 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-calendar-' . rand(100, 10000);
695 $url = !empty($attributes['url']) ? $attributes['url'] : '';
696 $is_private = isset($attributes['is_public']);
697 $client_id = md5($id);
698 $width = !empty($attributes['width']) ? $attributes['width'] . 'px' : '600px';
699 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
700 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
701 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
702 if (isset($attributes['powered_by'])) {
703 $powered_by = $attributes['powered_by'];
704 }
705
706 $aligns = [
707 'left' => 'alignleft',
708 'right' => 'alignright',
709 'wide' => 'alignwide',
710 'full' => 'alignfull'
711 ];
712 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
713 $dimension = "width:$width;height:$height";
714 ob_start();
715 ?>
716 <div class="embedpress-calendar-gutenberg embedpress-calendar ose-calendar <?php echo esc_attr($alignment) ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%;">
717
718 <?php
719 if (!empty($url) && !$is_private) {
720 ?>
721 <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>
722 <?php } else {
723 if (is_embedpress_pro_active()) {
724 echo Embedpress_Google_Helper::shortcode();
725 }
726 } ?>
727 <?php do_action('embedpress_calendar_gutenberg_after_embed', $client_id, 'calendar', $attributes); ?>
728
729 <?php
730 if ($powered_by) {
731 printf('<p class="embedpress-el-powered" style="width:' . esc_attr($width) . '" >%s</p>', __('Powered By EmbedPress', 'embedpress'));
732 } ?>
733
734 </div>
735 <?php
736 return ob_get_clean();
737 }