Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sanusart/wp-js-info
Simple plug-in to allow access to some WordPress data/info from JavaScript
https://github.com/sanusart/wp-js-info
Last synced: 23 days ago
JSON representation
Simple plug-in to allow access to some WordPress data/info from JavaScript
- Host: GitHub
- URL: https://github.com/sanusart/wp-js-info
- Owner: sanusart
- License: mit
- Created: 2015-04-20T21:11:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-22T16:38:56.000Z (over 9 years ago)
- Last Synced: 2024-10-30T06:27:29.625Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wp-js-info
Access to some WordPress data/info from JavaScript
---
### About
Once installed and activated, provides access to some wordpress data/info via `window.wpJsInfo` object.
### Why?
Sometimes I need to execute some snippets of JS only on particular pages/posts.
The suggested WordPress way of passing data from PHP to JavaScript is via parameter of [wp_localize_script()](https://codex.wordpress.org/Function_Reference/wp_localize_script).
I feel this a bit hack-ish as the real intend of the function is for pass localization strings to use in Javascript.### Example
`window.wpJsInfo`
![screenshot](http://i.imgur.com/Hu29k9g.png)
`window.wpJsInfo.post`
![screenshot](http://i.imgur.com/6ljvDSI.png)
... and so on
### License
MIT
:)