Show LOCK icon next to subscribe content
-
Dear Community,
I have got a memberpress plugin under my website and I would like to show a lock icon next to the exclusive content, following some code found in this forum I created a PHP page under wp-content/plugins/memberpress-lock-icon/lock-icon.php which contains the following code:
<?php /** * Plugin Name: Lock-icon * Plugin URI: * Description: Plugin to show the lock icon on subscription content * Version: 1.0 * Author: Gonzalo López * Author URI: https://twitter.com/ankeorum * License: GPL */ /* Copyright YEAR PLUGIN_AUTHOR_NAME (email : PLUGIN AUTHOR EMAIL) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Filter to display a Locked Font Awesome Icon next to the Title of a Restricted Post/Page */ add_filter('the_title', 'pmsc_add_icon_next_to_restricted_post', 10, 2); function pmsc_add_icon_next_to_restricted_post($post_title, $post_id) { if (is_admin()) { return ''; } if (pms_is_post_restricted($post_id)) { //return '<i class="icon-lock" aria-hidden="true"></i>' . ' ' . $post_title; return '<p>LOcked content</p>' . ' ' . $post_title; } return $post_title; }
Originally was designed to show an icon but as that did not work I changed to show a paragraph.
I do not know much about wordpress hence I am asking maybe so basic things. After creating that PHP file I only uploaded to the FTP server but did nothing on the wordpress administration panel. Is there something you should do to make it work? If not, can anyone assist? I just want to find the piece of code where it determines if the content is locked or not and add a keychain icon to the title (maybe a keychain icon hovering over the content image would be perfect but with the title is enough for now).
Thank you in advance!
- The topic ‘Show LOCK icon next to subscribe content’ is closed to new replies.