Permalink
Browse files

LESS Part 9: Widgets

And some formatting clean up in widget-related-posts.php
  • Loading branch information...
1 parent 9a080f9 commit b4393dd8568d21700528806c870e323fa27dc42a @jayj committed Oct 13, 2012
Showing with 98 additions and 128 deletions.
  1. +10 −12 functions/widget-related-posts.php
  2. +36 −43 style.dev.css
  3. +52 −73 style.dev.less
@@ -11,6 +11,7 @@
* @link http://wpthemes.jayj.dk/cakifo
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
*/
+
class Cakifo_Widget_Related_Posts extends WP_Widget {
/**
@@ -23,16 +24,13 @@ function __construct() {
/* Set up the widget options. */
$widget_options = array(
'classname' => 'related-posts',
- 'description' => esc_html__( 'Use this widget to list related posts to the current viewed post based on category and post format.', 'cakifo' )
+ 'description' => esc_html__( 'Use this widget to list related posts to the current viewed post, based on taxonomies.', 'cakifo' )
);
/* Create the widget. */
- $this->WP_Widget(
- 'cakifo-related-posts', // $this->id_base
- __( 'Cakifo: Related Posts', 'cakifo' ), // $this->name
- $widget_options // $this->widget_options
- );
+ $this->WP_Widget( 'cakifo-related-posts', __( 'Cakifo: Related Posts', 'cakifo' ), $widget_options );
+ /* Flush the cache when a post is updated or deleted */
add_action( 'save_post', array( &$this, 'flush_widget_cache' ) );
add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) );
}
@@ -122,7 +120,7 @@ function widget( $sidebar, $instance ) {
do_atomic( 'after_related_posts_list' ); // cakifo_after_related_posts_list
- // Nope, no related posts
+ /* Nope, no related posts */
else :
_e( 'No related posts.', 'cakifo' );
@@ -134,8 +132,8 @@ function widget( $sidebar, $instance ) {
}
/**
- * Gets the related posts based on the category and post format
- * and puts them in a custom field
+ * Gets the related posts based on the choosen taxonomies
+ * and puts them in the post meta
*
* @access private
* @param int $post_id
@@ -187,7 +185,7 @@ private function _get_related_posts( $post_id, $args ) {
/**
* Post formats query
*/
- if ( in_array( 'post_format', $taxonomies ) ) :
@jayj

jayj Oct 13, 2012

Owner

Oops! Fixed in 6ab0f05

+ if ( in_array( 'post_format', $taxonomies ) )
$format = ( get_post_format() ) ? 'post-format-' . get_post_format() : '';
$related_query['tax_query'][] = array(
@@ -251,7 +249,7 @@ function flush_widget_cache( $post_ID = null ) {
/* A post is being updated or deleted */
if ( isset( $post_ID ) ) :
// Delete the related post meta for all the related posts
- if ( isset( $related_meta ) ) :
+ if ( isset( $related_meta ) ) {
$related_posts = array( $post_ID );
@@ -260,7 +258,7 @@ function flush_widget_cache( $post_ID = null ) {
foreach( get_posts( array( 'include' => $related_posts, 'post_type' => 'post' ) ) as $postinfo )
delete_post_meta( $postinfo->ID, 'related' );
- endif;
+ }
// The widget settings has been updated: delete the post meta for all posts
else :
View
@@ -179,6 +179,7 @@ h6 {
padding: 8px 20px;
margin: 0 0 25px;
text-shadow: 0 1px 0 #fff;
+ letter-spacing: -1px;
}
.widget-title a {
color: #333333;
@@ -1858,10 +1859,10 @@ table caption {
margin-right: 2px;
padding: 13px 14px 12px;
text-shadow: 0 1px 0 #ffffff;
- -webkit-transition: all 150ms ease-in-out;
- -moz-transition: all 150ms ease-in-out;
- -o-transition: all 150ms ease-in-out;
- transition: all 150ms ease-in-out;
+ -webkit-transition: all 150ms ease;
+ -moz-transition: all 150ms ease;
+ -o-transition: all 150ms ease;
+ transition: all 150ms ease;
}
.pagination a:hover {
background-color: #ffc768;
@@ -1896,50 +1897,41 @@ table caption {
word-wrap: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
+ -o-hyphens: auto;
hyphens: auto;
}
-#sidebar-after-singular .widget .textwidget,
-#sidebar-after-single .widget .textwidget {
- padding: 0 20px;
-}
/**
- * Calendar
- */
-#wp-calendar tr th,
-#wp-calendar thead th,
-#wp-calendar tr td {
+ * Calendar
+ */
+#wp-calendar th,
+#wp-calendar td {
padding: 5px;
text-align: center;
}
-#sidebar-subsidiary #wp-calendar th,
-#sidebar-subsidiary #wp-calendar tr td {
- font-size: 12px;
- padding: 0px 0px;
-}
/**
- * Related Posts widget
- */
+ * Related Posts widget
+ */
/* Related Posts with thumbnails turned on */
.related-posts .with-thumbnails {
list-style-type: none;
- margin: 0 25px;
+ padding: 0;
+ margin: 0;
}
.related-posts .with-thumbnails .related-post {
- background: #fff;
- border: 1px solid #e7e7e7;
- box-shadow: 0 2px 0 #e7e7e7;
+ background: #ffffff;
border-radius: 3px;
- width: 100px;
- height: 100px;
+ border: 1px solid #e6e6e6;
+ width: 110px;
+ height: 110px;
float: left;
- margin-right: 15px;
+ margin-right: 25px;
}
.related-posts .with-thumbnails .related-post:hover {
- background: #d54e21;
- border-color: #9b000f;
- color: #fff;
- text-shadow: 0 -1px 0 #7b000f;
- box-shadow: 0 2px 0 #9b000f;
+ background: #ffc768;
+ border-color: #f89406;
+ box-shadow: 0 2px 0 #f89406;
+ color: #511d0c;
+ text-shadow: 0 1px 0 #ffedce;
}
.related-posts .with-thumbnails .related-post:nth-of-type(5n) {
margin-right: 0;
@@ -1948,25 +1940,26 @@ table caption {
display: block;
width: 100%;
height: 100%;
+ padding-top: 4px;
text-align: center;
- word-wrap: break-word;
overflow: hidden;
+ word-wrap: break-word;
+ -webkit-hyphens: auto;
+ -moz-hyphens: auto;
+ -o-hyphens: auto;
+ hyphens: auto;
}
.related-posts .with-thumbnails .related-post > a:hover {
- color: #fff;
+ color: #511d0c;
}
.related-posts .with-thumbnails .related-post img {
- border: none;
- padding: 0;
- max-width: 100%;
+ box-shadow: none;
}
.related-posts .with-thumbnails .related-post span {
- font: 13px 'PT Serif', Georgia, serif;
-}
-/* IE fixes */
-.related-posts .with-thumbnails .related-post {
- margin-right: 7px;
- margin-left: 7px;
+ font-family: 'PT Serif', Georgia, Cambria, "Bitstream Charter", serif;
+ font-size: 13px;
+ font-weight: normal;
+ line-height: 1.8;
}
/* =============================================================================
Layout: Comments
View
@@ -163,6 +163,7 @@ h6 {
/* Widget titles */
.widget-title {
.widget-title-bar;
+ letter-spacing: -1px;
// Links
a {
@@ -799,7 +800,7 @@ sub {
margin-right: 2px;
padding: 13px 14px 12px;
text-shadow: 0 1px 0 @white;
- .transition(all 150ms ease-in-out);
+ .transition(all 150ms ease);
}
a:hover {
@@ -840,94 +841,72 @@ sub {
========================================================================== */
.widget {
- margin-bottom: 25px;
- word-wrap: break-word;
- -webkit-hyphens: auto;
- -moz-hyphens: auto;
- hyphens: auto;
-}
-
-#sidebar-after-singular .widget .textwidget,
-#sidebar-after-single .widget .textwidget {
- padding: 0 20px;
+ margin-bottom: @smallGutterWidth;
+ .hyphens;
}
- /**
- * Calendar
- */
- #wp-calendar tr th,
- #wp-calendar thead th,
- #wp-calendar tr td {
+/**
+ * Calendar
+ */
+#wp-calendar {
+ th, td {
padding: 5px;
text-align: center;
}
+}
- #sidebar-subsidiary #wp-calendar th,
- #sidebar-subsidiary #wp-calendar tr td {
- font-size: 12px;
- padding: 0px 0px;
- }
-
- /**
- * Related Posts widget
- */
+/**
+ * Related Posts widget
+ */
- /* Related Posts with thumbnails turned on */
- .related-posts .with-thumbnails {
- list-style-type: none;
- margin: 0 25px;
- }
+/* Related Posts with thumbnails turned on */
+.related-posts .with-thumbnails {
+ list-style-type: none;
+ padding: 0;
+ margin: 0;
- .related-posts .with-thumbnails .related-post {
- background: #fff;
- border: 1px solid #e7e7e7;
- box-shadow: 0 2px 0 #e7e7e7;
+ .related-post {
+ background: @white;
border-radius: 3px;
- width: 100px;
- height: 100px;
+ border: 1px solid darken(@grayLighter, 3%);
+ .square(110px);
float: left;
- margin-right: 15px;
- }
+ margin-right: @smallGutterWidth;
- .related-posts .with-thumbnails .related-post:hover {
- background: #d54e21;
- border-color: #9b000f;
- color: #fff;
- text-shadow: 0 -1px 0 #7b000f;
- box-shadow: 0 2px 0 #9b000f;
- }
-
- .related-posts .with-thumbnails .related-post:nth-of-type(5n) {
- margin-right: 0;
- }
-
- .related-posts .with-thumbnails .related-post > a {
- display: block;
- width: 100%; height: 100%;
- text-align: center;
- word-wrap: break-word;
- overflow: hidden;
- }
+ &:hover {
+ background: @orangeLight;
+ border-color: @orange;
+ box-shadow: 0 2px 0 @orange;
+ color: darken(@orangeDark, 30%);
+ text-shadow: 0 1px 0 lighten(@orangeLight, 20%);
+ }
- .related-posts .with-thumbnails .related-post > a:hover {
- color: #fff;
- }
+ &:nth-of-type(5n) {
+ margin-right: 0;
+ }
- .related-posts .with-thumbnails .related-post img {
- border: none;
- padding: 0;
- max-width: 100%;
- }
+ > a {
+ display: block;
+ .square(100%);
+ padding-top: 4px;
+ text-align: center;
+ overflow: hidden;
+ .hyphens;
+
+ &:hover {
+ color: darken(@orangeDark, 30%);
+ }
+ }
- .related-posts .with-thumbnails .related-post span {
- font: 13px 'PT Serif', Georgia, serif;
- }
+ img {
+ box-shadow: none;
+ }
- /* IE fixes */
- .related-posts .with-thumbnails .related-post {
- margin-right: 7px;
- margin-left: 7px;
+ span {
+ #font > .alternative(13px);
+ }
}
+}
/* =============================================================================
Layout: Comments

0 comments on commit b4393dd

Please sign in to comment.