wc_print_notice()
Print a single notice immediately.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wc_print_notice( $message, $notice_type, $data, $return );
- $message(строка) (обязательный)
- The text to display in the notice.
- $notice_type(строка)
- The singular name of the notice type - either error, success or notice.
По умолчанию: 'success' - $data(массив)
- Optional notice data. @since 3.9.0.
По умолчанию: array() - $return(true|false)
- true to return rather than echo. @since 7.7.0.
По умолчанию: false
Список изменений
С версии 2.1 | Введена. |
Код wc_print_notice() wc print notice WC 8.7.0
function wc_print_notice( $message, $notice_type = 'success', $data = array(), $return = false ) { if ( 'success' === $notice_type ) { $message = apply_filters( 'woocommerce_add_message', $message ); } $message = apply_filters( 'woocommerce_add_' . $notice_type, $message ); // Buffer output. ob_start(); wc_get_template( "notices/{$notice_type}.php", array( 'messages' => array( $message ), // @deprecated 3.9.0 'notices' => array( array( 'notice' => $message, 'data' => $data, ), ), ) ); $notice = wc_kses_notice( ob_get_clean() ); if ( $return ) { return $notice; } echo $notice; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }