PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.4.8
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.4.8
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 6 months ago Embedpress_Document.php 6 months ago Embedpress_Elementor.php 6 months ago Embedpress_Pdf.php 6 months ago
Embedpress_Pdf.php
1201 lines
1 <?php
2
3 namespace EmbedPress\Elementor\Widgets;
4
5 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
6 use Elementor\Core\Kits\Manager;
7 use Elementor\Plugin;
8
9
10 use \Elementor\Controls_Manager as Controls_Manager;
11 use \Elementor\Modules\DynamicTags\Module as TagsModule;
12 use \Elementor\Widget_Base as Widget_Base;
13 use EmbedPress\Includes\Classes\Helper;
14 use EmbedPress\Includes\Traits\Branding;
15
16
17
18 (defined('ABSPATH')) or die("No direct script access allowed.");
19
20 class Embedpress_Pdf extends Widget_Base
21 {
22
23 use Branding;
24 protected $pro_class = '';
25 protected $pro_text = '';
26 public function get_name()
27 {
28 return 'embedpress_pdf';
29 }
30
31 public function get_title()
32 {
33 return esc_html__('EmbedPress PDF', 'embedpress');
34 }
35
36 public function get_categories()
37 {
38 return ['embedpress'];
39 }
40
41 public function get_custom_help_url()
42 {
43 return 'https://embedpress.com/documentation';
44 }
45
46 public function get_icon()
47 {
48 return 'icon-pdf';
49 }
50
51 public function get_style_depends()
52 {
53 return [
54 'embedpress-elementor-css',
55 'embedpress-css',
56 ];
57 }
58
59 public function get_script_depends()
60 {
61
62 $handler_keys = get_option('enabled_elementor_scripts', []);
63
64 $handles = [];
65
66 $handles[] = 'embedpress-pdfobject';
67 $handles[] = 'embedpress-front';
68
69 if (isset($handler_keys['enabled_ads']) && $handler_keys['enabled_ads'] === 'yes') {
70 $handles[] = 'embedpress-ads';
71 }
72
73 return $handles;
74 }
75
76 /**
77 * Get widget keywords.
78 *
79 * Retrieve the list of keywords the widget belongs to.
80 *
81 * @return array Widget keywords.
82 * @since 2.5.5
83 * @access public
84 *
85 */
86 public function get_keywords()
87 {
88 return ['embedpress', 'pdf', 'doc', 'embedpress-document'];
89 }
90
91
92 /**
93 * Performance Settings Section
94 */
95 public function init_performance_controls()
96 {
97 // Get global lazy load setting
98 $g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
99 $lazy_load_default = isset($g_settings['g_lazyload']) && $g_settings['g_lazyload'] == 1 ? 'yes' : '';
100
101 $this->start_controls_section(
102 'embedpress_performance_section',
103 [
104 'label' => __('Performance', 'embedpress'),
105 ]
106 );
107
108 $this->add_control(
109 'enable_lazy_load',
110 [
111 'label' => sprintf(__('Enable Lazy Loading %s', 'embedpress'), $this->pro_text),
112 'type' => \Elementor\Controls_Manager::SWITCHER,
113 'label_on' => __('Yes', 'embedpress'),
114 'label_off' => __('No', 'embedpress'),
115 'return_value' => 'yes',
116 'default' => $lazy_load_default,
117 'description' => __('Load iframe only when it enters the viewport for better performance', 'embedpress'),
118 'classes' => $this->pro_class,
119 ]
120 );
121
122 $this->end_controls_section();
123 }
124
125 protected function register_controls()
126 {
127 $class = 'embedpress-pro-control not-active';
128 $text = '<sup class="embedpress-pro-label" style="color:red">' . __('Pro', 'embedpress') . '</sup>';
129 $this->pro_class = apply_filters('embedpress/pro_class', $class);
130 $this->pro_text = apply_filters('embedpress/pro_text', $text);
131
132 /**
133 * EmbedPress Content Settings
134 */
135 $this->start_controls_section(
136 'embedpress_content_settings',
137 [
138 'label' => esc_html__('General', 'embedpress'),
139 ]
140 );
141
142 $this->add_control(
143 'embedpress_pdf_type',
144 [
145 'label' => __('Document Type', 'embedpress'),
146 'type' => Controls_Manager::SELECT,
147 'default' => 'file',
148 'options' => [
149 'file' => __('File', 'embedpress'),
150 'url' => __('URL', 'embedpress')
151 ],
152 ]
153 );
154
155 $this->add_control(
156 'embedpress_pdf_file_link_from',
157 [
158 'label' => __( 'URL From', 'embedpress' ),
159 'type' => Controls_Manager::SELECT,
160 'default' => 'external',
161 'options' => [
162 'self' => __( 'Self', 'embedpress' ),
163 'external' => __( 'External', 'embedpress' )
164 ],
165 'condition' => [
166 'embedpress_pdf_type' => 'url'
167 ]
168 ]
169 );
170
171 $this->add_control(
172 'embedpress_pdf_Uploader',
173 [
174 'label' => __('Upload File', 'embedpress'),
175 'type' => Controls_Manager::MEDIA,
176 'dynamic' => [
177 'active' => true,
178 'categories' => [
179 TagsModule::MEDIA_CATEGORY,
180 ],
181 ],
182 'media_type' => [
183 'application/pdf',
184 ],
185 'description' => __(
186 'Upload a file or pick one from your media library for embed. Supported File Type: PDF',
187 'embedpress'
188 ),
189 'condition' => [
190 'embedpress_pdf_type' => 'file'
191 ],
192 ]
193 );
194
195 $this->add_control(
196 'embedpress_pdf_file_link',
197 [
198 'label' => __('URL', 'embedpress'),
199 'type' => Controls_Manager::URL,
200 'placeholder' => __('https://your-link.com/file.pdf', 'embedpress'),
201 'dynamic' => [
202 'active' => true,
203 ],
204 'show_external' => false,
205 'dynamic' => [
206 'active' => true,
207 ],
208 'default' => [
209 'url' => ''
210 ],
211 'condition' => [
212 'embedpress_pdf_type' => 'url'
213 ],
214 ]
215 );
216
217
218 $this->add_control(
219 'embedpress_pdf_viewer_style',
220 [
221 'label' => __('Viewer Style', 'embedpress'),
222 'type' => Controls_Manager::SELECT,
223 'default' => 'modern',
224 'options' => [
225 'modern' => __('Modern', 'embedpress'),
226 'flip-book' => __('Flip Book', 'embedpress'),
227 ],
228 'conditions' => [
229 'relation' => 'or',
230 'terms' => [
231 ['name' => 'embedpress_pdf_type', 'operator' => '===', 'value' => 'file'],
232 ['name' => 'embedpress_pdf_file_link_from', 'operator' => '===', 'value' => 'self'],
233 ],
234 ],
235 ]
236 );
237
238 $this->add_control(
239 'embedpress_pdf_zoom',
240 [
241 'label' => __('Zoom', 'embedpress'),
242 'type' => Controls_Manager::SELECT,
243 'default' => 'auto',
244 'options' => [
245 'auto' => __('Automatic Zoom', 'embedpress'),
246 'page-actual' => __('Actual Size', 'embedpress'),
247 'page-fit' => __('Page Fit', 'embedpress'),
248 'page-width' => __('Page Width', 'embedpress'),
249 'custom' => __('Custom', 'embedpress'),
250 '50' => __('50%', 'embedpress'),
251 '75' => __('75%', 'embedpress'),
252 '100' => __('100%', 'embedpress'),
253 '125' => __('125%', 'embedpress'),
254 '150' => __('150%', 'embedpress'),
255 '200' => __('200%', 'embedpress'),
256 '300' => __('300%', 'embedpress'),
257 '400' => __('400%', 'embedpress'),
258 ],
259 'condition' => [
260 'embedpress_pdf_viewer_style' => 'modern'
261 ]
262 ]
263 );
264 $this->add_control(
265 'embedpress_pdf_zoom_custom',
266 [
267 'label' => __('Custom Zoom', 'embedpress'),
268 'type' => Controls_Manager::NUMBER,
269 'condition' => [
270 'embedpress_pdf_zoom' => 'custom'
271 ],
272 ]
273 );
274 $this->add_responsive_control(
275 'embedpress_elementor_document_width',
276 [
277 'type' => \Elementor\Controls_Manager::SLIDER,
278 'label' => esc_html__( 'Width', 'embedpress' ),
279 'size_units' => [ 'px', '%' ],
280 'range' => [
281 'px' => [
282 'min' => 1,
283 'max' => 1500,
284 ],
285 ],
286 'devices' => [ 'desktop', 'tablet', 'mobile' ],
287 'default' => [
288 'unit' => '%',
289 'size' => !empty($value = intval(Helper::get_options_value('enableEmbedResizeWidth'))) ? $value : 600,
290 ],
291 'desktop_default' => [
292 'unit' => 'px',
293 'size' => 600,
294 ],
295 'tablet_default' => [
296 'size' => 400,
297 'unit' => 'px',
298 ],
299 'mobile_default' => [
300 'size' => 300,
301 'unit' => 'px',
302 ],
303 'selectors' => [
304 '{{WRAPPER}} .embedpress-document-embed iframe, , {{WRAPPER}} .ep-share-position-bottom .ep-embed-content-wraper' => 'width: {{SIZE}}{{UNIT}}!important; max-width: {{SIZE}}{{UNIT}}!important',
305 // '{{WRAPPER}} .embedpress-document-embed' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%',
306 // '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%',
307 ],
308 'render_type' => 'template',
309 ]
310 );
311 $this->add_responsive_control(
312 'embedpress_elementor_document_height',
313 [
314 'type' => \Elementor\Controls_Manager::SLIDER,
315 'label' => esc_html__( 'Height', 'embedpress' ),
316 'range' => [
317 'px' => [
318 'min' => 1,
319 'max' => 2000,
320 ],
321 ],
322 'devices' => [ 'desktop', 'tablet', 'mobile' ],
323 'default' => [
324 'unit' => 'px',
325 'size' => !empty($value = intval(Helper::get_options_value('enableEmbedResizeHeight'))) ? $value : 600,
326
327 ],
328 'desktop_default' => [
329 'unit' => 'px',
330 'size' => 600,
331 ],
332 'tablet_default' => [
333 'size' => 400,
334 'unit' => 'px',
335 ],
336 'mobile_default' => [
337 'size' => 300,
338 'unit' => 'px',
339 ],
340 'selectors' => [
341 '{{WRAPPER}} .embedpress-document-embed iframe' => 'height: {{SIZE}}{{UNIT}}!important;',
342 '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'height: {{SIZE}}{{UNIT}}!important;',
343 ],
344 'render_type' => 'template',
345 ]
346 );
347
348 $this->add_responsive_control(
349 'embedpress_elementor_document_align',
350 [
351 'label' => __('Alignment', 'embedpress'),
352 'type' => Controls_Manager::CHOOSE,
353 'options' => [
354 'left' => [
355 'title' => __('Left', 'embedpress'),
356 'icon' => 'eicon-text-align-left',
357 ],
358 'center' => [
359 'title' => __('Center', 'embedpress'),
360 'icon' => 'eicon-text-align-center',
361 ],
362 'right' => [
363 'title' => __('Right', 'embedpress'),
364 'icon' => 'eicon-text-align-right',
365 ]
366 ],
367 'prefix_class' => 'elementor%s-align-',
368 'default' => '',
369 ]
370 );
371
372 // Get global powered_by setting
373 $g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
374 $powered_by_default = isset($g_settings['embedpress_document_powered_by']) && $g_settings['embedpress_document_powered_by'] === 'yes' ? 'yes' : 'no';
375
376 $this->add_control(
377 'embedpress_pdf_powered_by',
378 [
379 'label' => __('Powered By', 'embedpress'),
380 'type' => Controls_Manager::SWITCHER,
381 'label_on' => __('Show', 'embedpress'),
382 'label_off' => __('Hide', 'embedpress'),
383 'return_value' => 'yes',
384 'default' => apply_filters('embedpress_document_powered_by_control', $powered_by_default),
385 ]
386 );
387
388 $this->init_branding_controls('document');
389
390 $this->end_controls_section();
391
392
393 /**
394 * EmbedPress PDF Control Settings
395 */
396
397 $this->start_controls_section(
398 'embedpress_pdf_content_settings',
399 [
400 'label' => esc_html__('Controls', 'embedpress'),
401 'conditions' => [
402 'relation' => 'or',
403 'terms' => [
404 ['name' => 'embedpress_pdf_type', 'operator' => '===', 'value' => 'file'],
405 ['name' => 'embedpress_pdf_file_link_from', 'operator' => '===', 'value' => 'self'],
406 ],
407 ],
408 ]
409 );
410
411
412 $this->add_control(
413 'embedpress_theme_mode',
414 [
415 'label' => __('Theme', 'embedpress'),
416 'type' => Controls_Manager::SELECT,
417 'default' => 'default',
418 'options' => [
419 'default' => __('System Default', 'embedpress'),
420 'dark' => __('Dark', 'embedpress'),
421 'light' => __('Light', 'embedpress'),
422 'custom' => __('Custom', 'embedpress')
423 ],
424 ]
425 );
426
427 $this->add_control(
428 'embedpress_pdf_custom_color',
429 [
430 'label' => esc_html__( 'Color', 'embedpress' ),
431 'type' => \Elementor\Controls_Manager::COLOR,
432 // 'default' => Helper::get_options_value('custom_color'),
433 'global' => [
434 'default' => Global_Colors::COLOR_PRIMARY,
435 ],
436 'condition' => [
437 'embedpress_theme_mode' => 'custom',
438 ],
439 ]
440 );
441
442 $this->add_control(
443 'pdf_toolbar',
444 [
445 'label' => sprintf(__('Toolbar %s', 'embedpress'), $this->pro_text),
446 'type' => Controls_Manager::SWITCHER,
447 'label_on' => __('Show', 'embedpress'),
448 'label_off' => __('Hide', 'embedpress'),
449 'return_value' => 'yes',
450 'default' => 'yes',
451 'classes' => $this->pro_class,
452 ]
453 );
454
455
456 $this->add_control(
457 'pdf_toolbar_position',
458 [
459 'label' => esc_html__('Toolbar Position', 'embedpress'),
460 'type' => \Elementor\Controls_Manager::CHOOSE,
461 'options' => [
462 'top' => [
463 'title' => esc_html__('Top', 'embedpress'),
464 'icon' => 'eicon-arrow-up',
465 ],
466 'bottom' => [
467 'title' => esc_html__('Bottom', 'embedpress'),
468 'icon' => 'eicon-arrow-down',
469 ],
470 ],
471 'default' => 'top',
472 'toggle' => true,
473 'condition' => [
474 'pdf_toolbar' => 'yes',
475 'embedpress_pdf_viewer_style' => 'modern',
476 ],
477 ]
478 );
479 $this->add_control(
480 'flipbook_toolbar_position',
481 [
482 'label' => esc_html__('Toolbar Position', 'embedpress'),
483 'type' => \Elementor\Controls_Manager::CHOOSE,
484 'options' => [
485 'top' => [
486 'title' => esc_html__('Top', 'embedpress'),
487 'icon' => 'eicon-arrow-up',
488 ],
489 'bottom' => [
490 'title' => esc_html__('Bottom', 'embedpress'),
491 'icon' => 'eicon-arrow-down',
492 ],
493 ],
494 'default' => 'bottom',
495 'toggle' => true,
496 'condition' => [
497 'pdf_toolbar' => 'yes',
498 'embedpress_pdf_viewer_style' => 'flip-book',
499 ],
500 ]
501 );
502
503
504 $this->add_control(
505 'pdf_print_download',
506 [
507 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text),
508 'type' => Controls_Manager::SWITCHER,
509 'label_on' => __('Show', 'embedpress'),
510 'label_off' => __('Hide', 'embedpress'),
511 'return_value' => 'yes',
512 'default' => 'yes',
513 'classes' => $this->pro_class,
514 'condition' => [
515 'pdf_toolbar' => 'yes',
516 ],
517 ]
518 );
519
520
521
522 $this->add_control(
523 'pdf_zoom_in',
524 [
525 'label' => __('Zoom In', 'embedpress'),
526 'type' => Controls_Manager::SWITCHER,
527 'label_on' => __('Show', 'embedpress'),
528 'label_off' => __('Hide', 'embedpress'),
529 'return_value' => 'yes',
530 'default' => 'yes',
531 'condition' => [
532 'pdf_toolbar' => 'yes',
533 'embedpress_pdf_viewer_style' => 'flip-book',
534 ],
535 ]
536 );
537 $this->add_control(
538 'pdf_zoom_out',
539 [
540 'label' => __('Zoom Out', 'embedpress'),
541 'type' => Controls_Manager::SWITCHER,
542 'label_on' => __('Show', 'embedpress'),
543 'label_off' => __('Hide', 'embedpress'),
544 'return_value' => 'yes',
545 'default' => 'yes',
546 'condition' => [
547 'pdf_toolbar' => 'yes',
548 'embedpress_pdf_viewer_style' => 'flip-book',
549 ],
550 ]
551 );
552 $this->add_control(
553 'pdf_fit_view',
554 [
555 'label' => __('Fit View', 'embedpress'),
556 'type' => Controls_Manager::SWITCHER,
557 'label_on' => __('Show', 'embedpress'),
558 'label_off' => __('Hide', 'embedpress'),
559 'return_value' => 'yes',
560 'default' => 'yes',
561 'condition' => [
562 'pdf_toolbar' => 'yes',
563 'embedpress_pdf_viewer_style' => 'flip-book',
564 ],
565 ]
566 );
567 $this->add_control(
568 'pdf_bookmark',
569 [
570 'label' => __('Bookmark', 'embedpress'),
571 'type' => Controls_Manager::SWITCHER,
572 'label_on' => __('Show', 'embedpress'),
573 'label_off' => __('Hide', 'embedpress'),
574 'return_value' => 'yes',
575 'default' => 'yes',
576 'condition' => [
577 'pdf_toolbar' => 'yes',
578 'embedpress_pdf_viewer_style' => 'flip-book',
579 ],
580 ]
581 );
582
583 $this->add_control(
584 'pdf_sound',
585 [
586 'label' => __('Flip Sound', 'embedpress'),
587 'type' => Controls_Manager::SWITCHER,
588 'label_on' => __('On', 'embedpress'),
589 'label_off' => __('Off', 'embedpress'),
590 'return_value' => 'yes',
591 'default' => 'yes',
592 'condition' => [
593 'embedpress_pdf_viewer_style' => 'flip-book',
594 ],
595 ]
596 );
597
598
599 $this->add_control(
600 'pdf_presentation_mode',
601 [
602 'label' => __('PDF Presentation Mode', 'embedpress'),
603 'type' => Controls_Manager::SWITCHER,
604 'label_on' => __('Show', 'embedpress'),
605 'label_off' => __('Hide', 'embedpress'),
606 'return_value' => 'yes',
607 'default' => 'yes',
608 'condition' => [
609 'pdf_toolbar' => 'yes',
610 ],
611 ]
612 );
613 $this->add_control(
614 'pdf_lazyload',
615 [
616 'label' => __('Lazy Load', 'embedpress'),
617 'type' => Controls_Manager::SWITCHER,
618 'label_on' => __('Yes', 'embedpress'),
619 'label_off' => __('No', 'embedpress'),
620 'return_value' => 'yes',
621 'default' => '',
622 'condition' => [
623 'pdf_toolbar' => 'yes',
624 ],
625 ]
626 );
627
628 $this->add_control(
629 'pdf_text_copy',
630 [
631 'label' => sprintf(__('Copy Text %s', 'embedpress'), $this->pro_text),
632 'type' => Controls_Manager::SWITCHER,
633 'label_on' => __('Show', 'embedpress'),
634 'label_off' => __('Hide', 'embedpress'),
635 'return_value' => 'yes',
636 'default' => 'yes',
637 'classes' => $this->pro_class,
638 'condition' => [
639 'pdf_toolbar' => 'yes',
640 'embedpress_pdf_viewer_style' => 'modern',
641 ],
642 ]
643 );
644
645 $this->add_control(
646 'add_text',
647 [
648 'label' => sprintf(__('Add Text', 'embedpress')),
649 'type' => Controls_Manager::SWITCHER,
650 'label_on' => __('Show', 'embedpress'),
651 'label_off' => __('Hide', 'embedpress'),
652 'return_value' => 'yes',
653 'default' => 'yes',
654 'condition' => [
655 'pdf_toolbar' => 'yes',
656 'embedpress_pdf_viewer_style' => 'modern',
657 ],
658 ]
659 );
660 $this->add_control(
661 'draw',
662 [
663 'label' => sprintf(__('Draw %s', 'embedpress'), $this->pro_text),
664 'type' => Controls_Manager::SWITCHER,
665 'label_on' => __('Show', 'embedpress'),
666 'label_off' => __('Hide', 'embedpress'),
667 'return_value' => 'yes',
668 'default' => 'yes',
669 'classes' => $this->pro_class,
670 'condition' => [
671 'pdf_toolbar' => 'yes',
672 'embedpress_pdf_viewer_style' => 'modern',
673 ],
674 ]
675 );
676
677 $this->add_control(
678 'add_image',
679 [
680 'label' => __('Add Image', 'embedpress'),
681 'type' => Controls_Manager::SWITCHER,
682 'label_on' => __('Show', 'embedpress'),
683 'label_off' => __('Hide', 'embedpress'),
684 'return_value' => 'yes',
685 'default' => 'yes',
686 'condition' => [
687 'pdf_toolbar' => 'yes',
688 'embedpress_pdf_viewer_style' => 'modern',
689 ],
690 ]
691 );
692 $this->add_control(
693 'pdf_rotate_access',
694 [
695 'label' => __('Rotation', 'embedpress'),
696 'type' => Controls_Manager::SWITCHER,
697 'label_on' => __('Show', 'embedpress'),
698 'label_off' => __('Hide', 'embedpress'),
699 'return_value' => 'yes',
700 'default' => 'yes',
701 'condition' => [
702 'pdf_toolbar' => 'yes',
703 'embedpress_pdf_viewer_style' => 'modern',
704 ],
705 ]
706 );
707
708 $this->add_control(
709 'pdf_details',
710 [
711 'label' => __('Properties', 'embedpress'),
712 'type' => Controls_Manager::SWITCHER,
713 'label_on' => __('Show', 'embedpress'),
714 'label_off' => __('Hide', 'embedpress'),
715 'return_value' => 'yes',
716 'default' => 'yes',
717 'condition' => [
718 'pdf_toolbar' => 'yes',
719 'embedpress_pdf_viewer_style' => 'modern',
720 ],
721 ]
722 );
723
724 $this->add_control(
725 'selection_tool',
726 [
727 'label' => sprintf(__('Default Selection Tool %s', 'embedpress'), $this->pro_text),
728 'type' => \Elementor\Controls_Manager::SELECT,
729 'options' => [
730 '0' => esc_html__('Text Tool', 'embedpress'),
731 '1' => esc_html__('Hand Tool', 'embedpress'),
732 ],
733 'default' => '0',
734 'classes' => $this->pro_class,
735
736 ]
737 );
738
739 $this->add_control(
740 'scrolling',
741 [
742 'label' => sprintf(__('Default Scrolling %s', 'embedpress'), $this->pro_text),
743 'type' => \Elementor\Controls_Manager::SELECT,
744 'options' => [
745 '-1' => esc_html__('Page Scrolling', 'embedpress'),
746 '0' => esc_html__('Vertical Scrolling', 'embedpress'),
747 '1' => esc_html__('Horizontal Scrolling', 'embedpress'),
748 '2' => esc_html__('Wrapped Scrolling', 'embedpress'),
749 ],
750 'default' => '0',
751 'classes' => $this->pro_class,
752 ]
753 );
754
755 $this->add_control(
756 'spreads',
757 [
758 'label' => esc_html__('Default Spreads', 'embedpress'),
759 'type' => \Elementor\Controls_Manager::SELECT,
760 'options' => [
761 '0' => esc_html__('No Spreads', 'embedpress'),
762 '1' => esc_html__('Odd Spreads', 'embedpress'),
763 '2' => esc_html__('Even Spreads', 'embedpress'),
764 ],
765 'default' => '-1',
766 'condition' => [
767 'scrolling!' => '1',
768 ],
769 ]
770 );
771
772 $this->end_controls_section();
773
774
775 do_action( 'extend_elementor_controls', $this, '_pdf_', $this->pro_text, $this->pro_class);
776 $this->init_performance_controls();
777
778 }
779
780 private function is_pdf($url)
781 {
782 $arr = explode('.', $url);
783 return end($arr) === 'pdf';
784 }
785
786 public function render()
787 {
788 $settings = $this->get_settings();
789
790 Helper::get_enable_settings_data_for_scripts($settings);
791
792 $is_editor_view = Plugin::$instance->editor->is_edit_mode();
793 $url = $this->get_file_url();
794
795 if ($settings['embedpress_pdf_type'] === 'url') {
796 if (!empty($settings['__dynamic__']['embedpress_pdf_file_link'])) {
797 $decode_url = urldecode($settings['__dynamic__']['embedpress_pdf_file_link']);
798 preg_match('/name="([^"]+)"/', $decode_url, $name_matches);
799
800 if (!empty($name_matches[1])) {
801 $name_key = $name_matches[1];
802 $pattern = '';
803
804 if ($name_key === 'acf-url' && class_exists('ACF') && function_exists('get_field')) {
805 $pattern = '/"key":"[^"]+:(.*?)"/';
806 } elseif ($name_key === 'toolset-url' && class_exists('Types_Helper_Output_Meta_Box')) {
807 $pattern = '/"key":"[^"]+:(.*?)"/';
808 } elseif ($name_key === 'jet-post-custom-field' && class_exists('Jet_Engine')) {
809 $pattern = '/"meta_field":"([^"]+)"/';
810 }
811
812 if ($pattern) {
813 preg_match($pattern, $decode_url, $matches);
814
815 if (!empty($matches[1])) {
816 $get_field_key = sanitize_key($matches[1]);
817
818 $url = '';
819
820 if ($name_key === 'acf-url') {
821 $url = get_field($get_field_key);
822 } elseif ($name_key === 'toolset-url') {
823 $url = get_post_meta(get_the_ID(), 'wpcf-' . $get_field_key, true);
824 } elseif ($name_key === 'jet-post-custom-field') {
825 $url = get_post_meta(get_the_ID(), $get_field_key, true);
826 }
827
828 $url = apply_filters('embedpress/custom_meta_field_value', $url, $get_field_key);
829
830 // Fallback if empty
831 if (empty($url)) {
832 preg_match('/"fallback":"([^"]+)"/', $decode_url, $fallback_matches);
833 if (!empty($fallback_matches[1])) {
834 $url = $fallback_matches[1];
835 }
836 }
837
838 // Final sanitization
839 $url = esc_url_raw($url);
840 }
841 }
842 }
843 }
844 }
845
846 $client_id = $this->get_id();
847
848 $this->_render($url, $settings, $client_id, $is_editor_view);
849 Helper::get_source_data(md5($this->get_id()).'_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data');
850 }
851
852
853 public function getParamData($settings){
854 $urlParamData = array(
855 'themeMode' => $settings['embedpress_theme_mode'],
856 'toolbar' => !empty($settings['pdf_toolbar']) ? 'true' : 'false',
857 'position' => $settings['pdf_toolbar_position'],
858 'presentation' => !empty($settings['pdf_presentation_mode']) ? 'true' : 'false',
859 'lazyLoad' => !empty($settings['pdf_lazyload']) ? 'true' : 'false',
860 'download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'true',
861 'copy_text' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'true',
862 'add_text' => !empty($settings['add_text']) ? 'true' : 'false',
863 'draw' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['draw'] : 'true',
864 'add_image' => !empty($settings['add_image']) ? 'true' : 'false',
865 'pdf_rotation' => !empty($settings['pdf_rotate_access']) ? 'true' : 'false',
866 'pdf_details' => !empty($settings['pdf_details']) ? 'true' : 'false',
867 'zoom_in' => !empty($settings['pdf_zoom_in']) ? 'true' : 'false',
868 'zoom_out' => !empty($settings['pdf_zoom_out']) ? 'true' : 'false',
869 'fit_view' => !empty($settings['pdf_fit_view']) ? 'true' : 'false',
870 'bookmark' => !empty($settings['pdf_bookmark']) ? 'true' : 'false',
871 'sound' => !empty($settings['pdf_sound']) ? 'true' : 'false',
872 'flipbook_toolbar_position' => !empty($settings['flipbook_toolbar_position']) ? $settings['flipbook_toolbar_position'] : 'bottom',
873 'selection_tool' => isset($settings['selection_tool']) ? esc_attr($settings['selection_tool']) : '0',
874 'scrolling' => isset($settings['scrolling']) ? esc_attr($settings['scrolling']) : '-1',
875 'spreads' => isset($settings['spreads']) ? esc_attr($settings['spreads']) : '-1',
876 'is_pro_active' => apply_filters('embedpress/is_allow_rander', false)
877
878 );
879
880 $custom_color = Helper::get_elementor_global_color($settings, 'embedpress_pdf_custom_color');
881
882 if($settings['embedpress_theme_mode'] == 'custom') {
883 $urlParamData['customColor'] = $custom_color;
884 }
885
886 if($settings['embedpress_pdf_viewer_style'] == 'flip-book'){
887 return "&key=" . base64_encode(mb_convert_encoding(http_build_query($urlParamData), "UTF-8"));
888 }
889
890 return "#key=" . base64_encode(mb_convert_encoding(http_build_query($urlParamData), "UTF-8"));
891
892 }
893
894 public function _render($url, $settings, $id, $is_editor_view = false)
895 {
896
897 $custom_color = Helper::get_elementor_global_color($settings, 'embedpress_pdf_custom_color');
898
899 $unitoption = 'emebedpress-unit-px';
900 if($settings['embedpress_elementor_document_width']['unit'] === '%'){
901 $unitoption = 'emebedpress-unit-percent';
902 }
903 $client_id = $id;
904 $id = 'embedpress-pdf-' . $id;
905 $hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_pdf_lock_content_password']));
906
907 $dimension = '';
908
909 $password_correct = isset($_COOKIE['password_correct_' . $client_id]) ? sanitize_text_field($_COOKIE['password_correct_' . $client_id]) : '';
910
911 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))){
912 $dimension = "width: {$settings['embedpress_elementor_document_width']['size']}{$settings['embedpress_elementor_document_width']['unit']}!important;height: {$settings['embedpress_elementor_document_height']['size']}px;";
913 }
914
915 $content_protection_class = 'ep-content-protection-enabled';
916 $content_locked_class = 'ep-content-locked';
917 if(empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || $hash_pass === $password_correct) {
918 $content_locked_class = '';
919 $content_protection_class = 'ep-content-protection-disabled';
920 }
921
922 $pass_hash_key = md5($settings['embedpress_pdf_lock_content_password']);
923 // Generate content ID for analytics tracking
924 $content_id = md5($url . 'pdf-elementor');
925
926 // Track PDF widget usage for analytics
927 $this->track_pdf_widget_usage($settings, $url, $content_id);
928
929 $this->add_render_attribute('embedpres-pdf-render', [
930 'class' => ['embedpress-embed-document-pdf', esc_attr($id)],
931 'data-emid' => esc_attr($id),
932 // 'data-embedpress-content' => esc_attr($content_id),
933 'data-embed-type' => 'PDF'
934 ]);
935 $this->add_render_attribute('embedpress-document', [
936 'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $unitoption, $content_locked_class ],
937 'data-thememode' => isset($settings['embedpress_theme_mode']) ? esc_attr($settings['embedpress_theme_mode']) : '',
938 'data-customcolor' => isset($custom_color) ? esc_attr($custom_color) : '',
939 'data-toolbar' => isset($settings['pdf_toolbar']) ? esc_attr($settings['pdf_toolbar']) : '',
940 'data-toolbar-position' => isset($settings['pdf_toolbar_position']) ? esc_attr($settings['pdf_toolbar_position']) : 'top',
941 'data-open' => 'no', // Assuming 'no' is a static value, no need to sanitize
942 'data-presentation-mode' => isset($settings['pdf_presentation_mode']) ? esc_attr($settings['pdf_presentation_mode']) : '',
943 'data-download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION') ? esc_attr($settings['pdf_print_download']) : 'yes', // Assuming 'yes' is a safe fallback
944 'data-copy' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION') ? esc_attr($settings['pdf_text_copy']) : 'yes', // Assuming 'yes' is a safe fallback
945 'data-add-image' => isset($settings['add_image']) ? esc_attr($settings['add_image']) : '',
946 'data-rotate' => isset($settings['pdf_rotate_access']) ? esc_attr($settings['pdf_rotate_access']) : '',
947 'data-details' => isset($settings['pdf_details']) ? esc_attr($settings['pdf_details']) : '',
948 'data-id' => $id, // Assuming $id is safe, no need to sanitize
949 'data-selection-tool' => isset($settings['selection_tool']) ? esc_attr($settings['selection_tool']) : '0',
950 'data-scrolling' => isset($settings['scrolling']) ? esc_attr($settings['scrolling']) : '-1',
951 'data-spreads' => isset($settings['spreads']) ? esc_attr($settings['spreads']) : '-1',
952 ]);
953
954 $embed_settings = [];
955 $embed_settings['customThumbnail'] = !empty($settings['embedpress_pdf_content_share_custom_thumbnail']['url']) ? esc_url($settings['embedpress_pdf_content_share_custom_thumbnail']['url']) : '';
956
957 $embed_settings['customTitle'] = !empty($settings['embedpress_pdf_content_title']) ? sanitize_text_field($settings['embedpress_pdf_content_title']) : Helper::get_file_title($url);
958
959 $embed_settings['customDescription'] = !empty($settings['embedpress_pdf_content_descripiton']) ? sanitize_text_field($settings['embedpress_pdf_content_descripiton']) : Helper::get_file_title($url);
960
961 $embed_settings['sharePosition'] = !empty($settings['embedpress_pdf_content_share_position']) ? sanitize_text_field($settings['embedpress_pdf_content_share_position']) : 'right';
962
963 // Add social share platform settings
964 $embed_settings['shareFacebook'] = !empty($settings['embedpress_pdf_share_facebook']) ? true : false;
965 $embed_settings['shareTwitter'] = !empty($settings['embedpress_pdf_share_twitter']) ? true : false;
966 $embed_settings['sharePinterest'] = !empty($settings['embedpress_pdf_share_pinterest']) ? true : false;
967 $embed_settings['shareLinkedin'] = !empty($settings['embedpress_pdf_share_linkedin']) ? true : false;
968
969 $embed_settings['lockHeading'] = !empty($settings['embedpress_pdf_lock_content_heading']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_heading']) : '';
970
971 $embed_settings['lockSubHeading'] = !empty($settings['embedpress_pdf_lock_content_sub_heading']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_sub_heading']) : '';
972
973 $embed_settings['lockErrorMessage'] = !empty($settings['embedpress_pdf_lock_content_error_message']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_error_message']) : '';
974
975 $embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_pdf_password_placeholder']) ? sanitize_text_field($settings['embedpress_pdf_password_placeholder']) : '';
976
977 $embed_settings['submitButtonText'] = !empty($settings['embedpress_pdf_submit_button_text']) ? sanitize_text_field($settings['embedpress_pdf_submit_button_text']) : '';
978
979 $embed_settings['submitUnlockingText'] = !empty($settings['embedpress_pdf_submit_Unlocking_text']) ? sanitize_text_field($settings['embedpress_pdf_submit_Unlocking_text']) : '';
980
981 $embed_settings['enableFooterMessage'] = !empty($settings['embedpress_pdf_enable_footer_message']) ? sanitize_text_field($settings['embedpress_pdf_enable_footer_message']) : '';
982
983 $embed_settings['footerMessage'] = !empty($settings['embedpress_pdf_lock_content_footer_message']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_footer_message']) : '';
984
985 $embed_settings['userRole'] = !empty($settings['embedpress_pdf_select_roles']) ? $settings['embedpress_pdf_select_roles'] : [];
986
987 $embed_settings['protectionMessage'] = !empty($settings['embedpress_pdf_protection_message']) ? $settings['embedpress_pdf_protection_message'] : '';
988
989
990 if($settings['embedpress_elementor_document_width']['unit'] === '%'){
991 $width_class = ' ep-percentage-width';
992 }
993 else{
994 $width_class = 'ep-fixed-width';
995 }
996 $content_share_class = '';
997 $share_position_class = '';
998 $share_position = isset($settings['embedpress_pdf_content_share_position']) ? $settings['embedpress_pdf_content_share_position'] : 'right';
999
1000 if(!empty($settings['embedpress_pdf_content_share'])) {
1001 $content_share_class = 'ep-content-share-enabled';
1002 $share_position_class = 'ep-share-position-'.$share_position;
1003 }
1004
1005 $adsAtts = '';
1006
1007 if (!empty($settings['adManager'])) {
1008 $ad = base64_encode(json_encode($settings)); // Using WordPress JSON encoding function
1009 $adsAtts = 'data-sponsored-id="' . esc_attr($client_id) . '" data-sponsored-attrs="' . esc_attr($ad) . '" class="sponsored-mask"';
1010 }
1011
1012 ?>
1013 <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style=" max-width:100%; display: inline-block">
1014
1015 <?php
1016 do_action('embedpress_pdf_after_embed', $settings, $url, $id, $this);
1017
1018 if ($url != '') {
1019 $url = esc_url($url);
1020
1021 if ($this->is_pdf($url) && !$this->is_external_url($url)) {
1022 $renderer = Helper::get_pdf_renderer();
1023 $src = $renderer . ((strpos($renderer, '?') === false) ? '?' : '&')
1024 . 'file=' . urlencode($url)
1025 . '&scrolling=' . $settings['scrolling']
1026 . '&selection_tool=' . $settings['selection_tool']
1027 . '&spreads=' . $settings['spreads']
1028 . $this->getParamData($settings);
1029
1030
1031 if (!empty($settings['embedpress_pdf_zoom'])) {
1032 $zoom = $settings['embedpress_pdf_zoom'];
1033 if ($zoom == 'custom') {
1034 if (!empty($settings['embedpress_pdf_zoom_custom'])) {
1035 $zoom = $settings['embedpress_pdf_zoom_custom'];
1036 } else {
1037 $zoom = null;
1038 }
1039 }
1040 if ($zoom) {
1041 $src = $src . "&zoom=$zoom";
1042 }
1043 }
1044
1045 if(isset($settings['embedpress_pdf_viewer_style']) && $settings['embedpress_pdf_viewer_style'] === 'modern') {
1046 $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_url($src).'"';
1047 }
1048 else{
1049 $src = urlencode($url).$this->getParamData($settings);
1050 $renderer = Helper::get_flipbook_renderer();
1051 $src_url = $renderer . ((strpos($renderer, '?') === false) ? '?' : '&') . 'file=' . $src;
1052 $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_url($src_url).'"';
1053 }
1054
1055
1056 $embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').' frameborder="0"></iframe>';
1057 if ($settings['embedpress_pdf_powered_by'] === 'yes') {
1058 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
1059 }
1060
1061 } else {
1062 $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).'"';
1063 $embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').'></iframe>';
1064
1065 if ($settings['embedpress_pdf_powered_by'] === 'yes') {
1066 $embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
1067 }
1068 }
1069
1070 ?>
1071
1072 <div <?php echo $adsAtts; ?>>
1073
1074 <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); ?>">
1075 <div id="<?php echo esc_attr( $this->get_id() ); ?>" class="ep-embed-content-wraper">
1076 <?php
1077 // Apply lazy loading if enabled (but not in editor mode)
1078 if (!empty($settings['enable_lazy_load']) && $settings['enable_lazy_load'] === 'yes' && !$is_editor_view) {
1079 $embed_content = preg_replace_callback(
1080 '/<iframe([^>]*)src=["\']([^"\']+)["\']([^>]*)>/i',
1081 function($matches) {
1082 $before = $matches[1];
1083 $src = $matches[2];
1084 $after = $matches[3];
1085
1086 // Extract style attribute if exists
1087 $style = '';
1088 if (preg_match('/style=["\']([^"\']+)["\']/i', $before . $after, $style_match)) {
1089 $style = $style_match[1];
1090 }
1091
1092 return sprintf(
1093 '<div class="ep-lazy-iframe-placeholder" data-ep-lazy-src="%s" data-ep-iframe-style="%s" %s %s style="%s"></div>',
1094 esc_attr($src),
1095 esc_attr($style),
1096 $before,
1097 $after,
1098 esc_attr($style)
1099 );
1100 },
1101 $embed_content
1102 );
1103 }
1104
1105 $embed = '<div>'.$embed_content.'</div>';
1106
1107 $content_id = $client_id;
1108 if(
1109
1110 (empty($settings['embedpress_pdf_lock_content']) || ($settings['embedpress_pdf_protection_type'] == 'password' && empty($settings['embedpress_pdf_lock_content_password'])) || $settings['embedpress_pdf_lock_content'] == 'no') ||
1111 ($settings['embedpress_pdf_protection_type'] == 'password' && !empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct) ) ||
1112 !apply_filters('embedpress/is_allow_rander', false) ||
1113 ($settings['embedpress_pdf_protection_type'] == 'user-role' && Helper::has_allowed_roles($embed_settings['userRole']))
1114
1115 ){
1116 if(!empty($settings['embedpress_pdf_content_share'])){
1117 $embed .= Helper::embed_content_share($content_id, $embed_settings);
1118 }
1119 echo $embed ;
1120
1121 } else {
1122 if(!empty($settings['embedpress_pdf_content_share'])){
1123 $embed .= Helper::embed_content_share($content_id, $embed_settings);
1124 }
1125
1126 if ($settings['embedpress_pdf_protection_type'] == 'password') {
1127 do_action('embedpress/display_password_form', $client_id, $embed, $pass_hash_key, $embed_settings);
1128 } else {
1129 do_action('embedpress/content_protection_content', $client_id, $embed_settings['protectionMessage'], $embed_settings['userRole']);
1130 }
1131 }
1132 ?>
1133 </div>
1134
1135 </div>
1136
1137
1138 <?php
1139 $isAdEnabled = !empty($settings['adManager']);
1140 $isContentUnlocked = empty($settings['embedpress_pdf_lock_content']);
1141 $isPasswordCorrect = Helper::is_password_correct($client_id) && ($hash_pass === $password_correct);
1142
1143 if ($isAdEnabled && ($isContentUnlocked || $isPasswordCorrect)) {
1144 $embed_content = apply_filters('embedpress/generate_ad_template', $embed_content, $client_id, $settings, 'elementor');
1145 }
1146 ?>
1147
1148 </div>
1149 <?php
1150
1151 }
1152 ?>
1153
1154 </div>
1155
1156 <?php
1157 }
1158
1159 private function get_file_url()
1160 {
1161 $settings = $this->get_settings();
1162 return $settings['embedpress_pdf_type'] === 'url' ? $settings['embedpress_pdf_file_link']['url'] : $settings['embedpress_pdf_Uploader']['url'];
1163 }
1164
1165 protected function is_external_url($url)
1166 {
1167 return strpos($url, get_site_url()) === false;
1168 }
1169
1170 /**
1171 * Track PDF widget usage for analytics
1172 *
1173 * @param array $settings
1174 * @param string $url
1175 * @param string $content_id
1176 * @return void
1177 */
1178 private function track_pdf_widget_usage($settings, $url, $content_id)
1179 {
1180 // Only track if analytics is enabled and we have the necessary classes
1181 if (class_exists('EmbedPress\Includes\Classes\Analytics\Analytics_Manager')) {
1182 if (empty($url)) {
1183 return;
1184 }
1185
1186 $provider_name = 'PDF';
1187
1188 $tracking_data = [
1189 'embed_type' => $provider_name,
1190 'embed_url' => $url,
1191 'post_id' => get_the_ID(),
1192 'page_url' => get_permalink(),
1193 'title' => get_the_title()
1194 ];
1195
1196 // Track content creation
1197 do_action('embedpress_content_embedded', $content_id, 'elementor-pdf', $tracking_data);
1198 }
1199 }
1200 }
1201