WordPress command line PHP

This is a quick overview on running a PHP file via the command line, bootstrapped within the WordPress ecosystem. This sounds like a mouthful, but it’s a fairly straight forward concept. Let’s suppose you have a requirement, where you need to run a PHP script as a one off, or even regularly as a cron job (let’s forgot about WP cron for a moment). The specifc use-case I find arising again and again, is where I need to import data from another source into WordPress. Perhaps the data I’m getting is in a really weird format, from a legacy system, needs to go into a custom system, or a host of other reasons why imports may not already exist for your use-case.… Read the rest

Contact Form 7 – Editing email output of tags

Have you ever needed to make small changes to the output that Contact Form 7 creates for emails? Change a certain word, replace certain characters, etc.? Well here’s the solution:

add_filter('wpcf7_mail_tag_replaced', tag_replace_function(), 10, 3);

Now, this is not a perfect solution, it’s fairly brutish in fact. CF7 did not see it fit to provide you with many avenues for editing the mail output. This filter only provides you with the following information:

  • The replaced text ($replaced)
  • The original values ($submitted)
  • Whether or not is it HTML ($html)

Using this information you can’t do a whole lot, unless you want some really broad changes.… Read the rest

Development Processes – Making WP Config Generic

My Process

When developing a site it’s good to have levels of separation between your development environment and a live production server. I normally have three levels when creating a site:

  1. Development
    • This server is mine, I can do what I want on it and destroy what I please. Clients and users will have absolutely no visibility of it. There will be frequent changes of varying size and complexity.
  2. QA
    • This is where clients start to come in. Using this server they can view major versions that I release from Development when they are ready. This should be a stable server but will have well controlled occasional changes.
Read the rest

Renaming a theme and its folder

Considerations

Sometimes you are going to want to rename a Theme. Maybe you’re utilising a free theme to base your development work on. Perhaps you’ve just done a huge rewrite on an existing theme. Or even you just think your theme needs a new name. If you want to modify your theme you may as well do a thorough job, as there are some annoyances that’ll show if you don’t. Below I’ve included the considerations you’ll need to account for:

  • WordPress Admin – Appearance -> Themes
    • The theme selector – all of the theme information will be displayed here. You’ll also receive update notifications for themes here.
Read the rest

Character Encoding Woes

Recently I’ve been plagued with character encoding issues everywhere I go. Inevitably people just do not plan for special characters on their website. English does not generally use them, so it can often slip the mind of developers. Unfortunately special characters are extremely important and if you do not cater for them your website can look unprofessional or just plain bad. This is especially true if you have a team of editors working on your site to provide content – content copied from word processors/publishing software can unintentionally contain special characters such as curly quotes ( ‘ ’ “ ” ) and long dashes ( — ).… Read the rest