WP Include File: a WordPress Plugin

WP Include FileWP Include File utilizes the WordPress Shortcode API to include the contents and output from PHP code located in an external file within the post content.

DOWNLOAD >>

Features

  • Advanced form security, nonce and whitelist registration of option variable to be written in the database
  • Options stored as one array in the database to minimize database cluster
  • Unregistration of option variable from whitelist on deactivation
  • On uninstall option array is removed from the database. No trail left behind
  • Functional and user-friendly options page
  • Help page build-in

Why do you need WP Include File?

WP Include File is needed because any PHP code you type within the tinyMCE will not be rendered when the post content is displayed. Hence instead of having to create templates for each specific task/post, you can just create localized specific files and just include them in the post content using WP Include File.

WP Include File Implementation in tinyMCE

Furthermore it becomes handy when applying specific styles to certain posts that are not required by the rest of the site. Just enclose the style definitions in the style tags, save it in a file and include it in the specific post using WP Include File. Hence you save on bandwidth and load times by not loading unecessary style definitions where they are not needed.

The WP Include File plugin comes with an intuitive and functional options that will have you up and running in no time.

WP Include File options page

If you want to learn more about the philosophy behind WP Include File you can read this article: Using the WordPress Shortcode API to include an external file in the post content

Invoking WP Include File using the Shortcode within the tinyMCE

WP Include File can be invoked using the Shortcode . The Shortcode accepts three attributes: file, path and masterpath. It will include the contents of the specified file at the location the Shortcode is placed within the post content.

Usage:

  1. [include file=”MyCustomFile.php”]
    This will include the contents of the file MyCustomFile.php located in the directory selected on the WP Include File Options page.
    For example:
    If you selected Site Root Directory on the Options page, the full path to the file to be included will be MyCustomFile.php
    If you selected Theme Root Directory on the Options page, the full path to the file to be included will be /MyCustomFile.php
  2. [include file=”MyCustomFile.php” path=”/MyDirectory/demos”]
    The path attribute will override any path extension specified on the WP Include File Options page. This will include the contents of the file MyCustomFile.php located in the directory /MyDirectory/demos relative to the Root directory selected on the WP Include File Options page.
    For example:
    If you selected Site Root Directory on the Options page, the full path to the file to be included will be MyDirectory/demos/MyCustomFile.php
    If you selected Theme Root Directory on the Options page, the full path to the file to be included will be /MyDirectory/demos/MyCustomFile.php
  3. [include file=”MyCustomFile.php” masterpath=”/home/SomeUser/SomeDirectory/SomeOtherDirectory/MyDirectory/demos”]
    The masterpath attribute will override all the selections on the WP Include File Options page. This will include the contents of the file MyCustomFile.php located in the directory /home/SomeUser/SomeDirectory/SomeOtherDirectory/MyDirectory/demos.
    For example:
    The full path to the file to be included will be /home/SomeUser/SomeDirectory/SomeOtherDirectory/MyDirectory/demos/MyCustomFile.php

FAQ

  1. I am using the path attribute and my file is not included.
    The first forward slash (/) should be included when declaring a path extension using the path attribute. For example path=”/MyIncludeDirectory/Content”

Version History

  • v. 1.9.10.14
    First public release.

If you have any comments or suggestions or bugs to report please leave them below. Alternatively you can use our contact form.

Leave a Reply