PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.8.4
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.8.4
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 2 years ago dist 2 years ago plugin.php 2 years ago
plugin.php
779 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 // Calendly attributes
419 'cEmbedType' => array(
420 'type' => 'string',
421 'default' => 'inline'
422 ),
423 'hideCookieBanner' => array(
424 'type' => 'boolean',
425 'default' => false
426 ),
427 'hideEventTypeDetails' => array(
428 'type' => 'boolean',
429 'default' => false
430 ),
431 'cBackgroundColor' => array(
432 'type' => 'string',
433 'default' => 'ffffff'
434 ),
435 'cTextColor' => array(
436 'type' => 'string',
437 'default' => '1A1A1A'
438 ),
439 'cButtonLinkColor' => array(
440 'type' => 'string',
441 'default' => '0000FF'
442 ),
443 'cPopupButtonText' => array(
444 'type' => 'string',
445 'default' => 'Schedule time with me'
446 ),
447 'cPopupButtonBGColor' => array(
448 'type' => 'string',
449 'default' => '#0000FF'
450 ),
451 'cPopupButtonTextColor' => array(
452 'type' => 'string',
453 'default' => '#FFFFFF'
454 ),
455 'cPopupLinkText' => array(
456 'type' => 'string',
457 'default' => 'Schedule time with me'
458 )
459
460 ),
461 ]);
462 } elseif ('embedpress-pdf' === $blocks_to_register) {
463 register_block_type('embedpress/embedpress-pdf', [
464 'attributes' => array(
465 'powered_by' => [
466 'type' => 'boolean',
467 'default' => true
468 ],
469 'lockContent' => [
470 'type' => 'boolean',
471 'default' => false
472 ],
473 'lockHeading' => [
474 'type' => 'string',
475 'default' => 'Content Locked'
476 ],
477 'lockSubHeading' => [
478 'type' => 'string',
479 'default' => 'Content is locked and requires password to access it.'
480 ],
481 'passwordPlaceholder' => [
482 'type' => 'string',
483 'default' => 'Password'
484 ],
485 'submitButtonText' => [
486 'type' => 'string',
487 'default' => 'Unlock'
488 ],
489 'submitUnlockingText' => [
490 'type' => 'string',
491 'default' => 'Unlocking'
492 ],
493 'lockErrorMessage' => [
494 'type' => 'string',
495 'default' => 'Oops, that wasn\'t the right password. Try again.'
496 ],
497 'enableFooterMessage' => [
498 'type' => 'boolean',
499 'default' => false
500 ],
501 'footerMessage' => [
502 'type' => 'string',
503 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
504 ],
505 'contentPassword' => [
506 'type' => 'string',
507 'default' => ''
508 ],
509 'contentShare' => [
510 'type' => 'boolean',
511 'default' => false
512 ],
513 'sharePosition' => [
514 'type' => 'string',
515 'default' => 'right'
516 ],
517 'presentation' => [
518 'type' => "boolean",
519 'default' => true,
520 ],
521
522 'position' => [
523 'type' => "string",
524 'default' => 'top',
525 ],
526
527 'print' => [
528 'type' => "boolean",
529 'default' => true,
530 ],
531
532 'download' => [
533 'type' => "boolean",
534 'default' => true,
535 ],
536 'open' => [
537 'type' => "boolean",
538 'default' => true,
539 ],
540 'copy_text' => [
541 'type' => "boolean",
542 'default' => true,
543 ],
544 'add_text' => [
545 'type' => "boolean",
546 'default' => true,
547 ],
548 'draw' => [
549 'type' => "boolean",
550 'default' => true,
551 ],
552 'toolbar' => [
553 'type' => "boolean",
554 'default' => true,
555 ],
556 'doc_details' => [
557 'type' => "boolean",
558 'default' => true,
559 ],
560 'doc_rotation' => [
561 'type' => "boolean",
562 'default' => true,
563 ],
564 'unitoption' => [
565 'type' => "string",
566 'default' => 'px',
567 ],
568 ),
569 'render_callback' => 'embedpress_pdf_render_block',
570 ]);
571 } elseif ('embedpress-calendar' === $blocks_to_register) {
572 register_block_type('embedpress/embedpress-calendar', [
573 'render_callback' => 'embedpress_calendar_render_block',
574 ]);
575 } else {
576 register_block_type('embedpress/' . $blocks_to_register);
577 }
578 } else {
579
580 if (WP_Block_Type_Registry::get_instance()->is_registered('embedpress/' . $blocks_to_register)) {
581 unregister_block_type('embedpress/' . $blocks_to_register);
582 }
583 }
584 }
585
586 endif;
587 }
588
589 add_action('init', 'embedpress_gutenberg_register_all_block');
590
591 function getParamData($attributes)
592 {
593
594 $urlParamData = array(
595 'themeMode' => !empty($attributes['themeMode']) ? $attributes['themeMode'] : 'default',
596 'toolbar' => !empty($attributes['toolbar']) ? 'true' : 'false',
597 'position' => $attributes['position'],
598 'presentation' => !empty($attributes['presentation']) ? 'true' : 'false',
599 'download' => !empty($attributes['download']) ? 'true' : 'false',
600 'copy_text' => !empty($attributes['copy_text']) ? 'true' : 'false',
601 'add_text' => !empty($attributes['add_text']) ? 'true' : 'false',
602 'draw' => !empty($attributes['draw']) ? 'true' : 'false',
603 'doc_rotation' => !empty($attributes['doc_rotation']) ? 'true' : 'false',
604 'doc_details' => !empty($attributes['doc_details']) ? 'true' : 'false',
605 );
606
607 if($urlParamData['themeMode'] == 'custom') {
608 $urlParamData['customColor'] = !empty($attributes['customColor']) ? $attributes['customColor'] : '#403A81';
609 }
610
611 return "#key=" . base64_encode(utf8_encode(http_build_query($urlParamData)));
612 }
613
614 function embedpress_pdf_render_block($attributes)
615 {
616
617
618 if (!empty($attributes['href'])) {
619 $renderer = Helper::get_pdf_renderer();
620 $pdf_url = $attributes['href'];
621 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-pdf-' . rand(100, 10000);
622 $client_id = md5($id);
623
624 $hash_pass = hash('sha256', wp_salt(32) . md5(isset($attributes['contentPassword']) ? $attributes['contentPassword'] : ''));
625
626 $unitoption = !empty($attributes['unitoption']) ? $attributes['unitoption'] : 'px';
627 $width = !empty($attributes['width']) ? $attributes['width'] . $unitoption : '600px';
628
629 if($unitoption == '%'){
630 $width_class = ' ep-percentage-width';
631 }
632 else{
633 $width_class = 'ep-fixed-width';
634 }
635 $content_share_class = '';
636 $share_position_class = '';
637 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
638
639 if(!empty($attributes['contentShare'])) {
640 $content_share_class = 'ep-content-share-enabled';
641 $share_position_class = 'ep-share-position-'.$share_position;
642 }
643
644 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
645
646 $content_protection_class = 'ep-content-protection-enabled';
647 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || $hash_pass === $password_correct) {
648 $content_protection_class = 'ep-content-protection-disabled';
649 }
650
651
652
653 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
654 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
655
656 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
657 if (isset($attributes['powered_by'])) {
658 $powered_by = $attributes['powered_by'];
659 }
660
661 $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($attributes['href']) . getParamData($attributes);
662
663 $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): '';
664
665 $aligns = [
666 'left' => 'ep-alignleft',
667 'right' => 'ep-alignright',
668 'center' => 'ep-aligncenter',
669 'wide' => 'ep-alignwide',
670 'full' => 'ep-alignfull'
671 ];
672 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
673 $dimension = "width:$width;height:$height";
674 ob_start();
675 ?>
676
677
678 <?php
679
680 $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> ';
681
682
683 if ($powered_by) {
684 $embed_code .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
685 }
686
687
688 $url = !empty($attributes['href']) ? $attributes['href'] : '';
689 ?>
690
691 <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); ?> ">
692 <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); ?>">
693
694 <?php
695 do_action('embedpress_pdf_gutenberg_after_embed', $client_id, 'pdf', $attributes, $pdf_url);
696 $embed = $embed_code;
697 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
698
699 $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : '';
700
701 echo '<div class="ep-embed-content-wraper">';
702 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
703 $embed .= $embed_code;
704 $embed.= '</div>';
705
706 if(!empty($attributes['contentShare'])) {
707 $content_id = $attributes['id'];
708 $embed .= Helper::embed_content_share($content_id, $attributes);
709 }
710 echo $embed;
711 echo '</div>';
712 } else {
713 if(!empty($attributes['contentShare'])) {
714 $content_id = $attributes['clientId'];
715 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
716 $embed .= $embed_code;
717 $embed.= '</div>';
718 $embed .= Helper::embed_content_share($content_id, $attributes);
719 }
720 echo '<div class="ep-embed-content-wraper">';
721 Helper::display_password_form($client_id, $embed, $pass_hash_key, $attributes);
722 echo '</div>';
723 }
724 ?>
725
726 </div>
727 </div>
728 <?php
729 return ob_get_clean();
730 }
731 }
732
733 function embedpress_calendar_render_block($attributes)
734 {
735
736 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-calendar-' . rand(100, 10000);
737 $url = !empty($attributes['url']) ? $attributes['url'] : '';
738 $is_private = isset($attributes['is_public']);
739 $client_id = md5($id);
740 $width = !empty($attributes['width']) ? $attributes['width'] . 'px' : '600px';
741 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
742 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
743 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
744 if (isset($attributes['powered_by'])) {
745 $powered_by = $attributes['powered_by'];
746 }
747
748 $aligns = [
749 'left' => 'alignleft',
750 'right' => 'alignright',
751 'wide' => 'alignwide',
752 'full' => 'alignfull'
753 ];
754 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
755 $dimension = "width:$width;height:$height";
756 ob_start();
757 ?>
758 <div class="embedpress-calendar-gutenberg embedpress-calendar ose-calendar <?php echo esc_attr($alignment) ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%;">
759
760 <?php
761 if (!empty($url) && !$is_private) {
762 ?>
763 <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>
764 <?php } else {
765 if (is_embedpress_pro_active()) {
766 echo Embedpress_Google_Helper::shortcode();
767 }
768 } ?>
769 <?php do_action('embedpress_calendar_gutenberg_after_embed', $client_id, 'calendar', $attributes); ?>
770
771 <?php
772 if ($powered_by) {
773 printf('<p class="embedpress-el-powered" style="width:' . esc_attr($width) . '" >%s</p>', __('Powered By EmbedPress', 'embedpress'));
774 } ?>
775
776 </div>
777 <?php
778 return ob_get_clean();
779 }