Tag Archives: WordPress

Bulk Delete 0.3

I have fixed a bug in my Bulk Delete WordPress Plugin, which deleted drafts in a particular category even if only posts were selected. Thanks to one review for reporting it.

If you want to only delete posts in a category and not drafts, then you need to update to the latest version.

You can download the latest version from the Plugins home page. I have also uploaded the Plugin to the official directory to make your update process painless.

I am working on other features for the Plugin like deleting posts waiting for pending reviews etc. So stay tuned ๐Ÿ™‚

Posted in Plugin Releases | Tagged , , | 3 Comments

Matt, it’s your fault

I was browsing the WordPress official Plugin repository and I came across this error message. It trickled my funny bone and I took a screenshot.

wordpress-error-message
So now I know, if something goes wrong in Plugin repository it is Mattโ€™s fault ๐Ÿ™‚

PS: By the way, a page refresh solved the issue and things were working fine after that.

Posted in WordPress | Tagged , , , | 2 Comments

oAuth support in Twitter and WordPress 2.8

After waiting for more than two years, Twitter has finally enabled support for oAuth to all developers using its API. Itโ€™s a great move and itโ€™s a win-win situation both for the developers and also for Twitter users. Going forward, the Twitter third-party developers need not ask Twitter users for their username and password.

For the uninitiated, oAuth is an open protocol for online authentication. It enables a user who stores information such as a password on a particular Web site to then authorize yet another site to access that data, all the while not sharing the user’s identity with that site.

To give you a real-world non-technical example, it is like a car valet key, given to a parking assistant. Valet key unlike the original key, will have lot of restrictions like you cannot drive beyond few kilometers or cannot go beyond a particular speed etc.

In a similar move, WordPress 2.8 will also enable support for oAuth. Will Norris, has published an article explaining how oAuth is planned to be implemented in WordPress 2.8. There are yet some limitations (oAuth libraries need PHP5) but itโ€™s a great start.

If you are a WordPress Plugin author of any Plugin that hooks into authentication then you may have to change your Plugin code to support oAuth.

I am really excited about the support for oAuth in Twitter and WordPress. I need to play with them a little once I get some free time. ๐Ÿ™‚

Posted in API's/Mashup, WordPress | Tagged , , | 4 Comments

WordPress Plugin Readme File Generator

After writing some WordPress Plugins recently, I found that it takes a lot of effort to generate the Readme file for each of them.

For the uninitiated, readme file is a text file which has meta information about the Plugin and is usually bundled with the Plugin. Readme files for WordPress Plugins are very important, especially if you are planning to upload them to the official repository. WordPress follows a standard for the readme file so that the official repository can parse the meta information present in the file and render it like shown in the below screenshot.

bulk-delete-wordpress-plugin

The official Plugin repository has a sample readme file and also a validator. The readme file should have some tags and the text should be specified in the markdown format.

I was looking for ways to automate the process of generating these readme files and didnโ€™t find a solution. So I created my own ๐Ÿ™‚

You can find the WordPress Plugin readme file generator in my projects page and you can use it to generate the readme file for your WordPress Plugins too. ๐Ÿ™‚

Try it out guys and let me know if you want any other feature to be added to it.

Posted in WordPress | Tagged , , , | 3 Comments

Retrieving the categories of a blog post in WordPress

While writing my Bulk Move WordPress Plugin, I faced a unique bug. I was breaking my head for nearly two days to find out the correct way to retrieve the categories of a blog post in WordPress. I thought of documenting it here so that I know where I can search for it in future, when I need it and also it might help other WordPress developers who are hunted by the same bug.

Let me try to explain what I was trying to do, why it failed and finally how I rectified it.

Well I was trying to retrieve all the blog posts which satisfy a certain condition and then loop through them and assign them to a new category.

I was using the following code to retrieve the blog posts which satisfied a certain condition. Note that that I am using the built-in WordPress API as much as possible and not directly querying the database. This is one of the good coding practices for writing WordPress Plugins.

$my_query = new WP_Query;
$posts = $my_query->query(array('category__in'=>array($cat_id1, $cat_id2), 'post_type'=>'post', 'nopaging'=>'true'));

Now the variable $posts will have an array of post objects. You can loop through them using foreach.

foreach ($posts as $post) {
    print_r($post);
}

Will print

Array
(
    [ID] => 33
    [post_author] => 1
    [post_date] => 2009-01-19 08:32:41
    [post_date_gmt] => 2009-01-19 08:32:41
    [post_content] => Test from Sudar...
    [post_title] => Sudar Test
    [post_category] => 0
    [post_excerpt] =>
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] =>
    [post_name] => sudar-test
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2009-02-04 17:54:10
    [post_modified_gmt] => 2009-02-04 17:54:10
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http://sudarmuthu.com/?p=33
    [menu_order] => 0
    [post_type] => post
    [post_mime_type] =>
    [comment_count] => 0
)

If you look into the post object, you will see a column called post_category. I was trying to retrieve the category/categories of the blog post by reading this variable. But to my horror, I was getting only zero as value in this variable.

After some hours of hair pulling, I posted about this in the WP-hackers mailing list. It was only then I came to know that post_category is deprecated and we have to use other functions to retrieve the categories to which a blog post belongs to.

So the correct way to retrieve the category/categories is

foreach ($posts as $post) {
    $post_cats = wp_get_post_categories($post->ID);
}

$post_cats will be an array of category ids to which the blog post belongs.

So this is the complete code which you use to retrieve the list of categories to which a blog post belongs.

I didnโ€™t know the fact that the post_category was deprecated and I learned it the hard way ๐Ÿ˜‰

Even though the post_category field is deprecated it is not entirely useless. It can be used while updating a blog post.

Letโ€™s say that you want to move a blog post from one category to another. In this case you can set the array containing the category ids to post_category field and pass it to the wp_update_post () function. Code snippet below

foreach ($posts as $post) {
    $new_cats = array(5,10);
    wp_update_post(array('ID'=>$post->ID,'post_category'=>$new_cats));
}

Whew!! Finally I know how the correct way to retrieve the categories to which a blog post belong to. ๐Ÿ˜‰

Posted in WordPress | Tagged , | 25 Comments

WordPress 2.7.1 Released

WordPress 2.7.1 has been released and I just updated this blog.

It is a maintanence release for WordPress 2.7 and the official WordPress development blog reports that this release has fixes for around 68 tickets. Some of these tickets are bug fixes and therefore it is a recommended upgraded.

Since no new features have been introduced, this release should not break any of your Plugins or themes.

Posted in WordPress | Tagged | Leave a comment

BuddyPress for Single user WordPress installs – Confirmed

Well, the rumours are confirmed now. BuddyPress is going to be available for single user WordPress installs, later this year. The news has been confirmed by Andy Peatling, the lead developer behind BuddyPress, whom Automattic (the parent company behind WordPress) recruited to build BuddyPress.

So here is the tweet by Andy Peatling confirming the news

andy-peatling
This tweet was in reply to the following tweet
buddypress

Itโ€™s really very good news that BuddyPress is going to be available for single user WordPress installs, because when compared with WordPress MU, single-use WP is easy to install and maintain. Also this will surely increase the adoption rate of BuddyPress.

Also BuddyPress is getting stable and the 1.0 version might be released on Feb 12th 2009.

Meanwhile, if you are wondering what the heck is BuddyPress, then let me explain. It is a set of WordPress MU Plugins which will convert a plain WordPress MU install into a social network platform. You can get more information about BuddyPress at itโ€™s about page.

Posted in WordPress | Tagged , , | 6 Comments

Bulk Move Posts in WordPress

After I released my Bulk Delete WordPress Plugin (which can be used to delete posts in bulk) some of the readers of this blog asked me if there is a Plugin to move posts from one category to another in bulk rather than deleting them.

So I have created another Plugin called Bulk Move, which you can use to move posts from one category to another in bulk.

Screenshot

The following is the screenshot of the admin interface
Bulk Move WordPress Plugin Admin Screen

Download

You can download the Plugin for my WordPress Plugin page.

Disclaimer

Similar to the Bulk Delete Plugin, there is no way to undo the changes done once the categories are moved. So be very careful while using this Plugin and also note that you cannot hold me responsible for any damages done.

Posted in Plugin Releases | Tagged , , | 6 Comments

Bulk Delete Posts in WordPress

Recently I was playing with some auto posting WordPress Plugin in my test server and it quickly filled up a particular category with posts. I then wanted to bulk-delete the posts belonging to a single category. But I could find any WordPress Plugin to bulk-delete posts based on category or tag. So I created one. ๐Ÿ™‚

So guys I am releasing a new Plugin called Bulk Delete, which you can use to delete posts based on category or tag. I have also added abilities to delete all drafts, all post revisions or all pages.

Screenshot

The following is the screenshot of the admin interface.

bulk-delete-wordpress-plugin

Bulk Delete WordPress Plugin Screenshot

Download

You can download the Plugin for my WordPress Plugin page.

Disclaimer

Please note that there is no way to retrieve the posts once they are deleted. So be very careful while using this Plugin and also note that you cannot hold me responsible for any damages done. ๐Ÿ™‚

Update: If you are just looking for a Plugin to move the posts from one category to anothe in bulk, rather than deleting them, then check out my Bulk Move Plugin instead.

Posted in Plugin Releases | Tagged , , | 19 Comments

Open Flash Chart Core 0.4

I have updated the my Open Flash Chart Core WordPress Plugin to version 0.4

This is a mandatory update. So please update it.

I have fixed a couple of bugs and have also introduced two new options which you can use in your own Plugins which depend on Open Flash Chart Core Plugin. The following are the two options.

  • SM_OFC_PHP_INC โ€“ This constant contains the directory (include) path to the Open flash chart PHP library
  • SM_OFC_INC_URL โ€“ This constant contains the url path to the open-flash-chart.swf file.

If you are a WordPress Plugin developer, check out the Plugin’s page to find out ways to intergrate this Plugin with your other WordPress Plugins.

You can download the latest version from the Plugin page.

Posted in Plugin Releases | Tagged , , | Leave a comment