Advanced Ads - Version 1.7.7

Version Description

  • allow to inject a new ad into existing placements
  • added is/is_not operator to post type display condition
  • show ads with the specific pages display condition only on these pages and not on archives
  • set expired ads to draft post status
  • highlight draft and pending ads in ad list
  • updated AdSense 3-ads-limit text. AdSense has no explicit limit anymore
Download this release

Release Info

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

Code changes from version 1.7.6 to 1.7.7

admin/assets/css/admin.css CHANGED
@@ -25,6 +25,10 @@
25
  */
26
  .ad_details img { float: left; margin-right: 10px; }
27
  .ad_details img + p { float: left; }
 
 
 
 
28
 
29
  /**
30
  * AD EDIT PAGE
@@ -35,14 +39,18 @@ h2.hndle .advads-hndlelinks a + a { margin-left: 1em; }
35
  .advads-video-link-container { text-align: center; }
36
  .advads-ad-metabox { position: relative; top: 0; left: 0; padding: 3em; background: #fff; }
37
  .advads-ad-metabox h2 { font-weight: bold; color: #0074a2; font-size: 1.6em; margin: 0 0 2em; }
 
38
  #advads-ad-injection-box hr { clear: both; }
39
  #advads-ad-injection-box div pre input { width: 30em; }
40
  #advads-ad-injection-box .ui-accordion .ui-accordion-header { margin-top: 0; border-radius: 0; }
41
  #advads-ad-injection-box .ui-accordion .ui-accordion-content { border-radius: 0; }
42
- #advads-ad-injection-box .button-primary { float: left; margin-right: 10px; padding: 10px; width: 140px; height: 105px; background-size: 140px 105px; font-size: 2em; text-indent: -9999px; border: solid 1px #0085ba; }
 
43
  #advads-ad-injection-box .button-primary { box-shadow: 0px 0px 2px #0085ba; }
44
  #advads-ad-injection-box button:hover { background: #0085ba !important; color: #fff; text-indent: 0; white-space: normal; cursor: pointer; }
45
  #advads-ad-injection-box input[type="number"] { width: 4em; }
 
 
46
  #advads-ad-injection-shortcode { width: 130px; border: none; background: #ededed; }
47
  #advads-ad-injection-message-placement-created { font-size: 1.5em; }
48
  .advads-pro-link { opacity: 0.5; }
25
  */
26
  .ad_details img { float: left; margin-right: 10px; }
27
  .ad_details img + p { float: left; }
28
+ .post-type-advanced_ads .subsubsub .draft a { background-color: #FCE7C0; }
29
+ .post-type-advanced_ads .subsubsub .pending a { background-color: #FFDEDE; }
30
+ .post-type-advanced_ads .wp-list-table .status-draft { background-color: #FCE7C0; }
31
+ .post-type-advanced_ads .wp-list-table .status-pending { background-color: #FFDEDE; }
32
 
33
  /**
34
  * AD EDIT PAGE
39
  .advads-video-link-container { text-align: center; }
40
  .advads-ad-metabox { position: relative; top: 0; left: 0; padding: 3em; background: #fff; }
41
  .advads-ad-metabox h2 { font-weight: bold; color: #0074a2; font-size: 1.6em; margin: 0 0 2em; }
42
+
43
  #advads-ad-injection-box hr { clear: both; }
44
  #advads-ad-injection-box div pre input { width: 30em; }
45
  #advads-ad-injection-box .ui-accordion .ui-accordion-header { margin-top: 0; border-radius: 0; }
46
  #advads-ad-injection-box .ui-accordion .ui-accordion-content { border-radius: 0; }
47
+ #advads-ad-injection-box .advads-ad-injection-box-button-wrap { width: 100px; float: left; margin-right: 10px; margin-bottom: 0px; padding: 1px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
48
+ #advads-ad-injection-box .button-primary { display: block; margin-bottom: 10px; padding: 10px; width: 100px; height: 75px; background-size: 100px 75px; font-size: 1.5em; text-indent: -9999px; border: solid 1px #0085ba; }
49
  #advads-ad-injection-box .button-primary { box-shadow: 0px 0px 2px #0085ba; }
50
  #advads-ad-injection-box button:hover { background: #0085ba !important; color: #fff; text-indent: 0; white-space: normal; cursor: pointer; }
51
  #advads-ad-injection-box input[type="number"] { width: 4em; }
52
+
53
+
54
  #advads-ad-injection-shortcode { width: 130px; border: none; background: #ededed; }
55
  #advads-ad-injection-message-placement-created { font-size: 1.5em; }
56
  .advads-pro-link { opacity: 0.5; }
admin/assets/js/admin.js CHANGED
@@ -36,34 +36,42 @@ jQuery( document ).ready(function ($) {
36
  });
37
 
38
  // trigger for ad injection after ad creation
39
- $( '#advads-ad-injection-box .advads-ad-injection-button' ).click( function(){
40
- var placement_type = this.dataset.type;
41
- if( ! placement_type ){ return; }
42
- var options = {};
43
- // for content injection
44
- if( 'post_content' === placement_type ){
45
- var paragraph = prompt( advadstxt.after_paragraph_promt, 1);
46
- if ( paragraph !== null ) {
47
- options.index = parseInt( paragraph );
 
 
 
 
 
 
 
48
  }
49
- }
50
- // $( '#advads-ad-injection-box' ).html( '<span class="spinner advads-ad-parameters-spinner advads-spinner"></span>' );
 
 
51
  $.ajax({
52
  type: 'POST',
53
  url: ajaxurl,
54
  data: {
55
  action: 'advads-ad-injection-content',
56
  placement_type: placement_type,
 
57
  ad_id: $( '#post_ID' ).val(),
58
  options: options
59
  },
60
  success: function (r, textStatus, XMLHttpRequest) {
61
- if( r ){
62
- $( '#advads-ad-injection-box *' ).hide();
63
- // append anchor to placement message
64
- $( '#advads-ad-injection-message-placement-created a' ).attr( 'href', $( '#advads-ad-injection-message-placement-created a' ).attr( 'href' ) + r );
65
- $( '#advads-ad-injection-message-placement-created, #advads-ad-injection-message-placement-created *' ).show();
66
- }
67
  },
68
  error: function (MLHttpRequest, textStatus, errorThrown) {
69
  $( '#advads-ad-injection-box' ).html( errorThrown );
36
  });
37
 
38
  // trigger for ad injection after ad creation
39
+ $( '#advads-ad-injection-box .advads-ad-injection-button' ).on( 'click', function(){
40
+ var placement_type = this.dataset.placementType, // create new placement
41
+ placement_slug = this.dataset.placementSlug, // use existing placement
42
+ options = {};
43
+
44
+ if ( ! placement_type && ! placement_slug ) { return; }
45
+
46
+ // create new placement
47
+ if ( placement_type ) {
48
+ // for content injection
49
+ if ( 'post_content' === placement_type ) {
50
+ var paragraph = prompt( advadstxt.after_paragraph_promt, 1);
51
+ if ( paragraph !== null ) {
52
+ options.index = parseInt( paragraph, 10 );
53
+ }
54
+ }
55
  }
56
+ $( '#advads-ad-injection-box .advads-loader' ).show();
57
+ $( '#advads-ad-injection-box-placements' ).hide();
58
+ $( 'body').animate({ scrollTop: $( '#advads-ad-injection-box' ).offset().top -40 }, 1, 'linear' );
59
+
60
  $.ajax({
61
  type: 'POST',
62
  url: ajaxurl,
63
  data: {
64
  action: 'advads-ad-injection-content',
65
  placement_type: placement_type,
66
+ placement_slug: placement_slug,
67
  ad_id: $( '#post_ID' ).val(),
68
  options: options
69
  },
70
  success: function (r, textStatus, XMLHttpRequest) {
71
+ $( '#advads-ad-injection-box *' ).hide();
72
+ // append anchor to placement message
73
+ $( '#advads-ad-injection-message-placement-created a' ).attr( 'href', $( '#advads-ad-injection-message-placement-created a' ).attr( 'href' ) + r );
74
+ $( '#advads-ad-injection-message-placement-created, #advads-ad-injection-message-placement-created *' ).show();
 
 
75
  },
76
  error: function (MLHttpRequest, textStatus, errorThrown) {
77
  $( '#advads-ad-injection-box' ).html( errorThrown );
admin/includes/class-ad-type.php CHANGED
@@ -386,6 +386,9 @@ class Advanced_Ads_Admin_Ad_Type {
386
  }
387
  $ad = new Advanced_Ads_Ad( $post->ID );
388
 
 
 
 
389
  include ADVADS_BASE_PATH . 'admin/views/ad-info-top.php';
390
  }
391
 
386
  }
387
  $ad = new Advanced_Ads_Ad( $post->ID );
388
 
389
+ $placement_types = Advanced_Ads_Placements::get_placement_types();
390
+ $placements = Advanced_Ads::get_ad_placements_array(); // -TODO use model
391
+
392
  include ADVADS_BASE_PATH . 'admin/views/ad-info-top.php';
393
  }
394
 
admin/includes/class-overview-widgets.php CHANGED
@@ -64,8 +64,8 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
64
  array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_layer'), $screen->id, 'side', 'high');
65
  add_meta_box('advads_overview_addon_slider', __( 'Ad Slider', 'advanced-ads' ),
66
  array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_slider'), $screen->id, 'side', 'high');
67
- add_meta_box('advads_overview_addon_sellingads', __( 'Selling Ads', 'advanced-ads' ),
68
- array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_sellingads'), $screen->id, 'side', 'high');
69
  }
70
 
71
  /**
64
  array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_layer'), $screen->id, 'side', 'high');
65
  add_meta_box('advads_overview_addon_slider', __( 'Ad Slider', 'advanced-ads' ),
66
  array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_slider'), $screen->id, 'side', 'high');
67
+ // add_meta_box('advads_overview_addon_sellingads', __( 'Selling Ads', 'advanced-ads' ),
68
+ // array('Advanced_Ads_Overview_Widgets_Callbacks', 'render_add_on_sellingads'), $screen->id, 'side', 'high');
69
  }
70
 
71
  /**
admin/views/ad-info-top.php CHANGED
@@ -1,25 +1,58 @@
1
  <?php // show quick injection options
2
  if( isset( $_GET['message'] ) && 6 === $_GET['message'] ) : ?>
3
  <div id="advads-ad-injection-box" class="advads-ad-metabox postbox">
 
4
  <p id="advads-ad-injection-message-placement-created" class="hidden"><?php printf(__( 'Congratulations! Your ad is now visible in the frontend. You can adjust the placement options <a href="%s">here</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-placements#single-placement-' ) ); ?></p>
5
- <h2><?php _e( 'Where do you want to display the ad?', 'advanced-ads' ); ?></h2>
6
- <button type="button" class="advads-ad-injection-button button-primary" data-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>
7
- <button type="button" class="advads-ad-injection-button button-primary" data-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>
8
- <button type="button" class="advads-ad-injection-button button-primary" data-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>
9
- <a href="<?php echo admin_url( 'widgets.php' ); ?>"><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></a>
10
- <?php if( ! defined( 'AAP_VERSION' ) ) :
11
- ?><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"><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></a><?php
12
- endif;
13
- if( ! defined( 'AASADS_VERSION' ) ) :
14
- ?><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"><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></a><?php
15
- endif;
16
- if( ! defined( 'AAPLDS_VERSION' ) ) :
17
- ?><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"><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></a><?php
18
- endif;
19
- ?><div class="clear"></div>
20
- <br/>
21
- <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 . '\']"/>' ); ?>
22
- <?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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </div>
24
  <script>
25
  jQuery('#advads-ad-info-close').click(function(){
1
  <?php // show quick injection options
2
  if( isset( $_GET['message'] ) && 6 === $_GET['message'] ) : ?>
3
  <div id="advads-ad-injection-box" class="advads-ad-metabox postbox">
4
+ <span class="advads-loader" style="display: none;"></span>
5
  <p id="advads-ad-injection-message-placement-created" class="hidden"><?php printf(__( 'Congratulations! Your ad is now visible in the frontend. You can adjust the placement options <a href="%s">here</a>.', 'advanced-ads' ), admin_url( 'admin.php?page=advanced-ads-placements#single-placement-' ) ); ?></p>
6
+ <div id="advads-ad-injection-box-placements">
7
+ <h2><?php _e( 'Where do you want to display the ad?', 'advanced-ads' ); ?></h2>
8
+ <p><?php _e( 'New placement', 'advanced-ads' ); ?></p>
9
+ <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>
10
+ <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>
11
+ <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>
12
+ <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>
13
+ <?php
14
+ if( ! defined( 'AAP_VERSION' ) ) :
15
+ ?><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
16
+ endif;
17
+
18
+ if( ! defined( 'AASADS_VERSION' ) ) :
19
+ ?><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
20
+ endif;
21
+
22
+ if( ! defined( 'AAPLDS_VERSION' ) ) :
23
+ ?><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
24
+ endif;
25
+
26
+ ob_start();
27
+ foreach ( $placements as $_placement_slug => $_placement ) :
28
+ if ( ! isset( $_placement['type'] ) || ! isset( $_placement['name'] ) ) {
29
+ continue;
30
+ }
31
+ if ( ! isset( $placement_types[ $_placement['type'] ] ) ) {
32
+ $_placement['type'] = 'default';
33
+ }
34
+
35
+ $placement_img = '';
36
+ if ( isset( $placement_types[ $_placement['type'] ]['image'] ) ) {
37
+ $placement_img = 'style="background-image: url(' . $placement_types[ $_placement['type'] ]['image'] . ');"';
38
+ } ?>
39
+
40
+ <div class="advads-ad-injection-box-button-wrap"><?php
41
+ printf( '<button type="button" class="advads-ad-injection-button button-primary" data-placement-slug="%s" %s title="%s">%s</button>',
42
+ $_placement_slug, $placement_img, $_placement['name'], $placement_types[ $_placement['type'] ]['title'] );
43
+ echo $_placement['name']; ?></div>
44
+ <?php
45
+ endforeach;
46
+ if ( $existing_p_output = ob_get_clean() ) : ?>
47
+ <div class="clear"></div>
48
+ <p><?php _e( 'Existing placement', 'advanced-ads'); ?></p>
49
+ <?php echo $existing_p_output; ?>
50
+ <?php endif; ?>
51
+
52
+ <div class="clear"></div>
53
+ <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 . '\']"/>' ); ?>
54
+ <?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>
55
+ </div>
56
  </div>
57
  <script>
58
  jQuery('#advads-ad-info-close').click(function(){
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.7.6
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.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, textdomain
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
- define( 'ADVADS_VERSION', '1.7.6' );
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.7.7
16
  * Author: Thomas Maier
17
  * Author URI: http://webgilde.com
18
  * Text Domain: advanced-ads
39
  // general and global slug, e.g. to store options in WP, textdomain
40
  define( 'ADVADS_SLUG', 'advanced-ads' );
41
  define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
42
+ define( 'ADVADS_VERSION', '1.7.7' );
43
 
44
  /*----------------------------------------------------------------------------*
45
  * Autoloading, modules and functions
classes/ad.php CHANGED
@@ -260,7 +260,7 @@ class Advanced_Ads_Ad {
260
  public function output( $output_options = array() ){
261
  if ( ! $this->is_ad ) { return ''; }
262
 
263
- $output_options['global_output'] = isset( $output_options['global_output'] ) ? $output_options['global_output'] : $this->global_output;
264
 
265
  // switch between normal and debug mode
266
  if( isset( $this->output['debugmode'] ) ){
@@ -303,7 +303,7 @@ class Advanced_Ads_Ad {
303
 
304
  if ( ! $check_options['passive_cache_busting'] ) {
305
  // don’t display ads that are not published or private for users not logged in
306
- if ( $this->status !== 'publish' && ! ($this->status === 'private' && ! is_user_logged_in() ) ) {
307
  return false;
308
  }
309
 
@@ -403,12 +403,16 @@ class Advanced_Ads_Ad {
403
  // if expiry_date is not set null is returned
404
  $ad_expiry_date = (int) $this->options( 'expiry_date' );
405
 
406
- if ( $ad_expiry_date <= 0 ) {
407
  return true;
408
  }
409
 
410
- // check blog time against current time (GMT)
411
- return $ad_expiry_date > time();
 
 
 
 
412
  }
413
 
414
  /**
@@ -881,4 +885,5 @@ class Advanced_Ads_Ad {
881
 
882
  return $output;
883
  }
 
884
  }
260
  public function output( $output_options = array() ){
261
  if ( ! $this->is_ad ) { return ''; }
262
 
263
+ $output_options['global_output'] = $this->global_output = isset( $output_options['global_output'] ) ? $output_options['global_output'] : $this->global_output;
264
 
265
  // switch between normal and debug mode
266
  if( isset( $this->output['debugmode'] ) ){
303
 
304
  if ( ! $check_options['passive_cache_busting'] ) {
305
  // don’t display ads that are not published or private for users not logged in
306
+ if ( $this->status !== 'publish' && ! ($this->status === 'private' && is_user_logged_in() ) ) {
307
  return false;
308
  }
309
 
403
  // if expiry_date is not set null is returned
404
  $ad_expiry_date = (int) $this->options( 'expiry_date' );
405
 
406
+ if ( $ad_expiry_date <= 0 || $ad_expiry_date > time() ) {
407
  return true;
408
  }
409
 
410
+ // set status to 'draft' if the ad is expired
411
+ if ( $this->status !== 'draft' ) {
412
+ wp_update_post( array( 'ID' => $this->id, 'post_status' => 'draft' ) );
413
+ }
414
+
415
+ return false;
416
  }
417
 
418
  /**
885
 
886
  return $output;
887
  }
888
+
889
  }
classes/ad_ajax_callbacks.php CHANGED
@@ -259,16 +259,38 @@ class Advanced_Ads_Ad_Ajax_Callbacks {
259
  * @since 1.7.3
260
  */
261
  public function inject_placement(){
262
- if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads') ) ) {
263
- return;
264
- }
265
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  $placements = Advanced_Ads::get_instance()->get_model()->get_ad_placements_array();
267
 
268
  $type = esc_attr( $_REQUEST['placement_type'] );
269
- $ad_id = absint( $_REQUEST['ad_id'] );
270
- if ( empty($ad_id) ) { die(); }
271
-
272
  $item = 'ad_' . $ad_id;
273
 
274
  $options = array();
259
  * @since 1.7.3
260
  */
261
  public function inject_placement(){
262
+ if ( ! current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads') ) ) {
263
+ die();
264
+ }
265
+
266
+ $ad_id = absint( $_REQUEST['ad_id'] );
267
+ if ( empty( $ad_id ) ) { die(); }
268
+
269
+ // use existing placement
270
+ if ( isset( $_REQUEST['placement_slug'] ) ) {
271
+ $xml_array[] = '<placements type="array">';
272
+ $xml_array[] = '<item key="0" type="array">';
273
+ $xml_array[] = '<item type="string">ad_' . $ad_id . '</item>';
274
+ $xml_array[] = '<key type="string">' . $_REQUEST['placement_slug'] . '</key>';
275
+ $xml_array[] = '<use_existing type="boolean">1</use_existing>';
276
+ $xml_array[] = '</item>';
277
+ $xml_array[] = '</placements>';
278
+
279
+ $xml = '<advads-export>' . implode( '', $xml_array ) . '</advads-export>';
280
+
281
+ Advanced_Ads_Import::get_instance()->import( $xml );
282
+ if ( count( Advanced_Ads_Import::get_instance()->imported_data['placements'] ) ) {
283
+ // if the ad was assigned
284
+ echo $_REQUEST['placement_slug'];
285
+ };
286
+ die();
287
+ }
288
+
289
+ // create new placement
290
  $placements = Advanced_Ads::get_instance()->get_model()->get_ad_placements_array();
291
 
292
  $type = esc_attr( $_REQUEST['placement_type'] );
293
+
 
 
294
  $item = 'ad_' . $ad_id;
295
 
296
  $options = array();
classes/display-conditions.php CHANGED
@@ -181,7 +181,6 @@ class Advanced_Ads_Display_Conditions {
181
  * @param int $index index of the condition
182
  */
183
  static function metabox_post_type($options, $index = 0) {
184
-
185
  if (!isset($options['type']) || '' === $options['type']) {
186
  return;
187
  }
@@ -192,16 +191,25 @@ class Advanced_Ads_Display_Conditions {
192
  return;
193
  }
194
 
 
 
 
 
195
  // form name basis
196
  $name = self::FORM_NAME . '[' . $index . ']';
197
 
198
  // options
199
- ?><input type="hidden" name="<?php echo $name; ?>[type]" value="<?php echo $options['type']; ?>"/><?php
 
 
 
 
 
200
  // set defaults
201
  $post_types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'object', 'or');
202
  ?><div class="advads-conditions-single advads-buttonset"><?php
203
  foreach ($post_types as $_type_id => $_type) {
204
- if (isset($options['value']) && is_array($options['value']) && in_array($_type_id, $options['value'])) {
205
  $_val = 1;
206
  } else {
207
  $_val = 0;
@@ -210,7 +218,7 @@ class Advanced_Ads_Display_Conditions {
210
  ?>"><?php echo $_type->label; ?></label><input type="checkbox" id="advads-conditions-<?php echo $index; ?>-<?php echo $_type_id; ?>" name="<?php echo $name; ?>[value][]" <?php checked($_val, 1); ?> value="<?php echo $_type_id; ?>"><?php
211
  }
212
  ?><p class="advads-conditions-not-selected advads-error-message"><?php _ex( 'Please select some items.', 'Error message shown when no display condition term is selected', 'advanced-ads' ); ?></p></div><?php
213
- }
214
 
215
  /**
216
  * callback to display the metabox for the author condition
@@ -245,7 +253,7 @@ class Advanced_Ads_Display_Conditions {
245
  $authors = get_users(array('who' => 'authors', 'orderby' => 'nicename', 'number' => 50));
246
  ?><div class="advads-conditions-single advads-buttonset"><?php
247
  foreach ($authors as $_author) {
248
- if (isset($options['value']) && is_array($options['value']) && in_array($_author->ID, $options['value'])) {
249
  $_val = 1;
250
  } else {
251
  $_val = 0;
@@ -254,7 +262,7 @@ class Advanced_Ads_Display_Conditions {
254
  ?>"><?php echo $_author->display_name; ?></label><input type="checkbox" id="advads-conditions-<?php echo $index; ?>-<?php echo $_author->ID; ?>" name="<?php echo $name; ?>[value][]" <?php checked($_val, 1); ?> value="<?php echo $_author->ID; ?>"><?php
255
  }
256
  ?><p class="advads-conditions-not-selected advads-error-message"><?php _ex( 'Please select some items.', 'Error message shown when no display condition term is selected', 'advanced-ads' ); ?></p></div><?php
257
- }
258
 
259
  /**
260
  * callback to display the metabox for the taxonomy archive pages
@@ -490,17 +498,22 @@ class Advanced_Ads_Display_Conditions {
490
  * @return bool true if can be displayed
491
  */
492
  static function check_post_type($options = array(), Advanced_Ads_Ad $ad) {
493
-
494
  if (!isset($options['value']) || !is_array($options['value'])) {
495
  return false;
496
  }
497
 
 
 
 
 
 
 
498
  $ad_options = $ad->options();
499
  $query = $ad_options['wp_the_query'];
500
  $post = isset($ad_options['post']) ? $ad_options['post'] : null;
501
  $post_type = isset($post['post_type']) ? $post['post_type'] : false;
502
 
503
- if (self::in_array($post_type, $options['value']) === false) {
504
  return false;
505
  }
506
 
@@ -629,22 +642,25 @@ class Advanced_Ads_Display_Conditions {
629
  */
630
  static function check_post_ids($options = array(), Advanced_Ads_Ad $ad) {
631
 
632
- if (isset($options['operator']) && $options['operator'] === 'is_not') {
633
- $operator = 'is_not';
634
- } else {
635
- $operator = 'is';
636
- }
637
 
638
- $ad_options = $ad->options();
639
- $query = $ad_options['wp_the_query'];
640
- $post_id = isset($ad_options['post']['id']) ? $ad_options['post']['id'] : null;
641
- $is_singular = ! empty( $ad_options['wp_the_query']['is_singular'] );
 
 
 
642
 
643
- if ( ! isset( $options['value'] ) || ! is_array( $options['value'] ) || ! $post_id || ! $is_singular ) {
644
  return true;
645
  }
646
 
647
- return self::can_display_ids($post_id, $options['value'], $operator);
648
  }
649
 
650
  /**
@@ -772,6 +788,7 @@ class Advanced_Ads_Display_Conditions {
772
  $query = $options['wp_the_query'];
773
  $post = isset($options['post']) ? $options['post'] : null;
774
 
 
775
  $last_result = false;
776
  $length = count( $conditions );
777
 
181
  * @param int $index index of the condition
182
  */
183
  static function metabox_post_type($options, $index = 0) {
 
184
  if (!isset($options['type']) || '' === $options['type']) {
185
  return;
186
  }
191
  return;
192
  }
193
 
194
+ // get values and select operator based on previous settings
195
+ $operator = ( isset($options['operator']) && $options['operator'] === 'is_not' ) ? 'is_not' : 'is';
196
+ $values = ( isset($options['value'] ) && is_array( $options['value'] ) ) ? $options['value'] : array();
197
+
198
  // form name basis
199
  $name = self::FORM_NAME . '[' . $index . ']';
200
 
201
  // options
202
+ ?><input type="hidden" name="<?php echo $name; ?>[type]" value="<?php echo $options['type']; ?>"/>
203
+ <select name="<?php echo $name; ?>[operator]">
204
+ <option value="is" <?php selected('is', $operator); ?>><?php _e('show'); ?></option>
205
+ <option value="is_not" <?php selected('is_not', $operator); ?>><?php _e('hide'); ?></option>
206
+ </select><?php
207
+
208
  // set defaults
209
  $post_types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'object', 'or');
210
  ?><div class="advads-conditions-single advads-buttonset"><?php
211
  foreach ($post_types as $_type_id => $_type) {
212
+ if ( in_array($_type_id, $values)) {
213
  $_val = 1;
214
  } else {
215
  $_val = 0;
218
  ?>"><?php echo $_type->label; ?></label><input type="checkbox" id="advads-conditions-<?php echo $index; ?>-<?php echo $_type_id; ?>" name="<?php echo $name; ?>[value][]" <?php checked($_val, 1); ?> value="<?php echo $_type_id; ?>"><?php
219
  }
220
  ?><p class="advads-conditions-not-selected advads-error-message"><?php _ex( 'Please select some items.', 'Error message shown when no display condition term is selected', 'advanced-ads' ); ?></p></div><?php
221
+ }
222
 
223
  /**
224
  * callback to display the metabox for the author condition
253
  $authors = get_users(array('who' => 'authors', 'orderby' => 'nicename', 'number' => 50));
254
  ?><div class="advads-conditions-single advads-buttonset"><?php
255
  foreach ($authors as $_author) {
256
+ if ( in_array($_author->ID, $values ) ) {
257
  $_val = 1;
258
  } else {
259
  $_val = 0;
262
  ?>"><?php echo $_author->display_name; ?></label><input type="checkbox" id="advads-conditions-<?php echo $index; ?>-<?php echo $_author->ID; ?>" name="<?php echo $name; ?>[value][]" <?php checked($_val, 1); ?> value="<?php echo $_author->ID; ?>"><?php
263
  }
264
  ?><p class="advads-conditions-not-selected advads-error-message"><?php _ex( 'Please select some items.', 'Error message shown when no display condition term is selected', 'advanced-ads' ); ?></p></div><?php
265
+ }
266
 
267
  /**
268
  * callback to display the metabox for the taxonomy archive pages
498
  * @return bool true if can be displayed
499
  */
500
  static function check_post_type($options = array(), Advanced_Ads_Ad $ad) {
 
501
  if (!isset($options['value']) || !is_array($options['value'])) {
502
  return false;
503
  }
504
 
505
+ if (isset($options['operator']) && $options['operator'] === 'is_not') {
506
+ $operator = 'is_not';
507
+ } else {
508
+ $operator = 'is';
509
+ }
510
+
511
  $ad_options = $ad->options();
512
  $query = $ad_options['wp_the_query'];
513
  $post = isset($ad_options['post']) ? $ad_options['post'] : null;
514
  $post_type = isset($post['post_type']) ? $post['post_type'] : false;
515
 
516
+ if ( ! self::can_display_ids( $post_type, $options['value'], $operator ) ) {
517
  return false;
518
  }
519
 
642
  */
643
  static function check_post_ids($options = array(), Advanced_Ads_Ad $ad) {
644
 
645
+ if (isset($options['operator']) && $options['operator'] === 'is_not') {
646
+ $operator = 'is_not';
647
+ } else {
648
+ $operator = 'is';
649
+ }
650
 
651
+ $ad_options = $ad->options();
652
+ $query = $ad_options['wp_the_query'];
653
+ $post_id = isset($ad_options['post']['id']) ? $ad_options['post']['id'] : null;
654
+
655
+ if( empty( $ad_options['wp_the_query']['is_singular'] ) ){
656
+ return false;
657
+ }
658
 
659
+ if ( ! isset( $options['value'] ) || ! is_array( $options['value'] ) || ! $post_id ) {
660
  return true;
661
  }
662
 
663
+ return self::can_display_ids($post_id, $options['value'], $operator);
664
  }
665
 
666
  /**
788
  $query = $options['wp_the_query'];
789
  $post = isset($options['post']) ? $options['post'] : null;
790
 
791
+
792
  $last_result = false;
793
  $length = count( $conditions );
794
 
modules/gadsense/admin/admin.php CHANGED
@@ -196,11 +196,9 @@ class Advanced_Ads_AdSense_Admin {
196
  <p class="description">
197
  <?php
198
  printf(
199
- __( 'Currently, Google AdSense <a target="_blank" href="%s" title="Terms Of Service">TOS</a> imposes a limit of %d display ads per page. You can disable this limitation at your own risks.', 'advanced-ads' ),
200
- esc_url( 'https://www.google.com/adsense/terms' ), 3
201
- ); ?><br/><?php
202
- _e( 'Notice: Advanced Ads only considers the AdSense ad type for this limit.', 'advanced-ads' );
203
- ?></p>
204
  <?php if( defined( 'AAP_VERSION' ) ) : /* give warning when cache-busting in Pro is active */ ?>
205
  <p class="advads-error-message"><?php _e( 'Due to technical restrictions, the limit does not work on placements with cache-busting enabled.', 'advanced-ads' ); ?></p>
206
  <?php endif;
196
  <p class="description">
197
  <?php
198
  printf(
199
+ __( 'There is no explicit limit for AdSense ads anymore, but you can still use this setting to prevent too many AdSense ads to show accidentally on your site.', 'advanced-ads' ),
200
+ esc_url( 'https://www.google.com/adsense/terms' )
201
+ ); ?></p>
 
 
202
  <?php if( defined( 'AAP_VERSION' ) ) : /* give warning when cache-busting in Pro is active */ ?>
203
  <p class="advads-error-message"><?php _e( 'Due to technical restrictions, the limit does not work on placements with cache-busting enabled.', 'advanced-ads' ); ?></p>
204
  <?php endif;
modules/import-export/classes/import.php CHANGED
@@ -366,6 +366,10 @@ class Advanced_Ads_Import {
366
  switch ( $_item[0] ) {
367
  case 'ad':
368
  case Advanced_Ads_Select::AD :
 
 
 
 
369
  if ( $use_existing ) {
370
  // assign new ad to an existing placement
371
  // - if the placement has no or a single ad assigned, it will be swapped against the new one
@@ -379,26 +383,27 @@ class Advanced_Ads_Import {
379
  if ( ! empty( $_item_existing[1] ) && $_item_existing[0] === Advanced_Ads_Select::GROUP ) {
380
  $advads_ad_weights = get_option( 'advads-ad-weights', array() );
381
 
382
- if ( term_exists( absint( $_item_existing[1] ), Advanced_Ads::AD_GROUP_TAXONOMY )
383
- && ( $found = array_search( $_item[1], $this->imported_data['ads'] ) )
384
- ) {
385
  wp_set_post_terms( $found, $_item_existing[1], Advanced_Ads::AD_GROUP_TAXONOMY, true );
386
  $advads_ad_weights[ $_item_existing[1] ][ $found ] = 1;
387
  update_option( 'advads-ad-weights', $advads_ad_weights );
 
 
388
  break;
389
  }
390
  }
391
  }
392
  }
393
 
394
- if ( $found = array_search( $_item[1], $this->imported_data['ads'] ) ) {
395
- $placement['item'] = 'ad_' . $found;
396
- }
397
  break;
398
  case Advanced_Ads_Select::GROUP :
399
- if ( $found = array_search( $_item[1], $this->imported_data['groups'] ) ) {
400
- $placement['item'] = 'group_' . $found;
401
- }
 
 
 
402
  break;
403
  }
404
  }
@@ -413,6 +418,42 @@ class Advanced_Ads_Import {
413
  }
414
  }
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  /**
417
  * Create new options based on import information
418
  *
366
  switch ( $_item[0] ) {
367
  case 'ad':
368
  case Advanced_Ads_Select::AD :
369
+
370
+ $found = $this->search_item( $_item[1], Advanced_Ads_Select::AD );
371
+ if ( $found === false ) { break; }
372
+
373
  if ( $use_existing ) {
374
  // assign new ad to an existing placement
375
  // - if the placement has no or a single ad assigned, it will be swapped against the new one
383
  if ( ! empty( $_item_existing[1] ) && $_item_existing[0] === Advanced_Ads_Select::GROUP ) {
384
  $advads_ad_weights = get_option( 'advads-ad-weights', array() );
385
 
386
+ if ( term_exists( absint( $_item_existing[1] ), Advanced_Ads::AD_GROUP_TAXONOMY ) ) {
 
 
387
  wp_set_post_terms( $found, $_item_existing[1], Advanced_Ads::AD_GROUP_TAXONOMY, true );
388
  $advads_ad_weights[ $_item_existing[1] ][ $found ] = 1;
389
  update_option( 'advads-ad-weights', $advads_ad_weights );
390
+ // new placement key => old placement key
391
+ $this->imported_data['placements'][ $placement_key_uniq ] = $placement_key_uniq;
392
  break;
393
  }
394
  }
395
  }
396
  }
397
 
398
+ $placement['item'] = 'ad_' . $found;
 
 
399
  break;
400
  case Advanced_Ads_Select::GROUP :
401
+ $found = $this->search_item( $_item[1], Advanced_Ads_Select::GROUP );
402
+ if ( $found === false ) { break; }
403
+
404
+ $placement['item'] = 'group_' . $found;
405
+ // new placement key => old placement key
406
+ $this->imported_data['placements'][ $placement_key_uniq ] = $placement_key_uniq;
407
  break;
408
  }
409
  }
418
  }
419
  }
420
 
421
+ /**
422
+ * Search for ad/group id
423
+ *
424
+ * @param string $id ad/group id
425
+ * @param string $type
426
+ * @return
427
+ * - int id of the imported ad/group if exists
428
+ * - or int id of the existing ad/group if exists
429
+ * - or bool false
430
+ */
431
+ private function search_item( $id, $type ) {
432
+ $found = false;
433
+
434
+ switch ( $type ) {
435
+ case 'ad':
436
+ case Advanced_Ads_Select::AD :
437
+ // if the ad was was imported
438
+ if ( ! $found = array_search( $id, $this->imported_data['ads'] ) ) {
439
+ // if the ad already exists
440
+ if ( get_post_type( $id ) === Advanced_Ads::POST_TYPE_SLUG ) {
441
+ $found = $id;
442
+ }
443
+ }
444
+ break;
445
+ case Advanced_Ads_Select::GROUP :
446
+ if ( ! $found = array_search( $id, $this->imported_data['groups'] ) ) {
447
+ if ( term_exists( absint( $id ), Advanced_Ads::AD_GROUP_TAXONOMY ) ) {
448
+ $found = $id;
449
+ }
450
+ }
451
+ break;
452
+ }
453
+
454
+ return (int) $found;
455
+ }
456
+
457
  /**
458
  * Create new options based on import information
459
  *
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webzunft
3
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
4
  Tags: ads, ad, ad inserter, ad injection, ad manager, ads manager, ad widget, adrotate, adsense, advertise, advertisements, advertising, adverts, advert, amazon, banner, banners, buysellads, chitika, clickbank, dfp, doubleclick, geotarget, geolocation, geo location, google dfp, monetization, widget
5
  Requires at least: WP 4.2, PHP 5.3
6
- Tested up to: 4.6
7
- Stable tag: 1.7.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -142,6 +142,8 @@ Localizations: English, German, French, Spanish, Dutch, Italian, Portuguese
142
  > * [PopUp and Layer Ads](https://wpadvancedads.com/add-ons/popup-and-layer-ads/) – display ads and other content in layers and popups
143
  > * [Slider](https://wpadvancedads.com/add-ons/slider/) – create a simple slider from your ads
144
 
 
 
145
  == Installation ==
146
 
147
  How to install the plugin and get it working?
@@ -204,6 +206,15 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
204
 
205
  == Changelog ==
206
 
 
 
 
 
 
 
 
 
 
207
  = 1.7.6 =
208
 
209
  * prevent third part meta boxes in the ad edit screen
3
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RRRCEBGN3UT2
4
  Tags: ads, ad, ad inserter, ad injection, ad manager, ads manager, ad widget, adrotate, adsense, advertise, advertisements, advertising, adverts, advert, amazon, banner, banners, buysellads, chitika, clickbank, dfp, doubleclick, geotarget, geolocation, geo location, google dfp, monetization, widget
5
  Requires at least: WP 4.2, PHP 5.3
6
+ Tested up to: 4.6.1
7
+ Stable tag: 1.7.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
142
  > * [PopUp and Layer Ads](https://wpadvancedads.com/add-ons/popup-and-layer-ads/) – display ads and other content in layers and popups
143
  > * [Slider](https://wpadvancedads.com/add-ons/slider/) – create a simple slider from your ads
144
 
145
+ If you have problems with Advanced Ads, please reach out to [our support](https://wpadvancedads.com/support/).
146
+
147
  == Installation ==
148
 
149
  How to install the plugin and get it working?
206
 
207
  == Changelog ==
208
 
209
+ = 1.7.7 =
210
+
211
+ * allow to inject a new ad into existing placements
212
+ * added is/is_not operator to “post type” display condition
213
+ * show ads with the “specific pages” display condition only on these pages and not on archives
214
+ * set expired ads to “draft” post status
215
+ * highlight draft and pending ads in ad list
216
+ * updated AdSense 3-ads-limit text. AdSense has no explicit limit anymore
217
+
218
  = 1.7.6 =
219
 
220
  * prevent third part meta boxes in the ad edit screen