Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: post_password_required

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
868  *
869  * @param int|WP_Post|null $post An optional post. Global $post used if not provided.
870  * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
871  */
872 function post_password_required( $post = null ) {
873      $post = get_post( $post );
874
875      if ( empty( $post->post_password ) ) {
876           /** This filter is documented in wp-includes/post-template.php */
877           return apply_filters( 'post_password_required', false, $post );
878      }
879
880      if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) {
881           /** This filter is documented in wp-includes/post-template.php */
882           return apply_filters( 'post_password_required', true, $post );
883      }
884
885      require_once ABSPATH . WPINC . '/class-phpass.php';
886      $hasher = new PasswordHash( 8, true );
887
888      $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
889      if ( 0 !== strpos( $hash, '$P$B' ) ) {
890           $required = true;
891      } else {
 
Line Code
895      /**
896       * Filters whether a post requires the user to supply a password.
897       *
898       * @since 4.7.0
899       *
900       * @param bool    $required Whether the user needs to supply a password. True if password has not been
901       *                          provided or is incorrect, false if password has been supplied or is not required.
902       * @param WP_Post $post     Post object.
903       */
904      return apply_filters( 'post_password_required', $required, $post );
905 }
906
907 //
908 // Page Template Functions for usage in Themes.
909 //
910
911 /**
912  * The formatted output of a list of pages.
913  *