WordPress Archive

Notes on the 2010 WordPress Theme

Here are some of my random thoughts after going through the files of the new TwentyTen (2010) theme which will be introduced in WordPress 3.0.

header.php isn’t poetry at all

The content of the <title> should be generated within functions.php by using the wp_title filter, so that plugins and users can overwrite it. In header.php we would have only:

<title><?php wp_title('|', true, 'right'); ?></title>

and in functions.php something like:

add_filter('wp_title', 'twentyten_title', 10, 2);

function twentyten_title($title, $sep) {
	global $post;

	$title = wptexturize($title);
	$page_no = get_query_var('paged');

	if (is_front_page())
		$title = get_bloginfo('title') . ' ' . $sep . ' ' . get_bloginfo('description');
	elseif (!is_feed())
		$title .= ' ' . get_bloginfo('title');

	if ($page_no > 1)
		$title .= ' (page ' . $page_no . ')';

	return $title;
}

Theme’s stylesheet style.css should be loaded after the wp_head() call, so that users can overwrite styles added by the plugins. Read more »

Egīls Pārups (parups.com) running a child theme of Portfolio Racer

Parups.com is the very first website running a child theme of Portfolio Racer. The following plugins are helping out behind the scenes — Google XML Sitemaps, Infinite Scroll, Page Menu Editor, postMash (Filter), Top Level Categories, Widget Context and WP Super Cache.

Open source rocks!

/ Add a Comment »

Smarter Cleaner Gallery

Justin Tadlock’s Cleaner Gallery plugin fixes the semantics of the WordPress built-in gallery feature by placing all of the gallery related CSS in an external file instead of the inline CSS produced by WordPress core.

However, the problem is that this CSS file is loaded on every page request. Therefore, until WordPress supports combining all CSS files into one, here is a quick way to hide this CSS file on all pages that don’t contain a gallery (line 128 of cleaner-gallery.php):

Note: this will add cleaner-gallery.css only on single post and page views (not indexes or archives).

add_action('wp_head', 'cleaner_gallery_head', 0);
function cleaner_gallery_head() {
	global $post;
	if (strstr($post->post_content, '[gallery'))
		wp_enqueue_style( 'cleaner-gallery', CLEANER_GALLERY_URL . '/cleaner-gallery.css', false, 0.7, 'all' );
}

Hopefully, Justin can incorporate this into the next release of this handy plugin.

/ 8 comments, add yours »

Automatically Escape HTML Entities of Code Fragments in Comments

Update: Ryan has made this into a plugin — Code Comments.

Add this to your theme’s functions.php to allow readers post fragments of code in their comments (wrapped in <code>...</code>) which are automatically encoded (think of < and &lt;)

add_filter('pre_comment_content', 'encode_code_in_comment');

function encode_code_in_comment($source) {
  $encoded = preg_replace_callback('/<code>(.*?)<\/code>/ims',
  create_function(
    '$matches',
    '$matches[1] = preg_replace(
        array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "",
        $matches[1]);
      return "<code>" . htmlentities($matches[1]) . "</code>";'
  ),
  $source);

  if ($encoded)
    return $encoded;
  else
    return $source;
}

Worth noting:

  • Everything wrapped in <code>...</code> is encoded.
  • Line breaks after opening <code> and before closing </code> are removed in order to avoid unnecessary <br /> tags.

/ 7 comments, add yours »

Tabbed Widgets 0.83

Tabbed Widgets plugin has been updated — fixed default javascript variables.

/ Add a Comment »

Tabbed Widgets Updated for WordPress 2.8

I found the time to update one of my most popular plugins — Tabbed Widgets. Test it (version 0.81) and report your findings at WordPress support forum.

Your support and donations are much appreciated and encourage further updates and development.

/ 3 comments, add yours »

Multiple Galleries per Post/Page

Ever wanted to have multiple galleries on the same post or page? Currently most of the solutions require you to manually edit gallery shortcode and add something like include="img_id_1 img_id2". Luckily, WordPress 2.9 will have this include/exclude feature built in core, but you still don’t have an easy way to select images which to include or to insert multiple galleries.

Therefore, I created a plugin called Multiple Galleries which adds checkboxes next to images in the Insert Gallery window which makes selecting images to be included in galleries fast and easy. If no checkbox is selected, all images are included.

Select images which to include in gallery

I created this plugin because I am designing a new WordPress theme for designers, artists, architects and all of the creative types where the ability to have multiple galleries per portfolio entry is very important.

/ 12 comments, add yours »

The Pricey GPL Thought Experiment

Let’s create the most expensive GPL licensed WordPress plugin and call it the Pricey GPL. It is offered as a free download from WordPress.org and by default it displays a random paragraph from the most downloaded book at Project Gutenberg in the WordPress dashboard. Of course, there is a widget available, too.

However, to enjoy the real value of the Pricey GPL, you have to purchase a monthly subscription to the PriceyGPL.com service (an API key) which displays a random paragraph from one of the GPL licenses. Read more »

Basic Math of GPL

Khoi Vinh together with Allan Cole have released (a rather noisy) grid based WordPress theme called Basic Math.

They say it’s GPL, while the price tag reads: Single-site License (Limited time only) $45″, which clearly violates one of the main freedoms protected by GPLthe freedom to run the program, for any purpose (freedom 0).

Update: Basic Math is now fully GPL.

/ 2 comments, add yours »

Automatic Updates for Developer Hosted Themes

I just realized that the automatic update thing also works for themes hosted outside of wordpress.org.

/ Add a Comment »

Enable Automatic Updates for Plugins Hosted by Developers

Currently WordPress doesn’t offer an easy way for plugins which are not hosted on wordpress.org to use its built-in automatic update feature.

Fortunately, I have found a quick and simple way to add this functionality to any plugin and allow plugin authors to take a complete control over when and how the updates are released. Read more »

Concatenate Javascript and CSS Files with WP Minify

Minimizing the number of HTTP requests is one of the easiest ways to make your website load significantly faster. WP Minify is a WordPress plugin by Thaya Kareeson that combines all Javascript and CSS files into one respective file.

WP Minfy uses the old trick of modifying the output buffer before it is sent to the user. And until all plugins and themes start using wp_enqueue_script and wp_enqueue_style, this will remain the most reliable method of doing it.

I approve this plugin.

/ 4 comments, add yours »

PubSubHubbub & WordPress

Make your blog’s RSS feed real-time — add this one line of XML:

<link href="http://myhub.example.com/endpoint" rel="hub">

to your RSS feed automatically using this PubSubHubbub WordPress plugin by Josh Fraser. To see how it works, watch this demo of PubSubHubbub by its creators Brad Fitzpatrick and Brett Slatkin.

/ Add a Comment »

WordPress and Nginx

The fastest WordPress instance I have ever seen — 14 queries in 0.04 seconds, and Pingdom Tools reporting 0.6 seconds load time for the whole frontpage with a default theme. And all of that on a VPS powered by Debian and Nginx web server at deac.eu in Latvia . I’ll be moving soon.

/ Add a Comment »

Widget Context Plugin Added to the Official Plugin Repository

I have uploaded the Widget Context plugin to the official plugin repository. From now on, you’ll be getting the updates automatically (even those of you who installed it manually).

If you like this plugin, support the development by a donation.

/ 6 comments, add yours »

Widget Context 0.4.1

There is a new version of Widget Context plugin which is almost a complete rewrite of the plugin with improved performance and added functionality.

For the next version I planing to implement filters that allows developers to add custom context rules.

/ Add a Comment »

Proprietary vs. Liberal vs. GNU GPL

This is a response to an article written by Daniel Jalkut, titled Getting Pretty Lonely.

I think there is one critical point that we all should agree on — developers like to be compensated for their work, even those of Open Source and Free Software.

Some assume that GNU GPL makes it almost impossible or at least very hard to earn fair compensation for time invested in developing the software, while “Liberal” licences allow the freedom to determine (and guarantee) the compensation through controlling the distribution.

The reason for this is the current implementation of the competition-driven capitalism which has made the concepts of donation and freedom to compensate completely bizarre in the context of how businesses work these days. Read more »

Widget Context Update for WordPress 2.8

I have updated the Widget Context plugin to fix the CSS overlay issue that was introduced with the latest WordPress upgrade.

/ 1 comment, add yours »

WordPress, Plugins and Open Source

It’s funny how only now when WordPress has been updated and many plugins have stopped working, people realize how important and significant the plugins are.

Show your love for open source — say Thanks and donate. Get the developers’ enthusiasm flowing.

/ 1 comment, add yours »

OpenID Plugin and WordPress 2.8

Ever since using the nightly versions of WordPress, I got used to doing regular updates and not checking if all plugins work fine afterward.

Therefore only today I discovered that leaving comments on this blog has been impossible for a while already. Turns out that changes in the WordPress core have made the OpenID plugin unaware of the comment author’s name and e-mail.

Haven’t found a solution yet. Read more »

About the Author

Kaspars Dambis I am a race car driver, engineer and a web designer living in Latvia and working on the web since 2000. Read more or get in touch.

Es vienmēr tevi mīlēšu, Sirsniņ!