Simply Exclude plugin version 2.0…finally!

January 23rd, 2012 @ 6pm : no comments : Socialize This
Filed Under: Tags: , , ,

I’m formally announcing the release of the first best of the popular Simply-Exclude plugin. You can download the beta version plugin from this site below.

NOTE: THIS IS A BETA VERSION AND SHOULD NOT BE USED ON A PRODUCTION SITE. PLEASE ONLY TEST ON A DEVELOPMENT SITE. YOU HAVE BEEN WARNED

Some interesting points regarding the new 2.0 release:

  1. The plugin has been rewritten from the ground up. This means the old crappy code from 3 years ago have been replaced with newer crappy code. :)
  2. Taxonomies and Post Types. The prior version of the plugin only supported the built-in Taxonomies and Post Types. The new version supports any Taxonomy and Post Type. Some Post Types like nav menus and links are purposely excluded. Oh My!
  3. New interfaces. In the prior version of the plugin I build screens for each supported Taxonomy and Post Type. Over the years I had reports that when the site contains 3000 tags loading the Tag Exclude screen would take forever. Well good news. All those screens are history. In the new version of the plugin I’ve added columns to the Taxonomy, Post Type and User listing to allow management within a more natural interface.
  4. I’ve updated the Settings/Options screen to by a simply listing of the Taxonomies and Post Types and what actions you are allowed to filter on.
  5. I’ve removed support for third-party plugins. In the previous version of the plugin I supported integration with two plugins, Google XML Sitemaps an Search Unleashed. Over the years these plugins have changed such that my backdoor method of interfacing with them kept breaking. This became a headache. So decided to drop the support. Sorry for anyone who relies on this.
  6. Finally all those who have tried to use this plugin to Exclude Pages now will have a working solution. The new version of this plugin now properly filters Pages on Search. Also, I’ve added support for the WordPress Pages Widget.
  7. I’ve compiled a Help panel to assit those having trouble or just needing to get unstuck

Still todo. I need to make sure this new code works under a Multisite installation. I’ve tested on my local development site using the default WordPress theme and settings. From what I can tell it works. But would really like to get someone who is heavy into Multisite give it a review.

Download Simply Exclude version 2.0 Beta 1

Adding Custom Columns to WordPress Post listing

July 13th, 2011 @ 9am : 3 comments : Socialize This
Filed Under: Tags: , , , ,

In a reader comment one of my previous posts about “Adding columns to Taxonomy tables”. The commenter asks how to add columns to a normal Posts listing.

Well, readers here is the simple solutions. There are basically 2 hooks. One is a filter. The other an action. Below are examples of how to setup these hooks. I explain the details below the code listing.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
add_filter( 'manage_edit-post_columns', 'admin_post_header_columns', 10, 1);
add_action( 'manage_posts_custom_column', 'admin_post_data_row', 10, 2);

function admin_post_header_columns($columns)
{
    if (!isset($columns['note']))
        $columns['note'] = "Notes";
   
    return $columns;
}

function admin_post_data_row($column_name, $post_id)
{
    switch($column_name)
    {
        case 'note':       
            // Logic to display post 'Note' field information here.
            // $post_note = get_post_meta($post_id, 'note', true);
            //if ($post_note)   echo $post_note;
           
            break;
                       
        default:
            break;
    }
}

So what are these filters/actions function?

The first line, add_filter( ‘manage_edit-post_columns’… sets up a filter. This filter adds the new column to the listing. This filter is called only once when the page is loaded. Since this is a Filter WordPress will call our function ‘admin_post_header_columns’ and pass in a parameter. In this case the parameter is an array of columns. As part of our function we can change/add/delete items from the array then we MUST return the array. In our simple example all we are doing is adding an item to the array for our ‘Notes’ columns. As with any PHP array we assign a key to be ‘note’ and the column label ‘Notes’. Then return the array back to WP.

A note about the filter name. Notice we setup the filter as using the first parameter ‘manage_edit-post_columns’. Keep in mind this filter is specific to Posts. If you wanted to do this same thing for Pages you would instead use ‘manage_pages_columns’. Or if you were using a custom post type the value would be ‘manage_{$post_type}_posts_columns’ where ‘{$post_type}’ is your post_type. For example if we register a new post_type Products with the key ‘products’ then the filter would use the parameter of ‘manage_products_posts_columns’. On to the second hook. The action.

The second line of our code registers an action. While the previous filter added the column to the listing. This action gets called for each row of the displayed posts to display the contents in the row cell for that column. In WordPress an action is different than a filter in that your function may be passed some optional parameters but you are not expected to return any values. For our purpose we setup an action to the hook ‘manage_posts_custom_column’ which will call our function ‘admin_post_data_row’.

Inside our function we setup a case statement to switch on the column name. In our instance we only want to effect the ‘note’ column. This ‘note’ value is the array ‘key’ we defined in our previous filter function.

Back to the action hook registration. Notice the third and fourth parameters on this action registration call. The third parameter tells WordPress the priority of this hook o when to process it in relation to other hooks. A lower number means sooner a higher number means later. We set this to ’10′ which is a default value. The fourth parameter tells WordPress how many arguments to pass to our function. By default there will be only one argument, the column name. But since each row (post item) will have different values we need the second parameter which in this case is the ID of the post so we can look up the related custom field.

Also, like the filter hook where we setup the column there are different filters to call based on if you are using this on Pages, Posts or some custom post_type. In our case we are adding the column to the Posts listing so the first parameter of our hook is ‘manage_posts_custom_column’. If we were adding a column to Pages the parameter would instead be ‘manage_pages_custom_column’. And if we were adding this column to a custom post_type the parameter would be ‘manage_{$post->post_type}_posts_custom_column’ where ‘{$post->post_type}’ is the key to our registered post_type.

I hope this helps with a deeper understanding of WordPress and an appreciation of the wonderful world of WordPress actions and filters.

Pages-Children 1.5 released

July 3rd, 2011 @ 10am : Comments Off : Socialize This
Filed Under: Tags: , , , ,

Over the last week I’ve released 3 versions of my popular Pages-Children plugin.

Here is a breakdown of the changes.

1.3.1 – Fixed issues is plugin which were effecting the Media Library listing. As far as I can tell this was related to the update in WordPress 3.1.3

1.4 – Added support for any hierarchical post type. Previous versions of the plugin only worked for the default Pages. Now if you have any custom post type defined hierarchical you can have better formatting of the output.

1. 5 – In the previous version (1.4) I added support for custom post types. In this latest version I’ve added support for hierarchical taxonomies as well. Here is an example of a terms listing showing the breadcrumbs and navigation to ‘children’.

To comment or report an issue regarding this plugin please see the main project page for Pages-Children

Out of 1000 WordPress plugin developers I’m now ranked 372!

February 2nd, 2011 @ 8am : no comments : Socialize This
Filed Under: Tags: , ,

Thanks to W-Shadow for putting together this nice page, http://w-shadow.com/files/top-1000-plugin-authors.html.

The page appears to be a mashup (do people still use that term) taken form wordpress.org plugin repository. The ranking on the page appears to be based on plugin downloads. Still out of 1000 plugin authors it’s nice to be in the top half. Though would be grateful to placement anywhere on the list. Thanks W-Shadow.

Media-Tags 3.0 plugin for WordPress Released

December 9th, 2010 @ 3pm : no comments : Socialize This
Filed Under: Tags: , ,

I’m proud to say I’ve finally released Media-Tags 3.0 to the general public and it is available via the WordPress plugin repository http://wordpress.org/extend/plugins/media-tags/. Thanks to all who contributed ideas, bug reports and support in this milestone development. And my apologies for taking so long to get this out.

This plugin contains many new features. Some highlighted items are:

  • Bulk Administration of media items This feature on both the Media > Library and Media Upload popup for the Post admin screen allow you to assign/remove Media-Tags to a selected group of media items. In previous versions you would need to edit each media item.
  • Roles management Under the Media-Tags Settings panel is a new Roles management panel. This panel allows you to fine tune the access by individual users.
  • Internationalization This is a much needed and requested features. Now all text handled by the plugin are using the WordPress i18n hooks to support translation into other languages.
  • Removed over 1000 lines of custom code This old code was used to provide basic functionality for the tagging and URL rewrites. Since WordPress core functions have progressed over the last two years this custom code is no longer needed. This means the plugin will run cleaner and is more stable than previous releases.
  • Better support for WordPress standard Taxonomy templates In the past the plugin has supported a custom theme template, mediatag.php. The plugin now support the more standard WordPress templates taxonomy-media-tags.php.
  • A new Help section This new Help section provides many topics from general use to shortcodes tricks to template files support questions. Check it out.
  • Many other features have been added. Too many to mention here.

Please leave all comments on the Media-Tags project page.