Make WordPress Core

Ticket #30024: 30024.2.diff

File 30024.2.diff, 2.1 KB (added by kraftbj, 11 years ago)

Code standard correction and adding the is_admin check for the auto-excerpt.

  • src/wp-content/themes/twentyfifteen/functions.php

     
    310310}
    311311add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 );
    312312
     313if ( ! function_exists( 'twentyfifteen_continue_reading_link' ) ) :
    313314/**
     315 * Return a "Continue Reading" link for excerpts
     316 *
     317 * @since Twenty Fifteen 1.0
     318 *
     319 * @return string The "Continue Reading" HTML link.
     320 */
     321function twentyfifteen_continue_reading_link() {
     322        return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfifteen' ) . '</a>';
     323}
     324endif; // twentyfifteen_continue_reading_link
     325
     326/**
     327 * Replace "[...]" in the Read More link with an ellipsis.
     328 *
     329 * The "[...]" is appended to automatically generated excerpts.
     330 *
     331 * To override this in a child theme, remove the filter and add your own
     332 * function tied to the excerpt_more filter hook.
     333 *
     334 * @since Twenty Fifteen 1.0
     335 *
     336 * @param string $more The Read More text.
     337 * @return The filtered Read More text.
     338 */
     339function twentyfifteen_auto_excerpt_more( $more ) {
     340        if ( ! is_admin() ) {
     341                return ' &hellip;' . twentyfifteen_continue_reading_link();
     342        }
     343        return $more;
     344}
     345add_filter( 'excerpt_more', 'twentyfifteen_auto_excerpt_more' );
     346
     347/**
     348 * Add a pretty "Continue Reading" link to custom post excerpts.
     349 *
     350 * To override this link in a child theme, remove the filter and add your own
     351 * function tied to the get_the_excerpt filter hook.
     352 *
     353 * @since Twenty Fifteen 1.0
     354 *
     355 * @param string $output The "Continue Reading" link.
     356 * @return string The filtered "Continue Reading" link.
     357 */
     358function twentyfifteen_custom_excerpt_more( $output ) {
     359        if ( has_excerpt() && ! is_attachment() && ! is_admin() ) {
     360                $output .= twentyfifteen_continue_reading_link();
     361        }
     362        return $output;
     363}
     364add_filter( 'get_the_excerpt', 'twentyfifteen_custom_excerpt_more' );
     365
     366/**
    314367 * Implement the Custom Header feature.
    315368 *
    316369 * @since Twenty Fifteen 1.0