PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.6.6.1
Advanced Ads – Ad Manager & AdSense v1.6.6.1
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 10 years ago ad-model.php 11 years ago ad-select.php 11 years ago ad.php 10 years ago ad_ajax_callbacks.php 11 years ago ad_group.php 11 years ago ad_placements.php 10 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 10 years ago visitor-conditions.php 10 years ago widget.php 10 years ago
ad.php
662 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 // clean post from object cache
371 clean_post_cache( $this->id );
372
373 // sanitize conditions
374 // see sanitize_conditions function for example on using this filter
375 $conditions = self::sanitize_conditions_on_save( $this->conditions );
376
377 // save other options to post meta field
378 $options = $this->options();
379
380 $options['type'] = $this->type;
381 $options['width'] = $this->width;
382 $options['height'] = $this->height;
383 $options['conditions'] = $conditions;
384 $options['expiry_date'] = $this->expiry_date;
385 $options['description'] = $this->description;
386
387 // filter to manipulate options or add more to be saved
388 $options = apply_filters( 'advanced-ads-save-options', $options, $this );
389
390 update_post_meta( $this->id, self::$options_meta_field, $options );
391 }
392
393 /**
394 * native filter for content field before being saved
395 *
396 * @return string $content ad content
397 * @since 1.0.0
398 */
399 public function prepare_content_to_save() {
400
401 $content = $this->content;
402
403 // load ad type specific parameter filter
404 $content = $this->type_obj->sanitize_content( $content );
405 // apply a custom filter by ad type
406 $content = apply_filters( 'advanced-ads-pre-ad-save-' . $this->type, $content );
407
408 return $content;
409 }
410
411 /**
412 * native filter for ad parameters before being saved
413 *
414 * @return arr $parameters sanitized parameters
415 */
416 public function prepare_parameters_to_save() {
417
418 $parameters = $this->parameters;
419 // load ad type specific parameter filter
420 $parameters = $this->type_obj->sanitize_parameters( $parameters );
421
422 // apply native WP filter for content fields
423 return $parameters;
424 }
425
426 /**
427 * prepare ads output
428 *
429 * @param string $content ad content
430 * @param obj $ad ad object
431 */
432 public function prepare_frontend_output() {
433
434 // load ad type specific content filter
435 $output = $this->type_obj->prepare_output( $this );
436 // don’t deliver anything, if main ad content is empty
437 if( $output == '' ) {
438 return;
439 }
440
441 // filter to manipulate the output before the wrapper is added
442 $output = apply_filters( 'advanced-ads-output-inside-wrapper', $output, $this );
443
444 // build wrapper around the ad
445 $output = $this->add_wrapper( $output );
446
447 // add a clearfix, if set
448 if ( isset($this->output['clearfix']) && $this->output['clearfix'] ){
449 $output .= '<br style="clear: both; display: block; float: none;"/>';
450 }
451
452 // apply a custom filter by ad type
453 $output = apply_filters( 'advanced-ads-ad-output', $output, $this );
454
455 return $output;
456 }
457
458 /**
459 * sanitize ad display conditions when saving the ad
460 *
461 * @param array $conditions conditions array send via the dashboard form for an ad
462 * @return array with sanitized conditions
463 * @since 1.0.0
464 */
465 public function sanitize_conditions_on_save($conditions = array()){
466
467 global $advanced_ads_ad_conditions;
468
469 if ( ! is_array( $conditions ) || $conditions == array() ) { return array(); }
470
471 foreach ( $conditions as $_key => $_condition ){
472 if ( $_key == 'postids' ){
473 // sanitize single post conditions
474 if ( empty($_condition['ids']) ){ // remove, if empty
475 $_condition['include'] = array();
476 $_condition['exclude'] = array();
477 } else {
478 switch ( $_condition['method'] ){
479 case 'include' :
480 $_condition['include'] = $_condition['ids'];
481 $_condition['exclude'] = array();
482 break;
483 case 'exclude' :
484 $_condition['include'] = array();
485 $_condition['exclude'] = $_condition['ids'];
486 break;
487 }
488 }
489 } else {
490 if ( ! is_array( $_condition ) ) {
491 $_condition = trim( $_condition ); }
492 if ( $_condition == '' ) {
493 $conditions[$_key] = $_condition;
494 continue;
495 }
496 }
497 $type = ! empty($advanced_ads_ad_conditions[$_key]['type']) ? $advanced_ads_ad_conditions[$_key]['type'] : 0;
498 if ( empty($type) ) { continue; }
499
500 // dynamically apply filters for each condition used
501 $conditions[$_key] = apply_filters( 'advanced-ads-sanitize-condition-' . $type, $_condition );
502 }
503
504 return $conditions;
505 }
506
507 /**
508 * sanitize id input field(s) for pattern /1,2,3,4/
509 *
510 * @pararm array/string $cond input string/array
511 * @return array/string $cond sanitized string/array
512 */
513 public static function sanitize_condition_idfield($cond = ''){
514 // strip anything that is not comma or number
515
516 if ( is_array( $cond ) ){
517 foreach ( $cond as $_key => $_cond ){
518 $cond[$_key] = preg_replace( '#[^0-9,]#', '', $_cond );
519 }
520 } else {
521 $cond = preg_replace( '#[^0-9,]#', '', $cond );
522 }
523 return $cond;
524 }
525
526 /**
527 * sanitize radio input field
528 *
529 * @pararm string $string input string
530 * @return string $string sanitized string
531 */
532 public static function sanitize_condition_radio($string = ''){
533 // only allow 0, 1 and empty
534 return $string = preg_replace( '#[^01]#', '', $string );
535 }
536
537 /**
538 * sanitize comma seperated text input field
539 *
540 * @pararm array/string $cond input string/array
541 * @return array/string $cond sanitized string/array
542 */
543 public static function sanitize_condition_textvalues($cond = ''){
544 // strip anything that is not comma, alphanumeric, minus and underscore
545 if ( is_array( $cond ) ){
546 foreach ( $cond as $_key => $_cond ){
547 $cond[$_key] = preg_replace( '#[^0-9,A-Za-z-_]#', '', $_cond );
548 }
549 } else {
550 $cond = preg_replace( '#[^0-9,A-Za-z-_]#', '', $cond );
551 }
552 return $cond;
553 }
554
555 /**
556 * load wrapper options set with the ad
557 *
558 * @since 1.3
559 * @return arr $wrapper options array ready to be use in add_wrapper() function
560 */
561 protected function load_wrapper_options(){
562 $wrapper = array();
563
564 // print_r($this->output);
565
566 if ( ! empty($this->output['position']) ) {
567 switch ( $this->output['position'] ) {
568 case 'left' :
569 $wrapper['style']['float'] = 'left';
570 break;
571 case 'right' :
572 $wrapper['style']['float'] = 'right';
573 break;
574 case 'center' :
575 $wrapper['style']['text-align'] = 'center';
576 break;
577 case 'clearfix' :
578 $wrapper['style']['clear'] = 'both';
579 break;
580 }
581 }
582
583 if ( ! empty($this->output['class']) && is_array( $this->output['class'] ) ) {
584 $wrapper['class'] = $this->output['class'];
585 }
586
587 if ( ! empty($this->output['margin']['top']) ) {
588 $wrapper['style']['margin-top'] = intval( $this->output['margin']['top'] ) . 'px';
589 }
590 if ( ! empty($this->output['margin']['right']) ) {
591 $wrapper['style']['margin-right'] = intval( $this->output['margin']['right'] ) . 'px';
592 }
593 if ( ! empty($this->output['margin']['bottom']) ) {
594 $wrapper['style']['margin-bottom'] = intval( $this->output['margin']['bottom'] ) . 'px';
595 }
596 if ( ! empty($this->output['margin']['left']) ) {
597 $wrapper['style']['margin-left'] = intval( $this->output['margin']['left'] ) . 'px';
598 }
599
600 return $wrapper;
601 }
602
603 /**
604 * add a wrapper arount the ad content if wrapper information are given
605 *
606 * @since 1.1.4
607 * @param str $ad_content content of the ad
608 * @return str $wrapper ad within the wrapper
609 */
610 protected function add_wrapper($ad_content = ''){
611
612 $wrapper_options = apply_filters( 'advanced-ads-output-wrapper-options', $this->wrapper, $this );
613
614 if ( $wrapper_options == array() || ! is_array( $wrapper_options ) || empty($wrapper_options) ) { return $ad_content; }
615
616 $wrapper = $ad_content;
617
618 // create unique id if not yet given
619 if ( empty($wrapper_options['id']) ){
620 $wrapper_options['id'] = $this->create_wrapper_id();
621 }
622
623 // build the box
624 $wrapper = '<div';
625 foreach ( $wrapper_options as $_html_attr => $_values ){
626 if ( $_html_attr == 'style' ){
627 $_style_values_string = '';
628 foreach ( $_values as $_style_attr => $_style_values ){
629 if ( is_array( $_style_values ) ) {
630 $_style_values_string .= $_style_attr . ': ' .implode( ' ', $_style_values ). '; '; }
631 else {
632 $_style_values_string .= $_style_attr . ': ' .$_style_values. '; '; }
633 }
634 $wrapper .= " style=\"$_style_values_string\"";
635 } else {
636 if ( is_array( $_values ) ) {
637 $_values_string = implode( ' ', $_values ); }
638 else {
639 $_values_string = sanitize_title( $_values ); }
640 $wrapper .= " $_html_attr=\"$_values_string\"";
641 }
642 }
643 $wrapper .= '>';
644 $wrapper .= apply_filters( 'advanced-ads-output-wrapper-before-content', '', $this );
645 $wrapper .= $ad_content;
646 $wrapper .= apply_filters( 'advanced-ads-output-wrapper-after-content', '', $this );
647 $wrapper .= '</div>';
648
649 return $wrapper;
650 }
651
652 /**
653 * create a random wrapper id
654 *
655 * @since 1.1.4
656 * @return string $id random id string
657 */
658 private function create_wrapper_id(){
659 return 'advads-' . mt_rand();
660 }
661 }
662