Advanced Ads - Version 1.8.21

Version Description

  • added more checks for conflicting plugins
  • show critical warnings also on settings page
  • reopen placement options that were opened last when saving the placement list
  • added check for missing PHP extensions
  • updated label for bot detection setting and warn, if current user is bot-like
  • minified ad block counter code in frontend or remove, if not used
  • introduced advanced-ads-ad-image-tag-style filter to adjust image ad style
  • fixed images not being centered when in a placement
Download this release

Release Info

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

Code changes from version 1.8.20 to 1.8.21

admin/assets/js/admin.js CHANGED
@@ -221,7 +221,6 @@ jQuery( document ).ready(function ($) {
221
  $('#advads-last-edited-group').val('');
222
  } else {
223
  advadsgroupformrow.show();
224
- // attach current group id to url to open it later again
225
  var group_id = $( this ).parents( '.advads-group-row' ).find('.advads-group-id').val();
226
  $('#advads-last-edited-group').val( group_id );
227
 
@@ -237,6 +236,21 @@ jQuery( document ).ready(function ($) {
237
  usagediv.show();
238
  }
239
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  // display manual placement usage
241
  $( '.advads-placements-table .usage-link' ).click(function(e){
242
  e.preventDefault();
221
  $('#advads-last-edited-group').val('');
222
  } else {
223
  advadsgroupformrow.show();
 
224
  var group_id = $( this ).parents( '.advads-group-row' ).find('.advads-group-id').val();
225
  $('#advads-last-edited-group').val( group_id );
226
 
236
  usagediv.show();
237
  }
238
  });
239
+ // display placement settings form
240
+ $( '.advads-placements-table a.advads-placement-options-link' ).click(function(e){
241
+ e.preventDefault();
242
+ var advadsplacementformrow = $( this ).next( '.advads-placements-advanced-options' );
243
+ if( advadsplacementformrow.is( ':visible' ) ){
244
+ advadsplacementformrow.hide();
245
+ // clear last edited id
246
+ $('#advads-last-edited-placement').val('');
247
+ } else {
248
+ advadsplacementformrow.show();
249
+ var placement_id = $( this ).parents( '.advads-placements-table-options' ).find('.advads-placement-slug').val();
250
+ $('#advads-last-edited-placement').val( placement_id );
251
+
252
+ }
253
+ });
254
  // display manual placement usage
255
  $( '.advads-placements-table .usage-link' ).click(function(e){
256
  e.preventDefault();
admin/includes/class-licenses.php CHANGED
@@ -160,8 +160,8 @@ class Advanced_Ads_Admin_Licenses {
160
  }
161
  } else {
162
  // reset license_expires admin notification
163
- Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expires' );
164
- Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expired' );
165
  Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_invalid' );
166
  // save license key
167
  $licenses = $this->get_licenses();
@@ -254,7 +254,6 @@ class Advanced_Ads_Admin_Licenses {
254
  if( 'deactivated' === $license_data->license ) {
255
  delete_option( $options_slug . '-license-status' );
256
  delete_option( $options_slug . '-license-expires' );
257
- Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expires' );
258
  } elseif( 'failed' === $license_data->license ) {
259
  update_option($options_slug . '-license-expires', $license_data->expires, false);
260
  update_option($options_slug . '-license-status', $license_data->license, false);
160
  }
161
  } else {
162
  // reset license_expires admin notification
163
+ Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expires' ); // this one is no longer added, but we keep the check here in case it is still in the queue for some users
164
+ Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expired' ); // this one is no longer added, but we keep the check here in case it is still in the queue for some users
165
  Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_invalid' );
166
  // save license key
167
  $licenses = $this->get_licenses();
254
  if( 'deactivated' === $license_data->license ) {
255
  delete_option( $options_slug . '-license-status' );
256
  delete_option( $options_slug . '-license-expires' );
 
257
  } elseif( 'failed' === $license_data->license ) {
258
  update_option($options_slug . '-license-expires', $license_data->expires, false);
259
  update_option($options_slug . '-license-status', $license_data->license, false);
admin/includes/class-notices.php CHANGED
@@ -203,15 +203,6 @@ class Advanced_Ads_Admin_Notices {
203
  } else {
204
  $this->remove_from_queue( 'license_invalid' );
205
  }
206
-
207
- // check expired licenses
208
- if ( Advanced_Ads_Checks::licenses_expired() ){
209
- if( ! in_array( 'license_expired', $queue )) {
210
- $this->notices[] = 'license_expired';
211
- }
212
- } else {
213
- $this->remove_from_queue( 'license_expired' );
214
- }
215
  }
216
 
217
  /**
203
  } else {
204
  $this->remove_from_queue( 'license_invalid' );
205
  }
 
 
 
 
 
 
 
 
 
206
  }
207
 
208
  /**
admin/includes/class-settings.php CHANGED
@@ -452,8 +452,11 @@ class Advanced_Ads_Admin_Settings {
452
  $checked = ( ! empty($options['block-bots'])) ? 1 : 0;
453
 
454
  echo '<input id="advanced-ads-block-bots" type="checkbox" value="1" name="'.ADVADS_SLUG.'[block-bots]" '.checked( $checked, 1, false ).'>';
455
- echo '<p class="description">'. sprintf( __( 'Hide ads from crawlers, bots and empty user agents. Also prevents counting impressions for bots when using the <a href="%s" target="_blank">Tracking Add-On</a>.', 'advanced-ads' ), ADVADS_URL . 'add-ons/tracking/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings' ) .'<br/>'
456
- . __( 'Disabling this option only makes sense if your ads contain content you want to display to bots (like search engines) or your site is cached and bots could create a cached version without the ads.', 'advanced-ads' ) . '</p>';
 
 
 
457
  }
458
 
459
  /**
452
  $checked = ( ! empty($options['block-bots'])) ? 1 : 0;
453
 
454
  echo '<input id="advanced-ads-block-bots" type="checkbox" value="1" name="'.ADVADS_SLUG.'[block-bots]" '.checked( $checked, 1, false ).'>';
455
+ if( Advanced_Ads::get_instance()->is_bot() ){
456
+ echo '<span class="advads-error-message">' . __( 'You look like a bot', 'advanced-ads' ) . '</a>. </span>';
457
+ }
458
+ echo '<span class="description"><a href="'. ADVADS_URL . 'hide-ads-from-bots/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings" target="blank">'. __( 'Read this first', 'advanced-ads' ) . '</a></span>';
459
+ echo '<p class="description">'. __( 'Hide ads from crawlers, bots and empty user agents.', 'advanced-ads' ) .'</p>';
460
  }
461
 
462
  /**
admin/includes/notices.php CHANGED
@@ -39,13 +39,6 @@ $advanced_ads_admin_notices = apply_filters( 'advanced-ads-notices', array(
39
  'license_invalid' => array(
40
  'type' => 'plugin_error',
41
  'text' => __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>.', 'advanced-ads' ) . ' ' . sprintf( __( 'Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ), get_admin_url( 1, 'admin.php?page=advanced-ads-settings#top#licenses' ) ),
42
- 'global' => true
43
- ),
44
- // license expired
45
- 'license_expired' => array(
46
- 'type' => 'plugin_error',
47
- 'text' => sprintf( __( '<strong>Advanced Ads</strong> license(s) expired. Support and updates are disabled. Please visit <a href="%s"> the license page</a> for more information.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#licenses' ) ),
48
- 'global' => true
49
  ),
50
  // please review
51
  'review' => array(
39
  'license_invalid' => array(
40
  'type' => 'plugin_error',
41
  'text' => __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>.', 'advanced-ads' ) . ' ' . sprintf( __( 'Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ), get_admin_url( 1, 'admin.php?page=advanced-ads-settings#top#licenses' ) ),
 
 
 
 
 
 
 
42
  ),
43
  // please review
44
  'review' => array(
admin/views/checks.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * a couple of checks to see if there is any critical issue
5
+ * listed on support and settings page
6
+ */
7
+
8
+ $messages = array();
9
+ if( ! Advanced_Ads_Checks::php_version_minimum() ) :
10
+ $messages[] = sprintf(__( 'Your <strong>PHP version (%s) is too low</strong>. Advanced Ads is built for PHP 5.3 and higher. It might work, but updating PHP is highly recommended. Please ask your hosting provider for more information.', 'advanced-ads' ), phpversion() );
11
+ endif;
12
+ if( Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ) ) :
13
+ $messages[] = sprintf(__( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
14
+ endif;
15
+ if( Advanced_Ads_Checks::wp_update_available() ) :
16
+ $messages[] = __( 'There is a <strong>new WordPress version available</strong>. Please update.', 'advanced-ads' );
17
+ endif;
18
+ if( Advanced_Ads_Checks::plugin_updates_available() ) :
19
+ $messages[] = __( 'There are <strong>plugin updates available</strong>. Please update.', 'advanced-ads' );
20
+ endif;
21
+ if( Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ) :
22
+ $messages[] = sprintf(__( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
23
+ endif;
24
+ if( count( Advanced_Ads_Checks::conflicting_plugins() ) ) :
25
+ $messages[] = sprintf(__( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ), ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
26
+ endif;
27
+ if( count( Advanced_Ads_Checks::php_extensions() ) ) :
28
+ $messages[] = sprintf(__( 'Missing PHP extensions could cause issues. Please ask your hosting provider to enable them: %s', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::php_extensions() ) );
29
+ endif;
30
+ if( Advanced_Ads_Checks::ads_disabled() ) :
31
+ $messages[] = sprintf(__( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ), admin_url('admin.php?page=advanced-ads-settings#top#general') );
32
+ endif;
33
+ if( defined( 'IS_WPCOM' ) ) :
34
+ $messages[] = __( 'This site is hosted on wordpress.com.', 'advanced-ads' );
35
+ endif;
36
+ Advanced_Ads_Checks::jquery_ui_conflict();
37
+
38
+ $messages = apply_filters( 'advanced-ads-support-messages', $messages );
39
+
40
+ if( count( $messages )) :
41
+ foreach( $messages as $_message ) :
42
+ ?><div class="message error"><p><?php echo $_message; ?></p></div><?php
43
+ endforeach;
44
+ endif;
admin/views/placements.php CHANGED
@@ -60,6 +60,7 @@
60
  endif;
61
  ?></td>
62
  <td class="advads-placements-table-options">
 
63
  <?php if( ! isset( $_placement['type'] ) || 'default' === $_placement['type']) : ?>
64
  <div class="hidden advads-usage">
65
  <label><?php _e( 'shortcode', 'advanced-ads' ); ?>
@@ -124,9 +125,10 @@
124
  do_action( 'advanced-ads-placement-options-after-advanced', $_placement_slug, $_placement );
125
  $advanced_options = ob_get_clean();
126
  if( $advanced_options ) :
127
- ?><a class="advads-toggle-link" onclick="advads_toggle('.advads-placements-advanced-options-<?php
128
- echo $_placement_slug; ?>')"><?php _e( 'show all options', 'advanced-ads' ); ?></a>
129
- <div class="advads-placements-advanced-options-<?php echo $_placement_slug; ?>" style="display: none"><?php
 
130
  echo $advanced_options;
131
  ?></div><?php
132
  endif;
@@ -152,6 +154,7 @@
152
  _e( 'New Placement', 'advanced-ads' ); ?></button>
153
  <?php do_action( 'advanced-ads-placements-list-buttons', $placements ); ?>
154
  </div>
 
155
  </form>
156
  <?php do_action( 'advanced-ads-placements-list-after', $placements );
157
  endif;
60
  endif;
61
  ?></td>
62
  <td class="advads-placements-table-options">
63
+ <input type="hidden" class="advads-placement-slug" value="<?php echo $_placement_slug; ?>"/>
64
  <?php if( ! isset( $_placement['type'] ) || 'default' === $_placement['type']) : ?>
65
  <div class="hidden advads-usage">
66
  <label><?php _e( 'shortcode', 'advanced-ads' ); ?>
125
  do_action( 'advanced-ads-placement-options-after-advanced', $_placement_slug, $_placement );
126
  $advanced_options = ob_get_clean();
127
  if( $advanced_options ) :
128
+ ?><a class="advads-toggle-link advads-placement-options-link"><?php _e( 'show all options', 'advanced-ads' ); ?></a>
129
+ <?php
130
+ $hidden = ( isset( $_POST['advads-last-edited-placement'] ) && $_placement_slug == $_POST['advads-last-edited-placement'] ) ? '' : ' hidden'; ?>
131
+ <div class="advads-placements-advanced-options advads-placements-advanced-options-<?php echo $_placement_slug; echo $hidden; ?>"><?php
132
  echo $advanced_options;
133
  ?></div><?php
134
  endif;
154
  _e( 'New Placement', 'advanced-ads' ); ?></button>
155
  <?php do_action( 'advanced-ads-placements-list-buttons', $placements ); ?>
156
  </div>
157
+ <input type="hidden" name="advads-last-edited-placement" id="advads-last-edited-placement" value="0"/>
158
  </form>
159
  <?php do_action( 'advanced-ads-placements-list-after', $placements );
160
  endif;
admin/views/setting-license.php CHANGED
@@ -12,7 +12,7 @@ ob_start();
12
  name="advads_license_activate"><?php _e( 'Update expiry date', 'advanced-ads' ); ?></button><?php
13
  $update_button = ob_get_clean();
14
 
15
- $expired_error .= $expired_renew_link = ' ' . sprintf(__( 'Click on %2$s if you renewed it or have a subscription or <a href="%1$s" target="_blank">renew your license with a discount</a>.', 'advanced-ads' ), ADVADS_URL . 'checkout/?edd_license_key=' . esc_attr($license_key) . '#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses', $update_button );
16
  if( 'lifetime' !== $expires ){
17
  $expires_time = strtotime( $expires );
18
  $days_left = ( $expires_time - time() ) / DAY_IN_SECONDS;
12
  name="advads_license_activate"><?php _e( 'Update expiry date', 'advanced-ads' ); ?></button><?php
13
  $update_button = ob_get_clean();
14
 
15
+ $expired_error .= $expired_renew_link = ' ' . sprintf(__( 'Click on %2$s if you renewed it or have a subscription or <a href="%1$s" target="_blank">renew your license</a>.', 'advanced-ads' ), ADVADS_URL . 'checkout/?edd_license_key=' . esc_attr($license_key) . '#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses', $update_button );
16
  if( 'lifetime' !== $expires ){
17
  $expires_time = strtotime( $expires );
18
  $days_left = ( $expires_time - time() ) / DAY_IN_SECONDS;
admin/views/settings.php CHANGED
@@ -14,6 +14,8 @@ $setting_tabs = apply_filters('advanced-ads-setting-tabs', array(
14
  ));
15
  ?><div class="wrap">
16
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
 
 
17
  <?php settings_errors(); ?>
18
  <div class="nav-tab-wrapper" id="advads-tabs">
19
  <?php foreach ( $setting_tabs as $_setting_tab_id => $_setting_tab ) : ?>
14
  ));
15
  ?><div class="wrap">
16
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
17
+ <?php Advanced_Ads_Checks::show_issues(); ?>
18
+
19
  <?php settings_errors(); ?>
20
  <div class="nav-tab-wrapper" id="advads-tabs">
21
  <?php foreach ( $setting_tabs as $_setting_tab_id => $_setting_tab ) : ?>
admin/views/support.php CHANGED
@@ -6,43 +6,8 @@
6
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
7
  <p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
8
 
9
- <?php $messages = array();
10
- if( ! Advanced_Ads_Checks::php_version_minimum() ) :
11
- $messages[] = sprintf(__( 'Your <strong>PHP version (%s) is too low</strong>. Advanced Ads is built for PHP 5.3 and higher. It might work, but updating PHP is highly recommended. Please ask your hosting provider for more information.', 'advanced-ads' ), phpversion() );
12
- endif;
13
- if( Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ) ) :
14
- $messages[] = sprintf(__( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
15
- endif;
16
- if( Advanced_Ads_Checks::wp_update_available() ) :
17
- $messages[] = __( 'There is a <strong>new WordPress version available</strong>. Please update.', 'advanced-ads' );
18
- endif;
19
- if( Advanced_Ads_Checks::plugin_updates_available() ) :
20
- $messages[] = __( 'There are <strong>plugin updates available</strong>. Please update.', 'advanced-ads' );
21
- endif;
22
- /* if( Advanced_Ads_Checks::licenses_invalid() ) :
23
- $messages[] = sprintf( __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>. Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#licenses' ) );
24
- endif;
25
- if( Advanced_Ads_Checks::licenses_expired() ) :
26
- $messages[] = sprintf( __( '<strong>Advanced Ads</strong> license(s) expired. Support and updates are disabled. Please visit <a href="%s"> the license page</a> for more information.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#licenses' ) );
27
- endif;*/
28
- if( Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ) :
29
- $messages[] = sprintf(__( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
30
- endif;
31
- if( count( Advanced_Ads_Checks::conflicting_plugins() ) ) :
32
- $messages[] = sprintf(__( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ), ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
33
- endif;
34
- if( Advanced_Ads_Checks::ads_disabled() ) :
35
- $messages[] = sprintf(__( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ), admin_url('admin.php?page=advanced-ads-settings#top#general') );
36
- endif;
37
- Advanced_Ads_Checks::jquery_ui_conflict();
38
-
39
- $messages = apply_filters( 'advanced-ads-support-messages', $messages );
40
 
41
- if( count( $messages )) :
42
- foreach( $messages as $_message ) :
43
- ?><div class="message error"><p><?php echo $_message; ?></p></div><?php
44
- endforeach;
45
- endif; ?>
46
  <h2><?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
47
  <ul>
48
  <li><a href="<?php echo ADVADS_URL; ?>manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Ads not showing up', 'advanced-ads' ); ?></a></li>
6
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
7
  <p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
8
 
9
+ <?php Advanced_Ads_Checks::show_issues(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
 
 
 
11
  <h2><?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
12
  <ul>
13
  <li><a href="<?php echo ADVADS_URL; ?>manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Ads not showing up', 'advanced-ads' ); ?></a></li>
advanced-ads.php CHANGED
@@ -6,13 +6,13 @@
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
  * @link http://webgilde.com
9
- * @copyright 2013-2017 Thomas Maier, webgilde GmbH
10
  *
11
  * @wordpress-plugin
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
- * Version: 1.8.20
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, textdomain
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
- define( 'ADVADS_VERSION', '1.8.20' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
  * @link http://webgilde.com
9
+ * @copyright 2013-2018 Thomas Maier, webgilde GmbH
10
  *
11
  * @wordpress-plugin
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.8.21
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, textdomain
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
+ define( 'ADVADS_VERSION', '1.8.21' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/ad_ajax_callbacks.php CHANGED
@@ -35,6 +35,7 @@ class Advanced_Ads_Ad_Ajax_Callbacks {
35
  add_action( 'wp_ajax_advads-post-search', array( $this, 'post_search' ) );
36
  add_action( 'wp_ajax_advads-ad-injection-content', array( $this, 'inject_placement' ) );
37
  add_action( 'wp_ajax_advads-save-hide-wizard-state', array( $this, 'save_wizard_state' ) );
 
38
 
39
  }
40
 
@@ -413,4 +414,20 @@ class Advanced_Ads_Ad_Ajax_Callbacks {
413
  die();
414
  }
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
35
  add_action( 'wp_ajax_advads-post-search', array( $this, 'post_search' ) );
36
  add_action( 'wp_ajax_advads-ad-injection-content', array( $this, 'inject_placement' ) );
37
  add_action( 'wp_ajax_advads-save-hide-wizard-state', array( $this, 'save_wizard_state' ) );
38
+ add_action( 'wp_ajax_advads-adsense-enable-pla', array( $this, 'adsense_enable_pla' ) );
39
 
40
  }
41
 
414
  die();
415
  }
416
 
417
+ /**
418
+ * Enable Adsense Page-level ads.
419
+ */
420
+ public function adsense_enable_pla(){
421
+
422
+ check_ajax_referer( 'advanced-ads-admin-ajax-nonce', 'nonce' );
423
+
424
+ if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options') ) ) {
425
+ return;
426
+ }
427
+
428
+ $options = get_option( GADSENSE_OPT_NAME, array() );
429
+ $options['page-level-enabled'] = true;
430
+ update_option( GADSENSE_OPT_NAME, $options );
431
+ die();
432
+ }
433
  }
classes/ad_placements.php CHANGED
@@ -82,8 +82,11 @@ class Advanced_Ads_Placements {
82
  if( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_placements') ) ) {
83
  return;
84
  }
85
-
86
  $success = null;
 
 
 
87
 
88
  if ( isset($_POST['advads']['placement']) && check_admin_referer( 'advads-placement', 'advads_placement' ) ){
89
  $success = self::save_new_placement( $_POST['advads']['placement'] );
@@ -97,7 +100,7 @@ class Advanced_Ads_Placements {
97
 
98
  if(isset($success)){
99
  $message = $success ? 'updated' : 'error';
100
- wp_redirect( esc_url_raw( add_query_arg(array('message' => $message)) ) );
101
  }
102
  }
103
 
82
  if( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_placements') ) ) {
83
  return;
84
  }
85
+
86
  $success = null;
87
+
88
+ // add hook of last opened placement settings to URL
89
+ $hook = !empty( $_POST['advads-last-edited-placement'] ) ? '#single-placement-' . $_POST['advads-last-edited-placement'] : '';
90
 
91
  if ( isset($_POST['advads']['placement']) && check_admin_referer( 'advads-placement', 'advads_placement' ) ){
92
  $success = self::save_new_placement( $_POST['advads']['placement'] );
100
 
101
  if(isset($success)){
102
  $message = $success ? 'updated' : 'error';
103
+ wp_redirect( esc_url_raw( add_query_arg(array('message' => $message) ) ) . $hook );
104
  }
105
  }
106
 
classes/ad_type_image.php CHANGED
@@ -57,7 +57,7 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
57
  </p>
58
  <input type="hidden" name="advanced_ad[output][image_id]" value="<?php echo $id; ?>" id="advads-image-id"/>
59
  <div id="advads-image-preview">
60
- <?php $this->create_image_tag( $id ); ?>
61
  </div>
62
 
63
  <?php // don’t show if tracking plugin enabled
@@ -72,12 +72,15 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
72
  /**
73
  * render image tag
74
  *
75
- * @param int $attachment_id post id of the image
 
76
  * @since 1.6.10
77
  */
78
- public function create_image_tag( $attachment_id ){
79
 
80
  $image = wp_get_attachment_image_src( $attachment_id, 'full' );
 
 
81
  if ( $image ) {
82
  list( $src, $width, $height ) = $image;
83
  $hwstring = image_hwstring($width, $height);
@@ -103,9 +106,17 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
103
  }
104
  }
105
 
 
 
 
 
 
 
 
 
106
  $more_attributes = apply_filters( 'advanced-ads-ad-image-tag-attributes', $more_attributes );
107
 
108
- echo rtrim("<img $hwstring") . " src='$src' alt='$alt' title='$title' $more_attributes/>";
109
  }
110
  }
111
 
@@ -157,7 +168,7 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
157
 
158
  ob_start();
159
  if( ! defined( 'AAT_VERSION' ) && $url ){ echo '<a href="'. $url .'"'.$target_blank.'>'; }
160
- echo $this->create_image_tag( $id );
161
  if( ! defined( 'AAT_VERSION' ) && $url ){ echo '</a>'; }
162
 
163
  return ob_get_clean();
57
  </p>
58
  <input type="hidden" name="advanced_ad[output][image_id]" value="<?php echo $id; ?>" id="advads-image-id"/>
59
  <div id="advads-image-preview">
60
+ <?php $this->create_image_tag( $id, $ad ); ?>
61
  </div>
62
 
63
  <?php // don’t show if tracking plugin enabled
72
  /**
73
  * render image tag
74
  *
75
+ * @param int $attachment_id post id of the image
76
+ * @param obj $ad ad object, since 1.8.21
77
  * @since 1.6.10
78
  */
79
+ public function create_image_tag( $attachment_id, $ad ){
80
 
81
  $image = wp_get_attachment_image_src( $attachment_id, 'full' );
82
+ $style = '';
83
+
84
  if ( $image ) {
85
  list( $src, $width, $height ) = $image;
86
  $hwstring = image_hwstring($width, $height);
106
  }
107
  }
108
 
109
+ // add css rule to be able to center the ad
110
+ if( isset( $ad->output['position'] ) && 'center' === $ad->output['position'] ){
111
+ $style .= 'display: inline-block;';
112
+ }
113
+
114
+ $style = apply_filters( 'advanced-ads-ad-image-tag-style', $style );
115
+ $style = '' !== $style ? 'style="' . $style . '"' : '';
116
+
117
  $more_attributes = apply_filters( 'advanced-ads-ad-image-tag-attributes', $more_attributes );
118
 
119
+ echo rtrim("<img $hwstring") . " src='$src' alt='$alt' title='$title' $more_attributes $style/>";
120
  }
121
  }
122
 
168
 
169
  ob_start();
170
  if( ! defined( 'AAT_VERSION' ) && $url ){ echo '<a href="'. $url .'"'.$target_blank.'>'; }
171
+ echo $this->create_image_tag( $id, $ad );
172
  if( ! defined( 'AAT_VERSION' ) && $url ){ echo '</a>'; }
173
 
174
  return ob_get_clean();
classes/checks.php CHANGED
@@ -6,6 +6,13 @@
6
  * @since 1.6.9
7
  */
8
  class Advanced_Ads_Checks {
 
 
 
 
 
 
 
9
 
10
  /**
11
  * php version minimum 5.3
@@ -76,10 +83,11 @@ class Advanced_Ads_Checks {
76
  }
77
 
78
  /**
79
- * check if license keys are missing or invalid
80
  *
81
  * @since 1.6.6
82
  * @update 1.6.9 moved from Advanced_Ads_Plugin
 
83
  * @return true if there are missing licenses
84
  */
85
  public static function licenses_invalid(){
@@ -93,6 +101,13 @@ class Advanced_Ads_Checks {
93
  foreach( $add_ons as $_add_on_key => $_add_on ){
94
  $status = Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] );
95
 
 
 
 
 
 
 
 
96
  // don’t check if license is valid
97
  if( $status === 'valid' ) {
98
  continue;
@@ -110,79 +125,7 @@ class Advanced_Ads_Checks {
110
 
111
  return false;
112
  }
113
-
114
- /**
115
- * check if license keys are going to expire within next 14 days
116
- *
117
- * @since 1.6.6
118
- * @update 1.6.9 moved from Advanced_Ads_Plugin
119
- * @return true if there are expiring licenses
120
- */
121
- public static function licenses_expire(){
122
-
123
- $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
124
-
125
- if( $add_ons === array() ) {
126
- return false;
127
- }
128
-
129
- $now = time();
130
-
131
- foreach( $add_ons as $_add_on_key => $_add_on ){
132
- // don’t display error for invalid licenses
133
- if(Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] ) === 'invalid' ) {
134
- continue;
135
- }
136
-
137
- $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
138
-
139
- if( $expiry_date && 'lifetime' !== $expiry_date ){
140
- $expiry_date_t = strtotime( $expiry_date );
141
- $in_two_weeks = time() + ( WEEK_IN_SECONDS * 2) ;
142
- // check if expiry date is within next comming 2 weeks
143
- if( $expiry_date_t < $in_two_weeks && $expiry_date_t >= $now ){
144
- return true;
145
- }
146
-
147
- }
148
- }
149
-
150
- return false;
151
- }
152
-
153
- /**
154
- * check if license keys are already expired
155
- *
156
- * @since 1.6.6
157
- * @update 1.6.9 moved from Advanced_Ads_Plugin
158
- * @return true if there are expired licenses
159
- */
160
- public static function licenses_expired(){
161
-
162
- $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
163
-
164
- if( $add_ons === array() ) {
165
- return false;
166
- }
167
-
168
- $now = time();
169
-
170
- foreach( $add_ons as $_add_on_key => $_add_on ){
171
- // don’t display error for invalid licenses
172
- if(Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] ) === 'invalid' ) {
173
- continue;
174
- }
175
-
176
- $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
177
-
178
- if( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < $now ){
179
- return true;
180
- }
181
- }
182
-
183
- return false;
184
- }
185
-
186
  /**
187
  * Autoptimize plugin installed
188
  * can change ad tags, especially inline css and scripts
@@ -208,9 +151,24 @@ class Advanced_Ads_Checks {
208
 
209
  $conflicting_plugins = array();
210
 
211
- if( defined( 'Publicize_Base' )){ // JetPack Publicize module
 
 
 
212
  $conflicting_plugins[] = 'Jetpack – Publicize';
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  return $conflicting_plugins;
216
  }
@@ -233,6 +191,27 @@ class Advanced_Ads_Checks {
233
  return false;
234
  }
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
  /**
238
  * check for potential jQuery errors
6
  * @since 1.6.9
7
  */
8
  class Advanced_Ads_Checks {
9
+
10
+ /**
11
+ * show the list of potential issues
12
+ */
13
+ public static function show_issues(){
14
+ include_once ADVADS_BASE_PATH . '/admin/views/checks.php';
15
+ }
16
 
17
  /**
18
  * php version minimum 5.3
83
  }
84
 
85
  /**
86
+ * check if license keys are missing or invalid or expired
87
  *
88
  * @since 1.6.6
89
  * @update 1.6.9 moved from Advanced_Ads_Plugin
90
+ * @update 1.8.21 also check for expired licenses
91
  * @return true if there are missing licenses
92
  */
93
  public static function licenses_invalid(){
101
  foreach( $add_ons as $_add_on_key => $_add_on ){
102
  $status = Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] );
103
 
104
+ // check expiry date
105
+ $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
106
+
107
+ if( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < time() ){
108
+ return true;
109
+ }
110
+
111
  // don’t check if license is valid
112
  if( $status === 'valid' ) {
113
  continue;
125
 
126
  return false;
127
  }
128
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  /**
130
  * Autoptimize plugin installed
131
  * can change ad tags, especially inline css and scripts
151
 
152
  $conflicting_plugins = array();
153
 
154
+ if( defined( 'AALB_PLUGIN_CURRENT_VERSION' ) ){ // Amazon Associates Link Builder
155
+ $conflicting_plugins[] = 'Amazon Associates Link Builder';
156
+ }
157
+ if( defined( 'Publicize_Base' ) ){ // JetPack Publicize module
158
  $conflicting_plugins[] = 'Jetpack – Publicize';
159
  }
160
+ if( defined( 'PF__PLUGIN_DIR' ) ){ // Facebook Instant Articles & Google AMP Pages by PageFrog
161
+ $conflicting_plugins[] = 'Facebook Instant Articles & Google AMP Pages by PageFrog';
162
+ }
163
+ if( defined( 'GT_VERSION' ) ){ // GT ShortCodes
164
+ $conflicting_plugins[] = 'GT ShortCodes';
165
+ }
166
+ if( class_exists( 'ITSEC_Core', false ) ){ // iThemes Security
167
+ $conflicting_plugins[] = 'iThemes Security';
168
+ }
169
+ if( class_exists('q2w3_fixed_widget', false) ){ // Q2W3 Fixed Widget
170
+ $conflicting_plugins[] = 'Q2W3 Fixed Widget';
171
+ }
172
 
173
  return $conflicting_plugins;
174
  }
191
  return false;
192
  }
193
 
194
+ /**
195
+ * check for required php extensions
196
+ *
197
+ * @since 1.8.21
198
+ * @return bool
199
+ */
200
+ public static function php_extensions(){
201
+
202
+ $missing_extensions = array();
203
+
204
+ if( !extension_loaded('dom') ){
205
+ $missing_extensions[] = 'dom';
206
+ }
207
+
208
+ if( !extension_loaded('xml') ){
209
+ $missing_extensions[] = 'xml';
210
+ }
211
+
212
+ return $missing_extensions;
213
+ }
214
+
215
 
216
  /**
217
  * check for potential jQuery errors
classes/frontend_checks.php CHANGED
@@ -350,7 +350,8 @@ class Advanced_Ads_Frontend_Checks {
350
  */
351
  public function footer_checks() {
352
  $adsense_options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
353
- ?><!--noptimize--><style>.hidden { display: none; } .advads-adminbar-is-warnings { background: #a54811 ! important; color: #fff !important; }
 
354
  #wp-admin-bar-advanced_ads_ad_health-default a:after { content: "\25BA"; margin-left: .5em; font-size: smaller; }
355
  .advanced-ads-highlight-ads { outline:4px solid blue !important; }</style>
356
  <script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
350
  */
351
  public function footer_checks() {
352
  $adsense_options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
353
+ ?><!-- Advanced Ads: <?php _e( 'the following code is used for automatic error detection and only visible to admins', 'advanced-ads' ); ?>-->
354
+ <!--noptimize--><style>.hidden { display: none; } .advads-adminbar-is-warnings { background: #a54811 ! important; color: #fff !important; }
355
  #wp-admin-bar-advanced_ads_ad_health-default a:after { content: "\25BA"; margin-left: .5em; font-size: smaller; }
356
  .advanced-ads-highlight-ads { outline:4px solid blue !important; }</style>
357
  <script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
classes/plugin.php CHANGED
@@ -163,8 +163,9 @@ class Advanced_Ads_Plugin {
163
  * // Called when DOM is ready.
164
  * } );
165
  */
166
- ?>
167
- <!--noptimize--><script>
 
168
  <?php if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
169
  readfile( ADVADS_BASE_PATH . 'public/assets/js/ready.js' );
170
  } else { ?>
163
  * // Called when DOM is ready.
164
  * } );
165
  */
166
+
167
+ echo apply_filters( 'advanced-ads-attribution', '<!-- managing ads with Advanced Ads -->' );
168
+ ?><!--noptimize--><script>
169
  <?php if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
170
  readfile( ADVADS_BASE_PATH . 'public/assets/js/ready.js' );
171
  } else { ?>
modules/adblock-finder/public/public.php CHANGED
@@ -8,10 +8,23 @@ class Advanced_Ads_Adblock_Finder {
8
 
9
  public function print_adblock_check_js() {
10
  $options = Advanced_Ads::get_instance()->options();
11
-
 
 
 
 
12
  ?><script>
13
  var advanced_ads_adsense_UID = <?php echo isset( $options['ga-UID'] ) ? "'" . esc_js( $options['ga-UID'] ). "'" : 'false' ?>;
14
- <?php readfile( dirname( __FILE__ ) . '/script.js' ); ?>
 
 
 
 
 
 
 
 
 
15
  </script><?php
16
  }
17
- }
8
 
9
  public function print_adblock_check_js() {
10
  $options = Advanced_Ads::get_instance()->options();
11
+
12
+ if ( empty( $options['ga-UID'] ) ) {
13
+ return;
14
+ }
15
+
16
  ?><script>
17
  var advanced_ads_adsense_UID = <?php echo isset( $options['ga-UID'] ) ? "'" . esc_js( $options['ga-UID'] ). "'" : 'false' ?>;
18
+ <?php
19
+
20
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && current_user_can( 'manage_options' ) ) {
21
+ readfile( dirname( __FILE__ ) . '/script.js' );
22
+ } else {
23
+ readfile( dirname( __FILE__ ) . '/script.min.js' );
24
+ }
25
+
26
+ ?>
27
+
28
  </script><?php
29
  }
30
+ }
modules/adblock-finder/public/script.min.js ADDED
@@ -0,0 +1 @@
 
1
+ advanced_ads_check_adblocker=function(t){function e(t){(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return setTimeout(t,16)}).call(window,t)}var n=[],a=null;return e(function(){var t=document.createElement("div");t.innerHTML="&nbsp;",t.setAttribute("class","ad_unit ad-unit text-ad text_ad pub_300x250"),t.setAttribute("style","width: 1px !important; height: 1px !important; position: absolute !important; left: 0px !important; top: 0px !important; overflow: hidden !important;"),document.body.appendChild(t),e(function(){var e=window.getComputedStyle&&window.getComputedStyle(t),o=e&&e.getPropertyValue("-moz-binding");a=e&&"none"===e.getPropertyValue("display")||"string"==typeof o&&-1!==o.indexOf("about:");for(var i=0;i<n.length;i++)n[i](a);n=[]})}),function(t){if(null===a)return void n.push(t);t(a)}}(),function(){var t=function(t,e){this.name=t,this.UID=e,this.analyticsObject=null;var n=this,a={hitType:"event",eventCategory:"Advanced Ads",eventAction:"AdBlock",eventLabel:"Yes",nonInteraction:!0,transport:"beacon"};this.analyticsObject="string"==typeof GoogleAnalyticsObject&&"function"==typeof window[GoogleAnalyticsObject]&&window[GoogleAnalyticsObject],!1===this.analyticsObject?(!function(t,e,n,a,o,i,d){t.GoogleAnalyticsObject=o,t[o]=t[o]||function(){(t[o].q=t[o].q||[]).push(arguments)},t[o].l=1*new Date,i=e.createElement(n),d=e.getElementsByTagName(n)[0],i.async=1,i.src="https://www.google-analytics.com/analytics.js",d.parentNode.insertBefore(i,d)}(window,document,"script",0,"_advads_ga"),_advads_ga("create",n.UID,"auto",this.name),_advads_ga(n.name+".send",a)):(window.console&&window.console.log("Advanced Ads Analytics >> using other's variable named `"+GoogleAnalyticsObject+"`"),window[GoogleAnalyticsObject]("create",n.UID,"auto",this.name),window[GoogleAnalyticsObject](n.name+".send",a))};advanced_ads_check_adblocker(function(e){e&&"string"==typeof advanced_ads_adsense_UID&&advanced_ads_adsense_UID&&new t("advadsTracker",advanced_ads_adsense_UID)})}();
modules/gadsense/admin/admin.php CHANGED
@@ -41,9 +41,15 @@ class Advanced_Ads_AdSense_Admin {
41
  <script type="text/javascript">
42
  var gadsenseData = {
43
  pubId : '<?php echo $pub_id; ?>',
 
44
  msg : {
45
  unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", 'advanced-ads' ); ?>',
46
- pubIdMismatch : '<?php _e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', 'advanced-ads' ); ?>'
 
 
 
 
 
47
  }
48
  };
49
  </script>
41
  <script type="text/javascript">
42
  var gadsenseData = {
43
  pubId : '<?php echo $pub_id; ?>',
44
+ pageLevelEnabled: '<?php echo $db->is_page_level_enabled(); ?>',
45
  msg : {
46
  unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", 'advanced-ads' ); ?>',
47
+ pubIdMismatch : '<?php _e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', 'advanced-ads' ); ?>',
48
+ pageLevelEnabled: '<?php _e( sprintf(__( 'Page-Level ads are already activated in the <a href="%s">AdSense settings</a>. No need to add them manually.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ) ); ?>',
49
+ pageLevelDisabled: '<?php
50
+ printf( '%s <button id="adsense_enable_pla" type="button" class="button">%s</button>',
51
+ esc_attr__( 'This type of ad code is set up in the AdSense settings. Click on the following button to enable it now.', 'advanced-ads' ),
52
+ esc_attr__( 'Activate', 'advanced-ads' ) ); ?>'
53
  }
54
  };
55
  </script>
modules/gadsense/admin/assets/js/new-ad.js CHANGED
@@ -22,26 +22,14 @@
22
  var rawContent = $( '.advads-adsense-content' ).val();
23
 
24
  var parseResult = parseAdContent( rawContent );
25
- if (false === parseResult) {
26
- // Not recognized ad code
27
- $( '#pastecode-msg' ).append( $( '<p />' ).css( 'color', 'red' ).html( gadsenseData.msg.unknownAd ) );
28
- } else {
29
- setDetailsFromAdCode( parseResult );
30
- $( '.advads-adsense-code' ).hide();
31
- $( '.advads-adsense-show-code' ).show();
32
- }
33
-
34
  });
35
 
36
  $( document ).on('click', '#advanced-ad-type-adsense', function(){
37
  $( '#advanced-ads-ad-parameters' ).on('paramloaded', function(){
38
  var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
39
  var parseResult = parseAdContent( content );
40
- if (false !== parseResult) {
41
- setDetailsFromAdCode( parseResult );
42
- $( '.advads-adsense-code' ).hide();
43
- $( '.advads-adsense-show-code' ).show();
44
- }
45
  });
46
  });
47
 
@@ -49,6 +37,11 @@
49
  advads_update_adsense_type();
50
  });
51
 
 
 
 
 
 
52
  function parseAdContent(content) {
53
  var rawContent = ('undefined' != typeof(content))? content.trim() : '';
54
  var theAd = {};
@@ -114,7 +107,36 @@
114
  return theAd;
115
  }
116
  }
117
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
 
120
  /**
@@ -248,4 +270,31 @@
248
 
249
  });
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  })(jQuery);
22
  var rawContent = $( '.advads-adsense-content' ).val();
23
 
24
  var parseResult = parseAdContent( rawContent );
25
+ handleParseResult( parseResult );
 
 
 
 
 
 
 
 
26
  });
27
 
28
  $( document ).on('click', '#advanced-ad-type-adsense', function(){
29
  $( '#advanced-ads-ad-parameters' ).on('paramloaded', function(){
30
  var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
31
  var parseResult = parseAdContent( content );
32
+ handleParseResult( parseResult );
 
 
 
 
33
  });
34
  });
35
 
37
  advads_update_adsense_type();
38
  });
39
 
40
+ /**
41
+ * Parse ad content.
42
+ *
43
+ * @return {!Object}
44
+ */
45
  function parseAdContent(content) {
46
  var rawContent = ('undefined' != typeof(content))? content.trim() : '';
47
  var theAd = {};
107
  return theAd;
108
  }
109
  }
110
+
111
+ /* Page-Level ad */
112
+ if ( rawContent.indexOf( 'enable_page_level_ads' ) !== -1 ) {
113
+ return { 'parse_message': 'pageLevelAd' };
114
+ }
115
+
116
+ /* Unknown ad */
117
+ return { 'parse_message': 'unknownAd' };
118
+ }
119
+
120
+ /**
121
+ * Handle result of parsing content.
122
+ *
123
+ * @param {!Object}
124
+ */
125
+ function handleParseResult( parseResult) {
126
+ $( '#pastecode-msg' ).empty();
127
+ switch ( parseResult.parse_message ) {
128
+ case 'pageLevelAd' :
129
+ showPageLevelAdMessage();
130
+ break;
131
+ case 'unknownAd' :
132
+ // Not recognized ad code
133
+ $( '#pastecode-msg' ).append( $( '<p />' ).css( 'color', 'red' ).html( gadsenseData.msg.unknownAd ) );
134
+ break;
135
+ default:
136
+ setDetailsFromAdCode( parseResult );
137
+ $( '.advads-adsense-code' ).hide();
138
+ $( '.advads-adsense-show-code' ).show();
139
+ }
140
  }
141
 
142
  /**
270
 
271
  });
272
 
273
+ /**
274
+ * Show a message depending on whether Page-Level ads are enabled.
275
+ */
276
+ function showPageLevelAdMessage() {
277
+ var $msg = $( '<p class="advads-success-message" />' ).appendTo ( '#pastecode-msg' );
278
+ if ( gadsenseData.pageLevelEnabled ) {
279
+ $msg.html( gadsenseData.msg.pageLevelEnabled );
280
+ } else {
281
+ $msg.html( gadsenseData.msg.pageLevelDisabled );
282
+ $( document ).on('click', '#adsense_enable_pla', function(){
283
+ $msg.hide();
284
+ $.ajax( {
285
+ type: 'POST',
286
+ url: ajaxurl,
287
+ data: {
288
+ action: 'advads-adsense-enable-pla',
289
+ nonce: advadsglobal.ajax_nonce
290
+ },
291
+ } ).done(function( data ) {
292
+ $msg.show().html( gadsenseData.msg.pageLevelEnabled );
293
+ } ).fail(function( jqXHR, textStatus ) {
294
+ $msg.show();
295
+ } );
296
+ });
297
+ }
298
+ }
299
+
300
  })(jQuery);
modules/gadsense/includes/class-gadsense-data.php CHANGED
@@ -69,4 +69,10 @@ class Advanced_Ads_AdSense_Data {
69
  return self::$instance;
70
  }
71
 
 
 
 
 
 
 
72
  }
69
  return self::$instance;
70
  }
71
 
72
+ /**
73
+ * ISSERS/HASSERS
74
+ */
75
+ public function is_page_level_enabled() {
76
+ return $this->options['page-level-enabled'];
77
+ }
78
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad, ad inserter, ad injection, ad manager, ads manager, ad widget, ad
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.2
8
- Stable tag: 1.8.20
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -226,14 +226,29 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
226
  2. Support for all kinds of ad types, including dedicated AdSense type. AMP is included in the Responsive add-on.
227
  3. Flexible ad input with the Plain Text ad type and code highlighting.
228
  4. Align your ads within the content.
229
- 5. Choose from various conditions where and to whom to display your ads.
 
 
 
230
 
231
  == Changelog ==
232
 
 
 
 
 
 
 
 
 
 
 
 
233
  = 1.8.20 =
234
 
235
  * added "placement_has_ads" and "group_has_ads" functions to test if a placement/group has not empty output
236
  * allowed to rotate ordered ads with same weight
 
237
 
238
  = 1.8.19 =
239
 
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.2
8
+ Stable tag: 1.8.21
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
226
  2. Support for all kinds of ad types, including dedicated AdSense type. AMP is included in the Responsive add-on.
227
  3. Flexible ad input with the Plain Text ad type and code highlighting.
228
  4. Align your ads within the content.
229
+ 5. Dynamically change AdSense ad options in your WordPress backend.
230
+ 6. Choose where to display your ads using many conditions.
231
+ 7. Use various conditions to choose who should see ads (basic plugin and more in add-ons).
232
+ 8. Track impressions and clicks (Tracking add-on).
233
 
234
  == Changelog ==
235
 
236
+ = 1.8.21 =
237
+
238
+ * added more checks for conflicting plugins
239
+ * show critical warnings also on settings page
240
+ * reopen placement options that were opened last when saving the placement list
241
+ * added check for missing PHP extensions
242
+ * updated label for bot detection setting and warn, if current user is bot-like
243
+ * minified ad block counter code in frontend or remove, if not used
244
+ * introduced `advanced-ads-ad-image-tag-style` filter to adjust image ad style
245
+ * fixed images not being centered when in a placement
246
+
247
  = 1.8.20 =
248
 
249
  * added "placement_has_ads" and "group_has_ads" functions to test if a placement/group has not empty output
250
  * allowed to rotate ordered ads with same weight
251
+ * show warning if Page-level ad code is used for AdSense ad type
252
 
253
  = 1.8.19 =
254