コード例 #1
0
 public function ajax_make_customer_id()
 {
     if (!check_ajax_referer('eci_ajax', 'nonce', false)) {
         wp_send_json_error(__('Missing or invalid AJAX nonce.', 'easy-customer-invoices'));
     }
     if (!isset($_REQUEST['first_name'])) {
         wp_send_json_error(__('Missing first name.', 'easy-customer-invoices'));
     }
     if (!isset($_REQUEST['last_name'])) {
         wp_send_json_error(__('Missing last name.', 'easy-customer-invoices'));
     }
     $first_name = $_REQUEST['first_name'];
     $last_name = $_REQUEST['last_name'];
     $year = null;
     if (isset($_REQUEST['year'])) {
         $year = absint($_REQUEST['year']);
     }
     $old_id = null;
     if (isset($_REQUEST['old_id']) && !empty($_REQUEST['old_id'])) {
         $old_id = $_REQUEST['old_id'];
     }
     wp_send_json_success(Util::make_customer_id($first_name, $last_name, $year, $old_id));
 }