WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
| Line | Code |
|---|---|
| 852 | * |
| 853 | * @param int|WP_Post|null $post An optional post. Global $post used if not provided. |
| 854 | * @return bool false if a password is not required or the correct password cookie is present, true otherwise. |
| 855 | */ |
| 856 | function post_password_required( $post = null ) { |
| 857 | $post = get_post( $post ); |
| 858 | |
| 859 | if ( empty( $post->post_password ) ) { |
| 860 | /** This filter is documented in wp-includes/post-template.php */ |
| 861 | return apply_filters( 'post_password_required', false, $post ); |
| 862 | } |
| 863 | |
| 864 | if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { |
| 865 | /** This filter is documented in wp-includes/post-template.php */ |
| 866 | return apply_filters( 'post_password_required', true, $post ); |
| 867 | } |
| 868 | |
| 869 | require_once ABSPATH . WPINC . '/class-phpass.php'; |
| 870 | $hasher = new PasswordHash( 8, true ); |
| 871 | |
| 872 | $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ); |
| 873 | if ( 0 !== strpos( $hash, '$P$B' ) ) { |
| 874 | $required = true; |
| 875 | } else { |
| Line | Code |
| 879 | /** |
| 880 | * Filters whether a post requires the user to supply a password. |
| 881 | * |
| 882 | * @since 4.7.0 |
| 883 | * |
| 884 | * @param bool $required Whether the user needs to supply a password. True if password has not been |
| 885 | * provided or is incorrect, false if password has been supplied or is not required. |
| 886 | * @param WP_Post $post Post data. |
| 887 | */ |
| 888 | return apply_filters( 'post_password_required', $required, $post ); |
| 889 | } |
| 890 | |
| 891 | // |
| 892 | // Page Template Functions for usage in Themes |
| 893 | // |
| 894 | |
| 895 | /** |
| 896 | * The formatted output of a list of pages. |
| 897 | * |