Skip to content

Commit

Permalink
First pass at integrating Theme options
Browse files Browse the repository at this point in the history
  • Loading branch information
chipbennett committed Jan 26, 2011
1 parent a9eb30c commit 9de6286
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Register/Initialize Theme Options
// Admin Settings Page
// Contextual Help
//require_once( TEMPLATEPATH . '/functions/functions-options.php' );
require_once( '/functions/functions-options.php' );


/*
Expand Down
10 changes: 5 additions & 5 deletions functions/functions-options-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function oenology_setting_header_nav_menu_position() {
<label for="oenology_header_nav_menu_position">
Display header navigation menu above or below the site title/description?<br />
<select name="theme_oenology_options[header_nav_menu_position]">
<option <?php if ( 'above' == $oenology_options['header_nav_menu_position'] ) echo 'selected="selected"'; ?> value="above">Above</option>
<option <?php if ( 'below' == $oenology_options['header_nav_menu_position'] ) echo 'selected="selected"'; ?> value="below">Below</option>
<option <?php selected( 'above' == $oenology_options['header_nav_menu_position'] ); ?> value="above">Above</option>
<option <?php selected( 'below' == $oenology_options['header_nav_menu_position'] ); ?> value="below">Below</option>
</select>
</label>
</p>
Expand All @@ -60,8 +60,8 @@ function oenology_setting_footer_credit() {
<label for="oenology_footer_credit">
Display a credit link in the footer? This option is disabled by default, and you are under no obligation whatsoever to enable it.<br />
<select name="theme_oenology_options[footer_credit]">
<option <?php if ( true == $oenology_options['footer_credit'] ) echo 'selected="selected"'; ?> value="true">Do Not Display</option>
<option <?php if ( false == $oenology_options['footer_credit'] ) echo 'selected="selected"'; ?> value="false">Display</option>
<option <?php selected( false == $oenology_options['footer_credit'] ); ?> value="false">Do Not Display</option>
<option <?php selected( true == $oenology_options['footer_credit'] ); ?> value="true">Display</option>
</select>
</label>
</p>
Expand All @@ -77,7 +77,7 @@ function oenology_options_validate( $input ) {

$valid_input = $oenology_options;

$valid_input['header_nav_menu_location'] = ( 'below' == $input['header_nav_menu_location'] ? 'below' : 'above' );
$valid_input['header_nav_menu_position'] = ( 'below' == $input['header_nav_menu_position'] ? 'below' : 'above' );
$valid_input['footer_credit'] = ( 'true' == $input['footer_credit'] ? true : false );

return $valid_input;
Expand Down
7 changes: 4 additions & 3 deletions functions/functions-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*******************************************************************************************/
global $oenology_options_default;
$oenology_options_default = array(
'header_nav_menu_position' => 'top',
'header_nav_menu_position' => 'above',
'display_footer_credit' => false,
'theme_version' => '1.1'
);
Expand All @@ -34,8 +34,9 @@ function oenology_options_init() {
$oenology_options = get_option( 'theme_oenology_options' );

if ( false === $oenology_options ) {
$oenology_options_initial = $oenology_options_default;
$oenology_options = $oenology_options_default;
}
update_option( 'theme_oenology_options', $oenology_options );
}
// Initialize Theme options
add_action('after_setup_theme', 'oenology_options_init', 9 );
Expand All @@ -48,7 +49,7 @@ function oenology_options_init() {
// Add "Theme Options" link to the "Appearance" menu
function oenology_menu() {
global $oenology_admin_options_hook;
$oenology_admin_options_hook = add_theme_page('Theme Options', 'oenology', 'edit_theme_options', 'oenology', 'oenology_admin_options_page');
$oenology_admin_options_hook = add_theme_page('Theme Options', 'Oenology Options', 'edit_theme_options', 'oenology', 'oenology_admin_options_page');
}
// Load the Admin Options page
add_action('admin_menu', 'oenology_menu');
Expand Down
5 changes: 4 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

<!-- End HTML Header -->

<?php /*
<?php
global $oenology_options;
$oenology_options = get_option( 'theme_oenology_options' );
/*
Reference:
=============================================================================
The following functions, tags, and hooks are used (or referenced) in this Theme template file:
Expand Down
16 changes: 13 additions & 3 deletions site-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
This content is the same for all primary template page types (index.php, single.php, archive.php, page.php).
*/
?>
<!-- Begin Nav Bar -->
<?php get_template_part('site-navigation'); // site-navigation.php contains the main navigation menu. ?>
<!-- End Nav Bar -->

<?php
echo 'Header Nav Menu Position: ' . $oenology_options['header_nav_menu_position'];
if ( 'above' == $oenology_options['header_nav_menu_position'] ) {
get_template_part('site-navigation'); // site-navigation.php contains the main navigation menu.
}
?>

<div><?php bloginfo('name'); // Displays the blog name, as defined on the General Settings page in the administration panel ?></div>
<p><?php bloginfo('description'); // Displays the blog description, as defined on the General Settings page in the administration panel ?></p>

<?php
if ( 'below' == $oenology_options['header_nav_menu_position'] ) {
get_template_part('site-navigation'); // site-navigation.php contains the main navigation menu. ?
}
?>

<?php /*
Reference:
=============================================================================
Expand Down

0 comments on commit 9de6286

Please sign in to comment.