Open-sourcing Twig Anything – a comprehensive WordPress plugin to retrieve and display JSON, CSV or MySQL data – from anywhere, including from Discourse Data Explorer.
Source Code
Fork me; PRs welcome:
https://bitbucket.org/meglio/wp-twig-anything
Related topics here at Meta (disregard pricing info, it’s now FREE and OPEN SOURCE):
- Announcing WordPress plugin to display any data from Discourse
- Display Data Explorer query results in WordPress (with TwigAnything)
- "Recently joined" widget for WordPress (Illustrated Tutorial)
- "Who's online" widget in Discourse - my version
WordPress install
- Git clone the repository
- Copy folder
plugin_src
to your WordPress plugin directory - Rename
plugin_src
totwig-anything
’ - Activate the plugin in your WordPress dahsboard
Features
- Understands JSON of any complexity
- Fetches JSON from URLs (demo) or any data from your blog’s MySQL database (demo, tutorial)
- Configurable CSV (comma-separated values) reader
- Caches retrieved data locally for better performance
- Uses expired values from cache as a fallback if data source is not available
- Simple Twig syntax to output data (with syntax highlighting)
- Embed it anywhere in WordPress with using shortcodes
- Compatible with Visual Composer (demo)
- Integrates with Discourse (demo, tutorial 1, tutorial 2)
Donate
Any donations to PayPal a.andriievskyi@gmail.com will be spent on:
- hosting home page https://twiganything.com/
- further development, PR review and non-priority support
Version changelog
The current version of Twig Anything is 1.6.5
v1.6.5 2017-12-05
-
Update CodeMirror library to v. 5.32.0
(the existing bundle stopped working
for the latest Google Chrome browser version) -
Wrap
CodeMirror
library to prevent conflicts withCodeMirror
instances
loaded by other WordPress plugins or themes -
Toggle CodeMirror full screen mode by Ctrl-Enter rather than F11
(F11 has a different purpose in MacOs) -
Use
Clipboard.js
library instead of unsupported and outdatedZeroClipboard
v1.6.3 2016-03-13
- Add GET/POST selector to the URL Data Source
- Update React.js library to v. 0.14.7
v1.6.2 2016-01-23
- Make
get_post_meta()
andget_current_post_meta()
functions available in Twig Templates (example use-case)
v1.6.1 2015-08-14
- Add
{{request('var-name')}}
function to Twig templates - Add “Empty” data source that would not fetch anything and always return empty data; useful for template inheritance and use by other templates.
v1.6 2015-08-03
- Make WordPress globals available in Twig Templates through
{{ wp_globals }}
Note. From now on, accessing wpdb is only possible as {{ wp_globals.wpdb }} - Make WordPress conditionals available in Twig Templates
- Make
wp_get_current_user()
andget_current_user_meta()
functions available
in Twig Templates - Make URL Data Source accept Twig syntax in URLs, just like Twig Templates do
v1.5 2015-08-02
- Add
|json
and|json_pretty_print
filters - More extensibility points for add-on developers:
– Ability to load React.js library as a dependent script
– Control removal of line breaks from templates
– Override Twig configuration on template rendering
v1.4 2015-07-30
- Widgets support: add a custom widget named “Twig Template”
v1.3 2015-07-27
- Extensibility points for custom formats and data sources
- Update for php 5.3 compatibility (no warranties!)
v1.2 2015-07-26
- Improve the caching engine so that expired cached values can still be used as a fallback
- Add an option to configure how data errors are handled:
- Use cache or display nothing
- Use cache or display error
- Always display error
- Note. In the preview mode, errors are always displayed.
- Make the preview mode more intelligent
v1.1 2015-07-12
• Visual Composer support (demo)
v1.0 2015-07-01
• Initial release