"Hacking" Wordpress 2.7 MU - Part 2

This is my part 2 of my pursuit on howto host multiple Wordpress blogs spreading over multiple different domains (not only sub-domains) on the same Wordpress MU installation. You can read the first part here. It seems to be possible without using the Domain Mapping plugin which also creates the extra table to provide the functionality (which seems unnecessary).

So far my research shows that it possible using what’s already inside the Wordpress MU 2.7 release. There is no web interface for some of these things but with a few manual inserts into the database it seems to work like a charm.

After my last post I was able to create multiple blogs spread over mulitple domains. But before the blog was moved to its own domain you had to attach the users for the blog because the blog would disappear from the admin webinterface as soon as the site id changed (as soon as the blog was bound to another domain).

It was possible to login on the new domain with the admin user but the user would only serve as a blog admin and not as a site admin on that domain.

With the following I was able to make the admin user site admin for the new domain as well:

INSERT INTO `wp_sitemeta`
    ( `site_id` , `meta_key` , `meta_value` )
VALUES
    ('2', 'site_admins', 'a:1:{i:0;s:5:"admin";}');

The number two (2) refers to the site_id your domain got in the table wp_site. If you want another user than admin to be the site admin you’ll have to modify the strange string. Its not as hard as it might look. You can read about how to interpret the string on the Wordpress MU forum - capabilities explanation and the PHP function serialize

"Hacking" Wordpress 2.7 MU pre-release

Alright… one of my good friends wanted a Wordpress blog… I’ve been thinking of migrating this blog (Jacob’s Weblog - Time is always against me) along with another blog on my webserver to Wordpress… that’s 1 2… 3 Wordpress installations.

I went to the Wordpress website and finds they recently released a new version (version 2.7). After downloading it and falling in love my good friend points me to Wordpress MU Why maintain 3 Wordpress installations when you can maintain a single probably 10x times as complex one?… I like a challenge.

The first part of the challenge was that Wordpress MU hasn’t been released in a 2.7 version yet. Well I fetched it right from trunk (revision 1616) and installed. Then created two blogs on two different domains and created users for the blogs on the different domains. Second part of the challenge was that users attached to the second domain couldn’t login and was just redirected back to the login screen.

I described my problem in detail on the Wordpress forum in the hope of some mighty Wordpress MU guru would serve me the solution on a silver platter… that wasn’t the case.

I can get stubborn sometimes and the last 2 months we had a php development project on work so I figured: “How hard can it be?” After an a few hours (first spend googling for debugging Wordpress) I ended up using lots of echo, if and exit - there is no school like the old school :D

Now I think I found a solution and it wasn’t code changes. I needed som changes to the data in the database. You will find a table named wp_site where you will need to add your second domain (and third… etc.) Now browse the table wp_blogs and change the site_id so it matchs the site id for the domain in wp_site.

I still need to test this out but so far it looks good :D

The third challenge will be to make my domains work with www. prepended. But I’ll save that for another time.

Version control: From svn to git

Yesterday I played around with git-svn because git will be the future version control tool we will be using at work and we still have some projects stored in svn. I wanted to try out git but we are not about to convert the old projects just yet.

First I needed to check out the current code from svn and get it into git. I searched the net for how this was done and found something that cloned the entire svn repository to git… not quite what I needed but nice to know:

git svn clone svn://192.168.1.5/htdocs git_htdocs

The above takes the project htdocs from my current svn repository and saves it locally into git repository in the folder git_htdocs.

I just wanted to start hacking so I found that the following fetched the code I wanted:

mkdir git_htdocs
cd git_htdocs
git svn init svn://192.168.1.5/htdocs

Now you are ready to actually fetch some code from svn with:

git svn fetch -r1519

I found the revision I needed (the newest) by issuing a svn info within my old svn checkout.

Make your changes and commit locally with:

git commit lib/class.csv_import.php

When ready to push changes back to the central svn repository use:

git svn dcommit

To keep your local git checkout in sync with the upstream svn repository you can run:

git svn rebase

This article was great reading for me: An introduction to git-svn for Subversion/SVK users and deserters

Happy hacking :D

Whishing for more...

Lately I found myself wishing for more in the world of Linux and Open Source. Yesterday I installed the free VMware Server 2.0 which in my opinion is an upgrade worth while. I didn’t need to patch anything to get the modules running on my Ubuntu Intrepid system, and on my laptop where I’m still running Ubuntu Hardy matching binary modules was actually included in the installation… no need to compile them … I like that. Bridging the Atheros wireless on my laptop still doesn’t work, but I guess thats not VMwares fault.

Anyways after installing VMware Server I installed a virtual Ubuntu 8.04 server (Jeos - Just enought operation system) and wanted to install the VMware Tools on the machine. But honestly would like to just install a deb package. I searched the web for a bit to see if someone had created some debs ready to use…. nothing. At some point Ubuntu hard Debian packages for both the VMware server itself and the VMware Tools. I want that! Well a package with Open Virtual Machine Tools would do as well. I think my choice on Ubuntu (or Debian for that matter) mainly is because the gigantic repository of quality packages. But this is one of the few times when it comes short. As far as I can tell open-vm-tools will be packaged for Intrepid… looking forward to it :)

I’m still ripping all my music to FLAC and today I found some old pieces of music which had been tagged wrong. I was browsing my music library with Rhythmbox and right clicked to change the tag but I couldn’t edit it :( I found a few bugs which seems to describe my problem… and it seems to be fixed in gstreamer-plugins-good version 0.10.11… to bad Intrepid only have 0.10.10 atm :(

Last but not least I wish the nvidia driver would support Xrandr… though I’m not holding my breath :D

I’ve bumped into several other wishes but these was the ones I could remember on top of my head. It seems that for every time the overall quality Linux raises I just raise my expectations by the same degree.

Apple IR remote in Ubuntu Hardy

This weekend I decided to try and get my Apple remote to work on my Mac mini which I just upgraded to Hardy the other day.

Configuring the package lirc you are able to select the apple remote from a list but I couldn’t get it to work that way. So I found a way to create my own configuration file for the Apple remote:

sudo irrecord -H macmini -d /dev/usb/hiddev0 macmini.conf

-H tels irrecord which driver to use -d is the device irrecord listens for input on macmini.conf is the file where irrecord saves the configuration when done

First you need to hold a button. I had to wait almost 25 sec before it was satisfied and went on with the configuration. Now just follow the on screen instructions and in the end you should have you own configuration file. I recommend to compare the following file with the one you just created to check out the differences:

/usr/share/lirc/remotes/apple/lircd.conf.macmini

I made sure to call my buttons the same as in lircd.conf.macmini.

After that I altered these two files to point to my newly created configuration file and removed pointers to lircd.conf.macmini:

hardware.conf
lircd.conf

I then restarted lircd with:

sudo /etc/init.d/lirc restart

now you should be able to check that it is working with the command irw:

irw

Just Ctrl+c when you are satisfied with the result.

At some point I would like to use my remote with Elisa which just released a 0.5.6 which have DVD playback support, but for now I’ll just stick to Totem just to try getting it to work.

To use the remote in Totem you first have to enable the IR plugin (Edit -> Plugins…). Then you have to configure what to buttons are supposed to do which is done in a configuration file in you home folder:

~/.lircrc

Content could look something like this (read more about syntax on LIRC’s website):

begin
    prog = Totem
    remote = Apple_A1156
    button = vol+
    config = volume_up
end

Since the Apple remote have a combined Play/Pause button I wanted to find out if that was possible. I had a bit of trouble figuring out what was going in the config = line and looked through all documentation I could find on LIRC’s website. Suddenly it hit me that the values in config a specific for the application. Not much about this on the Totem website so I downloaded the source code for Totem. Don’t worry this isn’t going to be hardcore. I unpacked the source code and searched for files with the name lirc:

$ cd totem-2.22.1
$ find . -name \*lirc\*
./data/lirc_example
./src/plugins/lirc
./src/plugins/lirc/totem-lirc.c
./src/plugins/lirc/lirc.totem-plugin.in

I opened the file totem-lirc.c and found about 25 definitions for IR commands something like the following:

#define TOTEM_IR_COMMAND_PLAY "play"
#define TOTEM_IR_COMMAND_PAUSE "pause"
#define TOTEM_IR_COMMAND_NEXT "next"
#define TOTEM_IR_COMMAND_PREVIOUS "previous"
#define TOTEM_IR_COMMAND_SEEK_FORWARD "seek_forward"
#define TOTEM_IR_COMMAND_SEEK_BACKWARD "seek_backward"
#define TOTEM_IR_COMMAND_VOLUME_UP "volume_up"
#define TOTEM_IR_COMMAND_VOLUME_DOWN "volume_down"
#define TOTEM_IR_COMMAND_FULLSCREEN "fullscreen"
#define TOTEM_IR_COMMAND_QUIT "quit"
#define TOTEM_IR_COMMAND_UP "up"
#define TOTEM_IR_COMMAND_DOWN "down"
#define TOTEM_IR_COMMAND_LEFT "left"
#define TOTEM_IR_COMMAND_RIGHT "right"
#define TOTEM_IR_COMMAND_SELECT "select"
#define TOTEM_IR_COMMAND_MENU "menu"
#define TOTEM_IR_COMMAND_PLAYPAUSE "play_pause"
#define TOTEM_IR_COMMAND_ZOOM_UP "zoom_up"
#define TOTEM_IR_COMMAND_ZOOM_DOWN "zoom_down"
#define TOTEM_IR_COMMAND_SHOW_PLAYING "show_playing"
#define TOTEM_IR_COMMAND_SHOW_VOLUME "show_volume"
#define TOTEM_IR_COMMAND_EJECT "eject"
#define TOTEM_IR_COMMAND_PLAY_DVD "play_dvd"
#define TOTEM_IR_COMMAND_MUTE "mute"
#define TOTEM_IR_COMMAND_TOGGLE_ASPECT "toggle_aspect"

Other multimedia software might be better docuemented when it comes to IR but I guess you would be able to use something similar to figure out what possible config-options you have in the lircrc for the software.

Anyways Totem have a Play/Pause toggle and I ended up with:

begin
    prog = Totem
    remote = Apple_A1156
    button = play
    config = play_pause
end