Permalink
Browse files

Fixing bootstapwp_autoset_featured_img function

  • Loading branch information...
rachelbaker committed Jul 10, 2012
1 parent 273c800 commit 0cb2a739947b80d57f48fa52c55de7ad2f2dd78a
Showing with 1,404 additions and 1,389 deletions.
  1. +26 −4 README.md
  2. +3 −4 archive.php
  3. +3 −4 author.php
  4. +34 −18 functions.php
  5. +1 −1 less/bootstrap.less
  6. +1 −1 less/bswp-overrides.less
  7. +3 −3 less/button-groups.less
  8. +38 −36 less/buttons.less
  9. +9 −1 less/carousel.less
  10. +2 −2 less/code.less
  11. +38 −30 less/forms.less
  12. +3 −3 less/mixins.less
  13. +28 −6 less/navbar.less
  14. +1 −2 less/pager.less
  15. +1 −1 less/progress-bars.less
  16. +3 −2 less/thumbnails.less
  17. +26 −50 less/type.less
  18. +15 −13 less/variables.less
  19. +4 −3 page-blog.php
  20. +1,165 −1,205 page-styleguide.php
View
@@ -39,21 +39,43 @@ 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)
+##v.90 Changelog (still baking)
-__Functions.php__
+__The goals of this release are:__
-* 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'.
+1. Add Theme Options Screen
+2. Fix Custom Walker Menu PHP errors
+3. Fix Automatic Thumbnail PHP errors
+4. Remove any unnecessary theme files
+5. Update styles and scripts to Bootstrap 2.10 dev branch
+
+__Archive.php__
+
+* Replaced conditional for `the_post_thumbnail()` with `bootstrapwp_autoset_featured_img()`.
+
+__Author.php__
+
+* Replaced conditional for `the_post_thumbnail()` with `bootstrapwp_autoset_featured_img()`.
__Class-bootstrapwp-walker-nav_menu.php__
* Extending Walker_Nav_Menu to modify class assigned to submenu ul element.
+__Functions.php__
+
+* Fixed `bootstrapwp_autoset_featured_img()` function to return if there is no image set, clearing debug errors.
+* Removed the post hooks for `bootstrap_autoset_featured_img()` function to clear debug errors.
+* Added `bootstrapwp_post_thumbnail_check()` function to check if the post displayed in the loop has a post thumbnail already.
+* Removed Custom Walker class from file and replaced with external include call for file 'includes/class-bootstrap_walker_nav_menu.php'.
+
__Index.php__
* Removed unnecessary double loop for page title.
+__Page-blog.php__
+
+* Replaced conditional for `the_post_thumbnail()` with `bootstrapwp_autoset_featured_img()`.
+
__Docs Folder__
* Removed entire 'docs' folder to clean up theme files.
View
@@ -54,10 +54,9 @@
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><h3><?php the_title();?></h3></a>
<p class="meta"><?php echo bootstrapwp_posted_on();?></p>
<div class="row">
- <div class="span2"><?php // Checking for a post thumbnail
- if ( has_post_thumbnail() ) ?>
- <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
- <?php the_post_thumbnail();?></a>
+ <div class="span2">
+ <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
+ <?php echo bootstrapwp_autoset_featured_img(); ?></a>
</div><!-- /.span2 -->
<div class="span6">
<?php the_excerpt();?>
View
@@ -44,10 +44,9 @@
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><h3><?php the_title();?></h3></a>
<p class="meta"><?php echo bootstrapwp_posted_on();?></p>
<div class="row">
- <div class="span2"><?php // Checking for a post thumbnail
- if ( has_post_thumbnail() ) ?>
- <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
- <?php the_post_thumbnail();?></a>
+ <div class="span2">
+ <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
+ <?php echo bootstrapwp_autoset_featured_img(); ?></a>
</div><!-- /.span2 -->
<div class="span6">
<?php the_excerpt();?>
View
@@ -52,10 +52,9 @@ function bootstrapwp_theme_setup() {
/**
* Add support for the Aside and Gallery Post Formats
*/
- add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery' ) );
+ add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery', 'link', 'quote', 'status', 'video', 'audio', 'chat' ) );
}
-endif; // twentyeleven_header_style
-
+endif;
################################################################################
// Loading All CSS Stylesheets
@@ -373,33 +372,50 @@ function bootstrapwp_enhanced_image_navigation( $url ) {
}
add_filter( 'attachment_link', 'bootstrapwp_enhanced_image_navigation' );
+
+/*
+| -------------------------------------------------------------------
+| Checking for Post Thumbnail
+| -------------------------------------------------------------------
+|
+| */
+function bootstrapwp_post_thumbnail_check() {
+ global $post;
+ if (get_the_post_thumbnail()) {
+ return true; }
+ else { return false; }
+}
+
/*
| -------------------------------------------------------------------
| Setting Featured Image (Post Thumbnail)
| -------------------------------------------------------------------
| Will automatically add the first image attached to a post as the Featured Image if post does not have a featured image previously set.
| */
function bootstrapwp_autoset_featured_img() {
- global $post;
- $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) {
+ $post_thumbnail = bootstrapwp_post_thumbnail_check();
+ if ($post_thumbnail == true ){
+ return the_post_thumbnail();
+ }
+ if ($post_thumbnail == false ){
+ $image_args = array(
+ 'post_type' => 'attachment',
+ 'numberposts' => 1,
+ 'post_mime_type' => 'image',
+ 'post_parent' => $post->ID,
+ 'order' => 'desc'
+ );
+ $attached_image = get_children( $image_args );
+ if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
- } elseif (!$attached_image) {
- return;
- }
- }
+ return the_post_thumbnail();
+ } else { return " ";}
+ }
} //end function
-add_action('the_post', 'bootstrapwp_autoset_featured_img');
-add_action('save_post', 'bootstrapwp_autoset_featured_img');
-add_action('draft_to_publish', 'bootstrapwp_autoset_featured_img');
-add_action('new_to_publish', 'bootstrapwp_autoset_featured_img');
-add_action('pending_to_publish', 'bootstrapwp_autoset_featured_img');
-add_action('future_to_publish', 'bootstrapwp_autoset_featured_img');
+
/*
| -------------------------------------------------------------------
View
@@ -1,5 +1,5 @@
/*!
- * Bootstrap v2.0.3
+ * Bootstrap v2.0.4
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
View
@@ -1,4 +1,4 @@
-// BSWP OVERRIDES v0.87
+// BSWP OVERRIDES v0.90
/********************************************************
Overriding some defaults from the Bootstrap defaults to improve/fix integration with WordPress
-------------------------------------------------- */
View
@@ -34,16 +34,16 @@
}
.btn-group > .btn,
.btn-group > .dropdown-menu {
- font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack
+ font-size: 13px; // redeclare as part 2 of font-size inline-block hack
}
// Reset fonts for other sizes
.btn-group > .btn-mini,
.btn-group > .btn-small {
- font-size: @baseFontSize - 2px;
+ font-size: 12px;
}
.btn-group > .btn-large {
- font-size: @baseFontSize + 2px;
+ font-size: 16px;
}
// Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
View
@@ -10,10 +10,10 @@
.btn {
display: inline-block;
.ie7-inline-block();
- padding: 4px 10px 4px;
+ padding: 4px 14px;
margin-bottom: 0; // For input.btn
- font-size: @baseFontSize;
- line-height: @baseLineHeight;
+ font-size: 13px;
+ line-height: 20px;
*line-height: 20px;
color: @grayDark;
text-align: center;
@@ -27,47 +27,49 @@
.border-radius(4px);
.ie7-restore-left-whitespace(); // Give IE7 some love
.box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
-}
-// Hover state
-.btn:hover {
- color: @grayDark;
- text-decoration: none;
- background-color: darken(@white, 10%);
- *background-color: darken(@white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
- background-position: 0 -15px;
+ // Hover state
+ &:hover {
+ color: @grayDark;
+ text-decoration: none;
+ background-color: darken(@white, 10%);
+ *background-color: darken(@white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
+ background-position: 0 -15px;
+
+ // transition is only when going to hover, otherwise the background
+ // behind the gradient (there for IE<=9 fallback) gets mismatched
+ .transition(background-position .1s linear);
+ }
- // transition is only when going to hover, otherwise the background
- // behind the gradient (there for IE<=9 fallback) gets mismatched
- .transition(background-position .1s linear);
-}
+ // Focus state for keyboard and accessibility
+ &:focus {
+ .tab-focus();
+ }
-// Focus state for keyboard and accessibility
-.btn:focus {
- .tab-focus();
-}
+ // Active state
+ &.active,
+ &:active {
+ background-color: darken(@white, 10%);
+ background-color: darken(@white, 15%) e("\9");
+ background-image: none;
+ outline: 0;
+ .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
+ }
-// Active state
-.btn.active,
-.btn:active {
- background-color: darken(@white, 10%);
- background-color: darken(@white, 15%) e("\9");
- background-image: none;
- outline: 0;
- .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
-}
+ // Disabled state
+ &.disabled,
+ &[disabled] {
+ cursor: default;
+ background-color: darken(@white, 10%);
+ background-image: none;
+ .opacity(65);
+ .box-shadow(none);
+ }
-// Disabled state
-.btn.disabled,
-.btn[disabled] {
- cursor: default;
- background-color: darken(@white, 10%);
- background-image: none;
- .opacity(65);
- .box-shadow(none);
}
+
// Button Sizes
// --------------------------------------------------
View
@@ -105,6 +105,7 @@
}
}
+
// Caption for text below images
// -----------------------------
@@ -113,11 +114,18 @@
left: 0;
right: 0;
bottom: 0;
- padding: 10px 15px 5px;
+ padding: 15px;
background: @grayDark;
background: rgba(0,0,0,.75);
}
.carousel-caption h4,
.carousel-caption p {
color: @white;
+ line-height: @baseLineHeight;
+}
+.carousel-caption h4 {
+ margin: 0 0 5px;
+}
+.carousel-caption p {
+ margin-bottom: 0;
}
View
@@ -8,7 +8,7 @@ code,
pre {
padding: 0 3px 2px;
#font > #family > .monospace;
- font-size: @baseFontSize - 1;
+ font-size: @baseFontSize - 2;
color: @grayDark;
.border-radius(3px);
}
@@ -26,7 +26,7 @@ pre {
display: block;
padding: (@baseLineHeight - 1) / 2;
margin: 0 0 @baseLineHeight / 2;
- font-size: @baseFontSize * .925; // 13px to 12px
+ font-size: @baseFontSize - 2; // 14px to 12px
line-height: @baseLineHeight;
word-break: break-all;
word-wrap: break-word;
Oops, something went wrong.

0 comments on commit 0cb2a73

Please sign in to comment.