WordPress Plugin - Safe Include
Safe Include by Jack Born is a new Word Press plugin that is an off-shoot of my other plugin, staticJack. Both of these plugins are meant to make the job of adding static content to your Word Press blog simple, safe, and quick.
The really cool thing about Safe Include is the way in which you can write a post or page and just pop a {{placeholder}} in the body and bam… static content is added to the page or post.
If you want the static content to make up the entire post, then just use the placeholder alone. If you are using a static “block” of content (a contact form, or a short snippet of server side code) that you want to inject into the middle of a post, then this lets you do it.
Plus, this new plugin lets you go right into the code of your theme and inject static content wherever you want, in much the same way.
Easy to install and even easier to use.
If you like the code I want you to do two things
- Link back to me with a short post about the plugin
- Sign up for my update newsletter so I can announce new plugins and non-WP projects that I have in the pipeline. You’ll also get notifications about plugin updates.
17 Responses to “ WordPress Plugin - Safe Include”
Leave a Reply
Syndicate
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | Mar » | |||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
Categories
- Customer Service (1)
- Entrepreneurs (1)
- Marketing (3)
- Programming (9)
- Web Design (1)
- WordPress (5)




Tyler says:
February 9th, 2006 at 4:41 am
Nice plugin, though I had to hack it up a bit to make it work like I wanted it to. Basically, I was looking for something that would go and grab the output of any page from the safeIncludes folder instead of only html or php. This would allow me to code a page in python and include its output. If you’d like to see the changes let me know and I’ll send them to you.
Jay says:
April 21st, 2006 at 10:51 am
Just a question, If I have 10 static html pages linked all together, no header nothing just tables with contents. And want it to load in wordpress template, would this script work too? and is there anyway to make the links between my static 10 files work all around? Thank you
Jay says:
April 21st, 2006 at 11:27 am
And i got no idea why the script isnt working, i have did the main steps, installed the plugin, created the safeIncludes directory in the themes folder, placed the files in them, created a post, placed {{test1}} as my file inside the safeIncludes test1.htm and it shows nothing on the page. i am using wordpress 2.0, does you script have anything to do with the .htaccess? cause it’s weird its not working, what worked is the which we can use without any script. please can you tell me if i am missing anything? regards
Administrator says:
April 21st, 2006 at 1:45 pm
Turn debugging on:
define(’_DebugCode_’, false);/*true = show include path :: keep false unless you are debugging!*/
change to
define(’_DebugCode_’, true);/*true = show include path :: keep false unless you are debugging!*/
alby says:
June 7th, 2006 at 3:27 pm
correction
If I insert 2 files inner folder safeIncludes
so:
page1.htm
page2.php
and the setting is
AllowedSuffixes_’, ‘.php|.htm|.html’)
work only page2.php
but if I change
AllowedSuffixes_’, ‘.htm|.php|.html’)
work only page1.htm
so work only the first suffixes;
another:
in the page1.htm I not see the image (same problem
of the other your plugin static)
Administrator says:
June 8th, 2006 at 8:01 am
Changing the order of the suffixes changes the order in which the plugin looks for your pages. If you start with .htm then it first looks for a page with .htm
If it finds a page with .htm then it won’t continue searching.
The image issue can be fixed by fixing your html.
Instead of src=”image.gif”
Try src=”/dir/to/image.gif”
alby says:
June 9th, 2006 at 1:34 pm
So If I insert 2 files inner folder safeIncludes
so:
page1.htm
page2.php
and the suffix is … ‘.htm|.php|.html’)
and I have 2 link at their pages
link 1 page1, is page1 with code {{page1}}
link 2 page2, is page2 with code {{page2}}
I see only page1?
If so I can create only a list of link that can use only same extension (no mixer extension);
if is so then the correct name of
AllowedSuffixes
would to be
AllowedSuffixesOnlyOneForTime
————–
regard 2nd point
I have this
safeIncludes/page1.htm
safeIncludes/page1_file/image.gif
and the src is:
src=”page1_file/image.gif”
the link is correct:
work if I click direct ther file page1.htm;
not work with safe-include;
I have tested also url absolute
but not work.
any idea?
Administrator says:
June 10th, 2006 at 1:17 pm
Alby,
It’s generally not a good idea to suggest that I rename my constants within my code if you are looking for free help. It’s condescending — and beyond that, incorrect.
Here’s the deal:
The way my plugin is currently written, if you have “foo.htm” and “foo.php” on your server then there’s a potential name collision. To avoid the confusion, my plugin looks for files with the extensions listed in AllowedSuffixes in the order in which you list them. If you put .htm first, then it will grab foo.htm and disregard foo.php. If you put .php first, it will grab foo.php and disregard foo.htm.
Now…
If you have no name collision: you have foo.htm and bar.php on your server… then my plugin will find BOTH files.
Second point…
You should not put image files (or javascript, or css, etc etc) inside of the safeIncludes directory.
Why?
Because this is supposed to be the directory where my plugin goes looking for ‘include’ files… not images, not js, not css.
(You could make it work as you currently have it by changing your link to src=”/wp/safeIncludes/image.gif” where wp is your actual wordpress directory, whatever you are using)
I recommend you have an image folder in the public root of your server (”/images”) and you put your image files there. Then, in page1.htm you could have an image link such as src=”/image.gif”. Please note the leading slash. It’s important.
John Brackett says:
June 15th, 2006 at 6:48 pm
I used the debugging tool and received the following error. I’m using IIS6 and PHP 4.3 and all other .PHP file are readable. Any Ideas?
d:\Inetpub\vhosts\themoneyhelper.com\httpdocs\wp-content/safeIncludes/home_exerpts.php.php is iPath
d:\Inetpub\vhosts\themoneyhelper.com\httpdocs\wp-content/safeIncludes/home_exerpts.php.htm is iPath
d:\Inetpub\vhosts\themoneyhelper.com\httpdocs\wp-content/safeIncludes/home_exerpts.php.html is iPath
Lozbo says:
June 25th, 2006 at 2:41 am
Dame Jack, you don’t know how much time i wasted on trying to get a plug in like this… Thank you very much! I just don’t understand why wp is not allowing the correct (standard strict xhtml) markup for a table stay as is;
I use this structure:
table
thead
tr
th
tbody
tr
th
td
And wp keeps taking out some closing tags I dont know why. Anyway with safeInclude I manage to display it correctly. Thanks again very much!
Drew Decker says:
July 9th, 2006 at 7:29 pm
I was wondering… if I do the static pages…can i use the “pages” to do static pages…or do i have to stick with the “post” option (wordpress: write > post) ..
Also, if I have to do the “post” option, will it had my static posts…since I do use a “recent posts” plugin…and i don’t want it to display a static page as a recent post…
thanks.
paul says:
July 18th, 2006 at 1:54 am
Trying to get this working: here’s what debug says.
/opt/www/wordpress/wp-content/plugins/safeIncludes/zeitgeist.php is iPath
/opt/www/wordpress/wp-content/plugins/safeIncludes/zeitgeist.htm is iPath
/opt/www/wordpress/wp-content/plugins/safeIncludes/zeitgeist.html is iPath
the file exists:
file /opt/www/wordpress/wp-content/plugins/safeIncludes/zeitgeist.html
/opt/www/wordpress/wp-content/plugins/safeIncludes/zeitgeist.html: UTF-8 Unicode English text, with very long lines
Hmm, never mind. I added .txt to the AllowedSuffixes, changed the filename and hey presto.
Thanks, Jack.
a crank’s progress » WordPress, Pages, and php includes says:
July 18th, 2006 at 11:32 am
[…] It has been a long time coming but I finally found a way to integrate static content into WordPress’s Pages. Pages with a P are like posts but exist outside their time-based organization. […]
Todd says:
July 31st, 2006 at 10:18 am
Hi. I am trying to include the page www.iscramla.com/plogger in my wordpress layout. Will this plugin work, and if so, how?
Caroline says:
August 1st, 2006 at 8:59 pm
Hello Jack, question for you…what about pulling the blog contents onto a static web html page? Can the plug in do that? I need to dynamically replicate the headlines from the three most recent posts to the blog, on my homepage, index.html. Suggestions welcome!
Ian Heggie says:
August 17th, 2006 at 2:58 am
Plugin works well. I changed the match pattern to match only safe file names:
define('_MatchPattern_', '/{{([A-Z0-9][-\._ A-Z0-9]*)}}/iU');
Thanks again,
Ian
Ian Heggie says:
August 17th, 2006 at 3:01 am
Mmm… having justify on spaces out the code … there is only one space after the comma, and between the underline and A-Z.