Advertisement
Guest User

Admin Messages for WordPress Plugin Dev

a guest
Mar 12th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. /* Display a notice that can be dismissed */
  2. add_action('admin_notices', 'jwl_admin_notice');
  3. function jwl_admin_notice() {
  4.     global $current_user ;
  5.         $user_id = $current_user->ID;
  6.         /* Check that the user hasn't already clicked to ignore the message */
  7.     if ( ! get_user_meta($user_id, 'jwl_ignore_notice') ) {
  8.         global $pagenow;
  9.         if ( $pagenow == 'plugins.php' ) {
  10.         echo '<div class="updated"><p>';
  11.         printf(__('Thank you for choosing Google Webfonts.  Please visit the <a href="admin.php?page=ultimate-tinymce-google">Settings Page</a> to get started. | <a href="%1$s">Dismiss</a>'), '?jwl_nag_ignore=0');
  12.         echo "</p></div>";
  13.         }
  14.     }
  15. }
  16. add_action('admin_init', 'jwl_nag_ignore');
  17. function jwl_nag_ignore() {
  18.     global $current_user;
  19.         $user_id = $current_user->ID;
  20.         /* If user clicks to ignore the notice, add that to their user meta */
  21.         if ( isset($_GET['jwl_nag_ignore']) && '0' == $_GET['jwl_nag_ignore'] ) {
  22.              add_user_meta($user_id, 'jwl_ignore_notice', 'true', true);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement