Version Description
- added "placement_has_ads" and "group_has_ads" functions to test if a placement/group has not empty output
- allowed to rotate ordered ads with same weight
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.8.20 |
Comparing to | |
See all releases |
Code changes from version 1.8.19 to 1.8.20
- admin/includes/class-overview-widgets.php +6 -6
- admin/views/pitch-bundle.php +2 -2
- advanced-ads.php +2 -2
- classes/ad_group.php +36 -6
- classes/ad_placements.php +4 -1
- classes/ad_type_plain.php +1 -1
- includes/functions.php +33 -2
- readme.txt +6 -1
admin/includes/class-overview-widgets.php
CHANGED
@@ -100,7 +100,7 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
|
|
100 |
}
|
101 |
|
102 |
if ( $is_subscribed ) {
|
103 |
-
?><a class="button button-primary" href="<?php echo ADVADS_URL; ?>add-ons/
|
104 |
}
|
105 |
|
106 |
/*$_notice = 'nl_adsense';
|
@@ -417,13 +417,13 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
|
|
417 |
}
|
418 |
}
|
419 |
|
420 |
-
// only show
|
421 |
if( $installed_pro_plugins < 2 ){
|
422 |
$add_ons['bundle'] = array(
|
423 |
-
'title' => '
|
424 |
-
'desc' => __( 'Our best deal with all
|
425 |
-
'link' => ADVADS_URL . 'add-ons/
|
426 |
-
'link_title' => __( 'Get
|
427 |
'link_primary' => true,
|
428 |
'order' => 0,
|
429 |
);
|
100 |
}
|
101 |
|
102 |
if ( $is_subscribed ) {
|
103 |
+
?><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 All Access pass', 'advanced-ads' ); ?></a><?php
|
104 |
}
|
105 |
|
106 |
/*$_notice = 'nl_adsense';
|
417 |
}
|
418 |
}
|
419 |
|
420 |
+
// only show All Access Pitch if less than 2 add-ons exist
|
421 |
if( $installed_pro_plugins < 2 ){
|
422 |
$add_ons['bundle'] = array(
|
423 |
+
'title' => 'All Access',
|
424 |
+
'desc' => __( 'Our best deal with all add-ons included.', 'advanced-ads' ),
|
425 |
+
'link' => ADVADS_URL . 'add-ons/all-access/#utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
|
426 |
+
'link_title' => __( 'Get full access', 'advanced-ads' ),
|
427 |
'link_primary' => true,
|
428 |
'order' => 0,
|
429 |
);
|
admin/views/pitch-bundle.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<h3><?php _e( '
|
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>
|
@@ -10,4 +10,4 @@
|
|
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/
|
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>
|
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>
|
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.8.
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: https://wpadvancedads.com
|
18 |
* Text Domain: advanced-ads
|
@@ -39,7 +39,7 @@ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin
|
|
39 |
// general and global slug, e.g. to store options in WP, textdomain
|
40 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
41 |
define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
|
42 |
-
define( 'ADVADS_VERSION', '1.8.
|
43 |
|
44 |
/*----------------------------------------------------------------------------*
|
45 |
* Autoloading, modules and functions
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: https://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
+
* Version: 1.8.20
|
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, textdomain
|
40 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
41 |
define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
|
42 |
+
define( 'ADVADS_VERSION', '1.8.20' );
|
43 |
|
44 |
/*----------------------------------------------------------------------------*
|
45 |
* Autoloading, modules and functions
|
classes/ad_group.php
CHANGED
@@ -225,9 +225,11 @@ class Advanced_Ads_Group {
|
|
225 |
}
|
226 |
}
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
231 |
|
232 |
if ( ! $output ) { return ''; }
|
233 |
|
@@ -283,9 +285,7 @@ class Advanced_Ads_Group {
|
|
283 |
// order ads based on group type
|
284 |
switch($this->type){
|
285 |
case 'ordered' :
|
286 |
-
|
287 |
-
arsort( $weights );
|
288 |
-
$ordered_ad_ids = array_keys($weights);
|
289 |
break;
|
290 |
default : // default
|
291 |
$ordered_ad_ids = $this->shuffle_ads($ads, $weights);
|
@@ -392,6 +392,36 @@ class Advanced_Ads_Group {
|
|
392 |
return $shuffled_ads;
|
393 |
}
|
394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
/**
|
396 |
* get random ad by ad weight
|
397 |
*
|
225 |
}
|
226 |
}
|
227 |
|
228 |
+
if ( ! isset( $args['global_output'] ) || $args['global_output'] ) {
|
229 |
+
// add the group to the global output array
|
230 |
+
$advads = Advanced_Ads::get_instance();
|
231 |
+
$advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
|
232 |
+
}
|
233 |
|
234 |
if ( ! $output ) { return ''; }
|
235 |
|
285 |
// order ads based on group type
|
286 |
switch($this->type){
|
287 |
case 'ordered' :
|
288 |
+
$ordered_ad_ids = $this->shuffle_ordered_ads( $weights );
|
|
|
|
|
289 |
break;
|
290 |
default : // default
|
291 |
$ordered_ad_ids = $this->shuffle_ads($ads, $weights);
|
392 |
return $shuffled_ads;
|
393 |
}
|
394 |
|
395 |
+
/**
|
396 |
+
* Shuffle ads that have the same width.
|
397 |
+
*
|
398 |
+
* @since untagged
|
399 |
+
* @param array $weights Array of $ad_id => weight pairs.
|
400 |
+
* @return array $ordered_ad_ids Ordered ad ids.
|
401 |
+
*/
|
402 |
+
public function shuffle_ordered_ads( array $weights ) {
|
403 |
+
// order to highest weight first
|
404 |
+
arsort( $weights );
|
405 |
+
$ordered_ad_ids = array_keys( $weights );
|
406 |
+
|
407 |
+
$weights = array_values( $weights );
|
408 |
+
$count = count( $weights );
|
409 |
+
$pos = 0;
|
410 |
+
for ( $i = 1; $i <= $count; $i++ ) {
|
411 |
+
if ( $i == $count || $weights[ $i ] !== $weights[ $i - 1] ) {
|
412 |
+
$slice_len = $i - $pos;
|
413 |
+
if ( $slice_len !== 1 ) {
|
414 |
+
$shuffled = array_slice( $ordered_ad_ids, $pos, $slice_len );
|
415 |
+
shuffle ( $shuffled );
|
416 |
+
// Replace the unshuffled chunk with the shuffled one.
|
417 |
+
array_splice( $ordered_ad_ids, $pos, $slice_len, $shuffled );
|
418 |
+
}
|
419 |
+
$pos = $i;
|
420 |
+
}
|
421 |
+
}
|
422 |
+
return $ordered_ad_ids;
|
423 |
+
}
|
424 |
+
|
425 |
/**
|
426 |
* get random ad by ad weight
|
427 |
*
|
classes/ad_placements.php
CHANGED
@@ -314,7 +314,10 @@ class Advanced_Ads_Placements {
|
|
314 |
// add the placement to the global output array
|
315 |
$advads = Advanced_Ads::get_instance();
|
316 |
$name = isset( $placement['name'] ) ? $placement['name'] : $id;
|
317 |
-
|
|
|
|
|
|
|
318 |
|
319 |
$result = Advanced_Ads_Select::get_instance()->get_ad_by_method( (int) $_item[1], $_item[0], $args );
|
320 |
|
314 |
// add the placement to the global output array
|
315 |
$advads = Advanced_Ads::get_instance();
|
316 |
$name = isset( $placement['name'] ) ? $placement['name'] : $id;
|
317 |
+
|
318 |
+
if ( ! isset( $args['global_output'] ) || $args['global_output'] ) {
|
319 |
+
$advads->current_ads[] = array( 'type' => 'placement', 'id' => $id, 'title' => $name );
|
320 |
+
}
|
321 |
|
322 |
$result = Advanced_Ads_Select::get_instance()->get_ad_by_method( (int) $_item[1], $_item[0], $args );
|
323 |
|
classes/ad_type_plain.php
CHANGED
@@ -29,7 +29,7 @@ class Advanced_Ads_Ad_Type_Plain extends Advanced_Ads_Ad_Type_Abstract{
|
|
29 |
*/
|
30 |
public function __construct() {
|
31 |
$this->title = __( 'Plain Text and Code', 'advanced-ads' );
|
32 |
-
$this->description = __( '
|
33 |
$this->parameters = array(
|
34 |
'content' => ''
|
35 |
);
|
29 |
*/
|
30 |
public function __construct() {
|
31 |
$this->title = __( 'Plain Text and Code', 'advanced-ads' );
|
32 |
+
$this->description = __( 'Any ad network, Amazon, customized AdSense codes, shortcodes, and code like JavaScript, HTML or PHP.', 'advanced-ads' );
|
33 |
$this->parameters = array(
|
34 |
'content' => ''
|
35 |
);
|
includes/functions.php
CHANGED
@@ -90,11 +90,42 @@ function advads_can_display_ads(){
|
|
90 |
|
91 |
/**
|
92 |
* Are we currently on an AMP URL?
|
93 |
-
* Will always return `false` if called before the `parse_query` hook.
|
94 |
*
|
95 |
* @return bool true if amp url, false otherwise
|
96 |
*/
|
97 |
function advads_is_amp() {
|
|
|
|
|
|
|
|
|
98 |
return ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )
|
99 |
|| ( function_exists( 'is_wp_amp' ) && is_wp_amp() );
|
100 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
/**
|
92 |
* Are we currently on an AMP URL?
|
93 |
+
* Will always return `false` and show PHP Notice if called before the `parse_query` hook.
|
94 |
*
|
95 |
* @return bool true if amp url, false otherwise
|
96 |
*/
|
97 |
function advads_is_amp() {
|
98 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
return ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )
|
103 |
|| ( function_exists( 'is_wp_amp' ) && is_wp_amp() );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Test if a placement has ads.
|
108 |
+
*
|
109 |
+
* @return bool
|
110 |
+
*/
|
111 |
+
function placement_has_ads( $id = '' ) {
|
112 |
+
$args = array(
|
113 |
+
'global_output' => false,
|
114 |
+
'cache-busting' => 'ignore',
|
115 |
+
);
|
116 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $id, 'placement', $args ) != '';
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Test if a group has ads.
|
122 |
+
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
function group_has_ads( $id = '' ) {
|
126 |
+
$args = array(
|
127 |
+
'global_output' => false,
|
128 |
+
'cache-busting' => 'ignore',
|
129 |
+
);
|
130 |
+
return Advanced_Ads_Select::get_instance()->get_ad_by_method( $id, 'group', $args ) != '';
|
131 |
+
}
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad, ad inserter, ad injection, ad manager, ads manager, ad widget, ad
|
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.2
|
8 |
-
Stable tag: 1.8.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -230,6 +230,11 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
|
|
230 |
|
231 |
== Changelog ==
|
232 |
|
|
|
|
|
|
|
|
|
|
|
233 |
= 1.8.19 =
|
234 |
|
235 |
* delayed Ad Health checks for hidden AdSense ads
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.2
|
8 |
+
Stable tag: 1.8.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
230 |
|
231 |
== Changelog ==
|
232 |
|
233 |
+
= 1.8.20 =
|
234 |
+
|
235 |
+
* added "placement_has_ads" and "group_has_ads" functions to test if a placement/group has not empty output
|
236 |
+
* allowed to rotate ordered ads with same weight
|
237 |
+
|
238 |
= 1.8.19 =
|
239 |
|
240 |
* delayed Ad Health checks for hidden AdSense ads
|