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_Pdf.php
594 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 | (defined('ABSPATH')) or die("No direct script access allowed."); |
| 13 | |
| 14 | class Embedpress_Pdf extends Widget_Base |
| 15 | { |
| 16 | |
| 17 | use Branding; |
| 18 | protected $pro_class = ''; |
| 19 | protected $pro_text = ''; |
| 20 | public function get_name() |
| 21 | { |
| 22 | return 'embedpress_pdf'; |
| 23 | } |
| 24 | |
| 25 | public function get_title() |
| 26 | { |
| 27 | return esc_html__('EmbedPress PDF', '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-pdf'; |
| 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', '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_content_settings', |
| 69 | [ |
| 70 | 'label' => esc_html__('Content Settings', 'embedpress'), |
| 71 | ] |
| 72 | ); |
| 73 | |
| 74 | $this->add_control( |
| 75 | 'embedpress_pdf_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_pdf_Uploader', |
| 89 | [ |
| 90 | 'label' => __('Upload File', 'embedpress'), |
| 91 | 'type' => Controls_Manager::MEDIA, |
| 92 | 'dynamic' => [ |
| 93 | 'active' => true, |
| 94 | 'categories' => [ |
| 95 | TagsModule::MEDIA_CATEGORY, |
| 96 | ], |
| 97 | ], |
| 98 | 'media_type' => [ |
| 99 | 'application/pdf', |
| 100 | ], |
| 101 | 'description' => __( |
| 102 | 'Upload a file or pick one from your media library for embed. Supported File Type: PDF', |
| 103 | 'embedpress' |
| 104 | ), |
| 105 | 'condition' => [ |
| 106 | 'embedpress_pdf_type' => 'file' |
| 107 | ], |
| 108 | ] |
| 109 | ); |
| 110 | |
| 111 | $this->add_control( |
| 112 | 'embedpress_pdf_file_link', |
| 113 | [ |
| 114 | 'label' => __('URL', 'embedpress'), |
| 115 | 'type' => Controls_Manager::URL, |
| 116 | 'placeholder' => __('https://your-link.com/file.pdf', 'embedpress'), |
| 117 | 'show_external' => false, |
| 118 | 'default' => [ |
| 119 | 'url' => '' |
| 120 | ], |
| 121 | 'condition' => [ |
| 122 | 'embedpress_pdf_type' => 'url' |
| 123 | ], |
| 124 | ] |
| 125 | ); |
| 126 | |
| 127 | $this->add_control( |
| 128 | 'embedpress_pdf_zoom', |
| 129 | [ |
| 130 | 'label' => __('Zoom', 'embedpress'), |
| 131 | 'type' => Controls_Manager::SELECT, |
| 132 | 'default' => 'auto', |
| 133 | 'options' => [ |
| 134 | 'auto' => __('Automatic Zoom', 'embedpress'), |
| 135 | 'page-actual' => __('Actual Size', 'embedpress'), |
| 136 | 'page-fit' => __('Page Fit', 'embedpress'), |
| 137 | 'page-width' => __('Page Width', 'embedpress'), |
| 138 | 'custom' => __('Custom', 'embedpress'), |
| 139 | '50' => __('50%', 'embedpress'), |
| 140 | '75' => __('75%', 'embedpress'), |
| 141 | '100' => __('100%', 'embedpress'), |
| 142 | '125' => __('125%', 'embedpress'), |
| 143 | '150' => __('150%', 'embedpress'), |
| 144 | '200' => __('200%', 'embedpress'), |
| 145 | '300' => __('300%', 'embedpress'), |
| 146 | '400' => __('400%', 'embedpress'), |
| 147 | ], |
| 148 | ] |
| 149 | ); |
| 150 | $this->add_control( |
| 151 | 'embedpress_pdf_zoom_custom', |
| 152 | [ |
| 153 | 'label' => __('Custom Zoom', 'embedpress'), |
| 154 | 'type' => Controls_Manager::NUMBER, |
| 155 | 'condition' => [ |
| 156 | 'embedpress_pdf_zoom' => 'custom' |
| 157 | ], |
| 158 | ] |
| 159 | ); |
| 160 | |
| 161 | $this->add_control( |
| 162 | 'embedpress_elementor_document_width', |
| 163 | [ |
| 164 | 'label' => __('Width', 'embedpress'), |
| 165 | 'type' => Controls_Manager::SLIDER, |
| 166 | 'separator' => 'before', |
| 167 | 'size_units' => [ 'px', '%' ], |
| 168 | 'default' => [ |
| 169 | 'unit' => 'px', |
| 170 | 'size' => 600, |
| 171 | ], |
| 172 | 'range' => [ |
| 173 | '%' => [ |
| 174 | 'min' => 0, |
| 175 | 'max' => 100, |
| 176 | ], |
| 177 | 'px' => [ |
| 178 | 'min' => 6, |
| 179 | 'max' => 1000, |
| 180 | ], |
| 181 | ], |
| 182 | 'selectors' => [ |
| 183 | '{{WRAPPER}} .embedpress-document-embed iframe' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%', |
| 184 | '{{WRAPPER}} .embedpress-document-embed' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%', |
| 185 | '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'width: {{SIZE}}{{UNIT}} !important; max-width: 100%', |
| 186 | ], |
| 187 | 'render_type' => 'template', |
| 188 | ] |
| 189 | ); |
| 190 | |
| 191 | $this->add_control( |
| 192 | 'embedpress_elementor_document_height', |
| 193 | [ |
| 194 | 'label' => __('Height', 'embedpress'), |
| 195 | 'type' => Controls_Manager::SLIDER, |
| 196 | 'default' => [ |
| 197 | 'unit' => 'px', |
| 198 | 'size' => 600, |
| 199 | ], |
| 200 | 'range' => [ |
| 201 | 'px' => [ |
| 202 | 'min' => 6, |
| 203 | 'max' => 1000, |
| 204 | ], |
| 205 | ], |
| 206 | 'selectors' => [ |
| 207 | '{{WRAPPER}} .embedpress-document-embed iframe' => 'height: {{SIZE}}{{UNIT}};', |
| 208 | '{{WRAPPER}} .embedpress-document-embed .pdfobject-container' => 'height: {{SIZE}}{{UNIT}};', |
| 209 | ], |
| 210 | 'render_type' => 'template', |
| 211 | ] |
| 212 | ); |
| 213 | |
| 214 | $this->add_responsive_control( |
| 215 | 'embedpress_elementor_document_align', |
| 216 | [ |
| 217 | 'label' => __('Alignment', 'embedpress'), |
| 218 | 'type' => Controls_Manager::CHOOSE, |
| 219 | 'options' => [ |
| 220 | 'left' => [ |
| 221 | 'title' => __('Left', 'embedpress'), |
| 222 | 'icon' => 'eicon-text-align-left', |
| 223 | ], |
| 224 | 'center' => [ |
| 225 | 'title' => __('Center', 'embedpress'), |
| 226 | 'icon' => 'eicon-text-align-center', |
| 227 | ], |
| 228 | 'right' => [ |
| 229 | 'title' => __('Right', 'embedpress'), |
| 230 | 'icon' => 'eicon-text-align-right', |
| 231 | ] |
| 232 | ], |
| 233 | 'prefix_class' => 'elementor%s-align-', |
| 234 | 'default' => '', |
| 235 | ] |
| 236 | ); |
| 237 | |
| 238 | $this->add_control( |
| 239 | 'embedpress_pdf_powered_by', |
| 240 | [ |
| 241 | 'label' => __('Powered By', 'embedpress'), |
| 242 | 'type' => Controls_Manager::SWITCHER, |
| 243 | 'label_on' => __('Show', 'embedpress'), |
| 244 | 'label_off' => __('Hide', 'embedpress'), |
| 245 | 'return_value' => 'yes', |
| 246 | 'default' => apply_filters('embedpress_document_powered_by_control', 'yes'), |
| 247 | ] |
| 248 | ); |
| 249 | |
| 250 | $this->init_branding_controls('document'); |
| 251 | |
| 252 | $this->end_controls_section(); |
| 253 | |
| 254 | |
| 255 | /** |
| 256 | * EmbedPress PDF Control Settings |
| 257 | */ |
| 258 | |
| 259 | $this->start_controls_section( |
| 260 | 'embedpress_pdf_content_settings', |
| 261 | [ |
| 262 | 'label' => esc_html__('PDF Control Settings', 'embedpress'), |
| 263 | 'condition' => [ |
| 264 | 'embedpress_pdf_type' => 'file' |
| 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_pdf_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 | 'pdf_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 | 'pdf_toolbar_position', |
| 311 | [ |
| 312 | 'label' => esc_html__('Toolbar Position', 'embedpress'), |
| 313 | 'type' => \Elementor\Controls_Manager::CHOOSE, |
| 314 | 'options' => [ |
| 315 | 'top' => [ |
| 316 | 'title' => esc_html__('Top', 'embedpress'), |
| 317 | 'icon' => 'eicon-arrow-up', |
| 318 | ], |
| 319 | 'bottom' => [ |
| 320 | 'title' => esc_html__('Bottom', 'embedpress'), |
| 321 | 'icon' => 'eicon-arrow-down', |
| 322 | ], |
| 323 | ], |
| 324 | 'default' => 'top', |
| 325 | 'toggle' => true, |
| 326 | 'condition' => [ |
| 327 | 'pdf_toolbar' => 'yes', |
| 328 | ], |
| 329 | ] |
| 330 | ); |
| 331 | |
| 332 | |
| 333 | $this->add_control( |
| 334 | 'pdf_presentation_mode', |
| 335 | [ |
| 336 | 'label' => __('PDF Presentation Mode', 'embedpress'), |
| 337 | 'type' => Controls_Manager::SWITCHER, |
| 338 | 'label_on' => __('Show', 'embedpress'), |
| 339 | 'label_off' => __('Hide', 'embedpress'), |
| 340 | 'return_value' => 'yes', |
| 341 | 'default' => 'yes', |
| 342 | 'condition' => [ |
| 343 | 'pdf_toolbar' => 'yes', |
| 344 | ], |
| 345 | ] |
| 346 | ); |
| 347 | |
| 348 | $this->add_control( |
| 349 | 'pdf_print_download', |
| 350 | [ |
| 351 | 'label' => sprintf(__('Print/Download %s', 'embedpress'), $this->pro_text), |
| 352 | 'type' => Controls_Manager::SWITCHER, |
| 353 | 'label_on' => __('Show', 'embedpress'), |
| 354 | 'label_off' => __('Hide', 'embedpress'), |
| 355 | 'return_value' => 'yes', |
| 356 | 'default' => 'yes', |
| 357 | 'classes' => $this->pro_class, |
| 358 | 'condition' => [ |
| 359 | 'pdf_toolbar' => 'yes', |
| 360 | ], |
| 361 | ] |
| 362 | ); |
| 363 | $this->add_control( |
| 364 | 'pdf_text_copy', |
| 365 | [ |
| 366 | 'label' => sprintf(__('Copy Text %s', 'embedpress'), $this->pro_text), |
| 367 | 'type' => Controls_Manager::SWITCHER, |
| 368 | 'label_on' => __('Show', 'embedpress'), |
| 369 | 'label_off' => __('Hide', 'embedpress'), |
| 370 | 'return_value' => 'yes', |
| 371 | 'default' => 'yes', |
| 372 | 'classes' => $this->pro_class, |
| 373 | 'condition' => [ |
| 374 | 'pdf_toolbar' => 'yes', |
| 375 | ], |
| 376 | ] |
| 377 | ); |
| 378 | |
| 379 | $this->add_control( |
| 380 | 'add_text', |
| 381 | [ |
| 382 | 'label' => sprintf(__('Add Text', 'embedpress')), |
| 383 | 'type' => Controls_Manager::SWITCHER, |
| 384 | 'label_on' => __('Show', 'embedpress'), |
| 385 | 'label_off' => __('Hide', 'embedpress'), |
| 386 | 'return_value' => 'yes', |
| 387 | 'default' => 'yes', |
| 388 | 'condition' => [ |
| 389 | 'pdf_toolbar' => 'yes', |
| 390 | ], |
| 391 | ] |
| 392 | ); |
| 393 | $this->add_control( |
| 394 | 'draw', |
| 395 | [ |
| 396 | 'label' => sprintf(__('Draw %s', 'embedpress'), $this->pro_text), |
| 397 | 'type' => Controls_Manager::SWITCHER, |
| 398 | 'label_on' => __('Show', 'embedpress'), |
| 399 | 'label_off' => __('Hide', 'embedpress'), |
| 400 | 'return_value' => 'yes', |
| 401 | 'default' => 'yes', |
| 402 | 'classes' => $this->pro_class, |
| 403 | 'condition' => [ |
| 404 | 'pdf_toolbar' => 'yes', |
| 405 | ], |
| 406 | ] |
| 407 | ); |
| 408 | |
| 409 | $this->add_control( |
| 410 | 'pdf_rotate_access', |
| 411 | [ |
| 412 | 'label' => __('Rotation', 'embedpress'), |
| 413 | 'type' => Controls_Manager::SWITCHER, |
| 414 | 'label_on' => __('Show', 'embedpress'), |
| 415 | 'label_off' => __('Hide', 'embedpress'), |
| 416 | 'return_value' => 'yes', |
| 417 | 'default' => 'yes', |
| 418 | 'condition' => [ |
| 419 | 'pdf_toolbar' => 'yes', |
| 420 | ], |
| 421 | ] |
| 422 | ); |
| 423 | |
| 424 | $this->add_control( |
| 425 | 'pdf_details', |
| 426 | [ |
| 427 | 'label' => __('Properties', 'embedpress'), |
| 428 | 'type' => Controls_Manager::SWITCHER, |
| 429 | 'label_on' => __('Show', 'embedpress'), |
| 430 | 'label_off' => __('Hide', 'embedpress'), |
| 431 | 'return_value' => 'yes', |
| 432 | 'default' => 'yes', |
| 433 | 'condition' => [ |
| 434 | 'pdf_toolbar' => 'yes', |
| 435 | ], |
| 436 | ] |
| 437 | ); |
| 438 | |
| 439 | $this->end_controls_section(); |
| 440 | |
| 441 | |
| 442 | if (!is_embedpress_pro_active()) { |
| 443 | $this->start_controls_section( |
| 444 | 'embedpress_pro_section', |
| 445 | [ |
| 446 | 'label' => __('Go Premium for More Features', 'embedpress'), |
| 447 | ] |
| 448 | ); |
| 449 | |
| 450 | $this->add_control( |
| 451 | 'embedpress_pro_cta', |
| 452 | [ |
| 453 | 'label' => __('Unlock more possibilities', 'embedpress'), |
| 454 | 'type' => Controls_Manager::CHOOSE, |
| 455 | 'options' => [ |
| 456 | '1' => [ |
| 457 | 'title' => '', |
| 458 | 'icon' => 'eicon-lock', |
| 459 | ], |
| 460 | ], |
| 461 | 'default' => '1', |
| 462 | '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>', |
| 463 | ] |
| 464 | ); |
| 465 | |
| 466 | $this->end_controls_section(); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | private function is_pdf($url) |
| 471 | { |
| 472 | $arr = explode('.', $url); |
| 473 | return end($arr) === 'pdf'; |
| 474 | } |
| 475 | |
| 476 | protected function render() |
| 477 | { |
| 478 | $settings = $this->get_settings(); |
| 479 | $url = $this->get_file_url(); |
| 480 | $id = $this->get_id(); |
| 481 | $this->_render($url, $settings, $id); |
| 482 | |
| 483 | Helper::get_source_data(md5($this->get_id()).'_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data'); |
| 484 | } |
| 485 | |
| 486 | public function getParamData($settings){ |
| 487 | $urlParamData = array( |
| 488 | 'themeMode' => $settings['embedpress_theme_mode'], |
| 489 | 'toolbar' => !empty($settings['pdf_toolbar']) ? 'true' : 'false', |
| 490 | 'position' => $settings['pdf_toolbar_position'], |
| 491 | 'presentation' => !empty($settings['pdf_presentation_mode']) ? 'true' : 'false', |
| 492 | 'download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'true', |
| 493 | 'copy_text' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'true', |
| 494 | 'add_text' => !empty($settings['add_text']) ? 'true' : 'false', |
| 495 | 'draw' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['draw'] : 'true', |
| 496 | 'doc_rotation' => !empty($settings['pdf_rotate_access']) ? 'true' : 'false', |
| 497 | 'doc_details' => !empty($settings['pdf_details']) ? 'true' : 'false', |
| 498 | ); |
| 499 | |
| 500 | if($settings['embedpress_theme_mode'] == 'custom') { |
| 501 | $urlParamData['customColor'] = $settings['embedpress_pdf_custom_color']; |
| 502 | } |
| 503 | |
| 504 | if($settings['embedpress_pdf_type'] == 'file'){ |
| 505 | return "#" .http_build_query($urlParamData) ; |
| 506 | } |
| 507 | return ''; |
| 508 | |
| 509 | } |
| 510 | |
| 511 | public function _render($url, $settings, $id) |
| 512 | { |
| 513 | $unitoption = 'emebedpress-unit-px'; |
| 514 | if($settings['embedpress_elementor_document_width']['unit'] === '%'){ |
| 515 | $unitoption = 'emebedpress-unit-percent'; |
| 516 | } |
| 517 | $id = 'embedpress-pdf-' . $id; |
| 518 | $dimension = "width: {$settings['embedpress_elementor_document_width']['size']}{$settings['embedpress_elementor_document_width']['unit']};height: {$settings['embedpress_elementor_document_height']['size']}px"; |
| 519 | $this->add_render_attribute('embedpres-pdf-render', [ |
| 520 | 'class' => ['embedpress-embed-document-pdf', $id], |
| 521 | 'data-emid' => $id |
| 522 | ]); |
| 523 | $this->add_render_attribute('embedpress-document', [ |
| 524 | 'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $unitoption ], |
| 525 | 'data-thememode' => $settings['embedpress_theme_mode'], |
| 526 | 'data-customcolor' => $settings['embedpress_pdf_custom_color'], |
| 527 | 'data-toolbar' => $settings['pdf_toolbar'], |
| 528 | 'data-toolbar-position' => $settings['pdf_toolbar_position'], |
| 529 | 'data-open' => 'no', |
| 530 | 'data-presentation-mode' => $settings['pdf_presentation_mode'], |
| 531 | 'data-download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'yes', |
| 532 | 'data-copy' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'yes', |
| 533 | 'data-rotate' => $settings['pdf_rotate_access'], |
| 534 | 'data-details' => $settings['pdf_details'], |
| 535 | 'data-id' => $id |
| 536 | ]); |
| 537 | ?> |
| 538 | <div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block"> |
| 539 | <?php |
| 540 | do_action('embedpress_pdf_after_embed', $settings, $url, $id, $this); |
| 541 | ?> |
| 542 | <?php if ($url != '') { |
| 543 | if ($this->is_pdf($url) && !$this->is_external_url($url)) { |
| 544 | $this->add_render_attribute('embedpres-pdf-render', 'data-emsrc', $url); |
| 545 | $renderer = Helper::get_pdf_renderer(); |
| 546 | $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($url).$this->getParamData($settings); |
| 547 | if (!empty($settings['embedpress_pdf_zoom'])) { |
| 548 | $zoom = $settings['embedpress_pdf_zoom']; |
| 549 | if ($zoom == 'custom') { |
| 550 | if (!empty($settings['embedpress_pdf_zoom_custom'])) { |
| 551 | $zoom = $settings['embedpress_pdf_zoom_custom']; |
| 552 | } else { |
| 553 | $zoom = null; |
| 554 | } |
| 555 | } |
| 556 | if ($zoom) { |
| 557 | $src = $src . "&zoom=$zoom"; |
| 558 | } |
| 559 | } |
| 560 | ?> |
| 561 | <iframe title="<?php echo esc_attr(Helper::get_file_title($url)); ?>" class="embedpress-embed-document-pdf <?php echo esc_attr($id); ?>" style="<?php echo esc_attr($dimension); ?>; max-width:100%; display: inline-block" src="<?php echo esc_attr($src); ?>" <?php $this->get_render_attribute_string('embedpres-pdf-render'); ?> frameborder="0"></iframe> |
| 562 | <?php |
| 563 | |
| 564 | } else { |
| 565 | ?> |
| 566 | <div> |
| 567 | <iframe title="<?php echo esc_attr(Helper::get_file_title($url)); ?>" class="embedpress-embed-document-pdf <?php echo esc_attr($id); ?>" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="<?php echo esc_attr($dimension); ?>; max-width:100%;" src="<?php echo esc_url($url); ?>" <?php $this->get_render_attribute_string('embedpres-pdf-render'); ?>></iframe> |
| 568 | </div> |
| 569 | |
| 570 | <?php |
| 571 | } |
| 572 | if ($settings['embedpress_pdf_powered_by'] === 'yes') { |
| 573 | |
| 574 | printf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress')); |
| 575 | } |
| 576 | } |
| 577 | ?> |
| 578 | </div> |
| 579 | |
| 580 | <?php |
| 581 | } |
| 582 | |
| 583 | private function get_file_url() |
| 584 | { |
| 585 | $settings = $this->get_settings(); |
| 586 | return $settings['embedpress_pdf_type'] === 'url' ? $settings['embedpress_pdf_file_link']['url'] : $settings['embedpress_pdf_Uploader']['url']; |
| 587 | } |
| 588 | |
| 589 | protected function is_external_url($url) |
| 590 | { |
| 591 | return strpos($url, get_site_url()) === false; |
| 592 | } |
| 593 | } |
| 594 |