PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.6
Advanced Ads – Ad Manager & AdSense v1.6
2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / classes / ad.php
advanced-ads / classes Last commit date
EDD_SL_Plugin_Updater.php 11 years ago 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 visitor-conditions.php 11 years ago widget.php 11 years ago
ad.php
659 lines
1 <?php
2
3 /**
4 * Advanced Ads Ad.
5 *
6 * @package Advanced_Ads_Ad
7 * @author Thomas Maier <thomas.maier@webgilde.com>
8 * @license GPL-2.0+
9 * @link http://webgilde.com
10 * @copyright 2013 Thomas Maier, webgilde GmbH
11 */
12
13 /**
14 * an ad object
15 *
16 * @package Advanced_Ads_Ad
17 * @author Thomas Maier <thomas.maier@webgilde.com>
18 * @deprecated since version 1.5.3 (May 6th 2015)
19 */
20 class Advads_Ad extends Advanced_Ads_Ad {
21
22 }
23 /**
24 * an ad object
25 *
26 * @package Advanced_Ads_Ad
27 * @author Thomas Maier <thomas.maier@webgilde.com>
28 */
29 class Advanced_Ads_Ad {
30
31 /**
32 * id of the post type for this ad
33 */
34 public $id = 0;
35
36 /**
37 * true, if this is an Advanced Ads Ad post type
38 */
39 protected $is_ad = false;
40
41 /**
42 * ad type
43 */
44 public $type = 'content';
45
46 /**
47 * ad width
48 */
49 public $width = 0;
50
51 /**
52 * ad height
53 */
54 public $height = 0;
55
56 /**
57 * object of current ad type
58 */
59 protected $type_obj;
60
61 /**
62 * content of the ad
63 *
64 * only needed for ad types using the post content field
65 */
66 public $content = '';
67
68 /**
69 * conditions of the ad display
70 */
71 public $conditions = array();
72
73 /**
74 * status of the ad (e.g. publish, pending)
75 */
76 public $status = array();
77
78 /**
79 * array with meta field options aka parameters
80 */
81 protected $options = array();
82
83 /**
84 * name of the meta field to save options to
85 */
86 static $options_meta_field = 'advanced_ads_ad_options';
87
88 /**
89 * additional arguments set when ad is loaded, overwrites or extends options
90 */
91 public $args = array();
92
93 /**
94 * multidimensional array contains information about the wrapper
95 * each possible html attribute is an array with possible multiple elements
96 */
97 public $wrapper = array();
98
99 /**
100 * init ad object
101 *
102 * @param int $id id of the ad (= post id)
103 * @param arr $args additional arguments
104 */
105 public function __construct($id, $args = array()) {
106 $id = absint( $id );
107 $this->id = $id;
108 $this->args = is_array( $args ) ? $args : array();
109
110 if ( ! empty($id) ) { $this->load( $id ); }
111
112 // dynamically add sanitize filters for condition types
113 $_types = array();
114 // -TODO use model
115 $advanced_ads_ad_conditions = Advanced_Ads::get_ad_conditions();
116 foreach ( $advanced_ads_ad_conditions as $_condition ) {
117 // add unique
118 $_types[$_condition['type']] = false;
119 }
120 // iterate types
121 foreach ( array_keys( $_types ) as $_type ) {
122 // -TODO might be faster to use __call() method or isset()-test class method array
123 $method_name = 'sanitize_condition_'. $_type;
124 if ( method_exists( $this, $method_name ) ) {
125 add_filter( 'advanced-ads-sanitize-condition-' . $_type, array($this, $method_name), 10, 1 );
126 } elseif ( function_exists( 'advads_sanitize_condition_' . $_type ) ) {
127 // check for public function to sanitize this
128 add_filter( 'advanced-ads-sanitize-condition-' . $_type, 'advads_sanitize_condition_' . $_type, 10, 1 );
129
130 }
131 }
132 }
133
134 /**
135 * load an ad object by id based on its ad type
136 *
137 * @since 1.0.0
138 */
139 private function load($id = 0){
140
141 $_data = get_post( $id );
142 if ( $_data == null ) { return false; }
143
144 // return, if not an ad
145 if ( $_data->post_type != Advanced_Ads::POST_TYPE_SLUG ) {
146 return false;
147 } else {
148 $this->is_ad = true;
149 }
150
151 $this->type = $this->options( 'type' );
152 $this->title = $_data->post_title;
153 /* load ad type object */
154 $types = Advanced_Ads::get_instance()->ad_types;
155 if ( isset($types[$this->type]) ){
156 $this->type_obj = $types[$this->type];
157 } else {
158 $this->type_obj = new Advanced_Ads_Ad_Type_Abstract;
159 }
160 $this->width = $this->options( 'width' );
161 $this->height = $this->options( 'height' );
162 $this->conditions = $this->options( 'conditions' );
163 $this->description = $this->options( 'description' );
164 $this->output = $this->options( 'output' );
165 $this->status = $_data->post_status;
166 $this->wrapper = $this->load_wrapper_options();
167 $this->expiry_date = $this->options( 'expiry_date' );
168
169 // load content based on ad type
170 $this->content = $this->type_obj->load_content( $_data );
171
172 // set wrapper conditions
173 $this->wrapper = apply_filters( 'advanced-ads-set-wrapper', $this->wrapper, $this );
174 // add unique wrapper id, if options given
175 if ( is_array( $this->wrapper ) && $this->wrapper !== array() && ! isset( $this->wrapper['id'] ) ){
176 // create unique id if not yet given
177 $this->wrapper['id'] = $this->create_wrapper_id();
178 }
179 }
180
181 /**
182 * get options from meta field and return specific field
183 *
184 * @param string $field post meta key to be returned
185 * @return mixed meta field content
186 * @since 1.0.0
187 * @todo check against default values
188 */
189 public function options( $field = '', $default = null ) {
190 // retrieve options, if not given yet
191 // -TODO may execute multiple times (if empty); bad design and risk to access unintialised data with direct access to $this->options property.
192 if ( $this->options === array() ) {
193 // load arguments given on ad load
194 $this->options = $this->args;
195 // get_post_meta() may return false
196 $meta = get_post_meta( $this->id, self::$options_meta_field, true );
197 if ( $meta ){
198 $this->options = array_merge_recursive( $this->options, $meta );
199 }
200 }
201
202 // return specific option
203 if ( $field != '' ) {
204 if ( isset($this->options[$field]) ) {
205 return $this->options[$field];
206 }
207 } else { // return all options
208 if ( ! empty($this->options) ) {
209 return $this->options;
210 }
211 }
212
213 return $default;
214 }
215
216 /**
217 * set an option of the ad
218 *
219 * @since 1.1.0
220 * @param string $option name of the option
221 * @param mixed $value value of the option
222 */
223 public function set_option($option = '', $value = ''){
224 if ( $option == '' ) { return; }
225
226 // get current options
227 $options = $this->options();
228
229 // set options
230 $options[$option] = $value;
231
232 // save options
233 $this->options = $options;
234
235 }
236
237
238 /**
239 * return ad content for frontend output
240 *
241 * @since 1.0.0
242 * @return string $output ad output
243 */
244 public function output(){
245 if ( ! $this->is_ad ) { return ''; }
246
247 $output = $this->prepare_frontend_output();
248
249 // add the ad to the global output array
250 $advads = Advanced_Ads::get_instance();
251 $advads->current_ads[] = array('type' => 'ad', 'id' => $this->id, 'title' => $this->title);
252
253 // action when output is created
254 do_action( 'advanced-ads-output', $this, $output );
255
256 return $output;
257 }
258
259 /**
260 * check if the ad can be displayed in frontend due to its own conditions
261 *
262 * @since 1.0.0
263 * @return bool $can_display true if can be displayed in frontend
264 */
265 public function can_display(){
266
267 // don’t display ads that are not published or private for users not logged in
268 if ( $this->status !== 'publish' && ! ($this->status === 'private' && ! is_user_logged_in()) ){
269 return false;
270 }
271
272 if ( ! $this->can_display_by_visitor() || ! $this->can_display_by_expiry_date() ) {
273 return false;
274 }
275
276 // add own conditions to flag output as possible or not
277 $can_display = apply_filters( 'advanced-ads-can-display', true, $this );
278
279 return $can_display;
280 }
281
282 /**
283 * check visitor conditions
284 *
285 * @since 1.1.0
286 * @return bool $can_display true if can be displayed in frontend based on visitor settings
287 */
288 public function can_display_by_visitor(){
289
290 // check old "visitor" and new "visitors" conditions
291 if ( ( empty($this->options['visitors']) ||
292 ! is_array( $this->options['visitors'] ) )
293 && ( empty($this->options['visitor']) ||
294 ! is_array( $this->options['visitor'] )
295 )) { return true; }
296
297 if ( isset( $this->options['visitors'] ) && is_array( $this->options['visitors'] ) ) {
298
299 $visitor_conditions = $this->options['visitors'];
300
301 foreach( $visitor_conditions as $_condition ) {
302 $result = Advanced_Ads_Visitor_Conditions::frontend_check( $_condition );
303 if( ! $result ) {
304 // return false only, if the next condition doesn’t have an OR operator
305 $next = next( $visitor_conditions );
306 if( ! isset( $next['connector'] ) || $next['connector'] !== 'or' ) {
307 return false;
308 }
309 }
310 }
311 }
312
313 /**
314 * "old" visitor conditions
315 *
316 * @deprecated since version 1.5.4
317 */
318
319 if ( empty($this->options['visitor']) ||
320 ! is_array( $this->options['visitor'] ) ) { return true; }
321 $visitor_conditions = $this->options( 'visitor' );
322
323 // check mobile condition
324 if ( isset($visitor_conditions['mobile']) ){
325 switch ( $visitor_conditions['mobile'] ){
326 case 'only' :
327 if ( ! wp_is_mobile() ) { return false; }
328 break;
329 case 'no' :
330 if ( wp_is_mobile() ) { return false; }
331 break;
332 }
333 }
334
335 return true;
336 }
337
338 /**
339 * check expiry date
340 *
341 * @since 1.3.15
342 * @return bool $can_display true if can be displayed in frontend based on expiry date
343 */
344 public function can_display_by_expiry_date(){
345
346 // if expiry_date is not set null is returned
347 $ad_expiry_date = (int) $this->options( 'expiry_date' );
348
349 if ( $ad_expiry_date <= 0 ) {
350 return true;
351 }
352
353 // check blog time against current time (GMT)
354 return $ad_expiry_date > time();
355 }
356
357 /**
358 * save an ad to the database
359 * takes values from the current state
360 */
361 public function save(){
362 global $wpdb;
363
364 // remove slashes from content
365 $content = $this->prepare_content_to_save();
366
367 $where = array('ID' => $this->id);
368 $wpdb->update( $wpdb->posts, array( 'post_content' => $content ), $where );
369
370 // sanitize conditions
371 // see sanitize_conditions function for example on using this filter
372 $conditions = self::sanitize_conditions_on_save( $this->conditions );
373
374 // save other options to post meta field
375 $options = $this->options();
376
377 $options['type'] = $this->type;
378 $options['width'] = $this->width;
379 $options['height'] = $this->height;
380 $options['conditions'] = $conditions;
381 $options['expiry_date'] = $this->expiry_date;
382 $options['description'] = $this->description;
383
384 // filter to manipulate options or add more to be saved
385 $options = apply_filters( 'advanced-ads-save-options', $options, $this );
386
387 update_post_meta( $this->id, self::$options_meta_field, $options );
388 }
389
390 /**
391 * native filter for content field before being saved
392 *
393 * @return string $content ad content
394 * @since 1.0.0
395 */
396 public function prepare_content_to_save() {
397
398 $content = $this->content;
399
400 // load ad type specific parameter filter
401 $content = $this->type_obj->sanitize_content( $content );
402 // apply a custom filter by ad type
403 $content = apply_filters( 'advanced-ads-pre-ad-save-' . $this->type, $content );
404
405 return $content;
406 }
407
408 /**
409 * native filter for ad parameters before being saved
410 *
411 * @return arr $parameters sanitized parameters
412 */
413 public function prepare_parameters_to_save() {
414
415 $parameters = $this->parameters;
416 // load ad type specific parameter filter
417 $parameters = $this->type_obj->sanitize_parameters( $parameters );
418
419 // apply native WP filter for content fields
420 return $parameters;
421 }
422
423 /**
424 * prepare ads output
425 *
426 * @param string $content ad content
427 * @param obj $ad ad object
428 */
429 public function prepare_frontend_output() {
430
431 // load ad type specific content filter
432 $output = $this->type_obj->prepare_output( $this );
433 // don’t deliver anything, if main ad content is empty
434 if( $output == '' ) {
435 return;
436 }
437
438 // filter to manipulate the output before the wrapper is added
439 $output = apply_filters( 'advanced-ads-output-inside-wrapper', $output, $this );
440
441 // build wrapper around the ad
442 $output = $this->add_wrapper( $output );
443
444 // add a clearfix, if set
445 if ( isset($this->output['clearfix']) && $this->output['clearfix'] ){
446 $output .= '<br style="clear: both; display: block; float: none;"/>';
447 }
448
449 // apply a custom filter by ad type
450 $output = apply_filters( 'advanced-ads-ad-output', $output, $this );
451
452 return $output;
453 }
454
455 /**
456 * sanitize ad display conditions when saving the ad
457 *
458 * @param array $conditions conditions array send via the dashboard form for an ad
459 * @return array with sanitized conditions
460 * @since 1.0.0
461 */
462 public function sanitize_conditions_on_save($conditions = array()){
463
464 global $advanced_ads_ad_conditions;
465
466 if ( ! is_array( $conditions ) || $conditions == array() ) { return array(); }
467
468 foreach ( $conditions as $_key => $_condition ){
469 if ( $_key == 'postids' ){
470 // sanitize single post conditions
471 if ( empty($_condition['ids']) ){ // remove, if empty
472 $_condition['include'] = array();
473 $_condition['exclude'] = array();
474 } else {
475 switch ( $_condition['method'] ){
476 case 'include' :
477 $_condition['include'] = $_condition['ids'];
478 $_condition['exclude'] = array();
479 break;
480 case 'exclude' :
481 $_condition['include'] = array();
482 $_condition['exclude'] = $_condition['ids'];
483 break;
484 }
485 }
486 } else {
487 if ( ! is_array( $_condition ) ) {
488 $_condition = trim( $_condition ); }
489 if ( $_condition == '' ) {
490 $conditions[$_key] = $_condition;
491 continue;
492 }
493 }
494 $type = ! empty($advanced_ads_ad_conditions[$_key]['type']) ? $advanced_ads_ad_conditions[$_key]['type'] : 0;
495 if ( empty($type) ) { continue; }
496
497 // dynamically apply filters for each condition used
498 $conditions[$_key] = apply_filters( 'advanced-ads-sanitize-condition-' . $type, $_condition );
499 }
500
501 return $conditions;
502 }
503
504 /**
505 * sanitize id input field(s) for pattern /1,2,3,4/
506 *
507 * @pararm array/string $cond input string/array
508 * @return array/string $cond sanitized string/array
509 */
510 public static function sanitize_condition_idfield($cond = ''){
511 // strip anything that is not comma or number
512
513 if ( is_array( $cond ) ){
514 foreach ( $cond as $_key => $_cond ){
515 $cond[$_key] = preg_replace( '#[^0-9,]#', '', $_cond );
516 }
517 } else {
518 $cond = preg_replace( '#[^0-9,]#', '', $cond );
519 }
520 return $cond;
521 }
522
523 /**
524 * sanitize radio input field
525 *
526 * @pararm string $string input string
527 * @return string $string sanitized string
528 */
529 public static function sanitize_condition_radio($string = ''){
530 // only allow 0, 1 and empty
531 return $string = preg_replace( '#[^01]#', '', $string );
532 }
533
534 /**
535 * sanitize comma seperated text input field
536 *
537 * @pararm array/string $cond input string/array
538 * @return array/string $cond sanitized string/array
539 */
540 public static function sanitize_condition_textvalues($cond = ''){
541 // strip anything that is not comma, alphanumeric, minus and underscore
542 if ( is_array( $cond ) ){
543 foreach ( $cond as $_key => $_cond ){
544 $cond[$_key] = preg_replace( '#[^0-9,A-Za-z-_]#', '', $_cond );
545 }
546 } else {
547 $cond = preg_replace( '#[^0-9,A-Za-z-_]#', '', $cond );
548 }
549 return $cond;
550 }
551
552 /**
553 * load wrapper options set with the ad
554 *
555 * @since 1.3
556 * @return arr $wrapper options array ready to be use in add_wrapper() function
557 */
558 protected function load_wrapper_options(){
559 $wrapper = array();
560
561 // print_r($this->output);
562
563 if ( ! empty($this->output['position']) ) {
564 switch ( $this->output['position'] ) {
565 case 'left' :
566 $wrapper['style']['float'] = 'left';
567 break;
568 case 'right' :
569 $wrapper['style']['float'] = 'right';
570 break;
571 case 'center' :
572 $wrapper['style']['text-align'] = 'center';
573 break;
574 case 'clearfix' :
575 $wrapper['style']['clear'] = 'both';
576 break;
577 }
578 }
579
580 if ( ! empty($this->output['class']) && is_array( $this->output['class'] ) ) {
581 $wrapper['class'] = $this->output['class'];
582 }
583
584 if ( ! empty($this->output['margin']['top']) ) {
585 $wrapper['style']['margin-top'] = intval( $this->output['margin']['top'] ) . 'px';
586 }
587 if ( ! empty($this->output['margin']['right']) ) {
588 $wrapper['style']['margin-right'] = intval( $this->output['margin']['right'] ) . 'px';
589 }
590 if ( ! empty($this->output['margin']['bottom']) ) {
591 $wrapper['style']['margin-bottom'] = intval( $this->output['margin']['bottom'] ) . 'px';
592 }
593 if ( ! empty($this->output['margin']['left']) ) {
594 $wrapper['style']['margin-left'] = intval( $this->output['margin']['left'] ) . 'px';
595 }
596
597 return $wrapper;
598 }
599
600 /**
601 * add a wrapper arount the ad content if wrapper information are given
602 *
603 * @since 1.1.4
604 * @param str $ad_content content of the ad
605 * @return str $wrapper ad within the wrapper
606 */
607 protected function add_wrapper($ad_content = ''){
608
609 $wrapper_options = apply_filters( 'advanced-ads-output-wrapper-options', $this->wrapper, $this );
610
611 if ( $wrapper_options == array() || ! is_array( $wrapper_options ) || empty($wrapper_options) ) { return $ad_content; }
612
613 $wrapper = $ad_content;
614
615 // create unique id if not yet given
616 if ( empty($wrapper_options['id']) ){
617 $wrapper_options['id'] = $this->create_wrapper_id();
618 }
619
620 // build the box
621 $wrapper = '<div';
622 foreach ( $wrapper_options as $_html_attr => $_values ){
623 if ( $_html_attr == 'style' ){
624 $_style_values_string = '';
625 foreach ( $_values as $_style_attr => $_style_values ){
626 if ( is_array( $_style_values ) ) {
627 $_style_values_string .= $_style_attr . ': ' .implode( ' ', $_style_values ). '; '; }
628 else {
629 $_style_values_string .= $_style_attr . ': ' .$_style_values. '; '; }
630 }
631 $wrapper .= " style=\"$_style_values_string\"";
632 } else {
633 if ( is_array( $_values ) ) {
634 $_values_string = implode( ' ', $_values ); }
635 else {
636 $_values_string = sanitize_title( $_values ); }
637 $wrapper .= " $_html_attr=\"$_values_string\"";
638 }
639 }
640 $wrapper .= '>';
641 $wrapper .= apply_filters( 'advanced-ads-output-wrapper-before-content', '', $this );
642 $wrapper .= $ad_content;
643 $wrapper .= apply_filters( 'advanced-ads-output-wrapper-after-content', '', $this );
644 $wrapper .= '</div>';
645
646 return $wrapper;
647 }
648
649 /**
650 * create a random wrapper id
651 *
652 * @since 1.1.4
653 * @return string $id random id string
654 */
655 private function create_wrapper_id(){
656 return 'advads-' . mt_rand();
657 }
658 }
659