__( 'Main Menu', 'esquire' ), ) ); // Add post thumbnail support for audio album art add_theme_support( 'post-thumbnails' ); add_image_size( 'audio', 207, 207, false ); /** * Enable Post Formats */ add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'quote', 'link', 'audio', 'video' ) ); /** * Load up our functions for grabbing content from posts */ require( get_template_directory() . '/content-grabbers.php' ); } add_action( 'after_setup_theme', 'esquire_setup' ); /** * Sniff out the number of categories in use and return the number of categories */ function esquire_category_counter() { 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 = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0; set_transient( 'all_the_cool_cats', $all_the_cool_cats ); } return $all_the_cool_cats; } /** * Flush out the transients used in esquire_category_counter */ function esquire_category_transient_flusher() { // Like, beat it. Dig? delete_transient( 'all_the_cool_cats' ); } add_action( 'edit_category', 'esquire_category_transient_flusher' ); add_action( 'save_post', 'esquire_category_transient_flusher' ); /** * Add a class to the Older Posts link */ function esquire_next_posts_link_attributes( $attr ) { return 'rel="prev"'; } add_filter( 'next_posts_link_attributes', 'esquire_next_posts_link_attributes' ); /** * Add a class to the Newer Posts link */ function esquire_previous_posts_link_attributes( $attr ) { return 'rel="next"'; } add_filter( 'previous_posts_link_attributes', 'esquire_previous_posts_link_attributes' ); /** * Sets the post excerpt length to 40 words. * * To override this length in a child theme, remove the filter and add your own * function tied to the excerpt_length filter hook. */ function esquire_excerpt_length( $length ) { return 40; } add_filter( 'excerpt_length', 'esquire_excerpt_length' ); /** * Returns a "Continue reading" link for excerpts */ function esquire_continue_reading_link() { return ' ' . __( 'Continue reading ', 'esquire' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and esquire_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. */ function esquire_auto_excerpt_more( $more ) { return ' …' . esquire_continue_reading_link(); } add_filter( 'excerpt_more', 'esquire_auto_excerpt_more' ); /** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. */ function esquire_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= esquire_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'esquire_custom_excerpt_more' ); /** * Register our footer widget area * * @since Esquire 1.0 */ function esquire_widgets_init() { register_sidebar( array( 'name' => __( 'Footer', 'esquire' ), 'id' => 'sidebar-1', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'esquire_widgets_init' ); /** * Template for comments and pingbacks. * Used as a callback by wp_list_comments() for displaying the comments. * * @since Esquire 1.0 */ function esquire_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  • ', '' ); ?>

  • id="li-comment-">
    said:', 'esquire' ), sprintf( '%s', get_comment_author_link() ), sprintf( '', esc_url( get_comment_link( $comment->comment_ID ) ), get_comment_time( 'c' ), /* translators: 1: date, 2: time */ sprintf( __( '%1$s at %2$s', 'esquire' ), get_comment_date(), get_comment_time() ) ) ); ?> ', '' ); ?>
    comment_approved == '0' ) : ?>
    __( 'Reply ', 'esquire' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    ', '
    ' ); if ( $first_image && defined( 'WPCOM_THEMES_IMAGE_REPLACE_REGEX' ) ) $content = preg_replace( WPCOM_THEMES_IMAGE_REPLACE_REGEX, $first_image, $content, 1 ); $content = wp_kses_post( $content ); } return $content; } if ( ! is_admin() ) add_filter( 'the_content', 'esquire_the_content', 11 ); /** * Add extra markup to VideoPress embeds. * * @param string $html Video content from VideoPress plugin. * @return string Updated content with extra markup. */ function esquire_video_embed_html( $html ) { return sprintf( '
    %s
    ', $html ); } /** * Add extra markup to auto-embedded videos. * * @param string $html Content from the auto-embed plugin. * @param string $url Link embedded in the post, used to determine if this is a video we want to filter. * @return string Updated content with extra markup. */ function esquire_check_video_embeds( $html, $url ) { if ( false !== ( strstr( $url, 'youtube' ) ) || false !== ( strstr( $url, 'vimeo' ) ) ) $html = esquire_video_embed_html( $html ); return $html; } /** * Get a short-form mime type for an audio file to display as a class attribute. * * @param int ID of an attachment * @return string A short representation of the file's mime type. */ function esquire_post_classes( $classes ) { if ( has_post_format( 'audio' ) ) { $audio = esquire_audio_grabber( get_the_ID() ); if ( ! empty( $audio ) && is_object( $audio ) ) { $mime = str_replace( 'audio/', '', get_post_mime_type( $audio->ID ) ); if ( in_array( $mime, array( 'mp3', 'ogg', 'wav', ) ) ) $classes[] = $mime; } } return $classes; } add_filter( 'post_class', 'esquire_post_classes' ); if ( ! function_exists( 'the_post_format_audio' ) ) : /** * Shiv for the_post_format_audio(). * * the_post_format_audio() was introduced to WordPress in version 3.6. To * provide backward compatibility with previous versions, we will define our * own version of this function. * * @todo Remove this function when WordPress 3.8 is released. * * @param string $name The name of the shortcode. * @return bool True if shortcode exists; False otherwise. */ function the_post_format_audio() { $audio = esquire_audio_grabber( get_the_ID() ); if ( ! empty( $audio ) && is_object( $audio ) ) : $url = wp_get_attachment_url( $audio->ID ); ?>
    tag based on what is being viewed. * * @since Esquire 1.1.1 */ function esquire_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() ) return $title; // Add the blog name $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title .= " $sep $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) $title .= " $sep " . sprintf( __( 'Page %s', 'esquire' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'esquire_wp_title', 10, 2 ); /** * Load Jetpack compatibility file. */ if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) ) require get_template_directory() . '/inc/jetpack.php';