Skip to content

Commit

Permalink
Merge pull request #48 from mikevalstar/master
Browse files Browse the repository at this point in the history
Orphaned H1 closing tag, moved div row tag, and theme options page for sidebar
  • Loading branch information
rachelbaker committed Apr 28, 2012
2 parents 26cb2bc + 6439866 commit 1ad135c
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 21 deletions.
5 changes: 4 additions & 1 deletion 404.php
Expand Up @@ -8,6 +8,7 @@
*
* Last Revised: January 22, 2012
*/
$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<div class="row">
<div class="container">
Expand All @@ -25,6 +26,7 @@
</header>

<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar(); ?>
<div class="span8">


Expand All @@ -49,6 +51,7 @@
</div><!--/.span4 -->
</div><!--/.row -->
</div><!--/.span8 -->
<?php get_sidebar(); ?>
<?php if($options['sidebar_pos'] != 'left') get_sidebar(); ?>
</div><!-- /.row .content -->

<?php get_footer(); ?>
7 changes: 4 additions & 3 deletions archive.php
Expand Up @@ -11,7 +11,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.6
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header();
if (have_posts() ) ;?>
<div class="row">
Expand Down Expand Up @@ -44,10 +44,10 @@
_e( 'Blog Archives', 'bootstrapwp' );
}
?></h1>
</h1>
</header>

<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar('blog'); ?>
<div class="span8">
<?php while ( have_posts() ) : the_post(); ?>
<div <?php post_class(); ?>>
Expand All @@ -69,6 +69,7 @@
<?php bootstrapwp_content_nav('nav-below');?>

</div><!-- /.span8 -->
<?php get_sidebar('blog'); ?>
<?php if($options['sidebar_pos'] != 'left') get_sidebar('blog'); ?>
</div><!-- /.row .content -->

<?php get_footer(); ?>
6 changes: 4 additions & 2 deletions author.php
Expand Up @@ -6,7 +6,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.1
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>

<?php if ( have_posts() ) : ?>
Expand Down Expand Up @@ -37,6 +37,7 @@
rewind_posts();
?>
<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar('blog'); ?>
<div class="span8">
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
Expand All @@ -58,6 +59,7 @@
<?php endwhile; ?>
<?php endif; ?>
</div><!-- /.span8 -->
<?php get_sidebar('blog'); ?>
<?php if($options['sidebar_pos'] != 'left') get_sidebar('blog'); ?>
</div><!-- /.row .content -->

<?php get_footer(); ?>
5 changes: 5 additions & 0 deletions functions.php
Expand Up @@ -13,6 +13,11 @@
*
* Last Updated: April 11, 2012
*/

/**
* Declaring the theme options
*/
require_once ( get_stylesheet_directory() . '/theme-options.php' );

/**
* Declaring the content width based on the theme's design and stylesheet.
Expand Down
1 change: 1 addition & 0 deletions index.php
Expand Up @@ -10,6 +10,7 @@
*
* Last Revised: March 4, 2012
*/
$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Expand Down
6 changes: 4 additions & 2 deletions page-blog.php
Expand Up @@ -7,7 +7,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.1
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="row">
Expand All @@ -23,6 +23,7 @@
</header>

<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar('blog'); ?>
<div class="span8">
<?php the_content();
endwhile;
Expand Down Expand Up @@ -58,5 +59,6 @@
<?php bootstrapwp_content_nav('nav-below');?>

</div><!-- /.span8 -->
<?php get_sidebar('blog'); ?>
<?php if($options['sidebar_pos'] != 'left') get_sidebar('blog'); ?>
</div><!-- /.row .content -->
<?php get_footer(); ?>
2 changes: 1 addition & 1 deletion page-full-width.php
Expand Up @@ -7,7 +7,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.1
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="row">
Expand Down
7 changes: 4 additions & 3 deletions page.php
Expand Up @@ -9,7 +9,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.1
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="row">
Expand All @@ -27,13 +27,14 @@
</header>

<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar(); ?>
<div class="span8">

<?php the_content();?>
<?php endwhile; // end of the loop. ?>
</div><!-- /.span8 -->

<?php get_sidebar(); ?>

<?php if($options['sidebar_pos'] != 'left') get_sidebar(); ?>
</div><!-- /.row .content -->

<?php get_footer(); ?>
6 changes: 5 additions & 1 deletion search.php
Expand Up @@ -10,6 +10,7 @@
*
* Last Revised: January 22, 2012
*/
$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<div class="container">
<?php if ( have_posts() ) : ?>
Expand All @@ -21,6 +22,7 @@

</header>
<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar(); ?>
<div class="span8">
<?php while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><h2> <?php the_title();?></h2></a>
Expand All @@ -36,6 +38,7 @@
<p class="lead"><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps you should try again with a different search term.', 'bootstrapwp' ); ?></p>
</header>
<div class="row content">
<?php if($options['sidebar_pos'] == 'left') get_sidebar(); ?>
<div class="span8">


Expand All @@ -50,5 +53,6 @@

</div><!--/.span8 -->

<?php get_sidebar(); ?>
<?php if($options['sidebar_pos'] != 'left') get_sidebar(); ?>
</div><!-- /.row .content -->
<?php get_footer(); ?>
4 changes: 1 addition & 3 deletions sidebar-blog.php
Expand Up @@ -13,6 +13,4 @@
if ( function_exists('dynamic_sidebar')) dynamic_sidebar("sidebar-posts");
?>
</div><!--/.well .sidebar-nav -->
</div><!-- /.span4 -->
</div><!-- /.row .content -->

</div><!-- /.span4 -->
3 changes: 1 addition & 2 deletions sidebar.php
Expand Up @@ -13,6 +13,5 @@
if ( function_exists('dynamic_sidebar')) dynamic_sidebar("sidebar-page");
?>
</div><!--/.well .sidebar-nav -->
</div><!-- /.span4 -->
</div><!-- /.row .content -->
</div><!-- /.span4 -->

7 changes: 4 additions & 3 deletions single.php
Expand Up @@ -10,7 +10,7 @@
* @subpackage WP-Bootstrap
* @since WP-Bootstrap 0.1
*/

$options = get_option( 'bootstrapwp_theme_options' );
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="row">
Expand All @@ -28,6 +28,7 @@

<div class="row content">
<div class="span8">
<?php if($options['sidebar_pos'] == 'left') get_sidebar('blog'); ?>
<p class="meta"><?php echo bootstrapwp_posted_on();?></p>
<?php the_content();?>
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
Expand All @@ -38,7 +39,7 @@
<?php bootstrapwp_content_nav('nav-below');?>

</div><!-- /.span8 -->
<?php get_sidebar('blog'); ?>

<?php if($options['sidebar_pos'] != 'left') get_sidebar('blog'); ?>
</div><!-- /.row .content -->

<?php get_footer(); ?>
95 changes: 95 additions & 0 deletions theme-options.php
@@ -0,0 +1,95 @@
<?php

add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );

/**
* Init plugin options to white list our options
*/
function theme_options_init(){
register_setting( 'bootstrapwp_options', 'bootstrapwp_theme_options', 'theme_options_validate' );
}

/**
* Load up the menu page
*/
function theme_options_add_page() {
add_theme_page( __( 'Theme Options', 'bootstrapwp_theme' ), __( 'Theme Options', 'bootstrapwp_theme' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );
}

$sidebar_pos_options = array(
'right' => array(
'value' => 'right',
'label' => __( 'Right', 'bootstrapwp_theme' )
),
'left' => array(
'value' => 'left',
'label' => __( 'Left', 'bootstrapwp_theme' )
),
);

/**
* Create the options page
*/
function theme_options_do_page() {
global $sidebar_pos_options;

if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false;

$options = get_option( 'bootstrapwp_theme_options' );

if ( !isset($options['sidebar_pos']) || is_null($options['sidebar_pos']) || $options['sidebar_pos'] == '')
$options['sidebar_pos'] = 'right';

?>
<div class="wrap">
<?php screen_icon(); echo "<h2>" . get_current_theme() . __( ' Theme Options', 'bootstrapwp_theme' ) . "</h2>"; ?>

<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e( 'Options saved', 'bootstrapwp_theme' ); ?></strong></p></div>
<?php endif; ?>

<form method="post" action="options.php">
<?php settings_fields( 'bootstrapwp_options' ); ?>
<table class="form-table">
<tr valign="top"><th scope="row"><?php _e( 'Show sidebar on left or right', 'bootstrapwp_theme' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Show sidebar on left or right', 'bootstrapwp_theme' ); ?></span></legend>
<?php
foreach ( $sidebar_pos_options as $option ) {
$checked = ( $options['sidebar_pos'] == $option['value'] ) ? "checked=\"checked\"" : '';
?>
<label class="description"><input type="radio" name="bootstrapwp_theme_options[sidebar_pos]" value="<?php esc_attr_e( $option['value'] ); ?>" <?php echo $checked; ?> /> <?php echo $option['label']; ?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>

</table>

<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'bootstrapwp_theme' ); ?>" />
</p>
</form>
</div>
<?php
}

/**
* Sanitize and validate input. Accepts an array, return a sanitized array.
*/
function theme_options_validate( $input ) {
global $sidebar_pos_options;

// Our radio option must actually be in our array of radio options
if ( ! isset( $input['sidebar_pos'] ) )
$input['sidebar_pos'] = 'right';
if ( ! array_key_exists( $input['sidebar_pos'], $sidebar_pos_options ) )
$input['sidebar_pos'] = 'right';


return $input;
}

0 comments on commit 1ad135c

Please sign in to comment.