wordpress notice

Solutions on MaxInterview for wordpress notice by the best coders in the world

showing results for - "wordpress notice"
Mattia
19 Jul 2018
1// for success
2<div class="notice notice-success is-dismissible">
3        <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
4</div>
5  
6// for error  
7<div class="notice notice-error is-dismissible ">
8        <p><?php _e( 'Error message here!', 'sample-text-domain' ); ?></p>
9</div>
10  
Lohan
16 Apr 2018
1# More advance version
2
3function sample_admin_notice__error() {
4    $class = 'notice notice-error';
5    $message = __( 'Irks! An error has occurred.', 'sample-text-domain' );
6 
7    printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); 
8}
9add_action( 'admin_notices', 'sample_admin_notice__error' );
Joss
18 Apr 2019
1function sample_admin_notice__success() {
2    ?>
3    <div class="notice notice-success is-dismissible">
4        <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
5    </div>
6    <?php
7}
8add_action( 'admin_notices', 'sample_admin_notice__success' );
9