Title: JSM file_get_contents() Shortcode
Author: JS Morisset
Published: <strong>22. juni, 2014</strong>
Last modified: 25. marts, 2026

---

Søg plugins

![](https://ps.w.org/wp-file-get-contents/assets/banner-772x250.jpg?rev=3167654)

![](https://ps.w.org/wp-file-get-contents/assets/icon-256x256.jpg?rev=2396826)

# JSM file_get_contents() Shortcode

 Af [JS Morisset](https://profiles.wordpress.org/jsmoriss/)

[Download](https://downloads.wordpress.org/plugin/wp-file-get-contents.2.7.1.zip)

 * [Detaljer](https://da.wordpress.org/plugins/wp-file-get-contents/#description)
 * [Vurderinger](https://da.wordpress.org/plugins/wp-file-get-contents/#reviews)
 * [Udvikling](https://da.wordpress.org/plugins/wp-file-get-contents/#developers)

 [Support](https://wordpress.org/support/plugin/wp-file-get-contents/)

## Beskrivelse

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

#### Egenskaber for genvejskode

 * body = Keep only the content between <body></body> HTML tags (default is true).
 * cache = Number of seconds to cache the contents (defaults is 3600 seconds).
 * class = Add a class to the content ‘div’ container (default is none).
 * code = Wrap the content in a <code></code> container (default is false).
 * code_class = Add a class to the ‘code’ container (default is none).
 * code_lang = Escape HTML characters, wrap the content in a <pre><code></code></
   pre> container, and add a language class to the ‘code’ container (default is 
   none).
 * esc_html = Escape HTML characters (default is false).
 * esc_html_pre_code = Escape HTML characters and wrap the content in a <pre><code
   ></code></pre> container (default is false).
 * file = Path to a local file (**relative** to the wp-content/ folder).
 * filter = Apply the named filter to the content (default is none).
 * more = Add a more link on non-singular web pages (default is true).
 * pre = Wrap the content in a <pre></pre> container (default is false).
 * pre_class = Add a class to the ‘pre’ container (default is none).
 * pre_code = Wrap the content in a <pre><code></code></pre> container (default 
   is false).
 * pre_lang = Escape HTML characters, wrap the content in a <pre><code></code></
   pre> container, and add a language class to the ‘pre’ container (default is none).
 * pre_title = Add a title to the ‘pre’ container (default is none).
 * url = URL or file URI.
 * utf8 = Encode HTML entities (default is true).

> Note that all file paths (not URLs) are **relative** 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 `url="file://dir/file.html"` and`
> file="/dir/file.html"` are both read as wordpress/wp-contents/dir/file.html. The`..`
> folder name is also 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

    ```
    &#91;wpfgc url="http://example.com/dir/file.html"&#93;

    &#91;wpfgc url="http://example.com/counter/" cache="7200"&#93;

    &#91;wpfgc url="file://dir/file.html"&#93;

    &#91;wpfgc file="/dir/file.txt" pre="true" filter="my_custom_filter_name" cache="600"&#93;

    &#91;wpfgc file="examples/example-1.php" code_lang="php"&#93;
    ```

## Anmeldelser

![](https://secure.gravatar.com/avatar/6999dbee3769844097810b7b66ccb128a55ed775ef15d42ce5bfa66a48dfb766?
s=60&d=retro&r=g)

### 󠀁[Works perfectly](https://wordpress.org/support/topic/works-perfectly-1138/)󠁿

 [avanlaningham](https://profiles.wordpress.org/avanlaningham/) 12. april, 2017

There are tons of uses for this but for us it is an solution for SPA automated HTML
backend deployments.

 [ Læs 1 anmeldelse ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/)

## Bidragsydere & udviklere

“JSM file_get_contents() Shortcode” er open source-software. Følgende personer har
bidraget til dette plugin.

Bidragsydere

 *   [ JS Morisset ](https://profiles.wordpress.org/jsmoriss/)

[Oversæt “JSM file_get_contents() Shortcode” til dit eget sprog.](https://translate.wordpress.org/projects/wp-plugins/wp-file-get-contents)

### Interesseret i udvikling?

[Gennemse koden](https://plugins.trac.wordpress.org/browser/wp-file-get-contents/),
tjek [SVN repository](https://plugins.svn.wordpress.org/wp-file-get-contents/), 
eller abonner på [udviklerloggen](https://plugins.trac.wordpress.org/log/wp-file-get-contents/)
via [RSS](https://plugins.trac.wordpress.org/log/wp-file-get-contents/?limit=100&mode=stop_on_copy&format=rss).

## Ændringslog

### Version Numbering

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

 * {major} = Major structural code changes and/or incompatible API changes (ie. 
   breaking 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).

### Repositories

 * [GitHub](https://jsmoriss.github.io/wp-file-get-contents/)
 * [WordPress.org](https://plugins.trac.wordpress.org/browser/wp-file-get-contents/)

### Changelog / Release Notes

**Version 2.7.1 (2023/12/20)**

 * **New Features**
    - None.
 * **Improvements**
    - None.
 * **Bugfixes**
    - Added `sanitize_text_field()` sanitation for file path value.
    - Added `wp_http_validate_url()` sanitation for URL value (props Erwan Le Rousseau
      @ WPScan).
 * **Developer Notes**
    - None.
 * **Requires At Least**
    - PHP v7.4.33.
    - WordPress v6.0.

## Meta

 *  Version **2.7.1**
 *  Senest opdateret **4 uger siden**
 *  Aktive installationer **300+**
 *  WordPress-version ** 6.0 eller højere **
 *  Testet op til **6.9.4**
 *  PHP-version ** 7.4.33 eller højere **
 *  Sprog
 * [English (US)](https://wordpress.org/plugins/wp-file-get-contents/)
 * Tags
 * [file](https://da.wordpress.org/plugins/tags/file/)[file_get_contents](https://da.wordpress.org/plugins/tags/file_get_contents/)
   [include](https://da.wordpress.org/plugins/tags/include/)[shortcode](https://da.wordpress.org/plugins/tags/shortcode/)
   [url](https://da.wordpress.org/plugins/tags/url/)
 *  [Avanceret visning](https://da.wordpress.org/plugins/wp-file-get-contents/advanced/)

## Bedømmelser

 5 ud af 5 stjerner.

 *  [  1 5-stjernet anmeldelse     ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/?filter=5)
 *  [  0 4-stjernet anmeldelser     ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/?filter=4)
 *  [  0 3-stjernet anmeldelser     ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/?filter=3)
 *  [  0 2-stjernet anmeldelser     ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/?filter=2)
 *  [  0 1-stjernet anmeldelser     ](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/#new-post)

[Se alle anmeldelser.](https://wordpress.org/support/plugin/wp-file-get-contents/reviews/)

## Bidragsydere

 *   [ JS Morisset ](https://profiles.wordpress.org/jsmoriss/)

## Support

Har du noget at sige? Har du brug for hjælp?

 [Vis supportforum](https://wordpress.org/support/plugin/wp-file-get-contents/)