5ucms论坛

标题: wordpress自定义密码文章的提示文字 [打印本页]

作者: admin    时间: 2021-6-3 17:11
标题: wordpress自定义密码文章的提示文字
  1. /**
  2. * WordPress 自定义密码文章的提示文字
  3. * 钩子:the_password_form
  4. * 函数:get_the_password_form()
  5. * 位置:/wp-includes/post-template.php
  6. * 详解:https://developer.wordpress.org/reference/hooks/the_password_form/
  7. * 来源:http://yangjunwei.com/3688.html
  8. */
  9. add_filter( 'the_password_form', 'haibor_custom_password_form' );
  10. function haibor_custom_password_form() {
  11.         $post   = get_post( $post );
  12.         $label  = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
  13.         $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
  14.         <p>' . __( '本文受密码保护,请输入访问密码:' ) . ' <a href="'.get_option( 'siteurl' ).'/about-password-articles">为什么加密?</a></p>
  15.         <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>
  16.         ';
  17.         return $output;
  18. }
复制代码





欢迎光临 5ucms论坛 (http://bbs.5ucms.com/) Powered by Discuz! X3.2