Allow PHP in Posts and Pages - Version 1.1

Version Description

  • Bug fix for the conversion of the right square bracket

=

Download this release

Release Info

Developer Hit Reach
Plugin Icon wp plugin Allow PHP in Posts and Pages
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (2) hide show
  1. README.txt +27 -6
  2. allowphp.php +6 -7
README.txt CHANGED
@@ -1,10 +1,10 @@
1
- === PHP Shortcode ===
2
Contributors: Hit Reach
3
Donate link:
4
- Tags: post, pages, posts, code, php
5
Requires at least: 2.5
6
Tested up to: 3.0.1
7
- Stable tag: 1.0
8
9
Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages
10
@@ -57,11 +57,12 @@ Will result in the output:
57
58
This plugin strips away all instances of <p> and <br /> therefore code has been added so that if you wish to use tags in your output (e.g.):
59
[php]
60
- echo "hello <br /> world";
61
[/php]
62
63
64
the < and > tags will need to be swapped for [ and ] respectively so <p> becomes [p] and </p> becomes [/p] which is converted back to <p> at runtime. these [ ] work for all tags (p, strong, em etc.).
65
[php]
66
echo "hello [br /] world";
67
[/php]
@@ -69,9 +70,29 @@ the < and > tags will need to be swapped for [ and ] respectively so <p
69
== Installation ==
70
71
1. Extract the zip file and drop the contents in the wp-content/plugins/ directory of your WordPress installation
72
- 2. Activate the Plugin from Plugins page
73
74
== Misc ==
75
Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a>
76
Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a>
77
- Version: 1.0 <a href='http://www.hitreach.co.uk/services/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support &amp; Comments</a>
1
+ === Allow PHP in Posts and Pages ===
2
Contributors: Hit Reach
3
Donate link:
4
+ Tags: post, pages, posts, code, php, shortcode,
5
Requires at least: 2.5
6
Tested up to: 3.0.1
7
+ Stable tag: 1.1
8
9
Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages
10
57
58
This plugin strips away all instances of &lt;p&gt; and &lt;br /&gt; therefore code has been added so that if you wish to use tags in your output (e.g.):
59
[php]
60
+ echo "hello <br /> world";
61
[/php]
62
63
64
the &lt; and &gt; tags will need to be swapped for [ and ] respectively so &lt;p&gt; becomes [p] and &lt;/p&gt; becomes [/p] which is converted back to &lt;p&gt; at runtime. these [ ] work for all tags (p, strong, em etc.).
65
+
66
[php]
67
echo "hello [br /] world";
68
[/php]
70
== Installation ==
71
72
1. Extract the zip file and drop the contents in the wp-content/plugins/ directory of your WordPress installation
73
+ 1. Activate the Plugin from Plugins page
74
75
== Misc ==
76
Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a>
77
+
78
Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a>
79
+
80
+ Version: 1.0 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support & Comments</a>
81
+
82
+ == Change log ==
83
+ = 1.0 =
84
+ * Initial Release
85
+ = 1.1 =
86
+ * Bug fix for the conversion of the right square bracket
87
+
88
+ == Frequently Asked Questions ==
89
+ = What Tags Are Automatically Removed? =
90
+ Currently all &lt;br /&gt; and &lt;p&gt; (and its closing counterpart) tags are removed from the input code because these are the tags that Wordpress automatically add.
91
+ = How Do I Add Tags Without Them Being Stripped? =
92
+ If you want to echo a paragraph tag or a line break, or any other tag (strong, em etc) instead of enclosing them in &lt; and &gt; tags, enclose them in [ ] brackets for example [p] instead of &lt;p&gt; The square brackets are converted after the inital tags are stripped and function as normal tags.
93
+ = Thats All Good But I want To Include A [ and ] In My Output! =
94
+ To include square brackets in your output simply add a \ before it so [ becomes \[ and ] becomes \], again these are converted and will display as [ and ]
95
+ = Can I still connect to non-wordpress databases? =
96
+ Yes you can, just use the standard mysql_connect or the mysql_pconnect and their parameters.
97
+ = My Question Is Not Answered Here! =
98
+ If your question is not listed here please look on: <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/</a> and if the answer is not listed there, just leave a comment
allowphp.php CHANGED
@@ -1,10 +1,10 @@
1
<?php
2
/*
3
Plugin Name: Allow PHP in posts and pages
4
- version: 1.0
5
Plugin URI: http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/
6
Description: Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages whilst still retaining HTML tags
7
- Author: Jamie Fraser - Hit Reach
8
Author URI: http://www.hitreach.co.uk/
9
*/
10
add_shortcode('php','php_handler');
@@ -35,11 +35,11 @@ function php_handler($args, $content=null){
35
$content = str_replace("[br/]","<br/>",$content);
36
#other tags
37
$content = str_replace("\\[","&#91;",$content);
38
- $content = str_replace("\\]","&#93",$content);
39
$content = str_replace("[","<",$content);
40
$content = str_replace("]",">",$content);
41
- $content = str_replace("&lsb;",'[',$content);
42
- $content = str_replace("&rsb;",']',$content);
43
ob_start();
44
eval ($content);
45
if($args['debug'] == 1){
@@ -48,7 +48,6 @@ function php_handler($args, $content=null){
48
}
49
$returned = ob_get_clean();
50
return $returned;
51
-
52
}
53
54
function allow_php_menu(){
@@ -60,7 +59,7 @@ function allow_php_options(){
60
<div style='float:right; display:inline; margin-left:25px; margin-bottom:10px; margin-right:15px; padding:5px; background-color:#ffffcc; border:1px solid #ddddaa;'>
61
<span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a></span>
62
<span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a></span>
63
- <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Version: 1.0 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support &amp; Comments</a></span></div>
64
65
<p>Allow PHP in posts and pages adds the functionality to include PHP in wordpress posts and pages by adding a simple shortcode <span style='color:green'>[php]</span><em>.code.</em><span style='color:green'>[/php]</span></p>
66
<p>This plugin strips away the automatically generated wordpress &lt;p&gt; and &lt;br/&gt; tags but still allows the addition of your own &lt;p&gt; and &lt;br/&gt; tags
1
<?php
2
/*
3
Plugin Name: Allow PHP in posts and pages
4
+ version: 1.1
5
Plugin URI: http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/
6
Description: Allow PHP in posts and pages allows you to add php functionality to Wordpress Posts and Pages whilst still retaining HTML tags
7
+ Author: Hit Reach
8
Author URI: http://www.hitreach.co.uk/
9
*/
10
add_shortcode('php','php_handler');
35
$content = str_replace("[br/]","<br/>",$content);
36
#other tags
37
$content = str_replace("\\[","&#91;",$content);
38
+ $content = str_replace("\\]","&#93;",$content);
39
$content = str_replace("[","<",$content);
40
$content = str_replace("]",">",$content);
41
+ $content = str_replace("&#91;",'[',$content);
42
+ $content = str_replace("&#93;",']',$content);
43
ob_start();
44
eval ($content);
45
if($args['debug'] == 1){
48
}
49
$returned = ob_get_clean();
50
return $returned;
51
}
52
53
function allow_php_menu(){
59
<div style='float:right; display:inline; margin-left:25px; margin-bottom:10px; margin-right:15px; padding:5px; background-color:#ffffcc; border:1px solid #ddddaa;'>
60
<span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Developed by <a href='http://www.hitreach.co.uk' target="_blank" style='text-decoration:none;'>Hit Reach</a></span>
61
<span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Check out our other <a href='http://www.hitreach.co.uk/services/wordpress-plugins/' target="_blank" style='text-decoration:none;'>Wordpress Plugins</a></span>
62
+ <span style='font-size:1em; color:#999; display:block; line-height:1.2em;'>Version: 1.1 <a href='http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/' target="_blank" style='text-decoration:none;'>Support, Comments &amp; questions</a></span></div>
63
64
<p>Allow PHP in posts and pages adds the functionality to include PHP in wordpress posts and pages by adding a simple shortcode <span style='color:green'>[php]</span><em>.code.</em><span style='color:green'>[/php]</span></p>
65
<p>This plugin strips away the automatically generated wordpress &lt;p&gt; and &lt;br/&gt; tags but still allows the addition of your own &lt;p&gt; and &lt;br/&gt; tags