Making WordPress.org


Ignore:
Timestamp:
04/16/2019 10:21:35 PM (7 years ago)
Author:
coreymckrill
Message:

WordCamp themes: Add 'Continue Reading' link to excerpts in CampSite 2017

This makes excerpts in the CampSite 2017 theme match the behavior of nearly
every other theme available on the WordCamp.org network (remaining exceptions
are Twenty Twelve and Twenty Nineteen). However, this uses a feature
flag to ensure that only new sites going forward and those created recently
will implement the change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/campsite-2017/functions.php

    r8554 r8646  
    1010add_action( 'after_setup_theme',  __NAMESPACE__ . '\setup_theme'             );
    1111add_action( 'after_setup_theme',  __NAMESPACE__ . '\content_width',        0 );
     12add_filter( 'excerpt_more',       __NAMESPACE__ . '\excerpt_more'            );
    1213add_action( 'widgets_init',       __NAMESPACE__ . '\widgets_init'            );
    1314add_action( 'wp_head',            __NAMESPACE__ . '\javascript_detection', 0 );
     
    230231        register_sidebar( $args );
    231232    }
     233}
     234
     235/**
     236 * Replaces "[...]" (appended to automatically generated excerpts) with ... and
     237 * a 'Continue reading' link.
     238 *
     239 * @param string $link Link to single post/page.
     240 *
     241 * @return string 'Continue reading' link prepended with an ellipsis.
     242 */
     243function excerpt_more( $link ) {
     244    if ( is_admin() || wcorg_skip_feature( 'campsite_2017_excerpt_more' ) ) {
     245        return $link;
     246    }
     247
     248    $link = sprintf(
     249        '<a href="%1$s" class="more-link">%2$s</a>',
     250        esc_url( get_permalink( get_the_ID() ) ),
     251        /* translators: %s: Name of current post */
     252        sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'wordcamporg' ), get_the_title( get_the_ID() ) )
     253    );
     254
     255    return ' &hellip; ' . $link;
    232256}
    233257
Note: See TracChangeset for help on using the changeset viewer.