Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




post_password_required [ WordPress Function ]

post_password_required ( $post = null )
Parameters:
  • (int|object) $post An optional post. Global $post used if not provided.
Returns:
  • (bool) false if a password is not required or the correct password cookie is present, true otherwise.
Defined at:



Whether post requires password and correct password has been provided.

Source


<?php
function post_password_required$post null ) {
    global 
$wp_hasher;

    
$post get_post($post);

    if ( empty( 
$post->post_password ) )
        return 
false;

    if ( ! isset( 
$_COOKIE['wp-postpass_' COOKIEHASH] ) )
        return 
true;

    if ( empty( 
$wp_hasher ) ) {
        require_once( 
ABSPATH 'wp-includes/class-phpass.php');
        
// By default, use the portable hash from phpass
        
$wp_hasher = new PasswordHash(8true);
    }

    
$hash stripslashes$_COOKIE'wp-postpass_' COOKIEHASH ] );

    return ! 
$wp_hasher->CheckPassword$post->post_password$hash );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics