In the original release of Building Web Apps with WordPress, our chapter on localization included a section on localizing non-string assets. At the time, it seemed appropriate to include this information in case you needed to swap out images, text files, or html templates based on the chosen language. However, in practice, we almost never need to do this on the apps we’re building nowadays. Images rarely include text or other material to be translated. Instead of a folder full of .html files, templates are more often full on .php files or reference strings declared in other php files. Modern WordPress programming, even on the design side, expects a multidisciplined developer capable of editing .php files full of localized strings.

Further, our use of load_textdomain() over load_plugin_textdomain() and load_theme_textdomain() confused other plugins and tools that expect all properly localized plugins and themes to use one of those variants. The custom code we came up with to load the text domain with support for an assets folder turn out to be too clever.

We’ve decided to remove the section on localizing non-string assets from the second revision of the book. While localizing non-string assets hasn’t become as common a requirement as we once thought, the code and information below might be useful to developers who need to load the text domain in a similar way.

(more…)

Tom McFarlin has been maintaining an awesome WordPress Plugin Boilerplate for some time now. It’s a really good start for plugins that need a bit more structure to them and has things organized in a similar way to what we recommend in the book.

Tom just posted an update on the boilerplate on his blog and is asking for others to get involved.

To that end, we need help testing and reviewing the current version of the plugin. So if you’re a WordPress plugin developer who is familiar with the WordPress Coding Standards, the Documentation Standards, and who prefers an object-oriented approach to plugin development, then please check out the develop branch on GitHub.

Frontend frameworks are useful collections of code and assets that speed up and standardize the development of the frontend of your web apps. Two popular frontend frameworks are Bootstrap and Foundation. In the book, we offer an example of how you would include Boostrap into your WordPress theme.

Here is similar code to use Foundation in your theme. First, download the Foundation library from their website and place it into a /foundation/ folder in your theme. Then add the following code to the functions.php of your theme.

This will get the Foundation code and assets loaded into your theme. From here, you’ll have to follow their docs for how to actually start using their grid, CSS classes, and widgets in your theme.

I’m going to talking at the Philly Burbs Meetup tonight. If you are anywhere near Phoenixville, PA you should come. If you are anywhere near the Philly suburbs, you should join the burbs meetup group.

What am I going to be talking about? Building Web Apps with WordPress of course! I’m going to use this blog post to organize my notes.

Apps vs Websites

Websites with the following are more “appy”:

  1. Interactive elements.
  2. Tasks rather than content.
  3. Logins.
  4. Device capabilities.
  5. Offline use.
  6. Mashups.

Why use WordPress?

  1. You are already using WordPress.
  2. CMS
  3. User management.
  4. Plugins.
  5. Flexibility
  6. Security
  7. Cost

Using WordPress to Launch a “Lean” Business

The Lean Startup by Eric Ries summarized:

  1. Launch a minimal viable product (MVP) early.
  2. Experiment often.
  3. Iterate quickly.

With WordPress:

  1. One pager to announce product.
  2. Gather email addresses. (MVP)
  3. Add static pages.
  4. Add a blog.
  5. Add forums.
  6. Paid Memberships Pro to GET PAID.
  7. Build app into site, instant users.
  8. AppPresser for native mobile apps.

But but but… scaling

  • People talk about scaling too early.
  • Throwing money at hardware is okay.
  • Optimize your server.
  • Cache smartly.
  • Custom tables.
  • Bypass WordPress.

schoolpress_screenSee the site in action at schoolpress.me.

See the source code and docs on GitHub.

Some important notes.

  1. The site is in beta and will have issues. Point them out for me in the issue tracker in GitHub and help us work on them.
  2. Please only post true classes you intend to run at open.schoolpress.me. If you are just testing, use testschool.schoolpress.me.
  3. To deter spam, new classes won’t show up on the homepage or in the browse/search immediately. I have to enable this per class by hand. I may charge a small fee for open classes at some point in the future as well depending on what kind of spam bots we run into.

Going forward.

There are some obvious things that need to be completed (the code around submissions for assignments from the book for one), but remember that this isn’t an active project for me (yet anyway). It’s a demo we imagined up to showcase some of the ideas from the book. There is a lot going on and some really cool learning opportunities in the existing code and in the code that can be done going forward. I’m planning on blogging about the process on the site here.

The Building Web Apps with WordPress Class

The class I posted on the site is real. Sign up now. I may have to close signups at some point, but it is open for now and completely free. Starting in September, we’ll be tackling a couple chapters of BWAWWP each week, using the SchoolPress app as an example. Many readers of the book wish that BWAWWP was more of a step by step “how to build a WordPress app” book. We didn’t want to write the book that way, but I do believe that this class and some of the stuff that will come out of it will fill that need for people who are looking for that kind of experience.

Why did this take so long?

When we started writing the book, we thought up SchoolPress as an example app that we could use to help make the examples more concrete. We always intended on building the SchoolPress site, running it, and sharing the source code from it. As we got into the writing of the book we learned (1) that writing a book takes a lot of time and (2) an example from SchoolPress wasn’t always the best way to explain a concept. We ended up picking our examples based on what would help explain the topics we were writing about rather than having every example based on SchoolPress. And so we didn’t need a fully functional SchoolPress to finish writing the book, and we focused our time on the book itself.

We still had time to finish SchoolPress up before the books release, but didn’t hit that deadline obviously. Both Brian and I have small children, run startup companies, have many side projects, and generally are busier than we should be.

Excuses out of the way, I’m really sorry that we didn’t get SchoolPress launched earlier. I was honestly a little surprised in the interest in SchoolPress (how about the 450 page book?), but have come to respect why people want to and need to see that site to better appreciate the book.

Like any good project, SchoolPress was released behind schedule but still earlier than I am comfortable with. There is work to do to make it a good application and also general framework for building SchoolPress like sites. As I work through the project and share the challenges and interesting bits of development that come up, I’m sure I’ll have lots of great content to share here for people interested in building web apps with WordPress.

Thanks!

WDS hasn’t done a giveaway for a while now and we think it’s time to get one going. This time, we are giving away copies of Brian Messenlehner and Jason Coleman‘s recently published book — Building Web Apps with WordPress! If you’re unfamiliar with the book, here’s a quick overview:51gOTZ2xI0L

WordPress is much more than a blogging platform. As this practical guide clearly demonstrates, you can use WordPress to build web apps of any type—not mere content sites, but full-blown apps for specific tasks. If you have PHP experience with a smattering of HTML, CSS, and JavaScript, you’ll learn how to use WordPress plugins and themes to develop fast, scalable, and secure web apps, native mobile apps, web services, and even a network of multiple WordPress sites.

We are giving away 5 digital copies of the book, but we are also giving away 1 hard copy of the book that will be signed by Brian Messenlehner!

So, how do you win this giveaway?

In order to win one of these books, we are asking that you comment on this post with your idea of a web app powered by WordPress. Along with the idea of your app, we want to know what it would be used for and how it would benefit your WordPress site or someone else’s. It can be an idea of an app for yourself or an idea that will help the WordPress community as a whole.

How will we decide who wins?

After the deadline for the giveaway, the team as a whole will look over all of your impressive ideas. The most creative app idea will win the signed hard copy of the book. The remaining 5 digital copies will be given away to those who also have awesome ideas for a web app powered by WordPress.

Rules of the giveaway:

  • The giveaway starts today, May 21st at 12PM EST and ends Tuesday, May 27th at 1PM EST.
  • All entries must be in by 1PM EST on the 27th. Anything entered after that time will be appreciated, but will not be counted.
  • Employees of WDS and family members are welcome to participate in the giveaway but will not win a copy of the book.
  • You must comment on this post with your name, email address, and twitter handle.
  • We will announce the winner of the giveaway on Tuesday, May 27th at 4PM EST.

We look forward to seeing all of your amazing ideas for web apps powered by WordPress. Be sure to follow us on Twitter to keep updated with the giveaway and to find out the winners on the 27th!

Found Art is a series where we take real code from the wild (usually from open source projects) and use it to demonstrate different programming techniques in WordPress.

Chapter 10 of Building Web Apps with WordPress is all about the built in XMLRPC API for WordPress. We didn’t have time to get to it in the book, but WordPress makes it very easy to add your own methods to be called through the XMLRPC API.

A good example of this are the methods added by Paid Memberships Pro which allow API users to query for the membership level for a particular user and also to test if a user has access to a particular post. These calls have been used to develop single sign on solutions between a PMPro-powered WordPress site and other non-WordPress apps.

All of this code can be found in the /includes/xmlrpc.php file of the Paid Memberships Pro plugin. I’ve also broken out the code into sections so you can browse it here.

First, we add our methods to the WordPress XMLRPC API. Each method points to a callback function to handle it.

Then we write the callback function for the pmpro.getMembershipLevelForUser method call.

And finally, the callback function for the pmpro.hasMembershipAccess method call.

Notice that each callback function has a single parameter $args passed into it, which is an array of all of the arguments passed to the method via the XMLRPC call. The first two arguments will always be the username and password being used to access the API. The other parameters will come after. You should document and expect the arguments to be passed into the method in a certain order. In the pmpro.getMembershipLevelForUser method, the 3rd ($args[2]) parameter is the ID of the user to get a membership level for.

The actually callback function pmpro_xmlrpc_getMembershipLevelForUser() simply checks that the user calling is an admin or has the pmpro_xmlrpc capability and then passes the 3rd user_id parameter to the pmpro_getMembershipLevelForUser() function and returns the result, which is going to be serialized and delivered via the API. In this case, the pmpro_getMembershipLevelForUser() will return false for non-members and an object containing the membership level data for members.

With this API in place, you can make a call to the method using code like this in a WordPress app. If you place this code into a custom plugin or your theme’s functions.php file, it will load the XMLRPC class bundled with WordPress and make a call to a remote site where Paid Memberships Pro is activated and the PMPro methods are available. To test this out, make sure you update the remote url, username, password, and remote_user_id in the sample code and then navigate to “/?test=1” on the site you installed the code on. Notice that this is just a test. In the real world, this code would be part of a larger plugin or app and you would obviously do something with the level data returned instead of just halting output.

I hope this shows how easy it is to add your own API methods to WordPress. I know I was very surprised at how quickly I was able to add the method to Paid Memberships Pro when I finally got down to it.

If you want to see more examples like this, with great explanation of the inner workings of WordPress, be sure to pick up our book Building Web Apps with WordPress.

Macworld iWorld 2014

MacWorld/iWorld is the dream of Apple fans everywhere. A 3 day conference full of all things Apple, including the “6 About To Break” competition. The “6 About To Break” is a competition of the top 6 most innovative apps, accessories, software, and utilities that are going to be making waves in the Apple Marketplace.

WDS is excited about this competition — why? AppPresser has taken 1 of those 6 spots! All of the creators of these amazing products, in true Apple fashion, will have the chance at MacWorld to have a 5 minute demonstration and a 5 minute Q&A about their product. AppPresser co-founders, Brian Messenlehner and Scott Bolinger will be attending MacWorld to make the presentation. This showdown is happening on Thursday, March 27th from 4:30-5:30pm on the Macworld/iWorld’s Second Stage. After all the presentations have been made, a panel of experts will make the decision on who will be the winner.

Along with being in the “6 About To Break”, AppPresser will also have a kiosk throughout the event where you can ask questions and check it out! You can get more details about AppPresser at MacWorld/iWorld 2014 on their blog.

Good Luck, AppPresser!