WordPress.org

Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Remote Content Shortcode

Embed remote content into a post or page using a shortcode. Easily select and replace DOM elements.

Use the [remote_content url="http://www.example.com"] shortcode to import remotely hosted content into your posts or page using cURL. Supports HTML GET and POST, BASIC authentication, HTML entity escaping/encoding, CSS selectors and element removal, regular expression replacements, and caching.

This shortcode will let you...

  • Display the contents of a document stored in Subversion or Git repository into a post where it can then be formatted using SyntaxHighlighter.
  • Quickly integrate content from other CMS systems, for example a company intranet.
  • Control access to protected data using WordPress' permissions.
  • Select and remove DOM elements based on CSS selectors (like jQuery).
  • Find and replace text based on PHP regular expressions.
  • HTML encode the remote content.
  • Strip tags from the remote content.
  • Cache the remote content.

Usage

Attributes

[remote_content url="http://www.example.com" method="GET" timeout="10" userpwd="username:password" htmlentities="false" strip_tags="false" decode_atts="false" selector="body" remove="img" find="~domain\.com~" replace="new-domain.com" cache="true" cache_ttl="3600"]
  • url
    • the url that you want to request.
  • method=[GET| POST ]
    • the HTTP request type, defaults to GET.
  • timeout=[ 0-9...10]
    • the request timeout in seconds if it can't be fetched from the cache, defaults to 10 seconds.
  • userpwd=[**username:password **| post_meta | site_option | constant ]
    • the username and password to send for BASIC authentication. It is recommended to not set the username and password directly in the tag, as YOUR PASSWORD WILL BE PUBLICLY VISIBLE ON YOUR WEBSITE IF THIS PLUGIN IS DISABLED, and instead use one of the other options. By order of priority, if the value matches a post meta_key the meta_value is used, if it matches a site_option the option_value is used, and if it matches a constant the constant value is used, otherwise the string data is parsed as is. The format is username:password.
  • htmlentities=[false| true ]
    • if you want to HTML encode the content for display, set to true, defaults to false.
  • strip_tags=[false| true ]
    • strip all HTML tags from the response, defaults to false.
  • decode_atts=[false| true ]
    • the SyntaxHighlighter plugin will HTML encode your shortcode attributes, so attr="blah" becomes attr="blah". This fixes it to the intended value when set to true, defaults to false.
  • selector=[ CSS Selectors... ]
    • the CSS selector or comma separated list or selectors for the content you would like to display, for example div.main-content or div.this-class #this-id, defaults to the entire document.
  • remove=[ CSS Selectors... ]
    • the CSS selector or comma separated list or selectors for the content that you would like to remove from the content, for example h2.this-class or div#this-id, defaults to no replacement.
  • find=[ regex ]
    • use a PHP regular expression to find content and replace it based on the replace attribute, for example ~http://([^\.]*?)\.example\.com~, defaults to disabled.
  • replace=[ regex ]
    • the replacement text to use with the results of the find regular expression, for example https://\\1.new-domain.com, defaults to empty string replacement.
  • cache=[true| false ]
    • set to false to prevent the contents from being cached in the WP-Cache/WordPress transients, defaults to true for performance.
  • cache_ttl=[ 0-9...3600]
    • set the number of seconds to cache the results, using 0 for "as long as possible", defaults to 3600 seconds (one hour).

Shortcode Contents + POST If there is any content within the shortcode tags, it is sent as part of the request to the remote server.

[remote_content url="http://www.example.com" method="POST"]
{ json: { example: some_data } }
[/remote_content]

Requires: 2.8 or higher
Compatible up to: 4.6.1
Last Updated: 4 months ago
Active Installs: 300+

Ratings

5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
100,1,1