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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / wc-notice-functions.php
woocommerce / includes Last commit date
abstracts 8 years ago admin 8 years ago api 8 years ago cli 8 years ago customizer 8 years ago data-stores 8 years ago emails 8 years ago export 8 years ago gateways 8 years ago import 8 years ago interfaces 8 years ago legacy 8 years ago libraries 8 years ago log-handlers 8 years ago payment-tokens 9 years ago shipping 8 years ago shortcodes 8 years ago theme-support 8 years ago walkers 8 years ago widgets 8 years ago class-wc-ajax.php 8 years ago class-wc-api.php 8 years ago class-wc-auth.php 8 years ago class-wc-autoloader.php 8 years ago class-wc-background-emailer.php 8 years ago class-wc-background-updater.php 8 years ago class-wc-breadcrumb.php 8 years ago class-wc-cache-helper.php 8 years ago class-wc-cart-fees.php 8 years ago class-wc-cart-session.php 8 years ago class-wc-cart-totals.php 8 years ago class-wc-cart.php 8 years ago class-wc-checkout.php 8 years ago class-wc-cli.php 9 years ago class-wc-comments.php 8 years ago class-wc-countries.php 8 years ago class-wc-coupon.php 8 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 8 years ago class-wc-customer.php 8 years ago class-wc-data-exception.php 9 years ago class-wc-data-store.php 8 years ago class-wc-datetime.php 8 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 8 years ago class-wc-discounts.php 8 years ago class-wc-download-handler.php 8 years ago class-wc-emails.php 8 years ago class-wc-embed.php 9 years ago class-wc-form-handler.php 8 years ago class-wc-frontend-scripts.php 8 years ago class-wc-geo-ip.php 9 years ago class-wc-geolocation.php 8 years ago class-wc-https.php 9 years ago class-wc-install.php 8 years ago class-wc-integrations.php 9 years ago class-wc-log-levels.php 9 years ago class-wc-logger.php 8 years ago class-wc-meta-data.php 8 years ago class-wc-order-factory.php 8 years ago class-wc-order-item-coupon.php 8 years ago class-wc-order-item-fee.php 8 years ago class-wc-order-item-meta.php 8 years ago class-wc-order-item-product.php 8 years ago class-wc-order-item-shipping.php 8 years ago class-wc-order-item-tax.php 8 years ago class-wc-order-item.php 8 years ago class-wc-order-query.php 8 years ago class-wc-order-refund.php 9 years ago class-wc-order.php 8 years ago class-wc-payment-gateways.php 8 years ago class-wc-payment-tokens.php 9 years ago class-wc-post-data.php 8 years ago class-wc-post-types.php 8 years ago class-wc-product-attribute.php 8 years ago class-wc-product-download.php 8 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 9 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 8 years ago class-wc-product-simple.php 8 years ago class-wc-product-variable.php 8 years ago class-wc-product-variation.php 8 years ago class-wc-query.php 8 years ago class-wc-regenerate-images-request.php 8 years ago class-wc-regenerate-images.php 8 years ago class-wc-register-wp-admin-settings.php 9 years ago class-wc-session-handler.php 8 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 8 years ago class-wc-shipping-zones.php 8 years ago class-wc-shipping.php 8 years ago class-wc-shortcodes.php 8 years ago class-wc-structured-data.php 8 years ago class-wc-tax.php 8 years ago class-wc-template-loader.php 8 years ago class-wc-tracker.php 8 years ago class-wc-validation.php 8 years ago class-wc-webhook.php 8 years ago class-woocommerce.php 8 years ago wc-account-functions.php 8 years ago wc-attribute-functions.php 8 years ago wc-cart-functions.php 8 years ago wc-conditional-functions.php 8 years ago wc-core-functions.php 8 years ago wc-coupon-functions.php 9 years ago wc-deprecated-functions.php 8 years ago wc-formatting-functions.php 8 years ago wc-notice-functions.php 8 years ago wc-order-functions.php 8 years ago wc-order-item-functions.php 9 years ago wc-page-functions.php 8 years ago wc-product-functions.php 8 years ago wc-rest-functions.php 8 years ago wc-stock-functions.php 8 years ago wc-template-functions.php 8 years ago wc-template-hooks.php 8 years ago wc-term-functions.php 8 years ago wc-update-functions.php 8 years ago wc-user-functions.php 8 years ago wc-webhook-functions.php 8 years ago wc-widget-functions.php 8 years ago
wc-notice-functions.php
201 lines
1 <?php
2 /**
3 * WooCommerce Message Functions
4 *
5 * Functions for error/message handling and display.
6 *
7 * @package WooCommerce/Functions
8 * @version 2.1.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Get the count of notices added, either for all notices (default) or for one.
17 * particular notice type specified by $notice_type.
18 *
19 * @since 2.1
20 * @param string $notice_type Optional. The name of the notice type - either error, success or notice.
21 * @return int
22 */
23 function wc_notice_count( $notice_type = '' ) {
24 if ( ! did_action( 'woocommerce_init' ) ) {
25 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
26 return;
27 }
28
29 $notice_count = 0;
30 $all_notices = WC()->session->get( 'wc_notices', array() );
31
32 if ( isset( $all_notices[ $notice_type ] ) ) {
33
34 $notice_count = count( $all_notices[ $notice_type ] );
35
36 } elseif ( empty( $notice_type ) ) {
37
38 foreach ( $all_notices as $notices ) {
39 $notice_count += count( $notices );
40 }
41 }
42
43 return $notice_count;
44 }
45
46 /**
47 * Check if a notice has already been added.
48 *
49 * @since 2.1
50 * @param string $message The text to display in the notice.
51 * @param string $notice_type Optional. The name of the notice type - either error, success or notice.
52 * @return bool
53 */
54 function wc_has_notice( $message, $notice_type = 'success' ) {
55 if ( ! did_action( 'woocommerce_init' ) ) {
56 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
57 return false;
58 }
59
60 $notices = WC()->session->get( 'wc_notices', array() );
61 $notices = isset( $notices[ $notice_type ] ) ? $notices[ $notice_type ] : array();
62 return array_search( $message, $notices, true ) !== false;
63 }
64
65 /**
66 * Add and store a notice.
67 *
68 * @since 2.1
69 * @param string $message The text to display in the notice.
70 * @param string $notice_type Optional. The name of the notice type - either error, success or notice.
71 */
72 function wc_add_notice( $message, $notice_type = 'success' ) {
73 if ( ! did_action( 'woocommerce_init' ) ) {
74 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
75 return;
76 }
77
78 $notices = WC()->session->get( 'wc_notices', array() );
79
80 // Backward compatibility.
81 if ( 'success' === $notice_type ) {
82 $message = apply_filters( 'woocommerce_add_message', $message );
83 }
84
85 $notices[ $notice_type ][] = apply_filters( 'woocommerce_add_' . $notice_type, $message );
86
87 WC()->session->set( 'wc_notices', $notices );
88 }
89
90 /**
91 * Set all notices at once.
92 *
93 * @since 2.6.0
94 * @param mixed $notices Array of notices.
95 */
96 function wc_set_notices( $notices ) {
97 if ( ! did_action( 'woocommerce_init' ) ) {
98 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.6' );
99 return;
100 }
101 WC()->session->set( 'wc_notices', $notices );
102 }
103
104
105 /**
106 * Unset all notices.
107 *
108 * @since 2.1
109 */
110 function wc_clear_notices() {
111 if ( ! did_action( 'woocommerce_init' ) ) {
112 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
113 return;
114 }
115 WC()->session->set( 'wc_notices', null );
116 }
117
118 /**
119 * Prints messages and errors which are stored in the session, then clears them.
120 *
121 * @since 2.1
122 */
123 function wc_print_notices() {
124 if ( ! did_action( 'woocommerce_init' ) ) {
125 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
126 return;
127 }
128
129 $all_notices = WC()->session->get( 'wc_notices', array() );
130 $notice_types = apply_filters( 'woocommerce_notice_types', array( 'error', 'success', 'notice' ) );
131
132 foreach ( $notice_types as $notice_type ) {
133 if ( wc_notice_count( $notice_type ) > 0 ) {
134 wc_get_template( "notices/{$notice_type}.php", array(
135 'messages' => array_filter( $all_notices[ $notice_type ] ),
136 ) );
137 }
138 }
139
140 wc_clear_notices();
141 }
142 add_action( 'woocommerce_shortcode_before_product_cat_loop', 'wc_print_notices', 10 );
143 add_action( 'woocommerce_before_shop_loop', 'wc_print_notices', 10 );
144 add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
145
146 /**
147 * Print a single notice immediately.
148 *
149 * @since 2.1
150 * @param string $message The text to display in the notice.
151 * @param string $notice_type Optional. The singular name of the notice type - either error, success or notice.
152 */
153 function wc_print_notice( $message, $notice_type = 'success' ) {
154 if ( 'success' === $notice_type ) {
155 $message = apply_filters( 'woocommerce_add_message', $message );
156 }
157
158 wc_get_template( "notices/{$notice_type}.php", array(
159 'messages' => array( apply_filters( 'woocommerce_add_' . $notice_type, $message ) ),
160 ) );
161 }
162
163 /**
164 * Returns all queued notices, optionally filtered by a notice type.
165 *
166 * @since 2.1
167 * @param string $notice_type Optional. The singular name of the notice type - either error, success or notice.
168 * @return array|mixed
169 */
170 function wc_get_notices( $notice_type = '' ) {
171 if ( ! did_action( 'woocommerce_init' ) ) {
172 wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' );
173 return;
174 }
175
176 $all_notices = WC()->session->get( 'wc_notices', array() );
177
178 if ( empty( $notice_type ) ) {
179 $notices = $all_notices;
180 } elseif ( isset( $all_notices[ $notice_type ] ) ) {
181 $notices = $all_notices[ $notice_type ];
182 } else {
183 $notices = array();
184 }
185
186 return $notices;
187 }
188
189 /**
190 * Add notices for WP Errors.
191 *
192 * @param WP_Error $errors Errors.
193 */
194 function wc_add_wp_error_notices( $errors ) {
195 if ( is_wp_error( $errors ) && $errors->get_error_messages() ) {
196 foreach ( $errors->get_error_messages() as $error ) {
197 wc_add_notice( $error, 'error' );
198 }
199 }
200 }
201