| @@ -1,60 +1,137 @@ | ||
| 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 | -?> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Plugin Name: Woody ad snippets (PHP snippets | Insert PHP) | |
| 4 | + * Plugin URI: http://woody-ad-snippets.webcraftic.com/ | |
| 5 | + * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service’s code. Ensures no content duplication. | |
| 6 | + * Author: Will Bontrager Software, LLC <will@willmaster.com>, Webcraftic <wordpress.webraftic@gmail.com> | |
| 7 | + * Version: 2.1.91 | |
| 8 | + * Text Domain: insert-php | |
| 9 | + * Domain Path: /languages/ | |
| 10 | + * Author URI: http://woody-ad-snippets.webcraftic.com/ | |
| 11 | + */ | |
| 12 | + | |
| 13 | +// Exit if accessed directly | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; | |
| 16 | +} | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | +require_once( dirname( __FILE__ ) . '/libs/factory/core/includes/class.requirements.php' ); | |
| 21 | + | |
| 22 | +$wbcr_inp_plugin_info = array( | |
| 23 | + 'prefix' => 'wbcr_inp_', | |
| 24 | + 'plugin_name' => 'wbcr_insert_php', | |
| 25 | + 'plugin_title' => __( 'Woody ad snippets', 'insert-php' ), | |
| 26 | + 'plugin_build' => 'free', | |
| 27 | + 'updates' => dirname( __FILE__ ) . '/migrations/' | |
| 28 | +); | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * Checks compatibility with Wordpress, php and other plugins. | |
| 32 | + */ | |
| 33 | +$wbcr_inp_plugin_requirements = new Wbcr_Factory410_Requirements( __FILE__, array_merge( $wbcr_inp_plugin_info, array( | |
| 34 | + 'plugin_last_version' => '2.0.6', | |
| 35 | + 'plugin_already_activate' => defined( 'WINP_PLUGIN_ACTIVE' ), | |
| 36 | + 'required_php_version' => '5.2', | |
| 37 | + 'required_wp_version' => '4.2.0' | |
| 38 | +) ) ); | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * If the plugin is compatible, it will continue its work, otherwise it will be stopped and the user will receive a warning. | |
| 42 | + */ | |
| 43 | +if ( $wbcr_inp_plugin_requirements->check() ) { | |
| 44 | + global $wbcr_inp_safe_mode; | |
| 45 | + | |
| 46 | + $wbcr_inp_safe_mode = false; | |
| 47 | + | |
| 48 | + // Set the constant that the plugin is activated | |
| 49 | + define( 'WINP_PLUGIN_ACTIVE', true ); | |
| 50 | + | |
| 51 | + define( 'WINP_PLUGIN_VERSION', $wbcr_inp_plugin_requirements->getPluginVersion() ); | |
| 52 | + | |
| 53 | + // Root directory of the plugin | |
| 54 | + define( 'WINP_PLUGIN_DIR', dirname( __FILE__ ) ); | |
| 55 | + | |
| 56 | + // Absolute url of the root directory of the plugin | |
| 57 | + define( 'WINP_PLUGIN_URL', plugins_url( null, __FILE__ ) ); | |
| 58 | + | |
| 59 | + // Relative url of the plugin | |
| 60 | + define( 'WINP_PLUGIN_BASE', plugin_basename( __FILE__ ) ); | |
| 61 | + | |
| 62 | + // The type of posts used for snippets types | |
| 63 | + define( 'WINP_SNIPPETS_POST_TYPE', 'wbcr-snippets' ); | |
| 64 | + | |
| 65 | + // The taxonomy used for snippets types | |
| 66 | + define( 'WINP_SNIPPETS_TAXONOMY', 'wbcr-snippet-tags' ); | |
| 67 | + | |
| 68 | + // The snippets types | |
| 69 | + define( 'WINP_SNIPPET_TYPE_PHP', 'php' ); | |
| 70 | + define( 'WINP_SNIPPET_TYPE_TEXT', 'text' ); | |
| 71 | + define( 'WINP_SNIPPET_TYPE_UNIVERSAL', 'universal' ); | |
| 72 | + | |
| 73 | + // The snippet automatic insertion locations | |
| 74 | + define( 'WINP_SNIPPET_AUTO_HEADER', 'header' ); | |
| 75 | + define( 'WINP_SNIPPET_AUTO_FOOTER', 'footer' ); | |
| 76 | + define( 'WINP_SNIPPET_AUTO_BEFORE_POST', 'before_post' ); | |
| 77 | + define( 'WINP_SNIPPET_AUTO_BEFORE_CONTENT', 'before_content' ); | |
| 78 | + define( 'WINP_SNIPPET_AUTO_BEFORE_PARAGRAPH', 'before_paragraph' ); | |
| 79 | + define( 'WINP_SNIPPET_AUTO_AFTER_PARAGRAPH', 'after_paragraph' ); | |
| 80 | + define( 'WINP_SNIPPET_AUTO_AFTER_CONTENT', 'after_content' ); | |
| 81 | + define( 'WINP_SNIPPET_AUTO_AFTER_POST', 'after_post' ); | |
| 82 | + define( 'WINP_SNIPPET_AUTO_BEFORE_EXCERPT', 'before_excerpt' ); | |
| 83 | + define( 'WINP_SNIPPET_AUTO_AFTER_EXCERPT', 'after_excerpt' ); | |
| 84 | + define( 'WINP_SNIPPET_AUTO_BETWEEN_POSTS', 'between_posts' ); | |
| 85 | + define( 'WINP_SNIPPET_AUTO_BEFORE_POSTS', 'before_posts' ); | |
| 86 | + define( 'WINP_SNIPPET_AUTO_AFTER_POSTS', 'after_posts' ); | |
| 87 | + | |
| 88 | + require_once( WINP_PLUGIN_DIR . '/libs/factory/core/boot.php' ); | |
| 89 | + require_once( WINP_PLUGIN_DIR . '/includes/class.helpers.php' ); | |
| 90 | + require_once( WINP_PLUGIN_DIR . '/includes/class.plugin.php' ); | |
| 91 | + | |
| 92 | + try { | |
| 93 | + new WINP_Plugin( __FILE__, array_merge( $wbcr_inp_plugin_info, array( | |
| 94 | + 'plugin_version' => WINP_PLUGIN_VERSION | |
| 95 | + ) ) ); | |
| 96 | + } catch( Exception $exception ) { | |
| 97 | + throw new Exception( $exception->getMessage() ); | |
| 98 | + } | |
| 99 | +} | |
| 100 | + | |
| 101 | +/* | |
| 102 | +Note: This plugin requires WordPress version 3.3.1 or higher. | |
| 103 | + | |
| 104 | +Information about the Insert PHP plugin can be found here: | |
| 105 | +http://www.willmaster.com/software/WPplugins/go/iphphome_iphplugin | |
| 106 | + | |
| 107 | +Instructions and examples can be found here: | |
| 108 | +http://www.willmaster.com/software/WPplugins/go/iphpinstructions_iphplugin | |
| 109 | +*/ | |
| 110 | + | |
| 111 | +// todo: This is the code of the old version of the plugin, left unchanged for compatibility. Delete in the new major version of the plugin | |
| 112 | +if ( ! function_exists( 'will_bontrager_insert_php' ) ) { | |
| 113 | + | |
| 114 | + function will_bontrager_insert_php( $content ) { | |
| 115 | + | |
| 116 | + if ( WINP_Helper::is_safe_mode() ) { | |
| 117 | + return $content; | |
| 118 | + } | |
| 119 | + | |
| 120 | + $will_bontrager_content = $content; | |
| 121 | + preg_match_all( '!\[insert_php[^\]]*\](.*?)\[/insert_php[^\]]*\]!is', $will_bontrager_content, $will_bontrager_matches ); | |
| 122 | + $will_bontrager_nummatches = count( $will_bontrager_matches[0] ); | |
| 123 | + for ( $will_bontrager_i = 0; $will_bontrager_i < $will_bontrager_nummatches; $will_bontrager_i ++ ) { | |
| 124 | + ob_start(); | |
| 125 | + eval( $will_bontrager_matches[1][ $will_bontrager_i ] ); | |
| 126 | + $will_bontrager_replacement = ob_get_contents(); | |
| 127 | + ob_clean(); | |
| 128 | + ob_end_flush(); | |
| 129 | + $will_bontrager_content = preg_replace( '/' . preg_quote( $will_bontrager_matches[0][ $will_bontrager_i ], '/' ) . '/', $will_bontrager_replacement, $will_bontrager_content, 1 ); | |
| 130 | + } | |
| 131 | + | |
| 132 | + return $will_bontrager_content; | |
| 133 | + } # function will_bontrager_insert_php() | |
| 134 | + | |
| 135 | + add_filter( 'the_content', 'will_bontrager_insert_php', 9 ); | |
| 136 | +} # if( ! function_exists('will_bontrager_insert_php') ) | |
| 137 | + | |