post_parent ) && $image->post_parent != $id ) $url .= '#main'; return $url; } add_filter( 'attachment_link', 'spun_enhanced_image_navigation', 10, 2 ); /** * Remove widget title header if no title is entered. * @todo Remove this function when this is fixed in core. */ function spun_calendar_widget_title( $title = '', $instance = '', $id_base = '' ) { if ( 'calendar' == $id_base && ' ' == $title ) $title = ''; return $title; } add_filter( 'widget_title', 'spun_calendar_widget_title', 10, 3 ); /** * Filter archives to display one less post per page to account for the .page-title circle */ function spun_limit_posts_per_archive_page() { if ( ! is_home() && is_archive() || is_search() ) { $posts_per_page = intval( get_option( 'posts_per_page' ) ) - 1; set_query_var( 'posts_per_page', $posts_per_page ); } } add_filter( 'pre_get_posts', 'spun_limit_posts_per_archive_page' ); /** * Count the number of active sidebars and generate an ID to style them. */ function spun_count_sidebars() { $count = 0; if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) ) $count = 'one'; if ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) $count = 'two'; if ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) $count = 'three'; print $count; } /** * For image post format, as we display the featured image properly, * regex it out of the content. */ function spun_strip_featured_image( $content ) { if ( '' != get_the_post_thumbnail() && 'image' == get_post_format() ) { $image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); $image_url = $image_url[0]; $image_url = str_replace( array( 'http://', 'https://' ), 'https?://', $image_url ); $regex = sprintf( '#]*? src="%1$s[^"]*" [^>]*?/>#', $image_url ); $content = preg_replace( $regex, '', $content ); } return $content; } add_filter( 'the_content', 'spun_strip_featured_image' ); /** * Remove the 1st gallery shortcode from gallery post format content. */ function spun_strip_first_gallery( $content ) { if ( 'gallery' === get_post_format() && 'post' === get_post_type() && get_post_gallery() ) { if ( post_password_required() ) { return $content; } $regex = get_shortcode_regex( array( 'gallery' ) ); $content = preg_replace( '/'. $regex .'/s', '', $content, 1 ); $content = wp_kses_post( $content ); } return $content; } add_filter( 'the_content', 'spun_strip_first_gallery' ); /** * Filters wp_title to print a neat