Keeping Your Blog’s Theme Up To Date Using SVN

Zialus asked me to explain how I keep my blog’s theme up to date using SVN while keeping my modifications. The answer is too long for Twitter, so I’m writing a small blog post about it.

  • I checked out a copy of the theme I use to my computer (easier to work on it from my PC than my server). The SVN URL for themes hosted on WordPress.org is http://themes.svn.wordpress.org/. Find your theme there. For example my blog’s theme is http://themes.svn.wordpress.org/mystique/1.72/ (as of the time of this post).
  • I made the changes I wanted to the theme on my computer (tweaks and such) and then uploaded it to my server.
  • When a new version of the theme is released, I run svn diff > file.diff on my local checkout to get a file containing all of my modifications (this will be handy for the next step).
  • I use svn switch to switch to the new version SVN URL. Your SVN client will attempt to merge in any changes by the theme author into your modified files, but it may run into collisions (where the theme’s author and you have modified the same area of a file). You’ll need to manually fix any collisions (this is why I check out to my PC instead of my server). I tend to just hit revert on the file and then using the diff file from the previous step for reference, re-add my modifcations.
  • Upload the new version of the theme (with your modifications to your server).

Questions? Feel free to ask via my comments section. 🙂

Tracking WordPress Remote HTTP Requests

UPDATE: You can find improved code in this newer blog post. Use that instead.

I thought I’d share a bit of code that I run on my local WordPress test install to see when WordPress is contacting another website. I originally wrote this to help debug my oEmbed code, but it’s useful for a wide variety of purposes. 🙂

[php]<?php

if ( !defined(‘DOING_AJAX’) )
add_filter( ‘http_request_args’, ‘debug_http_api’, 10, 2 );

function debug_http_api( $r, $url ) {
echo ‘<p style="text-align:left">HTTP API was used to fetch <code>’ . esc_html( $url ) . ‘</code></p>’;

return $r;
}

?>[/php]

The above code will output something like this any time a HTTP request is made using the HTTP API, but only if the request was not made from an AJAX handling script (as it will break the AJAX response):

HTTP API was used to fetch http://www.google.com/

While I’m using a filter to do this, I’m actually using the filter much like an action as I’m not modifying the passed data but merely using the filter as a place to hook in and catch the URL.

Ugly Betty Uses WordPress

Jane noticed that Ugly Betty uses WordPress, so I thought I’d post some screen caps. It’s been heavily reworked, but you can still tell the production staff used WordPress as a base.

Pretty funny.

WordPress: Using Filters With get_posts()

Something I just learned and thought I’d share to save others the trouble: if you’re attempting to filter the results of get_posts(), for example with the posts_where filter, you need to disable suppress_filters.

For example, here’s how to fetch some posts from within the past 30 days (based on an example from the Codex):

[php]<?php

function last_thirty_days( $where = ” ) {
global $wpdb;

$where .= $wpdb->prepare( " AND post_date > %s", date( ‘Y-m-d’, strtotime(‘-30 days’) ) );

return $where;
}

add_filter( ‘posts_where’, ‘last_thirty_days’ );

$some_posts = get_posts( array( ‘suppress_filters’ => false ) );

// Important to avoid modifying other queries
remove_filter( ‘posts_where’, ‘last_thirty_days’ );

?>[/php]

New Plugin: Enable oEmbed Discovery

For security reasons, the UI to enable oEmbed’s discovery ability was removed from WordPress today. It’d be too easy for a novice to accidentally embed some bad HTML into their blog if they posted the URL to a malicious website.

However if you know what you’re doing, feel free to install my Enable oEmbed Discovery plugin which will re-enable the feature. 🙂

I Need GPL-Compatible Flash Video Player Suggestions

I am in the early stages on recoding my Viper’s Video Quicktags plugin from scratch and in the process I will be replacing JW Player with a free and open-source alternative. JW Player is really great, but sadly it’s released under a non-commercial license which just won’t do.

So please, if you know of any good Flash players that will do FLV, MP4, etc. please leave a comment with a link!

Here’s my list so far of players to compare and pick between: (I’ll update this list with suggestions)

  • Flowplayer (currently leaning towards this one, it seems really badass)
  • OS FLV

Plugin Release: YOURLS: Short URL Widget

I threw together a widget for my blog that displays the short URL to a post or page and since multiple expressed interest in using it on their own site, I’ve decided to release it. My YOURLS: Short URL Widget plugin will add a widget (Appearance -> Widgets) that will only show up on individual posts or pages and will output content of your choosing, including the short URL to that item as generated by the YOURLS: WordPress to Twitter plugin which is required for my widget to do anything.

WordPress 2.9 Beta 1

WordPress 2.9-beta-1 is available! Get it here: zip, tar.gz. Start hammering away.

You can also just install the super handy WordPress Beta Tester plugin to make the one-click upgrade feature upgrade you to WordPress 2.9 Beta 1.

Remember though — it’s still beta software, so backup your database and don’t run it on a site that you can’t afford to be buggy. 😉

Source: wpdevel

EDIT: Here’s two links covering some of the new features, including my embeds feature. The Codex also has a list going although it seems to be missing embeds.