cac/settings/tabs

Deprecated This documentation is deprecated since Admin Columns version 4.

The filter cac/settings/tabs is used to add or remove tabs from the Admin Columns settings screen. Plugins extending Admin Columns can use this to, for example, add an additional settings tab to Admin Columns. It is used by Admin Columns Pro to add import/export functionality.

This filter is usually used alongside the cac/settings/tab_contents filter, which is used to output the content of custom tabs.

Usage

/**
 * Filter the tabs on the settings screen
 *
 * @param array $tabs Available tabs
 */
function my_cac_filter_cac_settings_tabs( $tabs ) {

    // Possibly modify $tabs

    return $tabs;
}
add_filter( 'cac/settings/tabs', 'my_cac_filter_cac_settings_tabs' );

Example

The example below uses cac/settings/tabs and cac/settings/tab_contents to add a tab, predict (with an estimated 92% accuracy rate) whether the currently logged in user is a wizard and display a message accordingly.

/**
 * Add a wizard tab
 *
 */
function my_cac_settings_add_wizard_tab( $tabs ) {

    $tabs['myplugin-information'] = __( 'Am I a wizard?', 'myplugin_textdomain' );

    return $tabs;
}
add_filter( 'cac/settings/tabs', 'my_cac_settings_add_wizard_tab' );

/**
 * Add content to the wizard tab
 *
 */
function my_cac_settings_tab_contents_wizard( $contents ) {
	// Determine with 92% accuracy whether the current user is a wizard, and display a message accordingly
	if ( get_user_meta( get_current_user_id(), 'first_name', true ) == 'Harry' ) {
		$contents = __( 'You're a wizard, Harry.', 'myplugin_textdomain' );
	}
	else {
		$contents = __( 'Nope.', 'myplugin_textdomain' );
	}

	echo $contents;
}
add_action( 'cac/settings/tab_contents/tab=myplugin-information', 'my_cac_settings_tab_contents_wizard' );