Tag Archives: WordPress

Plugin to display WordCamp NYC Badge

I guess, I am getting addicted to writing WordPress Plugins. šŸ™‚

I was looking at the WordCamp New York Badge page and thought it would be nice to have a Plugin to display the badge, so after 30 minutes or so, WordCamp NYC Badge WordPress Plugin was born.

You can see it in action in my sidebar. šŸ™‚

PS: If you are wondering why I am interested in WordCamp NYC, then do wait for another 3 weeks šŸ˜‰

Posted in Plugin Releases | Tagged , , , | 4 Comments

Log every email send through WordPress

As promised, I have created a new Plugin called Email Log which will log every email that is being sent through WordPress. This Plugin will be very useful, while debugging issues related to email and will also let you to find out whether any spammer is abusing your WordPress installation. This Plugin is also MU compatible and can be used in WordPress MU installations also.

Features

Viewing logged emails

The logged emails will be stored in a separate table and can be viewed from the admin interface. While viewing the logs, the emails can be filtered or sorted based on the date, to address, subject etc.

Deleting logged emails

In the admin interface, all the logged emails can be delete in bulk or can also be selectively deleted based on date, to address, subject.

Cleaning up db on uninstall

As recommended by Ozh, the Plugin has uninstall hook which will clean up the database when the Plugin is uninstalled.

Screenshots

The following screenshot shows how the logged emails will be displayed

view-wordpress-email-logs

This screenshot shows how the email logs could be filtered or sorted.

wordpress-email-log-filter-options

This one shows how the email logs could be deleted.

wordpress-email-log-delete-options

Download

You can download the Plugin from the Pluginā€™s home page.

Feedback

As usual try out the Plugin and do let me know if you have any feedback, queries or comments.

Posted in Plugin Releases | Tagged , , , | 1 Comment

Lessons from WordPress Plugin competition

As you may know already (and if you donā€™t, dude, follow me) I participated in the recent WordPress Plugin competition. The results are out and even though my Plugins were not selected, I received a much more valuable gift. Guess what, a detailed review of all my five Plugins by my favorite WordPress expert and a great inspiration Ozh.

The following are the lessons that I learned from the reviews

  • The details that you enter in the Pluginā€™s page like Plugin Description, screenshot, installation instructions, FAQ, example usage etc, but really help you to get more users for your Plugins
  • When you are using PHP 5+ only features, make sure that you have a fall back mechanism and correct warning to users.
  • When making calls to APIā€™s it is better to use the built-in WP_Http class instead of CURL or sockets
  • Donā€™t hardcode the Plugin directory or file name, some users may change it, which might break your Plugin.
  • Similarly donā€™t hard code wp-content directory path. Some users might move their wp-content directory to a different path which might again break your Plugin.
  • If you need scripts or CSS, to be included, then include them only to the pages that need them and not to all pages.
  • If you are creating a table or storing too many options in db, then it is always better to provide an uninstall hook to clean this stuff when the Plugin is delete by the user.

I am guilty of most of them and I am in the process of modifying my Plugins to fix these issues and over a next couple of days you could see updates to most of my Plugins.

Itā€™s always nice to get feedback for your work from someone whom you respect and in that way I am really very happy that I participated. Thanks Ozh for your time and feedback and WTC for sponsoring the competition and wishes for the winners.

Posted in WordPress | Tagged , , | 8 Comments

WordPress MU and BuddyPress Plugin competition – 2009

Similar to the WordPress Plugin competition conducted by Weblogs Tools Collection, WPMU is coding a WordPress Plugin competition for WordPress MU and BuddyPress.

All you need to do is to create a (awesome) WordPress MU or BuddyPress Plugin and then release it. šŸ™‚

Dates

The competition is open till Friday October 16th.

Prizes

There are some cool prices and the first prize winner will be get a cash award of $1000.

Rules

The rules are similar the WordPress Plugin competition and the main thing to remember is that your Plugin should be in GPL or GPL-compatible licence.

So itā€™s time to start another WordPress project. šŸ˜‰

BTW guys, I am looking for ideas. So if you wanted a Plugin for WordPress MU or BuddyPress, then let me know and I might be able to create it for you. šŸ™‚

Posted in WordPress | Tagged , , , , | 3 Comments

Retrieving posts and pages based on title in WordPress

Update: The get_page_by_title() function now includes a third parameter that allows you to specify the post_type. You can use this parameter to get pages, posts or custom taxonomies. The below function is no longer needed.

Recently, I needed to retrieve posts and pages in WordPress based on their title. I digged into WordPress code to find out the function that can do it, but to my surprise, I found out that there isn’t a function that could work both for pages and posts.

Some people might argue that the easy way is to query the database directly, but I generally try to use a build-in function if available rather than querying the database directly.

After some poking around in the wp-hackers maling list and #wordpress irc channel, I used the following code in my Plugin. I thought of sharing this here, so that it could be helpful to others.

Retrieving pages based on title

For pages, there is a built-in function get_page_by_title() which we can use. The code would be

Retrieving posts based on title

For posts, we don’t have a built-in function. We have to manually query the database. I have written a function which can do this.

Retrieving multiple posts based on title

If you have more than one post with the same title, then the above function will return only the first post. If you want to retrieve all the posts which have the title, then you can use the below function. Thanks Jerry.

Including this as part of the core

As I said before, I always prefer to use a built-in function rather than querying the database directly. I am planning to add a new ticket to WordPress trac to add this function to the core. Will keep you all updated about the ticket status.

Update: I have created a ticket in WordPress trac, to add this function to the core. Let’s hope it gets to the core.

Posted in WordPress | Tagged | 31 Comments

Ability to sort posts, in Posts By Tag Plugin

I recently updated my Posts By Tag Plugin, to v 0.4

New Features

The main new feature of this update is that, now you have the option to choose the order in which the posts should be displayed in the widget. The credit for this feature goes entirely to Michael, because he is the one who code it. He sent me the modified file and I have just checked it into the Pluginā€™s SVN and modified the Readme file. (Can anyone expect more šŸ˜‰ ) Thanks Michael.

Screenshot

The following is the screenshot of the widgets page where now you have to option to choose whether the posts should be displayed in ascending or descending order by date.

posts-by-tag-settings

Download

You can download the latest version of the Plugin from the Pluginā€™s homepage.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment.

Vote for the Plugin

If you have used this Plugin and like it, please vote it and help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 2 Comments

How to send email in WordPress using Gmail’s SMTP server

Well this question was asked to me for more than a couple of times now. So I thought of documenting it here, instead of answering them individually. šŸ™‚

Long time readers of my blog would know that I use Google App for email. Ever since I moved to Linode for hosting, I stopped running a mail daemon in my server, and instead choose to use Gmailā€™s SMTP server for sending email.

There were two reasons for it. First most email providers ignore or mark as spam, emails sent from non-SMTP servers. Second, removing mail daemon from server will save some resources and will increase the over all performance of my server.

Using SMTP in WordPress

For WordPress there is an excellent Plugin called WP Mail SMTP, which can be used to send email through Googleā€™s SMTP servers.

Download and install the Plugin and in the settings page you have to set the following options.

  • SMTP Host: smtp.gmail.com
  • SMTP Port: 465
  • Encryption: Use SSL encryption
  • Authentication: Yes
  • Username: Your full Gmail address or Google App email
  • Password: your account password

You can also checkout the following screenshot for reference.

using gmail smtp in WordPress

I am also working on a Plugin to log all emails sent by WordPress. Expect it to be released soon šŸ™‚ (Update: The Plugin to log all emails is ready. It is called Email Log and you can download it from the Plugins page.)

Update (Oct 2012)

I just realized that these days Google has added additional security for logging in using other clients. If your email is not sent properly after giving correct password, then refer to instructions at Gmail help to fix it.

Also if you have enabled two factor authentication, then refer to this Gmail support page.

Posted in WordPress | Tagged , , , , | 66 Comments

Post to FriendFeed 1.0

I have updated my Post to FriendFeed WordPress Plugin to v1.0

New Features

The following are the new features that I have added to the Plugin

Pluggable Filters

I have added the following filters to the Plugin which can be hooked by your own code.

  • post2ff_blog_url ā€“ The link which will be posted to Friendfeed
  • post2ff_blog_excerpt ā€“ The excerpt that will be posted as the first comment to Friendfeed
  • post2ff_blog_images ā€“ The images that will be posted to Friendfeed

The following code example explains how you can use bit.ly (or any url shortening service) to shorten the link that will be posted to Friendfeed.

add_filter(ā€˜post2ff_blog_urlā€™,ā€™your_plugin_short_urlā€™);

function your_plugin_short_url($url) {
	$shorten_url = get_short_url($url);
	return $shorten_url;
}

You can place the above code either in your own Plugin or in the functions.php file of your theme. If you want to shorten the url using bit.ly then you can use the code from my other post.

You can use the similar technique to change the excerpt or images, which will be posted to Friendfeed.

Translation

I have added the ability to translate the Plugin. The pot file is available with the Plugin. If you are willing to do translation for the Plugin, use the pot file to create the .po files for your language and let me know. I will add it to the Plugin after giving credit to you.

Update

You can download the latest version of the Plugin form its home page. It is an optional update and doesnā€™t change anything in the front-end.

Feedback

As usual, if you have any feedback, queries or questions, feel free and leave a comment.

Posted in Plugin Releases | Tagged , , , | 3 Comments

Disable/Enable retweet button for each post

Okay, yet another update to my Easy Retweet Plugin. šŸ™‚

Configure retweet button for each post

Now you can enable or disable the retweet button for each post or page. When you update to the new version, you will see a new box on the right hand side of the write post/page screen where you can enable or disable the button.

This setting will over ride all the other options which are set in the admin console page.

Screenshot

Easy Retweet WordPress Plugin Screenshot

Removed the hard coded wp-content path

I have also removed the hard coded reference to the wp-content path. This means that the Plugin will work for people who have moved their wp-content to a different folder.

This change involved a hack to make the JavaScript work properly. I will write an article explaining this hack in detail, meanwhile if you canā€™t wait then check out the source code. It is well documented. šŸ™‚

Download

You can download the latest version of the Plugin from the Pluginā€™s homepage.

Feedback

Please keep the feedback coming and if you want me to add any new features or find a bug, please leave a comment.

Vote for the Plugin

If you have used this Plugin and like it, please vote it and help me win the WordPress Plugin competition.

Posted in Plugin Releases | Tagged , , | 5 Comments

Using WordPress built-in tag auto complete script in your Plugins

When I released my Posts By Tag WordPress Plugin, I promised to write a post explaining how to use the built-in auto complete tags script in WordPress, and so here is how you do it. šŸ˜‰

jQuery Plugin

WordPress has a jQuery Plugin called suggest, which will do the heavy lifting for us. To use this Plugin, you have to first enqueue the script using the wp_enqueue_script() function

// Register hooks
add_action('admin_print_scripts', 'add_script');

/**
 * Add script to admin page
 */
function add_script() {
    // Build in tag auto complete script
    wp_enqueue_script( 'suggest' );
}

Once the script is included, you have to just call a method called suggest on your jQuery collection and everything else will be taken care for you.

<?php
/**
 * add script to admin page
 */
function add_script_config() {
?>

    <script type="text/javascript" >
    // Function to add auto suggest
    function setSuggest(id) {
        jQuery('#' + id).suggest("<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag");
    }
    </script>
<?php
}
?>

If you want to support multiple tags, then you can use the following options.

  • multiple – to enable multiple tags to be entered, pass true
  • multipleSep – The separator symbol for multiple tags

so the code will be

<?php
/**
 * add script to admin page
 */
function add_script_config() {
?>

    <script type="text/javascript" >
    // Function to add auto suggest
    function setSuggest(id) {
        jQuery('#' + id).suggest("<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag", {multiple:true, multipleSep: ","});
    }
    </script>
<?php
}
?>

You can also use this script to auto complete other custom taxonomies, which were introduced in WordPress 2.8. For that you have to change the tax parameter in the url. The following are the default taxonomies that are available.

  • post_tag
  • link_category
  • category

In addition to them you can also use your custom taxonomies.

So the complete code is

<?php
// Register hooks
add_action('admin_print_scripts', 'add_script');
add_action('admin_head', 'add_script_config');

/**
 * Add script to admin page
 */
function add_script() {
    // Build in tag auto complete script
    wp_enqueue_script( 'suggest' );
}

/**
 * add script to admin page
 */
function add_script_config() {
?>

    <script type="text/javascript" >
    // Function to add auto suggest
    function setSuggest(id) {
        jQuery('#' + id).suggest("<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag", {multiple:true, multipleSep: ","});
    }
    </script>
<?php
}
?>


The only cavet to this method is that right now the admin-ajax.php file needs you to be logged in and therefore can only be used in admin pages. But in WordPress 2.9 even anonymous users can load admin-ajax.php file. If you need use auto tag completing in blog pages, then you may have to wait till 2.9 is released šŸ™‚

Posted in WordPress | Tagged , , , | 26 Comments