HTML5 Video

I haven’t been doing too much new development in WordPress lately. I’ve been reading a book to be more familiar with the internals so I attack my next project from a strong standing. In the mean time I have attempted to play a little with HTML5 video. I’m just trying to understand the styling possibilities with this technology. I’ve gotten a clip converted to the Ogg Theora format for use with Firefox. It plays fine and for now I’m using the built-in controls. So far, the only way I can get text to appear above the video is to make the text absolutely positioned. In my example, both the video and the text are set position absolute. I’m hoping that won’t be necessary but all examples I’ve seen so far use this. If I find another way, I will post about it.

Once I have my example looking something interesting, I’ll post it here.

Heads down reading

Haven’t posted much in a while for a couple of important reasons. The biggest reason is that I’ve been home on a personal matter. The second reason is I have been heads down reading to get myself up to speed on WordPress internals. I initially purchased two books on the subject:

My expectation was that Smashing WordPress would show me all the internals and the basics of extending WordPress with plugins and whatnot and that Wicked WordPress Themes would have all the detail I needed on theme development that was passed over by the first book. I started reading Smashing WordPress and am still reading it. For the most part, it does what I want it to do. It is still a bit light on some areas where I want more detail. I think it is meant to live between a design book and a programming book. In the future I hope to do a more thorough review of this book. I haven’t delved into the Wicked WordPress Themes book yet, though a friend of mine at tcassdesign has. He is more of a design guy and liked what he read. He quickly stopped reading when that book delved into code.

Feeling that Smashing WordPress is missing some of the detail I want, I decided to pick up Professional WordPress. This book arrived today and I have yet to even crack the spine. I plan to review this book too.

What I can say so far is that at least for me, having a book to guide my study is extremely helpful. I know most if not all of this material is available online somewhere. The problem is I don’t know what I don’t know. The books collect the ideas together and guide my further inquiry. So, for now my head is down and I am studying. Reviews to come in the future.


WordPress Multisite and Separate Domains

In some previous posts, I have talked about getting WordPress Multisite to work across separate domains instead of using subdomains as it was intended. It works with some manual wrangling, but the sites didn’t appear in the Super Admin section that multisite adds to the back end. I decided to try and fix that problem.

The main issue here comes from the table wp_blogs. In that table there are blog ids and site ids. This points to the intent to allow separate domains and separate subdomains in the same install. The problem is that functionality is intended more for a hosted site solution and the separate sites are protected from one another. To make separate domains works, the blogs need to have different site_ids. This is the crux of the problem as the admin takes the current site_id into account when making the blog list in the super admin. To fix the problem, I removed the reference to site_id from the queries.

in wp-admin/ms-sites.php there are several queries that populate the multisite admin and some code to protect sites from one another. Since my files are edited, I cannot give accurate line numbers, so please bare with me. Searching for site_id, you will find the following lines:

if ( $details->site_id != $wpdb->siteid )
  wp_die( __( 'You do not have permission to access this page.' ) );

These lines get commented out. Next, you should find:

$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";

I replace this with:

$query = "SELECT * FROM {$wpdb->blogs}";

Then comes:

$query = "SELECT *
FROM {$wpdb->blogs}, {$wpdb->registration_log}
WHERE site_id = '{$wpdb->siteid}'
AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";

replaced by:

$query = "SELECT *
FROM {$wpdb->blogs}, {$wpdb->registration_log}
WHERE {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";

After making these edits, all my sites appeared on the super admin list and so far I have not found any other issues. Use these changes at your own risk. This has not been heavily tested. As time goes on, if I find more issues, I will pass on the information. These modifications will be used on some rather large sites once all my conversion is done, so the testing will happen. I will keep you informed.

A very small bit of styling

I’ve taken some time to make some small updates to the scheme on this site. I this is the same base 2010 theme for WordPress with a few small adjustments. First thing was the addition of the ad at the top of the screen. The ad plugin I use does not support that placement directly. I had to edit the header.php template to add that placement.

Along with that placement, I made some minor tweeks to the page as a whole, making the site title white on black and changing margins to my liking. Perhaps the most interesting thing I did was change the title fonts on the page. I used a Google font for this.

Part of my motivation for this was to try it out. I have not used Google fonts before and wanted to see what it took to implement them and what other consideration might arise. I chose the font called Philosopher. Implementation was very easy, add a link tag to the header and then set the font-family in the CSS as usual. That was different was how the font presented itself. The font seemed to sit higher on the line that a “normal” font would. Since I haven’t played with other fonts, I don’t know if this is a universal issue with Google fonts, or specific to Philosopher. For the main site title, I added special margins to make the font sit on the line the way I wanted it to. Something to consider for certain if you plan on using Google fonts. It may be less of an issue if all your fonts are Google fonts, but when mixing, look for the different baselines.

Learning WordPress

With the data move complete, the next step will be theme creation. I am currently reading about WordPress in the book Smashing WordPress: Beyond the Blog from Smashing Magazine. I will post a full review later but so far the book has been good, though at times written a bit below my level (too simplistic). The information is good and that is what’s important.

Data move complete

All the lingering problems have been corrected and I have successfully brought all the data necessary from Article Manager (Artman) into WordPress. The date problem mentioned before was because Artman stored dates and Unix style timestamps and WordPress uses MySql datetime fields.

One odd point about the data move came from categories. First, I had issues as I was making the transition in improperly links category parents and children and linking categories to stories. The problem was I needed to use the term_id for the parent child relationships and the term_taxonomy_id for the post to category relationships. I had overlooked this initially.

The second odd thing with categories was sub-categories not showing up in the back end when inserted directly into the database. I could insert a top level category with no problem. Child categories wouldn’t show up till I saved a category. Didn’t matter which category and I didn’t need to change anything, but the act of saving a category made the system catch up.

Mission mostly accomplished

Well, today I was able to load users, categories and stories from my old system into WordPress. The conversion is not without issues, but great progress has been made. Dates have not transitioned correctly. I have not taken all the steps to properly reference images used in the articles so they will appear in the Media Library. Still, this is good progress and I will push on in the coming days.

Migrating from one system to another

My next project involves moving some sites from a now defunct application called Article Manager by Interactive Tools to WordPress. Since this also involves a redesign of the site, there is no need to translate the templates. This will be a data transition only.

Article manager creates flat files from its data. It is not a “live” system like WordPress is. The good part about that is the low database utilization and very quick serving site as all you need is a quick web server. The down side comes from the very limited template language the system uses. There are no variables you can create, very little branch control, very little state you can check. It was quick and relatively simple but in the end too simple for our needs. Interactive Tools has moved on from that product to one they call CMS Builder.

Article Manager (Artman) contains all its data in four tables, one for the articles, one for categories, one for users and one for what it called publish rules. The publish rules are instructions to the system on how the create the flat files. Since those are not needed in WordPress, I can ignore that table. That leaves three.

The first I will convert is the user table. I choose that one because it is referenced from the other two via creator ids and such. Second, I will move the categories and third will be the articles themselves. This will be the most interesting one and will take the most manipulation. I’ll need to update the user ids and category ids. I will also have to decode the way Artman stores image references for articles. Instead of keeping the original link to the images the way WordPress does, Artman had a code system for placing images into the article.

Since I will be doing this conversion more than once, I plan to build a tool to do the job. In the end, I will be combining many sites into one WordPress multisite install.

Changing hosts and WP-United

Just a quick note on an issue that popped up for me when moving a WordPress / WP-United site to a new host. The move was done by the hosting company without the knowledge of the site and its databases. The WP-United / WordPress combination is somewhat specific, so I wouldn\’t have expected them to have much knowledge of it anyhow.

After moving all the data and the databases, a message that it could not connect to the database kept showing on the site. Going directly to the forums however worked. Within the PHPBB control panel, I then emptied the cache. After that, WordPress was able to function again.