Advanced Ads - Version 1.32.0

Version Description

  • Improvement: load display/visitor conditions automatically after selecting them
  • Fix: prevent undefined index notice in display conditions
  • Fix: accommodate for deprecation in WP_User_Query in WordPress 5.9.0
  • Fix: prevent tooltips from flowing out of right edge of viewport
  • Fix: correct ad list counter for expiring ads
  • Fix: prevent creating unneeded group wrapper around Advanced Ads block
  • Fix: escape the ad title on groups screen to prevent authenticated XSS
  • Fix: prevent authenticated XSS in plain text ads if DISALLOW_UNFILTERED_HTML is set
  • Fix: prevent authenticated RCE in plain text ads if DISALLOW_FILE_EDIT is set
  • Fix: rename "Responsive (Matched Content)" AdSense ad type to "Multiplex ads"
Download this release

Release Info

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

Code changes from version 1.32.0-rc.1 to 1.32.0

admin/includes/class-shortcode-creator.php CHANGED
@@ -1,8 +1,17 @@
1
  <?php
2
  /**
3
  * Shortcode generator for TinyMCE editor
 
 
4
  */
5
  class Advanced_Ads_Shortcode_Creator {
 
 
 
 
 
 
 
6
  /**
7
  * Instance of this class.
8
  *
@@ -47,9 +56,10 @@ class Advanced_Ads_Shortcode_Creator {
47
 
48
  add_action( 'wp_ajax_advads_content_for_shortcode_creator', array( $this, 'get_content_for_shortcode_creator' ) );
49
 
50
- // @see self::hooks_exist
51
- add_filter( 'mce_buttons', array( $this, 'register_buttons' ) );
52
  add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ) );
 
 
53
  add_action( 'wp_tiny_mce_init', array( $this, 'print_shortcode_plugin' ) );
54
  add_action( 'print_default_editor_scripts', array( $this, 'print_shortcode_plugin' ) );
55
  }
@@ -61,14 +71,12 @@ class Advanced_Ads_Shortcode_Creator {
61
  */
62
  private function hooks_exist() {
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' ) ) ) {
70
  return true;
71
  }
 
72
  return false;
73
  }
74
 
@@ -91,7 +99,7 @@ class Advanced_Ads_Shortcode_Creator {
91
  return;
92
  }
93
 
94
- if ( ! $this->hooks_exist() ) {
95
  return;
96
  }
97
 
@@ -123,8 +131,6 @@ class Advanced_Ads_Shortcode_Creator {
123
  * Add the plugin to the array of default TinyMCE plugins.
124
  * We do not use the array of external TinyMCE plugins because we print the plugin file inline.
125
  *
126
- * @see self::admin_enqueue_scripts
127
- *
128
  * @param array $plugins An array of default TinyMCE plugins.
129
  * @return array $plugins An array of default TinyMCE plugins.
130
  */
@@ -138,33 +144,55 @@ class Advanced_Ads_Shortcode_Creator {
138
  }
139
 
140
  /**
141
- * Include the shortcode plugin inline to prevent it from being blocked by ad blockers.
 
 
 
 
 
 
 
 
142
  */
143
- public function admin_enqueue_scripts() {
144
- // Add the localization.
145
- include_once ADVADS_BASE_PATH . 'admin/includes/shortcode-creator-l10n.php';
146
- $script = $strings . "\n";
147
- // Add the plugin.
148
- $script .= file_get_contents( ADVADS_BASE_PATH . 'admin/assets/js/shortcode.js' );
149
-
150
- wp_add_inline_script( 'wp-tinymce', $script );
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
  /**
154
  * Add button to tinyMCE window
155
  *
156
- * @param array $buttons array with existing buttons.
 
157
  *
158
  * @return array
159
  */
160
- public function register_buttons( $buttons ) {
161
  if ( ! $this->hooks_exist() ) {
162
  return $buttons;
163
  }
164
  if ( ! is_array( $buttons ) ) {
165
  $buttons = array();
166
  }
167
- $buttons[] = 'advads_shortcode_button';
 
 
168
  return $buttons;
169
  }
170
 
1
  <?php
2
  /**
3
  * Shortcode generator for TinyMCE editor
4
+ *
5
+ * Includes the shortcode plugin inline to prevent it from being blocked by ad blockers.
6
  */
7
  class Advanced_Ads_Shortcode_Creator {
8
+ /**
9
+ * Contains ids of the editors that contains the Advanced Ads button.
10
+ *
11
+ * @var array
12
+ */
13
+ private $editors_with_buttons = array();
14
+
15
  /**
16
  * Instance of this class.
17
  *
56
 
57
  add_action( 'wp_ajax_advads_content_for_shortcode_creator', array( $this, 'get_content_for_shortcode_creator' ) );
58
 
59
+ add_filter( 'mce_buttons', array( $this, 'register_buttons' ), 10, 2 );
 
60
  add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ) );
61
+ add_filter( 'tiny_mce_before_init', array( $this, 'tiny_mce_before_init' ), 10, 2 );
62
+
63
  add_action( 'wp_tiny_mce_init', array( $this, 'print_shortcode_plugin' ) );
64
  add_action( 'print_default_editor_scripts', array( $this, 'print_shortcode_plugin' ) );
65
  }
71
  */
72
  private function hooks_exist() {
73
  if (
74
+ has_action( 'wp_tiny_mce_init', array( $this, 'print_shortcode_plugin' ) )
75
+ || has_action( 'print_default_editor_scripts', array( $this, 'print_shortcode_plugin' ) )
76
+ ) {
 
 
 
77
  return true;
78
  }
79
+
80
  return false;
81
  }
82
 
99
  return;
100
  }
101
 
102
+ if ( empty( $this->editors_with_buttons ) ) {
103
  return;
104
  }
105
 
131
  * Add the plugin to the array of default TinyMCE plugins.
132
  * We do not use the array of external TinyMCE plugins because we print the plugin file inline.
133
  *
 
 
134
  * @param array $plugins An array of default TinyMCE plugins.
135
  * @return array $plugins An array of default TinyMCE plugins.
136
  */
144
  }
145
 
146
  /**
147
+ * Delete the plugin added by the {@see `tiny_mce_plugins`} method when necessary hooks do not exist.
148
+ *
149
+ * This is needed because a plugin may call `wp_editor` (which will permanently add our `advads_shortcode` plugin,
150
+ * because the `tiny_mce_plugins` hooks is called only once) and after that another plugin may call
151
+ * `remove_all_filters( 'mce_buttons') function that will remove our hook.
152
+ *
153
+ * @param array $mce_init An array with TinyMCE config.
154
+ * @param string $editor_id Unique editor identifier.
155
+ * @return array the TinyMCE config.
156
  */
157
+ public function tiny_mce_before_init( $mce_init, $editor_id ) {
158
+ if (
159
+ ! isset( $mce_init['plugins'] )
160
+ || ! is_string( $mce_init['plugins'] )
161
+ ) {
162
+ return $mce_init;
163
+ }
164
+
165
+ $plugins = explode( ',', $mce_init['plugins'] );
166
+ $found = array_search( 'advads_shortcode', $plugins, true );
167
+
168
+ if ( ! $found || in_array( $editor_id, $this->editors_with_buttons, true ) ) {
169
+ return $mce_init;
170
+ }
171
+
172
+ unset( $plugins[ $found ] );
173
+ $mce_init['plugins'] = implode( ',', $plugins );
174
+
175
+ return $mce_init;
176
  }
177
 
178
  /**
179
  * Add button to tinyMCE window
180
  *
181
+ * @param array $buttons Array with existing buttons.
182
+ * @param string $editor_id Unique editor identifier.
183
  *
184
  * @return array
185
  */
186
+ public function register_buttons( $buttons, $editor_id ) {
187
  if ( ! $this->hooks_exist() ) {
188
  return $buttons;
189
  }
190
  if ( ! is_array( $buttons ) ) {
191
  $buttons = array();
192
  }
193
+
194
+ $this->editors_with_buttons[] = $editor_id;
195
+ $buttons [] = 'advads_shortcode_button';
196
  return $buttons;
197
  }
198
 
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.32.0-rc.1
16
  * Author: Thomas Maier, Advanced Ads GmbH
17
  * Author URI: https://wpadvancedads.com
18
  * Text Domain: advanced-ads
@@ -39,7 +39,7 @@ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin
39
  // general and global slug, e.g. to store options in WP.
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
- define( 'ADVADS_VERSION', '1.32.0-rc.1' );
43
 
44
  // Autoloading, modules and functions.
45
 
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.32.0
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.32.0' );
43
 
44
  // Autoloading, modules and functions.
45
 
changelog.txt CHANGED
@@ -1,5 +1,44 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 1.30.0 =
4
 
5
  - Improvement: add `advanced-ads-group-taxonomy-params` filter to change ad group taxonomy parameters
1
  == Changelog ==
2
 
3
+ = 1.31.1 =
4
+
5
+ - Fix: show ad edit button when Advanced Ads block is used
6
+ - Fix: revert regression from expired view when filtering by weekday
7
+
8
+ = 1.31.0 =
9
+
10
+ - Feature: add "Expired" and "Expiring" views to the ad overview list replacing the expiry date filter
11
+ - Improvement: use "saved" dashicon when an element was saved correctly or a process finished
12
+ - Improvement: don't report HTML5 tags or custom elements as invalid tags in custom ad content
13
+ - Improvement: optimize warnings from AdSense account and clarify that these warnings are not from Advanced Ads
14
+ - Improvement: separate `inject_in_content` code into class `Advanced_Ads_In_Content_Injector`
15
+ - Improvement: update video manual display conditions
16
+
17
+ = 1.30.5 =
18
+
19
+ - Fix: correct ad weight calculation if ad count in group is retained but ad ids change
20
+
21
+ = 1.30.4 =
22
+
23
+ - Fix: prevent overriding of ads' weight `0` in ad groups
24
+
25
+ = 1.30.3 =
26
+
27
+ - Fix: properly output HTML attributes for TCF 2.0 script tag
28
+ - Fix: centralize and normalize Ad Group weight calculation
29
+ - Fix: escape closing HTML tags for ads injected into main content which use document.write
30
+ - Fix: add CSS class for hidden elements on medium and wider screens
31
+
32
+ = 1.30.2 =
33
+
34
+ - Improvement: hide feedback form when the plugin is disabled multiple times without feedback
35
+ - Fix: prevent applying array functions to boolean in `Advanced_Ads_Group`
36
+ - Fix: add default weight for ads added to groups via the ad edit screen
37
+
38
+ = 1.30.1 =
39
+
40
+ - Fix: copy missing `composer/platform_check.php`
41
+
42
  = 1.30.0 =
43
 
44
  - Improvement: add `advanced-ads-group-taxonomy-params` filter to change ad group taxonomy parameters
languages/advanced-ads.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the same license as the Advanced Ads plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Advanced Ads 1.32.0-rc.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: 2022-03-03T09:02:51-06: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"
@@ -563,7 +563,7 @@ msgstr ""
563
 
564
  #: admin/includes/class-menu.php:80
565
  #: admin/includes/class-menu.php:81
566
- #: admin/includes/class-shortcode-creator.php:184
567
  #: admin/views/ad-group-list-form-row.php:91
568
  #: admin/views/ad-group-list-header.php:16
569
  #: admin/views/placement-form.php:90
@@ -600,7 +600,7 @@ msgid "Ad Placements"
600
  msgstr ""
601
 
602
  #: admin/includes/class-menu.php:132
603
- #: admin/includes/class-shortcode-creator.php:198
604
  #: admin/views/placements.php:57
605
  #: classes/widget.php:122
606
  #: modules/gutenberg/includes/class-gutenberg.php:88
@@ -1023,13 +1023,13 @@ msgctxt "label before ads"
1023
  msgid "Advertisements"
1024
  msgstr ""
1025
 
1026
- #: admin/includes/class-shortcode-creator.php:182
1027
  #: classes/widget.php:120
1028
  #: modules/gutenberg/includes/class-gutenberg.php:84
1029
  msgid "--empty--"
1030
  msgstr ""
1031
 
1032
- #: admin/includes/class-shortcode-creator.php:191
1033
  #: admin/views/placement-form.php:83
1034
  #: admin/views/placements-item.php:14
1035
  #: classes/widget.php:129
@@ -3613,7 +3613,7 @@ msgid "Normal"
3613
  msgstr ""
3614
 
3615
  #: modules/gadsense/admin/views/adsense-ad-parameters.php:110
3616
- msgid "Responsive (Matched Content)"
3617
  msgstr ""
3618
 
3619
  #: modules/gadsense/admin/views/adsense-ad-parameters.php:112
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.32.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: 2022-03-07T08:28:03-06: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"
563
 
564
  #: admin/includes/class-menu.php:80
565
  #: admin/includes/class-menu.php:81
566
+ #: admin/includes/class-shortcode-creator.php:212
567
  #: admin/views/ad-group-list-form-row.php:91
568
  #: admin/views/ad-group-list-header.php:16
569
  #: admin/views/placement-form.php:90
600
  msgstr ""
601
 
602
  #: admin/includes/class-menu.php:132
603
+ #: admin/includes/class-shortcode-creator.php:226
604
  #: admin/views/placements.php:57
605
  #: classes/widget.php:122
606
  #: modules/gutenberg/includes/class-gutenberg.php:88
1023
  msgid "Advertisements"
1024
  msgstr ""
1025
 
1026
+ #: admin/includes/class-shortcode-creator.php:210
1027
  #: classes/widget.php:120
1028
  #: modules/gutenberg/includes/class-gutenberg.php:84
1029
  msgid "--empty--"
1030
  msgstr ""
1031
 
1032
+ #: admin/includes/class-shortcode-creator.php:219
1033
  #: admin/views/placement-form.php:83
1034
  #: admin/views/placements-item.php:14
1035
  #: classes/widget.php:129
3613
  msgstr ""
3614
 
3615
  #: modules/gadsense/admin/views/adsense-ad-parameters.php:110
3616
+ msgid "Multiplex ads"
3617
  msgstr ""
3618
 
3619
  #: modules/gadsense/admin/views/adsense-ad-parameters.php:112
modules/gadsense/admin/views/adsense-ad-parameters.php CHANGED
@@ -107,7 +107,7 @@ if( $pub_id_errors ) : ?>
107
  <select name="unit-type" id="unit-type">
108
  <option value="normal" <?php selected( $unit_type, 'normal' ); ?>><?php _e( 'Normal', 'advanced-ads' ); ?></option>
109
  <option value="responsive" <?php selected( $unit_type, 'responsive' ); ?>><?php _e( 'Responsive', 'advanced-ads' ); ?></option>
110
- <option value="matched-content" <?php selected( $unit_type, 'matched-content' ); ?>><?php _e( 'Responsive (Matched Content)', 'advanced-ads' ); ?></option>
111
  <?php if ( $unit_type === 'link' ) : ?>
112
  <option value="link" <?php selected( $unit_type, 'link' ); ?>><?php _e( 'Link ads', 'advanced-ads' ); ?></option>
113
  <?php endif; ?>
107
  <select name="unit-type" id="unit-type">
108
  <option value="normal" <?php selected( $unit_type, 'normal' ); ?>><?php _e( 'Normal', 'advanced-ads' ); ?></option>
109
  <option value="responsive" <?php selected( $unit_type, 'responsive' ); ?>><?php _e( 'Responsive', 'advanced-ads' ); ?></option>
110
+ <option value="matched-content" <?php selected( $unit_type, 'matched-content' ); ?>><?php esc_html_e( 'Multiplex ads', 'advanced-ads' ); ?></option>
111
  <?php if ( $unit_type === 'link' ) : ?>
112
  <option value="link" <?php selected( $unit_type, 'link' ); ?>><?php _e( 'Link ads', 'advanced-ads' ); ?></option>
113
  <?php endif; ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: ads, adsense, amp, ads.txt, ad rotations, ad blocker, amazon, banner, clic
4
  Requires at least: 4.9
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
- Stable tag: 1.31.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -324,7 +324,7 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
324
 
325
  == Changelog ==
326
 
327
- = untagged =
328
 
329
  - Improvement: load display/visitor conditions automatically after selecting them
330
  - Fix: prevent undefined index notice in display conditions
@@ -335,63 +335,4 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
335
  - Fix: escape the ad title on groups screen to prevent authenticated XSS
336
  - Fix: prevent authenticated XSS in plain text ads if `DISALLOW_UNFILTERED_HTML` is set
337
  - Fix: prevent authenticated RCE in plain text ads if `DISALLOW_FILE_EDIT` is set
338
-
339
- = 1.31.1 =
340
-
341
- - Fix: show ad edit button when Advanced Ads block is used
342
- - Fix: revert regression from expired view when filtering by weekday
343
-
344
- = 1.31.0 =
345
-
346
- - Feature: add "Expired" and "Expiring" views to the ad overview list replacing the expiry date filter
347
- - Improvement: use "saved" dashicon when an element was saved correctly or a process finished
348
- - Improvement: don't report HTML5 tags or custom elements as invalid tags in custom ad content
349
- - Improvement: optimize warnings from AdSense account and clarify that these warnings are not from Advanced Ads
350
- - Improvement: separate `inject_in_content` code into class `Advanced_Ads_In_Content_Injector`
351
- - Improvement: update video manual display conditions
352
-
353
- = 1.30.5 =
354
-
355
- - Fix: correct ad weight calculation if ad count in group is retained but ad ids change
356
-
357
- = 1.30.4 =
358
-
359
- - Fix: prevent overriding of ads' weight `0` in ad groups
360
-
361
- = 1.30.3 =
362
-
363
- - Fix: properly output HTML attributes for TCF 2.0 script tag
364
- - Fix: centralize and normalize Ad Group weight calculation
365
- - Fix: escape closing HTML tags for ads injected into main content which use document.write
366
- - Fix: add CSS class for hidden elements on medium and wider screens
367
-
368
- = 1.30.2 =
369
-
370
- - Improvement: hide feedback form when the plugin is disabled multiple times without feedback
371
- - Fix: prevent applying array functions to boolean in `Advanced_Ads_Group`
372
- - Fix: add default weight for ads added to groups via the ad edit screen
373
-
374
- = 1.30.1 =
375
-
376
- - Fix: copy missing `composer/platform_check.php`
377
-
378
- = 1.30.0 =
379
-
380
- - Improvement: add `advanced-ads-group-taxonomy-params` filter to change ad group taxonomy parameters
381
- - Improvement: add "Manual Placements" to the Advanced Ads block and sidebar widget
382
- - Improvement: update Black Friday promotion
383
- - Fix: enable `Ad Admin` and `Ad Manager` to assign ads to groups from ad edit page and quick edit view
384
- - Fix: disable unavailable ad types on the ad edit page
385
- - Fix: improve AdSense auto ads code warning on ad edit page
386
- - Fix: handle AdSense report API response for accounts without earnings
387
- - Fix: remove `amp-auto-ads` element on non-AMP URLs
388
- - Fix: honor disabling ads settings for AMP pages
389
- - Fix: escape placement selectors for jQuery to allow adding conditions to multibyte placement names
390
- - Fix: ensure correct text domain for translations
391
- - Fix: make the ad list sortable in descending order
392
- - Fix: remove hard-coded `orderby` and `order` for posts list
393
- - Fix: prevent updating ad weights of non-published ads
394
- - Fix: correct Display Conditions meta box video player
395
- - Fix: remove escaped HTML tags in new placement form
396
- - Fix: resolve a conflict with WPML where conditions were not displayed correctly on the placement page
397
- - Fix: move placement of the ad blocker disguise settings
4
  Requires at least: 4.9
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
+ Stable tag: 1.32.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
324
 
325
  == Changelog ==
326
 
327
+ = 1.32.0 =
328
 
329
  - Improvement: load display/visitor conditions automatically after selecting them
330
  - Fix: prevent undefined index notice in display conditions
335
  - Fix: escape the ad title on groups screen to prevent authenticated XSS
336
  - Fix: prevent authenticated XSS in plain text ads if `DISALLOW_UNFILTERED_HTML` is set
337
  - Fix: prevent authenticated RCE in plain text ads if `DISALLOW_FILE_EDIT` is set
338
+ - Fix: rename "Responsive (Matched Content)" AdSense ad type to "Multiplex ads"