PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.10
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.10
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
682 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 'embedpress_theme_mode',
272 [
273 'label' => __('Theme', 'embedpress'),
274 'type' => Controls_Manager::SELECT,
275 'default' => 'default',
276 'options' => [
277 'default' => __('System Default', 'embedpress'),
278 'dark' => __('Dark', 'embedpress'),
279 'light' => __('Light', 'embedpress'),
280 'custom' => __('Custom', 'embedpress')
281 ],
282 ]
283 );
284
285 $this->add_control(
286 'embedpress_doc_custom_color',
287 [
288 'label' => esc_html__( 'Color', 'embedpress' ),
289 'type' => \Elementor\Controls_Manager::COLOR,
290 'condition' => [
291 'embedpress_theme_mode' => 'custom',
292 ],
293 ]
294 );
295
296 $this->add_control(
297 'doc_toolbar',
298 [
299 'label' => sprintf(__('Toolbar %s', 'embedpress'), $this->pro_text),
300 'type' => Controls_Manager::SWITCHER,
301 'label_on' => __('Show', 'embedpress'),
302 'label_off' => __('Hide', 'embedpress'),
303 'return_value' => 'yes',
304 'default' => 'yes',
305 'classes' => $this->pro_class,
306 ]
307 );
308
309
310 $this->add_control(
311 'doc_fullscreen_mode',
312 [
313 'label' => __('Fullscreen', 'embedpress'),
314 'type' => Controls_Manager::SWITCHER,
315 'label_on' => __('Show', 'embedpress'),
316 'label_off' => __('Hide', 'embedpress'),
317 'return_value' => 'yes',
318 'default' => 'yes',
319 'condition' => [
320 'doc_toolbar' => 'yes',
321 ],
322 ]
323 );
324
325 $this->add_control(
326 'doc_print_download',
327 [
328 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text),
329 'type' => Controls_Manager::SWITCHER,
330 'label_on' => __('Show', 'embedpress'),
331 'label_off' => __('Hide', 'embedpress'),
332 'return_value' => 'yes',
333 'default' => 'yes',
334 'classes' => $this->pro_class,
335 'condition' => [
336 'doc_toolbar' => 'yes',
337 ],
338 ]
339 );
340
341
342 $this->add_control(
343 'doc_draw',
344 [
345 'label' => __('Draw', 'embedpress'),
346 'type' => Controls_Manager::SWITCHER,
347 'label_on' => __('Show', 'embedpress'),
348 'label_off' => __('Hide', 'embedpress'),
349 'return_value' => 'yes',
350 'default' => 'yes',
351 'condition' => [
352 'doc_toolbar' => 'yes',
353 ],
354 ]
355 );
356
357
358 $this->end_controls_section();
359
360 do_action( 'extend_elementor_controls', $this, '_doc_', $this->pro_text, $this->pro_class);
361
362 if (! is_embedpress_pro_active()) {
363 $this->start_controls_section(
364 'embedpress_pro_section',
365 [
366 'label' => __('Go Premium for More Features', 'embedpress'),
367 ]
368 );
369
370 $this->add_control(
371 'embedpress_pro_cta',
372 [
373 'label' => __('Unlock more possibilities', 'embedpress'),
374 'type' => Controls_Manager::CHOOSE,
375 'options' => [
376 '1' => [
377 'title' => '',
378 'icon' => 'eicon-lock',
379 ],
380 ],
381 'default' => '1',
382 '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>',
383 ]
384 );
385
386 $this->end_controls_section();
387 }
388 }
389
390 private function is_pdf( $url )
391 {
392 $arr = explode( '.', $url );
393 return end( $arr ) === 'pdf';
394 }
395
396 protected function render()
397 {
398 $settings = $this->get_settings();
399
400 $client_id = esc_attr($this->get_id());
401 $pass_hash_key = md5($settings['embedpress_doc_lock_content_password']);
402 $url = esc_url($this->get_file_url());
403 $id = 'embedpress-pdf-' . $this->get_id();
404
405 if ($settings['embedpress_document_type'] === 'url') {
406 if (class_exists('ACF') && function_exists('get_field')) {
407 if (!empty($settings['__dynamic__']) && !empty($settings['__dynamic__']['embedpress_document_file_link'])) {
408 $decode_url = urldecode(($settings['__dynamic__']['embedpress_document_file_link']));
409 preg_match('/"key":"([^"]+):([^"]+)"/', $decode_url, $matches);
410 if (isset($matches[0])) {
411 if (isset($matches[1])) {
412 $get_acf_key = $matches[1];
413 $url = esc_url(get_field($get_acf_key));
414
415 if (empty($url)) {
416 $pattern = '/"fallback":"([^"]+)"/';
417 preg_match($pattern, $decode_url, $matches);
418
419 if (isset($matches[1])) {
420 $url = esc_url($matches[1]);
421 }
422 }
423 }
424 }
425 }
426 }
427 }
428 $hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_doc_lock_content_password']));
429
430 $dimension = '';
431 if (empty($settings['embedpress_doc_lock_content']) && empty($settings['embedpress_doc_lock_content_password'])) {
432 $dimension = "width: " . esc_attr($settings['embedpress_elementor_document_width']['size']) . "px; height: " . esc_attr($settings['embedpress_elementor_document_height']['size']) . "px";
433 }
434
435 $content_locked_class = '';
436 if (!empty($settings['embedpress_doc_lock_content']) && !empty($settings['embedpress_doc_lock_content_password'])) {
437 $content_locked_class = 'ep-content-locked';
438 }
439
440 $this->add_render_attribute('embedpres-pdf-render', [
441 'class' => ['embedpress-embed-document-pdf', $id],
442 'data-emid' => $id
443 ]);
444
445 Helper::get_source_data(md5($this->get_id()) . '_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data');
446
447 $this->add_render_attribute('embedpress-document', [
448 'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $content_locked_class]
449 ]);
450
451 $embed_settings = [];
452 $embed_settings['customThumbnail'] = !empty($settings['embedpress_doc_content_share_custom_thumbnail']['url']) ? esc_url($settings['embedpress_doc_content_share_custom_thumbnail']['url']) : '';
453
454 $embed_settings['customTitle'] = !empty($settings['embedpress_doc_content_title']) ? esc_html($settings['embedpress_doc_content_title']) : esc_html(Helper::get_file_title($url));
455
456 $embed_settings['customDescription'] = !empty($settings['embedpress_doc_content_descripiton']) ? esc_html($settings['embedpress_doc_content_descripiton']) : esc_html(Helper::get_file_title($url));
457
458 $embed_settings['sharePosition'] = !empty($settings['embedpress_doc_content_share_position']) ? esc_attr($settings['embedpress_doc_content_share_position']) : 'right';
459
460 $embed_settings['lockHeading'] = !empty($settings['embedpress_doc_lock_content_heading']) ? esc_html($settings['embedpress_doc_lock_content_heading']) : '';
461
462 $embed_settings['lockSubHeading'] = !empty($settings['embedpress_doc_lock_content_sub_heading']) ? esc_html($settings['embedpress_doc_lock_content_sub_heading']) : '';
463
464 $embed_settings['lockErrorMessage'] = !empty($settings['embedpress_doc_lock_content_error_message']) ? esc_html($settings['embedpress_doc_lock_content_error_message']) : '';
465
466 $embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_doc_password_placeholder']) ? esc_attr($settings['embedpress_doc_password_placeholder']) : '';
467
468 $embed_settings['submitButtonText'] = !empty($settings['embedpress_doc_submit_button_text']) ? esc_html($settings['embedpress_doc_submit_button_text']) : '';
469
470 $embed_settings['submitUnlockingText'] = !empty($settings['embedpress_doc_submit_Unlocking_text']) ? esc_html($settings['embedpress_doc_submit_Unlocking_text']) : '';
471
472 $embed_settings['enableFooterMessage'] = !empty($settings['embedpress_doc_enable_footer_message']) ? esc_attr($settings['embedpress_doc_enable_footer_message']) : '';
473
474 $embed_settings['footerMessage'] = !empty($settings['embedpress_doc_lock_content_footer_message']) ? esc_html($settings['embedpress_doc_lock_content_footer_message']) : '';
475
476 $content_share_class = '';
477 $share_position_class = '';
478 $share_position = isset($settings['embedpress_doc_content_share_position']) ? $settings['embedpress_doc_content_share_position'] : 'right';
479
480 if (!empty($settings['embedpress_doc_content_share'])) {
481 $content_share_class = 'ep-content-share-enabled';
482 $share_position_class = 'ep-share-position-' . $share_position;
483 }
484
485 $password_correct = isset($_COOKIE['password_correct_' . $client_id]) ? $_COOKIE['password_correct_' . $client_id] : '';
486
487 $content_protection_class = 'ep-content-protection-enabled';
488 if (empty($settings['embedpress_doc_lock_content']) || empty($settings['embedpress_doc_lock_content_password']) || $hash_pass === $password_correct) {
489 $content_protection_class = 'ep-content-protection-disabled';
490 }
491
492 $adsAtts = '';
493
494 if (!empty($settings['adManager'])) {
495 $ad = base64_encode(json_encode($settings));
496 $adsAtts = "data-ad-id=$client_id data-ad-attrs=$ad class=ad-mask";
497 }
498 ?>
499
500 <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block">
501
502 <?php
503 do_action('embedpress_document_after_embed', $settings, $url, $id, $this);
504
505 if ($url != '') {
506 if ($this->is_pdf($url)) {
507 $this->add_render_attribute('embedpres-pdf-render', 'data-emsrc', $url);
508 $embed_content = '<div ' . $this->get_render_attribute_string('embedpres-pdf-render') . '>';
509
510 $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>';
511
512 if ($settings['embedpress_document_powered_by'] === 'yes') {
513 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
514 }
515 $embed_content .= '</div>';
516
517 if (Plugin::$instance->editor->is_edit_mode()) {
518 $embed_content .= $this->render_editor_script($id, $url);
519 }
520 } else {
521 if (Helper::is_file_url($url)) {
522 $view_link = '//view.officeapps.live.com/op/embed.aspx?src=' . urlencode($url) . '&embedded=true';
523 } else {
524 $view_link = 'https://drive.google.com/viewerng/viewer?url=' . urlencode($url) . '&embedded=true&chrome=false';
525 }
526
527 $hostname = parse_url($url, PHP_URL_HOST);
528 $domain = implode(".", array_slice(explode(".", $hostname), -2));
529
530 if ($domain == "google.com") {
531 $view_link = $url . '?embedded=true';
532 if (strpos($view_link, '/presentation/')) {
533 $view_link = Helper::get_google_presentation_url($url);
534 }
535 }
536
537 $embed_content = '<div ' . $this->get_render_attribute_string('embedpres-pdf-render') . '>';
538
539 $is_powered_by = '';
540 if ($settings['embedpress_document_powered_by'] === 'yes') {
541 $is_powered_by = 'ep-powered-by-enabled';
542 }
543
544 $is_download_enabled = ' enabled-file-download';
545 if ($settings['doc_print_download'] !== 'yes') {
546 $is_download_enabled = '';
547 }
548
549 $file_extenstion = 'link';
550 if (!empty(Helper::is_file_url($url))) {
551 $file_extenstion = Helper::get_extension_from_file_url($url);
552 }
553
554 $is_custom_theme = '';
555 if ($settings['embedpress_theme_mode'] == 'custom') {
556 $is_custom_theme = 'data-custom-color=' . esc_attr($settings['embedpress_doc_custom_color']) . '';
557 }
558
559 $embed_content .= '<div class="ep-file-download-option-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()) . '">';
560
561 $sandbox = '';
562 if ($settings['doc_print_download'] === 'yes') {
563 $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"';
564 }
565
566 $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 . '>
567 </iframe>';
568
569 if ($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')) {
570 $embed_content .= '<div class="embed-download-disabled"></div>';
571 }
572
573 if ($settings['doc_draw'] === 'yes') {
574 $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>';
575 }
576
577 if ($settings['doc_print_download'] === 'yes' && Helper::get_extension_from_file_url($url) !== 'pptx') {
578 $embed_content .= '<div style="width: 40px; height: 40px; position: absolute; opacity: 0; right: 12px; top: 12px;"></div>';
579 }
580
581 if (!empty($settings['doc_toolbar'])) {
582 $embed_content .= '<div class="ep-external-doc-icons">';
583
584 if (empty(Helper::is_file_url($url))) {
585 $embed_content .= Helper::ep_get_popup_icon();
586 }
587
588 if (!empty(Helper::is_file_url($url))) {
589 if (!empty($settings['doc_print_download'])) {
590 $embed_content .= Helper::ep_get_print_icon();
591 $embed_content .= Helper::ep_get_download_icon();
592 }
593 }
594 if (!empty($settings['doc_draw'])) {
595 $embed_content .= Helper::ep_get_draw_icon();
596 }
597 if (!empty($settings['doc_fullscreen_mode'])) {
598 $embed_content .= Helper::ep_get_fullscreen_icon();
599 $embed_content .= Helper::ep_get_minimize_icon();
600 }
601
602 $embed_content .= '</div>';
603 }
604 $embed_content .= '</div>';
605
606 if ($settings['embedpress_document_powered_by'] === 'yes') {
607 $embed_content .= '<div>';
608 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', esc_html__('Powered By EmbedPress', 'embedpress'));
609 $embed_content .= '</div>';
610 }
611
612 $embed_content .= '</div>';
613 }
614 }
615
616
617 ?>
618 <div <?php echo esc_attr($adsAtts); ?>>
619
620 <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); ?>">
621 <div id="<?php echo esc_attr($this->get_id()); ?>" class="ep-embed-content-wraper">
622 <?php
623
624 $content_id = $client_id;
625 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]))) {
626
627 if (!empty($settings['embedpress_doc_content_share'])) {
628 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
629 }
630 if (!empty($embed_content)) {
631 echo $embed_content;
632 }
633 } else {
634 if (!empty($settings['embedpress_doc_content_share'])) {
635 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
636 }
637 Helper::display_password_form($client_id, $embed_content, $pass_hash_key, $embed_settings);
638 }
639 ?>
640 </div>
641 </div>
642 <?php
643 if (!empty($settings['adManager'])) {
644 $embed_content .= Helper::generateAdTemplate($client_id, $settings, 'elementor');
645 }
646 ?>
647 </div>
648 </div>
649
650 <?php
651 }
652
653
654 private function get_file_url()
655 {
656 $settings = $this->get_settings();
657 $file_url = $settings['embedpress_document_type'] === 'url' ? esc_url($settings['embedpress_document_file_link']['url']) : esc_url($settings['embedpress_document_Uploader']['url']);
658 return $file_url;
659 }
660
661
662 protected function render_editor_script( $id, $url )
663 {
664 ?>
665 <script>
666 (function ($) {
667 'use strict';
668 $(document).ready(function () {
669 var selector = $('.embedpress-embed-document-pdf');
670 let option = {
671 forceObject: false,
672 };
673 if (selector.length) {
674 PDFObject.embed("<?php echo $url; ?>", "<?php echo '.' . $id; ?>", option);
675 }
676 });
677 })(jQuery);
678 </script>
679 <?php
680 }
681 }
682