Monthly Archives: April 2011

WordPress: Fixing the broken links from Jetpack top stats

I use the upgraded awesome plugin Jetpack by WordPress.com to show the ‘Top Posts’ is the sidebar. I recently noticed that the links for these post were broken, even though I wasn’t doing anything wrong at all. I queried the plugin for top 5 posts using:

$top_posts = stats_get_csv('postviews', 'days=-1&limit=6&summarize');
echo '<ul class="most-viewed">';
  foreach ( $top_posts as $p ) {
    if($p['post_id'])
      echo '<li><a href="'. $p['post_permalink'] .'" title="'.
        $p['post_title']. '">'. $p['post_title'] .'</a> - <strong>'. $p['views'] . '</strong> views</li>';
  }
echo '</ul>';

But somehow, the value at post_permalink key was wrong. Instead of pulling out my hair, I downloaded the Jetpack plugin’s source code, opened the file stats.php and copied a few lines and now the following works awesomely well.

if ( function_exists('stats_get_csv') && $top_posts = stats_get_csv('postviews', 'days=-1&limit=6&summarize')) {
  echo '<ul class="most-viewed">';
  foreach ( $top_posts as $p ) {
    if($p['post_id'] && get_post($p['post_id']))
      echo '<li><a href="' . get_permalink( $p['post_id'] ) . '">' .
          get_the_title( $p['post_id'] ) . '</a>', number_format_i18n( $p['views'] ) </li>';
  }
  echo '</ul>';
}

I hope this helps people looking for a quick fix to this problem.

Drupal: Facebook-style Micropublisher v1.1 released

After four months of relatively slow development of Facebook-style Micropublisher (FBSMP), I am happy to tag the branch with 6.x-1.1 release. It might be the last release for this branch, as I would now be upgrading FBSMP to support the latest 6.x-3.x branch of Facebook-style Statuses.

A lot of cool features are coming up with this release especially in the beloved link plugin,

  1. link plugin: allow users to share links to audio sharing sites such as soundcloud, 8tracks.
  2. Repost the attachments along with status (similar to re-share and re-tweet functionality), supported by link and photo plugin.
  3. link plugin: inline editing of title and description, cool JS.
  4. link plugin: edit the title and description field of the attachment.
  5. Support for processing GET parameters in the URL.
  6. link plugin now allows to share the URL using the flink GET parameter. More…

The complete list of features and bug fixes can be found in the release notes.

I hope you enjoy creating amazing sites using the new features and share them here for the world to know how cool this module is 😉