PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 1.3
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v1.3
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / insert_php.php

insert_php.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 1.3, at insert_php.php

61 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 ?>
61