PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.7.3
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.7.3
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 3 years ago Embedpress_Document.php 3 years ago Embedpress_Elementor.php 3 years ago Embedpress_Pdf.php 3 years ago
Embedpress_Document.php
675 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
87 $this->add_control(
88 'embedpress_document_Uploader',
89 [
90
91 'label' => __( 'Upload File', 'embedpress' ),
92 'type' => Controls_Manager::MEDIA,
93 'dynamic' => [
94 'active' => true,
95 'categories' => [
96 TagsModule::MEDIA_CATEGORY,
97 ],
98 ],
99 'media_type' => [
100 'application/pdf',
101 'application/msword',
102 'application/vnd.ms-powerpoint',
103 'application/vnd.ms-excel',
104 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
105 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
106 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
107 ],
108 'description' => __( 'Upload a file or pick one from your media library for embed. Supported File Type: PDF, DOC/DOCX, PPT/PPTX, XLS/XLSX etc.',
109 'embedpress' ),
110 'condition' => [
111 'embedpress_document_type' => 'file'
112 ],
113 ]
114 );
115
116 $this->add_control(
117 'embedpress_document_file_link',
118 [
119 'label' => __( 'URL', 'embedpress' ),
120 'type' => Controls_Manager::URL,
121 'placeholder' => __( 'https://your-link.com/file.pdf', 'embedpress' ),
122 'show_external' => false,
123 'dynamic' => [
124 'active' => true,
125 ],
126 'default' => [
127 'url' => ''
128 ],
129 'condition' => [
130 'embedpress_document_type' => 'url'
131 ],
132 ]
133 );
134
135 $this->add_responsive_control(
136 'embedpress_elementor_document_width',
137 [
138 'type' => \Elementor\Controls_Manager::SLIDER,
139 'label' => esc_html__( 'Width', 'embedpress' ),
140 'range' => [
141 'px' => [
142 'min' => 1,
143 'max' => 1000,
144 ],
145 ],
146 'devices' => [ 'desktop', 'tablet', 'mobile' ],
147 'default' => [
148 'unit' => 'px',
149 'size' => 600,
150 ],
151 'desktop_default' => [
152 'unit' => 'px',
153 'size' => 600,
154 ],
155 'tablet_default' => [
156 'size' => 400,
157 'unit' => 'px',
158 ],
159 'mobile_default' => [
160 'size' => 300,
161 'unit' => 'px',
162 ],
163 'selectors' => [
164 '{{WRAPPER}} .embedpress-document-embed iframe' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
165 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
166 '{{WRAPPER}} .embedpress-document-embed' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
167 ],
168 ]
169 );
170 $this->add_responsive_control(
171 'embedpress_elementor_document_height',
172 [
173 'type' => \Elementor\Controls_Manager::SLIDER,
174 'label' => esc_html__( 'Height', 'embedpress' ),
175 'range' => [
176 'px' => [
177 'min' => 1,
178 'max' => 1000,
179 ],
180 ],
181 'devices' => [ 'desktop', 'tablet', 'mobile' ],
182 'default' => [
183 'unit' => 'px',
184 'size' => 600,
185 ],
186 'desktop_default' => [
187 'unit' => 'px',
188 'size' => 600,
189 ],
190 'tablet_default' => [
191 'size' => 400,
192 'unit' => 'px',
193 ],
194 'mobile_default' => [
195 'size' => 300,
196 'unit' => 'px',
197 ],
198 'selectors' => [
199 '{{WRAPPER}} .embedpress-document-embed iframe' => 'height: {{SIZE}}{{UNIT}}!important;',
200 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'height: {{SIZE}}{{UNIT}};',
201 '{{WRAPPER}} .embedpress-document-embed ' => 'max-height: {{SIZE}}{{UNIT}};',
202 ],
203 ]
204 );
205
206 $this->add_responsive_control(
207 'embedpress_elementor_document_align',
208 [
209 'label' => __( 'Alignment', 'embedpress' ),
210 'type' => Controls_Manager::CHOOSE,
211 'options' => [
212 'left' => [
213 'title' => __( 'Left', 'embedpress' ),
214 'icon' => 'eicon-text-align-left',
215 ],
216 'center' => [
217 'title' => __( 'Center', 'embedpress' ),
218 'icon' => 'eicon-text-align-center',
219 ],
220 'right' => [
221 'title' => __( 'Right', 'embedpress' ),
222 'icon' => 'eicon-text-align-right',
223 ]
224 ],
225 'prefix_class' => 'elementor%s-align-',
226 'default' => '',
227 ]
228 );
229
230 $this->add_control(
231 'embedpress_document_powered_by',
232 [
233 'label' => __( 'Powered By', 'embedpress' ),
234 'type' => Controls_Manager::SWITCHER,
235 'label_on' => __( 'Show', 'embedpress' ),
236 'label_off' => __( 'Hide', 'embedpress' ),
237 'return_value' => 'yes',
238 'default' => apply_filters( 'embedpress_document_powered_by_control', 'yes' ),
239 ]
240 );
241
242 $this->init_branding_controls( 'document');
243
244 $this->end_controls_section();
245
246 /**
247 * EmbedPress Document control settings
248 */
249
250 $this->start_controls_section(
251 'embedpress_doc_content_settings',
252 [
253 'label' => esc_html__('Controls', 'embedpress'),
254 ]
255 );
256
257 $this->add_control(
258 'important_note',
259 [
260 'type' => \Elementor\Controls_Manager::RAW_HTML,
261 'raw' => esc_html__( 'Download feature is available when link has the document extension at the end.', 'embedpress' ),
262 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
263 'condition' => [
264 'embedpress_document_type' => 'url',
265 ],
266 ]
267 );
268
269 $this->add_control(
270 'embedpress_theme_mode',
271 [
272 'label' => __('Theme', 'embedpress'),
273 'type' => Controls_Manager::SELECT,
274 'default' => 'default',
275 'options' => [
276 'default' => __('System Default', 'embedpress'),
277 'dark' => __('Dark', 'embedpress'),
278 'light' => __('Light', 'embedpress'),
279 'custom' => __('Custom', 'embedpress')
280 ],
281 ]
282 );
283
284 $this->add_control(
285 'embedpress_doc_custom_color',
286 [
287 'label' => esc_html__( 'Color', 'embedpress' ),
288 'type' => \Elementor\Controls_Manager::COLOR,
289 'condition' => [
290 'embedpress_theme_mode' => 'custom',
291 ],
292 ]
293 );
294
295 $this->add_control(
296 'doc_toolbar',
297 [
298 'label' => sprintf(__('Toolbar %s', 'embedpress'), $this->pro_text),
299 'type' => Controls_Manager::SWITCHER,
300 'label_on' => __('Show', 'embedpress'),
301 'label_off' => __('Hide', 'embedpress'),
302 'return_value' => 'yes',
303 'default' => 'yes',
304 'classes' => $this->pro_class,
305 ]
306 );
307
308
309 $this->add_control(
310 'doc_fullscreen_mode',
311 [
312 'label' => __('Fullscreen', 'embedpress'),
313 'type' => Controls_Manager::SWITCHER,
314 'label_on' => __('Show', 'embedpress'),
315 'label_off' => __('Hide', 'embedpress'),
316 'return_value' => 'yes',
317 'default' => 'yes',
318 'condition' => [
319 'doc_toolbar' => 'yes',
320 ],
321 ]
322 );
323
324 $this->add_control(
325 'doc_print_download',
326 [
327 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text),
328 'type' => Controls_Manager::SWITCHER,
329 'label_on' => __('Show', 'embedpress'),
330 'label_off' => __('Hide', 'embedpress'),
331 'return_value' => 'yes',
332 'default' => 'yes',
333 'classes' => $this->pro_class,
334 'condition' => [
335 'doc_toolbar' => 'yes',
336 ],
337 ]
338 );
339
340
341 $this->add_control(
342 'doc_draw',
343 [
344 'label' => __('Draw', 'embedpress'),
345 'type' => Controls_Manager::SWITCHER,
346 'label_on' => __('Show', 'embedpress'),
347 'label_off' => __('Hide', 'embedpress'),
348 'return_value' => 'yes',
349 'default' => 'yes',
350 'condition' => [
351 'doc_toolbar' => 'yes',
352 ],
353 ]
354 );
355
356
357 $this->end_controls_section();
358
359 do_action( 'extend_elementor_controls', $this, '_doc_', $this->pro_text, $this->pro_class);
360
361 if (! is_embedpress_pro_active()) {
362 $this->start_controls_section(
363 'embedpress_pro_section',
364 [
365 'label' => __('Go Premium for More Features', 'embedpress'),
366 ]
367 );
368
369 $this->add_control(
370 'embedpress_pro_cta',
371 [
372 'label' => __('Unlock more possibilities', 'embedpress'),
373 'type' => Controls_Manager::CHOOSE,
374 'options' => [
375 '1' => [
376 'title' => '',
377 'icon' => 'eicon-lock',
378 ],
379 ],
380 'default' => '1',
381 '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>',
382 ]
383 );
384
385 $this->end_controls_section();
386 }
387 }
388
389 private function is_pdf( $url )
390 {
391 $arr = explode( '.', $url );
392 return end( $arr ) === 'pdf';
393 }
394
395 protected function render()
396 {
397 $settings = $this->get_settings();
398
399 $client_id = $this->get_id();
400 $pass_hash_key = md5($settings['embedpress_doc_lock_content_password']);
401 $url = $this->get_file_url();
402 $id = 'embedpress-pdf-' . $this->get_id();
403
404 if($settings['embedpress_document_type'] === 'url') {
405 if(class_exists( 'ACF' ) && function_exists('get_field')){
406 if(!empty($settings['__dynamic__']) && !empty($settings['__dynamic__']['embedpress_document_file_link'])){
407 $decode_url = urldecode(($settings['__dynamic__']['embedpress_document_file_link']));
408 preg_match('/"key":"([^"]+):([^"]+)"/', $decode_url, $matches);
409 if (isset($matches[0])) {
410 if (isset($matches[1])) {
411 $get_acf_key = $matches[1];
412 $url = get_field($get_acf_key);
413
414 if(empty($url)){
415 $pattern = '/"fallback":"([^"]+)"/';
416 preg_match($pattern, $decode_url, $matches);
417
418 if (isset($matches[1])) {
419 $url = $matches[1];
420 }
421 }
422 }
423 }
424 }
425 }
426 }
427 $hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_doc_lock_content_password']));
428
429 $dimension = '';
430 if(empty($settings['embedpress_doc_lock_content']) && empty($settings['embedpress_doc_lock_content_password'])){
431 $dimension = "width: {$settings['embedpress_elementor_document_width']['size']}px;height: {$settings['embedpress_elementor_document_height']['size']}px";
432 }
433
434 $content_locked_class = '';
435 if(!empty($settings['embedpress_doc_lock_content']) && !empty($settings['embedpress_doc_lock_content_password'])){
436 $content_locked_class = 'ep-content-locked';
437 }
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']) ? $settings['embedpress_doc_content_share_custom_thumbnail']['url'] : '';
453
454 $embed_settings['customTitle'] = !empty($settings['embedpress_doc_content_title']) ? $settings['embedpress_doc_content_title'] : Helper::get_file_title($url);
455
456 $embed_settings['customDescription'] = !empty($settings['embedpress_doc_content_descripiton']) ? $settings['embedpress_doc_content_descripiton'] : Helper::get_file_title($url);
457
458 $embed_settings['sharePosition'] = !empty($settings['embedpress_doc_content_share_position']) ? $settings['embedpress_doc_content_share_position'] : 'right';
459
460 $embed_settings['lockHeading'] = !empty($settings['embedpress_doc_lock_content_heading']) ? $settings['embedpress_doc_lock_content_heading'] : '';
461
462 $embed_settings['lockSubHeading'] = !empty($settings['embedpress_doc_lock_content_sub_heading']) ? $settings['embedpress_doc_lock_content_sub_heading'] : '';
463
464 $embed_settings['lockErrorMessage'] = !empty($settings['embedpress_doc_lock_content_error_message']) ? $settings['embedpress_doc_lock_content_error_message'] : '';
465
466
467 $embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_doc_password_placeholder']) ? $settings['embedpress_doc_password_placeholder'] : '';
468
469 $embed_settings['submitButtonText'] = !empty($settings['embedpress_doc_submit_button_text']) ? $settings['embedpress_doc_submit_button_text'] : '';
470
471 $embed_settings['submitUnlockingText'] = !empty($settings['embedpress_doc_submit_Unlocking_text']) ? $settings['embedpress_doc_submit_Unlocking_text'] : '';
472
473
474 $embed_settings['enableFooterMessage'] = !empty($settings['embedpress_doc_enable_footer_message']) ? $settings['embedpress_doc_enable_footer_message'] : '';
475
476 $embed_settings['footerMessage'] = !empty($settings['embedpress_doc_lock_content_footer_message']) ? $settings['embedpress_doc_lock_content_footer_message'] : '';
477
478
479 $content_share_class = '';
480 $share_position_class = '';
481 $share_position = isset($settings['embedpress_doc_content_share_position']) ? $settings['embedpress_doc_content_share_position'] : 'right';
482
483 if(!empty($settings['embedpress_doc_content_share'])) {
484 $content_share_class = 'ep-content-share-enabled';
485 $share_position_class = 'ep-share-position-'.$share_position;
486 }
487
488 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
489
490 $content_protection_class = 'ep-content-protection-enabled';
491 if(empty($settings['embedpress_doc_lock_content']) || empty($settings['embedpress_doc_lock_content_password']) || $hash_pass === $password_correct) {
492 $content_protection_class = 'ep-content-protection-disabled';
493 }
494
495 ?>
496
497
498 <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block">
499
500 <?php
501
502
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>', __( '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
521 } else {
522 if(Helper::is_file_url($url)){
523 $view_link = '//view.officeapps.live.com/op/embed.aspx?src=' . urlencode($url) . '&embedded=true';
524 }
525 else{
526 $view_link = 'https://drive.google.com/viewerng/viewer?url=' . urlencode($url) . '&embedded=true&chrome=false';
527 }
528
529 $hostname = parse_url($url, PHP_URL_HOST);
530 $domain = implode(".", array_slice(explode(".", $hostname), -2));
531
532 if ($domain == "google.com") {
533 $view_link = $url.'?embedded=true';
534 if(strpos($view_link, '/presentation/')){
535 $view_link = Helper::get_google_presentation_url($url);
536 }
537 }
538
539 $embed_content = '<div ' . $this->get_render_attribute_string( 'embedpres-pdf-render' ) . '>';
540
541 $is_powered_by = '';
542 if ( $settings[ 'embedpress_document_powered_by' ] === 'yes' ) {
543 $is_powered_by = 'ep-powered-by-enabled';
544 }
545
546 $is_download_enabled = ' enabled-file-download';
547 if ( $settings[ 'doc_print_download' ] !== 'yes' ) {
548 $is_download_enabled = '';
549 }
550
551 $file_extenstion = 'link';
552 if(!empty(Helper::is_file_url($url))){
553 $file_extenstion = Helper::get_extension_from_file_url($url);
554 }
555
556 $is_custom_theme = '';
557 if($settings['embedpress_theme_mode'] == 'custom'){
558 $is_custom_theme = 'data-custom-color='.esc_attr($settings['embedpress_doc_custom_color']).'';
559 }
560
561 $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() ).'">';
562
563
564 $sandbox = '';
565 if ( $settings[ 'doc_print_download' ] === 'yes') {
566 $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"';
567 }
568
569 $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.'>
570 </iframe>';
571
572
573 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')) {
574 $embed_content.='<div class="embed-download-disabled"></div>';
575 }
576
577 if ( $settings[ 'doc_draw' ] === 'yes') {
578 $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>';
579 }
580
581 if ( $settings[ 'doc_print_download' ] === 'yes' && Helper::get_extension_from_file_url($url) !== 'pptx') {
582 $embed_content.='<div style="width: 40px; height: 40px; position: absolute; opacity: 0; right: 12px; top: 12px;"></div>';
583 }
584
585 if(!empty($settings['doc_toolbar'])){
586 $embed_content.= '<div class="ep-external-doc-icons">';
587
588 if(empty(Helper::is_file_url($url))){
589 $embed_content.= Helper::ep_get_popup_icon();
590 }
591
592 if(!empty(Helper::is_file_url($url))){
593 if(!empty($settings['doc_print_download'])){
594 $embed_content.= Helper::ep_get_print_icon();
595 $embed_content.= Helper::ep_get_download_icon();
596 }
597 }
598 if(!empty($settings['doc_draw'])){
599 $embed_content.= Helper::ep_get_draw_icon();
600 }
601 if(!empty($settings['doc_fullscreen_mode'])){
602 $embed_content.= Helper::ep_get_fullscreen_icon();
603 $embed_content.= Helper::ep_get_minimize_icon();
604 }
605
606 $embed_content.= '</div>';
607 }
608 $embed_content .='</div>';
609
610 if ( $settings[ 'embedpress_document_powered_by' ] === 'yes' ) {
611 $embed_content.= '<div>';
612 $embed_content .= sprintf( '<p class="embedpress-el-powered">%s</p>', __( 'Powered By EmbedPress', 'embedpress' ) );
613 $embed_content .='</div>';
614 }
615
616 $embed_content .='</div>';
617 }
618 }
619
620
621 ?>
622 <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); ?>">
623 <div id="<?php echo esc_attr( $this->get_id() ); ?>" class="ep-embed-content-wraper">
624 <?php
625
626 $content_id = $client_id;
627 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]))) {
628
629 if(!empty($settings['embedpress_doc_content_share'])){
630 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
631 }
632 if(!empty($embed_content)){
633 echo $embed_content;
634 }
635 } else {
636 if(!empty($settings['embedpress_doc_content_share'])){
637 $embed_content .= Helper::embed_content_share($content_id, $embed_settings);
638 }
639 Helper::display_password_form($client_id, $embed_content, $pass_hash_key, $embed_settings);
640 }
641 ?>
642 </div>
643 </div>
644 </div>
645
646 <?php
647 }
648
649 private function get_file_url()
650 {
651 $settings = $this->get_settings();
652 return $settings[ 'embedpress_document_type' ] === 'url' ? $settings[ 'embedpress_document_file_link' ][ 'url' ] : $settings[ 'embedpress_document_Uploader' ][ 'url' ];
653 }
654
655 protected function render_editor_script( $id, $url )
656 {
657 ?>
658 <script>
659 (function ($) {
660 'use strict';
661 $(document).ready(function () {
662 var selector = $('.embedpress-embed-document-pdf');
663 let option = {
664 forceObject: false,
665 };
666 if (selector.length) {
667 PDFObject.embed("<?php echo $url; ?>", "<?php echo '.' . $id; ?>", option);
668 }
669 });
670 })(jQuery);
671 </script>
672 <?php
673 }
674 }
675