X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/61343b82c4f0da4c68e4c6373daafff4a81efdd1..fcaa67f093b5c83deea7a361a8cf8c6ac4e832d3:/wp-content/themes/twentythirteen/functions.php
diff --git a/wp-content/themes/twentythirteen/functions.php b/wp-content/themes/twentythirteen/functions.php
index b4234bf1..9c85c993 100644
--- a/wp-content/themes/twentythirteen/functions.php
+++ b/wp-content/themes/twentythirteen/functions.php
@@ -1,13 +1,13 @@
for posts and comments.
add_theme_support( 'automatic-feed-links' );
- // Switches default core markup for search form, comment form, and comments
- // to output valid HTML5.
- add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
+ /*
+ * Switches default core markup for search form, comment form,
+ * and comments to output valid HTML5.
+ */
+ add_theme_support( 'html5', array(
+ 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
+ ) );
/*
* This theme supports all available post formats by default.
- * See http://codex.wordpress.org/Post_Formats
+ * See https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
@@ -105,7 +109,7 @@ function twentythirteen_setup() {
add_action( 'after_setup_theme', 'twentythirteen_setup' );
/**
- * Returns the Google font stylesheet URL, if available.
+ * Return the Google font stylesheet URL, if available.
*
* The use of Source Sans Pro and Bitter by default is localized. For languages
* that use characters not supported by the font, the font can be disabled.
@@ -142,22 +146,22 @@ function twentythirteen_fonts_url() {
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
- $fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" );
+ $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
}
return $fonts_url;
}
/**
- * Enqueues scripts and styles for front end.
+ * Enqueue scripts and styles for the front end.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_scripts_styles() {
- // Adds JavaScript to pages with the comment form to support sites with
- // threaded comments (when in use).
+ /*
+ * Adds JavaScript to pages with the comment form to support
+ * sites with threaded comments (when in use).
+ */
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
@@ -166,13 +170,13 @@ function twentythirteen_scripts_styles() {
wp_enqueue_script( 'jquery-masonry' );
// Loads JavaScript file with functionality specific to Twenty Thirteen.
- wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '2013-07-18', true );
+ wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true );
- // Add Open Sans and Bitter fonts, used in the main stylesheet.
+ // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
// Add Genericons font, used in the main stylesheet.
- wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '2.09' );
+ wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.03' );
// Loads our main stylesheet.
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri(), array(), '2013-07-18' );
@@ -184,13 +188,15 @@ function twentythirteen_scripts_styles() {
add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
/**
+ * Filter the page title.
+ *
* Creates a nicely formatted and more specific title element text for output
* in head of document, based on current view.
*
* @since Twenty Thirteen 1.0
*
* @param string $title Default title text for current view.
- * @param string $sep Optional separator.
+ * @param string $sep Optional separator.
* @return string The filtered title.
*/
function twentythirteen_wp_title( $title, $sep ) {
@@ -200,7 +206,7 @@ function twentythirteen_wp_title( $title, $sep ) {
return $title;
// Add the site name.
- $title .= get_bloginfo( 'name' );
+ $title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
@@ -208,7 +214,7 @@ function twentythirteen_wp_title( $title, $sep ) {
$title = "$title $sep $site_description";
// Add a page number if necessary.
- if ( $paged >= 2 || $page >= 2 )
+ if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) );
return $title;
@@ -216,11 +222,9 @@ function twentythirteen_wp_title( $title, $sep ) {
add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
/**
- * Registers two widget areas.
+ * Register two widget areas.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_widgets_init() {
register_sidebar( array(
@@ -247,11 +251,9 @@ add_action( 'widgets_init', 'twentythirteen_widgets_init' );
if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
/**
- * Displays navigation to next/previous set of posts when applicable.
+ * Display navigation to next/previous set of posts when applicable.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_paging_nav() {
global $wp_query;
@@ -280,11 +282,9 @@ endif;
if ( ! function_exists( 'twentythirteen_post_nav' ) ) :
/**
- * Displays navigation to next/previous post when applicable.
+ * Display navigation to next/previous post when applicable.
*
* @since Twenty Thirteen 1.0
-*
-* @return void
*/
function twentythirteen_post_nav() {
global $post;
@@ -311,17 +311,15 @@ endif;
if ( ! function_exists( 'twentythirteen_entry_meta' ) ) :
/**
- * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
+ * Print HTML with meta information for current post: categories, tags, permalink, author, and date.
*
* Create your own twentythirteen_entry_meta() to override in a child theme.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_entry_meta() {
if ( is_sticky() && is_home() && ! is_paged() )
- echo '' . __( 'Sticky', 'twentythirteen' ) . '';
+ echo '' . esc_html__( 'Sticky', 'twentythirteen' ) . '';
if ( ! has_post_format( 'link' ) && 'post' == get_post_type() )
twentythirteen_entry_date();
@@ -351,13 +349,13 @@ endif;
if ( ! function_exists( 'twentythirteen_entry_date' ) ) :
/**
- * Prints HTML with date information for current post.
+ * Print HTML with date information for current post.
*
* Create your own twentythirteen_entry_date() to override in a child theme.
*
* @since Twenty Thirteen 1.0
*
- * @param boolean $echo Whether to echo the date. Default true.
+ * @param boolean $echo (optional) Whether to echo the date. Default true.
* @return string The HTML-formatted post date.
*/
function twentythirteen_entry_date( $echo = true ) {
@@ -382,18 +380,26 @@ endif;
if ( ! function_exists( 'twentythirteen_the_attached_image' ) ) :
/**
- * Prints the attached image with a link to the next attached image.
+ * Print the attached image with a link to the next attached image.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_the_attached_image() {
- $post = get_post();
+ /**
+ * Filter the image attachment size to use.
+ *
+ * @since Twenty thirteen 1.0
+ *
+ * @param array $size {
+ * @type int The attachment height in pixels.
+ * @type int The attachment width in pixels.
+ * }
+ */
$attachment_size = apply_filters( 'twentythirteen_attachment_size', array( 724, 724 ) );
$next_attachment_url = wp_get_attachment_url();
+ $post = get_post();
- /**
+ /*
* Grab the IDs of all the image attachments in a gallery so we can get the URL
* of the next adjacent image in a gallery, or the first image (if we're
* looking at the last image in a gallery), or, in a gallery of one, just the
@@ -407,7 +413,7 @@ function twentythirteen_the_attached_image() {
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
- 'orderby' => 'menu_order ID'
+ 'orderby' => 'menu_order ID',
) );
// If there is more than 1 attachment in a gallery...
@@ -425,7 +431,7 @@ function twentythirteen_the_attached_image() {
// or get the URL of the first image attachment.
else
- $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
+ $next_attachment_url = get_attachment_link( reset( $attachment_ids ) );
}
printf( '%3$s',
@@ -437,7 +443,7 @@ function twentythirteen_the_attached_image() {
endif;
/**
- * Returns the URL from the post.
+ * Return the post URL.
*
* @uses get_url_in_content() to get the URL in the post meta (if it exists) or
* the first link found in the post content.
@@ -455,8 +461,29 @@ function twentythirteen_get_link_url() {
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
+if ( ! function_exists( 'twentythirteen_excerpt_more' ) && ! is_admin() ) :
/**
- * Extends the default WordPress body classes.
+ * Replaces "[...]" (appended to automatically generated excerpts) with ...
+ * and a Continue reading link.
+ *
+ * @since Twenty Thirteen 1.4
+ *
+ * @param string $more Default Read More excerpt link.
+ * @return string Filtered Read More excerpt link.
+ */
+function twentythirteen_excerpt_more( $more ) {
+ $link = sprintf( '%2$s',
+ esc_url( get_permalink( get_the_ID() ) ),
+ /* translators: %s: Name of current post */
+ sprintf( __( 'Continue reading %s →', 'twentythirteen' ), '' . get_the_title( get_the_ID() ) . '' )
+ );
+ return ' … ' . $link;
+}
+add_filter( 'excerpt_more', 'twentythirteen_excerpt_more' );
+endif;
+
+/**
+ * Extend the default WordPress body classes.
*
* Adds body classes to denote:
* 1. Single or multiple authors.
@@ -483,11 +510,9 @@ function twentythirteen_body_class( $classes ) {
add_filter( 'body_class', 'twentythirteen_body_class' );
/**
- * Adjusts content_width value for video post formats and attachment templates.
+ * Adjust content_width value for video post formats and attachment templates.
*
* @since Twenty Thirteen 1.0
- *
- * @return void
*/
function twentythirteen_content_width() {
global $content_width;
@@ -505,7 +530,6 @@ add_action( 'template_redirect', 'twentythirteen_content_width' );
* @since Twenty Thirteen 1.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
- * @return void
*/
function twentythirteen_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
@@ -515,12 +539,14 @@ function twentythirteen_customize_register( $wp_customize ) {
add_action( 'customize_register', 'twentythirteen_customize_register' );
/**
- * Binds JavaScript handlers to make Customizer preview reload changes
- * asynchronously.
+ * Enqueue Javascript postMessage handlers for the Customizer.
+ *
+ * Binds JavaScript handlers to make the Customizer preview
+ * reload changes asynchronously.
*
* @since Twenty Thirteen 1.0
*/
function twentythirteen_customize_preview_js() {
- wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20130226', true );
+ wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
}
add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );