Plugin Directory

Changeset 3122938


Ignore:
Timestamp:
07/22/2024 07:47:21 AM (20 months ago)
Author:
soft8soft
Message:

New version 4.7.0

Location:
verge3d/trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • verge3d/trunk/app.php

    r3054421 r3122938  
    11<?php
    22
    3 define('V3D_DEFAULT_CANVAS_WIDTH', 800);
    4 define('V3D_DEFAULT_CANVAS_HEIGHT', 500);
     3require_once plugin_dir_path(__FILE__) . 'utils.php';
    54
    65if (!class_exists('WP_List_Table')){
    76    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
    87}
     8
     9const V3D_DEFAULT_CANVAS_WIDTH = 800;
     10const V3D_DEFAULT_CANVAS_HEIGHT = 500;
    911
    1012function v3d_app_menu() {
     
    632634
    633635            // 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());
    654637            if ($validate['type'] === false) {
    655638                wp_die('error');
  • verge3d/trunk/css/admin.css

    r3019209 r3122938  
    5757}
    5858
    59 .dialog-quote-sent {
     59.dialog-email-sent {
    6060    padding: 15px;
    6161}
    6262
    63 .dialog-quote-sent button.button {
     63.dialog-email-sent button.button {
    6464    display: block;
    6565    margin: 0px auto;
  • verge3d/trunk/file_storage.php

    r2995028 r3122938  
    11<?php
     2
     3require_once plugin_dir_path(__FILE__) . 'utils.php';
    24
    35const FILES_SUBDIR = 'files/';
    46
    57function v3d_api_upload_file(WP_REST_Request $request) {
     8    $response = new WP_REST_Response();
     9    $error_msg = '';
    610
    7     if (!empty($request->get_body())) {
     11    $data = $request->get_body();
    812
    9         $upload_dir = v3d_get_upload_dir().FILES_SUBDIR;
     13    if (!empty($data)) {
     14        $upload_dir = v3d_get_upload_dir() . FILES_SUBDIR;
    1015        if (!is_dir($upload_dir)) {
    1116            mkdir($upload_dir, 0777, true);
    1217        }
    1318
    14         $id = time();
     19        $id = v3d_unique_filename();
     20        $filename = $upload_dir.$id;
     21        $mime = $request->get_content_type()['value'];
    1522
    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;
    2737
    2838    } 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);
    3048    }
    3149
     
    3452
    3553    return $response;
    36 
    3754}
    3855
    3956function v3d_api_get_file(WP_REST_Request $request) {
    4057
    41     $id = intval($request->get_param('id'));
     58    $response = new WP_REST_Response();
     59    $error_msg = '';
     60
     61    $id = $request->get_param('id');
    4262
    4363    if (!empty($id)) {
     64        $upload_dir = v3d_get_upload_dir() . FILES_SUBDIR;
    4465
    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        }
    4774
    4875        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
    5596        } else
    56             $response = new WP_REST_Response(array('error' => 'File not found'), 500);
     97            $error_msg = 'File not found';
    5798
    5899    } else {
     100        $error_msg = 'Bad request';
     101    }
    59102
    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);
    62109    }
    63110
     
    66113
    67114    return $response;
     115}
    68116
     117function 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;
    69126}
    70127
     
    78135        ));
    79136
    80         register_rest_route('verge3d/v1', '/get_file/(?P<id>\d+)', array(
     137        register_rest_route('verge3d/v1', '/get_file/(?P<id>\w+)', array(
    81138            'methods' => 'GET',
    82139            'callback' => 'v3d_api_get_file',
     
    84141                'id' => array(
    85142                    'validate_callback' => function($param, $request, $key) {
    86                         return is_numeric($param);
     143                        // allow hex numbers
     144                        return (trim($param, '0..9A..Fa..f') === '');
    87145                    }
    88146                ),
     
    91149        ));
    92150    }
    93 
    94151});
  • verge3d/trunk/js/order.js

    r2773896 r3122938  
    199199}
    200200
    201 function send_pdf_cb(pdftype) {
     201async function send_pdf_cb(pdftype) {
    202202    const form_data = new FormData();
    203203    form_data.append('action', 'v3d_ajax_send_pdf');
     
    205205    form_data.append('pdftype', pdftype);
    206206
    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
     228function email_sent_close_cb() {
     229    document.querySelector('#dialog-email-sent').style.display = 'none';
    222230}
    223231
  • verge3d/trunk/order.php

    r3054421 r3122938  
    11<?php
    22
     3require_once plugin_dir_path(__FILE__) . 'utils.php';
     4
    35if (!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';
    57}
    68
     
    9294    case 'genpdf':
    9395        if (!empty($_REQUEST['order'])) {
    94             ob_end_clean();
    95 
    9696            $order_id = intval($_REQUEST['order']);
    9797            $order = v3d_get_order_by_id($order_id);
     
    100100            $attachments = v3d_gen_email_attachments($order, $order_id, false, [$pdftype]);
    101101
    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            }
    111118
    112119            v3d_cleanup_email_attachments($attachments);
    113         }
     120        } else {
     121            wp_die('Bad request');
     122        }
     123        break;
    114124    default:
    115125        $orderTable = new V3D_Order_List_Table();
     
    293303
    294304    $attachments = array();
     305    $error_msg = '';
    295306
    296307    $send_me = !empty($order_email) && $notify_type != 'quote' && $notify_type != 'invoice' && get_option("v3d_order_email_{$notify_type}_notify");
     
    324335
    325336        $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) {
    329345        $to = $order_email;
    330346        $subject = get_option("v3d_order_email_{$notify_type}_subject");
     
    334350        $body = ob_get_clean();
    335351
    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) {
    340357        $to = $order['user_email'];
    341358        $subject = get_option("v3d_order_email_{$notify_type}_subject_user");
     
    345362        $body = ob_get_clean();
    346363
    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';
    349366    }
    350367
    351368    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    );
    352374}
    353375
     
    411433
    412434    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     }
    423435}
    424436
     
    454466
    455467            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);
    462469                if (is_file($pdf))
    463470                    $attachments[] = $pdf;
     
    727734    </div>
    728735
    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>
    732739        <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>
    743741        </div>
    744742      </div>
     
    15741572}
    15751573
    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 
    15901574function v3d_save_order_attachments($data_urls) {
    15911575
     
    16151599
    16161600        $ext = $ALLOWED_MIME_TYPES[$mime];
    1617         $name = time().bin2hex(random_bytes(4)).'.'.$ext;
     1601        $name = v3d_unique_filename().'.'.$ext;
    16181602        $file = $att_dir.$name;
    16191603        $success = file_put_contents($file, $data);
     
    16391623}
    16401624
    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 
     1625function v3d_api_place_order($params) {
    16601626    if (!empty($params)) {
    1661 
    16621627        $params = v3d_sanitize_order($params);
    16631628
     
    16901655
    16911656    return $response;
    1692 
    1693 }
     1657}
     1658
     1659function v3d_api_place_order_form(WP_REST_Request $request) {
     1660    return v3d_api_place_order($request->get_body_params());
     1661}
     1662
     1663function v3d_api_place_order_json(WP_REST_Request $request) {
     1664    return v3d_api_place_order($request->get_json_params());
     1665}
     1666
    16941667
    16951668add_action('rest_api_init', function () {
     
    16971670        register_rest_route('verge3d/v1', '/place_order', array(
    16981671            'methods' => 'POST',
    1699             'callback' => 'v3d_api_place_order_compat',
     1672            'callback' => 'v3d_api_place_order_form',
    17001673            'permission_callback' => '__return_true',
    17011674        ));
    17021675        register_rest_route('verge3d/v2', '/place_order', array(
    17031676            'methods' => 'POST',
    1704             'callback' => 'v3d_api_place_order',
     1677            'callback' => 'v3d_api_place_order_json',
    17051678            'permission_callback' => '__return_true',
    17061679        ));
     
    17361709    if (!current_user_can('manage_verge3d')) {
    17371710        $response['status'] = 'error';
     1711        $response['statusText'] = 'Permission denied';
    17381712        wp_send_json($response);
    17391713    }
     
    17431717    $pdftype = esc_attr($_POST['pdftype']);
    17441718
    1745     v3d_send_emails($pdftype, $order, $order_id);
    1746 
    1747     $response['status'] = 'ok';
     1719    $response = v3d_send_emails($pdftype, $order, $order_id);
    17481720    wp_send_json($response);
    17491721}
  • verge3d/trunk/readme.txt

    r3054421 r3122938  
    33Tags: verge3d,3d,webgl,3dweb,ecommerce
    44Requires at least: 5.0
    5 Tested up to: 6.4.3
     5Tested up to: 6.6
    66Requires PHP: 7.0
    7 Stable tag: 4.6.0
     7Stable tag: 4.7.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6868
    6969== 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.
    7077
    7178= 4.6.0 =
  • verge3d/trunk/verge3d.php

    r3054421 r3122938  
    44Plugin URI: https://www.soft8soft.com/verge3d
    55Description: 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.0
     6Version: 4.7.0
    77Author: Soft8Soft LLC
    88Author URI: https://www.soft8soft.com
     
    1010*/
    1111
    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 
     12require_once plugin_dir_path(__FILE__) . 'app.php';
     13require_once plugin_dir_path(__FILE__) . 'file_storage.php';
     14require_once plugin_dir_path(__FILE__) . 'send_form.php';
     15require_once plugin_dir_path(__FILE__) . 'order.php';
     16require_once plugin_dir_path(__FILE__) . 'payment.php';
     17require_once plugin_dir_path(__FILE__) . 'product.php';
     18require_once plugin_dir_path(__FILE__) . 'woo_product.php';
     19require_once plugin_dir_path(__FILE__) . 'currencies.php';
     20require_once plugin_dir_path(__FILE__) . 'download_file.php';
     21require_once plugin_dir_path(__FILE__) . 'utils.php';
    2122
    2223function v3d_add_capability() {
     
    274275    delete_option('v3d_order_email_invoice_content_user');
    275276
     277    delete_option('v3d_send_form_email_subject');
     278    delete_option('v3d_send_form_email_attachments');
     279
    276280    delete_option('v3d_chrome_path');
    277281    delete_option('v3d_quote_notes');
     
    285289    delete_option('v3d_order_api');
    286290    delete_option('v3d_file_api');
     291    delete_option('v3d_send_form_api');
    287292    delete_option('v3d_product_api');
    288293    delete_option('v3d_cross_domain');
     
    343348    add_option('v3d_order_email_invoice_content_user', 'Please check out the invoice document attached.');
    344349
     350    add_option('v3d_send_form_email_subject', 'Form submitted by user');
     351    add_option('v3d_send_form_email_attachments', 1);
     352
    345353    add_option('v3d_chrome_path', '');
    346354    add_option('v3d_quote_notes', '');
     
    354362    add_option('v3d_order_api', 1);
    355363    add_option('v3d_file_api', 1);
     364    add_option('v3d_send_form_api', 1);
    356365    add_option('v3d_product_api', 1);
    357366    add_option('v3d_cross_domain', 1);
     
    567576    register_setting('verge3d_mail', 'v3d_order_email_invoice_content_user');
    568577
     578    register_setting('verge3d_mail', 'v3d_send_form_email_subject');
     579    register_setting('verge3d_mail', 'v3d_send_form_email_attachments');
     580
    569581    add_settings_section(
    570582        'v3d_mail_common_settings',
     
    576588    add_settings_field(
    577589        'v3d_order_email',
    578         'Order notification email',
     590        'Notification email',
    579591        'v3d_order_email_cb',
    580592        'verge3d_mail',
     
    584596    add_settings_field(
    585597        'v3d_order_email_from',
    586         'Order emails "From"',
     598        'Notification emails "From"',
    587599        'v3d_order_email_from_cb',
    588600        'verge3d_mail',
     
    717729
    718730
     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
    719755    register_setting('verge3d_documents', 'v3d_chrome_path');
    720756    register_setting('verge3d_documents', 'v3d_quote_notes');
     
    806842    register_setting('verge3d_security', 'v3d_order_api');
    807843    register_setting('verge3d_security', 'v3d_file_api');
     844    register_setting('verge3d_security', 'v3d_send_form_api');
    808845    register_setting('verge3d_security', 'v3d_product_api');
    809846    register_setting('verge3d_security', 'v3d_cross_domain');
     
    10261063    ?>
    10271064    <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>
    10291066    <?php
    10301067}
     
    12191256}
    12201257
     1258function 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
     1266function 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
    12211278/* Documents settings UI */
    12221279
     
    13251382    <br>
    13261383    <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>
    13271390      <input type="checkbox" name="v3d_product_api" value="1" <?php checked(1, get_option('v3d_product_api')); ?>>
    13281391      Product management
     
    14021465}
    14031466
    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 directory
    1413  */
    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 
    14291467function v3d_get_template($name) {
    14301468
Note: See TracChangeset for help on using the changeset viewer.