PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.9.11
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.9.11
4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Elementor / Widgets / Embedpress_Document.php
embedpress / EmbedPress / Elementor / Widgets Last commit date
Embedpress_Calendar.php 2 years ago Embedpress_Document.php 2 years ago Embedpress_Elementor.php 2 years ago Embedpress_Pdf.php 2 years ago
Embedpress_Document.php
744 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 \Elementor\Plugin;
10 use EmbedPress\Includes\Traits\Branding;
11 use EmbedPress\Includes\Classes\Helper;
12
13 ( defined( 'ABSPATH' ) ) or die( "No direct script access allowed." );
14
15 class Embedpress_Document extends Widget_Base
16 {
17 use Branding;
18 protected $pro_class = '';
19 protected $pro_text = '';
20 public function get_name()
21 {
22 return 'embedpres_document';
23 }
24
25 public function get_title()
26 {
27 return esc_html__( 'EmbedPress Document', 'embedpress' );
28 }
29
30 public function get_categories()
31 {
32 return ['embedpress'];
33 }
34
35 public function get_custom_help_url()
36 {
37 return 'https://embedpress.com/documentation';
38 }
39
40 public function get_icon()
41 {
42 return 'icon-document';
43 }
44
45 /**
46 * Get widget keywords.
47 *
48 * Retrieve the list of keywords the widget belongs to.
49 *
50 * @return array Widget keywords.
51 * @since 2.5.5
52 * @access public
53 *
54 */
55 public function get_keywords()
56 {
57 return ['embedpress', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'embedpress-document'];
58 }
59
60 protected function register_controls()
61 {
62 $this->pro_class = is_embedpress_pro_active() ? '': 'embedpress-pro-control not-active';
63 $this->pro_text = is_embedpress_pro_active() ? '': '<sup class="embedpress-pro-label" style="color:red">'.__('Pro', 'embedpress').'</sup>';
64 /**
65 * EmbedPress Content Settings
66 */
67 $this->start_controls_section(
68 'embedpress_document_content_settings',
69 [
70 'label' => esc_html__( 'General', 'embedpress' ),
71 ]
72 );
73
74 $this->add_control(
75 'embedpress_document_type',
76 [
77 'label' => __( 'Document Type', 'embedpress' ),
78 'type' => Controls_Manager::SELECT,
79 'default' => 'file',
80 'options' => [
81 'file' => __( 'File', 'embedpress' ),
82 'url' => __( 'URL', 'embedpress' )
83 ],
84 ]
85 );
86 $this->add_control(
87 'embedpress_document_Uploader',
88 [
89
90 'label' => __( 'Upload File', 'embedpress' ),
91 'type' => Controls_Manager::MEDIA,
92 'dynamic' => [
93 'active' => true,
94 'categories' => [
95 TagsModule::MEDIA_CATEGORY,
96 ],
97 ],
98 'media_type' => [
99 'application/pdf',
100 'application/msword',
101 'application/vnd.ms-powerpoint',
102 'application/vnd.ms-excel',
103 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
104 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
105 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
106 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' // Added PPSX MIME type
107
108 ],
109 'description' => __( 'Upload a file or pick one from your media library for embed. Supported File Type: PDF, DOC/DOCX, PPT/PPTX, XLS/XLSX etc.',
110 'embedpress' ),
111 'condition' => [
112 'embedpress_document_type' => 'file'
113 ],
114 ]
115 );
116
117 $this->add_control(
118 'embedpress_document_file_link',
119 [
120 'label' => __( 'URL', 'embedpress' ),
121 'type' => Controls_Manager::URL,
122 'placeholder' => __( 'https://your-link.com/file.pdf', 'embedpress' ),
123 'show_external' => false,
124 'dynamic' => [
125 'active' => true,
126 ],
127 'default' => [
128 'url' => ''
129 ],
130 'condition' => [
131 'embedpress_document_type' => 'url'
132 ],
133 ]
134 );
135
136 $this->add_responsive_control(
137 'embedpress_elementor_document_width',
138 [
139 'type' => \Elementor\Controls_Manager::SLIDER,
140 'label' => esc_html__( 'Width', 'embedpress' ),
141 'range' => [
142 'px' => [
143 'min' => 1,
144 'max' => 1000,
145 ],
146 ],
147 'devices' => [ 'desktop', 'tablet', 'mobile' ],
148 'default' => [
149 'unit' => 'px',
150 'size' => 600,
151 ],
152 'desktop_default' => [
153 'unit' => 'px',
154 'size' => 600,
155 ],
156 'tablet_default' => [
157 'size' => 400,
158 'unit' => 'px',
159 ],
160 'mobile_default' => [
161 'size' => 300,
162 'unit' => 'px',
163 ],
164 'selectors' => [
165 '{{WRAPPER}} .embedpress-document-embed iframe' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
166 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
167 '{{WRAPPER}} .embedpress-document-embed' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
168 ],
169 ]
170 );
171 $this->add_responsive_control(
172 'embedpress_elementor_document_height',
173 [
174 'type' => \Elementor\Controls_Manager::SLIDER,
175 'label' => esc_html__( 'Height', 'embedpress' ),
176 'range' => [
177 'px' => [
178 'min' => 1,
179 'max' => 1000,
180 ],
181 ],
182 'devices' => [ 'desktop', 'tablet', 'mobile' ],
183 'default' => [
184 'unit' => 'px',
185 'size' => 600,
186 ],
187 'desktop_default' => [
188 'unit' => 'px',
189 'size' => 600,
190 ],
191 'tablet_default' => [
192 'size' => 400,
193 'unit' => 'px',
194 ],
195 'mobile_default' => [
196 'size' => 300,
197 'unit' => 'px',
198 ],
199 'selectors' => [
200 '{{WRAPPER}} .embedpress-document-embed iframe' => 'height: {{SIZE}}{{UNIT}}!important;',
201 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'height: {{SIZE}}{{UNIT}};',
202 '{{WRAPPER}} .embedpress-document-embed ' => 'max-height: {{SIZE}}{{UNIT}};',
203 ],
204 ]
205 );
206
207 $this->add_responsive_control(
208 'embedpress_elementor_document_align',
209 [
210 'label' => __( 'Alignment', 'embedpress' ),
211 'type' => Controls_Manager::CHOOSE,
212 'options' => [
213 'left' => [
214 'title' => __( 'Left', 'embedpress' ),
215 'icon' => 'eicon-text-align-left',
216 ],
217 'center' => [
218 'title' => __( 'Center', 'embedpress' ),
219 'icon' => 'eicon-text-align-center',
220 ],
221 'right' => [
222 'title' => __( 'Right', 'embedpress' ),
223 'icon' => 'eicon-text-align-right',
224 ]
225 ],
226 'prefix_class' => 'elementor%s-align-',
227 'default' => '',
228 ]
229 );
230
231 $this->add_control(
232 'embedpress_document_powered_by',
233 [
234 'label' => __( 'Powered By', 'embedpress' ),
235 'type' => Controls_Manager::SWITCHER,
236 'label_on' => __( 'Show', 'embedpress' ),
237 'label_off' => __( 'Hide', 'embedpress' ),
238 'return_value' => 'yes',
239 'default' => apply_filters( 'embedpress_document_powered_by_control', 'yes' ),
240 ]
241 );
242
243 $this->init_branding_controls( 'document');
244
245 $this->end_controls_section();
246
247 /**
248 * EmbedPress Document control settings
249 */
250
251 $this->start_controls_section(
252 'embedpress_doc_content_settings',
253 [
254 'label' => esc_html__('Controls', 'embedpress'),
255 ]
256 );
257
258 $this->add_control(
259 'important_note',
260 [
261 'type' => \Elementor\Controls_Manager::RAW_HTML,
262 'raw' => esc_html__( 'Download feature is available when link has the document extension at the end.', 'embedpress' ),
263 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
264 'condition' => [
265 'embedpress_document_type' => 'url',
266 ],
267 ]
268 );
269
270 $this->add_control(
271 'important_note_2',
272 [
273 'type' => \Elementor\Controls_Manager::RAW_HTML,
274 'raw' => esc_html__( 'Toolbar and additional feature options become accessible upon selecting the Custom Viewer mode.', 'embedpress' ),
275 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
276 'condition' => [
277 'embedpress_document_type' => 'file',
278 'embedpress_document_viewer' => 'office',
279 ],
280 ]
281 );
282
283
284 $this->add_control(
285 'embedpress_document_viewer',
286 [
287 'label' => __('Viewer', 'embedpress'),
288 'type' => Controls_Manager::SELECT,
289 'default' => 'custom',
290 'options' => [
291 'custom' => __('Custom', 'embedpress'),
292 'office' => __('MS Office', 'embedpress'),
293 ],
294 ]
295 );
296
297 $this->add_control(
298 'embedpress_theme_mode',
299 [
300 'label' => __('Theme', 'embedpress'),
301 'type' => Controls_Manager::SELECT,
302 'default' => 'default',
303 'options' => [
304 'default' => __('System Default', 'embedpress'),
305 'dark' => __('Dark', 'embedpress'),
306 'light' => __('Light', 'embedpress'),
307 'custom' => __('Custom', 'embedpress')
308 ],
309 'condition' => [
310 'embedpress_document_viewer' => 'custom',
311 ],
312
313 ]
314 );
315
316 $this->add_control(
317 'embedpress_doc_custom_color',
318 [
319 'label' => esc_html__( 'Color', 'embedpress' ),
320 'type' => \Elementor\Controls_Manager::COLOR,
321 'condition' => [
322 'embedpress_theme_mode' => 'custom',
323 'embedpress_document_viewer' => 'custom',
324 ],
325 ]
326 );
327
328 $this->add_control(
329 'doc_toolbar',
330 [
331 'label' => sprintf(__('Toolbar %s', 'embedpress'), $this->pro_text),
332 'type' => Controls_Manager::SWITCHER,
333 'label_on' => __('Show', 'embedpress'),
334 'label_off' => __('Hide', 'embedpress'),
335 'return_value' => 'yes',
336 'default' => 'yes',
337 'classes' => $this->pro_class,
338 'condition' => [
339 'embedpress_document_viewer' => 'custom',
340 ],
341 ]
342 );
343
344
345 $this->add_control(
346 'doc_fullscreen_mode',
347 [
348 'label' => __('Fullscreen', 'embedpress'),
349 'type' => Controls_Manager::SWITCHER,
350 'label_on' => __('Show', 'embedpress'),
351 'label_off' => __('Hide', 'embedpress'),
352 'return_value' => 'yes',
353 'default' => 'yes',
354 'condition' => [
355 'doc_toolbar' => 'yes',
356 'embedpress_document_viewer' => 'custom',
357 ],
358 ]
359 );
360
361 $this->add_control(
362 'doc_print_download',
363 [
364 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text),
365 'type' => Controls_Manager::SWITCHER,
366 'label_on' => __('Show', 'embedpress'),
367 'label_off' => __('Hide', 'embedpress'),
368 'return_value' => 'yes',
369 'default' => 'yes',
370 'classes' => $this->pro_class,
371 'condition' => [
372 'doc_toolbar' => 'yes',
373 'embedpress_document_viewer' => 'custom',
374 ],
375 ]
376 );
377
378
379 $this->add_control(
380 'doc_draw',
381 [
382 'label' => __('Draw', 'embedpress'),
383 'type' => Controls_Manager::SWITCHER,
384 'label_on' => __('Show', 'embedpress'),
385 'label_off' => __('Hide', 'embedpress'),
386 'return_value' => 'yes',
387 'default' => 'yes',
388 'condition' => [
389 'doc_toolbar' => 'yes',
390 'embedpress_document_viewer' => 'custom',
391 ],
392 ]
393 );
394
395
396 $this->end_controls_section();
397
398 do_action( 'extend_elementor_controls', $this, '_doc_', $this->pro_text, $this->pro_class);
399
400 if (! is_embedpress_pro_active()) {
401 $this->start_controls_section(
402 'embedpress_pro_section',
403 [
404 'label' => __('Go Premium for More Features', 'embedpress'),
405 ]
406 );
407
408 $this->add_control(
409 'embedpress_pro_cta',
410 [
411 'label' => __('Unlock more possibilities', 'embedpress'),
412 'type' => Controls_Manager::CHOOSE,
413 'options' => [
414 '1' => [
415 'title' => '',
416 'icon' => 'eicon-lock',
417 ],
418 ],
419 'default' => '1',
420 '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>',
421 ]
422 );
423
424 $this->end_controls_section();
425 }
426 }
427
428 private function is_pdf( $url )
429 {
430 $arr = explode( '.', $url );
431 return end( $arr ) === 'pdf';
432 }
433
434 protected function render()
435 {
436 $settings = $this->get_settings();
437
438 $client_id = esc_attr($this->get_id());
439 $pass_hash_key = md5($settings['embedpress_doc_lock_content_password']);
440 $url = esc_url($this->get_file_url());
441 $id = 'embedpress-pdf-' . $this->get_id();
442
443 if ($settings['embedpress_document_type'] === 'url') {
444 if (class_exists('ACF') && function_exists('get_field')) {
445 if (!empty($settings['__dynamic__']) && !empty($settings['__dynamic__']['embedpress_document_file_link'])) {
446 $decode_url = urldecode(($settings['__dynamic__']['embedpress_document_file_link']));
447 preg_match('/"key":"([^"]+):([^"]+)"/', $decode_url, $matches);
448 if (isset($matches[0])) {
449 if (isset($matches[1])) {
450 $get_acf_key = $matches[1];
451 $url = esc_url(get_field($get_acf_key));
452
453 if (empty($url)) {
454 $pattern = '/"fallback":"([^"]+)"/';
455 preg_match($pattern, $decode_url, $matches);
456
457 if (isset($matches[1])) {
458 $url = esc_url($matches[1]);
459 }
460 }
461 }
462 }
463 }
464 }
465 }
466 $hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_doc_lock_content_password']));
467
468 $dimension = '';
469 if (empty($settings['embedpress_doc_lock_content']) && empty($settings['embedpress_doc_lock_content_password'])) {
470 $dimension = "width: " . esc_attr($settings['embedpress_elementor_document_width']['size']) . "px; height: " . esc_attr($settings['embedpress_elementor_document_height']['size']) . "px";
471 }
472
473 $content_locked_class = '';
474 if (!empty($settings['embedpress_doc_lock_content']) && !empty($settings['embedpress_doc_lock_content_password'])) {
475 $content_locked_class = 'ep-content-locked';
476 }
477
478 $this->add_render_attribute('embedpres-pdf-render', [
479 'class' => ['embedpress-embed-document-pdf', $id],
480 'data-emid' => $id
481 ]);
482
483 Helper::get_source_data(md5($this->get_id()) . '_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data');
484
485 $this->add_render_attribute('embedpress-document', [
486 'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $content_locked_class]
487 ]);
488
489 $embed_settings = [];
490 $embed_settings['customThumbnail'] = !empty($settings['embedpress_doc_content_share_custom_thumbnail']['url']) ? esc_url($settings['embedpress_doc_content_share_custom_thumbnail']['url']) : '';
491
492 $embed_settings['customTitle'] = !empty($settings['embedpress_doc_content_title']) ? esc_html($settings['embedpress_doc_content_title']) : esc_html(Helper::get_file_title($url));
493
494 $embed_settings['customDescription'] = !empty($settings['embedpress_doc_content_descripiton']) ? esc_html($settings['embedpress_doc_content_descripiton']) : esc_html(Helper::get_file_title($url));
495
496 $embed_settings['sharePosition'] = !empty($settings['embedpress_doc_content_share_position']) ? esc_attr($settings['embedpress_doc_content_share_position']) : 'right';
497
498 $embed_settings['lockHeading'] = !empty($settings['embedpress_doc_lock_content_heading']) ? esc_html($settings['embedpress_doc_lock_content_heading']) : '';
499
500 $embed_settings['lockSubHeading'] = !empty($settings['embedpress_doc_lock_content_sub_heading']) ? esc_html($settings['embedpress_doc_lock_content_sub_heading']) : '';
501
502 $embed_settings['lockErrorMessage'] = !empty($settings['embedpress_doc_lock_content_error_message']) ? esc_html($settings['embedpress_doc_lock_content_error_message']) : '';
503
504 $embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_doc_password_placeholder']) ? esc_attr($settings['embedpress_doc_password_placeholder']) : '';
505
506 $embed_settings['submitButtonText'] = !empty($settings['embedpress_doc_submit_button_text']) ? esc_html($settings['embedpress_doc_submit_button_text']) : '';
507
508 $embed_settings['submitUnlockingText'] = !empty($settings['embedpress_doc_submit_Unlocking_text']) ? esc_html($settings['embedpress_doc_submit_Unlocking_text']) : '';
509
510 $embed_settings['enableFooterMessage'] = !empty($settings['embedpress_doc_enable_footer_message']) ? esc_attr($settings['embedpress_doc_enable_footer_message']) : '';
511
512 $embed_settings['footerMessage'] = !empty($settings['embedpress_doc_lock_content_footer_message']) ? esc_html($settings['embedpress_doc_lock_content_footer_message']) : '';
513
514 $content_share_class = '';
515 $share_position_class = '';
516 $share_position = isset($settings['embedpress_doc_content_share_position']) ? $settings['embedpress_doc_content_share_position'] : 'right';
517
518 if (!empty($settings['embedpress_doc_content_share'])) {
519 $content_share_class = 'ep-content-share-enabled';
520 $share_position_class = 'ep-share-position-' . $share_position;
521 }
522
523 $password_correct = isset($_COOKIE['password_correct_' . $client_id]) ? $_COOKIE['password_correct_' . $client_id] : '';
524
525 $content_protection_class = 'ep-content-protection-enabled';
526 if (empty($settings['embedpress_doc_lock_content']) || empty($settings['embedpress_doc_lock_content_password']) || $hash_pass === $password_correct) {
527 $content_protection_class = 'ep-content-protection-disabled';
528 }
529
530 $adsAtts = '';
531
532 if (!empty($settings['adManager'])) {
533 $ad = base64_encode(json_encode($settings));
534 $adsAtts = "data-ad-id=$client_id data-ad-attrs=$ad class=ad-mask";
535 }
536 ?>
537
538 <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block">
539
540 <?php
541 do_action('embedpress_document_after_embed', $settings, $url, $id, $this);
542
543 if ($url != '') {
544 $url = esc_url($url);
545
546 if ($this->is_pdf($url)) {
547 $this->add_render_attribute('embedpres-pdf-render', 'data-emsrc', esc_url($url));
548 $embed_content = '<div ' . $this->get_render_attribute_string('embedpres-pdf-render') . '>';
549
550 $embed_content .= '<iframe title="' . esc_attr(Helper::get_file_title($url)) . '" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="' . esc_attr($dimension) . '; max-width:100%;" src="' . esc_url($url) . '"></iframe>';
551
552 if ($settings['embedpress_document_powered_by'] === 'yes') {
553 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
554 }
555 $embed_content .= '</div>';
556
557 if (Plugin::$instance->editor->is_edit_mode()) {
558 $embed_content .= $this->render_editor_script($id, $url);
559 }
560 } else {
561 if (Helper::is_file_url($url)) {
562 $view_link = '//view.officeapps.live.com/op/embed.aspx?src=' . urlencode($url) . '&embedded=true';
563 } else {
564 $view_link = 'https://drive.google.com/viewerng/viewer?url=' . urlencode($url) . '&embedded=true&chrome=false';
565 }
566
567
568 if($settings['embedpress_document_viewer'] === 'custom')
569 {
570 if (Helper::is_file_url($url)) {
571 $view_link = '//view.officeapps.live.com/op/embed.aspx?src=' . urlencode($url) . '&embedded=true';
572 } else {
573 $view_link = 'https://drive.google.com/viewerng/viewer?url=' . urlencode($url) . '&embedded=true&chrome=false';
574 }
575 }
576 elseif($settings['embedpress_document_viewer'] === 'office')
577 {
578 $view_link = '//view.officeapps.live.com/op/embed.aspx?src=' . urlencode($url) . '&embedded=true';
579 }
580
581
582 $hostname = parse_url($url, PHP_URL_HOST);
583 $domain = implode(".", array_slice(explode(".", $hostname), -2));
584
585 if ($domain == "google.com") {
586 $view_link = $url . '?embedded=true';
587 if (strpos($view_link, '/presentation/')) {
588 $view_link = Helper::get_google_presentation_url($url);
589 }
590 }
591
592 $embed_content = '<div ' . $this->get_render_attribute_string('embedpres-pdf-render') . '>';
593
594 $is_powered_by = '';
595 if ($settings['embedpress_document_powered_by'] === 'yes') {
596 $is_powered_by = 'ep-powered-by-enabled';
597 }
598
599 $is_download_enabled = ' enabled-file-download';
600 if ($settings['doc_print_download'] !== 'yes') {
601 $is_download_enabled = '';
602 }
603
604 $file_extenstion = 'link';
605 if (!empty(Helper::is_file_url($url))) {
606 $file_extenstion = Helper::get_extension_from_file_url($url);
607 }
608
609 $is_masked = '';
610
611 if($settings['embedpress_document_viewer'] === 'custom')
612 {
613 $is_masked = 'ep-file-download-option-masked ';
614 }
615
616 $is_custom_theme = '';
617 if ($settings['embedpress_theme_mode'] == 'custom') {
618 $is_custom_theme = 'data-custom-color=' . esc_attr($settings['embedpress_doc_custom_color']) . '';
619 }
620
621 $embed_content .= '<div class="'.esc_attr( $is_masked ).'ep-file-' . esc_attr($file_extenstion) . ' ' . $is_powered_by . '' . $is_download_enabled . '" data-theme-mode="' . esc_attr($settings['embedpress_theme_mode']) . '"' . esc_attr($is_custom_theme) . ' data-id="' . esc_attr($this->get_id()) . '">';
622
623 $sandbox = '';
624 if ($settings['doc_print_download'] === 'yes') {
625 $sandbox = 'sandbox="allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-same-origin allow-scripts allow-top-navigation allow-top-navigation-by-user-activation"';
626 }
627
628 $embed_content .= '<iframe title="' . esc_attr(Helper::get_file_title($url)) . '" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="' . esc_attr($dimension) . '; max-width:100%;" src="' . esc_url($view_link) . '" ' . $sandbox . '>
629 </iframe>';
630
631 if ($settings['embedpress_document_viewer'] === 'custom' && $settings['doc_print_download'] === 'yes' && (Helper::get_extension_from_file_url($url) === 'pptx' || Helper::get_extension_from_file_url($url) === 'ppt' || Helper::get_extension_from_file_url($url) === 'xls' || Helper::get_extension_from_file_url($url) === 'xlsx')) {
632 $embed_content .= '<div class="embed-download-disabled"></div>';
633 }
634
635 if ($settings['doc_draw'] === 'yes') {
636 $embed_content .= '<canvas class="ep-doc-canvas" width="' . esc_attr($settings['embedpress_elementor_document_width']['size']) . '" height="' . esc_attr($settings['embedpress_elementor_document_height']['size']) . '" ></canvas>';
637 }
638
639 if ($settings['doc_print_download'] === 'yes' && Helper::get_extension_from_file_url($url) !== 'pptx') {
640 $embed_content .= '<div style="width: 40px; height: 40px; position: absolute; opacity: 0; right: 12px; top: 12px;"></div>';
641 }
642
643 if (!empty($settings['doc_toolbar']) && $settings['embedpress_document_viewer'] === 'custom') {
644 $embed_content .= '<div class="ep-external-doc-icons">';
645
646 if (empty(Helper::is_file_url($url))) {
647 $embed_content .= Helper::ep_get_popup_icon();
648 }
649
650 if (!empty(Helper::is_file_url($url))) {
651 if (!empty($settings['doc_print_download'])) {
652 $embed_content .= Helper::ep_get_print_icon();
653 $embed_content .= Helper::ep_get_download_icon();
654 }
655 }
656 if (!empty($settings['doc_draw'])) {
657 $embed_content .= Helper::ep_get_draw_icon();
658 }
659 if (!empty($settings['doc_fullscreen_mode'])) {
660 $embed_content .= Helper::ep_get_fullscreen_icon();
661 $embed_content .= Helper::ep_get_minimize_icon();
662 }
663
664 $embed_content .= '</div>';
665 }
666 $embed_content .= '</div>';
667
668 if ($settings['embedpress_document_powered_by'] === 'yes') {
669 $embed_content .= '<div>';
670 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
671 $embed_content .= '</div>';
672 }
673
674 $embed_content .= '</div>';
675 }
676 }
677
678
679 ?>
680 <div <?php echo esc_attr($adsAtts); ?>>
681
682 <div id="ep-elementor-content-<?php echo esc_attr($client_id) ?>" class="ep-elementor-content <?php if (!empty($settings['embedpress_doc_content_share'])) : echo esc_attr('position-' . $settings['embedpress_doc_content_share_position'] . '-wraper'); endif; ?> <?php echo esc_attr($content_share_class . ' ' . $share_position_class . ' ' . $content_protection_class); ?>">
683 <div id="<?php echo esc_attr($this->get_id()); ?>" class="ep-embed-content-wraper">
684 <?php
685
686 $content_id = $client_id;
687 if ((empty($settings['embedpress_doc_lock_content']) || $settings['embedpress_doc_lock_content'] == 'no' || empty($settings['embedpress_doc_lock_content_password'])) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $_COOKIE['password_correct_' . $client_id]))) {
688
689 if (!empty($settings['embedpress_doc_content_share'])) {
690 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
691 }
692 if (!empty($embed_content)) {
693 echo $embed_content;
694 }
695 } else {
696 if (!empty($settings['embedpress_doc_content_share'])) {
697 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
698 }
699 Helper::display_password_form($client_id, $embed_content, $pass_hash_key, $embed_settings);
700 }
701 ?>
702 </div>
703 </div>
704 <?php
705 if (!empty($settings['adManager'])) {
706 $embed_content .= Helper::generateAdTemplate($client_id, $settings, 'elementor');
707 }
708 ?>
709 </div>
710 </div>
711
712 <?php
713 }
714
715
716 private function get_file_url()
717 {
718 $settings = $this->get_settings();
719 $file_url = $settings['embedpress_document_type'] === 'url' ? esc_url($settings['embedpress_document_file_link']['url']) : esc_url($settings['embedpress_document_Uploader']['url']);
720 return $file_url;
721 }
722
723
724 protected function render_editor_script( $id, $url )
725 {
726 ?>
727 <script>
728 (function ($) {
729 'use strict';
730 $(document).ready(function () {
731 var selector = $('.embedpress-embed-document-pdf');
732 let option = {
733 forceObject: false,
734 };
735 if (selector.length) {
736 PDFObject.embed("<?php echo $url; ?>", "<?php echo '.' . $id; ?>", option);
737 }
738 });
739 })(jQuery);
740 </script>
741 <?php
742 }
743 }
744