Search Over 30,000 FREE Plugins from the Official WordPress Plugin Directory Repository

JSM's file_get_contents() Shortcode

A WordPress shortcode for PHP's file_get_contents() function.

A WordPress shortcode for PHP's file_get_contents() function.

Shortcode Attributes

  • url = http, https, or file URI.
  • file = path to a local file (relative to the wp-content/ folder).
  • cache = number of seconds to cache the content in the transient cache (defaults is 3600 seconds).
  • pre = wrap the content in <pre></pre> HTML tags (default is false).
  • class = wrap the content in the specified div class (default is none).
  • filter = apply the specified filter to the content (default is none).
  • more = add more link on non-singular web pages (default is true).
  • body = keep only the content between <body></body> HTML tags (default is true).

All file paths are relative to the wp-content/ folder — you cannot include files outside of the wp-content/ folder. For example, the shortcode attributes url="file://dir/file.html" and file="/dir/file.html" are read as wordpress/wp-contents/dir/file.html. The .. folder name is removed from file paths to prevent backing out of the wp-content/ folder.

Shortcode Name

The WPFGC_SHORTCODE_NAME constant can be defined in your wp-config.php file to change the default shortcode name (the default shortcode name is 'wp-file-get-contents').

define( 'WPFGC_SHORTCODE_NAME', 'wpfgc' );

Shortcode Examples

[wp-file-get-contents url="http://example.com/dir/file.html"]
[wp-file-get-contents url="http://example.com/counter/" cache="7200"]
[wp-file-get-contents url="file://dir/file.html"]
[wp-file-get-contents file="/dir/file.txt" pre="true" filter="my_custom_filters" cache="600"]
Author JS Morisset
Profile
Contributors jsmoriss
Tags body, content, file, file_get_contents, include, shortcode, url

Automated Install

  1. Go to the wp-admin/ section of your website.
  2. Select the Plugins menu item.
  3. Select the Add New sub-menu item.
  4. In the Search box, enter the plugin name.
  5. Click the Search Plugins button.
  6. Click the Install Now link for the plugin.
  7. Click the Activate Plugin link.

Semi-Automated Install

  1. Download the plugin archive file.
  2. Go to the wp-admin/ section of your website.
  3. Select the Plugins menu item.
  4. Select the Add New sub-menu item.
  5. Click on Upload link (just under the Install Plugins page title).
  6. Click the Browse... button.
  7. Navigate your local folders / directories and choose the zip file you downloaded previously.
  8. Click on the Install Now button.
  9. Click the Activate Plugin link.

Repositories

Version Numbering Scheme

Version components: {major}.{minor}.{bugfix}-{stage}{level}

  • {major} = Major code changes / re-writes or significant feature changes.
  • {minor} = New features / options were added or improved.
  • {bugfix} = Bugfixes or minor improvements.
  • {stage}{level} = dev < a (alpha) < b (beta) < rc (release candidate) < # (production).

Note that the production stage level can be incremented on occasion for simple text revisions and/or translation updates. See PHP's version_compare() documentation for additional information on "PHP-standardized" version numbering.

Changelog / Release Notes

Version 1.4.1-1 (2016/12/23)

  • New Features
    • None
  • Improvements
    • None
  • Bugfixes
    • None
  • Developer Notes
    • Maintenance release - minor refactoring of code.
    • Renamed the wpfgc class to WPFGC.

Version 1.4.0-1 (2016/10/25)

  • New Features
    • None
  • Improvements
    • Added the 'body' shortcode argument to keep only the content between <body></body> HTML tags (default is true).
  • Bugfixes
    • Fixed cache clearing on post save when the content starts with the shortcode (position 0 of the content text).
  • Developer Notes
    • None

Version 1.3.0-1 (2016/08/24)

  • New Features
    • None
  • Improvements
    • Added a save_post() action to clear the cached content.
  • Bugfixes
    • None
  • Developer Notes
    • None

Version 1.2.0 (2016/02/06)

  • New Features
    • None
  • Improvements
    • Added support for a WPFGC_SHORTCODE_NAME constant to change the default shortcode name.
  • Bugfixes
    • None
  • Developer Notes
    • None

Frequently Asked Questions

  • None

Other Notes

Additional Documentation

  • None
Share  
Download
Version 1.4.1-1

Requires WordPress version: 3.8 or higher

Compatible up to: 4.7.2

Last Updated 03 Feb 2017

Date Added: 22 Jun 2014

Plugin Homepage

Evaluation
star1
star2
star3
star4
star5

0 stars
0 ratings
2,098 downloads

Compatibility

Not Enough Data

Reports:
Works: 0
Broken: 0