__( 'Sidebar Menu', 'dusktodawn' ), ) ); // Add support for Post Formats add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'video', 'quote', 'link', 'chat', 'audio' ) ); } endif; // dusktodawn_setup // Tell WordPress to run dusktodawn_setup() when the 'after_setup_theme' hook is run. add_action( 'after_setup_theme', 'dusktodawn_setup' ); /** * Setup the WordPress core custom background feature. * * Hooks into the after_setup_theme action. */ function dusktodawn_register_custom_background() { add_theme_support( 'custom-background', apply_filters( 'dusktodawn_custom_background_args', array( 'default-color' => '', 'default-image' => '', ) ) ); } add_action( 'after_setup_theme', 'dusktodawn_register_custom_background' ); function dusktodawn_custom_background() { if ( '' != get_background_image() ) : ?> __( 'Sidebar 1', 'dusktodawn' ), 'id' => 'sidebar-1', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'dusktodawn_widgets_init' ); // Display navigation to next/previous pages when applicable function dusktodawn_content_nav( $nav_id ) { global $wp_query; ?> by ', 'dusktodawn' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'dusktodawn' ), get_the_author() ) ), esc_html( get_the_author() ) ); } // Adds custom classes to the array of body classes. function dusktodawn_body_classes( $classes ) { // Adds a class of single-author to blogs with only 1 published author if ( ! is_multi_author() ) { $classes[] = 'single-author'; } return $classes; } add_filter( 'body_class', 'dusktodawn_body_classes' ); // Returns true if a blog has more than 1 category function dusktodawn_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 = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0; set_transient( 'all_the_cool_cats', $all_the_cool_cats ); } if ( '1' != $all_the_cool_cats ) { // This blog has more than 1 category so dusktodawn_categorized_blog should return true return true; } else { // This blog has only 1 category so dusktodawn_categorized_blog should return false return false; } } // Flush out the transients used in dusktodawn_categorized_blog function dusktodawn_category_transient_flusher() { // Like, beat it. Dig? delete_transient( 'all_the_cool_cats' ); } add_action( 'edit_category', 'dusktodawn_category_transient_flusher' ); add_action( 'save_post', 'dusktodawn_category_transient_flusher' ); function dusktodawn_post_meta() { if ( is_singular() ) : /* translators: used between list items, there is a space after the comma */ $category_list = get_the_category_list( __( ', ', 'dusktodawn' ) ); /* translators: used between list items, there is a space after the comma */ $tag_list = get_the_tag_list( '', ', ' ); if ( ! dusktodawn_categorized_blog() ) { // This blog only has 1 category so we just need to worry about tags in the meta text if ( '' != $tag_list && ! is_wp_error( $tag_list ) ) { $meta_text = __( 'This entry was tagged %2$s.
Bookmark the permalink.
', 'dusktodawn' ); } else { $meta_text = __( 'Bookmark the permalink.
', 'dusktodawn' ); } } else { // But this blog has loads of categories so we should probably display them here if ( '' != $tag_list && ! is_wp_error( $tag_list ) ) { $meta_text = __( 'This entry was posted in %1$s and tagged %2$s.
Bookmark the permalink.
', 'dusktodawn' ); } else { $meta_text = __( 'This entry was posted in %1$s.
Bookmark the permalink.
', 'dusktodawn' ); } } // end check for categories on this blog printf( $meta_text, $category_list, $tag_list, get_permalink(), the_title_attribute( 'echo=0' ) ); else : /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( __( ', ', 'dusktodawn' ) ); if ( $categories_list && dusktodawn_categorized_blog() ) : ?>

post_parent ?? null; if ( wp_attachment_is_image() && ( $wp_rewrite->using_permalinks() && ( $post_parent > 0 ) && ( $post_parent != get_the_ID() ) ) ) $url = $url . '#main'; return $url; } add_filter( 'attachment_link', 'dusktodawn_enhanced_image_navigation' ); // Enqueue font styles. function dusktodawn_fonts() { wp_enqueue_style( 'ubuntu', "https://fonts.googleapis.com/css?family=Ubuntu:300,400,700" ); } add_action( 'wp_enqueue_scripts', 'dusktodawn_fonts' ); /** * Appends post title to Aside and Quote posts * * @param string $content * @return string */ function dusktodawn_conditional_title( $content ) { if ( has_post_format( 'aside' ) || has_post_format( 'quote' ) ) { if ( ! is_singular() ) $content .= the_title( '

', '

', false ); else $content .= the_title( '

', '

', false ); } return $content; } add_filter( 'the_content', 'dusktodawn_conditional_title', 0 ); /** * Filters wp_title to print a neat tag based on what is being viewed. * * @since Dusk To Dawn 1.1 */ function dusktodawn_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', 'dusktodawn' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'dusktodawn_wp_title', 10, 2 ); if ( ! function_exists( 'dusktodawn_audio_player_class' ) ) : /** * 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 dusktodawn_audio_player_class( $post_id ) { $mime = get_post_mime_type( $post_id ); $short = array( 'audio/mpeg' => 'mp3', 'audio/ogg' => 'ogg', 'audio/wav' => 'wav', ); if ( isset( $short[ $mime ] ) ) return ' ' . $short[ $mime ]; return ''; } endif; if ( ! function_exists( 'dusktodawn_has_shortcode' ) ) : /** * Check to see whether a given shortcode exists. * * @param string $name The name of the shortcode. * @return bool True if shortcode exists; false otherwise. */ function dusktodawn_has_shortcode( $name ) { global $shortcode_tags; return ( ! is_string( $name ) || ! isset( $shortcode_tags[ $name ] ) ); } endif; /** * Deprecated. * * This function is kept just in case it has * been used in a child theme. It does nothing. */ function dusktodawn_add_audio_support() { _deprecated_function( __FUNCTION__ , '1.2' ); } /** * Load up our functions for grabbing content from posts. */ require( get_template_directory() . '/content-grabbers.php' ); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Load theme options. */ require get_template_directory() . '/inc/theme-options.php'; /** * Load Jetpack compatibility file. */ if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) ) require get_template_directory() . '/inc/jetpack.php'; /** * This theme was built with PHP, Semantic HTML, CSS, love, and a Toolbox. */