Fun?! with Subversion and WordPress

OK, so I’m a bit of a Cowboy Coder and after a session with Mark Jaquith the other week at WordCamp San Francisco, I’ve been mildly shamed into learning what I need to start using version control.

At home I have a pretty high-powered gaming PC and when I’m on the go I’m using a MacBook Pro. So the first thing I did using a (somewhat old but relevant) guide by Westi to setup TortoiseSVN on my PC and started hooking up my WordPress Trunk build repo using SVN. Prior to now, I’ve always sort of done it the hard way, e.g. a whole lot of downloading and ftp-ing a couple of times a week.

First impression: SVN is kind of complicated at first, but once you sort of get the hang of it, it’s a heckuva lot less work overall. After I got the hang of doing checkouts, updates and commits with my local repo, I got a little more ambitious and set out to get SVN setup on my VPS.

After an install, uninstall and re-install, I finally got all of the ra_* (See: Repository Access) modules in place that would allow me to checkout code from http & https URLs. Thanks to a very helpful guide by Otto, I managed to setup svn:externals and perform a couple of checkouts and updates directly from the WordPress trunk and my VPS. Pretty neat.

NoteToSelf: Next time: Read about it, read about it, try, fail, try, fail, fail, WIN.

I Am Guilty of Blog-Neglect

Something I discovered at WordCamp San Francisco over the weekend shouldn’t come as a great shock: I’m not the only developer/designer who can’t / doesn’t keep an updated blog. Who’s got the time?

I made a sort of promise to myself the other day and that was to try to blog at least once a week. With all of the troubleshooting and tinkering that goes into any Web project, it shouldn’t be that difficult for me to outline the problem and solution right here on WerdsWords. So that’s the plan, we’ll see if I can follow through. Call me out though if you start to see weeds growing up between the cracks.

WordPress On the Brain after WordCamp San Francisco

Wow, OK, so this is a random collection of thoughts after #WCSF last weekend.

Never before have I dreamt, thought about or immersed myself in so much WordPress in such a short amount of time.

#WCSF proved to be ample opportunity for networking, learning, eating and traveling. I met a lot of really passionate people out there from bloggers to developers, designers, entrepreneurs, web hosts and many of the people behind the mammoth that WordPress has become. It really was a fun time.

So here’s a shoutout to Adria Richards, Theme.fm, bluehost, Dream Host, the guys over at Media Temple, Matt Mullenweg, Brad Williams, Jeff Kropp, Lou Anne McKeefery, Pete Mall, Brian Tickler, Dan Ross, the guys over at StudioPress, Adam Chew, Linda Sherman and many others.

Probably the best-spent 3 days I’ve had in the 3 years I’ve been developing and designing for WordPress. Until next time!

WordPress 3.3 Could Improve Child Theme Integration

According to a recent WordPress trac ticket, theme authors could soon be rewarded with a little nugget of functionality that would make using child themes much more extensible.

The ticket suggests introducing a function that works similarly to locate_template(), but rather than returning the path of the file (in the parent theme only), it would return a URI to the file, thus allowing a child theme to override the parent’s .js, .css and even image files. The proposed function is called locate_theme_file().

According to the suggested patch posted by johnbillion, this is the current method for loading template files in parent themes only:


wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), null ); 

If locate_theme_file() is introduced, we could instead see functions like these:


wp_enqueue_style( 'dark', locate_theme_file( 'colors/dark.css' ), array(), null ); 

wp_enqueue_style( 'bar', locate_theme_file( 'bar.css' ) );

<img src="<?php echo locate_theme_file( 'icon.png' ); ?>" />

locate_theme_file() would automatically load any of these files via the child theme, BEFORE the parent. Pretty neat huh?

Up to this point, child themes could only override a parent theme’s template files. If theme authors are rewarded with the ability to enqueue many more types of files at the child theme level with this much ease, I anticipate seeing some really exciting new uses for child themes emerging.

How to Make SiteLauncher Work With Firefox 5

Being a Web-worker, I rely on my browser to provide the tools I need to work quickly and efficiently. And since I’m an avid Firefox user, the last couple of months have been fraught with turmoil because I was torn between staying with the trends and updating Firefox (first from 3.6 to 4, then recently from 4 to 5) and waiting for the developers of all of my add-ons to keep up.

I waited and waited and waited to upgrade Firefox to version 5 because I was holding out for the developer of SiteLauncher, to be updated. SiteLauncher is integral to my workflow, because it allows me to open specific webpages using preset keyboard shortcuts.

Turns out, I didn’t need to wait.

Thanks to the folks over at The Heat Web, making SiteLauncher 2.1.0 compatible with Firefox 5 was as easy as changing a value in a file.

There are two ways to do this:

1) The Easy Way

» Download/install this (already modified) file sitelauncher2.1.0.xpi and restart Firefox

2) The Hard-er Way

» Visit the SiteLauncher Download Page, right-click the Add SiteLauncher to Firefox button and click Save As. Save sitelauncher2.1.0.xpi to your hard disk.

» Open the directory where you saved sitelauncher2.1.0.xpi and change the file extension to .zip (sitelauncher2.1.0.zip)

» Important: Open the .zip file in your archival software. DO NOT UNZIP THE DIRECTORY.

» Right click on install.rdf and open it in NotePad (or TextEdit on Mac)

» Locate the maxversion value and change it from 4.2alpre to something above 5. I changed mine to 5.9.9 to make it compatible all the way to Firefox 6.

» Save install.rdf and update the archive

» Back in the directory where you saved the original file, change the file extension back to .xpi from .zip

» All you have to do now, is drag the sitelauncher2.1.0.xpi file over to your Firefox window and it should prompt you to install the add-on.

» That’s it!

Update: Though this hack makes your SiteLauncher keyboard shortcuts work, you’re still unable to modify or add new shortcuts via the backend menus. Thanks Steven!

Add something to post title based on post type

Recently, I was working on a WordPress install employing several custom post types to handle two separate “blogs” within a single site. The site used normal ‘posts’ to handle articles and the client wanted to append the word “BLOG” to the beginning of blog posts’ titles only.

Using the Codex I slapped something together rather easily.

Using the following snippet, I built a simple if statement to test for blog posts, and if not, to render the_title() minus any extra text.

// First test for the post type(s)
<?php global $post
if (get_post_type($post) == 'post_type_1') || get_post_type($post) == 'post_type_2') { ?>
// IF either test registers true, then set the $before parameter in this format: the_title($before, $after);
<h1><a href="<?php the_permalink(); ?>"><?php the_title('BLOG: ', ''); ?></a></h1>
// IF not, then display as normal
<?php } else { ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
// Close the IF statement
<?php } ?>

Using this example, posts that register as true would display like this:

BLOG: The post title

Append ‘Read More’ to the end of the_excerpt()

This snippet, when added to your theme’s functions.php file, will allow you to append ‘… Read More’ or any other text to the end of your excerpts. Creates a more streamlined look.

<br />
function excerpt_readmore($more) {<br />
	return '... &lt;a href=&quot;'. get_permalink($post-&gt;ID) . '&quot; class=&quot;readmore&quot;&gt;' . 'Read More' . '&lt;/a&gt;';<br />
}<br />
add_filter('excerpt_more', 'excerpt_readmore');<br />

Source: WPSnipp.com