get_the_password_form()

最后更新于:2021-11-27 02:19:32

get_the_password_form( int|GC_Post$post)

Retrieve protected post password form content.

参数

$post

(int|GC_Post) (Optional) Post ID or GC_Post object. Default is global $post.

响应

(string) HTML content for password form for password protected post.

源文件

文件: gc-includes/post-template.php

function get_the_password_form( $post = 0 ) {
	$post   = get_post( $post );
	$label  = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
	$output = '<form action="' . esc_url( site_url( 'gc-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
	<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
	<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
	';

	/**
	 * Filters the HTML output for the protected post password form.
	 *
	 * If modifying the password field, please note that the core database schema
	 * limits the password field to 20 characters regardless of the value of the
	 * size attribute in the form input.
	 *
	 * @since 2.7.0
	 * @since 5.8.0 Added the `$post` parameter.
	 *
	 * @param string  $output The password form HTML output.
	 * @param GC_Post $post   Post object.
	 */
	return apply_filters( 'the_password_form', $output, $post );
}