PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.9
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.9
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
887 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 //Ad attributes
467 'adManager' => [
468 'type' => 'boolean',
469 'default' => false
470 ],
471 'adSource' => [
472 'type' => 'string',
473 'default' => 'video'
474 ],
475 'adContent' => [
476 'type' => 'object',
477 ],
478 'adWidth' => array(
479 'type' => 'string',
480 'default' => '300'
481 ),
482 'adHeight' => array(
483 'type' => 'string',
484 'default' => '200'
485 ),
486 'adXPosition' => array(
487 'type' => 'number',
488 'default' => 25
489 ),
490 'adYPosition' => array(
491 'type' => 'number',
492 'default' => 10
493 ),
494 'adUrl' => [
495 'type' => 'string',
496 'default' => ''
497 ],
498 'adStart' => [
499 'type' => 'string',
500 'default' => '10'
501 ],
502 'adSkipButton' => [
503 'type' => 'boolean',
504 'default' => true
505 ],
506 'adSkipButtonAfter' => [
507 'type' => 'string',
508 'default' => '5'
509 ]
510
511 ),
512 ]);
513 } elseif ('embedpress-pdf' === $blocks_to_register) {
514 register_block_type('embedpress/embedpress-pdf', [
515 'attributes' => array(
516 'powered_by' => [
517 'type' => 'boolean',
518 'default' => true
519 ],
520 'lockContent' => [
521 'type' => 'boolean',
522 'default' => false
523 ],
524 'lockHeading' => [
525 'type' => 'string',
526 'default' => 'Content Locked'
527 ],
528 'lockSubHeading' => [
529 'type' => 'string',
530 'default' => 'Content is locked and requires password to access it.'
531 ],
532 'passwordPlaceholder' => [
533 'type' => 'string',
534 'default' => 'Password'
535 ],
536 'submitButtonText' => [
537 'type' => 'string',
538 'default' => 'Unlock'
539 ],
540 'submitUnlockingText' => [
541 'type' => 'string',
542 'default' => 'Unlocking'
543 ],
544 'lockErrorMessage' => [
545 'type' => 'string',
546 'default' => 'Oops, that wasn\'t the right password. Try again.'
547 ],
548 'enableFooterMessage' => [
549 'type' => 'boolean',
550 'default' => false
551 ],
552 'footerMessage' => [
553 'type' => 'string',
554 'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
555 ],
556 'contentPassword' => [
557 'type' => 'string',
558 'default' => ''
559 ],
560 'contentShare' => [
561 'type' => 'boolean',
562 'default' => false
563 ],
564 'sharePosition' => [
565 'type' => 'string',
566 'default' => 'right'
567 ],
568 'presentation' => [
569 'type' => "boolean",
570 'default' => true,
571 ],
572
573 'position' => [
574 'type' => "string",
575 'default' => 'top',
576 ],
577
578 'print' => [
579 'type' => "boolean",
580 'default' => true,
581 ],
582
583 'download' => [
584 'type' => "boolean",
585 'default' => true,
586 ],
587 'open' => [
588 'type' => "boolean",
589 'default' => true,
590 ],
591 'copy_text' => [
592 'type' => "boolean",
593 'default' => true,
594 ],
595 'add_text' => [
596 'type' => "boolean",
597 'default' => true,
598 ],
599 'draw' => [
600 'type' => "boolean",
601 'default' => true,
602 ],
603 'toolbar' => [
604 'type' => "boolean",
605 'default' => true,
606 ],
607 'doc_details' => [
608 'type' => "boolean",
609 'default' => true,
610 ],
611 'doc_rotation' => [
612 'type' => "boolean",
613 'default' => true,
614 ],
615 'unitoption' => [
616 'type' => "string",
617 'default' => 'px',
618 ],
619
620 //Ad attributes
621 'adManager' => [
622 'type' => 'boolean',
623 'default' => false
624 ],
625 'adSource' => [
626 'type' => 'string',
627 'default' => 'video'
628 ],
629 'adContent' => [
630 'type' => 'object',
631 ],
632 'adWidth' => array(
633 'type' => 'string',
634 'default' => '300'
635 ),
636 'adHeight' => array(
637 'type' => 'string',
638 'default' => '200'
639 ),
640 'adXPosition' => array(
641 'type' => 'number',
642 'default' => 25
643 ),
644 'adYPosition' => array(
645 'type' => 'number',
646 'default' => 20
647 ),
648 'adUrl' => [
649 'type' => 'string',
650 'default' => ''
651 ],
652 'adStart' => [
653 'type' => 'string',
654 'default' => '10'
655 ],
656 'adSkipButton' => [
657 'type' => 'boolean',
658 'default' => true
659 ],
660 'adSkipButtonAfter' => [
661 'type' => 'string',
662 'default' => '5'
663 ]
664 ),
665 'render_callback' => 'embedpress_pdf_render_block',
666 ]);
667 } elseif ('embedpress-calendar' === $blocks_to_register) {
668 register_block_type('embedpress/embedpress-calendar', [
669 'render_callback' => 'embedpress_calendar_render_block',
670 ]);
671 } else {
672 register_block_type('embedpress/' . $blocks_to_register);
673 }
674 } else {
675
676 if (WP_Block_Type_Registry::get_instance()->is_registered('embedpress/' . $blocks_to_register)) {
677 unregister_block_type('embedpress/' . $blocks_to_register);
678 }
679 }
680 }
681
682 endif;
683 }
684
685 add_action('init', 'embedpress_gutenberg_register_all_block');
686
687 function getParamData($attributes)
688 {
689
690 $urlParamData = array(
691 'themeMode' => !empty($attributes['themeMode']) ? $attributes['themeMode'] : 'default',
692 'toolbar' => !empty($attributes['toolbar']) ? 'true' : 'false',
693 'position' => $attributes['position'],
694 'presentation' => !empty($attributes['presentation']) ? 'true' : 'false',
695 'download' => !empty($attributes['download']) ? 'true' : 'false',
696 'copy_text' => !empty($attributes['copy_text']) ? 'true' : 'false',
697 'add_text' => !empty($attributes['add_text']) ? 'true' : 'false',
698 'draw' => !empty($attributes['draw']) ? 'true' : 'false',
699 'doc_rotation' => !empty($attributes['doc_rotation']) ? 'true' : 'false',
700 'doc_details' => !empty($attributes['doc_details']) ? 'true' : 'false',
701 );
702
703 if($urlParamData['themeMode'] == 'custom') {
704 $urlParamData['customColor'] = !empty($attributes['customColor']) ? $attributes['customColor'] : '#403A81';
705 }
706
707 return "#key=" . base64_encode(mb_convert_encoding(http_build_query($urlParamData), 'UTF-8'));
708
709 }
710
711 function embedpress_pdf_render_block($attributes)
712 {
713
714
715 if (!empty($attributes['href'])) {
716 $renderer = Helper::get_pdf_renderer();
717 $pdf_url = $attributes['href'];
718 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-pdf-' . rand(100, 10000);
719 $client_id = md5($id);
720
721
722 $unitoption = !empty($attributes['unitoption']) ? $attributes['unitoption'] : 'px';
723 $width = !empty($attributes['width']) ? $attributes['width'] . $unitoption : '600px';
724
725 if($unitoption == '%'){
726 $width_class = ' ep-percentage-width';
727 }
728 else{
729 $width_class = 'ep-fixed-width';
730 }
731 $content_share_class = '';
732 $share_position_class = '';
733 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
734
735 if(!empty($attributes['contentShare'])) {
736 $content_share_class = 'ep-content-share-enabled';
737 $share_position_class = 'ep-share-position-'.$share_position;
738 }
739
740 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
741 $hash_pass = hash('sha256', wp_salt(32) . md5(isset($attributes['contentPassword']) ? $attributes['contentPassword'] : ''));
742
743
744 $content_protection_class = 'ep-content-protection-enabled';
745 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || $hash_pass === $password_correct) {
746 $content_protection_class = 'ep-content-protection-disabled';
747 }
748
749
750
751 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
752 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
753
754 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
755 if (isset($attributes['powered_by'])) {
756 $powered_by = $attributes['powered_by'];
757 }
758
759 $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($attributes['href']) . getParamData($attributes);
760
761 $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): '';
762
763 $aligns = [
764 'left' => 'ep-alignleft',
765 'right' => 'ep-alignright',
766 'center' => 'ep-aligncenter',
767 'wide' => 'ep-alignwide',
768 'full' => 'ep-alignfull'
769 ];
770 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
771 $dimension = "width:$width;height:$height";
772 ob_start();
773 ?>
774
775
776 <?php
777
778 $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> ';
779
780 if ($powered_by) {
781 $embed_code .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
782 }
783
784 $url = !empty($attributes['href']) ? $attributes['href'] : '';
785
786 $adsAtts = '';
787 if(!empty($attributes['adManager'])) {
788 $ad = base64_encode(json_encode($attributes));
789 $adsAtts = "data-ad-id=$client_id data-ad-attrs=$ad class=ad-mask";
790 }
791 ?>
792
793 <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); ?> ">
794 <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); ?>">
795 <div <?php echo esc_attr( $adsAtts ); ?> >
796 <?php
797 do_action('embedpress_pdf_gutenberg_after_embed', $client_id, 'pdf', $attributes, $pdf_url);
798 $embed = $embed_code;
799 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
800
801 $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : '';
802
803 echo '<div class="ep-embed-content-wraper">';
804 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
805 $embed .= $embed_code;
806 $embed.= '</div>';
807
808 if(!empty($attributes['contentShare'])) {
809 $content_id = $attributes['id'];
810 $embed .= Helper::embed_content_share($content_id, $attributes);
811 }
812 echo $embed;
813 echo '</div>';
814 } else {
815 if(!empty($attributes['contentShare'])) {
816 $content_id = $attributes['clientId'];
817 $embed = '<div class="position-'.esc_attr( $share_position ).'-wraper gutenberg-pdf-wraper">';
818 $embed .= $embed_code;
819 $embed.= '</div>';
820 $embed .= Helper::embed_content_share($content_id, $attributes);
821 }
822 echo '<div class="ep-embed-content-wraper">';
823 Helper::display_password_form($client_id, $embed, $pass_hash_key, $attributes);
824 echo '</div>';
825 }
826 ?>
827
828 <?php
829 if(!empty($attributes['adManager'])) {
830 $embed .= Helper::generateAdTemplate($client_id, $attributes, 'gutenberg');
831 }
832 ?>
833 </div>
834 </div>
835 </div>
836 <?php
837 return ob_get_clean();
838 }
839 }
840
841 function embedpress_calendar_render_block($attributes)
842 {
843
844 $id = !empty($attributes['id']) ? $attributes['id'] : 'embedpress-calendar-' . rand(100, 10000);
845 $url = !empty($attributes['url']) ? $attributes['url'] : '';
846 $is_private = isset($attributes['is_public']);
847 $client_id = md5($id);
848 $width = !empty($attributes['width']) ? $attributes['width'] . 'px' : '600px';
849 $height = !empty($attributes['height']) ? $attributes['height'] . 'px' : '600px';
850 $gen_settings = get_option(EMBEDPRESS_PLG_NAME);
851 $powered_by = isset($gen_settings['embedpress_document_powered_by']) && 'yes' === $gen_settings['embedpress_document_powered_by'];
852 if (isset($attributes['powered_by'])) {
853 $powered_by = $attributes['powered_by'];
854 }
855
856 $aligns = [
857 'left' => 'alignleft',
858 'right' => 'alignright',
859 'wide' => 'alignwide',
860 'full' => 'alignfull'
861 ];
862 $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] : '';
863 $dimension = "width:$width;height:$height";
864 ob_start();
865 ?>
866 <div class="embedpress-calendar-gutenberg embedpress-calendar ose-calendar <?php echo esc_attr($alignment) ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%;">
867
868 <?php
869 if (!empty($url) && !$is_private) {
870 ?>
871 <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>
872 <?php } else {
873 if (is_embedpress_pro_active()) {
874 echo Embedpress_Google_Helper::shortcode();
875 }
876 } ?>
877 <?php do_action('embedpress_calendar_gutenberg_after_embed', $client_id, 'calendar', $attributes); ?>
878
879 <?php
880 if ($powered_by) {
881 printf('<p class="embedpress-el-powered" style="width:' . esc_attr($width) . '" >%s</p>', __('Powered By EmbedPress', 'embedpress'));
882 } ?>
883
884 </div>
885 <?php
886 return ob_get_clean();
887 }