Advanced Ads - Version 1.14

Version Description

  • rewrite of AdSense code logic. Please reach out through https://wpadvancedads.com/support/ if you discover any issues
  • show AdSense revenue in WP Admin
  • removed parent ad group option since it was never used by Advanced Ads
  • made newly installed Advanced Ads work correctly with Q2W3 Fixed Widget
Download this release

Release Info

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

Code changes from version 1.13.8 to 1.14

Files changed (43) hide show
  1. admin/assets/css/admin.css +74 -3
  2. admin/assets/js/admin.js +413 -1
  3. admin/class-advanced-ads-admin.php +13 -2
  4. admin/includes/ad-health-notices.php +45 -35
  5. admin/includes/class-ad-network-ad-importer.php +17 -0
  6. admin/includes/class-ad-network-ad-unit.php +61 -0
  7. admin/includes/class-ad-network.php +361 -0
  8. admin/includes/class-ad-type.php +17 -0
  9. admin/includes/class-meta-box.php +32 -0
  10. admin/includes/class-overview-widgets.php +180 -2
  11. admin/views/ad-group.php +0 -3
  12. admin/views/ad-main-metabox.php +4 -0
  13. admin/views/ad-parameters-metabox.php +5 -3
  14. admin/views/gadsense-dashboard.php +31 -0
  15. advanced-ads.php +2 -2
  16. classes/ad-health-notices.php +5 -0
  17. classes/ad_ajax_callbacks.php +5 -4
  18. classes/checks.php +48 -24
  19. classes/widget.php +0 -1
  20. languages/advanced-ads.pot +430 -334
  21. modules/gadsense/admin/admin.php +11 -288
  22. modules/gadsense/admin/assets/js/adsense.js +973 -0
  23. modules/gadsense/admin/assets/js/new-ad.js +0 -901
  24. modules/gadsense/admin/dummy.php +154 -0
  25. modules/gadsense/admin/views/adsense-account.php +1 -1
  26. modules/gadsense/admin/views/adsense-ad-parameters.php +5 -26
  27. modules/gadsense/admin/views/external-ads-adsense.php +0 -0
  28. modules/gadsense/admin/views/external-ads-links.php +39 -0
  29. modules/gadsense/admin/views/external-ads-list.php +122 -0
  30. modules/gadsense/admin/views/mapi-ad-selector.php +0 -131
  31. modules/gadsense/config.php +3 -0
  32. modules/gadsense/includes/class-ad-type-adsense.php +29 -1
  33. modules/gadsense/includes/class-adsense-report.php +532 -0
  34. modules/gadsense/includes/class-gadsense-data.php +9 -0
  35. modules/gadsense/includes/class-mapi.php +433 -398
  36. modules/gadsense/includes/class-network-adsense.php +364 -0
  37. modules/gadsense/main.php +12 -24
  38. public/class-advanced-ads.php +0 -24
  39. readme.txt +12 -3
  40. vendor/autoload_52.php +1 -1
  41. vendor/composer/autoload_classmap.php +4 -0
  42. vendor/composer/autoload_real_52.php +3 -3
  43. vendor/composer/autoload_static.php +4 -0
admin/assets/css/admin.css CHANGED
@@ -331,16 +331,18 @@ tr:hover .on-hover { display: block; }
331
  -*/
332
  #adsense-ad-param-error { color: red; font-weight: bold; }
333
  .advads-adsense-content { width: 100%; }
334
- .advads-adsense-show-code a, #mapi-open-selector a { padding: 0 10px; color: inherit; }
335
  #mapi-quota-message{ color: #ef8e00; font-style: italic; font-weight: bold; }
336
  .aa-select-list tbody [data-mapiaction="getCode"] { color: #46b450; }
337
  .aa-select-list tbody .disabled[data-mapiaction="getCode"] { color: #a7a7a7; cursor: default; }
338
  .aa-select-list tbody [data-mapiaction="updateCode"] { color: #0085ba; }
339
- #mapi-show-idle, #mapi-hide-idle { font-size: 20px; padding: 9px; position: absolute; top: 0; right: 78px; color: #72777c; cursor: pointer; }
340
  #remote-ad-unsupported-ad-type { background-color: #f0f0f0; padding: 8px; border: 1px solid #d6d6d6; }
341
  #mapi-table-wrap .unsupported { text-decoration:line-through; color:#555 }
342
  #mapi-table-wrap .unsupported span { text-decoration:none;color:#555 }
343
  #mapi-table-wrap table { border-left:none; border-right: none; }
 
 
344
  .advanced-ads-adsense-support { background-color: #fbfbfb; border: 1px solid #eee; padding: 1em; }
345
  .advanced-ads-adsense-support-text { font-size: 1.4em; font-weight: 400; }
346
  .advanced-ads-adsense-support .dashicons { color: #ffb900; }
@@ -453,4 +455,73 @@ tr:hover .on-hover { display: block; }
453
  #advads-tracking-pitch .advads-pro-pitch { float: none; }
454
 
455
  /* manual link without underline (e.g., when icon is used )*/
456
- a.advads-manual-icon { text-decoration: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  -*/
332
  #adsense-ad-param-error { color: red; font-weight: bold; }
333
  .advads-adsense-content { width: 100%; }
334
+ #mapi-insert-code a, #mapi-open-selector a, #mapi-close-selector-link a { padding: 0 10px; color: inherit; }
335
  #mapi-quota-message{ color: #ef8e00; font-style: italic; font-weight: bold; }
336
  .aa-select-list tbody [data-mapiaction="getCode"] { color: #46b450; }
337
  .aa-select-list tbody .disabled[data-mapiaction="getCode"] { color: #a7a7a7; cursor: default; }
338
  .aa-select-list tbody [data-mapiaction="updateCode"] { color: #0085ba; }
339
+ #mapi-toggle-idle { font-size: 20px; padding: 9px; position: absolute; top: 0; right: 78px; color: #72777c; cursor: pointer; }
340
  #remote-ad-unsupported-ad-type { background-color: #f0f0f0; padding: 8px; border: 1px solid #d6d6d6; }
341
  #mapi-table-wrap .unsupported { text-decoration:line-through; color:#555 }
342
  #mapi-table-wrap .unsupported span { text-decoration:none;color:#555 }
343
  #mapi-table-wrap table { border-left:none; border-right: none; }
344
+ #mapi-table-wrap.overflow { height: 22.2em; overflow-y: auto; }
345
+ #mapi-table-wrap.overflow table { position: absolute; }
346
  .advanced-ads-adsense-support { background-color: #fbfbfb; border: 1px solid #eee; padding: 1em; }
347
  .advanced-ads-adsense-support-text { font-size: 1.4em; font-weight: 400; }
348
  .advanced-ads-adsense-support .dashicons { color: #ffb900; }
455
  #advads-tracking-pitch .advads-pro-pitch { float: none; }
456
 
457
  /* manual link without underline (e.g., when icon is used )*/
458
+ a.advads-manual-icon { text-decoration: none; }
459
+
460
+ div.advads-flex{
461
+ display: flex;
462
+ align-items: top;
463
+ justify-content: top;
464
+ flex-direction: row;
465
+ flex-wrap: wrap;
466
+ flex-flow: row wrap;
467
+ align-content: flex-end;
468
+ }
469
+ .advads-flex1{
470
+ flex: 1;
471
+ }
472
+ .advads-flex2{
473
+ flex: 2;
474
+ }
475
+ .advads-flex3{
476
+ flex: 3;
477
+ }
478
+ div.advads-stats-box{
479
+ margin:4pt;
480
+ padding:4pt;
481
+ }
482
+ div.advads-stats-box div.advads-stats-box-main{
483
+ font-weight: bold;
484
+ font-size: 18px;
485
+ }
486
+ div.advads-stats-dd-container {
487
+ position:relative;
488
+ float:right;
489
+ text-align:right;
490
+ }
491
+ div.advads-stats-dd-button{
492
+ font-weight:bold;
493
+ font-size: 14px;
494
+ cursor:pointer;
495
+ }
496
+ div.advads-stats-dd-items{
497
+ background-color: #ffffff;
498
+ border: 1px solid #cccccc;
499
+ padding: 5px;
500
+ position:absolute;
501
+ overflow-y: auto;
502
+ overflow-x: hidden;
503
+ max-height:210px;
504
+ z-index: 1;
505
+ }
506
+ div.advads-stats-dd-item{
507
+ background-color: #ffffff;
508
+ padding: 5px;
509
+ cursor: pointer;
510
+ text-align:right;
511
+ min-width: 280px;
512
+ }
513
+ div.advads-stats-select{
514
+ border: none;
515
+ }
516
+ div.advads-stats-dd-item-selected{
517
+ background-color: #0073aa;
518
+ color: #ffffff;
519
+ font-weight: bold;
520
+ }
521
+ div#advads-gadsense-box{
522
+ display: none;
523
+ }
524
+
525
+ tr.advads-clickable-row:hover{
526
+ cursor: pointer;
527
+ }
admin/assets/js/admin.js CHANGED
@@ -33,6 +33,7 @@ jQuery( document ).ready(function ($) {
33
 
34
  $( document ).on( 'click', '#switch-to-adsense-type', function( ev ) {
35
  ev.preventDefault();
 
36
  $( '#advanced-ad-type-adsense' ).trigger( 'click' );
37
  $( this ).closest( 'li' ).addClass( 'hidden' );
38
  } );
@@ -454,7 +455,7 @@ jQuery( document ).ready(function ($) {
454
  // show image tooltips
455
  if ( $.fn.tooltip ) {
456
  $( ".advads-placements-new-form .advads-placement-type" ).tooltip({
457
- items: "span",
458
  content: function() {
459
  return $( this ).parents('.advads-placement-type').find( '.advads-placement-description' ).html();
460
  }
@@ -643,7 +644,13 @@ jQuery( document ).ready(function ($) {
643
  advads_show_adsense_auto_ads_warning();
644
  }
645
 
 
 
646
  advads_ads_txt_find_issues();
 
 
 
 
647
  });
648
 
649
 
@@ -1068,3 +1075,408 @@ window.Advanced_Ads_Admin = window.Advanced_Ads_Admin || {
1068
  }
1069
  }
1070
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  $( document ).on( 'click', '#switch-to-adsense-type', function( ev ) {
35
  ev.preventDefault();
36
+ AdvancedAdsAdmin.AdImporter.adsenseCode = Advanced_Ads_Admin.get_ad_source_editor_text();
37
  $( '#advanced-ad-type-adsense' ).trigger( 'click' );
38
  $( this ).closest( 'li' ).addClass( 'hidden' );
39
  } );
455
  // show image tooltips
456
  if ( $.fn.tooltip ) {
457
  $( ".advads-placements-new-form .advads-placement-type" ).tooltip({
458
+ items: "label",
459
  content: function() {
460
  return $( this ).parents('.advads-placement-type').find( '.advads-placement-description' ).html();
461
  }
644
  advads_show_adsense_auto_ads_warning();
645
  }
646
 
647
+
648
+ //advads_ads_txt_check_third_party();
649
  advads_ads_txt_find_issues();
650
+
651
+ jQuery( '.advanced-ads-adsense-dashboard' ).each( function(key,elm) {
652
+ Advanced_Ads_Adsense_Helper.process_dashboard(elm);
653
+ });
654
  });
655
 
656
 
1075
  }
1076
  }
1077
  };
1078
+
1079
+
1080
+ if (! window.AdvancedAdsAdmin) window.AdvancedAdsAdmin = {};
1081
+ if (! window.AdvancedAdsAdmin.AdImporter) window.AdvancedAdsAdmin.AdImporter = {
1082
+ /**
1083
+ * will highlight the currently selected ads in the list
1084
+ * @param hideInactive when true will hide inactive ad units
1085
+ * @returns the selector of the selected row or false if no row was selected.
1086
+ */
1087
+ highlightSelectedRowInExternalAdsList: function(hideInactive){
1088
+ if (typeof(hideInactive) == 'undefined') hideInactive = AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle;
1089
+ const tbody = $( '#mapi-table-wrap tbody' );
1090
+ const btn = $('#mapi-toggle-idle');
1091
+
1092
+ // update the style, if neccessary
1093
+ const nbUnits = hideInactive
1094
+ ? $( '#mapi-table-wrap tbody tr[data-active=1]' ).length
1095
+ : $( '#mapi-table-wrap tbody tr' ).length;
1096
+ if (nbUnits > 8) $( '#mapi-table-wrap' ).addClass('overflow');
1097
+ else $( '#mapi-table-wrap' ).removeClass('overflow');
1098
+
1099
+ if (hideInactive) {
1100
+ btn.removeClass('dashicons-hidden');
1101
+ btn.addClass('dashicons-visibility');
1102
+ btn.attr('title', advadstxt.show_inactive_ads);
1103
+ tbody.find('tr[data-slotid]').each(function (k, v) {
1104
+ v = $(v);
1105
+ if (v.data("active")) v.show();
1106
+ else v.hide();
1107
+ });
1108
+ }
1109
+ else{
1110
+ btn.removeClass('dashicons-visibility');
1111
+ btn.addClass('dashicons-hidden');
1112
+ btn.attr('title', advadstxt.hide_inactive_ads);
1113
+ tbody.find('tr[data-slotid]').show();
1114
+ }
1115
+
1116
+ tbody.find( 'tr' ).removeClass( 'selected' );
1117
+ const selectedRow = AdvancedAdsAdmin.AdImporter.getSelectedRow();
1118
+ if (selectedRow){
1119
+ selectedRow.addClass( 'selected' );
1120
+ selectedRow.show();
1121
+ return selectedRow;
1122
+ }
1123
+ return false;
1124
+ },
1125
+ getSelectedRow(){
1126
+ const selectedId = AdvancedAdsAdmin.AdImporter.adNetwork.getSelectedId();
1127
+ const tbody = $( '#mapi-table-wrap tbody' );
1128
+
1129
+ if (selectedId){
1130
+ const selectedRows = tbody.find( 'tr[data-slotid="' + selectedId + '"]' );
1131
+ if ( selectedRows.length ) {
1132
+ return selectedRows;
1133
+ }
1134
+ }
1135
+ return null;
1136
+ },
1137
+ openExternalAdsList: function(){
1138
+ const network = AdvancedAdsAdmin.AdImporter.adNetwork;
1139
+ network.openSelector();
1140
+
1141
+ $( '#mapi-insert-code' ).css( 'display', 'inline' );
1142
+ $( '#mapi-open-selector' ).css( 'display', 'none' );
1143
+ $( '#mapi-close-selector-link' ).css( 'display', 'inline' );
1144
+ $( '.advads-adsense-code' ).css( 'display', 'none' );
1145
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
1146
+
1147
+ AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList(network.hideIdle);
1148
+
1149
+
1150
+
1151
+
1152
+ var SNT = network.getCustomInputs();
1153
+ SNT.css( 'display', 'none' );
1154
+
1155
+ $( '#mapi-wrap' ).css( 'display', 'block' );
1156
+
1157
+ if (! network.fetchedExternalAds){
1158
+ network.fetchedExternalAds = true;
1159
+ const nbUnits = $( '#mapi-table-wrap tbody tr[data-slotid]' ).length;
1160
+ if (nbUnits == 0) {
1161
+ //usually we start with a preloaded list.
1162
+ //only reload, when the count is zero (true for new accounts).
1163
+ AdvancedAdsAdmin.AdImporter.refreshAds();
1164
+ }
1165
+ }
1166
+ AdvancedAdsAdmin.AdImporter.resizeAdListHeader();
1167
+ },
1168
+ setup: function (adNetwork) {
1169
+ AdvancedAdsAdmin.AdImporter.adNetwork = adNetwork;
1170
+ adNetwork.onSelected();
1171
+ if (AdvancedAdsAdmin.AdImporter.isSetup) return;
1172
+ AdvancedAdsAdmin.AdImporter.isSetup = true;
1173
+
1174
+ $( document ).on( 'click', '.prevent-default', function( ev ) { ev.preventDefault() } );
1175
+
1176
+ // handle clicks for the "insert new ... code" anchor
1177
+ $( document ).on('click', '#mapi-insert-code', function(e){
1178
+ e.preventDefault();
1179
+ $( '.advads-adsense-code' ).show();
1180
+ $( '#mapi-open-selector' ).css( 'display', 'inline' );
1181
+ $( '#mapi-close-selector-link' ).css( 'display', 'inline' );
1182
+ $( '#mapi-wrap' ).css( 'display', 'none' );
1183
+ var SNT = AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs();
1184
+ SNT.css( 'display', 'none' );
1185
+ $( this ).hide();
1186
+ });
1187
+
1188
+ // handle clicks for the "get ad code from your linked account" anchor
1189
+ $( document ).on( 'click', '#mapi-open-selector a', function(){
1190
+ AdvancedAdsAdmin.AdImporter.openExternalAdsList();
1191
+ });
1192
+
1193
+ // the close button of the ad unit list
1194
+ $( document ).on( 'click', '#mapi-close-selector,#mapi-close-selector-link', function(){
1195
+ AdvancedAdsAdmin.AdImporter.manualSetup();
1196
+ } );
1197
+
1198
+ //the individual rows of the ad units may contain elements with the mapiaction class
1199
+ $( document ).on( 'click', '.mapiaction', function( ev ) {
1200
+ var action = $( this ).attr( 'data-mapiaction' );
1201
+ switch ( action ) {
1202
+ case 'updateList':
1203
+ AdvancedAdsAdmin.AdImporter.refreshAds();
1204
+ break;
1205
+ case 'getCode':
1206
+ if ( $( this ).hasClass( 'disabled' ) ) {
1207
+ break;
1208
+ }
1209
+ var slotId = $( this ).attr( 'data-slotid' );
1210
+ AdvancedAdsAdmin.AdImporter.adNetwork.selectAdFromList(slotId);
1211
+ break;
1212
+ case 'updateCode':
1213
+ var slotId = $( this ).attr( 'data-slotid' );
1214
+ AdvancedAdsAdmin.AdImporter.adNetwork.updateAdFromList(slotId);
1215
+ break;
1216
+ case 'toggleidle':
1217
+ AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle = !AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle;
1218
+ AdvancedAdsAdmin.AdImporter.toggleIdleAds( AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle );
1219
+ break;
1220
+ default:
1221
+ }
1222
+ } );
1223
+
1224
+ AdvancedAdsAdmin.AdImporter.adNetwork.onDomReady();
1225
+ // AdvancedAdsAdmin.AdImporter.openExternalAdsList();
1226
+
1227
+
1228
+ },
1229
+
1230
+ /**
1231
+ * call this method to display the manual setup (if available for the current ad network)
1232
+ * this method is an equivalent to the close ad list button.
1233
+ */
1234
+ manualSetup(){
1235
+ $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
1236
+ $( '#mapi-insert-code' ).css( 'display', 'inline' );
1237
+ $( '#mapi-close-selector-link' ).css( 'display', 'none' );
1238
+ $( '#mapi-wrap' ).css( 'display', 'none' );
1239
+
1240
+ var SNT = AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs();
1241
+ SNT.css( 'display', 'block' );
1242
+ AdvancedAdsAdmin.AdImporter.adNetwork.onManualSetup();
1243
+ },
1244
+
1245
+ setRemoteErrorMessage(msg){
1246
+ if (! msg) jQuery('#remote-ad-code-msg').empty();
1247
+ else jQuery('#remote-ad-code-msg').html(msg);
1248
+ },
1249
+
1250
+ // another legacy method
1251
+ resizeAdListHeader: function() {
1252
+ var th = $( '#mapi-list-header span' );
1253
+ var tb = $( '#mapi-table-wrap tbody tr:visible' );
1254
+ var w = [];
1255
+
1256
+ tb.first().find( 'td' ).each(function(){
1257
+ w.push( $( this ).width() );
1258
+ });
1259
+
1260
+ th.each(function(i){
1261
+ if ( i != w.length - 1 ) {
1262
+ $( this ).width( w[i] );
1263
+ }
1264
+ });
1265
+ },
1266
+
1267
+
1268
+
1269
+ /**
1270
+ * legacy method
1271
+ */
1272
+ closeAdSelector: function() {
1273
+ // close the ad unit selector
1274
+ setTimeout(function(){
1275
+ $( '#mapi-wrap' ).animate(
1276
+ { height: 0, },
1277
+ 360,
1278
+ function(){
1279
+ $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
1280
+ $( '#mapi-close-selector-link' ).css( 'display', 'none' );
1281
+ $( '#mapi-wrap' ).css({
1282
+ display: 'none',
1283
+ height: 'auto',
1284
+ });
1285
+ const SNT = AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs();
1286
+ SNT.css( 'display', 'block' );
1287
+ }
1288
+ );
1289
+ }, 80);
1290
+
1291
+ },
1292
+
1293
+ /**
1294
+ * legacy method
1295
+ * updates the UI, (call if the selected unit is supported)
1296
+ */
1297
+ unitIsNotSupported: function( slotID ) {
1298
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'block' );
1299
+ AdsenseMAPI.unsupportedUnits[slotID] = 1;
1300
+ $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).addClass( 'disabled' );
1301
+ $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).addClass( 'unsupported' );
1302
+ if ( ! $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
1303
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
1304
+ var content = td.text();
1305
+ td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-type="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
1306
+ }
1307
+ if ( ! $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
1308
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
1309
+ var content = td.text();
1310
+ td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-size="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
1311
+ }
1312
+
1313
+ },
1314
+
1315
+ /**
1316
+ * legacy method
1317
+ * updates the UI, (call if the selected unit is NOT supported)
1318
+ */
1319
+ unitIsSupported: function( slotID ) {
1320
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
1321
+ if ( 'undefined' != typeof AdsenseMAPI.unsupportedUnits[slotID] ) {
1322
+ delete AdsenseMAPI.unsupportedUnits[slotID];
1323
+ }
1324
+ $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).removeClass( 'disabled' );
1325
+ $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).removeClass( 'unsupported' );
1326
+ if ( $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
1327
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
1328
+ var content = $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).attr( 'data-type' );
1329
+ td.text( content );
1330
+ }
1331
+ if ( $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
1332
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
1333
+ var content = $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).attr( 'data-size' );
1334
+ td.text( content );
1335
+ }
1336
+ },
1337
+
1338
+ /**
1339
+ * legacy method
1340
+ * updates the UI, (call if the selected unit is NOT supported)
1341
+ */
1342
+ emptyMapiSelector: function( msg ) {
1343
+ const nag = '<div class="notice notice-error" style="font-size:1.1em;padding:.6em 1em;font-weight:bold;">' + msg + '</div>';
1344
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
1345
+ $( '#mapi-wrap' ).html( $( nag ) );
1346
+ },
1347
+
1348
+ /**
1349
+ * legacy method
1350
+ */
1351
+ refreshAds: function() {
1352
+ const adNetwork = AdvancedAdsAdmin.AdImporter.adNetwork;
1353
+ $( '#mapi-loading-overlay' ).css( 'display', 'block' );
1354
+ $.ajax({
1355
+ type: 'post',
1356
+ url: ajaxurl,
1357
+ data: adNetwork.getRefreshAdsParameters(),
1358
+ success: function(response,status,XHR){
1359
+ if ( 'undefined' != typeof response.html ) {
1360
+ $( '#mapi-wrap' ).replaceWith( $( response.html ) );
1361
+ AdvancedAdsAdmin.AdImporter.openExternalAdsList();
1362
+ } else if ( 'undefined' != typeof response.msg ) {
1363
+ AdvancedAdsAdmin.AdImporter.emptyMapiSelector( response.msg );
1364
+ }
1365
+ if ( 'undefined' != typeof response.raw ) {
1366
+ console.log( response.raw );
1367
+ }
1368
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
1369
+ },
1370
+ error: function(request,status,err){
1371
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
1372
+ },
1373
+ });
1374
+
1375
+ },
1376
+
1377
+ toggleIdleAds: function ( hide ) {
1378
+ if ( 'undefined' == typeof hide ) {
1379
+ hide = true;
1380
+ }
1381
+ AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList(hide);
1382
+ }
1383
+ };
1384
+
1385
+ /**
1386
+ * The "abstract" base class for handling external ad units
1387
+ * Every ad unit will provide you with a set of methods to control the GUI and trigger requests to the server
1388
+ * while editing an ad that is backed by this network. The main logic takes place in admin/assets/admin.js,
1389
+ * and the methods in this class are the ones that needed abstraction, depending on the ad network. When you
1390
+ * need new network-dependant features in the frontend, this is the place to add new methods.
1391
+ *
1392
+ * An AdvancedAdsAdNetwork uses these fields:
1393
+ * id string The identifier, that is used for this network. Must match with the one used in the PHP code of Advanced Ads
1394
+ * units array Holds the ad units of this network.
1395
+ * vars map These are the variables that were transmitted from the underlying PHP class (method: append_javascript_data)
1396
+ * hideIdle Remembers, wheter idle ads should be displayed in the list;
1397
+ * fetchedExternalAds Remembers if the external ads list has already been loaded to prevent unneccesary requests
1398
+ */
1399
+ class AdvancedAdsAdNetwork{
1400
+ /**
1401
+ * @param id string representing the id of this network. has to match the identifier of the PHP class
1402
+ */
1403
+ constructor(id){
1404
+ this.id = id;
1405
+ this.units = [];
1406
+ this.vars = window[id + 'AdvancedAdsJS'];
1407
+ this.hideIdle = true;
1408
+ this.fetchedExternalAds = false;
1409
+ }
1410
+
1411
+ /**
1412
+ * will be called when an ad network is selected (ad type in edit ad)
1413
+ */
1414
+ onSelected(){
1415
+ console.error("Please override onSelected.");
1416
+ }
1417
+
1418
+ /**
1419
+ * opens the selector list containing the external ad units
1420
+ */
1421
+ openSelector(){
1422
+ console.error("Please override openSelector.");
1423
+ }
1424
+
1425
+ /**
1426
+ * returns the network specific id of the currently selected ad unit
1427
+ */
1428
+ getSelectedId(){
1429
+ console.error("Please override getSelectedId.");
1430
+ }
1431
+
1432
+ /**
1433
+ * will be called when an external ad unit has been selected from the selector list
1434
+ * @param slotId string the external ad unit id
1435
+ */
1436
+ selectAdFromList(slotId){
1437
+ console.error("Please override selectAdFromList.");
1438
+ }
1439
+
1440
+ /**
1441
+ * will be called when an the update button of an external ad unit has been clicked
1442
+ * TODO: decide wheter to remove this method. not required anymore - the button was removed.
1443
+ * @param slotId string the external ad unit id
1444
+ */
1445
+ updateAdFromList(slotId){
1446
+ console.error("Please override updateAdFromList.");
1447
+ }
1448
+
1449
+
1450
+ /**
1451
+ * return the POST params that you want to send to the server when requesting a refresh of the external ad units
1452
+ * (like nonce and action and everything else that is required)
1453
+ */
1454
+ getRefreshAdsParameters(){
1455
+ console.error("Please override getRefreshAdsParameters.");
1456
+ }
1457
+
1458
+ /**
1459
+ * return the jquery objects for all the custom html elements of this ad type
1460
+ */
1461
+ getCustomInputs(){
1462
+ console.error("Please override getCustomInputs.");
1463
+ }
1464
+
1465
+ /**
1466
+ * what to do when the DOM is ready
1467
+ */
1468
+ onDomReady(){
1469
+ console.error("Please override onDomReady.");
1470
+ }
1471
+
1472
+ /**
1473
+ * when you need custom behaviour for ad networks that support manual setup of ad units, override this method
1474
+ */
1475
+ onManualSetup(){
1476
+ //no console logging. this is optional
1477
+ }
1478
+ }
1479
+
1480
+ class AdvancedAdsExternalAdUnit{
1481
+
1482
+ }
admin/class-advanced-ads-admin.php CHANGED
@@ -223,6 +223,17 @@ class Advanced_Ads_Admin {
223
  'condition_and' => __( 'and', 'advanced-ads' ),
224
  'after_paragraph_promt' => __( 'After which paragraph?', 'advanced-ads' ),
225
  'page_level_ads_enabled' => $auto_ads_strings['enabled'],
 
 
 
 
 
 
 
 
 
 
 
226
  );
227
 
228
  wp_localize_script( $this->plugin_slug . '-admin-script', 'advadstxt', $translation_array );
@@ -667,8 +678,8 @@ class Advanced_Ads_Admin {
667
  public function admin_footer_text( $default_text ) {
668
  if ( $this->screen_belongs_to_advanced_ads() ) {
669
 
670
- /* translators: %s is the URL to add a new review, https://wordpress.org/support/plugin/advanced-ads/reviews/?filter=5#new-post */
671
- return sprintf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads/reviews/?filter=5#new-post' );
672
 
673
  }
674
  return $default_text;
223
  'condition_and' => __( 'and', 'advanced-ads' ),
224
  'after_paragraph_promt' => __( 'After which paragraph?', 'advanced-ads' ),
225
  'page_level_ads_enabled' => $auto_ads_strings['enabled'],
226
+ 'today' => __( 'Today', 'advanced-ads'),
227
+ 'yesterday' => __( 'Yesterday', 'advanced-ads'),
228
+ 'this_month' => __( 'This Month', 'advanced-ads'),
229
+ /* translators: 1: The number of days. */
230
+ 'last_n_days' => __( 'Last %1$d days', 'advanced-ads'),
231
+ /* translators: 1: An error message. */
232
+ 'error_message' => __( 'An error occurred: %1$s'),
233
+ 'all' => __( 'All', 'advanced-ads'),
234
+ 'no_results' => __( 'There were no results returned for this ad. Please make sure it is active, generating impressions and double check your ad parameters.', 'advanced-ads'),
235
+ 'show_inactive_ads' => __( 'Show inactive ads' , 'advanced-ads' ),
236
+ 'hide_inactive_ads' => __( 'Hide inactive ads' , 'advanced-ads' )
237
  );
238
 
239
  wp_localize_script( $this->plugin_slug . '-admin-script', 'advadstxt', $translation_array );
678
  public function admin_footer_text( $default_text ) {
679
  if ( $this->screen_belongs_to_advanced_ads() ) {
680
 
681
+ /* translators: %s is the URL to add a new review, https://wordpress.org/support/plugin/advanced-ads/reviews/#new-post */
682
+ return sprintf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads/reviews/#new-post' );
683
 
684
  }
685
  return $default_text;
admin/includes/ad-health-notices.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Array with ad health messages
4
  *
5
- * attribute: type
6
  * - "notice" (default, recommendation, etc.)
7
  * - "problem" (critical)
8
  *
@@ -27,7 +27,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
27
  // checked using Advanced_Ads_Checks::php_version_minimum().
28
  'old_php' => array(
29
  'text' => sprintf(
30
- // translators: %1$s is a version number.
31
  __( 'Your <strong>PHP version (%1$s) is too low</strong>. Advanced Ads is built for PHP %2$s and higher. It might work, but updating PHP is highly recommended. Please ask your hosting provider for more information.', 'advanced-ads' ),
32
  phpversion(),
33
  Advanced_Ads_Checks::MINIMUM_PHP_VERSION
@@ -38,7 +38,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
38
  // checked using Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ).
39
  'cache_no_pro' => array(
40
  'text' => sprintf(
41
- // translators: %s is a target URL.
42
  __( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ),
43
  ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-cache'
44
  ),
@@ -48,7 +48,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
48
  // Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ).
49
  'autoptimize_no_pro' => array(
50
  'text' => sprintf(
51
- // translators: %s is a target URL.
52
  __( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ),
53
  ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-autoptimize'
54
  ),
@@ -58,7 +58,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
58
  // Advanced_Ads_Checks::conflicting_plugins().
59
  'conflicting_plugins' => array(
60
  'text' => sprintf(
61
- // translators: %1$s is a list of plugin names; %2$s a target URL.
62
  __( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ),
63
  implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ),
64
  ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-plugin-conflicts'
@@ -69,7 +69,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
69
  // Advanced_Ads_Checks::php_extensions().
70
  'php_extensions_missing' => array(
71
  'text' => sprintf(
72
- // translators: %s is a list of PHP extensions.
73
  __( 'Missing PHP extensions could cause issues. Please ask your hosting provider to enable them: %s', 'advanced-ads' ),
74
  implode( ', ', Advanced_Ads_Checks::php_extensions() )
75
  ),
@@ -79,7 +79,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
79
  // Advanced_Ads_Checks::ads_disabled().
80
  'ads_disabled' => array(
81
  'text' => sprintf(
82
- // translators: %s is a target URL.
83
  __( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ),
84
  admin_url( 'admin.php?page=advanced-ads-settings#top#general' )
85
  ),
@@ -95,7 +95,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
95
  // Advanced_Ads_Checks::jquery_ui_conflict().
96
  'jquery_ui_conflict' => array(
97
  'text' => sprintf(
98
- // translators: %s is a target URL.
99
  __( 'Possible conflict between jQueryUI library, used by Advanced Ads and other libraries (probably <a href="%s">Twitter Bootstrap</a>). This might lead to misfortunate formats in forms, but should not damage features.', 'advanced-ads' ),
100
  'http://getbootstrap.com/javascript/#js-noconflict'
101
  ),
@@ -105,7 +105,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
105
  // Advanced_Ads_Checks::assets_expired().
106
  'assets_expired' => array(
107
  'text' => sprintf(
108
- // translators: %s is a target URL.
109
  __( 'Some assets were changed. Please <strong>rebuild the asset folder</strong> in the <a href="%s">Advanced Ads settings</a> to update the ad blocker disguise.', 'advanced-ads' ),
110
  admin_url( 'admin.php?page=advanced-ads-settings' )
111
  ),
@@ -116,11 +116,11 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
116
  // Advanced_Ads_Checks::license_invalid().
117
  'license_invalid' => array(
118
  'text' => __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>.', 'advanced-ads' ) . ' '
119
- . sprintf(
120
- // translators: %s is a target URL.
121
- __( 'Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ),
122
- get_admin_url( 1, 'admin.php?page=advanced-ads-settings#top#licenses' )
123
- ),
124
  'type' => 'problem',
125
  'hide' => false,
126
  'timeout' => WEEK_IN_SECONDS,
@@ -136,7 +136,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
136
  'ad_with_output_in_head' => array(
137
  // we keep the %s here and replace it with an empty string, because we use it somewhere else and don’t want to create a new string that is basically the same.
138
  'text' => sprintf(
139
- // translators: %s is empty here, but the string will be followed by a name of an ad unit.
140
  __( 'Visible ads should not use the Header placement: %s', 'advanced-ads' ),
141
  ''
142
  ),
@@ -193,28 +193,28 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
193
  // AdSense account alert. Missing ads.txt – version 1.
194
  'adsense_alert_ALERT_TYPE_ADS_TXT_UNAUTHORIZED' => array(
195
  'text' => sprintf(
196
- __( 'One of your sites is missing the AdSense publisher ID in the ads.txt file.', 'advanced-ads' )
197
- . ' <a class="advads-settings-link" href="%s">'
198
- . _x( 'Create one now.', 'related to ads.txt file', 'advanced-ads' ) . '</a>',
199
- admin_url( 'admin.php?page=advanced-ads-settings#general__advads-ads-txt' )
200
- ) . ' ' . Advanced_Ads_Ad_Health_Notices::get_adsense_error_link( 'ALERT_TYPE_ADS_TXT_UNAUTHORIZED' ),
201
  'type' => 'problem',
202
  ), // AdSense account alert. . Missing ads.txt – version 2.
203
- 'adsense_alert_ADS_TXT_MISSING' => array(
204
  'text' => sprintf(
205
- __( 'One of your sites is missing the AdSense publisher ID in the ads.txt file.', 'advanced-ads' )
206
- . ' <a class="advads-settings-link" href="%s">'
207
- . _x( 'Create one now.', 'related to ads.txt file', 'advanced-ads' ) . '</a>',
208
- admin_url( 'admin.php?page=advanced-ads-settings#general__advads-ads-txt' )
209
- ) . ' ' . Advanced_Ads_Ad_Health_Notices::get_adsense_error_link( 'ADS_TXT_MISSING' ),
210
  'type' => 'problem',
211
  ),
212
  'nested_the_content_filters' => array(
213
  'text' => sprintf(
214
- // translators: %s is a filter hook, here `the_content`.
215
- __( '<strong>%s</strong> filter found multiple times.', 'advanced-ads' ),
216
- 'the_content'
217
- ) . '&nbsp;' . __( 'Advanced Ads uses the outermost of them.', 'advanced-ads' ),
218
  'get_help_link' => ADVADS_URL . 'manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=error-multiple-the-content#the_content_filter_found_multiple_times',
219
  'type' => 'notice',
220
  'hide' => false,
@@ -222,7 +222,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
222
  // BuddyPress installed.
223
  'buddypress_no_pro' => array(
224
  'text' => sprintf(
225
- // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
226
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
227
  '<strong>BuddyPress</strong>',
228
  '<a href="' . ADVADS_URL . 'ads-on-buddypress-pages/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-buddypress" target="_blank">',
@@ -233,7 +233,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
233
  // bbPress installed.
234
  'bbpress_no_pro' => array(
235
  'text' => sprintf(
236
- // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
237
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
238
  '<strong>bbPress</strong>',
239
  '<a href="' . ADVADS_URL . 'ads-in-bbpress/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-bbpress" target="_blank">',
@@ -244,7 +244,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
244
  // WPML plugin activated.
245
  'WPML_active' => array(
246
  'text' => sprintf(
247
- // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
248
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
249
  '<strong>WPML</strong>',
250
  '<a href="' . ADVADS_URL . 'translating-ads-wpml/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-WPML" target="_blank">',
@@ -257,7 +257,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
257
  // AMP and Accelerated Mobile Pages plugins.
258
  'AMP_active' => array(
259
  'text' => sprintf(
260
- // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
261
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
262
  '<strong>AMP</strong>',
263
  '<a href="' . ADVADS_URL . 'manual/ads-on-amp-pages/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-amp" target="_blank">',
@@ -271,7 +271,7 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
271
  // Advanced_Ads_Checks::wp_engine_hosting().
272
  'wpengine' => array(
273
  'text' => sprintf(
274
- // translators: %s is a service or plugin name.
275
  '<strong>' . __( '%s detected.', 'advanced-ads' ) . '</strong>'
276
  . ' <a href="' . ADVADS_URL . 'wp-engine-and-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-wpengine">' . __( 'Learn how this might impact your ad setup.', 'advanced-ads' ) . '</a>',
277
  'WP Engine'
@@ -280,5 +280,15 @@ $advanced_ads_ad_health_notices = apply_filters( 'advanced-ads-ad-health-notices
280
  'hide' => false,
281
  'timeout' => YEAR_IN_SECONDS,
282
  ),
 
 
 
 
 
 
 
 
 
 
283
  )
284
  );
2
  /**
3
  * Array with ad health messages
4
  *
5
+ * Attribute: type
6
  * - "notice" (default, recommendation, etc.)
7
  * - "problem" (critical)
8
  *
27
  // checked using Advanced_Ads_Checks::php_version_minimum().
28
  'old_php' => array(
29
  'text' => sprintf(
30
+ // translators: %1$s is a version number.
31
  __( 'Your <strong>PHP version (%1$s) is too low</strong>. Advanced Ads is built for PHP %2$s and higher. It might work, but updating PHP is highly recommended. Please ask your hosting provider for more information.', 'advanced-ads' ),
32
  phpversion(),
33
  Advanced_Ads_Checks::MINIMUM_PHP_VERSION
38
  // checked using Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ).
39
  'cache_no_pro' => array(
40
  'text' => sprintf(
41
+ // translators: %s is a target URL.
42
  __( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ),
43
  ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-cache'
44
  ),
48
  // Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ).
49
  'autoptimize_no_pro' => array(
50
  'text' => sprintf(
51
+ // translators: %s is a target URL.
52
  __( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ),
53
  ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-autoptimize'
54
  ),
58
  // Advanced_Ads_Checks::conflicting_plugins().
59
  'conflicting_plugins' => array(
60
  'text' => sprintf(
61
+ // translators: %1$s is a list of plugin names; %2$s a target URL.
62
  __( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ),
63
  implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ),
64
  ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=error-plugin-conflicts'
69
  // Advanced_Ads_Checks::php_extensions().
70
  'php_extensions_missing' => array(
71
  'text' => sprintf(
72
+ // translators: %s is a list of PHP extensions.
73
  __( 'Missing PHP extensions could cause issues. Please ask your hosting provider to enable them: %s', 'advanced-ads' ),
74
  implode( ', ', Advanced_Ads_Checks::php_extensions() )
75
  ),
79
  // Advanced_Ads_Checks::ads_disabled().
80
  'ads_disabled' => array(
81
  'text' => sprintf(
82
+ // translators: %s is a target URL.
83
  __( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ),
84
  admin_url( 'admin.php?page=advanced-ads-settings#top#general' )
85
  ),
95
  // Advanced_Ads_Checks::jquery_ui_conflict().
96
  'jquery_ui_conflict' => array(
97
  'text' => sprintf(
98
+ // translators: %s is a target URL.
99
  __( 'Possible conflict between jQueryUI library, used by Advanced Ads and other libraries (probably <a href="%s">Twitter Bootstrap</a>). This might lead to misfortunate formats in forms, but should not damage features.', 'advanced-ads' ),
100
  'http://getbootstrap.com/javascript/#js-noconflict'
101
  ),
105
  // Advanced_Ads_Checks::assets_expired().
106
  'assets_expired' => array(
107
  'text' => sprintf(
108
+ // translators: %s is a target URL.
109
  __( 'Some assets were changed. Please <strong>rebuild the asset folder</strong> in the <a href="%s">Advanced Ads settings</a> to update the ad blocker disguise.', 'advanced-ads' ),
110
  admin_url( 'admin.php?page=advanced-ads-settings' )
111
  ),
116
  // Advanced_Ads_Checks::license_invalid().
117
  'license_invalid' => array(
118
  'text' => __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>.', 'advanced-ads' ) . ' '
119
+ . sprintf(
120
+ // translators: %s is a target URL.
121
+ __( 'Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ),
122
+ get_admin_url( 1, 'admin.php?page=advanced-ads-settings#top#licenses' )
123
+ ),
124
  'type' => 'problem',
125
  'hide' => false,
126
  'timeout' => WEEK_IN_SECONDS,
136
  'ad_with_output_in_head' => array(
137
  // we keep the %s here and replace it with an empty string, because we use it somewhere else and don’t want to create a new string that is basically the same.
138
  'text' => sprintf(
139
+ // translators: %s is empty here, but the string will be followed by a name of an ad unit.
140
  __( 'Visible ads should not use the Header placement: %s', 'advanced-ads' ),
141
  ''
142
  ),
193
  // AdSense account alert. Missing ads.txt – version 1.
194
  'adsense_alert_ALERT_TYPE_ADS_TXT_UNAUTHORIZED' => array(
195
  'text' => sprintf(
196
+ __( 'One of your sites is missing the AdSense publisher ID in the ads.txt file.', 'advanced-ads' )
197
+ . ' <a class="advads-settings-link" href="%s">'
198
+ . _x( 'Create one now.', 'related to ads.txt file', 'advanced-ads' ) . '</a>',
199
+ admin_url( 'admin.php?page=advanced-ads-settings#general__advads-ads-txt' )
200
+ ) . ' ' . Advanced_Ads_Ad_Health_Notices::get_adsense_error_link( 'ALERT_TYPE_ADS_TXT_UNAUTHORIZED' ),
201
  'type' => 'problem',
202
  ), // AdSense account alert. . Missing ads.txt – version 2.
203
+ 'adsense_alert_ADS_TXT_MISSING' => array(
204
  'text' => sprintf(
205
+ __( 'One of your sites is missing the AdSense publisher ID in the ads.txt file.', 'advanced-ads' )
206
+ . ' <a class="advads-settings-link" href="%s">'
207
+ . _x( 'Create one now.', 'related to ads.txt file', 'advanced-ads' ) . '</a>',
208
+ admin_url( 'admin.php?page=advanced-ads-settings#general__advads-ads-txt' )
209
+ ) . ' ' . Advanced_Ads_Ad_Health_Notices::get_adsense_error_link( 'ADS_TXT_MISSING' ),
210
  'type' => 'problem',
211
  ),
212
  'nested_the_content_filters' => array(
213
  'text' => sprintf(
214
+ // translators: %s is a filter hook, here `the_content`.
215
+ __( '<strong>%s</strong> filter found multiple times.', 'advanced-ads' ),
216
+ 'the_content'
217
+ ) . '&nbsp;' . __( 'Advanced Ads uses the outermost of them.', 'advanced-ads' ),
218
  'get_help_link' => ADVADS_URL . 'manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=error-multiple-the-content#the_content_filter_found_multiple_times',
219
  'type' => 'notice',
220
  'hide' => false,
222
  // BuddyPress installed.
223
  'buddypress_no_pro' => array(
224
  'text' => sprintf(
225
+ // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
226
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
227
  '<strong>BuddyPress</strong>',
228
  '<a href="' . ADVADS_URL . 'ads-on-buddypress-pages/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-buddypress" target="_blank">',
233
  // bbPress installed.
234
  'bbpress_no_pro' => array(
235
  'text' => sprintf(
236
+ // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
237
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
238
  '<strong>bbPress</strong>',
239
  '<a href="' . ADVADS_URL . 'ads-in-bbpress/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-bbpress" target="_blank">',
244
  // WPML plugin activated.
245
  'WPML_active' => array(
246
  'text' => sprintf(
247
+ // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
248
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
249
  '<strong>WPML</strong>',
250
  '<a href="' . ADVADS_URL . 'translating-ads-wpml/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-WPML" target="_blank">',
257
  // AMP and Accelerated Mobile Pages plugins.
258
  'AMP_active' => array(
259
  'text' => sprintf(
260
+ // translators: %1$s is a plugin name, %2$s is the opening a tag and %3$s the closing one.
261
  __( 'Learn how to integrate %1$s with Advanced Ads %2$shere%3$s.', 'advanced-ads' ),
262
  '<strong>AMP</strong>',
263
  '<a href="' . ADVADS_URL . 'manual/ads-on-amp-pages/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-amp" target="_blank">',
271
  // Advanced_Ads_Checks::wp_engine_hosting().
272
  'wpengine' => array(
273
  'text' => sprintf(
274
+ // translators: %s is a service or plugin name.
275
  '<strong>' . __( '%s detected.', 'advanced-ads' ) . '</strong>'
276
  . ' <a href="' . ADVADS_URL . 'wp-engine-and-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-wpengine">' . __( 'Learn how this might impact your ad setup.', 'advanced-ads' ) . '</a>',
277
  'WP Engine'
280
  'hide' => false,
281
  'timeout' => YEAR_IN_SECONDS,
282
  ),
283
+ // Notice about existing ads.txt plugins.
284
+ // Advanced_Ads_Checks::ads_txt_plugins().
285
+ 'ads_txt_plugins_enabled' => array(
286
+ 'text' => sprintf(
287
+ __( 'Advanced Ads handles your ads.txt file automatically. You might be able to <strong>remove %1$s</strong>.', 'advanced-ads' ),
288
+ implode( ', ', Advanced_Ads_Checks::ads_txt_plugins() )
289
+ ),
290
+ 'hide' => false,
291
+ 'timeout' => YEAR_IN_SECONDS,
292
+ ),
293
  )
294
  );
admin/includes/class-ad-network-ad-importer.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Advanced_Ads_Ad_Network_Ad_Importer{
3
+ protected $ad_network;
4
+
5
+ /**
6
+ * Advanced_Ads_Ad_Network_Ad_Importer constructor.
7
+ * @param $ad_network
8
+ */
9
+ public function __construct($ad_network)
10
+ {
11
+ $this->ad_network = $ad_network;
12
+ }
13
+
14
+ public function render(){
15
+
16
+ }
17
+ }
admin/includes/class-ad-network-ad-unit.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Advanced_Ads_Ad_Network_Ad_Unit
5
+ * This represents an external ad unit. Will be used for importing external ads from various ad networks.
6
+ */
7
+ class Advanced_Ads_Ad_Network_Ad_Unit{
8
+ /**
9
+ * @var contains the raw data (typically from a JSON response) for this ad unit
10
+ */
11
+ public $raw;
12
+
13
+ /**
14
+ * @var the (external) id of this ad unit (e.g. pub-ca... for adsense)
15
+ */
16
+
17
+ public $id;
18
+ /**
19
+ * @var the display name of the ad
20
+ */
21
+ public $name;
22
+
23
+ /**
24
+ * @var the type of this ad unit (displayed in list)
25
+ */
26
+ public $display_type;
27
+
28
+ /**
29
+ * @var the size of this ad unit (displayed in list)
30
+ */
31
+ public $display_size;
32
+
33
+ /**
34
+ * @var in case of an adsense ad, this is the id of the ad without the publisher id
35
+ * the value will be displayed in the ads list
36
+ */
37
+ public $slot_id;
38
+
39
+ /**
40
+ * @var a bool that indicates wheter an ad is active (inactives will be hidden by default)
41
+ */
42
+ public $active;
43
+
44
+ public function __construct($raw) {
45
+ $this->raw = $raw;
46
+ }
47
+
48
+ public static function sort_ad_units(array &$ad_units, $selected_id){
49
+ usort($ad_units, function($a, $b) use ($selected_id){
50
+ if ($a->id == $selected_id) return -1;
51
+ if ($b->id == $selected_id) return 1;
52
+ if ($a->is_supported){
53
+ if (!$b->is_supported) return -1;
54
+ }
55
+ else if ($b->is_supported) return 1;
56
+ return strcmp($a->name, $b->name);
57
+ });
58
+
59
+ return $ad_units;
60
+ }
61
+ }
admin/includes/class-ad-network.php ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Advanced_Ads_Ad_Network
4
+ */
5
+ abstract class Advanced_Ads_Ad_Network{
6
+ /**
7
+ * @var string The identifier will be used for generated ids, names etc.
8
+ */
9
+ protected $identifier;
10
+
11
+ /**
12
+ * @var string The name of the ad network
13
+ */
14
+ protected $name;
15
+
16
+ /**
17
+ * @var string the name of the hook for the advanced ads settings page
18
+ */
19
+ protected $settings_page_hook;
20
+
21
+ /**
22
+ * @var the wordpress nonce (retrieve with the get_nonce method)
23
+ */
24
+ protected $nonce;
25
+
26
+ /**
27
+ * Advanced_Ads_Ad_Network constructor.
28
+ * @param $identifier an identifier that will be used for hooks, settings, ids and much more - MAKE SURE IT IS UNIQUE!
29
+ * @param $name - the (translateable) display name for this ad network
30
+ */
31
+ public function __construct($identifier, $name){
32
+ $this->identifier = $identifier;
33
+ $this->name = $name;
34
+ $this->settings_page_hook = ADVADS_SLUG . '-' . $this->identifier . '-settings-page';
35
+ $this->settings_section_id = ADVADS_SLUG . '-' . $this->identifier . '-settings-section';
36
+ $this->settings_init_hook = ADVADS_SLUG . '-' . $this->identifier . '-settings-init';
37
+ }
38
+
39
+ /**
40
+ * @return string the identifier for this network
41
+ */
42
+ public function get_identifier() {
43
+ return $this->identifier;
44
+ }
45
+
46
+ /**
47
+ * @return string the display name for this network
48
+ */
49
+ public function get_display_name(){
50
+ return $this->name;
51
+ }
52
+
53
+ /**
54
+ * @return string the display value for the settings tab
55
+ */
56
+ public function get_settings_tab_name(){
57
+ return $this->get_display_name();
58
+ }
59
+
60
+ /**
61
+ * @return string url for the settings page (admin)
62
+ */
63
+ public function get_settings_href(){
64
+ return admin_url( 'admin.php?page=advanced-ads-settings#top#' . $this->identifier );
65
+ }
66
+
67
+ /**
68
+ * @return string the identifier / name for the javascript file that will be injected.
69
+ */
70
+ public function get_js_library_name(){
71
+ return "advanced-ads-network" . $this->identifier;
72
+ }
73
+
74
+ /**
75
+ * registers this ad network
76
+ */
77
+ public function register(){
78
+ // register the ad type
79
+ add_filter('advanced-ads-ad-types', array($this, 'register_ad_type_callback'));
80
+
81
+ if (is_admin()) {
82
+ if (defined('DOING_AJAX') && DOING_AJAX){
83
+ // we need add all the actions for our ajax calls here.
84
+ // our ajax method that will trigger an update of the ad units of this network
85
+ add_action('wp_ajax_advanced_ads_get_ad_units_' . $this->identifier, array($this, 'update_external_ad_units'));
86
+ add_action('wp_ajax_advanced_ads_toggle_idle_ads_' . $this->identifier, array( $this, 'toggle_idle_ads'));
87
+ } else {
88
+ // find out if we need to register the settings. this is necessary
89
+ // 1) when viewing the settings (admin.php with page="advanced-ads-settings")
90
+ // 2) when posting the settings to options.php
91
+ // in all other cases, there is nothing to do
92
+ global $pagenow;
93
+ $requires_settings = false;
94
+ $requires_javascript = false;
95
+
96
+ if ($pagenow == "admin.php") {
97
+ $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null;
98
+ switch ($page){
99
+ case "advanced-ads-settings":
100
+ $requires_settings = true;
101
+ $requires_javascript = true;
102
+ break;
103
+ case "advanced-ads":
104
+ $requires_javascript = true;
105
+ default:
106
+ break;
107
+ }
108
+ }
109
+ else if ($pagenow == "options.php") {
110
+ $requires_settings = true;
111
+ }
112
+ else if ($pagenow == 'post.php' || $pagenow == 'post-new.php'){
113
+ $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : '';
114
+ add_filter('advanced-ads-ad-settings-pre-save', array($this, 'sanitize_ad_settings'));
115
+ if (isset($_GET['action']) && 'edit' == $_GET['action']){
116
+ $requires_javascript = true;
117
+ }
118
+ else if ($post_type == "advanced_ads"){
119
+ $requires_javascript = true;
120
+ }
121
+ }
122
+
123
+ if ($requires_settings) {
124
+ // register the settings
125
+ add_action('advanced-ads-settings-init', array($this, 'register_settings_callback'));
126
+ add_filter('advanced-ads-setting-tabs', array($this, 'register_settings_tabs_callback'));
127
+ }
128
+ if ($requires_javascript){
129
+ add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_callback') );
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ /**
136
+ * the callback method for the filter "advanced-ads-ad-types"
137
+ * @param $types
138
+ */
139
+ public function register_ad_type_callback($types){
140
+ $types[$this->identifier] = $this->get_ad_type();
141
+ return $types;
142
+ }
143
+ /**
144
+ * this method will be called for the wp action "advanced-ads-settings-init" and therefore has to be public.
145
+ */
146
+ public function register_settings_callback(){
147
+ // register new settings
148
+ register_setting( ADVADS_SLUG . '-' . $this->identifier,
149
+ ADVADS_SLUG . '-' . $this->identifier,
150
+ array($this, 'sanitize_settings_callback')
151
+ );
152
+
153
+ // add a new section
154
+ add_settings_section(
155
+ $this->settings_section_id,
156
+ '', //__( 'AdSense', 'advanced-ads' ),
157
+ array($this, 'render_settings_callback'),
158
+ $this->settings_page_hook
159
+ );
160
+
161
+ // register all the custom settings
162
+ $this->register_settings($this->settings_page_hook, $this->settings_section_id);
163
+
164
+ do_action($this->settings_init_hook, $this->settings_page_hook);
165
+ }
166
+
167
+ protected function get_localized_script_object_name(){
168
+ return $this->identifier . 'AdvancedAdsJS';
169
+ }
170
+ public function enqueue_scripts_callback(){
171
+ $js_path = $this->get_javascript_base_path();
172
+ if ($js_path) {
173
+ $id = $this->get_js_library_name();
174
+ wp_enqueue_script($id, $js_path, array('jquery', 'advanced-ads-admin-script'));
175
+ // next we have to pass the data.
176
+ $data = array(
177
+ 'nonce' => $this->get_nonce()
178
+ );
179
+ $data = $this->append_javascript_data($data);
180
+ wp_localize_script($id, $this->get_localized_script_object_name(), $data);
181
+ }
182
+ }
183
+
184
+ /**
185
+ * @return string
186
+ */
187
+ public function get_nonce(){
188
+ if (! $this->nonce)
189
+ $this->nonce = wp_create_nonce($this->get_nonce_action());
190
+ return $this->nonce;
191
+ }
192
+
193
+ /**
194
+ * returns the action (name) of the nonce for this network
195
+ * in some cases you may want to override this method to faciliate
196
+ * integration with existing code
197
+ * @return string
198
+ */
199
+ public function get_nonce_action(){
200
+ return 'advads-network-' . $this->identifier;
201
+ }
202
+
203
+ /**
204
+ * this method will be called for the wp action "advanced-ads-settings-tabs" and therefore has to be public.
205
+ * it simply adds a tab for this ad type. if you don't want that just override this method with an empty one.
206
+ */
207
+ public function register_settings_tabs_callback($tabs){
208
+ $tab_id = $this->identifier;
209
+ $tabs[$tab_id] = array(
210
+ 'page' => $this->settings_page_hook,
211
+ 'group' => ADVADS_SLUG . '-' . $this->identifier,
212
+ 'tabid' => $tab_id,
213
+ 'title' => $this->get_settings_tab_name()
214
+ );
215
+ return $tabs;
216
+ }
217
+
218
+ public function render_settings_callback(){
219
+
220
+ }
221
+
222
+ public function sanitize_settings_callback($options){
223
+ $options = $this->sanitize_settings($options);
224
+ return $options;
225
+ }
226
+
227
+ public function sanitize_ad_settings_callback( array $ad_settings_post ){
228
+ return $this->sanitize_ad_settings($ad_settings_post);
229
+ }
230
+
231
+ /**
232
+ * performs basic security checks for wp ajax requests (nonce, capabilities)
233
+ * dies, when a problem was detected
234
+ */
235
+ protected function ajax_security_checks(){
236
+ if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) {
237
+ //TODO: translate
238
+ $this->send_ajax_error_response_and_die("You don't have the permission to manage ads.");
239
+ }
240
+ $nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
241
+ if ( ! wp_verify_nonce( $nonce, $this->get_nonce_action() ) ) {
242
+ //TODO: translate
243
+ $this->send_ajax_error_response_and_die("You sent an invalid request.");
244
+ }
245
+ }
246
+
247
+ protected function send_ajax_response_and_die($json_serializable_response = false){
248
+ if (!$json_serializable_response) $json_serializable_response = new stdClass();
249
+ header( 'Content-Type: application/json' );
250
+ echo json_encode($json_serializable_response);
251
+ die();
252
+ }
253
+
254
+ protected function send_ajax_error_response_and_die($message){
255
+ header( 'Content-Type: application/json' );
256
+ $r = new stdClass();
257
+ $r->error = $message;
258
+ echo json_encode($r);
259
+ die();
260
+ }
261
+
262
+ public function toggle_idle_ads(){
263
+ $this->ajax_security_checks();
264
+ global $external_ad_unit_id;
265
+ $hide_idle_ads = isset($_POST['hide']) ? $_POST['hide'] : false;
266
+ $external_ad_unit_id = isset($_POST['ad_unit_id']) ? $_POST['ad_unit_id'] : "";
267
+ if (!$external_ad_unit_id) $external_ad_unit_id = "";
268
+ ob_start();
269
+
270
+ $this->print_external_ads_list($hide_idle_ads);
271
+ $ad_selector = ob_get_clean();
272
+
273
+ $response = array(
274
+ 'status' => true,
275
+ 'html' => $ad_selector,
276
+ );
277
+ $this->send_ajax_response_and_die($response);
278
+ }
279
+
280
+ /**
281
+ * when you need some kind of manual ad setup (meaning you can edit the custom inputs of this ad type)
282
+ * you should override this method to return true. this results in an additional link (Setup code manually)
283
+ * @return bool
284
+ */
285
+ public function supports_manual_ad_setup(){
286
+ return false;
287
+ }
288
+
289
+ public abstract function print_external_ads_list($hide_idle_ads = true);
290
+
291
+ /**
292
+ * retrieves an instance of the ad type for this ad network
293
+ */
294
+ public abstract function get_ad_type();
295
+
296
+ /**
297
+ * this method will be called via wp AJAX.
298
+ * it has to retrieve the list of ads from the ad network and store it as an option
299
+ * does not return ad units - use "get_external_ad_units" if you're looking for an array of ad units
300
+ */
301
+ public abstract function update_external_ad_units();
302
+
303
+ /**
304
+ * adds the custom wp settings to the tab for this ad unit
305
+ */
306
+ protected abstract function register_settings($hook, $section_id);
307
+
308
+ /**
309
+ * sanitize the network specific options
310
+ * @param $options the options to sanitize
311
+ * @return mixed the sanitizzed options
312
+ */
313
+ protected abstract function sanitize_settings($options);
314
+
315
+ /**
316
+ * sanitize the settings for this ad network
317
+ * @param $ad_settings_post
318
+ * @return mixed the sanitized settings
319
+ */
320
+ public abstract function sanitize_ad_settings($ad_settings_post);
321
+
322
+
323
+
324
+ /**
325
+ * @return array of ad units (Advanced_Ads_Ad_Network_Ad_Unit)
326
+ */
327
+ public abstract function get_external_ad_units();
328
+
329
+ /**
330
+ * checks if the ad_unit is supported by advanced ads.
331
+ * this determines wheter it can be imported or not.
332
+ * @param $ad_unit
333
+ * @return boolean
334
+ */
335
+ public abstract function is_supported($ad_unit);
336
+
337
+ /**
338
+ * there is no common way to connect to an external account. you will have to implement it somehow, just
339
+ * like the whole setup process (usually done in the settings tab of this network). this method provides
340
+ * a way to return this account connection
341
+ * @return boolean true, when an account was successfully connected
342
+ */
343
+ public abstract function is_account_connected();
344
+
345
+ /**
346
+ * external ad networks rely on the same javascript base code. however you still have to provide
347
+ * a javascript class that inherits from the AdvancedAdsAdNetwork js class
348
+ * this has to point to that file, or return false,
349
+ * if you don't have to include it in another way (NOT RECOMMENDED!)
350
+ * @return string path to the javascript file containing the javascriot class for this ad type
351
+ */
352
+ public abstract function get_javascript_base_path();
353
+
354
+ /**
355
+ * our script might need translations or other variables (llike a nonce, which is included automatically)
356
+ * add anything you need in this method and return the array
357
+ * @param $data array holding the data
358
+ * @return array the data, that will be passed to the base javascript file containing the AdvancedAdsAdNetwork class
359
+ */
360
+ public abstract function append_javascript_data(&$data);
361
+ }
admin/includes/class-ad-type.php CHANGED
@@ -51,6 +51,9 @@ class Advanced_Ads_Admin_Ad_Type {
51
  $this->post_type = constant( 'Advanced_Ads::POST_TYPE_SLUG' );
52
 
53
  add_filter( 'gettext', array( $this, 'replace_cheating_message' ), 20, 2 );
 
 
 
54
  }
55
 
56
  /**
@@ -674,4 +677,18 @@ class Advanced_Ads_Admin_Ad_Type {
674
  return $translated_text;
675
  }
676
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
677
  }
51
  $this->post_type = constant( 'Advanced_Ads::POST_TYPE_SLUG' );
52
 
53
  add_filter( 'gettext', array( $this, 'replace_cheating_message' ), 20, 2 );
54
+
55
+ // Remove parent group dropdown in ad edit
56
+ add_filter( 'wp_dropdown_cats', array( $this, 'remove_parent_group_dropdown'), 10, 2 );
57
  }
58
 
59
  /**
677
  return $translated_text;
678
  }
679
 
680
+ /**
681
+ * Remove parent group dropdown from ad group taxonomy
682
+ *
683
+ * @param string $output parent group HTML
684
+ * @param array $arguments
685
+ * @return string new parent group HTML
686
+ */
687
+ public function remove_parent_group_dropdown( $output, $arguments) {
688
+ if( $arguments['name']=='newadvanced_ads_groups_parent' ){
689
+ $output ='';
690
+ }
691
+ return $output;
692
+ }
693
+
694
  }
admin/includes/class-meta-box.php CHANGED
@@ -54,6 +54,17 @@ class Advanced_Ads_Admin_Meta_Boxes {
54
  add_meta_box(
55
  'ad-main-box', __( 'Ad Type', 'advanced-ads' ), array($this, 'markup_meta_boxes'), $post_type, 'normal', 'high'
56
  );
 
 
 
 
 
 
 
 
 
 
 
57
  // use dynamic filter from to add close class to ad type meta box after saved first time
58
  add_filter( 'postbox_classes_advanced_ads_ad-main-box', array( $this, 'close_ad_type_metabox' ) );
59
 
@@ -83,6 +94,7 @@ class Advanced_Ads_Admin_Meta_Boxes {
83
  // register meta box ids
84
  $this->meta_box_ids = array(
85
  'ad-main-box',
 
86
  'ad-parameters-box',
87
  'ad-output-box',
88
  'ad-display-box',
@@ -163,6 +175,26 @@ class Advanced_Ads_Admin_Meta_Boxes {
163
  $view = 'pitch-tracking.php';
164
  // $hndlelinks = '<a href="' . ADVADS_URL . 'manual/visitor-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor" target="_blank">' . __('Manual', 'advanced-ads') . '</a>';
165
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
167
 
168
  if ( ! isset( $view ) ) {
54
  add_meta_box(
55
  'ad-main-box', __( 'Ad Type', 'advanced-ads' ), array($this, 'markup_meta_boxes'), $post_type, 'normal', 'high'
56
  );
57
+ if (Advanced_Ads_AdSense_Data::get_instance()->is_setup()){
58
+ global $post_id;
59
+ if ($post_id){
60
+ $ad = new Advanced_Ads_Ad( $post_id );
61
+
62
+ add_meta_box(
63
+ 'advads-gadsense-box', __('AdSense Earnings', 'advanced-ads'), array($this, 'markup_meta_boxes'), $post_type, 'normal', 'high'
64
+ );
65
+
66
+ }
67
+ }
68
  // use dynamic filter from to add close class to ad type meta box after saved first time
69
  add_filter( 'postbox_classes_advanced_ads_ad-main-box', array( $this, 'close_ad_type_metabox' ) );
70
 
94
  // register meta box ids
95
  $this->meta_box_ids = array(
96
  'ad-main-box',
97
+ 'advads-gadsense-box',
98
  'ad-parameters-box',
99
  'ad-output-box',
100
  'ad-display-box',
175
  $view = 'pitch-tracking.php';
176
  // $hndlelinks = '<a href="' . ADVADS_URL . 'manual/visitor-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor" target="_blank">' . __('Manual', 'advanced-ads') . '</a>';
177
  break;
178
+ case 'advads-gadsense-box':
179
+ $unit_code = null;
180
+ if ($ad && isset($ad->type) && $ad->type === "adsense"){
181
+ if (isset($ad->content)){
182
+ $json_content = json_decode($ad->content);
183
+ if (isset($json_content->slotId)){
184
+ $unit_code = $json_content->slotId;
185
+ }
186
+ }
187
+ }
188
+ $advads_gadsense_options = array(
189
+ "dimension_name" => "AD_UNIT_CODE",
190
+ "filter_value" => $unit_code,
191
+ "hide_dimensions" => true,
192
+ "metabox_selector" => "#advads-gadsense-box",
193
+ "hidden" => !$unit_code
194
+ );
195
+ $advads_gadsense_options['hidden'] = !$unit_code;
196
+ $view = 'gadsense-dashboard.php';
197
+ break;
198
  }
199
 
200
  if ( ! isset( $view ) ) {
admin/includes/class-overview-widgets.php CHANGED
@@ -7,7 +7,19 @@
7
  * @since 1.4.3
8
  */
9
  class Advanced_Ads_Overview_Widgets_Callbacks {
10
-
 
 
 
 
 
 
 
 
 
 
 
 
11
  /**
12
  * register the plugin overview widgets
13
  *
@@ -34,6 +46,10 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
34
  'render_next_steps');
35
  self::add_meta_box('advads_overview_support', __( 'Manual and Support', 'advanced-ads' ), 'right',
36
  'render_support' );
 
 
 
 
37
 
38
  // add widgets for pro add ons
39
  self::add_meta_box('advads_overview_addons', __( 'Add-Ons', 'advanced-ads' ), 'full', 'render_addons' );
@@ -153,7 +169,7 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
153
  ?><ul>
154
  <li><?php printf( __( '<a href="%s" target="_blank">Manual</a>', 'advanced-ads' ), ADVADS_URL . 'manual/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-manual' ); ?></li>
155
  <li><?php printf( __( '<a href="%s" target="_blank">FAQ and Support</a>', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-support' ); ?></li>
156
- <li><?php printf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads/reviews/?filter=5#new-post' ); ?></li>
157
  </ul><?php
158
 
159
  $ignored_count = count( Advanced_Ads_Ad_Health_Notices::get_instance()->ignore );
@@ -168,6 +184,168 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
168
  do_action( 'advanced-ads-overview-below-support' );
169
 
170
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  /**
173
  * pro addons widget
7
  * @since 1.4.3
8
  */
9
  class Advanced_Ads_Overview_Widgets_Callbacks {
10
+ /**
11
+ * in case one wants to inject several dashboards into a page, we will prevent executing redundant javascript
12
+ * with the help of this little bool
13
+ */
14
+ private static $processed_adsense_stats_js = false;
15
+
16
+ /**
17
+ * when doing ajax request (refreshing the dashboard), we need to have a nonce.
18
+ * one is enough, that's why we need to remember it.
19
+ */
20
+ private static $gadsense_dashboard_nonce = false;
21
+
22
+
23
  /**
24
  * register the plugin overview widgets
25
  *
46
  'render_next_steps');
47
  self::add_meta_box('advads_overview_support', __( 'Manual and Support', 'advanced-ads' ), 'right',
48
  'render_support' );
49
+ if (Advanced_Ads_AdSense_Data::get_instance()->is_setup()){
50
+ self::add_meta_box('advads_overview_adsense_stats', __( 'AdSense Earnings', 'advanced-ads' ), 'full',
51
+ 'render_adsense_stats' );
52
+ }
53
 
54
  // add widgets for pro add ons
55
  self::add_meta_box('advads_overview_addons', __( 'Add-Ons', 'advanced-ads' ), 'full', 'render_addons' );
169
  ?><ul>
170
  <li><?php printf( __( '<a href="%s" target="_blank">Manual</a>', 'advanced-ads' ), ADVADS_URL . 'manual/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-manual' ); ?></li>
171
  <li><?php printf( __( '<a href="%s" target="_blank">FAQ and Support</a>', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-support' ); ?></li>
172
+ <li><?php printf( __( 'Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a href="%s" target="_blank">wordpress.org</a>', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads/reviews/#new-post' ); ?></li>
173
  </ul><?php
174
 
175
  $ignored_count = count( Advanced_Ads_Ad_Health_Notices::get_instance()->ignore );
184
  do_action( 'advanced-ads-overview-below-support' );
185
 
186
  }
187
+
188
+ /**
189
+ * adsense stats widget
190
+ */
191
+ public static function render_adsense_stats(){
192
+ $option_name = "advanced-ads-adsense-dashboard-filter";
193
+ $filter_value = get_option($option_name, null);
194
+ if (! $filter_value){
195
+ $filter_value = self::get_site_domain();
196
+ }
197
+ if ($filter_value === "*") $filter_value = null;
198
+ $advads_gadsense_options = array(
199
+ "dimension_name" => "DOMAIN_NAME",
200
+ "allow_refresh" => true,
201
+ "filter_value" => $filter_value
202
+ );
203
+ include(ADVADS_BASE_PATH . 'admin/views/gadsense-dashboard.php');
204
+ }
205
+
206
+ public static final function adsense_stats_js($pub_id){
207
+ if (self::$processed_adsense_stats_js) return;
208
+ self::$processed_adsense_stats_js = true;
209
+ $nonce = self::get_adsense_dashboard_nonce();
210
+ ?><script>
211
+ window.gadsenseData = window.gadsenseData || {};
212
+ gadsenseData['pubId'] = '<?php echo $pub_id; ?>';
213
+ window.Advanced_Ads_Adsense_Helper.nonce = '<?php echo $nonce;?>';
214
+ </script><?php
215
+ }
216
+
217
+ public static final function get_adsense_dashboard_nonce(){
218
+ if (! self::$gadsense_dashboard_nonce){
219
+ self::$gadsense_dashboard_nonce = wp_create_nonce( 'advads-gadsense-dashboard' );
220
+ }
221
+ return self::$gadsense_dashboard_nonce;
222
+ }
223
+
224
+ /**
225
+ * extracts the domain from the site url
226
+ * @return string the domain, that was extracted from get_site_url()
227
+ */
228
+ public static function get_site_domain(){
229
+ $site = get_site_url();
230
+ preg_match("|^([\d\w]+://)?([^/]+)|", $site, $matches);
231
+ $domain = count($matches) > 1 ? $matches[2] : null;
232
+ return $domain;
233
+ }
234
+
235
+ /**
236
+ * this method should be used, if you want to render a dashboard summary.
237
+ * it takes an associative options array as parameter to create a summary object,
238
+ * which can be used to create a json or html response.
239
+ * @param array $options
240
+ * @return Advanced_Ads_AdSense_Dashboard_Summary
241
+ */
242
+ public static function create_dashboard_summary($options){
243
+ if (! $options) $options = array();
244
+ $options = array_merge( array(
245
+ "dimension_name" => null,
246
+ "filter_value" => null,
247
+ "hide_dimensions" => false,
248
+ "force_refresh" => false,
249
+ "allow_refresh" => true,
250
+ ), $options);
251
+
252
+ $dimension_name = $options['dimension_name'];
253
+ $filter_value = $options['filter_value'];
254
+ $hide_dimensions = $options['hide_dimensions'];
255
+ $force_refresh = $options['force_refresh'];
256
+ $allow_refresh = $options['allow_refresh'];
257
+
258
+ $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id();
259
+ $optional_dimension_names = $dimension_name == "AD_UNIT_CODE" ? Advanced_Ads_Overview_Widgets_Callbacks::get_ad_code_map($pub_id) : null;
260
+
261
+ $summary = Advanced_Ads_AdSense_Report_Builder::createDashboardSummary($dimension_name, $filter_value, "dashboard", $optional_dimension_names, $force_refresh, $allow_refresh);
262
+ if ($hide_dimensions){
263
+ $summary->dimensions = null;
264
+ }
265
+ $summary->hide_dimensions = $hide_dimensions;
266
+ return $summary;
267
+ }
268
+ /**
269
+ * we want to display the name of the ad code insted of the code itself.
270
+ * @param string $pub_id the publisher id of the adsense account
271
+ * @return array an associative array with ad codes as key and their respective name as value
272
+ */
273
+ public static function get_ad_code_map($pub_id){
274
+ $map = array();
275
+ $ad_units_opts = get_option(Advanced_Ads_AdSense_MAPI::OPTNAME);
276
+ if (! isset($ad_units_opts['accounts'])) return null;
277
+ foreach ($ad_units_opts['accounts'] as $key => $account){
278
+ if ($key === $pub_id && isset($account['ad_units']) && is_array($account['ad_units'])){
279
+ $units = $account['ad_units'];
280
+ foreach ($units as $unit){
281
+ $map[$unit['code']] = $unit['name'];
282
+ }
283
+ }
284
+ }
285
+ return $map;
286
+ }
287
+
288
+
289
+ /**
290
+ * this method is called when the dashboard data is requested via ajax
291
+ * it prints the relevant data as json, then dies.
292
+ */
293
+ public static function ajax_gadsense_dashboard(){
294
+ // retrieve our post parameters.
295
+ $dimension_name = isset($_POST['dimension_name']) ? $_POST['dimension_name'] : "DOMAIN_NAME";
296
+ $filter_value = isset($_POST['filter']) ? $_POST['filter'] : null;
297
+ $dimension_name = sanitize_text_field($dimension_name);
298
+ if ($filter_value) $filter_value = sanitize_text_field($filter_value);
299
+
300
+ $errors = array();
301
+ // check nonce and capabilities
302
+ if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options') ) ) {
303
+ $errors[] = "missing capability";
304
+ }
305
+ // check nonce
306
+ if (! check_ajax_referer( 'advads-gadsense-dashboard', 'nonce', false)){
307
+ $errors[] = "invalid request";
308
+ }
309
+
310
+ // when there is an error, send it right away
311
+ if (count($errors) > 0){
312
+ $r = array("summary" => array("valid" => false, "errors" => $errors));
313
+ header( 'Content-Type: application/json' );
314
+ echo wp_json_encode($r);
315
+ die();
316
+ }
317
+
318
+
319
+ $options = array(
320
+ "dimension_name" => $dimension_name,
321
+ );
322
+ if ($dimension_name === "DOMAIN_NAME"){
323
+ if ($filter_value){
324
+ update_option("advanced-ads-adsense-dashboard-filter", $filter_value);
325
+ }
326
+ }
327
+ else if ($dimension_name === "AD_UNIT_CODE"){
328
+ $options["hide_dimensions"] = true;
329
+ }
330
+ if ($filter_value && $filter_value === "*") $filter_value = null;
331
+ $options["filter_value"] = $filter_value;
332
+
333
+ $r = array();
334
+ $summary = self::create_dashboard_summary($options);
335
+ $r['summary'] = $summary;
336
+
337
+ header( 'Content-Type: application/json' );
338
+ echo wp_json_encode($r);
339
+ die();
340
+ }
341
+
342
+ public static final function render_stats_box($title, $main, $footer){
343
+ ?><div class="advanced-ads-stats-box flex1">
344
+ <?php echo $title; ?>
345
+ <div class="advanced-ads-stats-box-main"><?php echo $main;?></div>
346
+ <?php echo $footer; ?>
347
+ </div><?php
348
+ }
349
 
350
  /**
351
  * pro addons widget
admin/views/ad-group.php CHANGED
@@ -38,9 +38,6 @@ if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
38
  $last_edited_group_id = 0;
39
  if (isset( $_REQUEST['advads-last-edited-group'] )){
40
  $last_edited_group_id = $_REQUEST['advads-last-edited-group'];
41
- wp_add_inline_script(
42
- 'advads-ad-groups', 'alert("TEST");'
43
- );
44
  ?>
45
  <script>
46
  var body = document.getElementsByTagName("body")[0];
38
  $last_edited_group_id = 0;
39
  if (isset( $_REQUEST['advads-last-edited-group'] )){
40
  $last_edited_group_id = $_REQUEST['advads-last-edited-group'];
 
 
 
41
  ?>
42
  <script>
43
  var body = document.getElementsByTagName("body")[0];
admin/views/ad-main-metabox.php CHANGED
@@ -29,7 +29,11 @@ jQuery( document ).on('change', '#advanced-ad-type input', function () {
29
  advads_main_metabox_title = jQuery('#ad-main-box h2').text();
30
  function advads_update_ad_type_headline(){
31
  var advads_selected_type = jQuery('#advanced-ad-type input:checked + label').text();
 
32
  jQuery('#ad-main-box h2').html( advads_main_metabox_title + ': ' + advads_selected_type );
 
 
 
33
  }
34
  advads_update_ad_type_headline();
35
  </script>
29
  advads_main_metabox_title = jQuery('#ad-main-box h2').text();
30
  function advads_update_ad_type_headline(){
31
  var advads_selected_type = jQuery('#advanced-ad-type input:checked + label').text();
32
+ var advads_selected_id = jQuery('#advanced-ad-type input:checked').attr('id');
33
  jQuery('#ad-main-box h2').html( advads_main_metabox_title + ': ' + advads_selected_type );
34
+ // if (advads_selected_id === "advanced-ad-type-adsense") jQuery('#advads-gadsense-box').show();
35
+ // else jQuery('#advads-gadsense-box').hide();
36
+ jQuery('#advads-gadsense-box').hide();
37
  }
38
  advads_update_ad_type_headline();
39
  </script>
admin/views/ad-parameters-metabox.php CHANGED
@@ -24,9 +24,11 @@ do_action( 'advanced-ads-ad-params-before', $ad, $types );
24
  $type = ( isset( $types[ $ad->type ] ) ) ? $types[ $ad->type ] : current( $types );
25
  $type->render_parameters( $ad );
26
 
27
- if ( 'dummy' !== $ad->type ) :
28
- include ADVADS_BASE_PATH . 'admin/views/ad-parameters-size.php';
29
- endif;
 
 
30
  ?>
31
  </div>
32
  <?php
24
  $type = ( isset( $types[ $ad->type ] ) ) ? $types[ $ad->type ] : current( $types );
25
  $type->render_parameters( $ad );
26
 
27
+ $types_without_size = array('dummy');
28
+ $types_without_size = apply_filters( 'advanced-ads-types-without-size', $types_without_size );
29
+ if ( ! in_array($ad->type, $types_without_size) ) {
30
+ include ADVADS_BASE_PATH . 'admin/views/ad-parameters-size.php';
31
+ };
32
  ?>
33
  </div>
34
  <?php
admin/views/gadsense-dashboard.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id();
3
+ if ($pub_id){
4
+ if (! $advads_gadsense_options) $advads_gadsense_options = array();
5
+ $advads_gadsense_options = array_merge( array(
6
+ "dimension_name" => null,
7
+ "filter_value" => null,
8
+ "hide_dimensions" => false,
9
+ "metabox_selector" => null,
10
+ "hidden" => null,
11
+ ), $advads_gadsense_options);
12
+ $div_tag_extras = "";
13
+ if ($advads_gadsense_options['metabox_selector']){
14
+ $div_tag_extras .= 'data-metabox_selector="' . $advads_gadsense_options['metabox_selector'] . '""';
15
+ }
16
+
17
+ $summary = Advanced_Ads_Overview_Widgets_Callbacks::create_dashboard_summary($advads_gadsense_options);
18
+ Advanced_Ads_Overview_Widgets_Callbacks::adsense_stats_js($pub_id);
19
+
20
+
21
+ if ($advads_gadsense_options['hidden'] || ($advads_gadsense_options['dimension_name'] != "DOMAIN_NAME" && ! $advads_gadsense_options['filter_value'])){
22
+ $summary->hidden = true;
23
+ }
24
+
25
+ ?>
26
+ <div class="advanced-ads-adsense-dashboard" data-refresh='<?php echo json_encode($summary)?>' <?php echo $div_tag_extras?>></div><?php
27
+ }
28
+ else{
29
+ echo __("There is an error in your AdSense setup.", "advanced-ads");
30
+ }
31
+ ?>
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.13.8
16
  * Author: Thomas Maier
17
  * Author URI: https://wpadvancedads.com
18
  * Text Domain: advanced-ads
@@ -39,7 +39,7 @@ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin
39
  // general and global slug, e.g. to store options in WP
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
- define( 'ADVADS_VERSION', '1.13.8' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
12
  * Plugin Name: Advanced Ads
13
  * Plugin URI: https://wpadvancedads.com
14
  * Description: Manage and optimize your ads in WordPress
15
+ * Version: 1.14
16
  * Author: Thomas Maier
17
  * Author URI: https://wpadvancedads.com
18
  * Text Domain: advanced-ads
39
  // general and global slug, e.g. to store options in WP
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
+ define( 'ADVADS_VERSION', '1.14' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/ad-health-notices.php CHANGED
@@ -307,6 +307,11 @@ class Advanced_Ads_Ad_Health_Notices {
307
  if ( Advanced_Ads_Checks::wp_engine_hosting() ) {
308
  $this->add( 'wpengine' );
309
  }
 
 
 
 
 
310
 
311
  set_transient( self::DAILY_CHECK_TRANSIENT_NAME, true, DAY_IN_SECONDS );
312
  }
307
  if ( Advanced_Ads_Checks::wp_engine_hosting() ) {
308
  $this->add( 'wpengine' );
309
  }
310
+ if ( count( Advanced_Ads_Checks::ads_txt_plugins() ) ) {
311
+ $this->add( 'ads_txt_plugins_enabled' );
312
+ } else {
313
+ $this->remove( 'ads_txt_plugins_enabled' );
314
+ }
315
 
316
  set_transient( self::DAILY_CHECK_TRANSIENT_NAME, true, DAY_IN_SECONDS );
317
  }
classes/ad_ajax_callbacks.php CHANGED
@@ -52,7 +52,6 @@ class Advanced_Ads_Ad_Ajax_Callbacks {
52
  public function load_ad_parameters_metabox() {
53
 
54
  check_ajax_referer('advanced-ads-admin-ajax-nonce', 'nonce');
55
-
56
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads') ) ) {
57
  return;
58
  }
@@ -68,9 +67,11 @@ class Advanced_Ads_Ad_Ajax_Callbacks {
68
  $type = $types[ $type_string ];
69
  $type->render_parameters( $ad );
70
 
71
- if( 'dummy' !== $type_string ) :
72
- include ADVADS_BASE_PATH . 'admin/views/ad-parameters-size.php';
73
- endif;
 
 
74
  }
75
 
76
  die();
52
  public function load_ad_parameters_metabox() {
53
 
54
  check_ajax_referer('advanced-ads-admin-ajax-nonce', 'nonce');
 
55
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads') ) ) {
56
  return;
57
  }
67
  $type = $types[ $type_string ];
68
  $type->render_parameters( $ad );
69
 
70
+ $types_without_size = array('dummy');
71
+ $types_without_size = apply_filters( 'advanced-ads-types-without-size', $types_without_size );
72
+ if ( ! in_array($type_string, $types_without_size) ) {
73
+ include ADVADS_BASE_PATH . 'admin/views/ad-parameters-size.php';
74
+ }
75
  }
76
 
77
  die();
classes/checks.php CHANGED
@@ -6,13 +6,13 @@
6
  * @since 1.6.9
7
  */
8
  class Advanced_Ads_Checks {
9
-
10
  /**
11
  * Minimum required PHP version of Advanced Ads
12
  */
13
  const MINIMUM_PHP_VERSION = '5.6.20';
14
-
15
-
16
  /**
17
  * show the list of potential issues
18
  */
@@ -82,7 +82,7 @@ class Advanced_Ads_Checks {
82
  public static function licenses_invalid(){
83
 
84
  $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
85
-
86
  if( $add_ons === array() ) {
87
  Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
88
  return false;
@@ -90,14 +90,14 @@ class Advanced_Ads_Checks {
90
 
91
  foreach( $add_ons as $_add_on_key => $_add_on ){
92
  $status = Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] );
93
-
94
  // check expiry date
95
  $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
96
 
97
  if( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < time() ){
98
  return true;
99
  }
100
-
101
  // don’t check if license is valid
102
  if( $status === 'valid' ) {
103
  continue;
@@ -117,7 +117,7 @@ class Advanced_Ads_Checks {
117
  Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
118
  return false;
119
  }
120
-
121
  /**
122
  * Autoptimize plugin installed
123
  * can change ad tags, especially inline css and scripts
@@ -133,7 +133,7 @@ class Advanced_Ads_Checks {
133
 
134
  return false;
135
  }
136
-
137
  /**
138
  * WP rocket plugin installed
139
  *
@@ -143,10 +143,10 @@ class Advanced_Ads_Checks {
143
  if( defined( 'WP_ROCKET_SLUG' ) ){
144
  return true;
145
  }
146
-
147
  return false;
148
  }
149
-
150
  /**
151
  * checks the settings of wp rocket to find out if combining of javascript files is enabled
152
  * @return boolean true, when "Combine JavaScript files" is enabled
@@ -184,7 +184,7 @@ class Advanced_Ads_Checks {
184
 
185
  return false;
186
  }
187
-
188
  /**
189
  * checks if the preconditions are met to wrap an ad with <!--noptimize--> comments
190
  * @return boolean
@@ -220,11 +220,11 @@ class Advanced_Ads_Checks {
220
 
221
  return $conflicting_plugins;
222
  }
223
-
224
  /**
225
  * check if any of the global hide ads options is set
226
  * ignore RSS feed setting, because it is standard
227
- *
228
  * @since 1.7.10
229
  * @return bool
230
  */
@@ -240,28 +240,28 @@ class Advanced_Ads_Checks {
240
  }
241
  return false;
242
  }
243
-
244
  /**
245
  * check for required php extensions
246
- *
247
  * @since 1.8.21
248
  * @return bool
249
  */
250
  public static function php_extensions(){
251
-
252
  $missing_extensions = array();
253
-
254
  if( !extension_loaded('dom') ){
255
  $missing_extensions[] = 'dom';
256
  }
257
-
258
  if( !extension_loaded('xml') ){
259
  $missing_extensions[] = 'xml';
260
  }
261
-
262
  return $missing_extensions;
263
  }
264
-
265
  /**
266
  * Get the list of Advanced Ads constant defined by the user.
267
  *
@@ -313,21 +313,21 @@ class Advanced_Ads_Checks {
313
 
314
  return false;
315
  }
316
-
317
  /**
318
  * Notice for Adblocker module if assets have expired
319
  */
320
  public static function assets_expired() {
321
  $plugin_options = Advanced_Ads_Plugin::get_instance()->options();
322
  $adblocker_options = Advanced_Ads_Ad_Blocker::get_instance()->options();
323
-
324
  return ( ! empty ( $plugin_options['use-adblocker'] ) && empty ( $adblocker_options['module_can_work'] ) );
325
  }
326
-
327
  /**
328
  * check for potential jQuery errors
329
  * only script, so no return, but direct output
330
- *
331
  */
332
  public static function jquery_ui_conflict(){
333
  ?>
@@ -340,4 +340,28 @@ class Advanced_Ads_Checks {
340
  });
341
  </script><?php
342
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  }
6
  * @since 1.6.9
7
  */
8
  class Advanced_Ads_Checks {
9
+
10
  /**
11
  * Minimum required PHP version of Advanced Ads
12
  */
13
  const MINIMUM_PHP_VERSION = '5.6.20';
14
+
15
+
16
  /**
17
  * show the list of potential issues
18
  */
82
  public static function licenses_invalid(){
83
 
84
  $add_ons = apply_filters( 'advanced-ads-add-ons', array() );
85
+
86
  if( $add_ons === array() ) {
87
  Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
88
  return false;
90
 
91
  foreach( $add_ons as $_add_on_key => $_add_on ){
92
  $status = Advanced_Ads_Admin_Licenses::get_instance()->get_license_status( $_add_on['options_slug'] );
93
+
94
  // check expiry date
95
  $expiry_date = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $_add_on['options_slug'] );
96
 
97
  if( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < time() ){
98
  return true;
99
  }
100
+
101
  // don’t check if license is valid
102
  if( $status === 'valid' ) {
103
  continue;
117
  Advanced_Ads_Ad_Health_Notices::get_instance()->remove( 'license_invalid' );
118
  return false;
119
  }
120
+
121
  /**
122
  * Autoptimize plugin installed
123
  * can change ad tags, especially inline css and scripts
133
 
134
  return false;
135
  }
136
+
137
  /**
138
  * WP rocket plugin installed
139
  *
143
  if( defined( 'WP_ROCKET_SLUG' ) ){
144
  return true;
145
  }
146
+
147
  return false;
148
  }
149
+
150
  /**
151
  * checks the settings of wp rocket to find out if combining of javascript files is enabled
152
  * @return boolean true, when "Combine JavaScript files" is enabled
184
 
185
  return false;
186
  }
187
+
188
  /**
189
  * checks if the preconditions are met to wrap an ad with <!--noptimize--> comments
190
  * @return boolean
220
 
221
  return $conflicting_plugins;
222
  }
223
+
224
  /**
225
  * check if any of the global hide ads options is set
226
  * ignore RSS feed setting, because it is standard
227
+ *
228
  * @since 1.7.10
229
  * @return bool
230
  */
240
  }
241
  return false;
242
  }
243
+
244
  /**
245
  * check for required php extensions
246
+ *
247
  * @since 1.8.21
248
  * @return bool
249
  */
250
  public static function php_extensions(){
251
+
252
  $missing_extensions = array();
253
+
254
  if( !extension_loaded('dom') ){
255
  $missing_extensions[] = 'dom';
256
  }
257
+
258
  if( !extension_loaded('xml') ){
259
  $missing_extensions[] = 'xml';
260
  }
261
+
262
  return $missing_extensions;
263
  }
264
+
265
  /**
266
  * Get the list of Advanced Ads constant defined by the user.
267
  *
313
 
314
  return false;
315
  }
316
+
317
  /**
318
  * Notice for Adblocker module if assets have expired
319
  */
320
  public static function assets_expired() {
321
  $plugin_options = Advanced_Ads_Plugin::get_instance()->options();
322
  $adblocker_options = Advanced_Ads_Ad_Blocker::get_instance()->options();
323
+
324
  return ( ! empty ( $plugin_options['use-adblocker'] ) && empty ( $adblocker_options['module_can_work'] ) );
325
  }
326
+
327
  /**
328
  * check for potential jQuery errors
329
  * only script, so no return, but direct output
330
+ *
331
  */
332
  public static function jquery_ui_conflict(){
333
  ?>
340
  });
341
  </script><?php
342
  }
343
+
344
+ /**
345
+ * Check for other ads.txt plugins
346
+ *
347
+ * @return array
348
+ */
349
+ public static function ads_txt_plugins(){
350
+
351
+ $ads_txt_plugins = array();
352
+
353
+ // Ads.txt Manager
354
+ if( function_exists( 'tenup_display_ads_txt' ) ) {
355
+ $ads_txt_plugins[] = 'Ads.txt Manager';
356
+ }
357
+
358
+ // todo:
359
+ // ads-txt-admin/unveil-media-ads-txt.php
360
+ // simple-ads-txt/bs_ads_txt.php
361
+ // ads-txt-manager/adstxtmanager.php
362
+ // monetizemore-ads-txt/wp-ads-txt.php
363
+ // authorized-sellers-manager/ads-txt-publisher.php' ) ) {
364
+
365
+ return $ads_txt_plugins;
366
+ }
367
  }
classes/widget.php CHANGED
@@ -60,7 +60,6 @@ class Advanced_Ads_Widget extends WP_Widget {
60
  $instance['remove-widget-id'] = true;
61
  }
62
  return $instance;
63
- return $instance;
64
  }
65
 
66
  function form($instance) {
60
  $instance['remove-widget-id'] = true;
61
  }
62
  return $instance;
 
63
  }
64
 
65
  function form($instance) {
languages/advanced-ads.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Advanved Ads\n"
5
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
6
- "POT-Creation-Date: 2019-06-25 10:44+0000\n"
7
  "POT-Revision-Date: Wed Jul 13 2016 13:23:05 GMT+0200 (CEST)\n"
8
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9
  "Last-Translator: Thomas Maier <post@webzunft.de>\n"
@@ -25,8 +25,9 @@ msgstr ""
25
 
26
  #: admin/class-advanced-ads-admin.php:222 classes/display-conditions.php:215
27
  #: classes/visitor-conditions.php:242 admin/views/ad-display-metabox.php:189
28
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:89
29
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:92
 
30
  msgid "or"
31
  msgstr ""
32
 
@@ -39,23 +40,60 @@ msgstr ""
39
  msgid "After which paragraph?"
40
  msgstr ""
41
 
42
- #: admin/class-advanced-ads-admin.php:336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  #, php-format
44
  msgid "time of %s"
45
  msgstr ""
46
 
47
- #: admin/class-advanced-ads-admin.php:401 admin/includes/class-menu.php:113
48
  #: admin/includes/class-menu.php:116 admin/views/settings.php:28
49
  msgid "Support"
50
  msgstr ""
51
 
52
- #: admin/class-advanced-ads-admin.php:405
53
- #: admin/includes/class-overview-widgets.php:39
54
  msgid "Add-Ons"
55
  msgstr ""
56
 
57
- #: admin/class-advanced-ads-admin.php:671
58
- #: admin/includes/class-overview-widgets.php:156
59
  #, php-format
60
  msgid ""
61
  "Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a "
@@ -95,11 +133,11 @@ msgid "main query"
95
  msgstr ""
96
 
97
  #: classes/ad-debug.php:118 classes/ad-debug.php:167 classes/ad-debug.php:169
98
- #: public/class-advanced-ads.php:742 admin/views/ad-group-list-ads.php:13
99
  msgid "Ad"
100
  msgstr ""
101
 
102
- #: classes/ad-debug.php:121 public/class-advanced-ads.php:705
103
  msgctxt "ad group singular name"
104
  msgid "Ad Group"
105
  msgstr ""
@@ -108,11 +146,11 @@ msgstr ""
108
  msgid "Placement"
109
  msgstr ""
110
 
111
- #: classes/ad-debug.php:152 admin/includes/class-meta-box.php:67
112
  msgid "Display Conditions"
113
  msgstr ""
114
 
115
- #: classes/ad-debug.php:239 admin/includes/class-meta-box.php:70
116
  msgid "Visitor Conditions"
117
  msgstr ""
118
 
@@ -124,8 +162,8 @@ msgid ""
124
  msgstr ""
125
 
126
  #. %1$s is an anchor (link) opening tag, %2$s is the closing tag.
127
- #: classes/ad-health-notices.php:844
128
- #: modules/gadsense/includes/class-mapi.php:1388
129
  #, php-format
130
  msgid "Learn more about AdSense account issues %1$shere%2$s."
131
  msgstr ""
@@ -622,7 +660,7 @@ msgstr ""
622
  msgid "Everything is fine"
623
  msgstr ""
624
 
625
- #: classes/frontend_checks.php:394 admin/includes/class-ad-type.php:671
626
  #: admin/views/notices/welcome-panel.php:20
627
  msgid "Get help"
628
  msgstr ""
@@ -684,29 +722,29 @@ msgstr ""
684
  msgid "Display Ads and Ad Groups."
685
  msgstr ""
686
 
687
- #: classes/widget.php:71
688
  msgid "Title:"
689
  msgstr ""
690
 
691
- #: classes/widget.php:77 admin/includes/class-shortcode-creator.php:82
692
  #: modules/gutenberg/includes/class-gutenberg.php:77
693
  msgid "--empty--"
694
  msgstr ""
695
 
696
- #: classes/widget.php:79 admin/includes/class-menu.php:95
697
  #: admin/includes/class-shortcode-creator.php:98 admin/views/placements.php:26
698
  #: modules/gutenberg/includes/class-gutenberg.php:81
699
  #: modules/import-export/views/page.php:25
700
  msgid "Placements"
701
  msgstr ""
702
 
703
- #: classes/widget.php:86 admin/includes/class-shortcode-creator.php:91
704
  #: admin/views/placements-item.php:4 admin/views/placements.php:253
705
  #: modules/gutenberg/includes/class-gutenberg.php:80
706
  msgid "Ad Groups"
707
  msgstr ""
708
 
709
- #: classes/widget.php:93 public/class-advanced-ads.php:741
710
  #: admin/includes/class-menu.php:68 admin/includes/class-menu.php:68
711
  #: admin/includes/class-shortcode-creator.php:84
712
  #: admin/views/ad-group-list-form-row.php:90
@@ -743,70 +781,70 @@ msgstr ""
743
  msgid "Individual Posts, Pages and Public Post Types"
744
  msgstr ""
745
 
746
- #: public/class-advanced-ads.php:380
747
  msgid "Advanced Ads Error following:"
748
  msgstr ""
749
 
750
- #: public/class-advanced-ads.php:384
751
  #, php-format
752
  msgid "Advanced Ads Error: %s"
753
  msgstr ""
754
 
755
- #: public/class-advanced-ads.php:704
756
  msgctxt "ad group general name"
757
  msgid "Ad Groups & Rotations"
758
  msgstr ""
759
 
760
- #: public/class-advanced-ads.php:706
761
  msgid "Search Ad Groups"
762
  msgstr ""
763
 
764
- #: public/class-advanced-ads.php:707
765
  msgid "All Ad Groups"
766
  msgstr ""
767
 
768
- #: public/class-advanced-ads.php:708
769
  msgid "Parent Ad Groups"
770
  msgstr ""
771
 
772
- #: public/class-advanced-ads.php:709
773
  msgid "Parent Ad Groups:"
774
  msgstr ""
775
 
776
- #: public/class-advanced-ads.php:710
777
  msgid "Edit Ad Group"
778
  msgstr ""
779
 
780
- #: public/class-advanced-ads.php:711
781
  msgid "Update Ad Group"
782
  msgstr ""
783
 
784
- #: public/class-advanced-ads.php:712
785
  msgid "Add New Ad Group"
786
  msgstr ""
787
 
788
- #: public/class-advanced-ads.php:713
789
  msgid "New Ad Groups Name"
790
  msgstr ""
791
 
792
- #: public/class-advanced-ads.php:714 modules/import-export/views/page.php:24
793
  msgid "Groups"
794
  msgstr ""
795
 
796
- #: public/class-advanced-ads.php:715
797
  msgid "No Ad Group found"
798
  msgstr ""
799
 
800
- #: public/class-advanced-ads.php:743 public/class-advanced-ads.php:747
801
  #: admin/includes/class-menu.php:85 admin/views/ad-group-list-ads.php:28
802
  msgid "New Ad"
803
  msgstr ""
804
 
805
- #: public/class-advanced-ads.php:744 admin/includes/class-menu.php:85
806
  msgid "Add New Ad"
807
  msgstr ""
808
 
809
- #: public/class-advanced-ads.php:745
810
  #: admin/includes/class-ad-groups-list.php:313
811
  #: modules/import-export/classes/import.php:146
812
  #: modules/import-export/classes/import.php:186
@@ -814,35 +852,35 @@ msgstr ""
814
  msgid "Edit"
815
  msgstr ""
816
 
817
- #: public/class-advanced-ads.php:746
818
  msgid "Edit Ad"
819
  msgstr ""
820
 
821
- #: public/class-advanced-ads.php:748
822
  msgid "View"
823
  msgstr ""
824
 
825
- #: public/class-advanced-ads.php:749
826
  msgid "View the Ad"
827
  msgstr ""
828
 
829
- #: public/class-advanced-ads.php:750
830
  msgid "Search Ads"
831
  msgstr ""
832
 
833
- #: public/class-advanced-ads.php:751
834
  msgid "No Ads found"
835
  msgstr ""
836
 
837
- #: public/class-advanced-ads.php:752
838
  msgid "No Ads found in Trash"
839
  msgstr ""
840
 
841
- #: public/class-advanced-ads.php:753
842
  msgid "Parent Ad"
843
  msgstr ""
844
 
845
- #: public/class-advanced-ads.php:915
846
  msgctxt "label above ads"
847
  msgid "Advertisements"
848
  msgstr ""
@@ -983,6 +1021,13 @@ msgstr ""
983
  msgid "Learn how this might impact your ad setup."
984
  msgstr ""
985
 
 
 
 
 
 
 
 
986
  #: admin/includes/class-ad-groups-list.php:165
987
  msgid "Ad weight"
988
  msgstr ""
@@ -1065,86 +1110,86 @@ msgstr ""
1065
  msgid "No ad group created"
1066
  msgstr ""
1067
 
1068
- #: admin/includes/class-ad-type.php:83 admin/includes/class-ad-type.php:89
1069
  msgid "Ad Details"
1070
  msgstr ""
1071
 
1072
- #: admin/includes/class-ad-type.php:84 admin/includes/class-ad-type.php:90
1073
  msgid "Ad Planning"
1074
  msgstr ""
1075
 
1076
- #: admin/includes/class-ad-type.php:85 admin/includes/class-ad-type.php:91
1077
  msgid "Ad Shortcode"
1078
  msgstr ""
1079
 
1080
- #: admin/includes/class-ad-type.php:237
1081
  #, php-format
1082
  msgid "%s ad updated."
1083
  msgid_plural "%s ads updated."
1084
  msgstr[0] ""
1085
  msgstr[1] ""
1086
 
1087
- #: admin/includes/class-ad-type.php:238
1088
  #, php-format
1089
  msgid "%s ad not updated, somebody is editing it."
1090
  msgid_plural "%s ads not updated, somebody is editing them."
1091
  msgstr[0] ""
1092
  msgstr[1] ""
1093
 
1094
- #: admin/includes/class-ad-type.php:239
1095
  #, php-format
1096
  msgid "%s ad permanently deleted."
1097
  msgid_plural "%s ads permanently deleted."
1098
  msgstr[0] ""
1099
  msgstr[1] ""
1100
 
1101
- #: admin/includes/class-ad-type.php:240
1102
  #, php-format
1103
  msgid "%s ad moved to the Trash."
1104
  msgid_plural "%s ads moved to the Trash."
1105
  msgstr[0] ""
1106
  msgstr[1] ""
1107
 
1108
- #: admin/includes/class-ad-type.php:241
1109
  #, php-format
1110
  msgid "%s ad restored from the Trash."
1111
  msgid_plural "%s ads restored from the Trash."
1112
  msgstr[0] ""
1113
  msgstr[1] ""
1114
 
1115
- #: admin/includes/class-ad-type.php:571 admin/includes/class-ad-type.php:572
1116
  msgid "Ad updated."
1117
  msgstr ""
1118
 
1119
  #. translators: %s: date and time of the revision
1120
- #: admin/includes/class-ad-type.php:574
1121
  #, php-format
1122
  msgid "Ad restored to revision from %s"
1123
  msgstr ""
1124
 
1125
- #: admin/includes/class-ad-type.php:575 admin/includes/class-ad-type.php:576
1126
  msgid "Ad saved."
1127
  msgstr ""
1128
 
1129
- #: admin/includes/class-ad-type.php:577
1130
  msgid "Ad submitted."
1131
  msgstr ""
1132
 
1133
- #: admin/includes/class-ad-type.php:579
1134
  #, php-format
1135
  msgid "Ad scheduled for: <strong>%1$s</strong>."
1136
  msgstr ""
1137
 
1138
  #. translators: Publish box date format, see http://php.net/date
1139
- #: admin/includes/class-ad-type.php:581
1140
  msgid "M j, Y @ G:i"
1141
  msgstr ""
1142
 
1143
- #: admin/includes/class-ad-type.php:583
1144
  msgid "Ad draft updated."
1145
  msgstr ""
1146
 
1147
- #: admin/includes/class-ad-type.php:670
1148
  msgid ""
1149
  "You don’t have access to ads. Please deactivate and re-enable Advanced Ads "
1150
  "again to fix this."
@@ -1215,17 +1260,17 @@ msgid ""
1215
  "."
1216
  msgstr ""
1217
 
1218
- #: admin/includes/class-list-filters.php:140
1219
- #: modules/gadsense/admin/admin.php:29
1220
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:135
1221
  msgid "Responsive"
1222
  msgstr ""
1223
 
1224
- #: admin/includes/class-list-filters.php:149
1225
  msgid "expired"
1226
  msgstr ""
1227
 
1228
- #: admin/includes/class-list-filters.php:153
1229
  msgid "any expiry date"
1230
  msgstr ""
1231
 
@@ -1268,61 +1313,66 @@ msgstr ""
1268
  msgid "Ad Type"
1269
  msgstr ""
1270
 
1271
- #: admin/includes/class-meta-box.php:61
 
 
 
 
 
1272
  msgid "Ad Parameters"
1273
  msgstr ""
1274
 
1275
- #: admin/includes/class-meta-box.php:64 admin/includes/class-settings.php:66
1276
  msgid "Layout / Output"
1277
  msgstr ""
1278
 
1279
- #: admin/includes/class-meta-box.php:74
1280
  msgid "Increase your ad revenue"
1281
  msgstr ""
1282
 
1283
- #: admin/includes/class-meta-box.php:79
1284
  msgid "Ad Stats"
1285
  msgstr ""
1286
 
1287
- #: admin/includes/class-meta-box.php:140 admin/includes/class-meta-box.php:151
1288
- #: admin/includes/class-meta-box.php:156 admin/includes/class-settings.php:610
1289
  #: admin/views/ad-output-metabox.php:81
1290
  #: modules/ads-txt/admin/views/setting-create.php:11
1291
  #: modules/privacy/admin/views/setting-enable.php:2
1292
  msgid "Manual"
1293
  msgstr ""
1294
 
1295
- #: admin/includes/class-meta-box.php:150
1296
  msgid "Video"
1297
  msgstr ""
1298
 
1299
- #: admin/includes/class-meta-box.php:271
1300
  msgid "Ad Settings"
1301
  msgstr ""
1302
 
1303
- #: admin/includes/class-meta-box.php:373 admin/views/overview.php:6
1304
  msgid "Ads Dashboard"
1305
  msgstr ""
1306
 
1307
- #: admin/includes/class-meta-box.php:384
1308
  #, php-format
1309
  msgid "%d ads – <a href=\"%s\">manage</a> - <a href=\"%s\">new</a>"
1310
  msgstr ""
1311
 
1312
- #: admin/includes/class-meta-box.php:395
1313
  msgid "Get the tutorial via email"
1314
  msgstr ""
1315
 
1316
- #: admin/includes/class-meta-box.php:402
1317
  msgid "Get AdSense tips via email"
1318
  msgstr ""
1319
 
1320
- #: admin/includes/class-meta-box.php:409
1321
  msgid "Visit our blog for more articles about ad optimization"
1322
  msgstr ""
1323
 
1324
  #. %s is our URL
1325
- #: admin/includes/class-meta-box.php:462
1326
  msgid "Latest posts on wpadvancedads.com"
1327
  msgstr ""
1328
 
@@ -1346,220 +1396,218 @@ msgid ""
1346
  "href=\"%s\" target=\"_blank\">this form</a> to sign up."
1347
  msgstr ""
1348
 
1349
- #: admin/includes/class-overview-widgets.php:33
1350
  msgid "Next steps"
1351
  msgstr ""
1352
 
1353
- #: admin/includes/class-overview-widgets.php:35
1354
  msgid "Manual and Support"
1355
  msgstr ""
1356
 
1357
- #: admin/includes/class-overview-widgets.php:86
1358
  #: admin/views/notices/welcome-panel.php:6
1359
  msgid "Create your first ad"
1360
  msgstr ""
1361
 
1362
- #: admin/includes/class-overview-widgets.php:89
1363
  #: modules/gadsense/admin/views/adsense-account.php:71
1364
  #: modules/gadsense/admin/views/adsense-account.php:89
1365
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:94
1366
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:96
1367
  msgid "Connect to AdSense"
1368
  msgstr ""
1369
 
1370
- #: admin/includes/class-overview-widgets.php:99
1371
  msgid "Join the newsletter for more benefits"
1372
  msgstr ""
1373
 
1374
- #: admin/includes/class-overview-widgets.php:101
1375
  msgid "Get 2 free add-ons"
1376
  msgstr ""
1377
 
1378
- #: admin/includes/class-overview-widgets.php:102
1379
  msgid "Get the first steps and more tutorials to your inbox"
1380
  msgstr ""
1381
 
1382
- #: admin/includes/class-overview-widgets.php:103
1383
  msgid "How to earn more with AdSense"
1384
  msgstr ""
1385
 
1386
- #: admin/includes/class-overview-widgets.php:106
1387
  msgid "Join now"
1388
  msgstr ""
1389
 
1390
- #: admin/includes/class-overview-widgets.php:114
1391
  msgid ""
1392
  "Do you find Advanced Ads useful and would like to keep us motivated? Please "
1393
  "help us with a review."
1394
  msgstr ""
1395
 
1396
- #: admin/includes/class-overview-widgets.php:116
1397
  msgid "Sure, I’ll rate the plugin"
1398
  msgstr ""
1399
 
1400
- #: admin/includes/class-overview-widgets.php:118
1401
  msgid "I already did"
1402
  msgstr ""
1403
 
1404
- #: admin/includes/class-overview-widgets.php:124
1405
  msgid "Manage your ads"
1406
  msgstr ""
1407
 
1408
- #: admin/includes/class-overview-widgets.php:128
1409
  msgid "Get the All Access pass"
1410
  msgstr ""
1411
 
1412
- #: admin/includes/class-overview-widgets.php:154
1413
  #: admin/views/notices/welcome-panel.php:22
1414
  #, php-format
1415
  msgid "<a href=\"%s\" target=\"_blank\">Manual</a>"
1416
  msgstr ""
1417
 
1418
- #: admin/includes/class-overview-widgets.php:155
1419
  #, php-format
1420
  msgid "<a href=\"%s\" target=\"_blank\">FAQ and Support</a>"
1421
  msgstr ""
1422
 
1423
  #. %s includes a number and markup like <span class="count">6</span>.
1424
- #: admin/includes/class-overview-widgets.php:164
1425
  #: admin/views/overview-notices.php:17
1426
  #, php-format
1427
  msgid "Show %s hidden notices"
1428
  msgstr ""
1429
 
1430
- #: admin/includes/class-overview-widgets.php:182
1431
  msgid "The solution for professional websites."
1432
  msgstr ""
1433
 
1434
- #: admin/includes/class-overview-widgets.php:185
1435
  #: admin/views/pitch-pro-tab.php:7
1436
  msgid "support for cached sites"
1437
  msgstr ""
1438
 
1439
- #: admin/includes/class-overview-widgets.php:188
1440
- #: admin/includes/class-overview-widgets.php:189
1441
- #: admin/includes/class-overview-widgets.php:190
1442
- #: admin/includes/class-overview-widgets.php:191
1443
  #, php-format
1444
  msgid "integrates with <strong>%s</strong>"
1445
  msgstr ""
1446
 
1447
- #: admin/includes/class-overview-widgets.php:192
1448
  msgid "click fraud protection, lazy load, ad-block ads"
1449
  msgstr ""
1450
 
1451
- #: admin/includes/class-overview-widgets.php:193
1452
  #: admin/views/pitch-pro-tab.php:8
1453
  msgid "11 more display and visitor conditions"
1454
  msgstr ""
1455
 
1456
- #: admin/includes/class-overview-widgets.php:194
1457
  #: admin/views/pitch-pro-tab.php:9
1458
  msgid "6 more placements"
1459
  msgstr ""
1460
 
1461
- #: admin/includes/class-overview-widgets.php:195
1462
  #: admin/views/pitch-pro-tab.php:10
1463
  msgid "placement tests for ad optimization"
1464
  msgstr ""
1465
 
1466
- #: admin/includes/class-overview-widgets.php:196
1467
  #: admin/views/pitch-pro-tab.php:11
1468
  msgid "ad grids and many more advanced features"
1469
  msgstr ""
1470
 
1471
- #: admin/includes/class-overview-widgets.php:203
1472
  msgid ""
1473
  "Analyze clicks and impressions of your ads locally or in Google Analytics, "
1474
  "share reports, and limit ads to a specific number of impressions or clicks."
1475
  msgstr ""
1476
 
1477
- #: admin/includes/class-overview-widgets.php:209
1478
  msgid ""
1479
  "Display ads based on the device or the size of your visitor’s browser, and "
1480
  "control ads on AMP pages."
1481
  msgstr ""
1482
 
1483
- #: admin/includes/class-overview-widgets.php:222
1484
  msgid ""
1485
  "Earn more money and let advertisers pay for ad space directly on the "
1486
  "frontend of your site."
1487
  msgstr ""
1488
 
1489
- #: admin/includes/class-overview-widgets.php:228
1490
  msgid ""
1491
  "Target visitors with ads that match their geo location and make more money "
1492
  "with regional campaigns."
1493
  msgstr ""
1494
 
1495
- #: admin/includes/class-overview-widgets.php:234
1496
  msgid ""
1497
  "Increase click rates on your ads by placing them in sticky positions above, "
1498
  "next or below your site."
1499
  msgstr ""
1500
 
1501
- #: admin/includes/class-overview-widgets.php:240
1502
  msgid ""
1503
  "Users will never miss an ad or other information in a PopUp. Choose when it "
1504
  "shows up and for how long a user can close it."
1505
  msgstr ""
1506
 
1507
- #: admin/includes/class-overview-widgets.php:246
1508
  msgid ""
1509
  "Create a beautiful and simple slider from your ads to show more information "
1510
  "on less space."
1511
  msgstr ""
1512
 
1513
- #: admin/includes/class-overview-widgets.php:252
1514
  msgid ""
1515
  "Place AdSense In-feed ads between posts on homepage, category, and archive "
1516
  "pages."
1517
  msgstr ""
1518
 
1519
- #: admin/includes/class-overview-widgets.php:255
1520
- #: admin/includes/class-overview-widgets.php:430
1521
- #: admin/includes/class-overview-widgets.php:446
1522
  msgid "Install now"
1523
  msgstr ""
1524
 
1525
- #: admin/includes/class-overview-widgets.php:273
1526
- #: admin/includes/class-overview-widgets.php:294
1527
- #: admin/includes/class-overview-widgets.php:319
1528
- #: admin/includes/class-overview-widgets.php:337
1529
- #: admin/includes/class-overview-widgets.php:355
1530
- #: admin/includes/class-overview-widgets.php:373
1531
- #: admin/includes/class-overview-widgets.php:391
1532
- #: admin/includes/class-overview-widgets.php:409
1533
  msgid "Activate now"
1534
  msgstr ""
1535
 
1536
- #: admin/includes/class-overview-widgets.php:302
1537
  msgid "Visit your ad stats"
1538
  msgstr ""
1539
 
1540
- #: admin/includes/class-overview-widgets.php:426
1541
  msgid "Use Genesis specific ad positions."
1542
  msgstr ""
1543
 
1544
- #: admin/includes/class-overview-widgets.php:442
1545
  msgid ""
1546
  "Manage ad positions with WPBakery Page Builder (formerly Visual Composer)."
1547
  msgstr ""
1548
 
1549
- #: admin/includes/class-overview-widgets.php:458
1550
  msgid "Our best deal with all add-ons included."
1551
  msgstr ""
1552
 
1553
- #: admin/includes/class-overview-widgets.php:460
1554
  msgid "Get full access"
1555
  msgstr ""
1556
 
1557
- #: admin/includes/class-overview-widgets.php:474
1558
  #: admin/views/ad-display-metabox.php:48 admin/views/ad-visitor-metabox.php:48
1559
  msgid "Visit the manual"
1560
  msgstr ""
1561
 
1562
- #: admin/includes/class-overview-widgets.php:477
1563
  msgid "Get this add-on"
1564
  msgstr ""
1565
 
@@ -1948,7 +1996,7 @@ msgid "Forced to OR."
1948
  msgstr ""
1949
 
1950
  #: admin/views/ad-display-metabox.php:104
1951
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:142
1952
  msgid "manual"
1953
  msgstr ""
1954
 
@@ -2013,14 +2061,14 @@ msgid "weight"
2013
  msgstr ""
2014
 
2015
  #: admin/views/ad-group-list-form-row.php:29 admin/views/placements.php:32
2016
- #: modules/gadsense/admin/views/mapi-ad-selector.php:42
2017
- #: modules/gadsense/admin/views/mapi-ad-selector.php:54
2018
  #: modules/privacy/admin/views/setting-consent-method.php:9
2019
  msgid "Name"
2020
  msgstr ""
2021
 
2022
  #: admin/views/ad-group-list-form-row.php:55 admin/views/placements.php:31
2023
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:131
2024
  msgid "Type"
2025
  msgstr ""
2026
 
@@ -2075,20 +2123,20 @@ msgstr ""
2075
  msgid "Ad Groups successfully updated"
2076
  msgstr ""
2077
 
2078
- #: admin/views/ad-group.php:63
2079
  #, php-format
2080
  msgid "Search results for &#8220;%s&#8221;"
2081
  msgstr ""
2082
 
2083
- #: admin/views/ad-group.php:70
2084
  msgid "Group title"
2085
  msgstr ""
2086
 
2087
- #: admin/views/ad-group.php:71
2088
  msgid "save"
2089
  msgstr ""
2090
 
2091
- #: admin/views/ad-group.php:73
2092
  msgid ""
2093
  "Ad Groups are a very flexible method to bundle ads. You can use them to "
2094
  "display random ads in the frontend or run split tests, but also just for "
@@ -2096,14 +2144,14 @@ msgid ""
2096
  "ad can belong to multiple ad groups."
2097
  msgstr ""
2098
 
2099
- #: admin/views/ad-group.php:79
2100
  #, php-format
2101
  msgid ""
2102
  "Find more information about ad groups in the <a href=\"%s\" "
2103
  "target=\"_blank\">manual</a>."
2104
  msgstr ""
2105
 
2106
- #: admin/views/ad-group.php:107
2107
  msgid "Update Groups"
2108
  msgstr ""
2109
 
@@ -2214,6 +2262,7 @@ msgstr ""
2214
  #: admin/views/placements-ad-label-position.php:5
2215
  #: admin/views/placements-ad-label.php:1 admin/views/placements-ad-label.php:4
2216
  #: admin/views/placements.php:74
 
2217
  msgid "default"
2218
  msgstr ""
2219
 
@@ -2522,6 +2571,10 @@ msgstr ""
2522
  msgid "Disabling the plugin now…"
2523
  msgstr ""
2524
 
 
 
 
 
2525
  #: admin/views/pitch-bundle.php:1
2526
  msgid "All Access – with all available add-ons"
2527
  msgstr ""
@@ -2593,7 +2646,7 @@ msgid "Where do you want to display the ad?"
2593
  msgstr ""
2594
 
2595
  #: admin/views/placement-injection-top.php:24
2596
- #: modules/gadsense/admin/admin.php:464
2597
  #, php-format
2598
  msgid ""
2599
  "The AdSense verification and Auto ads code is already activated in the <a "
@@ -2601,7 +2654,7 @@ msgid ""
2601
  msgstr ""
2602
 
2603
  #: admin/views/placement-injection-top.php:30
2604
- #: modules/gadsense/admin/admin.php:466
2605
  msgid ""
2606
  "No need to add the code manually here, unless you want to include it into "
2607
  "certain pages only."
@@ -3025,10 +3078,6 @@ msgid ""
3025
  "for individual help."
3026
  msgstr ""
3027
 
3028
- #: modules/gadsense/main.php:19
3029
- msgid " at "
3030
- msgstr ""
3031
-
3032
  #: public/views/ad-debug.php:20
3033
  msgid "Ad debug output"
3034
  msgstr ""
@@ -3152,113 +3201,7 @@ msgid ""
3152
  "to the ads.txt file of the root domain: %s"
3153
  msgstr ""
3154
 
3155
- #: modules/gadsense/admin/admin.php:135
3156
- msgid "AdSense account"
3157
- msgstr ""
3158
-
3159
- #: modules/gadsense/admin/admin.php:144
3160
- msgid "Verification code & Auto ads"
3161
- msgstr ""
3162
-
3163
- #: modules/gadsense/admin/admin.php:153
3164
- msgid "Auto ads"
3165
- msgstr ""
3166
-
3167
- #: modules/gadsense/admin/admin.php:153
3168
- msgid "Disable top anchor ad"
3169
- msgstr ""
3170
-
3171
- #: modules/gadsense/admin/admin.php:165
3172
- msgid "Limit to 3 ads"
3173
- msgstr ""
3174
-
3175
- #: modules/gadsense/admin/admin.php:175
3176
- msgid "Disable violation warnings"
3177
- msgstr ""
3178
-
3179
- #: modules/gadsense/admin/admin.php:183
3180
- msgid "Transparent background"
3181
- msgstr ""
3182
-
3183
- #: modules/gadsense/admin/admin.php:241
3184
- #, php-format
3185
- msgid "Limit to %d AdSense ads"
3186
- msgstr ""
3187
-
3188
- #: modules/gadsense/admin/admin.php:245
3189
- msgid ""
3190
- "There is no explicit limit for AdSense ads anymore, but you can still use "
3191
- "this setting to prevent too many AdSense ads to show accidentally on your "
3192
- "site."
3193
- msgstr ""
3194
-
3195
- #: modules/gadsense/admin/admin.php:249
3196
- msgid ""
3197
- "Due to technical restrictions, the limit does not work on placements with "
3198
- "cache-busting enabled."
3199
- msgstr ""
3200
-
3201
- #: modules/gadsense/admin/admin.php:261
3202
- msgid ""
3203
- "Enable this box if you don’t want Google Auto ads to place anchor ads at the "
3204
- "top of your page."
3205
- msgstr ""
3206
-
3207
- #: modules/gadsense/admin/admin.php:276
3208
- #: modules/gadsense/admin/views/connect-adsense.php:37
3209
- msgid ""
3210
- "Insert the AdSense header code used for verification and the Auto Ads "
3211
- "feature."
3212
- msgstr ""
3213
-
3214
- #. this is the text for a link to a sub-page in an AdSense account
3215
- #: modules/gadsense/admin/admin.php:281
3216
- msgid "Adjust Auto ads options"
3217
- msgstr ""
3218
-
3219
- #: modules/gadsense/admin/admin.php:283
3220
- #, php-format
3221
- msgid ""
3222
- "Please read <a href=\"%s\" target=\"_blank\">this article</a> if <strong>ads "
3223
- "appear in random places</strong>."
3224
- msgstr ""
3225
-
3226
- #: modules/gadsense/admin/admin.php:284
3227
- msgid "Display Auto ads only on specific pages"
3228
- msgstr ""
3229
-
3230
- #: modules/gadsense/admin/admin.php:285
3231
- msgid "Auto ads on AMP pages"
3232
- msgstr ""
3233
-
3234
- #: modules/gadsense/admin/admin.php:298
3235
- msgid "Disable warnings about potential violations of the AdSense terms."
3236
- msgstr ""
3237
-
3238
- #: modules/gadsense/admin/admin.php:299
3239
- #, php-format
3240
- msgid ""
3241
- "Our <a href=\"%s\" target=\"_blank\">Ad Health</a> feature monitors if "
3242
- "AdSense is implemented correctly on your site. It also considers ads not "
3243
- "managed with Advanced Ads. Enable this option to remove these checks"
3244
- msgstr ""
3245
-
3246
- #: modules/gadsense/admin/admin.php:310
3247
- msgid ""
3248
- "Enable this option in case your theme adds an unfortunate background color "
3249
- "to AdSense ads."
3250
- msgstr ""
3251
-
3252
- #: modules/gadsense/admin/admin.php:333
3253
- #: modules/gadsense/includes/class-ad-type-adsense.php:76
3254
- msgid "The Publisher ID has an incorrect format. (must start with \"pub-\")"
3255
- msgstr ""
3256
-
3257
- #: modules/gadsense/admin/admin.php:355
3258
- msgid "AdSense"
3259
- msgstr ""
3260
-
3261
- #: modules/gadsense/admin/admin.php:407
3262
  #, php-format
3263
  msgid ""
3264
  "Responsive AdSense ads don’t work reliably with <em>Position</em> set to "
@@ -3267,14 +3210,14 @@ msgid ""
3267
  "wrapped in text."
3268
  msgstr ""
3269
 
3270
- #: modules/gadsense/admin/admin.php:413
3271
  #, php-format
3272
  msgid ""
3273
  "<a href=\"%s\" target=\"_blank\">Install the free AdSense In-feed add-on</a> "
3274
  "in order to place ads between posts."
3275
  msgstr ""
3276
 
3277
- #: modules/gadsense/admin/admin.php:420
3278
  #, php-format
3279
  msgid ""
3280
  "Use the <a href=\"%s\" target=\"_blank\">Responsive add-on</a> in order to "
@@ -3282,7 +3225,7 @@ msgid ""
3282
  "vertical, or rectangle formats."
3283
  msgstr ""
3284
 
3285
- #: modules/gadsense/admin/admin.php:468
3286
  #, php-format
3287
  msgid ""
3288
  "The AdSense verification and Auto ads code should be set up in the <a "
@@ -3290,10 +3233,14 @@ msgid ""
3290
  "now."
3291
  msgstr ""
3292
 
3293
- #: modules/gadsense/admin/admin.php:469
3294
  msgid "Activate"
3295
  msgstr ""
3296
 
 
 
 
 
3297
  #: modules/gadsense/includes/class-ad-type-adsense.php:35
3298
  msgid "AdSense ad"
3299
  msgstr ""
@@ -3302,10 +3249,20 @@ msgstr ""
3302
  msgid "Use ads from your Google AdSense account"
3303
  msgstr ""
3304
 
3305
- #: modules/gadsense/includes/class-ad-type-adsense.php:112
 
 
 
 
 
3306
  msgid "Your AdSense Publisher ID is missing."
3307
  msgstr ""
3308
 
 
 
 
 
 
3309
  #: modules/gadsense/includes/class-gadsense-data.php:40
3310
  msgid "Auto"
3311
  msgstr ""
@@ -3315,74 +3272,207 @@ msgstr ""
3315
  msgid "Error while retrieving ad code for \"%s\"."
3316
  msgstr ""
3317
 
3318
- #: modules/gadsense/includes/class-mapi.php:361
3319
  #, php-format
3320
  msgid "Invalid response while retrieving ad code for \"%s\"."
3321
  msgstr ""
3322
 
3323
- #: modules/gadsense/includes/class-mapi.php:402
3324
  #, php-format
3325
  msgid "Error while retrieving adUnits list for \"%s\"."
3326
  msgstr ""
3327
 
3328
- #: modules/gadsense/includes/class-mapi.php:411
3329
  #, php-format
3330
  msgid "Invalid response while retrieving adUnits list for \"%s\"."
3331
  msgstr ""
3332
 
 
 
 
 
 
 
 
 
3333
  #. %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.
3334
- #: modules/gadsense/includes/class-mapi.php:420
3335
  #, php-format
3336
  msgid ""
3337
  "The account \"%1$s\" does not seem to have any ad units. Please create some "
3338
  "%2$shere%3$s."
3339
  msgstr ""
3340
 
3341
- #: modules/gadsense/includes/class-mapi.php:482
3342
  msgid ""
3343
  "It seems that some changes have been made in the Advanced Ads settings. "
3344
  "Please refresh this page."
3345
  msgstr ""
3346
 
3347
- #: modules/gadsense/includes/class-mapi.php:489
3348
  #, php-format
3349
  msgid ""
3350
  "Advanced Ads does not have access to your account (<code>%s</code>) anymore."
3351
  msgstr ""
3352
 
3353
- #: modules/gadsense/includes/class-mapi.php:531
3354
  #, php-format
3355
  msgid "error while renewing access token for \"%s\""
3356
  msgstr ""
3357
 
3358
- #: modules/gadsense/includes/class-mapi.php:553
3359
  #, php-format
3360
  msgid "invalid response received while renewing access token for \"%s\""
3361
  msgstr ""
3362
 
3363
- #: modules/gadsense/includes/class-mapi.php:778
3364
  msgid "Invalid response body while retrieving account alerts"
3365
  msgstr ""
3366
 
3367
- #: modules/gadsense/includes/class-mapi.php:787
3368
  msgid "error while retrieving account alerts"
3369
  msgstr ""
3370
 
3371
- #: modules/gadsense/includes/class-mapi.php:941
3372
  msgid "No token provided. Token data needed to get account details."
3373
  msgstr ""
3374
 
3375
- #: modules/gadsense/includes/class-mapi.php:1006
3376
  msgid "An error occurred while requesting account details."
3377
  msgstr ""
3378
 
3379
- #: modules/gadsense/includes/class-mapi.php:1355
3380
  #, php-format
3381
  msgid ""
3382
  "There are one or more warnings about the currently linked AdSense account. "
3383
  "You can view them <a href=\"%s\">here</a>"
3384
  msgstr ""
3385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3386
  #. Name of the plugin
3387
  #: modules/gutenberg/includes/class-gutenberg.php:78
3388
  msgid "Advanced Ads"
@@ -3710,114 +3800,106 @@ msgid ""
3710
  msgstr ""
3711
 
3712
  #: modules/gadsense/admin/views/adsense-account.php:152
3713
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:102
3714
  msgid "Can not connect AdSense account. PHP version is too low."
3715
  msgstr ""
3716
 
3717
  #. this is a label for an ad that we can currently not import from the AdSense account
3718
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:49
3719
- #: modules/gadsense/admin/views/mapi-ad-selector.php:86
3720
- #: modules/gadsense/admin/views/mapi-ad-selector.php:95
3721
  msgid "unsupported"
3722
  msgstr ""
3723
 
3724
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:59
3725
  msgid "The ad details couldn't be retrieved from the ad code"
3726
  msgstr ""
3727
 
3728
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:60
3729
  msgid ""
3730
  "Warning: The AdSense account from this code does not match the one set in "
3731
  "the Advanced Ads options."
3732
  msgstr ""
3733
 
3734
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:68
3735
  msgid ""
3736
  "Copy the ad code from your AdSense account, paste it into the area below and "
3737
  "click on <em>Get details</em>."
3738
  msgstr ""
3739
 
3740
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:70
3741
  msgid "Get details"
3742
  msgstr ""
3743
 
3744
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:71
3745
  msgid "cancel"
3746
  msgstr ""
3747
 
3748
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:73
3749
  msgid "connect to your AdSense account"
3750
  msgstr ""
3751
 
3752
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:84
3753
- msgid "Insert new AdSense code"
3754
- msgstr ""
3755
-
3756
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:89
3757
- msgid "Get ad code from your linked account"
3758
- msgstr ""
3759
-
3760
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:108
3761
  msgid "Ad Slot ID"
3762
  msgstr ""
3763
 
3764
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:113
3765
  #, php-format
3766
  msgid "Publisher ID: %s"
3767
  msgstr ""
3768
 
3769
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:117
3770
  msgid ""
3771
  "The ad slot ID is either a number or empty and not the same as the publisher "
3772
  "ID."
3773
  msgstr ""
3774
 
3775
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:128
3776
  #, php-format
3777
  msgid "Please <a href=\"%s\" target=\"_blank\">change it here</a>."
3778
  msgstr ""
3779
 
3780
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:134
3781
  msgid "Normal"
3782
  msgstr ""
3783
 
3784
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:136
3785
  msgid "Responsive (Matched Content)"
3786
  msgstr ""
3787
 
3788
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:137
3789
  msgid "Link ads"
3790
  msgstr ""
3791
 
3792
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:138
3793
  msgid "Link ads (Responsive)"
3794
  msgstr ""
3795
 
3796
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:139
3797
  msgid "InArticle"
3798
  msgstr ""
3799
 
3800
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:140
3801
  msgid "InFeed"
3802
  msgstr ""
3803
 
3804
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:145
3805
  msgid "Resizing"
3806
  msgstr ""
3807
 
3808
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:153
3809
  msgid "Layout"
3810
  msgstr ""
3811
 
3812
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:157
3813
  msgid "Layout-Key"
3814
  msgstr ""
3815
 
3816
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:162
3817
  msgid "Clearfix"
3818
  msgstr ""
3819
 
3820
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:165
3821
  msgid "Enable this box if responsive ads cover something on your site"
3822
  msgstr ""
3823
 
@@ -3841,83 +3923,97 @@ msgstr ""
3841
  msgid "Use this account"
3842
  msgstr ""
3843
 
3844
- #: modules/gadsense/admin/views/mapi-ad-selector.php:27
3845
- msgid "Show inactive ads"
 
 
3846
  msgstr ""
3847
 
3848
- #: modules/gadsense/admin/views/mapi-ad-selector.php:29
3849
- msgid "Hide inactive ads"
 
 
 
 
 
 
 
 
 
 
 
 
3850
  msgstr ""
3851
 
3852
- #: modules/gadsense/admin/views/mapi-ad-selector.php:33
3853
- #: modules/gadsense/admin/views/mapi-ad-selector.php:64
3854
  msgid "Update the ad units list"
3855
  msgstr ""
3856
 
3857
- #: modules/gadsense/admin/views/mapi-ad-selector.php:41
3858
- #: modules/gadsense/admin/views/mapi-ad-selector.php:53
3859
  msgctxt "AdSense ad"
3860
  msgid "Ad unit"
3861
  msgstr ""
3862
 
3863
- #: modules/gadsense/admin/views/mapi-ad-selector.php:43
3864
- #: modules/gadsense/admin/views/mapi-ad-selector.php:55
3865
  msgctxt "AdSense ad"
3866
  msgid "Slot ID"
3867
  msgstr ""
3868
 
3869
- #: modules/gadsense/admin/views/mapi-ad-selector.php:44
3870
- #: modules/gadsense/admin/views/mapi-ad-selector.php:56
3871
  msgctxt "AdSense ad"
3872
  msgid "Type"
3873
  msgstr ""
3874
 
3875
- #: modules/gadsense/admin/views/mapi-ad-selector.php:45
3876
- #: modules/gadsense/admin/views/mapi-ad-selector.php:57
3877
  msgid "Size"
3878
  msgstr ""
3879
 
3880
- #: modules/gadsense/admin/views/mapi-ad-selector.php:63
3881
  msgid "No ad units found"
3882
  msgstr ""
3883
 
3884
- #: modules/gadsense/admin/views/mapi-ad-selector.php:72
3885
  msgid "Get the code for this ad"
3886
  msgstr ""
3887
 
3888
- #: modules/gadsense/admin/views/mapi-ad-selector.php:73
3889
  msgid "Update and get the code for this ad from Google"
3890
  msgstr ""
3891
 
3892
- #: modules/gadsense/admin/views/mapi-ad-selector.php:108
3893
  msgid "Unrecognized ad code"
3894
  msgstr ""
3895
 
3896
- #: modules/gadsense/admin/views/mapi-ad-selector.php:111
3897
  msgid "This ad type can currently not be imported from AdSense."
3898
  msgstr ""
3899
 
3900
- #: modules/gadsense/admin/views/mapi-ad-selector.php:112
3901
  msgid "Learn more and help us to enable it here."
3902
  msgstr ""
3903
 
3904
- #: modules/gadsense/admin/views/mapi-ad-selector.php:113
3905
  msgid "In the meantime, you can use AdSense with one of these methods:"
3906
  msgstr ""
3907
 
3908
- #: modules/gadsense/admin/views/mapi-ad-selector.php:115
3909
  msgid ""
3910
  "Click on <em>Insert new AdSense code</em> and copy the code from your "
3911
  "AdSense account into it."
3912
  msgstr ""
3913
 
3914
- #: modules/gadsense/admin/views/mapi-ad-selector.php:116
3915
  msgid ""
3916
  "Create an ad on the fly. Just select the <em>Normal</em> or <em>"
3917
  "Responsive</em> type and the size."
3918
  msgstr ""
3919
 
3920
- #: modules/gadsense/admin/views/mapi-ad-selector.php:117
3921
  msgid ""
3922
  "Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from "
3923
  "your AdSense account."
3
  msgstr ""
4
  "Project-Id-Version: Advanved Ads\n"
5
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
6
+ "POT-Creation-Date: 2019-07-01 12:37+0000\n"
7
  "POT-Revision-Date: Wed Jul 13 2016 13:23:05 GMT+0200 (CEST)\n"
8
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9
  "Last-Translator: Thomas Maier <post@webzunft.de>\n"
25
 
26
  #: admin/class-advanced-ads-admin.php:222 classes/display-conditions.php:215
27
  #: classes/visitor-conditions.php:242 admin/views/ad-display-metabox.php:189
28
+ #: modules/gadsense/admin/views/external-ads-links.php:17
29
+ #: modules/gadsense/admin/views/external-ads-links.php:21
30
+ #: modules/gadsense/admin/views/external-ads-links.php:28
31
  msgid "or"
32
  msgstr ""
33
 
40
  msgid "After which paragraph?"
41
  msgstr ""
42
 
43
+ #: admin/class-advanced-ads-admin.php:226
44
+ msgid "Today"
45
+ msgstr ""
46
+
47
+ #: admin/class-advanced-ads-admin.php:227
48
+ msgid "Yesterday"
49
+ msgstr ""
50
+
51
+ #: admin/class-advanced-ads-admin.php:228
52
+ msgid "This Month"
53
+ msgstr ""
54
+
55
+ #. 1: The number of days.
56
+ #: admin/class-advanced-ads-admin.php:230
57
+ #, php-format
58
+ msgid "Last %1$d days"
59
+ msgstr ""
60
+
61
+ #: admin/class-advanced-ads-admin.php:233
62
+ msgid "All"
63
+ msgstr ""
64
+
65
+ #: admin/class-advanced-ads-admin.php:234
66
+ msgid ""
67
+ "There were no results returned for this ad. Please make sure it is active, "
68
+ "generating impressions and double check your ad parameters."
69
+ msgstr ""
70
+
71
+ #: admin/class-advanced-ads-admin.php:235
72
+ #: modules/gadsense/admin/views/external-ads-list.php:12
73
+ msgid "Show inactive ads"
74
+ msgstr ""
75
+
76
+ #: admin/class-advanced-ads-admin.php:236
77
+ msgid "Hide inactive ads"
78
+ msgstr ""
79
+
80
+ #: admin/class-advanced-ads-admin.php:347
81
  #, php-format
82
  msgid "time of %s"
83
  msgstr ""
84
 
85
+ #: admin/class-advanced-ads-admin.php:412 admin/includes/class-menu.php:113
86
  #: admin/includes/class-menu.php:116 admin/views/settings.php:28
87
  msgid "Support"
88
  msgstr ""
89
 
90
+ #: admin/class-advanced-ads-admin.php:416
91
+ #: admin/includes/class-overview-widgets.php:55
92
  msgid "Add-Ons"
93
  msgstr ""
94
 
95
+ #: admin/class-advanced-ads-admin.php:682
96
+ #: admin/includes/class-overview-widgets.php:172
97
  #, php-format
98
  msgid ""
99
  "Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a "
133
  msgstr ""
134
 
135
  #: classes/ad-debug.php:118 classes/ad-debug.php:167 classes/ad-debug.php:169
136
+ #: public/class-advanced-ads.php:739 admin/views/ad-group-list-ads.php:13
137
  msgid "Ad"
138
  msgstr ""
139
 
140
+ #: classes/ad-debug.php:121 public/class-advanced-ads.php:702
141
  msgctxt "ad group singular name"
142
  msgid "Ad Group"
143
  msgstr ""
146
  msgid "Placement"
147
  msgstr ""
148
 
149
+ #: classes/ad-debug.php:152 admin/includes/class-meta-box.php:78
150
  msgid "Display Conditions"
151
  msgstr ""
152
 
153
+ #: classes/ad-debug.php:239 admin/includes/class-meta-box.php:81
154
  msgid "Visitor Conditions"
155
  msgstr ""
156
 
162
  msgstr ""
163
 
164
  #. %1$s is an anchor (link) opening tag, %2$s is the closing tag.
165
+ #: classes/ad-health-notices.php:849
166
+ #: modules/gadsense/includes/class-mapi.php:1407
167
  #, php-format
168
  msgid "Learn more about AdSense account issues %1$shere%2$s."
169
  msgstr ""
660
  msgid "Everything is fine"
661
  msgstr ""
662
 
663
+ #: classes/frontend_checks.php:394 admin/includes/class-ad-type.php:674
664
  #: admin/views/notices/welcome-panel.php:20
665
  msgid "Get help"
666
  msgstr ""
722
  msgid "Display Ads and Ad Groups."
723
  msgstr ""
724
 
725
+ #: classes/widget.php:70
726
  msgid "Title:"
727
  msgstr ""
728
 
729
+ #: classes/widget.php:76 admin/includes/class-shortcode-creator.php:82
730
  #: modules/gutenberg/includes/class-gutenberg.php:77
731
  msgid "--empty--"
732
  msgstr ""
733
 
734
+ #: classes/widget.php:78 admin/includes/class-menu.php:95
735
  #: admin/includes/class-shortcode-creator.php:98 admin/views/placements.php:26
736
  #: modules/gutenberg/includes/class-gutenberg.php:81
737
  #: modules/import-export/views/page.php:25
738
  msgid "Placements"
739
  msgstr ""
740
 
741
+ #: classes/widget.php:85 admin/includes/class-shortcode-creator.php:91
742
  #: admin/views/placements-item.php:4 admin/views/placements.php:253
743
  #: modules/gutenberg/includes/class-gutenberg.php:80
744
  msgid "Ad Groups"
745
  msgstr ""
746
 
747
+ #: classes/widget.php:92 public/class-advanced-ads.php:738
748
  #: admin/includes/class-menu.php:68 admin/includes/class-menu.php:68
749
  #: admin/includes/class-shortcode-creator.php:84
750
  #: admin/views/ad-group-list-form-row.php:90
781
  msgid "Individual Posts, Pages and Public Post Types"
782
  msgstr ""
783
 
784
+ #: public/class-advanced-ads.php:377
785
  msgid "Advanced Ads Error following:"
786
  msgstr ""
787
 
788
+ #: public/class-advanced-ads.php:381
789
  #, php-format
790
  msgid "Advanced Ads Error: %s"
791
  msgstr ""
792
 
793
+ #: public/class-advanced-ads.php:701
794
  msgctxt "ad group general name"
795
  msgid "Ad Groups & Rotations"
796
  msgstr ""
797
 
798
+ #: public/class-advanced-ads.php:703
799
  msgid "Search Ad Groups"
800
  msgstr ""
801
 
802
+ #: public/class-advanced-ads.php:704
803
  msgid "All Ad Groups"
804
  msgstr ""
805
 
806
+ #: public/class-advanced-ads.php:705
807
  msgid "Parent Ad Groups"
808
  msgstr ""
809
 
810
+ #: public/class-advanced-ads.php:706
811
  msgid "Parent Ad Groups:"
812
  msgstr ""
813
 
814
+ #: public/class-advanced-ads.php:707
815
  msgid "Edit Ad Group"
816
  msgstr ""
817
 
818
+ #: public/class-advanced-ads.php:708
819
  msgid "Update Ad Group"
820
  msgstr ""
821
 
822
+ #: public/class-advanced-ads.php:709
823
  msgid "Add New Ad Group"
824
  msgstr ""
825
 
826
+ #: public/class-advanced-ads.php:710
827
  msgid "New Ad Groups Name"
828
  msgstr ""
829
 
830
+ #: public/class-advanced-ads.php:711 modules/import-export/views/page.php:24
831
  msgid "Groups"
832
  msgstr ""
833
 
834
+ #: public/class-advanced-ads.php:712
835
  msgid "No Ad Group found"
836
  msgstr ""
837
 
838
+ #: public/class-advanced-ads.php:740 public/class-advanced-ads.php:744
839
  #: admin/includes/class-menu.php:85 admin/views/ad-group-list-ads.php:28
840
  msgid "New Ad"
841
  msgstr ""
842
 
843
+ #: public/class-advanced-ads.php:741 admin/includes/class-menu.php:85
844
  msgid "Add New Ad"
845
  msgstr ""
846
 
847
+ #: public/class-advanced-ads.php:742
848
  #: admin/includes/class-ad-groups-list.php:313
849
  #: modules/import-export/classes/import.php:146
850
  #: modules/import-export/classes/import.php:186
852
  msgid "Edit"
853
  msgstr ""
854
 
855
+ #: public/class-advanced-ads.php:743
856
  msgid "Edit Ad"
857
  msgstr ""
858
 
859
+ #: public/class-advanced-ads.php:745
860
  msgid "View"
861
  msgstr ""
862
 
863
+ #: public/class-advanced-ads.php:746
864
  msgid "View the Ad"
865
  msgstr ""
866
 
867
+ #: public/class-advanced-ads.php:747
868
  msgid "Search Ads"
869
  msgstr ""
870
 
871
+ #: public/class-advanced-ads.php:748
872
  msgid "No Ads found"
873
  msgstr ""
874
 
875
+ #: public/class-advanced-ads.php:749
876
  msgid "No Ads found in Trash"
877
  msgstr ""
878
 
879
+ #: public/class-advanced-ads.php:750
880
  msgid "Parent Ad"
881
  msgstr ""
882
 
883
+ #: public/class-advanced-ads.php:891
884
  msgctxt "label above ads"
885
  msgid "Advertisements"
886
  msgstr ""
1021
  msgid "Learn how this might impact your ad setup."
1022
  msgstr ""
1023
 
1024
+ #: admin/includes/ad-health-notices.php:287
1025
+ #, php-format
1026
+ msgid ""
1027
+ "Advanced Ads handles your ads.txt file automatically. You might be able to "
1028
+ "<strong>remove %1$s</strong>."
1029
+ msgstr ""
1030
+
1031
  #: admin/includes/class-ad-groups-list.php:165
1032
  msgid "Ad weight"
1033
  msgstr ""
1110
  msgid "No ad group created"
1111
  msgstr ""
1112
 
1113
+ #: admin/includes/class-ad-type.php:86 admin/includes/class-ad-type.php:92
1114
  msgid "Ad Details"
1115
  msgstr ""
1116
 
1117
+ #: admin/includes/class-ad-type.php:87 admin/includes/class-ad-type.php:93
1118
  msgid "Ad Planning"
1119
  msgstr ""
1120
 
1121
+ #: admin/includes/class-ad-type.php:88 admin/includes/class-ad-type.php:94
1122
  msgid "Ad Shortcode"
1123
  msgstr ""
1124
 
1125
+ #: admin/includes/class-ad-type.php:240
1126
  #, php-format
1127
  msgid "%s ad updated."
1128
  msgid_plural "%s ads updated."
1129
  msgstr[0] ""
1130
  msgstr[1] ""
1131
 
1132
+ #: admin/includes/class-ad-type.php:241
1133
  #, php-format
1134
  msgid "%s ad not updated, somebody is editing it."
1135
  msgid_plural "%s ads not updated, somebody is editing them."
1136
  msgstr[0] ""
1137
  msgstr[1] ""
1138
 
1139
+ #: admin/includes/class-ad-type.php:242
1140
  #, php-format
1141
  msgid "%s ad permanently deleted."
1142
  msgid_plural "%s ads permanently deleted."
1143
  msgstr[0] ""
1144
  msgstr[1] ""
1145
 
1146
+ #: admin/includes/class-ad-type.php:243
1147
  #, php-format
1148
  msgid "%s ad moved to the Trash."
1149
  msgid_plural "%s ads moved to the Trash."
1150
  msgstr[0] ""
1151
  msgstr[1] ""
1152
 
1153
+ #: admin/includes/class-ad-type.php:244
1154
  #, php-format
1155
  msgid "%s ad restored from the Trash."
1156
  msgid_plural "%s ads restored from the Trash."
1157
  msgstr[0] ""
1158
  msgstr[1] ""
1159
 
1160
+ #: admin/includes/class-ad-type.php:574 admin/includes/class-ad-type.php:575
1161
  msgid "Ad updated."
1162
  msgstr ""
1163
 
1164
  #. translators: %s: date and time of the revision
1165
+ #: admin/includes/class-ad-type.php:577
1166
  #, php-format
1167
  msgid "Ad restored to revision from %s"
1168
  msgstr ""
1169
 
1170
+ #: admin/includes/class-ad-type.php:578 admin/includes/class-ad-type.php:579
1171
  msgid "Ad saved."
1172
  msgstr ""
1173
 
1174
+ #: admin/includes/class-ad-type.php:580
1175
  msgid "Ad submitted."
1176
  msgstr ""
1177
 
1178
+ #: admin/includes/class-ad-type.php:582
1179
  #, php-format
1180
  msgid "Ad scheduled for: <strong>%1$s</strong>."
1181
  msgstr ""
1182
 
1183
  #. translators: Publish box date format, see http://php.net/date
1184
+ #: admin/includes/class-ad-type.php:584
1185
  msgid "M j, Y @ G:i"
1186
  msgstr ""
1187
 
1188
+ #: admin/includes/class-ad-type.php:586
1189
  msgid "Ad draft updated."
1190
  msgstr ""
1191
 
1192
+ #: admin/includes/class-ad-type.php:673
1193
  msgid ""
1194
  "You don’t have access to ads. Please deactivate and re-enable Advanced Ads "
1195
  "again to fix this."
1260
  "."
1261
  msgstr ""
1262
 
1263
+ #: admin/includes/class-list-filters.php:141
1264
+ #: modules/gadsense/admin/admin.php:25
1265
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:114
1266
  msgid "Responsive"
1267
  msgstr ""
1268
 
1269
+ #: admin/includes/class-list-filters.php:150
1270
  msgid "expired"
1271
  msgstr ""
1272
 
1273
+ #: admin/includes/class-list-filters.php:154
1274
  msgid "any expiry date"
1275
  msgstr ""
1276
 
1313
  msgid "Ad Type"
1314
  msgstr ""
1315
 
1316
+ #: admin/includes/class-meta-box.php:63
1317
+ #: admin/includes/class-overview-widgets.php:50
1318
+ msgid "AdSense Earnings"
1319
+ msgstr ""
1320
+
1321
+ #: admin/includes/class-meta-box.php:72
1322
  msgid "Ad Parameters"
1323
  msgstr ""
1324
 
1325
+ #: admin/includes/class-meta-box.php:75 admin/includes/class-settings.php:66
1326
  msgid "Layout / Output"
1327
  msgstr ""
1328
 
1329
+ #: admin/includes/class-meta-box.php:85
1330
  msgid "Increase your ad revenue"
1331
  msgstr ""
1332
 
1333
+ #: admin/includes/class-meta-box.php:90
1334
  msgid "Ad Stats"
1335
  msgstr ""
1336
 
1337
+ #: admin/includes/class-meta-box.php:152 admin/includes/class-meta-box.php:163
1338
+ #: admin/includes/class-meta-box.php:168 admin/includes/class-settings.php:610
1339
  #: admin/views/ad-output-metabox.php:81
1340
  #: modules/ads-txt/admin/views/setting-create.php:11
1341
  #: modules/privacy/admin/views/setting-enable.php:2
1342
  msgid "Manual"
1343
  msgstr ""
1344
 
1345
+ #: admin/includes/class-meta-box.php:162
1346
  msgid "Video"
1347
  msgstr ""
1348
 
1349
+ #: admin/includes/class-meta-box.php:303
1350
  msgid "Ad Settings"
1351
  msgstr ""
1352
 
1353
+ #: admin/includes/class-meta-box.php:405 admin/views/overview.php:6
1354
  msgid "Ads Dashboard"
1355
  msgstr ""
1356
 
1357
+ #: admin/includes/class-meta-box.php:416
1358
  #, php-format
1359
  msgid "%d ads – <a href=\"%s\">manage</a> - <a href=\"%s\">new</a>"
1360
  msgstr ""
1361
 
1362
+ #: admin/includes/class-meta-box.php:427
1363
  msgid "Get the tutorial via email"
1364
  msgstr ""
1365
 
1366
+ #: admin/includes/class-meta-box.php:434
1367
  msgid "Get AdSense tips via email"
1368
  msgstr ""
1369
 
1370
+ #: admin/includes/class-meta-box.php:441
1371
  msgid "Visit our blog for more articles about ad optimization"
1372
  msgstr ""
1373
 
1374
  #. %s is our URL
1375
+ #: admin/includes/class-meta-box.php:494
1376
  msgid "Latest posts on wpadvancedads.com"
1377
  msgstr ""
1378
 
1396
  "href=\"%s\" target=\"_blank\">this form</a> to sign up."
1397
  msgstr ""
1398
 
1399
+ #: admin/includes/class-overview-widgets.php:45
1400
  msgid "Next steps"
1401
  msgstr ""
1402
 
1403
+ #: admin/includes/class-overview-widgets.php:47
1404
  msgid "Manual and Support"
1405
  msgstr ""
1406
 
1407
+ #: admin/includes/class-overview-widgets.php:102
1408
  #: admin/views/notices/welcome-panel.php:6
1409
  msgid "Create your first ad"
1410
  msgstr ""
1411
 
1412
+ #: admin/includes/class-overview-widgets.php:105
1413
  #: modules/gadsense/admin/views/adsense-account.php:71
1414
  #: modules/gadsense/admin/views/adsense-account.php:89
 
 
1415
  msgid "Connect to AdSense"
1416
  msgstr ""
1417
 
1418
+ #: admin/includes/class-overview-widgets.php:115
1419
  msgid "Join the newsletter for more benefits"
1420
  msgstr ""
1421
 
1422
+ #: admin/includes/class-overview-widgets.php:117
1423
  msgid "Get 2 free add-ons"
1424
  msgstr ""
1425
 
1426
+ #: admin/includes/class-overview-widgets.php:118
1427
  msgid "Get the first steps and more tutorials to your inbox"
1428
  msgstr ""
1429
 
1430
+ #: admin/includes/class-overview-widgets.php:119
1431
  msgid "How to earn more with AdSense"
1432
  msgstr ""
1433
 
1434
+ #: admin/includes/class-overview-widgets.php:122
1435
  msgid "Join now"
1436
  msgstr ""
1437
 
1438
+ #: admin/includes/class-overview-widgets.php:130
1439
  msgid ""
1440
  "Do you find Advanced Ads useful and would like to keep us motivated? Please "
1441
  "help us with a review."
1442
  msgstr ""
1443
 
1444
+ #: admin/includes/class-overview-widgets.php:132
1445
  msgid "Sure, I’ll rate the plugin"
1446
  msgstr ""
1447
 
1448
+ #: admin/includes/class-overview-widgets.php:134
1449
  msgid "I already did"
1450
  msgstr ""
1451
 
1452
+ #: admin/includes/class-overview-widgets.php:140
1453
  msgid "Manage your ads"
1454
  msgstr ""
1455
 
1456
+ #: admin/includes/class-overview-widgets.php:144
1457
  msgid "Get the All Access pass"
1458
  msgstr ""
1459
 
1460
+ #: admin/includes/class-overview-widgets.php:170
1461
  #: admin/views/notices/welcome-panel.php:22
1462
  #, php-format
1463
  msgid "<a href=\"%s\" target=\"_blank\">Manual</a>"
1464
  msgstr ""
1465
 
1466
+ #: admin/includes/class-overview-widgets.php:171
1467
  #, php-format
1468
  msgid "<a href=\"%s\" target=\"_blank\">FAQ and Support</a>"
1469
  msgstr ""
1470
 
1471
  #. %s includes a number and markup like <span class="count">6</span>.
1472
+ #: admin/includes/class-overview-widgets.php:180
1473
  #: admin/views/overview-notices.php:17
1474
  #, php-format
1475
  msgid "Show %s hidden notices"
1476
  msgstr ""
1477
 
1478
+ #: admin/includes/class-overview-widgets.php:360
1479
  msgid "The solution for professional websites."
1480
  msgstr ""
1481
 
1482
+ #: admin/includes/class-overview-widgets.php:363
1483
  #: admin/views/pitch-pro-tab.php:7
1484
  msgid "support for cached sites"
1485
  msgstr ""
1486
 
1487
+ #: admin/includes/class-overview-widgets.php:366
1488
+ #: admin/includes/class-overview-widgets.php:367
1489
+ #: admin/includes/class-overview-widgets.php:368
1490
+ #: admin/includes/class-overview-widgets.php:369
1491
  #, php-format
1492
  msgid "integrates with <strong>%s</strong>"
1493
  msgstr ""
1494
 
1495
+ #: admin/includes/class-overview-widgets.php:370
1496
  msgid "click fraud protection, lazy load, ad-block ads"
1497
  msgstr ""
1498
 
1499
+ #: admin/includes/class-overview-widgets.php:371
1500
  #: admin/views/pitch-pro-tab.php:8
1501
  msgid "11 more display and visitor conditions"
1502
  msgstr ""
1503
 
1504
+ #: admin/includes/class-overview-widgets.php:372
1505
  #: admin/views/pitch-pro-tab.php:9
1506
  msgid "6 more placements"
1507
  msgstr ""
1508
 
1509
+ #: admin/includes/class-overview-widgets.php:373
1510
  #: admin/views/pitch-pro-tab.php:10
1511
  msgid "placement tests for ad optimization"
1512
  msgstr ""
1513
 
1514
+ #: admin/includes/class-overview-widgets.php:374
1515
  #: admin/views/pitch-pro-tab.php:11
1516
  msgid "ad grids and many more advanced features"
1517
  msgstr ""
1518
 
1519
+ #: admin/includes/class-overview-widgets.php:381
1520
  msgid ""
1521
  "Analyze clicks and impressions of your ads locally or in Google Analytics, "
1522
  "share reports, and limit ads to a specific number of impressions or clicks."
1523
  msgstr ""
1524
 
1525
+ #: admin/includes/class-overview-widgets.php:387
1526
  msgid ""
1527
  "Display ads based on the device or the size of your visitor’s browser, and "
1528
  "control ads on AMP pages."
1529
  msgstr ""
1530
 
1531
+ #: admin/includes/class-overview-widgets.php:400
1532
  msgid ""
1533
  "Earn more money and let advertisers pay for ad space directly on the "
1534
  "frontend of your site."
1535
  msgstr ""
1536
 
1537
+ #: admin/includes/class-overview-widgets.php:406
1538
  msgid ""
1539
  "Target visitors with ads that match their geo location and make more money "
1540
  "with regional campaigns."
1541
  msgstr ""
1542
 
1543
+ #: admin/includes/class-overview-widgets.php:412
1544
  msgid ""
1545
  "Increase click rates on your ads by placing them in sticky positions above, "
1546
  "next or below your site."
1547
  msgstr ""
1548
 
1549
+ #: admin/includes/class-overview-widgets.php:418
1550
  msgid ""
1551
  "Users will never miss an ad or other information in a PopUp. Choose when it "
1552
  "shows up and for how long a user can close it."
1553
  msgstr ""
1554
 
1555
+ #: admin/includes/class-overview-widgets.php:424
1556
  msgid ""
1557
  "Create a beautiful and simple slider from your ads to show more information "
1558
  "on less space."
1559
  msgstr ""
1560
 
1561
+ #: admin/includes/class-overview-widgets.php:430
1562
  msgid ""
1563
  "Place AdSense In-feed ads between posts on homepage, category, and archive "
1564
  "pages."
1565
  msgstr ""
1566
 
1567
+ #: admin/includes/class-overview-widgets.php:433
1568
+ #: admin/includes/class-overview-widgets.php:608
1569
+ #: admin/includes/class-overview-widgets.php:624
1570
  msgid "Install now"
1571
  msgstr ""
1572
 
1573
+ #: admin/includes/class-overview-widgets.php:451
1574
+ #: admin/includes/class-overview-widgets.php:472
1575
+ #: admin/includes/class-overview-widgets.php:497
1576
+ #: admin/includes/class-overview-widgets.php:515
1577
+ #: admin/includes/class-overview-widgets.php:533
1578
+ #: admin/includes/class-overview-widgets.php:551
1579
+ #: admin/includes/class-overview-widgets.php:569
1580
+ #: admin/includes/class-overview-widgets.php:587
1581
  msgid "Activate now"
1582
  msgstr ""
1583
 
1584
+ #: admin/includes/class-overview-widgets.php:480
1585
  msgid "Visit your ad stats"
1586
  msgstr ""
1587
 
1588
+ #: admin/includes/class-overview-widgets.php:604
1589
  msgid "Use Genesis specific ad positions."
1590
  msgstr ""
1591
 
1592
+ #: admin/includes/class-overview-widgets.php:620
1593
  msgid ""
1594
  "Manage ad positions with WPBakery Page Builder (formerly Visual Composer)."
1595
  msgstr ""
1596
 
1597
+ #: admin/includes/class-overview-widgets.php:636
1598
  msgid "Our best deal with all add-ons included."
1599
  msgstr ""
1600
 
1601
+ #: admin/includes/class-overview-widgets.php:638
1602
  msgid "Get full access"
1603
  msgstr ""
1604
 
1605
+ #: admin/includes/class-overview-widgets.php:652
1606
  #: admin/views/ad-display-metabox.php:48 admin/views/ad-visitor-metabox.php:48
1607
  msgid "Visit the manual"
1608
  msgstr ""
1609
 
1610
+ #: admin/includes/class-overview-widgets.php:655
1611
  msgid "Get this add-on"
1612
  msgstr ""
1613
 
1996
  msgstr ""
1997
 
1998
  #: admin/views/ad-display-metabox.php:104
1999
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:121
2000
  msgid "manual"
2001
  msgstr ""
2002
 
2061
  msgstr ""
2062
 
2063
  #: admin/views/ad-group-list-form-row.php:29 admin/views/placements.php:32
2064
+ #: modules/gadsense/admin/views/external-ads-list.php:30
2065
+ #: modules/gadsense/admin/views/external-ads-list.php:43
2066
  #: modules/privacy/admin/views/setting-consent-method.php:9
2067
  msgid "Name"
2068
  msgstr ""
2069
 
2070
  #: admin/views/ad-group-list-form-row.php:55 admin/views/placements.php:31
2071
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:110
2072
  msgid "Type"
2073
  msgstr ""
2074
 
2123
  msgid "Ad Groups successfully updated"
2124
  msgstr ""
2125
 
2126
+ #: admin/views/ad-group.php:60
2127
  #, php-format
2128
  msgid "Search results for &#8220;%s&#8221;"
2129
  msgstr ""
2130
 
2131
+ #: admin/views/ad-group.php:67
2132
  msgid "Group title"
2133
  msgstr ""
2134
 
2135
+ #: admin/views/ad-group.php:68
2136
  msgid "save"
2137
  msgstr ""
2138
 
2139
+ #: admin/views/ad-group.php:70
2140
  msgid ""
2141
  "Ad Groups are a very flexible method to bundle ads. You can use them to "
2142
  "display random ads in the frontend or run split tests, but also just for "
2144
  "ad can belong to multiple ad groups."
2145
  msgstr ""
2146
 
2147
+ #: admin/views/ad-group.php:76
2148
  #, php-format
2149
  msgid ""
2150
  "Find more information about ad groups in the <a href=\"%s\" "
2151
  "target=\"_blank\">manual</a>."
2152
  msgstr ""
2153
 
2154
+ #: admin/views/ad-group.php:104
2155
  msgid "Update Groups"
2156
  msgstr ""
2157
 
2262
  #: admin/views/placements-ad-label-position.php:5
2263
  #: admin/views/placements-ad-label.php:1 admin/views/placements-ad-label.php:4
2264
  #: admin/views/placements.php:74
2265
+ #: modules/gadsense/includes/class-network-adsense.php:214
2266
  msgid "default"
2267
  msgstr ""
2268
 
2571
  msgid "Disabling the plugin now…"
2572
  msgstr ""
2573
 
2574
+ #: admin/views/gadsense-dashboard.php:29
2575
+ msgid "There is an error in your AdSense setup."
2576
+ msgstr ""
2577
+
2578
  #: admin/views/pitch-bundle.php:1
2579
  msgid "All Access – with all available add-ons"
2580
  msgstr ""
2646
  msgstr ""
2647
 
2648
  #: admin/views/placement-injection-top.php:24
2649
+ #: modules/gadsense/admin/admin.php:178
2650
  #, php-format
2651
  msgid ""
2652
  "The AdSense verification and Auto ads code is already activated in the <a "
2654
  msgstr ""
2655
 
2656
  #: admin/views/placement-injection-top.php:30
2657
+ #: modules/gadsense/admin/admin.php:180
2658
  msgid ""
2659
  "No need to add the code manually here, unless you want to include it into "
2660
  "certain pages only."
3078
  "for individual help."
3079
  msgstr ""
3080
 
 
 
 
 
3081
  #: public/views/ad-debug.php:20
3082
  msgid "Ad debug output"
3083
  msgstr ""
3201
  "to the ads.txt file of the root domain: %s"
3202
  msgstr ""
3203
 
3204
+ #: modules/gadsense/admin/admin.php:121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3205
  #, php-format
3206
  msgid ""
3207
  "Responsive AdSense ads don’t work reliably with <em>Position</em> set to "
3210
  "wrapped in text."
3211
  msgstr ""
3212
 
3213
+ #: modules/gadsense/admin/admin.php:127
3214
  #, php-format
3215
  msgid ""
3216
  "<a href=\"%s\" target=\"_blank\">Install the free AdSense In-feed add-on</a> "
3217
  "in order to place ads between posts."
3218
  msgstr ""
3219
 
3220
+ #: modules/gadsense/admin/admin.php:134
3221
  #, php-format
3222
  msgid ""
3223
  "Use the <a href=\"%s\" target=\"_blank\">Responsive add-on</a> in order to "
3225
  "vertical, or rectangle formats."
3226
  msgstr ""
3227
 
3228
+ #: modules/gadsense/admin/admin.php:182
3229
  #, php-format
3230
  msgid ""
3231
  "The AdSense verification and Auto ads code should be set up in the <a "
3233
  "now."
3234
  msgstr ""
3235
 
3236
+ #: modules/gadsense/admin/admin.php:183
3237
  msgid "Activate"
3238
  msgstr ""
3239
 
3240
+ #: modules/gadsense/admin/dummy.php:61
3241
+ msgid "Dummy Account Id"
3242
+ msgstr ""
3243
+
3244
  #: modules/gadsense/includes/class-ad-type-adsense.php:35
3245
  msgid "AdSense ad"
3246
  msgstr ""
3249
  msgid "Use ads from your Google AdSense account"
3250
  msgstr ""
3251
 
3252
+ #: modules/gadsense/includes/class-ad-type-adsense.php:93
3253
+ #: modules/gadsense/includes/class-network-adsense.php:248
3254
+ msgid "The Publisher ID has an incorrect format. (must start with \"pub-\")"
3255
+ msgstr ""
3256
+
3257
+ #: modules/gadsense/includes/class-ad-type-adsense.php:134
3258
  msgid "Your AdSense Publisher ID is missing."
3259
  msgstr ""
3260
 
3261
+ #: modules/gadsense/includes/class-adsense-report.php:463
3262
+ #: modules/gadsense/includes/class-adsense-report.php:482
3263
+ msgid "Never"
3264
+ msgstr ""
3265
+
3266
  #: modules/gadsense/includes/class-gadsense-data.php:40
3267
  msgid "Auto"
3268
  msgstr ""
3272
  msgid "Error while retrieving ad code for \"%s\"."
3273
  msgstr ""
3274
 
3275
+ #: modules/gadsense/includes/class-mapi.php:360
3276
  #, php-format
3277
  msgid "Invalid response while retrieving ad code for \"%s\"."
3278
  msgstr ""
3279
 
3280
+ #: modules/gadsense/includes/class-mapi.php:401
3281
  #, php-format
3282
  msgid "Error while retrieving adUnits list for \"%s\"."
3283
  msgstr ""
3284
 
3285
+ #: modules/gadsense/includes/class-mapi.php:408
3286
  #, php-format
3287
  msgid "Invalid response while retrieving adUnits list for \"%s\"."
3288
  msgstr ""
3289
 
3290
+ #: modules/gadsense/includes/class-mapi.php:416
3291
+ msgid "Reason:"
3292
+ msgstr ""
3293
+
3294
+ #: modules/gadsense/includes/class-mapi.php:417
3295
+ msgid "Message:"
3296
+ msgstr ""
3297
+
3298
  #. %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.
3299
+ #: modules/gadsense/includes/class-mapi.php:432
3300
  #, php-format
3301
  msgid ""
3302
  "The account \"%1$s\" does not seem to have any ad units. Please create some "
3303
  "%2$shere%3$s."
3304
  msgstr ""
3305
 
3306
+ #: modules/gadsense/includes/class-mapi.php:494
3307
  msgid ""
3308
  "It seems that some changes have been made in the Advanced Ads settings. "
3309
  "Please refresh this page."
3310
  msgstr ""
3311
 
3312
+ #: modules/gadsense/includes/class-mapi.php:501
3313
  #, php-format
3314
  msgid ""
3315
  "Advanced Ads does not have access to your account (<code>%s</code>) anymore."
3316
  msgstr ""
3317
 
3318
+ #: modules/gadsense/includes/class-mapi.php:543
3319
  #, php-format
3320
  msgid "error while renewing access token for \"%s\""
3321
  msgstr ""
3322
 
3323
+ #: modules/gadsense/includes/class-mapi.php:568
3324
  #, php-format
3325
  msgid "invalid response received while renewing access token for \"%s\""
3326
  msgstr ""
3327
 
3328
+ #: modules/gadsense/includes/class-mapi.php:797
3329
  msgid "Invalid response body while retrieving account alerts"
3330
  msgstr ""
3331
 
3332
+ #: modules/gadsense/includes/class-mapi.php:806
3333
  msgid "error while retrieving account alerts"
3334
  msgstr ""
3335
 
3336
+ #: modules/gadsense/includes/class-mapi.php:961
3337
  msgid "No token provided. Token data needed to get account details."
3338
  msgstr ""
3339
 
3340
+ #: modules/gadsense/includes/class-mapi.php:1025
3341
  msgid "An error occurred while requesting account details."
3342
  msgstr ""
3343
 
3344
+ #: modules/gadsense/includes/class-mapi.php:1374
3345
  #, php-format
3346
  msgid ""
3347
  "There are one or more warnings about the currently linked AdSense account. "
3348
  "You can view them <a href=\"%s\">here</a>"
3349
  msgstr ""
3350
 
3351
+ #. 1:A link to the settings page
3352
+ #. 2:The name of an ad network
3353
+ #: modules/gadsense/includes/class-mapi.php:1461
3354
+ #, php-format
3355
+ msgid ""
3356
+ "Please try to <a href=\"%1$s\" target=\"_blank\">reconnect to your %2$s "
3357
+ "account</a>."
3358
+ msgstr ""
3359
+
3360
+ #: modules/gadsense/includes/class-network-adsense.php:34
3361
+ msgid "AdSense account"
3362
+ msgstr ""
3363
+
3364
+ #: modules/gadsense/includes/class-network-adsense.php:43
3365
+ msgid "Verification code & Auto ads"
3366
+ msgstr ""
3367
+
3368
+ #: modules/gadsense/includes/class-network-adsense.php:52
3369
+ msgid "Auto ads"
3370
+ msgstr ""
3371
+
3372
+ #: modules/gadsense/includes/class-network-adsense.php:52
3373
+ msgid "Disable top anchor ad"
3374
+ msgstr ""
3375
+
3376
+ #: modules/gadsense/includes/class-network-adsense.php:64
3377
+ msgid "Limit to 3 ads"
3378
+ msgstr ""
3379
+
3380
+ #: modules/gadsense/includes/class-network-adsense.php:74
3381
+ msgid "Disable violation warnings"
3382
+ msgstr ""
3383
+
3384
+ #: modules/gadsense/includes/class-network-adsense.php:82
3385
+ msgid "Transparent background"
3386
+ msgstr ""
3387
+
3388
+ #: modules/gadsense/includes/class-network-adsense.php:90
3389
+ msgid "Full width responsive ads on mobile"
3390
+ msgstr ""
3391
+
3392
+ #: modules/gadsense/includes/class-network-adsense.php:134
3393
+ #, php-format
3394
+ msgid "Limit to %d AdSense ads"
3395
+ msgstr ""
3396
+
3397
+ #: modules/gadsense/includes/class-network-adsense.php:138
3398
+ msgid ""
3399
+ "There is no explicit limit for AdSense ads anymore, but you can still use "
3400
+ "this setting to prevent too many AdSense ads to show accidentally on your "
3401
+ "site."
3402
+ msgstr ""
3403
+
3404
+ #: modules/gadsense/includes/class-network-adsense.php:142
3405
+ msgid ""
3406
+ "Due to technical restrictions, the limit does not work on placements with "
3407
+ "cache-busting enabled."
3408
+ msgstr ""
3409
+
3410
+ #: modules/gadsense/includes/class-network-adsense.php:154
3411
+ msgid ""
3412
+ "Enable this box if you don’t want Google Auto ads to place anchor ads at the "
3413
+ "top of your page."
3414
+ msgstr ""
3415
+
3416
+ #: modules/gadsense/includes/class-network-adsense.php:169
3417
+ #: modules/gadsense/admin/views/connect-adsense.php:37
3418
+ msgid ""
3419
+ "Insert the AdSense header code used for verification and the Auto Ads "
3420
+ "feature."
3421
+ msgstr ""
3422
+
3423
+ #. this is the text for a link to a sub-page in an AdSense account
3424
+ #: modules/gadsense/includes/class-network-adsense.php:174
3425
+ msgid "Adjust Auto ads options"
3426
+ msgstr ""
3427
+
3428
+ #: modules/gadsense/includes/class-network-adsense.php:176
3429
+ #, php-format
3430
+ msgid ""
3431
+ "Please read <a href=\"%s\" target=\"_blank\">this article</a> if <strong>ads "
3432
+ "appear in random places</strong>."
3433
+ msgstr ""
3434
+
3435
+ #: modules/gadsense/includes/class-network-adsense.php:177
3436
+ msgid "Display Auto ads only on specific pages"
3437
+ msgstr ""
3438
+
3439
+ #: modules/gadsense/includes/class-network-adsense.php:178
3440
+ msgid "Auto ads on AMP pages"
3441
+ msgstr ""
3442
+
3443
+ #: modules/gadsense/includes/class-network-adsense.php:191
3444
+ msgid "Disable warnings about potential violations of the AdSense terms."
3445
+ msgstr ""
3446
+
3447
+ #: modules/gadsense/includes/class-network-adsense.php:192
3448
+ #, php-format
3449
+ msgid ""
3450
+ "Our <a href=\"%s\" target=\"_blank\">Ad Health</a> feature monitors if "
3451
+ "AdSense is implemented correctly on your site. It also considers ads not "
3452
+ "managed with Advanced Ads. Enable this option to remove these checks"
3453
+ msgstr ""
3454
+
3455
+ #: modules/gadsense/includes/class-network-adsense.php:203
3456
+ msgid ""
3457
+ "Enable this option in case your theme adds an unfortunate background color "
3458
+ "to AdSense ads."
3459
+ msgstr ""
3460
+
3461
+ #: modules/gadsense/includes/class-network-adsense.php:215
3462
+ msgid "enable"
3463
+ msgstr ""
3464
+
3465
+ #: modules/gadsense/includes/class-network-adsense.php:216
3466
+ msgid "disable"
3467
+ msgstr ""
3468
+
3469
+ #: modules/gadsense/includes/class-network-adsense.php:221
3470
+ #, php-format
3471
+ msgid ""
3472
+ "Whether your responsive ad unit may expand to <a href='%s' target='blank'>"
3473
+ "use the full width</a> of your visitor's mobile device screen"
3474
+ msgstr ""
3475
+
3476
  #. Name of the plugin
3477
  #: modules/gutenberg/includes/class-gutenberg.php:78
3478
  msgid "Advanced Ads"
3800
  msgstr ""
3801
 
3802
  #: modules/gadsense/admin/views/adsense-account.php:152
3803
+ #: modules/gadsense/admin/views/external-ads-links.php:37
3804
  msgid "Can not connect AdSense account. PHP version is too low."
3805
  msgstr ""
3806
 
3807
  #. this is a label for an ad that we can currently not import from the AdSense account
3808
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:48
3809
+ #: modules/gadsense/admin/views/external-ads-list.php:88
3810
+ #: modules/gadsense/admin/views/external-ads-list.php:97
3811
  msgid "unsupported"
3812
  msgstr ""
3813
 
3814
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:58
3815
  msgid "The ad details couldn't be retrieved from the ad code"
3816
  msgstr ""
3817
 
3818
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:59
3819
  msgid ""
3820
  "Warning: The AdSense account from this code does not match the one set in "
3821
  "the Advanced Ads options."
3822
  msgstr ""
3823
 
3824
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:67
3825
  msgid ""
3826
  "Copy the ad code from your AdSense account, paste it into the area below and "
3827
  "click on <em>Get details</em>."
3828
  msgstr ""
3829
 
3830
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:69
3831
  msgid "Get details"
3832
  msgstr ""
3833
 
3834
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:70
3835
  msgid "cancel"
3836
  msgstr ""
3837
 
3838
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:72
3839
  msgid "connect to your AdSense account"
3840
  msgstr ""
3841
 
3842
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:87
 
 
 
 
 
 
 
 
3843
  msgid "Ad Slot ID"
3844
  msgstr ""
3845
 
3846
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:92
3847
  #, php-format
3848
  msgid "Publisher ID: %s"
3849
  msgstr ""
3850
 
3851
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:96
3852
  msgid ""
3853
  "The ad slot ID is either a number or empty and not the same as the publisher "
3854
  "ID."
3855
  msgstr ""
3856
 
3857
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:107
3858
  #, php-format
3859
  msgid "Please <a href=\"%s\" target=\"_blank\">change it here</a>."
3860
  msgstr ""
3861
 
3862
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:113
3863
  msgid "Normal"
3864
  msgstr ""
3865
 
3866
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:115
3867
  msgid "Responsive (Matched Content)"
3868
  msgstr ""
3869
 
3870
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:116
3871
  msgid "Link ads"
3872
  msgstr ""
3873
 
3874
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:117
3875
  msgid "Link ads (Responsive)"
3876
  msgstr ""
3877
 
3878
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:118
3879
  msgid "InArticle"
3880
  msgstr ""
3881
 
3882
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:119
3883
  msgid "InFeed"
3884
  msgstr ""
3885
 
3886
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:124
3887
  msgid "Resizing"
3888
  msgstr ""
3889
 
3890
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:132
3891
  msgid "Layout"
3892
  msgstr ""
3893
 
3894
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:136
3895
  msgid "Layout-Key"
3896
  msgstr ""
3897
 
3898
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:141
3899
  msgid "Clearfix"
3900
  msgstr ""
3901
 
3902
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:144
3903
  msgid "Enable this box if responsive ads cover something on your site"
3904
  msgstr ""
3905
 
3923
  msgid "Use this account"
3924
  msgstr ""
3925
 
3926
+ #. 1: The name of an ad network.
3927
+ #: modules/gadsense/admin/views/external-ads-links.php:12
3928
+ #, php-format
3929
+ msgid "Insert new %1$s code"
3930
  msgstr ""
3931
 
3932
+ #: modules/gadsense/admin/views/external-ads-links.php:17
3933
+ msgid "Get ad code from your linked account"
3934
+ msgstr ""
3935
+
3936
+ #. 1: The name of an ad network.
3937
+ #: modules/gadsense/admin/views/external-ads-links.php:23
3938
+ #, php-format
3939
+ msgid "Set up %1$s code manually"
3940
+ msgstr ""
3941
+
3942
+ #. 1: The name of an ad network.
3943
+ #: modules/gadsense/admin/views/external-ads-links.php:30
3944
+ #, php-format
3945
+ msgid "Connect to %1$s"
3946
  msgstr ""
3947
 
3948
+ #: modules/gadsense/admin/views/external-ads-list.php:15
3949
+ #: modules/gadsense/admin/views/external-ads-list.php:54
3950
  msgid "Update the ad units list"
3951
  msgstr ""
3952
 
3953
+ #: modules/gadsense/admin/views/external-ads-list.php:28
3954
+ #: modules/gadsense/admin/views/external-ads-list.php:41
3955
  msgctxt "AdSense ad"
3956
  msgid "Ad unit"
3957
  msgstr ""
3958
 
3959
+ #: modules/gadsense/admin/views/external-ads-list.php:31
3960
+ #: modules/gadsense/admin/views/external-ads-list.php:44
3961
  msgctxt "AdSense ad"
3962
  msgid "Slot ID"
3963
  msgstr ""
3964
 
3965
+ #: modules/gadsense/admin/views/external-ads-list.php:32
3966
+ #: modules/gadsense/admin/views/external-ads-list.php:45
3967
  msgctxt "AdSense ad"
3968
  msgid "Type"
3969
  msgstr ""
3970
 
3971
+ #: modules/gadsense/admin/views/external-ads-list.php:33
3972
+ #: modules/gadsense/admin/views/external-ads-list.php:46
3973
  msgid "Size"
3974
  msgstr ""
3975
 
3976
+ #: modules/gadsense/admin/views/external-ads-list.php:53
3977
  msgid "No ad units found"
3978
  msgstr ""
3979
 
3980
+ #: modules/gadsense/admin/views/external-ads-list.php:69
3981
  msgid "Get the code for this ad"
3982
  msgstr ""
3983
 
3984
+ #: modules/gadsense/admin/views/external-ads-list.php:70
3985
  msgid "Update and get the code for this ad from Google"
3986
  msgstr ""
3987
 
3988
+ #: modules/gadsense/admin/views/external-ads-list.php:110
3989
  msgid "Unrecognized ad code"
3990
  msgstr ""
3991
 
3992
+ #: modules/gadsense/admin/views/external-ads-list.php:113
3993
  msgid "This ad type can currently not be imported from AdSense."
3994
  msgstr ""
3995
 
3996
+ #: modules/gadsense/admin/views/external-ads-list.php:114
3997
  msgid "Learn more and help us to enable it here."
3998
  msgstr ""
3999
 
4000
+ #: modules/gadsense/admin/views/external-ads-list.php:115
4001
  msgid "In the meantime, you can use AdSense with one of these methods:"
4002
  msgstr ""
4003
 
4004
+ #: modules/gadsense/admin/views/external-ads-list.php:117
4005
  msgid ""
4006
  "Click on <em>Insert new AdSense code</em> and copy the code from your "
4007
  "AdSense account into it."
4008
  msgstr ""
4009
 
4010
+ #: modules/gadsense/admin/views/external-ads-list.php:118
4011
  msgid ""
4012
  "Create an ad on the fly. Just select the <em>Normal</em> or <em>"
4013
  "Responsive</em> type and the size."
4014
  msgstr ""
4015
 
4016
+ #: modules/gadsense/admin/views/external-ads-list.php:119
4017
  msgid ""
4018
  "Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from "
4019
  "your AdSense account."
modules/gadsense/admin/admin.php CHANGED
@@ -12,14 +12,10 @@ class Advanced_Ads_AdSense_Admin {
12
 
13
  private function __construct() {
14
  $this->data = Advanced_Ads_AdSense_Data::get_instance();
15
- add_action( 'advanced-ads-settings-init', array($this, 'settings_init') );
16
- // add_action( 'advanced-ads-additional-settings-form', array($this, 'settings_init') );
17
- add_filter('advanced-ads-setting-tabs', array($this, 'setting_tabs'));
18
 
19
  add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts') );
20
  add_action( 'admin_print_scripts', array($this, 'print_scripts') );
21
  add_filter( 'advanced-ads-list-ad-size', array($this, 'ad_details_column'), 10, 2 );
22
- add_filter( 'advanced-ads-ad-settings-pre-save', array($this, 'sanitize_ad_settings') );
23
  add_filter( 'advanced-ads-ad-notices', array($this, 'ad_notices'), 10, 3 );
24
  }
25
 
@@ -62,15 +58,7 @@ class Advanced_Ads_AdSense_Admin {
62
  ('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type) ||
63
  ('post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action'])
64
  ) {
65
- $default_script = array(
66
- 'path' => GADSENSE_BASE_URL . 'admin/assets/js/new-ad.js',
67
- 'dep' => array('jquery'),
68
- 'version' => null,
69
- );
70
-
71
- $scripts = array(
72
- 'gadsense-new-ad' => $default_script,
73
- );
74
 
75
  // Allow modifications of script files to enqueue
76
  $scripts = apply_filters( 'advanced-ads-gadsense-ad-param-script', $scripts );
@@ -113,280 +101,6 @@ class Advanced_Ads_AdSense_Admin {
113
  }
114
  return self::$instance;
115
  }
116
-
117
- public function settings_init() {
118
-
119
- // get settings page hook
120
- $hook = $this->settings_page_hook;
121
-
122
- register_setting( ADVADS_SLUG . '-adsense', ADVADS_SLUG . '-adsense', array($this, 'sanitize_settings') );
123
-
124
- // add new section
125
- add_settings_section(
126
- 'advanced_ads_adsense_setting_section',
127
- '', //__( 'AdSense', 'advanced-ads' ),
128
- array($this, 'render_settings_section_callback'),
129
- $hook
130
- );
131
-
132
- // add setting field to disable ads
133
- add_settings_field(
134
- 'adsense-id',
135
- __( 'AdSense account', 'advanced-ads' ),
136
- array($this, 'render_settings_adsense_id'),
137
- $hook,
138
- 'advanced_ads_adsense_setting_section'
139
- );
140
-
141
- // activate AdSense verification code and Auto ads (previously Page-Level ads)
142
- add_settings_field(
143
- 'adsense-page-level',
144
- __( 'Verification code & Auto ads', 'advanced-ads' ),
145
- array($this, 'render_settings_adsense_page_level'),
146
- $hook,
147
- 'advanced_ads_adsense_setting_section'
148
- );
149
-
150
- // AdSense anchor ad on top of pages.
151
- add_settings_field(
152
- 'top_anchor_ad',
153
- __( 'Auto ads', 'advanced-ads' ) . ':&nbsp;' . __( 'Disable top anchor ad', 'advanced-ads' ),
154
- array( $this, 'render_settings_adsense_top_anchor_ad' ),
155
- $hook,
156
- 'advanced_ads_adsense_setting_section'
157
- );
158
-
159
- // add setting field for adsense limit
160
- // deprecated of January, 2019; will be removed one year later
161
- $limit_per_page = $this->data->get_limit_per_page();
162
- if( $limit_per_page ){
163
- add_settings_field(
164
- 'adsense-limit',
165
- __( 'Limit to 3 ads', 'advanced-ads' ),
166
- array($this, 'render_settings_adsense_limit'),
167
- $hook,
168
- 'advanced_ads_adsense_setting_section'
169
- );
170
- };
171
-
172
- // disable AdSense violation warnings
173
- add_settings_field(
174
- 'adsense-warnings-disable',
175
- __( 'Disable violation warnings', 'advanced-ads' ),
176
- array($this, 'render_settings_adsense_warnings_disable'),
177
- $hook,
178
- 'advanced_ads_adsense_setting_section'
179
- );
180
-
181
- add_settings_field(
182
- 'adsense-background',
183
- __( 'Transparent background', 'advanced-ads' ),
184
- array( $this, 'render_settings_adsense_background' ),
185
- $hook,
186
- 'advanced_ads_adsense_setting_section'
187
- );
188
-
189
- $adsense_id = $this->data->get_adsense_id();
190
-
191
- // if ( !empty( $adsense_id ) ) {
192
-
193
- // add_settings_field(
194
- // 'adsense-mapi',
195
- // __( 'Google AdSense Management API', 'advanced-ads' ),
196
- // array( $this, 'render_settings_management_api' ),
197
- // $hook,
198
- // 'advanced_ads_adsense_setting_section'
199
- // );
200
-
201
- // }
202
- // hook for additional settings from add-ons
203
- do_action( 'advanced-ads-adsense-settings-init', $hook );
204
- }
205
-
206
- /**
207
- * render adsense settings section
208
- *
209
- * @since 1.5.1
210
- */
211
- public function render_settings_section_callback(){
212
- // for whatever purpose there might come
213
- }
214
-
215
- /**
216
- * render adsense management api setting
217
- */
218
- public function render_settings_management_api() {
219
- require_once GADSENSE_BASE_PATH . 'admin/views/mapi-settings.php';
220
- }
221
-
222
- /**
223
- * render adsense id setting
224
- *
225
- * @since 1.5.1
226
- */
227
- public function render_settings_adsense_id(){
228
- require_once GADSENSE_BASE_PATH . 'admin/views/adsense-account.php';
229
- }
230
-
231
- /**
232
- * render adsense limit setting
233
- *
234
- * @since 1.5.1
235
- * @deprecated January, 2019 – let’s give users one year until we remove the whole logic completely
236
- */
237
- public function render_settings_adsense_limit(){
238
- $limit_per_page = $this->data->get_limit_per_page();
239
-
240
- ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[limit-per-page]" value="1" <?php checked( $limit_per_page ); ?> />
241
- <?php printf( __( 'Limit to %d AdSense ads', 'advanced-ads' ), 3 ); ?></label>
242
- <p class="description">
243
- <?php
244
- printf(
245
- __( 'There is no explicit limit for AdSense ads anymore, but you can still use this setting to prevent too many AdSense ads to show accidentally on your site.', 'advanced-ads' ),
246
- esc_url( 'https://www.google.com/adsense/terms' )
247
- ); ?></p>
248
- <?php if( defined( 'AAP_VERSION' ) ) : /* give warning when cache-busting in Pro is active */ ?>
249
- <p class="advads-error-message"><?php _e( 'Due to technical restrictions, the limit does not work on placements with cache-busting enabled.', 'advanced-ads' ); ?></p>
250
- <?php endif;
251
- }
252
-
253
- /**
254
- * Render top anchor ad setting
255
- */
256
- public function render_settings_adsense_top_anchor_ad() {
257
- $options = $this->data->get_options();
258
- $anchor_ad = isset( $options['top-anchor-ad'] )? $options['top-anchor-ad'] : ''; ?>
259
- <label>
260
- <input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[top-anchor-ad]" value="1" <?php checked( $anchor_ad ); ?> />
261
- <?php esc_html_e( 'Enable this box if you don’t want Google Auto ads to place anchor ads at the top of your page.', 'advanced-ads' ); ?>
262
- </label>
263
- <?php
264
- }
265
-
266
- /**
267
- * render page-level ads setting
268
- *
269
- * @since 1.6.9
270
- */
271
- public function render_settings_adsense_page_level(){
272
- $options = $this->data->get_options();
273
- $page_level = $options['page-level-enabled'];
274
-
275
- ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
276
- <?php esc_attr_e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' );
277
- if( !empty( $options['adsense-id'] ) ) :
278
- ?>&nbsp;<a href="https://www.google.com/adsense/new/u/0/<?php echo $options['adsense-id']; ?>/myads/auto-ads" target="_blank"><?php /**
279
- * translators: this is the text for a link to a sub-page in an AdSense account
280
- */
281
- esc_attr_e( 'Adjust Auto ads options', 'advanced-ads' ); ?></a>
282
- <?php endif; ?>
283
- </label><p class="description"><?php printf(__( 'Please read <a href="%s" target="_blank">this article</a> if <strong>ads appear in random places</strong>.', 'advanced-ads' ), ADVADS_URL . 'adsense-in-random-positions-auto-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=backend-autoads-ads' ); ?></p>
284
- <p class="description"><a href="<?php echo ADVADS_URL . 'adsense-auto-ads-wordpress/#Display_Auto_Ads_only_on_specific_pages'; ?>" target="_blank"><?php esc_attr_e( 'Display Auto ads only on specific pages', 'advanced-ads' ); ?></a></p>
285
- <p class="description"><a href="<?php echo ADVADS_URL . 'adsense-auto-ads-wordpress/#AMP_Auto_Ads'; ?>" target="_blank"><?php esc_attr_e( 'Auto ads on AMP pages', 'advanced-ads' ); ?></a></p><?php
286
- }
287
-
288
- /**
289
- * render AdSense violation warnings setting
290
- *
291
- * @since 1.6.9
292
- */
293
- public function render_settings_adsense_warnings_disable(){
294
- $options = $this->data->get_options();
295
- $disable_violation_warnings = isset( $options['violation-warnings-disable'] ) ? 1 : 0;
296
-
297
- ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[violation-warnings-disable]" value="1" <?php checked( 1, $disable_violation_warnings ); ?> />
298
- <?php _e( 'Disable warnings about potential violations of the AdSense terms.', 'advanced-ads' ); ?></label>
299
- <p class="description"><?php printf(__( 'Our <a href="%s" target="_blank">Ad Health</a> feature monitors if AdSense is implemented correctly on your site. It also considers ads not managed with Advanced Ads. Enable this option to remove these checks', 'advanced-ads' ), ADVADS_URL . 'manual/ad-health/#utm_source=advanced-ads&utm_medium=link&utm_campaign=backend-autoads-ads' ); ?></p><?php
300
- }
301
-
302
- /**
303
- * Render transparent background setting.
304
- */
305
- public function render_settings_adsense_background() {
306
- $options = $this->data->get_options();
307
- $background = $options['background'];
308
-
309
- ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[background]" value="1" <?php checked( $background ); ?> />
310
- <?php _e( 'Enable this option in case your theme adds an unfortunate background color to AdSense ads.', 'advanced-ads' ); ?></label><?php
311
- }
312
-
313
- /**
314
- * sanitize adsense settings
315
- *
316
- * @since 1.5.1
317
- * @param array $options all the options
318
- */
319
- public function sanitize_settings($options){
320
-
321
- // sanitize whatever option one wants to sanitize
322
- if(isset($options['adsense-id']) && $options['adsense-id'] != ''){
323
- // remove "ca-" prefix if it was added by the user
324
- if( 0 === strpos( $options['adsense-id'], 'ca-' ) ){
325
- $options['adsense-id'] = str_replace( 'ca-', '', $options['adsense-id'] );
326
- }
327
-
328
- if( 0 !== strpos( $options['adsense-id'], 'pub-' ) ){
329
- // add settings error
330
- add_settings_error(
331
- 'adsense-limit',
332
- 'settings_updated',
333
- __( 'The Publisher ID has an incorrect format. (must start with "pub-")', 'advanced-ads' ));
334
- }
335
- // trim publisher id
336
- $options['adsense-id'] = trim($options['adsense-id']);
337
- }
338
-
339
- return $options;
340
- }
341
-
342
- /**
343
- * add adsense setting tab
344
- *
345
- * @since 1.5.1
346
- * @param arr $tabs existing setting tabs
347
- * @return arr $tabs setting tabs with AdSense tab attached
348
- */
349
- public function setting_tabs(array $tabs){
350
-
351
- $tabs['adsense'] = array(
352
- 'page' => $this->settings_page_hook,
353
- 'group' => ADVADS_SLUG . '-adsense',
354
- 'tabid' => 'adsense',
355
- 'title' => __( 'AdSense', 'advanced-ads' )
356
- );
357
-
358
- return $tabs;
359
- }
360
-
361
- /**
362
- * sanitize ad settings
363
- * save publisher id from new ad unit if not given in main options
364
- *
365
- * @since 1.6.2
366
- * @param arr $ad_settings_post
367
- * @return arr $ad_settings_post
368
- */
369
- public function sanitize_ad_settings( array $ad_settings_post ){
370
-
371
- // check ad type
372
- if( ! isset( $ad_settings_post['type'] ) || 'adsense' !== $ad_settings_post['type'] ){
373
- return $ad_settings_post;
374
- }
375
-
376
- // save AdSense publisher ID if there is no one stored yet
377
- if ( ! empty($ad_settings_post['output']['adsense-pub-id']) ) {
378
- // get options
379
- $adsense_options = get_option( 'advanced-ads-adsense', array() );
380
-
381
- if ( empty( $adsense_options['adsense-id'] ) ) {
382
- $adsense_options['adsense-id'] = $ad_settings_post['output']['adsense-pub-id'];
383
- update_option( 'advanced-ads-adsense', $adsense_options );
384
- }
385
- }
386
- unset( $ad_settings_post['output']['adsense-pub-id'] );
387
-
388
- return $ad_settings_post;
389
- }
390
 
391
  /**
392
  * show AdSense ad specific notices in parameters box
@@ -476,6 +190,15 @@ class Advanced_Ads_AdSense_Admin {
476
  * @param type $hide_idle Whether to hide idle ads.
477
  */
478
  public static function get_mapi_ad_selector( $hide_idle_ads = true ) {
479
- require_once GADSENSE_BASE_PATH . 'admin/views/mapi-ad-selector.php';
 
 
 
 
 
 
 
 
 
480
  }
481
  }
12
 
13
  private function __construct() {
14
  $this->data = Advanced_Ads_AdSense_Data::get_instance();
 
 
 
15
 
16
  add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts') );
17
  add_action( 'admin_print_scripts', array($this, 'print_scripts') );
18
  add_filter( 'advanced-ads-list-ad-size', array($this, 'ad_details_column'), 10, 2 );
 
19
  add_filter( 'advanced-ads-ad-notices', array($this, 'ad_notices'), 10, 3 );
20
  }
21
 
58
  ('post-new.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type) ||
59
  ('post.php' == $pagenow && Advanced_Ads::POST_TYPE_SLUG == $post_type && isset($_GET['action']) && 'edit' == $_GET['action'])
60
  ) {
61
+ $scripts = array();
 
 
 
 
 
 
 
 
62
 
63
  // Allow modifications of script files to enqueue
64
  $scripts = apply_filters( 'advanced-ads-gadsense-ad-param-script', $scripts );
101
  }
102
  return self::$instance;
103
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  /**
106
  * show AdSense ad specific notices in parameters box
190
  * @param type $hide_idle Whether to hide idle ads.
191
  */
192
  public static function get_mapi_ad_selector( $hide_idle_ads = true ) {
193
+ global $closeable, $use_dashicons, $network, $ad_units, $unsupported_ad_type_link, $display_slot_id;
194
+ $closeable = true;
195
+ $use_dashicons = false;
196
+ $network = Advanced_Ads_Network_Adsense::get_instance();
197
+ $ad_units = $network->get_external_ad_units();
198
+ $unsupported_ad_type_link = Advanced_Ads_AdSense_MAPI::UNSUPPORTED_TYPE_LINK;
199
+ $display_slot_id = true;
200
+
201
+ require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-list.php';
202
+ require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-adsense.php';
203
  }
204
  }
modules/gadsense/admin/assets/js/adsense.js ADDED
@@ -0,0 +1,973 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * actually this method was moved inside the ad network class.
3
+ * however the responsive addon depends on it, so i made it global again.
4
+ * this makes it downward compatible (with an older version of responsive),
5
+ * but you should probably adjust the responsive plugin to make use of
6
+ * the static method (AdvancedAdsNetworkAdsense.gadsenseFormatAdContent)
7
+ *
8
+ * in case you come across a missing method originating from the deleted new-ad.js,
9
+ * please just make the methods static and create a wrapper function like the one below
10
+ */
11
+ window.gadsenseFormatAdContent = function() {
12
+ AdvancedAdsNetworkAdsense.gadsenseFormatAdContent();
13
+ };
14
+
15
+ class AdvancedAdsNetworkAdsense extends AdvancedAdsAdNetwork{
16
+ constructor(codes){
17
+ super('adsense');
18
+ this.name = 'adsense';
19
+ this.codes = codes;
20
+ this.parseCodeBtnClicked = false;
21
+ this.preventCloseAdSelector = false;
22
+ // this.adUnitName = null;
23
+ // the legacy code of gadsense executes a script inside a php template and will may not have been executed
24
+ // at this stage. the AdvancedAdsAdNetwork class already knows the publisher id, so we will overwrite
25
+ // the field in gadsenseData to be up to date at all times.
26
+ // TODO: the use of gadsenseData.pubId could be removed from this class in favor of this.vars.pubId
27
+ gadsenseData.pubId = this.vars.pubId;
28
+ }
29
+ openSelector(){
30
+
31
+ }
32
+
33
+ closeAdSelector(){
34
+ if (this.preventCloseAdSelector) return;
35
+ AdvancedAdsAdmin.AdImporter.closeAdSelector();
36
+ }
37
+
38
+ getSelectedId() {
39
+ const pubId = gadsenseData.pubId || false;
40
+ const slotId = $( '#unit-code' ).val().trim();
41
+ if (pubId && slotId)
42
+ return "ca-" + pubId + ":" + slotId;
43
+ return null;
44
+ }
45
+
46
+ selectAdFromList(slotId){
47
+ this.preventCloseAdSelector = true;
48
+ this.onSelectAd(slotId);
49
+ AdvancedAdsAdmin.AdImporter.openExternalAdsList();
50
+
51
+ // try to update the adsense stats dashboard
52
+ jQuery('#advads-gadsense-box').show();
53
+ jQuery( '.advanced-ads-adsense-dashboard' ).each( function(key,elm) {
54
+ var elmData = jQuery(elm).data('refresh');
55
+ if (elmData){
56
+ elmData = typeof(elmData) === 'string' ? JSON.parse(elmData) : elmData;
57
+ var unit_code = $('input#unit-code').val();
58
+ elmData.filter_value = unit_code;
59
+ elmData.requires_refresh = true;
60
+ jQuery(elm).data('refresh', elmData);
61
+ Advanced_Ads_Adsense_Helper.process_dashboard(elm);
62
+ }
63
+ });
64
+ }
65
+
66
+ updateAdFromList(slotId){
67
+ this.getRemoteCode(slotId);
68
+ }
69
+
70
+ getRefreshAdsParameters(){
71
+ return {
72
+ nonce: AdsenseMAPI.nonce,
73
+ action: 'advanced_ads_get_ad_units_adsense',
74
+ account: gadsenseData.pubId,
75
+ };
76
+ }
77
+
78
+ onManualSetup() {
79
+ $( '.advads-adsense-code' ).css( 'display', 'none' );
80
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
81
+ this.undoReadOnly();
82
+ // const name = (this.adUnitName) ? "( " + this.adUnitName + " ) " : "";
83
+ // $( '#advanced-ads-adsense-unit-name').text(name);
84
+ }
85
+
86
+ /**
87
+ * parse the code of an adsense ad and adjust the GUI
88
+ * call it, when an ad unit was selected.
89
+ * returns the parsed obj or false, when the ad code could not be parsed
90
+ */
91
+ processAdCode(code){
92
+ const parsed = this.parseAdContentFailsafe(code);
93
+ if ( parsed ) {
94
+ this.undoReadOnly();
95
+ this.setDetailsFromAdCode(parsed);
96
+ this.makeReadOnly();
97
+ $('#remote-ad-code-error').css('display', 'none');
98
+ $('#remote-ad-unsupported-ad-type').css('display', 'none');
99
+ this.closeAdSelector();
100
+ } else {
101
+ $( '#remote-ad-code-error' ).css( 'display', 'block' );
102
+ }
103
+ return parsed;
104
+ }
105
+
106
+ /**
107
+ * clone of legacy method
108
+ * @param slotID
109
+ */
110
+ onSelectAd( slotID ) {
111
+ if ( 'undefined' != typeof this.codes[ slotID ] ) {
112
+ this.getSavedDetails(slotID );
113
+ } else {
114
+ this.getRemoteCode( slotID );
115
+ }
116
+ }
117
+
118
+ /**
119
+ * legacy method
120
+ * @param slotID
121
+ */
122
+ getSavedDetails( slotID ) {
123
+ if ( 'undefined' != typeof this.codes[slotID] ) {
124
+ var code = this.codes[slotID];
125
+ var parsed = this.processAdCode(code);
126
+ if ( false !== parsed ) {
127
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
128
+ this.closeAdSelector();
129
+ this.preventCloseAdSelector = false;
130
+ }
131
+ }
132
+ }
133
+
134
+ /**
135
+ * legacy method
136
+ * @param slotID
137
+ */
138
+ getRemoteCode( slotID ) {
139
+
140
+ if ( '' == slotID ) return;
141
+ $( '#mapi-loading-overlay' ).css( 'display', 'block' );
142
+ const that = this;
143
+ $.ajax({
144
+ type: 'post',
145
+ url: ajaxurl,
146
+ data: {
147
+ nonce: AdsenseMAPI.nonce,
148
+ action: 'advads_mapi_get_adCode',
149
+ unit: slotID,
150
+ },
151
+ success: function(response,status,XHR){
152
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
153
+ if ( 'undefined' != typeof response.code ) {
154
+ $( '#remote-ad-code-msg' ).empty();
155
+ var parsed = that.processAdCode( response.code );
156
+ if ( false !== parsed ) {
157
+ that.codes[slotID] = response.code;
158
+ AdvancedAdsAdmin.AdImporter.unitIsSupported( slotID );
159
+ }
160
+ AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList();
161
+ // // Update quota message if needed
162
+ // if ( 1 == 0 ) {
163
+ // $( '#mapi-quota-message' ).text( response.quotaMsg );
164
+ // AdsenseMAPI.quota = response.quota;
165
+ // if ( 0 == response.quota ) {
166
+ // $( '#mapi-get-adcode,#mapi-get-adunits' ).prop( 'disabled', true );
167
+ // }
168
+ // }
169
+ that.closeAdSelector();
170
+
171
+ } else {
172
+ if ( 'undefined' != typeof response.raw ) {
173
+ $( '#remote-ad-code-msg' ).html( response.raw );
174
+ } else if( 'undefined' != typeof response.msg ) {
175
+ if ( 'undefined' != typeof response.reload ) {
176
+ AdvancedAdsAdmin.AdImporter.emptyMapiSelector( response.msg );
177
+ } else {
178
+ if ( 'doesNotSupportAdUnitType' == response.msg ) {
179
+ AdvancedAdsAdmin.AdImporter.unitIsNotSupported( slotID );
180
+ } else {
181
+ $( '#remote-ad-code-msg' ).html( response.msg );
182
+ }
183
+ }
184
+ if ( 'undefined' != typeof response.raw ) {
185
+ console.log( response.raw );
186
+ }
187
+ }
188
+ }
189
+ },
190
+ error: function(request,status,err){
191
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
192
+
193
+ },
194
+ });
195
+
196
+ }
197
+
198
+ /**
199
+ * legacy method
200
+ * Parse ad content.
201
+ *
202
+ * @return {!Object}
203
+ */
204
+ parseAdContent(content) {
205
+ var rawContent = ('undefined' != typeof(content))? content.trim() : '';
206
+ var theAd = {};
207
+ var theContent = $( '<div />' ).html( rawContent );
208
+ var adByGoogle = theContent.find( 'ins' );
209
+ theAd.slotId = adByGoogle.attr( 'data-ad-slot' ) || '';
210
+ if ('undefined' != typeof(adByGoogle.attr( 'data-ad-client' ))) {
211
+ theAd.pubId = adByGoogle.attr( 'data-ad-client' ).substr( 3 );
212
+ }
213
+
214
+ if (undefined !== theAd.slotId && '' != theAd.pubId) {
215
+ theAd.display = adByGoogle.css( 'display' );
216
+ theAd.format = adByGoogle.attr( 'data-ad-format' );
217
+ theAd.layout = adByGoogle.attr( 'data-ad-layout' ); // for InFeed and InArticle
218
+ theAd.layout_key = adByGoogle.attr( 'data-ad-layout-key' ); // for InFeed
219
+ theAd.style = adByGoogle.attr( 'style' ) || '';
220
+
221
+ /* normal ad */
222
+ if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf( 'width' )) {
223
+ theAd.type = 'normal';
224
+ theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
225
+ theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
226
+ }
227
+
228
+ /* Responsive ad, auto resize */
229
+ else if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
230
+ theAd.type = 'responsive';
231
+ }
232
+
233
+
234
+ /* older link unit format; for new ads the format type is no longer needed; link units are created through the AdSense panel */
235
+ else if ('undefined' != typeof(theAd.format) && 'link' == theAd.format) {
236
+
237
+ if( -1 != theAd.style.indexOf( 'width' ) ){
238
+ // is fixed size
239
+ theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
240
+ theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
241
+ theAd.type = 'link';
242
+ } else {
243
+ // is responsive
244
+ theAd.type = 'link-responsive';
245
+ }
246
+ }
247
+
248
+ /* Responsive Matched Content */
249
+ else if ('undefined' != typeof(theAd.format) && 'autorelaxed' == theAd.format) {
250
+ theAd.type = 'matched-content';
251
+ }
252
+
253
+ /* InArticle & InFeed ads */
254
+ else if ('undefined' != typeof(theAd.format) && 'fluid' == theAd.format) {
255
+
256
+ // InFeed
257
+ if('undefined' != typeof(theAd.layout) && 'in-article' == theAd.layout){
258
+ theAd.type = 'in-article';
259
+ } else {
260
+ // InArticle
261
+ theAd.type = 'in-feed';
262
+ }
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Synchronous code
268
+ */
269
+ if ( -1 != rawContent.indexOf( 'google_ad_slot' ) ) {
270
+ var _client = rawContent.match( /google_ad_client ?= ?["']([^'"]+)/ );
271
+ var _slot = rawContent.match( /google_ad_slot ?= ?["']([^'"]+)/ );
272
+ var _format = rawContent.match( /google_ad_format ?= ?["']([^'"]+)/ );
273
+ var _width = rawContent.match( /google_ad_width ?= ?([\d]+)/ );
274
+ var _height = rawContent.match( /google_ad_height ?= ?([\d]+)/ );
275
+
276
+ theAd = {};
277
+
278
+ theAd.pubId = _client[1].substr( 3 );
279
+
280
+ if ( null !== _slot ) {
281
+ theAd.slotId = _slot[1];
282
+ }
283
+ if ( null !== _format ) {
284
+ theAd.format = _format[1];
285
+ }
286
+ if ( null !== _width ) {
287
+ theAd.width = parseInt( _width[1] );
288
+ }
289
+ if ( null !== _height ) {
290
+ theAd.height = parseInt( _height[1] );
291
+ }
292
+
293
+ if ( 'undefined' == typeof theAd.format ) {
294
+ theAd.type = 'normal';
295
+ }
296
+
297
+ }
298
+
299
+ if ( '' == theAd.slotId && gadsenseData.pubId && '' != gadsenseData.pubId ) {
300
+ theAd.type = $( '#unit-type' ).val();
301
+ }
302
+
303
+ /* Page-Level ad */
304
+ if ( rawContent.indexOf( 'enable_page_level_ads' ) !== -1 ) {
305
+ theAd = { 'parse_message': 'pageLevelAd' };
306
+ }
307
+
308
+ else if ( ! theAd.type ) {
309
+ /* Unknown ad */
310
+ theAd = { 'parse_message': 'unknownAd' };
311
+ }
312
+
313
+ $( document ).trigger( 'gadsenseParseAdContent', [ theAd, adByGoogle ] );
314
+ return theAd;
315
+ }
316
+
317
+ parseAdContentFailsafe(code) {
318
+ if (typeof(code) == 'string'){
319
+ try {
320
+ const json = JSON.parse(code);
321
+ code = json;
322
+ } catch(e){}
323
+ }
324
+
325
+ return typeof(code) == 'object'
326
+ ? code
327
+ : this.parseAdContent( code );
328
+ }
329
+
330
+ /**
331
+ * Handle result of parsing content.
332
+ * legacy method
333
+ */
334
+ handleParseResult( parseResult ) {
335
+ $( '#pastecode-msg' ).empty();
336
+ switch ( parseResult.parse_message ) {
337
+ case 'pageLevelAd' :
338
+ advads_show_adsense_auto_ads_warning();
339
+ break;
340
+ case 'unknownAd' :
341
+ // Not recognized ad code
342
+ if ( this.parseCodeBtnClicked && 'post-new.php' == gadsenseData.pagenow ) {
343
+ // do not show if just after switching to AdSense ad type on ad creation
344
+ $( '#pastecode-msg' ).append( $( '<p />' ).css( 'color', 'red' ).html( gadsenseData.msg.unknownAd ) );
345
+ }
346
+ break;
347
+ default:
348
+ this.setDetailsFromAdCode( parseResult );
349
+ if ( 'undefined' != typeof AdsenseMAPI && 'undefined' != typeof AdsenseMAPI.hasToken && parseResult.pubId == AdsenseMAPI.pubId ) {
350
+ var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
351
+ this.mapiSaveAdCode( content, parseResult.slotId );
352
+ this.makeReadOnly();
353
+ }
354
+ $( '.advads-adsense-code' ).hide();
355
+ $( '.advads-adsense-show-code' ).show();
356
+ $( '#mapi-insert-code' ).show();
357
+ var SNT = this.getCustomInputs();
358
+ SNT.css( 'display', 'block' );
359
+ }
360
+ }
361
+
362
+ /**
363
+ * legacy method
364
+ * Set ad parameters fields from the result of parsing ad code
365
+ */
366
+ setDetailsFromAdCode(theAd) {
367
+ this.undoReadOnly();
368
+ $( '#unit-code' ).val( theAd.slotId );
369
+ $( '#advads-adsense-pub-id' ).val( theAd.pubId );
370
+ if ('normal' == theAd.type) {
371
+ $( '#unit-type' ).val( 'normal' );
372
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
373
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
374
+ }
375
+ if ('responsive' == theAd.type) {
376
+ $( '#unit-type' ).val( 'responsive' );
377
+ $( '#ad-resize-type' ).val( 'auto' );
378
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
379
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
380
+ }
381
+ if ('link' == theAd.type) {
382
+ $( '#unit-type' ).val( 'link' );
383
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
384
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
385
+ }
386
+ if ('link-responsive' == theAd.type) {
387
+ $( '#unit-type' ).val( 'link-responsive' );
388
+ $( '#ad-resize-type' ).val( 'auto' );
389
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
390
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
391
+ }
392
+ if ('matched-content' == theAd.type) {
393
+ $( '#unit-type' ).val( 'matched-content' );
394
+ $( '#ad-resize-type' ).val( 'auto' );
395
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
396
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
397
+ }
398
+ if ('in-article' == theAd.type) {
399
+ $( '#unit-type' ).val( 'in-article' );
400
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
401
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
402
+ }
403
+ if ('in-feed' == theAd.type) {
404
+ $( '#unit-type' ).val( 'in-feed' );
405
+ $( '#ad-layout' ).val( theAd.layout );
406
+ $( '#ad-layout-key' ).val( theAd.layout_key );
407
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
408
+ $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
409
+ }
410
+ var storedPubId = gadsenseData.pubId;
411
+
412
+ if ( '' !== storedPubId && theAd.pubId != storedPubId && '' != theAd.slotId ) {
413
+ $( '#adsense-ad-param-error' ).text( gadsenseData.msg.pubIdMismatch );
414
+ } else {
415
+ $( '#adsense-ad-param-error' ).empty();
416
+ }
417
+ $( document ).trigger( 'this.setDetailsFromAdCode', [ theAd ] );
418
+ $( '#unit-type' ).trigger( 'change' );
419
+ }
420
+
421
+ /**
422
+ * legacy method
423
+ * Format the post content field
424
+ */
425
+ static gadsenseFormatAdContent() {
426
+ var slotId = $( '#ad-parameters-box #unit-code' ).val();
427
+ var unitType = $( '#ad-parameters-box #unit-type' ).val();
428
+ var publisherId = $( '#advads-adsense-pub-id' ).val() ? $( '#advads-adsense-pub-id' ).val() : gadsenseData.pubId;
429
+ var adContent = {
430
+ slotId: slotId,
431
+ unitType: unitType,
432
+ pubId: publisherId,
433
+ };
434
+ if ('responsive' == unitType) {
435
+ var resize = $( '#ad-parameters-box #ad-resize-type' ).val();
436
+ if (0 == resize) { resize = 'auto'; }
437
+ adContent.resize = resize;
438
+ }
439
+ if ('in-feed' == unitType) {
440
+ adContent.layout = $( '#ad-parameters-box #ad-layout' ).val();
441
+ adContent.layout_key = $( '#ad-parameters-box #ad-layout-key' ).val();
442
+ }
443
+ if ('undefined' != typeof(adContent.resize) && 'auto' != adContent.resize) {
444
+ $( document ).trigger( 'gadsenseFormatAdResponsive', [adContent] );
445
+ }
446
+ $( document ).trigger( 'gadsenseFormatAdContent', [adContent] );
447
+
448
+ if ('undefined' != typeof(window.gadsenseAdContent)) {
449
+ adContent = window.gadsenseAdContent;
450
+ delete( window.gadsenseAdContent );
451
+ }
452
+ $( '#advads-ad-content-adsense' ).val( JSON.stringify( adContent, false, 2 ) );
453
+
454
+ }
455
+
456
+ /**
457
+ * legacy method
458
+ */
459
+ updateAdsenseType(){
460
+ var type = $( '#unit-type' ).val();
461
+ $( '.advads-adsense-layout' ).hide();
462
+ $( '.advads-adsense-layout' ).next('div').hide();
463
+ $( '.advads-adsense-layout-key' ).hide();
464
+ $( '.advads-adsense-layout-key' ).next('div').hide();
465
+ $( '.advads-ad-notice-in-feed-add-on' ).hide();
466
+ if ( 'responsive' == type || 'link-responsive' == type || 'matched-content' == type ) {
467
+ $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
468
+ $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
469
+ $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
470
+ $( '.clearfix-before' ).show();
471
+ } else if ( 'in-feed' == type ) {
472
+ $( '.advads-adsense-layout' ).css( 'display', 'block' );
473
+ $( '.advads-adsense-layout' ).next('div').css( 'display', 'block' );
474
+ $( '.advads-adsense-layout-key' ).css( 'display', 'block' );
475
+ $( '.advads-adsense-layout-key' ).next('div').css( 'display', 'block' );
476
+ $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
477
+ $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
478
+ $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
479
+ // show add-on notice
480
+ $( '.advads-ad-notice-in-feed-add-on' ).show();
481
+ $( '.clearfix-before' ).show();
482
+ } else if ( 'in-article' == type ) {
483
+ $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
484
+ $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
485
+ $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
486
+ $( '.clearfix-before' ).show();
487
+ } else if ( 'normal' == type || 'link' == type ) {
488
+ $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'block' );
489
+ $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'block' );
490
+ $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'block' );
491
+ $( '.clearfix-before' ).hide();
492
+
493
+ if ( ! $( '[name="advanced_ad\[width\]"]' ).val() ) {
494
+ $( '[name="advanced_ad\[width\]"]' ).val( '300' );
495
+ }
496
+ if ( ! $( '[name="advanced_ad\[height\]"]' ).val() ) {
497
+ $( '[name="advanced_ad\[height\]"]' ).val( '250' );
498
+ }
499
+ }
500
+ $( document ).trigger( 'gadsenseUnitChanged' );
501
+ AdvancedAdsNetworkAdsense.gadsenseFormatAdContent();
502
+
503
+ this.show_float_warnings( type );
504
+ }
505
+
506
+ /**
507
+ * legacy method
508
+ * Show / hide position warning.
509
+ */
510
+ show_float_warnings( unit_type ) {
511
+ var resize_type = $('#ad-resize-type').val();
512
+ var position = $( '#advanced-ad-output-position input[name="advanced_ad[output][position]"]:checked' ).val();
513
+
514
+ if (
515
+ ( -1 !== [ 'link-responsive', 'matched-content', 'in-article', 'in-feed' ].indexOf( unit_type )
516
+ || ( 'responsive' === unit_type && 'manual' !== resize_type )
517
+ )
518
+ && ( 'left' == position || 'right' == position )
519
+ ) {
520
+ $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').show();
521
+ } else {
522
+ $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').hide();
523
+ }
524
+ }
525
+
526
+ /**
527
+ * legacy method - adds readonly to relevant inputs
528
+ */
529
+ makeReadOnly() {
530
+ $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', true );
531
+ $( '#unit-type option:not(:selected)' ).prop( 'disabled', true );
532
+ }
533
+
534
+ /**
535
+ * legacy method - removes readonly from relevant inputs (original name getSlotAndType_jq)
536
+ */
537
+ undoReadOnly() {
538
+ $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', false );
539
+ $( '#unit-type option:not(:selected)' ).prop( 'disabled', false );
540
+ }
541
+
542
+ getCustomInputs() {
543
+ var $div1 = $( '#unit-code' ).closest( 'div' );
544
+ var $label1 = $div1.prev();
545
+ var $hr1 = $div1.next();
546
+ var $label2 = $hr1.next();
547
+ var $div2 = $label2.next();
548
+
549
+ var $elems = $div1.add( $label1 ).add( $hr1 ).add( $label2 ).add( $div2 );
550
+ return $elems;
551
+ }
552
+
553
+ onSelected(){
554
+ //handle a click from the "Switch to AdSense ad" button
555
+ if (AdvancedAdsAdmin.AdImporter.adsenseCode){
556
+ this.parseCodeBtnClicked = true;
557
+ const parseResult = this.parseAdContent(AdvancedAdsAdmin.AdImporter.adsenseCode);
558
+ AdvancedAdsAdmin.AdImporter.adsenseCode = null;
559
+ this.handleParseResult( parseResult );
560
+ }
561
+ else{
562
+ // when you are not connected to adsense, or if the ad was edited manually open the manual setup view
563
+ let switchToManualSetup = ! this.vars.connected;
564
+ if (! switchToManualSetup) {
565
+ const code = this.codes[this.getSelectedId()];
566
+ const parsedAd = this.parseAdContentFailsafe(code);
567
+ if (parsedAd) {
568
+ // check
569
+ // we need to check if the type of the ad is different from the default. this marks a manually setup ad.
570
+ const unitType = $('#unit-type').val();
571
+ if (parsedAd.type != unitType) {
572
+ //this ad was manually setup. don't open the selector, but switch to manual select.
573
+ switchToManualSetup = true;
574
+
575
+ }
576
+ }
577
+ }
578
+ if (switchToManualSetup) {
579
+ AdvancedAdsAdmin.AdImporter.manualSetup();
580
+ }
581
+ else if (AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList() || ! this.getSelectedId()){
582
+ AdvancedAdsAdmin.AdImporter.openExternalAdsList();
583
+ }
584
+ }
585
+
586
+ }
587
+
588
+ onDomReady() {
589
+ const that = this;
590
+ $( document ).on( 'click', '.advads-adsense-close-code', function( ev ) {
591
+ ev.preventDefault();
592
+ that.onSelected();
593
+ } );
594
+
595
+ $( document ).on('click', '.advads-adsense-submit-code', function(ev){
596
+ ev.preventDefault();
597
+ that.parseCodeBtnClicked = true;
598
+ var rawContent = $( '.advads-adsense-content' ).val();
599
+ var parseResult = that.parseAdContent( rawContent );
600
+ that.handleParseResult( parseResult );
601
+ if (AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList()){
602
+ AdvancedAdsAdmin.AdImporter.openExternalAdsList();
603
+ that.preventCloseAdSelector = true;
604
+ }
605
+ else{
606
+ // no adsense ad with this slot id was found
607
+ // switches to manual ad setup view
608
+ that.preventCloseAdSelector = false;
609
+ AdvancedAdsAdmin.AdImporter.manualSetup();
610
+ }
611
+ });
612
+
613
+ $( document ).on('change', '#unit-type, #unit-code', function (ev) {
614
+ that.checkAdSlotId(this);
615
+ });
616
+
617
+ let inputCode = $('#unit-code');
618
+ if (inputCode) {
619
+ this.checkAdSlotId(inputCode[0]);
620
+ }
621
+
622
+ $( document ).on( 'change', '#ad-resize-type', function( ev ) {
623
+ that.show_float_warnings( 'responsive' );
624
+ } );
625
+ this.updateAdsenseType();
626
+
627
+ if ( 'undefined' != typeof AdsenseMAPI.hasToken ) {
628
+ try {
629
+ this.mapiMayBeSaveAdCode();
630
+ } catch (ex) {}
631
+ }
632
+
633
+ this.onSelected();
634
+ }
635
+
636
+ checkAdSlotId(elm) {
637
+ if ( 'unit-code' == $( elm ).attr( 'id' ) ) {
638
+ var val = $( elm ).val();
639
+ if (val) val = val.trim();
640
+ if ( val.length > 0 && ( gadsenseData.pubId && -1 != val.indexOf( gadsenseData.pubId.substr( 4 ) ) ) ) {
641
+ // if ( val.length > 0 && -1 != val.indexOf( gadsenseData.pubId.substr( 4 ) ) ) {
642
+ $( '#advads-pubid-in-slot' ).css( 'display', 'block' );
643
+ $( elm ).css( 'background-color', 'rgba(255, 235, 59, 0.33)' );
644
+ } else {
645
+ $( '#unit-code' ).css( 'background-color', '#fff' );
646
+ $( '#advads-pubid-in-slot' ).css( 'display', 'none' );
647
+ }
648
+ } else {
649
+ $( '#unit-code' ).css( 'background-color', '#fff' );
650
+ $( '#advads-pubid-in-slot' ).css( 'display', 'none' );
651
+ }
652
+ this.updateAdsenseType();
653
+ }
654
+
655
+ mapiSaveAdCode( code, slot ) {
656
+ if ( 'undefined' != typeof AdsenseMAPI.hasToken && 'undefined' == typeof this.codes[ 'ca-' + AdsenseMAPI.pubId + ':' + slot ] ) {
657
+ this.codes['ca-' + AdsenseMAPI.pubId + ':' + slot] = code;
658
+ $( '#mapi-loading-overlay' ).css( 'display', 'block' );
659
+ $.ajax({
660
+ type: 'post',
661
+ url: ajaxurl,
662
+ data: {
663
+ nonce: AdsenseMAPI.nonce,
664
+ slot: slot,
665
+ code: code,
666
+ action: 'advads-mapi-reconstructed-code',
667
+ },
668
+ success: function( resp, status, XHR ) {
669
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
670
+ },
671
+ error: function( req, status, err ) {
672
+ $( '#mapi-loading-overlay' ).css( 'display', 'none' );
673
+ },
674
+ });
675
+ }
676
+ }
677
+
678
+ mapiMayBeSaveAdCode(){
679
+ // MAPI not set up
680
+ if ( 'undefined' == typeof AdsenseMAPI.hasToken ) return;
681
+ var slotId = $( '#unit-code' ).val();
682
+ if ( !slotId ) return;
683
+
684
+ var type = $( '#unit-type' ).val();
685
+ var width = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val().trim();
686
+ var height = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val().trim();
687
+ var layout = $( '#ad-layout' ).val();
688
+ var layoutKey = $( '#ad-layout-key' ).val();
689
+
690
+ var code = false;
691
+
692
+ switch ( type ) {
693
+ case 'in-feed':
694
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
695
+ '<ins class="adsbygoogle" ' +
696
+ 'style="display:block;" ' +
697
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
698
+ 'data-ad-slot="' + slotId + '" ' +
699
+ 'data-ad-layout-key="' + layoutKey + '" ';
700
+ if ( '' != layout ) {
701
+ code += 'data-ad-layout="' + layout + '" ';
702
+ }
703
+ code += 'data-ad-format="fluid"></ins>' +
704
+ '<script>' +
705
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
706
+ '</script>';
707
+ break;
708
+ case 'in-article':
709
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
710
+ '<ins class="adsbygoogle" ' +
711
+ 'style="display:block;text-align:center;" ' +
712
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
713
+ 'data-ad-slot="' + slotId + '" ' +
714
+ 'data-ad-layout="in-article" ' +
715
+ 'data-ad-format="fluid"></ins>' +
716
+ '<script>' +
717
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
718
+ '</script>';
719
+ break;
720
+ case 'matched-content':
721
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
722
+ '<ins class="adsbygoogle" ' +
723
+ 'style="display:block;" ' +
724
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
725
+ 'data-ad-slot="' + slotId + '" ' +
726
+ 'data-ad-format="autorelaxed"></ins>' +
727
+ '<script>' +
728
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
729
+ '</script>';
730
+ break;
731
+ case 'link-responsive':
732
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
733
+ '<ins class="adsbygoogle" ' +
734
+ 'style="display:block;" ' +
735
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
736
+ 'data-ad-slot="' + slotId + '" ' +
737
+ 'data-ad-format="link"></ins>' +
738
+ '<script>' +
739
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
740
+ '</script>';
741
+ break;
742
+ case 'link':
743
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
744
+ '<ins class="adsbygoogle" ' +
745
+ 'style="display:block;width:' + width + 'px;height:' + height + 'px" ' +
746
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
747
+ 'data-ad-slot="' + slotId + '" ' +
748
+ 'data-ad-format="link"></ins>' +
749
+ '<script>' +
750
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
751
+ '</script>';
752
+ break;
753
+ case 'responsive':
754
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
755
+ '<ins class="adsbygoogle" ' +
756
+ 'style="display:block;" ' +
757
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
758
+ 'data-ad-slot="' + slotId + '" ' +
759
+ 'data-ad-format="auto"></ins>' +
760
+ '<script>' +
761
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
762
+ '</script>';
763
+ break;
764
+ case 'normal':
765
+ code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
766
+ '<ins class="adsbygoogle" ' +
767
+ 'style="display:inline-block;width:' + width + 'px;height:' + height + 'px" ' +
768
+ 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
769
+ 'data-ad-slot="' + slotId + '"></ins>' +
770
+ '<script>' +
771
+ '(adsbygoogle = window.adsbygoogle || []).push({});' +
772
+ '</script>';
773
+ break;
774
+ default:
775
+ }
776
+
777
+ if ( code ) {
778
+ this.mapiSaveAdCode( code, slotId );
779
+ }
780
+
781
+ }
782
+
783
+ }
784
+
785
+ window.Advanced_Ads_Adsense_Helper = window.Advanced_Ads_Adsense_Helper || {
786
+ build_dropdown: function(selected, values){
787
+ const dropdown = {};
788
+ const container = jQuery('<div class="advads-stats-dd-container"/>');
789
+ const button = jQuery('<div class="advads-stats-dd-button"><span class="dashicons dashicons-admin-multisite"></span></div>');
790
+ container.append(button);
791
+ const fc = jQuery('<div style="right:0; width:300px; position:absolute; display:none;"/>');
792
+ const items = jQuery('<div class="advads-stats-dd-items"/>');
793
+ for (let i in values){
794
+ const val = values[i];
795
+ const itm = jQuery('<div class="advads-stats-dd-item">' + val + '</div>');
796
+ // if (selected === val) itm.addClass("advads-stats-dd-item-selected");
797
+ if (selected === i) itm.addClass("advads-stats-dd-item-selected");
798
+ itm.data('key', i);
799
+ itm.data('val', val);
800
+ itm[0].onclick = function(evt){
801
+ jQuery(fc).fadeOut('fast');
802
+ const key = jQuery(this).data('key');
803
+ if (dropdown.onclick) dropdown.onclick(key);
804
+ }
805
+ items.append(itm);
806
+ }
807
+ container.append(fc);
808
+ fc.append(items);
809
+
810
+ button[0].onclick = function(e){
811
+ e.stopPropagation();
812
+ jQuery(fc).fadeToggle('fast');
813
+ };
814
+ jQuery(document).click(function(){
815
+ jQuery(fc).fadeOut('fast');
816
+ });
817
+
818
+ dropdown.elm = container;
819
+ return dropdown;
820
+ },
821
+
822
+
823
+ loading_spinner: function(elm, visible){
824
+ let spinner = jQuery(elm).find("div[spinner='1']");;
825
+ if (spinner && spinner.length){
826
+ spinner = spinner[0];
827
+ }
828
+ else{
829
+ spinner = jQuery('<div spinner="1" style="height:100%; width:100%; position:absolute; left:0; top:0;"><div style="z-index:2; background-color: rgba(200,200,200,0.5); height:100%; vertical-align:middle; text-align:center;"><span class="spinner advads-ad-parameters-spinner advads-spinner"/></div></div>');
830
+ elm.append(spinner);
831
+ }
832
+ if (visible) jQuery(spinner).show();
833
+ else jQuery(spinner).hide();
834
+ },
835
+
836
+ build_dashboard: function(summary, elm){
837
+ if (! summary) summary = {};
838
+ const container = jQuery('<div/>');
839
+ Advanced_Ads_Adsense_Helper.loading_spinner(container, true);
840
+
841
+ if (summary.dimensions){
842
+ const dimensions = summary.dimensions;
843
+ if (! dimensions['*']) dimensions['*'] = advadstxt.all;
844
+ if (! summary.filter_value) summary.filter_value = "*";
845
+ // const selected = summary.dimension || dimensions['*'];
846
+ const dd = Advanced_Ads_Adsense_Helper.build_dropdown(summary.filter_value, dimensions);
847
+ dd.onclick = function(val){
848
+ Advanced_Ads_Adsense_Helper.request_dashboard(elm, {dimension_name: summary.dimension_name, filter: val});
849
+ };
850
+ container.append(dd.elm);
851
+ }
852
+ if (summary.age){
853
+ container.append(jQuery('<div style="clear: right; float:right; text-align:right; color:#bbbbbb; margin-top:5px;">' + summary.age + '</div>'));
854
+ }
855
+
856
+ // when there is no filter value, this usually means that there is no data for this ad
857
+ // i used to display a general error message (advadstxt.no_results), but this looks too much like an error
858
+ // and that's why we will ignore it for now and simply display a bunch of zeroes
859
+ // if (summary.filterValueExists != undefined && ! summary.filterValueExists){
860
+ // summary.valid = false;
861
+ // summary.errors = summary.errors || [];
862
+ // summary.errors.push(advadstxt.no_results);
863
+ // }
864
+
865
+ const dflex = jQuery('<div class="advads-flex"/>')
866
+ container.append(dflex);
867
+
868
+ if (summary.errors) {
869
+ const derrors = jQuery('<ul class="advads-error-message"/>')
870
+ container.append(derrors);
871
+ for (let i in summary.errors) {
872
+ const msg = advadstxt.error_message.replace('\%1$s', summary.errors[i]);
873
+ derrors.append(jQuery('<li>' + msg + '</li>'));
874
+ }
875
+ }
876
+ else {
877
+ if (!summary.valid || !summary.earningsToday) {
878
+ // we might have some old data floating around...
879
+ if (Advanced_Ads_Adsense_Helper.lastSummary) {
880
+ summary = Advanced_Ads_Adsense_Helper.lastSummary;
881
+ } else {
882
+ summary.earningsToday = summary.earningsYesterday = summary.earnings7Days = summary.earningsThisMonth = summary.earnings28Days = '...';
883
+ }
884
+ } else if (summary.valid) {
885
+ // remember the summary to be able to quickly fall back in case of a future error
886
+ Advanced_Ads_Adsense_Helper.lastSummary = summary;
887
+ }
888
+ dflex.append(Advanced_Ads_Adsense_Helper.build_dashboard_item(advadstxt.today, summary.earningsToday));
889
+ dflex.append(Advanced_Ads_Adsense_Helper.build_dashboard_item(advadstxt.yesterday, summary.earningsYesterday));
890
+ dflex.append(Advanced_Ads_Adsense_Helper.build_dashboard_item(advadstxt.last_n_days.replace('\%1$d', 7), summary.earnings7Days));
891
+ dflex.append(Advanced_Ads_Adsense_Helper.build_dashboard_item(advadstxt.this_month, summary.earningsThisMonth));
892
+ dflex.append(Advanced_Ads_Adsense_Helper.build_dashboard_item(advadstxt.last_n_days.replace('\%1$d', 28), summary.earnings28Days));
893
+ }
894
+ return container;
895
+ },
896
+
897
+ build_dashboard_item: function(title, main){
898
+ const d = jQuery('<div class="advads-flex1 advads-stats-box"/>');
899
+ d.append(jQuery('<div>' + title + '</div>'));
900
+ d.append(jQuery('<div class="advads-stats-box-main">' + main + '</div>'));
901
+ return d;
902
+ },
903
+
904
+ process_dashboard: function(elm){
905
+ let elmData = jQuery(elm).data('refresh');
906
+ if (elmData){
907
+ try {
908
+ elmData = typeof (elmData) === 'string' ? JSON.parse(elmData) : elmData;
909
+ }
910
+ catch (e){
911
+ elmData = null;
912
+ }
913
+ }
914
+ if (elmData) {
915
+ Advanced_Ads_Adsense_Helper.render_dashboard(elm, elmData);
916
+ }
917
+ const requires_refresh = !elmData || elmData.requires_refresh;
918
+ if (requires_refresh){
919
+ const extraData = {};
920
+ if (elmData){
921
+ if (elmData.dimension_name) extraData.dimension_name = elmData.dimension_name;
922
+ if (elmData.filter_value) extraData.filter = elmData.filter_value;
923
+ }
924
+ Advanced_Ads_Adsense_Helper.request_dashboard(elm, extraData);
925
+ }
926
+ },
927
+
928
+ render_dashboard: function(elm, summary){
929
+ jQuery(elm).html('').append(Advanced_Ads_Adsense_Helper.build_dashboard(summary, elm));
930
+ Advanced_Ads_Adsense_Helper.loading_spinner(elm, false);
931
+ const metabox_selector = jQuery(elm).data('metabox_selector');
932
+ if (metabox_selector) {
933
+ if (summary.hidden) {
934
+ jQuery(metabox_selector).hide();
935
+ } else {
936
+ jQuery(metabox_selector).show();
937
+ }
938
+ }
939
+ },
940
+
941
+ request_dashboard: function(elm, extraData){
942
+ const data = {
943
+ nonce: Advanced_Ads_Adsense_Helper.nonce,
944
+ action: 'advads_gadsense_dashboard',
945
+ account: gadsenseData.pubId
946
+ };
947
+ if (extraData) for (let i in extraData) data[i] = extraData[i];
948
+ Advanced_Ads_Adsense_Helper.loading_spinner(elm, true);
949
+ Advanced_Ads_Adsense_Helper.process_request(data, function(response){
950
+ Advanced_Ads_Adsense_Helper.render_dashboard(elm, response.summary);
951
+ jQuery(elm).data('refresh', response.summary);
952
+ });
953
+ },
954
+
955
+ process_request: function(data, success){
956
+ jQuery.ajax({
957
+ type: 'post',
958
+ url: ajaxurl,
959
+ data: data,
960
+ success: function(response,status,XHR){
961
+ if (response.errors && response.errors.length > 0){
962
+ let txt = "";
963
+ for (let i in response.errors) txt += response.errors[i] + "\n";
964
+ console.log("Error while processing AdSense stats: " + txt);
965
+ }
966
+ success(response,status,XHR);
967
+ },
968
+ error: function(request,status,err){
969
+ },
970
+ });
971
+ },
972
+
973
+ };
modules/gadsense/admin/assets/js/new-ad.js DELETED
@@ -1,901 +0,0 @@
1
- /**
2
- * Advanced Ads.
3
- *
4
- * @author Thomas Maier <thomas.maier@webgilde.com>
5
- * @license GPL-2.0+
6
- * @link http://webgilde.com
7
- * @copyright 2013-2018 Thomas Maier, webgilde GmbH
8
- */
9
- ;
10
- (function ($) {
11
- "use strict";
12
- var parseCodeBtnClicked = false;
13
- $( document ).on( 'click', '.prevent-default', function( ev ) { ev.preventDefault() } );
14
-
15
- function reloadAdparameter( connect ) {
16
-
17
- $( '#advanced-ad-type input' ).prop( 'disabled', true );
18
- $( '#advanced-ads-tinymce-wrapper' ).hide();
19
- $( '#advanced-ads-ad-parameters' ).html( '<span class="spinner advads-ad-parameters-spinner advads-spinner"></span>' );
20
-
21
- $.ajax({
22
- type: 'POST',
23
- url: ajaxurl,
24
- data: {
25
- 'action': 'load_ad_parameters_metabox',
26
- 'ad_type': 'adsense',
27
- 'ad_id': $( '#post_ID' ).val(),
28
- 'nonce': advadsglobal.ajax_nonce
29
- },
30
- success: function (data, textStatus, XMLHttpRequest) {
31
- // toggle main content field
32
- if (data) {
33
- $( '#advanced-ads-ad-parameters' ).html( data ).trigger( 'paramloaded' );
34
- $( '#mapi-open-selector a' ).trigger( 'click' );
35
- advads_maybe_textarea_to_tinymce( 'adsense' );
36
- }
37
- },
38
- error: function (MLHttpRequest, textStatus, errorThrown) {
39
- $( '#advanced-ads-ad-parameters' ).html( errorThrown );
40
- }
41
- }).always( function ( MLHttpRequest, textStatus, errorThrown ) {
42
- $( '#advanced-ad-type input').prop( 'disabled', false );
43
- connect.hide();
44
- });
45
-
46
- }
47
-
48
- $( document ).on( 'click', '#mapi-connect-adsense', function ( ev ) {
49
- ev.preventDefault();
50
- if ( 'undefined' != typeof window.advadsMapiConnect ) {
51
- window.advadsMapiConnect( 'confirm-code', {onSuccess:reloadAdparameter} );
52
- }
53
- } );
54
-
55
- function getSlotAndType_jq() {
56
- var $div1 = $( '#unit-code' ).closest( 'div' );
57
- var $label1 = $div1.prev();
58
- var $hr1 = $div1.next();
59
- var $label2 = $hr1.next();
60
- var $div2 = $label2.next();
61
-
62
- var $elems = $div1.add( $label1 ).add( $hr1 ).add( $label2 ).add( $div2 );
63
- return $elems;
64
- }
65
-
66
- function resizeAdListHeader() {
67
- var th = $( '#mapi-list-header span' );
68
- var tb = $( '#mapi-table-wrap tbody tr' );
69
- var w = [];
70
-
71
- tb.first().find( 'td' ).each(function(){
72
- w.push( $( this ).width() );
73
- });
74
-
75
- th.each(function(i){
76
- if ( i != w.length - 1 ) {
77
- $( this ).width( w[i] );
78
- }
79
- });
80
- }
81
-
82
- $( window ).resize(function(){
83
- if ( $( '#mapi-wrap' ).length && $( '#mapi-wrap' ).is( ':visible' ) ) {
84
- resizeAdListHeader();
85
- }
86
- });
87
-
88
- function MapiMayBeSaveAdCode(){
89
-
90
- // MAPI not set up
91
- if ( 'undefined' == typeof AdsenseMAPI.hasToken ) return;
92
-
93
- var slotId = $( '#unit-code' ).val();
94
- if ( !slotId ) return;
95
-
96
- var type = $( '#unit-type' ).val();
97
- var width = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val().trim();
98
- var height = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val().trim();
99
- var layout = $( '#ad-layout' ).val();
100
- var layoutKey = $( '#ad-layout-key' ).val();
101
-
102
- var code = false;
103
-
104
- switch ( type ) {
105
- case 'in-feed':
106
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
107
- '<ins class="adsbygoogle" ' +
108
- 'style="display:block;" ' +
109
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
110
- 'data-ad-slot="' + slotId + '" ' +
111
- 'data-ad-layout-key="' + layoutKey + '" ';
112
- if ( '' != layout ) {
113
- code += 'data-ad-layout="' + layout + '" ';
114
- }
115
- code += 'data-ad-format="fluid"></ins>' +
116
- '<script>' +
117
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
118
- '</script>';
119
- break;
120
- case 'in-article':
121
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
122
- '<ins class="adsbygoogle" ' +
123
- 'style="display:block;text-align:center;" ' +
124
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
125
- 'data-ad-slot="' + slotId + '" ' +
126
- 'data-ad-layout="in-article" ' +
127
- 'data-ad-format="fluid"></ins>' +
128
- '<script>' +
129
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
130
- '</script>';
131
- break;
132
- case 'matched-content':
133
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
134
- '<ins class="adsbygoogle" ' +
135
- 'style="display:block;" ' +
136
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
137
- 'data-ad-slot="' + slotId + '" ' +
138
- 'data-ad-format="autorelaxed"></ins>' +
139
- '<script>' +
140
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
141
- '</script>';
142
- break;
143
- case 'link-responsive':
144
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
145
- '<ins class="adsbygoogle" ' +
146
- 'style="display:block;" ' +
147
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
148
- 'data-ad-slot="' + slotId + '" ' +
149
- 'data-ad-format="link"></ins>' +
150
- '<script>' +
151
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
152
- '</script>';
153
- break;
154
- case 'link':
155
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
156
- '<ins class="adsbygoogle" ' +
157
- 'style="display:block;width:' + width + 'px;height:' + height + 'px" ' +
158
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
159
- 'data-ad-slot="' + slotId + '" ' +
160
- 'data-ad-format="link"></ins>' +
161
- '<script>' +
162
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
163
- '</script>';
164
- break;
165
- case 'responsive':
166
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
167
- '<ins class="adsbygoogle" ' +
168
- 'style="display:block;" ' +
169
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
170
- 'data-ad-slot="' + slotId + '" ' +
171
- 'data-ad-format="auto"></ins>' +
172
- '<script>' +
173
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
174
- '</script>';
175
- break;
176
- case 'normal':
177
- code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
178
- '<ins class="adsbygoogle" ' +
179
- 'style="display:inline-block;width:' + width + 'px;height:' + height + 'px" ' +
180
- 'data-ad-client="ca-' + AdsenseMAPI.pubId + '" ' +
181
- 'data-ad-slot="' + slotId + '"></ins>' +
182
- '<script>' +
183
- '(adsbygoogle = window.adsbygoogle || []).push({});' +
184
- '</script>';
185
- break;
186
- default:
187
- }
188
-
189
- if ( code ) {
190
- MapiSaveAdCode( code, slotId );
191
- }
192
-
193
- }
194
-
195
- function MapiSaveAdCode( code, slot ) {
196
- if ( 'undefined' != typeof AdsenseMAPI.hasToken && 'undefined' == typeof AdsenseMAPI.codes[ 'ca-' + AdsenseMAPI.pubId + ':' + slot ] ) {
197
- AdsenseMAPI.codes['ca-' + AdsenseMAPI.pubId + ':' + slot] = code;
198
- $( '#mapi-loading-overlay' ).css( 'display', 'block' );
199
- $.ajax({
200
- type: 'post',
201
- url: ajaxurl,
202
- data: {
203
- nonce: AdsenseMAPI.nonce,
204
- slot: slot,
205
- code: code,
206
- action: 'advads-mapi-reconstructed-code',
207
- },
208
- success: function( resp, status, XHR ) {
209
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
210
- },
211
- error: function( req, status, err ) {
212
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
213
- },
214
- });
215
- }
216
- }
217
-
218
- function makeReadOnly() {
219
- $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', true );
220
- $( '#unit-type option:not(:selected)' ).prop( 'disabled', true );
221
- }
222
-
223
- function undoReadOnly() {
224
- $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', false );
225
- $( '#unit-type option:not(:selected)' ).prop( 'disabled', false );
226
- }
227
-
228
- function closeAdSelector() {
229
-
230
- // close the ad unit selector
231
- setTimeout(function(){
232
- $( '#mapi-wrap' ).animate(
233
- { height: 0, },
234
- 360,
235
- function(){
236
- $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
237
- $( '#mapi-wrap' ).css({
238
- display: 'none',
239
- height: 'auto',
240
- });
241
- var SNT = getSlotAndType_jq();
242
- SNT.css( 'display', 'block' );
243
- }
244
- );
245
- }, 80);
246
-
247
- }
248
-
249
- function emptyMapiSelector( msg ) {
250
- var nag = '<div class="notice notice-error" style="font-size:1.1em;padding:.6em 1em;font-weight:bold;">' + msg + '</div>';
251
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
252
- $( '#mapi-wrap' ).html( $( nag ) );
253
- }
254
-
255
- /**
256
- * Show / hide position warning.
257
- */
258
- function show_float_warnings( unit_type ) {
259
- var resize_type = $('#ad-resize-type').val();
260
- var position = $( '#advanced-ad-output-position input[name="advanced_ad[output][position]"]:checked' ).val();
261
-
262
- if (
263
- ( -1 !== [ 'link-responsive', 'matched-content', 'in-article', 'in-feed' ].indexOf( unit_type )
264
- || ( 'responsive' === unit_type && 'manual' !== resize_type )
265
- )
266
- && ( 'left' == position || 'right' == position )
267
- ) {
268
- $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').show();
269
- } else {
270
- $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').hide();
271
- }
272
- }
273
-
274
-
275
- // On DOM ready
276
- $(function () {
277
- $( document ).on('click', '.advads-adsense-show-code', function(e){
278
- e.preventDefault();
279
- $( '.advads-adsense-code' ).show();
280
- $( '#mapi-open-selector' ).css( 'display', 'inline' );
281
- $( '#mapi-wrap' ).css( 'display', 'none' );
282
- var SNT = getSlotAndType_jq();
283
- SNT.css( 'display', 'none' );
284
- $( this ).hide();
285
- })
286
-
287
- $( document ).on( 'click', '.advads-adsense-close-code', function( ev ) {
288
- ev.preventDefault();
289
- $( '.advads-adsense-content' ).val( '' );
290
- $( '.advads-adsense-code' ).hide();
291
- $( '.advads-adsense-show-code' ).show();
292
- var SNT = getSlotAndType_jq();
293
- SNT.css( 'display', 'block' );
294
- } );
295
-
296
- $( document ).on('click', '.advads-adsense-submit-code', function(ev){
297
- ev.preventDefault();
298
- parseCodeBtnClicked = true;
299
- var rawContent = $( '.advads-adsense-content' ).val();
300
-
301
- var parseResult = parseAdContent( rawContent );
302
-
303
- handleParseResult( parseResult );
304
- });
305
-
306
- $( document ).on( 'paramloaded', '#advanced-ads-ad-parameters', function(){
307
- var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
308
- var parseResult = parseAdContent( content );
309
-
310
- var adType = $( '[name="advanced_ad[type]"]:checked' ).val();
311
-
312
- if ( 'undefined' != typeof AdsenseMAPI ) {
313
- if ( 'adsense' != adType ) {
314
- if ( 'undefined' == typeof window['AdsenseMAPI'] ) {
315
- delete( window['AdsenseMAPI'] );
316
- }
317
- } else {
318
- if ( 'post-new.php' == gadsenseData.pagenow || ( 'draft' == AdsenseMAPI.adStatus && ! $( '#advads-ad-content-adsense' ).val() ) ) {
319
- $( '#mapi-open-selector a' ).trigger( 'click' );
320
- }
321
- }
322
- }
323
- handleParseResult( parseResult );
324
- } );
325
-
326
- function getAdCode( slotID ) {
327
- if ( 'undefined' != typeof AdsenseMAPI.codes[ slotID ] ) {
328
- getSavedDetails(slotID );
329
- } else {
330
- getRemoteCode( slotID );
331
- }
332
- }
333
-
334
- $( document ).on('change', '#unit-type, #unit-code', function (ev) {
335
- if ( 'unit-code' == $( this ).attr( 'id' ) ) {
336
- var val = $( this ).val();
337
- if ( -1 != val.indexOf( gadsenseData.pubId.substr( 4 ) ) ) {
338
- $( '#advads-pubid-in-slot' ).css( 'display', 'block' );
339
- $( this ).css( 'background-color', 'rgba(255, 235, 59, 0.33)' );
340
- } else {
341
- $( '#unit-code' ).css( 'background-color', '#fff' );
342
- $( '#advads-pubid-in-slot' ).css( 'display', 'none' );
343
- }
344
- } else {
345
- $( '#unit-code' ).css( 'background-color', '#fff' );
346
- $( '#advads-pubid-in-slot' ).css( 'display', 'none' );
347
- }
348
- advads_update_adsense_type();
349
- });
350
-
351
- $( document ).on( 'change', '#ad-resize-type', function( ev ) {
352
- show_float_warnings( 'responsive' );
353
- } );
354
-
355
- function getRemoteCode( slotID ) {
356
-
357
- if ( '' == slotID ) return;
358
- $( '#mapi-loading-overlay' ).css( 'display', 'block' );
359
-
360
- $.ajax({
361
- type: 'post',
362
- url: ajaxurl,
363
- data: {
364
- nonce: AdsenseMAPI.nonce,
365
- action: 'advads_mapi_get_adCode',
366
- unit: slotID,
367
- },
368
- success: function(response,status,XHR){
369
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
370
- if ( 'undefined' != typeof response.code ) {
371
- $( '#remote-ad-code-msg' ).empty();
372
- var parsed = parseAdContent( response.code );
373
- if ( false !== parsed ) {
374
- AdsenseMAPI.codes[slotID] = response.code;
375
- undoReadOnly();
376
- setDetailsFromAdCode( parsed );
377
- makeReadOnly();
378
- $( '#remote-ad-code-error' ).css( 'display', 'none' );
379
- unitIsSupported( slotID );
380
- } else {
381
- $( '#remote-ad-code-error' ).css( 'display', 'block' );
382
- }
383
-
384
- // Update quota message if needed
385
- if ( 1 == 0 ) {
386
- $( '#mapi-quota-message' ).text( response.quotaMsg );
387
- AdsenseMAPI.quota = response.quota;
388
- if ( 0 == response.quota ) {
389
- $( '#mapi-get-adcode,#mapi-get-adunits' ).prop( 'disabled', true );
390
- }
391
- }
392
-
393
- closeAdSelector();
394
-
395
- } else {
396
- if ( 'undefined' != typeof response.raw ) {
397
- $( '#remote-ad-code-msg' ).html( response.raw );
398
- } else if( 'undefined' != typeof response.msg ) {
399
- if ( 'undefined' != typeof response.reload ) {
400
- emptyMapiSelector( response.msg );
401
- } else {
402
- if ( 'doesNotSupportAdUnitType' == response.msg ) {
403
- unitIsNotSupported( slotID );
404
- } else {
405
- $( '#remote-ad-code-msg' ).html( response.msg );
406
- }
407
- }
408
- if ( 'undefined' != typeof response.raw ) {
409
- console.log( response.raw );
410
- }
411
- }
412
- }
413
- },
414
- error: function(request,status,err){
415
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
416
-
417
- },
418
- });
419
-
420
- }
421
-
422
- function unitIsNotSupported( slotID ) {
423
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'block' );
424
- AdsenseMAPI.unsupportedUnits[slotID] = 1;
425
- $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).addClass( 'disabled' );
426
- $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).addClass( 'unsupported' );
427
- if ( ! $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
428
- var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
429
- var content = td.text();
430
- td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-type="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
431
- }
432
- if ( ! $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
433
- var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
434
- var content = td.text();
435
- td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-size="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
436
- }
437
-
438
- }
439
-
440
- function unitIsSupported( slotID ) {
441
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
442
- if ( 'undefined' != typeof AdsenseMAPI.unsupportedUnits[slotID] ) {
443
- delete AdsenseMAPI.unsupportedUnits[slotID];
444
- }
445
- $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).removeClass( 'disabled' );
446
- $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).removeClass( 'unsupported' );
447
- if ( $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
448
- var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
449
- var content = $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).attr( 'data-type' );
450
- td.text( content );
451
- }
452
- if ( $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
453
- var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
454
- var content = $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).attr( 'data-size' );
455
- td.text( content );
456
- }
457
- }
458
-
459
- function getSavedDetails( slotID ) {
460
- if ( 'undefined' != typeof AdsenseMAPI.codes[slotID] ) {
461
- var code = AdsenseMAPI.codes[slotID];
462
- var parsed = parseAdContent( code );
463
- if ( false !== parsed ) {
464
- undoReadOnly();
465
- setDetailsFromAdCode( parsed );
466
- makeReadOnly();
467
- $( '#remote-ad-code-error' ).css( 'display', 'none' );
468
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
469
- closeAdSelector();
470
- } else {
471
- $( '#remote-ad-code-error' ).css( 'display', 'block' );
472
- }
473
- }
474
- }
475
-
476
- /**
477
- * Parse ad content.
478
- *
479
- * @return {!Object}
480
- */
481
- function parseAdContent(content) {
482
- var rawContent = ('undefined' != typeof(content))? content.trim() : '';
483
- var theAd = {};
484
- var theContent = $( '<div />' ).html( rawContent );
485
- var adByGoogle = theContent.find( 'ins' );
486
- theAd.slotId = adByGoogle.attr( 'data-ad-slot' ) || '';
487
- if ('undefined' != typeof(adByGoogle.attr( 'data-ad-client' ))) {
488
- theAd.pubId = adByGoogle.attr( 'data-ad-client' ).substr( 3 );
489
- }
490
-
491
- if (undefined !== theAd.slotId && '' != theAd.pubId) {
492
- theAd.display = adByGoogle.css( 'display' );
493
- theAd.format = adByGoogle.attr( 'data-ad-format' );
494
- theAd.layout = adByGoogle.attr( 'data-ad-layout' ); // for InFeed and InArticle
495
- theAd.layout_key = adByGoogle.attr( 'data-ad-layout-key' ); // for InFeed
496
- theAd.style = adByGoogle.attr( 'style' ) || '';
497
-
498
- /* normal ad */
499
- if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf( 'width' )) {
500
- theAd.type = 'normal';
501
- theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
502
- theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
503
- }
504
-
505
- /* Responsive ad, auto resize */
506
- else if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
507
- theAd.type = 'responsive';
508
- }
509
-
510
-
511
- /* older link unit format; for new ads the format type is no longer needed; link units are created through the AdSense panel */
512
- else if ('undefined' != typeof(theAd.format) && 'link' == theAd.format) {
513
-
514
- if( -1 != theAd.style.indexOf( 'width' ) ){
515
- // is fixed size
516
- theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
517
- theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
518
- theAd.type = 'link';
519
- } else {
520
- // is responsive
521
- theAd.type = 'link-responsive';
522
- }
523
- }
524
-
525
- /* Responsive Matched Content */
526
- else if ('undefined' != typeof(theAd.format) && 'autorelaxed' == theAd.format) {
527
- theAd.type = 'matched-content';
528
- }
529
-
530
- /* InArticle & InFeed ads */
531
- else if ('undefined' != typeof(theAd.format) && 'fluid' == theAd.format) {
532
-
533
- // InFeed
534
- if('undefined' != typeof(theAd.layout) && 'in-article' == theAd.layout){
535
- theAd.type = 'in-article';
536
- } else {
537
- // InArticle
538
- theAd.type = 'in-feed';
539
- }
540
- }
541
- }
542
-
543
- /**
544
- * Synchronous code
545
- */
546
- if ( -1 != rawContent.indexOf( 'google_ad_slot' ) ) {
547
- var _client = rawContent.match( /google_ad_client ?= ?["']([^'"]+)/ );
548
- var _slot = rawContent.match( /google_ad_slot ?= ?["']([^'"]+)/ );
549
- var _format = rawContent.match( /google_ad_format ?= ?["']([^'"]+)/ );
550
- var _width = rawContent.match( /google_ad_width ?= ?([\d]+)/ );
551
- var _height = rawContent.match( /google_ad_height ?= ?([\d]+)/ );
552
-
553
- theAd = {};
554
-
555
- theAd.pubId = _client[1].substr( 3 );
556
-
557
- if ( null !== _slot ) {
558
- theAd.slotId = _slot[1];
559
- }
560
- if ( null !== _format ) {
561
- theAd.format = _format[1];
562
- }
563
- if ( null !== _width ) {
564
- theAd.width = parseInt( _width[1] );
565
- }
566
- if ( null !== _height ) {
567
- theAd.height = parseInt( _height[1] );
568
- }
569
-
570
- if ( 'undefined' == typeof theAd.format ) {
571
- theAd.type = 'normal';
572
- }
573
-
574
- }
575
-
576
- if ( '' == theAd.slotId && gadsenseData.pubId && '' != gadsenseData.pubId ) {
577
- theAd.type = $( '#unit-type' ).val();
578
- }
579
-
580
- /* Page-Level ad */
581
- if ( rawContent.indexOf( 'enable_page_level_ads' ) !== -1 ) {
582
- theAd = { 'parse_message': 'pageLevelAd' };
583
- }
584
-
585
- else if ( ! theAd.type ) {
586
- /* Unknown ad */
587
- theAd = { 'parse_message': 'unknownAd' };
588
- }
589
-
590
- $( document ).trigger( 'gadsenseParseAdContent', [ theAd, adByGoogle ] );
591
- return theAd;
592
- }
593
-
594
- /**
595
- * Handle result of parsing content.
596
- *
597
- * @param {!Object}
598
- */
599
- function handleParseResult( parseResult ) {
600
- $( '#pastecode-msg' ).empty();
601
- switch ( parseResult.parse_message ) {
602
- case 'pageLevelAd' :
603
- advads_show_adsense_auto_ads_warning();
604
- break;
605
- case 'unknownAd' :
606
- // Not recognized ad code
607
- if ( parseCodeBtnClicked && 'post-new.php' == gadsenseData.pagenow ) {
608
- // do not show if just after switching to AdSense ad type on ad creation
609
- $( '#pastecode-msg' ).append( $( '<p />' ).css( 'color', 'red' ).html( gadsenseData.msg.unknownAd ) );
610
- }
611
- break;
612
- default:
613
- setDetailsFromAdCode( parseResult );
614
- if ( 'undefined' != typeof AdsenseMAPI && 'undefined' != typeof AdsenseMAPI.hasToken && parseResult.pubId == AdsenseMAPI.pubId ) {
615
- var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
616
- MapiSaveAdCode( content, parseResult.slotId );
617
- makeReadOnly();
618
- }
619
- $( '.advads-adsense-code' ).hide();
620
- $( '.advads-adsense-show-code' ).show();
621
- var SNT = getSlotAndType_jq();
622
- SNT.css( 'display', 'block' );
623
- }
624
- }
625
-
626
- /**
627
- * Set ad parameters fields from the result of parsing ad code
628
- */
629
- function setDetailsFromAdCode(theAd) {
630
- undoReadOnly();
631
- $( '#unit-code' ).val( theAd.slotId );
632
- $( '#advads-adsense-pub-id' ).val( theAd.pubId );
633
- if ('normal' == theAd.type) {
634
- $( '#unit-type' ).val( 'normal' );
635
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
636
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
637
- }
638
- if ('responsive' == theAd.type) {
639
- $( '#unit-type' ).val( 'responsive' );
640
- $( '#ad-resize-type' ).val( 'auto' );
641
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
642
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
643
- }
644
- if ('link' == theAd.type) {
645
- $( '#unit-type' ).val( 'link' );
646
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
647
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
648
- }
649
- if ('link-responsive' == theAd.type) {
650
- $( '#unit-type' ).val( 'link-responsive' );
651
- $( '#ad-resize-type' ).val( 'auto' );
652
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
653
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
654
- }
655
- if ('matched-content' == theAd.type) {
656
- $( '#unit-type' ).val( 'matched-content' );
657
- $( '#ad-resize-type' ).val( 'auto' );
658
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
659
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
660
- }
661
- if ('in-article' == theAd.type) {
662
- $( '#unit-type' ).val( 'in-article' );
663
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
664
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
665
- }
666
- if ('in-feed' == theAd.type) {
667
- $( '#unit-type' ).val( 'in-feed' );
668
- $( '#ad-layout' ).val( theAd.layout );
669
- $( '#ad-layout-key' ).val( theAd.layout_key );
670
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
671
- $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
672
- }
673
- var storedPubId = gadsenseData.pubId;
674
-
675
- if ( '' !== storedPubId && theAd.pubId != storedPubId && '' != theAd.slotId ) {
676
- $( '#adsense-ad-param-error' ).text( gadsenseData.msg.pubIdMismatch );
677
- } else {
678
- $( '#adsense-ad-param-error' ).empty();
679
- }
680
- $( document ).trigger( 'setDetailsFromAdCode', [ theAd ] );
681
- $( '#unit-type' ).trigger( 'change' );
682
- }
683
-
684
- /**
685
- * Format the post content field
686
- *
687
- */
688
- window.gadsenseFormatAdContent = function () {
689
- var slotId = $( '#ad-parameters-box #unit-code' ).val();
690
- var unitType = $( '#ad-parameters-box #unit-type' ).val();
691
- var publisherId = $( '#advads-adsense-pub-id' ).val() ? $( '#advads-adsense-pub-id' ).val() : gadsenseData.pubId;
692
- var adContent = {
693
- slotId: slotId,
694
- unitType: unitType,
695
- pubId: publisherId,
696
- };
697
- if ('responsive' == unitType) {
698
- var resize = $( '#ad-parameters-box #ad-resize-type' ).val();
699
- if (0 == resize) { resize = 'auto'; }
700
- adContent.resize = resize;
701
- }
702
- if ('in-feed' == unitType) {
703
- adContent.layout = $( '#ad-parameters-box #ad-layout' ).val();
704
- adContent.layout_key = $( '#ad-parameters-box #ad-layout-key' ).val();
705
- }
706
- if ('undefined' != typeof(adContent.resize) && 'auto' != adContent.resize) {
707
- $( document ).trigger( 'gadsenseFormatAdResponsive', [adContent] );
708
- }
709
- $( document ).trigger( 'gadsenseFormatAdContent', [adContent] );
710
-
711
- if ('undefined' != typeof(window.gadsenseAdContent)) {
712
- adContent = window.gadsenseAdContent;
713
- delete( window.gadsenseAdContent );
714
- }
715
- $( '#advads-ad-content-adsense' ).val( JSON.stringify( adContent, false, 2 ) );
716
-
717
- }
718
-
719
- $( document ).on( 'click', '#mapi-open-selector a', function(){
720
- $( '.advads-adsense-show-code' ).css( 'display', 'inline' );
721
- $( '#mapi-open-selector' ).css( 'display', 'none' );
722
- $( '.advads-adsense-code' ).css( 'display', 'none' );
723
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
724
- var pubId = gadsenseData.pubId || false;
725
- var slotId = $( '#unit-code' ).val().trim();
726
- var tbody = $( '#mapi-table-wrap tbody' );
727
- tbody.find( 'tr' ).removeClass( 'selected' );
728
- if ( pubId && slotId ) {
729
- if ( $( '#mapi-table-wrap tr i[data-slotid="ca-' + pubId + ':' + slotId + '"]' ).length ) {
730
- tbody.find( 'tr i[data-slotid="ca-' + pubId + ':' + slotId + '"]' ).parents( 'tr' ).addClass( 'selected' );
731
- }
732
- }
733
-
734
- var SNT = getSlotAndType_jq();
735
- SNT.css( 'display', 'none' );
736
-
737
- $( '#mapi-wrap' ).css( 'display', 'block' );
738
- if ( $( '#mapi-no-ad-units-found' ).length ) {
739
- $( '#mapi-no-ad-units-found' ).trigger( 'click' );
740
- return;
741
- }
742
- resizeAdListHeader();
743
- });
744
-
745
- $( document ).on( 'click', '#mapi-close-selector', function(){
746
- $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
747
- $( '#mapi-wrap' ).css( 'display', 'none' );
748
-
749
- var SNT = getSlotAndType_jq();
750
- SNT.css( 'display', 'block' );
751
-
752
- } );
753
-
754
- function updateAdList() {
755
-
756
- $( '#mapi-loading-overlay' ).css( 'display', 'block' );
757
-
758
- $.ajax({
759
- type: 'post',
760
- url: ajaxurl,
761
- data: {
762
- nonce: AdsenseMAPI.nonce,
763
- action: 'advads_gadsense_mapi_get_adUnits',
764
- account: gadsenseData.pubId,
765
- },
766
- success: function(response,status,XHR){
767
- if ( 'undefined' != typeof response.html ) {
768
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
769
- $( '#mapi-wrap' ).replaceWith( $( response.html ) );
770
- $( '#mapi-open-selector a' ).trigger( 'click' );
771
- } else if ( 'undefined' != typeof response.msg ) {
772
- emptyMapiSelector( response.msg );
773
- }
774
- if ( 'undefined' != typeof response.raw ) {
775
- console.log( response.raw );
776
- }
777
- },
778
- error: function(request,status,err){
779
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
780
- },
781
- });
782
-
783
- }
784
-
785
- function toggleIdleAds( hide ) {
786
- if ( 'undefined' == typeof hide ) {
787
- hide = true;
788
- }
789
- $( '#mapi-loading-overlay' ).css( 'display', 'block' );
790
-
791
- $.ajax({
792
- type: 'post',
793
- url: ajaxurl,
794
- data: {
795
- nonce: AdsenseMAPI.nonce,
796
- action: 'advads-mapi-idle-ads',
797
- hide: hide? 1 : 0,
798
- },
799
- success: function(response,status,XHR){
800
- if ( 'undefined' != typeof response.html ) {
801
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
802
- $( '#mapi-wrap' ).replaceWith( $( response.html ) );
803
- $( '#mapi-open-selector a' ).trigger( 'click' );
804
- } else if ( 'undefined' != typeof response.msg ) {
805
- emptyMapiSelector( response.msg );
806
- }
807
- if ( 'undefined' != typeof response.raw ) {
808
- console.log( response.raw );
809
- }
810
- },
811
- error: function(request,status,err){
812
- $( '#mapi-loading-overlay' ).css( 'display', 'none' );
813
- },
814
- });
815
-
816
- }
817
-
818
- $( document ).on( 'click', '.mapiaction', function( ev ) {
819
- var action = $( this ).attr( 'data-mapiaction' );
820
- switch ( action ) {
821
- case 'updateList':
822
- updateAdList();
823
- break;
824
- case 'getCode':
825
- if ( $( this ).hasClass( 'disabled' ) ) {
826
- break;
827
- }
828
- var slotID = $( this ).attr( 'data-slotid' );
829
- getAdCode( slotID );
830
- break;
831
- case 'updateCode':
832
- var slotID = $( this ).attr( 'data-slotid' );
833
- getRemoteCode( slotID );
834
- break;
835
- case 'showidle':
836
- toggleIdleAds( false );
837
- break;
838
- case 'hideidle':
839
- toggleIdleAds( true );
840
- break;
841
- default:
842
- }
843
- } );
844
-
845
- function advads_update_adsense_type(){
846
- var type = $( '#unit-type' ).val();
847
- $( '.advads-adsense-layout' ).hide();
848
- $( '.advads-adsense-layout' ).next('div').hide();
849
- $( '.advads-adsense-layout-key' ).hide();
850
- $( '.advads-adsense-layout-key' ).next('div').hide();
851
- $( '.advads-ad-notice-in-feed-add-on' ).hide();
852
- if ( 'responsive' == type || 'link-responsive' == type || 'matched-content' == type ) {
853
- $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
854
- $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
855
- $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
856
- $( '.clearfix-before' ).show();
857
- } else if ( 'in-feed' == type ) {
858
- $( '.advads-adsense-layout' ).css( 'display', 'block' );
859
- $( '.advads-adsense-layout' ).next('div').css( 'display', 'block' );
860
- $( '.advads-adsense-layout-key' ).css( 'display', 'block' );
861
- $( '.advads-adsense-layout-key' ).next('div').css( 'display', 'block' );
862
- $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
863
- $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
864
- $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
865
- // show add-on notice
866
- $( '.advads-ad-notice-in-feed-add-on' ).show();
867
- $( '.clearfix-before' ).show();
868
- } else if ( 'in-article' == type ) {
869
- $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'none' );
870
- $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'none' );
871
- $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'none' );
872
- $( '.clearfix-before' ).show();
873
- } else if ( 'normal' == type || 'link' == type ) {
874
- $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'block' );
875
- $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'block' );
876
- $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'block' );
877
- $( '.clearfix-before' ).hide();
878
- }
879
- if ( 'link' == type || 'normal' == type ) {
880
- if ( ! $( '[name="advanced_ad\[width\]"]' ).val() ) {
881
- $( '[name="advanced_ad\[width\]"]' ).val( '300' );
882
- }
883
- if ( ! $( '[name="advanced_ad\[height\]"]' ).val() ) {
884
- $( '[name="advanced_ad\[height\]"]' ).val( '250' );
885
- }
886
- }
887
- $( document ).trigger( 'gadsenseUnitChanged' );
888
- window.gadsenseFormatAdContent();
889
-
890
- show_float_warnings( type );
891
- }
892
-
893
- advads_update_adsense_type();
894
-
895
- if ( 'undefined' != typeof AdsenseMAPI.hasToken ) {
896
- MapiMayBeSaveAdCode();
897
- }
898
-
899
- }); // DOM ready
900
-
901
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/gadsense/admin/dummy.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) {
3
+ die();
4
+ }
5
+ require_once ADVADS_BASE_PATH . '/admin/includes/class-ad-network.php';
6
+
7
+ class Dummy_Type extends Advanced_Ads_Ad_Type_Abstract{
8
+ public $ID = "dummy2000";
9
+ public function __construct(){
10
+ // $this->ID = "dummy2000";
11
+ $this->title = "ASDF Dummy";
12
+ $this->description = "Some dummy description";
13
+
14
+ $this->parameters = array(
15
+ 'content' => ''
16
+ );
17
+ }
18
+ public function render_parameters($ad){
19
+ $network = Dummy_Network::get_instance();
20
+ global $dummy_content;
21
+ $dummy_content = (string) ( isset( $ad->content ) ? $ad->content : '' );
22
+
23
+ include(ADVADS_BASE_PATH . '/modules/gadsense/admin/views/external-ads-links.php');
24
+ include(ADVADS_BASE_PATH . '/modules/gadsense/admin/views/external-ads-list.php');
25
+ include(ADVADS_BASE_PATH . '/modules/gadsense/admin/views/external-ads-dummy.php');
26
+ }
27
+
28
+ public function sanitize_content($content = '') {
29
+ return $content = wp_unslash( $content );
30
+ }
31
+
32
+ public function prepare_output($ad) {
33
+ $output = '<div style="background-color:#ff00ff;"><h1>' . $ad->content . '</h1>';
34
+ $output.= "<pre><code>" . json_encode($ad, JSON_PRETTY_PRINT) . "</code></pre>";
35
+ $output.= "</div>";
36
+ return $output;
37
+ }
38
+
39
+ protected function append_defaut_responsive_content(&$output, $pub_id, $content) {
40
+ $output .= '<div style="background-color:#00ffff;"><h2>Responsive content</h2>';
41
+ }
42
+
43
+ }
44
+
45
+ class Dummy_Network extends Advanced_Ads_Ad_Network {
46
+ private static $instance;
47
+ public static function get_instance(){
48
+ if (! self::$instance) self::$instance = new Dummy_Network();
49
+ return self::$instance;
50
+ }
51
+ public function __construct()
52
+ {
53
+ parent::__construct('dummy2000', 'Testing Dummy Ads');
54
+ }
55
+
56
+ protected function register_settings($hook, $section_id)
57
+ {
58
+ // add setting field to disable ads
59
+ add_settings_field(
60
+ 'adsense-id',
61
+ __( 'Dummy Account Id', 'advanced-ads' ),
62
+ //array($this, 'render_dummy_account_id'),
63
+ function(){
64
+ echo "Connected: " . (($this->is_account_connected()) ? "Y" : "N");
65
+ },
66
+ $this->settings_page_hook,
67
+ $this->settings_section_id
68
+ );
69
+ }
70
+
71
+ protected function sanitize_settings($options)
72
+ {
73
+ return $options;
74
+ }
75
+
76
+
77
+ public function sanitize_ad_settings($ad_settings_post)
78
+ {
79
+ return $ad_settings_post;
80
+ }
81
+
82
+ public function get_ad_type()
83
+ {
84
+ return new Dummy_Type();
85
+ }
86
+
87
+ public function get_external_ad_units()
88
+ {
89
+ $units = array();
90
+ for ($i=0; $i<42; $i++){
91
+ $ad_unit = new Advanced_Ads_Ad_Network_Ad_Unit("RAW DATA");
92
+ $ad_unit->id = "Dummy" . $i;
93
+ $ad_unit->slot_id = "Dummy Slot #" . $i;
94
+ $ad_unit->name = "Dummy #" . $i;
95
+ $ad_unit->active = $i % 2 == 0;
96
+ $ad_unit->code = "Some Code";
97
+ $ad_unit->display_type = "Some Type";
98
+ $ad_unit->display_size = "Some Size";
99
+ $units[] = $ad_unit;
100
+ }
101
+ return $units;
102
+ }
103
+
104
+ public function is_supported($ad_unit)
105
+ {
106
+ // TODO: Implement is_supported() method.
107
+ return true;
108
+ }
109
+
110
+ public function update_external_ad_units()
111
+ {
112
+ //TODO: user cap & nonce check!
113
+ //TODO: copy from class-mapi.php
114
+
115
+ $network = $this; //required in templates
116
+ $ad_units = $this->get_external_ad_units();
117
+ $unsupported_ad_type_link = Advanced_Ads_AdSense_MAPI::UNSUPPORTED_TYPE_LINK;
118
+
119
+ ob_start();
120
+ require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-list.php';
121
+ require_once GADSENSE_BASE_PATH . 'admin/views/external-ads-dummy.php';
122
+ $html_ad_selector = ob_get_clean();
123
+
124
+ $response = array(
125
+ 'status' => true,
126
+ 'html' => $html_ad_selector,
127
+ );
128
+ header( 'Content-Type: application/json' );
129
+ echo wp_json_encode( $response );
130
+ die();
131
+ }
132
+
133
+ public function is_account_connected()
134
+ {
135
+ return true;
136
+ }
137
+
138
+
139
+ public function get_javascript_base_path()
140
+ {
141
+ // TODO: Implement get_javascript_base_handle() method.
142
+ }
143
+
144
+ public function append_javascript_data(&$data)
145
+ {
146
+ // TODO: Implement append_javascript_data() method.
147
+ }
148
+ }
149
+
150
+ //$network = new Dummy_Network();
151
+ //$network->register();
152
+ //
153
+ //$network = new Advanced_Ads_Network_Adsense();
154
+ //$network->register();
modules/gadsense/admin/views/adsense-account.php CHANGED
@@ -91,7 +91,7 @@ $alerts_advads_messages = Advanced_Ads_Adsense_MAPI::get_adsense_alert_messages(
91
  </div>
92
  <div class="widget-col">
93
  <h3><?php _e( "No, I still don't have an AdSense account", 'advanced-ads' ) ?></h3>
94
- <a class="button button-secondary" target="_blank" href="<?php echo self::ADSENSE_NEW_ACCOUNT_LINK; ?>"><?php _e( 'Get a free AdSense account', 'advanced-ads' ); ?></a>
95
  </div>
96
  </div>
97
  <style type="text/css">
91
  </div>
92
  <div class="widget-col">
93
  <h3><?php _e( "No, I still don't have an AdSense account", 'advanced-ads' ) ?></h3>
94
+ <a class="button button-secondary" target="_blank" href="<?php echo Advanced_Ads_AdSense_Admin::ADSENSE_NEW_ACCOUNT_LINK; ?>"><?php _e( 'Get a free AdSense account', 'advanced-ads' ); ?></a>
95
  </div>
96
  </div>
97
  <style type="text/css">
modules/gadsense/admin/views/adsense-ad-parameters.php CHANGED
@@ -28,7 +28,6 @@ $quota = $MAPI->get_quota();
28
 
29
  $mapi_ad_codes = $mapi_options['ad_codes'];
30
  $mapi_ad_codes['length'] = count( $mapi_ad_codes );
31
-
32
  ?>
33
  <?php if ( $has_token ) : ?>
34
  <script type="text/javascript">
@@ -37,7 +36,7 @@ $mapi_ad_codes['length'] = count( $mapi_ad_codes );
37
  }
38
  AdsenseMAPI.hasToken = true;
39
  AdsenseMAPI.nonce = '<?php echo $mapi_nonce ?>';
40
- AdsenseMAPI.codes = <?php echo json_encode( $mapi_ad_codes ) ?>;
41
  AdsenseMAPI.quota = <?php echo json_encode( $quota ) ?>;
42
  AdsenseMAPI.pubId = '<?php echo $pub_id ?>';
43
  AdsenseMAPI.adStatus = '<?php echo $ad->status ?>';
@@ -77,31 +76,11 @@ gadsenseData['msg'] = {
77
  <?php if ( $has_token && Advanced_Ads_Checks::php_version_minimum() ) {
78
  Advanced_Ads_AdSense_Admin::get_mapi_ad_selector();
79
  }
80
- ?>
81
-
82
- <p>
83
- <span class="advads-adsense-show-code">
84
- <a href="#"><?php _e( 'Insert new AdSense code', 'advanced-ads' ); ?></a>
85
- </span>
86
- <?php if ( Advanced_Ads_Checks::php_version_minimum() ) : ?>
87
- <?php if ( $has_token ) : ?>
88
- <span id="mapi-open-selector">
89
- <?php _e( 'or', 'advanced-ads' ); ?><a href="#" class="prevent-default"><?php _e( 'Get ad code from your linked account', 'advanced-ads' ); ?></a>
90
- </span>
91
- <?php else : ?>
92
- <?php _e( 'or', 'advanced-ads' ); ?>
93
- <?php if ( $adsense_id ) : ?>
94
- <a href="<?php echo admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ?>" style="padding:0 10px;font-weight:bold;"><?php _e( 'Connect to AdSense', 'advanced-ads' ); ?></a>
95
- <?php else : ?>
96
- <a id="mapi-connect-adsense" href="#" style="padding:0 10px;font-weight:bold;"><?php _e( 'Connect to AdSense', 'advanced-ads' ); ?></a>
97
- <?php endif; ?>
98
- <?php endif; ?>
99
- <?php endif; ?>
100
- </p>
101
- <?php if ( $has_token && ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
102
- <p class="advads-error-message"><?php _e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ); ?></p>
103
- <?php endif; ?>
104
 
 
 
 
 
105
  <?php endif; ?>
106
  <p id="adsense-ad-param-error"></p>
107
  <?php ob_start(); ?>
28
 
29
  $mapi_ad_codes = $mapi_options['ad_codes'];
30
  $mapi_ad_codes['length'] = count( $mapi_ad_codes );
 
31
  ?>
32
  <?php if ( $has_token ) : ?>
33
  <script type="text/javascript">
36
  }
37
  AdsenseMAPI.hasToken = true;
38
  AdsenseMAPI.nonce = '<?php echo $mapi_nonce ?>';
39
+ //AdsenseMAPI.codes = <?php echo json_encode( $mapi_ad_codes ) ?>;
40
  AdsenseMAPI.quota = <?php echo json_encode( $quota ) ?>;
41
  AdsenseMAPI.pubId = '<?php echo $pub_id ?>';
42
  AdsenseMAPI.adStatus = '<?php echo $ad->status ?>';
76
  <?php if ( $has_token && Advanced_Ads_Checks::php_version_minimum() ) {
77
  Advanced_Ads_AdSense_Admin::get_mapi_ad_selector();
78
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ // the network variable needs to be set for the view to work!
81
+ $network = Advanced_Ads_Network_Adsense::get_instance();
82
+ include(ADVADS_BASE_PATH . '/modules/gadsense/admin/views/external-ads-links.php');
83
+ ?>
84
  <?php endif; ?>
85
  <p id="adsense-ad-param-error"></p>
86
  <?php ob_start(); ?>
modules/gadsense/admin/views/external-ads-adsense.php ADDED
File without changes
modules/gadsense/admin/views/external-ads-links.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WARNING: be careful when modifying the DOM of this document!
4
+ * there are some jquery calls that rely on this structure!
5
+ */
6
+ $is_account_connected = $network->is_account_connected();
7
+ ?><p>
8
+ <span id="mapi-insert-code">
9
+
10
+ <a href="#"><?php
11
+ /* translators: 1: The name of an ad network. */
12
+ printf(__( 'Insert new %1$s code', 'advanced-ads' ), $network->get_display_name()) ?></a>
13
+ </span>
14
+ <?php if ( Advanced_Ads_Checks::php_version_minimum() ) : ?>
15
+ <?php if ( $is_account_connected ) : ?>
16
+ <span id="mapi-open-selector">
17
+ <?php _e( 'or', 'advanced-ads' ); ?><a href="#" class="prevent-default"><?php _e( 'Get ad code from your linked account', 'advanced-ads' ); ?></a>
18
+ </span>
19
+ <?php if ($network->supports_manual_ad_setup()):?>
20
+ <span id="mapi-close-selector-link"><?php
21
+ _e( 'or', 'advanced-ads' ); ?><a href="#" class="prevent-default"><?php
22
+ /* translators: 1: The name of an ad network. */
23
+ printf(__( 'Set up %1$s code manually', 'advanced-ads' ), $network->get_display_name());
24
+ ?></a>
25
+ </span>
26
+ <?php endif;?>
27
+ <?php else : ?>
28
+ <?php _e( 'or', 'advanced-ads' );
29
+ /* translators: 1: The name of an ad network. */
30
+ $connect_link_label = sprintf(__( 'Connect to %1$s', 'advanced-ads' ), $network->get_display_name());
31
+ ?>
32
+ <a href="<?php echo $network->get_settings_href() ?>" style="padding:0 10px;font-weight:bold;"><?php echo $connect_link_label ?></a>
33
+ <?php endif; ?>
34
+ <?php endif; ?>
35
+ </p>
36
+ <?php if ( $is_account_connected && ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
37
+ <p class="advads-error-message"><?php _e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ); ?></p>
38
+ <?php endif; ?>
39
+
modules/gadsense/admin/views/external-ads-list.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $external_ad_unit_id, $use_dashicons, $closeable, $display_slot_id;
3
+
4
+ if (! isset($hide_idle_ads)) $hide_idle_ads = true;
5
+ if (! isset($ad_units)) $ad_units = array();
6
+
7
+ ?>
8
+ <div id="mapi-wrap" class="aa-select-list">
9
+ <?php if ($closeable): ?>
10
+ <button type="button" id="mapi-close-selector" class="notice-dismiss"></button>
11
+ <?php endif;?>
12
+ <i id="mapi-toggle-idle" title="<?php esc_attr_e( 'Show inactive ads' , 'advanced-ads' ); ?>" class="dashicons dashicons-visibility mapiaction" data-mapiaction="toggleidle"></i>
13
+ <?php if ( !empty( $ad_units ) ) : ?>
14
+ <i class="aa-select-list-update dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php
15
+ esc_attr_e( 'Update the ad units list', 'advanced-ads' ) ?>"></i>
16
+ <?php endif; ?>
17
+ <div id="mapi-loading-overlay" class="aa-select-list-loading-overlay">
18
+ <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:8em;" />
19
+ </div>
20
+ <?php if ( !empty( $ad_units ) ) :
21
+ // this div is referenced in the legacy mapi code. not sure if it is needed at all, it doesn't make much sense right now...
22
+ // the texts of the span elements were shifted to the right and did not really match well with the ads list (table)
23
+ // it was removed in favor of the table header below, that was used for empty ad units display only
24
+ // TODO: make sure the div is not needed anymore, and what it's purpose is, then remove it, if possible
25
+ ?>
26
+ <div id="mapi-list-header" class="aa-select-list-header" style="display:none;">
27
+ <?php if ($use_dashicons) :?>
28
+ <span><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></span>
29
+ <?php endif; ?>
30
+ <span><?php esc_html_e( 'Name', 'advanced-ads' ); ?></span>
31
+ <?php if ($display_slot_id):?><span><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></span><?php endif;?>
32
+ <span><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></span>
33
+ <span><?php esc_html_e( 'Size', 'advanced-ads' ); ?></span>
34
+ </div>
35
+ <?php endif; ?>
36
+ <div id="mapi-table-wrap" class="aa-select-list-table-wrap">
37
+ <table class="widefat striped">
38
+ <thead>
39
+ <tr>
40
+ <?php if ($use_dashicons) :?>
41
+ <th><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></th>
42
+ <?php endif; ?>
43
+ <th><?php esc_html_e( 'Name', 'advanced-ads' ); ?></th>
44
+ <?php if ($display_slot_id):?><th><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></th><?php endif;?>
45
+ <th><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></th>
46
+ <th><?php esc_html_e( 'Size', 'advanced-ads' ); ?></th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ <?php if ( empty( $ad_units ) ) : ?>
51
+ <tr>
52
+ <td colspan="5" style="text-align:center;">
53
+ <?php esc_attr_e( 'No ad units found', 'advanced-ads' ) ?>
54
+ <i class="dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php esc_attr_e( 'Update the ad units list', 'advanced-ads' ) ?>"></i>
55
+ </td>
56
+ </tr>
57
+ <?php else :
58
+ foreach ($ad_units as $ad_unit){
59
+ $ad_unit->is_supported = $network->is_supported($ad_unit);
60
+ }
61
+ $sorted_adunits = Advanced_Ads_Ad_Network_Ad_Unit::sort_ad_units( $ad_units, $external_ad_unit_id);
62
+ ?>
63
+ <?php foreach ( $sorted_adunits as $unit ) :
64
+ $unit_is_supported = $unit->is_supported;//$network->is_supported($unit);
65
+ $unsupported_class = $unit_is_supported ? '' : ' disabled'; ?>
66
+ <?php if ($use_dashicons):?>
67
+ <tr data-slotid="<?php echo esc_attr( $unit->id ); ?>" data-active="<?php echo esc_attr( $unit->active ); ?>">
68
+ <td>
69
+ <i data-slotid="<?php echo esc_attr( $unit->id ); ?>" class="dashicons dashicons-download mapiaction<?php echo $unsupported_class; ?>" data-mapiaction="getCode" title="<?php esc_attr_e( 'Get the code for this ad', 'advanced-ads' ) ?>"></i>
70
+ <i data-slotid="<?php echo esc_attr( $unit->id ); ?>" class="dashicons dashicons-update mapiaction" data-mapiaction="updateCode" title="<?php esc_attr_e( 'Update and get the code for this ad from Google', 'advanced-ads' ) ?>"></i>
71
+ </td>
72
+ <?php else: ?>
73
+ <tr class="advads-clickable-row mapiaction" data-mapiaction="getCode" data-slotid="<?php echo esc_attr( $unit->id ); ?>" data-active="<?php echo esc_attr( $unit->active ); ?>">
74
+ <?php endif;?>
75
+ <td><?php echo $unit->name; ?></td>
76
+ <?php if ($display_slot_id):?>
77
+ <td class="unitcode"><?php
78
+ if ( !$unit_is_supported ) {
79
+ echo '<span class="unsupported"><span>' . esc_html( $unit->slot_id ) . '</span></span>';
80
+ } else {
81
+ echo '<span><span>' . esc_html( $unit->slot_id ) . '</span></span>';
82
+ }
83
+ ?></td>
84
+ <?php endif;?>
85
+ <td class="unittype"><?php
86
+ if ( !$unit_is_supported ) {
87
+ echo '<a href="' . esc_url( $unsupported_ad_type_link ) . '" target="_blank" data-type="' . esc_attr( Advanced_Ads_AdSense_MAPI::format_ad_data( $unit->display_type, 'type' ) ) . '">';
88
+ esc_html_e( 'unsupported', 'advanced-ads' );
89
+ echo '</a>';
90
+ } else {
91
+ echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit->display_type, 'type' );
92
+ }
93
+ ?></td>
94
+ <td class="unitsize"><?php
95
+ if ( !$unit_is_supported ) {
96
+ echo '<a href="' . esc_url( $unsupported_ad_type_link ) . '" target="_blank" data-size="' . Advanced_Ads_AdSense_MAPI::format_ad_data( $unit->display_size, 'size' ) . '">';
97
+ esc_html_e( 'unsupported', 'advanced-ads' );
98
+ echo '</a>';
99
+ } else {
100
+ echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit->display_size, 'size' );
101
+ }
102
+ ?></td>
103
+ </tr>
104
+ <?php endforeach; ?>
105
+ <?php endif; ?>
106
+ </tbody>
107
+ </table>
108
+ </div>
109
+
110
+ <p class="advads-error-message" id="remote-ad-code-error" style="display:none;"><strong><?php esc_attr_e( 'Unrecognized ad code', 'advanced-ads' ); ?></strong></p>
111
+ <p class="advads-error-message" id="remote-ad-code-msg"></p>
112
+ <div style="display:none;" id="remote-ad-unsupported-ad-type"><p><i class="dashicons dashicons-warning"></i><b class="advads-error-message"><?php
113
+ esc_attr_e( 'This ad type can currently not be imported from AdSense.', 'advanced-ads' ) ?></b>&nbsp;<a href="<?php echo ADVADS_URL . 'adsense-ad-type-not-available/#utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-type-not-available'; ?>" target="_blank"><?php
114
+ esc_attr_e( 'Learn more and help us to enable it here.', 'advanced-ads' ) ?></a></p>
115
+ <?php esc_attr_e( 'In the meantime, you can use AdSense with one of these methods:', 'advanced-ads' ) ?>
116
+ <ul>
117
+ <li><?php _e( 'Click on <em>Insert new AdSense code</em> and copy the code from your AdSense account into it.', 'advanced-ads' ) ?></li>
118
+ <li><?php _e( 'Create an ad on the fly. Just select the <em>Normal</em> or <em>Responsive</em> type and the size.', 'advanced-ads' ) ?></li>
119
+ <li><?php _e( 'Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from your AdSense account.', 'advanced-ads' ) ?></li>
120
+ </ul>
121
+ </div>
122
+ </div>
modules/gadsense/admin/views/mapi-ad-selector.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
- $G_Data = Advanced_Ads_AdSense_Data::get_instance();
3
- $adsense_id = $G_Data->get_adsense_id();
4
- $mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
5
- $ad_units = array();
6
- if ( isset( $mapi_options['accounts'][$adsense_id]['ad_units'] ) ) {
7
- $ad_units = $mapi_options['accounts'][$adsense_id]['ad_units'];
8
- }
9
- if ( ! isset( $hide_idle_ads ) ) $hide_idle_ads = true;
10
-
11
- if ( $hide_idle_ads ) {
12
- $_ads = array();
13
- foreach( $ad_units as $unit ) {
14
- if ( 'INACTIVE' != $unit['status'] ) {
15
- $_ads[ $unit['id'] ] = $unit;
16
- }
17
- }
18
- $ad_units = $_ads;
19
- }
20
-
21
- $unsupported_ad_type_link = Advanced_Ads_AdSense_MAPI::UNSUPPORTED_TYPE_LINK;
22
-
23
- ?>
24
- <div id="mapi-wrap" class="aa-select-list">
25
- <button type="button" id="mapi-close-selector" class="notice-dismiss"></button>
26
- <?php if ( $hide_idle_ads ) : ?>
27
- <i id="mapi-show-idle" title="<?php esc_attr_e( 'Show inactive ads' , 'advanced-ads' ); ?>" class="dashicons dashicons-visibility mapiaction" data-mapiaction="showidle"></i>
28
- <?php else : ?>
29
- <i id="mapi-hide-idle" title="<?php esc_attr_e( 'Hide inactive ads' , 'advanced-ads' ); ?>" class="dashicons dashicons-hidden mapiaction" data-mapiaction="hideidle"></i>
30
- <?php endif; ?>
31
- <?php if ( !empty( $ad_units ) ) : ?>
32
- <i class="aa-select-list-update dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php
33
- esc_attr_e( 'Update the ad units list', 'advanced-ads' ) ?>"></i>
34
- <?php endif; ?>
35
- <div id="mapi-loading-overlay" class="aa-select-list-loading-overlay">
36
- <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:8em;" />
37
- </div>
38
-
39
- <?php if ( !empty( $ad_units ) ) : ?>
40
- <div id="mapi-list-header" class="aa-select-list-header">
41
- <span><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></span>
42
- <span><?php esc_html_e( 'Name', 'advanced-ads' ); ?></span>
43
- <span><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></span>
44
- <span><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></span>
45
- <span><?php esc_html_e( 'Size', 'advanced-ads' ); ?></span>
46
- </div>
47
- <?php endif; ?>
48
- <div id="mapi-table-wrap" class="aa-select-list-table-wrap">
49
- <table class="widefat striped">
50
- <?php if ( empty( $ad_units ) ) : ?>
51
- <thead>
52
- <tr>
53
- <th><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></th>
54
- <th><?php esc_html_e( 'Name', 'advanced-ads' ); ?></th>
55
- <th><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></th>
56
- <th><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></th>
57
- <th><?php esc_html_e( 'Size', 'advanced-ads' ); ?></th>
58
- </tr>
59
- </thead>
60
- <tbody>
61
- <tr>
62
- <td colspan="5" style="text-align:center;">
63
- <?php esc_attr_e( 'No ad units found', 'advanced-ads' ) ?>
64
- <i id="mapi-no-ad-units-found" class="dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php esc_attr_e( 'Update the ad units list', 'advanced-ads' ) ?>"></i>
65
- </td>
66
- </tr>
67
- <?php else : $sorted_adunits = Advanced_Ads_AdSense_MAPI::get_sorted_adunits( $ad_units ); ?>
68
- <tbody>
69
- <?php foreach ( $sorted_adunits as $name => $unit ) : $unsupported_class = array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ? ' disabled' : ''; ?>
70
- <tr data-slotid="<?php echo esc_attr( $unit['id'] ); ?>">
71
- <td>
72
- <i data-slotid="<?php echo esc_attr( $unit['id'] ); ?>" class="dashicons dashicons-download mapiaction<?php echo $unsupported_class; ?>" data-mapiaction="getCode" title="<?php esc_attr_e( 'Get the code for this ad', 'advanced-ads' ) ?>"></i>
73
- <i data-slotid="<?php echo esc_attr( $unit['id'] ); ?>" class="dashicons dashicons-update mapiaction" data-mapiaction="updateCode" title="<?php esc_attr_e( 'Update and get the code for this ad from Google', 'advanced-ads' ) ?>"></i>
74
- </td>
75
- <td><?php echo $name; ?></td>
76
- <td class="unitcode"><?php
77
- if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
78
- echo '<span class="unsupported"><span>' . esc_html( $unit['code'] ) . '</span></span>';
79
- } else {
80
- echo '<span><span>' . esc_html( $unit['code'] ) . '</span></span>';
81
- }
82
- ?></td>
83
- <td class="unittype"><?php
84
- if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
85
- echo '<a href="' . esc_url( $unsupported_ad_type_link ) . '" target="_blank" data-type="' . esc_attr( Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['type'], 'type' ) ) . '">';
86
- esc_html_e( 'unsupported', 'advanced-ads' );
87
- echo '</a>';
88
- } else {
89
- echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['type'], 'type' );
90
- }
91
- ?></td>
92
- <td class="unitsize"><?php
93
- if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
94
- echo '<a href="' . esc_url( $unsupported_ad_type_link ) . '" target="_blank" data-size="' . Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['size'], 'size' ) . '">';
95
- esc_html_e( 'unsupported', 'advanced-ads' );
96
- echo '</a>';
97
- } else {
98
- echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['size'], 'size' );
99
- }
100
- ?></td>
101
- </tr>
102
- <?php endforeach; ?>
103
- <?php endif; ?>
104
- </tbody>
105
- </table>
106
- </div>
107
-
108
- <p class="advads-error-message" id="remote-ad-code-error" style="display:none;"><strong><?php esc_attr_e( 'Unrecognized ad code', 'advanced-ads' ); ?></strong></p>
109
- <p class="advads-error-message" id="remote-ad-code-msg"></p>
110
- <div style="display:none;" id="remote-ad-unsupported-ad-type"><p><i class="dashicons dashicons-warning"></i><b class="advads-error-message"><?php
111
- esc_attr_e( 'This ad type can currently not be imported from AdSense.', 'advanced-ads' ) ?></b>&nbsp;<a href="<?php echo ADVADS_URL . 'adsense-ad-type-not-available/#utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-type-not-available'; ?>" target="_blank"><?php
112
- esc_attr_e( 'Learn more and help us to enable it here.', 'advanced-ads' ) ?></a></p>
113
- <?php esc_attr_e( 'In the meantime, you can use AdSense with one of these methods:', 'advanced-ads' ) ?>
114
- <ul>
115
- <li><?php _e( 'Click on <em>Insert new AdSense code</em> and copy the code from your AdSense account into it.', 'advanced-ads' ) ?></li>
116
- <li><?php _e( 'Create an ad on the fly. Just select the <em>Normal</em> or <em>Responsive</em> type and the size.', 'advanced-ads' ) ?></li>
117
- <li><?php _e( 'Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from your AdSense account.', 'advanced-ads' ) ?></li>
118
- </ul>
119
- </div>
120
- <?php if ( 8 < count( $ad_units ) ) : ?>
121
- <style type="text/css">
122
- #mapi-table-wrap {
123
- height: 22.2em;
124
- overflow: auto;
125
- }
126
- #mapi-wrap table {
127
- position: absolute;
128
- }
129
- </style>
130
- <?php endif; ?>
131
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/gadsense/config.php CHANGED
@@ -11,6 +11,9 @@ return array(
11
  'Advanced_Ads_AdSense_MAPI' => $path . '/includes/class-mapi.php',
12
  'Advanced_Ads_AdSense_Admin' => $path . '/admin/admin.php',
13
  'Advanced_Ads_AdSense_Public' => $path . '/public/public.php',
 
 
 
14
  ),
15
  'textdomain' => null,
16
  );
11
  'Advanced_Ads_AdSense_MAPI' => $path . '/includes/class-mapi.php',
12
  'Advanced_Ads_AdSense_Admin' => $path . '/admin/admin.php',
13
  'Advanced_Ads_AdSense_Public' => $path . '/public/public.php',
14
+ 'Advanced_Ads_AdSense_Report_Builder' => $path . '/includes/class-adsense-report.php',
15
+
16
+ 'Advanced_Ads_Network_Adsense' => $path . '/includes/class-network-adsense.php',
17
  ),
18
  'textdomain' => null,
19
  );
modules/gadsense/includes/class-ad-type-adsense.php CHANGED
@@ -50,6 +50,23 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
50
  * @since 1.4
51
  */
52
  public function render_parameters($ad) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  $options = $ad->options();
54
 
55
  $content = (string) ( isset( $ad->content ) ? $ad->content : '' );
@@ -76,6 +93,10 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
76
  $pub_id_errors = __( 'The Publisher ID has an incorrect format. (must start with "pub-")', 'advanced-ads' );
77
  }
78
 
 
 
 
 
79
  if ( trim($content) !== '' ) {
80
 
81
  $json_content = stripslashes( $content );
@@ -105,6 +126,7 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
105
  if ( ! empty( $unit_pubid ) ) {
106
  $unit_id = 'ca-' . $unit_pubid . ':' . $unit_code;
107
  }
 
108
  }
109
  }
110
 
@@ -223,7 +245,6 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
223
 
224
  }
225
 
226
-
227
  return $output;
228
  }
229
 
@@ -272,6 +293,13 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
272
  $output .= isset( $layout_key ) ? 'data-ad-layout-key="' . $layout_key . '"' . "\n" : '';
273
  $output .= 'data-ad-format="';
274
  $output .= $format;
 
 
 
 
 
 
 
275
  $output .= '"></ins>' . "\n";
276
  $output .= '<script> ' . "\n";
277
  $output .= apply_filters( 'advanced-ads-gadsense-responsive-adsbygoogle', '(adsbygoogle = window.adsbygoogle || []).push({}); ' . "\n");
50
  * @since 1.4
51
  */
52
  public function render_parameters($ad) {
53
+ {
54
+ // THIS IS JUST A QUICK AND DIRTY HACK
55
+ // TODO: create a dedicated method to handle this properly
56
+ ?>
57
+ <script>
58
+ $(function () {
59
+ <?php
60
+ $mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
61
+ $json_ad_codes = json_encode($mapi_options['ad_codes']);
62
+ ?>
63
+ const adsense = new AdvancedAdsNetworkAdsense(<?php echo $json_ad_codes?>);
64
+ AdvancedAdsAdmin.AdImporter.setup(adsense);
65
+ });
66
+ </script>
67
+ <?php
68
+ }
69
+
70
  $options = $ad->options();
71
 
72
  $content = (string) ( isset( $ad->content ) ? $ad->content : '' );
93
  $pub_id_errors = __( 'The Publisher ID has an incorrect format. (must start with "pub-")', 'advanced-ads' );
94
  }
95
 
96
+ global $external_ad_unit_id, $use_dashicons, $closeable;
97
+ $closeable = true;
98
+ $use_dashicons = false;
99
+ $external_ad_unit_id = "";
100
  if ( trim($content) !== '' ) {
101
 
102
  $json_content = stripslashes( $content );
126
  if ( ! empty( $unit_pubid ) ) {
127
  $unit_id = 'ca-' . $unit_pubid . ':' . $unit_code;
128
  }
129
+ $external_ad_unit_id = $unit_id;
130
  }
131
  }
132
 
245
 
246
  }
247
 
 
248
  return $output;
249
  }
250
 
293
  $output .= isset( $layout_key ) ? 'data-ad-layout-key="' . $layout_key . '"' . "\n" : '';
294
  $output .= 'data-ad-format="';
295
  $output .= $format;
296
+
297
+ $options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
298
+ $fw = !empty( $options['fullwidth-ads'] ) ? $options['fullwidth-ads'] : 'default';
299
+ if ( 'default'!== $fw ) {
300
+ $output .= 'enable' == $fw ? '" data-full-width-responsive="true' : '" data-full-width-responsive="false';
301
+ }
302
+
303
  $output .= '"></ins>' . "\n";
304
  $output .= '<script> ' . "\n";
305
  $output .= apply_filters( 'advanced-ads-gadsense-responsive-adsbygoogle', '(adsbygoogle = window.adsbygoogle || []).push({}); ' . "\n");
modules/gadsense/includes/class-adsense-report.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
23
+ * after a report has been requested
24
+ * this holds all the plot & trace info
25
+ */
26
+ 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;
36
+ private $dimensions = array();
37
+ private $metrics = array();
38
+ private $dt_start;
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;
46
+ }
47
+ public function addMetric($name){
48
+ $dim = new Advanced_Ads_AdSense_Report_Metric($name);
49
+ $this->metrics[] = $dim;
50
+ }
51
+ public function setDaterange($dt_start, $dt_end){
52
+ $this->dt_start = $dt_start;
53
+ $this->dt_end = $dt_end;
54
+ }
55
+ public function setOverwriteDaterangeIdentifier($id){
56
+ $this->overwrite_dt_identifier = $id;
57
+ }
58
+ public function setStoreAsTransient($store_as_transient_bool){
59
+ $this->store_as_transient = $store_as_transient_bool;
60
+ }
61
+ public function setDaterangeByDays($nbDays, $dt_end = null){
62
+ if (! $dt_end) $dt_end = (new DateTime())->format("Y-m-d");
63
+ $dt = new DateTime($dt_end);
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";
71
+ foreach ($this->dimensions as $dim){
72
+ $url .= "&dimension=$dim->name";
73
+ }
74
+ foreach ($this->metrics as $metric){
75
+ $url .= "&metric=$metric->name";
76
+ }
77
+ return $url;
78
+ }
79
+ /**
80
+ * generate an identifier that will be used to store and retrieve transients.
81
+ */
82
+ public function getIdentifier(){
83
+ $id = "advanced_ads_adsense_report_";
84
+ foreach ($this->dimensions as $dim){
85
+ $id .= $dim->name . "_";
86
+ }
87
+ foreach ($this->metrics as $metric){
88
+ $id .= $metric->name . "_";
89
+ }
90
+ if ($this->overwrite_dt_identifier){
91
+ $id .= $this->overwrite_dt_identifier;
92
+ }
93
+ else{
94
+ $id.= $this->dt_start . "_" . $this->dt_end;
95
+ }
96
+ return $id;
97
+ }
98
+
99
+ public function request_raw(){
100
+ //gather the data for the request
101
+ $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
102
+ $pub_id = trim($gadsense_data->get_adsense_id());
103
+ $access_token = Advanced_Ads_AdSense_MAPI::get_access_token($pub_id);
104
+ //build the url and request it
105
+ $url = $this->getUrl($pub_id);
106
+ return $this->process_request($url, $access_token);
107
+ }
108
+
109
+ public static function get_age_in_seconds($updated_at){
110
+ $timestamp = ($updated_at) ? $updated_at->getTimestamp() : 0;
111
+ return (new DateTime())->getTimestamp() - $timestamp;
112
+ }
113
+
114
+ public function build($plotter, $type, $forceRefresh = false, $allowRefresh = true){
115
+ $transient_id = $this->getIdentifier();
116
+ $response = $this->get_option($transient_id);
117
+ // $wants_refresh = $forceRefresh || $response == null || ! isset($response['body']) || ! isset($response['body']->rows);
118
+ $wants_refresh = $forceRefresh || $response == null || ! isset($response['body']);
119
+ if ($response){
120
+ $age_in_seconds = self::get_age_in_seconds($response['updatedAt']);
121
+ if ($age_in_seconds >= self::TRANSIENT_VALIDITY) $wants_refresh = true;
122
+
123
+ }
124
+ if ($wants_refresh){
125
+ if ($allowRefresh){
126
+
127
+ $response = $this->request_raw();
128
+ if (is_array($response) && isset($response['body']) && isset($response['headers'])){
129
+ // remove all but body and header
130
+ foreach ($response as $key => $val){
131
+ if ($key != "body" && $key != "header"){
132
+ unset($response[$key]);
133
+ }
134
+ }
135
+ $response['updatedAt'] = new DateTime();
136
+ //set_transient($transient_id, $response, self::TRANSIENT_VALIDITY);
137
+ //update_option($transient_id, $response);
138
+ $this->save_option($transient_id, $response);
139
+ }
140
+ }
141
+ }
142
+ else if (! $forceRefresh){
143
+ $response = $this->get_option($transient_id); // just a little fallback. it actually should never happen.
144
+ }
145
+ if ($response){
146
+ return new Advanced_Ads_AdSense_Report($response, $plotter, $type);
147
+ }
148
+ return null;
149
+ }
150
+
151
+ public function request_report($plotter, $type){
152
+ $response = $this->request_raw();
153
+ try{
154
+ $report = $this->build($plotter, $type, true);
155
+ if ($response){
156
+ $response = $report->generateResponse();
157
+ return $response;
158
+ }
159
+ }
160
+ catch(Exception $ex){}
161
+ return null;
162
+ }
163
+
164
+ private function get_option($id){
165
+ if ($this->store_as_transient) {
166
+ return get_transient($id);
167
+ }
168
+ else{
169
+ return get_option($id);
170
+ }
171
+ }
172
+ private function save_option($id, $value){
173
+ if ($this->store_as_transient) {
174
+ set_transient($id, $value, self::TRANSIENT_VALIDITY);
175
+ }
176
+ else{
177
+ update_option($id, $value);
178
+ }
179
+ }
180
+
181
+ private function process_request($url, $access_token){
182
+ if ( ! isset( $access_token['msg'] ) ) {
183
+ $headers = array(
184
+ 'Authorization' => 'Bearer ' . $access_token,
185
+ );
186
+ $adsense_data = wp_remote_get( $url, array( 'headers' => $headers ) );
187
+ Advanced_Ads_AdSense_MAPI::log("Fetched AdSense Report from $url");
188
+ return $adsense_data;
189
+ } else {
190
+ return -1;
191
+ }
192
+ }
193
+
194
+ /**
195
+ * a quick way to create a dashboard summary.
196
+ */
197
+ public static function createDashboardSummary($secondary_dimension_name = "DOMAIN_NAME", $filter_value = null, $overwrite_dt_identifier = null, $optional_dimension_names = null, $force_refresh = false, $allow_refresh = true){
198
+ $builder = new Advanced_Ads_AdSense_Report_Builder();
199
+ $builder->setDaterangeByDays(30);
200
+ $builder->addDimension("DATE");
201
+ $builder->addDimension($secondary_dimension_name);
202
+ $builder->addMetric("EARNINGS");
203
+ $builder->setOverwriteDaterangeIdentifier($overwrite_dt_identifier);
204
+ $report = $builder->build("plotly", "lines", $force_refresh, $allow_refresh);
205
+ $summary = Advanced_Ads_AdSense_Dashboard_Summary::create($report, $filter_value, $optional_dimension_names);
206
+ $summary->dimension_name = $secondary_dimension_name;
207
+ return $summary;
208
+ }
209
+ }
210
+
211
+ class Advanced_Ads_AdSense_Report{
212
+ public $valid;
213
+ public $errors;
214
+ public $dimensions;
215
+ public $dimensionalData;
216
+ public $metrics;
217
+ public $columns;
218
+ public $plotGenerator;
219
+ public $secondaryDimension;
220
+
221
+ function __construct($json_response, $plotter='jqplot', $type='lines'){
222
+ $this->plotter = $plotter;
223
+ $this->type = $type;
224
+ $this->process_json_response($json_response);
225
+ // $this->plotGenerator = $plotter === 'jqplot'
226
+ // ? new Advanced_Ads_AdSense_Plot_Generator_Jqplot($this)
227
+ // : new Advanced_Ads_AdSense_Plot_Generator_Plotly($this);
228
+ }
229
+
230
+ private function process_json_response($json_response){
231
+ $valid = false;
232
+ $errors = array();
233
+ if ($json_response && is_array($json_response)){
234
+ $body = isset($json_response['body']) ? json_decode($json_response['body']) : null;
235
+ if ($body && isset($body->headers) && is_array($body->headers)){
236
+ try{
237
+ $headers = $body->headers;
238
+ $dimensions = array();
239
+ $metrics = array();
240
+ foreach ($headers as $header){
241
+ $name = $header->name;
242
+ $type = $header->type;
243
+ if ($type === "DIMENSION"){
244
+ $object = new Advanced_Ads_AdSense_Report_Dimension($name);
245
+ $dimensions[] = $object;
246
+ }
247
+ else if ($type === "METRIC_TALLY"){
248
+ $object = new Advanced_Ads_AdSense_Report_Metric($name);
249
+ $metrics[] = $object;
250
+ }
251
+ else if ($type === "METRIC_RATIO"){
252
+ $object = new Advanced_Ads_AdSense_Report_Metric($name);
253
+ $metrics[] = $object;
254
+ }
255
+ else if ($type === "METRIC_CURRENCY"){
256
+ $object = new Advanced_Ads_AdSense_Report_Metric($name);
257
+ $object->currency = $header->currency;
258
+ $metrics[] = $object;
259
+ }
260
+ else{
261
+ throw new RuntimeException("Unknown Header Type: $type");
262
+ }
263
+ $columns[] = $object;
264
+ }
265
+
266
+ $valid = count($dimensions) > 0 && count($dimensions) < 3 && count($metrics) > 0;
267
+ if ($valid){
268
+ $this->body = $body;
269
+ $this->dimensions = $dimensions;
270
+ $this->metrics = $metrics;
271
+ $this->columns = $columns;
272
+ $this->secondaryDimension = count($dimensions) > 1 ? $dimensions[1] : null;
273
+ $this->updatedAt = isset($json_response['updatedAt']) ? $json_response['updatedAt'] : null;
274
+ }
275
+ else{
276
+ throw new RuntimeException(__("Invalid response from AdSense."));
277
+ }
278
+ }
279
+ catch (Exception $ex){
280
+ $valid = false;
281
+ }
282
+ }
283
+ else{
284
+ if ($body->error && $body->error->errors && is_array($body->error->errors) && count($body->error->errors)){
285
+ foreach ($body->error->errors as $err){
286
+ $hint = Advanced_Ads_AdSense_MAPI::get_adsense_error_hint($err->reason);
287
+ if ($hint){
288
+ $errors[] = $err->message . " (" . $err->reason .").<br>" . $hint;
289
+ }
290
+ else{
291
+ $errors[] = $err->message . " (" . $err->reason .")";
292
+ }
293
+ }
294
+ }
295
+ //$errors[] = "Missing or incomplete response from AdSense 1231231231ssssssssssssssssssss.";
296
+ }
297
+ }
298
+ $this->valid = $valid;
299
+ if (! $valid && count($errors) == 0){
300
+ // Display a default error message.
301
+ $errors[] = __("Invalid response from AdSense.");
302
+ }
303
+ $this->errors = $errors;
304
+ }
305
+
306
+ public function filterRowsByPattern($column_index, $pattern){
307
+ if (isset($this->body) && isset($this->body->rows) && is_array($this->body->rows)) {
308
+ $filtered = array();
309
+ foreach ($this->body->rows as $row) {
310
+ if (preg_match($pattern, $row[$column_index])) {
311
+ $filtered[] = $row;
312
+ }
313
+ }
314
+ $this->body->rows = $filtered;
315
+ }
316
+ }
317
+
318
+ public function getRowsByDimensionValues($dimension_values, $dimension_index){
319
+ $filtered = array();
320
+ if ($this->body && isset($this->body->rows) && is_array($this->body->rows)) {
321
+ foreach ($this->body->rows as $row) {
322
+ if (in_array($row[$dimension_index], $dimension_values)) {
323
+ $filtered[] = $row;
324
+ }
325
+ }
326
+ }
327
+ return $filtered;
328
+ }
329
+ public function getDictByDimensionValues($dimension_values, $dimension_index, $value_column_index, $key_column_index){
330
+ $dict = array();
331
+ foreach ($this->body->rows as $row){
332
+ if (in_array($row[$dimension_index], $dimension_values)){
333
+ $dict[$row[$key_column_index]] = $row[$value_column_index];
334
+ }
335
+ }
336
+ return $dict;
337
+ }
338
+
339
+ public function getDistinctValuesByDimension($dimension_index){
340
+ $map = array();
341
+ $vals = array();
342
+ if (isset($this->body) && isset($this->body->rows)) {
343
+ foreach ($this->body->rows as $row) {
344
+ $key = $row[$dimension_index];
345
+ if (!isset($map[$key])) {
346
+ $map[$key] = 1;
347
+ $vals[] = $key;
348
+ }
349
+ }
350
+ }
351
+ return $vals;
352
+ }
353
+
354
+ public function generateResponse(){
355
+ $response = new Advanced_Ads_Adsense_Report_Response();
356
+ $response->plots = $this->generatePlots();
357
+ $response->plotter = $this->plotter;
358
+ $response->errors = $this->errors;
359
+ return $response;
360
+ }
361
+
362
+ private function createDimensionalData(){
363
+ $data = array();
364
+ if ($this->secondaryDimension != null){
365
+ // extract the dimensional data
366
+ foreach ($this->body->rows as $row){
367
+ $key = $row[1];
368
+ if (! isset($data[$key])){
369
+ $data[$key] = array();
370
+ }
371
+ $data[$key][] = $row;
372
+ }
373
+ }
374
+ else{
375
+ foreach ($this->body->rows as $row){
376
+ $data['default'][] = $row;
377
+ }
378
+ }
379
+ return $data;
380
+ }
381
+
382
+
383
+ private function generatePlots(){
384
+ $this->dimensionalData = $this->createDimensionalData();
385
+ $plots = array();
386
+ $plots[] = $this->generatePlot();
387
+ // $plots = $this->plotGenerator->generatePlots($this);
388
+ // foreach ($this->dimensionalData as $dimdata){
389
+
390
+ // }
391
+ //$plots[] = $this->generatePlot();
392
+ return $plots;
393
+ }
394
+
395
+ private function generatePlot(){
396
+ return $this->plotGenerator->generatePlot($this);
397
+ }
398
+ }
399
+
400
+ class Advanced_Ads_AdSense_Dashboard_Summary{
401
+ private function __construct(){}
402
+
403
+ /**
404
+ * @param $report Advanced_Ads_AdSense_Report
405
+ * @param $filter_value string A value for the filter (e.g. domain name)
406
+ * @param $optional_dimension_names array an array with optional dimension names.
407
+ * @return Advanced_Ads_AdSense_Dashboard_Summary
408
+ */
409
+ public static final function create($report, $filter_value, $optional_dimension_names){
410
+ //TODO: check for validity
411
+ $summary = new Advanced_Ads_AdSense_Dashboard_Summary();
412
+ if ($report && $report->valid){
413
+ $colDimension = 1;
414
+ $colEarnings = 2;
415
+ $summary->nb_rows = isset($report->body) && isset($report->body->rows) ? count($report->body->rows) : 0;
416
+ $summary->dimension = $optional_dimension_names;
417
+ $summary->filter_value = $filter_value;
418
+ $dimension_values = $report->getDistinctValuesByDimension(1);
419
+
420
+ $dims = array();
421
+ foreach ($dimension_values as $dim){
422
+ $name = ($optional_dimension_names && isset($optional_dimension_names[$dim]))
423
+ ? $optional_dimension_names[$dim] : $dim;
424
+ $dims[$dim] = $name;
425
+ }
426
+ $summary->dimensions = $dims;
427
+ $summary->dimension_name = $report->secondaryDimension->name;
428
+ if ($filter_value){
429
+ // prevent values that don't exist as a dimension.
430
+ // this allows for a proper fallback in the main dashboard that tries to find the domain of the blog
431
+ // if it does not match, it will not display a bunch of zeroes but the sum of earnings of all domains
432
+ // we also make sure this only happens for the DOMAIN_NAME dimension, and not for others
433
+ $apply_filter = true;
434
+
435
+ $filter_value_exists_in_dimension = false;
436
+ foreach ($dims as $key => $name){
437
+ if ($key == $filter_value) {
438
+ $filter_value_exists_in_dimension = true;
439
+ break;
440
+ }
441
+ }
442
+ $summary->filterValueExists = $filter_value_exists_in_dimension;
443
+ if ($summary->dimension_name == "DOMAIN_NAME"){
444
+ $apply_filter = $filter_value_exists_in_dimension;
445
+ if (! $filter_value_exists_in_dimension)
446
+ $filter_value = null;
447
+ $summary->filter_value = $filter_value;
448
+ }
449
+
450
+ if ($apply_filter){
451
+ $report->filterRowsByPattern($colDimension, '/' . $filter_value . '$/');
452
+ }
453
+ }
454
+
455
+ $summary->earningsToday = self::sum($report, $colEarnings, 1);
456
+ $summary->earningsYesterday = self::sum($report, $colEarnings, 1, 1);
457
+ $summary->earnings7Days = self::sum($report, $colEarnings, 7, 1);
458
+ $summary->earnings28Days = self::sum($report, $colEarnings, 28, 1);
459
+ $summary->earningsThisMonth = self::sumDim($report, $colEarnings, self::createDateDimensionValuesCurrentMonth());
460
+
461
+ $age_in_seconds = Advanced_Ads_AdSense_Report_Builder::get_age_in_seconds($report->updatedAt);
462
+ $summary->requires_refresh = $age_in_seconds > Advanced_Ads_AdSense_Report_Builder::TRANSIENT_VALIDITY;
463
+
464
+ if (! $report->updatedAt) $summary->age = __("Never", "advanced-ads");
465
+ else{
466
+ $date_format = get_option( 'date_format' );
467
+ $date = new DateTime();
468
+ $today_str = date_i18n($date_format, $date->getTimestamp());
469
+ $date = $report->updatedAt;
470
+ if (! is_a($date, 'DateTime')) $date = new DateTime();
471
+ $is_today = date_i18n($date_format, $date->getTimestamp()) === $today_str;
472
+ if ($is_today) $summary->age = date_i18n( get_option( 'time_format' ), $date->getTimestamp());
473
+ else $summary->age = date_i18n($date_format, $date->getTimestamp());
474
+ }
475
+ $summary->valid = $report->valid;
476
+ }
477
+ else {
478
+ if ($report->errors){
479
+ $summary->errors = $report->errors;
480
+ }
481
+ $summary->valid = false;
482
+ $summary->requires_refresh = true;
483
+ $summary->age = __("Never", "advanced-ads");
484
+ }
485
+
486
+ return $summary;
487
+ }
488
+
489
+ private static final function sum($report, $col_index, $nb_days, $offset_days = 0){
490
+ $dim = self::createDateDimensionValues($nb_days, $offset_days);
491
+ return self::sumDim($report, $col_index, $dim);
492
+ }
493
+ private static final function sumDim($report, $colIndex, $dim){
494
+ // $dict = $report->getDictByDimensionValues($dim, 0, $colIndex, 0);
495
+ // return round(array_sum($dict),2) . " €";
496
+ $rows = $report->getRowsByDimensionValues($dim, 0);
497
+ $sum = 0.0;
498
+ foreach ($rows as $row){
499
+ $sum += $row[$colIndex];
500
+ }
501
+ $sum = number_format(round($sum, 2), 2);
502
+ if (isset($report->columns[$colIndex]) && isset($report->columns[$colIndex]->currency))
503
+ $sum .= " " . $report->columns[$colIndex]->currency;
504
+ return $sum;
505
+ }
506
+ private static final function createDateDimensionValues($nbDays, $offsetDays = 0){
507
+ $dim = array();
508
+ $dt = new DateTime();
509
+ for ($i=0; $i<$offsetDays; $i++){
510
+ $dt = $dt->sub(new DateInterval("P1D"));
511
+ }
512
+ for ($i=0; $i<$nbDays; $i++){
513
+ $dim[] = $dt->format("Y-m-d");
514
+ $dt = $dt->sub(new DateInterval("P1D"));
515
+ }
516
+ return $dim;
517
+ }
518
+ private static final function createDateDimensionValuesCurrentMonth(){
519
+ $dim = array();
520
+ $dt = new DateTime();
521
+ $month = $dt->format("m");
522
+ $m = $month;
523
+ while ($m == $month){
524
+ $dim[] = $dt->format("Y-m-d");
525
+ $dt = $dt->sub(new DateInterval("P1D"));
526
+ $m = $dt->format("m");
527
+ }
528
+ return $dim;
529
+ }
530
+ }
531
+
532
+ ?>
modules/gadsense/includes/class-gadsense-data.php CHANGED
@@ -83,4 +83,13 @@ class Advanced_Ads_AdSense_Data {
83
  public function is_page_level_enabled() {
84
  return $this->options['page-level-enabled'];
85
  }
 
 
 
 
 
 
 
 
 
86
  }
83
  public function is_page_level_enabled() {
84
  return $this->options['page-level-enabled'];
85
  }
86
+ public function is_setup(){
87
+ if (isset($this->options) && is_array($this->options) && isset($this->options['adsense-id']) && $this->options['adsense-id']){
88
+ $adsense_id = $this->get_adsense_id();
89
+ if ($adsense_id) {
90
+ return Advanced_Ads_AdSense_MAPI::has_token($adsense_id);
91
+ }
92
+ };
93
+ return false;
94
+ }
95
  }
modules/gadsense/includes/class-mapi.php CHANGED
@@ -1,22 +1,22 @@
1
  <?php
2
  class Advanced_Ads_AdSense_MAPI {
3
-
4
  const OPTNAME = 'advanced-ads-adsense-mapi';
5
-
6
- const ALERTS_URL = 'https://www.googleapis.com/adsense/v1.4/accounts/PUBID/alerts/';
7
-
8
  const CID = '400595147946-alk0j13qk563bg94rd4f3ip2t0b2tr5r.apps.googleusercontent.com';
9
-
10
  const CS = '5jecyWgvCszB8UxSM0oS1W22';
11
-
12
  const CALL_PER_24H = 20;
13
-
14
  const UNSUPPORTED_TYPE_LINK = 'https://wpadvancedads.com/adsense-ad-type-not-available/';
15
-
16
  private static $instance = null;
17
-
18
  private static $default_options = array();
19
-
20
  private static $empty_account_data = array(
21
  'default_app' => array(
22
  'access_token' => '',
@@ -32,15 +32,15 @@ class Advanced_Ads_AdSense_MAPI {
32
  ),
33
  'ad_units' => array(),
34
  'details' => array(),
35
- 'alerts' => array(),
36
  );
37
-
38
  private function __construct() {
39
-
40
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
41
-
42
  add_action( 'wp_ajax_advads_gadsense_mapi_confirm_code', array( $this, 'ajax_confirm_code' ) );
43
- add_action( 'wp_ajax_advads_gadsense_mapi_get_adUnits', array( $this, 'ajax_get_adUnits' ) );
44
  add_action( 'wp_ajax_advads_gadsense_mapi_get_details', array( $this, 'ajax_get_account_details' ) );
45
  add_action( 'wp_ajax_advads_gadsense_mapi_select_account', array( $this, 'ajax_account_selected' ) );
46
  add_action( 'wp_ajax_advads_mapi_get_adCode', array( $this, 'ajax_get_adCode' ) );
@@ -48,11 +48,11 @@ class Advanced_Ads_AdSense_MAPI {
48
  add_action( 'wp_ajax_advads-mapi-revoke-token', array( $this, 'ajax_revoke_tokken' ) );
49
  add_action( 'wp_ajax_advads-mapi-get-alerts', array( $this, 'ajax_get_account_alerts' ) );
50
  add_action( 'wp_ajax_advads-mapi-dismiss-alert', array( $this, 'ajax_dismiss_alert' ) );
51
- add_action( 'wp_ajax_advads-mapi-dismiss-connect-error', array( $this, 'ajax_dismiss_connect_error' ) );
52
- add_action( 'wp_ajax_advads-mapi-idle-ads', array( $this, 'ajax_toggle_idle_ads' ) );
53
-
54
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
55
 
 
 
56
  self::$default_options = array(
57
  'accounts' => array(),
58
  'ad_codes' => array(),
@@ -61,118 +61,118 @@ class Advanced_Ads_AdSense_MAPI {
61
  'count' => self::CALL_PER_24H,
62
  'ts' => 0,
63
  ),
64
- 'connect_error' => array(),
65
  );
66
-
67
- add_filter( 'advanced-ads-support-messages', array( 'Advanced_Ads_AdSense_MAPI', 'adsense_warnings_check' ) );
68
-
69
- add_action( 'wp_loaded', array( $this, 'update_ad_health_notices' ) );
70
-
71
  }
72
-
73
- /**
74
- * Update all MAPI related notices.
75
- */
76
- public function update_ad_health_notices() {
77
- $mapi_options = self::get_option();
78
-
79
- $connection_error_messages = self::get_connect_error_messages();
80
-
81
- $health_class = Advanced_Ads_Ad_Health_Notices::get_instance();
82
-
83
- // Last connection failed.
84
- if ( isset ( $mapi_options['connect_error'] ) && ! empty( $mapi_options['connect_error'] ) ) {
85
-
86
- if ( isset( $connection_error_messages[ $mapi_options['connect_error']['reason'] ] ) ) {
87
- $health_class->add( 'adsense_connect_' . $mapi_options['connect_error']['reason'] );
88
- } else {
89
- $health_class->add( 'adsense_connect_' . $mapi_options['connect_error']['reason'], array(
90
- 'text' => esc_html__( 'Last AdSense account connection attempt failed.', 'advanced-ads' ) . ' ' . $mapi_options['connect_error']['message'],
91
- 'type' => 'problem',
92
- ) );
93
- }
94
-
95
- foreach( $health_class->notices as $key => $value ) {
96
- // There was already a connection error but the user tried again and obtained another error.
97
- if ( false !== stripos( $key, 'adsense_connect_' ) && 'adsense_connect_' . $mapi_options['connect_error']['reason'] !== $key ) {
98
- $health_class->remove( $key );
99
- }
100
- }
101
-
102
- } else {
103
-
104
- // Once a connection has been established (or a the warning has been discarded on the AA settings page), remove connection related notices.
105
- foreach( $health_class->notices as $key => $value ) {
106
- if ( false !== stripos( $key, 'adsense_connect_' ) ) {
107
- $health_class->remove( $key );
108
- }
109
- }
110
-
111
- }
112
-
113
- $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
114
- $adsense_id = $gadsense_data->get_adsense_id();
115
-
116
- $alerts = Advanced_Ads_AdSense_MAPI::get_stored_account_alerts( $adsense_id );
117
-
118
- // AdSense account alerts (can not happens simultaneously with the connection error).
119
- if ( is_array( $alerts ) && isset( $alerts['items'] ) && is_array( $alerts['items'] ) && $alerts['items'] ) {
120
-
121
- $alerts_advads_messages = Advanced_Ads_Adsense_MAPI::get_adsense_alert_messages();
122
- $item_ids = array();
123
-
124
- foreach ( $alerts['items'] as $internal_id => $item ) {
125
- $item_ids[] = $item['id'];
126
- if ( isset( $alerts_advads_messages[ $item['id'] ] ) ) {
127
- $health_class->add( 'adsense_alert_' . $item['id'] );
128
- } else {
129
- $health_class->add( 'adsense_alert_' . $item['id'], array( 'text' => $item['message'] . ' ' . self::get_adsense_error_link( $item['id'] ), 'type' => 'problem' ) );
130
- }
131
-
132
- }
133
-
134
- // Remove notices that no more exist in the AdSense account (or have been dismissed).
135
- $_remove_ids = array();
136
- foreach( $health_class->notices as $key => $value ) {
137
- if ( false !== stripos( $key, 'adsense_alert_' ) ) {
138
- $alert_id = substr( $key, strlen( 'adsense_alert_' ) );
139
- if ( ! in_array( $alert_id, $item_ids, true ) ) {
140
- $_remove_ids[] = $key;
141
- }
142
- }
143
- }
144
- foreach( $_remove_ids as $id ) {
145
- $health_class->remove( $id );
146
- }
147
-
148
- } else {
149
- // No more alerts.
150
- foreach( $health_class->notices as $key => $value ) {
151
- if ( false !== stripos( $key, 'adsense_alert_' ) ) {
152
- $health_class->remove( $key );
153
- }
154
- }
155
-
156
- }
157
- }
158
-
159
- /**
160
- * Discard account connection error
161
- */
162
- public function ajax_dismiss_connect_error() {
163
  $nonce = isset( $_GET['nonce'] ) ? $_GET['nonce'] : '';
164
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) {
165
  die;
166
  }
167
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
168
- $options = self::get_option();
169
- $options['connect_error'] = array();
170
- update_option( self::OPTNAME, $options );
171
- echo 1;
172
- }
173
- die;
174
- }
175
-
176
  /**
177
  * Get available quota and eventual message about remaining call
178
  */
@@ -195,105 +195,105 @@ class Advanced_Ads_AdSense_MAPI {
195
  }
196
  }
197
  }
198
-
199
  /**
200
  * Get the readable quota
201
  */
202
  public function get_quota_msg() {
203
-
204
  $options = $this->get_option();
205
  $now = time();
206
  $secs = $options['quota']['ts'] + ( 24 * 3600 ) - $now;
207
  $hours = floor( $secs / 3600 );
208
  $mins = ceil( ( $secs - ( $hours * 3600 ) ) / 60 );
209
-
210
  if ( 60 == $mins ) {
211
  $hours += 1;
212
  $mins = 0;
213
  }
214
-
215
  if ( 0 == $options['quota']['count'] ) {
216
-
217
  $msg = sprintf(
218
  /*
219
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
220
- _x( 'No API call left before %1$s %2$s.', 'No call left for the next X hours Y minutes.', 'advanced-ads' ),
221
- sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
222
- sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
223
- */
224
  'No API call left before %1$s %2$s.',
225
  sprintf( '%s hours', $hours ),
226
  sprintf( '%s minutes', $mins )
227
- );
228
-
229
  if ( 0 == $hours ) {
230
  /*
231
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
232
- $msg = sprintf(
233
- _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
234
- sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
235
- );
236
  */
237
- $msg = 'No API call left before.';
238
  }
239
-
240
  if ( 0 == $mins ) {
241
  /*
242
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
243
- $msg = sprintf(
244
- _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
245
- sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
246
- );
247
  */
248
  $msg = 'No API call left.';
249
  }
250
  } else {
251
-
252
  $msg = sprintf(
253
  /*
254
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
255
- _x( '%1$s for the next %2$s %3$s.', 'Calls remaining for the next X hours Y minutes.', 'advanced-ads' ),
256
- sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
257
- sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
258
- sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
259
  */
260
  '%1$s for the next %2$s %3$s',
261
  sprintf( '%s API calls remaining', $options['quota']['count'] ),
262
  sprintf( '%s hours', $hours ),
263
  sprintf( '%s minutes', $mins )
264
- );
265
-
266
  if ( 0 == $hours ) {
267
  /*
268
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
269
- $msg = sprintf(
270
- _x( '%1$s for the next %2$s', 'Calls remaining for the next X time.', 'advanced-ads' ),
271
- sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
272
- sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
273
- );
274
  */
275
  $msg = sprintf( '%s API calls remaining.', $options['quota']['count'] );
276
  }
277
-
278
  if ( 0 == $mins ) {
279
  /*
280
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
281
- $msg = sprintf(
282
- _x( '%1$s for the next %2$s', 'calls remaining for the next X time', 'advanced-ads' ),
283
- sprintf( _n( '%s API call remaining', '%s API calls remaining', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
284
- sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
285
- );
286
  */
287
  $msg = sprintf(
288
  '%1$s for the next %2$s',
289
  sprintf( '%s API calls remaining', $options['quota']['count'] ),
290
  sprintf( '%s hours', $hours )
291
- );
292
  }
293
  }
294
  return $msg;
295
  }
296
-
297
  /**
298
  * Decrement quota by 1, and return message about remaining call
299
  */
@@ -309,7 +309,7 @@ class Advanced_Ads_AdSense_MAPI {
309
  return $this->get_quota_msg();
310
  }
311
  }
312
-
313
  /**
314
  * Return the ad code for a given client and unit
315
  *
@@ -319,20 +319,20 @@ class Advanced_Ads_AdSense_MAPI {
319
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
320
  $adsense_id = $gadsense_data->get_adsense_id();
321
  $options = self::get_option();
322
-
323
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
324
  $adsense_id = $gadsense_data->get_adsense_id();
325
-
326
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $adsense_id . '/adclients/ca-' . $adsense_id . '/adunits/' . $adUnit . '/adcode';
327
- $access_token = $this->get_access_token( $adsense_id );
328
-
329
  if ( ! isset( $access_token['msg'] ) ) {
330
  $headers = array(
331
  'Authorization' => 'Bearer ' . $access_token,
332
  );
333
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
334
- $this->log( 'Get ad code for ad Unit [' . $adUnit . ']' );
335
-
336
  if ( is_wp_error( $response ) ) {
337
  return array(
338
  'status' => false,
@@ -342,26 +342,25 @@ class Advanced_Ads_AdSense_MAPI {
342
  } else {
343
  $adCode = json_decode( $response['body'], true );
344
  if ( null === $adCode || ! isset( $adCode['adCode'] ) ) {
345
- if (
346
- $adCode['error'] &&
347
- $adCode['error']['errors'] &&
348
- isset( $adCode['error']['errors'][0] ) &&
349
- isset( $adCode['error']['errors'][0]['reason'] ) &&
350
- 'doesNotSupportAdUnitType' == $adCode['error']['errors'][0]['reason']
351
- ) {
352
- $options['unsupported_units'][ $adUnit ] = 1;
353
- update_option( self::OPTNAME, $options );
354
- return array(
355
- 'status' => false,
356
- 'msg' => 'doesNotSupportAdUnitType',
357
- );
358
- } else {
359
- return array(
360
- 'status' => false,
361
- 'msg' => sprintf( esc_html__( 'Invalid response while retrieving ad code for "%s".', 'advanced-ads' ), $adUnit ),
362
- 'raw' => $response['body'],
363
- );
364
- }
365
  } else {
366
  $options['ad_codes'][ $adUnit ] = $adCode['adCode'];
367
  if ( isset( $options['unsupported_units'][ $adUnit ] ) ) {
@@ -376,26 +375,26 @@ class Advanced_Ads_AdSense_MAPI {
376
  return $access_token;
377
  }
378
  }
379
-
380
  /**
381
  * Get/Update ad unit list for a given client
382
  *
383
  * @return [bool]|[array] TRUE on success, error info (as array) if an error occurred.
384
  */
385
- public function get_ad_units( $account ) {
386
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
387
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $account . '/adclients/ca-' . $account . '/adunits?includeInactive=true';
388
- $access_token = $this->get_access_token( $account );
389
-
390
  $options = self::get_option();
391
-
392
  if ( ! isset( $access_token['msg'] ) ) {
393
  $headers = array(
394
  'Authorization' => 'Bearer ' . $access_token,
395
  );
396
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
397
- $this->log( 'Get ad units list for ca-' . $account );
398
-
399
  if ( is_wp_error( $response ) ) {
400
  return array(
401
  'status' => false,
@@ -406,9 +405,22 @@ class Advanced_Ads_AdSense_MAPI {
406
  $adUnits = json_decode( $response['body'], true );
407
 
408
  if ( null === $adUnits || ! isset( $adUnits['kind'] ) || 'adsense#adUnits' !== $adUnits['kind'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  return array(
410
  'status' => false,
411
- 'msg' => sprintf( esc_html__( 'Invalid response while retrieving adUnits list for "%s".', 'advanced-ads' ), $account ),
412
  'raw' => $response['body'],
413
  );
414
  } else {
@@ -439,70 +451,70 @@ class Advanced_Ads_AdSense_MAPI {
439
  return $access_token;
440
  }
441
  }
442
-
443
  /**
444
  * Get the appropriate access token (default one or from user's Google app). Update it if needed.
445
  *
446
  * @return [str]|[array] the token on success, error info (as array) if an error occurred.
447
  */
448
- public function get_access_token( $account ) {
449
  $options = self::get_option();
450
- if ( isset( $options['accounts'][ $account ] ) ) {
451
- if ( self::use_user_app() ) {
452
- if ( time() > $options['accounts'][ $account ]['user_app']['expires'] ) {
453
- $new_tokens = $this->renew_access_token( $account );
454
- if ( $new_tokens['status'] ) {
455
- return $new_tokens['access_token'];
456
- } else {
457
- // return all error info [arr]
458
- return $new_tokens;
459
- }
460
- } else {
461
- return $options['accounts'][ $account ]['user_app']['access_token'];
462
- }
463
- } else {
464
- if ( time() > $options['accounts'][ $account ]['default_app']['expires'] ) {
465
- $new_tokens = $this->renew_access_token( $account );
466
- if ( $new_tokens['status'] ) {
467
- return $new_tokens['access_token'];
468
- } else {
469
- // return all error info [arr]
470
- return $new_tokens;
471
- }
472
- } else {
473
- return $options['accounts'][ $account ]['default_app']['access_token'];
474
- }
475
- }
476
- } else {
477
- // Account does not exists.
478
- if ( ! empty( $options['accounts'] ) ) {
479
- // There is another account connected.
480
- return array(
481
- 'status' => false,
482
- 'msg' => esc_html__( 'It seems that some changes have been made in the Advanced Ads settings. Please refresh this page.', 'advanced-ads' ),
483
- 'reload' => true,
484
- );
485
- } else {
486
- // No account at all.
487
- return array(
488
- 'status' => false,
489
- 'msg' => wp_kses( sprintf( __( 'Advanced Ads does not have access to your account (<code>%s</code>) anymore.', 'advanced-ads' ), $account ), array( 'code' => true ) ),
490
- 'reload' => true,
491
- );
492
- }
493
- }
494
  }
495
-
496
  /**
497
  * Renew the current access token.
498
  */
499
- public function renew_access_token( $account ) {
500
  $cid = self::CID;
501
  $cs = self::CS;
502
  $options = self::get_option();
503
  $access_token = $options['accounts'][ $account ]['default_app']['access_token'];
504
  $refresh_token = $options['accounts'][ $account ]['default_app']['refresh_token'];
505
-
506
  if ( self::use_user_app() ) {
507
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
508
  $_options = $gadsense_data->get_options();
@@ -511,7 +523,7 @@ class Advanced_Ads_AdSense_MAPI {
511
  $access_token = $options['accounts'][ $account ]['user_app']['access_token'];
512
  $refresh_token = $options['accounts'][ $account ]['user_app']['refresh_token'];
513
  }
514
-
515
  $url = 'https://www.googleapis.com/oauth2/v4/token';
516
  $args = array(
517
  'body' => array(
@@ -521,10 +533,10 @@ class Advanced_Ads_AdSense_MAPI {
521
  'grant_type' => 'refresh_token',
522
  ),
523
  );
524
-
525
  $response = wp_remote_post( $url, $args );
526
- $this->log( 'Refresh access token' );
527
-
528
  if ( is_wp_error( $response ) ) {
529
  return array(
530
  'status' => false,
@@ -533,7 +545,10 @@ class Advanced_Ads_AdSense_MAPI {
533
  );
534
  } else {
535
  $tokens = json_decode( $response['body'], true );
536
- if ( null !== $tokens ) {
 
 
 
537
  $expires = time() + absint( $tokens['expires_in'] );
538
  if ( self::use_user_app() ) {
539
  $options['accounts'][ $account ]['user_app']['access_token'] = $tokens['access_token'];
@@ -556,12 +571,12 @@ class Advanced_Ads_AdSense_MAPI {
556
  }
557
  }
558
  }
559
-
560
  /**
561
  * Recoke a refresh token
562
  */
563
- public function ajax_revoke_tokken() {
564
-
565
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
566
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) {
567
  die;
@@ -569,7 +584,7 @@ class Advanced_Ads_AdSense_MAPI {
569
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
570
  $adsense_id = stripslashes( $_POST['adsenseId'] );
571
  $options = self::get_option();
572
-
573
  if ( self::use_user_app() ) {
574
  $token = $options['accounts'][ $adsense_id ]['user_app']['refresh_token'];
575
  } else {
@@ -580,14 +595,19 @@ class Advanced_Ads_AdSense_MAPI {
580
  'timeout' => 5,
581
  'header' => array( 'Content-type' => 'application/x-www-form-urlencoded' ),
582
  );
583
-
584
  $response = wp_remote_post( $url, $args );
585
-
586
- $this->log( 'Revoke API access for ca-' . $adsense_id );
587
-
588
  if ( is_wp_error( $response ) ) {
589
  echo json_encode( array( 'status' => false ) );
590
  } else {
 
 
 
 
 
591
  header( 'Content-Type: application/json' );
592
  unset( $options['accounts'][ $adsense_id ] );
593
  update_option( self::OPTNAME, $options );
@@ -595,9 +615,9 @@ class Advanced_Ads_AdSense_MAPI {
595
  }
596
  }
597
  die;
598
-
599
  }
600
-
601
  /**
602
  * Save ad code reconstructed from ad parameters
603
  */
@@ -619,7 +639,7 @@ class Advanced_Ads_AdSense_MAPI {
619
  }
620
  die;
621
  }
622
-
623
  /**
624
  * Get ad code for a given unit
625
  */
@@ -630,10 +650,10 @@ class Advanced_Ads_AdSense_MAPI {
630
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
631
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
632
  $unit = stripslashes( $_POST['unit'] );
633
-
634
  if ( ! self::use_user_app() ) {
635
  $quota = $this->get_quota();
636
-
637
  // No more quota left
638
  if ( $quota['count'] < 1 ) {
639
  $quota_msg = $this->get_quota_msg();
@@ -644,20 +664,20 @@ class Advanced_Ads_AdSense_MAPI {
644
  'quota' => 0,
645
  'quotaMsg' => $quota_msg,
646
  )
647
- );
648
  die;
649
  }
650
  }
651
-
652
  $code = $this->get_ad_code( $unit );
653
-
654
  /**
655
  * Ad code is returned as string. Otherwise it's an error
656
  */
657
  if ( is_string( $code ) ) {
658
-
659
  $response = array( 'code' => $code );
660
-
661
  /**
662
  * Add quota info for default API creds
663
  */
@@ -667,21 +687,20 @@ class Advanced_Ads_AdSense_MAPI {
667
  $response['quota'] = $quota['count'];
668
  $response['quotaMsg'] = $quota_msg;
669
  }
670
-
671
  header( 'Content-Type: application/json' );
672
  echo wp_json_encode( $response );
673
-
674
  } else {
675
-
676
  // return info about the error
677
  header( 'Content-Type: application/json' );
678
  echo wp_json_encode( $code );
679
-
680
  }
681
  }
682
  die;
683
  }
684
-
685
  /**
686
  * Dismiss an account alert
687
  */
@@ -804,32 +823,33 @@ class Advanced_Ads_AdSense_MAPI {
804
  die;
805
  }
806
 
807
- /**
808
- * Show / Hide idle ads on the ad list table.
809
- */
810
- public function ajax_toggle_idle_ads() {
811
- if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads' ) ) ) {
812
- die;
813
- }
814
- $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
815
- if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
816
-
817
- $hide = (bool)$_POST['hide'];
818
-
819
- ob_start();
820
- Advanced_Ads_AdSense_Admin::get_mapi_ad_selector( $hide );
821
- $ad_selector = ob_get_clean();
822
-
823
- $response = array(
824
- 'status' => true,
825
- 'html' => $ad_selector,
826
- );
827
- header( 'Content-Type: application/json' );
828
- echo wp_json_encode( $response );
829
- }
830
- die;
831
- }
832
-
 
833
  /**
834
  * Get / Update the ad unit list for a given ad client. The corresponding <select /> input used in the ad selector is passed as a fied of an array
835
  */
@@ -838,23 +858,23 @@ class Advanced_Ads_AdSense_MAPI {
838
  die;
839
  }
840
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
841
- if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
842
  $account = stripslashes( $_POST['account'] );
843
- $units = $this->get_ad_units( $account );
844
-
845
  if ( true === $units ) {
846
  $options = self::get_option();
847
  $ad_units = $options['accounts'][ $account ]['ad_units'];
848
-
849
  ob_start();
850
  Advanced_Ads_AdSense_Admin::get_mapi_ad_selector();
851
  $ad_selector = ob_get_clean();
852
-
853
  $response = array(
854
  'status' => true,
855
  'html' => $ad_selector,
856
  );
857
-
858
  /**
859
  * Add quota info for default API creds
860
  */
@@ -875,7 +895,7 @@ class Advanced_Ads_AdSense_MAPI {
875
  }
876
  die;
877
  }
878
-
879
  /**
880
  * Save account and token after account selection MCN.
881
  */
@@ -887,21 +907,21 @@ class Advanced_Ads_AdSense_MAPI {
887
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
888
  $token_data = wp_unslash( $_POST['token_data'] );
889
  $account = wp_unslash( $_POST['account'] );
890
-
891
  if ( $token_data && $account ) {
892
-
893
  self::save_token_from_data( $token_data, $account, array( 'autoads' => isset( $_POST['autoads'] ) ) );
894
-
895
  header( 'Content-Type: application/json' );
896
  echo json_encode(
897
  array(
898
  'status' => true,
899
  'adsense_id' => $account['id'],
900
  )
901
- );
902
-
903
  } else {
904
-
905
  $error = 'Token data missing';
906
  if ( $token_data ) {
907
  $error = 'No account provided';
@@ -912,13 +932,13 @@ class Advanced_Ads_AdSense_MAPI {
912
  'status' => false,
913
  'error_msg' => $error,
914
  )
915
- );
916
-
917
  }
918
  }
919
  die;
920
  }
921
-
922
  /**
923
  * Get AdSense account details from a new access token.
924
  */
@@ -928,60 +948,60 @@ class Advanced_Ads_AdSense_MAPI {
928
  }
929
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
930
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
931
-
932
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts';
933
  $token_data = wp_unslash( $_POST['token_data'] );
934
-
935
  if ( ! is_array( $token_data ) ) {
936
-
937
  header( 'Content-Type: application/json' );
938
  echo json_encode(
939
  array(
940
  'status' => false,
941
  'error_msg' => esc_html__( 'No token provided. Token data needed to get account details.', 'advanced-ads' ),
942
  )
943
- );
944
  die;
945
-
946
  }
947
-
948
  $headers = array( 'Authorization' => 'Bearer ' . $token_data['access_token'] );
949
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
950
-
951
- $this->log( 'Get account details from new access token' );
952
-
953
  if ( is_wp_error( $response ) ) {
954
-
955
  header( 'Content-Type: application/json' );
956
  echo json_encode(
957
  array(
958
  'status' => false,
959
  'error_msg' => $response->get_error_message(),
960
  )
961
- );
962
-
963
  } else {
964
-
965
  $accounts = json_decode( $response['body'], true );
966
-
967
  if ( isset( $accounts['items'] ) ) {
968
- $options = self::get_option();
969
- $options['connect_error'] = array();
970
- update_option( self::OPTNAME, $options );
971
-
972
  if ( 2 > count( $accounts['items'] ) ) {
973
-
974
  $adsense_id = $accounts['items'][0]['id'];
975
  self::save_token_from_data( $token_data, $accounts['items'][0], array( 'autoads' => isset( $_POST['autoads'] ) ) );
976
-
977
  header( 'Content-Type: application/json' );
978
  echo json_encode(
979
  array(
980
  'status' => true,
981
  'adsense_id' => $adsense_id,
982
  )
983
- );
984
-
985
  } else {
986
  $html = '';
987
  $details = array();
@@ -997,28 +1017,27 @@ class Advanced_Ads_AdSense_MAPI {
997
  'details' => $details,
998
  'token_data' => $token_data,
999
  )
1000
- );
1001
-
1002
  }
1003
  } else {
1004
  if ( isset( $accounts['error'] ) ) {
1005
-
1006
  $msg = esc_html__( 'An error occurred while requesting account details.', 'advanced-ads' );
1007
  if ( isset( $accounts['error']['message'] ) ) {
1008
  $msg = $accounts['error']['message'];
1009
  }
1010
-
1011
- $options = self::get_option();
1012
- $options['connect_error'] = array(
1013
- 'message' => $msg,
1014
- );
1015
-
1016
- if ( isset( $accounts['error']['errors'][0]['reason'] ) ) {
1017
- $options['connect_error']['reason'] = $accounts['error']['errors'][0]['reason'];
1018
- }
1019
-
1020
- update_option( self::OPTNAME, $options );
1021
-
1022
  header( 'Content-Type: application/json' );
1023
  echo json_encode(
1024
  array(
@@ -1026,15 +1045,15 @@ class Advanced_Ads_AdSense_MAPI {
1026
  'error_msg' => $msg,
1027
  'raw' => $accounts['error'],
1028
  )
1029
- );
1030
-
1031
  }
1032
  }
1033
  }
1034
  }
1035
  die;
1036
  }
1037
-
1038
  /**
1039
  * Submit Google API confirmation code. Save the token and update ad client list.
1040
  */
@@ -1047,18 +1066,18 @@ class Advanced_Ads_AdSense_MAPI {
1047
  $code = urldecode( $_POST['code'] );
1048
  $cid = self::CID;
1049
  $cs = self::CS;
1050
-
1051
  $use_user_app = self::use_user_app();
1052
-
1053
  if ( $use_user_app ) {
1054
  $cid = ADVANCED_ADS_MAPI_CID;
1055
  $cs = ADVANCED_ADS_MAPI_CIS;
1056
  }
1057
-
1058
  $code_url = 'https://www.googleapis.com/oauth2/v4/token';
1059
  $redirect_uri = 'urn:ietf:wg:oauth:2.0:oob';
1060
  $grant_type = 'authorization_code';
1061
-
1062
  $args = array(
1063
  'timeout' => 10,
1064
  'body' => array(
@@ -1069,11 +1088,11 @@ class Advanced_Ads_AdSense_MAPI {
1069
  'grant_type' => $grant_type,
1070
  ),
1071
  );
1072
-
1073
  $response = wp_remote_post( $code_url, $args );
1074
-
1075
- $this->log( 'Confirm authorization code' );
1076
-
1077
  if ( is_wp_error( $response ) ) {
1078
  return json_encode(
1079
  array(
@@ -1081,10 +1100,10 @@ class Advanced_Ads_AdSense_MAPI {
1081
  'msg' => 'error while submitting code',
1082
  'raw' => $response->get_error_message(),
1083
  )
1084
- );
1085
  } else {
1086
  $token = json_decode( $response['body'], true );
1087
-
1088
  if ( null !== $token && isset( $token['refresh_token'] ) ) {
1089
  $expires = time() + absint( $token['expires_in'] );
1090
  $token['expires'] = $expires;
@@ -1094,8 +1113,8 @@ class Advanced_Ads_AdSense_MAPI {
1094
  'status' => true,
1095
  'token_data' => $token,
1096
  )
1097
- );
1098
-
1099
  } else {
1100
  header( 'Content-Type: application/json' );
1101
  echo json_encode(
@@ -1103,13 +1122,13 @@ class Advanced_Ads_AdSense_MAPI {
1103
  'status' => false,
1104
  'response_body' => $response['body'],
1105
  )
1106
- );
1107
  }
1108
  }
1109
  }
1110
  die;
1111
  }
1112
-
1113
  /**
1114
  * Enqueue admin scripts
1115
  */
@@ -1118,30 +1137,30 @@ class Advanced_Ads_AdSense_MAPI {
1118
  wp_enqueue_script( 'gasense/mapi/settings', GADSENSE_BASE_URL . 'admin/assets/js/mapi-settings.js', array( 'jquery' ), ADVADS_VERSION );
1119
  }
1120
  }
1121
-
1122
- /**
1123
- * Print alert data in admin footer
1124
- */
1125
- public function admin_footer() {
1126
- $data = Advanced_Ads_AdSense_Data::get_instance();
1127
- $adsense_id = $data->get_adsense_id();
1128
- $has_token = Advanced_Ads_AdSense_MAPI::has_token( $adsense_id );
1129
- $alerts = self::get_stored_account_alerts( $adsense_id );
1130
- $refresh_alerts = false;
1131
-
1132
- // default value, never checked for alerts.
1133
- if ( array() === $alerts && $has_token ) {
1134
- $refresh_alerts = true;
1135
- }
1136
- if ( $has_token && is_array( $alerts ) && isset( $alerts['lastCheck'] ) ) {
1137
- // check weekly for alerts.
1138
- if ( time() > absint( $alerts['lastCheck'] ) + 3600 * 24 * 7 ) {
1139
- $refresh_alerts = true;
1140
- }
1141
- }
1142
- if ( $refresh_alerts ) {
1143
- $nonce = wp_create_nonce( 'mapi-alerts' );
1144
- ?>
1145
  <input type="hidden" id="advads-mapi-refresh-alerts" />
1146
  <script type="text/javascript">
1147
  ;(function($){
@@ -1174,7 +1193,7 @@ class Advanced_Ads_AdSense_MAPI {
1174
  }
1175
  }
1176
 
1177
- public function log( $task = 'No task provided' ) {
1178
  if ( ! defined( 'ADVANCED_ADS_LOG_ADSENSE_API' ) || ! ADVANCED_ADS_LOG_ADSENSE_API ) {
1179
  return;
1180
  }
@@ -1426,4 +1445,20 @@ class Advanced_Ads_AdSense_MAPI {
1426
  }
1427
  return self::$instance;
1428
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1429
  }
1
  <?php
2
  class Advanced_Ads_AdSense_MAPI {
3
+
4
  const OPTNAME = 'advanced-ads-adsense-mapi';
5
+
6
+ const ALERTS_URL = 'https://www.googleapis.com/adsense/v1.4/accounts/PUBID/alerts/';
7
+
8
  const CID = '400595147946-alk0j13qk563bg94rd4f3ip2t0b2tr5r.apps.googleusercontent.com';
9
+
10
  const CS = '5jecyWgvCszB8UxSM0oS1W22';
11
+
12
  const CALL_PER_24H = 20;
13
+
14
  const UNSUPPORTED_TYPE_LINK = 'https://wpadvancedads.com/adsense-ad-type-not-available/';
15
+
16
  private static $instance = null;
17
+
18
  private static $default_options = array();
19
+
20
  private static $empty_account_data = array(
21
  'default_app' => array(
22
  'access_token' => '',
32
  ),
33
  'ad_units' => array(),
34
  'details' => array(),
35
+ 'alerts' => array(),
36
  );
37
+
38
  private function __construct() {
39
+
40
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
41
+
42
  add_action( 'wp_ajax_advads_gadsense_mapi_confirm_code', array( $this, 'ajax_confirm_code' ) );
43
+ //add_action( 'wp_ajax_advads_gadsense_mapi_get_adUnits', array( $this, 'ajax_get_adUnits' ) );
44
  add_action( 'wp_ajax_advads_gadsense_mapi_get_details', array( $this, 'ajax_get_account_details' ) );
45
  add_action( 'wp_ajax_advads_gadsense_mapi_select_account', array( $this, 'ajax_account_selected' ) );
46
  add_action( 'wp_ajax_advads_mapi_get_adCode', array( $this, 'ajax_get_adCode' ) );
48
  add_action( 'wp_ajax_advads-mapi-revoke-token', array( $this, 'ajax_revoke_tokken' ) );
49
  add_action( 'wp_ajax_advads-mapi-get-alerts', array( $this, 'ajax_get_account_alerts' ) );
50
  add_action( 'wp_ajax_advads-mapi-dismiss-alert', array( $this, 'ajax_dismiss_alert' ) );
51
+ add_action( 'wp_ajax_advads-mapi-dismiss-connect-error', array( $this, 'ajax_dismiss_connect_error' ) );
52
+ add_action( 'wp_ajax_advads_gadsense_dashboard', array( 'Advanced_Ads_Overview_Widgets_Callbacks', 'ajax_gadsense_dashboard' ) );
 
 
53
 
54
+ add_action( 'admin_footer', array( $this, 'admin_footer' ) );
55
+
56
  self::$default_options = array(
57
  'accounts' => array(),
58
  'ad_codes' => array(),
61
  'count' => self::CALL_PER_24H,
62
  'ts' => 0,
63
  ),
64
+ 'connect_error' => array(),
65
  );
66
+
67
+ add_filter( 'advanced-ads-support-messages', array( 'Advanced_Ads_AdSense_MAPI', 'adsense_warnings_check' ) );
68
+
69
+ add_action( 'wp_loaded', array( $this, 'update_ad_health_notices' ) );
70
+
71
  }
72
+
73
+ /**
74
+ * Update all MAPI related notices.
75
+ */
76
+ public function update_ad_health_notices() {
77
+ $mapi_options = self::get_option();
78
+
79
+ $connection_error_messages = self::get_connect_error_messages();
80
+
81
+ $health_class = Advanced_Ads_Ad_Health_Notices::get_instance();
82
+
83
+ // Last connection failed.
84
+ if ( isset ( $mapi_options['connect_error'] ) && ! empty( $mapi_options['connect_error'] ) ) {
85
+
86
+ if ( isset( $connection_error_messages[ $mapi_options['connect_error']['reason'] ] ) ) {
87
+ $health_class->add( 'adsense_connect_' . $mapi_options['connect_error']['reason'] );
88
+ } else {
89
+ $health_class->add( 'adsense_connect_' . $mapi_options['connect_error']['reason'], array(
90
+ 'text' => esc_html__( 'Last AdSense account connection attempt failed.', 'advanced-ads' ) . ' ' . $mapi_options['connect_error']['message'],
91
+ 'type' => 'problem',
92
+ ) );
93
+ }
94
+
95
+ foreach( $health_class->notices as $key => $value ) {
96
+ // There was already a connection error but the user tried again and obtained another error.
97
+ if ( false !== stripos( $key, 'adsense_connect_' ) && 'adsense_connect_' . $mapi_options['connect_error']['reason'] !== $key ) {
98
+ $health_class->remove( $key );
99
+ }
100
+ }
101
+
102
+ } else {
103
+
104
+ // Once a connection has been established (or a the warning has been discarded on the AA settings page), remove connection related notices.
105
+ foreach( $health_class->notices as $key => $value ) {
106
+ if ( false !== stripos( $key, 'adsense_connect_' ) ) {
107
+ $health_class->remove( $key );
108
+ }
109
+ }
110
+
111
+ }
112
+
113
+ $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
114
+ $adsense_id = $gadsense_data->get_adsense_id();
115
+
116
+ $alerts = Advanced_Ads_AdSense_MAPI::get_stored_account_alerts( $adsense_id );
117
+
118
+ // AdSense account alerts (can not happens simultaneously with the connection error).
119
+ if ( is_array( $alerts ) && isset( $alerts['items'] ) && is_array( $alerts['items'] ) && $alerts['items'] ) {
120
+
121
+ $alerts_advads_messages = Advanced_Ads_Adsense_MAPI::get_adsense_alert_messages();
122
+ $item_ids = array();
123
+
124
+ foreach ( $alerts['items'] as $internal_id => $item ) {
125
+ $item_ids[] = $item['id'];
126
+ if ( isset( $alerts_advads_messages[ $item['id'] ] ) ) {
127
+ $health_class->add( 'adsense_alert_' . $item['id'] );
128
+ } else {
129
+ $health_class->add( 'adsense_alert_' . $item['id'], array( 'text' => $item['message'] . ' ' . self::get_adsense_error_link( $item['id'] ), 'type' => 'problem' ) );
130
+ }
131
+
132
+ }
133
+
134
+ // Remove notices that no more exist in the AdSense account (or have been dismissed).
135
+ $_remove_ids = array();
136
+ foreach( $health_class->notices as $key => $value ) {
137
+ if ( false !== stripos( $key, 'adsense_alert_' ) ) {
138
+ $alert_id = substr( $key, strlen( 'adsense_alert_' ) );
139
+ if ( ! in_array( $alert_id, $item_ids, true ) ) {
140
+ $_remove_ids[] = $key;
141
+ }
142
+ }
143
+ }
144
+ foreach( $_remove_ids as $id ) {
145
+ $health_class->remove( $id );
146
+ }
147
+
148
+ } else {
149
+ // No more alerts.
150
+ foreach( $health_class->notices as $key => $value ) {
151
+ if ( false !== stripos( $key, 'adsense_alert_' ) ) {
152
+ $health_class->remove( $key );
153
+ }
154
+ }
155
+
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Discard account connection error
161
+ */
162
+ public function ajax_dismiss_connect_error() {
163
  $nonce = isset( $_GET['nonce'] ) ? $_GET['nonce'] : '';
164
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) {
165
  die;
166
  }
167
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
168
+ $options = self::get_option();
169
+ $options['connect_error'] = array();
170
+ update_option( self::OPTNAME, $options );
171
+ echo 1;
172
+ }
173
+ die;
174
+ }
175
+
176
  /**
177
  * Get available quota and eventual message about remaining call
178
  */
195
  }
196
  }
197
  }
198
+
199
  /**
200
  * Get the readable quota
201
  */
202
  public function get_quota_msg() {
203
+
204
  $options = $this->get_option();
205
  $now = time();
206
  $secs = $options['quota']['ts'] + ( 24 * 3600 ) - $now;
207
  $hours = floor( $secs / 3600 );
208
  $mins = ceil( ( $secs - ( $hours * 3600 ) ) / 60 );
209
+
210
  if ( 60 == $mins ) {
211
  $hours += 1;
212
  $mins = 0;
213
  }
214
+
215
  if ( 0 == $options['quota']['count'] ) {
216
+
217
  $msg = sprintf(
218
  /*
219
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
220
+ _x( 'No API call left before %1$s %2$s.', 'No call left for the next X hours Y minutes.', 'advanced-ads' ),
221
+ sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
222
+ sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
223
+ */
224
  'No API call left before %1$s %2$s.',
225
  sprintf( '%s hours', $hours ),
226
  sprintf( '%s minutes', $mins )
227
+ );
228
+
229
  if ( 0 == $hours ) {
230
  /*
231
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
232
+ $msg = sprintf(
233
+ _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
234
+ sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
235
+ );
236
  */
237
+ $msg = 'No API call left before.';
238
  }
239
+
240
  if ( 0 == $mins ) {
241
  /*
242
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
243
+ $msg = sprintf(
244
+ _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
245
+ sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
246
+ );
247
  */
248
  $msg = 'No API call left.';
249
  }
250
  } else {
251
+
252
  $msg = sprintf(
253
  /*
254
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
255
+ _x( '%1$s for the next %2$s %3$s.', 'Calls remaining for the next X hours Y minutes.', 'advanced-ads' ),
256
+ sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
257
+ sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
258
+ sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
259
  */
260
  '%1$s for the next %2$s %3$s',
261
  sprintf( '%s API calls remaining', $options['quota']['count'] ),
262
  sprintf( '%s hours', $hours ),
263
  sprintf( '%s minutes', $mins )
264
+ );
265
+
266
  if ( 0 == $hours ) {
267
  /*
268
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
269
+ $msg = sprintf(
270
+ _x( '%1$s for the next %2$s', 'Calls remaining for the next X time.', 'advanced-ads' ),
271
+ sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
272
+ sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
273
+ );
274
  */
275
  $msg = sprintf( '%s API calls remaining.', $options['quota']['count'] );
276
  }
277
+
278
  if ( 0 == $mins ) {
279
  /*
280
  commented out so that these unused strings don’t show up for translators; using fixed strings instead in case we forget this when we might add the check again later
281
+ $msg = sprintf(
282
+ _x( '%1$s for the next %2$s', 'calls remaining for the next X time', 'advanced-ads' ),
283
+ sprintf( _n( '%s API call remaining', '%s API calls remaining', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
284
+ sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
285
+ );
286
  */
287
  $msg = sprintf(
288
  '%1$s for the next %2$s',
289
  sprintf( '%s API calls remaining', $options['quota']['count'] ),
290
  sprintf( '%s hours', $hours )
291
+ );
292
  }
293
  }
294
  return $msg;
295
  }
296
+
297
  /**
298
  * Decrement quota by 1, and return message about remaining call
299
  */
309
  return $this->get_quota_msg();
310
  }
311
  }
312
+
313
  /**
314
  * Return the ad code for a given client and unit
315
  *
319
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
320
  $adsense_id = $gadsense_data->get_adsense_id();
321
  $options = self::get_option();
322
+
323
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
324
  $adsense_id = $gadsense_data->get_adsense_id();
325
+
326
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $adsense_id . '/adclients/ca-' . $adsense_id . '/adunits/' . $adUnit . '/adcode';
327
+ $access_token = self::get_access_token( $adsense_id );
328
+
329
  if ( ! isset( $access_token['msg'] ) ) {
330
  $headers = array(
331
  'Authorization' => 'Bearer ' . $access_token,
332
  );
333
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
334
+ self::log( 'Get ad code for ad Unit [' . $adUnit . ']' );
335
+
336
  if ( is_wp_error( $response ) ) {
337
  return array(
338
  'status' => false,
342
  } else {
343
  $adCode = json_decode( $response['body'], true );
344
  if ( null === $adCode || ! isset( $adCode['adCode'] ) ) {
345
+ if ($adCode['error'] &&
346
+ $adCode['error']['errors'] &&
347
+ isset( $adCode['error']['errors'][0] ) &&
348
+ isset( $adCode['error']['errors'][0]['reason'] ) &&
349
+ 'doesNotSupportAdUnitType' == $adCode['error']['errors'][0]['reason']
350
+ ) {
351
+ $options['unsupported_units'][ $adUnit ] = 1;
352
+ update_option( self::OPTNAME, $options );
353
+ return array(
354
+ 'status' => false,
355
+ 'msg' => 'doesNotSupportAdUnitType',
356
+ );
357
+ } else {
358
+ return array(
359
+ 'status' => false,
360
+ 'msg' => sprintf( esc_html__( 'Invalid response while retrieving ad code for "%s".', 'advanced-ads' ), $adUnit ),
361
+ 'raw' => $response['body'],
362
+ );
363
+ }
 
364
  } else {
365
  $options['ad_codes'][ $adUnit ] = $adCode['adCode'];
366
  if ( isset( $options['unsupported_units'][ $adUnit ] ) ) {
375
  return $access_token;
376
  }
377
  }
378
+
379
  /**
380
  * Get/Update ad unit list for a given client
381
  *
382
  * @return [bool]|[array] TRUE on success, error info (as array) if an error occurred.
383
  */
384
+ public static function get_ad_units( $account ) {
385
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
386
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $account . '/adclients/ca-' . $account . '/adunits?includeInactive=true';
387
+ $access_token = self::get_access_token( $account );
388
+
389
  $options = self::get_option();
390
+
391
  if ( ! isset( $access_token['msg'] ) ) {
392
  $headers = array(
393
  'Authorization' => 'Bearer ' . $access_token,
394
  );
395
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
396
+ self::log( 'Get ad units list for ca-' . $account );
397
+
398
  if ( is_wp_error( $response ) ) {
399
  return array(
400
  'status' => false,
405
  $adUnits = json_decode( $response['body'], true );
406
 
407
  if ( null === $adUnits || ! isset( $adUnits['kind'] ) || 'adsense#adUnits' !== $adUnits['kind'] ) {
408
+ $error_message = sprintf( esc_html__( 'Invalid response while retrieving adUnits list for "%s".', 'advanced-ads' ), $account );
409
+ // check the response for errors and display them for better problem solving
410
+ if ($adUnits && isset($adUnits['error']) && isset($adUnits['error']['errors']) && count($adUnits['error']['errors'])) {
411
+ foreach ($adUnits['error']['errors'] as $err) {
412
+ $hint = self::get_adsense_error_hint($err['reason']);
413
+ if ($hint) {
414
+ $error_message .= "<p class=\"description\">$hint</p>";
415
+ }
416
+ $error_message .= '<p class="description">' . __('Reason:', 'advanced-ads') . ' "' . $err['reason'] . '"<br>';
417
+ $error_message .= __('Message:', 'advanced-ads') . ' "' . $err['message'] . '"</p>';
418
+ }
419
+ }
420
+
421
  return array(
422
  'status' => false,
423
+ 'msg' => $error_message,
424
  'raw' => $response['body'],
425
  );
426
  } else {
451
  return $access_token;
452
  }
453
  }
454
+
455
  /**
456
  * Get the appropriate access token (default one or from user's Google app). Update it if needed.
457
  *
458
  * @return [str]|[array] the token on success, error info (as array) if an error occurred.
459
  */
460
+ public static function get_access_token( $account ) {
461
  $options = self::get_option();
462
+ if ( isset( $options['accounts'][ $account ] ) ) {
463
+ if ( self::use_user_app() ) {
464
+ if ( time() > $options['accounts'][ $account ]['user_app']['expires'] ) {
465
+ $new_tokens = self::renew_access_token( $account );
466
+ if ( $new_tokens['status'] ) {
467
+ return $new_tokens['access_token'];
468
+ } else {
469
+ // return all error info [arr]
470
+ return $new_tokens;
471
+ }
472
+ } else {
473
+ return $options['accounts'][ $account ]['user_app']['access_token'];
474
+ }
475
+ } else {
476
+ if ( time() > $options['accounts'][ $account ]['default_app']['expires'] ) {
477
+ $new_tokens = self::renew_access_token( $account );
478
+ if ( $new_tokens['status'] ) {
479
+ return $new_tokens['access_token'];
480
+ } else {
481
+ // return all error info [arr]
482
+ return $new_tokens;
483
+ }
484
+ } else {
485
+ return $options['accounts'][ $account ]['default_app']['access_token'];
486
+ }
487
+ }
488
+ } else {
489
+ // Account does not exists.
490
+ if ( ! empty( $options['accounts'] ) ) {
491
+ // There is another account connected.
492
+ return array(
493
+ 'status' => false,
494
+ 'msg' => esc_html__( 'It seems that some changes have been made in the Advanced Ads settings. Please refresh this page.', 'advanced-ads' ),
495
+ 'reload' => true,
496
+ );
497
+ } else {
498
+ // No account at all.
499
+ return array(
500
+ 'status' => false,
501
+ 'msg' => wp_kses( sprintf( __( 'Advanced Ads does not have access to your account (<code>%s</code>) anymore.', 'advanced-ads' ), $account ), array( 'code' => true ) ),
502
+ 'reload' => true,
503
+ );
504
+ }
505
+ }
506
  }
507
+
508
  /**
509
  * Renew the current access token.
510
  */
511
+ public static function renew_access_token( $account ) {
512
  $cid = self::CID;
513
  $cs = self::CS;
514
  $options = self::get_option();
515
  $access_token = $options['accounts'][ $account ]['default_app']['access_token'];
516
  $refresh_token = $options['accounts'][ $account ]['default_app']['refresh_token'];
517
+
518
  if ( self::use_user_app() ) {
519
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
520
  $_options = $gadsense_data->get_options();
523
  $access_token = $options['accounts'][ $account ]['user_app']['access_token'];
524
  $refresh_token = $options['accounts'][ $account ]['user_app']['refresh_token'];
525
  }
526
+
527
  $url = 'https://www.googleapis.com/oauth2/v4/token';
528
  $args = array(
529
  'body' => array(
533
  'grant_type' => 'refresh_token',
534
  ),
535
  );
536
+
537
  $response = wp_remote_post( $url, $args );
538
+ self::log( 'Refresh access token' );
539
+
540
  if ( is_wp_error( $response ) ) {
541
  return array(
542
  'status' => false,
545
  );
546
  } else {
547
  $tokens = json_decode( $response['body'], true );
548
+ // checking for the $tokens is not enough. it can be empty.
549
+ // monitored this, when the access token is revoked from the outside
550
+ // this can happen, when the user connects from another domain.
551
+ if ( null !== $tokens && isset($tokens['expires_in']) ) {
552
  $expires = time() + absint( $tokens['expires_in'] );
553
  if ( self::use_user_app() ) {
554
  $options['accounts'][ $account ]['user_app']['access_token'] = $tokens['access_token'];
571
  }
572
  }
573
  }
574
+
575
  /**
576
  * Recoke a refresh token
577
  */
578
+ public function ajax_revoke_tokken() {
579
+
580
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
581
  if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_manage_options' ) ) ) {
582
  die;
584
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
585
  $adsense_id = stripslashes( $_POST['adsenseId'] );
586
  $options = self::get_option();
587
+
588
  if ( self::use_user_app() ) {
589
  $token = $options['accounts'][ $adsense_id ]['user_app']['refresh_token'];
590
  } else {
595
  'timeout' => 5,
596
  'header' => array( 'Content-type' => 'application/x-www-form-urlencoded' ),
597
  );
598
+
599
  $response = wp_remote_post( $url, $args );
600
+
601
+ self::log( 'Revoke API access for ca-' . $adsense_id );
602
+
603
  if ( is_wp_error( $response ) ) {
604
  echo json_encode( array( 'status' => false ) );
605
  } else {
606
+ // remove all the adsense stats
607
+ global $wpdb;
608
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'advanced_ads_adsense_report_%';" );
609
+ delete_option("advanced-ads-adsense-dashboard-filter");
610
+
611
  header( 'Content-Type: application/json' );
612
  unset( $options['accounts'][ $adsense_id ] );
613
  update_option( self::OPTNAME, $options );
615
  }
616
  }
617
  die;
618
+
619
  }
620
+
621
  /**
622
  * Save ad code reconstructed from ad parameters
623
  */
639
  }
640
  die;
641
  }
642
+
643
  /**
644
  * Get ad code for a given unit
645
  */
650
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
651
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
652
  $unit = stripslashes( $_POST['unit'] );
653
+
654
  if ( ! self::use_user_app() ) {
655
  $quota = $this->get_quota();
656
+
657
  // No more quota left
658
  if ( $quota['count'] < 1 ) {
659
  $quota_msg = $this->get_quota_msg();
664
  'quota' => 0,
665
  'quotaMsg' => $quota_msg,
666
  )
667
+ );
668
  die;
669
  }
670
  }
671
+
672
  $code = $this->get_ad_code( $unit );
673
+
674
  /**
675
  * Ad code is returned as string. Otherwise it's an error
676
  */
677
  if ( is_string( $code ) ) {
678
+
679
  $response = array( 'code' => $code );
680
+
681
  /**
682
  * Add quota info for default API creds
683
  */
687
  $response['quota'] = $quota['count'];
688
  $response['quotaMsg'] = $quota_msg;
689
  }
690
+
691
  header( 'Content-Type: application/json' );
692
  echo wp_json_encode( $response );
693
+
694
  } else {
695
+
696
  // return info about the error
697
  header( 'Content-Type: application/json' );
698
  echo wp_json_encode( $code );
699
+
700
  }
701
  }
702
  die;
703
  }
 
704
  /**
705
  * Dismiss an account alert
706
  */
823
  die;
824
  }
825
 
826
+ // /**
827
+ // * Show / Hide idle ads on the ad list table.
828
+ // */
829
+ // public function ajax_toggle_idle_ads() {
830
+ // if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads' ) ) ) {
831
+ // die;
832
+ // }
833
+ //
834
+ // $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
835
+ // if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
836
+ //
837
+ // $hide = (bool)$_POST['hide'];
838
+ //
839
+ // ob_start();
840
+ // Advanced_Ads_AdSense_Admin::get_mapi_ad_selector( $hide );
841
+ // $ad_selector = ob_get_clean();
842
+ //
843
+ // $response = array(
844
+ // 'status' => true,
845
+ // 'html' => $ad_selector,
846
+ // );
847
+ // header( 'Content-Type: application/json' );
848
+ // echo wp_json_encode( $response );
849
+ // }
850
+ // die;
851
+ // }
852
+
853
  /**
854
  * Get / Update the ad unit list for a given ad client. The corresponding <select /> input used in the ad selector is passed as a fied of an array
855
  */
858
  die;
859
  }
860
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
861
+ if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) && isset($_POST['account'])) {
862
  $account = stripslashes( $_POST['account'] );
863
+ $units = self::get_ad_units( $account );
864
+
865
  if ( true === $units ) {
866
  $options = self::get_option();
867
  $ad_units = $options['accounts'][ $account ]['ad_units'];
868
+
869
  ob_start();
870
  Advanced_Ads_AdSense_Admin::get_mapi_ad_selector();
871
  $ad_selector = ob_get_clean();
872
+
873
  $response = array(
874
  'status' => true,
875
  'html' => $ad_selector,
876
  );
877
+
878
  /**
879
  * Add quota info for default API creds
880
  */
895
  }
896
  die;
897
  }
898
+
899
  /**
900
  * Save account and token after account selection MCN.
901
  */
907
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
908
  $token_data = wp_unslash( $_POST['token_data'] );
909
  $account = wp_unslash( $_POST['account'] );
910
+
911
  if ( $token_data && $account ) {
912
+
913
  self::save_token_from_data( $token_data, $account, array( 'autoads' => isset( $_POST['autoads'] ) ) );
914
+
915
  header( 'Content-Type: application/json' );
916
  echo json_encode(
917
  array(
918
  'status' => true,
919
  'adsense_id' => $account['id'],
920
  )
921
+ );
922
+
923
  } else {
924
+
925
  $error = 'Token data missing';
926
  if ( $token_data ) {
927
  $error = 'No account provided';
932
  'status' => false,
933
  'error_msg' => $error,
934
  )
935
+ );
936
+
937
  }
938
  }
939
  die;
940
  }
941
+
942
  /**
943
  * Get AdSense account details from a new access token.
944
  */
948
  }
949
  $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
950
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
951
+
952
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts';
953
  $token_data = wp_unslash( $_POST['token_data'] );
954
+
955
  if ( ! is_array( $token_data ) ) {
956
+
957
  header( 'Content-Type: application/json' );
958
  echo json_encode(
959
  array(
960
  'status' => false,
961
  'error_msg' => esc_html__( 'No token provided. Token data needed to get account details.', 'advanced-ads' ),
962
  )
963
+ );
964
  die;
965
+
966
  }
967
+
968
  $headers = array( 'Authorization' => 'Bearer ' . $token_data['access_token'] );
969
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
970
+
971
+ self::log( 'Get account details from new access token' );
972
+
973
  if ( is_wp_error( $response ) ) {
974
+
975
  header( 'Content-Type: application/json' );
976
  echo json_encode(
977
  array(
978
  'status' => false,
979
  'error_msg' => $response->get_error_message(),
980
  )
981
+ );
982
+
983
  } else {
984
+
985
  $accounts = json_decode( $response['body'], true );
986
+
987
  if ( isset( $accounts['items'] ) ) {
988
+ $options = self::get_option();
989
+ $options['connect_error'] = array();
990
+ update_option( self::OPTNAME, $options );
991
+
992
  if ( 2 > count( $accounts['items'] ) ) {
993
+
994
  $adsense_id = $accounts['items'][0]['id'];
995
  self::save_token_from_data( $token_data, $accounts['items'][0], array( 'autoads' => isset( $_POST['autoads'] ) ) );
996
+
997
  header( 'Content-Type: application/json' );
998
  echo json_encode(
999
  array(
1000
  'status' => true,
1001
  'adsense_id' => $adsense_id,
1002
  )
1003
+ );
1004
+
1005
  } else {
1006
  $html = '';
1007
  $details = array();
1017
  'details' => $details,
1018
  'token_data' => $token_data,
1019
  )
1020
+ );
1021
+
1022
  }
1023
  } else {
1024
  if ( isset( $accounts['error'] ) ) {
 
1025
  $msg = esc_html__( 'An error occurred while requesting account details.', 'advanced-ads' );
1026
  if ( isset( $accounts['error']['message'] ) ) {
1027
  $msg = $accounts['error']['message'];
1028
  }
1029
+
1030
+ $options = self::get_option();
1031
+ $options['connect_error'] = array(
1032
+ 'message' => $msg,
1033
+ );
1034
+
1035
+ if ( isset( $accounts['error']['errors'][0]['reason'] ) ) {
1036
+ $options['connect_error']['reason'] = $accounts['error']['errors'][0]['reason'];
1037
+ }
1038
+
1039
+ update_option( self::OPTNAME, $options );
1040
+
1041
  header( 'Content-Type: application/json' );
1042
  echo json_encode(
1043
  array(
1045
  'error_msg' => $msg,
1046
  'raw' => $accounts['error'],
1047
  )
1048
+ );
1049
+
1050
  }
1051
  }
1052
  }
1053
  }
1054
  die;
1055
  }
1056
+
1057
  /**
1058
  * Submit Google API confirmation code. Save the token and update ad client list.
1059
  */
1066
  $code = urldecode( $_POST['code'] );
1067
  $cid = self::CID;
1068
  $cs = self::CS;
1069
+
1070
  $use_user_app = self::use_user_app();
1071
+
1072
  if ( $use_user_app ) {
1073
  $cid = ADVANCED_ADS_MAPI_CID;
1074
  $cs = ADVANCED_ADS_MAPI_CIS;
1075
  }
1076
+
1077
  $code_url = 'https://www.googleapis.com/oauth2/v4/token';
1078
  $redirect_uri = 'urn:ietf:wg:oauth:2.0:oob';
1079
  $grant_type = 'authorization_code';
1080
+
1081
  $args = array(
1082
  'timeout' => 10,
1083
  'body' => array(
1088
  'grant_type' => $grant_type,
1089
  ),
1090
  );
1091
+
1092
  $response = wp_remote_post( $code_url, $args );
1093
+
1094
+ self::log( 'Confirm authorization code' );
1095
+
1096
  if ( is_wp_error( $response ) ) {
1097
  return json_encode(
1098
  array(
1100
  'msg' => 'error while submitting code',
1101
  'raw' => $response->get_error_message(),
1102
  )
1103
+ );
1104
  } else {
1105
  $token = json_decode( $response['body'], true );
1106
+
1107
  if ( null !== $token && isset( $token['refresh_token'] ) ) {
1108
  $expires = time() + absint( $token['expires_in'] );
1109
  $token['expires'] = $expires;
1113
  'status' => true,
1114
  'token_data' => $token,
1115
  )
1116
+ );
1117
+
1118
  } else {
1119
  header( 'Content-Type: application/json' );
1120
  echo json_encode(
1122
  'status' => false,
1123
  'response_body' => $response['body'],
1124
  )
1125
+ );
1126
  }
1127
  }
1128
  }
1129
  die;
1130
  }
1131
+
1132
  /**
1133
  * Enqueue admin scripts
1134
  */
1137
  wp_enqueue_script( 'gasense/mapi/settings', GADSENSE_BASE_URL . 'admin/assets/js/mapi-settings.js', array( 'jquery' ), ADVADS_VERSION );
1138
  }
1139
  }
1140
+
1141
+ /**
1142
+ * Print alert data in admin footer
1143
+ */
1144
+ public function admin_footer() {
1145
+ $data = Advanced_Ads_AdSense_Data::get_instance();
1146
+ $adsense_id = $data->get_adsense_id();
1147
+ $has_token = Advanced_Ads_AdSense_MAPI::has_token( $adsense_id );
1148
+ $alerts = self::get_stored_account_alerts( $adsense_id );
1149
+ $refresh_alerts = false;
1150
+
1151
+ // default value, never checked for alerts.
1152
+ if ( array() === $alerts && $has_token ) {
1153
+ $refresh_alerts = true;
1154
+ }
1155
+ if ( $has_token && is_array( $alerts ) && isset( $alerts['lastCheck'] ) ) {
1156
+ // check weekly for alerts.
1157
+ if ( time() > absint( $alerts['lastCheck'] ) + 3600 * 24 * 7 ) {
1158
+ $refresh_alerts = true;
1159
+ }
1160
+ }
1161
+ if ( $refresh_alerts ) {
1162
+ $nonce = wp_create_nonce( 'mapi-alerts' );
1163
+ ?>
1164
  <input type="hidden" id="advads-mapi-refresh-alerts" />
1165
  <script type="text/javascript">
1166
  ;(function($){
1193
  }
1194
  }
1195
 
1196
+ public static function log( $task = 'No task provided' ) {
1197
  if ( ! defined( 'ADVANCED_ADS_LOG_ADSENSE_API' ) || ! ADVANCED_ADS_LOG_ADSENSE_API ) {
1198
  return;
1199
  }
1445
  }
1446
  return self::$instance;
1447
  }
1448
+
1449
+ /**
1450
+ * get a hint for an error object that was received from AdSense
1451
+ * @param $reason string the reason from the response's error
1452
+ * @return string|void if there is a hint for this reason, a string containing the hint will be returned.
1453
+ */
1454
+ public static final function get_adsense_error_hint($reason){
1455
+
1456
+ switch($reason){
1457
+ case "authError":
1458
+ /* translators: 1:A link to the settings page
1459
+ translators: 2:The name of an ad network
1460
+ */
1461
+ return sprintf(__( 'Please try to <a href="%1$s" target="_blank">reconnect to your %2$s account</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ), 'AdSense');
1462
+ }
1463
+ }
1464
  }
modules/gadsense/includes/class-network-adsense.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Advanced_Ads_Network_Adsense extends Advanced_Ads_Ad_Network{
3
+ /**
4
+ * @var array an array containing all the AdSense status codes that flag an {$link Advanced_Ads_Ad_Network_Ad_Unit} ad unit as active
5
+ * for downward compatibility with PHP < 5.6 the const had to be changed to static field. you can revert to const when PHP5 support is FINALLY dropped
6
+ */
7
+ // const STATUS_CODES_ACTIVE = array("ACTIVE", "NEW");
8
+ private static $STATUS_CODES_ACTIVE = array("ACTIVE", "NEW");
9
+
10
+ /**
11
+ * @var Advanced_Ads_Ad_Type_Adsense a globally usable instance, that will be created when calling {$link Advanced_Ads_Ad_Network#get_instance) for the first time
12
+ */
13
+ private static $instance;
14
+
15
+ public static final function get_instance(){
16
+ if (! self::$instance) self::$instance = new Advanced_Ads_Network_Adsense();
17
+ return self::$instance;
18
+ }
19
+
20
+ public function __construct()
21
+ {
22
+ parent::__construct('adsense', 'AdSense');
23
+ $this->data = Advanced_Ads_AdSense_Data::get_instance();
24
+
25
+ //adsense does not use the default generated settings section id. overwrite it with the old value.
26
+ $this->settings_section_id = 'advanced_ads_adsense_setting_section';
27
+ }
28
+
29
+ protected function register_settings($hook, $section_id)
30
+ {
31
+ // add setting field to disable ads
32
+ add_settings_field(
33
+ 'adsense-id',
34
+ __( 'AdSense account', 'advanced-ads' ),
35
+ array($this, 'render_settings_adsense_id'),
36
+ $hook,
37
+ $section_id
38
+ );
39
+
40
+ // activate AdSense verification code and Auto ads (previously Page-Level ads)
41
+ add_settings_field(
42
+ 'adsense-page-level',
43
+ __( 'Verification code & Auto ads', 'advanced-ads' ),
44
+ array($this, 'render_settings_adsense_page_level'),
45
+ $hook,
46
+ $section_id
47
+ );
48
+
49
+ // AdSense anchor ad on top of pages.
50
+ add_settings_field(
51
+ 'top_anchor_ad',
52
+ __( 'Auto ads', 'advanced-ads' ) . ':&nbsp;' . __( 'Disable top anchor ad', 'advanced-ads' ),
53
+ array( $this, 'render_settings_adsense_top_anchor_ad' ),
54
+ $hook,
55
+ $section_id
56
+ );
57
+
58
+ // add setting field for adsense limit
59
+ // deprecated of January, 2019; will be removed one year later
60
+ $limit_per_page = $this->data->get_limit_per_page();
61
+ if( $limit_per_page ){
62
+ add_settings_field(
63
+ 'adsense-limit',
64
+ __( 'Limit to 3 ads', 'advanced-ads' ),
65
+ array($this, 'render_settings_adsense_limit'),
66
+ $hook,
67
+ $section_id
68
+ );
69
+ };
70
+
71
+ // disable AdSense violation warnings
72
+ add_settings_field(
73
+ 'adsense-warnings-disable',
74
+ __( 'Disable violation warnings', 'advanced-ads' ),
75
+ array($this, 'render_settings_adsense_warnings_disable'),
76
+ $hook,
77
+ $section_id
78
+ );
79
+
80
+ add_settings_field(
81
+ 'adsense-background',
82
+ __( 'Transparent background', 'advanced-ads' ),
83
+ array( $this, 'render_settings_adsense_background' ),
84
+ $hook,
85
+ $section_id
86
+ );
87
+
88
+ add_settings_field(
89
+ 'adsense-full-width',
90
+ __( 'Full width responsive ads on mobile', 'advanced-ads' ),
91
+ array( $this, 'render_settings_adsense_fullwidth' ),
92
+ $hook,
93
+ 'advanced_ads_adsense_setting_section'
94
+ );
95
+ }
96
+
97
+
98
+
99
+ /**
100
+ * render AdSense settings section
101
+ *
102
+ * @since 1.5.1
103
+ */
104
+ public function render_settings_section_callback(){
105
+ // for whatever purpose there might come
106
+ }
107
+
108
+ /**
109
+ * render AdSense management api setting
110
+ */
111
+ public function render_settings_management_api() {
112
+ require_once GADSENSE_BASE_PATH . 'admin/views/mapi-settings.php';
113
+ }
114
+
115
+ /**
116
+ * render AdSense id setting
117
+ *
118
+ * @since 1.5.1
119
+ */
120
+ public function render_settings_adsense_id(){
121
+ require_once GADSENSE_BASE_PATH . 'admin/views/adsense-account.php';
122
+ }
123
+
124
+ /**
125
+ * render AdSense limit setting
126
+ *
127
+ * @since 1.5.1
128
+ * @deprecated January, 2019 – let’s give users one year until we remove the whole logic completely
129
+ */
130
+ public function render_settings_adsense_limit(){
131
+ $limit_per_page = $this->data->get_limit_per_page();
132
+
133
+ ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[limit-per-page]" value="1" <?php checked( $limit_per_page ); ?> />
134
+ <?php printf( __( 'Limit to %d AdSense ads', 'advanced-ads' ), 3 ); ?></label>
135
+ <p class="description">
136
+ <?php
137
+ printf(
138
+ __( 'There is no explicit limit for AdSense ads anymore, but you can still use this setting to prevent too many AdSense ads to show accidentally on your site.', 'advanced-ads' ),
139
+ esc_url( 'https://www.google.com/adsense/terms' )
140
+ ); ?></p>
141
+ <?php if( defined( 'AAP_VERSION' ) ) : /* give warning when cache-busting in Pro is active */ ?>
142
+ <p class="advads-error-message"><?php _e( 'Due to technical restrictions, the limit does not work on placements with cache-busting enabled.', 'advanced-ads' ); ?></p>
143
+ <?php endif;
144
+ }
145
+
146
+ /**
147
+ * Render top anchor ad setting
148
+ */
149
+ public function render_settings_adsense_top_anchor_ad() {
150
+ $options = $this->data->get_options();
151
+ $anchor_ad = isset( $options['top-anchor-ad'] )? $options['top-anchor-ad'] : ''; ?>
152
+ <label>
153
+ <input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[top-anchor-ad]" value="1" <?php checked( $anchor_ad ); ?> />
154
+ <?php esc_html_e( 'Enable this box if you don’t want Google Auto ads to place anchor ads at the top of your page.', 'advanced-ads' ); ?>
155
+ </label>
156
+ <?php
157
+ }
158
+
159
+ /**
160
+ * render page-level ads setting
161
+ *
162
+ * @since 1.6.9
163
+ */
164
+ public function render_settings_adsense_page_level(){
165
+ $options = $this->data->get_options();
166
+ $page_level = $options['page-level-enabled'];
167
+
168
+ ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
169
+ <?php esc_attr_e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' );
170
+ if( !empty( $options['adsense-id'] ) ) :
171
+ ?>&nbsp;<a href="https://www.google.com/adsense/new/u/0/<?php echo $options['adsense-id']; ?>/myads/auto-ads" target="_blank"><?php /**
172
+ * translators: this is the text for a link to a sub-page in an AdSense account
173
+ */
174
+ esc_attr_e( 'Adjust Auto ads options', 'advanced-ads' ); ?></a>
175
+ <?php endif; ?>
176
+ </label><p class="description"><?php printf(__( 'Please read <a href="%s" target="_blank">this article</a> if <strong>ads appear in random places</strong>.', 'advanced-ads' ), ADVADS_URL . 'adsense-in-random-positions-auto-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=backend-autoads-ads' ); ?></p>
177
+ <p class="description"><a href="<?php echo ADVADS_URL . 'adsense-auto-ads-wordpress/#Display_Auto_Ads_only_on_specific_pages'; ?>" target="_blank"><?php esc_attr_e( 'Display Auto ads only on specific pages', 'advanced-ads' ); ?></a></p>
178
+ <p class="description"><a href="<?php echo ADVADS_URL . 'adsense-auto-ads-wordpress/#AMP_Auto_Ads'; ?>" target="_blank"><?php esc_attr_e( 'Auto ads on AMP pages', 'advanced-ads' ); ?></a></p><?php
179
+ }
180
+
181
+ /**
182
+ * render AdSense violation warnings setting
183
+ *
184
+ * @since 1.6.9
185
+ */
186
+ public function render_settings_adsense_warnings_disable(){
187
+ $options = $this->data->get_options();
188
+ $disable_violation_warnings = isset( $options['violation-warnings-disable'] ) ? 1 : 0;
189
+
190
+ ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[violation-warnings-disable]" value="1" <?php checked( 1, $disable_violation_warnings ); ?> />
191
+ <?php _e( 'Disable warnings about potential violations of the AdSense terms.', 'advanced-ads' ); ?></label>
192
+ <p class="description"><?php printf(__( 'Our <a href="%s" target="_blank">Ad Health</a> feature monitors if AdSense is implemented correctly on your site. It also considers ads not managed with Advanced Ads. Enable this option to remove these checks', 'advanced-ads' ), ADVADS_URL . 'manual/ad-health/#utm_source=advanced-ads&utm_medium=link&utm_campaign=backend-autoads-ads' ); ?></p><?php
193
+ }
194
+
195
+ /**
196
+ * Render transparent background setting.
197
+ */
198
+ public function render_settings_adsense_background() {
199
+ $options = $this->data->get_options();
200
+ $background = $options['background'];
201
+
202
+ ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[background]" value="1" <?php checked( $background ); ?> />
203
+ <?php _e( 'Enable this option in case your theme adds an unfortunate background color to AdSense ads.', 'advanced-ads' ); ?></label><?php
204
+ }
205
+
206
+ /**
207
+ * Render full width ads setting.
208
+ */
209
+ public function render_settings_adsense_fullwidth() {
210
+ $options = $this->data->get_options();
211
+ $fw = !empty( $options['fullwidth-ads'] ) ? $options['fullwidth-ads'] : 'default';
212
+ ?>
213
+ <select name="<?php echo GADSENSE_OPT_NAME; ?>[fullwidth-ads]">
214
+ <option value="default" <?php selected( $fw, 'default' ); ?>><?php esc_html_e( 'default', 'advanced-ads' ) ?></option>
215
+ <option value="enable" <?php selected( $fw, 'enable' ); ?>><?php esc_html_e( 'enable', 'advanced-ads' ) ?></option>
216
+ <option value="disable" <?php selected( $fw, 'disable' ); ?>><?php esc_html_e( 'disable', 'advanced-ads' ) ?></option>
217
+ </select>
218
+ <p class="description"><?php
219
+ echo wp_kses(
220
+ sprintf(
221
+ __( "Whether your responsive ad unit may expand to <a href='%s' target='blank'>use the full width</a> of your visitor's mobile device screen", 'advanced-ads' ),
222
+ esc_url( 'https://support.google.com/adsense/answer/7445870' )
223
+ ),
224
+ array( 'a' => array( 'href' => true, 'target' => true ) )
225
+ ); ?></p>
226
+ <?php
227
+ }
228
+
229
+ /**
230
+ * sanitize AdSense settings
231
+ *
232
+ * @since 1.5.1
233
+ * @param array $options all the options
234
+ */
235
+ protected function sanitize_settings($options){
236
+ // sanitize whatever option one wants to sanitize
237
+ if(isset($options['adsense-id']) && $options['adsense-id'] != ''){
238
+ // remove "ca-" prefix if it was added by the user
239
+ if( 0 === strpos( $options['adsense-id'], 'ca-' ) ){
240
+ $options['adsense-id'] = str_replace( 'ca-', '', $options['adsense-id'] );
241
+ }
242
+
243
+ if( 0 !== strpos( $options['adsense-id'], 'pub-' ) ){
244
+ // add settings error
245
+ add_settings_error(
246
+ 'adsense-limit',
247
+ 'settings_updated',
248
+ __( 'The Publisher ID has an incorrect format. (must start with "pub-")', 'advanced-ads' ));
249
+ }
250
+ // trim publisher id
251
+ $options['adsense-id'] = trim($options['adsense-id']);
252
+ }
253
+ return $options;
254
+ }
255
+
256
+ /**
257
+ * sanitize ad settings
258
+ * save publisher id from new ad unit if not given in main options
259
+ *
260
+ * @since 1.6.2
261
+ * @param arr $ad_settings_post
262
+ * @return arr $ad_settings_post
263
+ */
264
+ public function sanitize_ad_settings( $ad_settings_post ){
265
+ // check ad type
266
+ if( ! isset( $ad_settings_post['type'] ) || 'adsense' !== $ad_settings_post['type'] ){
267
+ return $ad_settings_post;
268
+ }
269
+
270
+ // save AdSense publisher ID if there is no one stored yet
271
+ if ( ! empty($ad_settings_post['output']['adsense-pub-id']) ) {
272
+ // get options
273
+ $adsense_options = get_option( 'advanced-ads-adsense', array() );
274
+
275
+ if ( empty( $adsense_options['adsense-id'] ) ) {
276
+ $adsense_options['adsense-id'] = $ad_settings_post['output']['adsense-pub-id'];
277
+ update_option( 'advanced-ads-adsense', $adsense_options );
278
+ }
279
+ }
280
+ unset( $ad_settings_post['output']['adsense-pub-id'] );
281
+ return $ad_settings_post;
282
+ }
283
+
284
+ public function get_ad_type()
285
+ {
286
+ return new Advanced_Ads_Ad_Type_Adsense();
287
+ }
288
+
289
+ public function get_external_ad_units()
290
+ {
291
+ $db = Advanced_Ads_AdSense_Data::get_instance();
292
+ $adsense_id = trim( $db->get_adsense_id() );
293
+
294
+ $units = array();
295
+ $mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
296
+
297
+ if (isset($mapi_options['ad_codes'])
298
+ && isset($mapi_options['accounts'])
299
+ && isset($mapi_options['accounts'][$adsense_id])
300
+ && isset($mapi_options['accounts'][$adsense_id]['ad_units'])){
301
+ $ad_codes = $mapi_options['ad_codes'];
302
+ foreach ($mapi_options['accounts'][$adsense_id]['ad_units'] as $id => $raw){
303
+ $ad_unit = new Advanced_Ads_Ad_Network_Ad_Unit($raw);
304
+ $ad_unit->id = $id;
305
+ $ad_unit->slot_id = isset($raw['code']) ? $raw['code'] : '-';
306
+ $ad_unit->name = isset($raw['name']) ? $raw['name'] : '-';
307
+ $ad_unit->active = isset($raw['status']) && in_array($raw['status'], self::$STATUS_CODES_ACTIVE);
308
+
309
+ if (isset($ad_codes[$id])) {
310
+ $ad_unit->code = $ad_codes[$id];
311
+ }
312
+ if (isset ($raw['contentAdsSettings'])){
313
+ if (isset ($raw['contentAdsSettings']['type'])){
314
+ $ad_unit->display_type = Advanced_Ads_AdSense_MAPI::format_ad_data( $raw['contentAdsSettings']['type'], 'type' );
315
+ }
316
+ if (isset ($raw['contentAdsSettings']['size'])){
317
+ $ad_unit->display_size = Advanced_Ads_AdSense_MAPI::format_ad_data( $raw['contentAdsSettings']['size'], 'size' );
318
+ }
319
+ }
320
+ $units[] = $ad_unit;
321
+ }
322
+ }
323
+ return $units;
324
+ }
325
+
326
+ public function print_external_ads_list($hide_idle_ads = true, $ad_unit_id = null)
327
+ {
328
+ Advanced_Ads_AdSense_Admin::get_mapi_ad_selector($hide_idle_ads);
329
+ }
330
+
331
+ public function is_supported($ad_unit)
332
+ {
333
+ $mapi_options = Advanced_Ads_AdSense_MAPI::get_option();
334
+ return ! array_key_exists( $ad_unit->id, $mapi_options['unsupported_units'] );
335
+ }
336
+
337
+ public function update_external_ad_units()
338
+ {
339
+ Advanced_Ads_AdSense_MAPI::get_instance()->ajax_get_adUnits();
340
+ }
341
+
342
+ public function is_account_connected()
343
+ {
344
+ return Advanced_Ads_AdSense_Data::get_instance()->is_setup();
345
+ }
346
+
347
+ public function get_javascript_base_path()
348
+ {
349
+ return GADSENSE_BASE_URL . 'admin/assets/js/adsense.js';
350
+ }
351
+
352
+ public function append_javascript_data(&$data)
353
+ {
354
+ $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id();
355
+ $data['pubId'] = $pub_id;
356
+ $data['connected'] = $this->is_account_connected();
357
+ return $data;
358
+ }
359
+
360
+ public function supports_manual_ad_setup()
361
+ {
362
+ return true;
363
+ }
364
+ }
modules/gadsense/main.php CHANGED
@@ -5,33 +5,21 @@ if ( class_exists( 'Advanced_Ads', false ) ) {
5
  define( 'GADSENSE_BASE_URL', plugins_url( basename( ADVADS_BASE_PATH ) . '/modules/' . basename( GADSENSE_BASE_PATH ) . '/' ) );
6
  define( 'GADSENSE_OPT_NAME', ADVADS_SLUG . '-adsense' );
7
 
8
- /**
9
- * initialize ad type and add it to the plugins ad types
10
- *
11
- * "content" key must match the id
12
- */
13
- function advads_add_ad_type_adsense($types) {
14
- $types['adsense'] = new Advanced_Ads_Ad_Type_Adsense();
15
- return $types;
16
- }
17
-
18
- function gadsense_date_time($time) {
19
- return date_i18n( get_option( 'date_format' ), $time ) . __( ' at ', 'advanced-ads' ) . date_i18n( get_option( 'time_format' ), $time );
20
- }
21
-
22
  function gadsense_init() {
23
  Advanced_Ads_AdSense_Data::get_instance();
24
- add_filter( 'advanced-ads-ad-types', 'advads_add_ad_type_adsense' );
25
 
26
- if ( is_admin() ) {
27
- Advanced_Ads_AdSense_MAPI::get_instance();
28
- }
29
-
30
- if ( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX) && is_admin() ) {
31
- Advanced_Ads_AdSense_Admin::get_instance();
32
- } else {
33
- Advanced_Ads_AdSense_Public::get_instance();
34
- }
 
 
 
35
  }
36
  add_action( 'advanced-ads-plugin-loaded', 'gadsense_init' );
37
  }
5
  define( 'GADSENSE_BASE_URL', plugins_url( basename( ADVADS_BASE_PATH ) . '/modules/' . basename( GADSENSE_BASE_PATH ) . '/' ) );
6
  define( 'GADSENSE_OPT_NAME', ADVADS_SLUG . '-adsense' );
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  function gadsense_init() {
9
  Advanced_Ads_AdSense_Data::get_instance();
 
10
 
11
+ if ( is_admin() ) {
12
+ Advanced_Ads_AdSense_MAPI::get_instance();
13
+ }
14
+
15
+ if ( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX) && is_admin() ) {
16
+ Advanced_Ads_AdSense_Admin::get_instance();
17
+ } else {
18
+ Advanced_Ads_AdSense_Public::get_instance();
19
+ }
20
+
21
+ $network = Advanced_Ads_Network_Adsense::get_instance();
22
+ $network->register();
23
  }
24
  add_action( 'advanced-ads-plugin-loaded', 'gadsense_init' );
25
  }
public/class-advanced-ads.php CHANGED
@@ -193,9 +193,6 @@ class Advanced_Ads {
193
  // register hooks and filters for auto ad injection.
194
  $this->init_injection();
195
 
196
- // manipulate sidebar widget.
197
- add_filter( 'dynamic_sidebar_params', array( $this, 'manipulate_widget_output' ) );
198
-
199
  // add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type.
200
  add_action( 'wp_head', array( $this, 'noindex_attachment_images' ) );
201
 
@@ -796,27 +793,6 @@ class Advanced_Ads {
796
  return apply_filters( 'advanced-ads-post-type-params', $post_type_params );
797
  }
798
 
799
- /**
800
- * Manipulate output of ad widget
801
- *
802
- * @since 1.6.8.2
803
- * @param arr $params widget and sidebar params.
804
- */
805
- public function manipulate_widget_output( $params = array() ) {
806
-
807
- if ( 'Advanced Ads' === $params[0]['widget_name'] ) {
808
-
809
- $options = $this->plugin->options();
810
- // hide id by default (when options are empty) or when option is enabled.
811
- if ( array() === $options || ( isset( $options['remove-widget-id'] ) && $options['remove-widget-id'] ) ) {
812
- $pattern = '#\s(id)=("|\')[^"^\']+("|\')#';
813
- $params[0]['before_widget'] = preg_replace( $pattern, '', $params[0]['before_widget'] );
814
- }
815
- }
816
-
817
- return $params;
818
- }
819
-
820
  /**
821
  * Add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type
822
  */
193
  // register hooks and filters for auto ad injection.
194
  $this->init_injection();
195
 
 
 
 
196
  // add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type.
197
  add_action( 'wp_head', array( $this, 'noindex_attachment_images' ) );
198
 
793
  return apply_filters( 'advanced-ads-post-type-params', $post_type_params );
794
  }
795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  /**
797
  * Add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type
798
  */
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad manager, ad rotation, adsense, banner
5
  Requires at least: 4.6
6
  Tested up to: 5.2
7
  Requires PHP: 5.6
8
- Stable tag: 1.13.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -109,6 +109,7 @@ Amazing features of the most powerful and easy Google AdSense plugin.
109
 
110
  * unlimited Google AdSense ads banners
111
  * pull ad units directly from your Google AdSense account
 
112
  * change settings of your Google AdSense ads directly from your WordPress backend
113
  * supports all Google AdSense ad types, including Google AdSense display ads, link units, native ads like In-feed ads, In-article ads, matched content ads, Google AdSense Auto ads, and Google AdSense Auto ads for AMP
114
  * change type and sizes of an ad without going into your Google AdSense account
@@ -283,11 +284,19 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
283
  5. Dynamically change AdSense ad options in your WordPress backend.
284
  6. Choose where to display your ads using many conditions.
285
  7. Use various conditions to choose who should see ads (basic plugin and more in add-ons).
286
- 8. Track impressions and clicks (Tracking add-on).
287
- 9. Convert AdSense ads into AMP automatically (Responsive add-on)
 
288
 
289
  == Changelog ==
290
 
 
 
 
 
 
 
 
291
  = 1.13.8 =
292
 
293
  * prevented warning about missing ads.txt file when the file exists
5
  Requires at least: 4.6
6
  Tested up to: 5.2
7
  Requires PHP: 5.6
8
+ Stable tag: 1.14
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
109
 
110
  * unlimited Google AdSense ads banners
111
  * pull ad units directly from your Google AdSense account
112
+ * show AdSense revenue in WP Admin
113
  * change settings of your Google AdSense ads directly from your WordPress backend
114
  * supports all Google AdSense ad types, including Google AdSense display ads, link units, native ads like In-feed ads, In-article ads, matched content ads, Google AdSense Auto ads, and Google AdSense Auto ads for AMP
115
  * change type and sizes of an ad without going into your Google AdSense account
284
  5. Dynamically change AdSense ad options in your WordPress backend.
285
  6. Choose where to display your ads using many conditions.
286
  7. Use various conditions to choose who should see ads (basic plugin and more in add-ons).
287
+ 8. See AdSense earnings in your WP Backend
288
+ 9. Track impressions and clicks (Tracking add-on).
289
+ 10. Convert AdSense ads into AMP automatically (Responsive add-on)
290
 
291
  == Changelog ==
292
 
293
+ = 1.14 =
294
+
295
+ * rewrite of AdSense code logic. Please reach out through https://wpadvancedads.com/support/ if you discover any issues
296
+ * show AdSense revenue in WP Admin
297
+ * removed parent ad group option since it was never used by Advanced Ads
298
+ * made newly installed Advanced Ads work correctly with Q2W3 Fixed Widget
299
+
300
  = 1.13.8 =
301
 
302
  * prevented warning about missing ads.txt file when the file exists
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInit7ce491af71c20f0c4c61971657d35fd8::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit654978bf511f36f6eca47c8335223e8b::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -14,6 +14,9 @@ return array(
14
  'Advanced_Ads_Ad_Debug' => $baseDir . '/classes/ad-debug.php',
15
  'Advanced_Ads_Ad_Health_Notices' => $baseDir . '/classes/ad-health-notices.php',
16
  'Advanced_Ads_Ad_List_Filters' => $baseDir . '/admin/includes/class-list-filters.php',
 
 
 
17
  'Advanced_Ads_Ad_Type_Abstract' => $baseDir . '/classes/ad_type_abstract.php',
18
  'Advanced_Ads_Ad_Type_Content' => $baseDir . '/classes/ad_type_content.php',
19
  'Advanced_Ads_Ad_Type_Dummy' => $baseDir . '/classes/ad_type_dummy.php',
@@ -37,6 +40,7 @@ return array(
37
  'Advanced_Ads_Group' => $baseDir . '/classes/ad_group.php',
38
  'Advanced_Ads_Groups_List' => $baseDir . '/admin/includes/class-ad-groups-list.php',
39
  'Advanced_Ads_Model' => $baseDir . '/classes/ad-model.php',
 
40
  'Advanced_Ads_Overview_Widgets_Callbacks' => $baseDir . '/admin/includes/class-overview-widgets.php',
41
  'Advanced_Ads_Placements' => $baseDir . '/classes/ad_placements.php',
42
  'Advanced_Ads_Plugin' => $baseDir . '/classes/plugin.php',
14
  'Advanced_Ads_Ad_Debug' => $baseDir . '/classes/ad-debug.php',
15
  'Advanced_Ads_Ad_Health_Notices' => $baseDir . '/classes/ad-health-notices.php',
16
  'Advanced_Ads_Ad_List_Filters' => $baseDir . '/admin/includes/class-list-filters.php',
17
+ 'Advanced_Ads_Ad_Network' => $baseDir . '/admin/includes/class-ad-network.php',
18
+ 'Advanced_Ads_Ad_Network_Ad_Importer' => $baseDir . '/admin/includes/class-ad-network-ad-importer.php',
19
+ 'Advanced_Ads_Ad_Network_Ad_Unit' => $baseDir . '/admin/includes/class-ad-network-ad-unit.php',
20
  'Advanced_Ads_Ad_Type_Abstract' => $baseDir . '/classes/ad_type_abstract.php',
21
  'Advanced_Ads_Ad_Type_Content' => $baseDir . '/classes/ad_type_content.php',
22
  'Advanced_Ads_Ad_Type_Dummy' => $baseDir . '/classes/ad_type_dummy.php',
40
  'Advanced_Ads_Group' => $baseDir . '/classes/ad_group.php',
41
  'Advanced_Ads_Groups_List' => $baseDir . '/admin/includes/class-ad-groups-list.php',
42
  'Advanced_Ads_Model' => $baseDir . '/classes/ad-model.php',
43
+ 'Advanced_Ads_Module' => $baseDir . '/admin/includes/class-module.php',
44
  'Advanced_Ads_Overview_Widgets_Callbacks' => $baseDir . '/admin/includes/class-overview-widgets.php',
45
  'Advanced_Ads_Placements' => $baseDir . '/classes/ad_placements.php',
46
  'Advanced_Ads_Plugin' => $baseDir . '/classes/plugin.php',
vendor/composer/autoload_real_52.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
- class ComposerAutoloaderInit7ce491af71c20f0c4c61971657d35fd8 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit7ce491af71c20f0c4c61971657d35fd8 {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit7ce491af71c20f0c4c61971657d35fd8', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit7ce491af71c20f0c4c61971657d35fd8', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInit654978bf511f36f6eca47c8335223e8b {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit654978bf511f36f6eca47c8335223e8b', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit654978bf511f36f6eca47c8335223e8b', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
vendor/composer/autoload_static.php CHANGED
@@ -39,6 +39,9 @@ class ComposerStaticInitd24de3c06687d3cf4aad0b15c83747be
39
  'Advanced_Ads_Ad_Debug' => __DIR__ . '/../..' . '/classes/ad-debug.php',
40
  'Advanced_Ads_Ad_Health_Notices' => __DIR__ . '/../..' . '/classes/ad-health-notices.php',
41
  'Advanced_Ads_Ad_List_Filters' => __DIR__ . '/../..' . '/admin/includes/class-list-filters.php',
 
 
 
42
  'Advanced_Ads_Ad_Type_Abstract' => __DIR__ . '/../..' . '/classes/ad_type_abstract.php',
43
  'Advanced_Ads_Ad_Type_Content' => __DIR__ . '/../..' . '/classes/ad_type_content.php',
44
  'Advanced_Ads_Ad_Type_Dummy' => __DIR__ . '/../..' . '/classes/ad_type_dummy.php',
@@ -62,6 +65,7 @@ class ComposerStaticInitd24de3c06687d3cf4aad0b15c83747be
62
  'Advanced_Ads_Group' => __DIR__ . '/../..' . '/classes/ad_group.php',
63
  'Advanced_Ads_Groups_List' => __DIR__ . '/../..' . '/admin/includes/class-ad-groups-list.php',
64
  'Advanced_Ads_Model' => __DIR__ . '/../..' . '/classes/ad-model.php',
 
65
  'Advanced_Ads_Overview_Widgets_Callbacks' => __DIR__ . '/../..' . '/admin/includes/class-overview-widgets.php',
66
  'Advanced_Ads_Placements' => __DIR__ . '/../..' . '/classes/ad_placements.php',
67
  'Advanced_Ads_Plugin' => __DIR__ . '/../..' . '/classes/plugin.php',
39
  'Advanced_Ads_Ad_Debug' => __DIR__ . '/../..' . '/classes/ad-debug.php',
40
  'Advanced_Ads_Ad_Health_Notices' => __DIR__ . '/../..' . '/classes/ad-health-notices.php',
41
  'Advanced_Ads_Ad_List_Filters' => __DIR__ . '/../..' . '/admin/includes/class-list-filters.php',
42
+ 'Advanced_Ads_Ad_Network' => __DIR__ . '/../..' . '/admin/includes/class-ad-network.php',
43
+ 'Advanced_Ads_Ad_Network_Ad_Importer' => __DIR__ . '/../..' . '/admin/includes/class-ad-network-ad-importer.php',
44
+ 'Advanced_Ads_Ad_Network_Ad_Unit' => __DIR__ . '/../..' . '/admin/includes/class-ad-network-ad-unit.php',
45
  'Advanced_Ads_Ad_Type_Abstract' => __DIR__ . '/../..' . '/classes/ad_type_abstract.php',
46
  'Advanced_Ads_Ad_Type_Content' => __DIR__ . '/../..' . '/classes/ad_type_content.php',
47
  'Advanced_Ads_Ad_Type_Dummy' => __DIR__ . '/../..' . '/classes/ad_type_dummy.php',
65
  'Advanced_Ads_Group' => __DIR__ . '/../..' . '/classes/ad_group.php',
66
  'Advanced_Ads_Groups_List' => __DIR__ . '/../..' . '/admin/includes/class-ad-groups-list.php',
67
  'Advanced_Ads_Model' => __DIR__ . '/../..' . '/classes/ad-model.php',
68
+ 'Advanced_Ads_Module' => __DIR__ . '/../..' . '/admin/includes/class-module.php',
69
  'Advanced_Ads_Overview_Widgets_Callbacks' => __DIR__ . '/../..' . '/admin/includes/class-overview-widgets.php',
70
  'Advanced_Ads_Placements' => __DIR__ . '/../..' . '/classes/ad_placements.php',
71
  'Advanced_Ads_Plugin' => __DIR__ . '/../..' . '/classes/plugin.php',