Created
June 4, 2019 16:03
-
-
Save erikasarti/1304c78ae07ff9853063b0022babbbfa to your computer and use it in GitHub Desktop.
Como exibir uma mensagem no painel administrativo do WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('admin_notices', 'meu_aviso'); | |
function meu_aviso() { | |
global $current_user ; | |
$user_id = $current_user->ID; | |
if ( ! get_user_meta($user_id, 'ignorar_aviso') ) { | |
echo '<div class="updated"><p>'; | |
printf(__('<strong>Aviso!</strong> O manual de atualização do WordPress foi atualizado e a nova versão está disponível na Intranet. <a href="%1$s">Não mostrar essa mensagem novamente</a>'), '?ignorar_aviso=0'); | |
echo '</p></div>'; | |
} | |
} | |
add_action('admin_init', 'ignorar_aviso'); | |
function ignorar_aviso() { | |
global $current_user; | |
$user_id = $current_user->ID; | |
if ( isset($_GET['ignorar_aviso']) && '0' == $_GET['ignorar_aviso'] ) { | |
add_user_meta($user_id, 'ignorar_aviso', 'true', true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment