Changeset 2198016
- Timestamp:
- 11/21/2019 12:18:12 PM (6 years ago)
- Location:
- save-as-pdf/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (2 diffs)
-
restpack.js (modified) (1 diff)
-
save-as-pdf.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
save-as-pdf/trunk/readme.txt
r2196715 r2198016 4 4 Requires at least: 4.1 5 5 Tested up to: 5.2.1 6 Stable tag: 1. 76 Stable tag: 1.8 7 7 Requires PHP: 5.2.4 8 8 License: GNUGPLv3 … … 55 55 == Changelog == 56 56 57 = 1.8 = 58 * Improvements 59 57 60 = 1.7 = 58 61 * Minor -
save-as-pdf/trunk/restpack.js
r2196715 r2198016 7 7 x.parentNode.insertBefore(s, x); 8 8 })(window.document); 9 10 window.document.addEventListener("click", function (event) {11 if (event.target.classList.contains("restpack-api")) {12 event.preventDefault();13 var elem = event.target;14 15 var props = elem.getAttribute("data-props");16 17 document.body.style.cursor = "wait";18 var ajaxcallurl = window.ajaxcallurl || [window.location.protocol, '', window.location.host, 'wp-admin', 'admin-ajax.php'].join('/');19 20 fetch(ajaxcallurl, {21 method: "POST",22 body: "action=restpack_ajax",23 headers: {24 "Content-Type": "application/x-www-form-urlencoded;"25 }26 })27 .then(function (data) {28 document.body.style.cursor = "default";29 return data.json();30 })31 .then(function (data) {32 if (data.error || data.errors) return alert(data.error || JSON.stringify(data.errors));33 window.open(data.image);34 })35 .catch(function (error) {36 alert(error);37 });38 39 try {40 JSON.parse(props);41 } catch (e) { }42 43 console.log("clicked");44 }45 }); -
save-as-pdf/trunk/save-as-pdf.php
r2196715 r2198016 5 5 * Plugin URI: https://restpack.io/html2pdf 6 6 * Description: Allows visitors to save current page as PDF file 7 * Version: 1. 77 * Version: 1.8 8 8 * Text Domain: save-as-pdf 9 9 * Author: Restpack Inc … … 306 306 ); 307 307 308 add_settings_field($this->key("width"), 'Width', array(&$this, 'render_settings_field'), __FILE__, $third_section, array( 309 "key" => "width" 310 )); 311 308 312 add_settings_field( 309 313 $this->key("emulate_media"), … … 330 334 331 335 add_settings_field( 336 $this->key("form_data"), 337 'Get dynamic form data', 338 array(&$this, 'render_settings_field'), 339 __FILE__, 340 $third_section, 341 array( 342 "key" => "form_data" 343 ) 344 ); 345 346 add_settings_field( 332 347 $this->key("block_cookie_warnings"), 333 348 'Block EU cookie warning', … … 399 414 break; 400 415 416 417 case 'form_data': 401 418 case 'block_ads': 402 419 case 'block_cookie_warnings': … … 496 513 { 497 514 $options = get_option($this->key("options")); 515 516 $_props = array( 517 'pdf_page' => $options['pdf_page'], 518 "pdf_margins" => $options['pdf_margins'], 519 "pdf_header" => $options['pdf_header'], 520 "pdf_orientation" => $options['pdf_orientation'], 521 "pdf_footer" => $options['pdf_footer'], 522 "emulate_media" => $options['emulate_media'], 523 "js" => $options['js'], 524 "css" => $options['css'], 525 "block_cookie_warnings" => $options['block_cookie_warnings'], 526 "block_ads" => $options['block_ads'], 527 "filename" => $options['filename'], 528 "headers" => $options['http_headers'], 529 "access_token" => $options['api_key'], 530 'delay' => $options['delay'], 531 ); 532 533 if($options['form_data']) 534 $_props["private"] = true; 535 498 536 $props = shortcode_atts( 499 array( 500 'pdf_page' => $options['pdf_page'], 501 'pdf_orientation' => $options['pdf_orientation'], 502 'delay' => $options['delay'] 503 ), 537 array_filter($_props), 504 538 $attrs 505 539 ); 506 507 $have_key = $options['api_key'];508 540 509 541 $button_text = $options['button_text']; … … 514 546 $query = http_build_query($props); 515 547 516 return "<a class=\"restpack-button" . 517 ($have_key ? ' restpack-api' : '') . 518 "\" data-props=" . 519 json_encode($props) . 520 (!$have_key ? " href=\"https://restpack.io/html2pdf/save-as-pdf?" . $query . "\"" : " href='#'") . 521 "> 522 <img style='display: inline; width:" . 523 $options['button_width'] . 524 "' src='" . 525 plugin_dir_url(__FILE__) . 526 'assets/' . 527 $options['button_icon'] . 528 "' alt='" . 529 $button_text . 530 "' title='" . 531 $button_text . 532 "'/> 533 " . 534 $button_text . 535 "</a>"; 536 } 548 return "<a class=\"restpack-button\" href=\"https://restpack.io/html2pdf/save-as-pdf?" . $query . "\" data-props=" . json_encode($props) ."> 549 <img style='display: inline; width:" . $options['button_width'] . "' src='" . plugin_dir_url(__FILE__) . 'assets/' . $options['button_icon'] . "' alt='" . $button_text . "' title='" . $button_text . "'/> " . $button_text . "</a>"; 550 } 537 551 538 552 function restpack_ajax() … … 593 607 wp_die(); 594 608 } 609 610 595 611 function render_settings_page() 596 612 {
Note: See TracChangeset
for help on using the changeset viewer.