]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/themes/twentyfourteen/inc/template-tags.php
WordPress 4.6.3
[autoinstalls/wordpress.git] / wp-content / themes / twentyfourteen / inc / template-tags.php
index dee499e1e2c991ee92ed5475892438bcaf1f80f6..f63ee8284ba96c2889da49d7b01ca2ab53533758 100644 (file)
@@ -13,11 +13,14 @@ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) :
  *
  * @since Twenty Fourteen 1.0
  *
  *
  * @since Twenty Fourteen 1.0
  *
- * @return void
+ * @global WP_Query   $wp_query   WordPress Query object.
+ * @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
  */
 function twentyfourteen_paging_nav() {
  */
 function twentyfourteen_paging_nav() {
+       global $wp_query, $wp_rewrite;
+
        // Don't print empty markup if there's only one page.
        // Don't print empty markup if there's only one page.
-       if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
+       if ( $wp_query->max_num_pages < 2 ) {
                return;
        }
 
                return;
        }
 
@@ -33,14 +36,14 @@ function twentyfourteen_paging_nav() {
        $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
        $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
 
        $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
        $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
 
-       $format  = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
-       $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
+       $format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
+       $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
 
        // Set up paginated links.
        $links = paginate_links( array(
                'base'     => $pagenum_link,
                'format'   => $format,
 
        // Set up paginated links.
        $links = paginate_links( array(
                'base'     => $pagenum_link,
                'format'   => $format,
-               'total'    => $GLOBALS['wp_query']->max_num_pages,
+               'total'    => $wp_query->max_num_pages,
                'current'  => $paged,
                'mid_size' => 1,
                'add_args' => array_map( 'urlencode', $query_args ),
                'current'  => $paged,
                'mid_size' => 1,
                'add_args' => array_map( 'urlencode', $query_args ),
@@ -67,8 +70,6 @@ if ( ! function_exists( 'twentyfourteen_post_nav' ) ) :
  * Display navigation to next/previous post when applicable.
  *
  * @since Twenty Fourteen 1.0
  * Display navigation to next/previous post when applicable.
  *
  * @since Twenty Fourteen 1.0
- *
- * @return void
  */
 function twentyfourteen_post_nav() {
        // Don't print empty markup if there's nowhere to navigate.
  */
 function twentyfourteen_post_nav() {
        // Don't print empty markup if there's nowhere to navigate.
@@ -102,8 +103,6 @@ if ( ! function_exists( 'twentyfourteen_posted_on' ) ) :
  * Print HTML with meta information for the current post-date/time and author.
  *
  * @since Twenty Fourteen 1.0
  * Print HTML with meta information for the current post-date/time and author.
  *
  * @since Twenty Fourteen 1.0
- *
- * @return void
  */
 function twentyfourteen_posted_on() {
        if ( is_sticky() && is_home() && ! is_paged() ) {
  */
 function twentyfourteen_posted_on() {
        if ( is_sticky() && is_home() && ! is_paged() ) {
@@ -154,8 +153,6 @@ function twentyfourteen_categorized_blog() {
  * Flush out the transients used in twentyfourteen_categorized_blog.
  *
  * @since Twenty Fourteen 1.0
  * Flush out the transients used in twentyfourteen_categorized_blog.
  *
  * @since Twenty Fourteen 1.0
- *
- * @return void
  */
 function twentyfourteen_category_transient_flusher() {
        // Like, beat it. Dig?
  */
 function twentyfourteen_category_transient_flusher() {
        // Like, beat it. Dig?
@@ -164,6 +161,7 @@ function twentyfourteen_category_transient_flusher() {
 add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' );
 add_action( 'save_post',     'twentyfourteen_category_transient_flusher' );
 
 add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' );
 add_action( 'save_post',     'twentyfourteen_category_transient_flusher' );
 
+if ( ! function_exists( 'twentyfourteen_post_thumbnail' ) ) :
 /**
  * Display an optional post thumbnail.
  *
 /**
  * Display an optional post thumbnail.
  *
@@ -171,11 +169,10 @@ add_action( 'save_post',     'twentyfourteen_category_transient_flusher' );
  * views, or a div element when on single views.
  *
  * @since Twenty Fourteen 1.0
  * views, or a div element when on single views.
  *
  * @since Twenty Fourteen 1.0
- *
- * @return void
-*/
+ * @since Twenty Fourteen 1.4 Was made 'pluggable', or overridable.
+ */
 function twentyfourteen_post_thumbnail() {
 function twentyfourteen_post_thumbnail() {
-       if ( post_password_required() || ! has_post_thumbnail() ) {
+       if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
                return;
        }
 
                return;
        }
 
@@ -194,15 +191,37 @@ function twentyfourteen_post_thumbnail() {
 
        <?php else : ?>
 
 
        <?php else : ?>
 
-       <a class="post-thumbnail" href="<?php the_permalink(); ?>">
+       <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
        <?php
                if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
                        the_post_thumbnail( 'twentyfourteen-full-width' );
                } else {
        <?php
                if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
                        the_post_thumbnail( 'twentyfourteen-full-width' );
                } else {
-                       the_post_thumbnail();
+                       the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
                }
        ?>
        </a>
 
        <?php endif; // End is_singular()
 }
                }
        ?>
        </a>
 
        <?php endif; // End is_singular()
 }
+endif;
+
+if ( ! function_exists( 'twentyfourteen_excerpt_more' ) && ! is_admin() ) :
+/**
+ * Replaces "[...]" (appended to automatically generated excerpts) with ...
+ * and a Continue reading link.
+ *
+ * @since Twenty Fourteen 1.3
+ *
+ * @param string $more Default Read More excerpt link.
+ * @return string Filtered Read More excerpt link.
+ */
+function twentyfourteen_excerpt_more( $more ) {
+       $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
+               esc_url( get_permalink( get_the_ID() ) ),
+                       /* translators: %s: Name of current post */
+                       sprintf( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
+               );
+       return ' &hellip; ' . $link;
+}
+add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' );
+endif;