Cordova project to read wordpress blog and generate a cross platform mobile app.
As you can see, the names and references, it's always about recipes. It's because we use this repo to build the mobile app for the blog Begin Vegan Begun™
- Install Cordova, dependencies, etc. (Don't worry! It's "fun")
- Cordova plugins needed:
- cordova-plugin-dialogs 1.2.0 "Notification"
- cordova-plugin-whitelist 1.2.0 "Whitelist"
- org.apache.cordova.device 0.3.0 "Device"
- Install the Wordpress API plugin in your blog. WP Rest API.
- Add CORS headers to API. Go to file
rest-api/core/wp-includes/rest-api/rest-functions.php
and set:
header( 'Access-Control-Allow-Headers: accept, access-control-allow-headers, access-control-allow-origin' );
header( 'Access-Control-Allow-Origin: *' );
- Allow query post by date in the API. We need this info in the app. Go to file
rest-api/core/wp-includes/functions.php
and add:
function my_rest_query_vars( $valid_vars ) {
$valid_vars = array_merge( $valid_vars, array( 'date_query' ) );
return $valid_vars;
}
add_filter( 'rest_query_vars', 'my_rest_query_vars' );
- Add tags and categories to post controller in order to get it in the JSON response. Go to file
rest-api/core/wp-includes/rest-api/class-wp-rest-posts-controller.php
, then go to functionprepare_item_for_response
and add to the array the following entries:
'tags' => wp_get_post_tags($post->ID),
'categories' => wp_get_object_terms($post->ID, 'category'),
- Configure settings.js
- Be careful and remember to change each reference to Begin Vegan Begun™ to your blog's name. Begin Vegan Begun™ is a trade mark.
- Add the platforms you want by
cordova platform add [platform]
and configure them as you wish. - Run
cordova build [platform]
- Have fun!
You can take a look at the application that I made with this proyect. It's published in the Play Store and iTunes (soon).
-
Push notifications
I'm working in a parallel project (Pushificator) to send push notifications to a mobiles from a web app. Once I get this project finished I'm going to add in this project functionality to register the devices in that web app, vía API. And then send the notifications :)
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Enol Iglesias Lorenzo (undefinedmethod.com)
WP Reader is released under the MIT License.
Begin Vegan Begun™ is a trade mark.