本文整理汇总了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;未经允许,请勿转载。 |
请发表评论