Advanced Ads - Version 1.23.1

Version Description

  • removed warning about iThemes Security since it is no longer causing the reported issue
  • added correct icon to Advanced Ads block
  • fixed escaping for AdSense Auto ads codes that use the deprecated "Disable Top Level" option
  • fixed TinyMCE warning in dev console
  • replaced intval() and floatval() with type-casting
Download this release

Release Info

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

Code changes from version 1.23.0 to 1.23.1

admin/includes/class-licenses.php CHANGED
@@ -551,7 +551,6 @@ class Advanced_Ads_Admin_Licenses {
551
  'version' => $_add_on['version'],
552
  'license' => $license_key,
553
  'item_name' => $_add_on['name'],
554
- 'author' => 'Thomas Maier',
555
  )
556
  );
557
  }
551
  'version' => $_add_on['version'],
552
  'license' => $license_key,
553
  'item_name' => $_add_on['name'],
 
554
  )
555
  );
556
  }
admin/includes/class-settings.php CHANGED
@@ -431,7 +431,7 @@ class Advanced_Ads_Admin_Settings {
431
  */
432
  public function render_settings_content_injection_priority() {
433
  $options = Advanced_Ads::get_instance()->options();
434
- $priority = ( isset( $options['content-injection-priority'] ) ) ? intval( $options['content-injection-priority'] ) : 100;
435
 
436
  include ADVADS_BASE_PATH . 'admin/views/settings/general/content-injection-priority.php';
437
  }
431
  */
432
  public function render_settings_content_injection_priority() {
433
  $options = Advanced_Ads::get_instance()->options();
434
+ $priority = ( isset( $options['content-injection-priority'] ) ) ? (int) $options['content-injection-priority'] : 100;
435
 
436
  include ADVADS_BASE_PATH . 'admin/views/settings/general/content-injection-priority.php';
437
  }
admin/includes/class-shortcode-creator.php CHANGED
@@ -63,7 +63,7 @@ class Advanced_Ads_Shortcode_Creator {
63
  if (
64
  (
65
  has_action( 'wp_tiny_mce_init', array( $this, 'print_shortcode_plugin' ) )
66
- || add_action( 'print_default_editor_scripts', array( $this, 'print_shortcode_plugin' ) )
67
  )
68
  && has_filter( 'mce_buttons', array( $this, 'register_buttons' ) )
69
  && has_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ) ) ) {
@@ -84,6 +84,11 @@ class Advanced_Ads_Shortcode_Creator {
84
 
85
  $printed = true;
86
 
 
 
 
 
 
87
  if ( ! $this->hooks_exist() ) {
88
  return;
89
  }
63
  if (
64
  (
65
  has_action( 'wp_tiny_mce_init', array( $this, 'print_shortcode_plugin' ) )
66
+ || has_action( 'print_default_editor_scripts', array( $this, 'print_shortcode_plugin' ) )
67
  )
68
  && has_filter( 'mce_buttons', array( $this, 'register_buttons' ) )
69
  && has_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ) ) ) {
84
 
85
  $printed = true;
86
 
87
+ // the `tinymce` argument of the `wp_editor()` function is set to `false`.
88
+ if ( ! wp_script_is( 'wp-tinymce', 'done' ) ) {
89
+ return;
90
+ }
91
+
92
  if ( ! $this->hooks_exist() ) {
93
  return;
94
  }
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.23.0
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.23.0' );
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.23.1
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.23.1' );
43
 
44
  // Autoloading, modules and functions.
45
 
classes/EDD_SL_Plugin_Updater.php CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.7.1
11
  */
12
  class ADVADS_SL_Plugin_Updater {
13
 
@@ -106,47 +106,50 @@ class ADVADS_SL_Plugin_Updater {
106
  return $_transient_data;
107
  }
108
 
109
- $version_info = $this->get_cached_version_info();
110
-
111
- if ( false === $version_info ) {
112
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
113
-
114
- $this->set_version_info_cache( $version_info );
115
-
 
116
  }
 
 
117
 
118
- if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
119
-
120
- $no_update = false;
121
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
122
-
123
- $_transient_data->response[ $this->name ] = $version_info;
124
 
125
- // Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
126
- $_transient_data->response[ $this->name ]->plugin = $this->name;
 
 
 
 
 
 
127
 
128
- } else {
129
- $no_update = new stdClass();
130
- $no_update->id = '';
131
- $no_update->slug = $this->slug;
132
- $no_update->plugin = $this->name;
133
- $no_update->new_version = $version_info->new_version;
134
- $no_update->url = isset( $version_info->homepage ) ? $version_info->homepage : '';
135
- $no_update->package = isset( $version_info->package ) ? $version_info->package : '';
136
- $no_update->icons = isset( $version_info->icons ) ? $version_info->icons : '';
137
- $no_update->banners = isset( $version_info->banners ) ? $version_info->banners : '';
138
- $no_update->banners_rtl = array();
139
  }
140
 
141
- $_transient_data->last_checked = time();
142
- $_transient_data->checked[ $this->name ] = $this->version;
 
143
 
144
- if ( $no_update ) {
145
- $_transient_data->no_update[ $this->name ] = $no_update;
146
- }
147
  }
148
 
149
- return $_transient_data;
150
  }
151
 
152
  /**
@@ -173,7 +176,7 @@ class ADVADS_SL_Plugin_Updater {
173
  return;
174
  }
175
 
176
- // Remove our filter on the site transient.
177
  remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
178
 
179
  $update_cache = get_site_transient( 'update_plugins' );
@@ -182,12 +185,12 @@ class ADVADS_SL_Plugin_Updater {
182
 
183
  if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
184
 
185
- $version_info = $this->get_cached_version_info();
186
 
187
  if ( false === $version_info ) {
188
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
189
 
190
- // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now.
191
  if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
192
  $version_info->banners = $this->convert_object_to_array( $version_info->banners );
193
  }
@@ -211,29 +214,14 @@ class ADVADS_SL_Plugin_Updater {
211
  return;
212
  }
213
 
214
- $no_update = false;
215
  if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
216
-
217
  $update_cache->response[ $this->name ] = $version_info;
218
-
219
  } else {
220
- $no_update = new stdClass();
221
- $no_update->id = '';
222
- $no_update->slug = $this->slug;
223
- $no_update->plugin = $this->name;
224
- $no_update->new_version = $version_info->new_version;
225
- $no_update->url = isset( $version_info->homepage ) ? $version_info->homepage : '';
226
- $no_update->package = isset( $version_info->package ) ? $version_info->package : '';
227
- $no_update->icons = isset( $version_info->icons ) ? $version_info->icons : '';
228
- $no_update->banners = isset( $version_info->banners ) ? $version_info->banners : '';
229
- $no_update->banners_rtl = array();
230
  }
231
 
232
  $update_cache->last_checked = time();
233
  $update_cache->checked[ $this->name ] = $this->version;
234
- if ( $no_update ) {
235
- $update_cache->no_update[ $this->name ] = $no_update;
236
- }
237
 
238
  set_site_transient( 'update_plugins', $update_cache );
239
 
@@ -243,12 +231,12 @@ class ADVADS_SL_Plugin_Updater {
243
 
244
  }
245
 
246
- // Restore our filter.
247
  add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
248
 
249
  if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
250
 
251
- // Build a plugin list row, with update notification.
252
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
253
  # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
254
  echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
@@ -408,8 +396,8 @@ class ADVADS_SL_Plugin_Updater {
408
  * @uses wp_remote_post()
409
  * @uses is_wp_error()
410
  *
411
- * @param string $_action The requested action.
412
- * @param array $_data Parameters for the API action.
413
  * @return false|object
414
  */
415
  private function api_request( $_action, $_data ) {
@@ -437,13 +425,13 @@ class ADVADS_SL_Plugin_Updater {
437
  }
438
 
439
  if ( false === $edd_plugin_url_available[ $store_hash ] ) {
440
- return;
441
  }
442
 
443
  $data = array_merge( $this->api_data, $_data );
444
 
445
  if ( $data['slug'] != $this->slug ) {
446
- return;
447
  }
448
 
449
  if( $this->api_url == trailingslashit ( home_url() ) ) {
@@ -482,7 +470,7 @@ class ADVADS_SL_Plugin_Updater {
482
  $request->icons = maybe_unserialize( $request->icons );
483
  }
484
 
485
- if( ! empty( $request->sections ) ) {
486
  foreach( $request->sections as $key => $section ) {
487
  $request->$key = (array) $section;
488
  }
@@ -550,7 +538,7 @@ class ADVADS_SL_Plugin_Updater {
550
 
551
  $this->set_version_info_cache( $version_info );
552
 
553
- // Delete the unneeded option.
554
  delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
555
  }
556
 
@@ -579,7 +567,7 @@ class ADVADS_SL_Plugin_Updater {
579
  $cache = get_option( $cache_key );
580
 
581
  if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
582
- return false; // Cache is expired.
583
  }
584
 
585
  // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
@@ -611,7 +599,7 @@ class ADVADS_SL_Plugin_Updater {
611
 
612
  update_option( $cache_key, $data, 'no' );
613
 
614
- // Delete the duplicate option.
615
  delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
616
  }
617
 
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
+ * @version 1.8.0
11
  */
12
  class ADVADS_SL_Plugin_Updater {
13
 
106
  return $_transient_data;
107
  }
108
 
109
+ $current = $this->get_repo_api_data();
110
+ if ( false !== $current && is_object( $current ) && isset( $current->new_version ) ) {
111
+ if ( version_compare( $this->version, $current->new_version, '<' ) ) {
112
+ $_transient_data->response[ $this->name ] = $current;
113
+ } else {
114
+ // Populating the no_update information is required to support auto-updates in WordPress 5.5.
115
+ $_transient_data->no_update[ $this->name ] = $current;
116
+ }
117
  }
118
+ $_transient_data->last_checked = time();
119
+ $_transient_data->checked[ $this->name ] = $this->version;
120
 
121
+ return $_transient_data;
122
+ }
 
 
 
 
123
 
124
+ /**
125
+ * Get repo API data from store.
126
+ * Save to cache.
127
+ *
128
+ * @return stdClass
129
+ */
130
+ public function get_repo_api_data() {
131
+ $version_info = $this->get_cached_version_info();
132
 
133
+ if ( false === $version_info ) {
134
+ $version_info = $this->api_request(
135
+ 'plugin_latest_version',
136
+ array(
137
+ 'slug' => $this->slug,
138
+ 'beta' => $this->beta,
139
+ )
140
+ );
141
+ if ( ! $version_info ) {
142
+ return false;
 
143
  }
144
 
145
+ // This is required for your plugin to support auto-updates in WordPress 5.5.
146
+ $version_info->plugin = $this->name;
147
+ $version_info->id = $this->name;
148
 
149
+ $this->set_version_info_cache( $version_info );
 
 
150
  }
151
 
152
+ return $version_info;
153
  }
154
 
155
  /**
176
  return;
177
  }
178
 
179
+ // Remove our filter on the site transient
180
  remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
181
 
182
  $update_cache = get_site_transient( 'update_plugins' );
185
 
186
  if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
187
 
188
+ $version_info = $this->get_repo_api_data();
189
 
190
  if ( false === $version_info ) {
191
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
192
 
193
+ // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
194
  if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
195
  $version_info->banners = $this->convert_object_to_array( $version_info->banners );
196
  }
214
  return;
215
  }
216
 
 
217
  if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
 
218
  $update_cache->response[ $this->name ] = $version_info;
 
219
  } else {
220
+ $update_cache->no_update[ $this->name ] = $version_info;
 
 
 
 
 
 
 
 
 
221
  }
222
 
223
  $update_cache->last_checked = time();
224
  $update_cache->checked[ $this->name ] = $this->version;
 
 
 
225
 
226
  set_site_transient( 'update_plugins', $update_cache );
227
 
231
 
232
  }
233
 
234
+ // Restore our filter
235
  add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
236
 
237
  if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
238
 
239
+ // build a plugin list row, with update notification
240
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
241
  # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
242
  echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
396
  * @uses wp_remote_post()
397
  * @uses is_wp_error()
398
  *
399
+ * @param string $_action The requested action.
400
+ * @param array $_data Parameters for the API action.
401
  * @return false|object
402
  */
403
  private function api_request( $_action, $_data ) {
425
  }
426
 
427
  if ( false === $edd_plugin_url_available[ $store_hash ] ) {
428
+ return false;
429
  }
430
 
431
  $data = array_merge( $this->api_data, $_data );
432
 
433
  if ( $data['slug'] != $this->slug ) {
434
+ return false;
435
  }
436
 
437
  if( $this->api_url == trailingslashit ( home_url() ) ) {
470
  $request->icons = maybe_unserialize( $request->icons );
471
  }
472
 
473
+ if ( ! empty( $request->sections ) ) {
474
  foreach( $request->sections as $key => $section ) {
475
  $request->$key = (array) $section;
476
  }
538
 
539
  $this->set_version_info_cache( $version_info );
540
 
541
+ // Delete the unneeded option
542
  delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
543
  }
544
 
567
  $cache = get_option( $cache_key );
568
 
569
  if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
570
+ return false; // Cache is expired
571
  }
572
 
573
  // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
599
 
600
  update_option( $cache_key, $data, 'no' );
601
 
602
+ // Delete the duplicate option
603
  delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
604
  }
605
 
classes/ad_type_group.php CHANGED
@@ -11,7 +11,7 @@
11
  * Class containing information about the plain text/code ad type
12
  *
13
  * see ad-type-content.php for a better sample on ad type
14
- *
15
  * @since 1.7.1.1
16
  *
17
  */
@@ -32,32 +32,36 @@ class Advanced_Ads_Ad_Type_Group extends Advanced_Ads_Ad_Type_Abstract{
32
  $this->parameters = array(
33
  'group_id' => 0
34
  );
35
-
36
  // on save, remove the group in which the ad is itself to prevent infinite loops
37
  add_action( 'save_post_advanced_ads', array($this, 'remove_from_ad_group'), 1 );
38
  }
39
-
40
  /**
41
  * When saving the ad, remove it from the ad group, if this is the group assigned as ad content
42
  * see also: /admin/includes/class-ad-groups-list.php::update_groups()
 
 
43
  */
44
  public function remove_from_ad_group( $post_id ){
45
-
 
46
  if( ! isset( $_POST['post_type'] ) || $_POST['post_type'] !== Advanced_Ads::POST_TYPE_SLUG ){
47
  return;
48
  }
49
-
50
  if( isset( $_POST[ 'advanced_ad' ]['output']['group_id'] ) ){
51
- $group_id = intval( $_POST[ 'advanced_ad' ]['output']['group_id'] );
52
  if( isset( $_POST['tax_input']['advanced_ads_groups'] ) ){
53
  if(( $key = array_search( $group_id, $_POST['tax_input']['advanced_ads_groups'])) !== false ) {
54
  $res = wp_remove_object_terms( $post_id, $group_id, Advanced_Ads::AD_GROUP_TAXONOMY );
55
  unset( $_POST['tax_input']['advanced_ads_groups'][$key] );
56
  }
57
  }
58
- }
 
59
  }
60
-
61
 
62
  /**
63
  * Output for the ad parameters metabox
@@ -69,29 +73,29 @@ class Advanced_Ads_Ad_Type_Group extends Advanced_Ads_Ad_Type_Abstract{
69
  * @param obj $ad ad object
70
  */
71
  public function render_parameters($ad){
72
-
73
  $group_id = ( isset( $ad->output['group_id'] ) ) ? $ad->output['group_id'] : '';
74
-
75
  $select = array();
76
  $model = Advanced_Ads::get_instance()->get_model();
77
 
78
  // load all ad groups
79
  $groups = $model->get_ad_groups();
80
-
81
  if( ! is_array( $groups ) || ! count( $groups ) ){
82
  return;
83
  }
84
-
85
  ?><label for="advads-group-id" class="label"><?php _e('ad group', 'advanced-ads'); ?></label><div><select name="advanced_ad[output][group_id]" id="advads-group-id"><?php
86
 
87
  foreach ( $groups as $_group ) {
88
  ?><option value="<?php echo $_group->term_id; ?>" <?php selected( $_group->term_id, $group_id ); ?>><?php echo $_group->name; ?></option><?php
89
  }
90
-
91
  ?></select></div><hr/><?php
92
 
93
  }
94
-
95
  /**
96
  * Prepare the ads frontend output
97
  *
@@ -106,4 +110,4 @@ class Advanced_Ads_Ad_Type_Group extends Advanced_Ads_Ad_Type_Abstract{
106
  }
107
  }
108
 
109
- }
11
  * Class containing information about the plain text/code ad type
12
  *
13
  * see ad-type-content.php for a better sample on ad type
14
+ *
15
  * @since 1.7.1.1
16
  *
17
  */
32
  $this->parameters = array(
33
  'group_id' => 0
34
  );
35
+
36
  // on save, remove the group in which the ad is itself to prevent infinite loops
37
  add_action( 'save_post_advanced_ads', array($this, 'remove_from_ad_group'), 1 );
38
  }
39
+
40
  /**
41
  * When saving the ad, remove it from the ad group, if this is the group assigned as ad content
42
  * see also: /admin/includes/class-ad-groups-list.php::update_groups()
43
+ *
44
+ * @param integer $post_id ID of the post.
45
  */
46
  public function remove_from_ad_group( $post_id ){
47
+
48
+ // phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce is verified before calling the hook
49
  if( ! isset( $_POST['post_type'] ) || $_POST['post_type'] !== Advanced_Ads::POST_TYPE_SLUG ){
50
  return;
51
  }
52
+
53
  if( isset( $_POST[ 'advanced_ad' ]['output']['group_id'] ) ){
54
+ $group_id = (int) $_POST['advanced_ad']['output']['group_id'];
55
  if( isset( $_POST['tax_input']['advanced_ads_groups'] ) ){
56
  if(( $key = array_search( $group_id, $_POST['tax_input']['advanced_ads_groups'])) !== false ) {
57
  $res = wp_remove_object_terms( $post_id, $group_id, Advanced_Ads::AD_GROUP_TAXONOMY );
58
  unset( $_POST['tax_input']['advanced_ads_groups'][$key] );
59
  }
60
  }
61
+ }
62
+ // phpcs:enable
63
  }
64
+
65
 
66
  /**
67
  * Output for the ad parameters metabox
73
  * @param obj $ad ad object
74
  */
75
  public function render_parameters($ad){
76
+
77
  $group_id = ( isset( $ad->output['group_id'] ) ) ? $ad->output['group_id'] : '';
78
+
79
  $select = array();
80
  $model = Advanced_Ads::get_instance()->get_model();
81
 
82
  // load all ad groups
83
  $groups = $model->get_ad_groups();
84
+
85
  if( ! is_array( $groups ) || ! count( $groups ) ){
86
  return;
87
  }
88
+
89
  ?><label for="advads-group-id" class="label"><?php _e('ad group', 'advanced-ads'); ?></label><div><select name="advanced_ad[output][group_id]" id="advads-group-id"><?php
90
 
91
  foreach ( $groups as $_group ) {
92
  ?><option value="<?php echo $_group->term_id; ?>" <?php selected( $_group->term_id, $group_id ); ?>><?php echo $_group->name; ?></option><?php
93
  }
94
+
95
  ?></select></div><hr/><?php
96
 
97
  }
98
+
99
  /**
100
  * Prepare the ads frontend output
101
  *
110
  }
111
  }
112
 
113
+ }
classes/checks.php CHANGED
@@ -203,7 +203,6 @@ class Advanced_Ads_Checks {
203
  * @return array $plugins names of conflicting plugins
204
  */
205
  public static function conflicting_plugins() {
206
-
207
  $conflicting_plugins = array();
208
 
209
  if ( defined( 'Publicize_Base' ) ) { // JetPack Publicize module.
@@ -215,9 +214,6 @@ class Advanced_Ads_Checks {
215
  if ( defined( 'GT_VERSION' ) ) { // GT ShortCodes.
216
  $conflicting_plugins[] = 'GT ShortCodes';
217
  }
218
- if ( class_exists( 'ITSEC_Core', false ) && defined( 'AAP_VERSION' ) ) { // iThemes Security, but only if Pro is enabled.
219
- $conflicting_plugins[] = 'iThemes Security';
220
- }
221
  if ( class_exists( 'SimilarPosts', false ) ) { // Similar Posts, https://de.wordpress.org/plugins/similar-posts/.
222
  $conflicting_plugins[] = 'Similar Posts';
223
  }
203
  * @return array $plugins names of conflicting plugins
204
  */
205
  public static function conflicting_plugins() {
 
206
  $conflicting_plugins = array();
207
 
208
  if ( defined( 'Publicize_Base' ) ) { // JetPack Publicize module.
214
  if ( defined( 'GT_VERSION' ) ) { // GT ShortCodes.
215
  $conflicting_plugins[] = 'GT ShortCodes';
216
  }
 
 
 
217
  if ( class_exists( 'SimilarPosts', false ) ) { // Similar Posts, https://de.wordpress.org/plugins/similar-posts/.
218
  $conflicting_plugins[] = 'Similar Posts';
219
  }
classes/display-conditions.php CHANGED
@@ -795,7 +795,7 @@ class Advanced_Ads_Display_Conditions {
795
  $name = self::get_form_name_with_index( $form_name, $index );
796
 
797
  $operator = isset( $options['operator'] ) ? $options['operator'] : 'older_than';
798
- $value = ( isset( $options['value'] ) && is_numeric( $options['value'] ) ) ? floatval( $options['value'] ) : 0;
799
 
800
  self::render_type_field( $options['type'], $name );
801
 
795
  $name = self::get_form_name_with_index( $form_name, $index );
796
 
797
  $operator = isset( $options['operator'] ) ? $options['operator'] : 'older_than';
798
+ $value = ( isset( $options['value'] ) && is_numeric( $options['value'] ) ) ? (float) $options['value'] : 0;
799
 
800
  self::render_type_field( $options['type'], $name );
801
 
classes/plugin.php CHANGED
@@ -573,7 +573,7 @@ class Advanced_Ads_Plugin {
573
  public function get_content_injection_priority() {
574
  $options = $this->options();
575
 
576
- return isset( $options['content-injection-priority'] ) ? intval( $options['content-injection-priority'] ) : 100;
577
  }
578
 
579
  /**
573
  public function get_content_injection_priority() {
574
  $options = $this->options();
575
 
576
+ return isset( $options['content-injection-priority'] ) ? (int) $options['content-injection-priority'] : 100;
577
  }
578
 
579
  /**
languages/advanced-ads.pot CHANGED
@@ -1,15 +1,15 @@
1
- # Copyright (C) 2020 Thomas Maier, Advanced Ads GmbH
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.23.0\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-12-29T07:56:23+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"
@@ -513,11 +513,11 @@ msgstr ""
513
  msgid "License couldn’t be deactivated. Please try again later."
514
  msgstr ""
515
 
516
- #: admin/includes/class-licenses.php:607
517
  msgid "Download failed. <a href=\"%s\">Click here to try another method</a>."
518
  msgstr ""
519
 
520
- #: admin/includes/class-licenses.php:609
521
  msgid "Download failed. <a href=\"%s\" target=\"_blank\">Click here to learn why</a>."
522
  msgstr ""
523
 
@@ -544,7 +544,7 @@ msgstr ""
544
 
545
  #: admin/includes/class-menu.php:80
546
  #: admin/includes/class-menu.php:81
547
- #: admin/includes/class-shortcode-creator.php:177
548
  #: admin/views/ad-group-list-form-row.php:91
549
  #: admin/views/ad-group-list-header.php:16
550
  #: admin/views/placement-form.php:88
@@ -581,7 +581,7 @@ msgid "Ad Placements"
581
  msgstr ""
582
 
583
  #: admin/includes/class-menu.php:132
584
- #: admin/includes/class-shortcode-creator.php:191
585
  #: admin/views/placements.php:54
586
  #: classes/widget.php:115
587
  #: modules/gutenberg/includes/class-gutenberg.php:81
@@ -995,13 +995,13 @@ msgctxt "label before ads"
995
  msgid "Advertisements"
996
  msgstr ""
997
 
998
- #: admin/includes/class-shortcode-creator.php:175
999
  #: classes/widget.php:113
1000
  #: modules/gutenberg/includes/class-gutenberg.php:77
1001
  msgid "--empty--"
1002
  msgstr ""
1003
 
1004
- #: admin/includes/class-shortcode-creator.php:184
1005
  #: admin/views/placement-form.php:81
1006
  #: admin/views/placements-item.php:14
1007
  #: classes/widget.php:122
@@ -2484,7 +2484,7 @@ msgstr ""
2484
 
2485
  #. translators: %1$s is an anchor (link) opening tag, %2$s is the closing tag.
2486
  #: classes/ad-health-notices.php:865
2487
- #: modules/gadsense/includes/class-mapi.php:1682
2488
  msgid "Learn more about AdSense account issues %1$shere%2$s."
2489
  msgstr ""
2490
 
@@ -2636,7 +2636,7 @@ msgstr ""
2636
  msgid "Choose an existing ad group. Use this type when you want to assign the same display and visitor conditions to all ads in that group."
2637
  msgstr ""
2638
 
2639
- #: classes/ad_type_group.php:85
2640
  msgid "ad group"
2641
  msgstr ""
2642
 
@@ -2892,19 +2892,19 @@ msgstr ""
2892
  msgid "days"
2893
  msgstr ""
2894
 
2895
- #: classes/EDD_SL_Plugin_Updater.php:262
2896
  msgid "There is a new version of %1$s available. %2$sView version %3$s details%4$s."
2897
  msgstr ""
2898
 
2899
- #: classes/EDD_SL_Plugin_Updater.php:270
2900
  msgid "There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s."
2901
  msgstr ""
2902
 
2903
- #: classes/EDD_SL_Plugin_Updater.php:514
2904
  msgid "You do not have permission to install plugin updates"
2905
  msgstr ""
2906
 
2907
- #: classes/EDD_SL_Plugin_Updater.php:514
2908
  msgid "Error"
2909
  msgstr ""
2910
 
@@ -3648,8 +3648,18 @@ msgstr ""
3648
  msgid "Your AdSense Publisher ID is missing."
3649
  msgstr ""
3650
 
3651
- #: modules/gadsense/includes/class-adsense-report.php:472
3652
- #: modules/gadsense/includes/class-adsense-report.php:498
 
 
 
 
 
 
 
 
 
 
3653
  msgid "Never"
3654
  msgstr ""
3655
 
@@ -3697,70 +3707,75 @@ msgstr ""
3697
  msgid "Advanced Ads does not have access to your account (<code>%s</code>) anymore."
3698
  msgstr ""
3699
 
3700
- #: modules/gadsense/includes/class-mapi.php:658
3701
  msgid "error while renewing access token for \"%s\""
3702
  msgstr ""
3703
 
3704
- #: modules/gadsense/includes/class-mapi.php:683
 
3705
  msgid "invalid response received while renewing access token for \"%s\""
3706
  msgstr ""
3707
 
3708
- #: modules/gadsense/includes/class-mapi.php:752
 
 
 
 
3709
  msgid "This ad code is from a different AdSense Account"
3710
  msgstr ""
3711
 
3712
- #: modules/gadsense/includes/class-mapi.php:981
3713
  msgid "Invalid response body while retrieving account alerts"
3714
  msgstr ""
3715
 
3716
- #: modules/gadsense/includes/class-mapi.php:990
3717
  msgid "error while retrieving account alerts"
3718
  msgstr ""
3719
 
3720
- #: modules/gadsense/includes/class-mapi.php:1161
3721
  msgid "No token provided. Token data needed to get account details."
3722
  msgstr ""
3723
 
3724
- #: modules/gadsense/includes/class-mapi.php:1225
3725
  msgid "An error occurred while requesting account details."
3726
  msgstr ""
3727
 
3728
- #: modules/gadsense/includes/class-mapi.php:1450
3729
  #: modules/gadsense/includes/class-network-adsense.php:509
3730
  msgctxt "AdSense ad type"
3731
  msgid "Matched Content"
3732
  msgstr ""
3733
 
3734
- #: modules/gadsense/includes/class-mapi.php:1453
3735
  #: modules/gadsense/includes/class-network-adsense.php:510
3736
  msgctxt "AdSense ad type"
3737
  msgid "In-article"
3738
  msgstr ""
3739
 
3740
- #: modules/gadsense/includes/class-mapi.php:1455
3741
  #: modules/gadsense/includes/class-network-adsense.php:511
3742
  msgctxt "AdSense ad type"
3743
  msgid "In-feed"
3744
  msgstr ""
3745
 
3746
- #: modules/gadsense/includes/class-mapi.php:1460
3747
  #: modules/gadsense/includes/class-network-adsense.php:512
3748
  msgctxt "AdSense ad type"
3749
  msgid "Display"
3750
  msgstr ""
3751
 
3752
- #: modules/gadsense/includes/class-mapi.php:1462
3753
  #: modules/gadsense/includes/class-network-adsense.php:513
3754
  msgctxt "AdSense ad type"
3755
  msgid "Link"
3756
  msgstr ""
3757
 
3758
- #: modules/gadsense/includes/class-mapi.php:1649
3759
  msgid "There are one or more warnings about the currently linked AdSense account. You can view them <a href=\"%s\">here</a>"
3760
  msgstr ""
3761
 
3762
  #. translators: 1:A link to the settings page translators: 2:The name of an ad network
3763
- #: modules/gadsense/includes/class-mapi.php:1736
3764
  msgid "Please try to <a href=\"%1$s\" target=\"_blank\">reconnect to your %2$s account</a>."
3765
  msgstr ""
3766
 
1
+ # Copyright (C) 2021 Thomas Maier, Advanced Ads GmbH
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.23.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: 2021-01-12T11:06:25+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"
513
  msgid "License couldn’t be deactivated. Please try again later."
514
  msgstr ""
515
 
516
+ #: admin/includes/class-licenses.php:606
517
  msgid "Download failed. <a href=\"%s\">Click here to try another method</a>."
518
  msgstr ""
519
 
520
+ #: admin/includes/class-licenses.php:608
521
  msgid "Download failed. <a href=\"%s\" target=\"_blank\">Click here to learn why</a>."
522
  msgstr ""
523
 
544
 
545
  #: admin/includes/class-menu.php:80
546
  #: admin/includes/class-menu.php:81
547
+ #: admin/includes/class-shortcode-creator.php:182
548
  #: admin/views/ad-group-list-form-row.php:91
549
  #: admin/views/ad-group-list-header.php:16
550
  #: admin/views/placement-form.php:88
581
  msgstr ""
582
 
583
  #: admin/includes/class-menu.php:132
584
+ #: admin/includes/class-shortcode-creator.php:196
585
  #: admin/views/placements.php:54
586
  #: classes/widget.php:115
587
  #: modules/gutenberg/includes/class-gutenberg.php:81
995
  msgid "Advertisements"
996
  msgstr ""
997
 
998
+ #: admin/includes/class-shortcode-creator.php:180
999
  #: classes/widget.php:113
1000
  #: modules/gutenberg/includes/class-gutenberg.php:77
1001
  msgid "--empty--"
1002
  msgstr ""
1003
 
1004
+ #: admin/includes/class-shortcode-creator.php:189
1005
  #: admin/views/placement-form.php:81
1006
  #: admin/views/placements-item.php:14
1007
  #: classes/widget.php:122
2484
 
2485
  #. translators: %1$s is an anchor (link) opening tag, %2$s is the closing tag.
2486
  #: classes/ad-health-notices.php:865
2487
+ #: modules/gadsense/includes/class-mapi.php:1688
2488
  msgid "Learn more about AdSense account issues %1$shere%2$s."
2489
  msgstr ""
2490
 
2636
  msgid "Choose an existing ad group. Use this type when you want to assign the same display and visitor conditions to all ads in that group."
2637
  msgstr ""
2638
 
2639
+ #: classes/ad_type_group.php:89
2640
  msgid "ad group"
2641
  msgstr ""
2642
 
2892
  msgid "days"
2893
  msgstr ""
2894
 
2895
+ #: classes/EDD_SL_Plugin_Updater.php:250
2896
  msgid "There is a new version of %1$s available. %2$sView version %3$s details%4$s."
2897
  msgstr ""
2898
 
2899
+ #: classes/EDD_SL_Plugin_Updater.php:258
2900
  msgid "There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s."
2901
  msgstr ""
2902
 
2903
+ #: classes/EDD_SL_Plugin_Updater.php:502
2904
  msgid "You do not have permission to install plugin updates"
2905
  msgstr ""
2906
 
2907
+ #: classes/EDD_SL_Plugin_Updater.php:502
2908
  msgid "Error"
2909
  msgstr ""
2910
 
3648
  msgid "Your AdSense Publisher ID is missing."
3649
  msgstr ""
3650
 
3651
+ #: modules/gadsense/includes/class-adsense-report.php:311
3652
+ #: modules/gadsense/includes/class-adsense-report.php:336
3653
+ msgid "Invalid response from AdSense."
3654
+ msgstr ""
3655
+
3656
+ #: modules/gadsense/includes/class-adsense-report.php:311
3657
+ #: modules/gadsense/includes/class-adsense-report.php:336
3658
+ msgid "You could try to re-connect under Advanced Ads > Settings > AdSense."
3659
+ msgstr ""
3660
+
3661
+ #: modules/gadsense/includes/class-adsense-report.php:499
3662
+ #: modules/gadsense/includes/class-adsense-report.php:525
3663
  msgid "Never"
3664
  msgstr ""
3665
 
3707
  msgid "Advanced Ads does not have access to your account (<code>%s</code>) anymore."
3708
  msgstr ""
3709
 
3710
+ #: modules/gadsense/includes/class-mapi.php:660
3711
  msgid "error while renewing access token for \"%s\""
3712
  msgstr ""
3713
 
3714
+ #. translators: %s AdSense account ID
3715
+ #: modules/gadsense/includes/class-mapi.php:687
3716
  msgid "invalid response received while renewing access token for \"%s\""
3717
  msgstr ""
3718
 
3719
+ #: modules/gadsense/includes/class-mapi.php:689
3720
+ msgid "You could try to connect again under Advanced Ads > Settings > AdSense."
3721
+ msgstr ""
3722
+
3723
+ #: modules/gadsense/includes/class-mapi.php:758
3724
  msgid "This ad code is from a different AdSense Account"
3725
  msgstr ""
3726
 
3727
+ #: modules/gadsense/includes/class-mapi.php:987
3728
  msgid "Invalid response body while retrieving account alerts"
3729
  msgstr ""
3730
 
3731
+ #: modules/gadsense/includes/class-mapi.php:996
3732
  msgid "error while retrieving account alerts"
3733
  msgstr ""
3734
 
3735
+ #: modules/gadsense/includes/class-mapi.php:1167
3736
  msgid "No token provided. Token data needed to get account details."
3737
  msgstr ""
3738
 
3739
+ #: modules/gadsense/includes/class-mapi.php:1231
3740
  msgid "An error occurred while requesting account details."
3741
  msgstr ""
3742
 
3743
+ #: modules/gadsense/includes/class-mapi.php:1456
3744
  #: modules/gadsense/includes/class-network-adsense.php:509
3745
  msgctxt "AdSense ad type"
3746
  msgid "Matched Content"
3747
  msgstr ""
3748
 
3749
+ #: modules/gadsense/includes/class-mapi.php:1459
3750
  #: modules/gadsense/includes/class-network-adsense.php:510
3751
  msgctxt "AdSense ad type"
3752
  msgid "In-article"
3753
  msgstr ""
3754
 
3755
+ #: modules/gadsense/includes/class-mapi.php:1461
3756
  #: modules/gadsense/includes/class-network-adsense.php:511
3757
  msgctxt "AdSense ad type"
3758
  msgid "In-feed"
3759
  msgstr ""
3760
 
3761
+ #: modules/gadsense/includes/class-mapi.php:1466
3762
  #: modules/gadsense/includes/class-network-adsense.php:512
3763
  msgctxt "AdSense ad type"
3764
  msgid "Display"
3765
  msgstr ""
3766
 
3767
+ #: modules/gadsense/includes/class-mapi.php:1468
3768
  #: modules/gadsense/includes/class-network-adsense.php:513
3769
  msgctxt "AdSense ad type"
3770
  msgid "Link"
3771
  msgstr ""
3772
 
3773
+ #: modules/gadsense/includes/class-mapi.php:1655
3774
  msgid "There are one or more warnings about the currently linked AdSense account. You can view them <a href=\"%s\">here</a>"
3775
  msgstr ""
3776
 
3777
  #. translators: 1:A link to the settings page translators: 2:The name of an ad network
3778
+ #: modules/gadsense/includes/class-mapi.php:1742
3779
  msgid "Please try to <a href=\"%1$s\" target=\"_blank\">reconnect to your %2$s account</a>."
3780
  msgstr ""
3781
 
modules/gadsense/includes/class-adsense-report.php CHANGED
@@ -1,22 +1,38 @@
1
  <?php
 
 
 
 
2
  class Advanced_Ads_Adsense_Report_Column{
3
  public $name;
4
  public function __construct($name){
5
  $this->name = $name;
6
  }
7
  }
 
 
 
 
8
  class Advanced_Ads_AdSense_Report_Dimension extends Advanced_Ads_Adsense_Report_Column{
9
  public function __construct($name){
10
  parent::__construct($name);
11
  }
12
  }
 
 
 
 
13
  class Advanced_Ads_AdSense_Report_Metric extends Advanced_Ads_Adsense_Report_Column{
14
  public function __construct($name){
15
  parent::__construct($name);
16
  }
17
  }
 
 
 
 
18
  class Advanced_Ads_Adsense_Dimensional_Data{
19
-
20
  }
21
  /**
22
  * Represents the response that will be sent to the javascript frontend
@@ -27,9 +43,12 @@ class Advanced_Ads_Adsense_Report_Response{
27
  public $plots = array();
28
  }
29
 
 
 
 
30
  class Advanced_Ads_AdSense_Report_Builder{
31
  /**
32
- * This determines the time in seconds a transient or option representing the response
33
  * of the adsense server will be valid.
34
  */
35
  const TRANSIENT_VALIDITY = HOUR_IN_SECONDS;
@@ -39,7 +58,7 @@ class Advanced_Ads_AdSense_Report_Builder{
39
  private $dt_end;
40
  private $overwrite_dt_identifier;
41
  private $store_as_transient = false;
42
-
43
  public function addDimension($name){
44
  $dim = new Advanced_Ads_AdSense_Report_Dimension($name);
45
  $this->dimensions[] = $dim;
@@ -64,7 +83,7 @@ class Advanced_Ads_AdSense_Report_Builder{
64
  $dt->sub(new DateInterval("P" . $nbDays . "D"));
65
  $this->setDaterange($dt->format("Y-m-d"), $dt_end);
66
  }
67
-
68
  public function getUrl($pubId){
69
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $pubId . '/reports';
70
  $url .= "?startDate=$this->dt_start&endDate=$this->dt_end";
@@ -96,7 +115,7 @@ class Advanced_Ads_AdSense_Report_Builder{
96
  }
97
  return $id;
98
  }
99
-
100
  public function request_raw(){
101
  //gather the data for the request
102
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
@@ -106,7 +125,7 @@ class Advanced_Ads_AdSense_Report_Builder{
106
  $url = $this->getUrl($pub_id);
107
  return $this->process_request($url, $access_token);
108
  }
109
-
110
  public static function get_age_in_seconds($updated_at){
111
  // when upgrading from a previous version of AA to V1.14.2+ a refresh of the adsense dashboard
112
  // within one hour, might raise a notice when users are running their site in dev mode
@@ -118,7 +137,7 @@ class Advanced_Ads_AdSense_Report_Builder{
118
  }
119
  return (new DateTime())->getTimestamp() - $updated_at;
120
  }
121
-
122
  public function build($plotter, $type, $forceRefresh = false, $allowRefresh = true){
123
  $transient_id = $this->getIdentifier();
124
  $response = $this->get_option($transient_id);
@@ -127,7 +146,7 @@ class Advanced_Ads_AdSense_Report_Builder{
127
  if ($response){
128
  $age_in_seconds = self::get_age_in_seconds($response['updatedAt']);
129
  if ($age_in_seconds >= self::TRANSIENT_VALIDITY) $wants_refresh = true;
130
-
131
  }
132
  if ($wants_refresh){
133
  if ($allowRefresh){
@@ -155,7 +174,7 @@ class Advanced_Ads_AdSense_Report_Builder{
155
  }
156
  return null;
157
  }
158
-
159
  public function request_report($plotter, $type){
160
  $response = $this->request_raw();
161
  try{
@@ -168,7 +187,7 @@ class Advanced_Ads_AdSense_Report_Builder{
168
  catch(Exception $ex){}
169
  return null;
170
  }
171
-
172
  private function get_option($id){
173
  if ($this->store_as_transient) {
174
  return get_transient($id);
@@ -185,7 +204,7 @@ class Advanced_Ads_AdSense_Report_Builder{
185
  update_option($id, $value);
186
  }
187
  }
188
-
189
  private function process_request($url, $access_token){
190
  if ( ! isset( $access_token['msg'] ) ) {
191
  $headers = array(
@@ -198,7 +217,7 @@ class Advanced_Ads_AdSense_Report_Builder{
198
  return -1;
199
  }
200
  }
201
-
202
  /**
203
  * A quick way to create a dashboard summary.
204
  */
@@ -216,6 +235,9 @@ class Advanced_Ads_AdSense_Report_Builder{
216
  }
217
  }
218
 
 
 
 
219
  class Advanced_Ads_AdSense_Report{
220
  public $valid;
221
  public $errors;
@@ -225,7 +247,7 @@ class Advanced_Ads_AdSense_Report{
225
  public $columns;
226
  public $plotGenerator;
227
  public $secondaryDimension;
228
-
229
  function __construct($json_response, $plotter='jqplot', $type='lines'){
230
  $this->plotter = $plotter;
231
  $this->type = $type;
@@ -234,7 +256,13 @@ class Advanced_Ads_AdSense_Report{
234
  // ? new Advanced_Ads_AdSense_Plot_Generator_Jqplot($this)
235
  // : new Advanced_Ads_AdSense_Plot_Generator_Plotly($this);
236
  }
237
-
 
 
 
 
 
 
238
  private function process_json_response($json_response){
239
  $valid = false;
240
  $errors = array();
@@ -270,7 +298,7 @@ class Advanced_Ads_AdSense_Report{
270
  }
271
  $columns[] = $object;
272
  }
273
-
274
  $valid = count($dimensions) > 0 && count($dimensions) < 3 && count($metrics) > 0;
275
  if ($valid){
276
  $this->body = $body;
@@ -279,9 +307,8 @@ class Advanced_Ads_AdSense_Report{
279
  $this->columns = $columns;
280
  $this->secondaryDimension = count($dimensions) > 1 ? $dimensions[1] : null;
281
  $this->updatedAt = isset($json_response['updatedAt']) ? $json_response['updatedAt'] : null;
282
- }
283
- else{
284
- throw new RuntimeException(__("Invalid response from AdSense."));
285
  }
286
  }
287
  catch (Exception $ex){
@@ -306,7 +333,7 @@ class Advanced_Ads_AdSense_Report{
306
  $this->valid = $valid;
307
  if (! $valid && count($errors) == 0){
308
  // Display a default error message.
309
- $errors[] = __("Invalid response from AdSense.");
310
  }
311
  $this->errors = $errors;
312
  }
@@ -322,7 +349,7 @@ class Advanced_Ads_AdSense_Report{
322
  $this->body->rows = $filtered;
323
  }
324
  }
325
-
326
  public function getRowsByDimensionValues($dimension_values, $dimension_index){
327
  $filtered = array();
328
  if ($this->body && isset($this->body->rows) && is_array($this->body->rows)) {
@@ -343,7 +370,7 @@ class Advanced_Ads_AdSense_Report{
343
  }
344
  return $dict;
345
  }
346
-
347
  public function getDistinctValuesByDimension($dimension_index){
348
  $map = array();
349
  $vals = array();
@@ -358,7 +385,7 @@ class Advanced_Ads_AdSense_Report{
358
  }
359
  return $vals;
360
  }
361
-
362
  public function generateResponse(){
363
  $response = new Advanced_Ads_Adsense_Report_Response();
364
  $response->plots = $this->generatePlots();
@@ -366,7 +393,7 @@ class Advanced_Ads_AdSense_Report{
366
  $response->errors = $this->errors;
367
  return $response;
368
  }
369
-
370
  private function createDimensionalData(){
371
  $data = array();
372
  if ($this->secondaryDimension != null){
@@ -386,20 +413,20 @@ class Advanced_Ads_AdSense_Report{
386
  }
387
  return $data;
388
  }
389
-
390
-
391
  private function generatePlots(){
392
  $this->dimensionalData = $this->createDimensionalData();
393
  $plots = array();
394
  $plots[] = $this->generatePlot();
395
  // $plots = $this->plotGenerator->generatePlots($this);
396
  // foreach ($this->dimensionalData as $dimdata){
397
-
398
  // }
399
  //$plots[] = $this->generatePlot();
400
  return $plots;
401
  }
402
-
403
  private function generatePlot(){
404
  return $this->plotGenerator->generatePlot($this);
405
  }
@@ -459,16 +486,16 @@ class Advanced_Ads_AdSense_Dashboard_Summary{
459
  $report->filterRowsByPattern($colDimension, '/' . $filter_value . '$/');
460
  }
461
  }
462
-
463
  $summary->earningsToday = self::sum($report, $colEarnings, 1);
464
  $summary->earningsYesterday = self::sum($report, $colEarnings, 1, 1);
465
  $summary->earnings7Days = self::sum($report, $colEarnings, 7, 1);
466
  $summary->earnings28Days = self::sum($report, $colEarnings, 28, 1);
467
  $summary->earningsThisMonth = self::sumDim($report, $colEarnings, self::createDateDimensionValuesCurrentMonth());
468
-
469
  $age_in_seconds = Advanced_Ads_AdSense_Report_Builder::get_age_in_seconds($report->updatedAt);
470
  $summary->requires_refresh = $age_in_seconds > Advanced_Ads_AdSense_Report_Builder::TRANSIENT_VALIDITY;
471
-
472
  if (! $report->updatedAt) $summary->age = __("Never", "advanced-ads");
473
  else{
474
  $tz = self::get_timezone();
1
  <?php
2
+
3
+ /**
4
+ * Class Advanced_Ads_Adsense_Report_Column
5
+ */
6
  class Advanced_Ads_Adsense_Report_Column{
7
  public $name;
8
  public function __construct($name){
9
  $this->name = $name;
10
  }
11
  }
12
+
13
+ /**
14
+ * Class Advanced_Ads_AdSense_Report_Dimension
15
+ */
16
  class Advanced_Ads_AdSense_Report_Dimension extends Advanced_Ads_Adsense_Report_Column{
17
  public function __construct($name){
18
  parent::__construct($name);
19
  }
20
  }
21
+
22
+ /**
23
+ * Class Advanced_Ads_AdSense_Report_Metric
24
+ */
25
  class Advanced_Ads_AdSense_Report_Metric extends Advanced_Ads_Adsense_Report_Column{
26
  public function __construct($name){
27
  parent::__construct($name);
28
  }
29
  }
30
+
31
+ /**
32
+ * Class Advanced_Ads_Adsense_Dimensional_Data
33
+ */
34
  class Advanced_Ads_Adsense_Dimensional_Data{
35
+
36
  }
37
  /**
38
  * Represents the response that will be sent to the javascript frontend
43
  public $plots = array();
44
  }
45
 
46
+ /**
47
+ * Class Advanced_Ads_AdSense_Report_Builder
48
+ */
49
  class Advanced_Ads_AdSense_Report_Builder{
50
  /**
51
+ * This determines the time in seconds a transient or option representing the response
52
  * of the adsense server will be valid.
53
  */
54
  const TRANSIENT_VALIDITY = HOUR_IN_SECONDS;
58
  private $dt_end;
59
  private $overwrite_dt_identifier;
60
  private $store_as_transient = false;
61
+
62
  public function addDimension($name){
63
  $dim = new Advanced_Ads_AdSense_Report_Dimension($name);
64
  $this->dimensions[] = $dim;
83
  $dt->sub(new DateInterval("P" . $nbDays . "D"));
84
  $this->setDaterange($dt->format("Y-m-d"), $dt_end);
85
  }
86
+
87
  public function getUrl($pubId){
88
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $pubId . '/reports';
89
  $url .= "?startDate=$this->dt_start&endDate=$this->dt_end";
115
  }
116
  return $id;
117
  }
118
+
119
  public function request_raw(){
120
  //gather the data for the request
121
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
125
  $url = $this->getUrl($pub_id);
126
  return $this->process_request($url, $access_token);
127
  }
128
+
129
  public static function get_age_in_seconds($updated_at){
130
  // when upgrading from a previous version of AA to V1.14.2+ a refresh of the adsense dashboard
131
  // within one hour, might raise a notice when users are running their site in dev mode
137
  }
138
  return (new DateTime())->getTimestamp() - $updated_at;
139
  }
140
+
141
  public function build($plotter, $type, $forceRefresh = false, $allowRefresh = true){
142
  $transient_id = $this->getIdentifier();
143
  $response = $this->get_option($transient_id);
146
  if ($response){
147
  $age_in_seconds = self::get_age_in_seconds($response['updatedAt']);
148
  if ($age_in_seconds >= self::TRANSIENT_VALIDITY) $wants_refresh = true;
149
+
150
  }
151
  if ($wants_refresh){
152
  if ($allowRefresh){
174
  }
175
  return null;
176
  }
177
+
178
  public function request_report($plotter, $type){
179
  $response = $this->request_raw();
180
  try{
187
  catch(Exception $ex){}
188
  return null;
189
  }
190
+
191
  private function get_option($id){
192
  if ($this->store_as_transient) {
193
  return get_transient($id);
204
  update_option($id, $value);
205
  }
206
  }
207
+
208
  private function process_request($url, $access_token){
209
  if ( ! isset( $access_token['msg'] ) ) {
210
  $headers = array(
217
  return -1;
218
  }
219
  }
220
+
221
  /**
222
  * A quick way to create a dashboard summary.
223
  */
235
  }
236
  }
237
 
238
+ /**
239
+ * Class Advanced_Ads_AdSense_Report
240
+ */
241
  class Advanced_Ads_AdSense_Report{
242
  public $valid;
243
  public $errors;
247
  public $columns;
248
  public $plotGenerator;
249
  public $secondaryDimension;
250
+
251
  function __construct($json_response, $plotter='jqplot', $type='lines'){
252
  $this->plotter = $plotter;
253
  $this->type = $type;
256
  // ? new Advanced_Ads_AdSense_Plot_Generator_Jqplot($this)
257
  // : new Advanced_Ads_AdSense_Plot_Generator_Plotly($this);
258
  }
259
+
260
+ /**
261
+ * Process AdSense JSON response
262
+ *
263
+ * @param array $json_response response array.
264
+ * @throws RuntimeException If response is invalid.
265
+ */
266
  private function process_json_response($json_response){
267
  $valid = false;
268
  $errors = array();
298
  }
299
  $columns[] = $object;
300
  }
301
+
302
  $valid = count($dimensions) > 0 && count($dimensions) < 3 && count($metrics) > 0;
303
  if ($valid){
304
  $this->body = $body;
307
  $this->columns = $columns;
308
  $this->secondaryDimension = count($dimensions) > 1 ? $dimensions[1] : null;
309
  $this->updatedAt = isset($json_response['updatedAt']) ? $json_response['updatedAt'] : null;
310
+ } else {
311
+ throw new RuntimeException( __( 'Invalid response from AdSense.', 'advanced-ads' ) . ' ' . __( 'You could try to re-connect under Advanced Ads > Settings > AdSense.', 'advanced-ads' ) );
 
312
  }
313
  }
314
  catch (Exception $ex){
333
  $this->valid = $valid;
334
  if (! $valid && count($errors) == 0){
335
  // Display a default error message.
336
+ $errors[] = __( 'Invalid response from AdSense.', 'advanced-ads' ) . ' ' . __( 'You could try to re-connect under Advanced Ads > Settings > AdSense.', 'advanced-ads' );
337
  }
338
  $this->errors = $errors;
339
  }
349
  $this->body->rows = $filtered;
350
  }
351
  }
352
+
353
  public function getRowsByDimensionValues($dimension_values, $dimension_index){
354
  $filtered = array();
355
  if ($this->body && isset($this->body->rows) && is_array($this->body->rows)) {
370
  }
371
  return $dict;
372
  }
373
+
374
  public function getDistinctValuesByDimension($dimension_index){
375
  $map = array();
376
  $vals = array();
385
  }
386
  return $vals;
387
  }
388
+
389
  public function generateResponse(){
390
  $response = new Advanced_Ads_Adsense_Report_Response();
391
  $response->plots = $this->generatePlots();
393
  $response->errors = $this->errors;
394
  return $response;
395
  }
396
+
397
  private function createDimensionalData(){
398
  $data = array();
399
  if ($this->secondaryDimension != null){
413
  }
414
  return $data;
415
  }
416
+
417
+
418
  private function generatePlots(){
419
  $this->dimensionalData = $this->createDimensionalData();
420
  $plots = array();
421
  $plots[] = $this->generatePlot();
422
  // $plots = $this->plotGenerator->generatePlots($this);
423
  // foreach ($this->dimensionalData as $dimdata){
424
+
425
  // }
426
  //$plots[] = $this->generatePlot();
427
  return $plots;
428
  }
429
+
430
  private function generatePlot(){
431
  return $this->plotGenerator->generatePlot($this);
432
  }
486
  $report->filterRowsByPattern($colDimension, '/' . $filter_value . '$/');
487
  }
488
  }
489
+
490
  $summary->earningsToday = self::sum($report, $colEarnings, 1);
491
  $summary->earningsYesterday = self::sum($report, $colEarnings, 1, 1);
492
  $summary->earnings7Days = self::sum($report, $colEarnings, 7, 1);
493
  $summary->earnings28Days = self::sum($report, $colEarnings, 28, 1);
494
  $summary->earningsThisMonth = self::sumDim($report, $colEarnings, self::createDateDimensionValuesCurrentMonth());
495
+
496
  $age_in_seconds = Advanced_Ads_AdSense_Report_Builder::get_age_in_seconds($report->updatedAt);
497
  $summary->requires_refresh = $age_in_seconds > Advanced_Ads_AdSense_Report_Builder::TRANSIENT_VALIDITY;
498
+
499
  if (! $report->updatedAt) $summary->age = __("Never", "advanced-ads");
500
  else{
501
  $tz = self::get_timezone();
modules/gadsense/includes/class-mapi.php CHANGED
@@ -12,7 +12,7 @@ class Advanced_Ads_AdSense_MAPI {
12
  const CID = '400595147946-3ot506jh20qld7bqmg1l87ms4vn2uok5.apps.googleusercontent.com';
13
 
14
  const CS = 'WKX8ghwUbxdrBcVmZ9WXOKph';
15
-
16
  const REDIRECT_URI = 'https://c.wpadvancedads.com/oauth.php';
17
 
18
  const CALL_PER_24H = 20;
@@ -456,11 +456,11 @@ class Advanced_Ads_AdSense_MAPI {
456
  } else {
457
 
458
  if ( ! isset( $resp_body['items'] ) ) {
459
-
460
  if ( ! $inactive ) {
461
  return 'load_inactive';
462
  } else {
463
-
464
  return array(
465
  'status' => false,
466
  'msg' => sprintf(
@@ -474,7 +474,7 @@ class Advanced_Ads_AdSense_MAPI {
474
  );
475
 
476
  }
477
-
478
  } else {
479
 
480
  /**
@@ -622,6 +622,8 @@ class Advanced_Ads_AdSense_MAPI {
622
 
623
  /**
624
  * Renew the current access token.
 
 
625
  */
626
  public static function renew_access_token( $account ) {
627
  $cid = self::CID;
@@ -680,7 +682,11 @@ class Advanced_Ads_AdSense_MAPI {
680
  } else {
681
  return array(
682
  'status' => false,
683
- 'msg' => sprintf( esc_html__( 'invalid response received while renewing access token for "%s"', 'advanced-ads' ), $account ),
 
 
 
 
684
  'raw' => $response['body'],
685
  );
686
  }
@@ -1070,7 +1076,7 @@ class Advanced_Ads_AdSense_MAPI {
1070
  $response['quotaMsg'] = $quota_msg;
1071
  }
1072
  } else {
1073
-
1074
  if ( 'load_inactive' === $units ) {
1075
  // load markup with inactive ads button in the table.
1076
  ob_start();
@@ -1088,7 +1094,7 @@ class Advanced_Ads_AdSense_MAPI {
1088
  */
1089
  $response = $units;
1090
  }
1091
-
1092
  }
1093
  header( 'Content-Type: application/json' );
1094
  echo wp_json_encode( $response );
12
  const CID = '400595147946-3ot506jh20qld7bqmg1l87ms4vn2uok5.apps.googleusercontent.com';
13
 
14
  const CS = 'WKX8ghwUbxdrBcVmZ9WXOKph';
15
+
16
  const REDIRECT_URI = 'https://c.wpadvancedads.com/oauth.php';
17
 
18
  const CALL_PER_24H = 20;
456
  } else {
457
 
458
  if ( ! isset( $resp_body['items'] ) ) {
459
+
460
  if ( ! $inactive ) {
461
  return 'load_inactive';
462
  } else {
463
+
464
  return array(
465
  'status' => false,
466
  'msg' => sprintf(
474
  );
475
 
476
  }
477
+
478
  } else {
479
 
480
  /**
622
 
623
  /**
624
  * Renew the current access token.
625
+ *
626
+ * @param array $account AdSense account ID.
627
  */
628
  public static function renew_access_token( $account ) {
629
  $cid = self::CID;
682
  } else {
683
  return array(
684
  'status' => false,
685
+ 'msg' => sprintf(
686
+ // translators: %s AdSense account ID
687
+ esc_html__( 'invalid response received while renewing access token for "%s"', 'advanced-ads' ),
688
+ $account
689
+ ) . ' ' . __( 'You could try to connect again under Advanced Ads > Settings > AdSense.', 'advanced-ads' ),
690
  'raw' => $response['body'],
691
  );
692
  }
1076
  $response['quotaMsg'] = $quota_msg;
1077
  }
1078
  } else {
1079
+
1080
  if ( 'load_inactive' === $units ) {
1081
  // load markup with inactive ads button in the table.
1082
  ob_start();
1094
  */
1095
  $response = $units;
1096
  }
1097
+
1098
  }
1099
  header( 'Content-Type: application/json' );
1100
  echo wp_json_encode( $response );
modules/gadsense/public/templates/page-level.php CHANGED
@@ -52,7 +52,8 @@ if ( $top_anchor ) {
52
  printf(
53
  '<script async src="%s"></script><script>%s</script>',
54
  esc_attr( $script_src ),
55
- esc_attr( $top_anchor_code )
 
56
  );
57
  } else {
58
  printf(
52
  printf(
53
  '<script async src="%s"></script><script>%s</script>',
54
  esc_attr( $script_src ),
55
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- the snippet has already been escaped.
56
+ $top_anchor_code
57
  );
58
  } else {
59
  printf(
modules/gutenberg/js/advanced-ads.block.js CHANGED
@@ -6,6 +6,36 @@
6
  var el = wp.element.createElement,
7
  registerBlockType = wp.blocks.registerBlockType;
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
  * Register the single ad block type
11
  */
@@ -13,7 +43,7 @@
13
 
14
  title: advadsGutenberg.i18n.advads,
15
 
16
- icon: 'chart-line',
17
 
18
  category: 'common',
19
 
6
  var el = wp.element.createElement,
7
  registerBlockType = wp.blocks.registerBlockType;
8
 
9
+ /**
10
+ * Custom SVG icon
11
+ * could move to a separated file if we need it in other places, too
12
+ *
13
+ * @source https://gist.github.com/zgordon/e837e29f77c343d29ebb7290a1a75eea
14
+ */
15
+ const advadsIconEl = el(
16
+ 'svg',
17
+ {
18
+ width: "24px",
19
+ height: "24px",
20
+ viewBox: "1.396 3276 24 24",
21
+ xmlns: "http://www.w3.org/2000/svg",
22
+ x: "0px",
23
+ y: "0px"
24
+ },
25
+ el(
26
+ 'g',
27
+ {},
28
+ el(
29
+ 'path',
30
+ {
31
+ fill: "#1C1B3A",
32
+ d: "M18.602,3286.2v8.53H6.677v-11.925h8.53c-0.355-0.804-0.545-1.684-0.545-2.625s0.205-1.82,0.545-2.625 h-2.57H1.406v18.266l0.6,0.6l-0.6-0.6c0,2.304,1.875,4.179,4.18,4.179l0,0h7.05h11.216v-13.821 c-0.805,0.355-1.705,0.566-2.645,0.566C20.286,3286.745,19.406,3286.541,18.602,3286.2z"
33
+ }
34
+ ),
35
+ el( 'circle', { fill: "#0E75A4", cx: "21.206", cy: "3280.179", r: "4.18" } )
36
+ ),
37
+ );
38
+
39
  /**
40
  * Register the single ad block type
41
  */
43
 
44
  title: advadsGutenberg.i18n.advads,
45
 
46
+ icon: advadsIconEl,
47
 
48
  category: 'common',
49
 
modules/import-export/classes/import.php CHANGED
@@ -123,7 +123,7 @@ class Advanced_Ads_Import {
123
  /**
124
  * Create new ads and groups based on import information
125
  *
126
- * @param array $decoded decoded XML
127
  */
128
  private function import_ads_and_groups( &$decoded ) {
129
  if ( isset( $decoded['ads'] ) && is_array( $decoded['ads'] ) ) {
@@ -212,7 +212,7 @@ class Advanced_Ads_Import {
212
 
213
  // do not save the ad group, if this is the group assigned as ad content
214
  if ( $ad_group_id !== $group_id ) {
215
- $groups_to_set[] = intval( $group_id );
216
  }
217
 
218
  if ( ! isset( $advads_ad_groups[ $group_id ] ) ) {
123
  /**
124
  * Create new ads and groups based on import information
125
  *
126
+ * @param array $decoded decoded XML.
127
  */
128
  private function import_ads_and_groups( &$decoded ) {
129
  if ( isset( $decoded['ads'] ) && is_array( $decoded['ads'] ) ) {
212
 
213
  // do not save the ad group, if this is the group assigned as ad content
214
  if ( $ad_group_id !== $group_id ) {
215
+ $groups_to_set[] = (int) $group_id;
216
  }
217
 
218
  if ( ! isset( $advads_ad_groups[ $group_id ] ) ) {
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.6
6
  Requires PHP: 5.6
7
- Stable tag: 1.23.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -317,6 +317,14 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
317
 
318
  == Changelog ==
319
 
 
 
 
 
 
 
 
 
320
  = 1.23.0 =
321
 
322
  - MailPoet is going to deprecate custom shortcodes. See [this section](https://wpadvancedads.com/mailpoet-newsletters/#Enable_MailPoet_support_in_Advanced_Ads) in case you are using Advanced Ads ads in your newsletters
4
  Requires at least: 4.6
5
  Tested up to: 5.6
6
  Requires PHP: 5.6
7
+ Stable tag: 1.23.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
317
 
318
  == Changelog ==
319
 
320
+ = 1.23.1 =
321
+
322
+ - removed warning about iThemes Security since it is no longer causing the reported issue
323
+ - added correct icon to Advanced Ads block
324
+ - fixed escaping for AdSense Auto ads codes that use the deprecated "Disable Top Level" option
325
+ - fixed TinyMCE warning in dev console
326
+ - replaced `intval()` and `floatval()` with type-casting
327
+
328
  = 1.23.0 =
329
 
330
  - MailPoet is going to deprecate custom shortcodes. See [this section](https://wpadvancedads.com/mailpoet-newsletters/#Enable_MailPoet_support_in_Advanced_Ads) in case you are using Advanced Ads ads in your newsletters