Tag Info

Hot answers tagged

6

TL;DR There is no JavaScript API in the WordPress core and no one is planned, but actually, there is no need of it. Backend First of all let's say that, regarding the backend, some useful information can be fetched from already present JavaScript global variables (WordPress loves all global flavors). E.g. ajaxurl for the admin-ajax.php url to be used ...


4

There has been quite a bit of development around the JSON REST API that is supposed to be merged into the 4.1 release. I believe it's officially going to be called the 'WP API'. You can begin using the codebase now and keep up with the latest developments here until it gets to core. Ryan McCue and team have fleshed out some pretty good documentation here.


3

While historically WP has been backā€“end centric, there had been declaration made for years now about moving towards heavy JS use. With backwards compatibility commitments in mind it is questionable that JS will achieve parity or take over PHP any time soon (in my opinion), but there had been some progress on it. The WordPress admin now ships with Backbone ...


2

To answer your statement: [...] there is no built-in Javascript API for Wordpress. Therefore developers who want to build on Ajax seem to come up all with their own solution which doesn't seem right to me. There is no "own solution" to be done. You can ease things by using ATP with ajax_template_part() by @G.M. or similar plugins and take a short cut, ...


1

With a couple minor modifications, I was able to run your function with your desired outcome (sitewide except on single post/cpt pages & in admin area). The current preferred method of returning the stylesheet uri is with the get_stylesheet_directory_uri(), not by using get_bloginfo('stylesheet_directory'): From the WordPress Codex Function ...


1

the_content filter is (most likely) running long after you scripts were output. You need to either: Run localize logic earlier. Enqueue scripts for footer, using respective wp_enqueue_script() argument.


1

<script>YOUR CUSTOM JS CODE</script> inline does the same exact thing as YOUR CUSTOM JS CODE placed in a js file. I see no problem with the use of your app key in a js file. There is a few points to consider here though If your script is dependent on the main jquery library, just remember to set the $deps when you enqueue your script, ...



Only top voted, non community-wiki answers of a minimum length are eligible