http-syndication

Description

Offering content to other sites

Allows to render the raw content of a post or page without any header or menu.

  • Use ?p=#post_id&httpsyndication
  • or ?page_id=#page_id&httpsyndication HTTP requests on your WordPress site.

Other web sites can include pages and posts contents using a web service, the [import url=..] tag of this extension, or a <iframe /> HTML tag.

The post title (enclosed in <h1> HTML tag) and the post content are exported after filtering, while all other elements (menus, etc.) are skipped.

Displaying another site page with a specific banner from this site

Using the [import banner="#page_id" url="#external_url"]#link-text[/import] shortcode allows to display another site page in an iframe, with a banner from this site sitting on top of the external page.

Inside the [import ..] shortcode, the following options allows to adjust the behavior.

  • header=false : in order to include or not the usual site header().php on the top of the banner

  • height=1000 : in order to adjust the height of the frame for very long external pages.

  • newtab=1 : in order to open the page and banner in a new browser window.

  • style="border:none;" : in order to adjust the height of the frame for very long external pages.

Including content from other sites

On the reverse, using the [import url="#external_resource_location"] shortcode allows to include the content of another sites in the current content.

Inside the [import ..] shortcode, the following options allows syndication from sites offering content:

  • httpsyndication=1 : adds the ?httpsyndication query to the URL, in order to properly syndicate sites with this plugin activated.

  • mediawiki=1 : adds the ?printable=yes&action=render query to the URL, in order to properly syndicate mediawiki sites.

The following additional options are available:

  • body=1 : in order to only import the <body..>..</body> part of the <html><head>..</head><body..>..</body></html> page.

  • noscript=1 : in order to delete all <script..>..</script> parts, avoiding any active JavaScript running from the imported HTML.

  • raw_href=1 : in order to provide raw href values, instead of properly relocating relative href in the source HTML code, as done by default.

  • Content filtering:

    • tag_name=#name : only extract the content of all tags of the given name, i.e. the <#name ..>..</#name> part (for code safety only 100 tags can be extracted).
    • tag_id=#id : only extract the content of the 1st tag of the given id, i.e. the <#tag id="#id">..</#tag> part, where #tag is any tag (e.g., div, span, ..).
    • tag_class=#class : only extract the content of the 1st tag of the given class, i.e. the <#tag class="#class">..</#tag> part, where #tag is any tag (e.g., div, span, ..).
    • style=#style or class=#class allows to add a customized class or style attribute to the tag.

Example :

  • [import url="http://localhost/wordpress/?cat=4687" tag_id="content" style="width:100%"] allows to import a category rendering with another page.

Remarks:

  1. The value of a shortcode option, e.g. body=1 for the option body, is irrelevant: Only the fact that the option is defined matters.
  2. If the external content can not be read, an error message is produced in the page output.
  3. This functionality requires the allow_url_fopen option to be validated in the PHP configuration, otherwise an error message is produced in the page output.

Including content from this site

  • Using the [import id="#post_or_page_id" ] shortcode, allows to include the filtered content of another post or page in the current content. A filtered copy is performed.

  • Using the [import id="#post_or_page_id" content=1] shortcode, allows to include the unfiltered content of another post or page in the current content. A raw copy is performed: shortcode are expanded, but content filters are not applied.

Especially useful to avoid spurious import, e.g. of social media buttons (contrary to usual include plugins).

  • Using the [import id="#post_or_page_id" title=1] shortcode, allows to include the title of another post or page in the current content.

Shortcode recursion is managed (i.e. stopped when an infinite loop is detected).

Refering content of this site with a tiny URL

  • Using the ?w=#id query allows to refer any page, post or archive by its numerical index.

  • Using the [import wform=1 label="#theinputlabel"] shortcode, allows to insert a small input field to switch to any page, post or archive given its numerical index.

About embed/iframe/import alternatives

  • The embed shortcode is a core WordPress feature. It can embed content from many resources via direct link.

  • Using an iframe allows to safely and obviously include any external site page in “frame”. The iframe plugin works well and properly make the job.

  • Using the present import is only the 3rd alternative. It is to be preferred when mixing both pages content is required (avoid the “frame” rigidity, allow contents to interact, ..).

About external content import properties

  • Notice that by construction the import is “dynamic”, i.e., each time the page is loaded, the external content is queried and inserted in the page. Good news, to be sure to have an updated information. Bad news, if the external web site is down or slowed down. You may consider having a cache mechanism to overcome related caveats.

  • The external HTML content is imported with its external CSS class styles. For another WordPress site, the match is expected to be good.
    If this is an exotic content management system, the situation is less obvious: Local CSS patch is likely required, or some additional content filter has to be hooked.

  • There is no way to prevent from infinite syndication loops between sites (e.g., a site with a page importing an external page that itself import the inquiring page).

  • Unless using noscript=1, the external JavaScript code is imported. Though security flaws are normally not to be expected considering usual JavaScript security rules, clearly malicious code can easily hugely perturb the page rendering.

Adding dedicated URL address filter

Functions can be hooked to define specific URL filtering before getting its content.

  • The hook is defined calling add_filter('http_syndication/url/#name', #function_name).
  • The related function is of the form function #function_name($pre_filtered_url) { .. return $post_filtered_url; }.
  • The filter is invoked using the shortcode eponymous option name, i.e. [import #name=1 url=".."].

As an example, the mediawiki options is implemented as a hook adding action=render&printable=yes to the mediawiki URL.

Adding dedicated URL content filter

Functions can be hooked to define specific URL content filtering after getting the URL content.

  • The hook is defined calling add_filter('http_syndication/content/#name', #function_name).
  • The related function is of the form function #function_name($pre_filtered_content) { .. return $post_filtered_content; }.
  • The filter is invoked using the shortcode eponymous option name, i.e. [import #name=1 content=".."].

As an example, the body options is implemented as a hook deleting what is not the <body>..</body> content.

Screenshots

  • An article shown within its WordPress context

  • The same article raw content adding &http_syndication to its URL

Installation

Manual installation

  1. Download the ZIP file.
  2. In your WordPress Dashboard -> Plugins -> Add new page choose upload plugin in .zip format via this page
  3. Browse and select the http_syndication.zip to upload
  4. Activate the plugin through the ‘Plugins’ menu in WordPress

Automatic installation

  1. In your WordPress Dashboard -> Plugins -> Add new page search for http syndication
  2. Install the plugin and activate it through the ‘Plugins’ menu in WordPress

FAQ

Any question or suggestion?

Simply contact us via http://sparticipatives.gforge.inria.fr/wp-plugins

Reviews

September 3, 2016
Thank you for this great plugin and please keep the updates coming. I followed your instructions to the letter and modified the page I was pulling the information from....and viola! With the syndicated page I used there was no other way of implementing the code. This little plugin of yours bypassed the headache...:)
Read all 2 reviews

Contributors & Developers

“http-syndication” is open source software. The following people have contributed to this plugin.

Contributors

Translate “http-syndication” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.5

Now wrap with iframe and embed
Better support of remote pages parsing

1.4

Add the refering content by tiny URL functionnality

1.3

Adapt the shortcode parsing to editor that escape ‘&’

1.2

Adding the [import banner=..] shortcode functionality.

1.1

Adding the [import ..] shortcode functionality.

Uses the monkeysuffrage/phpuri open PHP library for converting relative URLs to absolute, thanks!

1.0

Nothing special with this trivial plugin, debugged with WP_DEBUG.