JSM’s file_get_contents() Shortcode


  • Plugin Name: JSM's file_get_contents() Shortcode
  • Stable Version: 1.5.0
  • Author: JS Morisset
  • Description: A WordPress shortcode for PHP's file_get_contents() function.
  • License: GPLv3
  • Requires At Least: WordPress 3.8
  • Tested Up To: WordPress 5.2.1
  • Last Updated: 12 hours ago
  • Plugin Homepage »

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').

Shortcode Examples