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