Advanced Ads - Version 1.20.2

Version Description

  • fixed displaying image ads if privacy method is set to custom cookie
  • fixed scroll to last edited placement with non-English letters
  • fixed minor UI issues
Download this release

Release Info

Developer advancedads
Plugin Icon 128x128 Advanced Ads
Version 1.20.2
Comparing to
See all releases

Code changes from version 1.20.1 to 1.20.2

admin/assets/css/admin.css CHANGED
@@ -42,7 +42,8 @@
42
  /**
43
  * AD OVERVIEW PAGE
44
  */
45
- .ad_details img { float: left; margin-right: 10px; width: calc(50% - 10px); }
 
46
  .ad_details img ~ p { float: left; width: 50%; }
47
  .advads-ad-size { white-space: nowrap; }
48
  .post-type-advanced_ads .subsubsub .draft a { background-color: #FCE7C0; }
42
  /**
43
  * AD OVERVIEW PAGE
44
  */
45
+ #posts-filter .ad_details > fieldset {float: none;}
46
+ .ad_details img { float: left; margin-right: 10px; width: 150px; max-width: calc(50% - 10px); height: auto;}
47
  .ad_details img ~ p { float: left; width: 50%; }
48
  .advads-ad-size { white-space: nowrap; }
49
  .post-type-advanced_ads .subsubsub .draft a { background-color: #FCE7C0; }
admin/assets/js/admin.js CHANGED
@@ -113,32 +113,32 @@ jQuery( document ).ready( function ( $ ) {
113
  $( '#advads-new-group-form' ).show().find( 'input[type="text"]' ).focus()
114
  } )
115
 
116
- // display ad groups form
117
- $( '#advads-ad-group-list a.edit, #advads-ad-group-list a.row-title' ).click( function ( e ) {
118
- e.preventDefault()
119
- var advadsgroupformrow = $( this ).parents( '.advads-group-row' ).next( '.advads-ad-group-form' )
120
- if ( advadsgroupformrow.is( ':visible' ) ) {
121
- advadsgroupformrow.hide()
122
- // clear last edited id
123
- $( '#advads-last-edited-group' ).val( '' )
124
- } else {
125
- advadsgroupformrow.show()
126
- var group_id = advadsgroupformrow.find( '.advads-group-id' ).val()
127
- $( '#advads-last-edited-group' ).val( group_id )
128
- // remember that we opened that one
129
- advadsgroupformrow.data( 'touched', true )
130
- }
131
- } )
132
- // display ad groups usage
133
- $( '#advads-ad-group-list a.usage' ).click( function ( e ) {
134
- e.preventDefault()
135
- var usagediv = $( this ).parents( '.advads-group-row' ).find( '.advads-usage' )
136
- if ( usagediv.is( ':visible' ) ) {
137
- usagediv.hide()
138
- } else {
139
- usagediv.show()
140
- }
141
- } )
142
  // handle the submission of the groups form
143
  $( 'form#advads-form-groups' ).submit( function () {
144
  var grouprows = jQuery( 'tr.advads-ad-group-form' )
@@ -175,10 +175,12 @@ jQuery( document ).ready( function ( $ ) {
175
  } )
176
  /**
177
  * Automatically open all options and show usage link when this is the placement linked in the URL
178
- * also highlight the box with an effect for a short time
 
179
  */
180
- if ( jQuery( window.location.hash ).length ) {
181
- jQuery( window.location.hash ).find( '.advads-toggle-link + div, .advads-usage' ).show()
 
182
 
183
  }
184
 
113
  $( '#advads-new-group-form' ).show().find( 'input[type="text"]' ).focus()
114
  } )
115
 
116
+ // display ad groups form
117
+ $('#advads-ad-group-list a.edit, #advads-ad-group-list a.row-title').click(function (e) {
118
+ e.preventDefault();
119
+ var advadsgroupformrow = $(this).parents('.advads-group-row').next('.advads-ad-group-form');
120
+ if (advadsgroupformrow.is(':visible')) {
121
+ advadsgroupformrow.addClass('hidden');
122
+ // clear last edited id
123
+ $('#advads-last-edited-group').val('');
124
+ } else {
125
+ advadsgroupformrow.removeClass('hidden');
126
+ var group_id = advadsgroupformrow.find('.advads-group-id').val()
127
+ $('#advads-last-edited-group').val(group_id);
128
+ // remember that we opened that one
129
+ advadsgroupformrow.data('touched', true);
130
+ }
131
+ });
132
+ // display ad groups usage
133
+ $('#advads-ad-group-list a.usage').click(function (e) {
134
+ e.preventDefault();
135
+ var usagediv = $(this).parents('.advads-group-row').find('.advads-usage');
136
+ if (usagediv.is(':visible')) {
137
+ usagediv.addClass('hidden');
138
+ } else {
139
+ usagediv.removeClass('hidden');
140
+ }
141
+ });
142
  // handle the submission of the groups form
143
  $( 'form#advads-form-groups' ).submit( function () {
144
  var grouprows = jQuery( 'tr.advads-ad-group-form' )
175
  } )
176
  /**
177
  * Automatically open all options and show usage link when this is the placement linked in the URL
178
+ * also highlight the box with an effect for a short time.
179
+ * Use attribute selector to avoid the need to escape the selector.
180
  */
181
+ var single_placement_slug = '[id="' + window.location.hash.substr( 1 ) + '"]';
182
+ if ( jQuery( single_placement_slug ).length ) {
183
+ jQuery( single_placement_slug ).find( '.advads-toggle-link + div, .advads-usage' ).show()
184
 
185
  }
186
 
admin/includes/class-admin-upgrades.php CHANGED
@@ -30,7 +30,7 @@ class Advanced_Ads_Admin_Upgrades {
30
  $ad_types['upgrade-gam'] = new stdClass();
31
  $ad_types['upgrade-gam']->ID = 'gam';
32
  $ad_types['upgrade-gam']->title = 'Google Ad Manager'; // Do not translate.
33
- $ad_types['upgrade-gam']->description = __( 'Load ad units directly from your Google Ad Manager account', 'advanced-ads' );
34
  $ad_types['upgrade-gam']->is_upgrade = true;
35
  $ad_types['upgrade-gam']->upgrade_url = ADVADS_URL . 'add-ons/google-ad-manager/';
36
  }
@@ -40,7 +40,7 @@ class Advanced_Ads_Admin_Upgrades {
40
  $ad_types['upgrade-amp'] = new stdClass();
41
  $ad_types['upgrade-amp']->ID = 'amp';
42
  $ad_types['upgrade-amp']->title = 'AMP'; // Do not translate.
43
- $ad_types['upgrade-amp']->description = __( 'Ads that are visible on Accelerated Mobile Pages', 'advanced-ads' );
44
  $ad_types['upgrade-amp']->is_upgrade = true;
45
  $ad_types['upgrade-amp']->upgrade_url = ADVADS_URL . 'add-ons/responsive-ads/';
46
  }
30
  $ad_types['upgrade-gam'] = new stdClass();
31
  $ad_types['upgrade-gam']->ID = 'gam';
32
  $ad_types['upgrade-gam']->title = 'Google Ad Manager'; // Do not translate.
33
+ $ad_types['upgrade-gam']->description = __( 'Load ad units directly from your Google Ad Manager account.', 'advanced-ads' );
34
  $ad_types['upgrade-gam']->is_upgrade = true;
35
  $ad_types['upgrade-gam']->upgrade_url = ADVADS_URL . 'add-ons/google-ad-manager/';
36
  }
40
  $ad_types['upgrade-amp'] = new stdClass();
41
  $ad_types['upgrade-amp']->ID = 'amp';
42
  $ad_types['upgrade-amp']->title = 'AMP'; // Do not translate.
43
+ $ad_types['upgrade-amp']->description = __( 'Ads that are visible on Accelerated Mobile Pages.', 'advanced-ads' );
44
  $ad_types['upgrade-amp']->is_upgrade = true;
45
  $ad_types['upgrade-amp']->upgrade_url = ADVADS_URL . 'add-ons/responsive-ads/';
46
  }
admin/views/ad-main-metabox.php CHANGED
@@ -22,7 +22,7 @@
22
  echo esc_html( $_type->description );
23
  if ( ! empty( $_type->upgrade_url ) ) :
24
  echo ' ';
25
- Advanced_Ads_Admin_Upgrades::upgrade_link( null, $_type->upgrade_url, 'upgrade-ad-type-' . $_type->ID );
26
  endif;
27
  ?>
28
  </span>
22
  echo esc_html( $_type->description );
23
  if ( ! empty( $_type->upgrade_url ) ) :
24
  echo ' ';
25
+ Advanced_Ads_Admin_Upgrades::upgrade_link( __( 'Manual', 'advanced-ads' ), $_type->upgrade_url, 'upgrade-ad-type-' . $_type->ID );
26
  endif;
27
  ?>
28
  </span>
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.20.1
16
  * Author: Thomas Maier, Advanced Ads GmbH
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.20.1' );
43
 
44
  // Autoloading, modules and functions.
45
 
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.20.2
16
  * Author: Thomas Maier, Advanced Ads GmbH
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.20.2' );
43
 
44
  // Autoloading, modules and functions.
45
 
classes/ad-ajax.php CHANGED
@@ -121,6 +121,9 @@ class Advanced_Ads_Ajax {
121
  );
122
  }
123
 
 
 
 
124
  add_filter( 'advanced-ads-can-display', array( $this, 'can_display_by_consent' ), 10, 2 );
125
  $content = $selector->get_ad_by_method( $id, $method, $arguments );
126
 
@@ -136,7 +139,7 @@ class Advanced_Ads_Ajax {
136
  'item' => $content,
137
  'id' => $id,
138
  'method' => $method,
139
- 'ads' => Advanced_Ads::get_instance()->current_ads,
140
  'blog_id' => get_current_blog_id(),
141
  );
142
 
@@ -222,19 +225,24 @@ class Advanced_Ads_Ajax {
222
  // if privacy module is not active, we can display.
223
  $privacy = Advanced_Ads_Privacy::get_instance();
224
  $privacy_options = $privacy->options();
225
- if ( ! isset( $privacy_options['enabled'] ) ) {
226
  return true;
227
  }
228
 
 
229
  $consent_state = sanitize_text_field( $_REQUEST['consent'] );
230
- if ( $consent_state === 'not_needed' ) {
 
 
231
  return true;
232
  }
233
- // Don't display ad if tcf is used and the consent state is anything different than accepted.
234
- if ( $privacy_options['consent-method'] === 'iab_tcf_20' && $consent_state !== 'accepted' ) {
235
- return ! $privacy->ad_type_needs_consent( $ad->type );
 
236
  }
237
 
238
- return true;
 
239
  }
240
  }
121
  );
122
  }
123
 
124
+ $advads = Advanced_Ads::get_instance();
125
+ $previous_ads = $advads->current_ads;
126
+
127
  add_filter( 'advanced-ads-can-display', array( $this, 'can_display_by_consent' ), 10, 2 );
128
  $content = $selector->get_ad_by_method( $id, $method, $arguments );
129
 
139
  'item' => $content,
140
  'id' => $id,
141
  'method' => $method,
142
+ 'ads' => array_slice( $advads->current_ads, count( $previous_ads ) ),
143
  'blog_id' => get_current_blog_id(),
144
  );
145
 
225
  // if privacy module is not active, we can display.
226
  $privacy = Advanced_Ads_Privacy::get_instance();
227
  $privacy_options = $privacy->options();
228
+ if ( empty( $privacy_options['enabled'] ) ) {
229
  return true;
230
  }
231
 
232
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nonce should be verified in ajax handler.
233
  $consent_state = sanitize_text_field( $_REQUEST['consent'] );
234
+
235
+ // Consent is either given or not needed.
236
+ if ( in_array( $consent_state, array( 'not_needed', 'accepted' ), true ) ) {
237
  return true;
238
  }
239
+
240
+ // If there is custom code, don't display the ad (unless it's a group).
241
+ if ( class_exists( 'Advanced_Ads_Pro' ) && ! empty( Advanced_Ads_Pro::get_instance()->get_custom_code( $ad ) ) && $ad->type !== 'group' ) {
242
+ return false;
243
  }
244
 
245
+ // See if this ad type needs consent.
246
+ return ! $privacy->ad_type_needs_consent( $ad->type );
247
  }
248
  }
classes/ad_placements.php CHANGED
@@ -781,7 +781,7 @@ class Advanced_Ads_Placements {
781
  $plugin_options = Advanced_Ads::get_instance()->options();
782
 
783
  // Prevent removing closing tags in scripts.
784
- $content_to_load = preg_replace( '/<script.*?<\/script>/', '<!--\0-->', $content );
785
 
786
  // check which priority the wpautop filter has; might have been disabled on purpose.
787
  $wpautop_priority = has_filter( 'the_content', 'wpautop' );
781
  $plugin_options = Advanced_Ads::get_instance()->options();
782
 
783
  // Prevent removing closing tags in scripts.
784
+ $content_to_load = preg_replace( '/<script.*?<\/script>/si', '<!--\0-->', $content );
785
 
786
  // check which priority the wpautop filter has; might have been disabled on purpose.
787
  $wpautop_priority = has_filter( 'the_content', 'wpautop' );
languages/advanced-ads.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the same license as the Advanced Ads plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Advanced Ads 1.20.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
7
  "Last-Translator: Thomas Maier <post@webzunft.de>\n"
8
  "Language-Team: webgilde <support@wpadvancedads.com>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2020-09-17T08:57:08+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: advanced-ads\n"
@@ -436,11 +436,11 @@ msgid "Get help"
436
  msgstr ""
437
 
438
  #: admin/includes/class-admin-upgrades.php:33
439
- msgid "Load ad units directly from your Google Ad Manager account"
440
  msgstr ""
441
 
442
  #: admin/includes/class-admin-upgrades.php:43
443
- msgid "Ads that are visible on Accelerated Mobile Pages"
444
  msgstr ""
445
 
446
  #: admin/includes/class-admin-upgrades.php:60
@@ -651,6 +651,7 @@ msgstr ""
651
  #: admin/includes/class-meta-box.php:218
652
  #: admin/includes/class-meta-box.php:223
653
  #: admin/includes/class-overview-widgets.php:182
 
654
  #: admin/views/ad-output-metabox.php:61
655
  #: admin/views/settings/general/custom-label.php:9
656
  #: modules/ads-txt/admin/views/setting-create.php:11
2
  # This file is distributed under the same license as the Advanced Ads plugin.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Advanced Ads 1.20.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
7
  "Last-Translator: Thomas Maier <post@webzunft.de>\n"
8
  "Language-Team: webgilde <support@wpadvancedads.com>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2020-10-01T09:48:50+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: advanced-ads\n"
436
  msgstr ""
437
 
438
  #: admin/includes/class-admin-upgrades.php:33
439
+ msgid "Load ad units directly from your Google Ad Manager account."
440
  msgstr ""
441
 
442
  #: admin/includes/class-admin-upgrades.php:43
443
+ msgid "Ads that are visible on Accelerated Mobile Pages."
444
  msgstr ""
445
 
446
  #: admin/includes/class-admin-upgrades.php:60
651
  #: admin/includes/class-meta-box.php:218
652
  #: admin/includes/class-meta-box.php:223
653
  #: admin/includes/class-overview-widgets.php:182
654
+ #: admin/views/ad-main-metabox.php:25
655
  #: admin/views/ad-output-metabox.php:61
656
  #: admin/views/settings/general/custom-label.php:9
657
  #: modules/ads-txt/admin/views/setting-create.php:11
modules/privacy/classes/class-privacy.php CHANGED
@@ -154,8 +154,14 @@ class Advanced_Ads_Privacy {
154
  return true;
155
  }
156
 
157
- // If method is iab_tcf_20, always set to true, JS needs to decide whether to display ad or not.
158
  $consent_method = isset( $this->options['consent-method'] ) ? $this->options['consent-method'] : '';
 
 
 
 
 
 
 
159
  if ( $consent_method === 'iab_tcf_20' ) {
160
  return true;
161
  }
@@ -212,11 +218,11 @@ class Advanced_Ads_Privacy {
212
  $consent_method = isset( $this->options['consent-method'] ) ? $this->options['consent-method'] : '';
213
  switch ( $consent_method ) {
214
  case 'custom':
215
- if ( empty( $this->options['custom-cookie-name'] ) ) {
 
216
  return 'not_needed';
217
  }
218
 
219
- $name = $this->options['custom-cookie-name'];
220
  if ( ! isset( $_COOKIE[ $name ] ) ) {
221
  return 'unknown';
222
  }
@@ -231,9 +237,8 @@ class Advanced_Ads_Privacy {
231
 
232
  return 'unknown';
233
  case 'iab_tcf_20':
234
- return 'unknown';
235
  default:
236
- return isset( $_COOKIE[ $consent_method ] ) ? 'accepted' : 'unknown';
237
  }
238
  }
239
  }
154
  return true;
155
  }
156
 
 
157
  $consent_method = isset( $this->options['consent-method'] ) ? $this->options['consent-method'] : '';
158
+
159
+ // If the consent method is set to cookie and the ad type does not need consent.
160
+ if ( $consent_method === 'custom' && ! $this->ad_type_needs_consent( $ad->type ) ) {
161
+ return true;
162
+ }
163
+
164
+ // If method is iab_tcf_20, always set to true, JS needs to decide whether to display ad or not.
165
  if ( $consent_method === 'iab_tcf_20' ) {
166
  return true;
167
  }
218
  $consent_method = isset( $this->options['consent-method'] ) ? $this->options['consent-method'] : '';
219
  switch ( $consent_method ) {
220
  case 'custom':
221
+ $name = $this->options['custom-cookie-name'];
222
+ if ( empty( $name ) ) {
223
  return 'not_needed';
224
  }
225
 
 
226
  if ( ! isset( $_COOKIE[ $name ] ) ) {
227
  return 'unknown';
228
  }
237
 
238
  return 'unknown';
239
  case 'iab_tcf_20':
 
240
  default:
241
+ return 'unknown';
242
  }
243
  }
244
  }
public/assets/js/advanced.js CHANGED
@@ -1 +1 @@
1
- advads={supports_localstorage:function(){"use strict";try{return window&&void 0!==window.localStorage?(window.localStorage.setItem("x","x"),window.localStorage.removeItem("x"),!0):!1}catch(e){return!1}},max_per_session:function(e,t){var a=1;if(void 0!==t&&0!==parseInt(t)||(t=1),this.cookie_exists(e)){if(this.get_cookie(e)>=t)return!0;a+=parseInt(this.get_cookie(e))}return this.set_cookie(e,a),!1},count_up:function(e,t){var a=1;this.cookie_exists(e)&&(a+=parseInt(this.get_cookie(e))),this.set_cookie(e,a)},set_cookie_exists:function(e){return!!get_cookie(e)||(set_cookie(e,"",0),!1)},get_cookie:function(e){for(var t,a,o=document.cookie.split(";"),n=0;n<o.length;n++)if(t=o[n].substr(0,o[n].indexOf("=")),a=o[n].substr(o[n].indexOf("=")+1),(t=t.replace(/^\s+|\s+$/g,""))===e)return unescape(a)},set_cookie:function(e,t,a,o,n,r){var i=null==a?null:24*a*60*60;this.set_cookie_sec(e,t,i,o,n,r)},set_cookie_sec:function(e,t,a,o,n,r){var i=new Date;i.setSeconds(i.getSeconds()+parseInt(a)),document.cookie=e+"="+escape(t)+(null==a?"":"; expires="+i.toUTCString())+(null==o?"; path=/":"; path="+o)+(null==n?"":"; domain="+n)+(null==r?"":"; secure")},cookie_exists:function(e){var t=this.get_cookie(e);return null!==t&&""!==t&&void 0!==t},move:function(e,t,a){var o=jQuery(e),n=t;if(void 0===a&&(a={}),void 0===a.css&&(a.css={}),void 0===a.method&&(a.method="prependTo"),""===t&&void 0!==a.target)switch(a.target){case"wrapper":var r="left";void 0!==a.offset&&(r=a.offset),t=this.find_wrapper(e,r)}switch(1<(t=void 0===a.moveintohidden?jQuery(t).filter(":visible"):jQuery(t)).length&&console.log("Advanced Ads: element '"+n+"' found "+t.length+" times."),a.method){case"insertBefore":o.insertBefore(t);break;case"insertAfter":o.insertAfter(t);break;case"appendTo":o.appendTo(t);break;case"prependTo":o.prependTo(t);break;default:o.prependTo(t)}},set_parent_relative:function(e,t){var t=void 0!==t?t:{},a=jQuery(e).parent();t.use_grandparent&&(a=a.parent()),"static"!==a.css("position")&&""!==a.css("position")||a.css("position","relative")},fix_element:function(e,t){var t=void 0!==t?t:{},a=jQuery(e);t.use_grandparent?this.set_parent_relative(a.parent()):this.set_parent_relative(a),t.is_invisible&&a.show();var o,n=parseInt(a.offset().top),r=parseInt(a.offset().left);t.is_invisible&&a.hide(),"left"===t.offset?(o=jQuery(window).width()-r-a.outerWidth(),a.css("position","fixed").css("top",n+"px").css("right",o+"px").css("left","")):a.css("position","fixed").css("top",n+"px").css("left",r+"px").css("right","")},find_wrapper:function(o,n){var r;return jQuery("body").children().each(function(e,t){if(t.id!==o.substring(1)){var a=jQuery(t);if("right"===n&&a.offset().left+jQuery(a).width()<jQuery(window).width()||"left"===n&&0<a.offset().left)return"static"!==a.css("position")&&""!==a.css("position")||a.css("position","relative"),r=t,!1}}),r},center_fixed_element:function(e){var t=jQuery(e),a=jQuery(window).width()/2-parseInt(t.css("width"))/2;t.css("left",a+"px")},center_vertically:function(e){var t=jQuery(e),a=jQuery(window).height()/2-parseInt(t.css("height"))/2;"fixed"!==t.css("position")&&(a-=topoffset=parseInt(t.offset().top)),t.css("top",a+"px")},close:function(e){jQuery(e).remove()},wait_for_images:function(n,r){var i=0,s=[];n.find('img[src][src!=""]').each(function(){s.push(this.src)}),0===s.length&&r.call(n),jQuery.each(s,function(e,t){var a=new Image;a.src=t;var o="load error";jQuery(a).one(o,function e(t){if(jQuery(this).off(o,e),++i==s.length)return r.call(n[0]),!1})})},privacy:{state:"unknown",state_executed:!1,get_state:function(){if("unknown"!==window.advads_options.privacy.state)return advads.privacy.state_executed||(advads.privacy.state_executed=!0,advads.privacy.dispatch_event(window.advads_options.privacy.state,!1)),advads.privacy.state;advads.privacy.state_executed=!0;var t=0,a=setInterval(function(){switch(600===t&&clearInterval(a),window.advads_options.privacy["consent-method"]){case"custom":var e=new RegExp(window.advads_options.privacy["custom-cookie-name"]+"=.*?"+window.advads_options.privacy["custom-cookie-value"]+"[^;]*");null!==document.cookie.match(e)&&(clearInterval(a),"accepted"!==advads.privacy.state&&advads.privacy.dispatch_event("accepted",!0));break;case"iab_tcf_20":if(void 0===window.__tcfapi)return;clearInterval(a),window.__tcfapi("addEventListener",2,function(e,t){if(t&&("tcloaded"===e.eventStatus||"useractioncomplete"===e.eventStatus)){var a="useractioncomplete"===e.eventStatus;if(!e.gdprApplies)return void("not_needed"!==advads.privacy.state&&advads.privacy.dispatch_event("not_needed",a));if(e.purpose.consents[1])return void("accepted"!==advads.privacy.state&&advads.privacy.dispatch_event("accepted",a));"rejected"!==advads.privacy.state&&advads.privacy.dispatch_event("rejected",a)}})}t++},100);return advads.privacy.state},is_adsense_npa_enabled:function(){return!window.advads_options||!window.advads_options.privacy||!(!window.advads_options.privacy["show-non-personalized-adsense"]||"custom"!==window.advads_options.privacy["consent-method"])},dispatch_event:function(e,t){var a=advads.privacy.state;advads.privacy.state=e,document.dispatchEvent(new CustomEvent("advanced_ads_privacy",{detail:{state:e,previousState:a,userAction:t}}))},is_ad_decoded:function(e){return null===document.querySelector('script[data-tcf="waiting-for-consent"][data-id="'+e+'"]')},decode_ad:function(e,t){t="boolean"!=typeof t||t;var a=decodeURIComponent(Array.prototype.map.call(atob(e.textContent),function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));if(!t)return a;e.replaceWith(document.createRange().createContextualFragment(a))}}},(window.advanced_ads_ready||jQuery(document).ready).call(null,function(){advads.privacy.get_state()}),document.addEventListener("advanced_ads_privacy",function(e){"accepted"!==e.detail.state&&"not_needed"!==e.detail.state||e.detail.userAction||"loading"===document.readyState||document.querySelectorAll('script[type="text/plain"][data-tcf="waiting-for-consent"]').forEach(advads.privacy.decode_ad)}),jQuery(document).ready(function(){var i,s,d,c;!advads.supports_localstorage()||!localStorage.getItem("advads_frontend_picker")||window.advads_options.blog_id&&localStorage.getItem("advads_frontend_blog_id")&&window.advads_options.blog_id!==localStorage.getItem("advads_frontend_blog_id")||localStorage.getItem("advads_frontend_starttime")&&parseInt(localStorage.getItem("advads_frontend_starttime"),10)<(new Date).getTime()-27e5&&(localStorage.removeItem("advads_frontend_action"),localStorage.removeItem("advads_frontend_element"),localStorage.removeItem("advads_frontend_picker"),localStorage.removeItem("advads_prev_url"),localStorage.removeItem("advads_frontend_pathtype"),localStorage.removeItem("advads_frontend_boundary"),localStorage.removeItem("advads_frontend_blog_id"),localStorage.removeItem("advads_frontend_starttime"),!void advads.set_cookie("advads_frontend_picker","",-1))||(s=jQuery("<div id='advads-picker-overlay'>"),d=[document.body,document.documentElement,document],s.css({position:"absolute",border:"solid 2px #428bca",backgroundColor:"rgba(66,139,202,0.5)",boxSizing:"border-box",zIndex:1e6,pointerEvents:"none"}).prependTo("body"),"true"===localStorage.getItem("advads_frontend_boundary")&&jQuery("body").css("cursor","not-allowed"),window.advads.is_boundary_reached=function(e){if("true"!==localStorage.getItem("advads_frontend_boundary"))return!1;$advads_picker_cur=jQuery(e);var t=jQuery(".advads-frontend-picker-boundary-helper");return $boundaries=t.parent(),$boundaries.css("cursor","pointer"),$advads_picker_cur.is($boundaries)||!$advads_picker_cur.closest($boundaries).length},c="xpath"===localStorage.getItem("advads_frontend_pathtype")?"getXPath":"getPath",jQuery(document).mousemove(function(e){if(e.target!==i){if(~d.indexOf(e.target))return i=null,void s.hide();var t=jQuery(e.target),a=t.offset(),o=t.outerWidth(),n=t.outerHeight();i=e.target;var r=jQuery(i)[c]();r&&(console.log(r),s.css({top:a.top,left:a.left,width:o,height:n}).show())}}),jQuery(document).click(function(e){var t=jQuery(i)[c]();advads.is_boundary_reached(i)||(localStorage.setItem("advads_frontend_element",t),window.location=localStorage.getItem("advads_prev_url"))}))}),jQuery.fn.extend({getPath:function(e,t){if(void 0===e&&(e=""),void 0===t&&(t=0),this.is("html"))return"html > "+e;if(3===t)return e;var a=this.get(0).nodeName.toLowerCase(),o=this.attr("id"),n=this.attr("class");return t+=1,void 0===o||/\d/.test(o)?void 0!==n&&(n=n.split(/[\s\n]+/),(n=jQuery.grep(n,function(e,t){return!/\d/.test(e)})).length&&(a+="."+n.slice(0,2).join("."))):a+="#"+o,this.siblings(a).length&&(a+=":eq("+this.siblings(a).addBack().not("#advads-picker-overlay").index(this)+")"),""===e?this.parent().getPath(a,t):this.parent().getPath(a+" > "+e,t)},getXPath:function(e,t){if(void 0===e&&(e=""),void 0===t&&(t=0),this.is("body")||3===t)return e;if(advads.is_boundary_reached(this))return e;var a,o=this.get(0).nodeName.toLowerCase(),n=o,r=this.attr("id"),i=this.attr("class"),s=[];if(void 0!==r&&!/\d/.test(r))return n+'[@id and id="'+r+'"]/'+e;if(void 0!==i&&(i=i.split(/[\s\n]+/),(i=jQuery.grep(i,function(e,t){return!/\d/.test(e)})).length)){t+=1;for(var s=i.slice(0,2),d=[],c=0;c<s.length;c++)d.push('(@class and contains(concat(" ", normalize-space(@class), " "), " '+s[c]+' "))');n+="["+d.join(" and ")+"]"}return(a=s.length?this.siblings(o+"."+s.join(".")):this.siblings(o)).length&&(n+="["+a.addBack().not("#advads-picker-overlay").index(this)+"]"),""===e?this.parent().getXPath(n,t):this.parent().getXPath(n+"/"+e,t)}});
1
+ advads={supports_localstorage:function(){"use strict";try{return window&&void 0!==window.localStorage?(window.localStorage.setItem("x","x"),window.localStorage.removeItem("x"),!0):!1}catch(e){return!1}},max_per_session:function(e,t){var a=1;if(void 0!==t&&0!==parseInt(t)||(t=1),this.cookie_exists(e)){if(this.get_cookie(e)>=t)return!0;a+=parseInt(this.get_cookie(e))}return this.set_cookie(e,a),!1},count_up:function(e,t){var a=1;this.cookie_exists(e)&&(a+=parseInt(this.get_cookie(e))),this.set_cookie(e,a)},set_cookie_exists:function(e){return!!get_cookie(e)||(set_cookie(e,"",0),!1)},get_cookie:function(e){for(var t,a,o=document.cookie.split(";"),n=0;n<o.length;n++)if(t=o[n].substr(0,o[n].indexOf("=")),a=o[n].substr(o[n].indexOf("=")+1),(t=t.replace(/^\s+|\s+$/g,""))===e)return unescape(a)},set_cookie:function(e,t,a,o,n,r){var i=null==a?null:24*a*60*60;this.set_cookie_sec(e,t,i,o,n,r)},set_cookie_sec:function(e,t,a,o,n,r){var i=new Date;i.setSeconds(i.getSeconds()+parseInt(a)),document.cookie=e+"="+escape(t)+(null==a?"":"; expires="+i.toUTCString())+(null==o?"; path=/":"; path="+o)+(null==n?"":"; domain="+n)+(null==r?"":"; secure")},cookie_exists:function(e){var t=this.get_cookie(e);return null!==t&&""!==t&&void 0!==t},move:function(e,t,a){var o=jQuery(e),n=t;if(void 0===a&&(a={}),void 0===a.css&&(a.css={}),void 0===a.method&&(a.method="prependTo"),""===t&&void 0!==a.target)switch(a.target){case"wrapper":var r="left";void 0!==a.offset&&(r=a.offset),t=this.find_wrapper(e,r)}switch(1<(t=void 0===a.moveintohidden?jQuery(t).filter(":visible"):jQuery(t)).length&&console.log("Advanced Ads: element '"+n+"' found "+t.length+" times."),a.method){case"insertBefore":o.insertBefore(t);break;case"insertAfter":o.insertAfter(t);break;case"appendTo":o.appendTo(t);break;case"prependTo":o.prependTo(t);break;default:o.prependTo(t)}},set_parent_relative:function(e,t){var t=void 0!==t?t:{},a=jQuery(e).parent();t.use_grandparent&&(a=a.parent()),"static"!==a.css("position")&&""!==a.css("position")||a.css("position","relative")},fix_element:function(e,t){var t=void 0!==t?t:{},a=jQuery(e);t.use_grandparent?this.set_parent_relative(a.parent()):this.set_parent_relative(a),t.is_invisible&&a.show();var o,n=parseInt(a.offset().top),r=parseInt(a.offset().left);t.is_invisible&&a.hide(),"left"===t.offset?(o=jQuery(window).width()-r-a.outerWidth(),a.css("position","fixed").css("top",n+"px").css("right",o+"px").css("left","")):a.css("position","fixed").css("top",n+"px").css("left",r+"px").css("right","")},find_wrapper:function(o,n){var r;return jQuery("body").children().each(function(e,t){if(t.id!==o.substring(1)){var a=jQuery(t);if("right"===n&&a.offset().left+jQuery(a).width()<jQuery(window).width()||"left"===n&&0<a.offset().left)return"static"!==a.css("position")&&""!==a.css("position")||a.css("position","relative"),r=t,!1}}),r},center_fixed_element:function(e){var t=jQuery(e),a=jQuery(window).width()/2-parseInt(t.css("width"))/2;t.css("left",a+"px")},center_vertically:function(e){var t=jQuery(e),a=jQuery(window).height()/2-parseInt(t.css("height"))/2;"fixed"!==t.css("position")&&(a-=topoffset=parseInt(t.offset().top)),t.css("top",a+"px")},close:function(e){jQuery(e).remove()},wait_for_images:function(n,r){var i=0,s=[];n.find('img[src][src!=""]').each(function(){s.push(this.src)}),0===s.length&&r.call(n),jQuery.each(s,function(e,t){var a=new Image;a.src=t;var o="load error";jQuery(a).one(o,function e(t){if(jQuery(this).off(o,e),++i==s.length)return r.call(n[0]),!1})})},privacy:{state:"unknown",state_executed:!1,get_state:function(){if("unknown"!==window.advads_options.privacy.state)return advads.privacy.state_executed||(advads.privacy.state_executed=!0,advads.privacy.dispatch_event(window.advads_options.privacy.state,!1)),advads.privacy.state;var e;"custom"===window.advads_options.privacy["consent-method"]&&(e=new RegExp(window.advads_options.privacy["custom-cookie-name"]+"=.*?"+window.advads_options.privacy["custom-cookie-value"]+"[^;]*"),advads.privacy.state_executed||(advads.privacy.state_executed=!0,advads.privacy.dispatch_event(null!==document.cookie.match(e)?"accepted":"unknown",!0))),advads.privacy.state_executed=!0;var t=0,a=setInterval(function(){switch(600==++t&&clearInterval(a),window.advads_options.privacy["consent-method"]){case"custom":null!==document.cookie.match(e)&&(clearInterval(a),"accepted"!==advads.privacy.state&&advads.privacy.dispatch_event("accepted",!0));break;case"iab_tcf_20":if(void 0===window.__tcfapi)return;clearInterval(a),window.__tcfapi("addEventListener",2,function(e,t){if(t&&("tcloaded"===e.eventStatus||"useractioncomplete"===e.eventStatus)){var a="useractioncomplete"===e.eventStatus;if(!e.gdprApplies)return void("not_needed"!==advads.privacy.state&&advads.privacy.dispatch_event("not_needed",a));if(e.purpose.consents[1])return void("accepted"!==advads.privacy.state&&advads.privacy.dispatch_event("accepted",a));"rejected"!==advads.privacy.state&&advads.privacy.dispatch_event("rejected",a)}})}},100);return advads.privacy.state},is_adsense_npa_enabled:function(){return!window.advads_options||!window.advads_options.privacy||!(!window.advads_options.privacy["show-non-personalized-adsense"]||"custom"!==window.advads_options.privacy["consent-method"])},dispatch_event:function(e,t){function a(){document.dispatchEvent(new CustomEvent("advanced_ads_privacy",{detail:{state:e,previousState:o,userAction:t}}))}var o=advads.privacy.state;if(advads.privacy.state=e,"loading"!==document.readyState)return a();document.addEventListener("readystatechange",a,{once:!0})},is_ad_decoded:function(e){return null===document.querySelector('script[data-tcf="waiting-for-consent"][data-id="'+e+'"]')},decode_ad:function(e,t){t="boolean"!=typeof t||t;var a=decodeURIComponent(Array.prototype.map.call(atob(e.textContent),function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));if(!t)return a;e.replaceWith(document.createRange().createContextualFragment(a))}}},(window.advanced_ads_ready||jQuery(document).ready).call(null,function(){advads.privacy.get_state()}),document.addEventListener("advanced_ads_privacy",function(e){"accepted"!==e.detail.state&&"not_needed"!==e.detail.state||e.detail.userAction||"loading"===document.readyState||document.querySelectorAll('script[type="text/plain"][data-tcf="waiting-for-consent"]').forEach(advads.privacy.decode_ad)}),jQuery(document).ready(function(){var i,s,d,c;!advads.supports_localstorage()||!localStorage.getItem("advads_frontend_picker")||window.advads_options.blog_id&&localStorage.getItem("advads_frontend_blog_id")&&window.advads_options.blog_id!==localStorage.getItem("advads_frontend_blog_id")||localStorage.getItem("advads_frontend_starttime")&&parseInt(localStorage.getItem("advads_frontend_starttime"),10)<(new Date).getTime()-27e5&&(localStorage.removeItem("advads_frontend_action"),localStorage.removeItem("advads_frontend_element"),localStorage.removeItem("advads_frontend_picker"),localStorage.removeItem("advads_prev_url"),localStorage.removeItem("advads_frontend_pathtype"),localStorage.removeItem("advads_frontend_boundary"),localStorage.removeItem("advads_frontend_blog_id"),localStorage.removeItem("advads_frontend_starttime"),!void advads.set_cookie("advads_frontend_picker","",-1))||(s=jQuery("<div id='advads-picker-overlay'>"),d=[document.body,document.documentElement,document],s.css({position:"absolute",border:"solid 2px #428bca",backgroundColor:"rgba(66,139,202,0.5)",boxSizing:"border-box",zIndex:1e6,pointerEvents:"none"}).prependTo("body"),"true"===localStorage.getItem("advads_frontend_boundary")&&jQuery("body").css("cursor","not-allowed"),window.advads.is_boundary_reached=function(e){if("true"!==localStorage.getItem("advads_frontend_boundary"))return!1;$advads_picker_cur=jQuery(e);var t=jQuery(".advads-frontend-picker-boundary-helper");return $boundaries=t.parent(),$boundaries.css("cursor","pointer"),$advads_picker_cur.is($boundaries)||!$advads_picker_cur.closest($boundaries).length},c="xpath"===localStorage.getItem("advads_frontend_pathtype")?"getXPath":"getPath",jQuery(document).mousemove(function(e){if(e.target!==i){if(~d.indexOf(e.target))return i=null,void s.hide();var t=jQuery(e.target),a=t.offset(),o=t.outerWidth(),n=t.outerHeight();i=e.target;var r=jQuery(i)[c]();r&&(console.log(r),s.css({top:a.top,left:a.left,width:o,height:n}).show())}}),jQuery(document).click(function(e){var t=jQuery(i)[c]();advads.is_boundary_reached(i)||(localStorage.setItem("advads_frontend_element",t),window.location=localStorage.getItem("advads_prev_url"))}))}),jQuery.fn.extend({getPath:function(e,t){if(void 0===e&&(e=""),void 0===t&&(t=0),this.is("html"))return"html > "+e;if(3===t)return e;var a=this.get(0).nodeName.toLowerCase(),o=this.attr("id"),n=this.attr("class");return t+=1,void 0===o||/\d/.test(o)?void 0!==n&&(n=n.split(/[\s\n]+/),(n=jQuery.grep(n,function(e,t){return!/\d/.test(e)})).length&&(a+="."+n.slice(0,2).join("."))):a+="#"+o,this.siblings(a).length&&(a+=":eq("+this.siblings(a).addBack().not("#advads-picker-overlay").index(this)+")"),""===e?this.parent().getPath(a,t):this.parent().getPath(a+" > "+e,t)},getXPath:function(e,t){if(void 0===e&&(e=""),void 0===t&&(t=0),this.is("body")||3===t)return e;if(advads.is_boundary_reached(this))return e;var a,o=this.get(0).nodeName.toLowerCase(),n=o,r=this.attr("id"),i=this.attr("class"),s=[];if(void 0!==r&&!/\d/.test(r))return n+'[@id and id="'+r+'"]/'+e;if(void 0!==i&&(i=i.split(/[\s\n]+/),(i=jQuery.grep(i,function(e,t){return!/\d/.test(e)})).length)){t+=1;for(var s=i.slice(0,2),d=[],c=0;c<s.length;c++)d.push('(@class and contains(concat(" ", normalize-space(@class), " "), " '+s[c]+' "))');n+="["+d.join(" and ")+"]"}return(a=s.length?this.siblings(o+"."+s.join(".")):this.siblings(o)).length&&(n+="["+a.addBack().not("#advads-picker-overlay").index(this)+"]"),""===e?this.parent().getXPath(n,t):this.parent().getXPath(n+"/"+e,t)}});
public/assets/js/advanced.orig.js CHANGED
@@ -392,6 +392,16 @@ advads = {
392
  return advads.privacy.state;
393
  }
394
 
 
 
 
 
 
 
 
 
 
 
395
  // make sure this only gets executed once.
396
  advads.privacy.state_executed = true;
397
 
@@ -399,14 +409,13 @@ advads = {
399
  var cnt = 0,
400
  consentSetInterval = setInterval(function () {
401
  // Bail if we have not gotten a consent response after 60 seconds.
402
- if (cnt === 600) {
403
  clearInterval(consentSetInterval);
404
  }
405
  switch (window.advads_options.privacy['consent-method']) {
406
  case 'custom' :
407
  // check if custom cookie is set and matches value.
408
- var regex = new RegExp(window.advads_options.privacy['custom-cookie-name'] + '=.*?' + window.advads_options.privacy['custom-cookie-value'] + '[^;]*');
409
- if (document.cookie.match(regex) !== null) {
410
  clearInterval(consentSetInterval);
411
  if (advads.privacy.state !== 'accepted') {
412
  advads.privacy.dispatch_event('accepted', true);
@@ -450,8 +459,6 @@ advads = {
450
  );
451
  break;
452
  }
453
-
454
- cnt++;
455
  }, 100);
456
 
457
  return advads.privacy.state;
@@ -475,20 +482,32 @@ advads = {
475
  * @param {boolean} userAction This is result of action by user.
476
  */
477
  dispatch_event: function (state, userAction) {
478
- var previousState = advads.privacy.state;
 
 
 
 
 
 
 
 
 
 
479
  advads.privacy.state = state;
 
480
  console.log({
481
  state: state,
482
  previousState: previousState,
483
  userAction: userAction
484
  });
485
- document.dispatchEvent(new CustomEvent('advanced_ads_privacy', {
486
- detail: {
487
- state: state,
488
- previousState: previousState,
489
- userAction: userAction
490
- }
491
- }));
 
492
  },
493
  /**
494
  * Check if ad is decoded.
392
  return advads.privacy.state;
393
  }
394
 
395
+ // If using the cookie method, fire an initial event, regardless if cookie set or not.
396
+ if (window.advads_options.privacy['consent-method'] === 'custom') {
397
+ var cookie_regex = new RegExp(window.advads_options.privacy['custom-cookie-name'] + '=.*?' + window.advads_options.privacy['custom-cookie-value'] + '[^;]*');
398
+ // Force the event, if we haven't yet fired one.
399
+ if (!advads.privacy.state_executed) {
400
+ advads.privacy.state_executed = true;
401
+ advads.privacy.dispatch_event(document.cookie.match(cookie_regex) !== null ? 'accepted' : 'unknown', true);
402
+ }
403
+ }
404
+
405
  // make sure this only gets executed once.
406
  advads.privacy.state_executed = true;
407
 
409
  var cnt = 0,
410
  consentSetInterval = setInterval(function () {
411
  // Bail if we have not gotten a consent response after 60 seconds.
412
+ if (++cnt === 600) {
413
  clearInterval(consentSetInterval);
414
  }
415
  switch (window.advads_options.privacy['consent-method']) {
416
  case 'custom' :
417
  // check if custom cookie is set and matches value.
418
+ if (document.cookie.match(cookie_regex) !== null) {
 
419
  clearInterval(consentSetInterval);
420
  if (advads.privacy.state !== 'accepted') {
421
  advads.privacy.dispatch_event('accepted', true);
459
  );
460
  break;
461
  }
 
 
462
  }, 100);
463
 
464
  return advads.privacy.state;
482
  * @param {boolean} userAction This is result of action by user.
483
  */
484
  dispatch_event: function (state, userAction) {
485
+ var previousState = advads.privacy.state,
486
+ fire_event = function () {
487
+ document.dispatchEvent(new CustomEvent('advanced_ads_privacy', {
488
+ detail: {
489
+ state: state,
490
+ previousState: previousState,
491
+ userAction: userAction
492
+ }
493
+ }));
494
+ };
495
+
496
  advads.privacy.state = state;
497
+
498
  console.log({
499
  state: state,
500
  previousState: previousState,
501
  userAction: userAction
502
  });
503
+
504
+ // DOM is ready.
505
+ if (document.readyState !== 'loading') {
506
+ return fire_event();
507
+ }
508
+
509
+ // If DOM is still loading, wait for it to be interactive/complete.
510
+ document.addEventListener('readystatechange', fire_event, {once: true});
511
  },
512
  /**
513
  * Check if ad is decoded.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: ads, ad manager, ad rotation, adsense, banner
4
  Requires at least: 4.6
5
  Tested up to: 5.5
6
  Requires PHP: 5.6
7
- Stable tag: 1.20.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -317,6 +317,12 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
317
 
318
  == Changelog ==
319
 
 
 
 
 
 
 
320
  = 1.20.1 =
321
 
322
  - don't escape top anchor ads code as a whole, user input has already been escaped
4
  Requires at least: 4.6
5
  Tested up to: 5.5
6
  Requires PHP: 5.6
7
+ Stable tag: 1.20.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
317
 
318
  == Changelog ==
319
 
320
+ = 1.20.2 =
321
+
322
+ - fixed displaying image ads if privacy method is set to custom cookie
323
+ - fixed scroll to last edited placement with non-English letters
324
+ - fixed minor UI issues
325
+
326
  = 1.20.1 =
327
 
328
  - don't escape top anchor ads code as a whole, user input has already been escaped