Created
July 25, 2014 16:09
-
-
Save bappi-d-great/f2f3c8ebbc4d0377b0e6 to your computer and use it in GitHub Desktop.
WPM Pro Sites: Add pro level expire notice in admin bar for sub sites
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
<?php | |
add_action( 'admin_bar_menu', 'add_extension', 999 ); | |
function add_extension($wp_admin_bar) { | |
if( !is_main_site() ) { | |
$id = get_current_blog_id(); | |
$expire = ProSites::get_expire($id); | |
$diff = $expire - time(); | |
$years = floor($diff / (365*60*60*24)); | |
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); | |
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); | |
$args = array( | |
'id' => 'pro_level', | |
'title' => sprintf("Your Pro Level expires at %d years, %d months, %d days\n", $years, $months, $days), | |
'parent' => 'top-secondary' | |
); | |
$wp_admin_bar->add_node( $args ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment