Changeset 3122938
- Timestamp:
- 07/22/2024 07:47:21 AM (20 months ago)
- Location:
- verge3d/trunk
- Files:
-
- 3 added
- 7 edited
-
app.php (modified) (2 diffs)
-
css/admin.css (modified) (1 diff)
-
file_storage.php (modified) (6 diffs)
-
js/order.js (modified) (2 diffs)
-
order.php (modified) (17 diffs)
-
readme.txt (modified) (2 diffs)
-
send_form.php (added)
-
templates/send_form_email_body.php (added)
-
utils.php (added)
-
verge3d.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
verge3d/trunk/app.php
r3054421 r3122938 1 1 <?php 2 2 3 define('V3D_DEFAULT_CANVAS_WIDTH', 800); 4 define('V3D_DEFAULT_CANVAS_HEIGHT', 500); 3 require_once plugin_dir_path(__FILE__) . 'utils.php'; 5 4 6 5 if (!class_exists('WP_List_Table')){ 7 6 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); 8 7 } 8 9 const V3D_DEFAULT_CANVAS_WIDTH = 800; 10 const V3D_DEFAULT_CANVAS_HEIGHT = 500; 9 11 10 12 function v3d_app_menu() { … … 632 634 633 635 // prevent harmful file types to be uploaded to the server 634 $allowed_mimes = get_allowed_mime_types(); 635 636 $v3d_mimes = get_option('v3d_upload_mime_types'); 637 if (!empty($v3d_mimes)) { 638 foreach (explode(PHP_EOL, $v3d_mimes) as $line) { 639 $line = wp_strip_all_tags($line); 640 $line_split = preg_split('/ +/', $line, null, PREG_SPLIT_NO_EMPTY); 641 642 if (count($line_split) != 2) 643 continue; 644 645 $mime = trim($line_split[0]); 646 $ext = trim($line_split[1]); 647 648 if (!empty($mime) && !empty($ext)) 649 $allowed_mimes[$ext] = $mime; 650 } 651 } 652 653 $validate = wp_check_filetype($fullpath, $allowed_mimes); 636 $validate = wp_check_filetype($fullpath, v3d_get_allowed_mime_types()); 654 637 if ($validate['type'] === false) { 655 638 wp_die('error'); -
verge3d/trunk/css/admin.css
r3019209 r3122938 57 57 } 58 58 59 .dialog- quote-sent {59 .dialog-email-sent { 60 60 padding: 15px; 61 61 } 62 62 63 .dialog- quote-sent button.button {63 .dialog-email-sent button.button { 64 64 display: block; 65 65 margin: 0px auto; -
verge3d/trunk/file_storage.php
r2995028 r3122938 1 1 <?php 2 3 require_once plugin_dir_path(__FILE__) . 'utils.php'; 2 4 3 5 const FILES_SUBDIR = 'files/'; 4 6 5 7 function v3d_api_upload_file(WP_REST_Request $request) { 8 $response = new WP_REST_Response(); 9 $error_msg = ''; 6 10 7 if (!empty($request->get_body())) {11 $data = $request->get_body(); 8 12 9 $upload_dir = v3d_get_upload_dir().FILES_SUBDIR; 13 if (!empty($data)) { 14 $upload_dir = v3d_get_upload_dir() . FILES_SUBDIR; 10 15 if (!is_dir($upload_dir)) { 11 16 mkdir($upload_dir, 0777, true); 12 17 } 13 18 14 $id = time(); 19 $id = v3d_unique_filename(); 20 $filename = $upload_dir.$id; 21 $mime = $request->get_content_type()['value']; 15 22 16 $filename = $upload_dir.$id.'.json'; 17 $success = file_put_contents($filename, $request->get_body()); 18 19 if ($success) 20 $response = new WP_REST_Response(array( 21 'id' => $id, 22 'link' => rest_url('verge3d/v1/get_file/'.$id), 23 'size' => filesize($filename) 24 )); 25 else 26 $response = new WP_REST_Response(array('error' => 'Unable to store file'), 500); 23 if (v3d_check_mime($mime)) { 24 $success = file_put_contents($filename, v3d_create_data_url($mime, $data)); 25 if ($success) 26 $response->set_data(array( 27 'status' => 'ok', 28 'statusText' => 'Yay! File uploaded successfully.', 29 'id' => $id, 30 'link' => rest_url('verge3d/v1/get_file/'.$id), 31 'size' => strlen($data) 32 )); 33 else 34 $error_msg = 'Oh no! Could not save file on the server.'; 35 } else 36 $error_msg = 'Upload error, MIME type is not allowed: ' . $mime; 27 37 28 38 } else { 29 $response = new WP_REST_Response(array('error' => 'Bad request'), 400); 39 $error_msg = 'Upload error, file is empty'; 40 } 41 42 if ($error_msg !== '') { 43 $response->set_data(array( 44 'status' => 'error', 45 'statusText' => $error_msg 46 )); 47 $response->set_status(400); 30 48 } 31 49 … … 34 52 35 53 return $response; 36 37 54 } 38 55 39 56 function v3d_api_get_file(WP_REST_Request $request) { 40 57 41 $id = intval($request->get_param('id')); 58 $response = new WP_REST_Response(); 59 $error_msg = ''; 60 61 $id = $request->get_param('id'); 42 62 43 63 if (!empty($id)) { 64 $upload_dir = v3d_get_upload_dir() . FILES_SUBDIR; 44 65 45 $upload_dir = v3d_get_upload_dir().FILES_SUBDIR; 46 $file = $upload_dir.$id.'.json'; 66 $file = $upload_dir.$id; 67 68 // COMPAT: < 4.7 69 $compat_json_storage = false; 70 if (!is_file($file)) { 71 $file = $file.'.json'; 72 $compat_json_storage = true; 73 } 47 74 48 75 if (is_file($file)) { 49 // hack to prevent excessive JSON encoding 50 header('Content-Type: text/plain'); 51 if (get_option('v3d_cross_domain')) 52 header('Access-Control-Allow-Origin: *'); 53 print_r(file_get_contents($file)); 54 exit(); 76 $data = file_get_contents($file); 77 78 if (!$compat_json_storage) { 79 $parsed = v3d_parse_data_url($data); 80 $mime = $parsed['mime']; 81 82 if (v3d_check_mime($mime)) { 83 $response->header('Content-Type', $mime); 84 $response->set_data($parsed['data']); 85 } else 86 $error_msg = 'MIME type is not allowed: ' . $mime; 87 } else { 88 // hack to prevent JSON decoding of base64-encoded strings 89 $response->header('Content-Type', 'text/plain'); 90 $response->set_data($data); 91 } 92 93 if ($error_msg === '') 94 add_filter('rest_pre_serve_request', 'v3d_api_get_file_response', 20, 2); 95 55 96 } else 56 $ response = new WP_REST_Response(array('error' => 'File not found'), 500);97 $error_msg = 'File not found'; 57 98 58 99 } else { 100 $error_msg = 'Bad request'; 101 } 59 102 60 $response = new WP_REST_Response(array('error' => 'Bad request'), 400); 61 103 if ($error_msg !== '') { 104 $response->set_data(array( 105 'status' => 'error', 106 'statusText' => $error_msg 107 )); 108 $response->set_status(400); 62 109 } 63 110 … … 66 113 67 114 return $response; 115 } 68 116 117 function v3d_api_get_file_response($served, $result) { 118 $data = $result->get_data(); 119 120 if (is_string($data)) { 121 echo $data; 122 return true; 123 } 124 125 return $served; 69 126 } 70 127 … … 78 135 )); 79 136 80 register_rest_route('verge3d/v1', '/get_file/(?P<id>\ d+)', array(137 register_rest_route('verge3d/v1', '/get_file/(?P<id>\w+)', array( 81 138 'methods' => 'GET', 82 139 'callback' => 'v3d_api_get_file', … … 84 141 'id' => array( 85 142 'validate_callback' => function($param, $request, $key) { 86 return is_numeric($param); 143 // allow hex numbers 144 return (trim($param, '0..9A..Fa..f') === ''); 87 145 } 88 146 ), … … 91 149 )); 92 150 } 93 94 151 }); -
verge3d/trunk/js/order.js
r2773896 r3122938 199 199 } 200 200 201 function send_pdf_cb(pdftype) {201 async function send_pdf_cb(pdftype) { 202 202 const form_data = new FormData(); 203 203 form_data.append('action', 'v3d_ajax_send_pdf'); … … 205 205 form_data.append('pdftype', pdftype); 206 206 207 const req = new XMLHttpRequest(); 208 req.open('POST', ajax_object.ajax_url); 209 req.send(form_data); 210 req.addEventListener('load', function() { 211 const response = JSON.parse(req.response); 212 document.getElementById(`${pdftype}_sent`).style.display = 'flex'; 213 }); 214 } 215 216 function quote_sent_close_cb() { 217 document.getElementById('quote_sent').style.display = 'none'; 218 } 219 220 function invoice_sent_close_cb() { 221 document.getElementById('invoice_sent').style.display = 'none'; 207 const options = { 208 method: 'POST', 209 body: form_data 210 } 211 212 let info; 213 214 try { 215 const response = await fetch(ajax_object.ajax_url, options); 216 if (!response.ok) 217 info = 'Failed to make request'; 218 else 219 info = (await response.json()).statusText; 220 } catch (e) { 221 info = 'Failed to make request'; 222 } 223 224 document.querySelector('#dialog-email-sent').style.display = 'flex'; 225 document.querySelector('#dialog-email-sent div.dialog-heading').textContent = info; 226 } 227 228 function email_sent_close_cb() { 229 document.querySelector('#dialog-email-sent').style.display = 'none'; 222 230 } 223 231 -
verge3d/trunk/order.php
r3054421 r3122938 1 1 <?php 2 2 3 require_once plugin_dir_path(__FILE__) . 'utils.php'; 4 3 5 if (!class_exists('WP_List_Table')){ 4 require_once (ABSPATH . 'wp-admin/includes/class-wp-list-table.php');6 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; 5 7 } 6 8 … … 92 94 case 'genpdf': 93 95 if (!empty($_REQUEST['order'])) { 94 ob_end_clean();95 96 96 $order_id = intval($_REQUEST['order']); 97 97 $order = v3d_get_order_by_id($order_id); … … 100 100 $attachments = v3d_gen_email_attachments($order, $order_id, false, [$pdftype]); 101 101 102 header('Content-Description: File Transfer'); 103 header('Content-Type: application/pdf'); 104 header('Content-Disposition: attachment; filename="'.$pdftype.'.pdf"'); 105 header('Expires: 0'); 106 header('Cache-Control: must-revalidate'); 107 header('Pragma: public'); 108 header('Content-Length: ' . filesize($attachments[0])); 109 110 readfile($attachments[0]); 102 if (!empty($attachments)) { 103 ob_end_clean(); 104 105 header('Content-Description: File Transfer'); 106 header('Content-Type: application/pdf'); 107 header('Content-Disposition: attachment; filename="'.$pdftype.'.pdf"'); 108 header('Expires: 0'); 109 header('Cache-Control: must-revalidate'); 110 header('Pragma: public'); 111 header('Content-Length: ' . filesize($attachments[0])); 112 113 readfile($attachments[0]); 114 die(); 115 } else { 116 wp_die('Failed to generate PDF file, possibly due to missing Chrome/Chromium'); 117 } 111 118 112 119 v3d_cleanup_email_attachments($attachments); 113 } 120 } else { 121 wp_die('Bad request'); 122 } 123 break; 114 124 default: 115 125 $orderTable = new V3D_Order_List_Table(); … … 293 303 294 304 $attachments = array(); 305 $error_msg = ''; 295 306 296 307 $send_me = !empty($order_email) && $notify_type != 'quote' && $notify_type != 'invoice' && get_option("v3d_order_email_{$notify_type}_notify"); … … 324 335 325 336 $attachments = v3d_gen_email_attachments($order, $order_id, $att_custom, $pdftypes); 326 } 327 328 if ($send_me) { 337 338 // quote/invoice mails require PDF attachments to be present 339 if (($notify_type == 'quote' || $notify_type == 'invoice') && empty($attachments)) { 340 $error_msg = 'Failed to generate PDF file, possibly due to missing Chrome/Chromium'; 341 } 342 } 343 344 if ($send_me && !$error_msg) { 329 345 $to = $order_email; 330 346 $subject = get_option("v3d_order_email_{$notify_type}_subject"); … … 334 350 $body = ob_get_clean(); 335 351 336 wp_mail($to, $subject, $body, $headers, $attachments); 337 } 338 339 if ($send_user) { 352 if (!wp_mail($to, $subject, $body, $headers, $attachments)) 353 $error_msg = 'Unable to send email'; 354 } 355 356 if ($send_user && !$error_msg) { 340 357 $to = $order['user_email']; 341 358 $subject = get_option("v3d_order_email_{$notify_type}_subject_user"); … … 345 362 $body = ob_get_clean(); 346 363 347 wp_mail($to, $subject, $body, $headers, $attachments);348 //file_put_contents('/var/www/wordpress/mail.html', $body);364 if (!wp_mail($to, $subject, $body, $headers, $attachments)) 365 $error_msg = 'Unable to send email'; 349 366 } 350 367 351 368 v3d_cleanup_email_attachments($attachments); 369 370 return array( 371 'status' => empty($error_msg) ? 'ok' : 'error', 372 'statusText' => empty($error_msg) ? 'Email sent successfully' : $error_msg 373 ); 352 374 } 353 375 … … 411 433 412 434 return ''; 413 }414 415 function v3d_get_attachments_tmp_dir($attachments) {416 if (empty($attachments)) {417 $temp_dir = get_temp_dir().uniqid('v3d_email_att');418 mkdir($temp_dir, 0777, true);419 return $temp_dir.'/';420 } else {421 return dirname($attachments[0]).'/';422 }423 435 } 424 436 … … 454 466 455 467 if ($success) { 456 // NOTE: undocumented wkhtmltopdf feature 457 if (basename($chrome_path) == 'wkhtmltopdf') 458 v3d_terminal($chrome_path.' -s Letter --print-media-type '.$pdf_html.' '.escapeshellarg($pdf)); 459 else 460 v3d_terminal($chrome_path.' --headless --disable-gpu --print-to-pdf='.escapeshellarg($pdf).' '.$pdf_html); 461 468 v3d_terminal($chrome_path.' --headless --disable-gpu --print-to-pdf='.escapeshellarg($pdf).' '.$pdf_html); 462 469 if (is_file($pdf)) 463 470 $attachments[] = $pdf; … … 727 734 </div> 728 735 729 <div class="dialog-bg" id=" quote_sent">730 <div class="dialog dialog- quote-sent">731 <div class="dialog-heading"> Quote sent successfully</div>736 <div class="dialog-bg" id="dialog-email-sent"> 737 <div class="dialog dialog-email-sent"> 738 <div class="dialog-heading"></div> 732 739 <div class="dialog-buttons"> 733 <button onclick="quote_sent_close_cb()" class="button">OK</button> 734 </div> 735 </div> 736 </div> 737 738 <div class="dialog-bg" id="invoice_sent"> 739 <div class="dialog dialog-quote-sent"> 740 <div class="dialog-heading">Invoice sent successfully</div> 741 <div class="dialog-buttons"> 742 <button onclick="invoice_sent_close_cb()" class="button">OK</button> 740 <button onclick="email_sent_close_cb()" class="button">OK</button> 743 741 </div> 744 742 </div> … … 1574 1572 } 1575 1573 1576 function v3d_parse_data_url($data_url) {1577 if (substr($data_url, 0, 5) == 'data:') {1578 $data_url = str_replace(' ', '+', $data_url);1579 $mime_start = strpos($data_url, ':') + 1;1580 $mime_length = strpos($data_url, ';') - $mime_start;1581 return array(1582 'mime' => substr($data_url, $mime_start, $mime_length),1583 'data' => base64_decode(substr($data_url, strpos($data_url, ',') + 1))1584 );1585 } else {1586 return null;1587 }1588 }1589 1590 1574 function v3d_save_order_attachments($data_urls) { 1591 1575 … … 1615 1599 1616 1600 $ext = $ALLOWED_MIME_TYPES[$mime]; 1617 $name = time().bin2hex(random_bytes(4)).'.'.$ext;1601 $name = v3d_unique_filename().'.'.$ext; 1618 1602 $file = $att_dir.$name; 1619 1603 $success = file_put_contents($file, $data); … … 1639 1623 } 1640 1624 1641 // COMPAT: < Verge3D 4.1 1642 function v3d_api_place_order_compat(WP_REST_Request $request) { 1643 1644 $response = new WP_REST_Response(array( 1645 'status' => 'rejected', 1646 'error' => 'This API method was removed in Verge3D 4.1. Place order with "v2" method.' 1647 ), 200); 1648 1649 if (get_option('v3d_cross_domain')) 1650 $response->header('Access-Control-Allow-Origin', '*'); 1651 1652 return $response; 1653 1654 } 1655 1656 function v3d_api_place_order(WP_REST_Request $request) { 1657 1658 $params = $request->get_json_params(); 1659 1625 function v3d_api_place_order($params) { 1660 1626 if (!empty($params)) { 1661 1662 1627 $params = v3d_sanitize_order($params); 1663 1628 … … 1690 1655 1691 1656 return $response; 1692 1693 } 1657 } 1658 1659 function v3d_api_place_order_form(WP_REST_Request $request) { 1660 return v3d_api_place_order($request->get_body_params()); 1661 } 1662 1663 function v3d_api_place_order_json(WP_REST_Request $request) { 1664 return v3d_api_place_order($request->get_json_params()); 1665 } 1666 1694 1667 1695 1668 add_action('rest_api_init', function () { … … 1697 1670 register_rest_route('verge3d/v1', '/place_order', array( 1698 1671 'methods' => 'POST', 1699 'callback' => 'v3d_api_place_order_ compat',1672 'callback' => 'v3d_api_place_order_form', 1700 1673 'permission_callback' => '__return_true', 1701 1674 )); 1702 1675 register_rest_route('verge3d/v2', '/place_order', array( 1703 1676 'methods' => 'POST', 1704 'callback' => 'v3d_api_place_order ',1677 'callback' => 'v3d_api_place_order_json', 1705 1678 'permission_callback' => '__return_true', 1706 1679 )); … … 1736 1709 if (!current_user_can('manage_verge3d')) { 1737 1710 $response['status'] = 'error'; 1711 $response['statusText'] = 'Permission denied'; 1738 1712 wp_send_json($response); 1739 1713 } … … 1743 1717 $pdftype = esc_attr($_POST['pdftype']); 1744 1718 1745 v3d_send_emails($pdftype, $order, $order_id); 1746 1747 $response['status'] = 'ok'; 1719 $response = v3d_send_emails($pdftype, $order, $order_id); 1748 1720 wp_send_json($response); 1749 1721 } -
verge3d/trunk/readme.txt
r3054421 r3122938 3 3 Tags: verge3d,3d,webgl,3dweb,ecommerce 4 4 Requires at least: 5.0 5 Tested up to: 6. 4.35 Tested up to: 6.6 6 6 Requires PHP: 7.0 7 Stable tag: 4. 6.07 Stable tag: 4.7.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 68 68 69 69 == Changelog == 70 71 = 4.7.0 = 72 * Support REST API for form submissions. 73 * Support REST API for order submissions via FormData. 74 * Preserve MIME type for uploaded files. 75 * Improve error reporting for admin interface and REST API. 76 * Security fixes. 70 77 71 78 = 4.6.0 = -
verge3d/trunk/verge3d.php
r3054421 r3122938 4 4 Plugin URI: https://www.soft8soft.com/verge3d 5 5 Description: Verge3D is the most artist-friendly toolkit for creating interactive web-based experiences. It can be used to create product configurators, 3D presentations, online stores, e-learning apps, 3D portfolios, browser games and more. 6 Version: 4. 6.06 Version: 4.7.0 7 7 Author: Soft8Soft LLC 8 8 Author URI: https://www.soft8soft.com … … 10 10 */ 11 11 12 include plugin_dir_path(__FILE__) . 'app.php'; 13 include plugin_dir_path(__FILE__) . 'file_storage.php'; 14 include plugin_dir_path(__FILE__) . 'order.php'; 15 include plugin_dir_path(__FILE__) . 'payment.php'; 16 include plugin_dir_path(__FILE__) . 'product.php'; 17 include plugin_dir_path(__FILE__) . 'woo_product.php'; 18 include plugin_dir_path(__FILE__) . 'currencies.php'; 19 include plugin_dir_path(__FILE__) . 'download_file.php'; 20 12 require_once plugin_dir_path(__FILE__) . 'app.php'; 13 require_once plugin_dir_path(__FILE__) . 'file_storage.php'; 14 require_once plugin_dir_path(__FILE__) . 'send_form.php'; 15 require_once plugin_dir_path(__FILE__) . 'order.php'; 16 require_once plugin_dir_path(__FILE__) . 'payment.php'; 17 require_once plugin_dir_path(__FILE__) . 'product.php'; 18 require_once plugin_dir_path(__FILE__) . 'woo_product.php'; 19 require_once plugin_dir_path(__FILE__) . 'currencies.php'; 20 require_once plugin_dir_path(__FILE__) . 'download_file.php'; 21 require_once plugin_dir_path(__FILE__) . 'utils.php'; 21 22 22 23 function v3d_add_capability() { … … 274 275 delete_option('v3d_order_email_invoice_content_user'); 275 276 277 delete_option('v3d_send_form_email_subject'); 278 delete_option('v3d_send_form_email_attachments'); 279 276 280 delete_option('v3d_chrome_path'); 277 281 delete_option('v3d_quote_notes'); … … 285 289 delete_option('v3d_order_api'); 286 290 delete_option('v3d_file_api'); 291 delete_option('v3d_send_form_api'); 287 292 delete_option('v3d_product_api'); 288 293 delete_option('v3d_cross_domain'); … … 343 348 add_option('v3d_order_email_invoice_content_user', 'Please check out the invoice document attached.'); 344 349 350 add_option('v3d_send_form_email_subject', 'Form submitted by user'); 351 add_option('v3d_send_form_email_attachments', 1); 352 345 353 add_option('v3d_chrome_path', ''); 346 354 add_option('v3d_quote_notes', ''); … … 354 362 add_option('v3d_order_api', 1); 355 363 add_option('v3d_file_api', 1); 364 add_option('v3d_send_form_api', 1); 356 365 add_option('v3d_product_api', 1); 357 366 add_option('v3d_cross_domain', 1); … … 567 576 register_setting('verge3d_mail', 'v3d_order_email_invoice_content_user'); 568 577 578 register_setting('verge3d_mail', 'v3d_send_form_email_subject'); 579 register_setting('verge3d_mail', 'v3d_send_form_email_attachments'); 580 569 581 add_settings_section( 570 582 'v3d_mail_common_settings', … … 576 588 add_settings_field( 577 589 'v3d_order_email', 578 ' Order notification email',590 'Notification email', 579 591 'v3d_order_email_cb', 580 592 'verge3d_mail', … … 584 596 add_settings_field( 585 597 'v3d_order_email_from', 586 ' Orderemails "From"',598 'Notification emails "From"', 587 599 'v3d_order_email_from_cb', 588 600 'verge3d_mail', … … 717 729 718 730 731 add_settings_section( 732 'v3d_send_form_email_settings', 733 'Form submissions (API)', 734 '', 735 'verge3d_mail' 736 ); 737 738 add_settings_field( 739 'v3d_send_form_email_subject', 740 'Email subject', 741 'v3d_send_form_email_subject_cb', 742 'verge3d_mail', 743 'v3d_send_form_email_settings' 744 ); 745 746 add_settings_field( 747 'v3d_send_form_email_attachments', 748 'Attachments', 749 'v3d_send_form_email_attachments_cb', 750 'verge3d_mail', 751 'v3d_send_form_email_settings' 752 ); 753 754 719 755 register_setting('verge3d_documents', 'v3d_chrome_path'); 720 756 register_setting('verge3d_documents', 'v3d_quote_notes'); … … 806 842 register_setting('verge3d_security', 'v3d_order_api'); 807 843 register_setting('verge3d_security', 'v3d_file_api'); 844 register_setting('verge3d_security', 'v3d_send_form_api'); 808 845 register_setting('verge3d_security', 'v3d_product_api'); 809 846 register_setting('verge3d_security', 'v3d_cross_domain'); … … 1026 1063 ?> 1027 1064 <input type="email" name="v3d_order_email" value="<?php echo isset($email) ? esc_attr($email) : ''; ?>" class="v3d-wide-input"> 1028 <p class="description">You will be notified about new orders on this e-mail. For example sales@yourcompany.com.</p>1065 <p class="description">You will be notified about new orders/forms on this e-mail. For example sales@yourcompany.com.</p> 1029 1066 <?php 1030 1067 } … … 1219 1256 } 1220 1257 1258 function v3d_send_form_email_subject_cb() { 1259 $subject = get_option('v3d_send_form_email_subject'); 1260 ?> 1261 <input type="text" name="v3d_send_form_email_subject" value="<?php echo isset($subject) ? esc_attr($subject) : ''; ?>" class="v3d-wide-input"> 1262 <p class="description">Subject of emails sent upon form submissions.</p> 1263 <?php 1264 } 1265 1266 function v3d_send_form_email_attachments_cb() { 1267 ?> 1268 <fieldset> 1269 <label> 1270 <input type="checkbox" name="v3d_send_form_email_attachments" value="1" <?php checked(1, get_option('v3d_send_form_email_attachments')); ?>> 1271 Allow 1272 </label> 1273 <p class="description">Receive files submitted via forms as email attachments.</p> 1274 </fieldset> 1275 <?php 1276 } 1277 1221 1278 /* Documents settings UI */ 1222 1279 … … 1325 1382 <br> 1326 1383 <label> 1384 <input type="checkbox" name="v3d_send_form_api" value="1" <?php checked(1, get_option('v3d_send_form_api')); ?>> 1385 Form submissions 1386 <p class="description">Allow REST API for sending forms via email.</p> 1387 </label> 1388 <br> 1389 <label> 1327 1390 <input type="checkbox" name="v3d_product_api" value="1" <?php checked(1, get_option('v3d_product_api')); ?>> 1328 1391 Product management … … 1402 1465 } 1403 1466 1404 function v3d_inline_image($path) {1405 $type = pathinfo($path, PATHINFO_EXTENSION);1406 $data = file_get_contents($path);1407 $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);1408 return $base64;1409 }1410 1411 /**1412 * Get/create plugin's upload directory1413 */1414 function v3d_get_upload_dir() {1415 $upload_dir = wp_upload_dir()['basedir'].'/verge3d/';1416 1417 if (!is_dir($upload_dir)) {1418 mkdir($upload_dir, 0777, true);1419 }1420 1421 return $upload_dir;1422 }1423 1424 function v3d_get_upload_url() {1425 $upload_url = wp_upload_dir()['baseurl'].'/verge3d/';1426 return $upload_url;1427 }1428 1429 1467 function v3d_get_template($name) { 1430 1468
Note: See TracChangeset
for help on using the changeset viewer.