{"id":30224,"date":"2014-06-22T10:26:13","date_gmt":"2014-06-22T10:26:13","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-file-get-contents\/"},"modified":"2026-03-25T12:18:43","modified_gmt":"2026-03-25T12:18:43","slug":"wp-file-get-contents","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/wp-file-get-contents\/","author":9782930,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"2.7.1","stable_tag":"2.7.1","tested":"6.9.4","requires":"6.0","requires_php":"7.4.33","requires_plugins":null,"header_name":"JSM file_get_contents() Shortcode","header_author":"JS Morisset","header_description":"","assets_banners_color":"f1f1f1","last_updated":"2026-03-25 12:18:43","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/surniaulula.com\/extend\/plugins\/wp-file-get-contents\/","header_author_uri":"https:\/\/surniaulula.com\/","rating":5,"author_block_rating":0,"active_installs":300,"downloads":13438,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","changelog"],"tags":{"2.7.1":{"tag":"2.7.1","author":"jsmoriss","date":"2026-03-25 12:18:43"}},"upgrade_notice":{"2.7.1":"<p>(2023\/12\/20) Added sanitation for file path and URL values.<\/p>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"1"},"assets_icons":{"icon-128x128.jpg":{"filename":"icon-128x128.jpg","revision":2396826,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.jpg":{"filename":"icon-256x256.jpg","revision":2396826,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":3167654,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":3167654,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["2.7.1"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[260,51003,12491,80,538],"plugin_category":[43,46,59],"plugin_contributors":[79194],"plugin_business_model":[],"class_list":["post-30224","plugin","type-plugin","status-publish","hentry","plugin_tags-file","plugin_tags-file_get_contents","plugin_tags-include","plugin_tags-shortcode","plugin_tags-url","plugin_category-customization","plugin_category-editor-and-writing","plugin_category-utilities-and-tools","plugin_contributors-jsmoriss","plugin_committers-jsmoriss"],"banners":{"banner":"https:\/\/ps.w.org\/wp-file-get-contents\/assets\/banner-772x250.jpg?rev=3167654","banner_2x":"https:\/\/ps.w.org\/wp-file-get-contents\/assets\/banner-1544x500.jpg?rev=3167654","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/wp-file-get-contents\/assets\/icon-128x128.jpg?rev=2396826","icon_2x":"https:\/\/ps.w.org\/wp-file-get-contents\/assets\/icon-256x256.jpg?rev=2396826","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>A safe and reliable WordPress shortcode for PHP's file_get_contents() function.<\/p>\n\n<h4>Shortcode Attributes<\/h4>\n\n<ul>\n<li>body = Keep only the content between &lt;body&gt;&lt;\/body&gt; HTML tags (default is true).<\/li>\n<li>cache = Number of seconds to cache the contents (defaults is 3600 seconds).<\/li>\n<li>class = Add a class to the content 'div' container (default is none).<\/li>\n<li>code = Wrap the content in a &lt;code&gt;&lt;\/code&gt; container (default is false).<\/li>\n<li>code_class = Add a class to the 'code' container (default is none).<\/li>\n<li>code_lang = Escape HTML characters, wrap the content in a &lt;pre&gt;&lt;code&gt;&lt;\/code&gt;&lt;\/pre&gt; container, and add a language class to the 'code' container (default is none).<\/li>\n<li>esc_html = Escape HTML characters (default is false).<\/li>\n<li>esc_html_pre_code = Escape HTML characters and wrap the content in a &lt;pre&gt;&lt;code&gt;&lt;\/code&gt;&lt;\/pre&gt; container (default is false).<\/li>\n<li>file = Path to a local file (<strong>relative<\/strong> to the wp-content\/ folder).<\/li>\n<li>filter = Apply the named filter to the content (default is none).<\/li>\n<li>more = Add a more link on non-singular web pages (default is true).<\/li>\n<li>pre = Wrap the content in a &lt;pre&gt;&lt;\/pre&gt; container (default is false).<\/li>\n<li>pre_class = Add a class to the 'pre' container (default is none).<\/li>\n<li>pre_code = Wrap the content in a &lt;pre&gt;&lt;code&gt;&lt;\/code&gt;&lt;\/pre&gt; container (default is false).<\/li>\n<li>pre_lang = Escape HTML characters, wrap the content in a &lt;pre&gt;&lt;code&gt;&lt;\/code&gt;&lt;\/pre&gt; container, and add a language class to the 'pre' container (default is none).<\/li>\n<li>pre_title = Add a title to the 'pre' container (default is none).<\/li>\n<li>url = URL or file URI.<\/li>\n<li>utf8 = Encode HTML entities (default is true).<\/li>\n<\/ul>\n\n<blockquote>\n  <p>Note that all file paths (not URLs) are <strong>relative<\/strong> to the wp-content\/ folder. For security reasons, it is not possible to include files outside the wp-content\/ folder. As an example, the shortcode attributes <code>url=\"file:\/\/dir\/file.html\"<\/code> and <code>file=\"\/dir\/file.html\"<\/code> are both read as wordpress\/wp-contents\/dir\/file.html. The <code>..<\/code> folder name is also stripped from file paths to prevent backing out of the wp-content\/ folder.<\/p>\n<\/blockquote>\n\n<h4>Shortcode Name<\/h4>\n\n<p>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').<\/p>\n\n<pre><code>define( 'WPFGC_SHORTCODE_NAME', 'include' );\n<\/code><\/pre>\n\n<h4>Shortcode Examples<\/h4>\n\n<pre><code>&amp;#91;wpfgc url=\"http:\/\/example.com\/dir\/file.html\"&amp;#93;\n\n&amp;#91;wpfgc url=\"http:\/\/example.com\/counter\/\" cache=\"7200\"&amp;#93;\n\n&amp;#91;wpfgc url=\"file:\/\/dir\/file.html\"&amp;#93;\n\n&amp;#91;wpfgc file=\"\/dir\/file.txt\" pre=\"true\" filter=\"my_custom_filter_name\" cache=\"600\"&amp;#93;\n\n&amp;#91;wpfgc file=\"examples\/example-1.php\" code_lang=\"php\"&amp;#93;\n<\/code><\/pre>\n\n<!--section=changelog-->\n<h3>Version Numbering<\/h3>\n\n<p>Version components: <code>{major}.{minor}.{bugfix}[-{stage}.{level}]<\/code><\/p>\n\n<ul>\n<li>{major} = Major structural code changes and\/or incompatible API changes (ie. breaking changes).<\/li>\n<li>{minor} = New functionality was added or improved in a backwards-compatible manner.<\/li>\n<li>{bugfix} = Backwards-compatible bug fixes or small improvements.<\/li>\n<li>{stage}.{level} = Pre-production release: dev &lt; a (alpha) &lt; b (beta) &lt; rc (release candidate).<\/li>\n<\/ul>\n\n<h3>Repositories<\/h3>\n\n<ul>\n<li><a href=\"https:\/\/jsmoriss.github.io\/wp-file-get-contents\/\">GitHub<\/a><\/li>\n<li><a href=\"https:\/\/plugins.trac.wordpress.org\/browser\/wp-file-get-contents\/\">WordPress.org<\/a><\/li>\n<\/ul>\n\n<h3>Changelog \/ Release Notes<\/h3>\n\n<p><strong>Version 2.7.1 (2023\/12\/20)<\/strong><\/p>\n\n<ul>\n<li><strong>New Features<\/strong>\n\n<ul>\n<li>None.<\/li>\n<\/ul><\/li>\n<li><strong>Improvements<\/strong>\n\n<ul>\n<li>None.<\/li>\n<\/ul><\/li>\n<li><strong>Bugfixes<\/strong>\n\n<ul>\n<li>Added <code>sanitize_text_field()<\/code> sanitation for file path value.<\/li>\n<li>Added <code>wp_http_validate_url()<\/code> sanitation for URL value (props Erwan Le Rousseau @ WPScan).<\/li>\n<\/ul><\/li>\n<li><strong>Developer Notes<\/strong>\n\n<ul>\n<li>None.<\/li>\n<\/ul><\/li>\n<li><strong>Requires At Least<\/strong>\n\n<ul>\n<li>PHP v7.4.33.<\/li>\n<li>WordPress v6.0.<\/li>\n<\/ul><\/li>\n<\/ul>","raw_excerpt":"A safe and reliable WordPress shortcode for PHP&#039;s file_get_contents() function.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/30224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=30224"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/jsmoriss"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=30224"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=30224"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=30224"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=30224"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=30224"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=30224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}