WordPress 3.3 ‘Killer Feature’ prediction

WordPress is now in feature freeze. This means no more ideas or features can be added. Development will focus on the features already in the pot. The WordPress team now have many years of experience rolling out open source collaborative projects, and for the more recent version have stated they will be more strict. Meaning that they will pull (or cut) features and not let deadlines slip. This makes their releases more reliable and regular. And it allows folks to make some noise about the upcoming new features. Inevitably there will be discussion on which new feature is best, which feature will have the most impact.

Historically, where WordPress has won, the up-front first thing that makes people use WordPress has been the ease of installation. The famous 5 minute install. The ability to be up and running with the up most of ease. To this end, I believe that the new guidelines (or New User Experience) will be the perfect complement. Following on from a quick and easy installation, new users are presented with helpful pop-up notes to let them know about new features.

[Updated] as per comments.

Remove images from post content on your WordPress homepage

Worried that all the images in your posts on your home page are slowing your page speed down? Or just want to de-clutter things? Or perhaps you need to cut down on bandwidth and want to reduce the page size on your most visited page (your homepage).

WordPress snippet to remove images from your homepage posts

function tcb_remove_images_from_homepage( $content ) {
   if( is_home() )
     $content = preg_replace('/<img[^>]+./','', $content);
   return $content;
}
add_filter( 'the_content', 'tcb_remove_images_from_homepage', 100 );

Personally, I’d just get some better hosting and not worry about it 🙂

WP Brighton – WordPress at the Brighton Digital Festival

As part of the Brighton Digital Festival, Friday the 23rd September saw Brighton’s first professional WordPress event take place. Superbly organised by Paul Bunkham, David Lockie and Michael Bailey, it brought together over one hundred local (and not so local) professionals, all with at least one commonality: using WordPress successfully as part of their business.

The lead up to the event was well handled. A clear idea and strategy was presented in the preceding weeks. Well written blog entries, eagerly tweeted by expectant attendees, kept the event fresh. The blog articles reinforced the benefits of businesses and web professionals getting together to share and discuss how they use WordPress.

The day itself went very smoothly. The inevitable minor hiccups were taken care of efficiently and with a certain ingenuity. There was great buzz throughout the proceedings, with many references to the sessions’ quality and friendly community atmosphere they were presented in. The presentations were all filmed and photographed, a daring thing to arrange for fledging event organisers, but a superb decision I think. The presentation slide shows are all going to be available to download from the website, but nothing quite compares to seeing and hearing the speaker’s expressions and emphasis.

The sell out attendance and positive reactions on the day prove that local businesses are not only interested in events such as this, but want to share and learn about WordPress just as much as the rest of the world. As corny as Dave thought his idea about improving things for everyone locally may have sounded, who knows just how much events like this can bring to the business community and the people they serve?

WordPress – the_slug() – Get post slug function

There is no template function (like the_title()) to get the slug of the current post.

There are two ways to do it:

1. Using basename() and get_permalink() to retrieve post slug.


  echo( basename(get_permalink()) ); 

2. Using global $post object to retrieve post slug.

<?php global $post; echo $post->post_name; ?>

I chose the former and added some hooks

3. Fully hookable function to retrieve the post slug

function the_slug($echo=true){
  $slug = basename(get_permalink());
  do_action('before_slug', $slug);
  $slug = apply_filters('slug_filter', $slug);
  if( $echo ) echo $slug;
  do_action('after_slug', $slug);
  return $slug;
}

This provides you with a simple way retrieve and display the post slug. I find this useful for applying unique CSS ids and classes to my HTML mark up.

<div id="some-post-container-<?php the_slug();?>">
 Lorem whatsit here
</div>

I’d love to hear what you use it for!

UPDATE

I’ve posted an update to this function – how to get the slug of your post or page?

Remove and disable WordPress theme and plugin editors

WordPress is growing at an amazing rate. It is an excellent CMS tool for companies and freelancers to build websites with. There are times when handing your finished WordPress build over to your client, that you want to keep things simple for them. Helping them not to break things.

WordPress has a built in editor. This allows administrators (and super admins) to edit the themes and plugins from within WordPress itself. Potentially this allows your client to (accidently) destroy all your good work.There are a number of ways to remove the link from the standard menu. Thus letting your client have the freedom to know that they can explore and familiarise themselves with the WordPress back end, without breaking anything serious. Here are two examples for removing the theme editor link:

1. Removing theme editor link from menu using remove_action()

function tcb_remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
}
add_action('admin_menu', 'tcb_remove_editor_menu', 1);

2. Removing theme editor link from menu using remove_submenu_page()

add_action('admin_init', 'tcb_remove_menu_elements', 102);
function tcb_remove_menu_elements(){
  remove_submenu_page( 'themes.php', 'theme-editor.php' );
}

The problem with these two methods is that they don’t actually stop anyone with the right roles and capabilities from editing the theme files. It just removes the link from the menu. If a plugin or theme provided links to the editor from somewhere else, then the above methods are pretty useless.

3. Disable theme and plugin editing completely using WordPress’s built in constant definition

Luckily WordPress has provided a really easy way to stop themes and plugins being edited from within WordPress itself.

define('DISALLOW_FILE_EDIT', true);

This not only removes the links from the menus, but effectively disables the edit_themes and edit_plugins capabilities. So even with the link to the right place, no user will have permission to edit anything. This is not only shorter, but more powerful. It is just a single line on the wp-config.php file.

Details on this and other settings can be found in the codex: Editing wp-config.php.