Using WordPress as a CMS for Mobile Apps

We already know WordPress is a very good CMS for websites but with the recently introduced JSON REST API in WordPress core, things just got a lot more interesting.

With this API we are now able to use WordPress as a CMS for both a client’s website and his mobile apps which allows for greater simplicity and a one-stop backoffice for all their contents.

I’m just coming off a project now where we used this approach and there are a few key points to share:

Pros

  • Uploading Media works well;
  • Normal Posts and Pages works well;
  • Custom Post Types, Custom taxonomies works well;
  • Integrates nicely with WPML as multilingual solution making it perfect for multilingual mobile apps;

Cons

  • In every request the mobile app will have to authenticate itself by sending username/password;
  • The API is built in such a way to expose as much information about every object as possible so you might find yourself digging through a large object even if you only need one or two fields;
  • If we’re talking about an app that will have lots of users you might find yourself overloading your web server unnecessarily.

Even so I believe the positive points still largely payoff.  I’m excited as I see this project coming into live in such a short period and the insane value delivered to the client that can now update his apps from a similar backoffice to where I’m writing this post :-)

WordPress On-Line Course Goes Live

After my talk “Using WordPress to create Sites that Customers Love” over at Explorers Festival I was invited by the good folks of Eduke.me to produce an on-line course aimed at small business owners and other professionals that want to start using WordPress and learn about its great potential.

The recording took place in early December last year and when I was recording this was my audience :-)

IMG_3488

The link for the full course is below, if you register on the platform you get a free course so if you want just to check it out there is no associated cost. Click here to access the course:

http://cursos.eduke.me/curso-criar-sites-wordpress/

The course is only available in Portuguese but if you watch it I would appreciate feedback about what you most liked, what you didn’t like and how I can improve it for the future.

nm-wordpress1-430x280

One of our mission goals over at WidgiLabs is to promote and democratize the use of WordPress. This is just one of many contributions we want to make. Enjoy. 

 

Disappearing files on WordPress

Two weeks ago I started looking at a problem report where some files would disappear every night from a WordPress install.

WordPress had been upgraded from 3.7.x to 3.8 and we were seeing the following files missing:

/wp-admin/css/wp-admin.min.css
/wp-admin/css/wp-admin-rtl.min.css
/wp-includes/js/tinymce/tiny_mce.js

This caused the login page to be unstyled and the visual editor of WordPress to not work at all. Very annoying. But most annoying would be that after a reinstall the next day the problem presented itself again.

I started pursuing possibilities and ruled out the following:

  • being caused by the WordPress auto-updater (Disabled the auto-updates and it would still happen).
  • being caused by a malicious plugin or theme (Scanned them for malicious code and found nothing).
  • being caused by a WordPress cron job (Checked which ones are active and what they do and found nothing).

My best guess at the time was that this was caused by a script that connected via FTP or other port to perform these changes. So I changed the FTP password and expect to confirm or discard this possibility the next morning. Except… same thing happened again.

Some efforts later together with the sysadmin we were able to figure out the root cause of this issue. There was an anti-malware process called “maldetect” running on the machine in order to scan php files and others for suspicious infected files and for some reason this was happening to those files.

“maldetect” was sending an e-mail alert to the admin e-mail address each time it quarantines a file but those messages were being marked as Spam and inadvertently compounded the problem.

Glad to finally nailed this one.

Services based on JavaScript Code Snippets

I’ve always been somehow fascinated about those JavaScript code snippets that you insert into your website in order to activate an external service to work. Most notorious example these days is Google Analytics but they are many others such as:

  • KISSmetrics (Analytics)
  • Crazyegg (Heatmaps)
  • Mouseflow (Live Clicking)
  • Olark (Chat Widget)
  • tlk.io (Web Chat Room)
  • Translate This (Translation)

It used to be the case that inserting these JavaScript snippets into a website would case delayed page loading and the recommendation was to place them just before the body close HTML tag.

The new HTML5 “async” attribute allows that the such snippets, once triggered, run in parallel with page loading. Which is kind of awesome. It creates the same effect as adding a <script> element, but it tells the browser that the script can be loaded asynchronously. Firefox 3.6 was the first browser to officially support this new feature.

Parallel to working on WidgiLabs I’m now also involved with UserFollowUp, a service that allows sending rule-based e-mails and SMS to users. We’re starting by focusing on WordPress users, namely with a WooCommerce follow up emails extension. Studies suggest that follow up emails can reduce up to 30% of cart abandonment so we think this is a pretty awesome service to offer. Do check it out and let me know if you find it useful or if you have any questions.

WordPress as a Web Application Framework

WordPress is not a Web application framework, we know that.

But what is a framework anyway? I believe a framework should first and foremost offer you convenience and rapid development in a structured manner. WordPress started as a blog engine (a very simple one) but it is quickly evolving and with the right set of tools and techniques it can also become a quite good web application framework.

What makes WordPress great is its simplicity. But what are some of its shortcomings?

Knowing where we fall short

At WidgiLabs we have done several WordPress-based websites and we are generally very happy with them. However as we move more into the development of web applications and away from websites, WordPress poses a few problems:

  • it’s not cloud ready – although these days you can now even run WordPress on Google App Engine, it is still heavily dependent on MySQL as the database system and you’ll have trouble using cloud databases.
  • debugging is an arse – I’ve seen experts manage to have step-by-step debugging for WordPress projects but most developers are flying on print_r, var_dump and error_log.
  • no database migrations – making it hard for people to collaborate on scenarios where you have a custom database schema that evolves quickly over time.
  • no clear MVC separation – making it very easy to start mixing logic with presentation and that’s never good.

So how can one go about and use WordPress as a web framework and avoid being trapped with these problems? Here’s a list of what I’ve found helps, what can be solved and when you should stick to using something else.

Minimize the shortcomings

  • although WordPress is not cloud ready straight away from the installation package it is still possible to build very robust infrastructures where WordPress will run and handle hundreds of thousands of visitors with great speed and performance. A lot of documentation and video resources exist already on this subject and wordpress.com is the supreme example of what can be achieved (see the stats).
  • debugging has been improved quite a lot with tools such as the Developer plugin and the Debug Bar plugin. Using XDebug you can add the handy convenience of step-by-step analysis.
  • database migrations are less of a subject if you stick to using Custom Post Types and other structures that don’t involve custom database schemas evolving rapidly over time. In case you do then maybe using WordPress isn’t the best choice (or maybe someone can suggest a tool/workflow for this?)
  • As for clear separation between logic and presentation one should always use the theme guidelines and you can also use Backjone.js that now ships with the default WordPress.

Knowing what we do best

WordPress has a few things done right already and you can take advantage of them, namely:

  • updating is a breeze – it’s so fucking easy, I love it.
  • the plugin and theme architecture is great
  • the SEO – even Matt Cutts from Google has come out to admit WordPress is the best blog engine for SEO.
  • stepping into the CMS territory – with custom post types and meta fields WordPress is becoming a very good CMS.

WordPress started as just a blogging system, but has evolved to be a full content management system and so much more through the use of thousands of plugins, widgets, and themes. The roadmap for WordPress is to keep aiming at simplified publishing on the Web but it is possible that at the same time it will also provide the convenience and rapid development that we are all eager to have for web development?

What’s your take? Would you like to hear more about using WordPress as a Web Application Framework? What are the main challenges you’ve identified in using WordPress as a framework for building custom Web apps?