You got your ionic app set up but now you need to create a process to request data from your WordPress REST API server. ionic is Angular so most of the stuff you learn can be translated to Angular development. Likewise, you can use Angular 2 code in your ionic app. We won’t go into details on Providers, if you want to learn more Google a bit and you can find some more in-depth tutorials. The ionic CLI has a generate provider command that adds the files to your app. Run the following CLI command in your app folder. Replace “api” with a name you choose to specify its data type. If you are building an app that displays posts you might[…]

The WordPress REST API is a great thing. It allows WordPress data to be broken free from PHP templates. You can consume this data with other technologies. Data can be accessed from external sources. There are a couple things you might add to the API that are not included. One is caching and the other is restricting access.   WordPress REST API CACHE There is no cache out of the box. If your data isn’t updated frequently then you might want to cache the data. Someone could direct a bot to slam your API endpoints and kill your server. Caching the data will slow down database hits and the data will respond quickly. I use the WP REST API CACHE plugin. The[…]

Ionic Framework comes with lots of Angular Components. If you create custom components or html elements and then use a click handler (click)=”itemTap()” you may notice a delay if the elements are not an anchor tag or button. I’ve had some items on iOS depending on my markup and CSS that wouldn’t navigate unless I double tapped. This works well on items that are not navigation links. You get a slight performance bump. Its an easy fix, add tappable as an attribute to your element or component. Note, using anchors to navigate and buttons to execute javascript is valid html but I dislike restyling a button for various elements that have click handlers. If you don’t use the button element for clickable items then[…]

Adding pages to an ionic app is just as easy as it is to start a new app project when you use the ionic CLI. One of the core concepts of Angular 2 and ionic is developing everything in a  modular ethos. Modular ionic code will allow you to “cut and paste” app parts over and over and you can quickly build apps for clients. ionic generator CLI command creates a page and its subsequent files are placed in a folder titled the name of the page. The generate command creates an .html, .scss, and a .ts file in a root folder /pages. use a camel-casing syntax for you page name if the title is multiple words.   ionic g page myPage √[…]

ionic offers a ton of features to create a mobile app. One feature is its command line interface. This CLI sets up app development environments with a few simple commands.   Installing ionic You will need node installed, ionic uses NPM modules. Once node is installed open terminal on mac or command prompt on Windows. Enter the following command. This will install ionic globally and allow the usage of ionic commands. sudo npm install -g ionic   Creating Starter Apps After ionic is installed, enter the following command. This will create a tabs starter app. There are a few starters available from ionic. We will go over these later. This will create a new app named myAwesomeApp. Change myAwesomeApp to the name of[…]

WordPress has had no formal REST API. There is the crude XMLRPC, but we won’t go into the gory details of the past. As part of Google Summer of Code (GSOC), Ryan McCue submitted a proposal for creating a formal JSON API to be included in WordPress core and therefore available to every WordPress.org install. For those who may not know what a REST API is; it stands for Representational State Transfer. In short, it separates client from the server. Each request from any client contains all the information necessary to service the request, and session state is held in the client. There is no “official” standard for RESTful web API’s. This is because REST is an architectural style. You can use HTML, XML or[…]

WordPress has come a long way since its humble beginnings as blog software. WordPress has got through a CMS phase where custom post types were introduced. We are now seeing the software enter a platform phase. Developers are beginning to use WordPress to build SaaS services and API’s to power desktop and WordPress mobile apps. The shift from content driven CMS to data delivering pipelines over the next few years will be drastic. The WordPress Admin is currently being overhauled to take advantage of new technologies and the data driven applications model thats swept away the old website based internet. All of this is made possible by the addition of a JSON REST API. Read this companion post of a WordCamp talk, Software of[…]

The WordPress REST API does not come with any type of authentication. A lot of the API endpoints do not require authentication. If you want to do things like post content or create users you will need to be authenticated or “logged in”. If your application is on the site, loaded from the same server as the API, you can piggy back on WordPress’ auth cookies in the form of a nonce. Setting the cookie nonce using wp_localize_script(). This function formats your nonce url to the API into JSON format so its easier to use in javascript ajax. Add the code below in your plugin or perhaps the themes functions file. Then in your Application javascript (example is jQuery) you[…]

  WordPress 4.7 will include the long awaited content endpoints. These endpoints are needed to display basic content types provided by WordPress core; posts, pages etc.   You can view the REST json responses in a browser but for serious development and testing of core endpoints as well as custom endpoints its best to setup a method for api calls.   There are a few options available to do this via apps, services and browser extensions. One beautiful and simple app to do this is Insomnia.   Here’s a tutorial video of a walk through setting up Insomnia for WP-API endpoints:     Links: Insomnia WP-API Workspace file: https://gist.github.com/modemlooper/22488f5489c2513687003ee82a0e3dd1 Basic Auth plugin: https://github.com/WP-API/Basic-Auth WP-API V2 Endpoint plugin: https://wordpress.org/plugins/rest-api/ WP Core Beta Tester plugin: https://wordpress.org/plugins/wordpress-beta-tester/ WP-API[…]

When I was 13, I started to notice the other kids had nicer things than we did. You see, we were dirt poor. My mom was a single mom with 4 kids. I decided if I wanted nice things I would have to get it on my own. LIGHTBULB! We had a broken down lawnmower and I thought if I could get that mower running I could make some cash and get that Atari 2600 I desperately needed. I tore that mower apart. My mom got home and yelled “what the hell did you do?”. I shrugged it off, not like it was going to get fixed by other means. I had no idea what I was doing but I[…]