Changeset 53715 for trunk/src/wp-includes/post-template.php
- Timestamp:
- 07/18/2022 05:35:51 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/post-template.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r53656 r53715 118 118 $post = get_post( $post ); 119 119 120 $ title = isset( $post->post_title ) ? $post->post_title : '';121 $ id = isset( $post->ID ) ? $post->ID : 0;120 $post_title = isset( $post->post_title ) ? $post->post_title : ''; 121 $post_id = isset( $post->ID ) ? $post->ID : 0; 122 122 123 123 if ( ! is_admin() ) { … … 139 139 */ 140 140 $protected_title_format = apply_filters( 'protected_title_format', $prepend, $post ); 141 $title = sprintf( $protected_title_format, $title ); 141 142 $post_title = sprintf( $protected_title_format, $post_title ); 142 143 } elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) { 143 144 … … 157 158 */ 158 159 $private_title_format = apply_filters( 'private_title_format', $prepend, $post ); 159 $title = sprintf( $private_title_format, $title ); 160 161 $post_title = sprintf( $private_title_format, $post_title ); 160 162 } 161 163 } … … 166 168 * @since 0.71 167 169 * 168 * @param string $ title The post title.169 * @param int $ id The post ID.170 * @param string $post_title The post title. 171 * @param int $post_id The post ID. 170 172 */ 171 return apply_filters( 'the_title', $ title, $id );173 return apply_filters( 'the_title', $post_title, $post_id ); 172 174 } 173 175 … … 188 190 $post = get_post( $post ); 189 191 190 $ guid = isset( $post->guid ) ? get_the_guid( $post ) : '';191 $ id = isset( $post->ID ) ? $post->ID : 0;192 $post_guid = isset( $post->guid ) ? get_the_guid( $post ) : ''; 193 $post_id = isset( $post->ID ) ? $post->ID : 0; 192 194 193 195 /** … … 198 200 * @see get_the_guid() 199 201 * 200 * @param string $ guid Escaped Global Unique Identifier (guid) of the post.201 * @param int $ id The post ID.202 * @param string $post_guid Escaped Global Unique Identifier (guid) of the post. 203 * @param int $post_id The post ID. 202 204 */ 203 echo apply_filters( 'the_guid', $ guid, $id );205 echo apply_filters( 'the_guid', $post_guid, $post_id ); 204 206 } 205 207 … … 219 221 $post = get_post( $post ); 220 222 221 $ guid = isset( $post->guid ) ? $post->guid : '';222 $ id = isset( $post->ID ) ? $post->ID : 0;223 $post_guid = isset( $post->guid ) ? $post->guid : ''; 224 $post_id = isset( $post->ID ) ? $post->ID : 0; 223 225 224 226 /** … … 227 229 * @since 1.5.0 228 230 * 229 * @param string $ guid Global Unique Identifier (guid) of the post.230 * @param int $ id The post ID.231 * @param string $post_guid Global Unique Identifier (guid) of the post. 232 * @param int $post_id The post ID. 231 233 */ 232 return apply_filters( 'get_the_guid', $ guid, $id );234 return apply_filters( 'get_the_guid', $post_guid, $post_id ); 233 235 } 234 236 … … 452 454 * @since 2.7.0 453 455 * 454 * @param string|string[] $class One or more classes to add to the class list.455 * @param int|WP_Post $post _idOptional. Post ID or post object. Defaults to the global `$post`.456 */ 457 function post_class( $class = '', $post _id= null ) {456 * @param string|string[] $class One or more classes to add to the class list. 457 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`. 458 */ 459 function post_class( $class = '', $post = null ) { 458 460 // Separates classes with a single space, collates classes for post DIV. 459 echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post _id) ) ) . '"';461 echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post ) ) ) . '"'; 460 462 } 461 463 … … 477 479 * @since 4.2.0 Custom taxonomy class names were added. 478 480 * 479 * @param string|string[] $class Space-separated string or array of class names to add to the class list.480 * @param int|WP_Post $post _idOptional. Post ID or post object.481 * @param string|string[] $class Space-separated string or array of class names to add to the class list. 482 * @param int|WP_Post $post Optional. Post ID or post object. 481 483 * @return string[] Array of class names. 482 484 */ 483 function get_post_class( $class = '', $post _id= null ) {484 $post = get_post( $post _id);485 function get_post_class( $class = '', $post = null ) { 486 $post = get_post( $post ); 485 487 486 488 $classes = array(); … … 1581 1583 * @since 2.0.0 1582 1584 * 1583 * @param int|WP_Post $ idOptional. Post ID or post object.1584 * @param bool $fullsize Optional. Whether to use full size. Default false.1585 * @param bool $deprecated Deprecated. Not used.1586 * @param bool $permalink Optional. Whether to include permalink. Default false.1587 */ 1588 function the_attachment_link( $ id= 0, $fullsize = false, $deprecated = false, $permalink = false ) {1585 * @param int|WP_Post $post Optional. Post ID or post object. 1586 * @param bool $fullsize Optional. Whether to use full size. Default false. 1587 * @param bool $deprecated Deprecated. Not used. 1588 * @param bool $permalink Optional. Whether to include permalink. Default false. 1589 */ 1590 function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) { 1589 1591 if ( ! empty( $deprecated ) ) { 1590 1592 _deprecated_argument( __FUNCTION__, '2.5.0' ); … … 1592 1594 1593 1595 if ( $fullsize ) { 1594 echo wp_get_attachment_link( $ id, 'full', $permalink );1596 echo wp_get_attachment_link( $post, 'full', $permalink ); 1595 1597 } else { 1596 echo wp_get_attachment_link( $ id, 'thumbnail', $permalink );1598 echo wp_get_attachment_link( $post, 'thumbnail', $permalink ); 1597 1599 } 1598 1600 } … … 1602 1604 * 1603 1605 * @since 2.5.0 1604 * @since 4.4.0 The `$ id` parameter can now accept either a post ID or `WP_Post` object.1605 * 1606 * @param int|WP_Post $ idOptional. Post ID or post object.1606 * @since 4.4.0 The `$post` parameter can now accept either a post ID or `WP_Post` object. 1607 * 1608 * @param int|WP_Post $post Optional. Post ID or post object. 1607 1609 * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array 1608 1610 * of width and height values in pixels (in that order). Default 'thumbnail'. … … 1614 1616 * @return string HTML content. 1615 1617 */ 1616 function wp_get_attachment_link( $ id= 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {1617 $_post = get_post( $ id);1618 function wp_get_attachment_link( $post = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) { 1619 $_post = get_post( $post ); 1618 1620 1619 1621 if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) { … … 1642 1644 $link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) ); 1643 1645 } 1646 1647 $link_html = "<a href='" . esc_url( $url ) . "'>$link_text</a>"; 1648 1644 1649 /** 1645 1650 * Filters a retrieved attachment page link. … … 1649 1654 * 1650 1655 * @param string $link_html The page link HTML output. 1651 * @param int|WP_Post $ idPost ID or object. Can be 0 for the current global post.1656 * @param int|WP_Post $post Post ID or object. Can be 0 for the current global post. 1652 1657 * @param string|int[] $size Requested image size. Can be any registered image size name, or 1653 1658 * an array of width and height values in pixels (in that order). … … 1657 1662 * @param array|string $attr Array or string of attributes. 1658 1663 */ 1659 return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr );1664 return apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr ); 1660 1665 } 1661 1666 … … 1826 1831 function wp_post_revision_title( $revision, $link = true ) { 1827 1832 $revision = get_post( $revision ); 1833 1828 1834 if ( ! $revision ) { 1829 1835 return $revision; … … 1867 1873 function wp_post_revision_title_expanded( $revision, $link = true ) { 1868 1874 $revision = get_post( $revision ); 1875 1869 1876 if ( ! $revision ) { 1870 1877 return $revision; … … 1928 1935 * @since 2.6.0 1929 1936 * 1930 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. 1931 * @param string $type 'all' (default), 'revision' or 'autosave' 1932 */ 1933 function wp_list_post_revisions( $post_id = 0, $type = 'all' ) { 1934 $post = get_post( $post_id ); 1937 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 1938 * @param string $type 'all' (default), 'revision' or 'autosave' 1939 */ 1940 function wp_list_post_revisions( $post = 0, $type = 'all' ) { 1941 $post = get_post( $post ); 1942 1935 1943 if ( ! $post ) { 1936 1944 return; … … 1944 1952 1945 1953 $revisions = wp_get_post_revisions( $post->ID ); 1954 1946 1955 if ( ! $revisions ) { 1947 1956 return;
Note: See TracChangeset
for help on using the changeset viewer.