Advanced Ads - Version 1.10.11

Version Description

  • added advanced-ads-frontend-prefix to adjust the frontend prefix dynamically
  • placement position set to center does cause selected ad to be placed to the left
  • fix ads within multiple groups not being saved
Download this release

Release Info

Developer webzunft
Plugin Icon 128x128 Advanced Ads
Version 1.10.11
Comparing to
See all releases

Code changes from version 1.10.10 to 1.10.11

admin/assets/js/admin.js CHANGED
@@ -242,6 +242,16 @@ jQuery( document ).ready(function ($) {
242
  usagediv.show();
243
  }
244
  });
 
 
 
 
 
 
 
 
 
 
245
  // display placement settings form
246
  $( '.advads-placements-table a.advads-placement-options-link' ).click(function(e){
247
  e.preventDefault();
@@ -251,8 +261,8 @@ jQuery( document ).ready(function ($) {
251
  // clear last edited id
252
  $('#advads-last-edited-placement').val('');
253
  } else {
254
- advadsplacementformrow.show();
255
  var placement_id = $( this ).parents( '.advads-placements-table-options' ).find('.advads-placement-slug').val();
 
256
  $('#advads-last-edited-placement').val( placement_id );
257
 
258
  }
@@ -301,6 +311,7 @@ jQuery( document ).ready(function ($) {
301
  // save the ad id, it is needed when this ad is not included in any other group
302
  $( '#advads-ad-group-list form' ).append(
303
  '<input type="hidden" name="advads-groups-removed-ads[]" value="' + $ad_row.data( 'ad-id' ) + '">'
 
304
  );
305
  }
306
  $ad_row.remove();
@@ -446,6 +457,28 @@ jQuery( document ).ready(function ($) {
446
  }
447
  });
448
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
 
450
  /**
451
  * Image ad uploader
@@ -948,16 +981,5 @@ window.Advanced_Ads_Admin = window.Advanced_Ads_Admin || {
948
  else{
949
  jQuery('#advads-parameters-shortcodes-warning').hide();
950
  }
951
- },
952
-
953
- submit_groups: function(){
954
- var grouprows = jQuery( 'tr.advads-ad-group-form' );
955
- jQuery( 'tr.advads-ad-group-form' ).each(function(k,v){
956
- v = jQuery(v);
957
- if (! v.data('touched')){
958
- v.remove();
959
- }
960
- });
961
- jQuery( '#advads-form-groups' ).submit();
962
- }
963
  };
242
  usagediv.show();
243
  }
244
  });
245
+ // handle the submission of the groups form
246
+ $ ('form#advads-form-groups').submit(function(){
247
+ var grouprows = jQuery( 'tr.advads-ad-group-form' );
248
+ jQuery( 'tr.advads-ad-group-form' ).each(function(k,v){
249
+ v = jQuery(v);
250
+ if (! v.data('touched')){
251
+ v.remove();
252
+ }
253
+ });
254
+ });
255
  // display placement settings form
256
  $( '.advads-placements-table a.advads-placement-options-link' ).click(function(e){
257
  e.preventDefault();
261
  // clear last edited id
262
  $('#advads-last-edited-placement').val('');
263
  } else {
 
264
  var placement_id = $( this ).parents( '.advads-placements-table-options' ).find('.advads-placement-slug').val();
265
+ advadsplacementformrow.show();
266
  $('#advads-last-edited-placement').val( placement_id );
267
 
268
  }
311
  // save the ad id, it is needed when this ad is not included in any other group
312
  $( '#advads-ad-group-list form' ).append(
313
  '<input type="hidden" name="advads-groups-removed-ads[]" value="' + $ad_row.data( 'ad-id' ) + '">'
314
+ + '<input type="hidden" name="advads-groups-removed-ads-gid[]" value="' + $ad_row.data( 'group-id' ) + '">'
315
  );
316
  }
317
  $ad_row.remove();
457
  }
458
  });
459
  }
460
+
461
+ // keep track of placements that were changed
462
+ $( 'form#advanced-ads-placements-form input, #advanced-ads-placements-form select' ).on( 'change', function(){
463
+ var tr = $( this ).closest( 'tr.advanced-ads-placement-row' );
464
+ if (tr){
465
+ tr.data('touched', true);
466
+ }
467
+ });
468
+
469
+ // on submit remove placements that were untouched
470
+ $ ('form#advanced-ads-placements-form').submit(function(){
471
+ var grouprows = jQuery( 'form#advanced-ads-placements-form tr.advanced-ads-placement-row' );
472
+ jQuery( 'form#advanced-ads-placements-form tr.advanced-ads-placement-row' ).each(function(k,v){
473
+ v = jQuery(v);
474
+ if (! v.data('touched')){
475
+ v.find( 'input, select' ).each(function(k2,v2){
476
+ v2 = jQuery(v2);
477
+ v2.prop("disabled", true);
478
+ });
479
+ }
480
+ });
481
+ });
482
 
483
  /**
484
  * Image ad uploader
981
  else{
982
  jQuery('#advads-parameters-shortcodes-warning').hide();
983
  }
984
+ }
 
 
 
 
 
 
 
 
 
 
 
985
  };
admin/includes/class-ad-groups-list.php CHANGED
@@ -115,7 +115,7 @@ class Advanced_Ads_Groups_List {
115
  foreach ( $ads->posts as $_ad ) {
116
  $row = '';
117
  $ad_id = $_ad->ID;
118
- $row .= '<tr data-ad-id="'. $ad_id . '"><td>' . $_ad->post_title . '</td><td>';
119
  $row .= '<select name="advads-groups['. $group->id . '][ads]['.$_ad->ID.']">';
120
  $ad_weight = (isset($weights[$ad_id])) ? $weights[$ad_id] : Advanced_Ads_Group::MAX_AD_GROUP_DEFAULT_WEIGHT;
121
  for ( $i = 0; $i <= $max_weight; $i++ ) {
@@ -382,6 +382,15 @@ class Advanced_Ads_Groups_List {
382
  return true;
383
  }
384
 
 
 
 
 
 
 
 
 
 
385
  /**
386
  * bulk update groups
387
  *
@@ -403,36 +412,58 @@ class Advanced_Ads_Groups_List {
403
  * edit: emptying disabled, because when only a few groups are saved (e.g. when filtered by search), options are reset
404
  * todo: needs a solution that also removes options when the group is removed
405
  */
406
- // update_option( 'advads-ad-groups', array() );
407
  // empty weights
408
- update_option( 'advads-ad-weights', array() );
 
 
409
 
410
  // ad_id => group_ids
411
  $ad_groups_assoc = array();
412
 
413
- if ( isset( $_POST['advads-groups-removed-ads'] ) && is_array( $_POST['advads-groups-removed-ads'] ) ) {
414
- foreach ( $_POST['advads-groups-removed-ads'] as $ad_id ) {
 
 
 
415
  $ad_groups_assoc[ $ad_id ] = array();
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
  }
 
418
 
419
  // iterate through groups
420
  if ( isset($_POST['advads-groups']) && count( $_POST['advads-groups'] ) ){
421
 
422
  foreach ( $_POST['advads-groups'] as $_group_id => $_group ){
 
423
  // save basic wp term
424
  wp_update_term( $_group_id, Advanced_Ads::AD_GROUP_TAXONOMY, $_group );
425
 
426
  $group = new Advanced_Ads_Group( $_group['id'] );
427
  if ( isset( $_group['ads'] ) && is_array( $_group['ads'] ) ) {
428
  foreach ( $_group['ads'] as $_ad_id => $_ad_weight ) {
429
-
430
  /**
431
  * check if this ad is representing the current group and remove it in this case
432
  * could cause an infinite loop otherwise
433
  * see also /classes/ad_type_group.php::remove_from_ad_group()
434
  */
435
  $ad = new Advanced_Ads_Ad( $_ad_id );
 
 
 
 
 
 
436
  if( isset( $ad->type )
437
  && 'group' === $ad->type
438
  && isset( $ad->output['group_id'] )
@@ -445,7 +476,8 @@ class Advanced_Ads_Groups_List {
445
  }
446
 
447
  // save ad weights
448
- $group->save_ad_weights( $_group['ads'] );
 
449
  }
450
 
451
  // save other attributes
@@ -462,12 +494,14 @@ class Advanced_Ads_Groups_List {
462
 
463
  $group->save( $atts );
464
  }
465
-
466
  foreach ( $ad_groups_assoc as $_ad_id => $group_ids ) {
467
  wp_set_object_terms( $_ad_id, $group_ids, $this->taxonomy);
468
  }
469
 
470
  }
 
 
471
 
472
  // reload groups
473
  $this->load_groups();
115
  foreach ( $ads->posts as $_ad ) {
116
  $row = '';
117
  $ad_id = $_ad->ID;
118
+ $row .= '<tr data-ad-id="'. $ad_id . '" data-group-id="'. $group->id . '"><td>' . $_ad->post_title . '</td><td>';
119
  $row .= '<select name="advads-groups['. $group->id . '][ads]['.$_ad->ID.']">';
120
  $ad_weight = (isset($weights[$ad_id])) ? $weights[$ad_id] : Advanced_Ads_Group::MAX_AD_GROUP_DEFAULT_WEIGHT;
121
  for ( $i = 0; $i <= $max_weight; $i++ ) {
382
  return true;
383
  }
384
 
385
+
386
+ private function get_groups_by_ad_id($ad_id){
387
+ $ids = array();
388
+ $terms = wp_get_object_terms($ad_id, $this->taxonomy);
389
+ foreach ($terms as $term){
390
+ $ids[] = $term->term_id;
391
+ }
392
+ return $ids;
393
+ }
394
  /**
395
  * bulk update groups
396
  *
412
  * edit: emptying disabled, because when only a few groups are saved (e.g. when filtered by search), options are reset
413
  * todo: needs a solution that also removes options when the group is removed
414
  */
 
415
  // empty weights
416
+ // update_option( 'advads-ad-weights', array() );
417
+
418
+ $all_weights = get_option( 'advads-ad-weights', array() );
419
 
420
  // ad_id => group_ids
421
  $ad_groups_assoc = array();
422
 
423
+ if ( isset( $_POST['advads-groups-removed-ads'] ) && is_array( $_POST['advads-groups-removed-ads'] ) && isset( $_POST['advads-groups-removed-ads-gid'])) {
424
+ $len = count($_POST['advads-groups-removed-ads']);
425
+ for ($i=0; $i<$len; $i++){
426
+ $ad_id = $_POST['advads-groups-removed-ads'][$i];
427
+ $group_id = $_POST['advads-groups-removed-ads-gid'][$i];
428
  $ad_groups_assoc[ $ad_id ] = array();
429
+ // remove it from the weights
430
+ if ( isset($all_weights[$group_id]) && isset($all_weights[$group_id][$ad_id])){
431
+ unset($all_weights[$group_id][$ad_id]);
432
+ }
433
+ // we need to load all the group ids, that are allocated to this ad and then remove the right one only.
434
+ $group_ids = $this->get_groups_by_ad_id($ad_id);
435
+ foreach ($group_ids as $gid){
436
+ if ($gid != $group_id){
437
+ $ad_groups_assoc[$ad_id][] = $gid;
438
+ }
439
+ }
440
  }
441
  }
442
+
443
 
444
  // iterate through groups
445
  if ( isset($_POST['advads-groups']) && count( $_POST['advads-groups'] ) ){
446
 
447
  foreach ( $_POST['advads-groups'] as $_group_id => $_group ){
448
+
449
  // save basic wp term
450
  wp_update_term( $_group_id, Advanced_Ads::AD_GROUP_TAXONOMY, $_group );
451
 
452
  $group = new Advanced_Ads_Group( $_group['id'] );
453
  if ( isset( $_group['ads'] ) && is_array( $_group['ads'] ) ) {
454
  foreach ( $_group['ads'] as $_ad_id => $_ad_weight ) {
 
455
  /**
456
  * check if this ad is representing the current group and remove it in this case
457
  * could cause an infinite loop otherwise
458
  * see also /classes/ad_type_group.php::remove_from_ad_group()
459
  */
460
  $ad = new Advanced_Ads_Ad( $_ad_id );
461
+
462
+ // we will have to load all the groups allocated to this ad.
463
+ if (! isset($ad_groups_assoc[$_ad_id])){
464
+ $ad_groups_assoc[$_ad_id] = $this->get_groups_by_ad_id($_ad_id);
465
+ }
466
+
467
  if( isset( $ad->type )
468
  && 'group' === $ad->type
469
  && isset( $ad->output['group_id'] )
476
  }
477
 
478
  // save ad weights
479
+ $all_weights[$group->id] = $group->sanitize_ad_weights( $_group['ads'] );
480
+ //$group->save_ad_weights( $_group['ads'] );
481
  }
482
 
483
  // save other attributes
494
 
495
  $group->save( $atts );
496
  }
497
+
498
  foreach ( $ad_groups_assoc as $_ad_id => $group_ids ) {
499
  wp_set_object_terms( $_ad_id, $group_ids, $this->taxonomy);
500
  }
501
 
502
  }
503
+
504
+ update_option( 'advads-ad-weights', $all_weights );
505
 
506
  // reload groups
507
  $this->load_groups();
admin/includes/class-menu.php CHANGED
@@ -220,6 +220,8 @@ class Advanced_Ads_Admin_Menu {
220
  wp_die( __( 'Sorry, you are not allowed to access this feature.', 'advanced-ads' ) ); }
221
 
222
  wp_delete_term( $group_id, $taxonomy );
 
 
223
 
224
  $forced_message = 2;
225
  }
220
  wp_die( __( 'Sorry, you are not allowed to access this feature.', 'advanced-ads' ) ); }
221
 
222
  wp_delete_term( $group_id, $taxonomy );
223
+ // delete the weights
224
+ Advanced_Ads_Group::delete_ad_weights($group_id);
225
 
226
  $forced_message = 2;
227
  }
admin/includes/class-notices.php CHANGED
@@ -371,7 +371,7 @@ class Advanced_Ads_Admin_Notices {
371
  return; }
372
 
373
  // register Black Friday 2018 deals
374
- if( time() > 1542931200 &&
375
  time() <= 1543320000 && Advanced_Ads_Admin::get_instance()->screen_belongs_to_advanced_ads() ){
376
  $options = $this->options();
377
  $closed = isset($options['closed']) ? $options['closed'] : array();
@@ -382,7 +382,7 @@ class Advanced_Ads_Admin_Notices {
382
  } elseif ( ! isset( $closed['bf2018_2'] ) ){
383
  $this->notices[] = 'bf2018_2';
384
  }
385
- }
386
 
387
  // load notices
388
  include ADVADS_BASE_PATH . '/admin/includes/notices.php';
371
  return; }
372
 
373
  // register Black Friday 2018 deals
374
+ /*if( time() > 1542931200 &&
375
  time() <= 1543320000 && Advanced_Ads_Admin::get_instance()->screen_belongs_to_advanced_ads() ){
376
  $options = $this->options();
377
  $closed = isset($options['closed']) ? $options['closed'] : array();
382
  } elseif ( ! isset( $closed['bf2018_2'] ) ){
383
  $this->notices[] = 'bf2018_2';
384
  }
385
+ }*/
386
 
387
  // load notices
388
  include ADVADS_BASE_PATH . '/admin/includes/notices.php';
admin/views/ad-group.php CHANGED
@@ -14,25 +14,25 @@ $ad_groups_list = new Advanced_Ads_Groups_List();
14
 
15
  // create new group.
16
  if ( isset( $_REQUEST['advads-group-add-nonce'] ) ) {
17
- $create_result = $ad_groups_list->create_group();
18
- // display error message.
19
- if ( is_wp_error( $create_result ) ) {
20
- $error_string = $create_result->get_error_message();
21
- echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
22
- } else {
23
- echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Group successfully created', 'advanced-ads' ) . '</p></div>';
24
- }
25
  }
26
  // save updated groups.
27
  if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
28
- $udpate_result = $ad_groups_list->update_groups();
29
- // display error message.
30
- if ( is_wp_error( $udpate_result ) ) {
31
- $error_string = $udpate_result->get_error_message();
32
- echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
33
- } else {
34
- echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Groups successfully updated', 'advanced-ads' ) . '</p></div>';
35
- }
36
  }
37
 
38
  ?><div class="wrap nosubsub">
@@ -73,14 +73,14 @@ if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
73
  <div id="col-container">
74
  <div class="col-wrap">
75
  <div class="tablenav top">
76
- <form id="advads-form-groups" class="search-form" action="" method="get">
77
  <!--input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /-->
78
  <input type="hidden" name="page" value="advanced-ads-groups" />
79
  <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
80
  </form>
81
  </div>
82
  <div id="advads-ad-group-list">
83
- <form action="" method="post">
84
  <?php wp_nonce_field( 'update-advads-groups', 'advads-group-update-nonce' ); ?>
85
  <table class="wp-list-table widefat fixed adgroups">
86
  <?php $ad_groups_list->render_header(); ?>
@@ -88,7 +88,7 @@ if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
88
  </table>
89
  <input type="hidden" name="advads-last-edited-group" id="advads-last-edited-group" value="0"/>
90
  <div class="tablenav bottom">
91
- <button type="submit" class="button button-primary" onclick="Advanced_Ads_Admin.submit_groups();"><?php _e( 'Update Groups', 'advanced-ads' );?></button>
92
  </div>
93
  </form>
94
  </div>
14
 
15
  // create new group.
16
  if ( isset( $_REQUEST['advads-group-add-nonce'] ) ) {
17
+ $create_result = $ad_groups_list->create_group();
18
+ // display error message.
19
+ if ( is_wp_error( $create_result ) ) {
20
+ $error_string = $create_result->get_error_message();
21
+ echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
22
+ } else {
23
+ echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Group successfully created', 'advanced-ads' ) . '</p></div>';
24
+ }
25
  }
26
  // save updated groups.
27
  if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
28
+ $udpate_result = $ad_groups_list->update_groups();
29
+ // display error message.
30
+ if ( is_wp_error( $udpate_result ) ) {
31
+ $error_string = $udpate_result->get_error_message();
32
+ echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
33
+ } else {
34
+ echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Groups successfully updated', 'advanced-ads' ) . '</p></div>';
35
+ }
36
  }
37
 
38
  ?><div class="wrap nosubsub">
73
  <div id="col-container">
74
  <div class="col-wrap">
75
  <div class="tablenav top">
76
+ <form class="search-form" action="" method="get">
77
  <!--input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /-->
78
  <input type="hidden" name="page" value="advanced-ads-groups" />
79
  <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
80
  </form>
81
  </div>
82
  <div id="advads-ad-group-list">
83
+ <form action="" method="post" id="advads-form-groups">
84
  <?php wp_nonce_field( 'update-advads-groups', 'advads-group-update-nonce' ); ?>
85
  <table class="wp-list-table widefat fixed adgroups">
86
  <?php $ad_groups_list->render_header(); ?>
88
  </table>
89
  <input type="hidden" name="advads-last-edited-group" id="advads-last-edited-group" value="0"/>
90
  <div class="tablenav bottom">
91
+ <?php submit_button( __( 'Update Groups', 'advanced-ads' ) ); ?>
92
  </div>
93
  </form>
94
  </div>
admin/views/placements.php CHANGED
@@ -24,7 +24,7 @@ if ( isset( $placements ) && is_array( $placements ) && count( $placements ) ) :
24
  do_action( 'advanced-ads-placements-list-before', $placements );
25
  ?>
26
  <h2><?php _e( 'Placements', 'advanced-ads' ); ?></h2>
27
- <form method="POST" action="">
28
  <table class="widefat advads-placements-table striped">
29
  <thead>
30
  <tr>
@@ -47,7 +47,7 @@ if ( isset( $placements ) && is_array( $placements ) && count( $placements ) ) :
47
  $type_missing = true;
48
  }
49
  ?>
50
- <tr id="single-placement-<?php echo $_placement_slug; ?>">
51
  <td>
52
  <?php
53
  if ( $type_missing ) : // type is not given
24
  do_action( 'advanced-ads-placements-list-before', $placements );
25
  ?>
26
  <h2><?php _e( 'Placements', 'advanced-ads' ); ?></h2>
27
+ <form method="POST" action="" id="advanced-ads-placements-form">
28
  <table class="widefat advads-placements-table striped">
29
  <thead>
30
  <tr>
47
  $type_missing = true;
48
  }
49
  ?>
50
+ <tr id="single-placement-<?php echo $_placement_slug; ?>" class="advanced-ads-placement-row">
51
  <td>
52
  <?php
53
  if ( $type_missing ) : // type is not given
advanced-ads.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
- * Version: 1.10.10
16
  * Author: Thomas Maier
17
  * Author URI: https://wpadvancedads.com
18
  * Text Domain: advanced-ads
@@ -39,7 +39,7 @@ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin
39
  // general and global slug, e.g. to store options in WP
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
- define( 'ADVADS_VERSION', '1.10.10' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.10.11
16
  * Author: Thomas Maier
17
  * Author URI: https://wpadvancedads.com
18
  * Text Domain: advanced-ads
39
  // general and global slug, e.g. to store options in WP
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
+ define( 'ADVADS_VERSION', '1.10.11' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/ad.php CHANGED
@@ -688,8 +688,8 @@ class Advanced_Ads_Ad {
688
  if ( isset($this->output['class'] ) && is_array( $this->output['class'] ) ) {
689
  $wrapper['class'] = $this->output['class'];
690
  }
691
-
692
  if ( ! empty( $this->args['placement_position'] ) ) {
 
693
  $use_placement_pos = true;
694
  $position = $this->args['placement_position'];
695
  }
@@ -703,9 +703,13 @@ class Advanced_Ads_Ad {
703
  $wrapper['style']['float'] = 'right';
704
  break;
705
  case 'center' :
706
- if ( ! empty ( $this->output['add_wrapper_sizes'] ) && ! $use_placement_pos ) {
707
  $wrapper['style']['margin-left'] = 'auto';
708
  $wrapper['style']['margin-right'] = 'auto';
 
 
 
 
709
  } else {
710
  $wrapper['style']['text-align'] = 'center';
711
  }
688
  if ( isset($this->output['class'] ) && is_array( $this->output['class'] ) ) {
689
  $wrapper['class'] = $this->output['class'];
690
  }
 
691
  if ( ! empty( $this->args['placement_position'] ) ) {
692
+ // If not group, Set placement position instead of ad position.
693
  $use_placement_pos = true;
694
  $position = $this->args['placement_position'];
695
  }
703
  $wrapper['style']['float'] = 'right';
704
  break;
705
  case 'center' :
706
+ if ( ! empty ( $this->output['add_wrapper_sizes'] ) ) {
707
  $wrapper['style']['margin-left'] = 'auto';
708
  $wrapper['style']['margin-right'] = 'auto';
709
+
710
+ if ( $use_placement_pos ) {
711
+ $wrapper['style']['text-align'] = 'center';
712
+ }
713
  } else {
714
  $wrapper['style']['text-align'] = 'center';
715
  }
classes/ad_group.php CHANGED
@@ -561,7 +561,7 @@ class Advanced_Ads_Group {
561
  * @since 1.0.0
562
  * @param arr $weights ad weights array with (key: ad id; value: weight)
563
  */
564
- private function sanitize_ad_weights($weights = array()) {
565
 
566
  if ( ! is_array( $weights ) ) {
567
  return ''; }
@@ -575,6 +575,19 @@ class Advanced_Ads_Group {
575
 
576
  return $sanitized_weights;
577
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
  /**
580
  * Create a wrapper to place around the group.
@@ -600,6 +613,7 @@ class Advanced_Ads_Group {
600
  $this->wrapper['style']['float'] = 'right';
601
  break;
602
  case 'center' :
 
603
  $this->wrapper['style']['text-align'] = 'center';
604
  break;
605
  }
561
  * @since 1.0.0
562
  * @param arr $weights ad weights array with (key: ad id; value: weight)
563
  */
564
+ public function sanitize_ad_weights($weights = array()) {
565
 
566
  if ( ! is_array( $weights ) ) {
567
  return ''; }
575
 
576
  return $sanitized_weights;
577
  }
578
+
579
+ /**
580
+ * delete all the ad weights for a group by id
581
+ *
582
+ * @since 1.0.0
583
+ */
584
+ public static function delete_ad_weights($group_id){
585
+ $all_weights = get_option( 'advads-ad-weights', array() );
586
+ if ($all_weights && isset($all_weights[$group_id])){
587
+ unset($all_weights[$group_id]);
588
+ update_option( 'advads-ad-weights', $all_weights );
589
+ }
590
+ }
591
 
592
  /**
593
  * Create a wrapper to place around the group.
613
  $this->wrapper['style']['float'] = 'right';
614
  break;
615
  case 'center' :
616
+ // We don't know whether the 'add_wrapper_sizes' option exists.
617
  $this->wrapper['style']['text-align'] = 'center';
618
  break;
619
  }
classes/checks.php CHANGED
@@ -239,6 +239,7 @@ class Advanced_Ads_Checks {
239
  'ADVANCED_ADS_PRO_PAGE_IMPR_EXDAYS',
240
  'ADVANCED_ADS_PRO_REFERRER_EXDAYS',
241
  'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH',
 
242
  'ADVANCED_ADS_SUPPRESS_PLUGIN_ERROR_NOTICES',
243
  'ADVANCED_ADS_TRACKING_DEBUG',
244
  'ADVANCED_ADS_TRACKING_NO_HOURLY_LIMIT',
239
  'ADVANCED_ADS_PRO_PAGE_IMPR_EXDAYS',
240
  'ADVANCED_ADS_PRO_REFERRER_EXDAYS',
241
  'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH',
242
+ 'ADVANCED_ADS_SHOW_LICENSE_RESPONSE',
243
  'ADVANCED_ADS_SUPPRESS_PLUGIN_ERROR_NOTICES',
244
  'ADVANCED_ADS_TRACKING_DEBUG',
245
  'ADVANCED_ADS_TRACKING_NO_HOURLY_LIMIT',
classes/plugin.php CHANGED
@@ -511,15 +511,20 @@ class Advanced_Ads_Plugin {
511
  if ( ! isset( $options['front-prefix'] ) ) {
512
  if ( isset( $options['id-prefix'] ) ) {
513
  // deprecated: keeps widgets working that previously received an id based on the front-prefix
514
- $this->frontend_prefix = esc_attr( $options['id-prefix'] );
515
  } else {
516
  $host = parse_url( get_home_url(), PHP_URL_HOST );
517
- $this->frontend_prefix = preg_match( '/[A-Za-z][A-Za-z0-9_]{4}/', $host, $result ) ? $result[0] . '-' : Advanced_Ads_Plugin::DEFAULT_FRONTEND_PREFIX;
518
  }
519
  } else {
520
- $this->frontend_prefix = esc_attr( $options['front-prefix'] );
521
  }
522
- }
 
 
 
 
 
523
  return $this->frontend_prefix;
524
  }
525
 
511
  if ( ! isset( $options['front-prefix'] ) ) {
512
  if ( isset( $options['id-prefix'] ) ) {
513
  // deprecated: keeps widgets working that previously received an id based on the front-prefix
514
+ $frontend_prefix = esc_attr( $options['id-prefix'] );
515
  } else {
516
  $host = parse_url( get_home_url(), PHP_URL_HOST );
517
+ $frontend_prefix = preg_match( '/[A-Za-z][A-Za-z0-9_]{4}/', $host, $result ) ? $result[0] . '-' : Advanced_Ads_Plugin::DEFAULT_FRONTEND_PREFIX;
518
  }
519
  } else {
520
+ $frontend_prefix = esc_attr( $options['front-prefix'] );
521
  }
522
+ /**
523
+ * Applying the filter here makes sure that it is the same frontend prefix for all
524
+ * calls on this page impression
525
+ */
526
+ $this->frontend_prefix = apply_filters( 'advanced-ads-frontend-prefix', $frontend_prefix );
527
+ }
528
  return $this->frontend_prefix;
529
  }
530
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad manager, ad widget, ad rotation, adsense, advertise, advertisement
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
- Stable tag: 1.10.10
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -276,6 +276,12 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
276
 
277
  == Changelog ==
278
 
 
 
 
 
 
 
279
  = 1.10.10 =
280
 
281
  * new ad block works with WordPress 5.0
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
+ Stable tag: 1.10.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
276
 
277
  == Changelog ==
278
 
279
+ = 1.10.11 =
280
+
281
+ * added `advanced-ads-frontend-prefix` to adjust the frontend prefix dynamically
282
+ * placement position set to center does cause selected ad to be placed to the left
283
+ * fix ads within multiple groups not being saved
284
+
285
  = 1.10.10 =
286
 
287
  * new ad block works with WordPress 5.0