making posting easy

WP Include File: a WordPress Plugin

Contributions on October 14th, 2009 5 Comments

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.

Tags: ,

5 Responses to “WP Include File: a WordPress Plugin”

  1. antony says:

    is it possible to insert a query string on the inserted file? For example something like that: [include file="media.php?var=34700"]

  2. Peter Armenti says:

    Seems very useful.. but.. how do I get other plugins and short codes to work within the include file? It seems that it ignores and types of plugins or short codes that I use in the include file. For example.. the file that I’m including is an html file (kit.html) and in that file I’m using a plugin called “WordPress Tabs Slides” in addition to another custom plugin that is called via a short tag. Is there a way I can get these to work in the included html file? Should I change it to a php file somehow or something like that? Do I have to make a call to the plugins? I’m not sure what is needed. Could you please provide some insight? Thank you very much.

    • AmberPanther says:

      You need to give the .php extension to your file so the PHP script will be executed on inclusion. The shortcodes within the included file will not work. You will have to figure out the corresponding plugin function call to the shortcode and use that instead, in the included file.

  3. Max says:

    Can this be used to run the content of say a shopping cart within the wordpress content area, or is it really only to display a single PHP page/file?
    Thanks

Leave a Reply

We stop spam together!

RSS Feed
on facebook
@twitter
footer