EDD_SL_Plugin_Updater.php
10 years ago
ad-ajax.php
10 years ago
ad-model.php
11 years ago
ad-select.php
10 years ago
ad.php
10 years ago
ad_ajax_callbacks.php
10 years ago
ad_group.php
10 years ago
ad_placements.php
10 years ago
ad_type_abstract.php
11 years ago
ad_type_content.php
10 years ago
ad_type_image.php
10 years ago
ad_type_plain.php
10 years ago
checks.php
10 years ago
plugin.php
10 years ago
visitor-conditions.php
10 years ago
widget.php
10 years ago
ad_type_plain.php
94 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Advanced Ads Plain Ad Type |
| 4 | * |
| 5 | * @package Advanced_Ads |
| 6 | * @author Thomas Maier <thomas.maier@webgilde.com> |
| 7 | * @license GPL-2.0+ |
| 8 | * @link http://webgilde.com |
| 9 | * @copyright 2014 Thomas Maier, webgilde GmbH |
| 10 | * |
| 11 | * Class containing information about the plain text/code ad type |
| 12 | * |
| 13 | * see ad-type-content.php for a better sample on ad type |
| 14 | * |
| 15 | */ |
| 16 | class Advanced_Ads_Ad_Type_Plain extends Advanced_Ads_Ad_Type_Abstract{ |
| 17 | |
| 18 | /** |
| 19 | * ID - internal type of the ad type |
| 20 | * * |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | public $ID = 'plain'; |
| 24 | |
| 25 | /** |
| 26 | * set basic attributes |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | */ |
| 30 | public function __construct() { |
| 31 | $this->title = __( 'Plain Text and Code', 'advanced-ads' ); |
| 32 | $this->description = __( 'Simple text editor without any filters. You might use it to display unfiltered content, php code or javascript. Shortcodes and other WordPress content field magic does not work here.', 'advanced-ads' ); |
| 33 | $this->parameters = array( |
| 34 | 'content' => '' |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * output for the ad parameters metabox |
| 40 | * |
| 41 | * this will be loaded using ajax when changing the ad type radio buttons |
| 42 | * echo the output right away here |
| 43 | * name parameters must be in the "advanced_ads" array |
| 44 | * |
| 45 | * @param obj $ad ad object |
| 46 | * @since 1.0.0 |
| 47 | */ |
| 48 | public function render_parameters($ad){ |
| 49 | // load content |
| 50 | $content = (isset($ad->content)) ? $ad->content : ''; |
| 51 | |
| 52 | // check if php is allowed |
| 53 | if ( isset($ad->output['allow_php']) ){ |
| 54 | $allow_php = absint( $ad->output['allow_php'] ); |
| 55 | } else { |
| 56 | /** |
| 57 | * for compatibility for ads with php added prior to 1.3.18 |
| 58 | * check if there is php code in the content |
| 59 | */ |
| 60 | if ( preg_match( '/\<\?php/', $content ) ){ |
| 61 | $allow_php = 1; |
| 62 | } else { |
| 63 | $allow_php = 0; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | ?><p class="description"><?php _e( 'Insert plain text or code into this field.', 'advanced-ads' ); ?></p> |
| 68 | <textarea id="advads-ad-content-plain" cols="40" rows="10" name="advanced_ad[content]"><?php echo $content; ?></textarea> |
| 69 | <input type="hidden" name="advanced_ad[output][allow_php]" value="0"/> |
| 70 | <label class="advads-ad-allow-php"><input type="checkbox" name="advanced_ad[output][allow_php]" value="1" <?php checked( 1, $allow_php ); ?>/><?php _e( 'Execute PHP code (wrapped in <code><?php ?></code>)', 'advanced-ads' ); ?></label> |
| 71 | <?php |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * prepare the ads frontend output |
| 76 | * |
| 77 | * @param obj $ad ad object |
| 78 | * @return str $content ad content prepared for frontend output |
| 79 | * @since 1.0.0 |
| 80 | */ |
| 81 | public function prepare_output($ad){ |
| 82 | |
| 83 | // evaluate the code as php if setting was never saved or is allowed |
| 84 | if ( ! isset($ad->output['allow_php']) || $ad->output['allow_php'] ){ |
| 85 | ob_start(); |
| 86 | eval('?>'.$ad->content); |
| 87 | $content = ob_get_clean(); |
| 88 | } else { |
| 89 | $content = $ad->content; |
| 90 | } |
| 91 | return $content; |
| 92 | } |
| 93 | |
| 94 | } |