ID, '_amy_scripts', true ) ); } add_action( 'wp_head', 'amy_header_scripts' ); add_filter( 'amy_header_scripts', 'do_shortcode' ); /** * Echo the footer scripts. */ function amy_footer_scripts() { echo html_entity_decode( apply_filters( 'amy_footer_scripts', get_theme_mod( 'amy_footer_scripts' ) ) ); } add_action( 'wp_footer', 'amy_footer_scripts' ); add_filter( 'amy_footer_scripts', 'do_shortcode' ); /** * Adds custom classes to the array of body classes. */ function amy_page_layout() { global $post; $custom_layout = get_theme_mod( 'amy_site_layout', 'content-sidebar' ); if ( is_singular() && get_post_meta( $post->ID, 'custom_layout', true ) && get_post_meta( $post->ID, 'custom_layout', true ) != 'default' ) { $custom_layout = get_post_meta( $post->ID, 'custom_layout', true ); } return $custom_layout; } if ( ! function_exists( 'amy_excerpt_more' ) && ! is_admin() ) : /** * Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link. */ function amy_excerpt_more() { $link = sprintf( '%2$s', esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading %s »', 'amy' ), '' . get_the_title( get_the_ID() ) . '' ) ); return ' … ' . $link; } add_filter( 'excerpt_more', 'amy_excerpt_more' ); endif; /** * Returns true if a blog has more than 1 category. * * @return bool */ function amy_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'amy_categories' ) ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'amy_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so amy_categorized_blog should return true. return true; } else { // This blog has only 1 category so amy_categorized_blog should return false. return false; } } /** * Flush out the transients used in amy_categorized_blog. */ function amy_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'amy_categories' ); } add_action( 'edit_category', 'amy_category_transient_flusher' ); add_action( 'save_post', 'amy_category_transient_flusher' );