Introduce new wc_print_notice() function
This commit is contained in:
parent
3fa310969f
commit
8dcf86335c
|
@ -90,6 +90,22 @@ function wc_print_notices() {
|
||||||
add_action( 'woocommerce_before_shop_loop', 'wc_print_notices', 10 );
|
add_action( 'woocommerce_before_shop_loop', 'wc_print_notices', 10 );
|
||||||
add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
|
add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a single notice immediately
|
||||||
|
*
|
||||||
|
* @param string $message The text to display in the notice.
|
||||||
|
* @param string $notice_type The singular name of the notice type - either error, success or notice. [optional]
|
||||||
|
*/
|
||||||
|
function wc_print_notice( $message, $notice_type = 'success' ) {
|
||||||
|
|
||||||
|
if ( 'success' === $notice_type )
|
||||||
|
$message = apply_filters( 'woocommerce_add_message', $message );
|
||||||
|
|
||||||
|
woocommerce_get_template( "notices/{$notice_type}.php", array(
|
||||||
|
"{$notice_type}s" => array( apply_filters( 'woocommerce_add_' . $notice_type, $message ) )
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all queued notices, optionally filtered by a notice type.
|
* Returns all queued notices, optionally filtered by a notice type.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue