wp-file-get-contents

JSM's file_get_contents() Shortcode

View the Project on GitHub jsmoriss/wp-file-get-contents

JSM's file_get_contents() Shortcode

Plugin NameJSM's file_get_contents() Shortcode
SummaryA safe and reliable WordPress shortcode for PHP's file_get_contents() function.
Stable Version2.3.0
Requires PHP7.0 or newer
Requires WordPress5.0 or newer
Tested Up To WordPress5.8
Contributorsjsmoriss
LicenseGPLv3
Tags / Keywordsfile_get_contents, shortcode, include, file, url, body, content

Description

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

Shortcode Attributes

Note that all local file paths are relative to the wp-content/ folder - you cannot include files outside the wp-content/ folder. For example, the shortcode attributes url="file://dir/file.html" and file="/dir/file.html" are both read as wordpress/wp-contents/dir/file.html. The .. folder name is stripped 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 add an additional custom shortcode name (the default shortcode names are 'wp-file-get-contents' and 'wpfgc').

define( 'WPFGC_SHORTCODE_NAME', 'include' );

Shortcode Examples

[wpfgc url="http://example.com/dir/file.html"]
[wpfgc url="http://example.com/counter/" cache="7200"]
[wpfgc url="file://dir/file.html"]
[wpfgc file="/dir/file.txt" pre="true" filter="my_custom_filter_name" cache="600"]

Need a Boost to your Social and Search Ranking?

Check out the WPSSO Core plugin to rank higher and improve click-through-rates by presenting your content at its best on social sites and in search results - no matter how URLs are shared, re-shared, messaged, posted, embedded, or crawled.

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 ZIP 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