Advanced Ads - Version 1.23.0

Version Description

  • MailPoet is going to deprecate custom shortcodes. See this section in case you are using Advanced Ads ads in your newsletters
  • updated Google AdSense API to use web application verification
  • prevent accidental public ad URLs. See Making the Ads post type public if you want to query ads via a dedicated URL
  • allow to reserve only width or height for plain, rich content and group ad types
Download this release

Release Info

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

Code changes from version 1.22.2 to 1.23.0

admin/assets/js/admin.js CHANGED
@@ -557,9 +557,10 @@ jQuery( document ).ready( function ( $ ) {
557
 
558
  // process "reserve this space" checkbox
559
  $( '#advanced-ads-ad-parameters' ).on( 'change', '#advanced-ads-ad-parameters-size input[type=number]', function () {
 
560
  if ( $( '#advanced-ads-ad-parameters-size input[type=number]' ).filter( function () {
561
  return parseInt( this.value, 10 ) > 0
562
- } ).length === 2 ) {
563
  $( '#advads-wrapper-add-sizes' ).prop( 'disabled', false )
564
  } else {
565
  $( '#advads-wrapper-add-sizes' ).prop( 'disabled', true ).prop( 'checked', false )
557
 
558
  // process "reserve this space" checkbox
559
  $( '#advanced-ads-ad-parameters' ).on( 'change', '#advanced-ads-ad-parameters-size input[type=number]', function () {
560
+ // Check if width and/or height is set.
561
  if ( $( '#advanced-ads-ad-parameters-size input[type=number]' ).filter( function () {
562
  return parseInt( this.value, 10 ) > 0
563
+ } ).length >= 1 ) {
564
  $( '#advads-wrapper-add-sizes' ).prop( 'disabled', false )
565
  } else {
566
  $( '#advads-wrapper-add-sizes' ).prop( 'disabled', true ).prop( 'checked', false )
admin/includes/ad-health-notices.php CHANGED
@@ -286,5 +286,15 @@ $advanced_ads_ad_health_notices = apply_filters(
286
  'hide' => false,
287
  'timeout' => YEAR_IN_SECONDS,
288
  ),
 
 
 
 
 
 
 
 
 
 
289
  )
290
  );
286
  'hide' => false,
287
  'timeout' => YEAR_IN_SECONDS,
288
  ),
289
+ // MailPoet changed how they are using custom shortcodes
290
+ // Advanced_Ads_Compatibility::mailpoet_ad_shortcode().
291
+ 'mailpoet-deprecated-custom-shortcodes' => array(
292
+ 'text' =>
293
+ __( 'MailPoet is going to deprecate custom shortcodes. This might remove ads from your newsletters.', 'advanced-ads' )
294
+ . ' <a href="' . ADVADS_URL . 'mailpoet-newsletters/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-mailpoet-shortcodes#Enable_MailPoet_support_in_Advanced_Ads">' . __( 'Learn more', 'advanced-ads' ) . '</a>',
295
+ 'type' => 'problem',
296
+ 'hide' => false,
297
+ 'timeout' => YEAR_IN_SECONDS,
298
+ ),
299
  )
300
  );
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.22.2
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.22.2' );
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.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.23.0' );
43
 
44
  // Autoloading, modules and functions.
45
 
classes/ad.php CHANGED
@@ -852,7 +852,11 @@ class Advanced_Ads_Ad {
852
  $wrapper['style']['margin-left'] = 'auto';
853
  $wrapper['style']['margin-right'] = 'auto';
854
 
855
- if ( empty( $this->output['add_wrapper_sizes'] ) || $use_placement_pos ) {
 
 
 
 
856
  $wrapper['style']['text-align'] = 'center';
857
  }
858
 
@@ -873,21 +877,28 @@ class Advanced_Ads_Ad {
873
  }
874
 
875
  if ( ! empty( $this->output['margin']['top'] ) ) {
876
- $wrapper['style']['margin-top'] = intval( $this->output['margin']['top'] ) . 'px';
877
  }
878
  if ( empty( $wrapper['style']['margin-right'] ) && ! empty( $this->output['margin']['right'] ) ) {
879
- $wrapper['style']['margin-right'] = intval( $this->output['margin']['right'] ) . 'px';
880
  }
881
  if ( ! empty( $this->output['margin']['bottom'] ) ) {
882
- $wrapper['style']['margin-bottom'] = intval( $this->output['margin']['bottom'] ) . 'px';
883
  }
884
  if ( empty( $wrapper['style']['margin-left'] ) && ! empty( $this->output['margin']['left'] ) ) {
885
- $wrapper['style']['margin-left'] = intval( $this->output['margin']['left'] ) . 'px';
886
  }
887
 
888
  if ( ! empty( $this->output['add_wrapper_sizes'] ) ) {
889
- $wrapper['style']['width'] = intval( $this->width ) . 'px';
890
- $wrapper['style']['height'] = intval( $this->height ) . 'px';
 
 
 
 
 
 
 
891
  }
892
 
893
  if ( ! empty( $this->output['clearfix_before'] ) ) {
852
  $wrapper['style']['margin-left'] = 'auto';
853
  $wrapper['style']['margin-right'] = 'auto';
854
 
855
+ $width = (int) $this->width;
856
+ if (
857
+ ( ! $width || empty( $this->output['add_wrapper_sizes'] ) )
858
+ || $use_placement_pos
859
+ ) {
860
  $wrapper['style']['text-align'] = 'center';
861
  }
862
 
877
  }
878
 
879
  if ( ! empty( $this->output['margin']['top'] ) ) {
880
+ $wrapper['style']['margin-top'] = (int) $this->output['margin']['top'] . 'px';
881
  }
882
  if ( empty( $wrapper['style']['margin-right'] ) && ! empty( $this->output['margin']['right'] ) ) {
883
+ $wrapper['style']['margin-right'] = (int) $this->output['margin']['right'] . 'px';
884
  }
885
  if ( ! empty( $this->output['margin']['bottom'] ) ) {
886
+ $wrapper['style']['margin-bottom'] = (int) $this->output['margin']['bottom'] . 'px';
887
  }
888
  if ( empty( $wrapper['style']['margin-left'] ) && ! empty( $this->output['margin']['left'] ) ) {
889
+ $wrapper['style']['margin-left'] = (int) $this->output['margin']['left'] . 'px';
890
  }
891
 
892
  if ( ! empty( $this->output['add_wrapper_sizes'] ) ) {
893
+ $width = (int) $this->width;
894
+ $height = (int) $this->height;
895
+
896
+ if ( $width ) {
897
+ $wrapper['style']['width'] = $width . 'px';
898
+ }
899
+ if ( $height ) {
900
+ $wrapper['style']['height'] = $height . 'px';
901
+ }
902
  }
903
 
904
  if ( ! empty( $this->output['clearfix_before'] ) ) {
classes/ad_group.php CHANGED
@@ -622,7 +622,7 @@ class Advanced_Ads_Group {
622
  $this->wrapper['style']['float'] = 'right';
623
  break;
624
  case 'center' :
625
- // We don't know whether the 'add_wrapper_sizes' option exists.
626
  $this->wrapper['style']['text-align'] = 'center';
627
  break;
628
  }
622
  $this->wrapper['style']['float'] = 'right';
623
  break;
624
  case 'center' :
625
+ // We don't know whether the 'add_wrapper_sizes' option exists and width is set.
626
  $this->wrapper['style']['text-align'] = 'center';
627
  break;
628
  }
classes/compatibility.php CHANGED
@@ -28,7 +28,7 @@ class Advanced_Ads_Compatibility {
28
  // WordPress SEO by Yoast.
29
  add_filter( 'wpseo_sitemap_entry', array( $this, 'wordpress_seo_noindex_ad_attachments' ), 10, 3 );
30
  // Add shortcode for MailPoet.
31
- add_filter( 'mailpoet_newsletter_shortcode', array( $this, 'mailpoet_ad_shortcode' ), 10, 5 );
32
 
33
  // Enable Advanced Custom Fields on ad edit pages.
34
  if ( class_exists( 'ACF', false ) ) {
@@ -143,6 +143,10 @@ class Advanced_Ads_Compatibility {
143
  * e.g., [custom:ad:123] to display ad with the ID 123
144
  * [custom:ad_group:345] to display ad group with the ID 345
145
  *
 
 
 
 
146
  * @param string $shortcode shortcode that placed the ad.
147
  * @param mixed $newsletter unused.
148
  * @param mixed $subscriber unused.
@@ -151,7 +155,8 @@ class Advanced_Ads_Compatibility {
151
  *
152
  * @return string
153
  */
154
- public function mailpoet_ad_shortcode( $shortcode, $newsletter, $subscriber, $queue, $newsletter_body ) {
 
155
  // display an ad group.
156
  if ( 0 === strpos( $shortcode, '[custom:ad_group:' ) ) {
157
  // get ad group ID.
@@ -163,6 +168,11 @@ class Advanced_Ads_Compatibility {
163
  return '';
164
  }
165
 
 
 
 
 
 
166
  // only display if the ad group type could work, i.e. default (random) and ordered.
167
  $ad_group = new Advanced_Ads_Group( $group_id );
168
  if ( isset( $ad_group->type ) && in_array( $ad_group->type, array( 'default', 'ordered' ), true ) ) {
@@ -182,6 +192,11 @@ class Advanced_Ads_Compatibility {
182
  return '';
183
  }
184
 
 
 
 
 
 
185
  $ad = new Advanced_Ads_Ad( $ad_id );
186
  // only display if the ad type could work, i.e. plain text and image ads.
187
  if ( isset( $ad->type ) && in_array( $ad->type, array( 'plain', 'image' ), true ) ) {
28
  // WordPress SEO by Yoast.
29
  add_filter( 'wpseo_sitemap_entry', array( $this, 'wordpress_seo_noindex_ad_attachments' ), 10, 3 );
30
  // Add shortcode for MailPoet.
31
+ add_filter( 'mailpoet_newsletter_shortcode', array( 'Advanced_Ads_Compatibility', 'mailpoet_ad_shortcode' ), 10, 5 );
32
 
33
  // Enable Advanced Custom Fields on ad edit pages.
34
  if ( class_exists( 'ACF', false ) ) {
143
  * e.g., [custom:ad:123] to display ad with the ID 123
144
  * [custom:ad_group:345] to display ad group with the ID 345
145
  *
146
+ * DECEMBER 2020: MailPoet deprecated support for custom shortcodes in December 2020
147
+ * right now, it is not clear if and how this will work in the future
148
+ * we add an Ad Health notice to users who use one of our custom shortcodes
149
+ *
150
  * @param string $shortcode shortcode that placed the ad.
151
  * @param mixed $newsletter unused.
152
  * @param mixed $subscriber unused.
155
  *
156
  * @return string
157
  */
158
+ public static function mailpoet_ad_shortcode( $shortcode, $newsletter, $subscriber, $queue, $newsletter_body ) {
159
+
160
  // display an ad group.
161
  if ( 0 === strpos( $shortcode, '[custom:ad_group:' ) ) {
162
  // get ad group ID.
168
  return '';
169
  }
170
 
171
+ // see function comment above
172
+ if ( class_exists( 'Advanced_Ads_Ad_Health_Notices', false ) ) {
173
+ Advanced_Ads_Ad_Health_Notices::get_instance()->add( 'mailpoet-deprecated-custom-shortcodes' );
174
+ }
175
+
176
  // only display if the ad group type could work, i.e. default (random) and ordered.
177
  $ad_group = new Advanced_Ads_Group( $group_id );
178
  if ( isset( $ad_group->type ) && in_array( $ad_group->type, array( 'default', 'ordered' ), true ) ) {
192
  return '';
193
  }
194
 
195
+ // see function comment above
196
+ if ( class_exists( 'Advanced_Ads_Ad_Health_Notices', false ) ) {
197
+ Advanced_Ads_Ad_Health_Notices::get_instance()->add( 'mailpoet-deprecated-custom-shortcodes' );
198
+ }
199
+
200
  $ad = new Advanced_Ads_Ad( $ad_id );
201
  // only display if the ad type could work, i.e. plain text and image ads.
202
  if ( isset( $ad->type ) && in_array( $ad->type, array( 'plain', 'image' ), true ) ) {
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.22.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
7
  "Last-Translator: Thomas Maier <post@webzunft.de>\n"
8
  "Language-Team: webgilde <support@wpadvancedads.com>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2020-12-16T13:01:22+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"
@@ -77,7 +77,7 @@ msgid "There were no results returned for this ad. Please make sure it is active
77
  msgstr ""
78
 
79
  #: admin/class-advanced-ads-admin.php:229
80
- #: modules/gadsense/admin/views/external-ads-list.php:33
81
  msgid "Show inactive ads"
82
  msgstr ""
83
 
@@ -176,7 +176,7 @@ msgstr ""
176
 
177
  #: admin/includes/ad-health-notices.php:148
178
  #: admin/includes/ad-health-notices.php:155
179
- #: modules/gadsense/includes/class-mapi.php:93
180
  msgid "Last AdSense account connection attempt failed."
181
  msgstr ""
182
 
@@ -241,6 +241,14 @@ msgstr ""
241
  msgid "Learn how."
242
  msgstr ""
243
 
 
 
 
 
 
 
 
 
244
  #: admin/includes/class-ad-groups-list.php:172
245
  msgid "Ad weight"
246
  msgstr ""
@@ -1160,8 +1168,8 @@ msgstr ""
1160
 
1161
  #: admin/views/ad-group-list-form-row.php:31
1162
  #: admin/views/placements.php:66
1163
- #: modules/gadsense/admin/views/external-ads-list.php:45
1164
- #: modules/gadsense/admin/views/external-ads-list.php:55
1165
  #: modules/privacy/admin/views/setting-general.php:44
1166
  msgid "Name"
1167
  msgstr ""
@@ -2476,7 +2484,7 @@ msgstr ""
2476
 
2477
  #. translators: %1$s is an anchor (link) opening tag, %2$s is the closing tag.
2478
  #: classes/ad-health-notices.php:865
2479
- #: modules/gadsense/includes/class-mapi.php:1658
2480
  msgid "Learn more about AdSense account issues %1$shere%2$s."
2481
  msgstr ""
2482
 
@@ -3529,33 +3537,15 @@ msgstr ""
3529
  msgid "Advanced Ads detected that <strong>%s</strong> is managing the Auto ads code and will therefore not add it."
3530
  msgstr ""
3531
 
3532
- #: modules/gadsense/admin/views/connect-adsense.php:35
3533
- msgid "Please enter the confirmation code."
3534
- msgstr ""
3535
-
3536
- #. Translators: 1: opening a tag to open Google Adsense modal 2: closing a tag
3537
- #: modules/gadsense/admin/views/connect-adsense.php:39
3538
- msgid "This is not the correct confirmation code. %1$sPlease try again%2$s."
3539
- msgstr ""
3540
-
3541
- #: modules/gadsense/admin/views/connect-adsense.php:43
3542
- #: modules/gadsense/includes/class-network-adsense.php:224
3543
- msgid "Insert the AdSense header code used for verification and the Auto Ads feature."
3544
- msgstr ""
3545
-
3546
- #: modules/gadsense/admin/views/connect-adsense.php:45
3547
- msgid "Submit code"
3548
- msgstr ""
3549
-
3550
- #: modules/gadsense/admin/views/connect-adsense.php:53
3551
  msgid "Cannot access your account information."
3552
  msgstr ""
3553
 
3554
- #: modules/gadsense/admin/views/connect-adsense.php:59
3555
  msgid "Please select an account"
3556
  msgstr ""
3557
 
3558
- #: modules/gadsense/admin/views/connect-adsense.php:64
3559
  msgid "Use this account"
3560
  msgstr ""
3561
 
@@ -3578,71 +3568,71 @@ msgstr ""
3578
  msgid "Connect to %1$s"
3579
  msgstr ""
3580
 
3581
- #: modules/gadsense/admin/views/external-ads-list.php:34
3582
- #: modules/gadsense/admin/views/external-ads-list.php:78
3583
  msgid "Update the ad units list"
3584
  msgstr ""
3585
 
3586
- #: modules/gadsense/admin/views/external-ads-list.php:46
3587
- #: modules/gadsense/admin/views/external-ads-list.php:56
3588
  msgctxt "AdSense ad"
3589
  msgid "Slot ID"
3590
  msgstr ""
3591
 
3592
- #: modules/gadsense/admin/views/external-ads-list.php:47
3593
- #: modules/gadsense/admin/views/external-ads-list.php:57
3594
  msgctxt "AdSense ad"
3595
  msgid "Type"
3596
  msgstr ""
3597
 
3598
- #: modules/gadsense/admin/views/external-ads-list.php:48
3599
- #: modules/gadsense/admin/views/external-ads-list.php:58
3600
  msgid "Size"
3601
  msgstr ""
3602
 
3603
- #: modules/gadsense/admin/views/external-ads-list.php:65
3604
  msgid "No active ad units found"
3605
  msgstr ""
3606
 
3607
- #: modules/gadsense/admin/views/external-ads-list.php:67
3608
  msgid "Show all ad units"
3609
  msgstr ""
3610
 
3611
- #: modules/gadsense/admin/views/external-ads-list.php:76
3612
  msgid "No ad units found"
3613
  msgstr ""
3614
 
3615
- #: modules/gadsense/admin/views/external-ads-list.php:102
3616
  msgid "Get the code for this ad"
3617
  msgstr ""
3618
 
3619
- #: modules/gadsense/admin/views/external-ads-list.php:107
3620
  msgid "Ad can't be imported, click for details"
3621
  msgstr ""
3622
 
3623
- #: modules/gadsense/admin/views/external-ads-list.php:119
3624
  msgid "Unrecognized ad code"
3625
  msgstr ""
3626
 
3627
- #: modules/gadsense/admin/views/external-ads-list.php:125
3628
  msgid "This ad type can currently not be imported from AdSense."
3629
  msgstr ""
3630
 
3631
- #: modules/gadsense/admin/views/external-ads-list.php:128
3632
  msgid "You can proceed with one of the following solutions"
3633
  msgstr ""
3634
 
3635
  #. Translators: 1: opening tag for AdSense account link 2: opening tag for a link to insert ad code 3: closing a tag
3636
- #: modules/gadsense/admin/views/external-ads-list.php:134
3637
  msgid "%1$sCopy the code from your AdSense account%3$s and %2$sinsert a new AdSense code here%3$s."
3638
  msgstr ""
3639
 
3640
  #. Translators: 1: opening tag for a link to create an ad manually 2: closing a tag
3641
- #: modules/gadsense/admin/views/external-ads-list.php:140
3642
  msgid "%1$sCreate an AdSense code manually%2$s: Select the <em>Normal</em> or <em>Responsive</em> type and the size."
3643
  msgstr ""
3644
 
3645
- #: modules/gadsense/admin/views/external-ads-list.php:147
3646
  msgid "Choose a different ad from your AdSense account above."
3647
  msgstr ""
3648
 
@@ -3667,110 +3657,110 @@ msgstr ""
3667
  msgid "Auto"
3668
  msgstr ""
3669
 
3670
- #: modules/gadsense/includes/class-mapi.php:342
3671
  msgid "Error while retrieving ad code for \"%s\"."
3672
  msgstr ""
3673
 
3674
- #: modules/gadsense/includes/class-mapi.php:369
3675
  msgid "Invalid response while retrieving ad code for \"%s\"."
3676
  msgstr ""
3677
 
3678
  #. translators: the publisher ID.
3679
- #: modules/gadsense/includes/class-mapi.php:424
3680
- #: modules/gadsense/includes/class-mapi.php:509
3681
  msgid "Error while retrieving adUnits list for \"%s\"."
3682
  msgstr ""
3683
 
3684
  #. translators: %s is the publisher ID.
3685
- #: modules/gadsense/includes/class-mapi.php:435
3686
  msgid "Invalid response while retrieving adUnits list for \"%s\"."
3687
  msgstr ""
3688
 
3689
- #: modules/gadsense/includes/class-mapi.php:443
3690
  msgid "Reason:"
3691
  msgstr ""
3692
 
3693
- #: modules/gadsense/includes/class-mapi.php:444
3694
  msgid "Message:"
3695
  msgstr ""
3696
 
3697
  #. translators: %1$s is the AdSense publisher ID; %2$s a starting a tag to the AdSense ad unit list and %3$s the closing link.
3698
- #: modules/gadsense/includes/class-mapi.php:461
3699
  msgid "The account \"%1$s\" does not seem to have any ad units. Please create some %2$shere%3$s."
3700
  msgstr ""
3701
 
3702
- #: modules/gadsense/includes/class-mapi.php:600
3703
  msgid "It seems that some changes have been made in the Advanced Ads settings. Please refresh this page."
3704
  msgstr ""
3705
 
3706
- #: modules/gadsense/includes/class-mapi.php:607
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:649
3711
  msgid "error while renewing access token for \"%s\""
3712
  msgstr ""
3713
 
3714
- #: modules/gadsense/includes/class-mapi.php:674
3715
  msgid "invalid response received while renewing access token for \"%s\""
3716
  msgstr ""
3717
 
3718
- #: modules/gadsense/includes/class-mapi.php:743
3719
  msgid "This ad code is from a different AdSense Account"
3720
  msgstr ""
3721
 
3722
- #: modules/gadsense/includes/class-mapi.php:972
3723
  msgid "Invalid response body while retrieving account alerts"
3724
  msgstr ""
3725
 
3726
- #: modules/gadsense/includes/class-mapi.php:981
3727
  msgid "error while retrieving account alerts"
3728
  msgstr ""
3729
 
3730
- #: modules/gadsense/includes/class-mapi.php:1137
3731
  msgid "No token provided. Token data needed to get account details."
3732
  msgstr ""
3733
 
3734
- #: modules/gadsense/includes/class-mapi.php:1201
3735
  msgid "An error occurred while requesting account details."
3736
  msgstr ""
3737
 
3738
- #: modules/gadsense/includes/class-mapi.php:1426
3739
  #: modules/gadsense/includes/class-network-adsense.php:509
3740
  msgctxt "AdSense ad type"
3741
  msgid "Matched Content"
3742
  msgstr ""
3743
 
3744
- #: modules/gadsense/includes/class-mapi.php:1429
3745
  #: modules/gadsense/includes/class-network-adsense.php:510
3746
  msgctxt "AdSense ad type"
3747
  msgid "In-article"
3748
  msgstr ""
3749
 
3750
- #: modules/gadsense/includes/class-mapi.php:1431
3751
  #: modules/gadsense/includes/class-network-adsense.php:511
3752
  msgctxt "AdSense ad type"
3753
  msgid "In-feed"
3754
  msgstr ""
3755
 
3756
- #: modules/gadsense/includes/class-mapi.php:1436
3757
  #: modules/gadsense/includes/class-network-adsense.php:512
3758
  msgctxt "AdSense ad type"
3759
  msgid "Display"
3760
  msgstr ""
3761
 
3762
- #: modules/gadsense/includes/class-mapi.php:1438
3763
  #: modules/gadsense/includes/class-network-adsense.php:513
3764
  msgctxt "AdSense ad type"
3765
  msgid "Link"
3766
  msgstr ""
3767
 
3768
- #: modules/gadsense/includes/class-mapi.php:1625
3769
  msgid "There are one or more warnings about the currently linked AdSense account. You can view them <a href=\"%s\">here</a>"
3770
  msgstr ""
3771
 
3772
  #. translators: 1:A link to the settings page translators: 2:The name of an ad network
3773
- #: modules/gadsense/includes/class-mapi.php:1712
3774
  msgid "Please try to <a href=\"%1$s\" target=\"_blank\">reconnect to your %2$s account</a>."
3775
  msgstr ""
3776
 
@@ -3779,9 +3769,6 @@ msgid "AdSense account"
3779
  msgstr ""
3780
 
3781
  #: modules/gadsense/includes/class-network-adsense.php:63
3782
- msgid "Verification code & Auto ads"
3783
- msgstr ""
3784
-
3785
  #: modules/gadsense/includes/class-network-adsense.php:74
3786
  msgid "Auto ads"
3787
  msgstr ""
@@ -3831,6 +3818,10 @@ msgstr ""
3831
  msgid "Enable this option to stop loading stats from AdSense into your WordPress backend."
3832
  msgstr ""
3833
 
 
 
 
 
3834
  #: modules/gadsense/includes/class-network-adsense.php:229
3835
  msgid "Why are ads appearing in random positions?"
3836
  msgstr ""
@@ -4171,7 +4162,7 @@ msgstr ""
4171
  msgid "Parent Ad"
4172
  msgstr ""
4173
 
4174
- #: public/class-advanced-ads.php:968
4175
  msgctxt "label above ads"
4176
  msgid "Advertisements"
4177
  msgstr ""
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"
77
  msgstr ""
78
 
79
  #: admin/class-advanced-ads-admin.php:229
80
+ #: modules/gadsense/admin/views/external-ads-list.php:29
81
  msgid "Show inactive ads"
82
  msgstr ""
83
 
176
 
177
  #: admin/includes/ad-health-notices.php:148
178
  #: admin/includes/ad-health-notices.php:155
179
+ #: modules/gadsense/includes/class-mapi.php:95
180
  msgid "Last AdSense account connection attempt failed."
181
  msgstr ""
182
 
241
  msgid "Learn how."
242
  msgstr ""
243
 
244
+ #: admin/includes/ad-health-notices.php:293
245
+ msgid "MailPoet is going to deprecate custom shortcodes. This might remove ads from your newsletters."
246
+ msgstr ""
247
+
248
+ #: admin/includes/ad-health-notices.php:294
249
+ msgid "Learn more"
250
+ msgstr ""
251
+
252
  #: admin/includes/class-ad-groups-list.php:172
253
  msgid "Ad weight"
254
  msgstr ""
1168
 
1169
  #: admin/views/ad-group-list-form-row.php:31
1170
  #: admin/views/placements.php:66
1171
+ #: modules/gadsense/admin/views/external-ads-list.php:41
1172
+ #: modules/gadsense/admin/views/external-ads-list.php:51
1173
  #: modules/privacy/admin/views/setting-general.php:44
1174
  msgid "Name"
1175
  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
 
3537
  msgid "Advanced Ads detected that <strong>%s</strong> is managing the Auto ads code and will therefore not add it."
3538
  msgstr ""
3539
 
3540
+ #: modules/gadsense/admin/views/connect-adsense.php:57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3541
  msgid "Cannot access your account information."
3542
  msgstr ""
3543
 
3544
+ #: modules/gadsense/admin/views/connect-adsense.php:63
3545
  msgid "Please select an account"
3546
  msgstr ""
3547
 
3548
+ #: modules/gadsense/admin/views/connect-adsense.php:68
3549
  msgid "Use this account"
3550
  msgstr ""
3551
 
3568
  msgid "Connect to %1$s"
3569
  msgstr ""
3570
 
3571
+ #: modules/gadsense/admin/views/external-ads-list.php:30
3572
+ #: modules/gadsense/admin/views/external-ads-list.php:74
3573
  msgid "Update the ad units list"
3574
  msgstr ""
3575
 
3576
+ #: modules/gadsense/admin/views/external-ads-list.php:42
3577
+ #: modules/gadsense/admin/views/external-ads-list.php:52
3578
  msgctxt "AdSense ad"
3579
  msgid "Slot ID"
3580
  msgstr ""
3581
 
3582
+ #: modules/gadsense/admin/views/external-ads-list.php:43
3583
+ #: modules/gadsense/admin/views/external-ads-list.php:53
3584
  msgctxt "AdSense ad"
3585
  msgid "Type"
3586
  msgstr ""
3587
 
3588
+ #: modules/gadsense/admin/views/external-ads-list.php:44
3589
+ #: modules/gadsense/admin/views/external-ads-list.php:54
3590
  msgid "Size"
3591
  msgstr ""
3592
 
3593
+ #: modules/gadsense/admin/views/external-ads-list.php:61
3594
  msgid "No active ad units found"
3595
  msgstr ""
3596
 
3597
+ #: modules/gadsense/admin/views/external-ads-list.php:63
3598
  msgid "Show all ad units"
3599
  msgstr ""
3600
 
3601
+ #: modules/gadsense/admin/views/external-ads-list.php:72
3602
  msgid "No ad units found"
3603
  msgstr ""
3604
 
3605
+ #: modules/gadsense/admin/views/external-ads-list.php:98
3606
  msgid "Get the code for this ad"
3607
  msgstr ""
3608
 
3609
+ #: modules/gadsense/admin/views/external-ads-list.php:103
3610
  msgid "Ad can't be imported, click for details"
3611
  msgstr ""
3612
 
3613
+ #: modules/gadsense/admin/views/external-ads-list.php:116
3614
  msgid "Unrecognized ad code"
3615
  msgstr ""
3616
 
3617
+ #: modules/gadsense/admin/views/external-ads-list.php:122
3618
  msgid "This ad type can currently not be imported from AdSense."
3619
  msgstr ""
3620
 
3621
+ #: modules/gadsense/admin/views/external-ads-list.php:125
3622
  msgid "You can proceed with one of the following solutions"
3623
  msgstr ""
3624
 
3625
  #. Translators: 1: opening tag for AdSense account link 2: opening tag for a link to insert ad code 3: closing a tag
3626
+ #: modules/gadsense/admin/views/external-ads-list.php:131
3627
  msgid "%1$sCopy the code from your AdSense account%3$s and %2$sinsert a new AdSense code here%3$s."
3628
  msgstr ""
3629
 
3630
  #. Translators: 1: opening tag for a link to create an ad manually 2: closing a tag
3631
+ #: modules/gadsense/admin/views/external-ads-list.php:137
3632
  msgid "%1$sCreate an AdSense code manually%2$s: Select the <em>Normal</em> or <em>Responsive</em> type and the size."
3633
  msgstr ""
3634
 
3635
+ #: modules/gadsense/admin/views/external-ads-list.php:144
3636
  msgid "Choose a different ad from your AdSense account above."
3637
  msgstr ""
3638
 
3657
  msgid "Auto"
3658
  msgstr ""
3659
 
3660
+ #: modules/gadsense/includes/class-mapi.php:344
3661
  msgid "Error while retrieving ad code for \"%s\"."
3662
  msgstr ""
3663
 
3664
+ #: modules/gadsense/includes/class-mapi.php:371
3665
  msgid "Invalid response while retrieving ad code for \"%s\"."
3666
  msgstr ""
3667
 
3668
  #. translators: the publisher ID.
3669
+ #: modules/gadsense/includes/class-mapi.php:426
3670
+ #: modules/gadsense/includes/class-mapi.php:518
3671
  msgid "Error while retrieving adUnits list for \"%s\"."
3672
  msgstr ""
3673
 
3674
  #. translators: %s is the publisher ID.
3675
+ #: modules/gadsense/includes/class-mapi.php:437
3676
  msgid "Invalid response while retrieving adUnits list for \"%s\"."
3677
  msgstr ""
3678
 
3679
+ #: modules/gadsense/includes/class-mapi.php:445
3680
  msgid "Reason:"
3681
  msgstr ""
3682
 
3683
+ #: modules/gadsense/includes/class-mapi.php:446
3684
  msgid "Message:"
3685
  msgstr ""
3686
 
3687
  #. translators: %1$s is the AdSense publisher ID; %2$s a starting a tag to the AdSense ad unit list and %3$s the closing link.
3688
+ #: modules/gadsense/includes/class-mapi.php:468
3689
  msgid "The account \"%1$s\" does not seem to have any ad units. Please create some %2$shere%3$s."
3690
  msgstr ""
3691
 
3692
+ #: modules/gadsense/includes/class-mapi.php:609
3693
  msgid "It seems that some changes have been made in the Advanced Ads settings. Please refresh this page."
3694
  msgstr ""
3695
 
3696
+ #: modules/gadsense/includes/class-mapi.php:616
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
 
3769
  msgstr ""
3770
 
3771
  #: modules/gadsense/includes/class-network-adsense.php:63
 
 
 
3772
  #: modules/gadsense/includes/class-network-adsense.php:74
3773
  msgid "Auto ads"
3774
  msgstr ""
3818
  msgid "Enable this option to stop loading stats from AdSense into your WordPress backend."
3819
  msgstr ""
3820
 
3821
+ #: modules/gadsense/includes/class-network-adsense.php:224
3822
+ msgid "Insert the AdSense header code to enable Auto ads and verify your website."
3823
+ msgstr ""
3824
+
3825
  #: modules/gadsense/includes/class-network-adsense.php:229
3826
  msgid "Why are ads appearing in random positions?"
3827
  msgstr ""
4162
  msgid "Parent Ad"
4163
  msgstr ""
4164
 
4165
+ #: public/class-advanced-ads.php:969
4166
  msgctxt "label above ads"
4167
  msgid "Advertisements"
4168
  msgstr ""
modules/gadsense/admin/admin.php CHANGED
@@ -255,7 +255,7 @@ class Advanced_Ads_AdSense_Admin {
255
  *
256
  * @param bool $hide_idle_ads Whether to hide idle ads.
257
  */
258
- public static function get_mapi_ad_selector( $hide_idle_ads = true ) {
259
  global $closeable, $use_dashicons, $network, $ad_units, $display_slot_id;
260
  $closeable = true;
261
  $use_dashicons = false;
@@ -265,6 +265,5 @@ class Advanced_Ads_AdSense_Admin {
265
  $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id();
266
 
267
  require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-list.php';
268
- // Require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-adsense.php';.
269
  }
270
  }
255
  *
256
  * @param bool $hide_idle_ads Whether to hide idle ads.
257
  */
258
+ public static function get_mapi_ad_selector( $hide_idle_ads = true, $load_inactive_button = false ) {
259
  global $closeable, $use_dashicons, $network, $ad_units, $display_slot_id;
260
  $closeable = true;
261
  $use_dashicons = false;
265
  $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id();
266
 
267
  require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-list.php';
 
268
  }
269
  }
modules/gadsense/admin/assets/js/adsense.js CHANGED
@@ -675,10 +675,16 @@ class AdvancedAdsNetworkAdsense extends AdvancedAdsAdNetwork{
675
  jQuery( '#wpwrap' ).on(
676
  'advads-mapi-adlist-opened',
677
  function (ev) {
678
- if (jQuery( '#mapi-table-wrap tbody tr' ).length != jQuery( '#mapi-table-wrap tbody tr[data-active="1"]' ).length) {
679
- // idle ads are present in the table. Adjust AdNetwork and AdImporter default values accordingly.
680
- that.hideIdle = false;
681
- window.AdvancedAdsAdmin.AdImporter.toggleIdleAds( false );
 
 
 
 
 
 
682
  }
683
  }
684
  );
675
  jQuery( '#wpwrap' ).on(
676
  'advads-mapi-adlist-opened',
677
  function (ev) {
678
+ if ( jQuery( '#mapi-table-wrap tbody tr' ).length != jQuery( '#mapi-table-wrap tbody tr[data-active="1"]' ).length) {
679
+ if ( jQuery( '#mapi-table-wrap tbody tr#mapi-notice-inactive' ).length || jQuery( '#mapi-table-wrap tbody tr#mapi-notice-noads' ).length ) {
680
+ // No active ads found.
681
+ that.hideIdle = true;
682
+ window.AdvancedAdsAdmin.AdImporter.toggleIdleAds( true );
683
+ } else {
684
+ // Idle ads are present in the table. Adjust AdNetwork and AdImporter default values accordingly.
685
+ that.hideIdle = false;
686
+ window.AdvancedAdsAdmin.AdImporter.toggleIdleAds( false );
687
+ }
688
  }
689
  }
690
  );
modules/gadsense/admin/assets/js/connect-adsense.js CHANGED
@@ -5,7 +5,6 @@
5
 
6
  var advadsMapiConnectClass = function( content, options ) {
7
  this.options = {};
8
- this.AUTH_WINDOW = null;
9
  this.modal = $( '#gadsense-modal' );
10
  this.frame = null;
11
  if ( 'undefined' == typeof content || ! content ) {
@@ -43,10 +42,49 @@
43
  this.options.onSuccess( this );
44
  }
45
  } else {
46
- window.location.reload();
47
  }
48
  },
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  // Initialization - mostly binding events.
51
  init: function(){
52
 
@@ -54,59 +92,7 @@
54
 
55
  // Close the modal and hide errors.
56
  $( document ).on( 'click', '#gadsense-modal .dashicons-dismiss', function(){
57
- $( '#mapi-code' ).val( '' );
58
- $( '#gadsense-modal, #gadsense-modal-error' ).css( 'display', 'none' );
59
- } );
60
-
61
- // Confirm code for account connection.
62
- $( document ).on( 'click', '#mapi-confirm-code', function(){
63
-
64
- var code = $( '#mapi-code' ).val();
65
- if ( '' == code ) return;
66
- $( '.gadsense-overlay' ).css( 'display', 'block' );
67
- $( '#gadsense-modal-error' ).hide();
68
- var data = {
69
- action: 'advads_gadsense_mapi_confirm_code',
70
- code: code,
71
- nonce: AdsenseMAPI.nonce,
72
- };
73
-
74
- $.ajax({
75
- url: ajaxurl,
76
- type: 'post',
77
- data: data,
78
- success:function(response, status, XHR){
79
- if ( null !== that.AUTH_WINDOW ) {
80
- that.AUTH_WINDOW.close();
81
- }
82
- $( '#mapi-code' ).val( '' );
83
- if ( response.status && true === response.status && response['token_data'] ) {
84
- that.getAccountDetails( response['token_data'] );
85
- } else {
86
- /**
87
- * Connection error handling.
88
- */
89
- console.log( response );
90
- $( '.gadsense-overlay' ).css( 'display', 'none' );
91
- $( '#mapi-code' ).val( '' );
92
- $( '#mapi-autoads' ).prop( 'checked', false );
93
- $( '#gadsense-modal-content-inner .dashicons-dismiss' ).trigger( 'click' );
94
- if ($.parseJSON(response.response_body).error === 'invalid_grant') {
95
- $('#gadsense-modal-error').show();
96
-
97
- $('#gadsense-reopen-connect').one('click', function (event) {
98
- event.preventDefault();
99
- $('#gadsense-modal-error').hide();
100
- that.show();
101
- });
102
- }
103
- }
104
- },
105
- error:function(request, status, error){
106
- $( '#gadsense-loading-overlay' ).css( 'display', 'none' );
107
- },
108
- });
109
-
110
  } );
111
 
112
  // Account selection
@@ -227,28 +213,16 @@
227
  }
228
  this.switchContent( content );
229
 
230
- if ( 'confirm-code' == content ) {
231
-
232
- // Open Google authentication in a child window.
233
- this.modal.css( 'display', 'block' );
234
-
235
- var oW = $( window ).width(),
236
- oH = $( window ).height(),
237
- w = Math.min( oW, oH ) * 0.8,
238
- h = Math.min( oW, oH ) * 0.8,
239
- l = (oW - w) / 2,
240
- t = (oH - h) / 2,
241
-
242
- args = 'resize=1,titlebar=1,width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
243
- this.AUTH_WINDOW = window.open( AdsenseMAPI.oAuth2, 'advadsOAuth2', args );
244
-
245
- }
246
  },
247
 
248
  // Hide the modal frame
249
  hide: function(){
250
- this.switchContent( 'confirm-code' );
251
- this.modal.css( 'display', 'none' );
252
  },
253
 
254
  };
@@ -273,6 +247,11 @@
273
  $(function(){
274
  // Move the the pop-up outside of any form.
275
  $( '#wpwrap' ).append( $( '#gadsense-modal' ) );
 
 
 
 
 
276
  });
277
 
278
  })(window.jQuery);
5
 
6
  var advadsMapiConnectClass = function( content, options ) {
7
  this.options = {};
 
8
  this.modal = $( '#gadsense-modal' );
9
  this.frame = null;
10
  if ( 'undefined' == typeof content || ! content ) {
42
  this.options.onSuccess( this );
43
  }
44
  } else {
45
+ this.hide();
46
  }
47
  },
48
 
49
+ // Submit OAuth2 code for account connection.
50
+ submitOAuthCode: function( code ) {
51
+
52
+ var that = this;
53
+ if ( '' == code ) return;
54
+ $( '.gadsense-overlay' ).css( 'display', 'block' );
55
+ $( '#gadsense-modal-error' ).hide();
56
+ var data = {
57
+ action: 'advads_gadsense_mapi_confirm_code',
58
+ code: code,
59
+ nonce: AdsenseMAPI.nonce,
60
+ };
61
+
62
+ $.ajax({
63
+ url: ajaxurl,
64
+ type: 'post',
65
+ data: data,
66
+ success:function(response, status, XHR){
67
+ $( '#mapi-code' ).val( '' );
68
+ if ( response.status && true === response.status && response['token_data'] ) {
69
+ that.getAccountDetails( response['token_data'] );
70
+ } else {
71
+ /**
72
+ * Connection error handling.
73
+ */
74
+ console.log( response );
75
+ $( '.gadsense-overlay' ).css( 'display', 'none' );
76
+ $( '#mapi-code' ).val( '' );
77
+ $( '#mapi-autoads' ).prop( 'checked', false );
78
+ $( '#gadsense-modal-content-inner .dashicons-dismiss' ).trigger( 'click' );
79
+ }
80
+ },
81
+ error:function(request, status, error){
82
+ $( '#gadsense-loading-overlay' ).css( 'display', 'none' );
83
+ },
84
+ });
85
+
86
+ },
87
+
88
  // Initialization - mostly binding events.
89
  init: function(){
90
 
92
 
93
  // Close the modal and hide errors.
94
  $( document ).on( 'click', '#gadsense-modal .dashicons-dismiss', function(){
95
+ that.hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  } );
97
 
98
  // Account selection
213
  }
214
  this.switchContent( content );
215
 
216
+ if ( 'open-google' == content ) {
217
+ window.location.href = AdsenseMAPI.oAuth2;
218
+ } else {
219
+ this.modal.css( 'display', 'block' );
220
+ }
 
 
 
 
 
 
 
 
 
 
 
221
  },
222
 
223
  // Hide the modal frame
224
  hide: function(){
225
+ window.location.href = this.modal.attr( 'data-return' );
 
226
  },
227
 
228
  };
247
  $(function(){
248
  // Move the the pop-up outside of any form.
249
  $( '#wpwrap' ).append( $( '#gadsense-modal' ) );
250
+
251
+ if ( $( '#advads-adsense-oauth-code' ).length ) {
252
+ INSTANCE = new advadsMapiConnectClass( 'confirm-code', {} );
253
+ INSTANCE.submitOAuthCode( $( '#advads-adsense-oauth-code' ).val() );
254
+ }
255
  });
256
 
257
  })(window.jQuery);
modules/gadsense/admin/assets/js/mapi-settings.js CHANGED
@@ -86,7 +86,7 @@
86
  $( document ).on( 'click', '#connect-adsense', function(){
87
  if ( $( this ).hasClass( 'disabled' ) ) return;
88
  if ( 'undefined' != typeof window.advadsMapiConnect ) {
89
- window.advadsMapiConnect();
90
  }
91
  } );
92
 
86
  $( document ).on( 'click', '#connect-adsense', function(){
87
  if ( $( this ).hasClass( 'disabled' ) ) return;
88
  if ( 'undefined' != typeof window.advadsMapiConnect ) {
89
+ window.advadsMapiConnect( 'open-google' );
90
  }
91
  } );
92
 
modules/gadsense/admin/views/connect-adsense.php CHANGED
@@ -17,33 +17,37 @@ if ( $use_user_app ) {
17
  $CID = ADVANCED_ADS_MAPI_CID;
18
  }
19
 
 
 
 
 
 
 
20
  $connection_error_messages = Advanced_Ads_AdSense_MAPI::get_connect_error_messages();
21
 
22
  $auth_url = 'https://accounts.google.com/o/oauth2/v2/auth?scope=' .
23
  urlencode( 'https://www.googleapis.com/auth/adsense.readonly' ) .
24
  '&client_id=' . $CID .
25
- '&redirect_uri=' . urlencode( 'urn:ietf:wg:oauth:2.0:oob' ) .
26
- '&access_type=offline&include_granted_scopes=true&prompt=select_account&response_type=code';
 
 
 
27
 
28
- ?>
29
- <div id="gadsense-modal">
 
 
 
 
 
 
30
  <div id="gadsense-modal-outer">
31
  <div id="gadsense-modal-inner">
32
  <div id="gadsense-modal-content">
33
  <div class="gadsense-modal-content-inner" data-content="confirm-code">
34
  <i class="dashicons dashicons-dismiss"></i>
35
- <label style="font-size:1.1em;font-weight:600;margin-bottom:.3em;display:block;"><?php _e( 'Please enter the confirmation code.', 'advanced-ads' ); ?></label>
36
- <div class="gadsense-modal-error" id="gadsense-modal-error">
37
- <?php
38
- /* Translators: 1: opening a tag to open Google Adsense modal 2: closing a tag */
39
- printf( esc_attr__( 'This is not the correct confirmation code. %1$sPlease try again%2$s.', 'advanced-ads' ), '<a href="#" id="gadsense-reopen-connect">', '</a>' );
40
- ?>
41
- </div>
42
- <input type="text" class="widefat" id="mapi-code" value="" />
43
- <p><label><input type="checkbox" value="1" id="mapi-autoads"<?php echo ( $options['page-level-enabled'] ) ? ' checked="checked"' : ''; ?> />&nbsp;<?php _e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' ); ?></label></p>
44
- <p class="submit">
45
- <button id="mapi-confirm-code" class="button-primary preventDefault"><?php _e( 'Submit code', 'advanced-ads' ); ?></button>
46
- </p>
47
  <div class="gadsense-overlay">
48
  <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:3em" />
49
  </div>
17
  $CID = ADVANCED_ADS_MAPI_CID;
18
  }
19
 
20
+ $state = [
21
+ 'api' => 'adsense',
22
+ 'nonce' => $nonce,
23
+ 'return_url' => admin_url( 'admin.php?page=advanced-ads-settings&oauth=1#top#adsense' ),
24
+ ];
25
+
26
  $connection_error_messages = Advanced_Ads_AdSense_MAPI::get_connect_error_messages();
27
 
28
  $auth_url = 'https://accounts.google.com/o/oauth2/v2/auth?scope=' .
29
  urlencode( 'https://www.googleapis.com/auth/adsense.readonly' ) .
30
  '&client_id=' . $CID .
31
+ '&redirect_uri=' . urlencode( Advanced_Ads_AdSense_MAPI::REDIRECT_URI ) .
32
+ '&state=' . urlencode( base64_encode( wp_json_encode( $state ) ) ) .
33
+ '&access_type=offline&include_granted_scopes=true&prompt=consent&response_type=code';
34
+
35
+ $_get = wp_unslash( $_GET );
36
 
37
+ if ( isset( $_get['oauth'] ) && '1' == $_get['oauth'] && isset( $_get['api'] ) && 'adsense' == $_get['api'] ) : ?>
38
+ <?php if ( isset( $_get['nonce'] ) && false !== wp_verify_nonce( $_get['nonce'], 'advads-mapi' ) ) : ?>
39
+ <?php if ( isset( $_get['code'] ) && current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) : ?>
40
+ <input type="hidden" id="advads-adsense-oauth-code" value="<?php echo esc_attr( urldecode( $_get['code'] ) ); ?>" />
41
+ <?php endif; ?>
42
+ <?php endif; ?>
43
+ <?php endif; ?>
44
+ <div id="gadsense-modal" data-return="<?php echo ESC_ATTR( admin_url( 'admin.php?page=advanced-ads-settings&oauth=1#top#adsense' ) ); ?>">
45
  <div id="gadsense-modal-outer">
46
  <div id="gadsense-modal-inner">
47
  <div id="gadsense-modal-content">
48
  <div class="gadsense-modal-content-inner" data-content="confirm-code">
49
  <i class="dashicons dashicons-dismiss"></i>
50
+ <h2><?php esc_html_e( 'Processing authorization', 'advanced-ads-gam' );?></h2>
 
 
 
 
 
 
 
 
 
 
 
51
  <div class="gadsense-overlay">
52
  <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:3em" />
53
  </div>
modules/gadsense/admin/views/external-ads-list.php CHANGED
@@ -20,10 +20,6 @@ if ( ! isset( $hide_idle_ads ) ) {
20
  if ( ! isset( $ad_units ) ) {
21
  $ad_units = array();
22
  }
23
- $only_inactive_units = ! empty( $ad_units ) && empty( array_filter( $ad_units,
24
- function ( Advanced_Ads_Ad_Network_Ad_Unit $ad ) {
25
- return $ad->active;
26
- } ) );
27
 
28
  ?>
29
  <div id="mapi-wrap" class="aa-select-list">
@@ -59,7 +55,7 @@ $only_inactive_units = ! empty( $ad_units ) && empty( array_filter( $ad_units,
59
  </tr>
60
  </thead>
61
  <tbody>
62
- <?php if ( $only_inactive_units ) : ?>
63
  <tr id="mapi-notice-inactive">
64
  <td colspan="5" style="text-align:center;">
65
  <?php esc_attr_e( 'No active ad units found', 'advanced-ads' ); ?>
@@ -69,7 +65,7 @@ $only_inactive_units = ! empty( $ad_units ) && empty( array_filter( $ad_units,
69
  </button>
70
  </td>
71
  </tr>
72
- <?php endif; ?>
73
  <?php if ( empty( $ad_units ) ) : ?>
74
  <tr id="mapi-notice-noads">
75
  <td colspan="5" style="text-align:center;">
@@ -113,6 +109,7 @@ $only_inactive_units = ! empty( $ad_units ) && empty( array_filter( $ad_units,
113
  </tr>
114
  <?php endforeach; ?>
115
  <?php endif; ?>
 
116
  </tbody>
117
  </table>
118
  </div>
20
  if ( ! isset( $ad_units ) ) {
21
  $ad_units = array();
22
  }
 
 
 
 
23
 
24
  ?>
25
  <div id="mapi-wrap" class="aa-select-list">
55
  </tr>
56
  </thead>
57
  <tbody>
58
+ <?php if ( $load_inactive_button ) : ?>
59
  <tr id="mapi-notice-inactive">
60
  <td colspan="5" style="text-align:center;">
61
  <?php esc_attr_e( 'No active ad units found', 'advanced-ads' ); ?>
65
  </button>
66
  </td>
67
  </tr>
68
+ <?php else : ?>
69
  <?php if ( empty( $ad_units ) ) : ?>
70
  <tr id="mapi-notice-noads">
71
  <td colspan="5" style="text-align:center;">
109
  </tr>
110
  <?php endforeach; ?>
111
  <?php endif; ?>
112
+ <?php endif; ?>
113
  </tbody>
114
  </table>
115
  </div>
modules/gadsense/includes/class-ad-type-adsense.php CHANGED
@@ -241,7 +241,6 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
241
  $output .= '<script> ' . "\n";
242
  $output .= '(adsbygoogle = window.adsbygoogle || []).push({}); ' . "\n";
243
  $output .= '</script>' . "\n";
244
- unset( $ad->wrapper['style']['height'] );
245
  } else {
246
  /**
247
  * The value of $ad->content->resize should be tested to format the output correctly
241
  $output .= '<script> ' . "\n";
242
  $output .= '(adsbygoogle = window.adsbygoogle || []).push({}); ' . "\n";
243
  $output .= '</script>' . "\n";
 
244
  } else {
245
  /**
246
  * The value of $ad->content->resize should be tested to format the output correctly
modules/gadsense/includes/class-mapi.php CHANGED
@@ -9,9 +9,11 @@ class Advanced_Ads_AdSense_MAPI {
9
 
10
  const ALERTS_URL = 'https://www.googleapis.com/adsense/v1.4/accounts/PUBID/alerts/';
11
 
12
- const CID = '400595147946-alk0j13qk563bg94rd4f3ip2t0b2tr5r.apps.googleusercontent.com';
13
 
14
- const CS = '5jecyWgvCszB8UxSM0oS1W22';
 
 
15
 
16
  const CALL_PER_24H = 20;
17
 
@@ -454,18 +456,25 @@ class Advanced_Ads_AdSense_MAPI {
454
  } else {
455
 
456
  if ( ! isset( $resp_body['items'] ) ) {
457
- return array(
458
- 'status' => false,
459
- 'msg' => sprintf(
460
- // translators: %1$s is the AdSense publisher ID; %2$s a starting a tag to the AdSense ad unit list and %3$s the closing link.
461
- esc_html__( 'The account "%1$s" does not seem to have any ad units. Please create some %2$shere%3$s.', 'advanced-ads' ),
462
- $account,
463
- '<a href="https://www.google.com/adsense/new/u/0/' . $account . '/main/myads-viewall-adunits?product=SELF_SERVICE_CONTENT_ADS" target="_blank">',
464
- '</a>'
465
- ),
466
- 'raw' => $response['body'],
467
- );
 
 
 
 
 
468
 
 
 
469
  } else {
470
 
471
  /**
@@ -1061,10 +1070,25 @@ class Advanced_Ads_AdSense_MAPI {
1061
  $response['quotaMsg'] = $quota_msg;
1062
  }
1063
  } else {
1064
- /**
1065
- * Return the error info [arr]
1066
- */
1067
- $response = $units;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1068
  }
1069
  header( 'Content-Type: application/json' );
1070
  echo wp_json_encode( $response );
@@ -1251,7 +1275,7 @@ class Advanced_Ads_AdSense_MAPI {
1251
  }
1252
 
1253
  $code_url = 'https://www.googleapis.com/oauth2/v4/token';
1254
- $redirect_uri = 'urn:ietf:wg:oauth:2.0:oob';
1255
  $grant_type = 'authorization_code';
1256
 
1257
  $args = array(
9
 
10
  const ALERTS_URL = 'https://www.googleapis.com/adsense/v1.4/accounts/PUBID/alerts/';
11
 
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;
19
 
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(
467
+ // translators: %1$s is the AdSense publisher ID; %2$s a starting a tag to the AdSense ad unit list and %3$s the closing link.
468
+ esc_html__( 'The account "%1$s" does not seem to have any ad units. Please create some %2$shere%3$s.', 'advanced-ads' ),
469
+ $account,
470
+ '<a href="https://www.google.com/adsense/new/u/0/' . $account . '/main/myads-viewall-adunits?product=SELF_SERVICE_CONTENT_ADS" target="_blank">',
471
+ '</a>'
472
+ ),
473
+ 'raw' => $response['body'],
474
+ );
475
 
476
+ }
477
+
478
  } else {
479
 
480
  /**
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();
1077
+ Advanced_Ads_AdSense_Admin::get_mapi_ad_selector( true, true );
1078
+ $ad_selector = ob_get_clean();
1079
+
1080
+ $response = array(
1081
+ 'status' => true,
1082
+ 'html' => $ad_selector,
1083
+ );
1084
+
1085
+ } else {
1086
+ /**
1087
+ * Return the error info [arr]
1088
+ */
1089
+ $response = $units;
1090
+ }
1091
+
1092
  }
1093
  header( 'Content-Type: application/json' );
1094
  echo wp_json_encode( $response );
1275
  }
1276
 
1277
  $code_url = 'https://www.googleapis.com/oauth2/v4/token';
1278
+ $redirect_uri = self::REDIRECT_URI;
1279
  $grant_type = 'authorization_code';
1280
 
1281
  $args = array(
modules/gadsense/includes/class-network-adsense.php CHANGED
@@ -60,7 +60,7 @@ class Advanced_Ads_Network_Adsense extends Advanced_Ads_Ad_Network {
60
  // Activate AdSense verification code and Auto ads (previously Page-Level ads).
61
  add_settings_field(
62
  'adsense-page-level',
63
- __( 'Verification code & Auto ads', 'advanced-ads' ),
64
  array( $this, 'render_settings_adsense_page_level' ),
65
  $hook,
66
  $section_id
@@ -221,7 +221,7 @@ class Advanced_Ads_Network_Adsense extends Advanced_Ads_Ad_Network {
221
  ?>
222
  <label><input type="checkbox" name="<?php echo esc_attr( GADSENSE_OPT_NAME ); ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
223
  <?php
224
- esc_attr_e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' );
225
  ?>
226
  </label>
227
  <ul>
60
  // Activate AdSense verification code and Auto ads (previously Page-Level ads).
61
  add_settings_field(
62
  'adsense-page-level',
63
+ __( 'Auto ads', 'advanced-ads' ),
64
  array( $this, 'render_settings_adsense_page_level' ),
65
  $hook,
66
  $section_id
221
  ?>
222
  <label><input type="checkbox" name="<?php echo esc_attr( GADSENSE_OPT_NAME ); ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
223
  <?php
224
+ esc_attr_e( 'Insert the AdSense header code to enable Auto ads and verify your website.', 'advanced-ads' );
225
  ?>
226
  </label>
227
  <ul>
public/class-advanced-ads.php CHANGED
@@ -835,6 +835,7 @@ class Advanced_Ads {
835
  ),
836
  'has_archive' => false,
837
  'query_var' => false, // set to true and refresh your permalink settings to query ads under a public URL
 
838
  'supports' => $supports,
839
  'taxonomies' => array( self::AD_GROUP_TAXONOMY ),
840
  );
835
  ),
836
  'has_archive' => false,
837
  'query_var' => false, // set to true and refresh your permalink settings to query ads under a public URL
838
+ 'rewrite' => false, // defaults to true and so needs to be set to false to prevent any public URL
839
  'supports' => $supports,
840
  'taxonomies' => array( self::AD_GROUP_TAXONOMY ),
841
  );
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.22.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -317,6 +317,13 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
317
 
318
  == Changelog ==
319
 
 
 
 
 
 
 
 
320
  = 1.22.2 =
321
 
322
  - fix shortcode button within Classic editor and Classic editor block
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
 
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
323
+ - updated Google AdSense API to use web application verification
324
+ - prevent accidental public ad URLs. See [Making the Ads post type public](https://wpadvancedads.com/manual/making-the-ad-post-type-public/) if you want to query ads via a dedicated URL
325
+ - allow to reserve only width or height for plain, rich content and group ad types
326
+
327
  = 1.22.2 =
328
 
329
  - fix shortcode button within Classic editor and Classic editor block