Introduce new wc_print_notice() function

This commit is contained in:
thenbrent 2013-11-13 16:10:31 -08:00
parent 3fa310969f
commit 8dcf86335c
1 changed files with 16 additions and 0 deletions

View File

@ -90,6 +90,22 @@ function wc_print_notices() {
add_action( 'woocommerce_before_shop_loop', '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.
*