Archive for the ‘1’ Category

Slides now online for OSCON talk: “Building a Corporate Blog Portal using WordPress MU”

Monday, July 27th, 2009

The slides are now available on SlideShare for the talk I gave last Thursday at O’Reilly’s OSCON entitled “Building a Corporate Blog Portal using WordPress MU“. The presentation went well and I had some great interaction with those attending. I did record the session on video so I am aiming to get that video out this week.

In the meantime, enjoy the slides…


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


How to automatically add text to the bottom of a blog post in WordPress MU

Wednesday, July 15th, 2009

If you have been reading posts on the Voxeo blog site, you’ll notice that any posts that I have written have included this footer at the bottom of the text:


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook or following us on Twitter.


I want to include this as a direct note asking people to join us in the various conversational services (FB, Twitter) or to subscribe. Yes, we have the same links in our first sidebar, but I also want it in the post itself.

However that text does not show up on anyone else’s posts – only mine. The reason, of course, is because I have been manually adding that footer when I write the blog posts in MarsEdit. This obviously has several problems:

  1. As mentioned, it only shows up on my posts.
  2. I have to remember to manually add the footer.
  3. On the rare occasions when I post through the WPMU web interface (or a mobile interface), the footer doesn’t get added there.
  4. Because I have different footer macros in MarsEdit, they have over time gotten out-of-sync. For instance, they have used different URLs for getting to Voxeo’s Facebook page.

This has been very clearly something to automate through adding it to our theme… it’s just been an issue of not having enough of those darn “round tuits”. Today I finally made the change.

Now, the first intuitive place for me to look down in our “voxeo-default” theme was naturally footer.php. However, that puts any text way down at the bottom of a page. I wanted it to appear right up underneath the body text of an entry.

THE SOLUTION

It turns out that there were really three places I needed to add some text. Rather than adding the footer to three separate files, though, I first created a new file that I called “post-footer.php” and included this text:

     <hr>
     <p><em>If you found this post interesting or helpful, please consider either
     <a href="<?php bloginfo('rss2_url'); ?>">subscribing via RSS</a>, becoming 
     <a href="http://www.voxeo.com/facebook/">a fan on Facebook</a>, or 
     <a href="http://twitter.com/voxeo/">following us on Twitter</a>.</em>
     <hr>

Note that I’m using a WordPress variable to show the blog feed appropriate to the specific blog, but in the case of Facebook and Twitter they are both static URLs. (You’ll also note I’m using “http://voxeo.com/facebook” versus “http://www.facebook.com/voxeo“, which does also work, primarily because I’m interested in tracking click-throughs.)

Next, I started changing the relevant files. First, I changed the single.php file to have the following additional text (in red italic):

<div class="entry">
     <?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
     <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
     <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
     <?php include (TEMPLATEPATH . '/post-footer.php'); ?>
     <p class="postmetadata alt">

Ta da… this footer now gets added to all posts to our blog site when they are individually viewed.

Second, I changed “index.php” to have this text:

<div class="entry">
     <?php the_content('Read the rest of this entry »'); ?>
     <?php include (TEMPLATEPATH . '/post-footer.php'); ?>
<div>

This addressed the display of posts on the “main” blog page such as http://blogs.voxeo.com/voxeotalks/.

Finally I changed “archive.php” to look like this:

<div class="entry">
     <?php the_content(); ?>
     <?php include (TEMPLATEPATH . '/post-footer.php'); ?><div>

which gets archive pages of multiple posts such as http://blogs.voxeo.com/voxeotalks/2007/12/.

Note that because I modified single.php, anytime anyone clicks on any of the posts shown in the blog index or archive, they will see the post wrapped in the single.php template. If you didn’t want such a footer to appear for each post in the blog index or archive, you could simply not modify those files. I wanted to have the footer appear in all three views.

ALL IS GOOD, RIGHT?

The great aspect about this approach is that I can simply go into our theme and modify that single “post-footer.php” file if I want to update that footer text. For instance, at some point I may actually start using Voxeo’s identi.ca account and so I may want to add that link there.

Going back to my original four issues with manually adding the footer:

  1. The footer now shows up on all posts on the site.
  2. It is done automatically so I don’t have to remember to include it.
  3. Because it is on the display end of WPMU, it doesn’t matter how the blog post is created. It can come in through MarsEdit, through the WPMU web interface, through a mobile interface or really any other means.
  4. Footers across blogs never get out of sync because it’s the identical footer across all blogs.

ALMOST…

Now, here is one problem… the footer only shows up when the post is displayed on our site.

My main reason for starting to use the footer, really, was because I saw our content being scraped via the RSS feeds and appearing on other people’s sites. I therefore wanted to include the footer so that those sites blindly scraping our content would wind up including pointers back to our site and accounts.

Ideally, I like to really inject this footer at the time a blog post is created so that it is in the actual content of the post rather than the wrapping template that comes from the WordPress theme. Either that or have it injected in the RSS feed for each entry when that gets sent out.

However, for either of those I have to go outside the theme and get into either:

  1. Modifying the main WordPress MU files;
  2. Finding a plugin that will do this functionality; or
  3. Writing my own plugin to do this.

Perhaps at some point, I’ll do that… meanwhile, I’ll stick with modifying the display of the posts when they are viewed on our site.

P.S. Of course, there is the problem that all the posts that I have written now have TWO of these footers… but that’s just some time going through and removing that text from the content bodies…

Technorati Tags: , ,


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Upgrading to WordPress 2.6.2…

Monday, October 13th, 2008

On Friday, I made the jump to bring this site up to WordPress 2.6.2, the latest WPMU release. I pretty much just followed the upgrade steps I’d outlined back in June. For those curious, here was the database backup command I used:

mysqldump wordpress --add-drop-table -u username -ppassword | bzip2 -c > wpmudb-backup-20081010.bz2

Obviously I removed the username and password, and yes, there is a space between “-u” and the username and there is not a space between “-p” and the password. I didn’t research whether that was required… I admittedly followed the steps in one of the WPMU Forum posts I found.

With WordPress 2.6.2, I did need to add the following lines to my wp-config.php file:

define( 'LOGGED_IN_KEY', 'text removed' );
define( 'LOGGED_IN_SALT', 'text removed' );
define( 'AUTH_KEY', 'text removed' );
define( 'SECURE_AUTH_KEY', 'text removed' );
define( 'SECURE_AUTH_SALT', 'text removed' );

Obviously I’m again removing the values specific to our system. These lines were shown to me right at the top of the admin interface after I logged in after the upgrade. I just copied/pasted and then needed to login again.

Thankfully by this point, we’ve made most of our customizations either in the custom theme we use for the site or in specific plugins, so really the only post-upgrade manual tweak I had to do was to modify kses.php to allow “skype” and “sip” protocols in URLs as I had documented earlier. At some point I should probably figure out how to make this a plugin so that it survives upgrades… in the meantime it’s not a big deal provided I remember to do so. (Upgrade checklists are your friend!)

I did the upgrade primarily because I knew I needed to keep the site up-to-date on security issues and fixes, but also because I wanted to try out the WordPress app on the iPhone now that we have made the switch from Blackberries to iPhones. As you can see in this test post, the WordPress app on the iPhone does work. It does, though, seem to have one rather annoying limitation for working with WordPress MU that I mentioned there and will write about in more detail in another post.

Meanwhile, we’re up and running on WPMU 2.6.2…

Technorati Tags: , , ,


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Successful upgrade to WPMU 1.5.1 – with some lessons learned

Wednesday, June 11th, 2008

Tonight I successfully upgraded blogs.voxeo.com to WordPress MU 1.5.1, the latest version. I’ve been wanting to do this since the release a month ago but I’ve held off to monitor the WPMU Forums to see what upgrade issues there were. The other challenge is, of course, that doing a site-wide upgrade requires setting aside a block of time in case anything goes wrong (and it did… see below). However, in light of reports of mass hacking of WordPress sites (see also here), I decided to make the upgrade tonight.

Following some of the links off of this forum post, I did successfully complete the upgrade, but I thought I’d record several lessons I learned in case they help others:

1. BACKUPS ARE YOUR FRIEND – Before doing anything, I had done the good old

tar -cvzf wpmu-backup-20080612.tgz wpmu

command in the directory above my WPMU installation to have a nice little tar file sitting there. This turned out to be critical as I did in fact need to restore it all to how it originally was after messing it up with #2 below. I also performed a MySQL backup to be safe although that turned out not be needed.

2. DISABLE ALL PLUGINS – This was mentioned in a few posts but for whatever reason I didn’t do it. Bad move. There was something about the OpenID plugins I was using that did not like the upgrade. It was somewhat bizarre in that the plugin to accept OpenID logins actually seemed to start working, which it hadn’t done before! However, it was causing a host of errors – bizarrely even when I reverted to a backup… so I wound up going into mu-plugins and blowing away the OpenID plugins from the directory (thanks to having the backup in #1).

3. YOU DO HAVE TO ADD THE SECRET KEY AND SALT – Just as detailed on Donncha’s blog post, on my first login to the admin interface I was given the warning that I needed to add two lines to my wp-config.php file. This was a very simple copy/paste into a shell window I had open.

4. USE ‘UPGRADE’ FROM SITEADMIN – Once you’ve copied the WPMU 1.5.1 files into your WPMU directory, the upgrade process for the individual blogs is a simple matter of choosing ‘Upgrade’ from the Site Admin menu.

5. THE ‘DEFAULT’ THEME GETS OVERWRITTEN! – After the upgrade, our home page was perfectly fine, but each of the individual blogs looked horrible. After a forced browser refresh it became clear that they had reverted to the default Kubrick theme. The issue became clear – the ‘default’ WP theme gets overwritten by the upgrade. In retrospect, this makes sense, but here’s the problem – we replaced the ‘default’ theme with our own that is visible on any of our blogs. The reason is simple… on this site, the only blogs that will be created will be with this theme. It will be the default for all blogs. Rather than create a separate theme directory and require blogs to be changed to that separate theme, it seemed to make sense to just replace the ‘default’ theme.

Oops.

Thankfully because of the backup from #1, restoring our ‘default’ theme was a trivial matter.

In a nutshell, those were my lessons from tonight. We’ll see if there are any further issues as we use it, but so far everything seems fine (outside of the fact that I have to go back and add the OpenID plugins back in – which will be for another day).

Technorati Tags: , , ,


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.