Permalink
Browse files

Starting v.90 with PHP Debugging fixes for nav menu and automatic thu…

…mbnails.
  • Loading branch information...
1 parent 18007f5 commit c3b607a905242d9450a60cde9c1d46f78a069dbc @rachelbaker committed Jul 6, 2012
Showing with 79 additions and 28 deletions.
  1. +10 −0 README.md
  2. +41 −27 functions.php
  3. +8 −1 header.php
  4. +20 −0 includes/class-bootstrapwp_walker_nav_menu.php
View
@@ -39,6 +39,16 @@ Bug tracker
**Report theme bugs** [https://github.com/rachelbaker/bootstrapwp-Twitter-Bootstrap-for-WordPress/issues](https://github.com/rachelbaker/bootstrapwp-Twitter-Bootstrap-for-WordPress/issues)
+##v.90 Changelog (in progress)
+
+__Functions.php__
+
+* Fixed bootstrapwp_autoset_featured_img() function to return if there is no image set, clearing debug errors.
+* Removed Custom Walker class from file and replaced with external include call for file 'includes/class-bootstrap_walker_nav_menu.php'
+
+__Class-bootstrapwp-walker-nav_menu.php__
+
+* Extending Walker_Nav_Menu to modify class assigned to submenu ul element
##v.87 of BootstrapWP - Released June 4, 2012
View
@@ -14,6 +14,9 @@
* Last Updated: June 3, 2012
*/
+if (!defined('BOOTSTRAPWP_VERSION'))
+define('BOOTSTRAPWP_VERSION', '.90');
+
/**
* Declaring the content width based on the theme's design and stylesheet.
*/
@@ -25,6 +28,35 @@
*/
load_theme_textdomain('bootstrapwp');
+/*
+| -------------------------------------------------------------------
+| Setup Theme
+| -------------------------------------------------------------------
+|
+| */
+add_action( 'after_setup_theme', 'bootstrapwp_theme_setup' );
+if ( ! function_exists( 'bootstrapwp_theme_setup' ) ):
+function bootstrapwp_theme_setup() {
+ /**
+ * Add default posts and comments RSS feed links to head
+ */
+ add_theme_support( 'automatic-feed-links' );
+
+ /**
+ * Adds custom menu with wp_page_menu fallback
+ */
+ register_nav_menus( array(
+ 'main-menu' => __( 'Main Menu', 'bootstrapwp' ),
+ ) );
+
+ /**
+ * Add support for the Aside and Gallery Post Formats
+ */
+ add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery' ) );
+}
+endif; // twentyeleven_header_style
+
+
################################################################################
// Loading All CSS Stylesheets
################################################################################
@@ -48,14 +80,8 @@ function bootstrapwp_js_loader() {
/*
| -------------------------------------------------------------------
-| Registering Top Navigation Bar
+| Top Navigation Bar Customization
| -------------------------------------------------------------------
-| Adds custom menu with wp_page_menu fallback
-| */
-if ( function_exists( 'register_nav_menu' ) ) {
-register_nav_menu( 'main-menu', 'Main Menu' );
-}
-
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
@@ -67,14 +93,10 @@ function bootstrapwp_page_menu_args( $args ) {
add_filter( 'wp_page_menu_args', 'bootstrapwp_page_menu_args' );
/**
- * Custom Walker to change submenu class items from default "sub-menu" to ""
- */
-class Bootstrapwp_Walker_Nav_Menu extends Walker_Nav_Menu {
- function start_lvl(&$output, $depth) {
- $indent = str_repeat("\t", $depth);
- $output .= "\n$indent<ul class=\"dropdown-menu\">\n";
- }
-}
+ * Get file 'includes/class-bootstrap_walker_nav_menu.php' with Custom Walker class methods
+ * */
+
+include 'includes/class-bootstrapwp_walker_nav_menu.php';
/*
| -------------------------------------------------------------------
@@ -144,18 +166,7 @@ function bootstrapwp_widgets_init() {
-function bootstrapwp_theme_setup() {
- /**
- * Add default posts and comments RSS feed links to head
- */
- add_theme_support( 'automatic-feed-links' );
-
- /**
- * Add support for the Aside and Gallery Post Formats
- */
- add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery' ) );
-}
-add_action( 'after_setup_theme', 'bootstrapwp_theme_setup' );
+
/*
| -------------------------------------------------------------------
@@ -373,10 +384,13 @@ function bootstrapwp_autoset_featured_img() {
$already_has_thumb = has_post_thumbnail($post->ID);
if (!$already_has_thumb) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
+
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
+ } elseif (!$attached_image) {
+ return;
}
}
} //end function
View
@@ -66,7 +66,14 @@
<a class="brand" href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
<?php
/** Loading WordPress Custom Menu with Fallback to wp_list_pages **/
- wp_nav_menu( array( 'walker' => new bootstrapwp_walker_nav_menu(), 'menu' => 'main-menu', 'container_class' => 'nav-collapse', 'menu_class' => 'nav', 'menu_id' => 'main-menu')); ?>
+ wp_nav_menu( array(
+ 'menu' => 'main-menu',
+ 'container_class' => 'nav-collapse',
+ 'menu_class' => 'nav',
+ 'fallback_cb' => '',
+ 'menu_id' => 'main-menu',
+ 'walker' => new Bootstrapwp_Walker_Nav_Menu()
+ ) ); ?>
</div>
</div>
</div>
@@ -0,0 +1,20 @@
+<?php
+ /**
+ * class Bootstrap_Walker_Nav_Menu()
+ *
+ * Extending Walker_Nav_Menu to modify class assigned to submenu ul element
+ *
+ * @author Rachel Baker
+ **/
+class Bootstrapwp_Walker_Nav_Menu extends Walker_Nav_Menu {
+
+ function __construct() {
+
+ }
+ function start_lvl(&$output, $depth) {
+
+ $indent = str_repeat("\t", $depth);
+ $output .= "\n$indent<ul class=\"dropdown-menu\">\n";
+ }
+
+}

0 comments on commit c3b607a

Please sign in to comment.