All posts by KathyW

Web author, programmer and developer; photographer; designer; artist and bird breeder. Interested in all of the above plus underground homes, alternative energy systems, native plants and animals, alpacas, carnivorous plants, dyers plants and organic gardening.

Restoring a WP custom header

Missing custom header imagesThere are many good Plug-ins for backing up WordPress. None of them did exactly what I wanted. They either did too much, or not enough.

On top of that every time I’ve restored a server backup copy on my development (dev) machine the custom menus and header images inexplicably disappeared.

It’s no good having the best back-up routine in the world if the restore doesn’t quite work!

The disappearing custom header images seems to be a common problem according to Google search results. The common “answer” – upload the header image again through the Admin Appearance Header menu.

Hrumpff! Not exactly an explanation, not even a proper solution. Just another kludge that left you with multiple redundant copies of the header image scattered through the upload directories.

Well, this one time I wouldn’t take “upload it again” as an answer, and went digging deeper for an explanation.

Experimenting on my own site first (this one – www.kathyw.org) and examining the dev server page code compared to the live server gave the first clue. There were some lines of code missing that appeared to be generated out of the database.

The sql backup file was fine, except for discrete references to the live server URL. The usual remedy given – edit the sql file to change the ‘siteurl’ references from the live server URL to the new (in this case dev) server URL. Easy enough. The dev site runs and “looks” just like the live one.

Enter problem #2 – all the images in the “restored” site point to the original site. NOT what you want if you’re going to be moving domains.

So, edit the sql file again, and replace ALL references to the live URL with the dev URL. This can take a while. Update the dev database from the sql file and now with the database image catalogue entries updated the image links all point to the right server.

Enter problem #3 – now the header image has inexplicably disappeared and the menus have reset to default.

So Google some more, and eventually discovered this tasty tid-bit from 2010:

Moved to new subdomain – Lost text widgets and custom header images.

“Sometimes it’s not quite as simple as copying and pasting the new site domain over the old in the database. This is because the information contained in meta_values is often serialized. So it looks like:
a:22:{s:12:"productimage";s:69:"http://cooldomain.com/wp-content/uploads/products_img/DSC02043web.jpg";}

“This” (s:69) “basically refers to the number of characters within the quotation marks.”

Serialized data in the database. Hrumpfff!! Their solution – change the s:number to match the new URL length.

If you’re moving domains to a live one that is completely different, this is probably the only other option to manually resetting header images and menus and anything else thus affected.

However, if you are restoring to a development server where you have absolute control over the local URL it’s even simpler. When you do the search and replace on the SQL file to reset the siteurl and image URLs, make sure the new URL is the same length. Make your development virtual server name the same length for example by using (in my test case) www.kathyw.org locally as a copy of www.kathyw.org live.

I wanted to post my solution to the site where I found it as it might help others in the same situation, but alas only their paid-up members can post there. I hope by posting it here it may be discoverable by anyone else wanting an explanation, and an easy solution.

Matching the site URL to the serialized data length using either method above may resolve a number of backup restoration headaches. During one of my first restore tests cForms II managed to corrupt it’s database entry. I manually reset it and restored it settings with a backup txt file from cForms own “Save Settings” on the live server. After the final sql restore with the matching URL/data length numbers cForms II was still working fine and dandy.

The same SQL file was used for all tests, with only the URL references changed with a search and replace.

Off course, having just added this new post, my backup of this morning is now out of date …

Why WordPress

WordPressWordPress is a Content Management System, blogging software, and extensible Website framework. They describe themselves as a “semantic personal publishing platform with a focus on aesthetics, web standards, and usability”. So why did I choose to re-work my www.kathyw.org website with WordPress?

I have been writing, designing and coding websites since 1995. I’ve seen Web Standards evolve, trends come and go and browsers delight, frustrate and disappoint.

Here we are currently (June 2011) with FireFox 5.0, IE 9, Opera x, Chrome y, Webkit z, and still my Web Development mailing lists are full of questions of “something-on-my-page won’t work with IE 7-8, IE6 (shudder), Firefox 3” or some-other-old-browser.

I must confess I’ve been “guilty” myself if you like at trying to design usable websites down to IE6. The kludges required to support these old out-of-date browsers and their bugs is enough to make many throw our hands up in the air and say “enough”!

Then through my Web Development work I was introduced to WordPress to migrate a clients existing WP site to one of our servers. WordPress is seen by many as simply a blogging environment. It is also a whole lot more.

For over 3 years now I’ve dabbled in WordPress, not for blogs at all, but as a simple to use Content Management System for clients who want a professional looking site they can update easily themselves. WordPress lends itself to this task extremely well. It is an incredibly flexible and extensible environment, with a vibrant developer community and user base.

So when I decided to re-vamp my own Website (this one), I figured the best way to really get a handle on WordPress was to use it for myself.

Now instead of having to program everything (which I still do for some sites) I can leave a lot of the coding to the hundreds of programmers working on WordPress, it’s Plug-Ins and Themes. Now I can concentrate on the content, not the “container”.

Most of the browser issues and problems are handled by WordPress and it’s theme programmers, with only a little tweaking for personal taste – like transparent png support for bad-old ie6, and some extra JQuery .

Security is always an issue, and WordPress being as popular as it is, makes it a target for would-be hackers. Fortunately the people behind WordPress are vigilant to the threats and respond quickly to any newly discovered exploit. Properly secured and regularly updated WordPress seems to be a pretty reliable package.

Most Content Management Systems (CMS) tend to suffer from code bloat, and what is often referred to in Web Developer circles as “divitis” – an almost unending collection of nested and often empty divs (HTML scripting tag). WordPress is no exception, although it’s largely theme dependent, better in some than others, and far better than other CMS’s I’ve deployed projects with in the past.

The people behind WordPress and it’s Themes and Plug-ins also seem to be pretty handy at keeping up-to-date with Web trends. Social Networking considerations and support for mobile platforms being just two more aspects I can add with just a Plug-in or two. Sometimes it’s really handy to have an international army of keen young and experienced coders and resources to call on.

And did I say installation is a breeze? None of the horrendous hoops many other CMS’s require, instead it’s incredibly easy. This means I can spend more time securing, tweaking and designing. Yes if I want some specific functionality the base install doesn’t have, I’ll have to go get a plug-in or two, or write something myself. No big deal. Conversely, I only need to install or write things I need, without the hindrance of functionality I don’t need (or want).

So if you add together an army of coders to handle the dreaded cross browser issues, web standards and security, regular and easy updating, fresh new ideas and Plug-ins, lots of fellow web developers using WordPress (often abbreviated on-list to “WP”) and writing about what they have found, good and bad, it becomes an almost “must-do” to at least see what can be done with this publishing platform.

So now my journey continues. How far can WordPress take me? Will it in the long term let me spend that extra time on design and content? It’s an adventure I’m enjoying so far, and as long as the excitement continues I’ll keep on exploring it.

White Cedar Moth

White Cedar Moth Caterpillar
White Cedar Moth Caterpillar

In the summer of 2010 a hairy invasion began. First it was novel, one or two hairy caterpillars crawling through the aviary service area, or falling off the door frame whenever the sliding door was opened. As summer progressed the numbers of these hairy brown caterpillars increased dramatically until they were everywhere – up the walls, along the skirting boards, in the door frame and in the curtain folds. Then they started to pupate, turn into moths … and lay eggs.

White Cedar Moths
Male (top) and female (bottom) White Cedar Moths

By this time we had enough information and specimens to identify the invaders and they were positively id as White Cedar Moths, Leptocneria reducta. We have a number of young White Cedar trees planted to provide summer shade to the aviaries so another piece of the puzzle fell into place.

 

White Cedar Moth laying eggs
White Cedar Moth laying eggs, 5th March, 2011

The moths were almost as numerous as the caterpillars, and before long there were clusters of eggs on the service-way walls and dead moths all over the floor and trapped between the polycarbonate and aviary mesh. The moths themselves are nothing spectacular, in fact almost drab. Their egg clusters are intriguing and conveniently some were in plain enough view that we were able to observe and record their progression to hatching.

 

White Cedar Moth caterpillars hatch, 15th March 2011
White Cedar Moth caterpillars hatch, 15th March 2011

The caterpillars emerged en-mass, hung around for the day, and by the next morning had all disappeared. There was no sign of them or their egg cases. It is possible some may have survived to reach the White Cedar trees as there were no suitable food plants any closer. Or they may have fallen prey to a hungry spider or centipede. No further sign of juvenile caterpillars was seen inside the aviary service area or bird-room.

During autumn however, the White Cedar trees acquired woolly, hairy “trunk-warmers”. Masses of White Cedar Moth caterpillars congregated at the base of the tree trunks. Presumably under the cover of darkness they venture up the trees to wreck havoc on the leaves. While some damage is evident, it does not seem to concern the trees, which are deciduous, and have just about lost all their leaves by June.

White Cedar Moth caterpillars on White Cedar tree trunk
White Cedar Moth caterpillars on White Cedar tree trunk
White Cedar Moth caterpillars at base of White Cedar tree
White Cedar Moth caterpillars at base of White Cedar tree
White Cedar Moth caterpillar damage to White Cedar leaves.
White Cedar Moth caterpillar damage to White Cedar leaves.

The mass of caterpillars, armed with spiky and irritating hairs, would pose an unpleasant barrier for anything else small wanting to climb the tree or gnaw on it’s lower bark. Perhaps this behaviour is their way of protecting their food supply – the trees and their leaves – from other potential competitors or threats.

White Cedar Moth caterpillar close up of spiky hairs.
White Cedar Moth caterpillar close up of spiky hairs.

White Cedar Moths belong to the Leptocneria family, and both the moths and caterpillars are yet another in the “handle with care” category. Their hairs are irritants and will shed easily. The caterpillars might look cute and furry – but they are definitely not! Do not let children play with them.  The hairs can not only cause skin irritations in humans, they have also been implicated in abortions in horses. The caterpillars, pupae, and moths are all sources of irritating hairs, which retain their irritant properties long after they have been shed.

More information on health implications of White Cedar Moths can be found at the Department of Medical Entomology – http://medent.usyd.edu.au/fact/caterpillars.htm

Further reading on White Cedar Moths can be found here: Leptocneria reducta – http://lepidoptera.butterflyhouse.com.au/lyma/reducta.html

Addendum, February 25, 2012:

The White Cedars have been seriously defoliated this year, but there is no sign of the catterpillars around the base of the trees. Unlike last year however, the grass is dry and short. The caterpillars may be hiding in the dry leaf litter and grass during the day, emerging at night …

Caterpillars streaming up the branches.
Caterpillars streaming up the branches.
Adult caterpillars and egg clusters on a lower leaf.
Adult caterpillars and egg clusters on a lower leaf.
Half grown Cedar Moth caterpillar.
Half grown Cedar Moth caterpillar.

 

Which is indeed what they are doing. An evening torchlight visit to the White Cedars revealed them to be literally crawling with big, fat, White Cedar Moth caterpillars. They were streaming up the branches in lines, shunning away from the light from the torch (click for large photo which will open in another window/tab).

The underside of the leaves (or what’s left of them) were bristling with hungry, hairy catterpillars.

Cedar Moth caterpillars decimating the White Cedar leaves.
White Cedar full of Cedar Moth caterpillars.
Cedar Moth caterpiilar hugs the underside of the leaves.
Caterpiilars hug the underside of the leaves.
Close up of the Cedar Moth caterpillar's grip.
Close up of the Cedar Moth caterpillar's grip.

 

The trees themselves seem to be responding with new emergent growth at the tips. It will be interesting to see if this new growth is as tasty, or whether the trees are able to defend themselves and become less palatable as some other plants can.

The absence of caterpillars during the day this year may indicate they prefer dry grass and leaf litter, and disliked the lush grass and damp ground experienced in previous years. This has implications for potential organic control of them should they become a problem that the trees cannot cope with by themselves.