|
- /**
- * WordPress 自定义密码文章的提示文字
- * 钩子:the_password_form
- * 函数:get_the_password_form()
- * 位置:/wp-includes/post-template.php
- * 详解:https://developer.wordpress.org/reference/hooks/the_password_form/
- * 来源:http://yangjunwei.com/3688.html
- */
- add_filter( 'the_password_form', 'haibor_custom_password_form' );
- function haibor_custom_password_form() {
- $post = get_post( $post );
- $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
- $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
- <p>' . __( '本文受密码保护,请输入访问密码:' ) . ' <a href="'.get_option( 'siteurl' ).'/about-password-articles">为什么加密?</a></p>
- <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
- ';
- return $output;
- }
复制代码 |
|