WordPress.org

Plugin Directory

Test out the new Plugin Directory and let us know what you think.

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

Requires: 3.8 or higher
Compatible up to: 4.7.2
Last Updated: 3 weeks ago
Active Installs: 100+

Ratings

0 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1
100,1,1