Created
March 18, 2015 19:22
-
-
Save wpmark/1dba36c8a04160ea7709 to your computer and use it in GitHub Desktop.
WordPress Dashboard Tabs
This file contains 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 | |
/*************************************************************** | |
* Function wpbasis_dashboard_content() | |
* Pulls in the new dashboard page content from plugin file | |
***************************************************************/ | |
function wpbasis_dashboard() { | |
/* check for a dashboard content file in the theme folder */ | |
if( file_exists( STYLESHEETPATH . '/wpbasis/dashboard.php' ) ) { | |
/* load the dashboard content file from the theme folder */ | |
get_template_part( 'wpbasis/dashboard', 'content' ); | |
/* lets output the content of the dashboard */ | |
} else { | |
?> | |
<div class="wrap about-wrap wpbasis-dashboard-wrap"> | |
<h1><?php bloginfo( 'name' ); ?><br />Dashboard</h1> | |
<?php | |
/*************************************************************** | |
* @hooked wpbasis_dashboard_about_text | |
***************************************************************/ | |
do_action( 'wpbasis_dashboard_about_text' ); | |
?> | |
<div class="wpbasis-tabs-wrapper"> | |
<ul class="wpbasis-tabs"> | |
<?php | |
/*************************************************************** | |
* set an array of tab titles and ids | |
* the id set here should match the id given to the content wrapper | |
* which has the class wpbasis-tab-content included in the callback | |
* function | |
***************************************************************/ | |
$wpbasis_dashboard_tabs = apply_filters( | |
'wpbasis_dashboard_tabs', | |
array( | |
'welcome' => array( | |
'id' => '#wpbasis-welcome', | |
'label' => 'Welcome', | |
), | |
) | |
); | |
/* check we have items to show */ | |
if( ! empty( $wpbasis_dashboard_tabs ) ) { | |
/* loop through each item */ | |
foreach( $wpbasis_dashboard_tabs as $wpbasis_dashboard_tab ) { | |
?> | |
<li><a href="<?php echo esc_attr( $wpbasis_dashboard_tab[ 'id' ] ); ?>"><?php echo esc_html( $wpbasis_dashboard_tab[ 'label' ] ); ?></a></li> | |
<?php | |
} | |
} | |
?> | |
</ul> | |
<?php | |
/* set an array of tab content blocks */ | |
$wpbasis_dashboard_tabs_contents = apply_filters( | |
'wpbasis_dashboard_tabs_contents', | |
array( | |
'welcome' => array( | |
'callback' => 'wpbasis_dashboard_welcome_tab', | |
), | |
) | |
); | |
/* check we have items to show */ | |
if( ! empty( $wpbasis_dashboard_tabs_contents ) ) { | |
/* loop through each item */ | |
foreach( $wpbasis_dashboard_tabs_contents as $wpbasis_dashboard_tabs_content ) { | |
/* run the callback function for showing the content */ | |
$wpbasis_dashboard_tabs_content[ 'callback' ](); | |
} | |
} | |
?> | |
</div><!-- // wpbasis-tabs-wrapper --> | |
</div> | |
<?php | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment