This wordpress plugin removes the author column on Edit Posts page (for custom post types as well). The author column doesn’t make sense on single author blogs. By removing it, you can save precious real estate and use other useful plugins like Simply Show Ids.

This is my first wordpress plugin. Just 6 lines of php code :). I spent more time writing the readme.txt than I did to write this plugin.

Yourls: WordPress to Twitter is a wonderful plugin which bridges yourls with wordpress. In addition to yourls statistics, I also wanted to track the clicks on the shortened link using Google Analytics. This requires addition of Google Analytics tags to the permalink URL which then gets shortened by yourls. Hence I modified the plugin code so that the URL that is fed into yourls can be modified the wordpress way – using a filter hook. Here’s the patch that I made.

diff -aurN yourls-wordpress-to-twitter/inc/core.php /home/pratikmsinha/humbug.in/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php
--- yourls-wordpress-to-twitter/inc/core.php  2010-03-09 12:37:14.000000000 -0800
+++ /home/pratikmsinha/humbug.in/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php  2010-07-01 18:23:39.000000000 -0700
@@ -61,7 +61,8 @@
  global $wp_ozh_yourls;
  
  $post_id = $post->ID;
- $url = get_permalink( $post_id );
+ //$url = get_permalink( $post_id );
+ $url = apply_filters('yourls_blog_post_url', get_permalink($post_id));
  
  if ( $post->post_type != 'post' && $post->post_type != 'page' )
    return;
@@ -71,7 +72,8 @@
    return;
  
  $title = get_the_title($post_id);
- $url = get_permalink ($post_id);
+ //$url = get_permalink ($post_id);
+ $url = apply_filters('yourls_blog_post_url', get_permalink($post_id));
  $short = wp_ozh_yourls_get_new_short_url( $url );
  
  // Tweet short URL ?
diff -aurN yourls-wordpress-to-twitter/plugin.php /home/pratikmsinha/humbug.in/wp-content/plugins/yourls-wordpress-to-twitter/plugin.php
--- yourls-wordpress-to-twitter/plugin.php  2010-03-09 12:37:14.000000000 -0800
+++ /home/pratikmsinha/humbug.in/wp-content/plugins/yourls-wordpress-to-twitter/plugin.php  2010-07-01 18:26:14.000000000 -0700
@@ -68,7 +68,8 @@
  if ( !$short && !is_preview() ) {
    // short URL never was not created before, let's get it now
    require_once(dirname(__FILE__).'/inc/core.php');
-   $short = wp_ozh_yourls_get_new_short_url( get_permalink($id), $id );
+   $url = apply_filters('yourls_blog_post_url', get_permalink($id));
+   $short = wp_ozh_yourls_get_new_short_url( $url, $id );
  }
  
  return $short;

To use the above patch, copy-paste the code into a file, lets say yourls.patch. Go into the yourls plugin directory (wp-content/plugins/yourls-wordpress-to-twitter/) and execute the following command.

patch -p1 < yourls.patch

Do ensure that you use the correct path to yourls.patch.

The Google Sitemap Generator WordPress Plugin is the most widely used plugin to generate a sitemap for a wordpress site. However it doesn’t support custom types yet. Hence the Google Bot hasn’t been visiting my website as frequently coz the sitemap doesn’t have the posts I add on my custom microblog. So I modified the plugin to add support for all public non-built-in post types. Here’s the patch.

To apply the patch, go to the folder of the google sitemap generator plugin ROOTDIR/wp-content/plugins/google-sitemap-generator and execute the below command.

zcat sitemap.patch.gz | patch -p0

Do make sure you specify the correct path for sitemap.patch.gz.

If you want a more elegant solution, go here. I found it after I wrote the patch :(.

I’m adding it directly to the plugin code, hoping that the next release of the plugin would bring support for custom post types and I won’t have to worry about the patch being overwritten.

Lets say you want to post from your Android or Iphone WordPress clients to a custom post type instead of the the defualt ‘post’ type. Paste the code below in your functions.php and you should be good to go 🙂

function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
    $p2_custom_post_type = 'custom_post_type'; //Change this to the custom post type you are using for your blog
    if (defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) {
        $data['post_type'] = $p2_custom_post_type;
        return $data;
    }
    return $data;
}

add_filter('wp_insert_post_data', 'redirect_xmlrpc_to_custom_post_type', 99, 2);

Change $p2_custom_post_type = 'custom_post_type' to the custom post type you are using for your blog.

Now I can post from my Android Phone to my custom P2 micro-blog 🙂

In wordpress, if 2 widgets are stacked horizontally, there is no straightforward way of setting the width of the left widget as x and that of the right widget as y through php/css. The only way to accomplish that is by using hardcoded class definitions in the css. I have jotted down an easy solution for this problem in the wordpress ideas forum. However the code that I pasted looks all gibberish because most of the HTML tags in the code are not allowed. Hence this post for anybody who wants to see the code and other details.Continue reading

I have been playing around with Symphony CMS the past one week (I’m kinda bored of WordPress). I use Dreamhost for all my hosting needs. Dreamhost is also one of the recommended hosts for Symphony, but has a low 3 star rating. I soon figured out why – one of the core symphony features called ensemble doesn’t work on Dreamhost because PHP on Dreamhost isn’t compiled with the ZipArchive class. Continue reading

Continuing my attempt to avoid wordpress plugins when possible and hand code the theme to include different functionalities, I looked around for php code snippets so that I could include the twitter anywhere code in my theme – the hovercards, the tweetbox and all that jing-bang. I found it here. I also added the tweetbox in addition to that. Here are the code snippets that you need to include in your theme’s functions.php to get twitter anywhere on your theme. Enjoy!Continue reading