5ucms论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 9627|回复: 0
打印 上一主题 下一主题

[教程] wordpress自定义密码文章的提示文字

[复制链接]

670

主题

785

帖子

8228

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
8228
跳转到指定楼层
楼主
发表于 2021-6-3 17:11:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  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. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|5ucms.com

GMT+8, 2024-4-24 14:52 , Processed in 3.968750 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表