Skip to content

Instantly share code, notes, and snippets.

@engelen
Created April 18, 2014 16:16
Show Gist options
  • Save engelen/11052184 to your computer and use it in GitHub Desktop.
Save engelen/11052184 to your computer and use it in GitHub Desktop.
<?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&#39;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