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