post_parent ) && $image->post_parent != $id )
$url .= '#main';
return $url;
}
add_filter( 'attachment_link', 'writr_enhanced_image_navigation', 10, 2 );
/**
* Filters wp_title to print a neat
tag based on what is being viewed.
*/
function writr_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', 'writr' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'writr_wp_title', 10, 2 );
/**
* Returns the URL from the post.
*
* @uses get_the_link() to get the URL in the post meta (if it exists) or
* the first link found in the post content.
*
* Falls back to the post permalink if no URL is found in the post.
*
* @return string URL
*/
function writr_get_link_url() {
$content = get_the_content();
$has_url = get_url_in_content( $content );
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
/**
* Use … instead of [...] for excerpts.
*/
function writr_excerpt_more( $more ) {
return '…';
}
add_filter( 'excerpt_more', 'writr_excerpt_more' );
/**
* Wrap more link
*/
function writr_more_link( $link ) {
return '' . $link . '';
}
add_filter( 'the_content_more_link', 'writr_more_link' );
/**
* Decrease caption width for non-full-width images.
*/
function writr_shortcode_atts_caption( $attr ) {
global $content_width;
if (
'' !== $attr['width']
&& $attr['width'] < $content_width
) {
$attr['width'] -= 10;
}
return $attr;
}
add_filter( 'shortcode_atts_caption', 'writr_shortcode_atts_caption' );
/**
* Creates an HTML list of nav menu items that introduces multi-levels.
*/
class writr_nav_walker extends Walker_Nav_Menu {
// Each time an element is the child of the prior element, this is called.
function start_lvl( &$output, $depth = 0, $args = array() ) {
if ( $depth >= 1 )
$output .= apply_filters( 'walker_nav_menu_start_lvl', '