]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/post-template.php
WordPress 4.6.3-scripts
[autoinstalls/wordpress.git] / wp-includes / post-template.php
index 3164509b8e4fda1d3986c0c0a1b1be04277b079a..be152523f0615a97e815fdc062a16fb1fd187dc9 100644 (file)
@@ -56,12 +56,12 @@ function the_title( $before = '', $after = '', $echo = true ) {
 /**
  * Sanitize the current title when retrieving or displaying.
  *
- * Works like {@link the_title()}, except the parameters can be in a string or
+ * Works like the_title(), except the parameters can be in a string or
  * an array. See the function for what can be override in the $args parameter.
  *
- * The title before it is displayed will have the tags stripped and {@link
- * esc_attr()} before it is passed to the user or displayed. The default
- * as with {@link the_title()}, is to display the title.
+ * The title before it is displayed will have the tags stripped and esc_attr()
+ * before it is passed to the user or displayed. The default as with the_title(),
+ * is to display the title.
  *
  * @since 2.3.0
  *
@@ -117,7 +117,7 @@ function get_the_title( $post = 0 ) {
                if ( ! empty( $post->post_password ) ) {
 
                        /**
-                        * Filter the text prepended to the post title for protected posts.
+                        * Filters the text prepended to the post title for protected posts.
                         *
                         * The filter is only applied on the front end.
                         *
@@ -132,7 +132,7 @@ function get_the_title( $post = 0 ) {
                } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
 
                        /**
-                        * Filter the text prepended to the post title of private posts.
+                        * Filters the text prepended to the post title of private posts.
                         *
                         * The filter is only applied on the front end.
                         *
@@ -148,7 +148,7 @@ function get_the_title( $post = 0 ) {
        }
 
        /**
-        * Filter the post title.
+        * Filters the post title.
         *
         * @since 0.71
         *
@@ -161,27 +161,33 @@ function get_the_title( $post = 0 ) {
 /**
  * Display the Post Global Unique Identifier (guid).
  *
- * The guid will appear to be a link, but should not be used as an link to the
+ * The guid will appear to be a link, but should not be used as a link to the
  * post. The reason you should not use it as a link, is because of moving the
  * blog across domains.
  *
- * Url is escaped to make it xml safe
+ * URL is escaped to make it XML-safe.
  *
  * @since 1.5.0
  *
- * @param int|WP_Post $id Optional. Post ID or post object.
+ * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
  */
-function the_guid( $id = 0 ) {
+function the_guid( $post = 0 ) {
+       $post = get_post( $post );
+
+       $guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
+       $id   = isset( $post->ID ) ? $post->ID : 0;
+
        /**
-        * Filter the escaped Global Unique Identifier (guid) of the post.
+        * Filters the escaped Global Unique Identifier (guid) of the post.
         *
         * @since 4.2.0
         *
         * @see get_the_guid()
         *
-        * @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
+        * @param string $guid Escaped Global Unique Identifier (guid) of the post.
+        * @param int    $id   The post ID.
         */
-       echo apply_filters( 'the_guid', get_the_guid( $id ) );
+       echo apply_filters( 'the_guid', $guid, $id );
 }
 
 /**
@@ -193,20 +199,24 @@ function the_guid( $id = 0 ) {
  *
  * @since 1.5.0
  *
- * @param int|WP_Post $id Optional. Post ID or post object.
+ * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
  * @return string
  */
-function get_the_guid( $id = 0 ) {
-       $post = get_post($id);
+function get_the_guid( $post = 0 ) {
+       $post = get_post( $post );
+
+       $guid = isset( $post->guid ) ? $post->guid : '';
+       $id   = isset( $post->ID ) ? $post->ID : 0;
 
        /**
-        * Filter the Global Unique Identifier (guid) of the post.
+        * Filters the Global Unique Identifier (guid) of the post.
         *
         * @since 1.5.0
         *
-        * @param string $post_guid Global Unique Identifier (guid) of the post.
+        * @param string $guid Global Unique Identifier (guid) of the post.
+        * @param int    $id   The post ID.
         */
-       return apply_filters( 'get_the_guid', $post->guid );
+       return apply_filters( 'get_the_guid', $guid, $id );
 }
 
 /**
@@ -221,7 +231,7 @@ function the_content( $more_link_text = null, $strip_teaser = false) {
        $content = get_the_content( $more_link_text, $strip_teaser );
 
        /**
-        * Filter the post content.
+        * Filters the post content.
         *
         * @since 0.71
         *
@@ -252,8 +262,17 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) {
 
        $post = get_post();
 
-       if ( null === $more_link_text )
-               $more_link_text = __( '(more…)' );
+       if ( null === $more_link_text ) {
+               $more_link_text = sprintf(
+                       '<span aria-label="%1$s">%2$s</span>',
+                       sprintf(
+                               /* translators: %s: Name of current post */
+                               __( 'Continue reading %s' ),
+                               the_title_attribute( array( 'echo' => false ) )
+                       ),
+                       __( '(more&hellip;)' )
+               );
+       }
 
        $output = '';
        $has_teaser = false;
@@ -293,7 +312,7 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) {
                        if ( ! empty( $more_link_text ) )
 
                                /**
-                                * Filter the Read More link text.
+                                * Filters the Read More link text.
                                 *
                                 * @since 2.8.0
                                 *
@@ -332,7 +351,7 @@ function _convert_urlencoded_to_entities( $match ) {
 function the_excerpt() {
 
        /**
-        * Filter the displayed post excerpt.
+        * Filters the displayed post excerpt.
         *
         * @since 0.71
         *
@@ -344,34 +363,38 @@ function the_excerpt() {
 }
 
 /**
- * Retrieve the post excerpt.
+ * Retrieves the post excerpt.
  *
  * @since 0.71
+ * @since 4.5.0 Introduced the `$post` parameter.
  *
- * @param mixed $deprecated Not used.
- * @return string
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
+ * @return string Post excerpt.
  */
-function get_the_excerpt( $deprecated = '' ) {
-       if ( !empty( $deprecated ) )
-               _deprecated_argument( __FUNCTION__, '2.3' );
+function get_the_excerpt( $post = null ) {
+       if ( is_bool( $post ) ) {
+               _deprecated_argument( __FUNCTION__, '2.3.0' );
+       }
 
-       $post = get_post();
+       $post = get_post( $post );
        if ( empty( $post ) ) {
                return '';
        }
 
-       if ( post_password_required() ) {
+       if ( post_password_required( $post ) ) {
                return __( 'There is no excerpt because this is a protected post.' );
        }
 
        /**
-        * Filter the retrieved post excerpt.
+        * Filters the retrieved post excerpt.
         *
         * @since 1.2.0
+        * @since 4.5.0 Introduced the `$post` parameter.
         *
         * @param string $post_excerpt The post excerpt.
+        * @param WP_Post $post Post object.
         */
-       return apply_filters( 'get_the_excerpt', $post->post_excerpt );
+       return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
 }
 
 /**
@@ -401,15 +424,17 @@ function post_class( $class = '', $post_id = null ) {
 }
 
 /**
- * Retrieve the classes for the post div as an array.
+ * Retrieves the classes for the post div as an array.
  *
  * The class names are many. If the post is a sticky, then the 'sticky'
  * class name. The class 'hentry' is always added to each post. If the post has a
  * post thumbnail, 'has-post-thumbnail' is added as a class. For each taxonomy that
  * the post belongs to, a class will be added of the format '{$taxonomy}-{$slug}' -
- * eg 'category-foo' or 'my_custom_taxonomy-bar'. The 'post_tag' taxonomy is a special
+ * eg 'category-foo' or 'my_custom_taxonomy-bar'.
+ *
+ * The 'post_tag' taxonomy is a special
  * case; the class has the 'tag-' prefix instead of 'post_tag-'. All classes are
- * passed through the filter, 'post_class' with the list of classes, followed by
+ * passed through the filter, {@see 'post_class'}, with the list of classes, followed by
  * $class parameter value, with the post ID as the last parameter.
  *
  * @since 2.7.0
@@ -507,7 +532,7 @@ function get_post_class( $class = '', $post_id = null ) {
        $classes = array_map( 'esc_attr', $classes );
 
        /**
-        * Filter the list of CSS classes for the current post.
+        * Filters the list of CSS classes for the current post.
         *
         * @since 2.7.0
         *
@@ -689,6 +714,10 @@ function get_body_class( $class = '' ) {
        if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
                $classes[] = 'custom-background';
 
+       if ( has_custom_logo() ) {
+               $classes[] = 'wp-custom-logo';
+       }
+
        $page = $wp_query->get( 'page' );
 
        if ( ! $page || $page < 2 )
@@ -727,7 +756,7 @@ function get_body_class( $class = '' ) {
        $classes = array_map( 'esc_attr', $classes );
 
        /**
-        * Filter the list of CSS body classes for the current post or page.
+        * Filters the list of CSS body classes for the current post or page.
         *
         * @since 2.8.0
         *
@@ -823,7 +852,7 @@ function wp_link_pages( $args = '' ) {
        $params = wp_parse_args( $args, $defaults );
 
        /**
-        * Filter the arguments used in retrieving page links for paginated posts.
+        * Filters the arguments used in retrieving page links for paginated posts.
         *
         * @since 3.0.0
         *
@@ -841,7 +870,7 @@ function wp_link_pages( $args = '' ) {
                                        $link = _wp_link_page( $i ) . $link . '</a>';
                                }
                                /**
-                                * Filter the HTML output of individual page number links.
+                                * Filters the HTML output of individual page number links.
                                 *
                                 * @since 3.6.0
                                 *
@@ -879,7 +908,7 @@ function wp_link_pages( $args = '' ) {
        }
 
        /**
-        * Filter the HTML output of page links for paginated posts.
+        * Filters the HTML output of page links for paginated posts.
         *
         * @since 3.6.0
         *
@@ -976,7 +1005,7 @@ function the_meta() {
                        $value = implode($values,', ');
 
                        /**
-                        * Filter the HTML output of the li element in the post custom fields list.
+                        * Filters the HTML output of the li element in the post custom fields list.
                         *
                         * @since 2.2.0
                         *
@@ -1060,7 +1089,7 @@ function wp_dropdown_pages( $args = '' ) {
        }
 
        /**
-        * Filter the HTML output of a list of pages as a drop down.
+        * Filters the HTML output of a list of pages as a drop down.
         *
         * @since 2.1.0
         * @since 4.4.0 `$r` and `$pages` added as arguments.
@@ -1136,7 +1165,7 @@ function wp_list_pages( $args = '' ) {
        $exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
 
        /**
-        * Filter the array of pages to exclude from the pages list.
+        * Filters the array of pages to exclude from the pages list.
         *
         * @since 2.1.0
         *
@@ -1170,7 +1199,7 @@ function wp_list_pages( $args = '' ) {
        }
 
        /**
-        * Filter the HTML output of the pages to list.
+        * Filters the HTML output of the pages to list.
         *
         * @since 1.5.1
         * @since 4.4.0 `$pages` added as arguments.
@@ -1191,11 +1220,10 @@ function wp_list_pages( $args = '' ) {
 }
 
 /**
- * Display or retrieve list of pages with optional home link.
+ * Displays or retrieves a list of pages with an optional home link.
  *
- * The arguments are listed below and part of the arguments are for {@link
- * wp_list_pages()} function. Check that function for more info on those
- * arguments.
+ * The arguments are listed below and part of the arguments are for wp_list_pages()} function.
+ * Check that function for more info on those arguments.
  *
  * @since 2.7.0
  * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
@@ -1236,7 +1264,7 @@ function wp_page_menu( $args = array() ) {
        $args = wp_parse_args( $args, $defaults );
 
        /**
-        * Filter the arguments used to generate a page-based menu.
+        * Filters the arguments used to generate a page-based menu.
         *
         * @since 2.7.0
         *
@@ -1307,7 +1335,7 @@ function wp_page_menu( $args = array() ) {
        $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
 
        /**
-        * Filter the HTML output of a page-based menu.
+        * Filters the HTML output of a page-based menu.
         *
         * @since 2.7.0
         *
@@ -1389,7 +1417,7 @@ function walk_page_dropdown_tree() {
  */
 function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
        if ( !empty( $deprecated ) )
-               _deprecated_argument( __FUNCTION__, '2.5' );
+               _deprecated_argument( __FUNCTION__, '2.5.0' );
 
        if ( $fullsize )
                echo wp_get_attachment_link($id, 'full', $permalink);
@@ -1435,7 +1463,7 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
                $link_text = $_post->post_title;
 
        /**
-        * Filter a retrieved attachment page link.
+        * Filters a retrieved attachment page link.
         *
         * @since 2.7.0
         *
@@ -1447,7 +1475,7 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
         * @param bool         $icon      Whether to include an icon. Default false.
         * @param string|bool  $text      If string, will be link text. Default false.
         */
-       return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
+       return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text );
 }
 
 /**
@@ -1485,7 +1513,7 @@ function prepend_attachment($content) {
        }
 
        /**
-        * Filter the attachment markup to be prepended to the post content.
+        * Filters the attachment markup to be prepended to the post content.
         *
         * @since 2.0.0
         *
@@ -1515,11 +1543,11 @@ function get_the_password_form( $post = 0 ) {
        $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
        $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
        <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
-       <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__( 'Submit' ) . '" /></p></form>
+       <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
        ';
 
        /**
-        * Filter the HTML output for the protected post password form.
+        * Filters the HTML output for the protected post password form.
         *
         * If modifying the password field, please note that the core database schema
         * limits the password field to 20 characters regardless of the value of the
@@ -1603,7 +1631,7 @@ function wp_post_revision_title( $revision, $link = true ) {
        if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
                return false;
 
-       /* translators: revision date format, see http://php.net/date */
+       /* translators: revision date format, see https://secure.php.net/date */
        $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
        /* translators: 1: date */
        $autosavef = _x( '%1$s [Autosave]', 'post revision title extra' );
@@ -1639,7 +1667,7 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
                return false;
 
        $author = get_the_author_meta( 'display_name', $revision->post_author );
-       /* translators: revision date format, see http://php.net/date */
+       /* translators: revision date format, see https://secure.php.net/date */
        $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
 
        $gravatar = get_avatar( $revision->post_author, 24 );
@@ -1666,7 +1694,7 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
                $revision_date_author = sprintf( $autosavef, $revision_date_author );
 
        /**
-        * Filter the formatted author and date for a revision.
+        * Filters the formatted author and date for a revision.
         *
         * @since 4.4.0
         *
@@ -1696,7 +1724,7 @@ function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
        // $args array with (parent, format, right, left, type) deprecated since 3.6
        if ( is_array( $type ) ) {
                $type = ! empty( $type['type'] ) ? $type['type']  : $type;
-               _deprecated_argument( __FUNCTION__, '3.6' );
+               _deprecated_argument( __FUNCTION__, '3.6.0' );
        }
 
        if ( ! $revisions = wp_get_post_revisions( $post->ID ) )