.
add_theme_support( 'automatic-feed-links' );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu', 'augustwriting' ) );
// Add support for a variety of post formats
add_theme_support( 'post-formats', array( 'gallery', 'quote' ) );
// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
add_theme_support( 'post-thumbnails' );
add_theme_support('custom-background');
}
endif; // augustwriting_setup
/**
* 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 augustwriting_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'augustwriting_excerpt_length' );
/**
* Returns a "Continue Reading" link for excerpts
*/
function augustwriting_continue_reading_link() {
return ' ' . __( 'Continue reading →', 'augustwriting' ) . '';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and augustwriting_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 augustwriting_auto_excerpt_more( $more ) {
return ' …' . augustwriting_continue_reading_link();
}
add_filter( 'excerpt_more', 'augustwriting_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 augustwriting_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= augustwriting_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'augustwriting_custom_excerpt_more' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*/
function augustwriting_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'augustwriting_page_menu_args' );
/**
* Register our sidebars and widgetized areas. Also register the default Epherma widget.
*/
function augustwriting_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar' ),
'id' => 'sidebar-3',
'before_widget' => '",
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'augustwriting_widgets_init' );
if ( ! function_exists( 'augustwriting_content_nav' ) ) :
/**
* Display navigation to next/previous pages when applicable
*/
function augustwriting_content_nav( $nav_id ) {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) : ?>
]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
return false;
return esc_url_raw( $matches[1] );
}
/**
* Count the number of footer sidebars to enable dynamic classes for the footer
*/
function augustwriting_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 . '"';
}
if ( ! function_exists( 'augustwriting_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own augustwriting_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
*/
function augustwriting_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
by %7$s', 'augustwriting' ),
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', 'augustwriting' ), get_the_author() ) ),
get_the_author()
);
}
endif;
/**
* Adds two classes to the array of body classes.
* The first is if the site has only had one author with published posts.
* The second is if a singular post being displayed
*/
function augustwriting_body_classes( $classes ) {
if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
$classes[] = 'single-author';
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
$classes[] = 'singular';
return $classes;
}
add_filter( 'body_class', 'augustwriting_body_classes' );
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('//i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$site_url = bloginfo('template_url');
$first_img = "$site_url/images/default.jpg";
}
return $first_img;
}