當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wc_add_wp_error_notices函數代碼示例

本文整理匯總了PHP中wc_add_wp_error_notices函數的典型用法代碼示例。如果您正苦於以下問題:PHP wc_add_wp_error_notices函數的具體用法?PHP wc_add_wp_error_notices怎麽用?PHP wc_add_wp_error_notices使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wc_add_wp_error_notices函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process_reset_password

 /**
  * Handle reset password form.
  */
 public static function process_reset_password()
 {
     $posted_fields = array('wc_reset_password', 'password_1', 'password_2', 'reset_key', 'reset_login', '_wpnonce');
     foreach ($posted_fields as $field) {
         if (!isset($_POST[$field])) {
             return;
         }
         $posted_fields[$field] = $_POST[$field];
     }
     if (!wp_verify_nonce($posted_fields['_wpnonce'], 'reset_password')) {
         return;
     }
     $user = WC_Shortcode_My_Account::check_password_reset_key($posted_fields['reset_key'], $posted_fields['reset_login']);
     if ($user instanceof WP_User) {
         if (empty($posted_fields['password_1'])) {
             wc_add_notice(__('Please enter your password.', 'woocommerce'), 'error');
         }
         if ($posted_fields['password_1'] !== $posted_fields['password_2']) {
             wc_add_notice(__('Passwords do not match.', 'woocommerce'), 'error');
         }
         $errors = new WP_Error();
         do_action('validate_password_reset', $errors, $user);
         wc_add_wp_error_notices($errors);
         if (0 === wc_notice_count('error')) {
             WC_Shortcode_My_Account::reset_password($user, $posted_fields['password_1']);
             do_action('woocommerce_customer_reset_password', $user);
             wp_redirect(add_query_arg('password-reset', 'true', wc_get_page_permalink('myaccount')));
             exit;
         }
     }
 }
開發者ID:johnulist,項目名稱:woocommerce,代碼行數:34,代碼來源:class-wc-form-handler.php

示例2: save_wccpf_data

 function save_wccpf_data($cart_item_data, $product_id)
 {
     $unique_cart_item_key = md5(microtime() . rand());
     //$cart_item_data['wccpf_unique_key'] = $unique_cart_item_key;
     if ($product_id) {
         $val = "";
         $wccpf_options = get_option('wccpf_options');
         $wccpf_options = is_array($wccpf_options) ? $wccpf_options : array();
         $fields_cloning = isset($wccpf_options["fields_cloning"]) ? $wccpf_options["fields_cloning"] : "no";
         $all_fields = apply_filters('wcff/load/all_fields', $product_id, 'wccpf');
         if ($fields_cloning == "no") {
             foreach ($all_fields as $fields) {
                 foreach ($fields as $field) {
                     $is_multi_file = isset($field["multi_file"]) ? $field["multi_file"] : "no";
                     if (isset($_REQUEST[$field["name"]]) || isset($_FILES[$field["name"]])) {
                         if ($field["type"] != "checkbox" && $field["type"] != "file") {
                             $cart_item_data["wccpf_" . $field["name"]] = $_REQUEST[$field["name"]];
                         } else {
                             if ($field["type"] == "checkbox") {
                                 $cart_item_data["wccpf_" . $field["name"]] = implode(", ", $_REQUEST[$field["name"]]);
                             } else {
                                 $res = array();
                                 /* Handle the file upload */
                                 if ($is_multi_file == "yes") {
                                     $files = $_FILES[$field["name"]];
                                     foreach ($files['name'] as $key => $value) {
                                         if ($files['name'][$key]) {
                                             $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]);
                                             $temp_res = apply_filters('wccpf/upload/type=file', $file);
                                             if (isset($temp_res['error'])) {
                                                 $res = $temp_res;
                                                 break;
                                             } else {
                                                 $res[] = $temp_res;
                                             }
                                         }
                                     }
                                 } else {
                                     $res = apply_filters('wccpf/upload/type=file', $_FILES[$field["name"]]);
                                 }
                                 if (!isset($res['error'])) {
                                     $cart_item_data["wccpf_" . $field["name"]] = json_encode($res);
                                     do_action('wccpf/uploaded/file', $res);
                                 } else {
                                     wc_add_wp_error_notices($field["message"], 'error');
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if (isset($_REQUEST["quantity"])) {
                 $pcount = intval($_REQUEST["quantity"]);
                 foreach ($all_fields as $fields) {
                     foreach ($fields as $field) {
                         $is_multi_file = isset($field["multi_file"]) ? $field["multi_file"] : "no";
                         for ($i = 1; $i <= $pcount; $i++) {
                             if (isset($_REQUEST[$field["name"] . "_" . $i]) || isset($_REQUEST[$field["name"] . "_" . $i . "[]"]) || isset($_FILES[$field["name"] . "_" . $i])) {
                                 if ($field["type"] != "checkbox" && $field["type"] != "file") {
                                     $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = $_REQUEST[$field["name"] . "_" . $i];
                                 } else {
                                     if ($field["type"] == "checkbox") {
                                         $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = implode(", ", $_REQUEST[$field["name"] . "_" . $i]);
                                     } else {
                                         $res = array();
                                         /* Handle the file upload */
                                         if ($is_multi_file == "yes") {
                                             $files = $_FILES[$field["name"] . "_" . $i];
                                             foreach ($files['name'] as $key => $value) {
                                                 if ($files['name'][$key]) {
                                                     $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]);
                                                     $temp_res = apply_filters('wccpf/upload/type=file', $file);
                                                     if (isset($temp_res['error'])) {
                                                         $res = $temp_res;
                                                         break;
                                                     } else {
                                                         $res[] = $temp_res;
                                                     }
                                                 }
                                             }
                                         } else {
                                             $res = apply_filters('wccpf/upload/type=file', $_FILES[$field["name"] . "_" . $i]);
                                         }
                                         if (!isset($res['error'])) {
                                             $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = json_encode($res);
                                             do_action('wccpf/uploaded/file', $res);
                                         } else {
                                             wc_add_wp_error_notices($field["message"], 'error');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $cart_item_data;
//.........這裏部分代碼省略.........
開發者ID:pacificano,項目名稱:sweet-tooth-sweets,代碼行數:101,代碼來源:wcff-product-form.php


注:本文中的wc_add_wp_error_notices函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。