JSM's file_get_contents() Shortcode

설명

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

Shortcode Attributes

  • 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 = Wrap the content in the specified div class (default is none).
  • esc_html = Escape HTML characters (default is false).
  • file = Path to a local file (relative to the wp-content/ folder).
  • filter = Apply the specified filter to the content (default is none).
  • more = Add more link on non-singular web pages (default is true).
  • pre = Wrap the content in <pre></pre> HTML tags (default is false).
  • url = URL or file URI.
  • utf8 = Encode HTML entities (default is true).

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

후기

2017년 4월 12일
There are tons of uses for this but for us it is an solution for SPA automated HTML backend deployments.
모든 1 평가 읽기

기여자 & 개발자

“JSM's file_get_contents() Shortcode”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

자국어로 “JSM's file_get_contents() Shortcode”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

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

Changelog / Release Notes

Version 2.4.0 (2021/08/29)

  • New Features
    • Added the ‘esc_html’ shortcode attribute (default is false).
  • Improvements
    • Improved the creation of a unique transient cache salt string.
  • Bugfixes
    • Fixed caching of content incorrectly formatted with more link.
  • Developer Notes
    • Added a WPFGC->get_atts_salt() method.
    • Added a WPFGC->format_content() method.
  • Requires At Least
    • PHP v7.2.
    • WordPress v5.4.

Version 2.3.0 (2021/01/28)

  • New Features
    • Added the ‘utf8’ shortcode attribute (default is true).
  • Improvements
    • None.
  • Bugfixes
    • None.
  • Developer Notes
    • None.
  • Requires At Least
    • PHP v7.0.
    • WordPress v5.0.