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