tag based on what is being viewed. * * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string The filtered title. */ function boardwalk_wp_title( $title, $sep ) { if ( is_feed() ) { return $title; } global $page, $paged; // Add the blog name $title .= get_bloginfo( 'name', 'display' ); // 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 ) && ! is_404() ) { $title .= " $sep " . sprintf( __( 'Page %s', 'boardwalk' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'boardwalk_wp_title', 10, 2 ); /** * Title shim for sites older than WordPress 4.1. * * @link https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ * @todo Remove this function when WordPress 4.3 is released. */ function boardwalk_render_title() { ?> <?php wp_title( '|', true, 'right' ); ?> is_author() && isset( $wp_query->post ) ) { $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); } } add_action( 'wp', 'boardwalk_setup_author' ); /** * 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 boardwalk_get_link_url() { $content = get_the_content(); $has_url = get_url_in_content( $content ); return ( $has_url && has_post_format( 'link' ) ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } /** * Display menu item description. */ function boardwalk_primary_menu_description( $item_output, $item, $depth, $args ) { if ( 'primary' == $args->theme_location && $item->description ) { $item_output = str_replace( $args->link_after . '', '' . $item->description . '' . $args->link_after . '', $item_output ); } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'boardwalk_primary_menu_description', 10, 4 ); /** * Get one image from a specified post in the following order: * Featured Image, first attached image, first image from the_content HTML * * @param int $id, The post ID to check * @param string $size The image size to return, defaults to 'featured-home-big'. * @param string|array $attr Optional. Query string or array of attributes. * @return string $thumb Thumbnail image with markup. */ function boardwalk_get_image( $post_id = null, $size = 'post-thumbnail', $attr = '' ) { $post_id = ( null === $post_id ) ? get_the_ID() : $post_id; if ( '' != get_the_post_thumbnail( $post_id ) ) { return get_the_post_thumbnail( $post_id, $size, $attr ); } $attached_images = get_attached_media( 'image' ); if ( ! empty( $attached_images ) ) { $first_attached_image = array_shift( $attached_images ); return wp_get_attachment_image( $first_attached_image->ID, $size, false, $attr ); } if ( class_exists( 'Jetpack_PostImages' ) ) { global $_wp_additional_image_sizes; $args = array( 'from_thumbnail' => false, 'from_slideshow' => true, 'from_gallery' => true, 'from_attachment' => false, ); $image = Jetpack_PostImages::get_image( $post_id, $args ); if ( ! empty( $image ) ) { $image['width'] = ''; $image['height'] = ''; if ( array_key_exists( $size, $_wp_additional_image_sizes ) ) { $image['width'] = $_wp_additional_image_sizes[$size]['width']; $image['height'] = $_wp_additional_image_sizes[$size]['height']; } $image_src = Jetpack_PostImages::fit_image_url( $image['src'], $image['width'], $image['height'] ); return ''; } } return false; }