Created
April 18, 2014 16:16
-
-
Save engelen/11052184 to your computer and use it in GitHub Desktop.
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_filter( 'cac/settings/tabs', 'myplugin_cac_settings_tabs' ); | |
/** | |
* Add the tab | |
*/ | |
function myplugin_cac_settings_tabs( $tabs ) { | |
// Add a tab to the list of Admin Columns settings tabs | |
$tabs['myplugin-information'] = __( 'Am I a wizard?', 'myplugin_textdomain' ); | |
return $tabs; | |
} | |
// Applies to myplugin-information tab only | |
// Use the general filter "cac/settings/tab_contents" filter to filter all custom tabs (tab ID is passed as second parameter) | |
add_filter( 'cac/settings/tab_contents/tab=myplugin-information', 'myplugin_cac_settings_tab_contents' ); | |
/** | |
* Change the content of this tab | |
*/ | |
function myplugin_cac_settings_tab_contents( $contents ) { | |
$user = wp_get_current_user(); | |
// Determine with 92% accuracy whether the current user is a wizard, and display a message accordingly | |
if ( get_user_meta( $user->ID, 'first_name', true ) == 'Harry' ) { | |
$contents = __( 'You're a wizard, Harry.', 'myplugin_textdomain' ); | |
} | |
else { | |
$contents = __( 'Nope.', 'myplugin_textdomain' ); | |
} | |
return $contents; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment