Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Adding Custom Admin Notices in the Classic Editor wordpress

/**
 * Hook into the 'admin_notices' action to render
 * a generic HTML notice.
 */
function mysofthunt_admin_notice() {
    $screen = get_current_screen();
    // Only render this notice in the post editor.
    if ( ! $screen || 'post' !== $screen->base ) {
        return;
    }
    // Render the notice's HTML.
    // Each notice should be wrapped in a <div>
    // with a 'notice' class.
    echo '<div class="notice notice-success is-dismissible"><p>';
    echo sprintf( __( 'Post draft updated. <a href="%s" target="_blank">Preview post</a>' ), get_preview_post_link() );
    echo '</p></div>';
};
add_action( 'admin_notices', 'mysofthunt_admin_notice' );
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Adding #Custom #Admin #Notices #Classic #Editor #wordpress
ADD COMMENT
Topic
Name
9+3 =