Automate The Maintenance of your WordPress Blog – FREE!

A cascading waterfall, flanked by flowers.

Do you use WordPress as your blogging platform?

Are you sick of the amount of time it takes to keep the plugins up to date?

How about upgrading the core files every time WordPress issues an update?

It may not be a problem for you if you only have one blog.  But I have several blogs and maintaining them had become a major time consuming activity.  There HAD to be a better way.

The Problem

Now, I’m fully aware of various programs that are available.  Just do a search and you’ll find them yourself.  But here’s the problem with them:

  • Some only install, but don’t do the upgrading.  I’m sorry, the upgrades are what are eating my time, not the installation.  Although I’ll probably create a script to configure my blog the next time I put one up.
  • They all work with specific control panels.  At least one of the control panels I use isn’t listed.
  • There are several that look full-featured, but cost over $1,000.  Frankly, they have more than I need.

But then it struck me!  Shouldn’t we be able to script the DOM of the web page our blog is on and do everything with script that we would do by hand?

Of course!

That’s when I started searching for someone who had a solution that would let me write a script to do my updates.

Here’s what the current version does:

  • Automatically logs you into your blog
  • Looks for the upgrade link that indicates that your blog needs to be upgraded using “WordPress Automatic Upgrade
  • Runs through the upgrade process using the plugin.  Note: it DOES back up your files, but it does not download them.  You can modify the script to do that if you want.
  • Switches to the Active Plugins screen and looks for the link that indicates the plugin needs to be upgraded and runs through the upgrade.  It does this for each plugin that needs to be upgraded.

 

Here’s what you need:

function doUpgrade(userName, pswrd, domain, ftpUserName, ftpPswrd) {
    var macro;
    var upgradAutomatically;
    var doTheUpgrade1;
    var doTheUpgrade2;
    var retCode;

    // Login
    macro = "CODE:TAB T=1\nSET !TIMEOUT 240\n";
    macro += "URL GOTO=http://" + domain + "/wp-login.php\n";
    macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginform ATTR=ID:user_login CONTENT=" + userName + "\n";
    macro += "SET !ENCRYPTION NO\n";
    macro += "TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:loginform ATTR=ID:user_pass CONTENT=" + pswrd + "\n";
    macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:loginform ATTR=ID:wp-submit\n";
    iimPlay(macro);


    // Make sure the core is up to date first
    macro = "CODE:SET !TIMEOUT 240\n";
    macro += "URL GOTO=http://" + domain + "/wp-admin/plugins.php\n";
    macro += "TAG POS=1 TYPE=A ATTR=TXT:Click<SP>Here EXTRACT=TXT\n";
    iimPlay(macro);
    if (iimGetLastExtract() != "#EANF#") {
        macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:Click<SP>Here\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:click<SP>here<SP>to<SP>run<SP>the<SP>clean<SP>up<SP>process<SP>before<SP>continuing EXTRACT=TXT\n";
        iimPlay(macro);
        macro = "CODE:SET !TIMEOUT 240\n";
        if (iimGetLastExtract() == "#EANF#")
            macro += "";
        else
            macro += "TAG POS=1 TYPE=A ATTR=TXT:click<SP>here<SP>to<SP>run<SP>the<SP>clean<SP>up<SP>process<SP>before<SP>continuing\n";

        macro += "TAG POS=1 TYPE=A ATTR=TXT:Click<SP>here\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";

        iimPlay(macro);

        var testForCheck;
        var pos;
        pos = 1;
        while (true) {
            testForCheck = "CODE:SET !TIMEOUT 240\nTAG POS=" + pos + " TYPE=INPUT:CHECKBOX ATTR=NAME:other_tables[] EXTRACT=TXT\n";
            iimPlay(testForCheck)
            if (iimGetLastExtract() == "#EANF#")
                break;
            testForCheck = "CODE:SET !TIMEOUT 240\nTAG POS=" + pos + " TYPE=INPUT:CHECKBOX FORM=ACTION:* ATTR=NAME:other_tables[] CONTENT=YES"
            iimPlay(testForCheck);
            pos++;
        }

        iimPlay("CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:* ATTR=NAME:wpaudbbackup&&VALUE:Start<SP>DB<SP>Backup");

        macro = "CODE:SET !TIMEOUT 240\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:wpaunewversion ATTR=NAME:doversiondownload&&VALUE:Lets<SP>GO\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        macro += "TAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        iimPlay(macro);
        iimPlay("CODE:TAG POS=1 TYPE=A ATTR=TXT:Upgrade<SP>WordPress<SP>Database EXTRACT=TXT");
        if (iimGetLastExtract() != "#EANF#") {
            macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:Upgrade<SP>WordPress<SP>Database\n";
            macro += "TAG POS=1 TYPE=A ATTR=TXT:Continue\n";
            immPlay(macro);
            immPlay("CODE:TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:loginform ATTR=ID:user_pass EXTRACT=TXT");
            if (iimGetLastExtract() != "#EANF#") {
                macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:loginform ATTR=ID:user_pass CONTENT=" + pswrd + "\n";
                macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginform ATTR=ID:user_login CONTENT=" + userName + "\n";
                macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:loginform ATTR=ID:wp-submit\n";
            }
            iimPlay(macro);
        }
        macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\n";
        iimPlay(macro);
        iimPlay("CODE:TAG POS=1 TYPE=A ATTR=TXT:Clean<SP>up EXTRACT=TXT");
        if (iimGetLastExtract() != "#EANF#") {
            macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:Clean<SP>up\n";
        }
        else {
            macro = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:CLICK<SP>HERE\nTAG POS=1 TYPE=A ATTR=TXT:Clean<SP>up";
        }

        iimPlay(macro);
    }

    // now upgrade the plugins.

    macro = "CODE:SET !TIMEOUT 240\nURL GOTO=http://" + domain + "/wp-admin/plugins.php?plugin_status=active";
    retCode = iimPlay(macro);

    if (retCode < 0)
        alert(iimGetLastError());

    upgradAutomatically = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:upgrade<SP>automatically* EXTRACT=TXT\n";

    doTheUpgrade1 = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=A ATTR=TXT:upgrade<SP>automatically\n";
    doTheUpgrade2 = "CODE:SET !TIMEOUT 240\nTAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=ID:username CONTENT=" + ftpUserName + "\n";
    doTheUpgrade2 += "SET !ENCRYPTION NO\n";
    doTheUpgrade2 += "TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:* ATTR=ID:password CONTENT=" + ftpPswrd + "\n";
    doTheUpgrade2 += "TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=ID:hostname CONTENT=" + domain + "\n";
    doTheUpgrade2 += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:* ATTR=ID:upgrade\n";
    doTheUpgrade2 += "URL GOTO=http://" + domain + "/wp-admin/plugins.php?plugin_status=active\n";

    while (0 <= iimPlay(upgradAutomatically)) {
        if (iimGetLastExtract() == "#EANF#")
            break;
        iimPlay(doTheUpgrade1);
        iimPlay("CODE:TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=ID:hostname EXTRACT=TXT");
        if (iimGetLastExtract() != "#EANF#") {
            iimPlay(doTheUpgrade2);
        }
        else {
            iimPlay("CODE:SET !TIMEOUT 240\nURL GOTO=http://" + domain + "/wp-admin/plugins.php?plugin_status=active\n");
        }

    }


}

Put the code above in a js file in iMacros, then in a line above the function definition, call the function.

userName: Your blog username

pswrd: Your blog password

domain: Your blog domain.

ftpUserName: The username you use to ftp to your site.  This is needed for the plugin upgrade normally.  If your site doesn’t need ftp login information, you’ll need to modify the script.

ftpPswrd: the password you use to ftp to your site.

 

The script assumes that you do not need ftp login information to upgrade the blog, but may need it to upgrade the plugins.

I’ll try to keep this page updated as I make changes, but I’m not making any promises.  The script is provided as is.  You can do whatever you want with it, but you can’t sell it.  If you make some sort of embellishment to it, please let me know in the comments or by sending me a message using the “ask a question” link above.

(Last updated on 7/15/2009 to handle the option of not using ftp for plugins)

Other WordPress Resources

  • Download WordPress Automatic Blog Plugin | Cho Toan Dot Com- Automatic blogging is a best way for the bloggers haven’t enough time to blogging can make money online with Google Adsense. You can use WordPress or Blogspot to automatic blogging, but WordPress preferred and used more than Blogspot for auto … Hello. I think the article is really interesting. I am even interested in reading more. How soon will you update your blog? Toan Nguyen Minh says: June 15, 2009 at 7:50 pm. @Garryk: Hi, that great! I am update my blog everyday, …
  • Top 10 WordPress hacks from June ’09- If like me, you often display code snippets on your WordPress blog, you know how bad WordPress automatic formatting can be. Happilly, with the help from a very cool shortcode you can be able to disable it on a certain portion of text. … Yoast E-mail Update http://yoast.com/ The latest blog posts from Yoast.com.
  • DateTitle – A WordPress plugin for automatic post titles at …- DateTitle – A WordPress plugin for automatic post titles. These days I seem to be writing very little code and I do that only if I need something and I am unable to find something similar already written. Recently I shifted my journal …
  • List of the Best and Must Use WordPress Plugins | Blogging Planet- Google Analytics for WordPress – This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog. WordPress.com Stats – Tracks views, post/page views, …
  • Automate your WordPress posts on Twitter- Well, we just installed this plugin that automatically tweets your WP posts. If you do a ‘twitter’ search on the WP plugin repository, you get zillions of them, so we just shorlisted and picked the one we thought would fit our needs …
  • wordpress Plugin:Automatic Tag to Link – Linux-ist- wordpress 2.5+. It hasnot been tested in old wordpress versions, so I don’t know whether it works just right with them. I suggest you update your wordpress, not because of this plugin, believe me, wordpress2.5+ is really great. …
  • Disable WordPress automatic formatting on posts using a shortcode …- Disable WordPress automatic formatting on posts using a shortcode,If you often display code snippets on your WordPress blog, you know how bad Wor…
  • WordPress Toolbar v 2.1 – Adding support for tinyurl, sociable and …- Automatic update will do the work i guess. Or alternatively you just need to replace the toolbar.php file in the plugins/wordpress-toolbar directory. By Andy on Jun 27, 2009 | Reply. Hmm but now I have to translate again ;-)
  • WordPress update- To fix the incomplete automatic update I had to manually install the update which was a slow process given that Adobe Dreamweaver kept dropping the connection to the web server, but I got there in the end and all is well again.
  • 12 Clever Tips for Securing Your WordPress Site- Apparently a recent WordPress update allows us to move our config files for an added level of security. You can freely move the wp-config.php file up one level higher than the rest of your WordPress installation. …
  • 50+ New and Beautiful Free WordPress Themes | MisrIT Reader- Moss – Free WordPress Theme. Organic Moss – Free WordPress Theme. Details : 3 columns, right sidebar, preview image on articles wi th automatic resize, 468×60px top banner ad ready, Gravatar enabled, SEO optimized, threaded co …

Related Post

  • DotNetNuke SQL Space and the Event ViewerDotNetNuke SQL Space and the Event Viewer I've been meaning to address this topic for quite a while and now that I'm noticing a lot of my web hosting customers getting notifications about their plans using too much space, I think […]
  • Automated Web Testing with the WebBrowserControlAutomated Web Testing with the WebBrowserControl Actually, I used this technique to automate submitting information to a set of web sites, but you could use this same technique to script any web site, including one you are currently […]
  • WordPress w/ Forms Authentication on IIS6WordPress w/ Forms Authentication on IIS6 I know I said yesterday that I'd start a series about creating DotNetNuke modules, but I solved a problem yesterday after I wrote that post that I think a lot of you will be interested […]
  • The Programmers’ RevoltThe Programmers’ Revolt Every once in a while, something happens in life that makes you say, “enough!” That happened a couple of weeks ago to me and a couple other programmers working on the same project […]
  • Readable CodeReadable Code Time out today for just a bit of a rant. A couple of days ago, I posted a top ten list for why you shouldn't buy Visual Studio 2008.  Most people totally got that this was all tongue in […]

About Dave Bush

Dave Bush is a .NET programmer and Certified ScrumMaster who is passionate about managing risk as it relates to developing software. When he is not writing or speaking about topics related to Application Lifecycle Risk Management (ALRM), he is an example to his peers as he develops web sites in the ASP.NET environment using industry best practices.

One Pingback/Trackback

Awards & Certs