RTFM, Noob

• Saturday October 3rd by Bucky in WordPress

I’m a bit mad with myself. I’ve been using the Syntax Highlighter Evolved plugin on my WordPress blog to highlight my code. Well, I would have been using it to highlight my code if it had been working as advertised. There wasn’t any kind of highlighting happening – the code inside the generated pre tags looked the same as the rest of the text on the page.

I’ve hacked together my own WordPress template for fun and posterity to integrate into my site. See, I’m a pretty big newbie to all of this, and it didn’t help that the /blog directory under my main site actually pulls from a separate blog directory one level up (don’t ask me why I did this, I was probably drunk – in hindsight it’s pretty obviously boneheaded). Regardless, I had a suspicion that this had something to do with why the syntax highlighting wasn’t working. I did searches and couldn’t really turn up many good results. It seemed pretty obvious that most people with normal working blogs weren’t having issues.

I ended up looking at the plugin code in the WordPress plugins editor to see if there was something obvious causing it. I spent about 15 minutes looking through it when I figured that there was some kind of issue resolving the directory/URL structure between where the blog was being included and where it was actually located. I found the following code:


// Initalize the plugin by registering the hooks
 function __construct() {
 // Check WordPress version
 if ( !function_exists( 'plugins_url' ) ) return;

 // Load localization domain
 load_plugin_textdomain( 'syntaxhighlighter', false, '/syntaxhighlighter/localization' );

 // Register brush scripts
 wp_register_script( 'syntaxhighlighter-core',             plugins_url('syntaxhighlighter/syntaxhighlighter/scripts/shCore.js'),            array(),                         $this->agshver );
 wp_register_script( 'syntaxhighlighter-brush-as3',        plugins_url('syntaxhighlighter/syntaxhighlighter/scripts/shBrushAS3.js'),        array('syntaxhighlighter-core'), $this->agshver );

I figured it had something to do with the function


plugins_url()

not returning the correct location of the plugins directory where Syntax Highlighter is located. I figured it couldn’t resolve the location of the plugins directory and therefore couldn’t find the JavaScripts that color the code. I spent about an hour tooling around with


plugins_url()

trying to get it to work in various ways and permutations, all to no avail.

I was starting to get frustrated when I noticed, for the first time, right next to the code editor a list of plugin files to edit. One of them was titled ReadMe.txt. “What the hell,” I figured, it can’t hurt to take a look at it. I scrolled down about half way until I saw a FAQ. Right there, in the middle of the page, like a veritable bullhorn shouting, “You freaking moron!!!” at me, was my solution.

The code is just being displayed raw. It isn’t being converted into a code box or anything. What’s wrong?

The answer, of course, was to call the


wp_footer()

function in the blog’s footer. Man, did I feel like a jackass. Here I was, making things difficult, wearing my Big Boy Coder’s™ pants, trying to hack up functions and make things more complicated than they are, when all I had to do was RTFM like the noob that I am and find the function to include.

So naturally, the first thing I had to do (after fixing it) was write a post about it rife with Syntax Highlighting. Thanks, Alex Gorbatchev.

Tags:


Site redesign ‘09

• Thursday April 9th by Bucky in General

I’ve finished the second redesign of my site. After using jQuery extensively while preparing a presentation for my local ColdFusion usergroup, I decided that I wanted to redo my site with more jQuery. I initially wrote it using PHP, styled it, and published it, but quickly grew tired of the dark scheme. I’ve restyled it now with a lighter theme, which I’m pretty pleased with. I’ve also gotten my WordPress custom theme pages working correctly, and it was surprisingly easy.

So that’s about it.

Tags:


© david 'bucky' schwarz 2006 - 2010 | Contact