Page-Speed and garland-revisited

Someone recently pointed out to me that i should install Page-Speed for Firefox and fix some of the errors in my theme.

Here is what another site said about the plugin..

Attention all webmasters and web developers! Google wants to help you improve the performance of your web pages. This week, Google released a tool called Page Speed which is capable of identifying different ways to make your site or web pages run faster.

Page Speed is an open-source Firefox/Firebug add-on that Google has been using internally to improve the performance of their web pages. It supports Windows (XP and up), Mac OSX (x86 and PPC) and Linux (32-bit and 64-bit) operating systems. You must have Mozilla Firefox (3.0.4 or higher) and Firebug Firefox Add-on (1.3.3 or higher) installed on your computer before installation of Page Speed.

Once installed, this tool performs several tests to determine site’s web server configuration and front-end code. After the tests Page Speed offers suggestions on how to change your web pages in order to improve their performance. For example, Page Speed automatically optimizes images for you, giving you a compressed image that you can use immediately on your web site. It also identifies issues such as JavaScript and CSS loaded by your page that wasn’t actually used to display the page, which can help reduce time your users spend waiting for the page to download and display.

So, Page Speed will not only help you make your site run faster but will also keep visitors engaged with your site. By improving page load it can also reduce your bandwidth and hosting costs. In my view this tool is a must for all webmasters and web developers.

Page Speed evaluates performance of a web page, from the client point of view, which is typically measured as the page load time. In my view page load time is most crucial and as a webmaster or blogger, you must take it seriously. After all, who wants to visit web pages that takes forever to load? So, think from client point of view and use Page Speed to evaluate the performance of your site or blog.

Page Speed tests are based on a set of known best practices that enhances web page performance. After evaluation of your pages, Page Speed will give your specific tips and suggestions on how you can implement the front-end best practices to improve overall performance. The web performance best practices are also available in written form, which you can refer anytime during development of tweaking of your web pages. For further help regarding installation and use of Page Speed, the Webmaster Help Forum is always there to help you.

More info: http://code.google.com/speed/page-speed/

So my score was pretty bad to start with, had to rewrite some of the code to add custom headers to cache images properly, and rewrite some of the css.

A new version of the theme will be following shortly, a new dropdown menu has been added already.

I may add the latest tweet thing i have going on this site, and configurable header image too before it gets released.

Page-Speed and garland-revisited

[HOWTO] WordPress Child Themes

Here is an easy was to keep your custom edits to the theme php files.

We need to create a child theme that uses the garland core files for the main theme functions as well as and custom code you add, then when you update the theme from within wordpress only the parent theme will get changed, your child theme will remain intact!

first off we create a new folder within the themes dir and give it a name, inside it we put a style.css file. Ive chosen garland-redux for this example as were protecting my garland theme from changes…we still need the original garland-revisited theme folder, so dont go deleting it!

so your directory path will look like this:

wp-content
|_themes
        |_garland-revisited
        |_garland-redux
                       |_style.css

The format for the style.css file is simple, it just tells the child theme where the parent is:

/*
Theme Name: Garland-redux
Theme URI: http://www.pross.org.uk
Description: Testing WordPress Child Themes
Author: Simon Prosser
Author URI:http://www.pross.org.uk
Template: garland-revisited
Version: 1.0
.
This work, like WordPress, is released under GNU General Public License, version 2 (GPL).
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
.
*/

@import url('../garland-revisited/style.css');
[HOWTO] WordPress Child Themes

[HOWTO] Display number of spams stopped since your blog started.

So i wanted to display total number of spam coments blocked by askismet. Checking the the plugins source i found this function which returns the number:
[php]get_option(‘akismet_spam_count’);[/php]
Getting the blogs first post date was the tricky bit and required a database query:
[php]$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");[/php]
The query checks the first post above zero as most people delete post #1.

So the complete code is:
[php]<?php echo get_option(‘akismet_spam_count’); ?> Spams caught since
< ?php
$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");
echo gmdate(‘M Y’,strtotime($firstpost));
?>[/php]
the result looks like this:
10253 Spams caught since Jun 2006

[HOWTO] Display number of spams stopped since your blog started.

An email from wordpress!

Today I uploaded v1.0.1 of garland-revisited to the wordpress site, a few minutes later i got an email from wordpress.org!

Trying to pull in wp-config.php or wp-load.php directly is a bad idea.  The actual location of those files can be in a nearly infinite number of locations, so trying to reference them directly is guaranteed to break in at least some of the cases.

The code in question is in css.php, the file is requested out of wordpress to provide the custom css, but css.php has to use the wordpress database to find out your custom colours etc..
[php]require( ‘../../../wp-load.php’ );[/php]
The code itself works with a default install of wordpress, but a few people out there might define a different folder for wp-content/themes.. so after som hefty google-fu I found this http://planetozh.com/blog/2008/07/what-plugin-coders-must-know-about-wordpress-26/
[php]$rootPath = dirname(__FILE__);
$rootPathArray = explode("/",$rootPath);
$numDirs = count($rootPathArray);
for ($i=1; $i&lt;=$numDirs; $i++) {
$path = implode("/", $rootPathArray);
if (file_exists($path.’/wp-load.php’)) {
require_once($path.’/wp-load.php’);
break;
} elseif (file_exists($path.’/wp-config.php’)) {
require_once($path.’/wp-config.php’);
break;
}
array_pop($rootPathArray);
}[/php]
This snippet walks back through the dirs until it hits either wp-load or wp-config, I have tested it on a local copy it works fine, so the next version will inlude the fix.

EDIT:
I forgot to follow this post up woth the actual fix from the wordpress guys 😉
css.php is the file i want to call from outside wordpress, but it needs to be wp-config.php loaded first, so the following code is added to the functions.php:
[php]add_filter(‘query_vars’, ‘add_my_var’);
function add_my_var($public_query_vars) {
$public_query_vars[] = ‘garland_css’;
return $public_query_vars;
}
add_action(‘template_redirect’, ‘my_var_output’);
function my_var_output() {
$myvalue=get_query_var(‘garland_css’);
if ($myvalue) {
include(‘css.php’);
exit; // this stops WordPress entirely
}
}[/php]
now i can call the css file from a wordpress url like:
[code]http://myblogurl.com/index.php?garland_css=1[/code]

An email from wordpress!

Garland-revisited WordPress Theme

Garland-revisited

A flexible, three-column theme with customizable colors.

Design based on Themetastic for Drupal by Stefan Nagtegaal and Steven Wittens.

I took this theme and gave it new life by making it 2.7 compatible, the color changer in the admin section is also fixed.

Latest version is always here at the theme database http://wordpress.org/extend/themes/garland-revisited

Test blog for the theme is here

1.9 current release

1.6 css fix

1.5 Sidebar disable options added to admin page, many fixes!

1.1 Fixes bugs.

1.0.0 Updated for wordpress 2.8. Cleaned up css. Added rss and ping links.

0.9.6 More bugs fixed, almost final version now! Admin link in header added, only shows if admin is logged in. Blockquote css added to options with nice transparent .png.

0.9.5 Fixed bugs

0.9.4 Option for fixed/full width in admin, footer was not showing in IE, new css.php used for custom colors so page still validates always, blog tag smaller and italic.

0.9.3 Bug found in functions.php stopping the theme preview from redrawing.

0.9.2 HTML fix in comments.php, now validates fully. Search.php added with custom output and highlighted searchterms.

0.9.0 First release.

wp-super-cache users please add the following to your rejected URI’s:- garland_css=1 super-cache plugin adds a comment to the cached css which firefox does not like!

Garland-revisited WordPress Theme