Insert PHP - Version 1.3

Version Description

Fixed issue with str_replace() when haystack contained a slash character.

=

Download this release

Release Info

Developer webcraftic
Plugin Icon 128x128 Insert PHP
Version 1.3
Comparing to
See all releases

Version 1.3

Files changed (2) hide show
  1. insert_php.php +60 -0
  2. readme.txt +120 -0
insert_php.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Insert PHP
4
+ Plugin URI: http://www.willmaster.com/software/WPplugins/
5
+ Description: Run PHP code inserted into WordPress posts and pages.
6
+ Version: 1.3
7
+ Date: 29 September 2015
8
+ Author: Will Bontrager Software, LLC <will@willmaster.com>
9
+ Author URI: http://www.willmaster.com/contact.php
10
+ */
11
+
12
+ /*
13
+ Copyright 2012,2013,2015 Will Bontrager Software LLC (email: will@willmaster.com)
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation. A copy of the license is at
18
+ http://www.gnu.org/licenses/gpl-2.0.html
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+ */
25
+
26
+ /*
27
+ Note: This plugin requires WordPress version 3.3.1 or higher.
28
+
29
+ Information about the Insert PHP plugin can be found here:
30
+ http://www.willmaster.com/software/WPplugins/go/iphphome_iphplugin
31
+
32
+ Instructions and examples can be found here:
33
+ http://www.willmaster.com/software/WPplugins/go/iphpinstructions_iphplugin
34
+ */
35
+
36
+
37
+ if( ! function_exists('will_bontrager_insert_php') )
38
+ {
39
+
40
+ function will_bontrager_insert_php($content)
41
+ {
42
+ $will_bontrager_content = $content;
43
+ preg_match_all('!\[insert_php[^\]]*\](.*?)\[/insert_php[^\]]*\]!is',$will_bontrager_content,$will_bontrager_matches);
44
+ $will_bontrager_nummatches = count($will_bontrager_matches[0]);
45
+ for( $will_bontrager_i=0; $will_bontrager_i<$will_bontrager_nummatches; $will_bontrager_i++ )
46
+ {
47
+ ob_start();
48
+ eval($will_bontrager_matches[1][$will_bontrager_i]);
49
+ $will_bontrager_replacement = ob_get_contents();
50
+ ob_clean();
51
+ ob_end_flush();
52
+ $will_bontrager_content = preg_replace('/'.preg_quote($will_bontrager_matches[0][$will_bontrager_i],'/').'/',$will_bontrager_replacement,$will_bontrager_content,1);
53
+ }
54
+ return $will_bontrager_content;
55
+ } # function will_bontrager_insert_php()
56
+
57
+ add_filter( 'the_content', 'will_bontrager_insert_php', 9 );
58
+
59
+ } # if( ! function_exists('will_bontrager_insert_php') )
60
+ ?>
readme.txt ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Insert PHP ===
2
+ Contributors: WillBontrager
3
+ Donate link: http://www.willmaster.com/plugindonate.php
4
+ Tags: run PHP, insert PHP, insert PHP page, insert PHP post, use PHP, PHP plugin
5
+ Requires at least: 3.3.1
6
+ Tested up to: 4.3.1
7
+ Stable tag: trunk
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Run PHP code inserted into WordPress posts and pages.
12
+
13
+ == Description ==
14
+
15
+ Run PHP code inserted into WordPress posts and pages.
16
+
17
+ The PHP code is between special tags ("[insert_php]" instead of "&lt;?php" and "[/insert_php]" instead of "?&gt;").
18
+
19
+ The PHP code runs as the page is sent to the browser. Output of the PHP code is published directly onto the post or page where the PHP code between the special tags is located.
20
+
21
+ The code between the tags must be complete in and of itself. References to variables or code blocks outside the area between the tags will fail. See the "more information" URL for an explanation of this.
22
+
23
+ Examples of use:
24
+
25
+ * Publish local time (users' computer clock settings being unreliable).
26
+
27
+ * Insert output of a PHP script, or just to run a script whether or not it generates output.
28
+
29
+ * Check/manipulate cookies or other actions that JavaScript can accomplish when using JavaScript is undesirable.
30
+
31
+ More information about the Insert PHP plugin can be found here:
32
+ http://www.willmaster.com/software/WPplugins/go/iphphome_iphplugin
33
+
34
+ == Installation ==
35
+
36
+ 1. Download insert-php.zip from the "download" link on the web page where you're viewing this or from http://www.willmaster.com/download/DownloadHandlerLink.php?file=insert-php.zip (direct download link)
37
+
38
+ 1. Decompress the file contents.
39
+
40
+ 1. Upload the insert-php folder to your WordPress plugins directory (/wp-content/plugins/).
41
+
42
+ 1. Activate the Insert PHP plugin from the WordPress Dashboard.
43
+
44
+ 1. See instructions for using the plugin.
45
+
46
+ == Frequently Asked Questions ==
47
+
48
+ = How do I use this thing? =
49
+
50
+ Make a copy of the working PHP code to be used in a post or a page.
51
+
52
+ Replace "&lt;?php" on the first line with "[insert_php]". Replace "?&gt;" on the last line with "[/insert_php]".
53
+
54
+ Paste the code into your post or page.
55
+
56
+ Examples are here: http://www.willmaster.com/software/WPplugins/go/iphpinstructions_iphplugin
57
+
58
+ = Can I have more than one place with PHP code on individual posts and pages? =
59
+
60
+ Yes. I have found no limit to the number of places PHP code can be inserted into a post or page. Probably there is no WordPress software limit. There may be a server memory limit of your PHP code uses a lot of memory.
61
+
62
+ = Does the PHP output need to have paragraph and line break HTML formatting codes? =
63
+
64
+ No. HTML paragraph and line break formatting are applied to PHP output.
65
+
66
+ = Do I put the PHP code into content at the "Visual" tab or the "HTML/Text" tab? =
67
+
68
+ Use the HTML/Text tab. While the Visual tab will, sometimes, the HTML/Text tab allows working with the code without the visual formatting.
69
+
70
+ = Why can't I set cookies or do a browser redirect? =
71
+
72
+ With PHP, cookies are set in the web page header lines, before any page content is processed. Redirects, too, are done in the header lines. When PHP code is within a post or a page, all the header lines have already been sent, along with part of the content. At that point, it is too late to set cookies or redirect with PHP.
73
+
74
+ = I get a "Parse error: ..." What do I do now? =
75
+
76
+ Unless the source code of the plugin has been changed or somehow became corrupted, the parse error is likely to be in the PHP code inserted into the post or page. Example:
77
+
78
+ Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /public_html/wp331/wp-content/plugins/insert_php.php(48) : eval()'d code on line 5
79
+
80
+ Either within or at the end of the parse error message you'll find something like this:
81
+
82
+ eval()'d code on line 5
83
+
84
+ The error is on the indicated eval()'d code line number of the PHP code you are inserting ("5" in the example). At the PHP code you inserted, count down the number of lines indicated. You'll find the error at that line.
85
+
86
+ If you have PHP code inserted in more than one place, the error message may apply to any of those places. Temporarily remove or disable them, one at a time, until you determine which one the error message applies to.
87
+
88
+ If Insert PHP is used with an include() function, the include()'d file may be spawning the error message. In that case, the file name being include()'d and the line number of the error should be somewhere within the error message.
89
+
90
+ When the error is located, correct it and try again.
91
+
92
+ == Screenshots ==
93
+
94
+ No screenshots available.
95
+
96
+ == Changelog ==
97
+
98
+ = 1.0 =
99
+ First public distribution version.
100
+
101
+ = 1.1 =
102
+ Bug fix. Added ob_end_flush() and changed variable names to remove opportunity for conflict with variable names in user-provided PHP code.
103
+
104
+ = 1.2 =
105
+ Changed handling of content intended to remove conflict when Insert PHP is used within content that other plugins also handle.
106
+
107
+ = 1.3 =
108
+ Fixed issue with str_replace() when haystack contained a slash character.
109
+
110
+ == Upgrade Notice ==
111
+
112
+ = 1.1 =
113
+ Bug fix. Added ob_end_flush(); and changed variable names to remove opportunity for conflict with user-provided PHP code.
114
+
115
+ = 1.2 =
116
+ Changed handling of content.
117
+
118
+ = 1.3 =
119
+ Fixed issue with str_replace() when haystack contained a slash character.
120
+