449 /** |
449 /** |
450 * Displays the classes for the post container element. |
450 * Displays the classes for the post container element. |
451 * |
451 * |
452 * @since 2.7.0 |
452 * @since 2.7.0 |
453 * |
453 * |
454 * @param string|array $class One or more classes to add to the class list. |
454 * @param string|string[] $class One or more classes to add to the class list. |
455 * @param int|WP_Post $post_id Optional. Post ID or post object. Defaults to the global `$post`. |
455 * @param int|WP_Post $post_id Optional. Post ID or post object. Defaults to the global `$post`. |
456 */ |
456 */ |
457 function post_class( $class = '', $post_id = null ) { |
457 function post_class( $class = '', $post_id = null ) { |
458 // Separates classes with a single space, collates classes for post DIV. |
458 // Separates classes with a single space, collates classes for post DIV. |
459 echo 'class="' . esc_attr( join( ' ', get_post_class( $class, $post_id ) ) ) . '"'; |
459 echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post_id ) ) ) . '"'; |
460 } |
460 } |
461 |
461 |
462 /** |
462 /** |
463 * Retrieves an array of the class names for the post container element. |
463 * Retrieves an array of the class names for the post container element. |
464 * |
464 * |
590 * |
590 * |
591 * @param string|string[] $class Space-separated string or array of class names to add to the class list. |
591 * @param string|string[] $class Space-separated string or array of class names to add to the class list. |
592 */ |
592 */ |
593 function body_class( $class = '' ) { |
593 function body_class( $class = '' ) { |
594 // Separates class names with a single space, collates class names for body element. |
594 // Separates class names with a single space, collates class names for body element. |
595 echo 'class="' . esc_attr( join( ' ', get_body_class( $class ) ) ) . '"'; |
595 echo 'class="' . esc_attr( implode( ' ', get_body_class( $class ) ) ) . '"'; |
596 } |
596 } |
597 |
597 |
598 /** |
598 /** |
599 * Retrieves an array of the class names for the body element. |
599 * Retrieves an array of the class names for the body element. |
600 * |
600 * |
874 * |
874 * |
875 * @since 4.7.0 |
875 * @since 4.7.0 |
876 * |
876 * |
877 * @param bool $required Whether the user needs to supply a password. True if password has not been |
877 * @param bool $required Whether the user needs to supply a password. True if password has not been |
878 * provided or is incorrect, false if password has been supplied or is not required. |
878 * provided or is incorrect, false if password has been supplied or is not required. |
879 * @param WP_Post $post Post data. |
879 * @param WP_Post $post Post object. |
880 */ |
880 */ |
881 return apply_filters( 'post_password_required', $required, $post ); |
881 return apply_filters( 'post_password_required', $required, $post ); |
882 } |
882 } |
883 |
883 |
884 // |
884 // |
1003 * Filters the HTML output of page links for paginated posts. |
1004 * Filters the HTML output of page links for paginated posts. |
1004 * |
1005 * |
1005 * @since 3.6.0 |
1006 * @since 3.6.0 |
1006 * |
1007 * |
1007 * @param string $output HTML output of paginated posts' page links. |
1008 * @param string $output HTML output of paginated posts' page links. |
1008 * @param array $args An array of arguments. |
1009 * @param array $args An array of arguments. See wp_link_pages() |
|
1010 * for information on accepted arguments. |
1009 */ |
1011 */ |
1010 $html = apply_filters( 'wp_link_pages', $output, $args ); |
1012 $html = apply_filters( 'wp_link_pages', $output, $args ); |
1011 |
1013 |
1012 if ( $parsed_args['echo'] ) { |
1014 if ( $parsed_args['echo'] ) { |
1013 echo $html; |
1015 echo $html; |
1206 * |
1208 * |
1207 * @since 2.1.0 |
1209 * @since 2.1.0 |
1208 * @since 4.4.0 `$parsed_args` and `$pages` added as arguments. |
1210 * @since 4.4.0 `$parsed_args` and `$pages` added as arguments. |
1209 * |
1211 * |
1210 * @param string $output HTML output for drop down list of pages. |
1212 * @param string $output HTML output for drop down list of pages. |
1211 * @param array $parsed_args The parsed arguments array. |
1213 * @param array $parsed_args The parsed arguments array. See wp_dropdown_pages() |
|
1214 * for information on accepted arguments. |
1212 * @param WP_Post[] $pages Array of the page objects. |
1215 * @param WP_Post[] $pages Array of the page objects. |
1213 */ |
1216 */ |
1214 $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages ); |
1217 $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages ); |
1215 |
1218 |
1216 if ( $parsed_args['echo'] ) { |
1219 if ( $parsed_args['echo'] ) { |
1335 * @since 4.4.0 `$pages` added as arguments. |
1338 * @since 4.4.0 `$pages` added as arguments. |
1336 * |
1339 * |
1337 * @see wp_list_pages() |
1340 * @see wp_list_pages() |
1338 * |
1341 * |
1339 * @param string $output HTML output of the pages list. |
1342 * @param string $output HTML output of the pages list. |
1340 * @param array $parsed_args An array of page-listing arguments. |
1343 * @param array $parsed_args An array of page-listing arguments. See wp_list_pages() |
|
1344 * for information on accepted arguments. |
1341 * @param WP_Post[] $pages Array of the page objects. |
1345 * @param WP_Post[] $pages Array of the page objects. |
1342 */ |
1346 */ |
1343 $html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages ); |
1347 $html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages ); |
1344 |
1348 |
1345 if ( $parsed_args['echo'] ) { |
1349 if ( $parsed_args['echo'] ) { |
1489 * @since 2.7.0 |
1494 * @since 2.7.0 |
1490 * |
1495 * |
1491 * @see wp_page_menu() |
1496 * @see wp_page_menu() |
1492 * |
1497 * |
1493 * @param string $menu The HTML output. |
1498 * @param string $menu The HTML output. |
1494 * @param array $args An array of arguments. |
1499 * @param array $args An array of arguments. See wp_page_menu() |
|
1500 * for information on accepted arguments. |
1495 */ |
1501 */ |
1496 $menu = apply_filters( 'wp_page_menu', $menu, $args ); |
1502 $menu = apply_filters( 'wp_page_menu', $menu, $args ); |
1497 |
1503 |
1498 if ( $args['echo'] ) { |
1504 if ( $args['echo'] ) { |
1499 echo $menu; |
1505 echo $menu; |
1594 * |
1600 * |
1595 * @since 2.5.0 |
1601 * @since 2.5.0 |
1596 * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object. |
1602 * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object. |
1597 * |
1603 * |
1598 * @param int|WP_Post $id Optional. Post ID or post object. |
1604 * @param int|WP_Post $id Optional. Post ID or post object. |
1599 * @param string|array $size Optional. Image size. Accepts any valid image size, or an array |
1605 * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array |
1600 * of width and height values in pixels (in that order). |
1606 * of width and height values in pixels (in that order). Default 'thumbnail'. |
1601 * Default 'thumbnail'. |
|
1602 * @param bool $permalink Optional. Whether to add permalink to image. Default false. |
1607 * @param bool $permalink Optional. Whether to add permalink to image. Default false. |
1603 * @param bool $icon Optional. Whether the attachment is an icon. Default false. |
1608 * @param bool $icon Optional. Whether the attachment is an icon. Default false. |
1604 * @param string|false $text Optional. Link text to use. Activated by passing a string, false otherwise. |
1609 * @param string|false $text Optional. Link text to use. Activated by passing a string, false otherwise. |
1605 * Default false. |
1610 * Default false. |
1606 * @param array|string $attr Optional. Array or string of attributes. Default empty. |
1611 * @param array|string $attr Optional. Array or string of attributes. Default empty. |
1636 } |
1641 } |
1637 /** |
1642 /** |
1638 * Filters a retrieved attachment page link. |
1643 * Filters a retrieved attachment page link. |
1639 * |
1644 * |
1640 * @since 2.7.0 |
1645 * @since 2.7.0 |
1641 * @since 5.1.0 Added the $attr parameter. |
1646 * @since 5.1.0 Added the `$attr` parameter. |
1642 * |
1647 * |
1643 * @param string $link_html The page link HTML output. |
1648 * @param string $link_html The page link HTML output. |
1644 * @param int $id Post ID. |
1649 * @param int $id Post ID. |
1645 * @param string|array $size Size of the image. Image size or array of width and height values (in that order). |
1650 * @param string|int[] $size Requested image size. Can be any registered image size name, or |
1646 * Default 'thumbnail'. |
1651 * an array of width and height values in pixels (in that order). |
1647 * @param bool $permalink Whether to add permalink to image. Default false. |
1652 * @param bool $permalink Whether to add permalink to image. Default false. |
1648 * @param bool $icon Whether to include an icon. Default false. |
1653 * @param bool $icon Whether to include an icon. |
1649 * @param string|bool $text If string, will be link text. Default false. |
1654 * @param string|false $text If string, will be link text. |
1650 * @param array|string $attr Array or string of attributes. Default empty. |
1655 * @param array|string $attr Array or string of attributes. |
1651 */ |
1656 */ |
1652 return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr ); |
1657 return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr ); |
1653 } |
1658 } |
1654 |
1659 |
1655 /** |
1660 /** |
1727 * If modifying the password field, please note that the core database schema |
1732 * If modifying the password field, please note that the core database schema |
1728 * limits the password field to 20 characters regardless of the value of the |
1733 * limits the password field to 20 characters regardless of the value of the |
1729 * size attribute in the form input. |
1734 * size attribute in the form input. |
1730 * |
1735 * |
1731 * @since 2.7.0 |
1736 * @since 2.7.0 |
1732 * |
1737 * @since 5.8.0 Added the `$post` parameter. |
1733 * @param string $output The password form HTML output. |
1738 * |
|
1739 * @param string $output The password form HTML output. |
|
1740 * @param WP_Post $post Post object. |
1734 */ |
1741 */ |
1735 return apply_filters( 'the_password_form', $output ); |
1742 return apply_filters( 'the_password_form', $output, $post ); |
1736 } |
1743 } |
1737 |
1744 |
1738 /** |
1745 /** |
1739 * Determines whether currently in a page template. |
1746 * Determines whether currently in a page template. |
1740 * |
1747 * |
1748 * |
1755 * |
1749 * @since 2.5.0 |
1756 * @since 2.5.0 |
1750 * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates. |
1757 * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates. |
1751 * @since 4.7.0 Now works with any post type, not just pages. |
1758 * @since 4.7.0 Now works with any post type, not just pages. |
1752 * |
1759 * |
1753 * @param string|array $template The specific template filename or array of templates to match. |
1760 * @param string|string[] $template The specific template filename or array of templates to match. |
1754 * @return bool True on success, false on failure. |
1761 * @return bool True on success, false on failure. |
1755 */ |
1762 */ |
1756 function is_page_template( $template = '' ) { |
1763 function is_page_template( $template = '' ) { |
1757 if ( ! is_singular() ) { |
1764 if ( ! is_singular() ) { |
1758 return false; |
1765 return false; |
1822 |
1829 |
1823 if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { |
1830 if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { |
1824 return false; |
1831 return false; |
1825 } |
1832 } |
1826 |
1833 |
1827 /* translators: Revision date format, see https://www.php.net/date */ |
1834 /* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */ |
1828 $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
1835 $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
1829 /* translators: %s: Revision date. */ |
1836 /* translators: %s: Revision date. */ |
1830 $autosavef = __( '%s [Autosave]' ); |
1837 $autosavef = __( '%s [Autosave]' ); |
1831 /* translators: %s: Revision date. */ |
1838 /* translators: %s: Revision date. */ |
1832 $currentf = __( '%s [Current Revision]' ); |
1839 $currentf = __( '%s [Current Revision]' ); |
1864 if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { |
1871 if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { |
1865 return false; |
1872 return false; |
1866 } |
1873 } |
1867 |
1874 |
1868 $author = get_the_author_meta( 'display_name', $revision->post_author ); |
1875 $author = get_the_author_meta( 'display_name', $revision->post_author ); |
1869 /* translators: Revision date format, see https://www.php.net/date */ |
1876 /* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */ |
1870 $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
1877 $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
1871 |
1878 |
1872 $gravatar = get_avatar( $revision->post_author, 24 ); |
1879 $gravatar = get_avatar( $revision->post_author, 24 ); |
1873 |
1880 |
1874 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); |
1881 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); |
1956 |
1963 |
1957 echo "<ul class='post-revisions hide-if-no-js'>\n"; |
1964 echo "<ul class='post-revisions hide-if-no-js'>\n"; |
1958 echo $rows; |
1965 echo $rows; |
1959 echo '</ul>'; |
1966 echo '</ul>'; |
1960 } |
1967 } |
|
1968 |
|
1969 /** |
|
1970 * Retrieves the parent post object for the given post. |
|
1971 * |
|
1972 * @since 5.7.0 |
|
1973 * |
|
1974 * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post. |
|
1975 * @return WP_Post|null Parent post object, or null if there isn't one. |
|
1976 */ |
|
1977 function get_post_parent( $post = null ) { |
|
1978 $wp_post = get_post( $post ); |
|
1979 return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null; |
|
1980 } |
|
1981 |
|
1982 /** |
|
1983 * Returns whether the given post has a parent post. |
|
1984 * |
|
1985 * @since 5.7.0 |
|
1986 * |
|
1987 * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post. |
|
1988 * @return bool Whether the post has a parent post. |
|
1989 */ |
|
1990 function has_post_parent( $post = null ) { |
|
1991 return (bool) get_post_parent( $post ); |
|
1992 } |