This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Whitespace and commenting cleanup.

Also moved caching functions towards bottom of functions.php.
  • Loading branch information...
kwight committed May 4, 2014
1 parent 93ab081 commit f0116fc808a2203ad2173dec12b64f6e58dbf14c
Showing with 77 additions and 67 deletions.
  1. +55 −52 functions.php
  2. +19 −13 inc/customizer.php
  3. +3 −2 readme.txt
View
@@ -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' ) ) {
@@ -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
*/
@@ -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
@@ -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 );
@@ -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.
*/
View
@@ -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',
) );
@@ -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
@@ -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',
),
) ) );
View
@@ -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 =

0 comments on commit f0116fc

Please sign in to comment.