JSM's file_get_contents() Shortcode

Description

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"]

Additional Documentation

  • None

Installation

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.

FAQ

Installation Instructions

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.
Frequently Asked Questions
  • None

Reviews

Read all 0 reviews

Contributors & Developers

“JSM's file_get_contents() Shortcode” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

Repositories

Version Numbering

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

  • {major} = Major structural code changes / re-writes or incompatible API changes.
  • {minor} = New functionality was added or improved in a backwards-compatible manner.
  • {bugfix} = Backwards-compatible bug fixes or small improvements.
  • {stage}.{level} = Pre-production release: dev < a (alpha) < b (beta) < rc (release candidate).

Changelog / Release Notes

Version 1.4.2 (2017/04/08)

  • New Features
    • None
  • Improvements
    • None
  • Bugfixes
    • None
  • Developer Notes
    • Maintenance release – update to version numbering scheme.
    • Dropped the package number from the production version string.