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