“Aviso do WordPress” Respostas de código

Aviso do WordPress

// for success
<div class="notice notice-success is-dismissible">
        <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
</div>
  
// for error  
<div class="notice notice-error is-dismissible ">
        <p><?php _e( 'Error message here!', 'sample-text-domain' ); ?></p>
</div>
  
Faiz

WordPress Aviso

function sample_admin_notice__success() {
    ?>
    <div class="notice notice-success is-dismissible">
        <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
    </div>
    <?php
}
add_action( 'admin_notices', 'sample_admin_notice__success' );
Darkvent

Aviso do WordPress

# More advance version

function sample_admin_notice__error() {
    $class = 'notice notice-error';
    $message = __( 'Irks! An error has occurred.', 'sample-text-domain' );
 
    printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); 
}
add_action( 'admin_notices', 'sample_admin_notice__error' );
Darkvent

Respostas semelhantes a “Aviso do WordPress”

Perguntas semelhantes a “Aviso do WordPress”

Procure respostas de código populares por idioma

Procurar outros idiomas de código