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