Skip to content
This repository has been archived by the owner on Apr 21, 2018. It is now read-only.

Commit

Permalink
Whitespace and commenting cleanup.
Browse files Browse the repository at this point in the history
Also moved caching functions towards bottom of functions.php.
  • Loading branch information
kwight committed May 4, 2014
1 parent 93ab081 commit f0116fc
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 67 deletions.
107 changes: 55 additions & 52 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Adjust content width for the full-width template.
*
* @since 2.0
* @since 1.7
*/
function debut_content_width() {
if ( is_page_template( 'full-width.php' ) ) {
Expand Down Expand Up @@ -147,7 +147,7 @@ function debut_scripts() {


/**
* Add html5.js script to <head> conditionally for IE8 and under
* Add html5shiv script to <head> conditionally for IE8 and under
*
* @since 1.0.4
*/
Expand Down Expand Up @@ -224,49 +224,6 @@ function debut_posted_on() {
endif;


/**
* Returns true if a blog has more than one category
*
* @since 1.0
*/
if ( ! function_exists( 'debut_categorized_blog' ) ) :
function debut_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
// Create an array of all the categories that are attached to posts
$all_the_cool_cats = get_categories( array(
'hide_empty' => 1,
) );

// Count the number of categories that are attached to the posts
$all_the_cool_cats = count( $all_the_cool_cats );

set_transient( 'all_the_cool_cats', $all_the_cool_cats );
}

if ( '1' != $all_the_cool_cats ) {
// This blog has more than 1 category so debut_categorized_blog should return true
return true;
} else {
// This blog has only 1 category so debut_categorized_blog should return false
return false;
}
}
endif;


/**
* Flush out the transients used in debut_categorized_blog
*
* @since 1.0
*/
function debut_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' );
}
add_action( 'edit_category', 'debut_category_transient_flusher' );
add_action( 'save_post', 'debut_category_transient_flusher' );


/**
* Generate comment HTML
* Based on the P2 theme by Automattic
Expand Down Expand Up @@ -334,18 +291,21 @@ function debut_comment_form_args( $args ) {
* @since 1.0
*/
function debut_remove_caption_width( $current_html, $attr, $content ) {
extract(shortcode_atts(array(
extract( shortcode_atts( array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $content;
'caption' => '',
), $attr ) );
if ( 1 > (int) $width || empty( $caption ) ) {
return $content;
}

if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
if ( $id ) {
$id = 'id="' . esc_attr( $id ) . '" ';
}

return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . (int) $width . 'px">'
return '<div ' . $id . 'class="wp-caption ' . esc_attr( $align ) . '" style="width: ' . (int) $width . 'px">'
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
add_filter( 'img_caption_shortcode', 'debut_remove_caption_width', 10, 3 );
Expand Down Expand Up @@ -523,6 +483,49 @@ function debut_setup_author() {
add_action( 'wp', 'debut_setup_author' );


/**
* Returns true if a blog has more than one category
*
* @since 1.0
*/
if ( ! function_exists( 'debut_categorized_blog' ) ) :
function debut_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
// Create an array of all the categories that are attached to posts
$all_the_cool_cats = get_categories( array(
'hide_empty' => 1,
) );

// Count the number of categories that are attached to the posts
$all_the_cool_cats = count( $all_the_cool_cats );

set_transient( 'all_the_cool_cats', $all_the_cool_cats );
}

if ( '1' != $all_the_cool_cats ) {
// This blog has more than 1 category so debut_categorized_blog should return true
return true;
} else {
// This blog has only 1 category so debut_categorized_blog should return false
return false;
}
}
endif;


/**
* Flush out the transients used in debut_categorized_blog
*
* @since 1.0
*/
function debut_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' );
}
add_action( 'edit_category', 'debut_category_transient_flusher' );
add_action( 'save_post', 'debut_category_transient_flusher' );


/**
* Include out Theme Customizer code.
*/
Expand Down
32 changes: 19 additions & 13 deletions inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
* @since 1.5
*/
function debut_theme_customizer( $wp_customize ) {

// Highlight and link color
$wp_customize->add_setting( 'debut_link_color', array(
'default' => '#ff0000',
'transport' => 'postMessage',
'default' => '#ff0000',
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color',
) );

Expand All @@ -31,13 +33,15 @@ function debut_theme_customizer( $wp_customize ) {
'priority' => 30,
'description' => 'Upload a logo to replace the default site name and description in the header',
) );

$wp_customize->add_setting( 'debut_logo', array(
'sanitize_callback' => 'esc_url_raw',
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'debut_logo', array(
'label' => __( 'Logo', 'debut' ),
'section' => 'debut_logo_section',
'settings' => 'debut_logo',
'label' => __( 'Logo', 'debut' ),
'section' => 'debut_logo_section',
'settings' => 'debut_logo',
) ) );

// Choose excerpt or full content on blog
Expand All @@ -46,18 +50,20 @@ function debut_theme_customizer( $wp_customize ) {
'priority' => 30,
'description' => 'Change how Debut displays posts',
) );

$wp_customize->add_setting( 'debut_post_content', array(
'default' => 'option1',
'default' => 'option1',
'sanitize_callback' => 'debut_sanitize_index_content',
) );

$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'debut_post_content', array(
'label' => __( 'Post content', 'debut' ),
'section' => 'debut_layout_section',
'settings' => 'debut_post_content',
'type' => 'radio',
'choices' => array(
'option1' => 'Excerpts',
'option2' => 'Full content',
'label' => __( 'Post content', 'debut' ),
'section' => 'debut_layout_section',
'settings' => 'debut_post_content',
'type' => 'radio',
'choices' => array(
'option1' => 'Excerpts',
'option2' => 'Full content',
),
) ) );

Expand Down
5 changes: 3 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ Chrome, Firefox, Safari and IE9+ are supported. IE7 and IE8 are not supported, b

More detail on the theme [commit page](https://github.com/kwight/debut/commits?page=1).

= 2.0 =
= 1.7 =

* Enhancement: removed the silly slider
* Enhancement: removed the slider (was never publicly released)
* Bug fix: styling fixes

= 1.6 =

Expand Down

0 comments on commit f0116fc

Please sign in to comment.