Archive for the 'Programming' Category

Simple WYMeditor and WordPress 2.6

I love WYMeditor, it is by far the best Javascript text editor I have used.  As I have written before, I use the Simple WYMeditor plugin so I can have WYMeditor in my WordPress installation.

However, when I upgraded to WordPress 2.6 it stopped working for me.  There is no new version of Simple WYMeditor as yet, but this little fix worked for me.

Simply change line 69 from this:

69 if ( strpos($wp_version, '2.5') !== false ) {

to this:

69 if ( $wp_version >= "2.5" ) {

Enjoy!

New Admin SSL

I have released a new version of Admin SSL – version 1.0.  I am very excited about this release, because it represents a lot of hard work, and a complete re-write of the entire plugin since I took over developing it from Haris.

It has a lot of new features, a much more stable redirection script, and supports WordPress MU as well!  To find out more (or to post a comment) please visit the Admin SSL home page.

Website compression

I just found a helpful article about compressing website pages automatically using .htaccess here.  This reduced my page size by at least 75%, a big (and safe) help for viewing pages fast.

My next search was for a WordPress caching plugin.  I am currently testing WordPress Super Cache, which has been updated to work with WP 2.5.  However, it has a complicated setup and clashed with the .htaccess rules I already have setup for the rest of my website.

I've been testing other .htaccess rules to enable GZIP or Deflate for all files, but haven't yet found the perfect configuration.  If I do, I'll post it here!

Changing posts to pages

I have just converted the post on the WordPress plugin Admin SSL into a page – it can now be accessed here.

It is very easy to do this – simply edit the `post_type` in `wp_posts` in your database from 'post' to 'page'.  Then you need to edit the new page and tell it to use the default template with comments, or all the comments will not display!

Finally, you need to setup a redirect from the old post URL to the new page.  I did this using a directive in .htaccess:

Redirect 301 /blog/2008/04... http://www.kerrins.co.uk/blog/admin-ssl

Not only does this redirect people browsing to the page, it also redirects feed requests.

Using svn:externals

After learning most of the basics of subversion, I discovered I had missed one of its most useful features: svn:externals.  This allows you to checkout multiple repositories into one location.  For a more detailed definition, go here.  To access the property, use your subversion program (look for an option called 'Show Properties' or something like that).  Or, if you can log into your server's shell:

$ svn propedit svn:externals ../some_dir/another/

This will open vim (or whatever text editor you have) to edit the property 'svn:externals' for the directory '../some_dir/another/'.  You don't have to be in the directory to edit its svn properties – simply specify the relative path to it at the end of the command.

The best way to think of svn:externals (and the other svn properties) is as an invisible file.  There is one for every directory in your repository.  This means that when you checkout a project, it also checks out the external variables into the folders you specify.  So, for example, I have all the code for my website in an SVN repository, and in the root web directory (public_html) I have this line in svn:externals:

blog    http://svn.automattic.com/wordpress/tags/2.5/

This checks out whatever files are in the repository at 'http://svn.automattic.com/wordpress/tags/2.5/' into the directory 'blog'.  This is basically it, but there is one more thing I didn't realise at first.  If you want to checkout a project into a directory, say public_html/blog/wp-content/themes/some_theme/, you don't have to add the command to the svn:externals property of the 'themes' directory.  Instead, you can do this, in the svn:externals of public_html:

blog/wp-content/themes/some_theme    http://some_repos/trunk/

You can have as many of these as you like.  I use them to checkout plugins for my blog – as you can see from this example file.  If you hadn't already discovered svn:externals, I hope you find it as useful as I do!

WordPress 2.5 Media

Well I'm enjoying my experience of WordPress 2.5 already. The admin interface is so much cleaner, and it does so many things better than before!

I did however have one small problem. When trying to add media using the new media interface, I kept getting HTTP errors. After a bit of searching around, I discovered it was due to the mod_security Apache module.

Not wanting to disable it entirely, I discovered that it is possible simply to disable the POST filter, which allows the gallery to work. Simply add the following to the .htaccess file in the root folder of your blog:

<IfModule mod_security.c>SecFilterScanPOST Off</IfModule>

This works for me, so I hope it works for you!

Javascript hacking

I just read an extremely funny article from the States about 'securing' websites using javascript, with the username, the password, and the 'secure' page URL written in the clear: 'So you hacked our site?!'.