Code eyes

These are some technical notes on some of the changes I’ve made to the standard WordPress site for EDUtalk, I am not sure if they are of much interest to anyone but myself, but writing them up here will, 1. get them clear in my mind, and 2. provide a reference.

The site is running on WordPress 3.5.1. I made a child theme as I wanted to edit some of files and mostly be upgrade proof.

If you have no interest in this you might be interested in the main facts of the move: EDUtalk Has Moved, or just head over to EDUtalk and listen to some great audio.

Plugins

  1. Akismet, spam protection, pretty much a no brainer.
  2. FeedWordPress, this is very much at the heart of the new site, this plugin allows you to syndicate content from other sites, in our case audioboo boos tagged edutalk and iPadio phlogs with the same tag. Posts form these sites with the tag are added to EDUtalk. The plugin also allows us to make the titles link to the original site rather than our own post page, I believe this is a better way to do things for the authors who submit content by tagging.
  3. MediaElement.js – HTML5 Audio and Video, I installed this initially but it is now turned off. Instead I have used this JavaScript myself. As I understand it the plugin will provide html5 and fallback players for audio inserted with a short code player. As a lot of our content comes via FeedWordPress it would not work there unless we manually edited posts.
  4. In the process of importing all of the old content I found the Categories to Tags Converter Importer and WordPress Importer plugin invaluable.
  5. The Safe Redirect Manager plugin redirects links from the old site to the new one, for example, /pages/radio-edutalk to /listen.

Child Theme Files

It seems that the way you best edit a WordPress theme is through Child Themes, this avoids problems when upgrading.

I started by copying the content.php file from the theme to the child theme folder. Here I edited the php to add an html 5 audio player to the top of a post, if the post had an enclosure. I used:$enclosureData = get_post_meta($post->ID, 'enclosure' ); to find out if there was an enclosure. I had a bit of hassle as Audioboo encloses images as well as mp3s, but looped through the enclosures and used the first audio one I found.

I had to edit the main theme function.php file to comment out a bit of code that removed enclosures if they were not linked in the post. This proved a problem when doing some manual edits of the imports. I got information on how to do this from this post: How to stop WordPress 2.8 – 3.5 from deleting enclosures | Kevin J Edwards. The main tool used in building edutalk.info was google. In this case I edited the theme’s own function.php file, rather than the child themes, as the child theme’s function.php is added to, rather than replacing the parent theme. If there is a better way to do this, I’d like to know.

I did create a child theme function.php and added functions to include the jQuery and MediaElement.js. I then copied the footer.php to the child theme and added a script to added a flash player to the audio tags for browsers that do not play mp3s natively.

jQuery(document).ready(function() {
	jQuery('audio').mediaelementplayer();
});

Pretty simple stuff.

Originally I added a bit more jQuery to hide the audioboo and ipadio players and maps in the post. They were not making the posts look very nice, and I found it difficult to style them. Later on, as I found that the pages were loading very slowly, I went back into the content.php file and added some code to only show the post content, if it was in the Radio Edutalk category. Even with only 6 posts per page this made a huge difference in speeding up the page loading (twice as fast). I changed:

<?php  the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) );  ?>

to

<?php if(in_category(5)){the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) );} ?>

5 being the category for Radio Edutalk, I’ll be adding another category for mailed in audio if needed. Thinking about it it would be best to change to not in the audioboo and ipadio categories.

Screenshotpingdom

Altogether it was not very hard to figure this out with the help of google. WordPress is extremely well documented. The code is also easy to edit, without having to understand the whole thing. There are probably a lot of better ways to do this, and I’d be delighted to find out.

I’d also be interested in any other ways to improve the site, speed it up or add useful features.

Like quite a few folk I’ve been kicking the tyres of Glew a wee bit over the last week or so. One very interesting feature is a plugin that Charlie has preinstalled into the wordPress blogs, FeedWordPress:

FeedWordPress is an Atom/RSS aggregator for WordPress. It syndicates content from feeds that you choose into your WordPress weblog; the content it syndicates appears as a series of special posts in your WordPress posts database. If you syndicate several feeds then you can use WordPress’s posts database and templating engine as the back-end of an aggregation (“planet”) website.

I’ve given this a quick test here: johnj (glew login needed, get one while it is hot!) where I’ve aggregated two of my blogs, my flickr stream and audioboo. The only one that doesn’t work too well is the audioboo one as the plugin does not grab the attachment.

I’ve only given this a quick test, but it seems to work very well. There are lots of options for adding categories or tags to posts from a particular feed too.

This could be used for either collecting things from a variety of publishing platforms to one blog, or perhaps be the holy grail for teacher struggling with the current glows e-portfolios: collecting all of your pupils post in the one place. The current glow solution of this is to have a list of links in glow that the teachers can click on to visit blog. I’ve told as many folk as I can that it is better to save a folder of bookmarks in their browser and open in tabs but this is not ideal.

FeedWordPress will handle a lot of blogs over in DS106 is pulling in over 500 blogs and spitting them out in lots of interesting ways (for example Dynamic OPML Files Generated from FeedWordPress).

For those interested in e-portfolios Glew also has the Mahara ePortfolio System, open source e-portfolio and social networking software built in.

The Sandaig blogs have been running since 2004, it is now time to move to a newer system for the school’s blogging. We have installed wordpress and are going to use that for most of the blogging at Sandaig from now on.

The new blog address is:

http://www.sandaigprimary.co.uk/otters

Where you will find the sort of posts you use to find on the old Sandaig otter’s blog, the poetry blog, Sandaig TV and all the other blogs. The only exceptions are the Head Teacher’s blog, which is staying right were it is: HT News and the Eco blog which will move to http://www.sandaigprimary.co.uk/eco.

If you link to the Sandaig blogs you may like to update your links. The older blogs will stay where they for reference but comments will be closed in the near future.

Wordpressicon

At Sandaig I used pivot as a weblog system. it is a system I like. This blog run on PivotX a complete rewrite of pivot. When I started the Sandaig blogs, I choose pivot mainly on the basis that it uses a flat-file rather than a database for storage (pivotx can use either, I use a database here now as it seems faster) and you could have many subweblogs (we had over 20) running of the one install. Pivot is also an easy system to customise if you know a little html, so I could fit it in with the rest of the site easily (for example the HT News fits in with the rest of the site). Over the years the blogging system grew quite big and complex. We did try a wpmu install for a year, but didn’t use it enough to keep it going. I have been very happy with pivot except for a couple of times the config file has be corrupted and allowed a flood of spam in that required manual deletion. I had another one of these a few weeks ago and spent a Saturday morning deleting spam:(

So I though it was probably time for a change in setup. I could have upgraded all of the Blogs to the new version of pivot, but changing 20 odd themes and setting did not appeal especially as the school will not keep up the same amount of blogging. I decided to move to wordpress as that should be easier to maintain even if I am not involved. I like the fact that you can upgrade wordpress from the admin area of the blog. I also decided to sort of merge the functionality of most of the blogs into one. The excepting being the HT blog which will still be pivot and the eco blog which has been moved to a separate wordpress install. The eco blog only had a few posts so I though it would be simple to import them from pivot, via wordpress’ RSS import.

So I did a couple of wordpress installs and uploaded a couple of themes and messed about a bit. This all was fairly straightforward, I’ve installed wordpress a few times (amd wpmu too) so didn’t hit any major snags.

Importing from RSS gave me more of a headache, when I went to the import screen and choose RSS (or any other format) I got a blank page. I quick google show this has happened elsewhere but I didn’t see a solution i could use. I did a test on a test wordpress blog on this domain and could see the importer page there. So i made another install of wordpress here and imported the eco blogs rss. I then used phpMyAdmin to export the database from the mySQL database. using phpMyAdmin on the Sandaig site I dropped the relevant bits and imported the exported database. It went quite well, there are sill a few things to tidy up and i needed to change some of the urls in the database (as it kept redirecting my logon to this domain.) but all seems well now. I’ve created various class accounts and mailed instruction for use to Sandaig. hopefully they will get their heads round it soon. I believe there is an interesting International project in the works and hope to see that online.

I also hope that the blogs continue to get support for all the folk who commented there over the years, this is a great encouragement to the pupils.

After all the fuss last year testing WP and Lyceum here with pretty poor results, I now have a working wordpress mu setup: Sandaig PupilsI’ve not got any children started, just trying to get the setup ready, so far all I’ve added the Anarchy Media Player and put together a widget to pull the links for the rest of the Sandaig blogs in.
I hope to run this for one of our primary seven classes while the other one uses the pivot blogs set up last year now renamed Primary Seven S

Hopefully I’ll be able to do some comparisons between Pivot and WPMU.

If you have any good wordpress mu tips, please let me know. I am especially interested in being able to set up site wide widgets by default.

Blogged from tm