Advanced Ads - Version 1.10.5

Version Description

  • improved list of ads imported from AdSense account
  • use width and height ad settings for image ads if they differ from the entered sizes
  • added option column with shortcode to the ad list. It is optional. Go to "Screen Options" at the top right of the ad list page to enable it
  • show warning if AdSense Auto ads code is used in ad code field
  • added a warning if Advanced Ads constants are enabled
  • prevented possible JavaScript error created by the Privacy module
  • extended "Transpartent Background" option for AdSense to fix a border they have in some themes
  • removed ad block counter code when not used
  • updated add-on updater class
  • added a warning about floated responsive AdSense ads
Download this release

Release Info

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

Code changes from version 1.10.4 to 1.10.5

Files changed (77) hide show
  1. admin/assets/css/admin.css +28 -4
  2. admin/assets/js/admin-global.js +25 -8
  3. admin/assets/js/admin.js +29 -0
  4. admin/class-advanced-ads-admin.php +14 -12
  5. admin/includes/class-ad-type.php +39 -1
  6. admin/includes/class-list-filters.php +4 -4
  7. admin/includes/class-meta-box.php +17 -1
  8. admin/includes/class-overview-widgets.php +3 -0
  9. admin/views/ad-conditions-string-operators.php +22 -12
  10. admin/views/ad-display-metabox.php +169 -114
  11. admin/views/ad-group-edit.php +60 -42
  12. admin/views/ad-group-list-ads.php +30 -16
  13. admin/views/ad-group-list-form-row.php +89 -65
  14. admin/views/ad-group-list-header.php +19 -7
  15. admin/views/ad-group-list-row.php +44 -24
  16. admin/views/ad-group.php +72 -77
  17. admin/views/ad-info-after-textarea.php +26 -6
  18. admin/views/ad-info-bottom.php +26 -10
  19. admin/views/ad-info-top.php +30 -20
  20. admin/views/ad-info.php +20 -14
  21. admin/views/ad-list-details-column.php +14 -10
  22. admin/views/ad-list-filters.php +15 -15
  23. admin/views/ad-list-no-ads.php +4 -4
  24. admin/views/ad-list-shortcode-column.php +1 -0
  25. admin/views/ad-list-timing-column.php +27 -27
  26. admin/views/ad-main-metabox.php +24 -20
  27. admin/views/ad-output-metabox.php +105 -47
  28. admin/views/ad-parameters-metabox.php +15 -10
  29. admin/views/ad-parameters-size.php +18 -7
  30. admin/views/ad-submitbox-meta.php +26 -20
  31. admin/views/ad-visitor-metabox.php +168 -126
  32. admin/views/checks.php +48 -38
  33. admin/views/feedback-disable.php +43 -28
  34. admin/views/index.php +1 -1
  35. admin/views/notices/adblock.php +2 -2
  36. admin/views/notices/info.php +1 -1
  37. admin/views/notices/inline.php +4 -4
  38. admin/views/notices/jqueryui_error.php +2 -2
  39. admin/views/notices/plugin_error.php +1 -1
  40. admin/views/notices/subscribe.php +4 -4
  41. admin/views/notices/welcome-panel.php +4 -4
  42. admin/views/overview-addons-line.php +13 -9
  43. admin/views/overview-widget.php +5 -5
  44. admin/views/overview.php +6 -6
  45. admin/views/pitch-bundle.php +11 -11
  46. admin/views/pitch-pro-tab.php +11 -11
  47. admin/views/pitch-tracking.php +7 -7
  48. admin/views/placement-injection-top.php +118 -59
  49. admin/views/placements-ad-label-position.php +29 -12
  50. admin/views/placements-ad-label.php +16 -7
  51. admin/views/placements-content-index.php +31 -13
  52. admin/views/placements-item.php +36 -23
  53. admin/views/placements.php +210 -150
  54. admin/views/post-ad-settings-metabox.php +3 -2
  55. admin/views/setting-license.php +62 -42
  56. admin/views/setting-target.php +6 -3
  57. admin/views/settings-disable-ads.php +43 -16
  58. admin/views/settings.php +40 -35
  59. admin/views/support.php +18 -14
  60. advanced-ads.php +2 -2
  61. classes/EDD_SL_Plugin_Updater.php +86 -22
  62. classes/ad_group.php +1 -1
  63. classes/ad_type_image.php +36 -0
  64. classes/checks.php +36 -1
  65. classes/frontend_checks.php +87 -29
  66. languages/advanced-ads.pot +335 -233
  67. modules/adblock-finder/public/public.php +4 -5
  68. modules/gadsense/admin/admin.php +24 -8
  69. modules/gadsense/admin/assets/js/new-ad.js +187 -179
  70. modules/gadsense/admin/views/adsense-account.php +1 -1
  71. modules/gadsense/admin/views/adsense-ad-parameters.php +7 -1
  72. modules/gadsense/admin/views/mapi-ad-selector.php +104 -40
  73. modules/gadsense/includes/class-ad-type-adsense.php +5 -0
  74. modules/gadsense/includes/class-mapi.php +332 -263
  75. modules/gadsense/public/public.php +1 -1
  76. modules/privacy/classes/plugin.php +3 -0
  77. readme.txt +17 -3
admin/assets/css/admin.css CHANGED
@@ -22,7 +22,7 @@
22
  #advads-overview #advads_overview_addons table th { vertical-align: top; font-weight: bold; max-width: 300px; position: relative; top: 0; }
23
  #advads-overview #advads_overview_addons table tr.recommended th:before { position:absolute; top: 2px; left: 10px; font-size: .9em; content: 'Recommended'; color: green; font-weight: normal; }
24
  #advads-overview #advads_overview_addons table tr.free th:before { position:absolute; top: 2px; left: 10px; font-size: .9em; content: 'Free'; color: green; }
25
- #advads-overview #advads_overview_addons table tr.recommended th,
26
  #advads-overview #advads_overview_addons table tr.free th { padding-top: 20px; }
27
  #advads_overview_news .button-primary { margin-left: 0; }
28
 
@@ -56,7 +56,7 @@ h2.hndle .advads-hndlelinks a + a { margin-left: 1em; }
56
  #advads-ad-injection-box .advads-ad-injection-box-button-wrap button:hover { background: #0085ba !important; color: #fff; text-indent: 0; white-space: normal; cursor: pointer; }
57
  #advads-ad-injection-box input[type="number"] { width: 4.5em; }
58
 
59
- #advads-ad-injection-shortcode { width: 130px; border: none; background: #ededed; }
60
  #advads-ad-injection-message-placement-created > p:first-child { font-size: 1.5em; }
61
  .advads-pro-link { opacity: 0.5; }
62
  .advads-pro-link:before { content: 'ADD-ON'; position: absolute; bottom: -4px; right: 2px; text-indent: 0; color: #000; text-shadow: none; font-weight: bold; font-size: .8em; }
@@ -297,9 +297,32 @@ tr:hover .on-hover { display: block; }
297
  #adsense-ad-param-error { color: red; font-weight: bold; }
298
  .advads-adsense-content { width: 100%; }
299
  .advads-adsense-show-code a, #mapi-open-selector a { padding: 0 10px; color: inherit; }
300
- #mapi-wrap { border: 1px solid #ddd; padding: .5rem; position: relative; margin: 1rem auto; display:none; overflow: hidden; }
301
  #mapi-wrap .label { font-weight:bold; display:block; margin:.75em auto .25rem; }
302
  #mapi-quota-message{ color: #ef8e00; font-style: italic; font-weight: bold; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  /**
304
  - TABS + SETTINGS
305
  -*/
@@ -326,7 +349,7 @@ tr:hover .on-hover { display: block; }
326
  - PLUGIN LIST
327
  -*/
328
  #advanced-ads-feedback-overlay {
329
- /* Height & width depends on how you want to reveal the overlay (see JS below) */
330
  height: 100%;
331
  width: 100%;
332
  position: fixed; /* Stay in place */
@@ -348,6 +371,7 @@ tr:hover .on-hover { display: block; }
348
  background-color: #fff;
349
  overflow-y: scroll;
350
  }
 
351
  #advanced-ads-feedback-content textarea:not(.advanced_ads_disable_help_text),
352
  #advanced-ads-feedback-content input[type="text"] { display:none; }
353
  #advanced-ads-feedback-content textarea,
22
  #advads-overview #advads_overview_addons table th { vertical-align: top; font-weight: bold; max-width: 300px; position: relative; top: 0; }
23
  #advads-overview #advads_overview_addons table tr.recommended th:before { position:absolute; top: 2px; left: 10px; font-size: .9em; content: 'Recommended'; color: green; font-weight: normal; }
24
  #advads-overview #advads_overview_addons table tr.free th:before { position:absolute; top: 2px; left: 10px; font-size: .9em; content: 'Free'; color: green; }
25
+ #advads-overview #advads_overview_addons table tr.recommended th,
26
  #advads-overview #advads_overview_addons table tr.free th { padding-top: 20px; }
27
  #advads_overview_news .button-primary { margin-left: 0; }
28
 
56
  #advads-ad-injection-box .advads-ad-injection-box-button-wrap button:hover { background: #0085ba !important; color: #fff; text-indent: 0; white-space: normal; cursor: pointer; }
57
  #advads-ad-injection-box input[type="number"] { width: 4.5em; }
58
 
59
+ .advads-ad-injection-shortcode { width: 100%; border: none; background: #ededed; }
60
  #advads-ad-injection-message-placement-created > p:first-child { font-size: 1.5em; }
61
  .advads-pro-link { opacity: 0.5; }
62
  .advads-pro-link:before { content: 'ADD-ON'; position: absolute; bottom: -4px; right: 2px; text-indent: 0; color: #000; text-shadow: none; font-weight: bold; font-size: .8em; }
297
  #adsense-ad-param-error { color: red; font-weight: bold; }
298
  .advads-adsense-content { width: 100%; }
299
  .advads-adsense-show-code a, #mapi-open-selector a { padding: 0 10px; color: inherit; }
300
+ #mapi-wrap { border: 1px solid #ddd; padding: .5rem; position: relative; display:none; overflow: hidden; }
301
  #mapi-wrap .label { font-weight:bold; display:block; margin:.75em auto .25rem; }
302
  #mapi-quota-message{ color: #ef8e00; font-style: italic; font-weight: bold; }
303
+
304
+ #mapi-loading-overlay { position:absolute; background-color:rgba(255,255,255,.75); top:0; right:0; bottom:0; left:0; text-align:center; z-index: 1; display:none; }
305
+ #mapi-wrap { padding-top: 46px; }
306
+ #mapi-wrap table, #mapi-wrap table tbody { width: 100%; }
307
+ #mapi-wrap table { margin-bottom: 10px; }
308
+ #mapi-wrap tbody .dashicons { font-size: 1.2em; cursor: pointer; }
309
+ #mapi-wrap thead th { font-weight: 700; }
310
+ #mapi-wrap tbody .dashicons.disabled { color: #939393; }
311
+ #mapi-wrap tbody [data-mapiaction="getCode"] { color: #46b450; }
312
+ #mapi-wrap tbody .disabled[data-mapiaction="getCode"] { color: #a7a7a7; cursor: default; }
313
+ #mapi-wrap tbody [data-mapiaction="updateCode"] { color: #0085ba; }
314
+ #mapi-wrap #mapi-update-unit-lists { font-size: 20px; padding: 13px; position: absolute; top: 0; right: 47px; }
315
+ #mapi-wrap #mapi-list-header { font-weight: 700; display: inline-block; font-size: 13px; line-height: 1.5em; }
316
+ #mapi-wrap #mapi-list-header span { display: inline-block; padding: 8px 9px; }
317
+ #mapi-table-wrap { position: relative; }
318
+ @media( min-width: 783px ) { #mapi-wrap { padding-top: 38px; } #mapi-wrap #mapi-update-unit-lists { padding: 9px; right: 39px; } }
319
+ #mapi-table-wrap tr.selected { background-color: #dcdcfb; }
320
+ #mapi-table-wrap tr.selected td { color: #0073aa; font-weight: bold; }
321
+ #remote-ad-unsupported-ad-type { background-color: #f0f0f0; padding: 8px; border: 1px solid #d6d6d6; }
322
+ #mapi-table-wrap .unsupported { text-decoration:line-through; color:#555 }
323
+ #mapi-table-wrap .unsupported span { text-decoration:none;color:#555 }
324
+ #mapi-table-wrap table { border-left:none; border-right: none; }
325
+ #mapi-table-wrap { margin-left: -.5rem; margin-right: -.5rem; }
326
  /**
327
  - TABS + SETTINGS
328
  -*/
349
  - PLUGIN LIST
350
  -*/
351
  #advanced-ads-feedback-overlay {
352
+ /* Height & width depends on how you want to reveal the overlay (see JS below) */
353
  height: 100%;
354
  width: 100%;
355
  position: fixed; /* Stay in place */
371
  background-color: #fff;
372
  overflow-y: scroll;
373
  }
374
+ #advanced-ads-feedback-overlay-close-button { position: absolute; top: 10px; right: 10px; cursor: pointer; }
375
  #advanced-ads-feedback-content textarea:not(.advanced_ads_disable_help_text),
376
  #advanced-ads-feedback-content input[type="text"] { display:none; }
377
  #advanced-ads-feedback-content textarea,
admin/assets/js/admin-global.js CHANGED
@@ -98,9 +98,14 @@ jQuery( document ).ready(function () {
98
  // save if plugin should be disabled
99
  var disable_plugin = self.hasClass('advanced-ads-feedback-not-deactivate') ? false : true;
100
 
101
- jQuery( '#advanced-ads-feedback-overlay' ).hide();
 
102
  if ( self.hasClass('advanced-ads-feedback-submit') ) {
103
- // show text field if there is one
 
 
 
 
104
  jQuery.ajax({
105
  type: 'POST',
106
  url: ajaxurl,
@@ -111,26 +116,38 @@ jQuery( document ).ready(function () {
111
  formdata: jQuery( '#advanced-ads-feedback-content form' ).serialize()
112
  },
113
  complete: function (MLHttpRequest, textStatus, errorThrown) {
114
- // deactivate the plugin and close the popup
115
- jQuery( '#advanced-ads-feedback-overlay' ).remove();
116
- console.log( disable_plugin );
 
117
  if( disable_plugin ){
118
  window.location.href = advads_deactivate_link_url;
119
  }
120
 
121
  }
122
  });
123
- } else {
124
  jQuery( '#advanced-ads-feedback-overlay' ).remove();
125
  window.location.href = advads_deactivate_link_url;
126
  }
127
  });
128
  // close form and disable the plugin without doing anything
129
  jQuery('.advanced-ads-feedback-only-deactivate').click(function ( e ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  jQuery( '#advanced-ads-feedback-overlay' ).hide();
131
- window.location.href = advads_deactivate_link_url;
132
  });
133
-
134
  });
135
 
136
  function advads_admin_get_cookie (name) {
98
  // save if plugin should be disabled
99
  var disable_plugin = self.hasClass('advanced-ads-feedback-not-deactivate') ? false : true;
100
 
101
+ // hide the content of the feedback form
102
+ jQuery( '#advanced-ads-feedback-content form' ).hide();
103
  if ( self.hasClass('advanced-ads-feedback-submit') ) {
104
+ // show feedback message
105
+ jQuery( '#advanced-ads-feedback-after-submit-waiting' ).show();
106
+ if( disable_plugin ){
107
+ jQuery( '#advanced-ads-feedback-after-submit-disabling-plugin' ).show();
108
+ }
109
  jQuery.ajax({
110
  type: 'POST',
111
  url: ajaxurl,
116
  formdata: jQuery( '#advanced-ads-feedback-content form' ).serialize()
117
  },
118
  complete: function (MLHttpRequest, textStatus, errorThrown) {
119
+ // deactivate the plugin and close the popup with a timeout
120
+ setTimeout( function(){
121
+ jQuery( '#advanced-ads-feedback-overlay' ).remove();
122
+ }, 2000 )
123
  if( disable_plugin ){
124
  window.location.href = advads_deactivate_link_url;
125
  }
126
 
127
  }
128
  });
129
+ } else { // currently not reachable
130
  jQuery( '#advanced-ads-feedback-overlay' ).remove();
131
  window.location.href = advads_deactivate_link_url;
132
  }
133
  });
134
  // close form and disable the plugin without doing anything
135
  jQuery('.advanced-ads-feedback-only-deactivate').click(function ( e ) {
136
+ // hide the content of the feedback form
137
+ jQuery( '#advanced-ads-feedback-content form' ).hide();
138
+ // show feedback message
139
+ jQuery( '#advanced-ads-feedback-after-submit-goodbye' ).show();
140
+ jQuery( '#advanced-ads-feedback-after-submit-disabling-plugin' ).show();
141
+ // wait 3 seconds
142
+ setTimeout(function(){
143
+ jQuery( '#advanced-ads-feedback-overlay' ).hide();
144
+ window.location.href = advads_deactivate_link_url;
145
+ }, 3000);
146
+ });
147
+ // close button for feedback form
148
+ jQuery('#advanced-ads-feedback-overlay-close-button').click(function ( e ) {
149
  jQuery( '#advanced-ads-feedback-overlay' ).hide();
 
150
  });
 
151
  });
152
 
153
  function advads_admin_get_cookie (name) {
admin/assets/js/admin.js CHANGED
@@ -589,8 +589,15 @@ jQuery( document ).ready(function ($) {
589
  jQuery( '#advads_xml_content' ).hide();
590
  }
591
  });
 
 
 
 
 
 
592
  });
593
 
 
594
  /**
595
  * store the action hash in settings form action
596
  * thanks for Yoast SEO for this idea
@@ -777,6 +784,28 @@ function advads_maybe_textarea_to_tinymce( ad_type ) {
777
  }
778
  }
779
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
  // Change JQueryUI names to fix name collision with other libraries, eg. Bootstrap
781
  jQuery.fn.advads_button = jQuery.fn.button;
782
 
589
  jQuery( '#advads_xml_content' ).hide();
590
  }
591
  });
592
+
593
+ // Find Adsense Auto Ads inside ad content.
594
+ var ad_content = jQuery('textarea[name=advanced_ad\\[content\\]]').html();
595
+ if ( ad_content && ad_content.indexOf( 'enable_page_level_ads' ) !== -1 ) {
596
+ advads_show_adsense_auto_ads_warning();
597
+ }
598
  });
599
 
600
+
601
  /**
602
  * store the action hash in settings form action
603
  * thanks for Yoast SEO for this idea
784
  }
785
  }
786
 
787
+ /**
788
+ * Show a message depending on whether Adsense Auto ads are enabled.
789
+ */
790
+ function advads_show_adsense_auto_ads_warning() {
791
+ $msg = jQuery( '.advads-auto-ad-in-ad-content' ).show();
792
+ $msg.on( 'click', 'button', function() {
793
+ $msg.hide();
794
+ jQuery.ajax( {
795
+ type: 'POST',
796
+ url: ajaxurl,
797
+ data: {
798
+ action: 'advads-adsense-enable-pla',
799
+ nonce: advadsglobal.ajax_nonce
800
+ },
801
+ } ).done(function( data ) {
802
+ $msg.show().html( advadstxt.page_level_ads_enabled );
803
+ } ).fail(function( jqXHR, textStatus ) {
804
+ $msg.show();
805
+ } );
806
+ });
807
+ }
808
+
809
  // Change JQueryUI names to fix name collision with other libraries, eg. Bootstrap
810
  jQuery.fn.advads_button = jQuery.fn.button;
811
 
admin/class-advanced-ads-admin.php CHANGED
@@ -1,21 +1,17 @@
1
  <?php
2
  /**
3
- * Advanced Ads.
4
  *
5
  * @package Advanced_Ads_Admin
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
- * @link http://webgilde.com
9
- * @copyright 2013-2018 Thomas Maier, webgilde GmbH
10
- */
11
-
12
- /**
13
  * Plugin class. This class should ideally be used to work with the
14
  * administrative side of the WordPress site.
15
- *
16
- * @package Advanced_Ads_Admin
17
- * @author Thomas Maier <thomas.maier@webgilde.com>
18
  */
 
19
  class Advanced_Ads_Admin {
20
 
21
  /**
@@ -217,12 +213,16 @@ class Advanced_Ads_Admin {
217
  // just register this script for later inclusion on ad group list page.
218
  wp_register_script( 'inline-edit-group-ads', plugins_url( 'assets/js/inline-edit-group-ads.js', __FILE__ ), array( 'jquery' ), ADVADS_VERSION, false );
219
 
 
 
220
  // register admin.js translations.
221
  $translation_array = array(
222
- 'condition_or' => __( 'or', 'advanced-ads' ),
223
- 'condition_and' => __( 'and', 'advanced-ads' ),
224
- 'after_paragraph_promt' => __( 'After which paragraph?', 'advanced-ads' ),
 
225
  );
 
226
  wp_localize_script( $this->plugin_slug . '-admin-script', 'advadstxt', $translation_array );
227
 
228
  wp_enqueue_script( $this->plugin_slug . '-admin-script' );
@@ -459,6 +459,8 @@ class Advanced_Ads_Admin {
459
  }
460
 
461
  $subject = isset( $form['advanced_ads_disable_reason'] ) ? $form['advanced_ads_disable_reason'] : '(no reason given)';
 
 
462
 
463
  $success = wp_mail( 'improve@wpadvancedads.com', $subject, $text, $headers );
464
 
1
  <?php
2
  /**
3
+ * Advanced Ads main admin class
4
  *
5
  * @package Advanced_Ads_Admin
6
  * @author Thomas Maier <thomas.maier@webgilde.com>
7
  * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ *
 
 
11
  * Plugin class. This class should ideally be used to work with the
12
  * administrative side of the WordPress site.
 
 
 
13
  */
14
+
15
  class Advanced_Ads_Admin {
16
 
17
  /**
213
  // just register this script for later inclusion on ad group list page.
214
  wp_register_script( 'inline-edit-group-ads', plugins_url( 'assets/js/inline-edit-group-ads.js', __FILE__ ), array( 'jquery' ), ADVADS_VERSION, false );
215
 
216
+ $auto_ads_strings = Advanced_Ads_AdSense_Admin::get_auto_ads_messages();
217
+
218
  // register admin.js translations.
219
  $translation_array = array(
220
+ 'condition_or' => __( 'or', 'advanced-ads' ),
221
+ 'condition_and' => __( 'and', 'advanced-ads' ),
222
+ 'after_paragraph_promt' => __( 'After which paragraph?', 'advanced-ads' ),
223
+ 'page_level_ads_enabled' => $auto_ads_strings['enabled'],
224
  );
225
+
226
  wp_localize_script( $this->plugin_slug . '-admin-script', 'advadstxt', $translation_array );
227
 
228
  wp_enqueue_script( $this->plugin_slug . '-admin-script' );
459
  }
460
 
461
  $subject = isset( $form['advanced_ads_disable_reason'] ) ? $form['advanced_ads_disable_reason'] : '(no reason given)';
462
+ // append plugin name to get a better subject.
463
+ $subject .= ' (Advanced Ads)';
464
 
465
  $success = wp_mail( 'improve@wpadvancedads.com', $subject, $text, $headers );
466
 
admin/includes/class-ad-type.php CHANGED
@@ -22,7 +22,9 @@ class Advanced_Ads_Admin_Ad_Type {
22
  add_filter( 'manage_advanced_ads_posts_columns', array($this, 'ad_list_columns_head') ); // extra column
23
  add_filter( 'manage_advanced_ads_posts_custom_column', array($this, 'ad_list_columns_content'), 10, 2 ); // extra column
24
  add_filter( 'manage_advanced_ads_posts_custom_column', array($this, 'ad_list_columns_timing'), 10, 2 ); // extra column
 
25
  add_action( 'restrict_manage_posts', array( $this, 'ad_list_add_filters') );
 
26
 
27
  // ad updated messages
28
  add_filter( 'bulk_post_updated_messages', array($this, 'ad_bulk_update_messages'), 10, 2 );
@@ -80,11 +82,13 @@ class Advanced_Ads_Admin_Ad_Type {
80
  if ( $key == 'title' ){
81
  $new_columns[ 'ad_details' ] = __( 'Ad Details', 'advanced-ads' );
82
  $new_columns[ 'ad_timing' ] = __( 'Ad Planning', 'advanced-ads' );
 
83
  }
84
  }
85
  } else {
86
  $new_columns[ 'ad_details' ] = __( 'Ad Details', 'advanced-ads' );
87
  $new_columns[ 'ad_timing' ] = __( 'Ad Planning', 'advanced-ads' );
 
88
  }
89
 
90
  // white-listed columns
@@ -93,6 +97,7 @@ class Advanced_Ads_Admin_Ad_Type {
93
  'title',
94
  'ad_details',
95
  'ad_timing',
 
96
  'taxonomy-advanced_ads_groups',
97
  ) );
98
 
@@ -171,10 +176,43 @@ class Advanced_Ads_Admin_Ad_Type {
171
  }
172
  }
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  /**
175
  * adds filter dropdowns before the 'Filter' button on the ad list table
176
  */
177
- function ad_list_add_filters() {
178
  $screen = get_current_screen();
179
  if ( ! isset( $screen->id ) || $screen->id !== 'edit-advanced_ads' ) {
180
  return;
22
  add_filter( 'manage_advanced_ads_posts_columns', array($this, 'ad_list_columns_head') ); // extra column
23
  add_filter( 'manage_advanced_ads_posts_custom_column', array($this, 'ad_list_columns_content'), 10, 2 ); // extra column
24
  add_filter( 'manage_advanced_ads_posts_custom_column', array($this, 'ad_list_columns_timing'), 10, 2 ); // extra column
25
+ add_filter( 'manage_advanced_ads_posts_custom_column', array($this, 'ad_list_columns_shortcode'), 10, 2 ); // extra column
26
  add_action( 'restrict_manage_posts', array( $this, 'ad_list_add_filters') );
27
+ add_filter( 'default_hidden_columns', array( $this, 'hide_ad_list_columns' ), 10, 2 ); // hide the ad shortcode column by default
28
 
29
  // ad updated messages
30
  add_filter( 'bulk_post_updated_messages', array($this, 'ad_bulk_update_messages'), 10, 2 );
82
  if ( $key == 'title' ){
83
  $new_columns[ 'ad_details' ] = __( 'Ad Details', 'advanced-ads' );
84
  $new_columns[ 'ad_timing' ] = __( 'Ad Planning', 'advanced-ads' );
85
+ $new_columns[ 'ad_shortcode' ] = __( 'Ad Shortcode', 'advanced-ads' );
86
  }
87
  }
88
  } else {
89
  $new_columns[ 'ad_details' ] = __( 'Ad Details', 'advanced-ads' );
90
  $new_columns[ 'ad_timing' ] = __( 'Ad Planning', 'advanced-ads' );
91
+ $new_columns[ 'ad_shortcode' ] = __( 'Ad Shortcode', 'advanced-ads' );
92
  }
93
 
94
  // white-listed columns
97
  'title',
98
  'ad_details',
99
  'ad_timing',
100
+ 'ad_shortcode',
101
  'taxonomy-advanced_ads_groups',
102
  ) );
103
 
176
  }
177
  }
178
 
179
+ /**
180
+ * display ad shortcode in ads list
181
+ *
182
+ * @since 1.8.2
183
+ * @param string $column_name name of the column
184
+ * @param int $ad_id id of the ad
185
+ */
186
+ public function ad_list_columns_shortcode($column_name, $ad_id) {
187
+ if ( $column_name == 'ad_shortcode' ) {
188
+ $ad = new Advanced_Ads_Ad( $ad_id );
189
+
190
+ include ADVADS_BASE_PATH . 'admin/views/ad-list-shortcode-column.php';
191
+ }
192
+ }
193
+
194
+ /**
195
+ * display ad shortcode in ads list
196
+ *
197
+ * @since 1.10.5
198
+ * @param array $hidden An array of columns hidden by default.
199
+ * @param WP_Screen $screen WP_Screen object of the current screen.
200
+ */
201
+ public function hide_ad_list_columns( $hidden, $screen ) {
202
+
203
+ if( isset( $screen->id ) && 'edit-' . Advanced_Ads::POST_TYPE_SLUG === $screen->id ){
204
+
205
+ $hidden[] = 'ad_shortcode';
206
+
207
+ }
208
+
209
+ return $hidden;
210
+ }
211
+
212
  /**
213
  * adds filter dropdowns before the 'Filter' button on the ad list table
214
  */
215
+ public function ad_list_add_filters() {
216
  $screen = get_current_screen();
217
  if ( ! isset( $screen->id ) || $screen->id !== 'edit-advanced_ads' ) {
218
  return;
admin/includes/class-list-filters.php CHANGED
@@ -240,7 +240,7 @@ class Advanced_Ads_Ad_List_Filters {
240
  // and only on the ad list page.
241
  $request = wp_unslash( $_REQUEST );
242
  $server = wp_unslash( $_SERVER );
243
- if ( false !== strpos( $server['PHP_SELF'], 'edit.php' ) && isset( $request['post_type'] ) && 'advanced_ads' === $request['post_type'] ) {
244
  $orderby = 'post_title ASC';
245
  }
246
  }
@@ -259,8 +259,8 @@ class Advanced_Ads_Ad_List_Filters {
259
  }
260
 
261
  // If for some reason, requested posts are not ads, abort everything.
262
- if ( count( $posts ) && isset( $_REQUEST['post_type'] ) && 'advanced_ads' === $_REQUEST['post_type'] ) {
263
- if ( 'advanced_ads' !== $posts[0]->post_type ) {
264
  return $posts;
265
  }
266
  }
@@ -277,7 +277,7 @@ class Advanced_Ads_Ad_List_Filters {
277
  // and only on the ad list page.
278
  $request = wp_unslash( $_REQUEST );
279
  $server = wp_unslash( $_SERVER );
280
- if ( false !== strpos( $server['PHP_SELF'], 'edit.php' ) && isset( $request['post_type'] ) && 'advanced_ads' === $request['post_type'] ) {
281
  $this->collect_all_ads( $posts );
282
  }
283
  return $posts;
240
  // and only on the ad list page.
241
  $request = wp_unslash( $_REQUEST );
242
  $server = wp_unslash( $_SERVER );
243
+ if ( false !== strpos( $server['PHP_SELF'], 'edit.php' ) && isset( $request['post_type'] ) && Advanced_Ads::POST_TYPE_SLUG === $request['post_type'] ) {
244
  $orderby = 'post_title ASC';
245
  }
246
  }
259
  }
260
 
261
  // If for some reason, requested posts are not ads, abort everything.
262
+ if ( count( $posts ) && isset( $_REQUEST['post_type'] ) && Advanced_Ads::POST_TYPE_SLUG === $_REQUEST['post_type'] ) {
263
+ if ( Advanced_Ads::POST_TYPE_SLUG !== $posts[0]->post_type ) {
264
  return $posts;
265
  }
266
  }
277
  // and only on the ad list page.
278
  $request = wp_unslash( $_REQUEST );
279
  $server = wp_unslash( $_SERVER );
280
+ if ( false !== strpos( $server['PHP_SELF'], 'edit.php' ) && isset( $request['post_type'] ) && Advanced_Ads::POST_TYPE_SLUG === $request['post_type'] ) {
281
  $this->collect_all_ads( $posts );
282
  }
283
  return $posts;
admin/includes/class-meta-box.php CHANGED
@@ -190,6 +190,22 @@ class Advanced_Ads_Admin_Meta_Boxes {
190
  'class' =>'advads-ad-notice-https-missing error'
191
  );
192
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  $warnings = apply_filters( 'advanced-ads-ad-notices', $warnings, $box, $post );
195
  echo '<ul id="' .$box['id'].'-notices" class="advads-metabox-notices">';
@@ -476,4 +492,4 @@ class Advanced_Ads_Admin_Meta_Boxes {
476
  return $allowed_post_types;
477
  }
478
 
479
- }
190
  'class' =>'advads-ad-notice-https-missing error'
191
  );
192
  }
193
+
194
+ if ( 'ad-parameters-box' === $box['id'] ) {
195
+ $auto_ads_strings = Advanced_Ads_AdSense_Admin::get_auto_ads_messages();
196
+
197
+ if ( Advanced_Ads_AdSense_Data::get_instance()->is_page_level_enabled() ) {
198
+ $warnings[] = array(
199
+ 'text' => $auto_ads_strings['enabled'],
200
+ 'class' => 'advads-auto-ad-in-ad-content hidden error'
201
+ );
202
+ } else {
203
+ $warnings[] = array(
204
+ 'text' => $auto_ads_strings['disabled'],
205
+ 'class' => 'advads-auto-ad-in-ad-content hidden error'
206
+ );
207
+ }
208
+ }
209
 
210
  $warnings = apply_filters( 'advanced-ads-ad-notices', $warnings, $box, $post );
211
  echo '<ul id="' .$box['id'].'-notices" class="advads-metabox-notices">';
492
  return $allowed_post_types;
493
  }
494
 
495
+ }
admin/includes/class-overview-widgets.php CHANGED
@@ -63,6 +63,9 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
63
  if ( count( $recent_ads ) == 0 ) :
64
  echo '<p><a class="button button-primary" href="' . admin_url( 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG ) .
65
  '">' . __( 'Create your first ad', 'advanced-ads' ) . '</a></p>';
 
 
 
66
  $primary_taken = true;
67
  endif;
68
 
63
  if ( count( $recent_ads ) == 0 ) :
64
  echo '<p><a class="button button-primary" href="' . admin_url( 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG ) .
65
  '">' . __( 'Create your first ad', 'advanced-ads' ) . '</a></p>';
66
+ // Connect to AdSense
67
+ echo '<p><a class="button button-primary" href="' . admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) .
68
+ '">' . esc_attr__( 'Connect to AdSense', 'advanced-ads' ) . '</a></p>';
69
  $primary_taken = true;
70
  endif;
71
 
admin/views/ad-conditions-string-operators.php CHANGED
@@ -1,12 +1,22 @@
1
- <select name="<?php echo $name; ?>[operator]">
2
- <option value="contain" <?php selected( 'contain', $operator ); ?>><?php _e( 'contains', 'advanced-ads' ); ?></option>
3
- <option value="start" <?php selected( 'start', $operator ); ?>><?php _e( 'starts with', 'advanced-ads' ); ?></option>
4
- <option value="end" <?php selected( 'end', $operator ); ?>><?php _e( 'ends with', 'advanced-ads' ); ?></option>
5
- <option value="match" <?php selected( 'match', $operator ); ?>><?php _e( 'matches', 'advanced-ads' ); ?></option>
6
- <option value="regex" <?php selected( 'regex', $operator ); ?>><?php _e( 'matches regex', 'advanced-ads' ); ?></option>
7
- <option value="contain_not" <?php selected( 'contain_not', $operator ); ?>><?php _e( 'does not contain', 'advanced-ads' ); ?></option>
8
- <option value="start_not" <?php selected( 'start_not', $operator ); ?>><?php _e( 'does not start with', 'advanced-ads' ); ?></option>
9
- <option value="end_not" <?php selected( 'end_not', $operator ); ?>><?php _e( 'does not end with', 'advanced-ads' ); ?></option>
10
- <option value="match_not" <?php selected( 'match_not', $operator ); ?>><?php _e( 'does not match', 'advanced-ads' ); ?></option>
11
- <option value="regex_not" <?php selected( 'regex_not', $operator ); ?>><?php _e( 'does not match regex', 'advanced-ads' ); ?></option>
12
- </select>
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Render select field for matching-technique of string-based Display Conditions
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ */
11
+ ?><select name="<?php echo $name; ?>[operator]">
12
+ <option value="contain" <?php selected( 'contain', $operator ); ?>><?php esc_attr_e( 'contains', 'advanced-ads' ); ?></option>
13
+ <option value="start" <?php selected( 'start', $operator ); ?>><?php esc_attr_e( 'starts with', 'advanced-ads' ); ?></option>
14
+ <option value="end" <?php selected( 'end', $operator ); ?>><?php esc_attr_e( 'ends with', 'advanced-ads' ); ?></option>
15
+ <option value="match" <?php selected( 'match', $operator ); ?>><?php esc_attr_e( 'matches', 'advanced-ads' ); ?></option>
16
+ <option value="regex" <?php selected( 'regex', $operator ); ?>><?php esc_attr_e( 'matches regex', 'advanced-ads' ); ?></option>
17
+ <option value="contain_not" <?php selected( 'contain_not', $operator ); ?>><?php esc_attr_e( 'does not contain', 'advanced-ads' ); ?></option>
18
+ <option value="start_not" <?php selected( 'start_not', $operator ); ?>><?php esc_attr_e( 'does not start with', 'advanced-ads' ); ?></option>
19
+ <option value="end_not" <?php selected( 'end_not', $operator ); ?>><?php esc_attr_e( 'does not end with', 'advanced-ads' ); ?></option>
20
+ <option value="match_not" <?php selected( 'match_not', $operator ); ?>><?php esc_attr_e( 'does not match', 'advanced-ads' ); ?></option>
21
+ <option value="regex_not" <?php selected( 'regex_not', $operator ); ?>><?php esc_attr_e( 'does not match regex', 'advanced-ads' ); ?></option>
22
+ </select>
admin/views/ad-display-metabox.php CHANGED
@@ -1,137 +1,192 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
2
  $display_conditions = Advanced_Ads_Display_Conditions::get_instance()->get_conditions();
3
 
4
- // add mockup conditions if add-ons are missing
5
  $pro_conditions = array();
6
- if( ! defined( 'AAP_VERSION' ) ){
7
- $pro_conditions[] = __( 'parent page', 'advanced-ads');
8
- $pro_conditions[] = __( 'post meta', 'advanced-ads');
9
- $pro_conditions[] = __( 'page template', 'advanced-ads');
10
- $pro_conditions[] = __( 'url parameters', 'advanced-ads');
11
  }
12
- if( ! defined( 'AAR_VERSION') ){
13
- $pro_conditions[] = __( 'accelerated mobile pages', 'advanced-ads');
14
  }
15
  asort( $pro_conditions );
16
 
17
- $options = $ad->options('conditions');
18
- $empty_options = ( !is_array( $options ) || !count( $options ) );
19
- if( $empty_options ) :
20
- ?><div class="advads-show-in-wizard">
21
- <p><?php _e( 'Click on the button below if the ad should NOT show up on all pages when included automatically.', 'advanced-ads' ); ?></p>
22
- <button type="button" class="button button-secondary" id="advads-wizard-display-conditions-show"><?php _e( 'Hide the ad on some pages', 'advanced-ads' ); ?></button>
23
  </div>
24
  <?php endif; ?>
25
- <div id="advads-display-conditions" <?php if( $empty_options ) : ?>class="advads-hide-in-wizard"<?php endif; ?>>
26
- <?php // display help when no conditions are given
27
- if( $empty_options ) :
28
- $options = array();
29
- ?><p><button type="button" class="advads-video-link-inline button button-primary"><?php _e( 'Watch video', 'advanced-ads' ); ?></button><?php
30
- ?>&nbsp;<a class="button button-secondary" href="<?php echo ADVADS_URL; ?>manual/display-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-display" target="_blank">
31
- <?php _e( 'Visit the manual', 'advanced-ads' ); ?>
32
- </a></p><?php
33
- endif;
34
- ?><p class="advads-jqueryui-error advads-error-message hidden"><?php printf(__( 'There might be a problem with layouts and scripts in your dashboard. Please check <a href="%s" target="_blank">this article to learn more</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/jquery-problem-in-dashboard/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-jquery-error' ); ?></p>
35
- <p><?php _e('A page with this ad on it must match all of the following conditions.', 'advanced-ads'); ?></p>
36
- <table class="advads-conditions-table"><tbody><?php
37
- $last_index = -1;
38
- $i = 0;
39
- if (is_array($options)) :
40
- foreach ($options as $_index => $_options) :
41
- $show_or_force_warning = false;
42
- // get type attribute from previous option format
43
- $_options['type'] = isset($_options['type']) ? $_options['type'] : $_index;
44
- $connector = ( ! isset($_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
45
- if (isset($_options['type']) && isset($display_conditions[$_options['type']]['metabox'])) {
46
- $metabox = $display_conditions[$_options['type']]['metabox'];
47
- } else {
48
- continue;
49
- }
50
- if (method_exists($metabox[0], $metabox[1])) {
51
- /**
52
- * show warning for connector when
53
- * not set to OR already
54
- * this condition and the previous are on page level and not from the identical type
55
- * they are both set to SHOW
56
- */
57
- $tax = ( isset( $_options['type'] ) && isset( $display_conditions[ $_options['type'] ]['taxonomy'] ) ) ? $display_conditions[ $_options['type'] ]['taxonomy'] : false;
58
- $last_tax = ( isset( $options[$last_index]['type'] ) && isset( $display_conditions[ $options[$last_index]['type'] ]['taxonomy'] ) ) ? $display_conditions[ $options[$last_index]['type'] ]['taxonomy'] : false;
59
- if( $tax && $last_tax && $last_tax === $tax
60
- && ( ! isset( $_options['connector'] ) || $_options['connector'] !== 'or' )
61
- && 'is' === $_options['operator'] && 'is' === $options[$last_index]['operator']
62
- && $_options['type'] !== $options[$last_index]['type'] ){
63
-
64
- $show_or_force_warning = true;
65
- }
66
-
67
- if( $i > 0 ) : ?><tr class="advads-conditions-connector advads-conditions-connector-<?php echo $connector; ?>">
68
- <td colspan="3"><?php echo Advanced_Ads_Display_Conditions::render_connector_option( $i, $connector );
69
- if( $show_or_force_warning ){
70
- ?><p class="advads-error-message"><?php
71
- _e( 'Forced to OR.', 'advanced-ads');
72
- echo '&nbsp;<a target="_blank" href="' . ADVADS_URL . 'manual/display-conditions#manual-combining-multiple-conditions' . '">' . __( 'manual', 'advanced-ads' ) . '</a>';
73
- ?></p><?php
74
-
75
  }
76
- ?></td>
77
- </tr><?php endif; ?>
78
- <tr><td class="advads-conditions-type" data-condition-type="<?php echo $_options['type']; ?>"><?php echo $display_conditions[$_options['type']]['label']; ?></td><td><?php
79
- call_user_func(array($metabox[0], $metabox[1]), $_options, $i++);
80
- ?></td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr><?php
 
 
 
 
 
 
 
 
 
 
81
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  $last_index = $_index;
83
- endforeach;
84
  endif;
85
- ?></tbody></table>
86
- <input type="hidden" id="advads-display-conditions-index" value="<?php echo is_array($options) ? count($options) : 0; ?>"/>
87
- <?php if ( $empty_options ) :
88
- ?><p><?php _e('If you want to display the ad everywhere, don\'t do anything here. ', 'advanced-ads'); ?></p><?php
 
 
 
 
89
  endif;
90
- ?></div>
91
- <fieldset <?php if( $empty_options ) : ?>class="advads-hide-in-wizard"<?php endif; ?>>
92
- <legend><?php _e('New condition', 'advanced-ads'); ?></legend>
93
- <div id="advads-display-conditions-new">
 
 
 
 
 
94
  <select>
95
- <option value=""><?php _e('-- choose a condition --', 'advanced-ads'); ?></option>
96
- <?php foreach ($display_conditions as $_condition_id => $_condition) : ?>
97
- <option value="<?php echo $_condition_id; ?>"><?php echo $_condition['label']; ?></option>
98
- <?php endforeach;
99
- if( count( $pro_conditions ) ) :
100
- ?><optgroup label="<?php _e( 'Add-On features', 'advanced-ads' ); ?>"><?php
101
- foreach ( $pro_conditions as $_pro_condition ) :
102
- ?><option disabled="disabled"><?php echo $_pro_condition; ?></option><?php
103
  endforeach;
104
- ?></optgroup><?php
105
- endif;
106
- ?></select>
107
- <button type="button" class="button"><?php _e('add', 'advanced-ads'); ?></button>
 
 
 
 
 
 
 
 
 
 
 
 
108
  <span class="advads-loader" style="display: none;"></span>
109
- </div>
110
  </fieldset>
111
  <script>
112
- jQuery(document).ready(function ($) {
113
  $('#advads-display-conditions-new button').click(function () {
114
- var display_condition_type = $('#advads-display-conditions-new select').val();
115
- var display_condition_title = $('#advads-display-conditions-new select option:selected').text();
116
- var display_condition_index = parseInt($('#advads-display-conditions-index').val());
117
- if (!display_condition_type || '' == display_condition_type ){
118
  return;
119
- }
120
- $('#advads-display-conditions-new .advads-loader').show(); // show loader
121
- $('#advads-display-conditions-new button').hide(); // hide add button
122
- $.ajax({
123
  type: 'POST',
124
  url: ajaxurl,
125
  data: {
126
- action: 'load_display_conditions_metabox',
127
- type: display_condition_type,
128
- index: display_condition_index,
129
- nonce: advadsglobal.ajax_nonce
130
  },
131
  success: function (r, textStatus, XMLHttpRequest) {
132
- // add
133
- if (r) {
134
- var connector = '<input style="display:none;" type="checkbox" name="<?php echo Advanced_Ads_Display_Conditions::FORM_NAME; ?>[' + display_condition_index + '][connector]" checked="checked" value="or" id="advads-conditions-'+ display_condition_index +'-connector"><label for="advads-conditions-'+ display_condition_index +'-connector"><?php _e( 'or', 'advanced-ads' ); ?></label>';
135
  var newline = '<tr class="advads-conditions-connector advads-conditions-connector-or"><td colspan="3">'+connector+'</td></tr><tr><td class="advads-conditions-type" data-condition-type="'+ display_condition_type +'">' + display_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>';
136
  $('#advads-display-conditions table tbody').append(newline);
137
  if ( advads_use_ui_buttonset() ) {
@@ -145,18 +200,18 @@ endif;
145
  $('#advads-display-conditions-index').val(display_condition_index);
146
  // reset select
147
  $('#advads-display-conditions-new select')[0].selectedIndex = 0;
148
- }
149
  },
150
  error: function (MLHttpRequest, textStatus, errorThrown) {
151
- $('#advads-display-conditions-new').append(errorThrown);
152
  },
153
  complete: function( MLHttpRequest, textStatus ) {
154
- $('#advads-display-conditions-new .advads-loader').hide(); // hide loader
155
- $('#advads-display-conditions-new button').show(); // display add button
156
  }
157
- });
 
158
  });
159
- });
160
  </script>
161
  <?php
162
- do_action('advanced-ads-display-conditions-after', $ad);
1
  <?php
2
+ /**
3
+ * Render meta box for Display Conditions on ad edit page
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ */
11
+
12
  $display_conditions = Advanced_Ads_Display_Conditions::get_instance()->get_conditions();
13
 
14
+ // add mockup conditions if add-ons are missing.
15
  $pro_conditions = array();
16
+ if ( ! defined( 'AAP_VERSION' ) ) {
17
+ $pro_conditions[] = __( 'parent page', 'advanced-ads' );
18
+ $pro_conditions[] = __( 'post meta', 'advanced-ads' );
19
+ $pro_conditions[] = __( 'page template', 'advanced-ads' );
20
+ $pro_conditions[] = __( 'url parameters', 'advanced-ads' );
21
  }
22
+ if ( ! defined( 'AAR_VERSION' ) ) {
23
+ $pro_conditions[] = __( 'accelerated mobile pages', 'advanced-ads' );
24
  }
25
  asort( $pro_conditions );
26
 
27
+ $options = $ad->options( 'conditions' );
28
+ $empty_options = ( ! is_array( $options ) || ! count( $options ) );
29
+ if ( $empty_options ) :
30
+ ?><div class="advads-show-in-wizard">
31
+ <p><?php esc_attr_e( 'Click on the button below if the ad should NOT show up on all pages when included automatically.', 'advanced-ads' ); ?></p>
32
+ <button type="button" class="button button-secondary" id="advads-wizard-display-conditions-show"><?php esc_attr_e( 'Hide the ad on some pages', 'advanced-ads' ); ?></button>
33
  </div>
34
  <?php endif; ?>
35
+ <div id="advads-display-conditions"
36
+ <?php
37
+ if ( $empty_options ) :
38
+ ?>
39
+ class="advads-hide-in-wizard"<?php endif; ?>>
40
+ <?php
41
+ // display help when no conditions are given.
42
+ if ( $empty_options ) :
43
+ $options = array();
44
+ ?>
45
+ <p><button type="button" class="advads-video-link-inline button button-primary">
46
+ <?php esc_attr_e( 'Watch video', 'advanced-ads' ); ?>
47
+ </button>&nbsp;<a class="button button-secondary" href="<?php echo ADVADS_URL; ?>manual/display-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-display" target="_blank">
48
+ <?php esc_attr_e( 'Visit the manual', 'advanced-ads' ); ?>
49
+ </a></p>
50
+ <?php
51
+ endif;
52
+ ?>
53
+ <p class="advads-jqueryui-error advads-error-message hidden">
54
+ <?php
55
+ /*
56
+ * translators: %s is a link to a tutorial.
57
+ */
58
+ printf( __( 'There might be a problem with layouts and scripts in your dashboard. Please check <a href="%s" target="_blank">this article to learn more</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/jquery-problem-in-dashboard/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-jquery-error' ); ?></p>
59
+ <p><?php esc_attr_e( 'A page with this ad on it must match all of the following conditions.', 'advanced-ads' ); ?></p>
60
+ <table class="advads-conditions-table"><tbody>
61
+ <?php
62
+ $last_index = -1;
63
+ $i = 0;
64
+ if ( is_array( $options ) ) :
65
+ foreach ( $options as $_index => $_options ) :
66
+ $show_or_force_warning = false;
67
+ // get type attribute from previous option format.
68
+ $_options['type'] = isset( $_options['type'] ) ? $_options['type'] : $_index;
69
+ $connector = ( ! isset( $_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
70
+ if ( isset( $_options['type'] ) && isset( $display_conditions[ $_options['type'] ]['metabox'] ) ) {
71
+ $metabox = $display_conditions[ $_options['type'] ]['metabox'];
72
+ } else {
73
+ continue;
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
+ if ( method_exists( $metabox[0], $metabox[1] ) ) {
76
+ /**
77
+ * Show warning for connector when
78
+ * not set to OR already
79
+ * this condition and the previous are on page level and not from the identical type
80
+ * they are both set to SHOW
81
+ */
82
+ $tax = ( isset( $_options['type'] ) && isset( $display_conditions[ $_options['type'] ]['taxonomy'] ) ) ? $display_conditions[ $_options['type'] ]['taxonomy'] : false;
83
+ $last_tax = ( isset( $options[ $last_index ]['type'] ) && isset( $display_conditions[ $options[ $last_index ]['type'] ]['taxonomy'] ) ) ? $display_conditions[ $options[ $last_index ]['type'] ]['taxonomy'] : false;
84
+ if ( $tax && $last_tax && $last_tax === $tax
85
+ && ( ! isset( $_options['connector'] ) || 'or' !== $_options['connector'] )
86
+ && 'is' === $_options['operator'] && 'is' === $options[ $last_index ]['operator']
87
+ && $_options['type'] !== $options[ $last_index ]['type'] ) {
88
+
89
+ $show_or_force_warning = true;
90
  }
91
+
92
+ if ( $i > 0 ) :
93
+
94
+ ?>
95
+ <tr class="advads-conditions-connector advads-conditions-connector-<?php echo $connector; ?>">
96
+ <td colspan="3">
97
+ <?php
98
+ echo Advanced_Ads_Display_Conditions::render_connector_option( $i, $connector );
99
+ if ( $show_or_force_warning ) {
100
+ ?>
101
+ <p class="advads-error-message">
102
+ <?php
103
+ esc_attr_e( 'Forced to OR.', 'advanced-ads' );
104
+ echo '&nbsp;<a target="_blank" href="' . ADVADS_URL . 'manual/display-conditions#manual-combining-multiple-conditions' . '">' . esc_attr__( 'manual', 'advanced-ads' ) . '</a>';
105
+ ?>
106
+ </p>
107
+ <?php
108
+
109
+ }
110
+ ?>
111
+ </td>
112
+ </tr><?php endif; ?>
113
+ <tr><td class="advads-conditions-type" data-condition-type="<?php echo $_options['type']; ?>"><?php echo $display_conditions[ $_options['type'] ]['label']; ?></td><td>
114
+ <?php
115
+ call_user_func( array( $metabox[0], $metabox[1] ), $_options, $i++ );
116
+ ?>
117
+ </td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>
118
+ <?php
119
+ }
120
  $last_index = $_index;
121
+ endforeach;
122
  endif;
123
+ ?>
124
+ </tbody></table>
125
+ <input type="hidden" id="advads-display-conditions-index" value="<?php echo is_array( $options ) ? count( $options ) : 0; ?>"/>
126
+ <?php
127
+ if ( $empty_options ) :
128
+ ?>
129
+ <p><?php esc_attr_e( 'If you want to display the ad everywhere, don\'t do anything here. ', 'advanced-ads' ); ?></p>
130
+ <?php
131
  endif;
132
+ ?>
133
+ </div>
134
+ <fieldset
135
+ <?php
136
+ if ( $empty_options ) :
137
+ ?>
138
+ class="advads-hide-in-wizard"<?php endif; ?>>
139
+ <legend><?php esc_attr_e( 'New condition', 'advanced-ads' ); ?></legend>
140
+ <div id="advads-display-conditions-new">
141
  <select>
142
+ <option value=""><?php esc_attr_e( '-- choose a condition --', 'advanced-ads' ); ?></option>
143
+ <?php foreach ( $display_conditions as $_condition_id => $_condition ) : ?>
144
+ <option value="<?php echo $_condition_id; ?>"><?php echo $_condition['label']; ?></option>
145
+ <?php
 
 
 
 
146
  endforeach;
147
+ if ( count( $pro_conditions ) ) :
148
+ ?>
149
+ <optgroup label="<?php esc_attr_e( 'Add-On features', 'advanced-ads' ); ?>">
150
+ <?php
151
+ foreach ( $pro_conditions as $_pro_condition ) :
152
+ ?>
153
+ <option disabled="disabled"><?php echo $_pro_condition; ?></option>
154
+ <?php
155
+ endforeach;
156
+ ?>
157
+ </optgroup>
158
+ <?php
159
+ endif;
160
+ ?>
161
+ </select>
162
+ <button type="button" class="button"><?php esc_attr_e( 'add', 'advanced-ads' ); ?></button>
163
  <span class="advads-loader" style="display: none;"></span>
164
+ </div>
165
  </fieldset>
166
  <script>
167
+ jQuery(document).ready(function ($) {
168
  $('#advads-display-conditions-new button').click(function () {
169
+ var display_condition_type = $('#advads-display-conditions-new select').val();
170
+ var display_condition_title = $('#advads-display-conditions-new select option:selected').text();
171
+ var display_condition_index = parseInt($('#advads-display-conditions-index').val());
172
+ if (!display_condition_type || '' == display_condition_type ){
173
  return;
174
+ }
175
+ $('#advads-display-conditions-new .advads-loader').show(); // show loader
176
+ $('#advads-display-conditions-new button').hide(); // hide add button
177
+ $.ajax({
178
  type: 'POST',
179
  url: ajaxurl,
180
  data: {
181
+ action: 'load_display_conditions_metabox',
182
+ type: display_condition_type,
183
+ index: display_condition_index,
184
+ nonce: advadsglobal.ajax_nonce
185
  },
186
  success: function (r, textStatus, XMLHttpRequest) {
187
+ // add
188
+ if (r) {
189
+ var connector = '<input style="display:none;" type="checkbox" name="<?php echo Advanced_Ads_Display_Conditions::FORM_NAME; ?>[' + display_condition_index + '][connector]" checked="checked" value="or" id="advads-conditions-'+ display_condition_index +'-connector"><label for="advads-conditions-'+ display_condition_index +'-connector"><?php esc_attr_e( 'or', 'advanced-ads' ); ?></label>';
190
  var newline = '<tr class="advads-conditions-connector advads-conditions-connector-or"><td colspan="3">'+connector+'</td></tr><tr><td class="advads-conditions-type" data-condition-type="'+ display_condition_type +'">' + display_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>';
191
  $('#advads-display-conditions table tbody').append(newline);
192
  if ( advads_use_ui_buttonset() ) {
200
  $('#advads-display-conditions-index').val(display_condition_index);
201
  // reset select
202
  $('#advads-display-conditions-new select')[0].selectedIndex = 0;
203
+ }
204
  },
205
  error: function (MLHttpRequest, textStatus, errorThrown) {
206
+ $('#advads-display-conditions-new').append(errorThrown);
207
  },
208
  complete: function( MLHttpRequest, textStatus ) {
209
+ $('#advads-display-conditions-new .advads-loader').hide(); // hide loader
210
+ $('#advads-display-conditions-new button').show(); // display add button
211
  }
212
+ });
213
+ });
214
  });
 
215
  </script>
216
  <?php
217
+ do_action( 'advanced-ads-display-conditions-after', $ad );
admin/views/ad-group-edit.php CHANGED
@@ -1,18 +1,22 @@
1
  <?php
2
  /**
3
- * Create and edit ad group form
4
  *
5
- * @package WordPress
6
- * @subpackage Administration
 
 
 
 
7
  */
8
- // don't load directly
9
  if ( ! defined( 'ABSPATH' ) ) {
10
- die('-1'); }
11
 
12
  if ( ! is_int( $group_id ) ) {
13
  ?>
14
- <div id="message" class="updated"><p><strong><?php _e( 'You did not select an item for editing.', 'advanced-ads' ); ?></strong></p></div>
15
- <?php
16
  return;
17
  }
18
 
@@ -20,50 +24,64 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy );
20
  ?>
21
 
22
  <div class="wrap">
23
- <h1><?php echo $tax->labels->edit_item; ?></h1>
24
- <div id="ajax-response"></div>
25
- <form name="editgroup" id="editgroup" method="post" action="<?php echo Advanced_Ads_Groups_List::group_page_url(); ?>" class="validate"<?php do_action( $taxonomy . '_term_edit_form_tag' ); ?>>
26
- <input type="hidden" name="action" value="editedgroup" />
27
- <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
28
- <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>" />
29
- <?php wp_original_referer_field( true, 'previous' );
30
- wp_nonce_field( 'update-group_' . $group_id ); ?>
31
- <table class="form-table">
32
- <tr class="form-field form-required">
33
- <th scope="row" valign="top"><label for="name"><?php _ex( 'Name', 'Taxonomy Name', 'advanced-ads' ); ?></label></th>
34
- <td><input name="name" id="name" type="text" value="<?php if ( isset($tag->name) ) { echo esc_attr( $tag->name ); } ?>" size="40" aria-required="true" /></td>
35
- </tr>
 
 
 
 
 
 
 
36
  <?php if ( ! global_terms_enabled() ) { ?>
37
- <tr class="form-field">
38
- <th scope="row" valign="top"><label for="slug"><?php _ex( 'Slug', 'Taxonomy Slug', 'advanced-ads' ); ?></label></th>
39
- <td><input name="slug" id="slug" type="text" value="<?php if ( isset($tag->slug) ) { echo esc_attr( apply_filters( 'editable_slug', $tag->slug ) ); } ?>" size="40" />
40
- <p class="description"><?php _e( 'An id-like string with only letters in lower case, numbers, and hyphens.', 'advanced-ads' ); ?></p></td>
41
- </tr>
42
- <?php }
43
- $text = (isset($tag->description)) ? $tag->description : ''; ?>
44
- <tr class="form-field">
45
- <th scope="row" valign="top"><label for="description"><?php _ex( 'Description', 'Taxonomy Description', 'advanced-ads' ); ?></label></th>
46
- <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $text; // textarea_escaped ?></textarea></td>
47
- </tr>
48
- <?php
 
 
 
 
 
 
 
49
 
50
  do_action( $taxonomy . '_edit_form_fields', $tag, $taxonomy );
51
  ?>
52
- </table>
53
- <?php
54
  do_action( $taxonomy . '_edit_form', $tag, $taxonomy );
55
 
56
- if ( $group_id == 0 ){
57
- submit_button( __( 'Create new Ad Group', 'advanced-ads' ) );
58
  } else {
59
- submit_button( __( 'Update', 'advanced-ads' ) );
60
  }
61
  ?>
62
- </form>
63
  </div>
64
  <script type="text/javascript">
65
- try {
66
- document.forms.edittag.name.focus();
67
- } catch (e) {
68
- }
69
  </script>
1
  <?php
2
  /**
3
+ * Add and edit an ad group (taxonomy)
4
  *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ * @deprecated
11
  */
12
+
13
  if ( ! defined( 'ABSPATH' ) ) {
14
+ die( '-1' ); }
15
 
16
  if ( ! is_int( $group_id ) ) {
17
  ?>
18
+ <div id="message" class="updated"><p><strong><?php esc_attr_e( 'You did not select an item for editing.', 'advanced-ads' ); ?></strong></p></div>
19
+ <?php
20
  return;
21
  }
22
 
24
  ?>
25
 
26
  <div class="wrap">
27
+ <h1><?php echo $tax->labels->edit_item; ?></h1>
28
+ <div id="ajax-response"></div>
29
+ <form name="editgroup" id="editgroup" method="post" action="<?php echo Advanced_Ads_Groups_List::group_page_url(); ?>" class="validate"<?php do_action( $taxonomy . '_term_edit_form_tag' ); ?>>
30
+ <input type="hidden" name="action" value="editedgroup" />
31
+ <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
32
+ <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
33
+ <?php
34
+ wp_original_referer_field( true, 'previous' );
35
+ wp_nonce_field( 'update-group_' . $group_id );
36
+ ?>
37
+ <table class="form-table">
38
+ <tr class="form-field form-required">
39
+ <th scope="row" valign="top"><label for="name"><?php echo esc_attr_x( 'Name', 'Taxonomy Name', 'advanced-ads' ); ?></label></th>
40
+ <td><input name="name" id="name" type="text" value="
41
+ <?php
42
+ if ( isset( $tag->name ) ) {
43
+ echo esc_attr( $tag->name ); }
44
+ ?>
45
+ " size="40" aria-required="true" /></td>
46
+ </tr>
47
  <?php if ( ! global_terms_enabled() ) { ?>
48
+ <tr class="form-field">
49
+ <th scope="row" valign="top"><label for="slug"><?php echo esc_attr_x( 'Slug', 'Taxonomy Slug', 'advanced-ads' ); ?></label></th>
50
+ <td><input name="slug" id="slug" type="text" value="
51
+ <?php
52
+ if ( isset( $tag->slug ) ) {
53
+ echo esc_attr( apply_filters( 'editable_slug', $tag->slug ) ); }
54
+ ?>
55
+ " size="40" />
56
+ <p class="description"><?php esc_attr_e( 'An id-like string with only letters in lower case, numbers, and hyphens.', 'advanced-ads' ); ?></p></td>
57
+ </tr>
58
+ <?php
59
+ }
60
+ $text = ( isset( $tag->description ) ) ? $tag->description : '';
61
+ ?>
62
+ <tr class="form-field">
63
+ <th scope="row" valign="top"><label for="description"><?php echo esc_attr_x( 'Description', 'Taxonomy Description', 'advanced-ads' ); ?></label></th>
64
+ <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo esc_textarea( $text ); ?></textarea></td>
65
+ </tr>
66
+ <?php
67
 
68
  do_action( $taxonomy . '_edit_form_fields', $tag, $taxonomy );
69
  ?>
70
+ </table>
71
+ <?php
72
  do_action( $taxonomy . '_edit_form', $tag, $taxonomy );
73
 
74
+ if ( 0 === $group_id ) {
75
+ submit_button(esc_attr__( 'Create new Ad Group', 'advanced-ads' ) );
76
  } else {
77
+ submit_button( esc_attr__( 'Update', 'advanced-ads' ) );
78
  }
79
  ?>
80
+ </form>
81
  </div>
82
  <script type="text/javascript">
83
+ try {
84
+ document.forms.edittag.name.focus();
85
+ } catch (e) {
86
+ }
87
  </script>
admin/views/ad-group-list-ads.php CHANGED
@@ -1,26 +1,40 @@
1
- <table class="advads-group-ads">
2
- <thead><tr><th><?php _e( 'Ad', 'advanced-ads' );
3
- ?></th><th colspan="2"><?php _e('weight', 'advanced-ads'); ?></th></tr></thead>
4
- <tbody>
 
 
 
 
 
 
 
 
 
 
 
5
  <?php
6
- if (count($ad_form_rows)) {
7
- foreach ($ad_form_rows as $_row) {
8
- echo $_row;
9
- }
10
  }
11
  ?>
12
- </tbody>
13
- </table>
14
 
15
- <?php if ( $ads_for_select ): ?>
16
  <fieldset class="advads-group-add-ad">
17
- <legend><?php _e( 'New Ad', 'advanced-ads' ); ?></legend>
18
  <select class="advads-group-add-ad-list-ads">
19
- <?php foreach ( $ads_for_select as $_ad_id => $_ad_title ) {
 
20
  echo '<option value="advads-groups[' . $group->id . '][ads][' . $_ad_id . ']">' . $_ad_title . '</option>';
21
- } ?>
 
22
  </select>
23
  <?php echo $new_ad_weights; ?>
24
- <button type="button" class="button"><?php _e( 'add', 'advanced-ads' ); ?></button>
25
  </fieldset>
26
- <?php endif;
 
1
+ <?php
2
+ /**
3
+ * Render a list of ads included in an ad group
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ */
11
+
12
+ ?><table class="advads-group-ads">
13
+ <thead><tr><th><?php esc_attr_e( 'Ad', 'advanced-ads' );
14
+ ?></th><th colspan="2"><?php esc_attr_e( 'weight', 'advanced-ads' ); ?></th></tr></thead>
15
+ <tbody>
16
  <?php
17
+ if ( count( $ad_form_rows ) ) {
18
+ foreach ( $ad_form_rows as $_row ) {
19
+ echo $_row;
20
+ }
21
  }
22
  ?>
23
+ </tbody>
24
+ </table>
25
 
26
+ <?php if ( $ads_for_select ) : ?>
27
  <fieldset class="advads-group-add-ad">
28
+ <legend><?php esc_attr_e( 'New Ad', 'advanced-ads' ); ?></legend>
29
  <select class="advads-group-add-ad-list-ads">
30
+ <?php
31
+ foreach ( $ads_for_select as $_ad_id => $_ad_title ) {
32
  echo '<option value="advads-groups[' . $group->id . '][ads][' . $_ad_id . ']">' . $_ad_title . '</option>';
33
+ }
34
+ ?>
35
  </select>
36
  <?php echo $new_ad_weights; ?>
37
+ <button type="button" class="button"><?php esc_attr_e( 'add', 'advanced-ads' ); ?></button>
38
  </fieldset>
39
+ <?php
40
+ endif;
admin/views/ad-group-list-form-row.php CHANGED
@@ -1,72 +1,96 @@
1
- <?php // open form if this was the last edited
2
- $hidden = ( isset( $_POST['advads-last-edited-group'] ) && $group->id == $_POST['advads-last-edited-group'] ) ? '' : ' hidden';
3
- ?><tr class="advads-ad-group-form<?php echo $hidden; ?>">
4
- <td colspan="3">
5
- <?php // name
 
 
 
 
 
 
 
 
 
 
 
 
6
  ob_start();
7
- ?><input type="text" name="advads-groups[<?php echo $group->id; ?>][name]" value="<?php echo $group->name; ?>"/><?php
 
 
8
  $option_content = ob_get_clean();
9
-
10
- Advanced_Ads_Admin_Options::render_option(
11
- 'group-name static',
12
  __( 'Name', 'advanced-ads' ),
13
- $option_content );
14
-
15
- // description
16
- /* removed in 1.8 since we never saw it being used and so it just took space
17
- ob_start();
18
- ?><input type="text" name="advads-groups[<?php echo $group->id; ?>][description]" value="<?php echo $group->description; ?>"/><?php
19
- $option_content = ob_get_clean();
20
-
21
- Advanced_Ads_Admin_Options::render_option(
22
- 'group-description',
23
- __( 'Description', 'advanced-ads' ),
24
- $option_content );
25
- */
26
-
27
- // type
28
- ob_start();
29
- ?><div class="advads-ad-group-type"><?php foreach ( $this->types as $_type_key => $_type ) :
30
- ?><label title="<?php echo $_type['description']; ?>"><input type="radio" name="advads-groups[<?php echo $group->id;
31
- ?>][type]" value="<?php echo $_type_key; ?>" <?php checked( $group->type, $_type_key )?>/><?php
32
- echo $_type['title']; ?></label>
33
- <!--p class="description"><?php echo $_type['description']; ?></p-->
34
- <?php
35
- endforeach; ?>
36
- </div><?php
37
- $option_content = ob_get_clean();
38
-
39
- Advanced_Ads_Admin_Options::render_option(
40
- 'group-type static',
41
- __( 'Type', 'advanced-ads' ),
42
- $option_content );
43
-
44
- // group number
45
  ob_start();
46
- ?><select name="advads-groups[<?php echo $group->id; ?>][ad_count]"><?php
47
- $max = ( count( $ad_form_rows ) >= 10 ) ? count( $ad_form_rows ) + 2 : 10;
48
- for ( $i = 1; $i <= $max; $i++ ) : ?>
49
- <option <?php selected( $group->ad_count, $i ); ?>><?php echo $i; ?></option>
50
- <?php endfor;
51
- ?><option <?php selected( $group->ad_count, 'all' ); ?> value="all"><?php _ex('all', 'option to display all ads in an ad groups', 'advanced-ads'); ?></option>
52
- </select><?php
 
 
 
 
 
 
 
 
 
 
 
 
53
  $option_content = ob_get_clean();
54
-
55
- Advanced_Ads_Admin_Options::render_option(
56
- 'group-number advads-group-type-default advads-group-type-ordered',
57
- __( 'Visible ads', 'advanced-ads' ),
58
- $option_content,
59
- __( 'Number of ads that are visible at the same time', 'advanced-ads' ) );
60
-
61
- do_action( 'advanced-ads-group-form-options', $group );
62
-
63
  ob_start();
64
- include ADVADS_BASE_PATH . 'admin/views/ad-group-list-ads.php';
65
- $option_content = ob_get_clean();
66
- Advanced_Ads_Admin_Options::render_option(
67
- 'group-ads static',
68
- __( 'Ads', 'advanced-ads' ),
69
- $option_content );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
- ?></td>
72
- </tr>
 
1
+ <?php
2
+ /**
3
+ * Advanced Ads – form to edit ad groups in the admin
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ */
11
+
12
+ // Open form if this was the last edited.
13
+ $hidden = ( isset( $_POST['advads-last-edited-group'] ) && $group->id === $_POST['advads-last-edited-group'] ) ? '' : ' hidden';
14
+ ?><tr class="advads-ad-group-form<?php echo esc_attr( $hidden ); ?>">
15
+ <td colspan="3">
16
+ <?php
17
+ // group name.
18
  ob_start();
19
+ ?>
20
+ <input type="text" name="advads-groups[<?php echo $group->id; ?>][name]" value="<?php echo $group->name; ?>"/>
21
+ <?php
22
  $option_content = ob_get_clean();
23
+
24
+ Advanced_Ads_Admin_Options::render_option(
25
+ 'group-name static',
26
  __( 'Name', 'advanced-ads' ),
27
+ $option_content
28
+ );
29
+
30
+ // group type.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ob_start();
32
+ ?>
33
+ <div class="advads-ad-group-type">
34
+ <?php
35
+ foreach ( $this->types as $_type_key => $_type ) :
36
+ ?>
37
+ <label title="<?php echo $_type['description']; ?>"><input type="radio" name="advads-groups[
38
+ <?php
39
+ echo $group->id;
40
+ ?>
41
+ ][type]" value="<?php echo $_type_key; ?>" <?php checked( $group->type, $_type_key ); ?>/>
42
+ <?php
43
+ echo $_type['title'];
44
+ ?>
45
+ </label>
46
+ <?php
47
+ endforeach;
48
+ ?>
49
+ </div>
50
+ <?php
51
  $option_content = ob_get_clean();
52
+
53
+ Advanced_Ads_Admin_Options::render_option(
54
+ 'group-type static',
55
+ esc_attr__( 'Type', 'advanced-ads' ),
56
+ $option_content
57
+ );
58
+
59
+ // group number.
 
60
  ob_start();
61
+ ?>
62
+ <select name="advads-groups[<?php echo absint( $group->id ); ?>][ad_count]">
63
+ <?php
64
+ $max = ( count( $ad_form_rows ) >= 10 ) ? count( $ad_form_rows ) + 2 : 10;
65
+ for ( $i = 1; $i <= $max; $i++ ) :
66
+ ?>
67
+ <option <?php selected( $group->ad_count, $i ); ?>><?php echo $i; ?></option>
68
+ <?php
69
+ endfor;
70
+ ?>
71
+ <option <?php selected( $group->ad_count, 'all' ); ?> value="all"><?php echo esc_attr_x( 'all', 'option to display all ads in an ad groups', 'advanced-ads' ); ?></option>
72
+ </select>
73
+ <?php
74
+ $option_content = ob_get_clean();
75
+
76
+ Advanced_Ads_Admin_Options::render_option(
77
+ 'group-number advads-group-type-default advads-group-type-ordered',
78
+ esc_attr__( 'Visible ads', 'advanced-ads' ),
79
+ $option_content,
80
+ esc_attr__( 'Number of ads that are visible at the same time', 'advanced-ads' )
81
+ );
82
+
83
+ do_action( 'advanced-ads-group-form-options', $group );
84
+
85
+ ob_start();
86
+ require ADVADS_BASE_PATH . 'admin/views/ad-group-list-ads.php';
87
+ $option_content = ob_get_clean();
88
+ Advanced_Ads_Admin_Options::render_option(
89
+ 'group-ads static',
90
+ esc_attr__( 'Ads', 'advanced-ads' ),
91
+ $option_content
92
+ );
93
 
94
+ ?>
95
+ </td>
96
+ </tr>
admin/views/ad-group-list-header.php CHANGED
@@ -1,7 +1,19 @@
1
- <thead>
2
- <tr>
3
- <th><?php _e( 'Ad Group', 'advanced-ads' ); ?></th>
4
- <th><?php _e( 'Details', 'advanced-ads' ); ?></th>
5
- <th><?php _e( 'Ads', 'advanced-ads' ); ?></th>
6
- </tr>
7
- </thead>
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for <thead> of group list
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ *
11
+ */
12
+
13
+ ?><thead>
14
+ <tr>
15
+ <th><?php esc_attr_e( 'Ad Group', 'advanced-ads' ); ?></th>
16
+ <th><?php esc_attr_e( 'Details', 'advanced-ads' ); ?></th>
17
+ <th><?php esc_attr_e( 'Ads', 'advanced-ads' ); ?></th>
18
+ </tr>
19
+ </thead>
admin/views/ad-group-list-row.php CHANGED
@@ -1,24 +1,44 @@
1
- <tr class="advads-group-row">
2
- <td>
3
- <input type="hidden" class="advads-group-id" name="advads-groups[<?php echo $group->id; ?>][id]" value="<?php echo $group->id; ?>"/>
4
- <strong><a class="row-title" href="#"><?php echo $group->name; ?></a></strong>
5
- <p class="description"><?php echo $group->description; ?></p>
6
- <?php echo $this->render_action_links( $group ); ?>
7
- <div class="hidden advads-usage">
8
- <label><?php _e( 'shortcode', 'advanced-ads' ); ?>
9
- <code><input type="text" onclick="this.select();" style="width: 200px;" value='[the_ad_group id="<?php echo $group->id; ?>"]'/></code>
10
- </label><br/>
11
- <label><?php _e( 'template', 'advanced-ads' ); ?>
12
- <code><input type="text" onclick="this.select();" value="the_ad_group(<?php echo $group->id; ?>);"/></code>
13
- </label>
14
- <p><?php printf( __( 'Learn more about using groups in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/ad-groups/#utm_source=advanced-ads&utm_medium=link&utm_campaign=groups' ); ?></p>
15
- </div>
16
- </td>
17
- <td>
18
- <ul><?php $_type = isset($this->types[$group->type]['title']) ? $this->types[$group->type]['title'] : 'default'; ?>
19
- <li><strong><?php printf( __( 'Type: %s', 'advanced-ads' ), $_type ); ?></strong></li>
20
- <li><?php printf( __( 'ID: %s', 'advanced-ads' ), $group->id ); ?></li>
21
- </ul>
22
- </td>
23
- <td class="advads-ad-group-list-ads"><?php $this->render_ads_list( $group ); ?></td>
24
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for a single row in the group list
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ *
11
+ */
12
+
13
+ ?><tr class="advads-group-row">
14
+ <td>
15
+ <input type="hidden" class="advads-group-id" name="advads-groups[<?php echo $group->id; ?>][id]" value="<?php echo absint( $group->id ); ?>"/>
16
+ <strong><a class="row-title" href="#"><?php echo $group->name; ?></a></strong>
17
+ <p class="description"><?php echo $group->description; ?></p>
18
+ <?php echo $this->render_action_links( $group ); ?>
19
+ <div class="hidden advads-usage">
20
+ <label><?php esc_attr_e( 'shortcode', 'advanced-ads' ); ?>
21
+ <code><input type="text" onclick="this.select();" style="width: 200px;" value='[the_ad_group id="<?php echo absint( $group->id ); ?>"]'/></code>
22
+ </label><br/>
23
+ <label><?php esc_attr_e( 'template', 'advanced-ads' ); ?>
24
+ <code><input type="text" onclick="this.select();" value="the_ad_group(<?php echo absint( $group->id ); ?>);"/></code>
25
+ </label>
26
+ <p><?php printf( __( 'Learn more about using groups in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/ad-groups/#utm_source=advanced-ads&utm_medium=link&utm_campaign=groups' ); ?></p>
27
+ </div>
28
+ </td>
29
+ <td>
30
+ <ul><?php $_type = isset( $this->types[ $group->type ]['title'] ) ? $this->types[ $group->type ]['title'] : 'default'; ?>
31
+ <li><strong><?php
32
+ /*
33
+ * translators: %s is the name of a group type
34
+ */
35
+ printf(esc_attr__( 'Type: %s', 'advanced-ads' ), $_type ); ?></strong></li>
36
+ <li><?php
37
+ /*
38
+ * translators: %s is the ID of an ad group
39
+ */
40
+ printf(esc_attr__( 'ID: %s', 'advanced-ads' ), $group->id ); ?></li>
41
+ </ul>
42
+ </td>
43
+ <td class="advads-ad-group-list-ads"><?php $this->render_ads_list( $group ); ?></td>
44
+ </tr>
admin/views/ad-group.php CHANGED
@@ -1,102 +1,97 @@
1
  <?php
2
  /**
3
- * page lists ad groups
 
 
 
 
 
 
4
  *
5
- * @since 1.0.0
6
- * @see /wp-admin/edit-tags.php (for a good example in WP core)
7
  */
 
8
  $ad_groups_list = new Advanced_Ads_Groups_List();
9
 
10
- // create new group
11
- if ( isset($_REQUEST['advads-group-add-nonce']) ){
12
  $create_result = $ad_groups_list->create_group();
13
- // display error message
14
- if ( is_wp_error( $create_result ) ){
15
  $error_string = $create_result->get_error_message();
16
  echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
17
  } else {
18
- echo '<div id="message" class="updated"><p>' . __( 'Ad Group successfully created', 'advanced-ads' ) . '</p></div>';
19
  }
20
  }
21
- // save updated groups
22
- if ( isset($_REQUEST['advads-group-update-nonce']) ){
23
  $udpate_result = $ad_groups_list->update_groups();
24
- // display error message
25
- if ( is_wp_error( $udpate_result ) ){
26
  $error_string = $udpate_result->get_error_message();
27
  echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
28
  } else {
29
- echo '<div id="message" class="updated"><p>' . __( 'Ad Groups successfully updated', 'advanced-ads' ) . '</p></div>';
30
  }
31
  }
32
 
33
- /*$messages[$taxonomy] = array(
34
- 0 => '', // Unused. Messages start at index 1.
35
- 1 => __( 'Ad Group added.', 'advanced-ads' ),
36
- 2 => __( 'Ad Group deleted.', 'advanced-ads' ),
37
- 3 => __( 'Ad Group updated.', 'advanced-ads' ),
38
- 4 => __( 'Ad Group not added.', 'advanced-ads' ),
39
- 5 => __( 'Ad Group not updated.', 'advanced-ads' ),
40
- 6 => __( 'Ad Group deleted.', 'advanced-ads' )
41
- );
42
 
43
- $message = false;
44
- if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) || isset($forced_message) ) {
45
- if ( isset($msg) && isset($messages[$taxonomy][$msg]) ){
46
- $message = $messages[$taxonomy][$msg];
47
- } elseif ( isset($messages[$taxonomy][$forced_message]) ) {
48
- $message = $messages[$taxonomy][$forced_message];
49
  }
50
- }*/
51
- ?>
52
-
53
- <div class="wrap nosubsub">
54
- <h1 class="wp-heading-inline"><?php
55
- echo esc_html( $title );
56
- ?></h1><?php
57
-
58
- if ( ! empty($_REQUEST['s']) ) {
59
- printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;', 'advanced-ads' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
60
- } else {
61
- echo ' <a href="' . Advanced_Ads_Groups_List::group_page_url( array('action' => 'edit') ) . '" id="advads-new-ad-group-link" class="add-new-h2">' . $tax->labels->add_new_item . '</a>';
62
- }
63
- ?><form id="advads-new-group-form" action="" method="post" style="display:none;">
64
- <?php wp_nonce_field( 'add-advads-groups', 'advads-group-add-nonce' ); ?>
65
- <input type="text" name="advads-group-name" placeholder="<?php _e( 'Group title', 'advanced-ads' ); ?>"/>
66
- <input class="button button-primary" type="submit" value="<?php _e( 'save', 'advanced-ads' ); ?>"/>
67
- </form>
68
- <p><?php _e( 'Ad Groups are a very flexible method to bundle ads. You can use them to display random ads in the frontend or run split tests, but also just for informational purposes. Not only can an Ad Groups have multiple ads, but an ad can belong to multiple ad groups.', 'advanced-ads' ); ?></p>
69
- <p><?php printf(__( 'Find more information about ad groups in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/ad-groups/#utm_source=advanced-ads&utm_medium=link&utm_campaign=groups' ); ?></p>
70
- <?php if ( isset($message) ) : ?>
71
- <div id="message" class="updated"><p><?php echo $message; ?></p></div>
72
- <?php
73
- $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array('message'), $_SERVER['REQUEST_URI'] ) );
74
- endif;
75
  ?>
76
- <div id="ajax-response"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- <div id="col-container">
79
- <div class="col-wrap">
80
- <div class="tablenav top">
81
- <form class="search-form" action="" method="get">
82
- <!--input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /-->
83
- <input type="hidden" name="page" value="advanced-ads-groups" />
84
- <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </form>
86
  </div>
87
- <div id="advads-ad-group-list">
88
- <form action="" method="post">
89
- <?php wp_nonce_field( 'update-advads-groups', 'advads-group-update-nonce' ); ?>
90
- <table class="wp-list-table widefat fixed adgroups">
91
- <?php $ad_groups_list->render_header(); ?>
92
- <?php $ad_groups_list->render_rows(); ?>
93
- </table>
94
- <input type="hidden" name="advads-last-edited-group" id="advads-last-edited-group" value="0"/>
95
- <div class="tablenav bottom">
96
- <?php submit_button( __( 'Update Groups', 'advanced-ads' ) ); ?>
97
- </div>
98
- </form>
99
- </div>
100
- </div>
101
- </div><!-- /col-container -->
102
- </div><!-- /wrap -->
1
  <?php
2
  /**
3
+ * Renders the ad group page in WP Admin
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
  *
 
 
11
  */
12
+
13
  $ad_groups_list = new Advanced_Ads_Groups_List();
14
 
15
+ // create new group.
16
+ if ( isset( $_REQUEST['advads-group-add-nonce'] ) ) {
17
  $create_result = $ad_groups_list->create_group();
18
+ // display error message.
19
+ if ( is_wp_error( $create_result ) ) {
20
  $error_string = $create_result->get_error_message();
21
  echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
22
  } else {
23
+ echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Group successfully created', 'advanced-ads' ) . '</p></div>';
24
  }
25
  }
26
+ // save updated groups.
27
+ if ( isset( $_REQUEST['advads-group-update-nonce'] ) ) {
28
  $udpate_result = $ad_groups_list->update_groups();
29
+ // display error message.
30
+ if ( is_wp_error( $udpate_result ) ) {
31
  $error_string = $udpate_result->get_error_message();
32
  echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
33
  } else {
34
+ echo '<div id="message" class="updated"><p>' . esc_attr__( 'Ad Groups successfully updated', 'advanced-ads' ) . '</p></div>';
35
  }
36
  }
37
 
38
+ ?><div class="wrap nosubsub">
39
+ <h1 class="wp-heading-inline">
40
+ <?php
41
+ echo esc_html( $title );
42
+ ?>
43
+ </h1>
44
+ <?php
 
 
45
 
46
+ if ( ! empty( $_REQUEST['s'] ) ) {
47
+ printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;', 'advanced-ads' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
48
+ } else {
49
+ echo ' <a href="' . Advanced_Ads_Groups_List::group_page_url( array( 'action' => 'edit' ) ) . '" id="advads-new-ad-group-link" class="add-new-h2">' . $tax->labels->add_new_item . '</a>';
 
 
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ?>
52
+ <form id="advads-new-group-form" action="" method="post" style="display:none;">
53
+ <?php wp_nonce_field( 'add-advads-groups', 'advads-group-add-nonce' ); ?>
54
+ <input type="text" name="advads-group-name" placeholder="<?php esc_attr_e( 'Group title', 'advanced-ads' ); ?>"/>
55
+ <input class="button button-primary" type="submit" value="<?php esc_attr_e( 'save', 'advanced-ads' ); ?>"/>
56
+ </form>
57
+ <p><?php esc_attr_e( 'Ad Groups are a very flexible method to bundle ads. You can use them to display random ads in the frontend or run split tests, but also just for informational purposes. Not only can an Ad Groups have multiple ads, but an ad can belong to multiple ad groups.', 'advanced-ads' ); ?></p>
58
+ <p><?php
59
+
60
+ /*
61
+ * translators: %s is a URL
62
+ */
63
+ printf( __( 'Find more information about ad groups in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/ad-groups/#utm_source=advanced-ads&utm_medium=link&utm_campaign=groups' );
64
+ ?></p>
65
+ <?php if ( isset( $message ) ) : ?>
66
+ <div id="message" class="updated"><p><?php echo $message; ?></p></div>
67
+ <?php
68
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array( 'message' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
69
+ endif;
70
+ ?>
71
+ <div id="ajax-response"></div>
72
 
73
+ <div id="col-container">
74
+ <div class="col-wrap">
75
+ <div class="tablenav top">
76
+ <form class="search-form" action="" method="get">
77
+ <!--input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /-->
78
+ <input type="hidden" name="page" value="advanced-ads-groups" />
79
+ <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
80
+ </form>
81
+ </div>
82
+ <div id="advads-ad-group-list">
83
+ <form action="" method="post">
84
+ <?php wp_nonce_field( 'update-advads-groups', 'advads-group-update-nonce' ); ?>
85
+ <table class="wp-list-table widefat fixed adgroups">
86
+ <?php $ad_groups_list->render_header(); ?>
87
+ <?php $ad_groups_list->render_rows(); ?>
88
+ </table>
89
+ <input type="hidden" name="advads-last-edited-group" id="advads-last-edited-group" value="0"/>
90
+ <div class="tablenav bottom">
91
+ <?php submit_button( __( 'Update Groups', 'advanced-ads' ) ); ?>
92
+ </div>
93
  </form>
94
  </div>
95
+ </div>
96
+ </div>
97
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/views/ad-info-after-textarea.php CHANGED
@@ -1,15 +1,35 @@
1
  <?php
2
- if ( defined ( 'WP_DEBUG' ) && WP_DEBUG &&
 
 
 
 
 
 
 
 
 
 
 
 
3
  ( $error = Advanced_Ads_Admin_Ad_Type::check_ad_dom_is_not_valid( $ad ) ) ) : ?>
4
  <p class="advads-error-message">
5
- <?php _e( 'The code of this ad might not work properly with the <em>Content</em> placement.', 'advanced-ads' );
6
- ?>&nbsp;<?php printf(__( 'Reach out to <a href="%s">support</a> to get help.', 'advanced-ads' ), admin_url('admin.php?page=advanced-ads-settings#top#support') );
7
- if ( true === WP_DEBUG ) : ?>
 
 
 
 
 
 
 
 
8
  <span style="white-space:pre-wrap"><?php echo $error; ?></span>
9
- <?php endif;
 
10
  ?>
11
  </p>
12
  <?php endif;
13
 
14
  do_action( 'advanced-ads-ad-params-below-textarea', $ad );
15
- ?>
1
  <?php
2
+ /**
3
+ * Render additional information below the text area on the ad edit page
4
+ * currently "plain text" and "rich content" ad types
5
+ *
6
+ * @package Advanced_Ads_Admin
7
+ * @author Thomas Maier <thomas.maier@webgilde.com>
8
+ * @license GPL-2.0+
9
+ * @link https://wpadvancedads.com
10
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
11
+ *
12
+ */
13
+
14
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG &&
15
  ( $error = Advanced_Ads_Admin_Ad_Type::check_ad_dom_is_not_valid( $ad ) ) ) : ?>
16
  <p class="advads-error-message">
17
+ <?php
18
+ _e( 'The code of this ad might not work properly with the <em>Content</em> placement.', 'advanced-ads' );
19
+ ?>
20
+ &nbsp;
21
+ <?php
22
+ /*
23
+ * translators: %s is a URL
24
+ */
25
+ printf( __( 'Reach out to <a href="%s">support</a> to get help.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#support' ) );
26
+ if ( true === WP_DEBUG ) :
27
+ ?>
28
  <span style="white-space:pre-wrap"><?php echo $error; ?></span>
29
+ <?php
30
+ endif;
31
  ?>
32
  </p>
33
  <?php endif;
34
 
35
  do_action( 'advanced-ads-ad-params-below-textarea', $ad );
 
admin/views/ad-info-bottom.php CHANGED
@@ -1,12 +1,28 @@
1
- <div id="advads-wizard-controls" class="hidden">
2
- <button type="button" id="advads-wizard-controls-prev" class="button button-secondary button-large"><span class="dashicons dashicons-controls-back"></span>&nbsp;<?php _ex( 'previous', 'wizard navigation', 'advanced-ads' ); ?></button>
3
- <input type="submit" id="advads-wizard-controls-save" class="button button-primary button-large" value="<?php
4
- // display different message depending on a new ad (filter = raw) or existing one
5
- echo ( isset( $post->filter ) && 'raw' === $post->filter ) ? _x( 'next', 'wizard navigation', 'advanced-ads' ) : _x( 'save', 'wizard navigation', 'advanced-ads' ); ?>"/>
6
- <button type="button" id="advads-wizard-controls-next" class="button button-primary button-large"><?php _ex( 'next', 'wizard navigation', 'advanced-ads' ); ?>&nbsp;<span class="dashicons dashicons-controls-forward"></span></button>
7
- <p><a href="javascript:void(0)" class="advads-stop-wizard"><?php _e( 'Stop Wizard and show all options', 'advanced-ads' ); ?></a></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </div>
9
- <?php // start the wizard if it was never closed
10
- if( $this->start_wizard_automatically() ) : ?>
 
 
11
  <script>jQuery( document ).ready(function ($) { advads_wizard.start() });</script>
12
- <?php endif;
 
1
+ <?php
2
+ /**
3
+ * Render additional content below the ad edit page.
4
+ *
5
+ * @package Advanced_Ads_Admin
6
+ * @author Thomas Maier <thomas.maier@webgilde.com>
7
+ * @license GPL-2.0+
8
+ * @link https://wpadvancedads.com
9
+ * @copyright since 2013 Thomas Maier, webgilde GmbH
10
+ *
11
+ */
12
+
13
+ ?><div id="advads-wizard-controls" class="hidden">
14
+ <button type="button" id="advads-wizard-controls-prev" class="button button-secondary button-large"><span class="dashicons dashicons-controls-back"></span>&nbsp;<?php echo esc_attr_x( 'previous', 'wizard navigation', 'advanced-ads' ); ?></button>
15
+ <input type="submit" id="advads-wizard-controls-save" class="button button-primary button-large" value="<?php
16
+ // display different message depending on a new ad (filter = raw) or existing one.
17
+ echo ( isset( $post->filter ) && 'raw' === $post->filter ) ? esc_attr_x( 'next', 'wizard navigation', 'advanced-ads' ) : esc_attr_x( 'save', 'wizard navigation', 'advanced-ads' );
18
+ ?>"/>
19
+ <button type="button" id="advads-wizard-controls-next" class="button button-primary button-large"><?php echo esc_attr_x( 'next', 'wizard navigation', 'advanced-ads' ); ?>&nbsp;<span class="dashicons dashicons-controls-forward"></span></button>
20
+ <p><a href="javascript:void(0)" class="advads-stop-wizard"><?php esc_attr_e( 'Stop Wizard and show all options', 'advanced-ads' ); ?></a></p>
21
  </div>
22
+ <?php
23
+ // start the wizard if it was never closed.
24
+ if ( $this->start_wizard_automatically() ) :
25
+ ?>
26
  <script>jQuery( document ).ready(function ($) { advads_wizard.start() });</script>
27
+ <?php
28
+ endif;
admin/views/ad-info-top.php CHANGED
@@ -1,28 +1,38 @@
1
  <?php // display ad wizard controls
2
- ?><button type="button" id="advads-start-wizard" class="dashicons-before dashicons-controls-play page-title-action"><?php _e('Start Wizard', 'advanced-ads'); ?></button>
3
- <button type="button" id="advads-stop-wizard" class="advads-stop-wizard dashicons-before dashicons-no page-title-action hidden"><?php _e('Stop Wizard', 'advanced-ads'); ?></button>
4
  <script>
5
- // move wizard button to head
6
- jQuery('#advads-start-wizard').appendTo('h1');
7
- jQuery('.advads-stop-wizard').insertAfter('h1');
8
  </script>
9
- <?php // show wizard welcome message
10
- if( $this->show_wizard_welcome() || ! Advanced_Ads::get_number_of_ads() ) : ?>
 
 
11
  <div class="advads-ad-metabox postbox">
12
- <?php if( ! Advanced_Ads::get_number_of_ads() ){
13
- include ADVADS_BASE_PATH . 'admin/views/ad-list-no-ads.php';
14
- } if( $this->show_wizard_welcome() ) : ?>
 
 
15
  <div id="advads-wizard-welcome">
16
- <br/><?php /*
17
- <h2><?php _e( 'Welcome to the Wizard', 'advanced-ads' ); ?></h2>
18
- <p><?php _e( 'The Wizard helps you to quickly create and publish an ad. Therefore, only the most common options are visible.', 'advanced-ads' ); ?></p>*/
19
- ?><a class="advads-stop-wizard dashicons-before dashicons-no" style="line-height: 1.6em; cursor: pointer;"><?php _e('Stop Wizard and show all options', 'advanced-ads'); ?></a>
 
 
 
20
  </div>
21
  <script>
22
- // move wizard button to head
23
- jQuery('#advads-hide-wizard-welcome').click( function(){ jQuery( '#advads-wizard-welcome' ).remove(); });
24
- jQuery('#advads-end-wizard').insertBefore('h1');
25
  </script>
26
- <?php endif;
27
- ?></div><?php
28
- endif;
 
 
 
1
  <?php // display ad wizard controls
2
+ ?><button type="button" id="advads-start-wizard" class="dashicons-before dashicons-controls-play page-title-action"><?php _e( 'Start Wizard', 'advanced-ads' ); ?></button>
3
+ <button type="button" id="advads-stop-wizard" class="advads-stop-wizard dashicons-before dashicons-no page-title-action hidden"><?php _e( 'Stop Wizard', 'advanced-ads' ); ?></button>
4
  <script>
5
+ // move wizard button to head
6
+ jQuery('#advads-start-wizard').appendTo('h1');
7
+ jQuery('.advads-stop-wizard').insertAfter('h1');
8
  </script>
9
+ <?php
10
+ // show wizard welcome message
11
+ if ( $this->show_wizard_welcome() || ! Advanced_Ads::get_number_of_ads() ) :
12
+ ?>
13
  <div class="advads-ad-metabox postbox">
14
+ <?php
15
+ if ( ! Advanced_Ads::get_number_of_ads() ) {
16
+ include ADVADS_BASE_PATH . 'admin/views/ad-list-no-ads.php';
17
+ } if ( $this->show_wizard_welcome() ) :
18
+ ?>
19
  <div id="advads-wizard-welcome">
20
+ <br/>
21
+ <?php
22
+ /*
23
+ <h2><?php _e( 'Welcome to the Wizard', 'advanced-ads' ); ?></h2>
24
+ <p><?php _e( 'The Wizard helps you to quickly create and publish an ad. Therefore, only the most common options are visible.', 'advanced-ads' ); ?></p>*/
25
+ ?>
26
+ <a class="advads-stop-wizard dashicons-before dashicons-no" style="line-height: 1.6em; cursor: pointer;"><?php _e( 'Stop Wizard and show all options', 'advanced-ads' ); ?></a>
27
  </div>
28
  <script>
29
+ // move wizard button to head
30
+ jQuery('#advads-hide-wizard-welcome').click( function(){ jQuery( '#advads-wizard-welcome' ).remove(); });
31
+ jQuery('#advads-end-wizard').insertBefore('h1');
32
  </script>
33
+ <?php
34
+ endif;
35
+ ?>
36
+ </div>
37
+ <?php
38
+ endif;
admin/views/ad-info.php CHANGED
@@ -1,19 +1,25 @@
1
  <div id="advads-ad-info">
2
- <span><?php printf( __( 'Ad Id: %s', 'advanced-ads' ), "<strong>$post->ID</strong>" ); ?></span>
3
- <label><span><?php _e( 'shortcode', 'advanced-ads' ); ?></span>
4
  <pre><input type="text" onclick="this.select();" value='[the_ad id="<?php echo $post->ID; ?>"]' readonly="readonly"/></pre></label>
5
- <label><span><?php _e( 'theme function', 'advanced-ads' ); ?></span>
6
  <pre><input type="text" onclick="this.select();" value="&lt;?php the_ad(<?php echo $post->ID; ?>); ?&gt;" readonly="readonly"/></pre></label>
7
- <span><?php printf( __( 'Find more display options in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/display-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit' ); ?></span>
8
  </div>
9
  <div id="advads-ad-description">
10
- <?php if ( ! empty($ad->description) ) : ?>
11
- <p title="<?php _e( 'click to change', 'advanced-ads' ); ?>"
12
- onclick="advads_toggle('#advads-ad-description textarea'); advads_toggle('#advads-ad-description p')"><?php
13
- echo nl2br( $ad->description ); ?></p>
14
- <?php else : ?>
15
- <button type="button" onclick="advads_toggle('#advads-ad-description textarea'); advads_toggle('#advads-ad-description button')"><?php _e( 'Add a description', 'advanced-ads' ); ?></button>
16
- <?php endif; ?>
17
- <textarea name="advanced_ad[description]" placeholder="<?php
18
- _e( 'Internal description or your own notes about this ad.', 'advanced-ads' ); ?>"><?php echo $ad->description; ?></textarea>
19
- </div>
 
 
 
 
 
 
1
  <div id="advads-ad-info">
2
+ <span><?php printf( __( 'Ad Id: %s', 'advanced-ads' ), "<strong>$post->ID</strong>" ); ?></span>
3
+ <label><span><?php _e( 'shortcode', 'advanced-ads' ); ?></span>
4
  <pre><input type="text" onclick="this.select();" value='[the_ad id="<?php echo $post->ID; ?>"]' readonly="readonly"/></pre></label>
5
+ <label><span><?php _e( 'theme function', 'advanced-ads' ); ?></span>
6
  <pre><input type="text" onclick="this.select();" value="&lt;?php the_ad(<?php echo $post->ID; ?>); ?&gt;" readonly="readonly"/></pre></label>
7
+ <span><?php printf( __( 'Find more display options in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/display-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit' ); ?></span>
8
  </div>
9
  <div id="advads-ad-description">
10
+ <?php if ( ! empty( $ad->description ) ) : ?>
11
+ <p title="<?php _e( 'click to change', 'advanced-ads' ); ?>"
12
+ onclick="advads_toggle('#advads-ad-description textarea'); advads_toggle('#advads-ad-description p')">
13
+ <?php
14
+ echo nl2br( $ad->description );
15
+ ?>
16
+ </p>
17
+ <?php else : ?>
18
+ <button type="button" onclick="advads_toggle('#advads-ad-description textarea'); advads_toggle('#advads-ad-description button')"><?php _e( 'Add a description', 'advanced-ads' ); ?></button>
19
+ <?php endif; ?>
20
+ <textarea name="advanced_ad[description]" placeholder="
21
+ <?php
22
+ _e( 'Internal description or your own notes about this ad.', 'advanced-ads' );
23
+ ?>
24
+ "><?php echo $ad->description; ?></textarea>
25
+ </div>
admin/views/ad-list-details-column.php CHANGED
@@ -1,16 +1,20 @@
1
  <fieldset class="inline-edit-col-left">
2
- <div class="inline-edit-col">
3
- <?php if ( ! empty( $type ) ) :
4
  // display image, if this is the image type
5
- if( 'image' === $ad->type ) {
6
- $id = ( isset( $ad->output['image_id'] ) ) ? $ad->output['image_id'] : '';
7
- $types[$ad->type]->create_image_icon( $id );
8
  }
9
  ?><p><strong class="advads-ad-type"><?php echo $type; ?></strong></p>
10
- <?php endif;
11
- if ( ! empty( $size) ) : ?>
12
- <p class="advads-ad-size"><?php echo $size; ?></p><?php
13
  endif;
14
- do_action( 'advanced-ads-ad-list-details-column-after', $ad ); ?>
 
 
 
 
 
 
15
  </div>
16
- </fieldset>
1
  <fieldset class="inline-edit-col-left">
2
+ <div class="inline-edit-col">
3
+ <?php if ( ! empty( $type ) ) :
4
  // display image, if this is the image type
5
+ if ( 'image' === $ad->type ) {
6
+ $id = ( isset( $ad->output['image_id'] ) ) ? $ad->output['image_id'] : '';
7
+ $types[ $ad->type ]->create_image_icon( $id );
8
  }
9
  ?><p><strong class="advads-ad-type"><?php echo $type; ?></strong></p>
10
+ <?php
 
 
11
  endif;
12
+ if ( ! empty( $size ) ) :
13
+ ?>
14
+ <p class="advads-ad-size"><?php echo $size; ?></p>
15
+ <?php
16
+ endif;
17
+ do_action( 'advanced-ads-ad-list-details-column-after', $ad );
18
+ ?>
19
  </div>
20
+ </fieldset>
admin/views/ad-list-filters.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  $ad_list_filters = Advanced_Ads_Ad_List_Filters::get_instance();
3
- $all_filters = $ad_list_filters->get_all_filters();
4
 
5
- $ad_type = isset( $_REQUEST['adtype'] ) ? $_REQUEST['adtype'] : '';
6
- $ad_size = isset( $_REQUEST['adsize'] ) ? $_REQUEST['adsize'] : '';
7
- $ad_date = isset( $_REQUEST['addate'] ) ? $_REQUEST['addate'] : '';
8
  $ad_group = isset( $_REQUEST['adgroup'] ) ? $_REQUEST['adgroup'] : '';
9
 
10
  // hide the filter button. Can not filter correctly with "trashed" posts.
@@ -13,35 +13,35 @@ if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
13
  }
14
 
15
  ?>
16
- <?php if ( !empty( $all_filters['all_types'] ) ) : ?>
17
  <select id="advads-filter-type" name="adtype">
18
  <option value="">- <?php _e( 'all ad types', 'advanced-ads' ); ?> -</option>
19
- <?php foreach( $all_filters['all_types'] as $key => $value ) : ?>
20
- <option <?php selected( $ad_type, $key ) ?> value="<?php echo esc_attr( $key ) ?>"><?php echo $value ?></option>
21
  <?php endforeach; ?>
22
  </select>
23
  <?php endif; ?>
24
- <?php if ( !empty( $all_filters['all_sizes'] ) ) : ?>
25
  <select id="advads-filter-size" name="adsize">
26
  <option value="">- <?php _e( 'all ad sizes', 'advanced-ads' ); ?> -</option>
27
- <?php foreach( $all_filters['all_sizes'] as $key => $value ) : ?>
28
- <option <?php selected( $ad_size, $key ) ?> value="<?php echo esc_attr( $key ) ?>"><?php echo $value ?></option>
29
  <?php endforeach; ?>
30
  </select>
31
  <?php endif; ?>
32
- <?php if ( !empty( $all_filters['all_dates'] ) ) : ?>
33
  <select id="advads-filter-date" name="addate">
34
  <option value="">- <?php _e( 'all ad dates', 'advanced-ads' ); ?> -</option>
35
  <?php foreach ( $all_filters['all_dates'] as $key => $value ) : ?>
36
- <option <?php selected( $ad_date, $key ) ?> value="<?php echo esc_attr( $key ) ?>"><?php echo $value ?></option>
37
  <?php endforeach; ?>
38
  </select>
39
  <?php endif; ?>
40
- <?php if ( !empty( $all_filters['all_groups'] ) ) : ?>
41
  <select id="advads-filter-group" name="adgroup">
42
  <option value="">- <?php _e( 'all ad groups', 'advanced-ads' ); ?> -</option>
43
  <?php foreach ( $all_filters['all_groups'] as $key => $value ) : ?>
44
- <option <?php selected( $ad_group, $key ) ?> value="<?php echo esc_attr( $key ) ?>"><?php echo $value ?></option>
45
  <?php endforeach; ?>
46
  </select>
47
- <?php endif; ?>
1
  <?php
2
  $ad_list_filters = Advanced_Ads_Ad_List_Filters::get_instance();
3
+ $all_filters = $ad_list_filters->get_all_filters();
4
 
5
+ $ad_type = isset( $_REQUEST['adtype'] ) ? $_REQUEST['adtype'] : '';
6
+ $ad_size = isset( $_REQUEST['adsize'] ) ? $_REQUEST['adsize'] : '';
7
+ $ad_date = isset( $_REQUEST['addate'] ) ? $_REQUEST['addate'] : '';
8
  $ad_group = isset( $_REQUEST['adgroup'] ) ? $_REQUEST['adgroup'] : '';
9
 
10
  // hide the filter button. Can not filter correctly with "trashed" posts.
13
  }
14
 
15
  ?>
16
+ <?php if ( ! empty( $all_filters['all_types'] ) ) : ?>
17
  <select id="advads-filter-type" name="adtype">
18
  <option value="">- <?php _e( 'all ad types', 'advanced-ads' ); ?> -</option>
19
+ <?php foreach ( $all_filters['all_types'] as $key => $value ) : ?>
20
+ <option <?php selected( $ad_type, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo $value; ?></option>
21
  <?php endforeach; ?>
22
  </select>
23
  <?php endif; ?>
24
+ <?php if ( ! empty( $all_filters['all_sizes'] ) ) : ?>
25
  <select id="advads-filter-size" name="adsize">
26
  <option value="">- <?php _e( 'all ad sizes', 'advanced-ads' ); ?> -</option>
27
+ <?php foreach ( $all_filters['all_sizes'] as $key => $value ) : ?>
28
+ <option <?php selected( $ad_size, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo $value; ?></option>
29
  <?php endforeach; ?>
30
  </select>
31
  <?php endif; ?>
32
+ <?php if ( ! empty( $all_filters['all_dates'] ) ) : ?>
33
  <select id="advads-filter-date" name="addate">
34
  <option value="">- <?php _e( 'all ad dates', 'advanced-ads' ); ?> -</option>
35
  <?php foreach ( $all_filters['all_dates'] as $key => $value ) : ?>
36
+ <option <?php selected( $ad_date, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo $value; ?></option>
37
  <?php endforeach; ?>
38
  </select>
39
  <?php endif; ?>
40
+ <?php if ( ! empty( $all_filters['all_groups'] ) ) : ?>
41
  <select id="advads-filter-group" name="adgroup">
42
  <option value="">- <?php _e( 'all ad groups', 'advanced-ads' ); ?> -</option>
43
  <?php foreach ( $all_filters['all_groups'] as $key => $value ) : ?>
44
+ <option <?php selected( $ad_group, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo $value; ?></option>
45
  <?php endforeach; ?>
46
  </select>
47
+ <?php endif; ?>
admin/views/ad-list-no-ads.php CHANGED
@@ -1,8 +1,8 @@
1
  <div id="advads-first-ad-links">
2
- <button type="button" id="advads-first-ad-video-link" class="button-primary"><span class="dashicons dashicons-format-video" style="line-height: inherit"></span>&nbsp;<?php _e( 'Watch the “First Ad” Tutorial (Video)', 'advanced-ads'); ?></button>
3
  </div>
4
  <script>
5
- jQuery('#advads-first-ad-video-link').click(function(){
6
  jQuery( '<br class="clear"/><br/><iframe width="420" height="315" src="https://www.youtube-nocookie.com/embed/A5jKAzqyWwA?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>' ).appendTo('#advads-first-ad-links');
7
- });
8
- </script>
1
  <div id="advads-first-ad-links">
2
+ <button type="button" id="advads-first-ad-video-link" class="button-primary"><span class="dashicons dashicons-format-video" style="line-height: inherit"></span>&nbsp;<?php _e( 'Watch the “First Ad” Tutorial (Video)', 'advanced-ads' ); ?></button>
3
  </div>
4
  <script>
5
+ jQuery('#advads-first-ad-video-link').click(function(){
6
  jQuery( '<br class="clear"/><br/><iframe width="420" height="315" src="https://www.youtube-nocookie.com/embed/A5jKAzqyWwA?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>' ).appendTo('#advads-first-ad-links');
7
+ });
8
+ </script>
admin/views/ad-list-shortcode-column.php ADDED
@@ -0,0 +1 @@
 
1
+ <input class="advads-ad-injection-shortcode" onclick="this.select();" value="[the_ad id=&quot;<?php echo $ad->id; ?>&quot;]"/>
admin/views/ad-list-timing-column.php CHANGED
@@ -3,33 +3,33 @@
3
  <?php if ( $post_future ) : ?>
4
  <p><?php printf( __( 'starts %s', 'advanced-ads' ), get_date_from_gmt( date( 'Y-m-d H:i:s', $post_future ), $expiry_date_format ) ); ?></p>
5
  <?php endif; ?>
6
- <?php if ( $expiry ) : ?>
7
- <?php
8
- $tz_option = get_option( 'timezone_string' );
9
- $expiry_date = date_create( '@' . $expiry, new DateTimeZone( 'UTC' ) );
10
-
11
- if ( $tz_option ) {
12
-
13
- $expiry_date->setTimezone( Advanced_Ads_Admin::get_wp_timezone() );
14
  $expiry_date_string = $expiry_date->format( $expiry_date_format );
15
-
16
- } else {
17
-
18
- $tz_name = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
19
- $tz_offset = substr( $tz_name, 3 );
20
- $off_time = date_create( $expiry_date->format( 'Y-m-d\TH:i:s' ) . $tz_offset );
21
- $offset_in_sec = date_offset_get( $off_time );
22
- $expiry_date = date_create( '@' . ( $expiry + $offset_in_sec ) );
23
  $expiry_date_string = date_i18n( $expiry_date_format, absint( $expiry_date->format( 'U' ) ) );
24
-
25
- }
26
- ?>
27
- <?php if ( $expiry > time() ) :?>
28
- <p><?php printf( __( 'expires %s', 'advanced-ads' ), $expiry_date_string ); ?></p>
29
- <?php else : ?>
30
- <p><?php printf( __( '<strong>expired</strong> %s', 'advanced-ads' ), $expiry_date_string ); ?></p>
31
- <?php endif; ?>
32
- <?php endif; ?>
33
- <?php echo $content_after; ?>
34
  </div>
35
- </fieldset>
3
  <?php if ( $post_future ) : ?>
4
  <p><?php printf( __( 'starts %s', 'advanced-ads' ), get_date_from_gmt( date( 'Y-m-d H:i:s', $post_future ), $expiry_date_format ) ); ?></p>
5
  <?php endif; ?>
6
+ <?php if ( $expiry ) : ?>
7
+ <?php
8
+ $tz_option = get_option( 'timezone_string' );
9
+ $expiry_date = date_create( '@' . $expiry, new DateTimeZone( 'UTC' ) );
10
+
11
+ if ( $tz_option ) {
12
+
13
+ $expiry_date->setTimezone( Advanced_Ads_Admin::get_wp_timezone() );
14
  $expiry_date_string = $expiry_date->format( $expiry_date_format );
15
+
16
+ } else {
17
+
18
+ $tz_name = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
19
+ $tz_offset = substr( $tz_name, 3 );
20
+ $off_time = date_create( $expiry_date->format( 'Y-m-d\TH:i:s' ) . $tz_offset );
21
+ $offset_in_sec = date_offset_get( $off_time );
22
+ $expiry_date = date_create( '@' . ( $expiry + $offset_in_sec ) );
23
  $expiry_date_string = date_i18n( $expiry_date_format, absint( $expiry_date->format( 'U' ) ) );
24
+
25
+ }
26
+ ?>
27
+ <?php if ( $expiry > time() ) : ?>
28
+ <p><?php printf( __( 'expires %s', 'advanced-ads' ), $expiry_date_string ); ?></p>
29
+ <?php else : ?>
30
+ <p><?php printf( __( '<strong>expired</strong> %s', 'advanced-ads' ), $expiry_date_string ); ?></p>
31
+ <?php endif; ?>
32
+ <?php endif; ?>
33
+ <?php echo $content_after; ?>
34
  </div>
35
+ </fieldset>
admin/views/ad-main-metabox.php CHANGED
@@ -1,33 +1,37 @@
1
  <?php $types = Advanced_Ads::get_instance()->ad_types; ?>
2
- <?php if ( empty($types) ) : ?>
3
- <p><?php _e( 'No ad types defined', 'advanced-ads' ); ?></p>
4
  <?php else : ?>
5
- <ul id="advanced-ad-type">
6
- <?php
7
  // choose first type if none set
8
- $type = (isset($ad->type)) ? $ad->type : current( $types )->ID;
9
- foreach ( $types as $_type ) : ?>
10
- <li class="advanced-ads-type-list-<?php echo $_type->ID; ?>">
11
- <input type="radio" name="advanced_ad[type]"
12
- id="advanced-ad-type-<?php echo $_type->ID ?>"
13
- value="<?php echo $_type->ID; ?>"
14
- <?php checked( $type, $_type->ID ); ?>/>
15
- <label for="advanced-ad-type-<?php echo $_type->ID ?>"><?php echo (empty($_type->title)) ? $_type->ID : $_type->title; ?></label>
16
- <?php if ( ! empty($_type->description) ) : ?><span class="description"><?php echo $_type->description; ?></span><?php endif; ?>
17
- </li>
18
- <?php endforeach; ?>
19
- </ul>
 
 
 
 
20
  <?php endif; ?>
21
  <script>
22
  jQuery( document ).on('change', '#advanced-ad-type input', function () {
23
- advads_update_ad_type_headline();
24
  });
25
 
26
  // dynamically move ad type to the meta box title
27
  advads_main_metabox_title = jQuery('#ad-main-box h2').text();
28
  function advads_update_ad_type_headline(){
29
- var advads_selected_type = jQuery('#advanced-ad-type input:checked + label').text();
30
- jQuery('#ad-main-box h2').html( advads_main_metabox_title + ': ' + advads_selected_type );
31
  }
32
  advads_update_ad_type_headline();
33
- </script>
1
  <?php $types = Advanced_Ads::get_instance()->ad_types; ?>
2
+ <?php if ( empty( $types ) ) : ?>
3
+ <p><?php _e( 'No ad types defined', 'advanced-ads' ); ?></p>
4
  <?php else : ?>
5
+ <ul id="advanced-ad-type">
6
+ <?php
7
  // choose first type if none set
8
+ $type = ( isset( $ad->type ) ) ? $ad->type : current( $types )->ID;
9
+ foreach ( $types as $_type ) :
10
+ ?>
11
+ <li class="advanced-ads-type-list-<?php echo $_type->ID; ?>">
12
+ <input type="radio" name="advanced_ad[type]"
13
+ id="advanced-ad-type-<?php echo $_type->ID; ?>"
14
+ value="<?php echo $_type->ID; ?>"
15
+ <?php checked( $type, $_type->ID ); ?>/>
16
+ <label for="advanced-ad-type-<?php echo $_type->ID; ?>"><?php echo ( empty( $_type->title ) ) ? $_type->ID : $_type->title; ?></label>
17
+ <?php
18
+ if ( ! empty( $_type->description ) ) :
19
+ ?>
20
+ <span class="description"><?php echo $_type->description; ?></span><?php endif; ?>
21
+ </li>
22
+ <?php endforeach; ?>
23
+ </ul>
24
  <?php endif; ?>
25
  <script>
26
  jQuery( document ).on('change', '#advanced-ad-type input', function () {
27
+ advads_update_ad_type_headline();
28
  });
29
 
30
  // dynamically move ad type to the meta box title
31
  advads_main_metabox_title = jQuery('#ad-main-box h2').text();
32
  function advads_update_ad_type_headline(){
33
+ var advads_selected_type = jQuery('#advanced-ad-type input:checked + label').text();
34
+ jQuery('#ad-main-box h2').html( advads_main_metabox_title + ': ' + advads_selected_type );
35
  }
36
  advads_update_ad_type_headline();
37
+ </script>
admin/views/ad-output-metabox.php CHANGED
@@ -1,57 +1,115 @@
1
  <p class="description"><?php _e( 'Everything connected to the ads layout and output.', 'advanced-ads' ); ?></p>
2
  <?php $options = $ad->options( 'output' ); ?>
3
  <div class="advads-option-list">
4
- <span class="label"><?php _e( 'Position', 'advanced-ads' ); ?></span>
5
- <div id="advanced-ad-output-position">
6
- <label><input type="radio" name="advanced_ad[output][position]" value="" title="<?php _e( '- default -', 'advanced-ads' );
7
- ?>" <?php if ( empty($options['position']) ) { checked( 1, 1 ); } ?>/><?php _e( 'default', 'advanced-ads' ); ?></label>
8
- <label title="<?php _e( 'left', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="left"
9
- <?php if ( isset($options['position']) ) { checked( $options['position'], 'left' ); } ?>/>
10
- <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-left.png" width="60" height="45"/></label>
11
- <label title="<?php _e( 'center', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="center"
12
- <?php if ( isset($options['position']) ) { checked( $options['position'], 'center' ); } ?>/>
13
- <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-center.png" width="60" height="45"/></label>
14
- <label title="<?php _e( 'right', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="right"
15
- <?php if ( isset($options['position']) ) { checked( $options['position'], 'right' ); } ?>/>
16
- <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-right.png" width="60" height="45"/></label>
17
- <p><label><input type="checkbox" name="advanced_ad[output][clearfix]" value="1"<?php if ( isset($options['clearfix']) ) { checked( $options['clearfix'], 1 ); } ?>/><?php
18
- _e( 'Check this if you don\'t want the following elements to float around the ad. (adds a clearfix)', 'advanced-ads' );
19
- ?></label></p>
20
- </div>
21
- <hr/>
22
- <span class="label"><?php _e( 'Margin', 'advanced-ads' ); ?></span>
23
- <div id="advanced-ad-output-margin">
24
- <label><?php _e( 'top:', 'advanced-ads' ); ?> <input type="number" value="<?php
25
- if ( isset($options['margin']['top']) ) { echo $options['margin']['top']; } ?>" name="advanced_ad[output][margin][top]"/>px</label>
26
- <label><?php _e( 'right:', 'advanced-ads' ); ?> <input type="number" value="<?php
27
- if ( isset($options['margin']['right']) ) { echo $options['margin']['right']; } ?>" name="advanced_ad[output][margin][right]"/>px</label>
28
- <label><?php _e( 'bottom:', 'advanced-ads' ); ?> <input type="number" value="<?php
29
- if ( isset($options['margin']['bottom']) ) { echo $options['margin']['bottom']; } ?>" name="advanced_ad[output][margin][bottom]"/>px</label>
30
- <label><?php _e( 'left:', 'advanced-ads' ); ?> <input type="number" value="<?php
31
- if ( isset($options['margin']['left']) ) { echo $options['margin']['left']; } ?>" name="advanced_ad[output][margin][left]"/>px</label>
32
- <p class="description"><?php _e( 'tip: use this to add a margin around the ad', 'advanced-ads' ); ?></p>
33
- </div>
34
- <hr class="advads-hide-in-wizard"/>
35
- <label class='label advads-hide-in-wizard' for="advads-output-wrapper-id"><?php _e( 'container ID', 'advanced-ads' ); ?></label>
36
- <div class="advads-hide-in-wizard">
37
- <input type="text" id="advads-output-wrapper-id" name="advanced_ad[output][wrapper-id]" value="<?php if ( isset($options['wrapper-id']) ) { echo $options['wrapper-id']; } ?>"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  <p class="description"><?php _e( 'Specify the id of the ad container. Leave blank for random or no id.', 'advanced-ads' ); ?></p>
39
- </div>
40
- <hr class="advads-hide-in-wizard"/>
41
- <label class='label advads-hide-in-wizard' for="advads-output-wrapper-class"><?php _e( 'container classes', 'advanced-ads' ); ?></label>
42
- <div class="advads-hide-in-wizard">
43
- <input type="text" id="advads-output-wrapper-class" name="advanced_ad[output][wrapper-class]" value="<?php if ( isset($options['wrapper-class']) ) { echo $options['wrapper-class']; } ?>"/>
 
 
 
 
 
44
  <p class="description"><?php _e( 'Specify one or more classes for the container. Separate multiple classes with a space', 'advanced-ads' ); ?></p>
45
- </div>
46
- <hr class="advads-hide-in-wizard"/>
47
- <label for="advads-output-debugmode" class="label advads-hide-in-wizard"><?php _e( 'Enable debug mode', 'advanced-ads' ); ?></label>
48
- <div class="advads-hide-in-wizard">
49
- <input id="advads-output-debugmode" type="checkbox" name="advanced_ad[output][debugmode]" value="1"<?php if ( isset($options['debugmode']) ) { checked( $options['debugmode'], 1 ); } ?>/>
 
 
 
 
 
50
 
51
  <a href="<?php echo ADVADS_URL; ?>manual/ad-debug-mode/#utm_source=advanced-ads&utm_medium=link&utm_campaign=ad-debug-mode" target="_blank"><?php _e( 'Manual', 'advanced-ads' ); ?></a>
52
- </div>
53
 
54
 
55
- <?php do_action( 'advanced-ads-output-metabox-after', $ad ); ?>
56
 
57
- </div>
1
  <p class="description"><?php _e( 'Everything connected to the ads layout and output.', 'advanced-ads' ); ?></p>
2
  <?php $options = $ad->options( 'output' ); ?>
3
  <div class="advads-option-list">
4
+ <span class="label"><?php _e( 'Position', 'advanced-ads' ); ?></span>
5
+ <div id="advanced-ad-output-position">
6
+ <label><input type="radio" name="advanced_ad[output][position]" value="" title="
7
+ <?php
8
+ _e( '- default -', 'advanced-ads' );
9
+ ?>
10
+ "
11
+ <?php
12
+ if ( empty( $options['position'] ) ) {
13
+ checked( 1, 1 ); }
14
+ ?>
15
+ /><?php _e( 'default', 'advanced-ads' ); ?></label>
16
+ <label title="<?php _e( 'left', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="left"
17
+ <?php
18
+ if ( isset( $options['position'] ) ) {
19
+ checked( $options['position'], 'left' ); }
20
+ ?>
21
+ />
22
+ <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-left.png" width="60" height="45"/></label>
23
+ <label title="<?php _e( 'center', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="center"
24
+ <?php
25
+ if ( isset( $options['position'] ) ) {
26
+ checked( $options['position'], 'center' ); }
27
+ ?>
28
+ />
29
+ <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-center.png" width="60" height="45"/></label>
30
+ <label title="<?php _e( 'right', 'advanced-ads' ); ?>"><input type="radio" name="advanced_ad[output][position]" value="right"
31
+ <?php
32
+ if ( isset( $options['position'] ) ) {
33
+ checked( $options['position'], 'right' ); }
34
+ ?>
35
+ />
36
+ <img src="<?php echo ADVADS_BASE_URL; ?>admin/assets/img/output-right.png" width="60" height="45"/></label>
37
+ <p><label><input type="checkbox" name="advanced_ad[output][clearfix]" value="1"
38
+ <?php
39
+ if ( isset( $options['clearfix'] ) ) {
40
+ checked( $options['clearfix'], 1 ); }
41
+ ?>
42
+ />
43
+ <?php
44
+ _e( 'Check this if you don\'t want the following elements to float around the ad. (adds a clearfix)', 'advanced-ads' );
45
+ ?>
46
+ </label></p>
47
+ </div>
48
+ <hr/>
49
+ <span class="label"><?php _e( 'Margin', 'advanced-ads' ); ?></span>
50
+ <div id="advanced-ad-output-margin">
51
+ <label><?php _e( 'top:', 'advanced-ads' ); ?> <input type="number" value="
52
+ <?php
53
+ if ( isset( $options['margin']['top'] ) ) {
54
+ echo $options['margin']['top']; }
55
+ ?>
56
+ " name="advanced_ad[output][margin][top]"/>px</label>
57
+ <label><?php _e( 'right:', 'advanced-ads' ); ?> <input type="number" value="
58
+ <?php
59
+ if ( isset( $options['margin']['right'] ) ) {
60
+ echo $options['margin']['right']; }
61
+ ?>
62
+ " name="advanced_ad[output][margin][right]"/>px</label>
63
+ <label><?php _e( 'bottom:', 'advanced-ads' ); ?> <input type="number" value="
64
+ <?php
65
+ if ( isset( $options['margin']['bottom'] ) ) {
66
+ echo $options['margin']['bottom']; }
67
+ ?>
68
+ " name="advanced_ad[output][margin][bottom]"/>px</label>
69
+ <label><?php _e( 'left:', 'advanced-ads' ); ?> <input type="number" value="
70
+ <?php
71
+ if ( isset( $options['margin']['left'] ) ) {
72
+ echo $options['margin']['left']; }
73
+ ?>
74
+ " name="advanced_ad[output][margin][left]"/>px</label>
75
+ <p class="description"><?php _e( 'tip: use this to add a margin around the ad', 'advanced-ads' ); ?></p>
76
+ </div>
77
+ <hr class="advads-hide-in-wizard"/>
78
+ <label class='label advads-hide-in-wizard' for="advads-output-wrapper-id"><?php _e( 'container ID', 'advanced-ads' ); ?></label>
79
+ <div class="advads-hide-in-wizard">
80
+ <input type="text" id="advads-output-wrapper-id" name="advanced_ad[output][wrapper-id]" value="
81
+ <?php
82
+ if ( isset( $options['wrapper-id'] ) ) {
83
+ echo $options['wrapper-id']; }
84
+ ?>
85
+ "/>
86
  <p class="description"><?php _e( 'Specify the id of the ad container. Leave blank for random or no id.', 'advanced-ads' ); ?></p>
87
+ </div>
88
+ <hr class="advads-hide-in-wizard"/>
89
+ <label class='label advads-hide-in-wizard' for="advads-output-wrapper-class"><?php _e( 'container classes', 'advanced-ads' ); ?></label>
90
+ <div class="advads-hide-in-wizard">
91
+ <input type="text" id="advads-output-wrapper-class" name="advanced_ad[output][wrapper-class]" value="
92
+ <?php
93
+ if ( isset( $options['wrapper-class'] ) ) {
94
+ echo $options['wrapper-class']; }
95
+ ?>
96
+ "/>
97
  <p class="description"><?php _e( 'Specify one or more classes for the container. Separate multiple classes with a space', 'advanced-ads' ); ?></p>
98
+ </div>
99
+ <hr class="advads-hide-in-wizard"/>
100
+ <label for="advads-output-debugmode" class="label advads-hide-in-wizard"><?php _e( 'Enable debug mode', 'advanced-ads' ); ?></label>
101
+ <div class="advads-hide-in-wizard">
102
+ <input id="advads-output-debugmode" type="checkbox" name="advanced_ad[output][debugmode]" value="1"
103
+ <?php
104
+ if ( isset( $options['debugmode'] ) ) {
105
+ checked( $options['debugmode'], 1 ); }
106
+ ?>
107
+ />
108
 
109
  <a href="<?php echo ADVADS_URL; ?>manual/ad-debug-mode/#utm_source=advanced-ads&utm_medium=link&utm_campaign=ad-debug-mode" target="_blank"><?php _e( 'Manual', 'advanced-ads' ); ?></a>
110
+ </div>
111
 
112
 
113
+ <?php do_action( 'advanced-ads-output-metabox-after', $ad ); ?>
114
 
115
+ </div>
admin/views/ad-parameters-metabox.php CHANGED
@@ -2,27 +2,32 @@
2
  <?php
3
  /**
4
  * when changing ad type ad parameter content is loaded via ajax
 
5
  * @filesource admin/assets/js/admin.js
6
  * @filesource includes/class-ajax-callbacks.php ::load_ad_parameters_metabox
7
  * @filesource classes/ad-type-content.php :: renter_parameters()
8
  */
9
- do_action( 'advanced-ads-ad-params-before', $ad, $types ); ?>
 
10
  <div id="advanced-ads-tinymce-wrapper" style="display:none;">
11
- <?php
12
  $args = array(
13
  // used here instead of textarea_rows, because of display:none
14
- 'editor_height' => 300,
15
  'drag_drop_upload' => true,
16
  );
17
  wp_editor( '', 'advanced-ads-tinymce', $args );
18
- ?>
19
  </div>
20
  <div id="advanced-ads-ad-parameters" class="advads-option-list">
21
- <?php $type = (isset($types[$ad->type])) ? $types[$ad->type] : current( $types );
 
22
  $type->render_parameters( $ad );
23
 
24
- if( 'dummy' !== $ad->type ) :
25
- include ADVADS_BASE_PATH . 'admin/views/ad-parameters-size.php';
26
- endif;
27
- ?></div>
28
- <?php do_action( 'advanced-ads-ad-params-after', $ad, $types );
 
 
2
  <?php
3
  /**
4
  * when changing ad type ad parameter content is loaded via ajax
5
+ *
6
  * @filesource admin/assets/js/admin.js
7
  * @filesource includes/class-ajax-callbacks.php ::load_ad_parameters_metabox
8
  * @filesource classes/ad-type-content.php :: renter_parameters()
9
  */
10
+ do_action( 'advanced-ads-ad-params-before', $ad, $types );
11
+ ?>
12
  <div id="advanced-ads-tinymce-wrapper" style="display:none;">
13
+ <?php
14
  $args = array(
15
  // used here instead of textarea_rows, because of display:none
16
+ 'editor_height' => 300,
17
  'drag_drop_upload' => true,
18
  );
19
  wp_editor( '', 'advanced-ads-tinymce', $args );
20
+ ?>
21
  </div>
22
  <div id="advanced-ads-ad-parameters" class="advads-option-list">
23
+ <?php
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
33
+ do_action( 'advanced-ads-ad-params-after', $ad, $types );
admin/views/ad-parameters-size.php CHANGED
@@ -1,10 +1,21 @@
1
  <span class="label"><?php _e( 'size', 'advanced-ads' ); ?></span>
2
  <div id="advanced-ads-ad-parameters-size">
3
- <label><?php _e( 'width', 'advanced-ads' ); ?><input type="number" value="<?php echo isset($ad->width) ? $ad->width : 0; ?>" name="advanced_ad[width]">px</label>
4
- <label><?php _e( 'height', 'advanced-ads' ); ?><input type="number" value="<?php echo isset($ad->height) ? $ad->height : 0; ?>" name="advanced_ad[height]">px</label>
5
- <?php
6
- $show_reserve_space = in_array( $type->ID, array( 'plain', 'content', 'group', 'adsense' ) );
7
- $enable_reserve_space = $show_reserve_space && ! empty( $ad->output['add_wrapper_sizes'] ); ?>
8
- <label <?php if ( ! $show_reserve_space ) { echo 'style="display:none;"'; }?>><input type="checkbox" id="advads-wrapper-add-sizes" name="advanced_ad[output][add_wrapper_sizes]" value="true" <?php checked( $enable_reserve_space ); ?>><?php _e( 'reserve this space', 'advanced-ads' ); ?></label>
 
 
 
 
 
 
 
 
 
 
 
9
  </div>
10
- <hr/>
1
  <span class="label"><?php _e( 'size', 'advanced-ads' ); ?></span>
2
  <div id="advanced-ads-ad-parameters-size">
3
+ <label><?php _e( 'width', 'advanced-ads' ); ?><input type="number" value="<?php echo isset( $ad->width ) ? $ad->width : 0; ?>" name="advanced_ad[width]">px</label>
4
+ <label><?php _e( 'height', 'advanced-ads' ); ?><input type="number" value="<?php echo isset( $ad->height ) ? $ad->height : 0; ?>" name="advanced_ad[height]">px</label>
5
+ <?php
6
+ $show_reserve_space = in_array( $type->ID, array( 'plain', 'content', 'group', 'adsense' ) );
7
+ $enable_reserve_space = $show_reserve_space && ! empty( $ad->output['add_wrapper_sizes'] );
8
+ ?>
9
+ <label
10
+ <?php
11
+ if ( ! $show_reserve_space ) {
12
+ echo 'style="display:none;"'; }
13
+ ?>
14
+ ><input type="checkbox" id="advads-wrapper-add-sizes" name="advanced_ad[output][add_wrapper_sizes]" value="true" <?php checked( $enable_reserve_space ); ?>><?php _e( 'reserve this space', 'advanced-ads' ); ?></label>
15
+ <?php
16
+ if ( 'image' === $type->ID ) :
17
+ Advanced_Ads_Ad_Type_Image::show_original_image_size( $ad );
18
+ endif;
19
+ ?>
20
  </div>
21
+ <hr/>
admin/views/ad-submitbox-meta.php CHANGED
@@ -1,33 +1,39 @@
1
  <?php
2
  $TZ = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
3
  ?><div id="advanced-ads-expiry-date" class="misc-pub-section curtime misc-pub-curtime">
4
- <label onclick="advads_toggle_box('#advanced-ads-expiry-date-enable', '#advanced-ads-expiry-date .inner')">
5
- <input type="checkbox" id="advanced-ads-expiry-date-enable" name="advanced_ad[expiry_date][enabled]"
6
- value="1" <?php checked( $enabled, 1 ); ?>/><?php _e( 'Set expiry date', 'advanced-ads' ); ?>&nbsp;(<?php echo $TZ; ?>)
7
- </label>
8
- <br/>
9
 
10
- <div class="inner" <?php if ( ! $enabled ) : ?>style="display:none;"<?php endif; ?>>
11
- <?php
 
 
 
 
12
  $month = '<label><span class="screen-reader-text">' . __( 'Month', 'advanced-ads' ) . '</span><select id="advads-exp-mm" name="advanced_ad[expiry_date][month]"' . ">\n";
13
- for ( $i = 1; $i < 13; $i = $i + 1 ) {
14
- $monthnum = zeroise( $i, 2 );
15
- $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $curr_month, $monthnum, false ) . '>';
16
- $month .= sprintf( _x( '%1$s-%2$s', '1: month number (01, 02, etc.), 2: month abbreviation', 'advanced-ads' ),
17
- $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
18
- }
 
 
19
  $month .= '</select></label>';
20
 
21
- $day = '<label><span class="screen-reader-text">' . __( 'Day', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-jj" name="advanced_ad[expiry_date][day]" value="' . $curr_day . '" size="2" maxlength="2" autocomplete="off" /></label>';
22
- $year = '<label><span class="screen-reader-text">' . __( 'Year', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-aa" name="advanced_ad[expiry_date][year]" value="' . $curr_year . '" size="4" maxlength="4" autocomplete="off" /></label>';
23
- $hour = '<label><span class="screen-reader-text">' . __( 'Hour', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-hh" name="advanced_ad[expiry_date][hour]" value="' . $curr_hour . '" size="2" maxlength="2" autocomplete="off" /></label>';
24
  $minute = '<label><span class="screen-reader-text">' . __( 'Minute', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-mn" name="advanced_ad[expiry_date][minute]" value="' . $curr_minute . '" size="2" maxlength="2" autocomplete="off" /></label>';
25
 
26
  ?>
27
  <fieldset id="advads-exp-timestampdiv">
28
  <div class="timestamp-wrap">
29
  <?php printf( _x( '%1$s %2$s, %3$s @ %4$s %5$s', 'order of expiry date fields 1: month, 2: day, 3: year, 4: hour, 5: minute', 'advanced-ads' ), $month, $day, $year, $hour, $minute ); ?>
30
- </div>
31
- </fieldset>
32
- </div>
33
- </div>
1
  <?php
2
  $TZ = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
3
  ?><div id="advanced-ads-expiry-date" class="misc-pub-section curtime misc-pub-curtime">
4
+ <label onclick="advads_toggle_box('#advanced-ads-expiry-date-enable', '#advanced-ads-expiry-date .inner')">
5
+ <input type="checkbox" id="advanced-ads-expiry-date-enable" name="advanced_ad[expiry_date][enabled]"
6
+ value="1" <?php checked( $enabled, 1 ); ?>/><?php _e( 'Set expiry date', 'advanced-ads' ); ?>&nbsp;(<?php echo $TZ; ?>)
7
+ </label>
8
+ <br/>
9
 
10
+ <div class="inner"
11
+ <?php
12
+ if ( ! $enabled ) :
13
+ ?>
14
+ style="display:none;"<?php endif; ?>>
15
+ <?php
16
  $month = '<label><span class="screen-reader-text">' . __( 'Month', 'advanced-ads' ) . '</span><select id="advads-exp-mm" name="advanced_ad[expiry_date][month]"' . ">\n";
17
+ for ( $i = 1; $i < 13; $i = $i + 1 ) {
18
+ $monthnum = zeroise( $i, 2 );
19
+ $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $curr_month, $monthnum, false ) . '>';
20
+ $month .= sprintf(
21
+ _x( '%1$s-%2$s', '1: month number (01, 02, etc.), 2: month abbreviation', 'advanced-ads' ),
22
+ $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) )
23
+ ) . "</option>\n";
24
+ }
25
  $month .= '</select></label>';
26
 
27
+ $day = '<label><span class="screen-reader-text">' . __( 'Day', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-jj" name="advanced_ad[expiry_date][day]" value="' . $curr_day . '" size="2" maxlength="2" autocomplete="off" /></label>';
28
+ $year = '<label><span class="screen-reader-text">' . __( 'Year', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-aa" name="advanced_ad[expiry_date][year]" value="' . $curr_year . '" size="4" maxlength="4" autocomplete="off" /></label>';
29
+ $hour = '<label><span class="screen-reader-text">' . __( 'Hour', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-hh" name="advanced_ad[expiry_date][hour]" value="' . $curr_hour . '" size="2" maxlength="2" autocomplete="off" /></label>';
30
  $minute = '<label><span class="screen-reader-text">' . __( 'Minute', 'advanced-ads' ) . '</span><input type="text" id="advads-exp-mn" name="advanced_ad[expiry_date][minute]" value="' . $curr_minute . '" size="2" maxlength="2" autocomplete="off" /></label>';
31
 
32
  ?>
33
  <fieldset id="advads-exp-timestampdiv">
34
  <div class="timestamp-wrap">
35
  <?php printf( _x( '%1$s %2$s, %3$s @ %4$s %5$s', 'order of expiry date fields 1: month, 2: day, 3: year, 4: hour, 5: minute', 'advanced-ads' ), $month, $day, $year, $hour, $minute ); ?>
36
+ </div>
37
+ </fieldset>
38
+ </div>
39
+ </div>
admin/views/ad-visitor-metabox.php CHANGED
@@ -3,161 +3,203 @@ $visitor_conditions = Advanced_Ads_Visitor_Conditions::get_instance()->get_condi
3
 
4
  // add mockup conditions if add-ons are missing
5
  $pro_conditions = array();
6
- if( ! defined( 'AAP_VERSION' ) ){
7
- $pro_conditions[] = __( 'browser language', 'advanced-ads');
8
- $pro_conditions[] = __( 'cookie', 'advanced-ads');
9
- $pro_conditions[] = __( 'max. ad clicks', 'advanced-ads');
10
- $pro_conditions[] = __( 'max. ad impressions', 'advanced-ads');
11
- $pro_conditions[] = __( 'new visitor', 'advanced-ads');
12
- $pro_conditions[] = __( 'page impressions', 'advanced-ads');
13
- $pro_conditions[] = __( 'referrer url', 'advanced-ads');
14
- $pro_conditions[] = __( 'user agent', 'advanced-ads');
15
- $pro_conditions[] = __( 'user can (capabilities)', 'advanced-ads');
16
  }
17
- if( ! defined( 'AAGT_VERSION') ){
18
- $pro_conditions[] = __( 'geo location', 'advanced-ads');
19
  }
20
- if( ! defined( 'AAR_VERSION') ){
21
- $pro_conditions[] = __( 'browser width', 'advanced-ads');
22
  }
23
  asort( $pro_conditions );
24
 
25
- $options = $ad->options( 'visitors' );
26
- $empty_options = ( !is_array( $options ) || !count( $options ) );
27
- if( $empty_options ) :
28
- ?><div class="advads-show-in-wizard">
29
  <p><?php _e( 'Click on the button below if the ad should NOT be visible to all visitors', 'advanced-ads' ); ?></p>
30
  <button type="button" class="button button-secondary" id="advads-wizard-visitor-conditions-show"><?php _e( 'Hide the ad from some users', 'advanced-ads' ); ?></button>
31
  </div>
32
- <?php endif;
33
- ?><div id="advads-visitor-conditions"<?php if( $empty_options ) : ?> class="advads-hide-in-wizard"<?php endif; ?>>
34
- <p class="description"><?php _e( 'Display conditions that are based on the user. Use with caution on cached websites.', 'advanced-ads' ); ?></p><?php
35
- // display help when no conditions are given
36
- if( $empty_options ) :
37
- $options = array();
38
- ?><p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>manual/visitor-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor" target="_blank">
39
- <?php _e( 'Visit the manual', 'advanced-ads' ); ?>
40
- </a></p><?php
 
 
 
 
 
 
 
 
 
41
  endif;
42
- ?><table class="advads-conditions-table"><tbody><?php
43
- if ( isset( $options ) ) :
44
- $i = 0;
45
- foreach ( $options as $_options ) :
46
- if ( isset( $visitor_conditions[ $_options['type'] ]['metabox'] ) ) {
47
- $metabox = $visitor_conditions[ $_options['type'] ]['metabox'];
48
- } else {
49
- continue;
50
- }
51
- $connector = ( ! isset($_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
52
- if ( method_exists( $metabox[0], $metabox[1] ) ) {
53
- if( $i > 0 ) :
54
- ?><tr class="advads-conditions-connector advads-conditions-connector-<?php echo $connector; ?>">
55
- <td colspan="3"><?php
56
- echo Advanced_Ads_Visitor_Conditions::render_connector_option( $i, $connector );
57
- ?></td></tr>
58
- <?php endif; ?>
59
- <tr><td class="advads-conditions-type"><?php echo $visitor_conditions[ $_options['type'] ]['label']; ?></td><td><?php
60
- call_user_func( array( $metabox[0], $metabox[1] ), $_options, $i++ );
61
- ?></td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr><?php
62
- }
63
- endforeach;
 
 
 
 
 
 
 
 
64
  endif;
65
- ?></tbody></table>
66
- <input type="hidden" id="advads-visitor-conditions-index" value="<?php echo isset( $options ) ? count( $options ) : 0; ?>"/>
 
67
  </div>
68
- <?php if( $empty_options ) :
69
- ?><p><?php _e( 'Visitor conditions limit the number of users who can see your ad. There is no need to set visitor conditions if you want all users to see the ad.', 'advanced-ads' ); ?></p><?php
70
- elseif( Advanced_Ads_Checks::cache() && ! defined('AAP_VERSION') ) :
71
- ?><p><span class="advads-error-message"><?php _e( 'It seems that a caching plugin is activated.', 'advanced-ads' ); ?></span>&nbsp;<?php
72
- printf( __( 'Check out cache-busting in <a href="%s" target="_blank">Advanced Ads Pro</a> if dynamic features get cached.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor' ); ?></p><?php
 
 
 
 
 
 
 
 
73
  endif;
74
  ?>
75
- <fieldset<?php if( $empty_options ) : ?> class="advads-hide-in-wizard"<?php endif; ?>>
76
- <legend><?php _e( 'New condition', 'advanced-ads' ); ?></legend>
 
 
 
 
77
  <div id="advads-visitor-conditions-new">
78
  <select>
79
- <option value=""><?php _e( '-- choose a condition --', 'advanced-ads' ); ?></option>
80
- <?php foreach ( $visitor_conditions as $_condition_id => $_condition ) : ?>
81
- <?php if( empty( $_condition['disabled'] ) ) : ?>
82
- <option value="<?php echo $_condition_id; ?>"><?php echo $_condition['label']; ?></option>
83
  <?php endif; ?>
84
- <?php endforeach;
85
- if( count( $pro_conditions ) ) :
86
- ?><optgroup label="<?php _e( 'Add-On features', 'advanced-ads' ); ?>"><?php
87
- foreach ( $pro_conditions as $_pro_condition ) :
88
- ?><option disabled="disabled"><?php echo $_pro_condition; ?></option><?php
89
- endforeach;
90
- ?></optgroup><?php
91
- endif;
92
- ?></select>
 
 
 
 
 
 
 
 
93
  <button type="button" class="button"><?php _e( 'add', 'advanced-ads' ); ?></button>
94
  <span class="advads-loader" style="display: none;"></span>
95
  </div>
96
  </fieldset>
97
  <?php if ( ! defined( 'AAR_SLUG' ) ) : ?>
98
  <p class="advads-hide-in-wizard"><?php printf( __( 'Define the exact browser width for which an ad should be visible using the <a href="%s" target="_blank">Responsive add-on</a>.', 'advanced-ads' ), ADVADS_URL . 'add-ons/responsive-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor' ); ?></p>
99
- <?php endif;
100
- ?><script>
 
 
101
  jQuery( document ).ready(function ($) {
102
- $('#advads-visitor-conditions-new button').click(function(){
103
- var visitor_condition_type = $('#advads-visitor-conditions-new select').val();
104
- var visitor_condition_title = $('#advads-visitor-conditions-new select option:selected').text();
105
- var visitor_condition_index = parseInt( $('#advads-visitor-conditions-index').val() );
106
- if( ! visitor_condition_type ) return;
107
- $('#advads-visitor-conditions-new .advads-loader').show();
108
- $.ajax({
109
- type: 'POST',
110
- url: ajaxurl,
111
- data: {
112
- action: 'load_visitor_conditions_metabox',
113
- type: visitor_condition_type,
114
- index: visitor_condition_index,
115
- nonce: advadsglobal.ajax_nonce
116
- },
117
- success: function (r, textStatus, XMLHttpRequest) {
118
- // add
119
- if (r) {
120
- var connector = '<input type="checkbox" name="<?php echo Advanced_Ads_Visitor_Conditions::FORM_NAME; ?>[' + visitor_condition_index + '][connector]" value="or" id="advads-visitor-conditions-'+ visitor_condition_index +'-connector"><label for="advads-visitor-conditions-'+ visitor_condition_index +'-connector"><?php _e( 'and', 'advanced-ads' ); ?></label>';
121
- var newline = '<tr class="advads-conditions-connector advads-conditions-connector-and"><td colspan="3">'+connector+'</td></tr><tr><td>' + visitor_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>';
122
- $( '#advads-visitor-conditions table tbody' ).append( newline );
123
- if ( advads_use_ui_buttonset() ) { // only used in Pro right now
124
- $('#advads-visitor-conditions table tbody .advads-conditions-single.advads-buttonset').buttonset();
125
- }
126
- if ( jQuery.fn.advads_button ) {
127
  $('#advads-visitor-conditions table tbody .advads-conditions-connector input').advads_button();
128
- }
129
- // increase count
130
- visitor_condition_index++;
131
- $('#advads-visitor-conditions-index').val( visitor_condition_index );
132
- $('#advads-visitor-conditions-new .advads-loader').hide();
133
- }
134
- },
135
- error: function (MLHttpRequest, textStatus, errorThrown) {
136
- $( '#advads-visitor-conditions-new' ).append( errorThrown );
137
- $('#advads-visitor-conditions-new .advads-loader').hide();
138
- }
139
- });
140
- });
141
  });
142
  </script>
143
- <?php $options = $ad->options( 'visitor' );
 
144
  if ( isset( $options['mobile'] ) && '' !== $options['mobile'] ) :
145
- ?><p style="color: red;"><?php _e( 'The visitor conditions below are deprecated. Please use the new version of visitor conditions to replace it.', 'advanced-ads' ); ?></p>
 
146
  <ul id="advanced-ad-visitor-mobile">
147
- <li>
148
- <input type="radio" name="advanced_ad[visitor][mobile]"
149
- id="advanced-ad-visitor-mobile-all" value=""
150
- <?php checked( empty($options['mobile']), 1 ); ?>/>
151
- <label for="advanced-ad-visitor-mobile-all"><?php _e( 'Display on all devices', 'advanced-ads' ); ?></label>
152
- <input type="radio" name="advanced_ad[visitor][mobile]"
153
- id="advanced-ad-visitor-mobile-only" value="only"
154
  <?php checked( $options['mobile'], 'only' ); ?>/>
155
- <label for="advanced-ad-visitor-mobile-only"><?php _e( 'only on mobile devices', 'advanced-ads' ); ?></label>
156
- <input type="radio" name="advanced_ad[visitor][mobile]"
157
- id="advanced-ad-visitor-mobile-no" value="no"
158
  <?php checked( $options['mobile'], 'no' ); ?>/>
159
- <label for="advanced-ad-visitor-mobile-no"><?php _e( 'not on mobile devices', 'advanced-ads' ); ?></label>
160
- </li>
161
  </ul>
162
  <?php endif; ?>
163
- <?php do_action( 'advanced-ads-visitor-conditions-after', $ad ); ?>
3
 
4
  // add mockup conditions if add-ons are missing
5
  $pro_conditions = array();
6
+ if ( ! defined( 'AAP_VERSION' ) ) {
7
+ $pro_conditions[] = __( 'browser language', 'advanced-ads' );
8
+ $pro_conditions[] = __( 'cookie', 'advanced-ads' );
9
+ $pro_conditions[] = __( 'max. ad clicks', 'advanced-ads' );
10
+ $pro_conditions[] = __( 'max. ad impressions', 'advanced-ads' );
11
+ $pro_conditions[] = __( 'new visitor', 'advanced-ads' );
12
+ $pro_conditions[] = __( 'page impressions', 'advanced-ads' );
13
+ $pro_conditions[] = __( 'referrer url', 'advanced-ads' );
14
+ $pro_conditions[] = __( 'user agent', 'advanced-ads' );
15
+ $pro_conditions[] = __( 'user can (capabilities)', 'advanced-ads' );
16
  }
17
+ if ( ! defined( 'AAGT_VERSION' ) ) {
18
+ $pro_conditions[] = __( 'geo location', 'advanced-ads' );
19
  }
20
+ if ( ! defined( 'AAR_VERSION' ) ) {
21
+ $pro_conditions[] = __( 'browser width', 'advanced-ads' );
22
  }
23
  asort( $pro_conditions );
24
 
25
+ $options = $ad->options( 'visitors' );
26
+ $empty_options = ( ! is_array( $options ) || ! count( $options ) );
27
+ if ( $empty_options ) :
28
+ ?><div class="advads-show-in-wizard">
29
  <p><?php _e( 'Click on the button below if the ad should NOT be visible to all visitors', 'advanced-ads' ); ?></p>
30
  <button type="button" class="button button-secondary" id="advads-wizard-visitor-conditions-show"><?php _e( 'Hide the ad from some users', 'advanced-ads' ); ?></button>
31
  </div>
32
+ <?php
33
+ endif;
34
+ ?>
35
+ <div id="advads-visitor-conditions"
36
+ <?php
37
+ if ( $empty_options ) :
38
+ ?>
39
+ class="advads-hide-in-wizard"<?php endif; ?>>
40
+ <p class="description"><?php _e( 'Display conditions that are based on the user. Use with caution on cached websites.', 'advanced-ads' ); ?></p>
41
+ <?php
42
+ // display help when no conditions are given
43
+ if ( $empty_options ) :
44
+ $options = array();
45
+ ?>
46
+ <p><a class="button button-primary" href="<?php echo ADVADS_URL; ?>manual/visitor-conditions#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor" target="_blank">
47
+ <?php _e( 'Visit the manual', 'advanced-ads' ); ?>
48
+ </a></p>
49
+ <?php
50
  endif;
51
+ ?>
52
+ <table class="advads-conditions-table"><tbody>
53
+ <?php
54
+ if ( isset( $options ) ) :
55
+ $i = 0;
56
+ foreach ( $options as $_options ) :
57
+ if ( isset( $visitor_conditions[ $_options['type'] ]['metabox'] ) ) {
58
+ $metabox = $visitor_conditions[ $_options['type'] ]['metabox'];
59
+ } else {
60
+ continue;
61
+ }
62
+ $connector = ( ! isset( $_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
63
+ if ( method_exists( $metabox[0], $metabox[1] ) ) {
64
+ if ( $i > 0 ) :
65
+ ?>
66
+ <tr class="advads-conditions-connector advads-conditions-connector-<?php echo $connector; ?>">
67
+ <td colspan="3">
68
+ <?php
69
+ echo Advanced_Ads_Visitor_Conditions::render_connector_option( $i, $connector );
70
+ ?>
71
+ </td></tr>
72
+ <?php endif; ?>
73
+ <tr><td class="advads-conditions-type"><?php echo $visitor_conditions[ $_options['type'] ]['label']; ?></td><td>
74
+ <?php
75
+ call_user_func( array( $metabox[0], $metabox[1] ), $_options, $i++ );
76
+ ?>
77
+ </td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>
78
+ <?php
79
+ }
80
+ endforeach;
81
  endif;
82
+ ?>
83
+ </tbody></table>
84
+ <input type="hidden" id="advads-visitor-conditions-index" value="<?php echo isset( $options ) ? count( $options ) : 0; ?>"/>
85
  </div>
86
+ <?php
87
+ if ( $empty_options ) :
88
+ ?>
89
+ <p><?php _e( 'Visitor conditions limit the number of users who can see your ad. There is no need to set visitor conditions if you want all users to see the ad.', 'advanced-ads' ); ?></p>
90
+ <?php
91
+ elseif ( Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ) ) :
92
+ ?>
93
+ <p><span class="advads-error-message"><?php _e( 'It seems that a caching plugin is activated.', 'advanced-ads' ); ?></span>&nbsp;
94
+ <?php
95
+ printf( __( 'Check out cache-busting in <a href="%s" target="_blank">Advanced Ads Pro</a> if dynamic features get cached.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor' );
96
+ ?>
97
+ </p>
98
+ <?php
99
  endif;
100
  ?>
101
+ <fieldset
102
+ <?php
103
+ if ( $empty_options ) :
104
+ ?>
105
+ class="advads-hide-in-wizard"<?php endif; ?>>
106
+ <legend><?php _e( 'New condition', 'advanced-ads' ); ?></legend>
107
  <div id="advads-visitor-conditions-new">
108
  <select>
109
+ <option value=""><?php _e( '-- choose a condition --', 'advanced-ads' ); ?></option>
110
+ <?php foreach ( $visitor_conditions as $_condition_id => $_condition ) : ?>
111
+ <?php if ( empty( $_condition['disabled'] ) ) : ?>
112
+ <option value="<?php echo $_condition_id; ?>"><?php echo $_condition['label']; ?></option>
113
  <?php endif; ?>
114
+ <?php
115
+ endforeach;
116
+ if ( count( $pro_conditions ) ) :
117
+ ?>
118
+ <optgroup label="<?php _e( 'Add-On features', 'advanced-ads' ); ?>">
119
+ <?php
120
+ foreach ( $pro_conditions as $_pro_condition ) :
121
+ ?>
122
+ <option disabled="disabled"><?php echo $_pro_condition; ?></option>
123
+ <?php
124
+ endforeach;
125
+ ?>
126
+ </optgroup>
127
+ <?php
128
+ endif;
129
+ ?>
130
+ </select>
131
  <button type="button" class="button"><?php _e( 'add', 'advanced-ads' ); ?></button>
132
  <span class="advads-loader" style="display: none;"></span>
133
  </div>
134
  </fieldset>
135
  <?php if ( ! defined( 'AAR_SLUG' ) ) : ?>
136
  <p class="advads-hide-in-wizard"><?php printf( __( 'Define the exact browser width for which an ad should be visible using the <a href="%s" target="_blank">Responsive add-on</a>.', 'advanced-ads' ), ADVADS_URL . 'add-ons/responsive-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-visitor' ); ?></p>
137
+ <?php
138
+ endif;
139
+ ?>
140
+ <script>
141
  jQuery( document ).ready(function ($) {
142
+ $('#advads-visitor-conditions-new button').click(function(){
143
+ var visitor_condition_type = $('#advads-visitor-conditions-new select').val();
144
+ var visitor_condition_title = $('#advads-visitor-conditions-new select option:selected').text();
145
+ var visitor_condition_index = parseInt( $('#advads-visitor-conditions-index').val() );
146
+ if( ! visitor_condition_type ) return;
147
+ $('#advads-visitor-conditions-new .advads-loader').show();
148
+ $.ajax({
149
+ type: 'POST',
150
+ url: ajaxurl,
151
+ data: {
152
+ action: 'load_visitor_conditions_metabox',
153
+ type: visitor_condition_type,
154
+ index: visitor_condition_index,
155
+ nonce: advadsglobal.ajax_nonce
156
+ },
157
+ success: function (r, textStatus, XMLHttpRequest) {
158
+ // add
159
+ if (r) {
160
+ var connector = '<input type="checkbox" name="<?php echo Advanced_Ads_Visitor_Conditions::FORM_NAME; ?>[' + visitor_condition_index + '][connector]" value="or" id="advads-visitor-conditions-'+ visitor_condition_index +'-connector"><label for="advads-visitor-conditions-'+ visitor_condition_index +'-connector"><?php _e( 'and', 'advanced-ads' ); ?></label>';
161
+ var newline = '<tr class="advads-conditions-connector advads-conditions-connector-and"><td colspan="3">'+connector+'</td></tr><tr><td>' + visitor_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-conditions-remove button">x</button></td></tr>';
162
+ $( '#advads-visitor-conditions table tbody' ).append( newline );
163
+ if ( advads_use_ui_buttonset() ) { // only used in Pro right now
164
+ $('#advads-visitor-conditions table tbody .advads-conditions-single.advads-buttonset').buttonset();
165
+ }
166
+ if ( jQuery.fn.advads_button ) {
167
  $('#advads-visitor-conditions table tbody .advads-conditions-connector input').advads_button();
168
+ }
169
+ // increase count
170
+ visitor_condition_index++;
171
+ $('#advads-visitor-conditions-index').val( visitor_condition_index );
172
+ $('#advads-visitor-conditions-new .advads-loader').hide();
173
+ }
174
+ },
175
+ error: function (MLHttpRequest, textStatus, errorThrown) {
176
+ $( '#advads-visitor-conditions-new' ).append( errorThrown );
177
+ $('#advads-visitor-conditions-new .advads-loader').hide();
178
+ }
179
+ });
180
+ });
181
  });
182
  </script>
183
+ <?php
184
+ $options = $ad->options( 'visitor' );
185
  if ( isset( $options['mobile'] ) && '' !== $options['mobile'] ) :
186
+ ?>
187
+ <p style="color: red;"><?php _e( 'The visitor conditions below are deprecated. Please use the new version of visitor conditions to replace it.', 'advanced-ads' ); ?></p>
188
  <ul id="advanced-ad-visitor-mobile">
189
+ <li>
190
+ <input type="radio" name="advanced_ad[visitor][mobile]"
191
+ id="advanced-ad-visitor-mobile-all" value=""
192
+ <?php checked( empty( $options['mobile'] ), 1 ); ?>/>
193
+ <label for="advanced-ad-visitor-mobile-all"><?php _e( 'Display on all devices', 'advanced-ads' ); ?></label>
194
+ <input type="radio" name="advanced_ad[visitor][mobile]"
195
+ id="advanced-ad-visitor-mobile-only" value="only"
196
  <?php checked( $options['mobile'], 'only' ); ?>/>
197
+ <label for="advanced-ad-visitor-mobile-only"><?php _e( 'only on mobile devices', 'advanced-ads' ); ?></label>
198
+ <input type="radio" name="advanced_ad[visitor][mobile]"
199
+ id="advanced-ad-visitor-mobile-no" value="no"
200
  <?php checked( $options['mobile'], 'no' ); ?>/>
201
+ <label for="advanced-ad-visitor-mobile-no"><?php _e( 'not on mobile devices', 'advanced-ads' ); ?></label>
202
+ </li>
203
  </ul>
204
  <?php endif; ?>
205
+ <?php do_action( 'advanced-ads-visitor-conditions-after', $ad ); ?>
admin/views/checks.php CHANGED
@@ -1,46 +1,56 @@
1
  <?php
2
 
3
- /**
4
  * a couple of checks to see if there is any critical issue
5
  * listed on support and settings page
6
  */
7
 
8
  $messages = array();
9
- if( ! Advanced_Ads_Checks::php_version_minimum() ) :
10
- $messages[] = sprintf(__( 'Your <strong>PHP version (%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' ), phpversion(), Advanced_Ads_Checks::MINIMUM_PHP_VERSION );
11
- endif;
12
- if( Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ) ) :
13
- $messages[] = sprintf(__( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
14
- endif;
15
- if( Advanced_Ads_Checks::wp_update_available() ) :
16
- $messages[] = __( 'There is a <strong>new WordPress version available</strong>. Please update.', 'advanced-ads' );
17
- endif;
18
- if( Advanced_Ads_Checks::plugin_updates_available() ) :
19
- $messages[] = __( 'There are <strong>plugin updates available</strong>. Please update.', 'advanced-ads' );
20
- endif;
21
- if( Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ) :
22
- $messages[] = sprintf(__( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
23
- endif;
24
- if( count( Advanced_Ads_Checks::conflicting_plugins() ) ) :
25
- $messages[] = sprintf(__( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ), ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support');
26
- endif;
27
- if( count( Advanced_Ads_Checks::php_extensions() ) ) :
28
- $messages[] = sprintf(__( 'Missing PHP extensions could cause issues. Please ask your hosting provider to enable them: %s', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::php_extensions() ) );
29
- endif;
30
- if( Advanced_Ads_Checks::ads_disabled() ) :
31
- $messages[] = sprintf(__( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ), admin_url('admin.php?page=advanced-ads-settings#top#general') );
32
- endif;
33
- if( defined( 'IS_WPCOM' ) ) :
34
- $messages[] = __( 'This site is hosted on wordpress.com.', 'advanced-ads' );
35
- endif;
36
- Advanced_Ads_Checks::jquery_ui_conflict();
37
 
38
- $messages = apply_filters( 'advanced-ads-support-messages', $messages );
39
-
40
- if( count( $messages )) :
41
- ?><div class="message error"><?php
42
- foreach( $messages as $_message ) :
43
- ?><p><?php echo $_message; ?></p><?php
44
- endforeach;
45
- ?></div><?php
46
- endif;
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ /**
4
  * a couple of checks to see if there is any critical issue
5
  * listed on support and settings page
6
  */
7
 
8
  $messages = array();
9
+ if ( ! Advanced_Ads_Checks::php_version_minimum() ) :
10
+ $messages[] = sprintf( __( 'Your <strong>PHP version (%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' ), phpversion(), Advanced_Ads_Checks::MINIMUM_PHP_VERSION );
11
+ endif;
12
+ if ( Advanced_Ads_Checks::cache() && ! defined( 'AAP_VERSION' ) ) :
13
+ $messages[] = sprintf( __( 'Your <strong>website uses cache</strong>. Some dynamic features like ad rotation or visitor conditions might not work properly. Use the cache-busting feature of <a href="%s" target="_blank">Advanced Ads Pro</a> to load ads dynamically.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
14
+ endif;
15
+ if ( Advanced_Ads_Checks::wp_update_available() ) :
16
+ $messages[] = __( 'There is a <strong>new WordPress version available</strong>. Please update.', 'advanced-ads' );
17
+ endif;
18
+ if ( Advanced_Ads_Checks::plugin_updates_available() ) :
19
+ $messages[] = __( 'There are <strong>plugin updates available</strong>. Please update.', 'advanced-ads' );
20
+ endif;
21
+ if ( Advanced_Ads_Checks::active_autoptimize() && ! defined( 'AAP_VERSION' ) ) :
22
+ $messages[] = sprintf( __( '<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
23
+ endif;
24
+ if ( count( Advanced_Ads_Checks::conflicting_plugins() ) ) :
25
+ $messages[] = sprintf( __( 'Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::conflicting_plugins() ), ADVADS_URL . 'manual/known-plugin-conflicts/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' );
26
+ endif;
27
+ if ( count( Advanced_Ads_Checks::php_extensions() ) ) :
28
+ $messages[] = sprintf( __( 'Missing PHP extensions could cause issues. Please ask your hosting provider to enable them: %s', 'advanced-ads' ), implode( ', ', Advanced_Ads_Checks::php_extensions() ) );
29
+ endif;
30
+ if ( Advanced_Ads_Checks::ads_disabled() ) :
31
+ $messages[] = sprintf( __( 'Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#general' ) );
32
+ endif;
33
+ if ( defined( 'IS_WPCOM' ) ) :
34
+ $messages[] = __( 'This site is hosted on wordpress.com.', 'advanced-ads' );
35
+ endif;
 
36
 
37
+ if ( Advanced_Ads_Checks::get_defined_constants() ) {
38
+ $messages[] = '<a href="' . admin_url( 'admin.php?page=advanced-ads-settings#top#support' ) . '">' . esc_html__( 'Advanced Ads related constants enabled', 'advanced-ads' ) . '</a>';
39
+ }
40
+
41
+ Advanced_Ads_Checks::jquery_ui_conflict();
42
+
43
+ $messages = apply_filters( 'advanced-ads-support-messages', $messages );
44
+
45
+ if ( count( $messages ) ) :
46
+ ?><div class="message error">
47
+ <?php
48
+ foreach ( $messages as $_message ) :
49
+ ?>
50
+ <p><?php echo $_message; ?></p>
51
+ <?php
52
+ endforeach;
53
+ ?>
54
+ </div>
55
+ <?php
56
+ endif;
admin/views/feedback-disable.php CHANGED
@@ -1,29 +1,44 @@
1
  <div id="advanced-ads-feedback-overlay" style="display: none;">
2
- <div id="advanced-ads-feedback-content">
3
- <form action="" method="post">
4
- <p><strong><?php _e('Why did you decide to disable Advanced Ads?', 'advanced-ads'); ?></strong></p>
5
- <ul>
6
- <li class="advanced_ads_disable_help"><label><input type="radio" name="advanced_ads_disable_reason" value="get help" checked="checked"/><?php _e('I have a problem, a question or need help.', 'advanced-ads'); ?></label></li>
7
- <li><textarea class="advanced_ads_disable_help_text" name="advanced_ads_disable_text[]" placeholder="<?php _e('Please let us know how we can help', 'advanced-ads'); ?>"></textarea></li>
8
- <?php if( $email ) : ?>
9
- <?php $mailinput = '<input type="email" name="advanced_ads_disable_reply_email" value="'. $email .'"/>'; ?>
10
- <li class="advanced_ads_disable_reply"><label><?php printf(
11
- /* translators: %s is the email address of the current user */
12
- __('Send me free help to %s', 'advanced-ads'), $mailinput ); ?></label></li>
13
- <?php endif; ?>
14
- <li><label><input type="radio" name="advanced_ads_disable_reason" value="temporary"/><?php _e('It is only temporary', 'advanced-ads'); ?></label></li>
15
- <li><label><input type="radio" name="advanced_ads_disable_reason" value="missing feature"/><?php _e('I miss a feature', 'advanced-ads'); ?></label></li>
16
- <li><input type="text" name="advanced_ads_disable_text[]" value="" placeholder="<?php _e('Which one?', 'advanced-ads'); ?>"/></li>
17
- <li><label><input type="radio" name="advanced_ads_disable_reason" value="stopped showing ads"/><?php _e('I stopped using ads on my site.', 'advanced-ads'); ?></label></li>
18
- <li><label><input type="radio" name="advanced_ads_disable_reason" value="other plugin"/><?php _e('I switched to another plugin', 'advanced-ads'); ?></label></li>
19
- </ul>
20
- <?php if ($from) : ?>
21
- <input type="hidden" name="advanced_ads_disable_from" value="<?php echo $from; ?>"/>
22
- <?php endif; ?>
23
- <input class="advanced-ads-feedback-submit button button-primary" type="submit" name="advanced_ads_disable_submit" value="<?php _e('Submit & Deactivate', 'advanced-ads'); ?>"/>
24
- <input class="advanced-ads-feedback-not-deactivate advanced-ads-feedback-submit button" type="submit" name="advanced_ads_keep_submit" value="<?php _e('Keep it & get a reply within 12h', 'advanced-ads'); ?>">
25
- <?php wp_nonce_field( 'advanced_ads_disable_form', 'advanced_ads_disable_form_nonce' ); ?>
26
- <a class="advanced-ads-feedback-only-deactivate" href="#"><?php _e('Only Deactivate', 'advanced-ads'); ?></a>
27
- </form>
28
- </div>
29
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <div id="advanced-ads-feedback-overlay" style="display: none;">
2
+ <div id="advanced-ads-feedback-content">
3
+ <span id="advanced-ads-feedback-overlay-close-button">&#x2715;</span>
4
+ <form action="" method="post">
5
+ <p><strong><?php esc_attr_e( 'Why did you decide to disable Advanced Ads?', 'advanced-ads' ); ?></strong></p>
6
+ <ul>
7
+ <li class="advanced_ads_disable_help"><label><input type="radio" name="advanced_ads_disable_reason" value="get help" checked="checked"/><?php esc_attr_e( 'I have a problem, a question or need help.', 'advanced-ads' ); ?></label></li>
8
+ <li><textarea class="advanced_ads_disable_help_text" name="advanced_ads_disable_text[]" placeholder="<?php esc_attr_e( 'Please let us know how we can help', 'advanced-ads' ); ?>"></textarea></li>
9
+ <?php if ( $email ) : ?>
10
+ <?php $mailinput = '<input type="email" name="advanced_ads_disable_reply_email" value="' . $email . '"/>'; ?>
11
+ <li class="advanced_ads_disable_reply"><label>
12
+ <?php
13
+ printf(
14
+ /* translators: %s is the email address of the current user */
15
+ __( 'Send me free help to %s', 'advanced-ads' ), $mailinput
16
+ );
17
+ ?>
18
+ </label></li>
19
+ <?php endif; ?>
20
+ <li><label><input type="radio" name="advanced_ads_disable_reason" value="temporary"/><?php esc_attr_e( 'It is only temporary', 'advanced-ads' ); ?></label></li>
21
+ <li><label><input type="radio" name="advanced_ads_disable_reason" value="missing feature"/><?php esc_attr_e( 'I miss a feature', 'advanced-ads' ); ?></label></li>
22
+ <li><input type="text" name="advanced_ads_disable_text[]" value="" placeholder="<?php esc_attr_e( 'Which one?', 'advanced-ads' ); ?>"/></li>
23
+ <li><label><input type="radio" name="advanced_ads_disable_reason" value="stopped showing ads"/><?php esc_attr_e( 'I stopped using ads on my site.', 'advanced-ads' ); ?></label></li>
24
+ <li><label><input type="radio" name="advanced_ads_disable_reason" value="other plugin"/><?php esc_attr_e( 'I switched to another plugin', 'advanced-ads' ); ?></label></li>
25
+ </ul>
26
+ <?php if ( $from ) : ?>
27
+ <input type="hidden" name="advanced_ads_disable_from" value="<?php echo $from; ?>"/>
28
+ <?php endif; ?>
29
+ <input class="advanced-ads-feedback-submit button button-primary" type="submit" name="advanced_ads_disable_submit" value="<?php esc_attr_e( 'Send feedback & deactivate', 'advanced-ads' ); ?>"/>
30
+ <input class="advanced-ads-feedback-not-deactivate advanced-ads-feedback-submit button" type="submit" name="advanced_ads_keep_submit" value="<?php esc_attr_e( 'Send feedback', 'advanced-ads' ); ?>">
31
+ <?php wp_nonce_field( 'advanced_ads_disable_form', 'advanced_ads_disable_form_nonce' ); ?>
32
+ <a class="advanced-ads-feedback-only-deactivate" href="#"><?php esc_attr_e( 'Only Deactivate', 'advanced-ads' ); ?></a>
33
+ </form>
34
+ <div id="advanced-ads-feedback-after-submit">
35
+ <h2 id="advanced-ads-feedback-after-submit-waiting" style="display: none"><?php esc_attr_e( 'Thanks for submitting your feedback. I will reply within 24 hours on working days.', 'advanced-ads' ); ?></h2>
36
+ <h2 id="advanced-ads-feedback-after-submit-goodbye" style="display: none"><?php
37
+ /*
38
+ * translators: %s is the title of the website
39
+ */
40
+ printf( esc_attr__( 'All the best to you and %s.', 'advanced-ads' ), '<em>' . get_bloginfo( 'name' ) . '</em>' ); ?></h2>
41
+ <p id="advanced-ads-feedback-after-submit-disabling-plugin" style="display: none"><?php esc_attr_e( 'Disabling the plugin now…', 'advanced-ads' ); ?></p>
42
+ </div>
43
+ </div>
44
+ </div>
admin/views/index.php CHANGED
@@ -1 +1 @@
1
- <?php // Silence is golden
1
+ <?php // Silence is golden
admin/views/notices/adblock.php CHANGED
@@ -1,5 +1,5 @@
1
  <div class="advads-ad-block-check">
2
- <div class="message error update-message notice notice-alt notice-error" style="display: none;"><p><?php _e( 'Please disable your <strong>AdBlocker</strong> to prevent problems with your ad setup.', 'advanced-ads' ); ?></p></div>
3
  </div>
4
  <script>
5
  jQuery( document ).ready( function() {
@@ -7,4 +7,4 @@ jQuery( document ).ready( function() {
7
  jQuery('.advads-ad-block-check .message').show();
8
  }
9
  } );
10
- </script>
1
  <div class="advads-ad-block-check">
2
+ <div class="message error update-message notice notice-alt notice-error" style="display: none;"><p><?php _e( 'Please disable your <strong>AdBlocker</strong> to prevent problems with your ad setup.', 'advanced-ads' ); ?></p></div>
3
  </div>
4
  <script>
5
  jQuery( document ).ready( function() {
7
  jQuery('.advads-ad-block-check .message').show();
8
  }
9
  } );
10
+ </script>
admin/views/notices/info.php CHANGED
@@ -1,3 +1,3 @@
1
  <div class="notice notice-info advads-admin-notice message is-dismissible" data-notice="<?php echo $_notice; ?>">
2
- <p><?php echo $text; ?></p>
3
  </div>
1
  <div class="notice notice-info advads-admin-notice message is-dismissible" data-notice="<?php echo $_notice; ?>">
2
+ <p><?php echo $text; ?></p>
3
  </div>
admin/views/notices/inline.php CHANGED
@@ -1,5 +1,5 @@
1
- <div class="notice notice-info advads-admin-notice-inline advads-admin-notice is-dismissible" data-notice="<?php echo $_notice ?>">
2
- <p><?php echo $text; ?>
3
- <button type="button" class="button-primary advads-notices-button-subscribe"><?php echo isset( $notice['confirm_text'] ) ? $notice['confirm_text'] : __('Subscribe me now', 'advanced-ads'); ?></button>
4
- </p>
5
  </div>
1
+ <div class="notice notice-info advads-admin-notice-inline advads-admin-notice is-dismissible" data-notice="<?php echo $_notice; ?>">
2
+ <p><?php echo $text; ?>
3
+ <button type="button" class="button-primary advads-notices-button-subscribe"><?php echo isset( $notice['confirm_text'] ) ? $notice['confirm_text'] : __( 'Subscribe me now', 'advanced-ads' ); ?></button>
4
+ </p>
5
  </div>
admin/views/notices/jqueryui_error.php CHANGED
@@ -1,3 +1,3 @@
1
  <div class="notice notice-error advads-jqueryui-error" style="display: none;">
2
- <p><?php printf(__( 'There might be a problem with layouts and scripts in your dashboard. Please check <a href="%s" target="_blank">this article to learn more</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/jquery-problem-in-dashboard/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-jquery-error' ); ?></p>
3
- </div>
1
  <div class="notice notice-error advads-jqueryui-error" style="display: none;">
2
+ <p><?php printf( __( 'There might be a problem with layouts and scripts in your dashboard. Please check <a href="%s" target="_blank">this article to learn more</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/jquery-problem-in-dashboard/#utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-jquery-error' ); ?></p>
3
+ </div>
admin/views/notices/plugin_error.php CHANGED
@@ -1 +1 @@
1
- <div class="notice notice-error advads-admin-notice"><p><?php echo $text; ?><?php ?></p></div>
1
+ <div class="notice notice-error advads-admin-notice"><p><?php echo $text; ?></p></div>
admin/views/notices/subscribe.php CHANGED
@@ -1,5 +1,5 @@
1
- <div class="notice notice-info advads-admin-notice is-dismissible" data-notice="<?php echo $_notice ?>">
2
- <p><?php echo $text; ?>
3
- <button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php echo $_notice ?>"><?php echo isset( $notice['confirm_text'] ) ? $notice['confirm_text'] : __('Subscribe me now', 'advanced-ads'); ?></button>
4
- </p>
5
  </div>
1
+ <div class="notice notice-info advads-admin-notice is-dismissible" data-notice="<?php echo $_notice; ?>">
2
+ <p><?php echo $text; ?>
3
+ <button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php echo $_notice; ?>"><?php echo isset( $notice['confirm_text'] ) ? $notice['confirm_text'] : __( 'Subscribe me now', 'advanced-ads' ); ?></button>
4
+ </p>
5
  </div>
admin/views/notices/welcome-panel.php CHANGED
@@ -5,15 +5,15 @@
5
  <h3><?php _e( 'Get Started', 'advanced-ads' ); ?></h3>
6
  <a href="<?php echo admin_url( 'post-new.php?post_type=advanced_ads' ); ?>" class="button button-primary"><?php _e( 'Create your first ad', 'advanced-ads' ); ?></a>
7
  <ul>
8
- <li><a href="<?php echo ADVADS_URL . 'manual/first-ad/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-first-ad'; ?>" target="_blank"><?php _e( 'First ad tutorial', 'advanced-ads' ); ?></a></li>
9
  </ul>
10
  </div>
11
  <div class="aa-welcome-panel-column">
12
  <h3><?php _e( 'AdSense Options', 'advanced-ads' ); ?></h3>
13
  <a href="<?php echo admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ); ?>" class="button button-primary"><?php _e( 'Import ads from AdSense', 'advanced-ads' ); ?></a>
14
  <ul>
15
- <li><a href="<?php echo ADVADS_URL . 'manual/adsense-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-auto-ads'; ?>" target="_blank"><?php _e( 'Setting up Auto ads', 'advanced-ads' ); ?></a></li>
16
- <li><a href="<?php echo ADVADS_URL . 'manual/adsense-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-adsense'; ?>" target="_blank"><?php _e( 'Setting up AdSense ads manually', 'advanced-ads' ); ?></a></li>
17
  </ul>
18
  </div>
19
  <div class="aa-welcome-panel-column aa-welcome-panel-last">
@@ -24,4 +24,4 @@
24
  </ul>
25
  </div>
26
  </div>
27
- </div>
5
  <h3><?php _e( 'Get Started', 'advanced-ads' ); ?></h3>
6
  <a href="<?php echo admin_url( 'post-new.php?post_type=advanced_ads' ); ?>" class="button button-primary"><?php _e( 'Create your first ad', 'advanced-ads' ); ?></a>
7
  <ul>
8
+ <li><a href="<?php echo ADVADS_URL . 'manual/first-ad/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-first-ad'; ?>" target="_blank"><?php _e( 'First ad tutorial', 'advanced-ads' ); ?></a></li>
9
  </ul>
10
  </div>
11
  <div class="aa-welcome-panel-column">
12
  <h3><?php _e( 'AdSense Options', 'advanced-ads' ); ?></h3>
13
  <a href="<?php echo admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ); ?>" class="button button-primary"><?php _e( 'Import ads from AdSense', 'advanced-ads' ); ?></a>
14
  <ul>
15
+ <li><a href="<?php echo ADVADS_URL . 'adsense-auto-ads-wordpress/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-auto-ads'; ?>" target="_blank"><?php _e( 'Setting up Auto ads', 'advanced-ads' ); ?></a></li>
16
+ <li><a href="<?php echo ADVADS_URL . 'place-adsense-ad-unit-manually/#utm_source=advanced-ads&utm_medium=link&utm_campaign=welcome-adsense'; ?>" target="_blank"><?php _e( 'Setting up AdSense ads manually', 'advanced-ads' ); ?></a></li>
17
  </ul>
18
  </div>
19
  <div class="aa-welcome-panel-column aa-welcome-panel-last">
24
  </ul>
25
  </div>
26
  </div>
27
+ </div>
admin/views/overview-addons-line.php CHANGED
@@ -1,9 +1,13 @@
1
- <tr<?php echo isset( $_addon['class'] ) ? ' class="'. $_addon['class'].'"' : ''; ?>><th><?php echo $_addon['title'] ?></th>
2
- <td><?php echo $_addon['desc'] ?></td>
3
- <td><?php if( isset( $_addon['link'] ) && $_addon['link'] ) : ?>
4
- <a class="button <?php echo ( isset( $_addon['link_primary'] ) && isset( $_addon['link_primary'] ) ) ? 'button-primary' : 'button-secondary'; ?>" href="<?php echo $_addon['link'] ?>" target="_blank"><?php
5
- echo $link_title;
6
- ?></a><?php
7
- endif;
8
- ?></td>
9
- </tr>
 
 
 
 
1
+ <tr<?php echo isset( $_addon['class'] ) ? ' class="' . $_addon['class'] . '"' : ''; ?>><th><?php echo $_addon['title']; ?></th>
2
+ <td><?php echo $_addon['desc']; ?></td>
3
+ <td><?php if ( isset( $_addon['link'] ) && $_addon['link'] ) : ?>
4
+ <a class="button <?php echo ( isset( $_addon['link_primary'] ) && isset( $_addon['link_primary'] ) ) ? 'button-primary' : 'button-secondary'; ?>" href="<?php echo $_addon['link']; ?>" target="_blank">
5
+ <?php
6
+ echo $link_title;
7
+ ?>
8
+ </a>
9
+ <?php
10
+ endif;
11
+ ?>
12
+ </td>
13
+ </tr>
admin/views/overview-widget.php CHANGED
@@ -1,8 +1,8 @@
1
  <div id="<?php echo $id; ?>" class="postbox position-<?php echo $position; ?>">
2
- <h2><?php echo $title; ?></h2>
3
- <div class="inside">
4
  <div class="main">
5
- <?php echo $content; ?>
6
  </div>
7
- </div>
8
- </div>
1
  <div id="<?php echo $id; ?>" class="postbox position-<?php echo $position; ?>">
2
+ <h2><?php echo $title; ?></h2>
3
+ <div class="inside">
4
  <div class="main">
5
+ <?php echo $content; ?>
6
  </div>
7
+ </div>
8
+ </div>
admin/views/overview.php CHANGED
@@ -6,10 +6,10 @@
6
  $title = __( 'Ads Dashboard', 'advanced-ads' );
7
 
8
  ?><div class="wrap">
9
- <h1><?php echo esc_html( $title ); ?></h1>
10
 
11
- <div id="advads-overview">
12
- <?php Advanced_Ads_Overview_Widgets_Callbacks::setup_overview_widgets(); ?>
13
- </div><!-- dashboard-widgets-wrap -->
14
- <?php do_action( 'advanced-ads-admin-overview-after' ); ?>
15
- </div><!-- wrap -->
6
  $title = __( 'Ads Dashboard', 'advanced-ads' );
7
 
8
  ?><div class="wrap">
9
+ <h1><?php echo esc_html( $title ); ?></h1>
10
 
11
+ <div id="advads-overview">
12
+ <?php Advanced_Ads_Overview_Widgets_Callbacks::setup_overview_widgets(); ?>
13
+ </div><!-- dashboard-widgets-wrap -->
14
+ <?php do_action( 'advanced-ads-admin-overview-after' ); ?>
15
+ </div><!-- wrap -->
admin/views/pitch-bundle.php CHANGED
@@ -1,13 +1,13 @@
1
- <h3><?php _e( 'All Access – with all available add-ons', 'advanced-ads' ); ?></h3>
2
  <ul>
3
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Advanced Ads Pro'; ?></li>
4
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Tracking'; ?></li>
5
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Responsive, AMP and Mobile ads'; ?></li>
6
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Selling Ads'; ?></li>
7
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Geo Targeting'; ?></li>
8
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Sticky Ads'; ?></li>
9
- <li><span class="dashicons dashicons-yes"></span><?php echo 'PopUp Ads'; ?></li>
10
- <li><span class="dashicons dashicons-yes"></span><?php echo 'Ad Slider'; ?></li>
11
  </ul>
12
- <p><?php _e( 'Risk free with 30-day Money-Back guarantee', 'advanced-ads' ); ?></p>
13
- <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/all-access/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-bundle" target="_blank"><?php _e( 'Get the Pro Bundle', 'advanced-ads' ); ?></a>
1
+ <h3><?php esc_attr_e( 'All Access – with all available add-ons', 'advanced-ads' ); ?></h3>
2
  <ul>
3
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Advanced Ads Pro'; ?></li>
4
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Tracking'; ?></li>
5
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Responsive, AMP and Mobile ads'; ?></li>
6
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Selling Ads'; ?></li>
7
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Geo Targeting'; ?></li>
8
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Sticky Ads'; ?></li>
9
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'PopUp Ads'; ?></li>
10
+ <li><span class="dashicons dashicons-yes"></span><?php echo 'Ad Slider'; ?></li>
11
  </ul>
12
+ <p><?php esc_attr_e( 'Risk free with 30-day Money-Back guarantee', 'advanced-ads' ); ?></p>
13
+ <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/all-access/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-bundle" target="_blank"><?php esc_attr_e( 'Get All Access', 'advanced-ads' ); ?></a>
admin/views/pitch-pro-tab.php CHANGED
@@ -1,18 +1,18 @@
1
  <div class="advads-pro-pitch postbox">
2
- <h3><?php _e( 'Advanced Ads Pro – test and optimize your ad performance', 'advanced-ads' ); ?></h3>
3
  <ul>
4
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'Ads for Ad Blockers', 'advanced-ads' ); ?></li>
5
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'Click Fraud Protection', 'advanced-ads' ); ?></li>
6
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'Lazy Loading', 'advanced-ads' ); ?></li>
7
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'support for cached sites', 'advanced-ads' ); ?></li>
8
- <li><span class="dashicons dashicons-yes"></span><?php _e( '11 more display and visitor conditions', 'advanced-ads' ); ?></li>
9
- <li><span class="dashicons dashicons-yes"></span><?php _e( '6 more placements', 'advanced-ads' ); ?></li>
10
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'placement tests for ad optimization', 'advanced-ads' ); ?></li>
11
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'ad grids and many more advanced features', 'advanced-ads' ); ?></li>
12
  </ul>
13
  <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-pro" target="_blank"><?php _e( 'See all features and pricing', 'advanced-ads' ); ?></a>
14
  </div>
15
  <div class="advads-pro-pitch postbox">
16
- <?php include ADVADS_BASE_PATH . 'admin/views/pitch-bundle.php'; ?>
17
  </div>
18
- <div class="clear"></div>
1
  <div class="advads-pro-pitch postbox">
2
+ <h3><?php _e( 'Advanced Ads Pro – test and optimize your ad performance', 'advanced-ads' ); ?></h3>
3
  <ul>
4
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'Ads for Ad Blockers', 'advanced-ads' ); ?></li>
5
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'Click Fraud Protection', 'advanced-ads' ); ?></li>
6
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'Lazy Loading', 'advanced-ads' ); ?></li>
7
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'support for cached sites', 'advanced-ads' ); ?></li>
8
+ <li><span class="dashicons dashicons-yes"></span><?php _e( '11 more display and visitor conditions', 'advanced-ads' ); ?></li>
9
+ <li><span class="dashicons dashicons-yes"></span><?php _e( '6 more placements', 'advanced-ads' ); ?></li>
10
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'placement tests for ad optimization', 'advanced-ads' ); ?></li>
11
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'ad grids and many more advanced features', 'advanced-ads' ); ?></li>
12
  </ul>
13
  <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-pro" target="_blank"><?php _e( 'See all features and pricing', 'advanced-ads' ); ?></a>
14
  </div>
15
  <div class="advads-pro-pitch postbox">
16
+ <?php require ADVADS_BASE_PATH . 'admin/views/pitch-bundle.php'; ?>
17
  </div>
18
+ <div class="clear"></div>
admin/views/pitch-tracking.php CHANGED
@@ -1,12 +1,12 @@
1
  <div class="advads-pro-pitch postbox">
2
- <h3><?php _e( 'Tracking', 'advanced-ads' ); ?></h3>
3
  <ul>
4
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'track impressions and click on your ads', 'advanced-ads' ); ?></li>
5
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'compare ads and periods', 'advanced-ads' ); ?></li>
6
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'share reports via link or email', 'advanced-ads' ); ?></li>
7
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'limit ads views by overall number of impressions or clicks', 'advanced-ads' ); ?></li>
8
- <li><span class="dashicons dashicons-yes"></span><?php _e( 'spread impressions or clicks equally over a given period', 'advanced-ads' ); ?></li>
9
  </ul>
10
  <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/tracking/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-tracking" target="_blank"><?php _e( 'See all features and pricing', 'advanced-ads' ); ?></a>
11
  </div>
12
- <div class="clear"></div>
1
  <div class="advads-pro-pitch postbox">
2
+ <h3><?php _e( 'Tracking', 'advanced-ads' ); ?></h3>
3
  <ul>
4
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'track impressions and click on your ads', 'advanced-ads' ); ?></li>
5
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'compare ads and periods', 'advanced-ads' ); ?></li>
6
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'share reports via link or email', 'advanced-ads' ); ?></li>
7
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'limit ads views by overall number of impressions or clicks', 'advanced-ads' ); ?></li>
8
+ <li><span class="dashicons dashicons-yes"></span><?php _e( 'spread impressions or clicks equally over a given period', 'advanced-ads' ); ?></li>
9
  </ul>
10
  <a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/tracking/#utm_source=advanced-ads&utm_medium=link&utm_campaign=pitch-tracking" target="_blank"><?php _e( 'See all features and pricing', 'advanced-ads' ); ?></a>
11
  </div>
12
+ <div class="clear"></div>
admin/views/placement-injection-top.php CHANGED
@@ -1,74 +1,133 @@
1
  <?php
2
  // show quick injection options
3
- if( isset( $_GET['message'] ) && 6 === $_GET['message'] ) : ?>
 
 
 
4
  <div id="advads-ad-injection-box" class="advads-ad-metabox postbox">
5
  <span class="advads-loader" style="display: none;"></span>
6
- <div id="advads-ad-injection-message-placement-created" class="hidden">
7
  <p><?php _e( 'Congratulations! Your ad is now visible in the frontend.', 'advanced-ads' ); ?></p>
8
  <a class="advads-placement-link button button-primary" href="<?php echo admin_url( 'admin.php?page=advanced-ads-placements#single-placement-' ); ?>"><?php _e( 'Adjust the placement options', 'advanced-ads' ); ?></a>
9
- <p><?php printf(__( 'Ad not showing up? Take a look <a href="%s" target="_blank">here</a>', 'advanced-ads' ), ADVADS_URL . 'manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-ad-not-visible'); ?></p>
10
- </div>
11
- <div id="advads-ad-injection-box-placements">
12
  <h2><?php _e( 'Where do you want to display the ad?', 'advanced-ads' ); ?></h2>
13
- <p><?php _e( 'New placement', 'advanced-ads' ); ?></p>
14
- <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_top" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-before.png'; ?>)"><?php _e( 'Before Content', 'advanced-ads'); ?></button></div>
15
- <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_content" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-within.png'; ?>)"><?php _e( 'Content', 'advanced-ads'); ?></button></div>
16
- <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_bottom" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-after.png'; ?>)"><?php _e( 'After Content', 'advanced-ads'); ?></button></div>
17
- <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="default" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png'; ?>)"><?php _e( 'PHP or Shortcode', 'advanced-ads'); ?></button></div>
18
- <a href="<?php echo admin_url( 'widgets.php' ); ?>"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/widget.png'; ?>)"><?php _e( 'Manage Sidebar', 'advanced-ads'); ?></button></div></a>
19
- <a href="<?php echo ADVADS_URL . 'place-ads-in-website-header/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-placements'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/ads-in-header.png'; ?>)"><?php _e( 'Header (Manual)', 'advanced-ads'); ?></button></div></a>
20
- <?php
21
- if( ! defined( 'AAP_VERSION' ) ) :
22
- ?><a href="<?php echo ADVADS_URL . 'manual/custom-position-placement/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-placements' ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/custom-position.png'; ?>)"><?php _e( 'Custom Position', 'advanced-ads'); ?></button></div></a><?php
23
- ?><a href="<?php echo ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-pro' ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-random.png'; ?>)"><?php _e( 'Show Pro Places', 'advanced-ads'); ?></button></div></a><?php
24
- else :
25
- ?><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="custom_position" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/custom-position.png'; ?>)"><?php _e( 'Custom Position', 'advanced-ads'); ?></button></div><?php
26
- endif;
27
- if( class_exists( 'Advanced_Ads_In_Feed', false ) ) :
28
- ?><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="adsense_in_feed" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/adsense-in-feed.png'; ?>)"><?php _e( 'AdSense In-feed', 'advanced-ads'); ?></button></div><?php
29
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- if( ! defined( 'AASADS_VERSION' ) ) :
32
- ?><a href="<?php echo ADVADS_URL . 'add-ons/sticky-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-sticky' ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/sticky-sidebar-left.png'; ?>)"><?php _e( 'Show Sticky Places', 'advanced-ads'); ?></button></div></a><?php
33
- endif;
 
 
 
 
 
 
34
 
35
- if( ! defined( 'AAPLDS_VERSION' ) ) :
36
- ?><a href="<?php echo ADVADS_URL . 'add-ons/popup-and-layer-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-layer' ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/layer.png'; ?>)"><?php _e( 'Show PopUp', 'advanced-ads'); ?></button></div></a><?php
37
- else :
38
- ?><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="layer" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/layer.png'; ?>)"><?php _e( 'PopUp & Layer', 'advanced-ads'); ?></button></div><?php
39
- endif;
40
-
41
- ?><a href="<?php echo admin_url( 'admin.php?page=advanced-ads-placements' ); ?>"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/more.png'; ?>)"><?php _e( 'see all…', 'advanced-ads'); ?></button></div></a><?php
42
 
43
- ob_start();
44
- foreach ( $placements as $_placement_slug => $_placement ) :
45
- if ( ! isset( $_placement['type'] ) || ! isset( $_placement['name'] ) ) {
46
- continue;
47
- }
48
- if ( ! isset( $placement_types[ $_placement['type'] ] ) ) {
49
- $_placement['type'] = 'default';
50
- }
51
 
52
- $placement_img = '';
53
- if ( isset( $placement_types[ $_placement['type'] ]['image'] ) ) {
54
- $placement_img = 'style="background-image: url(' . $placement_types[ $_placement['type'] ]['image'] . ');"';
55
- } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
- <div class="advads-ad-injection-box-button-wrap"><?php
58
- printf( '<button type="button" class="advads-ad-injection-button button-primary" data-placement-slug="%s" %s title="%s">%s</button>',
59
- $_placement_slug, $placement_img, $_placement['name'], $placement_types[ $_placement['type'] ]['title'] );
60
- echo $_placement['name']; ?></div>
61
- <?php
62
- endforeach;
63
- if ( $existing_p_output = ob_get_clean() ) : ?>
64
  <div class="clear"></div>
65
- <p><?php _e( 'Existing placement', 'advanced-ads'); ?></p>
66
- <?php echo $existing_p_output; ?>
67
  <?php endif; ?>
68
-
69
- <div class="clear"></div>
70
- <p><?php printf( __( 'Or use the shortcode %s to insert the ad into the content manually.', 'advanced-ads'), '<input id="advads-ad-injection-shortcode" onclick="this.select();" value="[the_ad id=\'' . $post->ID . '\']"/>' ); ?>
71
- <?php printf( __( 'Learn more about your choices to display an ad in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/display-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created' ); ?></p>
72
- </div>
73
  </div>
74
- <?php endif;
 
1
  <?php
2
  // show quick injection options
3
+ // check if the ad code contains the AdSense verification and Auto ads code
4
+ $is_page_level_ad_in_code_field = isset( $ad->type ) && 'plain' === $ad->type && strpos( $ad->content, 'enable_page_level_ads' );
5
+
6
+ if ( isset( $_GET['message'] ) && 6 === $_GET['message'] ) : ?>
7
  <div id="advads-ad-injection-box" class="advads-ad-metabox postbox">
8
  <span class="advads-loader" style="display: none;"></span>
9
+ <div id="advads-ad-injection-message-placement-created" class="hidden">
10
  <p><?php _e( 'Congratulations! Your ad is now visible in the frontend.', 'advanced-ads' ); ?></p>
11
  <a class="advads-placement-link button button-primary" href="<?php echo admin_url( 'admin.php?page=advanced-ads-placements#single-placement-' ); ?>"><?php _e( 'Adjust the placement options', 'advanced-ads' ); ?></a>
12
+ <p><?php printf( __( 'Ad not showing up? Take a look <a href="%s" target="_blank">here</a>', 'advanced-ads' ), ADVADS_URL . 'manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-ad-not-visible' ); ?></p>
13
+ </div>
14
+ <div id="advads-ad-injection-box-placements">
15
  <h2><?php _e( 'Where do you want to display the ad?', 'advanced-ads' ); ?></h2>
16
+ <?php
17
+ // show different placements if this is the AdSense Auto ads code
18
+ if ( $is_page_level_ad_in_code_field ) :
19
+ if ( Advanced_Ads_AdSense_Data::get_instance()->is_page_level_enabled() ) :
20
+ ?>
21
+ <p>
22
+ <?php
23
+ sprintf(
24
+ __( 'The AdSense verification and Auto ads code is already activated in the <a href="%s">AdSense settings</a>.', 'advanced-ads' ),
25
+ admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' )
26
+ );
27
+ ?>
28
+ </p><p>
29
+ <?php
30
+ esc_attr_e( 'No need to add the code manually here, unless you want to include it into certain pages only.', 'advanced-ads' );
31
+ endif;
32
+ ?>
33
+ <p><?php esc_attr_e( 'Click on the button below to add the Auto ads code to the header of your site.', 'advanced-ads' ); ?></p>
34
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="header" style="background-image: url(
35
+ <?php
36
+ echo ADVADS_BASE_URL . 'admin/assets/img/placements/header.png';
37
+ ?>
38
+ )">
39
+ <?php
40
+ /**
41
+ * translators: this is a label in a button when a user uses an AdSense Auto ads code in a plain code field
42
+ * the button has barely space for the original English text, so keep it short
43
+ */
44
+ esc_attr_e( 'inject Auto ads', 'advanced-ads' );
45
+ ?>
46
+ </button></div>
47
+ <div class="clear"></div>
48
+
49
+ <?php else : ?>
50
+ <p><?php _e( 'New placement', 'advanced-ads' ); ?></p>
51
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_top" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-before.png'; ?>)"><?php _e( 'Before Content', 'advanced-ads' ); ?></button></div>
52
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_content" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-within.png'; ?>)"><?php _e( 'Content', 'advanced-ads' ); ?></button></div>
53
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="post_bottom" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-after.png'; ?>)"><?php _e( 'After Content', 'advanced-ads' ); ?></button></div>
54
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="default" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png'; ?>)"><?php _e( 'PHP or Shortcode', 'advanced-ads' ); ?></button></div>
55
+ <a href="<?php echo admin_url( 'widgets.php' ); ?>"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/widget.png'; ?>)"><?php _e( 'Manage Sidebar', 'advanced-ads' ); ?></button></div></a>
56
+ <a href="<?php echo ADVADS_URL . 'place-ads-in-website-header/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-placements'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/ads-in-header.png'; ?>)"><?php _e( 'Header (Manual)', 'advanced-ads' ); ?></button></div></a>
57
+ <?php
58
+ if ( ! defined( 'AAP_VERSION' ) ) :
59
+ ?>
60
+ <a href="<?php echo ADVADS_URL . 'manual/custom-position-placement/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-placements'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/custom-position.png'; ?>)"><?php _e( 'Custom Position', 'advanced-ads' ); ?></button></div></a><a href="<?php echo ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-pro'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/content-random.png'; ?>)"><?php _e( 'Show Pro Places', 'advanced-ads' ); ?></button></div></a>
61
+ <?php
62
+ else :
63
+ ?>
64
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="custom_position" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/custom-position.png'; ?>)"><?php _e( 'Custom Position', 'advanced-ads' ); ?></button></div>
65
+ <?php
66
+ endif;
67
+ if ( class_exists( 'Advanced_Ads_In_Feed', false ) ) :
68
+ ?>
69
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="adsense_in_feed" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/adsense-in-feed.png'; ?>)"><?php _e( 'AdSense In-feed', 'advanced-ads' ); ?></button></div>
70
+ <?php
71
+ endif;
72
+
73
+ if ( ! defined( 'AASADS_VERSION' ) ) :
74
+ ?>
75
+ <a href="<?php echo ADVADS_URL . 'add-ons/sticky-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-sticky'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/sticky-sidebar-left.png'; ?>)"><?php _e( 'Show Sticky Places', 'advanced-ads' ); ?></button></div></a>
76
+ <?php
77
+ endif;
78
 
79
+ if ( ! defined( 'AAPLDS_VERSION' ) ) :
80
+ ?>
81
+ <a href="<?php echo ADVADS_URL . 'add-ons/popup-and-layer-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created-injection-layer'; ?>" target="_blank"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary advads-pro-link" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/layer.png'; ?>)"><?php _e( 'Show PopUp', 'advanced-ads' ); ?></button></div></a>
82
+ <?php
83
+ else :
84
+ ?>
85
+ <div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" data-placement-type="layer" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/layer.png'; ?>)"><?php _e( 'PopUp & Layer', 'advanced-ads' ); ?></button></div>
86
+ <?php
87
+ endif;
88
 
89
+ ?>
90
+ <a href="<?php echo admin_url( 'admin.php?page=advanced-ads-placements' ); ?>"><div class="advads-ad-injection-box-button-wrap"><button type="button" class="advads-ad-injection-button button-primary" style="background-image: url(<?php echo ADVADS_BASE_URL . 'admin/assets/img/placements/more.png'; ?>)"><?php _e( 'see all…', 'advanced-ads' ); ?></button></div></a>
91
+ <?php
 
 
 
 
92
 
93
+ ob_start();
94
+ foreach ( $placements as $_placement_slug => $_placement ) :
95
+ if ( ! isset( $_placement['type'] ) || ! isset( $_placement['name'] ) ) {
96
+ continue;
97
+ }
98
+ if ( ! isset( $placement_types[ $_placement['type'] ] ) ) {
99
+ $_placement['type'] = 'default';
100
+ }
101
 
102
+ $placement_img = '';
103
+ if ( isset( $placement_types[ $_placement['type'] ]['image'] ) ) {
104
+ $placement_img = 'style="background-image: url(' . $placement_types[ $_placement['type'] ]['image'] . ');"';
105
+ }
106
+ ?>
107
+
108
+ <div class="advads-ad-injection-box-button-wrap">
109
+ <?php
110
+ printf(
111
+ '<button type="button" class="advads-ad-injection-button button-primary" data-placement-slug="%s" %s title="%s">%s</button>',
112
+ $_placement_slug, $placement_img, $_placement['name'], $placement_types[ $_placement['type'] ]['title']
113
+ );
114
+ echo $_placement['name'];
115
+ ?>
116
+ </div>
117
+ <?php
118
+ endforeach;
119
+ if ( $existing_p_output = ob_get_clean() ) :
120
+ ?>
121
+ <div class="clear"></div>
122
+ <p><?php _e( 'Existing placement', 'advanced-ads' ); ?></p>
123
+ <?php echo $existing_p_output; ?>
124
+ <?php endif; ?>
125
 
 
 
 
 
 
 
 
126
  <div class="clear"></div>
127
+ <p><?php printf( __( 'Or use the shortcode %s to insert the ad into the content manually.', 'advanced-ads' ), '<input id="advads-ad-injection-shortcode" onclick="this.select();" value="[the_ad id=\'' . $post->ID . '\']"/>' ); ?>
128
+ <?php printf( __( 'Learn more about your choices to display an ad in the <a href="%s" target="_blank">manual</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/display-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-created' ); ?></p>
129
  <?php endif; ?>
130
+ </div>
 
 
 
 
131
  </div>
132
+ <?php
133
+ endif;
admin/views/placements-ad-label-position.php CHANGED
@@ -1,19 +1,36 @@
1
  <br/><br/><p><?php _e( 'Position', 'advanced-ads' ); ?></p>
2
  <label title="<?php _e( 'default', 'advanced-ads' ); ?>">
3
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="" <?php
4
- checked( $_position, 'default' ); ?> /><?php _e( 'default', 'advanced-ads' ); ?>
 
 
 
5
  </label>
6
  <label title="<?php _e( 'left', 'advanced-ads' ); ?>">
7
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="left" <?php
8
- checked( $_position, 'left' ); ?> /><?php _e( 'left', 'advanced-ads' ); ?></label>
 
 
 
9
  <label title="<?php _e( 'center', 'advanced-ads' ); ?>">
10
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="center" <?php
11
- checked( $_position, 'center' ); ?> /><?php _e( 'center', 'advanced-ads' ); ?></label>
 
 
 
12
  <label title="<?php _e( 'right', 'advanced-ads' ); ?>">
13
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="right" <?php
14
- checked( $_position, 'right' ); ?> /><?php _e( 'right', 'advanced-ads' ); ?></label>
 
 
 
15
  <p><label>
16
- <input type="checkbox" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_clearfix]" value="1"<?php
17
- checked( $_clearfix, 1 ); ?> /><?php
18
- _e( 'Check this if you don\'t want the following elements to float around the ad. (adds a placement_clearfix)', 'advanced-ads' ); ?>
19
- </label></p>
 
 
 
 
 
1
  <br/><br/><p><?php _e( 'Position', 'advanced-ads' ); ?></p>
2
  <label title="<?php _e( 'default', 'advanced-ads' ); ?>">
3
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value=""
4
+ <?php
5
+ checked( $_position, 'default' );
6
+ ?>
7
+ /><?php _e( 'default', 'advanced-ads' ); ?>
8
  </label>
9
  <label title="<?php _e( 'left', 'advanced-ads' ); ?>">
10
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="left"
11
+ <?php
12
+ checked( $_position, 'left' );
13
+ ?>
14
+ /><?php _e( 'left', 'advanced-ads' ); ?></label>
15
  <label title="<?php _e( 'center', 'advanced-ads' ); ?>">
16
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="center"
17
+ <?php
18
+ checked( $_position, 'center' );
19
+ ?>
20
+ /><?php _e( 'center', 'advanced-ads' ); ?></label>
21
  <label title="<?php _e( 'right', 'advanced-ads' ); ?>">
22
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_position]" value="right"
23
+ <?php
24
+ checked( $_position, 'right' );
25
+ ?>
26
+ /><?php _e( 'right', 'advanced-ads' ); ?></label>
27
  <p><label>
28
+ <input type="checkbox" name="advads[placements][<?php echo $_placement_slug; ?>][options][placement_clearfix]" value="1"
29
+ <?php
30
+ checked( $_clearfix, 1 );
31
+ ?>
32
+ />
33
+ <?php
34
+ _e( 'Check this if you don\'t want the following elements to float around the ad. (adds a placement_clearfix)', 'advanced-ads' );
35
+ ?>
36
+ </label></p>
admin/views/placements-ad-label.php CHANGED
@@ -1,12 +1,21 @@
1
  <label title="<?php _e( 'default', 'advanced-ads' ); ?>">
2
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="default" <?php
3
- checked( $_label, 'default' ); ?> /><?php _e( 'default', 'advanced-ads' ); ?>
 
 
 
4
  </label>
5
  <label title="<?php _e( 'enabled', 'advanced-ads' ); ?>">
6
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="enabled" <?php
7
- checked( $_label, 'enabled' ); ?> /><?php _e( 'enabled', 'advanced-ads' ); ?>
 
 
 
8
  </label>
9
  <label title="<?php _e( 'disabled', 'advanced-ads' ); ?>">
10
- <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="disabled" <?php
11
- checked( $_label, 'disabled' ); ?> /><?php _e( 'disabled', 'advanced-ads' ); ?>
12
- </label>
 
 
 
1
  <label title="<?php _e( 'default', 'advanced-ads' ); ?>">
2
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="default"
3
+ <?php
4
+ checked( $_label, 'default' );
5
+ ?>
6
+ /><?php _e( 'default', 'advanced-ads' ); ?>
7
  </label>
8
  <label title="<?php _e( 'enabled', 'advanced-ads' ); ?>">
9
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="enabled"
10
+ <?php
11
+ checked( $_label, 'enabled' );
12
+ ?>
13
+ /><?php _e( 'enabled', 'advanced-ads' ); ?>
14
  </label>
15
  <label title="<?php _e( 'disabled', 'advanced-ads' ); ?>">
16
+ <input type="radio" name="advads[placements][<?php echo $_placement_slug; ?>][options][ad_label]" value="disabled"
17
+ <?php
18
+ checked( $_label, 'disabled' );
19
+ ?>
20
+ /><?php _e( 'disabled', 'advanced-ads' ); ?>
21
+ </label>
admin/views/placements-content-index.php CHANGED
@@ -1,21 +1,39 @@
1
- <?php $_positions = array('after' => __( 'after', 'advanced-ads' ), 'before' => __( 'before', 'advanced-ads' )); ?>
 
 
 
2
  <select name="advads[placements][<?php echo $_placement_slug; ?>][options][position]">
3
- <?php foreach ( $_positions as $_pos_key => $_pos ) : ?>
4
- <option value="<?php echo $_pos_key; ?>" <?php if ( isset($_placement['options']['position']) ) { selected( $_placement['options']['position'], $_pos_key ); } ?>><?php echo $_pos; ?></option>
5
- <?php endforeach; ?>
 
 
 
 
 
6
  </select>
7
 
8
- <input type="number" name="advads[placements][<?php echo $_placement_slug; ?>][options][index]" value="<?php
9
- echo ( isset( $_placement['options']['index'] ) ) ? max( 1, (int) $_placement['options']['index'] ) : 1;
10
- ?>" min="1"/>.
 
 
11
 
12
  <?php $tags = Advanced_Ads_Placements::tags_for_content_injection(); ?>
13
  <select name="advads[placements][<?php echo $_placement_slug; ?>][options][tag]">
14
- <?php foreach ( $tags as $_tag_key => $_tag ) : ?>
15
- <option value="<?php echo $_tag_key; ?>" <?php if ( isset($_placement['options']['tag']) ) { selected( $_placement['options']['tag'], $_tag_key ); } ?>><?php echo $_tag; ?></option>
16
- <?php endforeach; ?>
 
 
 
 
 
17
  </select>
18
 
19
- <p><label><input type="checkbox" name="advads[placements][<?php echo $_placement_slug; ?>][options][start_from_bottom]" value="1" <?php
20
- if (isset($_placement['options']['start_from_bottom'])) { checked( $_placement['options']['start_from_bottom'], 1); }
21
- ?>/><?php _e( 'start counting from bottom', 'advanced-ads' ); ?></label></p>
 
 
 
1
+ <?php $_positions = array(
2
+ 'after' => __( 'after', 'advanced-ads' ),
3
+ 'before' => __( 'before', 'advanced-ads' ),
4
+ ); ?>
5
  <select name="advads[placements][<?php echo $_placement_slug; ?>][options][position]">
6
+ <?php foreach ( $_positions as $_pos_key => $_pos ) : ?>
7
+ <option value="<?php echo $_pos_key; ?>"
8
+ <?php
9
+ if ( isset( $_placement['options']['position'] ) ) {
10
+ selected( $_placement['options']['position'], $_pos_key ); }
11
+ ?>
12
+ ><?php echo $_pos; ?></option>
13
+ <?php endforeach; ?>
14
  </select>
15
 
16
+ <input type="number" name="advads[placements][<?php echo $_placement_slug; ?>][options][index]" value="
17
+ <?php
18
+ echo ( isset( $_placement['options']['index'] ) ) ? max( 1, (int) $_placement['options']['index'] ) : 1;
19
+ ?>
20
+ " min="1"/>.
21
 
22
  <?php $tags = Advanced_Ads_Placements::tags_for_content_injection(); ?>
23
  <select name="advads[placements][<?php echo $_placement_slug; ?>][options][tag]">
24
+ <?php foreach ( $tags as $_tag_key => $_tag ) : ?>
25
+ <option value="<?php echo $_tag_key; ?>"
26
+ <?php
27
+ if ( isset( $_placement['options']['tag'] ) ) {
28
+ selected( $_placement['options']['tag'], $_tag_key ); }
29
+ ?>
30
+ ><?php echo $_tag; ?></option>
31
+ <?php endforeach; ?>
32
  </select>
33
 
34
+ <p><label><input type="checkbox" name="advads[placements][<?php echo $_placement_slug; ?>][options][start_from_bottom]" value="1"
35
+ <?php
36
+ if ( isset( $_placement['options']['start_from_bottom'] ) ) {
37
+ checked( $_placement['options']['start_from_bottom'], 1 ); }
38
+ ?>
39
+ /><?php _e( 'start counting from bottom', 'advanced-ads' ); ?></label></p>
admin/views/placements-item.php CHANGED
@@ -1,33 +1,46 @@
1
  <select id="advads-placements-item-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][item]">
2
- <option value=""><?php _e( '--not selected--', 'advanced-ads' ); ?></option>
3
- <?php if ( isset($items['groups']) ) : ?>
4
  <optgroup label="<?php _e( 'Ad Groups', 'advanced-ads' ); ?>">
5
- <?php foreach ( $items['groups'] as $_item_id => $_item_title ) : ?>
6
- <option value="<?php echo $_item_id; ?>" <?php if ( isset($_placement['item']) ) { selected( $_item_id, $_placement['item'] ); } ?>><?php echo $_item_title; ?></option>
 
 
 
 
 
7
  <?php endforeach; ?>
8
  </optgroup>
9
  <?php endif; ?>
10
- <?php if ( isset($items['ads']) ) : ?>
11
  <optgroup label="<?php _e( 'Ads', 'advanced-ads' ); ?>">
12
- <?php foreach ( $items['ads'] as $_item_id => $_item_title ) : ?>
13
- <option value="<?php echo $_item_id; ?>" <?php if ( isset($_placement['item']) ) { selected( $_item_id, $_placement['item'] ); } ?>><?php echo $_item_title; ?></option>
 
 
 
 
 
14
  <?php endforeach; ?>
15
  </optgroup>
16
  <?php endif; ?>
17
  </select>
18
- <?php // link to item
19
- if ( isset($_placement['item']) ) :
20
- $currently_linked_item = explode( '_', $_placement['item'] );
21
- $link_to_item = false;
22
- switch( $currently_linked_item[0] ) :
23
- case 'ad' :
24
- $link_to_item = get_edit_post_link( $currently_linked_item[1] );
25
- break;
26
- case 'group' :
27
- $link_to_item = admin_url( 'admin.php?page=advanced-ads-groups' ); //( $currently_linked_item[1] );
28
- break;
29
- endswitch;
30
- if( $link_to_item ) :
31
- ?><a href="<?php echo $link_to_item; ?>"><span class="dashicons dashicons-external"></span></span></a><?php
32
- endif;
33
- endif;
 
 
 
1
  <select id="advads-placements-item-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][item]">
2
+ <option value=""><?php _e( '--not selected--', 'advanced-ads' ); ?></option>
3
+ <?php if ( isset( $items['groups'] ) ) : ?>
4
  <optgroup label="<?php _e( 'Ad Groups', 'advanced-ads' ); ?>">
5
+ <?php foreach ( $items['groups'] as $_item_id => $_item_title ) : ?>
6
+ <option value="<?php echo $_item_id; ?>"
7
+ <?php
8
+ if ( isset( $_placement['item'] ) ) {
9
+ selected( $_item_id, $_placement['item'] ); }
10
+ ?>
11
+ ><?php echo $_item_title; ?></option>
12
  <?php endforeach; ?>
13
  </optgroup>
14
  <?php endif; ?>
15
+ <?php if ( isset( $items['ads'] ) ) : ?>
16
  <optgroup label="<?php _e( 'Ads', 'advanced-ads' ); ?>">
17
+ <?php foreach ( $items['ads'] as $_item_id => $_item_title ) : ?>
18
+ <option value="<?php echo $_item_id; ?>"
19
+ <?php
20
+ if ( isset( $_placement['item'] ) ) {
21
+ selected( $_item_id, $_placement['item'] ); }
22
+ ?>
23
+ ><?php echo $_item_title; ?></option>
24
  <?php endforeach; ?>
25
  </optgroup>
26
  <?php endif; ?>
27
  </select>
28
+ <?php
29
+ // link to item
30
+ if ( isset( $_placement['item'] ) ) :
31
+ $currently_linked_item = explode( '_', $_placement['item'] );
32
+ $link_to_item = false;
33
+ switch ( $currently_linked_item[0] ) :
34
+ case 'ad':
35
+ $link_to_item = get_edit_post_link( $currently_linked_item[1] );
36
+ break;
37
+ case 'group':
38
+ $link_to_item = admin_url( 'admin.php?page=advanced-ads-groups' ); // ( $currently_linked_item[1] );
39
+ break;
40
+ endswitch;
41
+ if ( $link_to_item ) :
42
+ ?>
43
+ <a href="<?php echo $link_to_item; ?>"><span class="dashicons dashicons-external"></span></span></a>
44
+ <?php
45
+ endif;
46
+ endif;
admin/views/placements.php CHANGED
@@ -3,208 +3,268 @@
3
  * the view for the placements page
4
  */
5
  ?><div class="wrap">
6
- <?php if ( isset($_GET['message'] ) ) :
 
7
  if ( $_GET['message'] === 'error' ) :
8
- ?><div id="message" class="error"><p><?php _e( 'Couldn’t create the new placement. Please check your form field and whether the name is already in use.', 'advanced-ads' ); ?></p></div><?php
 
 
9
  elseif ( $_GET['message'] === 'updated' ) :
10
- ?><div id="message" class="updated"><p><?php _e( 'Placements updated', 'advanced-ads' ); ?></p></div><?php
11
- endif; ?>
 
 
 
12
  <?php endif; ?>
13
- <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
14
- <p class="description"><?php _e( 'Placements are physically places in your theme and posts. You can use them if you plan to change ads and ad groups on the same place without the need to change your templates.', 'advanced-ads' ); ?></p>
15
- <p class="description"><?php printf( __( 'See also the manual for more information on <a href="%s">placements</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/placements/#utm_source=advanced-ads&utm_medium=link&utm_campaign=placements' ); ?></p>
16
- <?php if ( isset($placements) && is_array( $placements ) && count( $placements ) ) :
17
- do_action( 'advanced-ads-placements-list-before', $placements ); ?>
18
- <h2><?php _e( 'Placements', 'advanced-ads' ); ?></h2>
19
- <form method="POST" action="">
20
- <table class="widefat advads-placements-table striped">
21
- <thead>
22
- <tr>
23
- <th><?php _e( 'Type', 'advanced-ads' ); ?></th>
24
- <th><?php _e( 'Name', 'advanced-ads' ); ?></th>
25
- <th><?php _e( 'Options', 'advanced-ads' ); ?></th>
26
- <?php do_action( 'advanced-ads-placements-list-column-header' ); ?>
27
- <th></th>
28
- </tr>
29
- </thead>
30
- <tbody>
31
- <?php // order by slug
32
- ksort( $placements );
33
- foreach ( $placements as $_placement_slug => $_placement ) :
 
 
 
34
  $type_missing = false;
35
- if( isset( $_placement['type'] ) && ! isset( $placement_types[$_placement['type']] )) {
36
- $missed_type = $_placement['type'];
37
- $_placement['type'] = 'default';
38
- $type_missing = true;
39
- }
40
- ?><tr id="single-placement-<?php echo $_placement_slug; ?>">
41
- <td><?php
42
- if( $type_missing ) : // type is not given
43
- ?><p class="advads-error-message"><?php printf(__( 'Placement type "%s" is missing and was reset to "default".<br/>Please check if the responsible add-on is activated.', 'advanced-ads' ), $missed_type ); ?></p><?php
44
- elseif( isset($_placement['type'] )) :
45
- if( isset( $placement_types[$_placement['type']]['image'] )) :
46
- ?><img src="<?php echo $placement_types[$_placement['type']]['image'];
47
- ?>" title="<?php echo $placement_types[$_placement['type']]['title'];
48
- ?>" alt="<?php echo $placement_types[$_placement['type']]['title']; ?>"/><?php
49
- else :
50
- echo $placement_types[$_placement['type']]['title'];
51
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
52
  else :
53
- __( 'default', 'advanced-ads' );
54
  endif;
55
- ?></td>
56
- <td><?php echo $_placement['name']; ?><br/>
57
- <?php if( ! isset( $_placement['type'] ) || 'default' === $_placement['type']) :
58
- $_placement['type'] = 'default';
59
- ?><a class="usage-link"><?php _e( 'show usage', 'advanced-ads' ); ?></a><?php
 
 
 
 
60
  endif;
61
- ?></td>
62
- <td class="advads-placements-table-options">
 
63
  <input type="hidden" class="advads-placement-slug" value="<?php echo $_placement_slug; ?>"/>
64
- <?php if( ! isset( $_placement['type'] ) || 'default' === $_placement['type']) : ?>
65
  <div class="hidden advads-usage">
66
- <label><?php _e( 'shortcode', 'advanced-ads' ); ?>
67
  <code><input type="text" onclick="this.select();" value='[the_ad_placement id="<?php echo $_placement_slug; ?>"]'/></code>
68
- </label>
69
- <label><?php _e( 'template (PHP)', 'advanced-ads' ); ?>
70
  <code><input type="text" onclick="this.select();" value="if( function_exists('the_ad_placement') ) { the_ad_placement('<?php echo $_placement_slug; ?>'); }"/></code>
71
- </label>
72
  </div>
73
  <?php endif; ?>
74
 
75
- <?php do_action( 'advanced-ads-placement-options-before', $_placement_slug, $_placement ); ?>
76
 
77
- <?php
78
  ob_start();
79
  include ADVADS_BASE_PATH . 'admin/views/placements-item.php';
80
  $item_option_content = ob_get_clean();
81
-
82
- Advanced_Ads_Admin_Options::render_option(
83
- 'placement-item',
84
  __( 'Item', 'advanced-ads' ),
85
- $item_option_content ); ?>
86
- <?php switch ( $_placement['type'] ) :
87
- case 'post_content' :
88
-
89
- ob_start();
90
- include ADVADS_BASE_PATH . 'admin/views/placements-content-index.php';
91
- do_action( 'advanced-ads-placement-post-content-position', $_placement_slug, $_placement );
92
- $option_content = ob_get_clean();
93
-
94
- Advanced_Ads_Admin_Options::render_option(
95
- 'placement-content-injection-index',
96
- __( 'position', 'advanced-ads' ),
97
- $option_content );
98
-
99
- if( ! function_exists( 'mb_convert_encoding' ) ) : ?>
 
 
 
 
100
  <p><span class="advads-error-message"><?php _e( 'Important Notice', 'advanced-ads' ); ?>: </span><?php _e( 'Your server is missing an extension. This might break the content injection.<br/>Ignore this warning if everything works fine or else ask your hosting provider to enable <em>mbstring</em>.', 'advanced-ads' ); ?></p>
101
- <?php endif;
 
102
  break;
103
  endswitch;
104
  do_action( 'advanced-ads-placement-options-after', $_placement_slug, $_placement );
105
- ob_start();
106
 
107
- if ( 'header' !== $_placement['type'] ):
108
- $_label = isset( $_placement['options']['ad_label'] ) ? $_placement['options']['ad_label'] : 'default';
109
- $_position = ! empty( $_placement['options']['placement_position'] ) ? $_placement['options']['placement_position'] : 'default';
110
- $_clearfix = ! empty( $_placement['options']['placement_clearfix'] );
111
-
112
- ob_start();
113
- include ADVADS_BASE_PATH . 'admin/views/placements-ad-label.php';
114
- if ( ! empty( $placement_types[ $_placement['type']]['options']['show_position'] ) ) :
115
- include ADVADS_BASE_PATH . 'admin/views/placements-ad-label-position.php';
116
- endif;
117
- $option_content = ob_get_clean();
 
 
 
 
 
 
118
 
119
- Advanced_Ads_Admin_Options::render_option(
120
- 'placement-ad-label',
121
- __( 'ad label', 'advanced-ads' ),
122
- $option_content );
123
-
124
  endif;
125
 
126
- do_action( 'advanced-ads-placement-options-after-advanced', $_placement_slug, $_placement );
127
- $advanced_options = ob_get_clean();
128
- if( $advanced_options ) :
129
- ?><a class="advads-toggle-link advads-placement-options-link"><?php _e( 'show all options', 'advanced-ads' ); ?></a>
130
- <?php
131
- $hidden = ( isset( $_POST['advads-last-edited-placement'] ) && $_placement_slug == $_POST['advads-last-edited-placement'] ) ? '' : ' hidden'; ?>
132
- <div class="advads-placements-advanced-options advads-placements-advanced-options-<?php echo $_placement_slug; echo $hidden; ?>"><?php
133
- echo $advanced_options;
134
- ?></div><?php
135
- endif;
136
- // information after options
137
- if( isset( $_placement['type'] ) && 'header' === $_placement['type']) :
138
- ?><br/><p><?php printf(__( 'Tutorial: <a href="%s" target="_blank">How to place visible ads in the header of your website</a>.', 'advanced-ads' ), ADVADS_URL . 'place-ads-in-website-header/#utm_source=advanced-ads&utm_medium=link&utm_campaign=header-ad-tutorial' ); ?></p><?php
139
- endif;
140
-
141
- ?></td>
142
- <?php do_action( 'advanced-ads-placements-list-column', $_placement_slug, $_placement ); ?>
143
- <td>
144
- <input type="checkbox" id="advads-placements-item-delete-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][delete]" value="1"/>
145
- <label for="advads-placements-item-delete-<?php echo $_placement_slug; ?>"><?php _ex( 'delete', 'checkbox to remove placement', 'advanced-ads' ); ?></label>
146
- </td>
147
- </tr>
148
- <?php endforeach; ?>
149
- </tbody>
150
- </table>
151
- <div class="tablenav bottom">
152
- <input type="submit" id="advads-save-placements-button" class="button button-primary" value="<?php _e( 'Save Placements', 'advanced-ads' ); ?>"/>
153
- <?php wp_nonce_field( 'advads-placement', 'advads_placement', true ) ?>
154
- <button type="button" title="<?php _e( 'Create a new placement', 'advanced-ads' ); ?>" class="button-secondary" onclick="advads_toggle('.advads-placements-new-form')"><?php
155
- _e( 'New Placement', 'advanced-ads' ); ?></button>
156
- <?php do_action( 'advanced-ads-placements-list-buttons', $placements ); ?>
157
- </div>
158
- <input type="hidden" name="advads-last-edited-placement" id="advads-last-edited-placement" value="0"/>
159
- </form>
160
- <?php do_action( 'advanced-ads-placements-list-after', $placements );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  endif;
162
 
163
- ?><form method="POST" action="" onsubmit="return advads_validate_placement_form();" class="advads-placements-new-form"<?php if ( isset($placements) && count( $placements ) ) echo ' style="display: none;"' ; ?>>
 
 
 
 
 
 
 
164
  <h3>1. <?php _e( 'Choose a placement type', 'advanced-ads' ); ?></h3>
165
- <p class="description"><?php printf(__( 'Placement types define where the ad is going to be displayed. Learn more about the different types from the <a href="%s">manual</a>', 'advanced-ads' ), ADVADS_URL . 'manual/placements/#utm_source=advanced-ads&utm_medium=link&utm_campaign=placements' ); ?></p>
166
  <div class= "advads-new-placement-types advads-buttonset">
167
  <?php
168
  if ( is_array( $placement_types ) ) {
169
  foreach ( $placement_types as $_key => $_place ) :
170
- if( isset( $_place['image'] )) :
171
- $image = '<img src="' . $_place['image'] . '" alt="' . $_place['title'] . '"/>';
172
- else :
173
- $image = '<strong>' . $_place['title'] . '</strong><br/><p class="description">' . $_place['description'] . '</p>';
174
- endif;
175
- ?><div class="advads-placement-type"><label for="advads-placement-type-<?php echo $_key; ?>"><?php echo $image; ?></label>
 
176
  <input type="radio" id="advads-placement-type-<?php echo $_key; ?>" name="advads[placement][type]" value="<?php echo $_key; ?>"/>
177
- <p class="advads-placement-description"><strong><?php echo $_place['title'] ?></strong><br/><?php echo $_place['description']; ?></p>
178
- </div><?php
179
- endforeach; };
180
- ?></div>
 
 
 
181
  <div class="clear"></div>
182
  <p class="advads-error-message advads-placement-type-error"><?php _e( 'Please select a placement type.', 'advanced-ads' ); ?></p>
183
  <br/>
184
  <h3>2. <?php _e( 'Choose a Name', 'advanced-ads' ); ?></h3>
185
  <p class="description"><?php _e( 'The name of the placement is only visible to you. Tip: choose a descriptive one, e.g. <em>Below Post Headline</em>.', 'advanced-ads' ); ?></p>
186
- <p><input name="advads[placement][name]" class="advads-new-placement-name" type="text" value="" placeholder="<?php _e( 'Placement Name', 'advanced-ads' ); ?>"/></p>
187
  <p class="advads-error-message advads-placement-name-error"><?php _e( 'Please enter a name for your placement.', 'advanced-ads' ); ?></p>
188
  <h3>3. <?php _e( 'Choose the Ad or Group', 'advanced-ads' ); ?></h3>
189
  <p class="description"><?php _e( 'The ad or group that should be displayed.', 'advanced-ads' ); ?></p>
190
  <p><select name="advads[placement][item]">
191
- <option value=""><?php _e( '--not selected--', 'advanced-ads' ); ?></option>
192
- <?php if ( isset($items['groups']) ) : ?>
193
  <optgroup label="<?php _e( 'Ad Groups', 'advanced-ads' ); ?>">
194
- <?php foreach ( $items['groups'] as $_item_id => $_item_title ) : ?>
195
  <option value="<?php echo $_item_id; ?>"><?php echo $_item_title; ?></option>
196
  <?php endforeach; ?>
197
  </optgroup>
198
  <?php endif; ?>
199
- <?php if ( isset($items['ads']) ) : ?>
200
  <optgroup label="<?php _e( 'Ads', 'advanced-ads' ); ?>">
201
- <?php foreach ( $items['ads'] as $_item_id => $_item_title ) : ?>
202
  <option value="<?php echo $_item_id; ?>"><?php echo $_item_title; ?></option>
203
  <?php endforeach; ?>
204
  </optgroup>
205
  <?php endif; ?>
206
- </select></p>
207
- <?php wp_nonce_field( 'advads-placement', 'advads_placement', true ) ?>
208
- <input type="submit" class="button button-primary" value="<?php _e( 'Save New Placement', 'advanced-ads' ); ?>"/>
209
- </form>
210
  </div>
3
  * the view for the placements page
4
  */
5
  ?><div class="wrap">
6
+ <?php
7
+ if ( isset( $_GET['message'] ) ) :
8
  if ( $_GET['message'] === 'error' ) :
9
+ ?>
10
+ <div id="message" class="error"><p><?php _e( 'Couldn’t create the new placement. Please check your form field and whether the name is already in use.', 'advanced-ads' ); ?></p></div>
11
+ <?php
12
  elseif ( $_GET['message'] === 'updated' ) :
13
+ ?>
14
+ <div id="message" class="updated"><p><?php _e( 'Placements updated', 'advanced-ads' ); ?></p></div>
15
+ <?php
16
+ endif;
17
+ ?>
18
  <?php endif; ?>
19
+ <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+ <p class="description"><?php _e( 'Placements are physically places in your theme and posts. You can use them if you plan to change ads and ad groups on the same place without the need to change your templates.', 'advanced-ads' ); ?></p>
21
+ <p class="description"><?php printf( __( 'See also the manual for more information on <a href="%s">placements</a>.', 'advanced-ads' ), ADVADS_URL . 'manual/placements/#utm_source=advanced-ads&utm_medium=link&utm_campaign=placements' ); ?></p>
22
+ <?php
23
+ if ( isset( $placements ) && is_array( $placements ) && count( $placements ) ) :
24
+ do_action( 'advanced-ads-placements-list-before', $placements );
25
+ ?>
26
+ <h2><?php _e( 'Placements', 'advanced-ads' ); ?></h2>
27
+ <form method="POST" action="">
28
+ <table class="widefat advads-placements-table striped">
29
+ <thead>
30
+ <tr>
31
+ <th><?php _e( 'Type', 'advanced-ads' ); ?></th>
32
+ <th><?php _e( 'Name', 'advanced-ads' ); ?></th>
33
+ <th><?php _e( 'Options', 'advanced-ads' ); ?></th>
34
+ <?php do_action( 'advanced-ads-placements-list-column-header' ); ?>
35
+ <th></th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <?php
40
+ // order by slug
41
+ ksort( $placements );
42
+ foreach ( $placements as $_placement_slug => $_placement ) :
43
  $type_missing = false;
44
+ if ( isset( $_placement['type'] ) && ! isset( $placement_types[ $_placement['type'] ] ) ) {
45
+ $missed_type = $_placement['type'];
46
+ $_placement['type'] = 'default';
47
+ $type_missing = true;
48
+ }
49
+ ?>
50
+ <tr id="single-placement-<?php echo $_placement_slug; ?>">
51
+ <td>
52
+ <?php
53
+ if ( $type_missing ) : // type is not given
54
+ ?>
55
+ <p class="advads-error-message"><?php printf( __( 'Placement type "%s" is missing and was reset to "default".<br/>Please check if the responsible add-on is activated.', 'advanced-ads' ), $missed_type ); ?></p>
56
+ <?php
57
+ elseif ( isset( $_placement['type'] ) ) :
58
+ if ( isset( $placement_types[ $_placement['type'] ]['image'] ) ) :
59
+ ?>
60
+ <img src="
61
+ <?php
62
+ echo $placement_types[ $_placement['type'] ]['image'];
63
+ ?>
64
+ " title="
65
+ <?php
66
+ echo $placement_types[ $_placement['type'] ]['title'];
67
+ ?>
68
+ " alt="<?php echo $placement_types[ $_placement['type'] ]['title']; ?>"/>
69
+ <?php
70
+ else :
71
+ echo $placement_types[ $_placement['type'] ]['title'];
72
+ endif;
73
  else :
74
+ __( 'default', 'advanced-ads' );
75
  endif;
76
+ ?>
77
+ </td>
78
+ <td><?php echo $_placement['name']; ?><br/>
79
+ <?php
80
+ if ( ! isset( $_placement['type'] ) || 'default' === $_placement['type'] ) :
81
+ $_placement['type'] = 'default';
82
+ ?>
83
+ <a class="usage-link"><?php _e( 'show usage', 'advanced-ads' ); ?></a>
84
+ <?php
85
  endif;
86
+ ?>
87
+ </td>
88
+ <td class="advads-placements-table-options">
89
  <input type="hidden" class="advads-placement-slug" value="<?php echo $_placement_slug; ?>"/>
90
+ <?php if ( ! isset( $_placement['type'] ) || 'default' === $_placement['type'] ) : ?>
91
  <div class="hidden advads-usage">
92
+ <label><?php _e( 'shortcode', 'advanced-ads' ); ?>
93
  <code><input type="text" onclick="this.select();" value='[the_ad_placement id="<?php echo $_placement_slug; ?>"]'/></code>
94
+ </label>
95
+ <label><?php _e( 'template (PHP)', 'advanced-ads' ); ?>
96
  <code><input type="text" onclick="this.select();" value="if( function_exists('the_ad_placement') ) { the_ad_placement('<?php echo $_placement_slug; ?>'); }"/></code>
97
+ </label>
98
  </div>
99
  <?php endif; ?>
100
 
101
+ <?php do_action( 'advanced-ads-placement-options-before', $_placement_slug, $_placement ); ?>
102
 
103
+ <?php
104
  ob_start();
105
  include ADVADS_BASE_PATH . 'admin/views/placements-item.php';
106
  $item_option_content = ob_get_clean();
107
+
108
+ Advanced_Ads_Admin_Options::render_option(
109
+ 'placement-item',
110
  __( 'Item', 'advanced-ads' ),
111
+ $item_option_content
112
+ );
113
+ ?>
114
+ <?php
115
+ switch ( $_placement['type'] ) :
116
+ case 'post_content':
117
+ ob_start();
118
+ include ADVADS_BASE_PATH . 'admin/views/placements-content-index.php';
119
+ do_action( 'advanced-ads-placement-post-content-position', $_placement_slug, $_placement );
120
+ $option_content = ob_get_clean();
121
+
122
+ Advanced_Ads_Admin_Options::render_option(
123
+ 'placement-content-injection-index',
124
+ __( 'position', 'advanced-ads' ),
125
+ $option_content
126
+ );
127
+
128
+ if ( ! function_exists( 'mb_convert_encoding' ) ) :
129
+ ?>
130
  <p><span class="advads-error-message"><?php _e( 'Important Notice', 'advanced-ads' ); ?>: </span><?php _e( 'Your server is missing an extension. This might break the content injection.<br/>Ignore this warning if everything works fine or else ask your hosting provider to enable <em>mbstring</em>.', 'advanced-ads' ); ?></p>
131
+ <?php
132
+ endif;
133
  break;
134
  endswitch;
135
  do_action( 'advanced-ads-placement-options-after', $_placement_slug, $_placement );
136
+ ob_start();
137
 
138
+ if ( 'header' !== $_placement['type'] ) :
139
+ $_label = isset( $_placement['options']['ad_label'] ) ? $_placement['options']['ad_label'] : 'default';
140
+ $_position = ! empty( $_placement['options']['placement_position'] ) ? $_placement['options']['placement_position'] : 'default';
141
+ $_clearfix = ! empty( $_placement['options']['placement_clearfix'] );
142
+
143
+ ob_start();
144
+ include ADVADS_BASE_PATH . 'admin/views/placements-ad-label.php';
145
+ if ( ! empty( $placement_types[ $_placement['type'] ]['options']['show_position'] ) ) :
146
+ include ADVADS_BASE_PATH . 'admin/views/placements-ad-label-position.php';
147
+ endif;
148
+ $option_content = ob_get_clean();
149
+
150
+ Advanced_Ads_Admin_Options::render_option(
151
+ 'placement-ad-label',
152
+ __( 'ad label', 'advanced-ads' ),
153
+ $option_content
154
+ );
155
 
 
 
 
 
 
156
  endif;
157
 
158
+ do_action( 'advanced-ads-placement-options-after-advanced', $_placement_slug, $_placement );
159
+ $advanced_options = ob_get_clean();
160
+ if ( $advanced_options ) :
161
+ ?>
162
+ <a class="advads-toggle-link advads-placement-options-link"><?php _e( 'show all options', 'advanced-ads' ); ?></a>
163
+ <?php
164
+ $hidden = ( isset( $_POST['advads-last-edited-placement'] ) && $_placement_slug == $_POST['advads-last-edited-placement'] ) ? '' : ' hidden';
165
+ ?>
166
+ <div class="advads-placements-advanced-options advads-placements-advanced-options-
167
+ <?php
168
+ echo $_placement_slug;
169
+ echo $hidden;
170
+ ?>
171
+ ">
172
+ <?php
173
+ echo $advanced_options;
174
+ ?>
175
+ </div>
176
+ <?php
177
+ endif;
178
+ // information after options
179
+ if ( isset( $_placement['type'] ) && 'header' === $_placement['type'] ) :
180
+ ?>
181
+ <br/><p><?php printf( __( 'Tutorial: <a href="%s" target="_blank">How to place visible ads in the header of your website</a>.', 'advanced-ads' ), ADVADS_URL . 'place-ads-in-website-header/#utm_source=advanced-ads&utm_medium=link&utm_campaign=header-ad-tutorial' ); ?></p>
182
+ <?php
183
+ endif;
184
+
185
+ ?>
186
+ </td>
187
+ <?php do_action( 'advanced-ads-placements-list-column', $_placement_slug, $_placement ); ?>
188
+ <td>
189
+ <input type="checkbox" id="advads-placements-item-delete-<?php echo $_placement_slug; ?>" name="advads[placements][<?php echo $_placement_slug; ?>][delete]" value="1"/>
190
+ <label for="advads-placements-item-delete-<?php echo $_placement_slug; ?>"><?php _ex( 'delete', 'checkbox to remove placement', 'advanced-ads' ); ?></label>
191
+ </td>
192
+ </tr>
193
+ <?php endforeach; ?>
194
+ </tbody>
195
+ </table>
196
+ <div class="tablenav bottom">
197
+ <input type="submit" id="advads-save-placements-button" class="button button-primary" value="<?php _e( 'Save Placements', 'advanced-ads' ); ?>"/>
198
+ <?php wp_nonce_field( 'advads-placement', 'advads_placement', true ); ?>
199
+ <button type="button" title="<?php _e( 'Create a new placement', 'advanced-ads' ); ?>" class="button-secondary" onclick="advads_toggle('.advads-placements-new-form')">
200
+ <?php
201
+ _e( 'New Placement', 'advanced-ads' );
202
+ ?>
203
+ </button>
204
+ <?php do_action( 'advanced-ads-placements-list-buttons', $placements ); ?>
205
+ </div>
206
+ <input type="hidden" name="advads-last-edited-placement" id="advads-last-edited-placement" value="0"/>
207
+ </form>
208
+ <?php
209
+ do_action( 'advanced-ads-placements-list-after', $placements );
210
  endif;
211
 
212
+ ?>
213
+ <form method="POST" action="" onsubmit="return advads_validate_placement_form();" class="advads-placements-new-form"
214
+ <?php
215
+ if ( isset( $placements ) && count( $placements ) ) {
216
+ echo ' style="display: none;"';
217
+ }
218
+ ?>
219
+ >
220
  <h3>1. <?php _e( 'Choose a placement type', 'advanced-ads' ); ?></h3>
221
+ <p class="description"><?php printf( __( 'Placement types define where the ad is going to be displayed. Learn more about the different types from the <a href="%s">manual</a>', 'advanced-ads' ), ADVADS_URL . 'manual/placements/#utm_source=advanced-ads&utm_medium=link&utm_campaign=placements' ); ?></p>
222
  <div class= "advads-new-placement-types advads-buttonset">
223
  <?php
224
  if ( is_array( $placement_types ) ) {
225
  foreach ( $placement_types as $_key => $_place ) :
226
+ if ( isset( $_place['image'] ) ) :
227
+ $image = '<img src="' . $_place['image'] . '" alt="' . $_place['title'] . '"/>';
228
+ else :
229
+ $image = '<strong>' . $_place['title'] . '</strong><br/><p class="description">' . $_place['description'] . '</p>';
230
+ endif;
231
+ ?>
232
+ <div class="advads-placement-type"><label for="advads-placement-type-<?php echo $_key; ?>"><?php echo $image; ?></label>
233
  <input type="radio" id="advads-placement-type-<?php echo $_key; ?>" name="advads[placement][type]" value="<?php echo $_key; ?>"/>
234
+ <p class="advads-placement-description"><strong><?php echo $_place['title']; ?></strong><br/><?php echo $_place['description']; ?></p>
235
+ </div>
236
+ <?php
237
+ endforeach;
238
+ };
239
+ ?>
240
+ </div>
241
  <div class="clear"></div>
242
  <p class="advads-error-message advads-placement-type-error"><?php _e( 'Please select a placement type.', 'advanced-ads' ); ?></p>
243
  <br/>
244
  <h3>2. <?php _e( 'Choose a Name', 'advanced-ads' ); ?></h3>
245
  <p class="description"><?php _e( 'The name of the placement is only visible to you. Tip: choose a descriptive one, e.g. <em>Below Post Headline</em>.', 'advanced-ads' ); ?></p>
246
+ <p><input name="advads[placement][name]" class="advads-new-placement-name" type="text" value="" placeholder="<?php _e( 'Placement Name', 'advanced-ads' ); ?>"/></p>
247
  <p class="advads-error-message advads-placement-name-error"><?php _e( 'Please enter a name for your placement.', 'advanced-ads' ); ?></p>
248
  <h3>3. <?php _e( 'Choose the Ad or Group', 'advanced-ads' ); ?></h3>
249
  <p class="description"><?php _e( 'The ad or group that should be displayed.', 'advanced-ads' ); ?></p>
250
  <p><select name="advads[placement][item]">
251
+ <option value=""><?php _e( '--not selected--', 'advanced-ads' ); ?></option>
252
+ <?php if ( isset( $items['groups'] ) ) : ?>
253
  <optgroup label="<?php _e( 'Ad Groups', 'advanced-ads' ); ?>">
254
+ <?php foreach ( $items['groups'] as $_item_id => $_item_title ) : ?>
255
  <option value="<?php echo $_item_id; ?>"><?php echo $_item_title; ?></option>
256
  <?php endforeach; ?>
257
  </optgroup>
258
  <?php endif; ?>
259
+ <?php if ( isset( $items['ads'] ) ) : ?>
260
  <optgroup label="<?php _e( 'Ads', 'advanced-ads' ); ?>">
261
+ <?php foreach ( $items['ads'] as $_item_id => $_item_title ) : ?>
262
  <option value="<?php echo $_item_id; ?>"><?php echo $_item_title; ?></option>
263
  <?php endforeach; ?>
264
  </optgroup>
265
  <?php endif; ?>
266
+ </select></p>
267
+ <?php wp_nonce_field( 'advads-placement', 'advads_placement', true ); ?>
268
+ <input type="submit" class="button button-primary" value="<?php _e( 'Save New Placement', 'advanced-ads' ); ?>"/>
269
+ </form>
270
  </div>
admin/views/post-ad-settings-metabox.php CHANGED
@@ -1,3 +1,4 @@
1
  <label><input type="checkbox" name="advanced_ads[disable_ads]" value="1" <?php
2
- if ( isset($values['disable_ads']) ) { checked( $values['disable_ads'], true ); }
3
- ?>/><?php _e( 'Disable ads on this page', 'advanced-ads' ); ?></label>
 
1
  <label><input type="checkbox" name="advanced_ads[disable_ads]" value="1" <?php
2
+ if ( isset( $values['disable_ads'] ) ) {
3
+ checked( $values['disable_ads'], true ); }
4
+ ?>/><?php _e( 'Disable ads on this page', 'advanced-ads' ); ?></label>
admin/views/setting-license.php CHANGED
@@ -1,56 +1,76 @@
1
  <?php
2
- $errortext = false;
3
- $expires = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $options_slug );
4
- $expired = false;
5
  $expired_error = __( 'Your license expired.', 'advanced-ads' );
6
 
7
  ob_start();
8
  ?><button type="button" class="button-secondary advads-license-activate"
9
- data-addon="<?php echo $index; ?>"
10
- data-pluginname="<?php echo $plugin_name; ?>"
11
- data-optionslug="<?php echo $options_slug; ?>"
12
- name="advads_license_activate"><?php _e( 'Update expiry date', 'advanced-ads' ); ?></button><?php
13
- $update_button = ob_get_clean();
 
14
 
15
- $expired_error .= $expired_renew_link = ' ' . sprintf(__( 'Click on %2$s if you renewed it or have a subscription or <a href="%1$s" target="_blank">renew your license</a>.', 'advanced-ads' ), ADVADS_URL . 'checkout/?edd_license_key=' . esc_attr($license_key) . '#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses', $update_button );
16
- if( 'lifetime' !== $expires ){
17
- $expires_time = strtotime( $expires );
18
- $days_left = ( $expires_time - time() ) / DAY_IN_SECONDS;
19
- }
20
- if( 'lifetime' === $expires ){
21
- // do nothing
22
- } elseif( $days_left <= 0 ){
23
- $plugin_url = isset( $plugin_url ) ? $plugin_url : ADVADS_URL;
24
- $errortext = $expired_error;
25
- $expired = true;
26
- } elseif ( 0 < $days_left && 31 > $days_left ){
27
- $errortext = sprintf( __('(%d days left)', 'advanced-ads' ), $days_left );
28
- }
29
- $show_active = ( $license_status !== false && $license_status == 'valid' && ! $expired ) ? true : false;
30
 
31
- ?><input type="text" class="regular-text advads-license-key" placeholder="<?php _e( 'License key', 'advanced-ads' ); ?>"
32
- name="<?php echo ADVADS_SLUG . '-licenses'; ?>[<?php echo $index; ?>]"
33
- value="<?php echo esc_attr($license_key); ?>"
34
- <?php if( $license_status !== false && $license_status == 'valid' && ! $expired ) : ?> readonly="readonly"<?php endif; ?>/>
 
 
 
 
35
 
36
  <button type="button" class="button-secondary advads-license-deactivate"
37
- <?php if( $license_status !== 'valid' ) echo ' style="display: none;" '; ?>
 
 
 
38
  data-addon="<?php echo $index; ?>"
39
  data-pluginname="<?php echo $plugin_name; ?>"
40
  data-optionslug="<?php echo $options_slug; ?>"
41
- name="advads_license_activate"><?php _e('Deactivate License', 'advanced-ads' ); ?></button>
42
 
43
  <button type="button" class="button-primary advads-license-activate"
44
- data-addon="<?php echo $index; ?>"
45
- data-pluginname="<?php echo $plugin_name; ?>"
46
- data-optionslug="<?php echo $options_slug; ?>"
47
- name="advads_license_activate"><?php echo ( $license_status === 'valid' && ! $expired ) ? __('Update License', 'advanced-ads' ) : __('Activate License', 'advanced-ads'); ?></button><?php
48
- if( '' === trim( $license_key ) ){
49
- $errortext = __('Please enter a valid license key', 'advanced-ads');
50
- } elseif( ! $expired && ! $errortext ){
51
- $errortext = ( $license_status == 'invalid') ? __('License key invalid', 'advanced-ads') : '';
52
- }
53
- ?>&nbsp;
54
- <span class="advads-license-activate-active" <?php if( ! $show_active ) echo 'style="display: none;"'; ?>><?php _e( 'active', 'advanced-ads' ); ?></span>
55
- <span class="advads-license-activate-error" <?php if( ! $errortext ) echo 'style="display: none;"'; ?>><?php echo $errortext; ?></span>
56
- <span class="advads-license-expired-error advads-error-message" style="display: none;"><?php echo $expired_error; ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ $errortext = false;
3
+ $expires = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $options_slug );
4
+ $expired = false;
5
  $expired_error = __( 'Your license expired.', 'advanced-ads' );
6
 
7
  ob_start();
8
  ?><button type="button" class="button-secondary advads-license-activate"
9
+ data-addon="<?php echo $index; ?>"
10
+ data-pluginname="<?php echo $plugin_name; ?>"
11
+ data-optionslug="<?php echo $options_slug; ?>"
12
+ name="advads_license_activate"><?php _e( 'Update expiry date', 'advanced-ads' ); ?></button>
13
+ <?php
14
+ $update_button = ob_get_clean();
15
 
16
+ $expired_error .= $expired_renew_link = ' ' . sprintf( __( 'Click on %2$s if you renewed it or have a subscription or <a href="%1$s" target="_blank">renew your license</a>.', 'advanced-ads' ), ADVADS_URL . 'checkout/?edd_license_key=' . esc_attr( $license_key ) . '#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses', $update_button );
17
+ if ( 'lifetime' !== $expires ) {
18
+ $expires_time = strtotime( $expires );
19
+ $days_left = ( $expires_time - time() ) / DAY_IN_SECONDS;
20
+ }
21
+ if ( 'lifetime' === $expires ) {
22
+ // do nothing
23
+ } elseif ( $days_left <= 0 ) {
24
+ $plugin_url = isset( $plugin_url ) ? $plugin_url : ADVADS_URL;
25
+ $errortext = $expired_error;
26
+ $expired = true;
27
+ } elseif ( 0 < $days_left && 31 > $days_left ) {
28
+ $errortext = sprintf( __( '(%d days left)', 'advanced-ads' ), $days_left );
29
+ }
30
+ $show_active = ( $license_status !== false && $license_status == 'valid' && ! $expired ) ? true : false;
31
 
32
+ ?>
33
+ <input type="text" class="regular-text advads-license-key" placeholder="<?php _e( 'License key', 'advanced-ads' ); ?>"
34
+ name="<?php echo ADVADS_SLUG . '-licenses'; ?>[<?php echo $index; ?>]"
35
+ value="<?php echo esc_attr( $license_key ); ?>"
36
+ <?php
37
+ if ( $license_status !== false && $license_status == 'valid' && ! $expired ) :
38
+ ?>
39
+ readonly="readonly"<?php endif; ?>/>
40
 
41
  <button type="button" class="button-secondary advads-license-deactivate"
42
+ <?php
43
+ if ( $license_status !== 'valid' ) {
44
+ echo ' style="display: none;" ';}
45
+ ?>
46
  data-addon="<?php echo $index; ?>"
47
  data-pluginname="<?php echo $plugin_name; ?>"
48
  data-optionslug="<?php echo $options_slug; ?>"
49
+ name="advads_license_activate"><?php _e( 'Deactivate License', 'advanced-ads' ); ?></button>
50
 
51
  <button type="button" class="button-primary advads-license-activate"
52
+ data-addon="<?php echo $index; ?>"
53
+ data-pluginname="<?php echo $plugin_name; ?>"
54
+ data-optionslug="<?php echo $options_slug; ?>"
55
+ name="advads_license_activate"><?php echo ( $license_status === 'valid' && ! $expired ) ? __( 'Update License', 'advanced-ads' ) : __( 'Activate License', 'advanced-ads' ); ?></button>
56
+ <?php
57
+ if ( '' === trim( $license_key ) ) {
58
+ $errortext = __( 'Please enter a valid license key', 'advanced-ads' );
59
+ } elseif ( ! $expired && ! $errortext ) {
60
+ $errortext = ( $license_status == 'invalid' ) ? __( 'License key invalid', 'advanced-ads' ) : '';
61
+ }
62
+ ?>
63
+ &nbsp;
64
+ <span class="advads-license-activate-active"
65
+ <?php
66
+ if ( ! $show_active ) {
67
+ echo 'style="display: none;"';}
68
+ ?>
69
+ ><?php _e( 'active', 'advanced-ads' ); ?></span>
70
+ <span class="advads-license-activate-error"
71
+ <?php
72
+ if ( ! $errortext ) {
73
+ echo 'style="display: none;"';}
74
+ ?>
75
+ ><?php echo $errortext; ?></span>
76
+ <span class="advads-license-expired-error advads-error-message" style="display: none;"><?php echo $expired_error; ?></span>
admin/views/setting-target.php CHANGED
@@ -1,3 +1,6 @@
1
- <input name="<?php echo ADVADS_SLUG; ?>[target-blank]" type="checkbox" value="1" <?php
2
- checked( 1, $target); ?>/>
3
- <p class="description"><?php _e( 'Open programatically created links in a new window (use <code>target="_blank"</code>)', 'advanced-ads' ); ?></p>
 
 
 
1
+ <input name="<?php echo ADVADS_SLUG; ?>[target-blank]" type="checkbox" value="1"
2
+ <?php
3
+ checked( 1, $target );
4
+ ?>
5
+ />
6
+ <p class="description"><?php _e( 'Open programatically created links in a new window (use <code>target="_blank"</code>)', 'advanced-ads' ); ?></p>
admin/views/settings-disable-ads.php CHANGED
@@ -1,21 +1,48 @@
1
  <label><input id="advanced-ads-disable-ads-all" type="checkbox" value="1" name="<?php
2
- echo ADVADS_SLUG ?>[disabled-ads][all]" <?php checked( $disable_all, 1 );
3
- ?>><?php _e( 'Disable all ads in frontend', 'advanced-ads' ); ?></label>
 
 
 
4
  <p class="description"><?php _e( 'Use this option to disable all ads in the frontend, but still be able to use the plugin.', 'advanced-ads' ); ?></p>
5
 
6
- <label><input id="advanced-ads-disable-ads-404" type="checkbox" value="1" name="<?php
7
- echo ADVADS_SLUG; ?>[disabled-ads][404]" <?php checked( $disable_404, 1 );
8
- ?>><?php _e( 'Disable ads on 404 error pages', 'advanced-ads' ); ?></label>
 
 
 
 
 
 
9
 
10
- <br/><label><input id="advanced-ads-disable-ads-archives" type="checkbox" value="1" name="<?php
11
- echo ADVADS_SLUG; ?>[disabled-ads][archives]" <?php checked( $disable_archives, 1 );
12
- ?>><?php _e( 'Disable ads on non-singular pages', 'advanced-ads' ); ?></label>
13
- <p class="description"><?php _e( 'e.g. archive pages like categories, tags, authors, front page (if a list)', 'advanced-ads' ); ?></p>
14
- <label><input id="advanced-ads-disable-ads-secondary" type="checkbox" value="1" name="<?php
15
- echo ADVADS_SLUG; ?>[disabled-ads][secondary]" <?php checked( $disable_secondary, 1 );
16
- ?>><?php _e( 'Disable ads on secondary queries', 'advanced-ads' ); ?></label>
17
- <p class="description"><?php _e( 'Secondary queries are custom queries of posts outside the main query of a page. Try this option if you see ads injected on places where they shouldn’t appear.', 'advanced-ads' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- <label><input id="advanced-ads-disable-ads-feed" type="checkbox" value="1" name="<?php
20
- echo ADVADS_SLUG; ?>[disabled-ads][feed]" <?php checked( $disable_feed, 1 );
21
- ?>><?php _e( 'Disable ads in Feed', 'advanced-ads' ); ?></label>
 
 
 
 
 
 
1
  <label><input id="advanced-ads-disable-ads-all" type="checkbox" value="1" name="<?php
2
+ echo ADVADS_SLUG ?>[disabled-ads][all]"
3
+ <?php
4
+ checked( $disable_all, 1 );
5
+ ?>
6
+ ><?php _e( 'Disable all ads in frontend', 'advanced-ads' ); ?></label>
7
  <p class="description"><?php _e( 'Use this option to disable all ads in the frontend, but still be able to use the plugin.', 'advanced-ads' ); ?></p>
8
 
9
+ <label><input id="advanced-ads-disable-ads-404" type="checkbox" value="1" name="
10
+ <?php
11
+ echo ADVADS_SLUG;
12
+ ?>
13
+ [disabled-ads][404]"
14
+ <?php
15
+ checked( $disable_404, 1 );
16
+ ?>
17
+ ><?php _e( 'Disable ads on 404 error pages', 'advanced-ads' ); ?></label>
18
 
19
+ <br/><label><input id="advanced-ads-disable-ads-archives" type="checkbox" value="1" name="
20
+ <?php
21
+ echo ADVADS_SLUG;
22
+ ?>
23
+ [disabled-ads][archives]"
24
+ <?php
25
+ checked( $disable_archives, 1 );
26
+ ?>
27
+ ><?php _e( 'Disable ads on non-singular pages', 'advanced-ads' ); ?></label>
28
+ <p class="description"><?php _e( 'e.g. archive pages like categories, tags, authors, front page (if a list)', 'advanced-ads' ); ?></p>
29
+ <label><input id="advanced-ads-disable-ads-secondary" type="checkbox" value="1" name="
30
+ <?php
31
+ echo ADVADS_SLUG;
32
+ ?>
33
+ [disabled-ads][secondary]"
34
+ <?php
35
+ checked( $disable_secondary, 1 );
36
+ ?>
37
+ ><?php _e( 'Disable ads on secondary queries', 'advanced-ads' ); ?></label>
38
+ <p class="description"><?php _e( 'Secondary queries are custom queries of posts outside the main query of a page. Try this option if you see ads injected on places where they shouldn’t appear.', 'advanced-ads' ); ?></p>
39
 
40
+ <label><input id="advanced-ads-disable-ads-feed" type="checkbox" value="1" name="
41
+ <?php
42
+ echo ADVADS_SLUG;
43
+ ?>
44
+ [disabled-ads][feed]"
45
+ <?php
46
+ checked( $disable_feed, 1 );
47
+ ?>
48
+ ><?php _e( 'Disable ads in Feed', 'advanced-ads' ); ?></label>
admin/views/settings.php CHANGED
@@ -4,14 +4,16 @@
4
  */
5
 
6
  // array with setting tabs for frontend
7
- $setting_tabs = apply_filters('advanced-ads-setting-tabs', array(
8
- 'general' => array(
9
- 'page' => Advanced_Ads_Admin::get_instance()->plugin_screen_hook_suffix,
10
- 'group' => ADVADS_SLUG,
11
- 'tabid' => 'general',
12
- 'title' => __( 'General', 'advanced-ads' )
 
 
13
  )
14
- ));
15
  ?><div class="wrap">
16
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
17
  <?php Advanced_Ads_Checks::show_issues(); ?>
@@ -23,10 +25,10 @@ $setting_tabs = apply_filters('advanced-ads-setting-tabs', array(
23
  href="#top#<?php echo $_setting_tab_id; ?>"><?php echo $_setting_tab['title']; ?></a>
24
  <?php endforeach; ?>
25
  <a class="nav-tab" id="support-tab"
26
- href="#top#support"><?php _e('Support', 'advanced-ads'); ?></a>
27
  </div>
28
  <?php foreach ( $setting_tabs as $_setting_tab_id => $_setting_tab ) : ?>
29
- <div id="<?php echo $_setting_tab_id; ?>" class="advads-tab">
30
  <div id="advads-sub-menu-<?php echo $_setting_tab_id; ?>" class="advads-tab-sub-menu"></div>
31
  <form class="advads-settings-tab-main-form" method="post" action="options.php">
32
  <?php
@@ -36,21 +38,21 @@ $setting_tabs = apply_filters('advanced-ads-setting-tabs', array(
36
  do_settings_sections( $_setting_tab['page'] );
37
 
38
  do_action( 'advanced-ads-settings-form', $_setting_tab_id, $_setting_tab );
39
- if ( isset( $_setting_tab['group'] ) && 'advanced-ads-licenses' !== $_setting_tab['group'] ){
40
- submit_button( __( 'Save settings on this page', 'advanced-ads' ) );
41
  }
42
  ?>
43
  </form>
44
  <?php do_action( 'advanced-ads-settings-tab-after-form', $_setting_tab_id, $_setting_tab ); ?>
45
- <?php if( 'general' === $_setting_tab_id ) : ?>
46
  <ul>
47
- <li><a href="<?php echo esc_url( admin_url( 'admin.php?page=advanced-ads-import-export' ) ); ?>"><?php _e( 'Import &amp; Export', 'advanced-ads' ); ?></a></li>
48
  </ul>
49
  <?php endif; ?>
50
  </div>
51
  <?php endforeach; ?>
52
  <div id="support" class="advads-tab">
53
- <?php include_once( ADVADS_BASE_PATH . 'admin/views/support.php' ); ?>
54
  </div>
55
  <?php
56
  do_action( 'advanced-ads-additional-settings-form' );
@@ -82,35 +84,38 @@ jQuery( '.nav-tab-active' ).click();
82
  // set all tab urls
83
  advads_set_tab_hashes();
84
 
85
- // fixed link to Support page in admin menu while user is already on a settings page
86
- jQuery('.toplevel_page_advanced-ads a[href*=#top#support]').click(function(){
87
- // already on a settings page, so simulate another click on support tab
88
- if( window.location.href.indexOf( 'page=advanced-ads-settings' ) ){
89
- jQuery( '#advads-tabs' ).find( 'a#support-tab' ).click();
90
- }
 
 
 
91
  });
92
 
93
  // dynamically generate the sub-menu
94
  jQuery( '.advads-tab-sub-menu' ).each( function( key, e ){
95
- // abort if scrollIntoView is not supported; we can’t use anchors because they are used for tabs already
96
- if (typeof e.scrollIntoView !== "function") { return; };
97
- // get all h2 headlines
98
- advads_settings_parent_tab = jQuery( e ).parent( '.advads-tab');
99
- var headlines = advads_settings_parent_tab.find( 'h2' );
100
- // create list
101
- if( headlines.length ){
102
  advads_submenu_list = jQuery('<ul>');
103
  headlines.each( function( key, h ){
104
- // create anchor for this headline
105
- var headline_id = 'advads-tab-headline-' + advads_settings_parent_tab.attr( 'id' ) + key;
106
- jQuery( h ).attr( 'id', headline_id );
107
- // place the link in the top menu
108
- var text = text = h.textContent || h.innerText;
109
- jQuery( '<li><a onclick="document.getElementById(\'' + headline_id + '\').scrollIntoView()">' + text + '</a></li>' ).appendTo( advads_submenu_list );
110
  });
111
  // place the menu
112
  advads_submenu_list.appendTo( e );
113
- }
114
  });
115
 
116
- </script>
4
  */
5
 
6
  // array with setting tabs for frontend
7
+ $setting_tabs = apply_filters(
8
+ 'advanced-ads-setting-tabs', array(
9
+ 'general' => array(
10
+ 'page' => Advanced_Ads_Admin::get_instance()->plugin_screen_hook_suffix,
11
+ 'group' => ADVADS_SLUG,
12
+ 'tabid' => 'general',
13
+ 'title' => __( 'General', 'advanced-ads' ),
14
+ ),
15
  )
16
+ );
17
  ?><div class="wrap">
18
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
19
  <?php Advanced_Ads_Checks::show_issues(); ?>
25
  href="#top#<?php echo $_setting_tab_id; ?>"><?php echo $_setting_tab['title']; ?></a>
26
  <?php endforeach; ?>
27
  <a class="nav-tab" id="support-tab"
28
+ href="#top#support"><?php _e( 'Support', 'advanced-ads' ); ?></a>
29
  </div>
30
  <?php foreach ( $setting_tabs as $_setting_tab_id => $_setting_tab ) : ?>
31
+ <div id="<?php echo $_setting_tab_id; ?>" class="advads-tab">
32
  <div id="advads-sub-menu-<?php echo $_setting_tab_id; ?>" class="advads-tab-sub-menu"></div>
33
  <form class="advads-settings-tab-main-form" method="post" action="options.php">
34
  <?php
38
  do_settings_sections( $_setting_tab['page'] );
39
 
40
  do_action( 'advanced-ads-settings-form', $_setting_tab_id, $_setting_tab );
41
+ if ( isset( $_setting_tab['group'] ) && 'advanced-ads-licenses' !== $_setting_tab['group'] ) {
42
+ submit_button( __( 'Save settings on this page', 'advanced-ads' ) );
43
  }
44
  ?>
45
  </form>
46
  <?php do_action( 'advanced-ads-settings-tab-after-form', $_setting_tab_id, $_setting_tab ); ?>
47
+ <?php if ( 'general' === $_setting_tab_id ) : ?>
48
  <ul>
49
+ <li><a href="<?php echo esc_url( admin_url( 'admin.php?page=advanced-ads-import-export' ) ); ?>"><?php _e( 'Import &amp; Export', 'advanced-ads' ); ?></a></li>
50
  </ul>
51
  <?php endif; ?>
52
  </div>
53
  <?php endforeach; ?>
54
  <div id="support" class="advads-tab">
55
+ <?php require_once ADVADS_BASE_PATH . 'admin/views/support.php'; ?>
56
  </div>
57
  <?php
58
  do_action( 'advanced-ads-additional-settings-form' );
84
  // set all tab urls
85
  advads_set_tab_hashes();
86
 
87
+ // While user is already on the Settings page, find links (in admin menu,
88
+ // in the Checks at the top) to particular setting tabs and open them on click.
89
+ jQuery( '.toplevel_page_advanced-ads a[href*="#top"], .message a[href*="#top"]' ).click( function() {
90
+ // Already on the Settings page, so simulate another click on a tab.
91
+ if ( window.location.href.indexOf( 'page=advanced-ads-settings' ) ) {
92
+ // Extract the tab id from the url.
93
+ var tab = jQuery( this ).attr( 'href' ).split( 'advanced-ads-settings#top#' )[1];
94
+ jQuery( '#advads-tabs' ).find( 'a#' + tab + '-tab' ).click();
95
+ }
96
  });
97
 
98
  // dynamically generate the sub-menu
99
  jQuery( '.advads-tab-sub-menu' ).each( function( key, e ){
100
+ // abort if scrollIntoView is not supported; we can’t use anchors because they are used for tabs already
101
+ if (typeof e.scrollIntoView !== "function") { return; };
102
+ // get all h2 headlines
103
+ advads_settings_parent_tab = jQuery( e ).parent( '.advads-tab');
104
+ var headlines = advads_settings_parent_tab.find( 'h2' );
105
+ // create list
106
+ if( headlines.length ){
107
  advads_submenu_list = jQuery('<ul>');
108
  headlines.each( function( key, h ){
109
+ // create anchor for this headline
110
+ var headline_id = 'advads-tab-headline-' + advads_settings_parent_tab.attr( 'id' ) + key;
111
+ jQuery( h ).attr( 'id', headline_id );
112
+ // place the link in the top menu
113
+ var text = text = h.textContent || h.innerText;
114
+ jQuery( '<li><a onclick="document.getElementById(\'' + headline_id + '\').scrollIntoView()">' + text + '</a></li>' ).appendTo( advads_submenu_list );
115
  });
116
  // place the menu
117
  advads_submenu_list.appendTo( e );
118
+ }
119
  });
120
 
121
+ </script>
admin/views/support.php CHANGED
@@ -3,23 +3,27 @@
3
  * the view for the support page
4
  */
5
  ?><div class="wrap">
6
- <p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
7
-
8
- <h2><?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
9
- <ul>
10
  <li><a href="<?php echo ADVADS_URL; ?>manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Ads not showing up', 'advanced-ads' ); ?></a></li>
11
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/purchase-licenses/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Purchase & Licenses', 'advanced-ads' ); ?></a></li>
12
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/troubleshooting/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'General Issues', 'advanced-ads' ); ?></a></li>
13
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/add-on-issues/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Issues with Add-Ons', 'advanced-ads' ); ?></a></li>
14
- </ul>
15
- <p><?php _e( 'Use the following form to search for solutions in the manual on wpadvancedads.com', 'advanced-ads' ); ?></p>
16
- <form action="https://wpadvancedads.com/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support-form" method="get" class="advads-support-form">
17
  <input type="search" name="s"/>
18
  <input type="submit" class="button button-primary" value="<?php _e( 'search', 'advanced-ads' ); ?>">
19
- </form>
20
- <?php if( Advanced_Ads_Admin_Licenses::any_license_valid() ) : ?>
21
- <p><?php printf(__( 'Take a look at more common issues or contact us directly through the <a href="%s" target="_blank">support page</a>.', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' ); ?></p>
22
- <?php else : ?>
23
- <p><?php printf(__( 'Upgrade to any premium add-on and get <strong>priority email support</strong> or reach out through the <a href="%s" target="_blank">support forum</a> for individual help.', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads' ); ?></p>
24
- <?php endif; ?>
25
- </div>
 
 
 
 
 
3
  * the view for the support page
4
  */
5
  ?><div class="wrap">
6
+ <p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
7
+ <h2><?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
8
+ <ul>
 
9
  <li><a href="<?php echo ADVADS_URL; ?>manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Ads not showing up', 'advanced-ads' ); ?></a></li>
10
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/purchase-licenses/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Purchase & Licenses', 'advanced-ads' ); ?></a></li>
11
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/troubleshooting/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'General Issues', 'advanced-ads' ); ?></a></li>
12
  <li><a href="<?php echo ADVADS_URL; ?>manual-category/add-on-issues/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Issues with Add-Ons', 'advanced-ads' ); ?></a></li>
13
+ </ul>
14
+ <p><?php _e( 'Use the following form to search for solutions in the manual on wpadvancedads.com', 'advanced-ads' ); ?></p>
15
+ <form action="https://wpadvancedads.com/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support-form" method="get" class="advads-support-form">
16
  <input type="search" name="s"/>
17
  <input type="submit" class="button button-primary" value="<?php _e( 'search', 'advanced-ads' ); ?>">
18
+ </form>
19
+ <?php if ( Advanced_Ads_Admin_Licenses::any_license_valid() ) : ?>
20
+ <p><?php printf( __( 'Take a look at more common issues or contact us directly through the <a href="%s" target="_blank">support page</a>.', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' ); ?></p>
21
+ <?php else : ?>
22
+ <p><?php printf( __( 'Upgrade to any premium add-on and get <strong>priority email support</strong> or reach out through the <a href="%s" target="_blank">support forum</a> for individual help.', 'advanced-ads' ), 'https://wordpress.org/support/plugin/advanced-ads' ); ?></p>
23
+ <?php endif; ?>
24
+ <?php if ( $constants = Advanced_Ads_Checks::get_defined_constants() ) : ?>
25
+ <h2><?php _e( 'Advanced Ads related constants enabled', 'advanced-ads' ); ?></h2>
26
+ <ul><li><?php echo implode( '</li><li>', $constants ); ?></li></ul>
27
+ </p>
28
+ <?php endif; ?>
29
+ </div>
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.10.4
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.10.4' );
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.10.5
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.10.5' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/EDD_SL_Plugin_Updater.php CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.6.13
11
  */
12
  class ADVADS_SL_Plugin_Updater {
13
 
@@ -19,6 +19,8 @@ class ADVADS_SL_Plugin_Updater {
19
  private $wp_override = false;
20
  private $cache_key = '';
21
 
 
 
22
  /**
23
  * Class constructor.
24
  *
@@ -112,7 +114,7 @@ class ADVADS_SL_Plugin_Updater {
112
 
113
  }
114
 
115
- $_transient_data->last_checked = current_time( 'timestamp' );
116
  $_transient_data->checked[ $this->name ] = $this->version;
117
 
118
  }
@@ -158,6 +160,19 @@ class ADVADS_SL_Plugin_Updater {
158
  if ( false === $version_info ) {
159
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  $this->set_version_info_cache( $version_info );
162
  }
163
 
@@ -171,7 +186,7 @@ class ADVADS_SL_Plugin_Updater {
171
 
172
  }
173
 
174
- $update_cache->last_checked = current_time( 'timestamp' );
175
  $update_cache->checked[ $this->name ] = $this->version;
176
 
177
  set_site_transient( 'update_plugins', $update_cache );
@@ -251,7 +266,8 @@ class ADVADS_SL_Plugin_Updater {
251
  'is_ssl' => is_ssl(),
252
  'fields' => array(
253
  'banners' => array(),
254
- 'reviews' => false
 
255
  )
256
  );
257
 
@@ -278,26 +294,42 @@ class ADVADS_SL_Plugin_Updater {
278
 
279
  // Convert sections into an associative array, since we're getting an object, but Core expects an array.
280
  if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
281
- $new_sections = array();
282
- foreach ( $_data->sections as $key => $value ) {
283
- $new_sections[ $key ] = $value;
284
- }
285
-
286
- $_data->sections = $new_sections;
287
  }
288
 
289
  // Convert banners into an associative array, since we're getting an object, but Core expects an array.
290
  if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
291
- $new_banners = array();
292
- foreach ( $_data->banners as $key => $value ) {
293
- $new_banners[ $key ] = $value;
294
- }
295
-
296
- $_data->banners = $new_banners;
297
  }
298
 
299
  return $_data;
300
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
  /**
303
  * Disable SSL verification in order to prevent download update failures
@@ -329,15 +361,37 @@ class ADVADS_SL_Plugin_Updater {
329
  */
330
  private function api_request( $_action, $_data ) {
331
 
332
- global $wp_version;
 
 
 
 
 
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  $data = array_merge( $this->api_data, $_data );
335
 
336
  if ( $data['slug'] != $this->slug ) {
337
  return;
338
  }
339
 
340
- if( $this->api_url == trailingslashit (home_url() ) ) {
341
  return false; // Don't allow a plugin to ping itself
342
  }
343
 
@@ -369,6 +423,10 @@ class ADVADS_SL_Plugin_Updater {
369
  if ( $request && isset( $request->banners ) ) {
370
  $request->banners = maybe_unserialize( $request->banners );
371
  }
 
 
 
 
372
 
373
  if( ! empty( $request->sections ) ) {
374
  foreach( $request->sections as $key => $section ) {
@@ -455,11 +513,17 @@ class ADVADS_SL_Plugin_Updater {
455
 
456
  $cache = get_option( $cache_key );
457
 
458
- if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
459
  return false; // Cache is expired
460
  }
461
 
462
- return json_decode( $cache['value'] );
 
 
 
 
 
 
463
 
464
  }
465
 
@@ -470,11 +534,11 @@ class ADVADS_SL_Plugin_Updater {
470
  }
471
 
472
  $data = array(
473
- 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
474
  'value' => json_encode( $value )
475
  );
476
 
477
- update_option( $cache_key, $data );
478
 
479
  }
480
 
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
+ * @version 1.6.17
11
  */
12
  class ADVADS_SL_Plugin_Updater {
13
 
19
  private $wp_override = false;
20
  private $cache_key = '';
21
 
22
+ private $health_check_timeout = 5;
23
+
24
  /**
25
  * Class constructor.
26
  *
114
 
115
  }
116
 
117
+ $_transient_data->last_checked = time();
118
  $_transient_data->checked[ $this->name ] = $this->version;
119
 
120
  }
160
  if ( false === $version_info ) {
161
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
162
 
163
+ // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
164
+ if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
165
+ $version_info->banners = $this->convert_object_to_array( $version_info->banners );
166
+ }
167
+
168
+ if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
169
+ $version_info->sections = $this->convert_object_to_array( $version_info->sections );
170
+ }
171
+
172
+ if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
173
+ $version_info->icons = $this->convert_object_to_array( $version_info->icons );
174
+ }
175
+
176
  $this->set_version_info_cache( $version_info );
177
  }
178
 
186
 
187
  }
188
 
189
+ $update_cache->last_checked = time();
190
  $update_cache->checked[ $this->name ] = $this->version;
191
 
192
  set_site_transient( 'update_plugins', $update_cache );
266
  'is_ssl' => is_ssl(),
267
  'fields' => array(
268
  'banners' => array(),
269
+ 'reviews' => false,
270
+ 'icons' => array(),
271
  )
272
  );
273
 
294
 
295
  // Convert sections into an associative array, since we're getting an object, but Core expects an array.
296
  if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
297
+ $_data->sections = $this->convert_object_to_array( $_data->sections );
 
 
 
 
 
298
  }
299
 
300
  // Convert banners into an associative array, since we're getting an object, but Core expects an array.
301
  if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
302
+ $_data->banners = $this->convert_object_to_array( $_data->banners );
303
+ }
304
+
305
+ // Convert icons into an associative array, since we're getting an object, but Core expects an array.
306
+ if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
307
+ $_data->icons = $this->convert_object_to_array( $_data->icons );
308
  }
309
 
310
  return $_data;
311
  }
312
+
313
+ /**
314
+ * Convert some objects to arrays when injecting data into the update API
315
+ *
316
+ * Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
317
+ * decoding, they are objects. This method allows us to pass in the object and return an associative array.
318
+ *
319
+ * @since 3.6.5
320
+ *
321
+ * @param stdClass $data
322
+ *
323
+ * @return array
324
+ */
325
+ private function convert_object_to_array( $data ) {
326
+ $new_data = array();
327
+ foreach ( $data as $key => $value ) {
328
+ $new_data[ $key ] = $value;
329
+ }
330
+
331
+ return $new_data;
332
+ }
333
 
334
  /**
335
  * Disable SSL verification in order to prevent download update failures
361
  */
362
  private function api_request( $_action, $_data ) {
363
 
364
+ global $wp_version, $edd_plugin_url_available;
365
+
366
+ // Do a quick status check on this domain if we haven't already checked it.
367
+ $store_hash = md5( $this->api_url );
368
+ if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
369
+ $test_url_parts = parse_url( $this->api_url );
370
 
371
+ $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
372
+ $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
373
+ $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
374
+
375
+ if ( empty( $host ) ) {
376
+ $edd_plugin_url_available[ $store_hash ] = false;
377
+ } else {
378
+ $test_url = $scheme . '://' . $host . $port;
379
+ $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => true ) );
380
+ $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
381
+ }
382
+ }
383
+
384
+ if ( false === $edd_plugin_url_available[ $store_hash ] ) {
385
+ return;
386
+ }
387
+
388
  $data = array_merge( $this->api_data, $_data );
389
 
390
  if ( $data['slug'] != $this->slug ) {
391
  return;
392
  }
393
 
394
+ if( $this->api_url == trailingslashit ( home_url() ) ) {
395
  return false; // Don't allow a plugin to ping itself
396
  }
397
 
423
  if ( $request && isset( $request->banners ) ) {
424
  $request->banners = maybe_unserialize( $request->banners );
425
  }
426
+
427
+ if ( $request && isset( $request->icons ) ) {
428
+ $request->icons = maybe_unserialize( $request->icons );
429
+ }
430
 
431
  if( ! empty( $request->sections ) ) {
432
  foreach( $request->sections as $key => $section ) {
513
 
514
  $cache = get_option( $cache_key );
515
 
516
+ if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
517
  return false; // Cache is expired
518
  }
519
 
520
+ // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
521
+ $cache['value'] = json_decode( $cache['value'] );
522
+ if ( ! empty( $cache['value']->icons ) ) {
523
+ $cache['value']->icons = (array) $cache['value']->icons;
524
+ }
525
+
526
+ return $cache['value'];
527
 
528
  }
529
 
534
  }
535
 
536
  $data = array(
537
+ 'timeout' => strtotime( '+3 hours', time() ),
538
  'value' => json_encode( $value )
539
  );
540
 
541
+ update_option( $cache_key, $data, 'no' );
542
 
543
  }
544
 
classes/ad_group.php CHANGED
@@ -230,7 +230,7 @@ class Advanced_Ads_Group {
230
  }
231
  }
232
 
233
- if ( ! isset( $args['global_output'] ) || $args['global_output'] ) {
234
  // add the group to the global output array
235
  $advads = Advanced_Ads::get_instance();
236
  $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
230
  }
231
  }
232
 
233
+ if ( ! isset( $this->ad_args['global_output'] ) || $this->ad_args['global_output'] ) {
234
  // add the group to the global output array
235
  $advads = Advanced_Ads::get_instance();
236
  $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
classes/ad_type_image.php CHANGED
@@ -83,6 +83,12 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
83
 
84
  if ( $image ) {
85
  list( $src, $width, $height ) = $image;
 
 
 
 
 
 
86
  $hwstring = image_hwstring($width, $height);
87
  $attachment = get_post($attachment_id);
88
  $alt = trim(esc_textarea( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ));
@@ -170,5 +176,35 @@ class Advanced_Ads_Ad_Type_Image extends Advanced_Ads_Ad_Type_Abstract{
170
 
171
  return ob_get_clean();
172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  }
83
 
84
  if ( $image ) {
85
  list( $src, $width, $height ) = $image;
86
+ // override image sizes with the sizes given in ad options, but in frontend only
87
+ if( ! is_admin() || ( // is frontend
88
+ is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) ){ // is AJAX call (cache-busting)
89
+ $width = isset( $ad->width ) ? absint( $ad->width ) : $width;
90
+ $height = isset( $ad->height ) ? absint( $ad->height ) : $height;
91
+ }
92
  $hwstring = image_hwstring($width, $height);
93
  $attachment = get_post($attachment_id);
94
  $alt = trim(esc_textarea( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ));
176
 
177
  return ob_get_clean();
178
  }
179
+
180
+ /**
181
+ * Generate a string with the original image size for output in the backend
182
+ * Only show, if different from entered image sizes
183
+ *
184
+ * @param obj $ad Advanced_Ads_Ad
185
+ * @return str empty, if the entered size is the same as the original size
186
+ */
187
+ public static function show_original_image_size( $ad ){
188
+
189
+ $attachment_id = ( isset( $ad->output['image_id'] ) ) ? absint( $ad->output['image_id'] ) : '';
190
+
191
+ $image = wp_get_attachment_image_src( $attachment_id, 'full' );
192
+
193
+ if ( $image ) {
194
+ list( $src, $width, $height ) = $image;
195
+ ?><p class="description"><?php if( ( isset( $ad->width ) && $ad->width != $width )
196
+ || ( isset( $ad->height ) && $ad->height != $height ) ) {
197
+ printf(
198
+ /**
199
+ * translators: $s is a size string like "728 x 90".
200
+ * This string shows up on the ad edit page of image ads if the size entered for the ad is different from the size of the uploaded image.
201
+ */
202
+ esc_attr__( 'Original size: %s', 'advanced-ads' ), $width . '&nbsp;x&nbsp;' . $height ); ?></p><?php
203
+ }
204
+ }
205
+
206
+ return '';
207
+
208
+ }
209
 
210
  }
classes/checks.php CHANGED
@@ -217,6 +217,41 @@ class Advanced_Ads_Checks {
217
  return $missing_extensions;
218
  }
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  /**
222
  * check for potential jQuery errors
@@ -235,4 +270,4 @@ class Advanced_Ads_Checks {
235
  });
236
  </script><?php
237
  }
238
- }
217
  return $missing_extensions;
218
  }
219
 
220
+ /**
221
+ * Get the list of Advanced Ads constant defined by the user.
222
+ *
223
+ * @return array
224
+ */
225
+ public static function get_defined_constants() {
226
+ $constants = apply_filters( 'advanced-ads-constants', array(
227
+ 'ADVADS_ADS_DISABLED',
228
+ 'ADVADS_ALLOW_ADSENSE_ON_404',
229
+ 'ADVADS_DISABLE_RESPONSIVE_IMAGES',
230
+ 'ADVANCED_ADS_AD_DEBUG_FOR_ADMIN_ONLY',
231
+ 'ADVANCED_ADS_DISABLE_ANALYTICS_ANONYMIZE_IP',
232
+ 'ADVANCED_ADS_DISABLE_CHANGE',
233
+ 'ADVANCED_ADS_DISABLE_CODE_HIGHLIGHTING',
234
+ 'ADVANCED_ADS_DISABLE_FRONTEND_AD_WEIGHT_UPDATE',
235
+ 'ADVANCED_ADS_DISABLE_SHORTCODE_BUTTON',
236
+ 'ADVANCED_ADS_DISALLOW_PHP',
237
+ 'ADVANCED_ADS_ENABLE_REVISIONS',
238
+ 'ADVANCED_ADS_PRO_CUSTOM_POSITION_MOVE_INTO_HIDDEN',
239
+ 'ADVANCED_ADS_PRO_PAGE_IMPR_EXDAYS',
240
+ 'ADVANCED_ADS_PRO_REFERRER_EXDAYS',
241
+ 'ADVANCED_ADS_RESPONSIVE_DISABLE_BROWSER_WIDTH',
242
+ 'ADVANCED_ADS_SUPPRESS_PLUGIN_ERROR_NOTICES',
243
+ 'ADVANCED_ADS_TRACKING_DEBUG',
244
+ 'ADVANCED_ADS_TRACKING_NO_HOURLY_LIMIT',
245
+ ) );
246
+
247
+ $result = array();
248
+ foreach ( $constants as $constant ) {
249
+ if ( defined( $constant ) ) {
250
+ $result[] = $constant;
251
+ }
252
+ }
253
+ return $result;
254
+ }
255
 
256
  /**
257
  * check for potential jQuery errors
270
  });
271
  </script><?php
272
  }
273
+ }
classes/frontend_checks.php CHANGED
@@ -123,7 +123,7 @@ class Advanced_Ads_Frontend_Checks {
123
  'parent' => 'advanced_ads_ad_health',
124
  'id' => 'advanced_ads_ad_health_the_content_not_invoked',
125
  'title' => sprintf( __( '<em>%s</em> filter does not exist', 'advanced-ads' ), 'the_content' ),
126
- 'href' => 'https://wpadvancedads.com/manual/ads-not-showing-up/#frontend-issues-the-content-filter',
127
  'meta' => array(
128
  'class' => 'advanced_ads_ad_health_warning',
129
  'target' => '_blank'
@@ -235,7 +235,7 @@ class Advanced_Ads_Frontend_Checks {
235
  __( 'Your website is using HTTPS, but the ad code contains HTTP and might not work.', 'advanced-ads' ),
236
  sprintf( __( 'Ad IDs: %s', 'advanced-ads' ), '<i></i>' )
237
  ),
238
- 'href' => 'https://wpadvancedads.com/manual/ad-health/#https-ads',
239
  'meta' => array(
240
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_has_http',
241
  'target' => '_blank'
@@ -246,7 +246,7 @@ class Advanced_Ads_Frontend_Checks {
246
  'parent' => 'advanced_ads_ad_health',
247
  'id' => 'advanced_ads_ad_health_incorrect_head',
248
  'title' => sprintf( __( 'Visible ads should not use the Header placement: %s', 'advanced-ads' ), '<i></i>' ),
249
- 'href' => 'https://wpadvancedads.com/manual/ad-health/#header-ads',
250
  'meta' => array(
251
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_incorrect_head',
252
  'target' => '_blank'
@@ -263,13 +263,24 @@ class Advanced_Ads_Frontend_Checks {
263
  __( 'Ad is hidden', 'advanced-ads' ),
264
  sprintf( __( 'IDs: %s', 'advanced-ads' ), '<i></i>' )
265
  ),
266
- 'href' => 'https://wpadvancedads.com/manual/ad-health/#adsense-hidden&utm_source=advanced-ads&utm_medium=link&utm_campaign=frontend-adsense-hidden',
267
  'meta' => array(
268
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_hidden_adsense',
269
  'target' => '_blank'
270
  )
271
  ) );
272
  }
 
 
 
 
 
 
 
 
 
 
 
273
 
274
  // warn if consent was not given
275
  $privacy_state = Advanced_Ads_Privacy::get_instance()->get_state();
@@ -405,17 +416,70 @@ class Advanced_Ads_Frontend_Checks {
405
  }
406
  }
407
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  add_item_to_node: function( selector, item ) {
 
 
 
409
  var selector = document.querySelector( selector );
410
  if ( selector ) {
411
  selector.className = selector.className.replace( 'hidden', '' );
412
  selector.innerHTML = selector.innerHTML.replace( /(<i>)(.*?)(<\/i>)/, function( match, p1, p2, p3 ) {
413
  p2 = ( p2 ) ? p2.split( ', ' ) : [];
414
- if ( p2.indexOf( item ) === -1 ) p2.push( item );
 
415
  return p1 + p2.join( ', ' ) + p3;
416
  } );
417
  advanced_ads_frontend_checks.showCount();
418
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  }
420
  };
421
 
@@ -467,31 +531,9 @@ class Advanced_Ads_Frontend_Checks {
467
  <?php if( ! isset( $adsense_options['violation-warnings-disable'] ) ) : ?>
468
  // show warning if AdSense ad is hidden
469
  setTimeout( function(){
470
- advanced_ads_ready( advads_highlight_hidden_adsense );
471
  }, 2000 );
472
- function advads_highlight_hidden_adsense(){
473
- if ( window.jQuery ) {
474
- var advads_ad_health_check_adsense_hidden_ids = [];
475
- jQuery('ins.adsbygoogle').each( function(){
476
- if( ! jQuery( this ).parent().is(':visible') ){
477
- advads_ad_health_check_adsense_hidden_ids.push( this.dataset.adSlot );
478
- }
479
- });
480
- if( advads_ad_health_check_adsense_hidden_ids.length ){
481
- var advads_has_hidden_adsense_link = document.querySelector( '.advanced_ads_ad_health_hidden_adsense' );
482
- if ( advads_has_hidden_adsense_link ) {
483
- advads_has_hidden_adsense_link.className = advads_has_hidden_adsense_link.className.replace( 'hidden', '' );
484
- advads_has_hidden_adsense_link.innerHTML = advads_has_hidden_adsense_link.innerHTML.replace( /(<i>)(.*?)(<\/i>)/, function( match, p1, p2, p3 ) {
485
- var ad_id = advads_ad_health_check_adsense_hidden_ids.join( ', ');
486
- p2 = ( p2 ) ? p2.split( ', ' ) : [];
487
- if ( p2.indexOf( ad_id ) === -1 ) p2.push( ad_id );
488
- return p1 + p2.join( ', ' ) + p3;
489
- } );
490
- advanced_ads_frontend_checks.showCount();
491
- }
492
- }
493
- }
494
- };
495
 
496
  // highlight AdSense Auto Ads ads 3 seconds after site loaded
497
  setTimeout( function(){
@@ -581,9 +623,25 @@ class Advanced_Ads_Frontend_Checks {
581
  $content .= Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
582
  }
583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  return $content;
585
  }
586
 
 
587
  /**
588
  * Check if the 'Header Code' placement can be used to delived the ad.
589
  *
123
  'parent' => 'advanced_ads_ad_health',
124
  'id' => 'advanced_ads_ad_health_the_content_not_invoked',
125
  'title' => sprintf( __( '<em>%s</em> filter does not exist', 'advanced-ads' ), 'the_content' ),
126
+ 'href' => ADVADS_URL . 'manual/ads-not-showing-up/#the_content-filter-missing',
127
  'meta' => array(
128
  'class' => 'advanced_ads_ad_health_warning',
129
  'target' => '_blank'
235
  __( 'Your website is using HTTPS, but the ad code contains HTTP and might not work.', 'advanced-ads' ),
236
  sprintf( __( 'Ad IDs: %s', 'advanced-ads' ), '<i></i>' )
237
  ),
238
+ 'href' => 'https://wpadvancedads.com/manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adhealth-https-ads#https-ads',
239
  'meta' => array(
240
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_has_http',
241
  'target' => '_blank'
246
  'parent' => 'advanced_ads_ad_health',
247
  'id' => 'advanced_ads_ad_health_incorrect_head',
248
  'title' => sprintf( __( 'Visible ads should not use the Header placement: %s', 'advanced-ads' ), '<i></i>' ),
249
+ 'href' => 'https://wpadvancedads.com/manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adhealth-visible-ad-in-header#header-ads',
250
  'meta' => array(
251
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_incorrect_head',
252
  'target' => '_blank'
263
  __( 'Ad is hidden', 'advanced-ads' ),
264
  sprintf( __( 'IDs: %s', 'advanced-ads' ), '<i></i>' )
265
  ),
266
+ 'href' => 'https://wpadvancedads.com/manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adhealth-frontend-adsense-hidden#adsense-hidden',
267
  'meta' => array(
268
  'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_hidden_adsense',
269
  'target' => '_blank'
270
  )
271
  ) );
272
  }
273
+
274
+ $nodes[] = array( 'type' => 2, 'data' => array(
275
+ 'parent' => 'advanced_ads_ad_health',
276
+ 'id' => 'advanced_ads_ad_health_floated_responsive_adsense',
277
+ 'title' => sprintf( __( 'The following responsive AdSense ads are not showing up: %s', 'advanced-ads' ), '<i></i>' ),
278
+ 'href' => 'https://wpadvancedads.com/manual/ad-health/?utm_source=advanced-ads&utm_medium=link&utm_campaign=adhealth-adsense-responsive-not-showing#The_following_responsive_AdSense_ads_arenot_showing_up',
279
+ 'meta' => array(
280
+ 'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_floated_responsive_adsense',
281
+ 'target' => '_blank'
282
+ )
283
+ ) );
284
 
285
  // warn if consent was not given
286
  $privacy_state = Advanced_Ads_Privacy::get_instance()->get_state();
416
  }
417
  }
418
  },
419
+
420
+ array_unique: function( array ) {
421
+ var r= [];
422
+ for ( var i = 0; i < array.length; i++ ) {
423
+ if ( r.indexOf( array[ i ] ) === -1 ) {
424
+ r.push( array[ i ] );
425
+ }
426
+ }
427
+ return r;
428
+ },
429
+
430
+ /**
431
+ * Add item to Ad Health node.
432
+ *
433
+ * @param string selector Selector of the node.
434
+ * @param string/array Item(s) to add.
435
+ */
436
  add_item_to_node: function( selector, item ) {
437
+ if ( typeof item === 'string' ) {
438
+ item = item.split();
439
+ }
440
  var selector = document.querySelector( selector );
441
  if ( selector ) {
442
  selector.className = selector.className.replace( 'hidden', '' );
443
  selector.innerHTML = selector.innerHTML.replace( /(<i>)(.*?)(<\/i>)/, function( match, p1, p2, p3 ) {
444
  p2 = ( p2 ) ? p2.split( ', ' ) : [];
445
+ p2 = p2.concat( item );
446
+ p2 = advanced_ads_frontend_checks.array_unique( p2 );
447
  return p1 + p2.join( ', ' ) + p3;
448
  } );
449
  advanced_ads_frontend_checks.showCount();
450
  }
451
+ },
452
+
453
+ /**
454
+ * Search for hidden AdSense.
455
+ *
456
+ * @param string context Context for search.
457
+ */
458
+ advads_highlight_hidden_adsense: function( context ) {
459
+ if ( ! context ) {
460
+ context = 'html'
461
+ }
462
+ if ( window.jQuery ) {
463
+ var advads_ad_health_check_adsense_hidden_ids = [];
464
+ var responsive_zero_width = [];
465
+ jQuery( 'ins.adsbygoogle', context ).each( function() {
466
+ // The parent container is invisible.
467
+ if( ! jQuery( this ).parent().is(':visible') ){
468
+ advads_ad_health_check_adsense_hidden_ids.push( this.dataset.adSlot );
469
+ }
470
+
471
+ // Zero width, perhaps because a parent container is floated
472
+ if ( jQuery( this ).attr( 'data-ad-format' ) && 0 === jQuery( this ).width() ) {
473
+ responsive_zero_width.push( this.dataset.adSlot );
474
+ }
475
+ });
476
+ if( advads_ad_health_check_adsense_hidden_ids.length ){
477
+ advanced_ads_frontend_checks.add_item_to_node( '.advanced_ads_ad_health_hidden_adsense', advads_ad_health_check_adsense_hidden_ids );
478
+ }
479
+ if ( responsive_zero_width.length ) {
480
+ advanced_ads_frontend_checks.add_item_to_node( '.advanced_ads_ad_health_floated_responsive_adsense', responsive_zero_width );
481
+ }
482
+ }
483
  }
484
  };
485
 
531
  <?php if( ! isset( $adsense_options['violation-warnings-disable'] ) ) : ?>
532
  // show warning if AdSense ad is hidden
533
  setTimeout( function(){
534
+ advanced_ads_ready( advanced_ads_frontend_checks.advads_highlight_hidden_adsense );
535
  }, 2000 );
536
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
 
538
  // highlight AdSense Auto Ads ads 3 seconds after site loaded
539
  setTimeout( function(){
623
  $content .= Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
624
  }
625
 
626
+ $adsense_options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
627
+ if ( 'adsense' === $ad->type
628
+ && ! empty( $ad->args['cache_busting_elementid'] )
629
+ && ! isset( $adsense_options['violation-warnings-disable'] )
630
+ ) {
631
+ ob_start(); ?>
632
+ <script>advanced_ads_ready( function() {
633
+ var ad_id = '<?php echo $ad->id; ?>';
634
+ var wrapper = '#<?php echo $ad->args['cache_busting_elementid']; ?>';
635
+ advanced_ads_frontend_checks.advads_highlight_hidden_adsense( wrapper );
636
+ });</script>
637
+ <?php
638
+ $content .= Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
639
+ }
640
+
641
  return $content;
642
  }
643
 
644
+
645
  /**
646
  * Check if the 'Header Code' placement can be used to delived the ad.
647
  *
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: 2018-08-20 12:08+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"
@@ -23,38 +23,38 @@ msgstr ""
23
  "X-Poedit-Basepath: ../\n"
24
  "X-Poedit-SearchPath-0: ."
25
 
26
- #: admin/class-advanced-ads-admin.php:222 classes/display-conditions.php:211
27
  #: classes/visitor-conditions.php:241 admin/views/ad-display-metabox.php:134
28
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:68
29
  msgid "or"
30
  msgstr ""
31
 
32
- #: admin/class-advanced-ads-admin.php:223 classes/display-conditions.php:211
33
  #: classes/visitor-conditions.php:241 admin/views/ad-visitor-metabox.php:120
34
  msgid "and"
35
  msgstr ""
36
 
37
- #: admin/class-advanced-ads-admin.php:224
38
  msgid "After which paragraph?"
39
  msgstr ""
40
 
41
- #: admin/class-advanced-ads-admin.php:334
42
  #, php-format
43
  msgid "time of %s"
44
  msgstr ""
45
 
46
- #: admin/class-advanced-ads-admin.php:375 admin/includes/class-menu.php:107
47
  #: admin/includes/class-menu.php:110 admin/views/settings.php:26
48
  msgid "Support"
49
  msgstr ""
50
 
51
- #: admin/class-advanced-ads-admin.php:379
52
  #: admin/includes/class-overview-widgets.php:33
53
  msgid "Add-Ons"
54
  msgstr ""
55
 
56
- #: admin/class-advanced-ads-admin.php:633
57
- #: admin/includes/class-overview-widgets.php:132
58
  #, php-format
59
  msgid ""
60
  "Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a "
@@ -146,7 +146,7 @@ msgstr ""
146
  msgid "Injected in Footer (before closing &lt;/body&gt; Tag)."
147
  msgstr ""
148
 
149
- #: classes/ad_placements.php:47 admin/views/placement-injection-top.php:14
150
  msgid "Before Content"
151
  msgstr ""
152
 
@@ -154,7 +154,7 @@ msgstr ""
154
  msgid "Injected before the post content."
155
  msgstr ""
156
 
157
- #: classes/ad_placements.php:53 admin/views/placement-injection-top.php:16
158
  msgid "After Content"
159
  msgstr ""
160
 
@@ -162,7 +162,7 @@ msgstr ""
162
  msgid "Injected after the post content."
163
  msgstr ""
164
 
165
- #: classes/ad_placements.php:59 admin/views/placement-injection-top.php:15
166
  msgid "Content"
167
  msgstr ""
168
 
@@ -280,6 +280,15 @@ msgstr ""
280
  msgid "Link to target site"
281
  msgstr ""
282
 
 
 
 
 
 
 
 
 
 
283
  #: classes/ad_type_plain.php:31
284
  msgid "Plain Text and Code"
285
  msgstr ""
@@ -310,7 +319,7 @@ msgstr ""
310
  msgid "Execute shortcodes"
311
  msgstr ""
312
 
313
- #: classes/checks.php:222
314
  #, php-format
315
  msgid ""
316
  "Possible conflict between jQueryUI library, used by Advanced Ads and other "
@@ -360,30 +369,30 @@ msgstr ""
360
  msgid "Display ads based on the taxonomy of an archive page."
361
  msgstr ""
362
 
363
- #: classes/display-conditions.php:143
364
  #, php-format
365
  msgid "archive: %s"
366
  msgstr ""
367
 
368
- #: classes/display-conditions.php:246 classes/display-conditions.php:299
369
- #: classes/display-conditions.php:354 classes/display-conditions.php:471
370
  #: classes/visitor-conditions.php:136
371
  msgid "is"
372
  msgstr ""
373
 
374
- #: classes/display-conditions.php:247 classes/display-conditions.php:300
375
- #: classes/display-conditions.php:355 classes/display-conditions.php:472
376
  #: classes/visitor-conditions.php:137
377
  msgid "is not"
378
  msgstr ""
379
 
380
- #: classes/display-conditions.php:270 classes/display-conditions.php:315
381
- #: classes/display-conditions.php:402 classes/display-conditions.php:446
382
  msgctxt "Error message shown when no display condition term is selected"
383
  msgid "Please select some items."
384
  msgstr ""
385
 
386
- #: classes/display-conditions.php:316
387
  #, php-format
388
  msgid ""
389
  "Only %d elements are displayed above. Use the <code>advanced-ads-admin-max-"
@@ -391,90 +400,90 @@ msgid ""
391
  "target=\"_blank\">this page</a>."
392
  msgstr ""
393
 
394
- #: classes/display-conditions.php:437
395
  msgctxt "display the terms search field on ad edit page"
396
  msgid "add more terms"
397
  msgstr ""
398
 
399
- #: classes/display-conditions.php:439
400
  msgid "term name or id"
401
  msgstr ""
402
 
403
- #: classes/display-conditions.php:500
404
  msgid "title or id"
405
  msgstr ""
406
 
407
- #: classes/display-conditions.php:545 includes/array_ad_conditions.php:63
408
  msgid "Home Page"
409
  msgstr ""
410
 
411
- #: classes/display-conditions.php:546 includes/array_ad_conditions.php:64
412
  msgid "show on Home page"
413
  msgstr ""
414
 
415
- #: classes/display-conditions.php:550 includes/array_ad_conditions.php:68
416
  msgid "Singular Pages"
417
  msgstr ""
418
 
419
- #: classes/display-conditions.php:551 includes/array_ad_conditions.php:69
420
  msgid "show on singular pages/posts"
421
  msgstr ""
422
 
423
- #: classes/display-conditions.php:555 includes/array_ad_conditions.php:73
424
  msgid "Archive Pages"
425
  msgstr ""
426
 
427
- #: classes/display-conditions.php:556 includes/array_ad_conditions.php:74
428
  msgid "show on any type of archive page (category, tag, author and date)"
429
  msgstr ""
430
 
431
- #: classes/display-conditions.php:560 includes/array_ad_conditions.php:78
432
  msgid "Search Results"
433
  msgstr ""
434
 
435
- #: classes/display-conditions.php:561 includes/array_ad_conditions.php:79
436
  msgid "show on search result pages"
437
  msgstr ""
438
 
439
- #: classes/display-conditions.php:565 includes/array_ad_conditions.php:83
440
  msgid "404 Page"
441
  msgstr ""
442
 
443
- #: classes/display-conditions.php:566 includes/array_ad_conditions.php:84
444
  msgid "show on 404 error page"
445
  msgstr ""
446
 
447
- #: classes/display-conditions.php:570 includes/array_ad_conditions.php:88
448
  msgid "Attachment Pages"
449
  msgstr ""
450
 
451
- #: classes/display-conditions.php:571 includes/array_ad_conditions.php:89
452
  msgid "show on attachment pages"
453
  msgstr ""
454
 
455
- #: classes/display-conditions.php:575 includes/array_ad_conditions.php:93
456
  msgid "Secondary Queries"
457
  msgstr ""
458
 
459
- #: classes/display-conditions.php:576 includes/array_ad_conditions.php:94
460
  msgid "allow ads in secondary queries"
461
  msgstr ""
462
 
463
- #: classes/display-conditions.php:580
464
  msgid "Feed"
465
  msgstr ""
466
 
467
- #: classes/display-conditions.php:581
468
  msgid "allow ads in Feed"
469
  msgstr ""
470
 
471
- #: classes/EDD_SL_Plugin_Updater.php:201
472
  #, php-format
473
  msgid ""
474
  "There is a new version of %1$s available. %2$sView version %3$s details%4$s."
475
  msgstr ""
476
 
477
- #: classes/EDD_SL_Plugin_Updater.php:209
478
  #, php-format
479
  msgid ""
480
  "There is a new version of %1$s available. %2$sView version %3$s details%4$s "
@@ -905,82 +914,86 @@ msgstr ""
905
  msgid "No ad group created"
906
  msgstr ""
907
 
908
- #: admin/includes/class-ad-type.php:81 admin/includes/class-ad-type.php:86
909
  msgid "Ad Details"
910
  msgstr ""
911
 
912
- #: admin/includes/class-ad-type.php:82 admin/includes/class-ad-type.php:87
913
  msgid "Ad Planning"
914
  msgstr ""
915
 
916
- #: admin/includes/class-ad-type.php:199
 
 
 
 
917
  #, php-format
918
  msgid "%s ad updated."
919
  msgid_plural "%s ads updated."
920
  msgstr[0] ""
921
  msgstr[1] ""
922
 
923
- #: admin/includes/class-ad-type.php:200
924
  #, php-format
925
  msgid "%s ad not updated, somebody is editing it."
926
  msgid_plural "%s ads not updated, somebody is editing them."
927
  msgstr[0] ""
928
  msgstr[1] ""
929
 
930
- #: admin/includes/class-ad-type.php:201
931
  #, php-format
932
  msgid "%s ad permanently deleted."
933
  msgid_plural "%s ads permanently deleted."
934
  msgstr[0] ""
935
  msgstr[1] ""
936
 
937
- #: admin/includes/class-ad-type.php:202
938
  #, php-format
939
  msgid "%s ad moved to the Trash."
940
  msgid_plural "%s ads moved to the Trash."
941
  msgstr[0] ""
942
  msgstr[1] ""
943
 
944
- #: admin/includes/class-ad-type.php:203
945
  #, php-format
946
  msgid "%s ad restored from the Trash."
947
  msgid_plural "%s ads restored from the Trash."
948
  msgstr[0] ""
949
  msgstr[1] ""
950
 
951
- #: admin/includes/class-ad-type.php:532 admin/includes/class-ad-type.php:533
952
  msgid "Ad updated."
953
  msgstr ""
954
 
955
  #. translators: %s: date and time of the revision
956
- #: admin/includes/class-ad-type.php:535
957
  #, php-format
958
  msgid "Ad restored to revision from %s"
959
  msgstr ""
960
 
961
- #: admin/includes/class-ad-type.php:536 admin/includes/class-ad-type.php:537
962
  msgid "Ad saved."
963
  msgstr ""
964
 
965
- #: admin/includes/class-ad-type.php:538
966
  msgid "Ad submitted."
967
  msgstr ""
968
 
969
- #: admin/includes/class-ad-type.php:540
970
  #, php-format
971
  msgid "Ad scheduled for: <strong>%1$s</strong>."
972
  msgstr ""
973
 
974
  #. translators: Publish box date format, see http://php.net/date
975
- #: admin/includes/class-ad-type.php:542
976
  msgid "M j, Y @ G:i"
977
  msgstr ""
978
 
979
- #: admin/includes/class-ad-type.php:544
980
  msgid "Ad draft updated."
981
  msgstr ""
982
 
983
- #: admin/includes/class-ad-type.php:631
984
  msgid ""
985
  "You don’t have access to ads. Please deactivate and re-enable Advanced Ads "
986
  "again to fix this."
@@ -1052,7 +1065,7 @@ msgstr ""
1052
 
1053
  #: admin/includes/class-list-filters.php:129
1054
  #: modules/gadsense/admin/admin.php:29
1055
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:102
1056
  msgid "Responsive"
1057
  msgstr ""
1058
 
@@ -1130,36 +1143,36 @@ msgstr ""
1130
  msgid "Video"
1131
  msgstr ""
1132
 
1133
- #: admin/includes/class-meta-box.php:244
1134
  msgid "Ad Settings"
1135
  msgstr ""
1136
 
1137
- #: admin/includes/class-meta-box.php:346 admin/views/overview.php:6
1138
  msgid "Ads Dashboard"
1139
  msgstr ""
1140
 
1141
- #: admin/includes/class-meta-box.php:357
1142
  #, php-format
1143
  msgid "%d ads – <a href=\"%s\">manage</a> - <a href=\"%s\">new</a>"
1144
  msgstr ""
1145
 
1146
- #: admin/includes/class-meta-box.php:369
1147
  msgid "plugin manual and homepage"
1148
  msgstr ""
1149
 
1150
- #: admin/includes/class-meta-box.php:376
1151
  msgid "Get the tutorial via email"
1152
  msgstr ""
1153
 
1154
- #: admin/includes/class-meta-box.php:383
1155
  msgid "Get AdSense tips via email"
1156
  msgstr ""
1157
 
1158
- #: admin/includes/class-meta-box.php:439
1159
  msgid "From the ad optimization universe"
1160
  msgstr ""
1161
 
1162
- #: admin/includes/class-meta-box.php:448
1163
  msgid "Advanced Ads Tutorials"
1164
  msgstr ""
1165
 
@@ -1196,192 +1209,199 @@ msgstr ""
1196
  msgid "Create your first ad"
1197
  msgstr ""
1198
 
1199
- #: admin/includes/class-overview-widgets.php:75
 
 
 
 
 
 
 
1200
  msgid "Join the newsletter for more benefits"
1201
  msgstr ""
1202
 
1203
- #: admin/includes/class-overview-widgets.php:77
1204
  msgid "Get 2 free add-ons"
1205
  msgstr ""
1206
 
1207
- #: admin/includes/class-overview-widgets.php:78
1208
  msgid "Get the first steps and more tutorials to your inbox"
1209
  msgstr ""
1210
 
1211
- #: admin/includes/class-overview-widgets.php:79
1212
  msgid "How to earn more with AdSense"
1213
  msgstr ""
1214
 
1215
- #: admin/includes/class-overview-widgets.php:82
1216
  msgid "Join now"
1217
  msgstr ""
1218
 
1219
- #: admin/includes/class-overview-widgets.php:90 admin/includes/notices.php:49
1220
  msgid ""
1221
  "Do you find Advanced Ads useful and would like to keep us motivated? Please "
1222
  "help us with a review."
1223
  msgstr ""
1224
 
1225
- #: admin/includes/class-overview-widgets.php:92 admin/includes/notices.php:52
1226
  msgid "Sure, I’ll rate the plugin"
1227
  msgstr ""
1228
 
1229
- #: admin/includes/class-overview-widgets.php:94 admin/includes/notices.php:53
1230
  msgid "I already did"
1231
  msgstr ""
1232
 
1233
- #: admin/includes/class-overview-widgets.php:100
1234
  msgid "Manage your ads"
1235
  msgstr ""
1236
 
1237
- #: admin/includes/class-overview-widgets.php:104
1238
  msgid "Get the All Access pass"
1239
  msgstr ""
1240
 
1241
- #: admin/includes/class-overview-widgets.php:130
1242
  #: admin/views/notices/welcome-panel.php:22
1243
  #, php-format
1244
  msgid "<a href=\"%s\" target=\"_blank\">Manual</a>"
1245
  msgstr ""
1246
 
1247
- #: admin/includes/class-overview-widgets.php:131
1248
  #, php-format
1249
  msgid "<a href=\"%s\" target=\"_blank\">FAQ and Support</a>"
1250
  msgstr ""
1251
 
1252
- #: admin/includes/class-overview-widgets.php:149
1253
  msgid "The solution for professional websites."
1254
  msgstr ""
1255
 
1256
- #: admin/includes/class-overview-widgets.php:152
1257
  #: admin/views/pitch-pro-tab.php:7
1258
  msgid "support for cached sites"
1259
  msgstr ""
1260
 
1261
- #: admin/includes/class-overview-widgets.php:155
1262
- #: admin/includes/class-overview-widgets.php:156
1263
- #: admin/includes/class-overview-widgets.php:157
1264
  #: admin/includes/class-overview-widgets.php:158
 
 
 
1265
  #, php-format
1266
  msgid "integrates with <strong>%s</strong>"
1267
  msgstr ""
1268
 
1269
- #: admin/includes/class-overview-widgets.php:159
1270
  msgid "click fraud protection, lazy load, ad-block ads"
1271
  msgstr ""
1272
 
1273
- #: admin/includes/class-overview-widgets.php:160
1274
  #: admin/views/pitch-pro-tab.php:8
1275
  msgid "11 more display and visitor conditions"
1276
  msgstr ""
1277
 
1278
- #: admin/includes/class-overview-widgets.php:161
1279
  #: admin/views/pitch-pro-tab.php:9
1280
  msgid "6 more placements"
1281
  msgstr ""
1282
 
1283
- #: admin/includes/class-overview-widgets.php:162
1284
  #: admin/views/pitch-pro-tab.php:10
1285
  msgid "placement tests for ad optimization"
1286
  msgstr ""
1287
 
1288
- #: admin/includes/class-overview-widgets.php:163
1289
  #: admin/views/pitch-pro-tab.php:11
1290
  msgid "ad grids and many more advanced features"
1291
  msgstr ""
1292
 
1293
- #: admin/includes/class-overview-widgets.php:170
1294
  msgid ""
1295
  "Analyze clicks and impressions of your ads locally or in Google Analytics, "
1296
  "share reports, and limit ads to a specific number of impressions or clicks."
1297
  msgstr ""
1298
 
1299
- #: admin/includes/class-overview-widgets.php:176
1300
  msgid ""
1301
  "Display ads based on the device or the size of your visitor’s browser, and "
1302
  "control ads on AMP pages."
1303
  msgstr ""
1304
 
1305
- #: admin/includes/class-overview-widgets.php:189
1306
  msgid ""
1307
  "Earn more money and let advertisers pay for ad space directly on the "
1308
  "frontend of your site."
1309
  msgstr ""
1310
 
1311
- #: admin/includes/class-overview-widgets.php:195
1312
  msgid ""
1313
  "Target visitors with ads that match their geo location and make more money "
1314
  "with regional campaigns."
1315
  msgstr ""
1316
 
1317
- #: admin/includes/class-overview-widgets.php:201
1318
  msgid ""
1319
  "Increase click rates on your ads by placing them in sticky positions above, "
1320
  "next or below your site."
1321
  msgstr ""
1322
 
1323
- #: admin/includes/class-overview-widgets.php:207
1324
  msgid ""
1325
  "Users will never miss an ad or other information in a PopUp. Choose when it "
1326
  "shows up and for how long a user can close it."
1327
  msgstr ""
1328
 
1329
- #: admin/includes/class-overview-widgets.php:213
1330
  msgid ""
1331
  "Create a beautiful and simple slider from your ads to show more information "
1332
  "on less space."
1333
  msgstr ""
1334
 
1335
- #: admin/includes/class-overview-widgets.php:219
1336
  msgid ""
1337
  "Place AdSense In-feed ads between posts on homepage, category, and archive "
1338
  "pages."
1339
  msgstr ""
1340
 
1341
- #: admin/includes/class-overview-widgets.php:222
1342
- #: admin/includes/class-overview-widgets.php:397
1343
- #: admin/includes/class-overview-widgets.php:413
1344
  msgid "Install now"
1345
  msgstr ""
1346
 
1347
- #: admin/includes/class-overview-widgets.php:240
1348
- #: admin/includes/class-overview-widgets.php:261
1349
- #: admin/includes/class-overview-widgets.php:286
1350
- #: admin/includes/class-overview-widgets.php:304
1351
- #: admin/includes/class-overview-widgets.php:322
1352
- #: admin/includes/class-overview-widgets.php:340
1353
- #: admin/includes/class-overview-widgets.php:358
1354
- #: admin/includes/class-overview-widgets.php:376
1355
  msgid "Activate now"
1356
  msgstr ""
1357
 
1358
- #: admin/includes/class-overview-widgets.php:269
1359
  msgid "Visit your ad stats"
1360
  msgstr ""
1361
 
1362
- #: admin/includes/class-overview-widgets.php:393
1363
  msgid "Use Genesis specific ad positions."
1364
  msgstr ""
1365
 
1366
- #: admin/includes/class-overview-widgets.php:409
1367
  msgid ""
1368
  "Manage ad positions with WPBakery Page Builder (formerly Visual Composer)."
1369
  msgstr ""
1370
 
1371
- #: admin/includes/class-overview-widgets.php:425
1372
  msgid "Our best deal with all add-ons included."
1373
  msgstr ""
1374
 
1375
- #: admin/includes/class-overview-widgets.php:427
1376
  msgid "Get full access"
1377
  msgstr ""
1378
 
1379
- #: admin/includes/class-overview-widgets.php:441
1380
  #: admin/views/ad-display-metabox.php:31 admin/views/ad-visitor-metabox.php:39
1381
  msgid "Visit the manual"
1382
  msgstr ""
1383
 
1384
- #: admin/includes/class-overview-widgets.php:444
1385
  msgid "Get this add-on"
1386
  msgstr ""
1387
 
@@ -1765,7 +1785,7 @@ msgid "Forced to OR."
1765
  msgstr ""
1766
 
1767
  #: admin/views/ad-display-metabox.php:72
1768
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:109
1769
  msgid "manual"
1770
  msgstr ""
1771
 
@@ -1827,12 +1847,14 @@ msgid "weight"
1827
  msgstr ""
1828
 
1829
  #: admin/views/ad-group-list-form-row.php:12 admin/views/placements.php:24
 
 
1830
  #: modules/privacy/admin/views/setting-consent-method.php:9
1831
  msgid "Name"
1832
  msgstr ""
1833
 
1834
  #: admin/views/ad-group-list-form-row.php:41 admin/views/placements.php:23
1835
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:98
1836
  msgid "Type"
1837
  msgstr ""
1838
 
@@ -2257,9 +2279,9 @@ msgstr ""
2257
  #: admin/views/checks.php:10
2258
  #, php-format
2259
  msgid ""
2260
- "Your <strong>PHP version (%s) is too low</strong>. Advanced Ads is built for "
2261
- "PHP 5.3 and higher. It might work, but updating PHP is highly recommended. "
2262
- "Please ask your hosting provider for more information."
2263
  msgstr ""
2264
 
2265
  #: admin/views/checks.php:13
@@ -2314,6 +2336,10 @@ msgstr ""
2314
  msgid "This site is hosted on wordpress.com."
2315
  msgstr ""
2316
 
 
 
 
 
2317
  #: admin/views/feedback-disable.php:4
2318
  msgid "Why did you decide to disable Advanced Ads?"
2319
  msgstr ""
@@ -2415,79 +2441,106 @@ msgstr ""
2415
  msgid "spread impressions or clicks equally over a given period"
2416
  msgstr ""
2417
 
2418
- #: admin/views/placement-injection-top.php:7
2419
  msgid "Congratulations! Your ad is now visible in the frontend."
2420
  msgstr ""
2421
 
2422
- #: admin/views/placement-injection-top.php:8
2423
  msgid "Adjust the placement options"
2424
  msgstr ""
2425
 
2426
- #: admin/views/placement-injection-top.php:9
2427
  #, php-format
2428
  msgid ""
2429
  "Ad not showing up? Take a look <a href=\"%s\" target=\"_blank\">here</a>"
2430
  msgstr ""
2431
 
2432
- #: admin/views/placement-injection-top.php:12
2433
  msgid "Where do you want to display the ad?"
2434
  msgstr ""
2435
 
2436
- #: admin/views/placement-injection-top.php:13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2437
  msgid "New placement"
2438
  msgstr ""
2439
 
2440
- #: admin/views/placement-injection-top.php:17
2441
  msgid "PHP or Shortcode"
2442
  msgstr ""
2443
 
2444
- #: admin/views/placement-injection-top.php:18
2445
  msgid "Manage Sidebar"
2446
  msgstr ""
2447
 
2448
- #: admin/views/placement-injection-top.php:19
2449
  msgid "Header (Manual)"
2450
  msgstr ""
2451
 
2452
- #: admin/views/placement-injection-top.php:22
2453
- #: admin/views/placement-injection-top.php:25
2454
  msgid "Custom Position"
2455
  msgstr ""
2456
 
2457
- #: admin/views/placement-injection-top.php:23
2458
  msgid "Show Pro Places"
2459
  msgstr ""
2460
 
2461
- #: admin/views/placement-injection-top.php:28
2462
  msgid "AdSense In-feed"
2463
  msgstr ""
2464
 
2465
- #: admin/views/placement-injection-top.php:32
2466
  msgid "Show Sticky Places"
2467
  msgstr ""
2468
 
2469
- #: admin/views/placement-injection-top.php:36
2470
  msgid "Show PopUp"
2471
  msgstr ""
2472
 
2473
- #: admin/views/placement-injection-top.php:38
2474
  msgid "PopUp & Layer"
2475
  msgstr ""
2476
 
2477
- #: admin/views/placement-injection-top.php:41
2478
  msgid "see all…"
2479
  msgstr ""
2480
 
2481
- #: admin/views/placement-injection-top.php:65
2482
  msgid "Existing placement"
2483
  msgstr ""
2484
 
2485
- #: admin/views/placement-injection-top.php:70
2486
  #, php-format
2487
  msgid "Or use the shortcode %s to insert the ad into the content manually."
2488
  msgstr ""
2489
 
2490
- #: admin/views/placement-injection-top.php:71
2491
  #, php-format
2492
  msgid ""
2493
  "Learn more about your choices to display an ad in the <a href=\"%s\" "
@@ -2773,44 +2826,44 @@ msgid ""
2773
  "their consequences before contacting support."
2774
  msgstr ""
2775
 
2776
- #: admin/views/support.php:8
2777
  msgid "Possible Issues"
2778
  msgstr ""
2779
 
2780
- #: admin/views/support.php:10
2781
  msgid "Ads not showing up"
2782
  msgstr ""
2783
 
2784
- #: admin/views/support.php:11
2785
  msgid "Purchase & Licenses"
2786
  msgstr ""
2787
 
2788
- #: admin/views/support.php:12
2789
  msgid "General Issues"
2790
  msgstr ""
2791
 
2792
- #: admin/views/support.php:13
2793
  msgid "Issues with Add-Ons"
2794
  msgstr ""
2795
 
2796
- #: admin/views/support.php:15
2797
  msgid ""
2798
  "Use the following form to search for solutions in the manual on "
2799
  "wpadvancedads.com"
2800
  msgstr ""
2801
 
2802
- #: admin/views/support.php:18
2803
  msgid "search"
2804
  msgstr ""
2805
 
2806
- #: admin/views/support.php:21
2807
  #, php-format
2808
  msgid ""
2809
  "Take a look at more common issues or contact us directly through the <a "
2810
  "href=\"%s\" target=\"_blank\">support page</a>."
2811
  msgstr ""
2812
 
2813
- #: admin/views/support.php:23
2814
  #, php-format
2815
  msgid ""
2816
  "Upgrade to any premium add-on and get <strong>priority email support</strong>"
@@ -2915,85 +2968,87 @@ msgstr ""
2915
  msgid "Ad blocker counter"
2916
  msgstr ""
2917
 
2918
- #: modules/gadsense/admin/admin.php:48
2919
  msgid "The ad details couldn't be retrieved from the ad code"
2920
  msgstr ""
2921
 
2922
- #: modules/gadsense/admin/admin.php:49
2923
  msgid ""
2924
  "Warning : The AdSense account from this code does not match the one set with "
2925
  "the Advanced Ads Plugin. This ad might cause troubles when used in the front "
2926
  "end."
2927
  msgstr ""
2928
 
2929
- #: modules/gadsense/admin/admin.php:53
2930
- msgid ""
2931
- "This type of ad code is set up in the AdSense settings. Click on the "
2932
- "following button to enable it now."
2933
- msgstr ""
2934
-
2935
- #: modules/gadsense/admin/admin.php:54
2936
- msgid "Activate"
2937
- msgstr ""
2938
-
2939
- #: modules/gadsense/admin/admin.php:141
2940
  msgid "AdSense account"
2941
  msgstr ""
2942
 
2943
- #: modules/gadsense/admin/admin.php:150
2944
  msgid "Verification code & Auto ads"
2945
  msgstr ""
2946
 
2947
- #: modules/gadsense/admin/admin.php:159
2948
  msgid "Limit to 3 ads"
2949
  msgstr ""
2950
 
2951
- #: modules/gadsense/admin/admin.php:168
2952
  msgid "Disable violation warnings"
2953
  msgstr ""
2954
 
2955
- #: modules/gadsense/admin/admin.php:176
2956
  msgid "Transparent background"
2957
  msgstr ""
2958
 
2959
- #: modules/gadsense/admin/admin.php:233
2960
  #, php-format
2961
  msgid "Limit to %d AdSense ads"
2962
  msgstr ""
2963
 
2964
- #: modules/gadsense/admin/admin.php:237
2965
  msgid ""
2966
  "There is no explicit limit for AdSense ads anymore, but you can still use "
2967
  "this setting to prevent too many AdSense ads to show accidentally on your "
2968
  "site."
2969
  msgstr ""
2970
 
2971
- #: modules/gadsense/admin/admin.php:241
2972
  msgid ""
2973
  "Due to technical restrictions, the limit does not work on placements with "
2974
  "cache-busting enabled."
2975
  msgstr ""
2976
 
2977
- #: modules/gadsense/admin/admin.php:255
2978
- #: modules/gadsense/admin/views/adsense-account.php:117
2979
  msgid ""
2980
  "Insert the AdSense header code used for verification and the Auto Ads "
2981
  "feature."
2982
  msgstr ""
2983
 
 
 
 
 
 
2984
  #: modules/gadsense/admin/admin.php:256
2985
  #, php-format
2986
  msgid ""
2987
- "This code might also activate Auto ads. Please read <a href=\"%s\" "
2988
- "target=\"_blank\">this article</a> if <strong>ads appear in random "
2989
- "places</strong>."
 
 
 
2990
  msgstr ""
2991
 
2992
- #: modules/gadsense/admin/admin.php:269
 
 
 
 
2993
  msgid "Disable warnings about potential violations of the AdSense terms."
2994
  msgstr ""
2995
 
2996
- #: modules/gadsense/admin/admin.php:270
2997
  #, php-format
2998
  msgid ""
2999
  "Our <a href=\"%s\" target=\"_blank\">Ad Health</a> feature monitors if "
@@ -3001,22 +3056,22 @@ msgid ""
3001
  "managed with Advanced Ads. Enable this option to remove these checks"
3002
  msgstr ""
3003
 
3004
- #: modules/gadsense/admin/admin.php:281
3005
  msgid ""
3006
  "Enable this option in case your theme adds an unfortunate background color "
3007
  "to AdSense ads."
3008
  msgstr ""
3009
 
3010
- #: modules/gadsense/admin/admin.php:304
3011
- #: modules/gadsense/includes/class-ad-type-adsense.php:73
3012
  msgid "The Publisher ID has an incorrect format. (must start with \"pub-\")"
3013
  msgstr ""
3014
 
3015
- #: modules/gadsense/admin/admin.php:326
3016
  msgid "AdSense"
3017
  msgstr ""
3018
 
3019
- #: modules/gadsense/admin/admin.php:378
3020
  #, php-format
3021
  msgid ""
3022
  "Responsive AdSense ads don’t work reliably with <em>Position</em> set to "
@@ -3025,14 +3080,14 @@ msgid ""
3025
  "wrapped in text."
3026
  msgstr ""
3027
 
3028
- #: modules/gadsense/admin/admin.php:384
3029
  #, php-format
3030
  msgid ""
3031
  "<a href=\"%s\" target=\"_blank\">Install the free AdSense In-feed add-on</a> "
3032
  "in order to place ads between posts."
3033
  msgstr ""
3034
 
3035
- #: modules/gadsense/admin/admin.php:391
3036
  #, php-format
3037
  msgid ""
3038
  "Use the <a href=\"%s\" target=\"_blank\">Responsive add-on</a> in order to "
@@ -3040,6 +3095,18 @@ msgid ""
3040
  "vertical, or rectangle formats."
3041
  msgstr ""
3042
 
 
 
 
 
 
 
 
 
 
 
 
 
3043
  #: modules/gadsense/includes/class-ad-type-adsense.php:35
3044
  msgid "AdSense ad"
3045
  msgstr ""
@@ -3048,7 +3115,7 @@ msgstr ""
3048
  msgid "Use ads from your Google AdSense account"
3049
  msgstr ""
3050
 
3051
- #: modules/gadsense/includes/class-ad-type-adsense.php:108
3052
  msgid "Your AdSense Publisher ID is missing."
3053
  msgstr ""
3054
 
@@ -3056,16 +3123,6 @@ msgstr ""
3056
  msgid "Auto"
3057
  msgstr ""
3058
 
3059
- #: modules/gadsense/includes/class-mapi.php:488
3060
- #: modules/gadsense/admin/views/mapi-ad-selector.php:20
3061
- msgid "No ad unit found"
3062
- msgstr ""
3063
-
3064
- #: modules/gadsense/includes/class-mapi.php:490
3065
- #: modules/gadsense/admin/views/mapi-ad-selector.php:24
3066
- msgid "--select ad--"
3067
- msgstr ""
3068
-
3069
  #. Name of the plugin
3070
  #: modules/gutenberg/includes/class-gutenberg.php:78
3071
  msgid "Advanced Ads"
@@ -3252,11 +3309,11 @@ msgstr ""
3252
  msgid "Consent method"
3253
  msgstr ""
3254
 
3255
- #: modules/privacy/classes/plugin.php:141
3256
  msgid "Show all ads even without consent."
3257
  msgstr ""
3258
 
3259
- #: modules/privacy/classes/plugin.php:142
3260
  msgid "Cookie"
3261
  msgstr ""
3262
 
@@ -3320,12 +3377,6 @@ msgid ""
3320
  "Google Analytics property ID above to count them."
3321
  msgstr ""
3322
 
3323
- #: modules/gadsense/admin/views/adsense-account.php:33
3324
- #: modules/gadsense/admin/views/adsense-account.php:47
3325
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:47
3326
- msgid "Connect to AdSense"
3327
- msgstr ""
3328
-
3329
  #: modules/gadsense/admin/views/adsense-account.php:36
3330
  msgid "Revoke API acccess"
3331
  msgstr ""
@@ -3357,133 +3408,184 @@ msgid ""
3357
  "manual</a> and get a free setup check."
3358
  msgstr ""
3359
 
3360
- #: modules/gadsense/admin/views/adsense-account.php:115
 
 
 
 
3361
  msgid "Please enter the confirmation code."
3362
  msgstr ""
3363
 
3364
- #: modules/gadsense/admin/views/adsense-account.php:119
3365
  msgid "Submit code"
3366
  msgstr ""
3367
 
3368
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:52
 
 
 
 
 
 
 
3369
  msgid ""
3370
  "Copy the ad code from your AdSense account, paste it into the area below and "
3371
  "click on <em>Get details</em>."
3372
  msgstr ""
3373
 
3374
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:54
3375
  msgid "Get details"
3376
  msgstr ""
3377
 
3378
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:56
3379
  msgid "connect to your AdSense account"
3380
  msgstr ""
3381
 
3382
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:64
3383
  msgid "Insert new AdSense code"
3384
  msgstr ""
3385
 
3386
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:68
3387
  msgid "Get ad code from your linked account"
3388
  msgstr ""
3389
 
3390
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:75
 
 
 
 
3391
  msgid "Ad Slot ID"
3392
  msgstr ""
3393
 
3394
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:80
3395
  #, php-format
3396
  msgid "Publisher ID: %s"
3397
  msgstr ""
3398
 
3399
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:84
3400
  msgid ""
3401
  "The ad slot ID is either a number or empty and not the same as the publisher "
3402
  "ID."
3403
  msgstr ""
3404
 
3405
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:95
3406
  #, php-format
3407
  msgid "Please <a href=\"%s\" target=\"_blank\">change it here</a>."
3408
  msgstr ""
3409
 
3410
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:101
3411
  msgid "Normal"
3412
  msgstr ""
3413
 
3414
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:103
3415
  msgid "Responsive (Matched Content)"
3416
  msgstr ""
3417
 
3418
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:104
3419
  msgid "Link ads"
3420
  msgstr ""
3421
 
3422
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:105
3423
  msgid "Link ads (Responsive)"
3424
  msgstr ""
3425
 
3426
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:106
3427
  msgid "InArticle"
3428
  msgstr ""
3429
 
3430
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:107
3431
  msgid "InFeed"
3432
  msgstr ""
3433
 
3434
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:112
3435
  msgid "Resizing"
3436
  msgstr ""
3437
 
3438
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:120
3439
  msgid "Layout"
3440
  msgstr ""
3441
 
3442
- #: modules/gadsense/admin/views/adsense-ad-parameters.php:124
3443
  msgid "Layout-Key"
3444
  msgstr ""
3445
 
3446
- #: modules/gadsense/admin/views/mapi-ad-selector.php:15
3447
- msgid "AdSense Ad Unit"
3448
  msgstr ""
3449
 
3450
- #: modules/gadsense/admin/views/mapi-ad-selector.php:15
3451
- msgid "Update ad units list"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3452
  msgstr ""
3453
 
3454
  #: modules/gadsense/admin/views/mapi-ad-selector.php:32
3455
- msgid "Update Details"
 
 
 
 
 
3456
  msgstr ""
3457
 
3458
- #: modules/gadsense/admin/views/mapi-ad-selector.php:35
 
 
 
 
 
 
 
 
3459
  msgid "Unrecognized ad code"
3460
  msgstr ""
3461
 
3462
- #: modules/gadsense/admin/views/mapi-ad-selector.php:38
3463
  msgid "This ad type can currently not be imported from AdSense."
3464
  msgstr ""
3465
 
3466
- #: modules/gadsense/admin/views/mapi-ad-selector.php:39
3467
  msgid "Learn more and help us to enable it here."
3468
  msgstr ""
3469
 
3470
- #: modules/gadsense/admin/views/mapi-ad-selector.php:40
3471
  msgid "In the meantime, you can use AdSense with one of these methods:"
3472
  msgstr ""
3473
 
3474
- #: modules/gadsense/admin/views/mapi-ad-selector.php:42
3475
  msgid ""
3476
  "Click on <em>Insert new AdSense code</em> and copy the code from your "
3477
  "AdSense account into it."
3478
  msgstr ""
3479
 
3480
- #: modules/gadsense/admin/views/mapi-ad-selector.php:43
3481
  msgid ""
3482
  "Create an ad on the fly. Just select the <em>Normal</em> or <em>"
3483
  "Responsive</em> type and the size."
3484
  msgstr ""
3485
 
3486
- #: modules/gadsense/admin/views/mapi-ad-selector.php:44
3487
  msgid ""
3488
  "Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from "
3489
  "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: 2018-09-26 09:27+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"
23
  "X-Poedit-Basepath: ../\n"
24
  "X-Poedit-SearchPath-0: ."
25
 
26
+ #: admin/class-advanced-ads-admin.php:224 classes/display-conditions.php:215
27
  #: classes/visitor-conditions.php:241 admin/views/ad-display-metabox.php:134
28
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:74
29
  msgid "or"
30
  msgstr ""
31
 
32
+ #: admin/class-advanced-ads-admin.php:225 classes/display-conditions.php:215
33
  #: classes/visitor-conditions.php:241 admin/views/ad-visitor-metabox.php:120
34
  msgid "and"
35
  msgstr ""
36
 
37
+ #: admin/class-advanced-ads-admin.php:226
38
  msgid "After which paragraph?"
39
  msgstr ""
40
 
41
+ #: admin/class-advanced-ads-admin.php:338
42
  #, php-format
43
  msgid "time of %s"
44
  msgstr ""
45
 
46
+ #: admin/class-advanced-ads-admin.php:379 admin/includes/class-menu.php:107
47
  #: admin/includes/class-menu.php:110 admin/views/settings.php:26
48
  msgid "Support"
49
  msgstr ""
50
 
51
+ #: admin/class-advanced-ads-admin.php:383
52
  #: admin/includes/class-overview-widgets.php:33
53
  msgid "Add-Ons"
54
  msgstr ""
55
 
56
+ #: admin/class-advanced-ads-admin.php:637
57
+ #: admin/includes/class-overview-widgets.php:135
58
  #, php-format
59
  msgid ""
60
  "Thank the developer with a &#9733;&#9733;&#9733;&#9733;&#9733; review on <a "
146
  msgid "Injected in Footer (before closing &lt;/body&gt; Tag)."
147
  msgstr ""
148
 
149
+ #: classes/ad_placements.php:47 admin/views/placement-injection-top.php:36
150
  msgid "Before Content"
151
  msgstr ""
152
 
154
  msgid "Injected before the post content."
155
  msgstr ""
156
 
157
+ #: classes/ad_placements.php:53 admin/views/placement-injection-top.php:38
158
  msgid "After Content"
159
  msgstr ""
160
 
162
  msgid "Injected after the post content."
163
  msgstr ""
164
 
165
+ #: classes/ad_placements.php:59 admin/views/placement-injection-top.php:37
166
  msgid "Content"
167
  msgstr ""
168
 
280
  msgid "Link to target site"
281
  msgstr ""
282
 
283
+ #. $s is a size string like "728 x 90".
284
+ #. This string shows up on the ad edit page of
285
+ #. image ads if the size entered for the ad is
286
+ #. different from the size of the uploaded image.
287
+ #: classes/ad_type_image.php:202
288
+ #, php-format
289
+ msgid "Original size: %s"
290
+ msgstr ""
291
+
292
  #: classes/ad_type_plain.php:31
293
  msgid "Plain Text and Code"
294
  msgstr ""
319
  msgid "Execute shortcodes"
320
  msgstr ""
321
 
322
+ #: classes/checks.php:263
323
  #, php-format
324
  msgid ""
325
  "Possible conflict between jQueryUI library, used by Advanced Ads and other "
369
  msgid "Display ads based on the taxonomy of an archive page."
370
  msgstr ""
371
 
372
+ #: classes/display-conditions.php:147
373
  #, php-format
374
  msgid "archive: %s"
375
  msgstr ""
376
 
377
+ #: classes/display-conditions.php:250 classes/display-conditions.php:303
378
+ #: classes/display-conditions.php:358 classes/display-conditions.php:475
379
  #: classes/visitor-conditions.php:136
380
  msgid "is"
381
  msgstr ""
382
 
383
+ #: classes/display-conditions.php:251 classes/display-conditions.php:304
384
+ #: classes/display-conditions.php:359 classes/display-conditions.php:476
385
  #: classes/visitor-conditions.php:137
386
  msgid "is not"
387
  msgstr ""
388
 
389
+ #: classes/display-conditions.php:274 classes/display-conditions.php:319
390
+ #: classes/display-conditions.php:406 classes/display-conditions.php:450
391
  msgctxt "Error message shown when no display condition term is selected"
392
  msgid "Please select some items."
393
  msgstr ""
394
 
395
+ #: classes/display-conditions.php:320
396
  #, php-format
397
  msgid ""
398
  "Only %d elements are displayed above. Use the <code>advanced-ads-admin-max-"
400
  "target=\"_blank\">this page</a>."
401
  msgstr ""
402
 
403
+ #: classes/display-conditions.php:441
404
  msgctxt "display the terms search field on ad edit page"
405
  msgid "add more terms"
406
  msgstr ""
407
 
408
+ #: classes/display-conditions.php:443
409
  msgid "term name or id"
410
  msgstr ""
411
 
412
+ #: classes/display-conditions.php:504
413
  msgid "title or id"
414
  msgstr ""
415
 
416
+ #: classes/display-conditions.php:549 includes/array_ad_conditions.php:63
417
  msgid "Home Page"
418
  msgstr ""
419
 
420
+ #: classes/display-conditions.php:550 includes/array_ad_conditions.php:64
421
  msgid "show on Home page"
422
  msgstr ""
423
 
424
+ #: classes/display-conditions.php:554 includes/array_ad_conditions.php:68
425
  msgid "Singular Pages"
426
  msgstr ""
427
 
428
+ #: classes/display-conditions.php:555 includes/array_ad_conditions.php:69
429
  msgid "show on singular pages/posts"
430
  msgstr ""
431
 
432
+ #: classes/display-conditions.php:559 includes/array_ad_conditions.php:73
433
  msgid "Archive Pages"
434
  msgstr ""
435
 
436
+ #: classes/display-conditions.php:560 includes/array_ad_conditions.php:74
437
  msgid "show on any type of archive page (category, tag, author and date)"
438
  msgstr ""
439
 
440
+ #: classes/display-conditions.php:564 includes/array_ad_conditions.php:78
441
  msgid "Search Results"
442
  msgstr ""
443
 
444
+ #: classes/display-conditions.php:565 includes/array_ad_conditions.php:79
445
  msgid "show on search result pages"
446
  msgstr ""
447
 
448
+ #: classes/display-conditions.php:569 includes/array_ad_conditions.php:83
449
  msgid "404 Page"
450
  msgstr ""
451
 
452
+ #: classes/display-conditions.php:570 includes/array_ad_conditions.php:84
453
  msgid "show on 404 error page"
454
  msgstr ""
455
 
456
+ #: classes/display-conditions.php:574 includes/array_ad_conditions.php:88
457
  msgid "Attachment Pages"
458
  msgstr ""
459
 
460
+ #: classes/display-conditions.php:575 includes/array_ad_conditions.php:89
461
  msgid "show on attachment pages"
462
  msgstr ""
463
 
464
+ #: classes/display-conditions.php:579 includes/array_ad_conditions.php:93
465
  msgid "Secondary Queries"
466
  msgstr ""
467
 
468
+ #: classes/display-conditions.php:580 includes/array_ad_conditions.php:94
469
  msgid "allow ads in secondary queries"
470
  msgstr ""
471
 
472
+ #: classes/display-conditions.php:584
473
  msgid "Feed"
474
  msgstr ""
475
 
476
+ #: classes/display-conditions.php:585
477
  msgid "allow ads in Feed"
478
  msgstr ""
479
 
480
+ #: classes/EDD_SL_Plugin_Updater.php:216
481
  #, php-format
482
  msgid ""
483
  "There is a new version of %1$s available. %2$sView version %3$s details%4$s."
484
  msgstr ""
485
 
486
+ #: classes/EDD_SL_Plugin_Updater.php:224
487
  #, php-format
488
  msgid ""
489
  "There is a new version of %1$s available. %2$sView version %3$s details%4$s "
914
  msgid "No ad group created"
915
  msgstr ""
916
 
917
+ #: admin/includes/class-ad-type.php:83 admin/includes/class-ad-type.php:89
918
  msgid "Ad Details"
919
  msgstr ""
920
 
921
+ #: admin/includes/class-ad-type.php:84 admin/includes/class-ad-type.php:90
922
  msgid "Ad Planning"
923
  msgstr ""
924
 
925
+ #: admin/includes/class-ad-type.php:85 admin/includes/class-ad-type.php:91
926
+ msgid "Ad Shortcode"
927
+ msgstr ""
928
+
929
+ #: admin/includes/class-ad-type.php:237
930
  #, php-format
931
  msgid "%s ad updated."
932
  msgid_plural "%s ads updated."
933
  msgstr[0] ""
934
  msgstr[1] ""
935
 
936
+ #: admin/includes/class-ad-type.php:238
937
  #, php-format
938
  msgid "%s ad not updated, somebody is editing it."
939
  msgid_plural "%s ads not updated, somebody is editing them."
940
  msgstr[0] ""
941
  msgstr[1] ""
942
 
943
+ #: admin/includes/class-ad-type.php:239
944
  #, php-format
945
  msgid "%s ad permanently deleted."
946
  msgid_plural "%s ads permanently deleted."
947
  msgstr[0] ""
948
  msgstr[1] ""
949
 
950
+ #: admin/includes/class-ad-type.php:240
951
  #, php-format
952
  msgid "%s ad moved to the Trash."
953
  msgid_plural "%s ads moved to the Trash."
954
  msgstr[0] ""
955
  msgstr[1] ""
956
 
957
+ #: admin/includes/class-ad-type.php:241
958
  #, php-format
959
  msgid "%s ad restored from the Trash."
960
  msgid_plural "%s ads restored from the Trash."
961
  msgstr[0] ""
962
  msgstr[1] ""
963
 
964
+ #: admin/includes/class-ad-type.php:570 admin/includes/class-ad-type.php:571
965
  msgid "Ad updated."
966
  msgstr ""
967
 
968
  #. translators: %s: date and time of the revision
969
+ #: admin/includes/class-ad-type.php:573
970
  #, php-format
971
  msgid "Ad restored to revision from %s"
972
  msgstr ""
973
 
974
+ #: admin/includes/class-ad-type.php:574 admin/includes/class-ad-type.php:575
975
  msgid "Ad saved."
976
  msgstr ""
977
 
978
+ #: admin/includes/class-ad-type.php:576
979
  msgid "Ad submitted."
980
  msgstr ""
981
 
982
+ #: admin/includes/class-ad-type.php:578
983
  #, php-format
984
  msgid "Ad scheduled for: <strong>%1$s</strong>."
985
  msgstr ""
986
 
987
  #. translators: Publish box date format, see http://php.net/date
988
+ #: admin/includes/class-ad-type.php:580
989
  msgid "M j, Y @ G:i"
990
  msgstr ""
991
 
992
+ #: admin/includes/class-ad-type.php:582
993
  msgid "Ad draft updated."
994
  msgstr ""
995
 
996
+ #: admin/includes/class-ad-type.php:669
997
  msgid ""
998
  "You don’t have access to ads. Please deactivate and re-enable Advanced Ads "
999
  "again to fix this."
1065
 
1066
  #: admin/includes/class-list-filters.php:129
1067
  #: modules/gadsense/admin/admin.php:29
1068
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:112
1069
  msgid "Responsive"
1070
  msgstr ""
1071
 
1143
  msgid "Video"
1144
  msgstr ""
1145
 
1146
+ #: admin/includes/class-meta-box.php:260
1147
  msgid "Ad Settings"
1148
  msgstr ""
1149
 
1150
+ #: admin/includes/class-meta-box.php:362 admin/views/overview.php:6
1151
  msgid "Ads Dashboard"
1152
  msgstr ""
1153
 
1154
+ #: admin/includes/class-meta-box.php:373
1155
  #, php-format
1156
  msgid "%d ads – <a href=\"%s\">manage</a> - <a href=\"%s\">new</a>"
1157
  msgstr ""
1158
 
1159
+ #: admin/includes/class-meta-box.php:385
1160
  msgid "plugin manual and homepage"
1161
  msgstr ""
1162
 
1163
+ #: admin/includes/class-meta-box.php:392
1164
  msgid "Get the tutorial via email"
1165
  msgstr ""
1166
 
1167
+ #: admin/includes/class-meta-box.php:399
1168
  msgid "Get AdSense tips via email"
1169
  msgstr ""
1170
 
1171
+ #: admin/includes/class-meta-box.php:455
1172
  msgid "From the ad optimization universe"
1173
  msgstr ""
1174
 
1175
+ #: admin/includes/class-meta-box.php:464
1176
  msgid "Advanced Ads Tutorials"
1177
  msgstr ""
1178
 
1209
  msgid "Create your first ad"
1210
  msgstr ""
1211
 
1212
+ #: admin/includes/class-overview-widgets.php:68
1213
+ #: modules/gadsense/admin/views/adsense-account.php:33
1214
+ #: modules/gadsense/admin/views/adsense-account.php:47
1215
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:53
1216
+ msgid "Connect to AdSense"
1217
+ msgstr ""
1218
+
1219
+ #: admin/includes/class-overview-widgets.php:78
1220
  msgid "Join the newsletter for more benefits"
1221
  msgstr ""
1222
 
1223
+ #: admin/includes/class-overview-widgets.php:80
1224
  msgid "Get 2 free add-ons"
1225
  msgstr ""
1226
 
1227
+ #: admin/includes/class-overview-widgets.php:81
1228
  msgid "Get the first steps and more tutorials to your inbox"
1229
  msgstr ""
1230
 
1231
+ #: admin/includes/class-overview-widgets.php:82
1232
  msgid "How to earn more with AdSense"
1233
  msgstr ""
1234
 
1235
+ #: admin/includes/class-overview-widgets.php:85
1236
  msgid "Join now"
1237
  msgstr ""
1238
 
1239
+ #: admin/includes/class-overview-widgets.php:93 admin/includes/notices.php:49
1240
  msgid ""
1241
  "Do you find Advanced Ads useful and would like to keep us motivated? Please "
1242
  "help us with a review."
1243
  msgstr ""
1244
 
1245
+ #: admin/includes/class-overview-widgets.php:95 admin/includes/notices.php:52
1246
  msgid "Sure, I’ll rate the plugin"
1247
  msgstr ""
1248
 
1249
+ #: admin/includes/class-overview-widgets.php:97 admin/includes/notices.php:53
1250
  msgid "I already did"
1251
  msgstr ""
1252
 
1253
+ #: admin/includes/class-overview-widgets.php:103
1254
  msgid "Manage your ads"
1255
  msgstr ""
1256
 
1257
+ #: admin/includes/class-overview-widgets.php:107
1258
  msgid "Get the All Access pass"
1259
  msgstr ""
1260
 
1261
+ #: admin/includes/class-overview-widgets.php:133
1262
  #: admin/views/notices/welcome-panel.php:22
1263
  #, php-format
1264
  msgid "<a href=\"%s\" target=\"_blank\">Manual</a>"
1265
  msgstr ""
1266
 
1267
+ #: admin/includes/class-overview-widgets.php:134
1268
  #, php-format
1269
  msgid "<a href=\"%s\" target=\"_blank\">FAQ and Support</a>"
1270
  msgstr ""
1271
 
1272
+ #: admin/includes/class-overview-widgets.php:152
1273
  msgid "The solution for professional websites."
1274
  msgstr ""
1275
 
1276
+ #: admin/includes/class-overview-widgets.php:155
1277
  #: admin/views/pitch-pro-tab.php:7
1278
  msgid "support for cached sites"
1279
  msgstr ""
1280
 
 
 
 
1281
  #: admin/includes/class-overview-widgets.php:158
1282
+ #: admin/includes/class-overview-widgets.php:159
1283
+ #: admin/includes/class-overview-widgets.php:160
1284
+ #: admin/includes/class-overview-widgets.php:161
1285
  #, php-format
1286
  msgid "integrates with <strong>%s</strong>"
1287
  msgstr ""
1288
 
1289
+ #: admin/includes/class-overview-widgets.php:162
1290
  msgid "click fraud protection, lazy load, ad-block ads"
1291
  msgstr ""
1292
 
1293
+ #: admin/includes/class-overview-widgets.php:163
1294
  #: admin/views/pitch-pro-tab.php:8
1295
  msgid "11 more display and visitor conditions"
1296
  msgstr ""
1297
 
1298
+ #: admin/includes/class-overview-widgets.php:164
1299
  #: admin/views/pitch-pro-tab.php:9
1300
  msgid "6 more placements"
1301
  msgstr ""
1302
 
1303
+ #: admin/includes/class-overview-widgets.php:165
1304
  #: admin/views/pitch-pro-tab.php:10
1305
  msgid "placement tests for ad optimization"
1306
  msgstr ""
1307
 
1308
+ #: admin/includes/class-overview-widgets.php:166
1309
  #: admin/views/pitch-pro-tab.php:11
1310
  msgid "ad grids and many more advanced features"
1311
  msgstr ""
1312
 
1313
+ #: admin/includes/class-overview-widgets.php:173
1314
  msgid ""
1315
  "Analyze clicks and impressions of your ads locally or in Google Analytics, "
1316
  "share reports, and limit ads to a specific number of impressions or clicks."
1317
  msgstr ""
1318
 
1319
+ #: admin/includes/class-overview-widgets.php:179
1320
  msgid ""
1321
  "Display ads based on the device or the size of your visitor’s browser, and "
1322
  "control ads on AMP pages."
1323
  msgstr ""
1324
 
1325
+ #: admin/includes/class-overview-widgets.php:192
1326
  msgid ""
1327
  "Earn more money and let advertisers pay for ad space directly on the "
1328
  "frontend of your site."
1329
  msgstr ""
1330
 
1331
+ #: admin/includes/class-overview-widgets.php:198
1332
  msgid ""
1333
  "Target visitors with ads that match their geo location and make more money "
1334
  "with regional campaigns."
1335
  msgstr ""
1336
 
1337
+ #: admin/includes/class-overview-widgets.php:204
1338
  msgid ""
1339
  "Increase click rates on your ads by placing them in sticky positions above, "
1340
  "next or below your site."
1341
  msgstr ""
1342
 
1343
+ #: admin/includes/class-overview-widgets.php:210
1344
  msgid ""
1345
  "Users will never miss an ad or other information in a PopUp. Choose when it "
1346
  "shows up and for how long a user can close it."
1347
  msgstr ""
1348
 
1349
+ #: admin/includes/class-overview-widgets.php:216
1350
  msgid ""
1351
  "Create a beautiful and simple slider from your ads to show more information "
1352
  "on less space."
1353
  msgstr ""
1354
 
1355
+ #: admin/includes/class-overview-widgets.php:222
1356
  msgid ""
1357
  "Place AdSense In-feed ads between posts on homepage, category, and archive "
1358
  "pages."
1359
  msgstr ""
1360
 
1361
+ #: admin/includes/class-overview-widgets.php:225
1362
+ #: admin/includes/class-overview-widgets.php:400
1363
+ #: admin/includes/class-overview-widgets.php:416
1364
  msgid "Install now"
1365
  msgstr ""
1366
 
1367
+ #: admin/includes/class-overview-widgets.php:243
1368
+ #: admin/includes/class-overview-widgets.php:264
1369
+ #: admin/includes/class-overview-widgets.php:289
1370
+ #: admin/includes/class-overview-widgets.php:307
1371
+ #: admin/includes/class-overview-widgets.php:325
1372
+ #: admin/includes/class-overview-widgets.php:343
1373
+ #: admin/includes/class-overview-widgets.php:361
1374
+ #: admin/includes/class-overview-widgets.php:379
1375
  msgid "Activate now"
1376
  msgstr ""
1377
 
1378
+ #: admin/includes/class-overview-widgets.php:272
1379
  msgid "Visit your ad stats"
1380
  msgstr ""
1381
 
1382
+ #: admin/includes/class-overview-widgets.php:396
1383
  msgid "Use Genesis specific ad positions."
1384
  msgstr ""
1385
 
1386
+ #: admin/includes/class-overview-widgets.php:412
1387
  msgid ""
1388
  "Manage ad positions with WPBakery Page Builder (formerly Visual Composer)."
1389
  msgstr ""
1390
 
1391
+ #: admin/includes/class-overview-widgets.php:428
1392
  msgid "Our best deal with all add-ons included."
1393
  msgstr ""
1394
 
1395
+ #: admin/includes/class-overview-widgets.php:430
1396
  msgid "Get full access"
1397
  msgstr ""
1398
 
1399
+ #: admin/includes/class-overview-widgets.php:444
1400
  #: admin/views/ad-display-metabox.php:31 admin/views/ad-visitor-metabox.php:39
1401
  msgid "Visit the manual"
1402
  msgstr ""
1403
 
1404
+ #: admin/includes/class-overview-widgets.php:447
1405
  msgid "Get this add-on"
1406
  msgstr ""
1407
 
1785
  msgstr ""
1786
 
1787
  #: admin/views/ad-display-metabox.php:72
1788
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:119
1789
  msgid "manual"
1790
  msgstr ""
1791
 
1847
  msgstr ""
1848
 
1849
  #: admin/views/ad-group-list-form-row.php:12 admin/views/placements.php:24
1850
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:29
1851
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:41
1852
  #: modules/privacy/admin/views/setting-consent-method.php:9
1853
  msgid "Name"
1854
  msgstr ""
1855
 
1856
  #: admin/views/ad-group-list-form-row.php:41 admin/views/placements.php:23
1857
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:108
1858
  msgid "Type"
1859
  msgstr ""
1860
 
2279
  #: admin/views/checks.php:10
2280
  #, php-format
2281
  msgid ""
2282
+ "Your <strong>PHP version (%1$s) is too low</strong>. Advanced Ads is built "
2283
+ "for PHP %2$s and higher. It might work, but updating PHP is highly "
2284
+ "recommended. Please ask your hosting provider for more information."
2285
  msgstr ""
2286
 
2287
  #: admin/views/checks.php:13
2336
  msgid "This site is hosted on wordpress.com."
2337
  msgstr ""
2338
 
2339
+ #: admin/views/checks.php:38 admin/views/support.php:25
2340
+ msgid "Advanced Ads related constants enabled"
2341
+ msgstr ""
2342
+
2343
  #: admin/views/feedback-disable.php:4
2344
  msgid "Why did you decide to disable Advanced Ads?"
2345
  msgstr ""
2441
  msgid "spread impressions or clicks equally over a given period"
2442
  msgstr ""
2443
 
2444
+ #: admin/views/placement-injection-top.php:11
2445
  msgid "Congratulations! Your ad is now visible in the frontend."
2446
  msgstr ""
2447
 
2448
+ #: admin/views/placement-injection-top.php:12
2449
  msgid "Adjust the placement options"
2450
  msgstr ""
2451
 
2452
+ #: admin/views/placement-injection-top.php:13
2453
  #, php-format
2454
  msgid ""
2455
  "Ad not showing up? Take a look <a href=\"%s\" target=\"_blank\">here</a>"
2456
  msgstr ""
2457
 
2458
+ #: admin/views/placement-injection-top.php:16
2459
  msgid "Where do you want to display the ad?"
2460
  msgstr ""
2461
 
2462
+ #: admin/views/placement-injection-top.php:20
2463
+ #: modules/gadsense/admin/admin.php:418
2464
+ #, php-format
2465
+ msgid ""
2466
+ "The AdSense verification and Auto ads code is already activated in the <a "
2467
+ "href=\"%s\">AdSense settings</a>."
2468
+ msgstr ""
2469
+
2470
+ #: admin/views/placement-injection-top.php:22
2471
+ #: modules/gadsense/admin/admin.php:420
2472
+ msgid ""
2473
+ "No need to add the code manually here, unless you want to include it into "
2474
+ "certain pages only."
2475
+ msgstr ""
2476
+
2477
+ #: admin/views/placement-injection-top.php:24
2478
+ msgid ""
2479
+ "Click on the button below to add the Auto ads code to the header of your "
2480
+ "site."
2481
+ msgstr ""
2482
+
2483
+ #. this is a label in a button when a user uses an AdSense Auto ads code in a plain code field
2484
+ #. the button has barely space for the original English text, so keep it short
2485
+ #: admin/views/placement-injection-top.php:31
2486
+ msgid "inject Auto ads"
2487
+ msgstr ""
2488
+
2489
+ #: admin/views/placement-injection-top.php:35
2490
  msgid "New placement"
2491
  msgstr ""
2492
 
2493
+ #: admin/views/placement-injection-top.php:39
2494
  msgid "PHP or Shortcode"
2495
  msgstr ""
2496
 
2497
+ #: admin/views/placement-injection-top.php:40
2498
  msgid "Manage Sidebar"
2499
  msgstr ""
2500
 
2501
+ #: admin/views/placement-injection-top.php:41
2502
  msgid "Header (Manual)"
2503
  msgstr ""
2504
 
2505
+ #: admin/views/placement-injection-top.php:44
2506
+ #: admin/views/placement-injection-top.php:47
2507
  msgid "Custom Position"
2508
  msgstr ""
2509
 
2510
+ #: admin/views/placement-injection-top.php:45
2511
  msgid "Show Pro Places"
2512
  msgstr ""
2513
 
2514
+ #: admin/views/placement-injection-top.php:50
2515
  msgid "AdSense In-feed"
2516
  msgstr ""
2517
 
2518
+ #: admin/views/placement-injection-top.php:54
2519
  msgid "Show Sticky Places"
2520
  msgstr ""
2521
 
2522
+ #: admin/views/placement-injection-top.php:58
2523
  msgid "Show PopUp"
2524
  msgstr ""
2525
 
2526
+ #: admin/views/placement-injection-top.php:60
2527
  msgid "PopUp & Layer"
2528
  msgstr ""
2529
 
2530
+ #: admin/views/placement-injection-top.php:63
2531
  msgid "see all…"
2532
  msgstr ""
2533
 
2534
+ #: admin/views/placement-injection-top.php:87
2535
  msgid "Existing placement"
2536
  msgstr ""
2537
 
2538
+ #: admin/views/placement-injection-top.php:92
2539
  #, php-format
2540
  msgid "Or use the shortcode %s to insert the ad into the content manually."
2541
  msgstr ""
2542
 
2543
+ #: admin/views/placement-injection-top.php:93
2544
  #, php-format
2545
  msgid ""
2546
  "Learn more about your choices to display an ad in the <a href=\"%s\" "
2826
  "their consequences before contacting support."
2827
  msgstr ""
2828
 
2829
+ #: admin/views/support.php:7
2830
  msgid "Possible Issues"
2831
  msgstr ""
2832
 
2833
+ #: admin/views/support.php:9
2834
  msgid "Ads not showing up"
2835
  msgstr ""
2836
 
2837
+ #: admin/views/support.php:10
2838
  msgid "Purchase & Licenses"
2839
  msgstr ""
2840
 
2841
+ #: admin/views/support.php:11
2842
  msgid "General Issues"
2843
  msgstr ""
2844
 
2845
+ #: admin/views/support.php:12
2846
  msgid "Issues with Add-Ons"
2847
  msgstr ""
2848
 
2849
+ #: admin/views/support.php:14
2850
  msgid ""
2851
  "Use the following form to search for solutions in the manual on "
2852
  "wpadvancedads.com"
2853
  msgstr ""
2854
 
2855
+ #: admin/views/support.php:17
2856
  msgid "search"
2857
  msgstr ""
2858
 
2859
+ #: admin/views/support.php:20
2860
  #, php-format
2861
  msgid ""
2862
  "Take a look at more common issues or contact us directly through the <a "
2863
  "href=\"%s\" target=\"_blank\">support page</a>."
2864
  msgstr ""
2865
 
2866
+ #: admin/views/support.php:22
2867
  #, php-format
2868
  msgid ""
2869
  "Upgrade to any premium add-on and get <strong>priority email support</strong>"
2968
  msgid "Ad blocker counter"
2969
  msgstr ""
2970
 
2971
+ #: modules/gadsense/admin/admin.php:47
2972
  msgid "The ad details couldn't be retrieved from the ad code"
2973
  msgstr ""
2974
 
2975
+ #: modules/gadsense/admin/admin.php:48
2976
  msgid ""
2977
  "Warning : The AdSense account from this code does not match the one set with "
2978
  "the Advanced Ads Plugin. This ad might cause troubles when used in the front "
2979
  "end."
2980
  msgstr ""
2981
 
2982
+ #: modules/gadsense/admin/admin.php:135
 
 
 
 
 
 
 
 
 
 
2983
  msgid "AdSense account"
2984
  msgstr ""
2985
 
2986
+ #: modules/gadsense/admin/admin.php:144
2987
  msgid "Verification code & Auto ads"
2988
  msgstr ""
2989
 
2990
+ #: modules/gadsense/admin/admin.php:153
2991
  msgid "Limit to 3 ads"
2992
  msgstr ""
2993
 
2994
+ #: modules/gadsense/admin/admin.php:162
2995
  msgid "Disable violation warnings"
2996
  msgstr ""
2997
 
2998
+ #: modules/gadsense/admin/admin.php:170
2999
  msgid "Transparent background"
3000
  msgstr ""
3001
 
3002
+ #: modules/gadsense/admin/admin.php:227
3003
  #, php-format
3004
  msgid "Limit to %d AdSense ads"
3005
  msgstr ""
3006
 
3007
+ #: modules/gadsense/admin/admin.php:231
3008
  msgid ""
3009
  "There is no explicit limit for AdSense ads anymore, but you can still use "
3010
  "this setting to prevent too many AdSense ads to show accidentally on your "
3011
  "site."
3012
  msgstr ""
3013
 
3014
+ #: modules/gadsense/admin/admin.php:235
3015
  msgid ""
3016
  "Due to technical restrictions, the limit does not work on placements with "
3017
  "cache-busting enabled."
3018
  msgstr ""
3019
 
3020
+ #: modules/gadsense/admin/admin.php:249
3021
+ #: modules/gadsense/admin/views/adsense-account.php:120
3022
  msgid ""
3023
  "Insert the AdSense header code used for verification and the Auto Ads "
3024
  "feature."
3025
  msgstr ""
3026
 
3027
+ #. this is the text for a link to a sub-page in an AdSense account
3028
+ #: modules/gadsense/admin/admin.php:254
3029
+ msgid "Adjust Auto ads options"
3030
+ msgstr ""
3031
+
3032
  #: modules/gadsense/admin/admin.php:256
3033
  #, php-format
3034
  msgid ""
3035
+ "Please read <a href=\"%s\" target=\"_blank\">this article</a> if <strong>ads "
3036
+ "appear in random places</strong>."
3037
+ msgstr ""
3038
+
3039
+ #: modules/gadsense/admin/admin.php:257
3040
+ msgid "Display Auto ads only on specific pages"
3041
  msgstr ""
3042
 
3043
+ #: modules/gadsense/admin/admin.php:258
3044
+ msgid "Auto ads on AMP pages"
3045
+ msgstr ""
3046
+
3047
+ #: modules/gadsense/admin/admin.php:271
3048
  msgid "Disable warnings about potential violations of the AdSense terms."
3049
  msgstr ""
3050
 
3051
+ #: modules/gadsense/admin/admin.php:272
3052
  #, php-format
3053
  msgid ""
3054
  "Our <a href=\"%s\" target=\"_blank\">Ad Health</a> feature monitors if "
3056
  "managed with Advanced Ads. Enable this option to remove these checks"
3057
  msgstr ""
3058
 
3059
+ #: modules/gadsense/admin/admin.php:283
3060
  msgid ""
3061
  "Enable this option in case your theme adds an unfortunate background color "
3062
  "to AdSense ads."
3063
  msgstr ""
3064
 
3065
+ #: modules/gadsense/admin/admin.php:306
3066
+ #: modules/gadsense/includes/class-ad-type-adsense.php:75
3067
  msgid "The Publisher ID has an incorrect format. (must start with \"pub-\")"
3068
  msgstr ""
3069
 
3070
+ #: modules/gadsense/admin/admin.php:328
3071
  msgid "AdSense"
3072
  msgstr ""
3073
 
3074
+ #: modules/gadsense/admin/admin.php:380
3075
  #, php-format
3076
  msgid ""
3077
  "Responsive AdSense ads don’t work reliably with <em>Position</em> set to "
3080
  "wrapped in text."
3081
  msgstr ""
3082
 
3083
+ #: modules/gadsense/admin/admin.php:386
3084
  #, php-format
3085
  msgid ""
3086
  "<a href=\"%s\" target=\"_blank\">Install the free AdSense In-feed add-on</a> "
3087
  "in order to place ads between posts."
3088
  msgstr ""
3089
 
3090
+ #: modules/gadsense/admin/admin.php:393
3091
  #, php-format
3092
  msgid ""
3093
  "Use the <a href=\"%s\" target=\"_blank\">Responsive add-on</a> in order to "
3095
  "vertical, or rectangle formats."
3096
  msgstr ""
3097
 
3098
+ #: modules/gadsense/admin/admin.php:422
3099
+ #, php-format
3100
+ msgid ""
3101
+ "The AdSense verification and Auto ads code should be set up in the <a "
3102
+ "href=\"%s\">AdSense settings</a>. Click on the following button to enable it "
3103
+ "now."
3104
+ msgstr ""
3105
+
3106
+ #: modules/gadsense/admin/admin.php:423
3107
+ msgid "Activate"
3108
+ msgstr ""
3109
+
3110
  #: modules/gadsense/includes/class-ad-type-adsense.php:35
3111
  msgid "AdSense ad"
3112
  msgstr ""
3115
  msgid "Use ads from your Google AdSense account"
3116
  msgstr ""
3117
 
3118
+ #: modules/gadsense/includes/class-ad-type-adsense.php:110
3119
  msgid "Your AdSense Publisher ID is missing."
3120
  msgstr ""
3121
 
3123
  msgid "Auto"
3124
  msgstr ""
3125
 
 
 
 
 
 
 
 
 
 
 
3126
  #. Name of the plugin
3127
  #: modules/gutenberg/includes/class-gutenberg.php:78
3128
  msgid "Advanced Ads"
3309
  msgid "Consent method"
3310
  msgstr ""
3311
 
3312
+ #: modules/privacy/classes/plugin.php:144
3313
  msgid "Show all ads even without consent."
3314
  msgstr ""
3315
 
3316
+ #: modules/privacy/classes/plugin.php:145
3317
  msgid "Cookie"
3318
  msgstr ""
3319
 
3377
  "Google Analytics property ID above to count them."
3378
  msgstr ""
3379
 
 
 
 
 
 
 
3380
  #: modules/gadsense/admin/views/adsense-account.php:36
3381
  msgid "Revoke API acccess"
3382
  msgstr ""
3408
  "manual</a> and get a free setup check."
3409
  msgstr ""
3410
 
3411
+ #: modules/gadsense/admin/views/adsense-account.php:104
3412
+ msgid "Can not connect AdSense account. PHP version is too low."
3413
+ msgstr ""
3414
+
3415
+ #: modules/gadsense/admin/views/adsense-account.php:118
3416
  msgid "Please enter the confirmation code."
3417
  msgstr ""
3418
 
3419
+ #: modules/gadsense/admin/views/adsense-account.php:122
3420
  msgid "Submit code"
3421
  msgstr ""
3422
 
3423
+ #. this is a label for an ad that we can currently not import from the AdSense account
3424
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:46
3425
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:73
3426
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:82
3427
+ msgid "unsupported"
3428
+ msgstr ""
3429
+
3430
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:58
3431
  msgid ""
3432
  "Copy the ad code from your AdSense account, paste it into the area below and "
3433
  "click on <em>Get details</em>."
3434
  msgstr ""
3435
 
3436
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:60
3437
  msgid "Get details"
3438
  msgstr ""
3439
 
3440
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:62
3441
  msgid "connect to your AdSense account"
3442
  msgstr ""
3443
 
3444
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:70
3445
  msgid "Insert new AdSense code"
3446
  msgstr ""
3447
 
3448
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:74
3449
  msgid "Get ad code from your linked account"
3450
  msgstr ""
3451
 
3452
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:79
3453
+ msgid "Your PHP version is too low to connect an AdSense account"
3454
+ msgstr ""
3455
+
3456
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:85
3457
  msgid "Ad Slot ID"
3458
  msgstr ""
3459
 
3460
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:90
3461
  #, php-format
3462
  msgid "Publisher ID: %s"
3463
  msgstr ""
3464
 
3465
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:94
3466
  msgid ""
3467
  "The ad slot ID is either a number or empty and not the same as the publisher "
3468
  "ID."
3469
  msgstr ""
3470
 
3471
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:105
3472
  #, php-format
3473
  msgid "Please <a href=\"%s\" target=\"_blank\">change it here</a>."
3474
  msgstr ""
3475
 
3476
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:111
3477
  msgid "Normal"
3478
  msgstr ""
3479
 
3480
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:113
3481
  msgid "Responsive (Matched Content)"
3482
  msgstr ""
3483
 
3484
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:114
3485
  msgid "Link ads"
3486
  msgstr ""
3487
 
3488
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:115
3489
  msgid "Link ads (Responsive)"
3490
  msgstr ""
3491
 
3492
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:116
3493
  msgid "InArticle"
3494
  msgstr ""
3495
 
3496
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:117
3497
  msgid "InFeed"
3498
  msgstr ""
3499
 
3500
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:122
3501
  msgid "Resizing"
3502
  msgstr ""
3503
 
3504
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:130
3505
  msgid "Layout"
3506
  msgstr ""
3507
 
3508
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:134
3509
  msgid "Layout-Key"
3510
  msgstr ""
3511
 
3512
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:139
3513
+ msgid "Clearfix"
3514
  msgstr ""
3515
 
3516
+ #: modules/gadsense/admin/views/adsense-ad-parameters.php:142
3517
+ msgid "Enable this box if responsive ads cover something on your site"
3518
+ msgstr ""
3519
+
3520
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:19
3521
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:51
3522
+ msgid "Update the ad units list"
3523
+ msgstr ""
3524
+
3525
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:28
3526
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:40
3527
+ msgctxt "AdSense ad"
3528
+ msgid "Ad unit"
3529
+ msgstr ""
3530
+
3531
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:30
3532
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:42
3533
+ msgctxt "AdSense ad"
3534
+ msgid "Slot ID"
3535
+ msgstr ""
3536
+
3537
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:31
3538
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:43
3539
+ msgctxt "AdSense ad"
3540
+ msgid "Type"
3541
  msgstr ""
3542
 
3543
  #: modules/gadsense/admin/views/mapi-ad-selector.php:32
3544
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:44
3545
+ msgid "Size"
3546
+ msgstr ""
3547
+
3548
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:50
3549
+ msgid "No ad units found"
3550
  msgstr ""
3551
 
3552
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:59
3553
+ msgid "Get the code for this ad"
3554
+ msgstr ""
3555
+
3556
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:60
3557
+ msgid "Update and get the code for this ad from Google"
3558
+ msgstr ""
3559
+
3560
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:96
3561
  msgid "Unrecognized ad code"
3562
  msgstr ""
3563
 
3564
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:99
3565
  msgid "This ad type can currently not be imported from AdSense."
3566
  msgstr ""
3567
 
3568
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:100
3569
  msgid "Learn more and help us to enable it here."
3570
  msgstr ""
3571
 
3572
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:101
3573
  msgid "In the meantime, you can use AdSense with one of these methods:"
3574
  msgstr ""
3575
 
3576
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:103
3577
  msgid ""
3578
  "Click on <em>Insert new AdSense code</em> and copy the code from your "
3579
  "AdSense account into it."
3580
  msgstr ""
3581
 
3582
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:104
3583
  msgid ""
3584
  "Create an ad on the fly. Just select the <em>Normal</em> or <em>"
3585
  "Responsive</em> type and the size."
3586
  msgstr ""
3587
 
3588
+ #: modules/gadsense/admin/views/mapi-ad-selector.php:105
3589
  msgid ""
3590
  "Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from "
3591
  "your AdSense account."
modules/adblock-finder/public/public.php CHANGED
@@ -8,7 +8,7 @@ class Advanced_Ads_Adblock_Finder {
8
 
9
  public function print_adblock_check_js() {
10
  $options = Advanced_Ads::get_instance()->options();
11
-
12
  ?><script>
13
  var advanced_ads_ga_UID = <?php echo isset( $options['ga-UID'] ) ? "'" . esc_js( $options['ga-UID'] ). "'" : 'false' ?>;
14
  var advanced_ads_ga_anonymIP = <?php
@@ -24,9 +24,8 @@ class Advanced_Ads_Adblock_Finder {
24
  } else {
25
  readfile( dirname( __FILE__ ) . '/script.min.js' );
26
  }
27
-
28
- ?>
29
-
30
- </script><?php
31
  }
32
  }
8
 
9
  public function print_adblock_check_js() {
10
  $options = Advanced_Ads::get_instance()->options();
11
+ if ( !empty( $options['ga-UID'] ) ) {
12
  ?><script>
13
  var advanced_ads_ga_UID = <?php echo isset( $options['ga-UID'] ) ? "'" . esc_js( $options['ga-UID'] ). "'" : 'false' ?>;
14
  var advanced_ads_ga_anonymIP = <?php
24
  } else {
25
  readfile( dirname( __FILE__ ) . '/script.min.js' );
26
  }
27
+
28
+ ?></script><?php
29
+ }
 
30
  }
31
  }
modules/gadsense/admin/admin.php CHANGED
@@ -43,15 +43,9 @@ class Advanced_Ads_AdSense_Admin {
43
  <script type="text/javascript">
44
  var gadsenseData = {
45
  pubId : '<?php echo $pub_id; ?>',
46
- pageLevelEnabled: '<?php echo $db->is_page_level_enabled(); ?>',
47
  msg : {
48
  unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", 'advanced-ads' ); ?>',
49
  pubIdMismatch : '<?php esc_attr_e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', 'advanced-ads' ); ?>',
50
- pageLevelEnabled: '<?php _e( sprintf(__( 'Page-Level ads are already activated in the <a href="%s">AdSense settings</a>. No need to add them manually.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ) ); ?>',
51
- pageLevelDisabled: '<?php
52
- printf( '%s <button id="adsense_enable_pla" type="button" class="button">%s</button>',
53
- esc_attr__( 'This type of ad code is set up in the AdSense settings. Click on the following button to enable it now.', 'advanced-ads' ),
54
- esc_attr__( 'Activate', 'advanced-ads' ) ); ?>'
55
  },
56
  pagenow: '<?php echo $pagenow ?>',
57
  };
@@ -252,8 +246,16 @@ class Advanced_Ads_AdSense_Admin {
252
  $page_level = $options['page-level-enabled'];
253
 
254
  ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
255
- <?php _e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' ); ?></label>
256
- <p class="description"><?php printf(__( 'This code might also activate Auto ads. 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><?php
 
 
 
 
 
 
 
 
257
  }
258
 
259
  /**
@@ -408,4 +410,18 @@ class Advanced_Ads_AdSense_Admin {
408
  return $notices;
409
  }
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
43
  <script type="text/javascript">
44
  var gadsenseData = {
45
  pubId : '<?php echo $pub_id; ?>',
 
46
  msg : {
47
  unknownAd : '<?php esc_attr_e( "The ad details couldn't be retrieved from the ad code", 'advanced-ads' ); ?>',
48
  pubIdMismatch : '<?php esc_attr_e( 'Warning : The AdSense account from this code does not match the one set with the Advanced Ads Plugin. This ad might cause troubles when used in the front end.', 'advanced-ads' ); ?>',
 
 
 
 
 
49
  },
50
  pagenow: '<?php echo $pagenow ?>',
51
  };
246
  $page_level = $options['page-level-enabled'];
247
 
248
  ?><label><input type="checkbox" name="<?php echo GADSENSE_OPT_NAME; ?>[page-level-enabled]" value="1" <?php checked( $page_level ); ?> />
249
+ <?php esc_attr_e( 'Insert the AdSense header code used for verification and the Auto Ads feature.', 'advanced-ads' );
250
+ if( !empty( $options['adsense-id'] ) ) :
251
+ ?>&nbsp;<a href="https://www.google.com/adsense/new/u/0/<?php echo $options['adsense-id']; ?>/myads/auto-ads" target="_blank"><?php /**
252
+ * translators: this is the text for a link to a sub-page in an AdSense account
253
+ */
254
+ esc_attr_e( 'Adjust Auto ads options', 'advanced-ads' ); ?></a>
255
+ <?php endif; ?>
256
+ </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>
257
+ <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>
258
+ <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
259
  }
260
 
261
  /**
410
  return $notices;
411
  }
412
 
413
+ /**
414
+ * Get Auto Ads messages.
415
+ */
416
+ public static function get_auto_ads_messages() {
417
+ return array(
418
+ 'enabled' => sprintf(__( 'The AdSense verification and Auto ads code is already activated in the <a href="%s">AdSense settings</a>.', 'advanced-ads' ),
419
+ admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) )
420
+ . ' ' . __( 'No need to add the code manually here, unless you want to include it into certain pages only.', 'advanced-ads' ),
421
+ 'disabled' => sprintf( '%s <button id="adsense_enable_pla" type="button" class="button">%s</button>',
422
+ sprintf ( __( 'The AdSense verification and Auto ads code should be set up in the <a href="%s">AdSense settings</a>. Click on the following button to enable it now.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-settings#top#adsense' ) ),
423
+ esc_attr__( 'Activate', 'advanced-ads' ) )
424
+ );
425
+ }
426
+
427
  }
modules/gadsense/admin/assets/js/new-ad.js CHANGED
@@ -11,23 +11,45 @@
11
  "use strict";
12
  var parseCodeBtnClicked = false, advancedAdSenseHidden = false;
13
  $( document ).on( 'click', '.prevent-default', function( ev ) { ev.preventDefault() } );
14
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  function MapiMayBeSaveAdCode(){
16
-
17
  // MAPI not set up
18
  if ( 'undefined' == typeof AdsenseMAPI ) return;
19
-
20
  var slotId = $( '#unit-code' ).val();
21
  if ( !slotId ) return;
22
-
23
  var type = $( '#unit-type' ).val();
24
  var width = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val().trim();
25
  var height = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val().trim();
26
  var layout = $( '#ad-layout' ).val();
27
  var layoutKey = $( '#ad-layout-key' ).val();
28
-
29
  var code = false;
30
-
31
  switch ( type ) {
32
  case 'in-feed':
33
  code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
@@ -112,13 +134,13 @@
112
  break;
113
  default:
114
  }
115
-
116
  if ( code ) {
117
  MapiSaveAdCode( code, slotId );
118
  }
119
-
120
  }
121
-
122
  function MapiSaveAdCode( code, slot ) {
123
  if ( 'undefined' == typeof AdsenseMAPI.codes[ 'ca-' + AdsenseMAPI.pubId + ':' + slot ] ) {
124
  AdsenseMAPI.codes['ca-' + AdsenseMAPI.pubId + ':' + slot] = code;
@@ -140,60 +162,20 @@
140
  },
141
  });
142
  }
143
- makeReadOnly();
144
  }
145
-
146
- /**
147
- * Update details button state
148
- */
149
- function canUpdateDetails() {
150
- if ( 'undefined' == typeof AdsenseMAPI ) return;
151
- if ( 0 == 1 ) {
152
- $( '#mapi-get-adcode' ).prop( 'disabled', true );
153
- $( '#mapi-update-unit-list' ).prop( 'disabled', true );
154
- return;
155
- }
156
-
157
- var unit = $( '#mapi-adunit-select' ).val();
158
-
159
- // Disable the update button for an un-supported ad format
160
- if ( 'undefined' != typeof AdsenseMAPI.codes[unit] ) {
161
-
162
- var badFormats = [
163
- 'data-ad-format="autorelaxed"',
164
- 'data-ad-format="fluid"',
165
- ];
166
-
167
- var disabled = false;
168
- for ( var i in badFormats ) {
169
- if ( -1 != AdsenseMAPI.codes[unit].indexOf( badFormats[i] ) ) {
170
- disabled = true;
171
- break;
172
- }
173
- }
174
- $( '#mapi-get-adcode' ).prop( 'disabled', disabled );
175
-
176
- } else {
177
- if ( '' == $( '#mapi-adunit-select' ).val() ) {
178
- $( '#mapi-get-adcode' ).prop( 'disabled', true );
179
- } else {
180
- $( '#mapi-get-adcode' ).prop( 'disabled', false );
181
- }
182
- }
183
- }
184
-
185
  function makeReadOnly() {
186
  $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', true );
187
  $( '#unit-type option:not(:selected)' ).prop( 'disabled', true );
188
  }
189
-
190
  function undoReadOnly() {
191
  $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', false );
192
  $( '#unit-type option:not(:selected)' ).prop( 'disabled', false );
193
  }
194
-
195
  function closeAdSelector() {
196
-
197
  // close the ad unit selector
198
  setTimeout(function(){
199
  $( '#mapi-wrap' ).animate(
@@ -208,9 +190,9 @@
208
  }
209
  );
210
  }, 80);
211
-
212
  }
213
-
214
  // On DOM ready
215
  $(function () {
216
  $( document ).on('click', '.advads-adsense-show-code', function(e){
@@ -220,21 +202,23 @@
220
  $( '#mapi-wrap' ).css( 'display', 'none' );
221
  $( this ).hide();
222
  })
223
-
224
  $( document ).on('click', '.advads-adsense-submit-code', function(ev){
225
  ev.preventDefault();
226
  parseCodeBtnClicked = true;
227
  var rawContent = $( '.advads-adsense-content' ).val();
228
 
229
  var parseResult = parseAdContent( rawContent );
 
230
  handleParseResult( parseResult );
231
  });
232
-
233
  $( document ).on( 'paramloaded', '#advanced-ads-ad-parameters', function(){
234
  var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
235
  var parseResult = parseAdContent( content );
 
236
  var adType = $( '[name="advanced_ad[type]"]:checked' ).val();
237
-
238
  if ( 'undefined' != typeof AdsenseMAPI ) {
239
  if ( 'adsense' != adType ) {
240
  if ( 'undefined' == typeof window['AdsenseMAPI'] ) {
@@ -253,30 +237,23 @@
253
  }
254
  handleParseResult( parseResult );
255
  } );
256
-
257
- $( document ).on( 'change', '#mapi-adunit-select', function(){
258
-
259
- canUpdateDetails();
260
- var unit = $( this ).val();
261
- if ( 'undefined' != typeof AdsenseMAPI.codes[unit] ) {
262
- getSavedDetails();
263
  } else {
264
- getRemoteCode();
265
  }
266
-
267
  // display ad slot and ad type for newly created AdSense ad
268
  if ( advancedAdSenseHidden ) {
269
  $( '#unit-type-block' ).add( $( '#unit-type-block' ).next() ).add( $( '#unit-type-block' ).next().next() ).css( 'display', 'block' );
270
  var codeBlock = $( '#unit-code' ).parent();
271
  codeBlock.add( codeBlock.prev() ).add( codeBlock.next() ).css( 'display', 'block' );
272
  }
273
-
274
- } );
275
-
276
- $( document ).on( 'mapi-selector-loaded', function(){
277
- canUpdateDetails();
278
- } );
279
-
280
  $( document ).on('change', '#unit-type, #unit-code', function (ev) {
281
  if ( 'unit-code' == $( this ).attr( 'id' ) ) {
282
  var val = $( this ).val();
@@ -294,38 +271,35 @@
294
  advads_update_adsense_type();
295
  });
296
 
297
- function getRemoteCode() {
298
-
299
- var unit = $( '#mapi-adunit-select' ).val();
300
-
301
- if ( '' == unit ) return;
302
-
303
  $( '#mapi-loading-overlay' ).css( 'display', 'block' );
304
-
305
  $.ajax({
306
  type: 'post',
307
  url: ajaxurl,
308
  data: {
309
  nonce: AdsenseMAPI.nonce,
310
  action: 'advads_mapi_get_adCode',
311
- unit: unit,
312
  },
313
  success: function(response,status,XHR){
314
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
315
  if ( 'undefined' != typeof response.code ) {
316
  $( '#remote-ad-code-msg' ).empty();
317
- AdsenseMAPI.codes[unit] = response.code;
318
  var parsed = parseAdContent( response.code );
319
  if ( false !== parsed ) {
 
320
  undoReadOnly();
321
  setDetailsFromAdCode( parsed );
322
  makeReadOnly();
323
  $( '#remote-ad-code-error' ).css( 'display', 'none' );
324
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
325
  } else {
326
  $( '#remote-ad-code-error' ).css( 'display', 'block' );
327
  }
328
-
329
  // Update quota message if needed
330
  if ( 1 == 0 ) {
331
  $( '#mapi-quota-message' ).text( response.quotaMsg );
@@ -334,15 +308,15 @@
334
  $( '#mapi-get-adcode,#mapi-get-adunits' ).prop( 'disabled', true );
335
  }
336
  }
337
-
338
  closeAdSelector();
339
-
340
  } else {
341
  if ( 'undefined' != typeof response.raw ) {
342
  $( '#remote-ad-code-msg' ).text( response.raw );
343
  } else if( 'undefined' != typeof response.msg ) {
344
  if ( 'doesNotSupportAdUnitType' == response.msg ) {
345
- $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'block' );
346
  } else {
347
  $( '#remote-ad-code-msg' ).text( response.msg );
348
  }
@@ -351,16 +325,52 @@
351
  },
352
  error: function(request,status,err){
353
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
354
-
355
  },
356
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
 
358
  }
359
-
360
- function getSavedDetails() {
361
- var unit = $( '#mapi-adunit-select' ).val();
362
- if ( 'undefined' != typeof AdsenseMAPI.codes[unit] ) {
363
- var code = AdsenseMAPI.codes[unit];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  var parsed = parseAdContent( code );
365
  if ( false !== parsed ) {
366
  undoReadOnly();
@@ -374,7 +384,7 @@
374
  }
375
  }
376
  }
377
-
378
  /**
379
  * Parse ad content.
380
  *
@@ -389,14 +399,14 @@
389
  if ('undefined' != typeof(adByGoogle.attr( 'data-ad-client' ))) {
390
  theAd.pubId = adByGoogle.attr( 'data-ad-client' ).substr( 3 );
391
  }
392
-
393
  if (undefined !== theAd.slotId && '' != theAd.pubId) {
394
  theAd.display = adByGoogle.css( 'display' );
395
  theAd.format = adByGoogle.attr( 'data-ad-format' );
396
  theAd.layout = adByGoogle.attr( 'data-ad-layout' ); // for InFeed and InArticle
397
  theAd.layout_key = adByGoogle.attr( 'data-ad-layout-key' ); // for InFeed
398
  theAd.style = adByGoogle.attr( 'style' ) || '';
399
-
400
  /* normal ad */
401
  if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf( 'width' )) {
402
  theAd.type = 'normal';
@@ -408,11 +418,11 @@
408
  else if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
409
  theAd.type = 'responsive';
410
  }
411
-
412
-
413
  /* older link unit format; for new ads the format type is no longer needed; link units are created through the AdSense panel */
414
  else if ('undefined' != typeof(theAd.format) && 'link' == theAd.format) {
415
-
416
  if( -1 != theAd.style.indexOf( 'width' ) ){
417
  // is fixed size
418
  theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
@@ -423,15 +433,15 @@
423
  theAd.type = 'link-responsive';
424
  }
425
  }
426
-
427
  /* Responsive Matched Content */
428
  else if ('undefined' != typeof(theAd.format) && 'autorelaxed' == theAd.format) {
429
  theAd.type = 'matched-content';
430
  }
431
-
432
  /* InArticle & InFeed ads */
433
  else if ('undefined' != typeof(theAd.format) && 'fluid' == theAd.format) {
434
-
435
  // InFeed
436
  if('undefined' != typeof(theAd.layout) && 'in-article' == theAd.layout){
437
  theAd.type = 'in-article';
@@ -441,7 +451,7 @@
441
  }
442
  }
443
  }
444
-
445
  /**
446
  * Synchronous code
447
  */
@@ -451,11 +461,11 @@
451
  var _format = rawContent.match( /google_ad_format ?= ?["']([^'"]+)/ );
452
  var _width = rawContent.match( /google_ad_width ?= ?([\d]+)/ );
453
  var _height = rawContent.match( /google_ad_height ?= ?([\d]+)/ );
454
-
455
  theAd = {};
456
-
457
  theAd.pubId = _client[1].substr( 3 );
458
-
459
  if ( null !== _slot ) {
460
  theAd.slotId = _slot[1];
461
  }
@@ -468,17 +478,17 @@
468
  if ( null !== _height ) {
469
  theAd.height = parseInt( _height[1] );
470
  }
471
-
472
  if ( 'undefined' == typeof theAd.format ) {
473
  theAd.type = 'normal';
474
  }
475
-
476
  }
477
-
478
  if ( '' == theAd.slotId && gadsenseData.pubId && '' != gadsenseData.pubId ) {
479
  theAd.type = $( '#unit-type' ).val();
480
  }
481
-
482
  /* Page-Level ad */
483
  if ( rawContent.indexOf( 'enable_page_level_ads' ) !== -1 ) {
484
  theAd = { 'parse_message': 'pageLevelAd' };
@@ -498,11 +508,11 @@
498
  *
499
  * @param {!Object}
500
  */
501
- function handleParseResult( parseResult) {
502
  $( '#pastecode-msg' ).empty();
503
  switch ( parseResult.parse_message ) {
504
  case 'pageLevelAd' :
505
- showPageLevelAdMessage();
506
  break;
507
  case 'unknownAd' :
508
  // Not recognized ad code
@@ -610,16 +620,41 @@
610
  delete( window.gadsenseAdContent );
611
  }
612
  $( '#advads-ad-content-adsense' ).val( JSON.stringify( adContent, false, 2 ) );
613
-
614
  }
615
-
616
- $( document ).on( 'click', '#mapi-get-adcode', function(){
617
- getRemoteCode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618
  } );
619
-
620
- $( document ).on( 'click', '#mapi-get-adunits', function(){
 
621
  $( '#mapi-loading-overlay' ).css( 'display', 'block' );
622
-
623
  $.ajax({
624
  type: 'post',
625
  url: ajaxurl,
@@ -631,37 +666,38 @@
631
  success: function(response,status,XHR){
632
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
633
  if ( response.html ) {
634
- $( '#mapi-adunit-select' ).replaceWith( $( response.html ) );
635
- canUpdateDetails();
636
  }
637
  },
638
  error: function(request,status,err){
639
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
640
  },
641
  });
642
-
643
- } );
644
-
645
- $( document ).on( 'click', '#mapi-open-selector a', function(){
646
- $( '.advads-adsense-show-code' ).css( 'display', 'inline' );
647
- $( '#mapi-open-selector' ).css( 'display', 'none' );
648
- $( '.advads-adsense-code' ).css( 'display', 'none' );
649
- var pubId = gadsenseData.pubId || false;
650
- var slotId = $( '#unit-code' ).val().trim();
651
- if ( pubId && slotId ) {
652
- if ( $( '#mapi-adunit-select option[value="ca-' + pubId + ':' + slotId + '"]' ).length ) {
653
- $( '#mapi-adunit-select' ).val( 'ca-' + pubId + ':' + slotId );
654
  }
655
- }
656
- $( '#mapi-wrap' ).css( 'display', 'block' );
657
- });
658
-
659
- $( document ).on( 'click', '#mapi-close-selector', function(){
660
- $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
661
- $( '#mapi-wrap' ).css( 'display', 'none' );
662
- $( '#mapi-adclient-select' ).val( 'none' ).trigger( 'change' );
663
- } );
664
-
 
665
  function advads_update_adsense_type(){
666
  var type = $( '#unit-type' ).val();
667
  $( '.advads-adsense-layout' ).hide();
@@ -692,54 +728,26 @@
692
  $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'block' );
693
  $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'block' );
694
  $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'block' );
695
- }
696
  $( document ).trigger( 'gadsenseUnitChanged' );
697
  window.gadsenseFormatAdContent();
698
-
699
  // show / hide position warning
700
  var position = $( '#advanced-ad-output-position input[name="advanced_ad[output][position]"]:checked' ).val();
701
- if ( -1 !== ['responsive', 'in-article', 'in-feed' ].indexOf( type ) && ( 'left' == position || 'right' == position ) ){
702
  $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').show();
703
  } else {
704
  $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').hide();
705
  }
706
-
707
  }
708
-
709
  advads_update_adsense_type();
710
-
711
  if ( 'undefined' != typeof AdsenseMAPI ) {
712
  MapiMayBeSaveAdCode();
713
- canUpdateDetails();
714
  }
715
-
716
- }); // DOM ready
717
 
718
- /**
719
- * Show a message depending on whether Auto ads are enabled.
720
- */
721
- function showPageLevelAdMessage() {
722
- var $msg = $( '<p class="advads-success-message" />' ).appendTo ( '#pastecode-msg' );
723
- if ( gadsenseData.pageLevelEnabled ) {
724
- $msg.html( gadsenseData.msg.pageLevelEnabled );
725
- } else {
726
- $msg.html( gadsenseData.msg.pageLevelDisabled );
727
- $( document ).on('click', '#adsense_enable_pla', function(){
728
- $msg.hide();
729
- $.ajax( {
730
- type: 'POST',
731
- url: ajaxurl,
732
- data: {
733
- action: 'advads-adsense-enable-pla',
734
- nonce: advadsglobal.ajax_nonce
735
- },
736
- } ).done(function( data ) {
737
- $msg.show().html( gadsenseData.msg.pageLevelEnabled );
738
- } ).fail(function( jqXHR, textStatus ) {
739
- $msg.show();
740
- } );
741
- });
742
- }
743
- }
744
 
745
  })(jQuery);
11
  "use strict";
12
  var parseCodeBtnClicked = false, advancedAdSenseHidden = false;
13
  $( document ).on( 'click', '.prevent-default', function( ev ) { ev.preventDefault() } );
14
+
15
+ function resizeAdListHeader() {
16
+ var th = $( '#mapi-list-header span' );
17
+ var tb = $( '#mapi-table-wrap tbody tr' );
18
+ var w = [];
19
+
20
+ tb.first().find( 'td' ).each(function(){
21
+ w.push( $( this ).width() );
22
+ });
23
+
24
+ th.each(function(i){
25
+ if ( i != w.length - 1 ) {
26
+ $( this ).width( w[i] );
27
+ }
28
+ });
29
+ }
30
+
31
+ $( window ).resize(function(){
32
+ if ( $( '#mapi-wrap' ).length && $( '#mapi-wrap' ).is( ':visible' ) ) {
33
+ resizeAdListHeader();
34
+ }
35
+ });
36
+
37
  function MapiMayBeSaveAdCode(){
38
+
39
  // MAPI not set up
40
  if ( 'undefined' == typeof AdsenseMAPI ) return;
41
+
42
  var slotId = $( '#unit-code' ).val();
43
  if ( !slotId ) return;
44
+
45
  var type = $( '#unit-type' ).val();
46
  var width = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val().trim();
47
  var height = $( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val().trim();
48
  var layout = $( '#ad-layout' ).val();
49
  var layoutKey = $( '#ad-layout-key' ).val();
50
+
51
  var code = false;
52
+
53
  switch ( type ) {
54
  case 'in-feed':
55
  code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' +
134
  break;
135
  default:
136
  }
137
+
138
  if ( code ) {
139
  MapiSaveAdCode( code, slotId );
140
  }
141
+
142
  }
143
+
144
  function MapiSaveAdCode( code, slot ) {
145
  if ( 'undefined' == typeof AdsenseMAPI.codes[ 'ca-' + AdsenseMAPI.pubId + ':' + slot ] ) {
146
  AdsenseMAPI.codes['ca-' + AdsenseMAPI.pubId + ':' + slot] = code;
162
  },
163
  });
164
  }
 
165
  }
166
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  function makeReadOnly() {
168
  $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', true );
169
  $( '#unit-type option:not(:selected)' ).prop( 'disabled', true );
170
  }
171
+
172
  function undoReadOnly() {
173
  $( '#unit-code,#ad-layout,#ad-layout-key,[name="advanced_ad[width]"],[name="advanced_ad[height]"]' ).prop( 'readonly', false );
174
  $( '#unit-type option:not(:selected)' ).prop( 'disabled', false );
175
  }
176
+
177
  function closeAdSelector() {
178
+
179
  // close the ad unit selector
180
  setTimeout(function(){
181
  $( '#mapi-wrap' ).animate(
190
  }
191
  );
192
  }, 80);
193
+
194
  }
195
+
196
  // On DOM ready
197
  $(function () {
198
  $( document ).on('click', '.advads-adsense-show-code', function(e){
202
  $( '#mapi-wrap' ).css( 'display', 'none' );
203
  $( this ).hide();
204
  })
205
+
206
  $( document ).on('click', '.advads-adsense-submit-code', function(ev){
207
  ev.preventDefault();
208
  parseCodeBtnClicked = true;
209
  var rawContent = $( '.advads-adsense-content' ).val();
210
 
211
  var parseResult = parseAdContent( rawContent );
212
+
213
  handleParseResult( parseResult );
214
  });
215
+
216
  $( document ).on( 'paramloaded', '#advanced-ads-ad-parameters', function(){
217
  var content = $( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
218
  var parseResult = parseAdContent( content );
219
+
220
  var adType = $( '[name="advanced_ad[type]"]:checked' ).val();
221
+
222
  if ( 'undefined' != typeof AdsenseMAPI ) {
223
  if ( 'adsense' != adType ) {
224
  if ( 'undefined' == typeof window['AdsenseMAPI'] ) {
237
  }
238
  handleParseResult( parseResult );
239
  } );
240
+
241
+ function getAdCode( slotID ) {
242
+ if ( 'undefined' != typeof AdsenseMAPI.codes[ slotID ] ) {
243
+ getSavedDetails(slotID );
 
 
 
244
  } else {
245
+ getRemoteCode( slotID );
246
  }
247
+
248
  // display ad slot and ad type for newly created AdSense ad
249
  if ( advancedAdSenseHidden ) {
250
  $( '#unit-type-block' ).add( $( '#unit-type-block' ).next() ).add( $( '#unit-type-block' ).next().next() ).css( 'display', 'block' );
251
  var codeBlock = $( '#unit-code' ).parent();
252
  codeBlock.add( codeBlock.prev() ).add( codeBlock.next() ).css( 'display', 'block' );
253
  }
254
+
255
+ }
256
+
 
 
 
 
257
  $( document ).on('change', '#unit-type, #unit-code', function (ev) {
258
  if ( 'unit-code' == $( this ).attr( 'id' ) ) {
259
  var val = $( this ).val();
271
  advads_update_adsense_type();
272
  });
273
 
274
+ function getRemoteCode( slotID ) {
275
+
276
+ if ( '' == slotID ) return;
 
 
 
277
  $( '#mapi-loading-overlay' ).css( 'display', 'block' );
278
+
279
  $.ajax({
280
  type: 'post',
281
  url: ajaxurl,
282
  data: {
283
  nonce: AdsenseMAPI.nonce,
284
  action: 'advads_mapi_get_adCode',
285
+ unit: slotID,
286
  },
287
  success: function(response,status,XHR){
288
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
289
  if ( 'undefined' != typeof response.code ) {
290
  $( '#remote-ad-code-msg' ).empty();
 
291
  var parsed = parseAdContent( response.code );
292
  if ( false !== parsed ) {
293
+ AdsenseMAPI.codes[slotID] = response.code;
294
  undoReadOnly();
295
  setDetailsFromAdCode( parsed );
296
  makeReadOnly();
297
  $( '#remote-ad-code-error' ).css( 'display', 'none' );
298
+ unitIsSupported( slotID );
299
  } else {
300
  $( '#remote-ad-code-error' ).css( 'display', 'block' );
301
  }
302
+
303
  // Update quota message if needed
304
  if ( 1 == 0 ) {
305
  $( '#mapi-quota-message' ).text( response.quotaMsg );
308
  $( '#mapi-get-adcode,#mapi-get-adunits' ).prop( 'disabled', true );
309
  }
310
  }
311
+
312
  closeAdSelector();
313
+
314
  } else {
315
  if ( 'undefined' != typeof response.raw ) {
316
  $( '#remote-ad-code-msg' ).text( response.raw );
317
  } else if( 'undefined' != typeof response.msg ) {
318
  if ( 'doesNotSupportAdUnitType' == response.msg ) {
319
+ unitIsNotSupported( slotID );
320
  } else {
321
  $( '#remote-ad-code-msg' ).text( response.msg );
322
  }
325
  },
326
  error: function(request,status,err){
327
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
328
+
329
  },
330
  });
331
+
332
+ }
333
+
334
+ function unitIsNotSupported( slotID ) {
335
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'block' );
336
+ AdsenseMAPI.unsupportedUnits[slotID] = 1;
337
+ $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).addClass( 'disabled' );
338
+ $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).addClass( 'unsupported' );
339
+ if ( ! $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
340
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
341
+ var content = td.text();
342
+ td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-type="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
343
+ }
344
+ if ( ! $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
345
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
346
+ var content = td.text();
347
+ td.html( '<a target="_blank" href="' + AdsenseMAPI.unsupportedLink + '" data-size="' + content + '">' + AdsenseMAPI.unsupportedText + '</a>' );
348
+ }
349
 
350
  }
351
+
352
+ function unitIsSupported( slotID ) {
353
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
354
+ if ( 'undefined' != typeof AdsenseMAPI.unsupportedUnits[slotID] ) {
355
+ delete AdsenseMAPI.unsupportedUnits[slotID];
356
+ }
357
+ $( 'i[data-mapiaction="getCode"][data-slotid="' + slotID + '"]' ).removeClass( 'disabled' );
358
+ $( 'tr[data-slotid="' + slotID + '"] .unitcode > span' ).removeClass( 'unsupported' );
359
+ if ( $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).length ) {
360
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unittype' );
361
+ var content = $( 'tr[data-slotid="' + slotID + '"] .unittype a' ).attr( 'data-type' );
362
+ td.text( content );
363
+ }
364
+ if ( $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).length ) {
365
+ var td = $( 'tr[data-slotid="' + slotID + '"] .unitsize' );
366
+ var content = $( 'tr[data-slotid="' + slotID + '"] .unitsize a' ).attr( 'data-size' );
367
+ td.text( content );
368
+ }
369
+ }
370
+
371
+ function getSavedDetails( slotID ) {
372
+ if ( 'undefined' != typeof AdsenseMAPI.codes[slotID] ) {
373
+ var code = AdsenseMAPI.codes[slotID];
374
  var parsed = parseAdContent( code );
375
  if ( false !== parsed ) {
376
  undoReadOnly();
384
  }
385
  }
386
  }
387
+
388
  /**
389
  * Parse ad content.
390
  *
399
  if ('undefined' != typeof(adByGoogle.attr( 'data-ad-client' ))) {
400
  theAd.pubId = adByGoogle.attr( 'data-ad-client' ).substr( 3 );
401
  }
402
+
403
  if (undefined !== theAd.slotId && '' != theAd.pubId) {
404
  theAd.display = adByGoogle.css( 'display' );
405
  theAd.format = adByGoogle.attr( 'data-ad-format' );
406
  theAd.layout = adByGoogle.attr( 'data-ad-layout' ); // for InFeed and InArticle
407
  theAd.layout_key = adByGoogle.attr( 'data-ad-layout-key' ); // for InFeed
408
  theAd.style = adByGoogle.attr( 'style' ) || '';
409
+
410
  /* normal ad */
411
  if ('undefined' == typeof(theAd.format) && -1 != theAd.style.indexOf( 'width' )) {
412
  theAd.type = 'normal';
418
  else if ('undefined' != typeof(theAd.format) && 'auto' == theAd.format) {
419
  theAd.type = 'responsive';
420
  }
421
+
422
+
423
  /* older link unit format; for new ads the format type is no longer needed; link units are created through the AdSense panel */
424
  else if ('undefined' != typeof(theAd.format) && 'link' == theAd.format) {
425
+
426
  if( -1 != theAd.style.indexOf( 'width' ) ){
427
  // is fixed size
428
  theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
433
  theAd.type = 'link-responsive';
434
  }
435
  }
436
+
437
  /* Responsive Matched Content */
438
  else if ('undefined' != typeof(theAd.format) && 'autorelaxed' == theAd.format) {
439
  theAd.type = 'matched-content';
440
  }
441
+
442
  /* InArticle & InFeed ads */
443
  else if ('undefined' != typeof(theAd.format) && 'fluid' == theAd.format) {
444
+
445
  // InFeed
446
  if('undefined' != typeof(theAd.layout) && 'in-article' == theAd.layout){
447
  theAd.type = 'in-article';
451
  }
452
  }
453
  }
454
+
455
  /**
456
  * Synchronous code
457
  */
461
  var _format = rawContent.match( /google_ad_format ?= ?["']([^'"]+)/ );
462
  var _width = rawContent.match( /google_ad_width ?= ?([\d]+)/ );
463
  var _height = rawContent.match( /google_ad_height ?= ?([\d]+)/ );
464
+
465
  theAd = {};
466
+
467
  theAd.pubId = _client[1].substr( 3 );
468
+
469
  if ( null !== _slot ) {
470
  theAd.slotId = _slot[1];
471
  }
478
  if ( null !== _height ) {
479
  theAd.height = parseInt( _height[1] );
480
  }
481
+
482
  if ( 'undefined' == typeof theAd.format ) {
483
  theAd.type = 'normal';
484
  }
485
+
486
  }
487
+
488
  if ( '' == theAd.slotId && gadsenseData.pubId && '' != gadsenseData.pubId ) {
489
  theAd.type = $( '#unit-type' ).val();
490
  }
491
+
492
  /* Page-Level ad */
493
  if ( rawContent.indexOf( 'enable_page_level_ads' ) !== -1 ) {
494
  theAd = { 'parse_message': 'pageLevelAd' };
508
  *
509
  * @param {!Object}
510
  */
511
+ function handleParseResult( parseResult ) {
512
  $( '#pastecode-msg' ).empty();
513
  switch ( parseResult.parse_message ) {
514
  case 'pageLevelAd' :
515
+ advads_show_adsense_auto_ads_warning();
516
  break;
517
  case 'unknownAd' :
518
  // Not recognized ad code
620
  delete( window.gadsenseAdContent );
621
  }
622
  $( '#advads-ad-content-adsense' ).val( JSON.stringify( adContent, false, 2 ) );
623
+
624
  }
625
+
626
+ $( document ).on( 'click', '#mapi-open-selector a', function(){
627
+ $( '.advads-adsense-show-code' ).css( 'display', 'inline' );
628
+ $( '#mapi-open-selector' ).css( 'display', 'none' );
629
+ $( '.advads-adsense-code' ).css( 'display', 'none' );
630
+ $( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
631
+ var pubId = gadsenseData.pubId || false;
632
+ var slotId = $( '#unit-code' ).val().trim();
633
+ var tbody = $( '#mapi-table-wrap tbody' );
634
+ tbody.find( 'tr' ).removeClass( 'selected' );
635
+ if ( pubId && slotId ) {
636
+ if ( $( '#mapi-table-wrap tr i[data-slotid="ca-' + pubId + ':' + slotId + '"]' ).length ) {
637
+ tbody.find( 'tr i[data-slotid="ca-' + pubId + ':' + slotId + '"]' ).parents( 'tr' ).addClass( 'selected' );
638
+ }
639
+ }
640
+ $( '#mapi-wrap' ).css( 'display', 'block' );
641
+ if ( $( '#mapi-no-ad-units-found' ).length ) {
642
+ $( '#mapi-no-ad-units-found' ).trigger( 'click' );
643
+ return;
644
+ }
645
+ resizeAdListHeader();
646
+ });
647
+
648
+ $( document ).on( 'click', '#mapi-close-selector', function(){
649
+ $( '#mapi-open-selector,.advads-adsense-show-code' ).css( 'display', 'inline' );
650
+ $( '#mapi-wrap' ).css( 'display', 'none' );
651
+ $( '#mapi-adclient-select' ).val( 'none' ).trigger( 'change' );
652
  } );
653
+
654
+ function updateAdList() {
655
+
656
  $( '#mapi-loading-overlay' ).css( 'display', 'block' );
657
+
658
  $.ajax({
659
  type: 'post',
660
  url: ajaxurl,
666
  success: function(response,status,XHR){
667
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
668
  if ( response.html ) {
669
+ $( '#mapi-wrap' ).replaceWith( $( response.html ) );
670
+ $( '#mapi-open-selector a' ).trigger( 'click' );
671
  }
672
  },
673
  error: function(request,status,err){
674
  $( '#mapi-loading-overlay' ).css( 'display', 'none' );
675
  },
676
  });
677
+
678
+ }
679
+
680
+ $( document ).on( 'click', '.mapiaction', function( ev ) {
681
+ var action = $( this ).attr( 'data-mapiaction' );
682
+ switch ( action ) {
683
+ case 'updateList':
684
+ updateAdList();
685
+ break;
686
+ case 'getCode':
687
+ if ( $( this ).hasClass( 'disabled' ) ) {
688
+ break;
689
  }
690
+ var slotID = $( this ).attr( 'data-slotid' );
691
+ getAdCode( slotID );
692
+ break;
693
+ case 'updateCode':
694
+ var slotID = $( this ).attr( 'data-slotid' );
695
+ getRemoteCode( slotID );
696
+ break;
697
+ default:
698
+ }
699
+ } );
700
+
701
  function advads_update_adsense_type(){
702
  var type = $( '#unit-type' ).val();
703
  $( '.advads-adsense-layout' ).hide();
728
  $( '#advanced-ads-ad-parameters-size' ).css( 'display', 'block' );
729
  $( '#advanced-ads-ad-parameters-size' ).prev('.label').css( 'display', 'block' );
730
  $( '#advanced-ads-ad-parameters-size' ).next('.hr').css( 'display', 'block' );
731
+ }
732
  $( document ).trigger( 'gadsenseUnitChanged' );
733
  window.gadsenseFormatAdContent();
734
+
735
  // show / hide position warning
736
  var position = $( '#advanced-ad-output-position input[name="advanced_ad[output][position]"]:checked' ).val();
737
+ if ( -1 !== ['responsive', 'link-responsive', 'matched-content', 'in-article', 'in-feed' ].indexOf( type ) && ( 'left' == position || 'right' == position ) ){
738
  $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').show();
739
  } else {
740
  $('#ad-parameters-box-notices .advads-ad-notice-responsive-position').hide();
741
  }
742
+
743
  }
744
+
745
  advads_update_adsense_type();
746
+
747
  if ( 'undefined' != typeof AdsenseMAPI ) {
748
  MapiMayBeSaveAdCode();
 
749
  }
 
 
750
 
751
+ }); // DOM ready
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
 
753
  })(jQuery);
modules/gadsense/admin/views/adsense-account.php CHANGED
@@ -98,7 +98,7 @@ $has_token = Advanced_Ads_AdSense_MAPI::has_token( $adsense_id );
98
  }
99
  </style>
100
  <?php else : ?>
101
- <p><?php printf(__( 'Problems with AdSense? Check out the <a href="%s" target="_blank">manual</a> and get a free setup check.', 'advanced-ads' ), ADVADS_URL . 'manual/adsense-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-manual-check' ); ?></p>
102
  <?php endif; ?>
103
  <?php if ( ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
104
  <p class="advads-error-message"><?php _e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ) ?></p>
98
  }
99
  </style>
100
  <?php else : ?>
101
+ <p><?php printf(__( 'Problems with AdSense? Check out the <a href="%s" target="_blank">manual</a> and get a free setup check.', 'advanced-ads' ), ADVADS_URL . 'adsense-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-manual-check' ); ?></p>
102
  <?php endif; ?>
103
  <?php if ( ! Advanced_Ads_Checks::php_version_minimum() ) : ?>
104
  <p class="advads-error-message"><?php _e( 'Can not connect AdSense account. PHP version is too low.', 'advanced-ads' ) ?></p>
modules/gadsense/admin/views/adsense-ad-parameters.php CHANGED
@@ -38,6 +38,12 @@ $mapi_ad_codes['length'] = count( $mapi_ad_codes );
38
  quota: <?php echo json_encode( $quota ) ?>,
39
  pubId: '<?php echo $pub_id ?>',
40
  adStatus: '<?php echo $ad->status ?>',
 
 
 
 
 
 
41
  };
42
  </script>
43
  <?php endif; ?>
@@ -110,7 +116,7 @@ if( $pub_id_errors ) : ?>
110
  <option value="in-article" <?php selected( $unit_type, 'in-article' ); ?>><?php _e( 'InArticle', 'advanced-ads' ); ?></option>
111
  <option value="in-feed" <?php selected( $unit_type, 'in-feed' ); ?>><?php _e( 'InFeed', 'advanced-ads' ); ?></option>
112
  </select>
113
- <a href="<?php echo ADVADS_URL . 'manual/adsense-ads/#adsense-ad-types'; ?>" target="_blank"><?php _e( 'manual', 'advanced-ads' ); ?></a>
114
  </div>
115
  <hr/>
116
  <label class="label" <?php if ( ! $is_responsive || 2 > count( $sizing_array ) ) { echo 'style="display: none;"'; } ?> id="resize-label"><?php _e( 'Resizing', 'advanced-ads' ); ?></label>
38
  quota: <?php echo json_encode( $quota ) ?>,
39
  pubId: '<?php echo $pub_id ?>',
40
  adStatus: '<?php echo $ad->status ?>',
41
+ unsupportedUnits: <?php echo wp_json_encode( $mapi_options['unsupported_units'] ); ?>,
42
+ unsupportedLink: '<?php echo Advanced_Ads_AdSense_MAPI::UNSUPPORTED_TYPE_LINK; ?>',
43
+ unsupportedText: '<?php /**
44
+ * translators: this is a label for an ad that we can currently not import from the AdSense account
45
+ */
46
+ esc_html_e( 'unsupported', 'advanced-ads' ); ?>'
47
  };
48
  </script>
49
  <?php endif; ?>
116
  <option value="in-article" <?php selected( $unit_type, 'in-article' ); ?>><?php _e( 'InArticle', 'advanced-ads' ); ?></option>
117
  <option value="in-feed" <?php selected( $unit_type, 'in-feed' ); ?>><?php _e( 'InFeed', 'advanced-ads' ); ?></option>
118
  </select>
119
+ <a href="<?php echo ADVADS_URL . 'adsense-ads/#utm_source=advanced-ads&utm_medium=link&utm_campaign=adsense-ad-types'; ?>" target="_blank"><?php _e( 'manual', 'advanced-ads' ); ?></a>
120
  </div>
121
  <hr/>
122
  <label class="label" <?php if ( ! $is_responsive || 2 > count( $sizing_array ) ) { echo 'style="display: none;"'; } ?> id="resize-label"><?php _e( 'Resizing', 'advanced-ads' ); ?></label>
modules/gadsense/admin/views/mapi-ad-selector.php CHANGED
@@ -8,48 +8,112 @@ $quota = $MAPI->get_quota();
8
  $can_connect = $use_user_app || 0 < $quota['count'];
9
  $can_connect = true;
10
  $ad_units = $mapi_options['accounts'][$adsense_id]['ad_units'];
 
 
 
11
  ?>
12
  <div id="mapi-wrap">
13
  <button type="button" id="mapi-close-selector" class="notice-dismiss"></button>
14
- <div id="mapi-wrap-inner">
15
- <label class="label"><?php _e( 'AdSense Ad Unit', 'advanced-ads' ); ?><i id="mapi-get-adunits" class="dashicons dashicons-update" style="cursor:pointer;margin-left:.3em;color:#008ec2;" title="<?php echo esc_attr( __( 'Update ad units list', 'advanced-ads' ) ); ?>"></i></label>
16
- <div>
17
- <select id="mapi-adunit-select">
18
- <?php if ( empty( $ad_units ) ) : ?>
19
-
20
- <option value=""><?php _e( 'No ad unit found', 'advanced-ads' ); ?></option>
21
-
22
- <?php else : $sorted_adunits = Advanced_Ads_AdSense_MAPI::get_sorted_adunits( $ad_units ); ?>
23
-
24
- <option value=""><?php _e( '--select ad--', 'advanced-ads' ) ?></option>
25
- <?php foreach ( $sorted_adunits as $key => $value ) : ?>
26
- <option value="<?php echo esc_attr( $key ); ?>"><?php echo $value; ?></option>
27
- <?php endforeach; ?>
28
-
29
- <?php endif; ?>
30
- </select>
31
-
32
- <button class="button-secondary prevent-default" disabled <?php if ( !$can_connect ) echo 'disabled="disabled"' ?> id="mapi-get-adcode"><?php _e( 'Update Details', 'advanced-ads' ); ?></button>
33
- </div>
34
-
35
- <p class="advads-error-message" id="remote-ad-code-error" style="display:none;"><strong><?php _e( 'Unrecognized ad code', 'advanced-ads' ); ?></strong></p>
36
- <p class="advads-error-message" id="remote-ad-code-msg"></p>
37
- <div style="display:none;" id="remote-ad-unsupported-ad-type"><p><i class="dashicons dashicons-warning"></i><b class="advads-error-message"><?php
38
- _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
39
- _e( 'Learn more and help us to enable it here.', 'advanced-ads' ) ?></a></p>
40
- <?php _e( 'In the meantime, you can use AdSense with one of these methods:', 'advanced-ads' ) ?>
41
- <ul>
42
- <li><?php _e( 'Click on <em>Insert new AdSense code</em> and copy the code from your AdSense account into it.', 'advanced-ads' ) ?></li>
43
- <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>
44
- <li><?php _e( 'Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from your AdSense account.', 'advanced-ads' ) ?></li>
45
- </ul>
46
- </div>
47
- <p id="mapi-quota-message"></p>
48
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  </div>
50
  </div>
51
-
52
- <div id="mapi-loading-overlay" style="position:absolute;background-color:rgba(255,255,255,.75);top:0;right:0;bottom:0;left:0;text-align:center;display:none;">
53
- <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:8em;" />
54
- </div>
55
- <script type="text/javascript">jQuery( document ).trigger( 'mapi-selector-loaded' ); </script>
 
 
 
 
 
 
8
  $can_connect = $use_user_app || 0 < $quota['count'];
9
  $can_connect = true;
10
  $ad_units = $mapi_options['accounts'][$adsense_id]['ad_units'];
11
+
12
+ $unsupported_ad_type_link = Advanced_Ads_AdSense_MAPI::UNSUPPORTED_TYPE_LINK;
13
+
14
  ?>
15
  <div id="mapi-wrap">
16
  <button type="button" id="mapi-close-selector" class="notice-dismiss"></button>
17
+ <?php if ( !empty( $ad_units ) ) : ?>
18
+ <i id="mapi-update-unit-lists" class="dashicons dashicons-update mapiaction" data-mapiaction="updateList" style="color:#0085ba;cursor:pointer;font-size:20px;" title="<?php
19
+ esc_attr_e( 'Update the ad units list', 'advanced-ads' ) ?>"></i>
20
+ <?php endif; ?>
21
+ <div id="mapi-loading-overlay">
22
+ <img alt="..." src="<?php echo ADVADS_BASE_URL . 'admin/assets/img/loader.gif'; ?>" style="margin-top:8em;" />
23
+ </div>
24
+
25
+ <?php if ( $can_connect ) : ?>
26
+ <?php if ( !empty( $ad_units ) ) : ?>
27
+ <div id="mapi-list-header">
28
+ <span><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></span>
29
+ <span><?php esc_html_e( 'Name', 'advanced-ads' ); ?></span>
30
+ <span><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></span>
31
+ <span><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></span>
32
+ <span><?php esc_html_e( 'Size', 'advanced-ads' ); ?></span>
33
+ </div>
34
+ <?php endif; ?>
35
+ <div id="mapi-table-wrap">
36
+ <table class="widefat striped">
37
+ <?php if ( empty( $ad_units ) ) : ?>
38
+ <thead>
39
+ <tr>
40
+ <th><?php echo esc_attr_x( 'Ad unit', 'AdSense ad', 'advanced-ads' ); ?></th>
41
+ <th><?php esc_html_e( 'Name', 'advanced-ads' ); ?></th>
42
+ <th><?php echo esc_html_x( 'Slot ID', 'AdSense ad', 'advanced-ads' ); ?></th>
43
+ <th><?php echo esc_html_x( 'Type', 'AdSense ad', 'advanced-ads' ); ?></th>
44
+ <th><?php esc_html_e( 'Size', 'advanced-ads' ); ?></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <tr>
49
+ <td colspan="5" style="text-align:center;">
50
+ <?php esc_attr_e( 'No ad units found', 'advanced-ads' ) ?>
51
+ <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>
52
+ </td>
53
+ </tr>
54
+ <?php else : $sorted_adunits = Advanced_Ads_AdSense_MAPI::get_sorted_adunits( $ad_units ); ?>
55
+ <tbody>
56
+ <?php foreach ( $sorted_adunits as $name => $unit ) : $unsupported_class = array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ? ' disabled' : ''; ?>
57
+ <tr data-slotid="<?php echo esc_attr( $unit['id'] ); ?>">
58
+ <td>
59
+ <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>
60
+ <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>
61
+ </td>
62
+ <td><?php echo $name; ?></td>
63
+ <td class="unitcode"><?php
64
+ if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
65
+ echo '<span class="unsupported"><span>' . esc_html( $unit['code'] ) . '</span></span>';
66
+ } else {
67
+ echo '<span><span>' . esc_html( $unit['code'] ) . '</span></span>';
68
+ }
69
+ ?></td>
70
+ <td class="unittype"><?php
71
+ if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
72
+ 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' ) ) . '">';
73
+ esc_html_e( 'unsupported', 'advanced-ads' );
74
+ echo '</a>';
75
+ } else {
76
+ echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['type'], 'type' );
77
+ }
78
+ ?></td>
79
+ <td class="unitsize"><?php
80
+ if ( array_key_exists( $unit['id'], $mapi_options['unsupported_units'] ) ) {
81
+ echo '<a href="' . esc_url( $unsupported_ad_type_link ) . '" target="_blank" data-size="' . Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['size'], 'size' ) . '">';
82
+ esc_html_e( 'unsupported', 'advanced-ads' );
83
+ echo '</a>';
84
+ } else {
85
+ echo Advanced_Ads_AdSense_MAPI::format_ad_data( $unit['contentAdsSettings']['size'], 'size' );
86
+ }
87
+ ?></td>
88
+ </tr>
89
+ <?php endforeach; ?>
90
+ <?php endif; ?>
91
+ </tbody>
92
+ </table>
93
+ </div>
94
+ <?php endif; ?>
95
+
96
+ <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>
97
+ <p class="advads-error-message" id="remote-ad-code-msg"></p>
98
+ <div style="display:none;" id="remote-ad-unsupported-ad-type"><p><i class="dashicons dashicons-warning"></i><b class="advads-error-message"><?php
99
+ 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
100
+ esc_attr_e( 'Learn more and help us to enable it here.', 'advanced-ads' ) ?></a></p>
101
+ <?php esc_attr_e( 'In the meantime, you can use AdSense with one of these methods:', 'advanced-ads' ) ?>
102
+ <ul>
103
+ <li><?php _e( 'Click on <em>Insert new AdSense code</em> and copy the code from your AdSense account into it.', 'advanced-ads' ) ?></li>
104
+ <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>
105
+ <li><?php _e( 'Choose a <em>Normal</em>, <em>Responsive</em> or <em>Link Unit</em> ad from your AdSense account.', 'advanced-ads' ) ?></li>
106
+ </ul>
107
  </div>
108
  </div>
109
+ <?php if ( 8 < count( $ad_units ) ) : ?>
110
+ <style type="text/css">
111
+ #mapi-table-wrap {
112
+ height: 22.2em;
113
+ overflow: auto;
114
+ }
115
+ #mapi-wrap table {
116
+ position: absolute;
117
+ }
118
+ </style>
119
+ <?php endif; ?>
modules/gadsense/includes/class-ad-type-adsense.php CHANGED
@@ -215,7 +215,12 @@ class Advanced_Ads_Ad_Type_Adsense extends Advanced_Ads_Ad_Type_Abstract {
215
  */
216
  $this->append_defaut_responsive_content( $output, $pub_id, $content );
217
  }
 
 
 
218
  }
 
 
219
  return $output;
220
  }
221
 
215
  */
216
  $this->append_defaut_responsive_content( $output, $pub_id, $content );
217
  }
218
+
219
+ // Remove float setting if this is a responsive ad unit without custom sizes.
220
+ unset( $ad->wrapper['style']['float'] );
221
  }
222
+
223
+
224
  return $output;
225
  }
226
 
modules/gadsense/includes/class-mapi.php CHANGED
@@ -1,60 +1,63 @@
1
  <?php
2
- class Advanced_Ads_AdSense_MAPI
3
- {
4
  const OPTNAME = 'advanced-ads-adsense-mapi';
5
-
6
  const CID = '400595147946-alk0j13qk563bg94rd4f3ip2t0b2tr5r.apps.googleusercontent.com';
7
-
8
  const CS = '5jecyWgvCszB8UxSM0oS1W22';
9
-
10
  const CALL_PER_24H = 20;
11
 
 
 
12
  private static $instance = null;
13
-
14
  private static $default_options = array();
15
-
16
  private static $empty_account_data = array(
17
  'default_app' => array(
18
- 'access_token' => '',
19
  'refresh_token' => '',
20
- 'expires' => 0,
21
- 'token_type' => '',
22
  ),
23
- 'user_app' => array(
24
- 'access_token' => '',
25
  'refresh_token' => '',
26
- 'expires' => 0,
27
- 'token_type' => '',
28
  ),
29
- 'ad_units' => array(),
30
  );
31
-
32
  private function __construct() {
33
-
34
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
35
-
36
  add_action( 'wp_ajax_advads_gadsense_mapi_confirm_code', array( $this, 'ajax_confirm_code' ) );
37
  add_action( 'wp_ajax_advads_gadsense_mapi_get_adUnits', array( $this, 'ajax_get_adUnits' ) );
38
  add_action( 'wp_ajax_advads_mapi_get_adCode', array( $this, 'ajax_get_adCode' ) );
39
  add_action( 'wp_ajax_advads-mapi-reconstructed-code', array( $this, 'ajax_save_reconstructed_code' ) );
40
  add_action( 'wp_ajax_advads-mapi-revoke-token', array( $this, 'ajax_revoke_tokken' ) );
41
-
42
  self::$default_options = array(
43
- 'accounts' => array(),
44
- 'ad_codes' => array(),
45
- 'quota' => array(
 
46
  'count' => self::CALL_PER_24H,
47
- 'ts' => 0,
48
  ),
49
  );
50
  }
51
-
52
  /**
53
- * Get available quota and eventual message about remaining call
54
  */
55
  public function get_quota() {
56
  $options = $this->get_option();
57
- $now = time();
58
  if ( self::use_user_app() ) {
59
  return array( 'count' => PHP_INT_MAX );
60
  } else {
@@ -66,32 +69,33 @@ class Advanced_Ads_AdSense_MAPI
66
  $msg = $this->get_quota_msg();
67
  return array(
68
  'count' => $options['quota']['count'],
69
- 'msg' => $msg,
70
  );
71
  }
72
  }
73
  }
74
-
75
  /**
76
  * Get the readable quota
77
  */
78
  public function get_quota_msg() {
79
-
80
  $options = $this->get_option();
81
- $now = time();
82
- $secs = $options['quota']['ts'] + ( 24 * 3600 ) - $now;
83
- $hours = floor( $secs / 3600 );
84
- $mins = ceil( ( $secs - ( $hours * 3600 ) ) / 60 );
85
-
86
  if ( 60 == $mins ) {
87
  $hours += 1;
88
- $mins = 0;
89
  }
90
-
91
  if ( 0 == $options['quota']['count'] ) {
92
-
93
  $msg = sprintf(
94
- /* 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
 
95
  _x( 'No API call left before %1$s %2$s.', 'No call left for the next X hours Y minutes.', 'advanced-ads' ),
96
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
97
  sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
@@ -100,9 +104,10 @@ class Advanced_Ads_AdSense_MAPI
100
  sprintf( '%s hours', $hours ),
101
  sprintf( '%s minutes', $mins )
102
  );
103
-
104
  if ( 0 == $hours ) {
105
- /* 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
 
106
  $msg = sprintf(
107
  _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
108
  sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
@@ -110,9 +115,10 @@ class Advanced_Ads_AdSense_MAPI
110
  */
111
  $msg = 'No API call left before.';
112
  }
113
-
114
  if ( 0 == $mins ) {
115
- /* 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
 
116
  $msg = sprintf(
117
  _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
118
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
@@ -120,11 +126,11 @@ class Advanced_Ads_AdSense_MAPI
120
  */
121
  $msg = 'No API call left.';
122
  }
123
-
124
  } else {
125
-
126
  $msg = sprintf(
127
- /* 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
 
128
  _x( '%1$s for the next %2$s %3$s.', 'Calls remaining for the next X hours Y minutes.', 'advanced-ads' ),
129
  sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
130
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
@@ -135,9 +141,10 @@ class Advanced_Ads_AdSense_MAPI
135
  sprintf( '%s hours', $hours ),
136
  sprintf( '%s minutes', $mins )
137
  );
138
-
139
  if ( 0 == $hours ) {
140
- /* 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
 
141
  $msg = sprintf(
142
  _x( '%1$s for the next %2$s', 'Calls remaining for the next X time.', 'advanced-ads' ),
143
  sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
@@ -146,9 +153,10 @@ class Advanced_Ads_AdSense_MAPI
146
  */
147
  $msg = sprintf( '%s API calls remaining.', $options['quota']['count'] );
148
  }
149
-
150
  if ( 0 == $mins ) {
151
- /* 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
 
152
  $msg = sprintf(
153
  _x( '%1$s for the next %2$s', 'calls remaining for the next X time', 'advanced-ads' ),
154
  sprintf( _n( '%s API call remaining', '%s API calls remaining', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
@@ -161,13 +169,12 @@ class Advanced_Ads_AdSense_MAPI
161
  sprintf( '%s hours', $hours )
162
  );
163
  }
164
-
165
  }
166
  return $msg;
167
  }
168
-
169
  /**
170
- * Decrement quota by 1, and return message about remaining call
171
  */
172
  public function decrement_quota() {
173
  $options = $this->get_option();
@@ -181,7 +188,7 @@ class Advanced_Ads_AdSense_MAPI
181
  return $this->get_quota_msg();
182
  }
183
  }
184
-
185
  /**
186
  * Return the ad code for a given client and unit
187
  *
@@ -189,25 +196,29 @@ class Advanced_Ads_AdSense_MAPI
189
  */
190
  public function get_ad_code( $adUnit ) {
191
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
192
- $adsense_id = $gadsense_data->get_adsense_id();
193
- $options = self::get_option();
194
-
195
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
196
- $adsense_id = $gadsense_data->get_adsense_id();
197
-
198
- $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $adsense_id . '/adclients/ca-' . $adsense_id . '/adunits/' . $adUnit . '/adcode';
199
  $access_token = $this->get_access_token( $adsense_id );
200
-
201
- if ( !isset( $access_token['msg'] ) ) {
202
- $headers = array(
203
  'Authorization' => 'Bearer ' . $access_token,
204
  );
205
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
206
  if ( is_wp_error( $response ) ) {
207
- return array( 'status' => false, 'msg' => 'error while retrieving adUnits list', 'raw' => $response->get_error_message() );
 
 
 
 
208
  } else {
209
  $adCode = json_decode( $response['body'], true );
210
- if ( null === $adCode || !isset( $adCode['adCode'] ) ) {
211
  if (
212
  $adCode['error'] &&
213
  $adCode['error']['errors'] &&
@@ -215,12 +226,24 @@ class Advanced_Ads_AdSense_MAPI
215
  isset( $adCode['error']['errors'][0]['reason'] ) &&
216
  'doesNotSupportAdUnitType' == $adCode['error']['errors'][0]['reason']
217
  ) {
218
- return array( 'status' => false, 'msg' => 'doesNotSupportAdUnitType' );
 
 
 
 
 
219
  } else {
220
- return array( 'status' => false, 'msg' => 'invalid response while retrieving adCode for ' . $adUnit, 'raw' => $response['body'] );
 
 
 
 
221
  }
222
  } else {
223
- $options['ad_codes'][$adUnit] = $adCode['adCode'];
 
 
 
224
  update_option( self::OPTNAME, $options );
225
  return $adCode['adCode'];
226
  }
@@ -230,36 +253,44 @@ class Advanced_Ads_AdSense_MAPI
230
  return $access_token;
231
  }
232
  }
233
-
234
  /**
235
  * Get/Update ad unit list for a given client
236
- *
237
  * @return [bool]|[array] TRUE on success, error info (as array) if an error occurred.
238
  */
239
  public function get_ad_units( $account ) {
240
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
241
- $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $account . '/adclients/ca-' . $account . '/adunits?includeInactive=true';
242
- $access_token = $this->get_access_token( $account );
243
-
244
  $options = self::get_option();
245
-
246
- if ( !isset( $access_token['msg'] ) ) {
247
- $headers = array(
248
  'Authorization' => 'Bearer ' . $access_token,
249
  );
250
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
251
  if ( is_wp_error( $response ) ) {
252
- return array( 'status' => false, 'msg' => 'error while retrieving adUnits list for "' . $account . '"', 'raw' => $response->get_error_message() );
 
 
 
 
253
  } else {
254
  $adUnits = json_decode( $response['body'], true );
255
- if ( null === $adUnits || !isset( $adUnits['items'] ) ) {
256
- return array( 'status' => false, 'msg' => 'invalid response while retrieving adUnits list for "' . $account . '"', 'raw' => $response['body'] );
 
 
 
 
257
  } else {
258
  $new_adUnits = array();
259
- foreach( $adUnits['items'] as $item ) {
260
- $new_adUnits[$item['id']] = $item;
261
  }
262
- $options['accounts'][$account]['ad_units'] = $new_adUnits;
263
  update_option( self::OPTNAME, $options );
264
  return true;
265
  }
@@ -269,7 +300,7 @@ class Advanced_Ads_AdSense_MAPI
269
  return $access_token;
270
  }
271
  }
272
-
273
  /**
274
  * Get the appropriate access token (default one or from user's Google app). Update it if needed.
275
  *
@@ -278,7 +309,7 @@ class Advanced_Ads_AdSense_MAPI
278
  public function get_access_token( $account ) {
279
  $options = self::get_option();
280
  if ( self::use_user_app() ) {
281
- if ( time() > $options['accounts'][$account]['user_app']['expires'] ) {
282
  $new_tokens = $this->renew_access_token( $account );
283
  if ( $new_tokens['status'] ) {
284
  return $new_tokens['access_token'];
@@ -287,10 +318,10 @@ class Advanced_Ads_AdSense_MAPI
287
  return $new_tokens;
288
  }
289
  } else {
290
- return $options['accounts'][$account]['user_app']['access_token'];
291
  }
292
  } else {
293
- if ( time() > $options['accounts'][$account]['default_app']['expires'] ) {
294
  $new_tokens = $this->renew_access_token( $account );
295
  if ( $new_tokens['status'] ) {
296
  return $new_tokens['access_token'];
@@ -299,219 +330,217 @@ class Advanced_Ads_AdSense_MAPI
299
  return $new_tokens;
300
  }
301
  } else {
302
- return $options['accounts'][$account]['default_app']['access_token'];
303
  }
304
  }
305
  }
306
-
307
  /**
308
  * Renew the current access token.
309
  */
310
  public function renew_access_token( $account ) {
311
- $cid = self::CID;
312
- $cs = self::CS;
313
- $options = self::get_option();
314
- $access_token = $options['accounts'][$account]['default_app']['access_token'];
315
- $refresh_token = $options['accounts'][$account]['default_app']['refresh_token'];
316
-
317
  if ( self::use_user_app() ) {
318
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
319
- $_options = $gadsense_data->get_options();
320
- $cid = ADVANCED_ADS_MAPI_CID;
321
- $cs = ADVANCED_ADS_MAPI_CIS;
322
- $access_token = $options['accounts'][$account]['user_app']['access_token'];
323
- $refresh_token = $options['accounts'][$account]['user_app']['refresh_token'];
324
  }
325
-
326
- $url = 'https://www.googleapis.com/oauth2/v4/token';
327
  $args = array(
328
  'body' => array(
329
  'refresh_token' => $refresh_token,
330
- 'client_id' => $cid,
331
  'client_secret' => $cs,
332
- 'grant_type' => 'refresh_token',
333
  ),
334
  );
335
-
336
  $response = wp_remote_post( $url, $args );
337
  if ( is_wp_error( $response ) ) {
338
- return array( 'status' => false, 'msg' => 'error while renewing access token for "' . $account . '"', 'raw' => $response->get_error_message() );
 
 
 
 
339
  } else {
340
  $tokens = json_decode( $response['body'], true );
341
  if ( null !== $tokens ) {
342
  $expires = time() + absint( $tokens['expires_in'] );
343
  if ( self::use_user_app() ) {
344
- $options['accounts'][$account]['user_app']['access_token'] = $tokens['access_token'];
345
- $options['accounts'][$account]['user_app']['expires'] = $expires;
346
  } else {
347
- $options['accounts'][$account]['default_app']['access_token'] = $tokens['access_token'];
348
- $options['accounts'][$account]['default_app']['expires'] = $expires;
349
  }
350
  update_option( self::OPTNAME, $options );
351
- return array( 'status' => true, 'access_token' => $tokens['access_token'] );
 
 
 
352
  } else {
353
- return array( 'status' => false, 'msg' => 'invalid response received while renewing access token for "' . $account . '"', 'raw' => $response['body'] );
 
 
 
 
354
  }
355
  }
356
  }
357
-
358
  /**
359
  * Recoke a refresh token
360
  */
361
  public function ajax_revoke_tokken() {
362
-
363
- $nonce = isset( $_POST['nonce'] )? $_POST['nonce'] : '';
364
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
365
  $adsense_id = stripslashes( $_POST['adsenseId'] );
366
- $options = self::get_option();
367
  if ( self::use_user_app() ) {
368
- $token = $options['accounts'][$adsense_id]['user_app']['refresh_token'];
369
  } else {
370
- $token = $options['accounts'][$adsense_id]['default_app']['refresh_token'];
371
  }
372
- $url = 'https://accounts.google.com/o/oauth2/revoke?token=' . $token;
373
  $args = array(
374
  'timeout' => 5,
375
- 'header' => array( 'Content-type' => 'application/x-www-form-urlencoded' ),
376
  );
377
-
378
  $response = wp_remote_post( $url, $args );
379
  if ( is_wp_error( $response ) ) {
380
  echo json_encode( array( 'status' => false ) );
381
  } else {
382
- header( 'Content-Type: application/json' );
383
- unset( $options['accounts'][$adsense_id] );
384
  update_option( self::OPTNAME, $options );
385
  echo json_encode( array( 'status' => true ) );
386
  }
387
  }
388
  die;
389
-
390
  }
391
-
392
  /**
393
- * Save ad code reconstructed from ad parameters
394
  */
395
  public function ajax_save_reconstructed_code() {
396
- $nonce = isset( $_POST['nonce'] )? $_POST['nonce'] : '';
397
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
398
- $code = stripslashes( $_POST['code'] );
399
- $slot = stripslashes( $_POST['slot'] );
400
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
401
- $adsense_id = $gadsense_data->get_adsense_id();
402
- $options = self::get_option();
403
- $options['ad_codes']['ca-' . $adsense_id . ':' . $slot] = $code;
404
  update_option( self::OPTNAME, $options );
405
  header( 'Content-Type: application/json' );
406
  echo json_encode( array( 'status' => true ) );
407
  }
408
  die;
409
  }
410
-
411
  /**
412
- * Get ad code for a given unit
413
  */
414
  public function ajax_get_adCode() {
415
- $nonce = isset( $_POST['nonce'] )? $_POST['nonce'] : '';
416
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
417
  $unit = stripslashes( $_POST['unit'] );
418
-
419
- if ( !self::use_user_app() ) {
420
  $quota = $this->get_quota();
421
-
422
  // No more quota left
423
  if ( $quota['count'] < 1 ) {
424
  $quota_msg = $this->get_quota_msg();
425
  header( 'Content-Type: application/json' );
426
  $quota_msg = $this->get_quota_msg();
427
  echo wp_json_encode(
428
- array(
429
- 'quota' => 0,
430
  'quotaMsg' => $quota_msg,
431
  )
432
  );
433
  die;
434
  }
435
-
436
  }
437
-
438
  $code = $this->get_ad_code( $unit );
439
-
440
  /**
441
- * Ad code is returned as string. Otherwise it's an error
442
  */
443
  if ( is_string( $code ) ) {
444
-
445
  $response = array( 'code' => $code );
446
-
447
  /**
448
  * Add quota info for default API creds
449
  */
450
- if ( !self::use_user_app() ) {
451
- $quota = $this->get_quota();
452
- $quota_msg = $this->get_quota_msg();
453
- $response['quota'] = $quota['count'];
454
  $response['quotaMsg'] = $quota_msg;
455
  }
456
-
457
  header( 'Content-Type: application/json' );
458
  echo wp_json_encode( $response );
459
-
460
  } else {
461
-
462
  // return info about the error
463
  header( 'Content-Type: application/json' );
464
  echo wp_json_encode( $code );
465
-
466
  }
467
-
468
  }
469
  die;
470
  }
471
-
472
  /**
473
  * 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
474
  */
475
  public function ajax_get_adUnits() {
476
- $nonce = isset( $_POST['nonce'] )? $_POST['nonce'] : '';
477
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
478
  $account = stripslashes( $_POST['account'] );
479
- $units = $this->get_ad_units( $account );
480
-
481
  if ( true == $units ) {
482
- $options = self::get_option();
483
- $ad_units = $options['accounts'][$account]['ad_units'];
484
  ob_start();
485
-
486
- echo '<select id="mapi-adunit-select">';
487
- if ( empty( $ad_units ) ) {
488
- echo '<option value="">' . __( 'No ad unit found', 'advanced-ads' ) . '</option>';
489
- } else {
490
- echo '<option value="">' . __( '--select ad--', 'advanced-ads' ) . '</option>';
491
- $sorted_adunits = self::get_sorted_adunits( $ad_units );
492
- foreach ( $sorted_adunits as $key => $value ) {
493
- echo '<option value="' . esc_attr( $key ) . '">' . $value . '</option>';
494
- }
495
- }
496
- echo '</select>';
497
-
498
  $ad_selector = ob_get_clean();
499
-
500
  $response = array(
501
  'status' => true,
502
- 'html' => $ad_selector,
503
  );
504
-
505
  /**
506
  * Add quota info for default API creds
507
  */
508
- if ( !self::use_user_app() ) {
509
- $quota = $this->get_quota();
510
- $quota_msg = $this->get_quota_msg();
511
- $response['quota'] = $quota['count'];
512
  $response['quotaMsg'] = $quota_msg;
513
  }
514
-
515
  } else {
516
  /**
517
  * return the error info [arr]
@@ -523,129 +552,167 @@ class Advanced_Ads_AdSense_MAPI
523
  }
524
  die;
525
  }
526
-
527
  /**
528
  * Submit Google API confirmation code. Save the token and update ad client list.
529
  */
530
  public function ajax_confirm_code() {
531
- $nonce = isset( $_POST['nonce'] )? $_POST['nonce'] : '';
532
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
533
  $code = urldecode( $_POST['code'] );
534
- $cid = self::CID;
535
- $cs = self::CS;
536
-
537
  $use_user_app = self::use_user_app();
538
-
539
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
540
-
541
  if ( $use_user_app ) {
542
  $_options = $gadsense_data->get_options();
543
- $cid = ADVANCED_ADS_MAPI_CID;
544
- $cs = ADVANCED_ADS_MAPI_CIS;
545
  }
546
-
547
- $code_url = 'https://www.googleapis.com/oauth2/v4/token';
548
  $redirect_uri = 'urn:ietf:wg:oauth:2.0:oob';
549
- $grant_type = 'authorization_code';
550
-
551
  $args = array(
552
  'timeout' => 10,
553
- 'body' => array(
554
- 'code' => $code,
555
- 'client_id' => $cid,
556
  'client_secret' => $cs,
557
- 'redirect_uri' => $redirect_uri,
558
- 'grant_type' => $grant_type,
559
  ),
560
  );
561
-
562
  $response = wp_remote_post( $code_url, $args );
563
-
564
  if ( is_wp_error( $response ) ) {
565
- return json_encode( array( 'status' => false, 'msg' => 'error while submitting code', 'raw' => $response->get_error_message() ) );
 
 
 
 
 
 
566
  } else {
567
- $token = json_decode( $response['body'], true );
568
  $adsense_id = $gadsense_data->get_adsense_id();
569
-
570
  if ( null !== $token && isset( $token['refresh_token'] ) ) {
571
-
572
- if ( !empty( $adsense_id ) ) {
573
  self::save_token_from_code( $token, $adsense_id );
574
-
575
- $gadsense_options = $gadsense_data->get_options();
576
  $gadsense_options['page-level-enabled'] = isset( $_POST['autoads'] );
577
  update_option( GADSENSE_OPT_NAME, $gadsense_options );
578
-
579
  header( 'Content-Type: application/json' );
580
  echo json_encode( array( 'status' => true ) );
581
-
582
  } else {
583
  /**
584
- * get AdSense ID first
585
  */
586
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts';
587
-
588
- $headers = array( 'Authorization' => 'Bearer ' . $token['access_token'] );
589
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
590
-
591
  if ( is_wp_error( $response ) ) {
592
-
593
  header( 'Content-Type: application/json' );
594
- echo json_encode( array( 'status' => false, 'error_msg' => $response->get_error_message() ) );
595
-
 
 
 
 
 
596
  } else {
597
-
598
- $accounts = json_decode( $response['body'], true );
599
  $adsense_id = $accounts['items'][0]['id'];
600
-
601
- $gadsense_options = $gadsense_data->get_options();
602
  $gadsense_options['adsense-id'] = $adsense_id;
603
-
604
  $gadsense_options['page-level-enabled'] = isset( $_POST['autoads'] );
605
-
606
  update_option( GADSENSE_OPT_NAME, $gadsense_options );
607
  self::save_token_from_code( $token, $adsense_id );
608
-
609
  header( 'Content-Type: application/json' );
610
  echo json_encode( array( 'status' => true ) );
611
-
612
  }
613
  }
614
-
615
-
616
  } else {
617
  header( 'Content-Type: application/json' );
618
- echo json_encode( array( 'status' => false, 'response_body' => $response['body'] ) );
 
 
 
 
 
619
  }
620
  }
621
  }
622
  die;
623
  }
624
-
625
  /**
626
- * Enqueue admin scripts
627
  */
628
  public function admin_scripts( $hook ) {
629
  if ( 'advanced-ads_page_advanced-ads-settings' == $hook ) {
630
  wp_enqueue_script( 'gasense/mapi/settings', GADSENSE_BASE_URL . 'admin/assets/js/mapi-settings.js', array( 'jquery' ), ADVADS_VERSION );
631
  }
632
  }
633
-
634
  /**
635
  * Sort ad units list alphabetically
636
  */
637
  public static function get_sorted_adunits( $adunits ) {
638
- $results = array();
 
639
  foreach ( $adunits as $unit ) {
640
- $results[$unit['name']] = $unit['id'];
 
 
 
 
 
 
 
641
  }
642
- ksort( $results );
643
- $results = array_flip( $results );
644
  return $results;
645
  }
646
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  /**
648
- * Check if the credential are the default ones or from user's app
649
  */
650
  public static function use_user_app() {
651
  if ( ( defined( 'ADVANCED_ADS_MAPI_CID' ) && '' != ADVANCED_ADS_MAPI_CID ) && ( defined( 'ADVANCED_ADS_MAPI_CIS' ) && '' != ADVANCED_ADS_MAPI_CIS ) ) {
@@ -654,69 +721,71 @@ class Advanced_Ads_AdSense_MAPI
654
  return false;
655
  }
656
  }
657
-
658
  public static function has_token( $adsense_id = '' ) {
659
  if ( empty( $adsense_id ) ) {
660
  return false;
661
  }
662
-
663
  $has_token = false;
664
- $options = self::get_option();
665
  if ( self::use_user_app() ) {
666
- if ( isset( $options['accounts'][$adsense_id] ) && !empty( $options['accounts'][$adsense_id]['user_app']['refresh_token'] ) ) {
667
  $has_token = true;
668
  }
669
  } else {
670
- if ( isset( $options['accounts'][$adsense_id] ) && !empty( $options['accounts'][$adsense_id]['default_app']['refresh_token'] ) ) {
671
  $has_token = true;
672
  }
673
  }
674
  return $has_token;
675
-
676
  }
677
-
678
  /**
679
- * save token obtained from confirmation code
680
  */
681
  public static function save_token_from_code( $token, $adsense_id ) {
682
-
683
  $options = self::get_option();
684
  $expires = time() + absint( $token['expires_in'] );
685
- if ( !isset( $options['accounts'][$adsense_id] ) ) {
686
- $options['accounts'][$adsense_id] = self::$empty_account_data;
687
  }
688
  if ( self::use_user_app() ) {
689
- $options['accounts'][$adsense_id]['user_app'] = array(
690
- 'access_token' => $token['access_token'],
691
  'refresh_token' => $token['refresh_token'],
692
- 'expires' => $expires,
693
- 'token_type' => $token['token_type'],
694
  );
695
  } else {
696
- $options['accounts'][$adsense_id]['default_app'] = array(
697
- 'access_token' => $token['access_token'],
698
  'refresh_token' => $token['refresh_token'],
699
- 'expires' => $expires,
700
- 'token_type' => $token['token_type'],
701
  );
702
  }
703
  update_option( self::OPTNAME, $options );
704
-
705
  }
706
-
707
  /**
708
- * Get the class's option
709
  */
710
  public static function get_option() {
711
  $options = get_option( self::OPTNAME, array() );
712
- if ( !is_array( $options ) ) $options = array();
 
 
713
  return $options + self::$default_options;
714
  }
715
-
716
  public static function get_instance() {
717
- if (null == self::$instance) {
718
- self::$instance = new self;
719
  }
720
  return self::$instance;
721
- }
722
  }
1
  <?php
2
+ class Advanced_Ads_AdSense_MAPI {
3
+
4
  const OPTNAME = 'advanced-ads-adsense-mapi';
5
+
6
  const CID = '400595147946-alk0j13qk563bg94rd4f3ip2t0b2tr5r.apps.googleusercontent.com';
7
+
8
  const CS = '5jecyWgvCszB8UxSM0oS1W22';
9
+
10
  const CALL_PER_24H = 20;
11
 
12
+ const UNSUPPORTED_TYPE_LINK = 'https://wpadvancedads.com/adsense-ad-type-not-available/';
13
+
14
  private static $instance = null;
15
+
16
  private static $default_options = array();
17
+
18
  private static $empty_account_data = array(
19
  'default_app' => array(
20
+ 'access_token' => '',
21
  'refresh_token' => '',
22
+ 'expires' => 0,
23
+ 'token_type' => '',
24
  ),
25
+ 'user_app' => array(
26
+ 'access_token' => '',
27
  'refresh_token' => '',
28
+ 'expires' => 0,
29
+ 'token_type' => '',
30
  ),
31
+ 'ad_units' => array(),
32
  );
33
+
34
  private function __construct() {
35
+
36
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
37
+
38
  add_action( 'wp_ajax_advads_gadsense_mapi_confirm_code', array( $this, 'ajax_confirm_code' ) );
39
  add_action( 'wp_ajax_advads_gadsense_mapi_get_adUnits', array( $this, 'ajax_get_adUnits' ) );
40
  add_action( 'wp_ajax_advads_mapi_get_adCode', array( $this, 'ajax_get_adCode' ) );
41
  add_action( 'wp_ajax_advads-mapi-reconstructed-code', array( $this, 'ajax_save_reconstructed_code' ) );
42
  add_action( 'wp_ajax_advads-mapi-revoke-token', array( $this, 'ajax_revoke_tokken' ) );
43
+
44
  self::$default_options = array(
45
+ 'accounts' => array(),
46
+ 'ad_codes' => array(),
47
+ 'unsupported_units' => array(),
48
+ 'quota' => array(
49
  'count' => self::CALL_PER_24H,
50
+ 'ts' => 0,
51
  ),
52
  );
53
  }
54
+
55
  /**
56
+ * Get available quota and eventual message about remaining call
57
  */
58
  public function get_quota() {
59
  $options = $this->get_option();
60
+ $now = time();
61
  if ( self::use_user_app() ) {
62
  return array( 'count' => PHP_INT_MAX );
63
  } else {
69
  $msg = $this->get_quota_msg();
70
  return array(
71
  'count' => $options['quota']['count'],
72
+ 'msg' => $msg,
73
  );
74
  }
75
  }
76
  }
77
+
78
  /**
79
  * Get the readable quota
80
  */
81
  public function get_quota_msg() {
82
+
83
  $options = $this->get_option();
84
+ $now = time();
85
+ $secs = $options['quota']['ts'] + ( 24 * 3600 ) - $now;
86
+ $hours = floor( $secs / 3600 );
87
+ $mins = ceil( ( $secs - ( $hours * 3600 ) ) / 60 );
88
+
89
  if ( 60 == $mins ) {
90
  $hours += 1;
91
+ $mins = 0;
92
  }
93
+
94
  if ( 0 == $options['quota']['count'] ) {
95
+
96
  $msg = sprintf(
97
+ /*
98
+ 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
99
  _x( 'No API call left before %1$s %2$s.', 'No call left for the next X hours Y minutes.', 'advanced-ads' ),
100
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
101
  sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
104
  sprintf( '%s hours', $hours ),
105
  sprintf( '%s minutes', $mins )
106
  );
107
+
108
  if ( 0 == $hours ) {
109
+ /*
110
+ 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
111
  $msg = sprintf(
112
  _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
113
  sprintf( _n( '%s minute', '%s minutes', $mins, 'advanced-ads' ), $mins )
115
  */
116
  $msg = 'No API call left before.';
117
  }
118
+
119
  if ( 0 == $mins ) {
120
+ /*
121
+ 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
122
  $msg = sprintf(
123
  _x( 'No API call left before %s.', 'No call left for the next X time.', 'advanced-ads' ),
124
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours )
126
  */
127
  $msg = 'No API call left.';
128
  }
 
129
  } else {
130
+
131
  $msg = sprintf(
132
+ /*
133
+ 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
134
  _x( '%1$s for the next %2$s %3$s.', 'Calls remaining for the next X hours Y minutes.', 'advanced-ads' ),
135
  sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
136
  sprintf( _n( '%s hour', '%s hours', $hours, 'advanced-ads' ), $hours ),
141
  sprintf( '%s hours', $hours ),
142
  sprintf( '%s minutes', $mins )
143
  );
144
+
145
  if ( 0 == $hours ) {
146
+ /*
147
+ 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
148
  $msg = sprintf(
149
  _x( '%1$s for the next %2$s', 'Calls remaining for the next X time.', 'advanced-ads' ),
150
  sprintf( _n( '%s API call remaining.', '%s API calls remaining.', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
153
  */
154
  $msg = sprintf( '%s API calls remaining.', $options['quota']['count'] );
155
  }
156
+
157
  if ( 0 == $mins ) {
158
+ /*
159
+ 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
160
  $msg = sprintf(
161
  _x( '%1$s for the next %2$s', 'calls remaining for the next X time', 'advanced-ads' ),
162
  sprintf( _n( '%s API call remaining', '%s API calls remaining', $options['quota']['count'], 'advanced-ads' ), $options['quota']['count'] ),
169
  sprintf( '%s hours', $hours )
170
  );
171
  }
 
172
  }
173
  return $msg;
174
  }
175
+
176
  /**
177
+ * Decrement quota by 1, and return message about remaining call
178
  */
179
  public function decrement_quota() {
180
  $options = $this->get_option();
188
  return $this->get_quota_msg();
189
  }
190
  }
191
+
192
  /**
193
  * Return the ad code for a given client and unit
194
  *
196
  */
197
  public function get_ad_code( $adUnit ) {
198
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
199
+ $adsense_id = $gadsense_data->get_adsense_id();
200
+ $options = self::get_option();
201
+
202
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
203
+ $adsense_id = $gadsense_data->get_adsense_id();
204
+
205
+ $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $adsense_id . '/adclients/ca-' . $adsense_id . '/adunits/' . $adUnit . '/adcode';
206
  $access_token = $this->get_access_token( $adsense_id );
207
+
208
+ if ( ! isset( $access_token['msg'] ) ) {
209
+ $headers = array(
210
  'Authorization' => 'Bearer ' . $access_token,
211
  );
212
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
213
  if ( is_wp_error( $response ) ) {
214
+ return array(
215
+ 'status' => false,
216
+ 'msg' => 'error while retrieving adUnits list',
217
+ 'raw' => $response->get_error_message(),
218
+ );
219
  } else {
220
  $adCode = json_decode( $response['body'], true );
221
+ if ( null === $adCode || ! isset( $adCode['adCode'] ) ) {
222
  if (
223
  $adCode['error'] &&
224
  $adCode['error']['errors'] &&
226
  isset( $adCode['error']['errors'][0]['reason'] ) &&
227
  'doesNotSupportAdUnitType' == $adCode['error']['errors'][0]['reason']
228
  ) {
229
+ $options['unsupported_units'][ $adUnit ] = 1;
230
+ update_option( self::OPTNAME, $options );
231
+ return array(
232
+ 'status' => false,
233
+ 'msg' => 'doesNotSupportAdUnitType',
234
+ );
235
  } else {
236
+ return array(
237
+ 'status' => false,
238
+ 'msg' => 'invalid response while retrieving adCode for ' . $adUnit,
239
+ 'raw' => $response['body'],
240
+ );
241
  }
242
  } else {
243
+ $options['ad_codes'][ $adUnit ] = $adCode['adCode'];
244
+ if ( isset( $options['unsupported_units'][ $adUnit ] ) ) {
245
+ unset( $options['unsupported_units'][ $adUnit ] );
246
+ }
247
  update_option( self::OPTNAME, $options );
248
  return $adCode['adCode'];
249
  }
253
  return $access_token;
254
  }
255
  }
256
+
257
  /**
258
  * Get/Update ad unit list for a given client
259
+ *
260
  * @return [bool]|[array] TRUE on success, error info (as array) if an error occurred.
261
  */
262
  public function get_ad_units( $account ) {
263
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
264
+ $url = 'https://www.googleapis.com/adsense/v1.4/accounts/' . $account . '/adclients/ca-' . $account . '/adunits?includeInactive=true';
265
+ $access_token = $this->get_access_token( $account );
266
+
267
  $options = self::get_option();
268
+
269
+ if ( ! isset( $access_token['msg'] ) ) {
270
+ $headers = array(
271
  'Authorization' => 'Bearer ' . $access_token,
272
  );
273
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
274
  if ( is_wp_error( $response ) ) {
275
+ return array(
276
+ 'status' => false,
277
+ 'msg' => 'error while retrieving adUnits list for "' . $account . '"',
278
+ 'raw' => $response->get_error_message(),
279
+ );
280
  } else {
281
  $adUnits = json_decode( $response['body'], true );
282
+ if ( null === $adUnits || ! isset( $adUnits['items'] ) ) {
283
+ return array(
284
+ 'status' => false,
285
+ 'msg' => 'invalid response while retrieving adUnits list for "' . $account . '"',
286
+ 'raw' => $response['body'],
287
+ );
288
  } else {
289
  $new_adUnits = array();
290
+ foreach ( $adUnits['items'] as $item ) {
291
+ $new_adUnits[ $item['id'] ] = $item;
292
  }
293
+ $options['accounts'][ $account ]['ad_units'] = $new_adUnits;
294
  update_option( self::OPTNAME, $options );
295
  return true;
296
  }
300
  return $access_token;
301
  }
302
  }
303
+
304
  /**
305
  * Get the appropriate access token (default one or from user's Google app). Update it if needed.
306
  *
309
  public function get_access_token( $account ) {
310
  $options = self::get_option();
311
  if ( self::use_user_app() ) {
312
+ if ( time() > $options['accounts'][ $account ]['user_app']['expires'] ) {
313
  $new_tokens = $this->renew_access_token( $account );
314
  if ( $new_tokens['status'] ) {
315
  return $new_tokens['access_token'];
318
  return $new_tokens;
319
  }
320
  } else {
321
+ return $options['accounts'][ $account ]['user_app']['access_token'];
322
  }
323
  } else {
324
+ if ( time() > $options['accounts'][ $account ]['default_app']['expires'] ) {
325
  $new_tokens = $this->renew_access_token( $account );
326
  if ( $new_tokens['status'] ) {
327
  return $new_tokens['access_token'];
330
  return $new_tokens;
331
  }
332
  } else {
333
+ return $options['accounts'][ $account ]['default_app']['access_token'];
334
  }
335
  }
336
  }
337
+
338
  /**
339
  * Renew the current access token.
340
  */
341
  public function renew_access_token( $account ) {
342
+ $cid = self::CID;
343
+ $cs = self::CS;
344
+ $options = self::get_option();
345
+ $access_token = $options['accounts'][ $account ]['default_app']['access_token'];
346
+ $refresh_token = $options['accounts'][ $account ]['default_app']['refresh_token'];
347
+
348
  if ( self::use_user_app() ) {
349
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
350
+ $_options = $gadsense_data->get_options();
351
+ $cid = ADVANCED_ADS_MAPI_CID;
352
+ $cs = ADVANCED_ADS_MAPI_CIS;
353
+ $access_token = $options['accounts'][ $account ]['user_app']['access_token'];
354
+ $refresh_token = $options['accounts'][ $account ]['user_app']['refresh_token'];
355
  }
356
+
357
+ $url = 'https://www.googleapis.com/oauth2/v4/token';
358
  $args = array(
359
  'body' => array(
360
  'refresh_token' => $refresh_token,
361
+ 'client_id' => $cid,
362
  'client_secret' => $cs,
363
+ 'grant_type' => 'refresh_token',
364
  ),
365
  );
366
+
367
  $response = wp_remote_post( $url, $args );
368
  if ( is_wp_error( $response ) ) {
369
+ return array(
370
+ 'status' => false,
371
+ 'msg' => 'error while renewing access token for "' . $account . '"',
372
+ 'raw' => $response->get_error_message(),
373
+ );
374
  } else {
375
  $tokens = json_decode( $response['body'], true );
376
  if ( null !== $tokens ) {
377
  $expires = time() + absint( $tokens['expires_in'] );
378
  if ( self::use_user_app() ) {
379
+ $options['accounts'][ $account ]['user_app']['access_token'] = $tokens['access_token'];
380
+ $options['accounts'][ $account ]['user_app']['expires'] = $expires;
381
  } else {
382
+ $options['accounts'][ $account ]['default_app']['access_token'] = $tokens['access_token'];
383
+ $options['accounts'][ $account ]['default_app']['expires'] = $expires;
384
  }
385
  update_option( self::OPTNAME, $options );
386
+ return array(
387
+ 'status' => true,
388
+ 'access_token' => $tokens['access_token'],
389
+ );
390
  } else {
391
+ return array(
392
+ 'status' => false,
393
+ 'msg' => 'invalid response received while renewing access token for "' . $account . '"',
394
+ 'raw' => $response['body'],
395
+ );
396
  }
397
  }
398
  }
399
+
400
  /**
401
  * Recoke a refresh token
402
  */
403
  public function ajax_revoke_tokken() {
404
+
405
+ $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
406
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
407
  $adsense_id = stripslashes( $_POST['adsenseId'] );
408
+ $options = self::get_option();
409
  if ( self::use_user_app() ) {
410
+ $token = $options['accounts'][ $adsense_id ]['user_app']['refresh_token'];
411
  } else {
412
+ $token = $options['accounts'][ $adsense_id ]['default_app']['refresh_token'];
413
  }
414
+ $url = 'https://accounts.google.com/o/oauth2/revoke?token=' . $token;
415
  $args = array(
416
  'timeout' => 5,
417
+ 'header' => array( 'Content-type' => 'application/x-www-form-urlencoded' ),
418
  );
419
+
420
  $response = wp_remote_post( $url, $args );
421
  if ( is_wp_error( $response ) ) {
422
  echo json_encode( array( 'status' => false ) );
423
  } else {
424
+ header( 'Content-Type: application/json' );
425
+ unset( $options['accounts'][ $adsense_id ] );
426
  update_option( self::OPTNAME, $options );
427
  echo json_encode( array( 'status' => true ) );
428
  }
429
  }
430
  die;
431
+
432
  }
433
+
434
  /**
435
+ * Save ad code reconstructed from ad parameters
436
  */
437
  public function ajax_save_reconstructed_code() {
438
+ $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
439
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
440
+ $code = stripslashes( $_POST['code'] );
441
+ $slot = stripslashes( $_POST['slot'] );
442
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
443
+ $adsense_id = $gadsense_data->get_adsense_id();
444
+ $options = self::get_option();
445
+ $options['ad_codes'][ 'ca-' . $adsense_id . ':' . $slot ] = $code;
446
  update_option( self::OPTNAME, $options );
447
  header( 'Content-Type: application/json' );
448
  echo json_encode( array( 'status' => true ) );
449
  }
450
  die;
451
  }
452
+
453
  /**
454
+ * Get ad code for a given unit
455
  */
456
  public function ajax_get_adCode() {
457
+ $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
458
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
459
  $unit = stripslashes( $_POST['unit'] );
460
+
461
+ if ( ! self::use_user_app() ) {
462
  $quota = $this->get_quota();
463
+
464
  // No more quota left
465
  if ( $quota['count'] < 1 ) {
466
  $quota_msg = $this->get_quota_msg();
467
  header( 'Content-Type: application/json' );
468
  $quota_msg = $this->get_quota_msg();
469
  echo wp_json_encode(
470
+ array(
471
+ 'quota' => 0,
472
  'quotaMsg' => $quota_msg,
473
  )
474
  );
475
  die;
476
  }
 
477
  }
478
+
479
  $code = $this->get_ad_code( $unit );
480
+
481
  /**
482
+ * Ad code is returned as string. Otherwise it's an error
483
  */
484
  if ( is_string( $code ) ) {
485
+
486
  $response = array( 'code' => $code );
487
+
488
  /**
489
  * Add quota info for default API creds
490
  */
491
+ if ( ! self::use_user_app() ) {
492
+ $quota = $this->get_quota();
493
+ $quota_msg = $this->get_quota_msg();
494
+ $response['quota'] = $quota['count'];
495
  $response['quotaMsg'] = $quota_msg;
496
  }
497
+
498
  header( 'Content-Type: application/json' );
499
  echo wp_json_encode( $response );
500
+
501
  } else {
502
+
503
  // return info about the error
504
  header( 'Content-Type: application/json' );
505
  echo wp_json_encode( $code );
506
+
507
  }
 
508
  }
509
  die;
510
  }
511
+
512
  /**
513
  * 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
514
  */
515
  public function ajax_get_adUnits() {
516
+ $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
517
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
518
  $account = stripslashes( $_POST['account'] );
519
+ $units = $this->get_ad_units( $account );
520
+
521
  if ( true == $units ) {
522
+ $options = self::get_option();
523
+ $ad_units = $options['accounts'][ $account ]['ad_units'];
524
  ob_start();
525
+
526
+ include_once ADVADS_BASE_PATH . '/modules/gadsense/admin/views/mapi-ad-selector.php';
527
+
 
 
 
 
 
 
 
 
 
 
528
  $ad_selector = ob_get_clean();
529
+
530
  $response = array(
531
  'status' => true,
532
+ 'html' => $ad_selector,
533
  );
534
+
535
  /**
536
  * Add quota info for default API creds
537
  */
538
+ if ( ! self::use_user_app() ) {
539
+ $quota = $this->get_quota();
540
+ $quota_msg = $this->get_quota_msg();
541
+ $response['quota'] = $quota['count'];
542
  $response['quotaMsg'] = $quota_msg;
543
  }
 
544
  } else {
545
  /**
546
  * return the error info [arr]
552
  }
553
  die;
554
  }
555
+
556
  /**
557
  * Submit Google API confirmation code. Save the token and update ad client list.
558
  */
559
  public function ajax_confirm_code() {
560
+ $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
561
  if ( false !== wp_verify_nonce( $nonce, 'advads-mapi' ) ) {
562
  $code = urldecode( $_POST['code'] );
563
+ $cid = self::CID;
564
+ $cs = self::CS;
565
+
566
  $use_user_app = self::use_user_app();
567
+
568
  $gadsense_data = Advanced_Ads_AdSense_Data::get_instance();
569
+
570
  if ( $use_user_app ) {
571
  $_options = $gadsense_data->get_options();
572
+ $cid = ADVANCED_ADS_MAPI_CID;
573
+ $cs = ADVANCED_ADS_MAPI_CIS;
574
  }
575
+
576
+ $code_url = 'https://www.googleapis.com/oauth2/v4/token';
577
  $redirect_uri = 'urn:ietf:wg:oauth:2.0:oob';
578
+ $grant_type = 'authorization_code';
579
+
580
  $args = array(
581
  'timeout' => 10,
582
+ 'body' => array(
583
+ 'code' => $code,
584
+ 'client_id' => $cid,
585
  'client_secret' => $cs,
586
+ 'redirect_uri' => $redirect_uri,
587
+ 'grant_type' => $grant_type,
588
  ),
589
  );
590
+
591
  $response = wp_remote_post( $code_url, $args );
592
+
593
  if ( is_wp_error( $response ) ) {
594
+ return json_encode(
595
+ array(
596
+ 'status' => false,
597
+ 'msg' => 'error while submitting code',
598
+ 'raw' => $response->get_error_message(),
599
+ )
600
+ );
601
  } else {
602
+ $token = json_decode( $response['body'], true );
603
  $adsense_id = $gadsense_data->get_adsense_id();
604
+
605
  if ( null !== $token && isset( $token['refresh_token'] ) ) {
606
+
607
+ if ( ! empty( $adsense_id ) ) {
608
  self::save_token_from_code( $token, $adsense_id );
609
+
610
+ $gadsense_options = $gadsense_data->get_options();
611
  $gadsense_options['page-level-enabled'] = isset( $_POST['autoads'] );
612
  update_option( GADSENSE_OPT_NAME, $gadsense_options );
613
+
614
  header( 'Content-Type: application/json' );
615
  echo json_encode( array( 'status' => true ) );
616
+
617
  } else {
618
  /**
619
+ * get AdSense ID first
620
  */
621
  $url = 'https://www.googleapis.com/adsense/v1.4/accounts';
622
+
623
+ $headers = array( 'Authorization' => 'Bearer ' . $token['access_token'] );
624
  $response = wp_remote_get( $url, array( 'headers' => $headers ) );
625
+
626
  if ( is_wp_error( $response ) ) {
627
+
628
  header( 'Content-Type: application/json' );
629
+ echo json_encode(
630
+ array(
631
+ 'status' => false,
632
+ 'error_msg' => $response->get_error_message(),
633
+ )
634
+ );
635
+
636
  } else {
637
+
638
+ $accounts = json_decode( $response['body'], true );
639
  $adsense_id = $accounts['items'][0]['id'];
640
+
641
+ $gadsense_options = $gadsense_data->get_options();
642
  $gadsense_options['adsense-id'] = $adsense_id;
643
+
644
  $gadsense_options['page-level-enabled'] = isset( $_POST['autoads'] );
645
+
646
  update_option( GADSENSE_OPT_NAME, $gadsense_options );
647
  self::save_token_from_code( $token, $adsense_id );
648
+
649
  header( 'Content-Type: application/json' );
650
  echo json_encode( array( 'status' => true ) );
651
+
652
  }
653
  }
 
 
654
  } else {
655
  header( 'Content-Type: application/json' );
656
+ echo json_encode(
657
+ array(
658
+ 'status' => false,
659
+ 'response_body' => $response['body'],
660
+ )
661
+ );
662
  }
663
  }
664
  }
665
  die;
666
  }
667
+
668
  /**
669
+ * Enqueue admin scripts
670
  */
671
  public function admin_scripts( $hook ) {
672
  if ( 'advanced-ads_page_advanced-ads-settings' == $hook ) {
673
  wp_enqueue_script( 'gasense/mapi/settings', GADSENSE_BASE_URL . 'admin/assets/js/mapi-settings.js', array( 'jquery' ), ADVADS_VERSION );
674
  }
675
  }
676
+
677
  /**
678
  * Sort ad units list alphabetically
679
  */
680
  public static function get_sorted_adunits( $adunits ) {
681
+ $units_sorted_by_name = array();
682
+ $units_by_id = array();
683
  foreach ( $adunits as $unit ) {
684
+ $units_sorted_by_name[ $unit['name'] ] = $unit['id'];
685
+ $units_by_id[ $unit['id'] ] = $unit;
686
+ }
687
+ ksort( $units_sorted_by_name );
688
+ $units_sorted_by_name = array_flip( $units_sorted_by_name );
689
+ $results = array();
690
+ foreach ( $units_sorted_by_name as $id => $name ) {
691
+ $results[ $name ] = $units_by_id[ $id ];
692
  }
 
 
693
  return $results;
694
  }
695
+
696
+ /**
697
+ * Format ad type and size strings from Google for display
698
+ */
699
+ public static function format_ad_data( $str = '', $format = 'type' ) {
700
+ if ( 'type' == $format ) {
701
+ $str = str_replace( '_', ', ', $str );
702
+ $str = strtolower( $str );
703
+ $str = ucwords( $str );
704
+ } else {
705
+ // size.
706
+ $str = str_replace( 'SIZE_', '', $str );
707
+ $str = str_replace( '_', 'x', $str );
708
+ $str = strtolower( $str );
709
+ $str = ucwords( $str );
710
+ }
711
+ return $str;
712
+ }
713
+
714
  /**
715
+ * Check if the credential are the default ones or from user's app
716
  */
717
  public static function use_user_app() {
718
  if ( ( defined( 'ADVANCED_ADS_MAPI_CID' ) && '' != ADVANCED_ADS_MAPI_CID ) && ( defined( 'ADVANCED_ADS_MAPI_CIS' ) && '' != ADVANCED_ADS_MAPI_CIS ) ) {
721
  return false;
722
  }
723
  }
724
+
725
  public static function has_token( $adsense_id = '' ) {
726
  if ( empty( $adsense_id ) ) {
727
  return false;
728
  }
729
+
730
  $has_token = false;
731
+ $options = self::get_option();
732
  if ( self::use_user_app() ) {
733
+ if ( isset( $options['accounts'][ $adsense_id ] ) && ! empty( $options['accounts'][ $adsense_id ]['user_app']['refresh_token'] ) ) {
734
  $has_token = true;
735
  }
736
  } else {
737
+ if ( isset( $options['accounts'][ $adsense_id ] ) && ! empty( $options['accounts'][ $adsense_id ]['default_app']['refresh_token'] ) ) {
738
  $has_token = true;
739
  }
740
  }
741
  return $has_token;
742
+
743
  }
744
+
745
  /**
746
+ * save token obtained from confirmation code
747
  */
748
  public static function save_token_from_code( $token, $adsense_id ) {
749
+
750
  $options = self::get_option();
751
  $expires = time() + absint( $token['expires_in'] );
752
+ if ( ! isset( $options['accounts'][ $adsense_id ] ) ) {
753
+ $options['accounts'][ $adsense_id ] = self::$empty_account_data;
754
  }
755
  if ( self::use_user_app() ) {
756
+ $options['accounts'][ $adsense_id ]['user_app'] = array(
757
+ 'access_token' => $token['access_token'],
758
  'refresh_token' => $token['refresh_token'],
759
+ 'expires' => $expires,
760
+ 'token_type' => $token['token_type'],
761
  );
762
  } else {
763
+ $options['accounts'][ $adsense_id ]['default_app'] = array(
764
+ 'access_token' => $token['access_token'],
765
  'refresh_token' => $token['refresh_token'],
766
+ 'expires' => $expires,
767
+ 'token_type' => $token['token_type'],
768
  );
769
  }
770
  update_option( self::OPTNAME, $options );
771
+
772
  }
773
+
774
  /**
775
+ * Get the class's option
776
  */
777
  public static function get_option() {
778
  $options = get_option( self::OPTNAME, array() );
779
+ if ( ! is_array( $options ) ) {
780
+ $options = array();
781
+ }
782
  return $options + self::$default_options;
783
  }
784
+
785
  public static function get_instance() {
786
+ if ( null == self::$instance ) {
787
+ self::$instance = new self();
788
  }
789
  return self::$instance;
790
+ }
791
  }
modules/gadsense/public/public.php CHANGED
@@ -26,7 +26,7 @@ class Advanced_Ads_AdSense_Public {
26
 
27
  // Inject CSS to make AdSense background transparent.
28
  if ( ! empty( $options['background'] ) ) {
29
- echo '<style>ins.adsbygoogle { background-color: transparent; }</style>';
30
  }
31
 
32
  $privacy_options = Advanced_Ads_Privacy::get_instance()->options();
26
 
27
  // Inject CSS to make AdSense background transparent.
28
  if ( ! empty( $options['background'] ) ) {
29
+ echo '<style>ins.adsbygoogle { background-color: transparent; padding: 0; }</style>';
30
  }
31
 
32
  $privacy_options = Advanced_Ads_Privacy::get_instance()->options();
modules/privacy/classes/plugin.php CHANGED
@@ -30,6 +30,9 @@ class Advanced_Ads_Privacy
30
 
31
  add_filter( 'advanced-ads-can-display', array( $this, 'can_display_by_consent' ), 10, 3 );
32
 
 
 
 
33
  }
34
 
35
  /**
30
 
31
  add_filter( 'advanced-ads-can-display', array( $this, 'can_display_by_consent' ), 10, 3 );
32
 
33
+ if ( ! empty( $options['enabled'] ) ) {
34
+ add_filter( 'advanced-ads-activate-advanced-js', '__return_true' );
35
+ }
36
  }
37
 
38
  /**
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad manager, ad widget, ad rotation, adsense, advertise, advertisement
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
- Stable tag: 1.10.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -26,7 +26,7 @@ Are you looking for a simple ad manager plugin? These are the top arguments to u
26
 
27
  Would you like to know if there is a certain feature, what the optimized setup would be, or how to implement your client’s demands? Just [open a thread in the forum](https://wordpress.org/support/plugin/advanced-ads#new-post)!
28
 
29
- I built Advanced Ads based on my experience delivering millions of ads per month.
30
 
31
  [Full Feature List](https://wpadvancedads.com/features/).
32
 
@@ -177,7 +177,8 @@ To get started, just take a look at
177
 
178
  * the [general first ad tutorial](https://wpadvancedads.com/manual/first-ad/)
179
  * using [AdSense Auto ads](https://wpadvancedads.com/adsense-auto-ads-wordpress/) in WordPress
180
- * the [AdSense overview page](https://wpadvancedads.com/manual/adsense-ads).
 
181
 
182
  = What about my users’ privacy and GDPR? =
183
 
@@ -266,6 +267,19 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
266
 
267
  == Changelog ==
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  = 1.10.4 =
270
 
271
  * fixed posts instead of ads showing up on the ad overview list caused by 15zine theme
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
+ Stable tag: 1.10.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
26
 
27
  Would you like to know if there is a certain feature, what the optimized setup would be, or how to implement your client’s demands? Just [open a thread in the forum](https://wordpress.org/support/plugin/advanced-ads#new-post)!
28
 
29
+ Based on my experience as a publisher with millions of monthly served ads, I've developed Advanced Ads to be the best solution for WordPress ads.
30
 
31
  [Full Feature List](https://wpadvancedads.com/features/).
32
 
177
 
178
  * the [general first ad tutorial](https://wpadvancedads.com/manual/first-ad/)
179
  * using [AdSense Auto ads](https://wpadvancedads.com/adsense-auto-ads-wordpress/) in WordPress
180
+ * the [AdSense overview page](https://wpadvancedads.com/adsense-ads).
181
+ * Ads not showing up? Take a look [here](https://wpadvancedads.com/manual/ads-not-showing-up).
182
 
183
  = What about my users’ privacy and GDPR? =
184
 
267
 
268
  == Changelog ==
269
 
270
+ = 1.10.5 =
271
+
272
+ * improved list of ads imported from AdSense account
273
+ * use width and height ad settings for image ads if they differ from the entered sizes
274
+ * added option column with shortcode to the ad list. It is optional. Go to "Screen Options" at the top right of the ad list page to enable it
275
+ * show warning if AdSense Auto ads code is used in ad code field
276
+ * added a warning if Advanced Ads constants are enabled
277
+ * prevented possible JavaScript error created by the Privacy module
278
+ * extended "Transpartent Background" option for AdSense to fix a border they have in some themes
279
+ * removed ad block counter code when not used
280
+ * updated add-on updater class
281
+ * added a warning about floated responsive AdSense ads
282
+
283
  = 1.10.4 =
284
 
285
  * fixed posts instead of ads showing up on the ad overview list caused by 15zine theme