wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
post_password_required › WordPress Function
Seit2.7.0
Veraltetn/v
› post_password_required ( $post = null )
Parameter: |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Determines whether the post requires password and whether a correct password has been provided.
Ähnliche Funktionen: wp_lostpassword_url, the_post_password, wp_set_password, get_password_reset_key, wp_get_password_hint
Quellcode
function post_password_required( $post = null ) { $post = get_post( $post ); if ( empty( $post->post_password ) ) { /** This filter is documented in wp-includes/post-template.php */ return apply_filters( 'post_password_required', false, $post ); } if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { /** This filter is documented in wp-includes/post-template.php */ return apply_filters( 'post_password_required', true, $post ); } require_once ABSPATH . WPINC . '/class-phpass.php'; $hasher = new PasswordHash( 8, true ); $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ); if ( ! str_starts_with( $hash, '$P$B' ) ) { $required = true; } else { $required = ! $hasher->CheckPassword( $post->post_password, $hash ); } /** * Filters whether a post requires the user to supply a password. * * @since 4.7.0 * * @param bool $required Whether the user needs to supply a password. True if password has not been * provided or is incorrect, false if password has been supplied or is not required. * @param WP_Post $post Post object. */ return apply_filters( 'post_password_required', $required, $post ); }