ad.php
11 years ago
ad_ajax_callbacks.php
11 years ago
ad_group.php
11 years ago
ad_placements.php
11 years ago
ad_type_abstract.php
12 years ago
ad_type_content.php
11 years ago
ad_type_plain.php
11 years ago
widget.php
11 years ago
ad_type_plain.php
75 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 Advads_Ad_Type_Plain extends Advads_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', ADVADS_SLUG); |
| 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.', ADVADS_SLUG); |
| 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 tinymc content exitor |
| 50 | $content = (isset($ad->content)) ? $ad->content : ''; |
| 51 | /** |
| 52 | * build the tinymc editor |
| 53 | * @link http://codex.wordpress.org/Function_Reference/wp_editor |
| 54 | */ |
| 55 | ?><p class="description"><?php _e('Insert plain text or code into this field.', ADVADS_SLUG); ?></p> |
| 56 | <textarea id="advads-ad-content-plain" cols="40" rows="10" name="advanced_ad[content]"><?php echo $content; ?></textarea> |
| 57 | <?php |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * prepare the ads frontend output |
| 62 | * |
| 63 | * @param obj $ad ad object |
| 64 | * @return str $content ad content prepared for frontend output |
| 65 | * @since 1.0.0 |
| 66 | */ |
| 67 | public function prepare_output($ad){ |
| 68 | // evaluate the code as php |
| 69 | ob_start(); |
| 70 | eval('?>'.$ad->content); |
| 71 | $content = ob_get_clean(); |
| 72 | return $content; |
| 73 | } |
| 74 | |
| 75 | } |