Created
May 10, 2012 23:06
-
-
Save jazzsequence/2656479 to your computer and use it in GitHub Desktop.
Modular theme options
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
function ap_core_do_theme_options() { | |
ap_core_tab_setup(); | |
ap_core_general_settings(); | |
ap_core_typography_settings(); | |
ap_core_advanced_settings(); | |
} |
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
function ap_core_general_settings() { | |
$options_before = '<table class="form-table" id="tabs-1">'; | |
$options_after = '</table>'; | |
echo $options_before; | |
ap_core_sidebar_option(); | |
ap_core_posts_excerpts_option(); | |
ap_core_footer_option(); | |
ap_core_presstrends_option(); | |
echo $options_after; | |
} |
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
<form method="post" action="options.php"> | |
<div id="tabs"> | |
<?php settings_fields( 'AP_CORE_OPTIONS' ); ?> | |
<?php ap_core_do_theme_options(); ?> | |
</div> | |
<p class="submit"> | |
<input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'museum-core' ); ?>" /> | |
<input type="hidden" name="ap-core-settings-submit" value="Y" /> | |
</p> | |
</form> |
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
function do_my_custom_theme_options() { | |
my_custom_tab_setup(); | |
ap_core_general_settings(); | |
ap_core_typography_settings(); | |
ap_core_advanced_settings(); | |
my_custom_theme_settings(); | |
} |
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
function my_custom_tab_setup() { | |
ob_start(); | |
?> | |
<div class="tab-wrap"> | |
<ul class="nav-tab-wrapper"> | |
<li><?php screen_icon(); ?></li> | |
<li><h2><a class="nav-tab" href="#tabs-1"><?php _e('General','museum-core'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-2"><?php _e('Font Stuff','my-theme'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-3"><?php _e('Advanced','museum-core'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-4"><?php _e('Custom Tab','my-theme'); ?></a></h2></li> | |
</ul> | |
</div> | |
<?php | |
$tabs = ob_get_contents(); | |
ob_end_clean(); | |
echo $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
function my_custom_theme_settings() { | |
$options = get_option( 'my_custom_theme_options' ); | |
ob_start(); | |
?> | |
<table class="form-table" id="tabs-4"> | |
<tr valign="top"><th scope="row"><?php _e( 'Hello World!', 'museum-core' ); ?></th> | |
<td> | |
<select name="ap_core_theme_options[hello]"> | |
<?php | |
$selected = $options['hello']; | |
foreach ( ap_core_true_false() as $option ) { | |
$label = $option['label']; | |
$value = $option['value']; | |
echo '<option value="' . $value . '" ' . selected( $selected, $value ) . '>' . $label . '</option>'; | |
} ?> | |
</select><br /> | |
<label class="description" for="my_custom_theme_options[hello]"><?php _e( 'Some description of my setting.', 'museum-core' ); ?></label> | |
</td> | |
</tr> | |
</table> | |
<?php | |
$custom = ob_get_contents(); | |
ob_end_clean(); | |
echo $custom; | |
} |
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 | |
if (!function_exists('ap_core_do_theme_options')) { | |
function ap_core_do_theme_options() { | |
do_my_custom_theme_options(); | |
} | |
} | |
function do_my_custom_theme_options() { | |
my_custom_tab_setup(); | |
ap_core_general_settings(); | |
ap_core_typography_settings(); | |
ap_core_advanced_settings(); | |
my_custom_theme_settings(); | |
} | |
function my_custom_tab_setup() { | |
ob_start(); | |
?> | |
<div class="tab-wrap"> | |
<ul class="nav-tab-wrapper"> | |
<li><?php screen_icon(); ?></li> | |
<li><h2><a class="nav-tab" href="#tabs-1"><?php _e('General','museum-core'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-2"><?php _e('Font Stuff','my-theme'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-3"><?php _e('Advanced','museum-core'); ?></a></h2></li> | |
<li><h2><a class="nav-tab" href="#tabs-4"><?php _e('Custom Tab','my-theme'); ?></a></h2></li> | |
</ul> | |
</div> | |
<?php | |
$tabs = ob_get_contents(); | |
ob_end_clean(); | |
echo $tabs; | |
} | |
function my_custom_theme_settings() { | |
$options = get_option( 'my_custom_theme_options' ); | |
ob_start(); | |
?> | |
<table class="form-table" id="tabs-4"> | |
<tr valign="top"><th scope="row"><?php _e( 'Hello World!', 'museum-core' ); ?></th> | |
<td> | |
<select name="ap_core_theme_options[hello]"> | |
<?php | |
$selected = $options['hello']; | |
foreach ( ap_core_true_false() as $option ) { | |
$label = $option['label']; | |
$value = $option['value']; | |
echo '<option value="' . $value . '" ' . selected( $selected, $value ) . '>' . $label . '</option>'; | |
} ?> | |
</select><br /> | |
<label class="description" for="my_custom_theme_options[hello]"><?php _e( 'Some description of my setting.', 'museum-core' ); ?></label> | |
</td> | |
</tr> | |
</table> | |
<?php | |
$custom = ob_get_contents(); | |
ob_end_clean(); | |
echo $custom; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment