Advertisement
aknath

Add pro level expire notice in admin bar for sub sites

May 23rd, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. add_action( 'admin_bar_menu', 'add_extension', 999 );
  2.  
  3. function add_extension($wp_admin_bar) {
  4.     if( !is_main_site() ) {
  5.     $id = get_current_blog_id();
  6.     $expire = ProSites::get_expire($id);
  7.     $diff = $expire - time();
  8.     $years = floor($diff / (365*60*60*24));
  9.     $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
  10.     $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
  11.    
  12.     $args = array(
  13.         'id'    => 'pro_level',
  14.         'title' => sprintf("Your Pro Level expires at %d years, %d months, %d days\n", $years, $months, $days),
  15.         'parent' => 'top-secondary'
  16.     );
  17.     $wp_admin_bar->add_node( $args );
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement