PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.7.3
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.7.3
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 / EmbedPress / Elementor / Widgets / Embedpress_Pdf.php
embedpress / EmbedPress / Elementor / Widgets Last commit date
Embedpress_Calendar.php 3 years ago Embedpress_Document.php 3 years ago Embedpress_Elementor.php 3 years ago Embedpress_Pdf.php 3 years ago
Embedpress_Pdf.php
737 lines
1 <?php
2
3 namespace EmbedPress\Elementor\Widgets;
4
5
6 use \Elementor\Controls_Manager as Controls_Manager;
7 use \Elementor\Modules\DynamicTags\Module as TagsModule;
8 use \Elementor\Widget_Base as Widget_Base;
9 use EmbedPress\Includes\Classes\Helper;
10 use EmbedPress\Includes\Traits\Branding;
11
12
13
14 (defined('ABSPATH')) or die("No direct script access allowed.");
15
16 class Embedpress_Pdf extends Widget_Base
17 {
18
19 use Branding;
20 protected $pro_class = '';
21 protected $pro_text = '';
22 public function get_name()
23 {
24 return 'embedpress_pdf';
25 }
26
27 public function get_title()
28 {
29 return esc_html__('EmbedPress PDF', 'embedpress');
30 }
31
32 public function get_categories()
33 {
34 return ['embedpress'];
35 }
36
37 public function get_custom_help_url()
38 {
39 return 'https://embedpress.com/documentation';
40 }
41
42 public function get_icon()
43 {
44 return 'icon-pdf';
45 }
46
47 /**
48 * Get widget keywords.
49 *
50 * Retrieve the list of keywords the widget belongs to.
51 *
52 * @return array Widget keywords.
53 * @since 2.5.5
54 * @access public
55 *
56 */
57 public function get_keywords()
58 {
59 return ['embedpress', 'pdf', 'doc', 'embedpress-document'];
60 }
61
62 protected function register_controls()
63 {
64 $this->pro_class = is_embedpress_pro_active() ? '' : 'embedpress-pro-control not-active';
65 $this->pro_text = is_embedpress_pro_active() ? '' : '<sup class="embedpress-pro-label" style="color:red">' . __('Pro', 'embedpress') . '</sup>';
66 /**
67 * EmbedPress Content Settings
68 */
69 $this->start_controls_section(
70 'embedpress_content_settings',
71 [
72 'label' => esc_html__('General', 'embedpress'),
73 ]
74 );
75
76 $this->add_control(
77 'embedpress_pdf_type',
78 [
79 'label' => __('Document Type', 'embedpress'),
80 'type' => Controls_Manager::SELECT,
81 'default' => 'file',
82 'options' => [
83 'file' => __('File', 'embedpress'),
84 'url' => __('URL', 'embedpress')
85 ],
86 ]
87 );
88
89 $this->add_control(
90 'embedpress_pdf_Uploader',
91 [
92 'label' => __('Upload File', 'embedpress'),
93 'type' => Controls_Manager::MEDIA,
94 'dynamic' => [
95 'active' => true,
96 'categories' => [
97 TagsModule::MEDIA_CATEGORY,
98 ],
99 ],
100 'media_type' => [
101 'application/pdf',
102 ],
103 'description' => __(
104 'Upload a file or pick one from your media library for embed. Supported File Type: PDF',
105 'embedpress'
106 ),
107 'condition' => [
108 'embedpress_pdf_type' => 'file'
109 ],
110 ]
111 );
112
113 $this->add_control(
114 'embedpress_pdf_file_link',
115 [
116 'label' => __('URL', 'embedpress'),
117 'type' => Controls_Manager::URL,
118 'placeholder' => __('https://your-link.com/file.pdf', 'embedpress'),
119 'show_external' => false,
120 'dynamic' => [
121 'active' => true,
122 ],
123 'default' => [
124 'url' => ''
125 ],
126 'condition' => [
127 'embedpress_pdf_type' => 'url'
128 ],
129 ]
130 );
131
132
133
134
135 $this->add_control(
136 'embedpress_pdf_zoom',
137 [
138 'label' => __('Zoom', 'embedpress'),
139 'type' => Controls_Manager::SELECT,
140 'default' => 'auto',
141 'options' => [
142 'auto' => __('Automatic Zoom', 'embedpress'),
143 'page-actual' => __('Actual Size', 'embedpress'),
144 'page-fit' => __('Page Fit', 'embedpress'),
145 'page-width' => __('Page Width', 'embedpress'),
146 'custom' => __('Custom', 'embedpress'),
147 '50' => __('50%', 'embedpress'),
148 '75' => __('75%', 'embedpress'),
149 '100' => __('100%', 'embedpress'),
150 '125' => __('125%', 'embedpress'),
151 '150' => __('150%', 'embedpress'),
152 '200' => __('200%', 'embedpress'),
153 '300' => __('300%', 'embedpress'),
154 '400' => __('400%', 'embedpress'),
155 ],
156 ]
157 );
158 $this->add_control(
159 'embedpress_pdf_zoom_custom',
160 [
161 'label' => __('Custom Zoom', 'embedpress'),
162 'type' => Controls_Manager::NUMBER,
163 'condition' => [
164 'embedpress_pdf_zoom' => 'custom'
165 ],
166 ]
167 );
168 $this->add_responsive_control(
169 'embedpress_elementor_document_width',
170 [
171 'type' => \Elementor\Controls_Manager::SLIDER,
172 'label' => esc_html__( 'Width', 'embedpress' ),
173 'size_units' => [ 'px', '%' ],
174 'range' => [
175 'px' => [
176 'min' => 1,
177 'max' => 1000,
178 ],
179 ],
180 'devices' => [ 'desktop', 'tablet', 'mobile' ],
181 'default' => [
182 'unit' => 'px',
183 'size' => 600,
184 ],
185 'desktop_default' => [
186 'unit' => 'px',
187 'size' => 600,
188 ],
189 'tablet_default' => [
190 'size' => 400,
191 'unit' => 'px',
192 ],
193 'mobile_default' => [
194 'size' => 300,
195 'unit' => 'px',
196 ],
197 'selectors' => [
198 '{{WRAPPER}} .embedpress-document-embed iframe' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%',
199 // '{{WRAPPER}} .embedpress-document-embed' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%',
200 // '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
201 ],
202 'render_type' => 'template',
203 ]
204 );
205 $this->add_responsive_control(
206 'embedpress_elementor_document_height',
207 [
208 'type' => \Elementor\Controls_Manager::SLIDER,
209 'label' => esc_html__( 'Height', 'embedpress' ),
210 'range' => [
211 'px' => [
212 'min' => 1,
213 'max' => 1000,
214 ],
215 ],
216 'devices' => [ 'desktop', 'tablet', 'mobile' ],
217 'default' => [
218 'unit' => 'px',
219 'size' => 600,
220 ],
221 'desktop_default' => [
222 'unit' => 'px',
223 'size' => 600,
224 ],
225 'tablet_default' => [
226 'size' => 400,
227 'unit' => 'px',
228 ],
229 'mobile_default' => [
230 'size' => 300,
231 'unit' => 'px',
232 ],
233 'selectors' => [
234 '{{WRAPPER}} .embedpress-document-embed iframe' => 'height: {{SIZE}}{{UNIT}};',
235 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'height: {{SIZE}}{{UNIT}};',
236 ],
237 'render_type' => 'template',
238 ]
239 );
240
241 $this->add_responsive_control(
242 'embedpress_elementor_document_align',
243 [
244 'label' => __('Alignment', 'embedpress'),
245 'type' => Controls_Manager::CHOOSE,
246 'options' => [
247 'left' => [
248 'title' => __('Left', 'embedpress'),
249 'icon' => 'eicon-text-align-left',
250 ],
251 'center' => [
252 'title' => __('Center', 'embedpress'),
253 'icon' => 'eicon-text-align-center',
254 ],
255 'right' => [
256 'title' => __('Right', 'embedpress'),
257 'icon' => 'eicon-text-align-right',
258 ]
259 ],
260 'prefix_class' => 'elementor%s-align-',
261 'default' => '',
262 ]
263 );
264
265 $this->add_control(
266 'embedpress_pdf_powered_by',
267 [
268 'label' => __('Powered By', 'embedpress'),
269 'type' => Controls_Manager::SWITCHER,
270 'label_on' => __('Show', 'embedpress'),
271 'label_off' => __('Hide', 'embedpress'),
272 'return_value' => 'yes',
273 'default' => apply_filters('embedpress_document_powered_by_control', 'yes'),
274 ]
275 );
276
277 $this->init_branding_controls('document');
278
279 $this->end_controls_section();
280
281
282 /**
283 * EmbedPress PDF Control Settings
284 */
285
286 $this->start_controls_section(
287 'embedpress_pdf_content_settings',
288 [
289 'label' => esc_html__('Controls', 'embedpress'),
290 'condition' => [
291 'embedpress_pdf_type' => 'file'
292 ],
293 ]
294 );
295
296 $this->add_control(
297 'embedpress_theme_mode',
298 [
299 'label' => __('Theme', 'embedpress'),
300 'type' => Controls_Manager::SELECT,
301 'default' => 'default',
302 'options' => [
303 'default' => __('System Default', 'embedpress'),
304 'dark' => __('Dark', 'embedpress'),
305 'light' => __('Light', 'embedpress'),
306 'custom' => __('Custom', 'embedpress')
307 ],
308 ]
309 );
310
311 $this->add_control(
312 'embedpress_pdf_custom_color',
313 [
314 'label' => esc_html__( 'Color', 'embedpress' ),
315 'type' => \Elementor\Controls_Manager::COLOR,
316 'condition' => [
317 'embedpress_theme_mode' => 'custom',
318 ],
319 ]
320 );
321
322 $this->add_control(
323 'pdf_toolbar',
324 [
325 'label' => sprintf(__('Toolbar %s', 'embedpress'), $this->pro_text),
326 'type' => Controls_Manager::SWITCHER,
327 'label_on' => __('Show', 'embedpress'),
328 'label_off' => __('Hide', 'embedpress'),
329 'return_value' => 'yes',
330 'default' => 'yes',
331 'classes' => $this->pro_class,
332 ]
333 );
334
335
336 $this->add_control(
337 'pdf_toolbar_position',
338 [
339 'label' => esc_html__('Toolbar Position', 'embedpress'),
340 'type' => \Elementor\Controls_Manager::CHOOSE,
341 'options' => [
342 'top' => [
343 'title' => esc_html__('Top', 'embedpress'),
344 'icon' => 'eicon-arrow-up',
345 ],
346 'bottom' => [
347 'title' => esc_html__('Bottom', 'embedpress'),
348 'icon' => 'eicon-arrow-down',
349 ],
350 ],
351 'default' => 'top',
352 'toggle' => true,
353 'condition' => [
354 'pdf_toolbar' => 'yes',
355 ],
356 ]
357 );
358
359
360 $this->add_control(
361 'pdf_presentation_mode',
362 [
363 'label' => __('PDF Presentation Mode', 'embedpress'),
364 'type' => Controls_Manager::SWITCHER,
365 'label_on' => __('Show', 'embedpress'),
366 'label_off' => __('Hide', 'embedpress'),
367 'return_value' => 'yes',
368 'default' => 'yes',
369 'condition' => [
370 'pdf_toolbar' => 'yes',
371 ],
372 ]
373 );
374
375 $this->add_control(
376 'pdf_print_download',
377 [
378 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text),
379 'type' => Controls_Manager::SWITCHER,
380 'label_on' => __('Show', 'embedpress'),
381 'label_off' => __('Hide', 'embedpress'),
382 'return_value' => 'yes',
383 'default' => 'yes',
384 'classes' => $this->pro_class,
385 'condition' => [
386 'pdf_toolbar' => 'yes',
387 ],
388 ]
389 );
390 $this->add_control(
391 'pdf_text_copy',
392 [
393 'label' => sprintf(__('Copy Text %s', 'embedpress'), $this->pro_text),
394 'type' => Controls_Manager::SWITCHER,
395 'label_on' => __('Show', 'embedpress'),
396 'label_off' => __('Hide', 'embedpress'),
397 'return_value' => 'yes',
398 'default' => 'yes',
399 'classes' => $this->pro_class,
400 'condition' => [
401 'pdf_toolbar' => 'yes',
402 ],
403 ]
404 );
405
406 $this->add_control(
407 'add_text',
408 [
409 'label' => sprintf(__('Add Text', 'embedpress')),
410 'type' => Controls_Manager::SWITCHER,
411 'label_on' => __('Show', 'embedpress'),
412 'label_off' => __('Hide', 'embedpress'),
413 'return_value' => 'yes',
414 'default' => 'yes',
415 'condition' => [
416 'pdf_toolbar' => 'yes',
417 ],
418 ]
419 );
420 $this->add_control(
421 'draw',
422 [
423 'label' => sprintf(__('Draw %s', 'embedpress'), $this->pro_text),
424 'type' => Controls_Manager::SWITCHER,
425 'label_on' => __('Show', 'embedpress'),
426 'label_off' => __('Hide', 'embedpress'),
427 'return_value' => 'yes',
428 'default' => 'yes',
429 'classes' => $this->pro_class,
430 'condition' => [
431 'pdf_toolbar' => 'yes',
432 ],
433 ]
434 );
435
436 $this->add_control(
437 'pdf_rotate_access',
438 [
439 'label' => __('Rotation', 'embedpress'),
440 'type' => Controls_Manager::SWITCHER,
441 'label_on' => __('Show', 'embedpress'),
442 'label_off' => __('Hide', 'embedpress'),
443 'return_value' => 'yes',
444 'default' => 'yes',
445 'condition' => [
446 'pdf_toolbar' => 'yes',
447 ],
448 ]
449 );
450
451 $this->add_control(
452 'pdf_details',
453 [
454 'label' => __('Properties', 'embedpress'),
455 'type' => Controls_Manager::SWITCHER,
456 'label_on' => __('Show', 'embedpress'),
457 'label_off' => __('Hide', 'embedpress'),
458 'return_value' => 'yes',
459 'default' => 'yes',
460 'condition' => [
461 'pdf_toolbar' => 'yes',
462 ],
463 ]
464 );
465
466 $this->end_controls_section();
467
468 do_action( 'extend_elementor_controls', $this, '_pdf_', $this->pro_text, $this->pro_class);
469
470 if (!is_embedpress_pro_active()) {
471 $this->start_controls_section(
472 'embedpress_pro_section',
473 [
474 'label' => __('Go Premium for More Features', 'embedpress'),
475 ]
476 );
477
478 $this->add_control(
479 'embedpress_pro_cta',
480 [
481 'label' => __('Unlock more possibilities', 'embedpress'),
482 'type' => Controls_Manager::CHOOSE,
483 'options' => [
484 '1' => [
485 'title' => '',
486 'icon' => 'eicon-lock',
487 ],
488 ],
489 'default' => '1',
490 'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank">Pro version</a> for more provider support and customization options.</span>',
491 ]
492 );
493
494 $this->end_controls_section();
495 }
496 }
497
498 private function is_pdf($url)
499 {
500 $arr = explode('.', $url);
501 return end($arr) === 'pdf';
502 }
503
504 public function render()
505 {
506 $settings = $this->get_settings();
507
508 $url = $this->get_file_url();
509
510 if($settings['embedpress_pdf_type'] === 'url') {
511 if(class_exists( 'ACF' ) && function_exists('get_field')){
512 if(!empty($settings['__dynamic__']) && !empty($settings['__dynamic__']['embedpress_pdf_file_link'])){
513 $decode_url = urldecode(($settings['__dynamic__']['embedpress_pdf_file_link']));
514
515 preg_match('/"key":"([^"]+):([^"]+)"/', $decode_url, $matches);
516 if (isset($matches[0])) {
517 if (isset($matches[1])) {
518 $get_acf_key = $matches[1];
519 $url = get_field($get_acf_key);
520
521 if(empty($url)){
522 $pattern = '/"fallback":"([^"]+)"/';
523 preg_match($pattern, $decode_url, $matches);
524
525 if (isset($matches[1])) {
526 $url = $matches[1];
527 }
528 }
529 }
530 }
531 }
532 }
533 }
534
535 $client_id = $this->get_id();
536
537 $this->_render($url, $settings, $client_id);
538 Helper::get_source_data(md5($this->get_id()).'_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data');
539 }
540
541 public function getParamData($settings){
542 $urlParamData = array(
543 'themeMode' => $settings['embedpress_theme_mode'],
544 'toolbar' => !empty($settings['pdf_toolbar']) ? 'true' : 'false',
545 'position' => $settings['pdf_toolbar_position'],
546 'presentation' => !empty($settings['pdf_presentation_mode']) ? 'true' : 'false',
547 'download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'true',
548 'copy_text' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'true',
549 'add_text' => !empty($settings['add_text']) ? 'true' : 'false',
550 'draw' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['draw'] : 'true',
551 'pdf_rotation' => !empty($settings['pdf_rotate_access']) ? 'true' : 'false',
552 'pdf_details' => !empty($settings['pdf_details']) ? 'true' : 'false',
553 );
554
555 if($settings['embedpress_theme_mode'] == 'custom') {
556 $urlParamData['customColor'] = $settings['embedpress_pdf_custom_color'];
557 }
558
559 if($settings['embedpress_pdf_type'] == 'file'){
560 return "#key=" . base64_encode(utf8_encode(http_build_query($urlParamData)));
561 }
562 return '';
563
564 }
565
566 public function _render($url, $settings, $id)
567 {
568 $unitoption = 'emebedpress-unit-px';
569 if($settings['embedpress_elementor_document_width']['unit'] === '%'){
570 $unitoption = 'emebedpress-unit-percent';
571 }
572 $client_id = $id;
573 $id = 'embedpress-pdf-' . $id;
574 $hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_pdf_lock_content_password']));
575
576 $dimension = '';
577
578 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
579
580 if(empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct))){
581 $dimension = "width: {$settings['embedpress_elementor_document_width']['size']}{$settings['embedpress_elementor_document_width']['unit']}!important;height: {$settings['embedpress_elementor_document_height']['size']}px;";
582 }
583
584 $content_protection_class = 'ep-content-protection-enabled';
585 $content_locked_class = 'ep-content-locked';
586 if(empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || $hash_pass === $password_correct) {
587 $content_locked_class = '';
588 $content_protection_class = 'ep-content-protection-disabled';
589 }
590
591 $pass_hash_key = md5($settings['embedpress_pdf_lock_content_password']);
592 $this->add_render_attribute('embedpres-pdf-render', [
593 'class' => ['embedpress-embed-document-pdf', $id],
594 'data-emid' => $id
595 ]);
596 $this->add_render_attribute('embedpress-document', [
597 'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $unitoption, $content_locked_class ],
598 'data-thememode' => $settings['embedpress_theme_mode'],
599 'data-customcolor' => $settings['embedpress_pdf_custom_color'],
600 'data-toolbar' => $settings['pdf_toolbar'],
601 'data-toolbar-position' => $settings['pdf_toolbar_position'],
602 'data-open' => 'no',
603 'data-presentation-mode' => $settings['pdf_presentation_mode'],
604 'data-download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'yes',
605 'data-copy' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'yes',
606 'data-rotate' => $settings['pdf_rotate_access'],
607 'data-details' => $settings['pdf_details'],
608 'data-id' => $id
609 ]);
610
611 $embed_settings = [];
612 $embed_settings['customThumbnail'] = !empty($settings['embedpress_pdf_content_share_custom_thumbnail']['url']) ? $settings['embedpress_pdf_content_share_custom_thumbnail']['url'] : '';
613
614 $embed_settings['customTitle'] = !empty($settings['embedpress_pdf_content_title']) ? $settings['embedpress_pdf_content_title'] : Helper::get_file_title($url);
615
616 $embed_settings['customDescription'] = !empty($settings['embedpress_pdf_content_descripiton']) ? $settings['embedpress_pdf_content_descripiton'] : Helper::get_file_title($url);
617
618 $embed_settings['sharePosition'] = !empty($settings['embedpress_pdf_content_share_position']) ? $settings['embedpress_pdf_content_share_position'] : 'right';
619
620 $embed_settings['lockHeading'] = !empty($settings['embedpress_pdf_lock_content_heading']) ? $settings['embedpress_pdf_lock_content_heading'] : '';
621
622 $embed_settings['lockSubHeading'] = !empty($settings['embedpress_pdf_lock_content_sub_heading']) ? $settings['embedpress_pdf_lock_content_sub_heading'] : '';
623
624 $embed_settings['lockErrorMessage'] = !empty($settings['embedpress_pdf_lock_content_error_message']) ? $settings['embedpress_pdf_lock_content_error_message'] : '';
625
626 $embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_pdf_password_placeholder']) ? $settings['embedpress_pdf_password_placeholder'] : '';
627
628 $embed_settings['submitButtonText'] = !empty($settings['embedpress_pdf_submit_button_text']) ? $settings['embedpress_pdf_submit_button_text'] : '';
629
630 $embed_settings['submitUnlockingText'] = !empty($settings['embedpress_pdf_submit_Unlocking_text']) ? $settings['embedpress_pdf_submit_Unlocking_text'] : '';
631
632 $embed_settings['enableFooterMessage'] = !empty($settings['embedpress_pdf_enable_footer_message']) ? $settings['embedpress_pdf_enable_footer_message'] : '';
633
634 $embed_settings['footerMessage'] = !empty($settings['embedpress_pdf_lock_content_footer_message']) ? $settings['embedpress_pdf_lock_content_footer_message'] : '';
635
636
637 if($settings['embedpress_elementor_document_width']['unit'] === '%'){
638 $width_class = ' ep-percentage-width';
639 }
640 else{
641 $width_class = 'ep-fixed-width';
642 }
643 $content_share_class = '';
644 $share_position_class = '';
645 $share_position = isset($settings['embedpress_pdf_content_share_position']) ? $settings['embedpress_pdf_content_share_position'] : 'right';
646
647 if(!empty($settings['embedpress_pdf_content_share'])) {
648 $content_share_class = 'ep-content-share-enabled';
649 $share_position_class = 'ep-share-position-'.$share_position;
650 }
651
652 ?>
653 <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style=" max-width:100%; display: inline-block">
654
655 <?php
656 do_action('embedpress_pdf_after_embed', $settings, $url, $id, $this);
657
658 if ($url != '') {
659 if ($this->is_pdf($url) && !$this->is_external_url($url)) {
660 $this->add_render_attribute('embedpres-pdf-render', $url);
661 $renderer = Helper::get_pdf_renderer();
662 $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($url).$this->getParamData($settings);
663 if (!empty($settings['embedpress_pdf_zoom'])) {
664 $zoom = $settings['embedpress_pdf_zoom'];
665 if ($zoom == 'custom') {
666 if (!empty($settings['embedpress_pdf_zoom_custom'])) {
667 $zoom = $settings['embedpress_pdf_zoom_custom'];
668 } else {
669 $zoom = null;
670 }
671 }
672 if ($zoom) {
673 $src = $src . "&zoom=$zoom";
674 }
675 }
676
677 $embed_content = '<iframe title="'.esc_attr(Helper::get_file_title($url)).'" class="embedpress-embed-document-pdf '.esc_attr($id).'" style="'.esc_attr($dimension).'; max-width:100%; display: inline-block" src="'.esc_attr($src).'"';
678 $embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').' frameborder="0"></iframe>';
679 if ($settings['embedpress_pdf_powered_by'] === 'yes') {
680 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
681 }
682
683 } else {
684 $embed_content = '<iframe title="'.esc_attr(Helper::get_file_title($url)).'" class="embedpress-embed-document-pdf '.esc_attr($id).'" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="'.esc_attr($dimension).'; max-width:100%;" src="'.esc_url($url).'"';
685 $embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').'></iframe>';
686
687 if ($settings['embedpress_pdf_powered_by'] === 'yes') {
688 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
689 }
690 }
691
692 ?>
693
694
695 <div id="ep-elementor-content-<?php echo esc_attr( $client_id )?>" class="ep-elementor-content <?php if(!empty($settings['embedpress_pdf_content_share'])) : echo esc_attr( 'position-'.$settings['embedpress_pdf_content_share_position'].'-wraper' ); endif; ?> <?php echo esc_attr($width_class.' '.$content_share_class.' '.$share_position_class.' '.$content_protection_class); ?>">
696 <div id="<?php echo esc_attr( $this->get_id() ); ?>" class="ep-embed-content-wraper">
697 <?php
698 $embed = '<div>'.$embed_content.'</div>';
699
700 $content_id = $client_id;
701 if((empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || $settings['embedpress_pdf_lock_content'] == 'no') || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
702 if(!empty($settings['embedpress_pdf_content_share'])){
703 $embed .= Helper::embed_content_share($content_id, $embed_settings);
704 }
705 echo $embed ;
706
707 } else {
708 if(!empty($settings['embedpress_pdf_content_share'])){
709 $embed .= Helper::embed_content_share($content_id, $embed_settings);
710 }
711 Helper::display_password_form($client_id, $embed, $pass_hash_key, $embed_settings);
712 }
713 ?>
714 </div>
715 </div>
716 <?php
717
718 }
719 ?>
720
721 </div>
722
723 <?php
724 }
725
726 private function get_file_url()
727 {
728 $settings = $this->get_settings();
729 return $settings['embedpress_pdf_type'] === 'url' ? $settings['embedpress_pdf_file_link']['url'] : $settings['embedpress_pdf_Uploader']['url'];
730 }
731
732 protected function is_external_url($url)
733 {
734 return strpos($url, get_site_url()) === false;
735 }
736 }
737