Some of my clients are using their WordPress installs with pages only, i.e. without any posts, and with comments turned off completely. This is often referred to as “WordPress as a CMS”. To free the screen from clutter I like to remove the comments link from the new/revised WordPress 3.3 Admin Bar. I also usually change the “+ New” link to default to creating a new page instead of creating a new post.

To accomplish this you can drop the following lines into your theme’s functions.php file:

<?php
function my_admin_bar_menu( $wp_admin_bar )
{
  $wp_admin_bar->remove_node( 'comments' );
  $newpage = $wp_admin_bar->get_node( 'new-page' );
  $wp_admin_bar->add_node( array( 'id' => 'new-content', 'href' => $newpage->href, ) );
}
add_action( 'admin_bar_menu', 'my_admin_bar_menu', 100 );

To find out more about the Admin Bar API you should check out this post by Andrew Nacin on the official WordPress Development Blog.

Since the upgrade to version 3.2.2 Nagios does not update the host alias macro when the configuration is reloaded. Macros are the variables used in commands, such as notification commands, i.e. the information you receive via E-mail when there is a problem with your hosts or services.

As long as you don’t change your host alias information you will never notice. I did change it and I found myself scratching my head for some time, especially since the same information does get updated in the web interface.

I found a greater number of forum discussions relating to this, but none seemed to offer a practical solution for larger scale environments.

After some pondering I came up with these lines:

service nagios stop
cp /usr/local/nagios/var/retention.dat /usr/local/nagios/var/retention.bak
grep -v ^alias /usr/local/nagios/var/retention.bak > /usr/local/nagios/var/retention.dat
service nagios start

They do the trick in my installations.

Update: Here’s a brief summary of the error and what the script does to work around it.

When Nagios parses the configuration and finds a new host it loads the alias field into memory. When Nagios reloads the configuration, the alias information that is already in memory does not get updated. When Nagios stops (or before reloading the configuration) the alias information in memory is dumped to the retention.dat file. When Nagios isn’t running and you start the service, it doesn’t load the alias information from the configuration files but from retention.dat, unless that information is not present in the file. So my solution does the following:

  1. Stop Nagios
  2. Make a backup copy of the retention.dat file (Note: I’m copying the file instead of renaming it to make sure that it will still have the same owner/group and permissions when I write to the original file in the next step)
  3. Strip all lines starting with “alias” from the backup file and overwrite the original retention.dat file with this data
  4. Start Nagios

You may have to tweak the file location for the retention.dat and backup files. You may also need to change the commands that stop and start the Nagios deamon.

The next version 1.1 of my Open Graph Pro WordPress Plugin will feature an API (a public method and two filter hooks) that can be utilized by theme and plugin developers who would like to add “Like” buttons to their blogs. The API also allows you to add Custom Object Types.

If you want to test-run the API go to the Open Graph Pro download page and grab the Development Version. The API is not going to change anymore. The code is also pretty much final. I’m merely working on some final UI touches and i18n/L10n of the plugin.

Code snippets for adding “Like” buttons or using Custom Object Types are part of the API documentation.

I just released version 0.4.2 of my Comment E-Mail Verification WordPress plugin. Most important change: verification codes are no longer being generated (and thus no longer cluttering up the database) for trackbacks and pingbacks. Thanks to Joost de Valk who contributed a few lines of code that ultimately took this important aspect off my todo-list.

As always: Download it directly from the wordpress.org plugin directory!

So I’ve been playing around with Google+ for a little. And then +Lars Becker actually made me “Send feedback” to Google… seems that they have a little problem with their privacy settings:

If you hide who’s in your circles from your profile page, but then post something to a circle, people can click on the word “Limited” above your post and see a list of people who you’ve shared this post with, i.e. a list of the people who are in your circle(s).

If you’re on Google+ please click the “Send feedback” in the bottom right corner and let Google know so they can fix this ASAP!

If you want to add me to your circles, here’s my profile: +Martin Lormes (get used to the “+”!)

BTW: +Lars Becker also made the point that given enough posts to varying audiences one could even find out who’s in what circle (except for the names of circles, but the groups will be self-explaining I guess).

Peter Westwood and some other WordPress core developers have written a great plugin for WordPress plugin and theme developers: the Debug Bar. It plugs into the Admin Bar that was introduced with WordPress 3.1 and outputs various details about the current page, but to (super) admins only.

Thanks to the consequent usage of WordPress Plugin API functions there is a fairly easy and straightforward way of outputting your own debug information into the Debug Bar.

Your own Debug Bar Panel

You should create a separate file for your Debug Bar tab, let’s call it my-debug-bar-panel.php, and place it in the same directory as your plugin file or your theme’s functions.php file. In this file you create a child class of Debug_Bar_Panel, e.g. my_Debug_Bar_Panel, with at least one method render() in which you can output everything that should be on your tab.

<?php
class my_Debug_Bar_Panel extends Debug_Bar_Panel
{
  function render()
  {
    echo '<div id="my-debug-par-panel">';
    echo '<h3>Some header</h3>';
    echo '<p>Some debug output</p>';
    echo '</div>';
  }
}

Now back to your main plugin file or functions.php: You need a function that hooks into debug_bar_panels. I put a double check in my example to make sure the base class Debug_Bar_Panel exists (since you never know whether they drop this in a future release which would cause fatal runtime errors). Then you create a new instance of my_Debug_Bar_Panel with the title, which you would like to see on your tab, passed to the constructor:

function my_debug_bar_panels($a)
{
  if (class_exists('Debug_Bar_Panel'))
  {
    require_once dirname(__FILE__).'/my-debug-bar-panel.php';
    $a[]=new my_Debug_Bar_Panel('My tab title');
  }
  return $a;
}
add_filter('debug_bar_panels', 'my_debug_bar_panels');

Believe it or not, you’re done!

Here’s why I don’t normally apply updates on the first day: Backdoors in three popular WordPress Plugins

June 22, 2011 | No comments

I have just released my newest WordPress plugin to the public:

Open Graph Pro automagically adds Open Graph Protocol metadata to your WordPress powered blog/website. Through the Open Graph Protocol you can control how your posts and pages appear on Facebook when someone shares a link or likes your stuff.

The plugin does not add any “Like” buttons to your site just yet, but that’s on my to-do-list.

It does however give for a great deal of customization already by allowing you to change the object type of your entire site as well as the object type of individual pages, e.g. when you have a single page for each album or song of your band, or for each product of your company, etc. If you go to the settings page in the admin section of your site you can enter your Facebook user ID and give your site/blog the full potential of a Facebook page.

And just in case you’re wondering: I’m not using this plugin on this site at the moment, because liking or sharing stuff on Facebook only looks good with images, or it actually looks really crappy without them, and as you may have noticed I have very little eye-candy on my site at the moment. Now that the majority of all the coding is done I will focus next on the visual aspects of this blog, and then install the plugin when things have become more graphical around here…

I hope he takes this down to the Cafe: 1987 Compaq Portable III (286 based) with Wireless and Lynx part one, and here’s part two (seen it on Hack a Day)

June 19, 2011 | No comments

In the newest version (0.4.1) of my Comment E-Mail Verification plugin I fixed a bug that caused the verification link to malfunction with some setups.

Download it directly from the wordpress.org plugin directory

This update was inspired by user comments. Thanks for all your input.

« Older entries § Newer entries »