Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit 6a77c40

Browse files
Add latest client js including minified version
* Development happening at https://github.com/WP-API/client-js Full changeset: WP-API/client-js@22b1e42...477a49f Props: @delphinus35, @adamsilverstein, @westonruter Change highlights: * Api builds models and collections from Schema, no hard coded models or collections; any endpoint in the schema will be mapped; supports multiple schemas (apis); helper methods for post model: all helpers user _embed data if available, otherwise using ajax request. * new: Async load of api, apps can use the deferred to time startup * new: Ability to localize schema, falls back to making an ajax request & cached in session storage; develop branch of client js has code that only localizes data once per session * new Helper methods for Posts model: getCategories and setCategories * fix: cleanup TimeStampedMixin * new: models/collections get defaults and options from schema * fix: all code up to WordPress JavaScript coding standards * new: helper method to get post author user model `getAuthorUser` * new: helper method to get a featured image for a post: `getFeaturedImage` * new: models protect methods based on endpoint methods (eg. destory is blocked if an endpoint doesn't have a 'DELETE' method) * new: models contain a reference to the original route object * Ensure getters always return promise * Add remapping for names, see WP-API/client-js#75 * additional helpers: add getMeta, getTags, getRevisions #76 * When SCRIPT_DEBUG off, use minified script; update localized data
1 parent 7573f8a commit 6a77c40

File tree

4 files changed

+915
-646
lines changed

4 files changed

+915
-646
lines changed

extras.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919
* @see wp_register_scripts()
2020
*/
2121
function rest_register_scripts() {
22-
wp_register_script( 'wp-api', plugins_url( 'wp-api.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore' ), '1.1', true );
2322

24-
$settings = array( 'root' => esc_url_raw( get_rest_url() ), 'nonce' => wp_create_nonce( 'wp_rest' ) );
25-
wp_localize_script( 'wp-api', 'WP_API_Settings', $settings );
23+
// Use minified scripts if SCRIPT_DEBUG is not on.
24+
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
25+
26+
wp_register_script( 'wp-api', plugins_url( 'wp-api' . $suffix . '.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore' ), '1.1', true );
27+
28+
$settings = array(
29+
'root' => esc_url_raw( get_rest_url() ),
30+
'nonce' => wp_create_nonce( 'wp_rest' ),
31+
'versionString' => 'wp/v2/',
32+
);
33+
wp_localize_script( 'wp-api', 'wpApiSettings', $settings );
2634
}
2735

2836
/**

0 commit comments

Comments
 (0)