Category: WordPress

  • Clobber spam users WordPress plugin

    I’ve built another plugin for WordPress websites with open registration. This plugin makes it easy to prevent spam accounts from publishing posts.

    A screen shot of the dashboard this plugin creates

    Frequently asked questions

    What does this thing do?
    This plugin adds an item to the Users menu of your administration dashboard. Click the “Clobber Spam” link and you will see a page that puts the most recently created user names next to the email address and the title of the most recently created post by that user. You can check a box next to the users that have submitted spam and click a button to delete all their posts and prevent them from logging in again.
    Why not just delete the users?
    Because the software these spammers use will try to submit more than one post for each account, sometimes days later. If you delete the user, the same user name can be recreated. We can prevent the account from being used by changing the password and email address. The spam software is forced to create a new account to continue bothering us. Also, I already use a really good plugin to delete old and unused user accounts. It is called Inactive User Deleter by shra and I regularly use it to delete users with no posts and no comments that are at least 6 months old.
    Can this process of deleting spam post submissions be automated?
    I would love to build the “akismet for posts” because I could make a lot of money selling it. I have been using Ban Hammer and Stop Spammer Registrations and I still decided to build this plugin to handle about 50 posts a week that these plugins are failing to prevent.
    Can you add feature X?
    Send me your idea, and we can have a conversation.

     

    I have been running a WordPress website with open author registration for a few years, and the majority of the plugins I have written have been focused on making the management of that sort of site easier. Here is a list of the unreleased plugins I am using that I have created:

    • Count comment author URL as link: Include the comment author URL in the max links allowed for comment moderation
    • Disable comment author homepage links: Removes home page links from comment author user names
    • Hold posts with links: Set post status to pending when a new post is published containing any hyperlinks
    • Show pending posts count: Show the number of pending posts in the admin dashboard menu just like comments

    A list of the plugins I have published is always available on WordPress.org. I also use a version of WP Status Notifier that I have modified to include a post excerpt and a hyperlink that starts the user deletion process.

    With this plugin, Clobber spam users, I am going to stop deleting spam user accounts immediately and simply prevent their use for a number of months instead. I have given some thought to making the registration process more cumbersome for everyone, but I don’t want to sacrifice the user experience of real humans to fight the bots.

    Here is a download link: clobber-spam-users.zip @ WordPress.org

  • Top users WordPress plugin

    I wrote a new plugin to list the contributors to a WordPress website. The comment and post counts are added together, and the top X users are listed in a simple table alongside the counts.

    Download top-users-by-comment-plus-post-count.zip.

    Installation instructions

    1. Upload the `top-users-by-comment-plus-post-count` folder to the `/wp-content/plugins/` directory
    2. Activate the plugin through the ‘Plugins’ menu in WordPress
    3. Place this or a similar function call in your theme: <?php top_users_by_comment_plus_post_count( 10 ); ?>

    CSS sample

    This is the CSS I am using to style the output.

    #top-users-by-comment-plus-post-count td.tu-author{ padding-right: 8px; }
    #top-users-by-comment-plus-post-count td.tu-count{ text-align: right; }

    Sample output

    I added tab and line break characters for readability.

    <table id="top-users-by-comment-plus-post-count">
    	<tr><td class="tu-author">DisgustedInDenver</td><td class="tu-count">297</td></tr>
    	<tr><td class="tu-author">Corey</td><td class="tu-count">109</td></tr>
    	<tr><td class="tu-author">G11</td><td class="tu-count">60</td></tr>
    	<tr><td class="tu-author">jmbecker13</td><td class="tu-count">10</td></tr>
    	<tr><td class="tu-author">trustmedotcom</td><td class="tu-count">9</td></tr>
    	<tr><td class="tu-author">ulfwolf</td><td class="tu-count">8</td></tr>
    	<tr><td class="tu-author">noscamsforme</td><td class="tu-count">8</td></tr>
    	<tr><td class="tu-author">who8dapple</td><td class="tu-count">7</td></tr>
    	<tr><td class="tu-author">cindmo</td><td class="tu-count">7</td></tr>
    	<tr><td class="tu-author">nytemare4u</td><td class="tu-count">7</td></tr>
    </table>
    
  • Disable comment author links in WordPress

    I just wrote a new plugin to disable commenter names from linking to the website URLs they may provide when commenting.

    Some themes allow commenters to provide a home page URL along with their comment. The comment author’s name then becomes a link to that website wherever it appears on your site. This plugin removes those links.

    Download disable-comment-author-links.zip

    Installation instructions

    1. Upload the `disable-comment-author-links` folder to the `/wp-content/plugins/` directory
    2. Activate the plugin through the ‘Plugins’ menu in WordPress
  • Add content to the bottom of every WordPress post

    Bottom of every post is a WordPress plugin I wrote in July of 2011. This plugin is a simple filter that adds some content to the bottom of each post. I thought for sure a plugin like this would already exist, and I was surprised to find a few very complex solutions with way more features than necessary.

    This plugin has no other features and adds no administration options pages in your admin dashboard (because you can edit the settings via the Plugin editor). The message that is appended to each post is saved in a text file in the plugin directory. I chose a file on disk instead of a WordPress database option because I dislike plugin options pages for simple plugins.

    This plugin will never be updated, and that is a good thing. It is very simple and designed for you to make edits to suit your needs. An update would erase your customizations, so there will never be a new version.

    How can I edit the message?
    To edit the message that will be added to the bottom or footer of your posts, Go to Plugins > Editor and choose “Bottom of every post” with the top right selector. The plugin’s files will be loaded on the right. Choose the file `bottom_of_every_post.txt` and edit at will.
    How can I remove the message from my home page posts?
    You’ll have to edit the plugin. Find this line:

    if( !is_page( ) && file_exists( $fileName )){

    …and change that code to one of these lines depending on your configuration:

    Blog post home page

    if( !is_page( ) && !is_home( ) && file_exists( $fileName )){

    Static front page

    if( !is_page( ) && !is_front_page( ) && file_exists( $fileName )){

    How can I not show the message on a certain category?
    First, be sure whether you need a category exclusion or a custom post type exclusion. For categories, add a call to has_category:

    Exclude a category

    if( !is_page( ) && !has_category('portfolio') && file_exists( $fileName )){

    Exclude a custom post type

    if( !is_page( ) && 'portfolio' != get_post_type() && file_exists( $fileName )){

    Download bottom-of-every-post.zip

    Installation instructions

    1. Modify `bottom-of-every-post.txt` to contain the content you would like at the bottom of every post
    2. Upload the `bottom-of-every-post` folder to the `/wp-content/plugins/` directory
    3. Activate the plugin through the ‘Plugins’ menu in WordPress

    I am also going to use this code to teach a few people how to create their own WP plugins. Here is the full source code of my new plugin:

    
    <?php
    /*
    Plugin Name: Bottom of every post
    Plugin URI: https://coreysalzano.com/wordpress/bottom-of-every-post/
    Description: Add some content to the bottom of each post.
    Version: 1.0
    Author: Corey Salzano
    Author URI: http://profiles.wordpress.org/users/salzano/
    License: GPL2
    */
    
    
    /*
    	avoid a name collision, make sure this function is not
    	already defined */
    
    if( !function_exists("bottom_of_every_post")){
    	function bottom_of_every_post($content){
    
    	/*	there is a text file in the same directory as this script */
    
    		$fileName = dirname(__FILE__) ."/bottom_of_every_post.txt";
    
    	/*	we want to change `the_content` of posts, not pages
    		and the text file must exist for this to work */
    
    		if( !is_page( ) && file_exists( $fileName )){
    
    		/*	open the text file and read its contents */
    
    			$theFile = fopen( $fileName, "r");
    			$msg = fread( $theFile, filesize( $fileName ));
    			fclose( $theFile );
    
    		/*	append the text file contents to the end of `the_content` */
    			return $content . stripslashes( $msg );
    		} else{
    
    		/*	if `the_content` belongs to a page or our file is missing
    			the result of this filter is no change to `the_content` */
    
    			return $content;
    		}
    	}
    
    	/*	add our filter function to the hook */
    
    	add_filter('the_content', 'bottom_of_every_post');
    }
    
    ?>
  • Export comments WordPress plugin

    I launched a new WordPress plugin to export a blog’s comments. Specifically, this plugin creates a tab-delimited text version of the wp_comments database table. Options include approved, pending or spam (or any combination of) comments.

    This page will soon expand. For now…

    Download this plugin from WordPress.org

  • WordPress comment paging creates duplicate content

    I learned something today about WordPress that I would like to share. The “break comments into pages” feature can create duplicate content for all posts that have only a single page of comments. I made this graphic to explain exactly what happens.

    comment-page-1

  • Landing page triggers WP plugin free version

    This plugin redirects users of your WordPress website to any page you like after they publish a new post or log out. You can provide any URL, so the page can even be on a different website altogether.

    Landing pages can help coordinate, congratulate or incentivize users who are already interacting with your website.

    I have also written a non-free version that includes redirects after leaving a comment and user login in addition to the free features.

    Installation Instructions

    1. Download landing-page-triggers-free.zip
    2. Decompress the file contents
    3. Upload the landing-page-triggers-free folder to a WordPress plugins directory (/wp-content/plugins)
    4. Activate the plugin from the Administration Dashboard
    5. Visit “Landing pages” under Settings to configure the triggers

     

    Control panel screen shot:

    landing-page-triggers-free-version

     

    I have been using this functionality to thank contributors for their posts, and it works wonderfully. If you are interested in the enhanced feature set, that version is available here for 6$ USD.

  • WP Plugin: Recent comments widget with excerpts

    I wrote a WordPress plugin to modify the behavior of the recent comments widget. Since WP version 2.8.0, popular widgets have been included as core functionality. I don’t like how the recent comments widget works, so I changed it. Instead of displaying the post titles that received comments, my plugin shows comment excerpts. I made this graphic to show the difference between the default behavior and the effect of this plugin:

    recent-comments-widget-with-excerpts

    WordPress.org link

    Visit this plugin’s page in the official WP plugin directory.

     

    Installation Instructions

    1. Download recent-comments-widget-with-excerpts.zip
    2. Decompress the file contents
    3. Upload the recent-comments-widget-with-excerpts folder to a WordPress plugins directory (/wp-content/plugins)
    4. Activate the plugin from the Administration Dashboard
    5. Open the Widgets page under the Appearance section
    6. Drag the Recent Comments widget to the active sidebar

    Enjoy!

  • Disable WordPress New User Email Notification

    When a new user creates an account on a wordpress.org blog, the administrator is sent a notification email. Websites that have a large number of signups each day can generate a lot of emails announcing each new user.

    I wrote a simple WordPress plugin to disable the new user notification email. Visit this plugin’s page in the official WP Plugins Directory.

    Installation instructions

    1. Download disable-wp-new-user-notification.zip
    2. Decompress the file contents
    3. Upload the disable-wp-new-user-notification folder to a WordPress plugins directory (/wp-content/plugins)
    4. Activate the plugin from the Administration Dashboard
  • WordPress Sidebar Stats Widget

    I wrote a WordPress plugin that displays a small collection of site stats in a sidebar widget. Here is a screen shot of sample output:

    sidebar-stats-widget

    Widget options screen shot

    The widget includes a control panel to change the title and format the HTML that is inserted before and after each numerical stat.

    sidebar-stats-widget-options

    Installation Instructions

    1. Download sidebar-stats-widget.zip
    2. Decompress the file contents
    3. Upload the sidebar-stats-widget folder to a WordPress plugins directory (/wp-content/plugins)
    4. Activate the plugin from the Administration Dashboard
    5. Open the Widgets page under the Appearance section
    6. Drag the Sidebar Stats Widget to the active sidebar
    7. Configure the widget options to suit your needs and click Save

    WordPress.org plugin page

    This plugin is in the official WordPress Plugin Directory here.

  • Hide posts from WP home page

    Hiding posts from showing up on the home page is something I have been thinking about all week. Last night I finally dug into the WP Codex and figured out how to make it happen. Hide WordPress posts from appearing on your home page by adding their post IDs to the following array (where you see 603 and 621), and place this code before the loop starts in your theme’s main index file.


    <?php
    if( is_home()){ query_posts(array('post__not_in' => array(603,621))); }
    ?>

    This code prevents posts from showing up on your home page, but allows them to be directly accessed and shown in views other than the home page like category archive. The posts will also be included in your RSS feed.

    F.A.Q.

    • Where do I put this code?

      Place the code before the loop starts in your theme’s index. To edit the index file, browse to Design > Theme Editor > Main Index Template. Place the code anywhere before this line: <?php if (have_posts()) ?>

    • How do I find the IDs of my posts?

      Go to Manage > Posts and mouseover the titles of your posts. Look at the URL showing up in your browser’s status bar. The post ID will be at the end of the edit post link URL you see.

    Most ‘hidden post’ tutorials explain to use a hidden category. The problem with the category approach is the need to hide the category from showing up in the sidebar and any other place it may appear. WP does not have built in hidden or secret categories. The idea of chasing out a category everywhere categories are shown on my WP is not an attractive idea.

    This code lets me publish posts that are not intended for prime time viewing but work great as a post rather than a page.

  • Display WP Post Category without link

    Here is a small piece of code that will display the category name of a WordPress post without a hyperlink to the category page. Typically, the category data is retrieved with the_category( ). This function is not useful for manipulating the category name in plain text. Displaying the category in plain text is easy with get_the_category( ), however.


    <?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?>