WordPress Title Widow fix Plugin

In my very first post was about a small jQuery plugin I created to fix widows in text.

A widow for those who are not sure what I’m talking about looks like the below


Here is the title and it wraps and leaves a
widow


Here is the title and it wraps and leaves a

widow



Having a widow in a title looks really awkward; since I use WordPress for this and other sites I thought it was time that something like this was created.

Currently I’d call it beta because it hasn’t had a whole lot of testing on it yet.

Download the Widow Remover for Wordpress

FirebugLite WordPress Plugin

If you like me are not a fan of Internet Explorer development tools bug enjoy firebug then this might interest you.

Installing this plugin will allow you to activate Firebug Lite for any browser other than Firefox.  If you are not Familiar with Firebug lite it is simply a stripped down version of Firebug but for IE, Chrome, and Safari.  So that you don’t always show the Firebug window, to activate it you need to throw in a debug switch:

?debug=fblite

You can try it out on my site example usage:

www.gregprogramming.com/?debug=fblite

Download the FirebugLite Debugger plugin

Wordpress MU: Start with a different table prefix

With regular WordPress, when you install it on your server you are given the option to change the table prefix to something other than “wp_”; however, in Wordpress MU there is no option for this. So here is how you can do it from a CLEAN install.

In your wp-config-sample.php file find the following line

70
$table_prefix  = 'wp_';

Then change ‘wp_’ to anything you want preferably with an underscore at the end; something like the following would work.

70
$table_prefix  = 'muxyz_';

This will as mentioned previously only work on a Clean install so if you want to do this on a version of MU that is already running this won’t work unless you alter all your tables in your database as well.  Regular WordPress has plugins for this but I do not know if the they will work on MU and have yet to find one specifically for MU.

WordPress with Google Part 1 – Webmaster Tools Site Map

I’m an avid user of Google products ever since I opened up my first GMail account; It is pretty much my online hub. I use Chrome as my default browser (Firefox for development though), GMail for mail, Google Reader for RSS, iGoogle for everything newsie along with Analytics and the rest.

I’ve always been intrigued by Google Webmaster Tools; it’s a simple interface with nothing special but It helps me keep up to date with what’s going on with my site. Analytics is great for seeing trends, users and how people are finding you but that’s not what this article is about.

Step 1: Set up your site.

Google will ask that you verify that the site belongs to you; Since we’re using WordPress I would suggest grabbing the HTML file instead of updating the META tags. Why? If you change or update your theme you loose your Meta but not your HTML file. So Download the file, Upload it to your WordPress folder and then Verify.

Step 2: Submit a Sitemap

Grab a copy of Google XML Sitemaps plugin, upload and activate it.  There are full installation instructions on the Plugin’s WordPress Instructions Page; You can fiddle with the sitemap configuration along the way so that it best suits your site.  Now that your set up go on over to your Google Webmaster Tools account and under Site Configuration click on Site Maps.  This is the easy part now. Click on Submit a site map, finish of the url , click on the button next to it and voila! Go to Sitemaps.org for more information on sitemaps.

Step 3: Monitor and Adjust

Once you’ve set up your site map you have to wait for Google to index your site.  Check the sitemaps sections and see how things are doing.  If there fine good! if not then you need to do some checking.  The main culprit, go to Crawler Access under Site Configuration, I’ve had is my robots.txt and I found an article on Wordpress.org about SEO that helped with fixing my file.  There’s more information on that same page that will help with Technorati and others if that interests you at all.  Google also offers a robots.txt generator within the same section which you can play around with to get your file just right.  For more info on Robots.txt check out Robotstxt.org.

Final Thoughts

I figure the quicker you let Google know the quicker they find you and the sooner you get indexed.

jQuery Wordpress quick collapsable menus

Just a quick code snippet for creating Collapsible menus for the WordPress Page and Category Sidebar widgets.  It uses jQueryGoogle Ajax libraries and in its current state works only when you set your WordPress permalinks to /%category%/%postname%/.

Warning: By no means is this the best way to make your WordPress Page and Category Sidebar widgets expandable but it worked for me so I figure i’d share it.

google.load("jquery", "1");
google.setOnLoadCallback(function() {
jQuery("li.page_item a,li.cat-item a").each(function(){
	if(jQuery(this).next('ul').length){
		jQuery(this).after('&nbsp;&nbsp;&nbsp;&nbsp;<a class="toggle_list" href="#">+</a>');
	}
});
 
jQuery("li.page_item > ul,li.cat-item > ul").hide();
jQuery("a.toggle_list").click(function(){
	if(jQuery(this).next('ul:visible').length){
		jQuery(this).html('+').next('ul').hide('fast');
	}else{
		jQuery(this).html('–').next('ul').show('fast');
	}
});
var h = window.location.href;
jQuery('li.page_item a[href='+h+']').nextAll('ul').show();
h=h.substr(0,h.lastIndexOf('/'));
jQuery('li.page_item a[href='+h+']').nextAll('ul').show();
jQuery('li.page_item a[href='+h+']').next('a').html('–');
}

This will add a plus sign to the end of any parent pages and collapse them once the jQuery library is downloaded;  Your basic open and closing happens when you click the plus sign.  It should also open up the menu section if you are in the section or a child section.  Also this hasn’t been testing on a parent > child > child scheme.

WordPress MU as a CMS

Many people, myself included, are using WordPress for business by turning it into an easy to use CMS. Iv’e done a number of sites in WordPress and clients generally like it and it saves me time since the majority of my coding really just comes down to me creating a few WordPress pages and the styling the site.

The Problem/Task

A couple of weeks ago a previous client asked about ways they could update their site which was an old SHTML site.  We thought about using WordPress again for the same reasons we always do; however ever this site was fairly large and page heavy.  The goal wasn’t to trim down the site (unfortunately) but to make it editable without needing HTML experience.  The client wanted each area to have it’s own administrator to control over what is posted, event management, etc all your typical stuff.  A couple of coworkers of mine gave it a shot but what resulted was a website that was confusing hodge podge of pages and posts in categories that they weren’t organized in any simple fashion.  Add to that the admin area was a beast on it’s own trying to use rolescoper for permissions and it still just wasn’t working.

The Solution

The project was put on hold for weeks and then somehow made it’s way to me; I think I had some downtime so I was fair game.  I could remember how the last attempt just didn’t fly but figured that there still had to be a way to do it.  That’s when I remember about WordPress MU.  So I started building out the site by making major each section a new blog and then built each one separately.  I can’t remember what theme I used since I only used it because it supported child themes.  I ended up stripping it down to the barebones and using it on each blog.

Final Thoughts for WordPress MU as a CMS

I use it for development since I can create my development/test sites and manage them all from one area with one login and database.  And I’ve been thinking lately that it might be a good idea for creating a store section of the site (ie site.domain.tld).  It definitely has it’s uses though you at the same time it can be overkill if your just doing a simple blog or pamphlet/brochure website.

The Good Parts

  • Each Blog/Section could have it’s own administration
  • Plugins could be controlled better from the Site Administrator account
  • Users Could have access to only certain sections of the site admin
  • Advertising could be better targeted (though there advertising was lacking it had more potential)

The Bad Parts

  • Not every Plugin worked in WordPress MU
  • Some Plugins were ok to work separately on one site and not others but the rest were now harder to manage
  • limited MU specific plugins available

I guess I could have gone over security and updates but I figure that that is too much for this post so sorry if that is what you were looking for.


WordPress Cheat sheets

I’m always looking for better references than codex.wordpress.org. Today this wordpress reference link came across my RSS reader and it is definitely work a look at. Not only does it have great information for Template building it also has a great look and feel to it.

Web Design WordPress function list

Wordpress MU subdirectory fix

the install proces is creating half part of the table,
wp_1_comments ,
wp_1_links ,
wp_1_options ,
wp_1_postmeta ,
wp_1_posts ,
wp_1_terms ,
wp_1_term_relationships ,
wp_1_term_taxonomy ;

But not the other one, this is a new install.

I had this problem and it was caused by me having a plain wordpress install at the root level and MU install in a directory.

/ <- regular wordpress

/clients <- wordpress MU

to fix it open up the file “wp-blog-header.php”
look for

if ( !file_exists( dirname(__FILE__) . '/wp-config.php') &amp;&amp; !file_exists( dirname( dirname(__FILE__) ) . '/wp-config.php')) {

should be around line 10-11ish
once you have found this comment out from the “&&” to the bracket just after the last “wp-config.php”
so you should have

if ( !file_exists( dirname(__FILE__) . '/wp-config.php') /*&amp;&amp; !file_exists( dirname( dirname(__FILE__) ) . '/wp-config.php')*/) {

then try it again.


The problem is wordpress mu checks the current directory and then goes up one more level so for me it did the following

/clients – no wp-config.php
go up one level

/ – wp-config.php found
I’m sure that there is a point to this being there I’m just not sure what that is.
Hope that helps

Javascript Best Practices Take 1

I like Javascript; I use it everyday in my work and read article after article on new and old ways to use it.

  • Load Javascript in the Footer

    First off is load times are affected; you can find out more about this by checking out Steve Souders site and more specifically Rule 6 of his book High Performance Web Sites.

  • JSLint

    As a PHP programmer I make use of the php syntax checker via the command line “php -l %filename” (at least on windows). JSLint does syntax checking and more so it is definitely something that should be used. I’d love to use a command line version like in PHP though I haven’t found it yet but then again maybe I’m just not observant enough.

  • Using a CDN

    This is especially true if your running multiple sites. Rather than having each site host it’s own JS use a CDN; I generally use Google AJAX libraries for jQuery but lately have been looking at Yahoo for their YUI. If you’re loading your JavaScript in the footer this works great since ,at least with Google, you call your “google.load()” function and then work from there with the Callback function.

  • Javascript should not be a replacement for CSS

    Use JavaScript appropriately; It’s amazing what can be done with just CSS. Find whatever resources you can, I recommend CSS-Tricks and Smashing Magazine as two of the best places to start.

Hopefully this is helpful to someone as short as it is.

Removing widows

After reading an article from CSS Tricks: Preventing Widows in Post Titles I decided it was about time to make my first jQuery plugin, the Widow Remover.

The Problem: A single word alone on it’s own line.

The Solution: add in a non-breaking space


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function($) {
	$.fn.widow_remover = function(params) {
		params = $.extend( {words: 1}, params);
 
		this.each(function() {
			var string = $(this).text();
			var sp = string.lastIndexOf(' ');
			if(sp != -1){
				do{
					string = string.slice(0,sp)+' '+string.slice(sp+1);
					params.words -=1;
					sp = string.lastIndexOf(' ');
				}while(params.words&gt;0 &amp;&amp; sp != -1);
			}
			$(this).html(string);
		});
		return this;
	};
})(jQuery);

Usage:

1
jQuery('h1').widow_remover();

Result:

No more single words on a line

Still needs some improvements as looking back on it parts of the code I think I was in daze but the basic idea is there and hopefully it helps someone out

The Code is hosted at code.google.com and at plugins.jquery.com

Free Sprint phones for sale | Thanks to CD Rates, Reverse Phone and Registry Software