__( 'Primary Menu', 'reddle' ), ) ); /** * Add support for the Aside and Gallery Post Formats */ add_theme_support( 'post-formats', array( 'aside', 'image' ) ); /** * Add in support for post thumbnails */ add_theme_support( 'post-thumbnails' ); /** * Add support for custom backgrounds */ add_theme_support( 'custom-background' ); } endif; // reddle_setup /** * Tell WordPress to run reddle_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'reddle_setup' ); /** * Enqueue scripts and styles */ function reddle_scripts() { wp_enqueue_style( 'reddle-style', get_stylesheet_uri() ); wp_enqueue_script( 'reddle-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151026', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'reddle_scripts' ); /** * Sets the post excerpt length to 40 words. */ function reddle_excerpt_length( $length ) { return 40; } add_filter( 'excerpt_length', 'reddle_excerpt_length' ); /** * Returns a "Continue Reading" link for excerpts */ function reddle_continue_reading_link() { return ' ' . __( 'Continue reading ', 'reddle' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and reddle_continue_reading_link(). */ function reddle_auto_excerpt_more( $more ) { return ' …' . reddle_continue_reading_link(); } add_filter( 'excerpt_more', 'reddle_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 reddle_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= reddle_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'reddle_custom_excerpt_more' ); /** * Register widgetized area */ function reddle_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar 1', 'reddle' ), 'id' => 'sidebar-1', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Sidebar 2', 'reddle' ), 'id' => 'sidebar-2', 'description' => __( 'An optional second sidebar area', 'reddle' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'First Footer Area', 'reddle' ), 'id' => 'sidebar-3', 'description' => __( 'An optional widget area for your site footer', 'reddle' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Second Footer Area', 'reddle' ), 'id' => 'sidebar-4', 'description' => __( 'An optional widget area for your site footer', 'reddle' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Third Footer Area', 'reddle' ), 'id' => 'sidebar-5', 'description' => __( 'An optional widget area for your site footer', 'reddle' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'reddle_widgets_init' ); /** * Add some useful default widgets to the Reddle sidebar */ function reddle_default_widgets() { global $sidebars_widgets; $sidebars = get_option( 'sidebars_widgets' ); if ( empty( $sidebars['sidebar-1'] ) && isset( $_GET['activated'] ) ) { update_option( 'widget_calendar', array( 2 => array( 'title' => __( 'Archives', 'reddle' ) ), '_multiwidget' => 1 ) ); update_option( 'widget_pages', array( 2 => array( 'title' => __( 'Pages', 'reddle' ) ), '_multiwidget' => 1 ) ); update_option( 'widget_tag_cloud', array( 2 => array( 'title' => __( 'Topics', 'reddle' ) ), '_multiwidget' => 1 ) ); update_option( 'widget_meta', array( 2 => array( 'title' => __( 'Info', 'reddle' ) ), '_multiwidget' => 1 ) ); update_option( 'sidebars_widgets', array( 'wp_inactive_widgets' => array(), 'sidebar-1' => array( 0 => 'calendar-2', 1 => 'pages-2', 2 => 'tag_cloud-2', 3 => 'meta-2', ), 'array_version' => 3 ) ); } } add_action( 'after_setup_theme', 'reddle_default_widgets' ); if ( ! function_exists( 'reddle_content_nav' ) ): /** * Display navigation to next/previous pages when applicable * * @since Reddle 1.0 */ function reddle_content_nav( $nav_id ) { global $wp_query; ?> comment_type || 'trackback' == $comment->comment_type ) : ?>
  • id="li-comment-">
    comment_parent ) ? 47 : 23; echo get_avatar( $comment, $comment_avatar_size ); ?>
    comment_approved ) : ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    Posted by ', 'reddle' ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'reddle' ), get_the_author() ) ), esc_html( get_the_author() ) ); } endif; if ( ! function_exists( 'reddle_the_attached_image' ) ) : /** * Prints the attached image with a link to the next attached image. */ function reddle_the_attached_image() { $next_id = null; $post = get_post(); $attachment_size = apply_filters( 'reddle_attachment_size', 1200 ); $attachment_size = array( $attachment_size, $attachment_size ); $next_attachment_url = wp_get_attachment_url(); if ( $post->post_parent ) { /** * Grab the IDs of all the image attachments in a gallery so we can get the * URL of the next adjacent image in a gallery, or the first image (if * we're looking at the last image in a gallery), or, in a gallery of one, * just the link to that image file. */ $attachment_ids = get_posts( array( 'post_parent' => $post->post_parent, 'fields' => 'ids', 'numberposts' => 999, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); // If there is more than 1 attachment in a gallery... if ( is_countable( $attachment_ids ) && count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $idx => $attachment_id ) { if ( $attachment_id == $post->ID ) { $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } } // get the URL of the next image attachment... if ( $next_id ) $next_attachment_url = get_attachment_link( $next_id ); // or get the URL of the first image attachment. else $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); } } printf( '%3$s', esc_url( $next_attachment_url ), the_title_attribute( array( 'echo' => false ) ), wp_get_attachment_image( $post->ID, $attachment_size ) ); } endif; /** * Adds custom classes to the array of body classes. * * @since Reddle 1.0 */ function reddle_body_classes( $classes ) { // We should always have content $classes[] = 'primary'; // If we have 1 sidebar active we have secondary content if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) $classes[] = 'secondary'; // If we have both sidebars active we have tertiary content if ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) ) $classes[] = 'tertiary'; /** * What's going on here? * If there is a 'secondary' class we can override our basic CSS structure to make a 2-column layout * adding some page width and some CSS to accommodate one widget area * and if there is a 'tertiary' class we can override our basic structure to make a 3-column layout * adding more page width and some CSS to accommodate two widget areas */ // Adds a class of index to views that are not posts or pages or search if ( ! is_singular() && ! is_search() ) { $classes[] = 'indexed'; } // Adds a class of single-author to blogs with only 1 published author if ( ! is_multi_author() ) { $classes[] = 'single-author'; } // Add as a class of fixed or fluid depending on whether or not there is or isn't a header image $header_image = get_header_image(); if ( empty( $header_image ) ) { $classes[] = 'fluid'; } else { $classes[] = 'fixed'; } return $classes; } add_filter( 'body_class', 'reddle_body_classes' ); /** * Adds custom classes to the array of post classes. * * @since Reddle 1.0 */ function reddle_post_classes( $classes ) { global $post; // Adds a class of has-featured-image if ( '' != get_the_post_thumbnail() ) { $classes[] = 'has-featured-image'; } return $classes; } add_filter( 'post_class', 'reddle_post_classes' ); /** * Count the number of footer sidebars to enable dynamic classes for the footer * * @since Reddle 1.0 */ function reddle_footer_sidebar_class() { $count = 0; if ( is_active_sidebar( 'sidebar-3' ) ) $count++; if ( is_active_sidebar( 'sidebar-4' ) ) $count++; if ( is_active_sidebar( 'sidebar-5' ) ) $count++; $class = ''; switch ( $count ) { case '1': $class = 'one'; break; case '2': $class = 'two'; break; case '3': $class = 'three'; break; } if ( $class ) echo 'class="' . $class . '"'; } /** * Returns true if a blog has more than 1 category * * @since Reddle 1.0 */ function reddle_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 reddle_categorized_blog should return true return true; } else { // This blog has only 1 category so reddle_categorized_blog should return false return false; } } /** * Flush out the transients used in reddle_categorized_blog * * @since Reddle 1.0 */ function reddle_category_transient_flusher() { // Like, beat it. Dig? delete_transient( 'all_the_cool_cats' ); } add_action( 'edit_category', 'reddle_category_transient_flusher' ); add_action( 'save_post', 'reddle_category_transient_flusher' ); /** * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages */ function reddle_enhanced_image_navigation( $url ) { $post = get_post(); if ( wp_attachment_is_image() && ( $GLOBALS['wp_rewrite']->using_permalinks() && $post->post_parent > 0 && $post->post_parent != $post->ID ) ) $url = $url . '#main'; return $url; } add_filter( 'attachment_link', 'reddle_enhanced_image_navigation' ); /** * Filters wp_title to print a neat tag based on what is being viewed. * * @since Reddle 1.0 */ function reddle_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', 'reddle' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'reddle_wp_title', 10, 2 ); /** * Implement the Custom Header feature */ require get_template_directory() . '/inc/custom-header.php'; /** * Load Jetpack compatibility file. */ if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) ) require get_template_directory() . '/inc/jetpack.php';