ad-ajax.php
11 years ago
ad-model.php
11 years ago
ad-select.php
11 years ago
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
11 years ago
ad_type_content.php
11 years ago
ad_type_plain.php
11 years ago
plugin.php
11 years ago
widget.php
11 years ago
ad_type_abstract.php
124 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Advanced Ads Abstract 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 that are defaults for all the other ad types |
| 12 | * |
| 13 | * see ad_type_content.php for an example on ad type |
| 14 | * |
| 15 | */ |
| 16 | class Advads_Ad_Type_Abstract { |
| 17 | |
| 18 | /** |
| 19 | * ID - internal type of the ad type |
| 20 | * |
| 21 | * must be static so set your own ad type ID here |
| 22 | * use slug like format, only lower case, underscores and hyphens |
| 23 | * |
| 24 | * @since 1.0.0 |
| 25 | */ |
| 26 | public $ID = ''; |
| 27 | |
| 28 | /** |
| 29 | * public title |
| 30 | * |
| 31 | * will be set within __construct so one can localize it |
| 32 | * |
| 33 | * @since 1.0.0 |
| 34 | */ |
| 35 | public $title = ''; |
| 36 | |
| 37 | /** |
| 38 | * description of the ad type |
| 39 | * |
| 40 | * will be set within __construct so one can localize it |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | */ |
| 44 | public $description = ''; |
| 45 | |
| 46 | /** |
| 47 | * parameters of the ad |
| 48 | * |
| 49 | * defaults are set in construct |
| 50 | */ |
| 51 | public $parameters = array(); |
| 52 | |
| 53 | /** |
| 54 | * set basic attributes |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | */ |
| 58 | public function __construct() { |
| 59 | // initiall |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * output for the ad parameters metabox |
| 64 | * |
| 65 | * @param obj $ad ad object |
| 66 | * @since 1.0.0 |
| 67 | */ |
| 68 | public function render_parameters($ad){ |
| 69 | /** |
| 70 | * this will be loaded by default or using ajax when changing the ad type radio buttons |
| 71 | * echo the output right away here |
| 72 | * name parameters must be in the "advanced_ads" array |
| 73 | */ |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * sanitize ad parameters on save |
| 78 | * |
| 79 | * @param arr $parameters array with ad parameters |
| 80 | * @return arr $parameters sanitized ad parameters |
| 81 | * @since 1.0.0 |
| 82 | */ |
| 83 | public function sanitize_parameters($parameters = array()){ |
| 84 | // no specific filter for content ad parameters, because there are no |
| 85 | return $parameters; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * sanitize content field on save |
| 90 | * |
| 91 | * @param str $content ad content |
| 92 | * @return str $content sanitized ad content |
| 93 | * @since 1.0.0 |
| 94 | */ |
| 95 | public function sanitize_content($content = ''){ |
| 96 | |
| 97 | // remove slashes from content |
| 98 | return $content = wp_unslash( $content ); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * load content field for the ad |
| 103 | * |
| 104 | * @param obj $post WP post object |
| 105 | * @return str $content ad content |
| 106 | * @since 1.0.0 |
| 107 | */ |
| 108 | public function load_content($post){ |
| 109 | |
| 110 | return $post->post_content; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * prepare the ads frontend output |
| 115 | * |
| 116 | * @param obj $ad ad object |
| 117 | * @return str $content ad content prepared for frontend output |
| 118 | * @since 1.0.0 |
| 119 | */ |
| 120 | public function prepare_output($ad){ |
| 121 | return $ad->content; |
| 122 | } |
| 123 | |
| 124 | } |