WordPress插件发布:隐藏内容登陆后可见

日期: 标签:WordPress插件WordPress教程
如需帮忙改代码,或者WordPress二次开发、PHP网站建设等需求,可联系我购买付费服务:  点此联系我

Languages: English中文(简体)

请不要在登录状态下测试隐藏效果!

     应 流年 网友的请求,特地研究了一下在WordPress博客中,如何实现隐藏文章的部分内容,使得用户在登陆后才可以看到。其实这个难度不是很大,WordPress提供了很多的编程接口,可以很方便的实现很多功能,现在我使用WordPress Shortcode API,也就是简码,做了一个插件,基本上可以满足文章隐藏内容,登陆后可见的需求。之前也有人开发过相关的插件,不过那是隐藏文章全部内容,不能做到只隐藏部分内容,可以说今天我做的这个插件更加灵活一些。

     1.0版推出后不久,网友yken89提了一个非常有建设意义的意见。2.0版本采纳该网友的建议,添加了新的标签

<!--loginview start-->hidden contents.<!--loginview end-->

并在HTML模式下,添加了loginview按钮,方便用户添加隐藏内容。2.0版借鉴了WordPress插件Easy2hide的部分代码。升级至2.0版后,原来的标签[loginview]仍然有效。3.0版本修正了对WordPress 3.3的支持。

 

名称:Login to view all
版本:3.1
作者:Ludou
更新:2013-12-20
功能:您可以隐藏文章的部分内容,使得用户必须登录,才能浏览。
下载:WordPress 官方下载本地下载
WordPress最低版本要求:WordPress 2.7 及更高版本

 

安装方法:

1. 下载插件,解压缩,你将会看到一个文件夹login-to-view-all,然后将其放置到插件目录下,插件目录通常是 `wp-content/plugins/`
2. 在后台对应的插件管理页激活该插件Login to view all
4. 完成

 

使用说明:
1. 在WordPress后台编辑文章的时候,切换到HTML模式,选中你要隐藏的内容,点击按钮 loginview 即可用

<!--loginview start-->

<!--loginview end-->

将隐藏内容括起来;使用这个标签的好处是,你停用本插件后,该标签不会被显示出来。

2. 如果你不喜欢HTML代码模式,可以使用 [loginview] 和 [/loginview] 将你想要隐藏的内容括起来,该标签支持可视化模式和HTML编辑模式。你的文章内容应该像这样子:

[loginview]这里是你要隐藏的内容[/loginview]

3. 这样未登录的用户浏览文章的时候,将无法阅读隐藏的内容。

 

效果预览图:

隐藏内容登陆后可见

 

Plugin name:Login to view all
Version: 3.0
Author: Ludou
Update: 2012-02-11
Description:Login to view all is an plugin designed to help you add hidden contents of your post. The hidden contents are only visible for the visitor who are logged in.
Download: From wordpress.org

Installation:

  1. Upload to your plugins folder, usually `wp-content/plugins/` and unzip the file, it will create a `wp-content/plugins/login-to-view-all/` directory.
  2. Activate the plugin on the plugin screen.
  3. Done

How to use?

1. You can switch to HTML editor and click the "loginview" button, to put your words needed to hide between "<!--loginview start-->" and "<!--loginview end-->". like:

<!--loginview start-->hidden contents.<!--loginview end-->

This has the advantage of that if you disable this plugin, the tag <!--loginview start--> and <!--loginview end--> will still not be displayed.

2. Or you can use it like that in your blog post :

[loginview]hidden contents.[/loginview]

[loginview] can be use in the visual editor and HTML editor.

Screenshots

Login to view all1


 

Login to view all2

-- 完 --

本文采用 「CC BY-NC-SA 4.0」创作共享协议,转载请标注以下信息:
原文出处:露兜即刻 https://www.ludou.org/wordpress-plugin-login-to-view-all.html
露兜
kaapass@outlook.com  QQ 825533758

业余编程爱好者。

180 条留言

点此留言
1 2 3 4 88
  1. specter

    您好,wp后台插件库中安装的版本在最新的wp版本中似乎已失效?编辑器按钮无法显示,手工输入断码也没有有,希望可以有空确认一下,谢谢~

  2. 今天吃条鱼

    高版本的php貌似提示
    Methods with the same name as their class will not be constructors in a future version of PHP.
    该更新了。

  3. 鲁哆蜜 鲁哆蜜

    正好我需要,感谢了,才发现是老乡啊!

  4. myth

    <!–loginview start–>" and "<!–loginview end–>"这个功能好像在新版的的wordpress已经失效了

  5. 行者或过客

    老板,这个插件效果上,登陆这个错字太扎眼了,能改成登录吗?

1 2 3 4

发表留言