开发者 | ddean |
---|---|
更新时间 | 2014年7月14日 11:05 |
PHP版本: | 3.3 及以上 |
WordPress版本: | 3.5 |
[json src="http://example.com/my_data_src?format=json" key="Data.mykey"]
--> outputs contents of mykey
in the Data
object
[json src="http://example.com/my_data_src?format=json"]I want my value to appear right here {Data.mysubdata.otherKey} in the middle of my content.[/json]
--> replaces the text in {}
with contents of otherKey
in the mysubdata
object in the Data
object
Note: this plugin allows you to bring content from remote sites into your posts. Please exercise caution, especially if you allow posting by untrusted users.
Use the name
attribute to define a friendly name for your data source! The scope of this name is only the post / page you name it.
Also note that using the name
attribute more or less restricts you to the self-closing format, because of shortcode parser limitations.
[json src="http://example.com/my_data_src?format=json" name="ExampleData"]
Later in the same page...
[json name="ExampleData" key="Data.mykey"]
--> outputs contents of mykey
in the Data
object
Use the lifetime parameter! This parameter is in seconds, is per source, and should be set the same for all references to that source on a post / page for best results.
[json src="http://example.com/my_data_src?format=json" lifetime="300"]I want my value to appear right here {myData} in the middle of my content.[/json]
--> Will expire the cached data after 5 minutes.
Yes! Any output caching system will cache your post with JSON data included. However, your data will only be checked for expiration when your site builds the post, so time your cache expiration accordingly.
wp_remote_get
returned a WP_Error object