Version Description
- added option to analyze the number of visitors using an ad blocker
- exchanged Dummy ad image and URL to something more neutral
- compatibility with PHP 5.2
- use margin: auto to center reserved ad space
- renamed Groups menu item to also mention "Rotations"
- do not execute shortcodes of the current ad in its own content
- updated first-ad video tutorial link
- fixed wizard skipping a step after being stopped and reopened
- fixed wrong scheduled time displayed on ad overview list
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.8.7 |
Comparing to | |
See all releases |
Code changes from version 1.8.6 to 1.8.7
- admin/assets/css/admin.css +1 -1
- admin/assets/js/admin-global.js +13 -4
- admin/assets/js/wizard.js +4 -4
- admin/class-advanced-ads-admin.php +12 -4
- admin/includes/class-ad-groups-list.php +17 -7
- admin/includes/class-menu.php +1 -1
- admin/includes/class-overview-widgets.php +1 -1
- admin/views/ad-list-no-ads.php +1 -1
- admin/views/ad-list-timing-column.php +10 -3
- admin/views/feedback-disable.php +3 -3
- advanced-ads.php +2 -2
- classes/ad.php +16 -3
- classes/ad_placements.php +8 -6
- classes/ad_type_content.php +41 -1
- classes/ad_type_dummy.php +3 -3
- classes/frontend_checks.php +13 -4
- classes/plugin.php +23 -16
- modules/ad-blocker/admin/admin.php +1 -1
- modules/adblock-finder/admin/admin.php +39 -0
- modules/adblock-finder/admin/views/setting-ga.php +2 -0
- modules/adblock-finder/config.php +13 -0
- modules/adblock-finder/main.php +11 -0
- modules/adblock-finder/public/public.php +17 -0
- modules/adblock-finder/public/script.js +96 -0
- public/assets/img/dummy.jpg +0 -0
- public/assets/img/dummy.png +0 -0
- public/class-advanced-ads.php +1 -1
- readme.txt +16 -2
admin/assets/css/admin.css
CHANGED
@@ -329,7 +329,7 @@ tr:hover .on-hover { display: block; }
|
|
329 |
#advanced-ads-feedback-content textarea,
|
330 |
#advanced-ads-feedback-content input[type="text"] { display:none; width: 100%; }
|
331 |
#advanced-ads-feedback-content .advanced_ads_disable_reply { display:none; }
|
332 |
-
.advanced-ads-feedback-
|
333 |
|
334 |
/**
|
335 |
- GENERAL
|
329 |
#advanced-ads-feedback-content textarea,
|
330 |
#advanced-ads-feedback-content input[type="text"] { display:none; width: 100%; }
|
331 |
#advanced-ads-feedback-content .advanced_ads_disable_reply { display:none; }
|
332 |
+
.advanced-ads-feedback-only-deactivate { display: block; text-align: right; }
|
333 |
|
334 |
/**
|
335 |
- GENERAL
|
admin/assets/js/admin-global.js
CHANGED
@@ -73,13 +73,17 @@ jQuery( document ).ready(function () {
|
|
73 |
// send form or close it
|
74 |
jQuery('#advanced-ads-feedback-content .button').click(function ( e ) {
|
75 |
e.preventDefault();
|
|
|
76 |
// set cookie for 30 days
|
77 |
var exdate = new Date();
|
78 |
exdate.setSeconds( exdate.getSeconds() + 2592000 );
|
79 |
document.cookie = "advads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
|
|
|
|
|
|
80 |
|
81 |
jQuery( '#advanced-ads-feedback-overlay' ).hide();
|
82 |
-
if ( 'advanced-ads-feedback-submit'
|
83 |
// show text field if there is one
|
84 |
jQuery.ajax({
|
85 |
type: 'POST',
|
@@ -87,12 +91,16 @@ jQuery( document ).ready(function () {
|
|
87 |
dataType: 'json',
|
88 |
data: {
|
89 |
action: 'advads_send_feedback',
|
|
|
90 |
formdata: jQuery( '#advanced-ads-feedback-content form' ).serialize()
|
91 |
},
|
92 |
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
93 |
// deactivate the plugin and close the popup
|
94 |
jQuery( '#advanced-ads-feedback-overlay' ).remove();
|
95 |
-
|
|
|
|
|
|
|
96 |
|
97 |
}
|
98 |
});
|
@@ -101,9 +109,10 @@ jQuery( document ).ready(function () {
|
|
101 |
window.location.href = advads_deactivate_link_url;
|
102 |
}
|
103 |
});
|
104 |
-
// close form without doing anything
|
105 |
-
jQuery('.advanced-ads-feedback-
|
106 |
jQuery( '#advanced-ads-feedback-overlay' ).hide();
|
|
|
107 |
});
|
108 |
|
109 |
});
|
73 |
// send form or close it
|
74 |
jQuery('#advanced-ads-feedback-content .button').click(function ( e ) {
|
75 |
e.preventDefault();
|
76 |
+
var self = jQuery( this );
|
77 |
// set cookie for 30 days
|
78 |
var exdate = new Date();
|
79 |
exdate.setSeconds( exdate.getSeconds() + 2592000 );
|
80 |
document.cookie = "advads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
81 |
+
// save if plugin should be disabled
|
82 |
+
var disable_plugin = self.hasClass('advanced-ads-feedback-not-deactivate') ? false : true;
|
83 |
+
|
84 |
|
85 |
jQuery( '#advanced-ads-feedback-overlay' ).hide();
|
86 |
+
if ( self.hasClass('advanced-ads-feedback-submit') ) {
|
87 |
// show text field if there is one
|
88 |
jQuery.ajax({
|
89 |
type: 'POST',
|
91 |
dataType: 'json',
|
92 |
data: {
|
93 |
action: 'advads_send_feedback',
|
94 |
+
feedback: self.hasClass('advanced-ads-feedback-not-deactivate') ? true : false,
|
95 |
formdata: jQuery( '#advanced-ads-feedback-content form' ).serialize()
|
96 |
},
|
97 |
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
98 |
// deactivate the plugin and close the popup
|
99 |
jQuery( '#advanced-ads-feedback-overlay' ).remove();
|
100 |
+
console.log( disable_plugin );
|
101 |
+
if( disable_plugin ){
|
102 |
+
window.location.href = advads_deactivate_link_url;
|
103 |
+
}
|
104 |
|
105 |
}
|
106 |
});
|
109 |
window.location.href = advads_deactivate_link_url;
|
110 |
}
|
111 |
});
|
112 |
+
// close form and disable the plugin without doing anything
|
113 |
+
jQuery('.advanced-ads-feedback-only-deactivate').click(function ( e ) {
|
114 |
jQuery( '#advanced-ads-feedback-overlay' ).hide();
|
115 |
+
window.location.href = advads_deactivate_link_url;
|
116 |
});
|
117 |
|
118 |
});
|
admin/assets/js/wizard.js
CHANGED
@@ -28,6 +28,10 @@ var advads_wizard = {
|
|
28 |
jQuery( '.advads-stop-wizard' ).click( function(){
|
29 |
_this.close();
|
30 |
});
|
|
|
|
|
|
|
|
|
31 |
},
|
32 |
show_current_box: function(){
|
33 |
jQuery( this.current_box ).removeClass('advads-hide');
|
@@ -57,10 +61,6 @@ var advads_wizard = {
|
|
57 |
// remove close-class from ad type box
|
58 |
jQuery( '#ad-main-box' ).removeClass('closed');
|
59 |
this.save_hide_wizard( false );
|
60 |
-
// jump to next box when ad type is selected
|
61 |
-
jQuery('#advanced-ad-type input').change(function(){
|
62 |
-
_this.next();
|
63 |
-
});
|
64 |
},
|
65 |
close: function(){ // close the wizard by showing all elements again
|
66 |
jQuery('*').removeClass('advads-hide');
|
28 |
jQuery( '.advads-stop-wizard' ).click( function(){
|
29 |
_this.close();
|
30 |
});
|
31 |
+
// jump to next box when ad type is selected
|
32 |
+
jQuery('#advanced-ad-type input').change(function(e){
|
33 |
+
_this.next();
|
34 |
+
});
|
35 |
},
|
36 |
show_current_box: function(){
|
37 |
jQuery( this.current_box ).removeClass('advads-hide');
|
61 |
// remove close-class from ad type box
|
62 |
jQuery( '#ad-main-box' ).removeClass('closed');
|
63 |
this.save_hide_wizard( false );
|
|
|
|
|
|
|
|
|
64 |
},
|
65 |
close: function(){ // close the wizard by showing all elements again
|
66 |
jQuery('*').removeClass('advads-hide');
|
admin/class-advanced-ads-admin.php
CHANGED
@@ -413,10 +413,18 @@ class Advanced_Ads_Admin {
|
|
413 |
$headers = array();
|
414 |
|
415 |
$from = isset( $form['advanced_ads_disable_from'] ) ? $form['advanced_ads_disable_from'] : '';
|
416 |
-
// if an address is given in the form then use that one
|
417 |
-
if( isset( $
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
$text .= "\n\n REPLY ALLOWED";
|
421 |
}
|
422 |
if( $from ){
|
413 |
$headers = array();
|
414 |
|
415 |
$from = isset( $form['advanced_ads_disable_from'] ) ? $form['advanced_ads_disable_from'] : '';
|
416 |
+
// the user clicked on the "don’t disable" button or if an address is given in the form then use that one
|
417 |
+
if( ( isset( $_POST['feedback'] ) && $_POST['feedback'] )
|
418 |
+
|| (
|
419 |
+
isset( $form['advanced_ads_disable_reason'] )
|
420 |
+
&& in_array( $form['advanced_ads_disable_reason'], array( 'technical issue', 'get help' ) )
|
421 |
+
&& isset( $form[ 'advanced_ads_disable_reply' ] )
|
422 |
+
&& !empty( $form[ 'advanced_ads_disable_reply_email' ] ) ) )
|
423 |
+
{
|
424 |
+
$email = isset( $form[ 'advanced_ads_disable_reply_email' ] ) ? trim( $form[ 'advanced_ads_disable_reply_email' ] ) : $current_user->email;
|
425 |
+
$current_user = wp_get_current_user();
|
426 |
+
$name = ($current_user instanceof WP_User) ? $current_user->user_nicename : '';
|
427 |
+
$from = $name . ' <' . $email . '>';
|
428 |
$text .= "\n\n REPLY ALLOWED";
|
429 |
}
|
430 |
if( $from ){
|
admin/includes/class-ad-groups-list.php
CHANGED
@@ -166,7 +166,21 @@ class Advanced_Ads_Groups_List {
|
|
166 |
|
167 |
$ad = new Advanced_Ads_Ad( get_the_ID() );
|
168 |
$expiry_date_format = get_option( 'date_format' ). ', ' . get_option( 'time_format' );
|
169 |
-
$post_start = get_the_date('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
if ( $post_start > time() ) {
|
172 |
$line_output .= '<br />' . sprintf( __( 'starts %s', 'advanced-ads' ), date( $expiry_date_format, $post_start ) );
|
@@ -174,19 +188,15 @@ class Advanced_Ads_Groups_List {
|
|
174 |
if ( isset( $ad->expiry_date ) && $ad->expiry_date ) {
|
175 |
$expiry = $ad->expiry_date;
|
176 |
$expiry_date = date_create( '@' . $expiry );
|
177 |
-
$tz_option = get_option( 'timezone_string' );
|
178 |
|
179 |
if ( $tz_option ) {
|
180 |
$expiry_date->setTimezone( Advanced_Ads_Admin::get_wp_timezone() );
|
181 |
} else {
|
182 |
-
$tz_name = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
|
183 |
-
$tz_offset = substr( $tz_name, 3 );
|
184 |
-
$off_time = date_create( $expiry_date->format( 'Y-m-d\TH:i:s' ) . $tz_offset );
|
185 |
-
$offset_in_sec = date_offset_get( $off_time );
|
186 |
$expiry_date = date_create( '@' . ( $expiry + $offset_in_sec ) );
|
187 |
}
|
188 |
-
|
189 |
$TZ = ' ( ' . Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() ) . ' )';
|
|
|
190 |
if ( $expiry > time() ) {
|
191 |
$line_output .= '<br />' . sprintf( __( 'expires %s', 'advanced-ads' ), $expiry_date->format( $expiry_date_format ) ) . $TZ;
|
192 |
} elseif ( $expiry <= time() ) {
|
166 |
|
167 |
$ad = new Advanced_Ads_Ad( get_the_ID() );
|
168 |
$expiry_date_format = get_option( 'date_format' ). ', ' . get_option( 'time_format' );
|
169 |
+
$post_start = get_the_date('Y-m-d H:i:s', $ad->id );
|
170 |
+
|
171 |
+
$tz_option = get_option( 'timezone_string' );
|
172 |
+
if ( $tz_option ) {
|
173 |
+
$post_start = date_create( $post_start, Advanced_Ads_Admin::get_wp_timezone() );
|
174 |
+
$post_start = absint( $post_start->format( 'U' ) );
|
175 |
+
} else {
|
176 |
+
$post_start = date_create( $post_start );
|
177 |
+
$post_start = absint( $post_start->format( 'U' ) );
|
178 |
+
$tz_name = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
|
179 |
+
$tz_offset = substr( $tz_name, 3 );
|
180 |
+
$off_time = date_create( '2017-09-21 T10:44:02' . $tz_offset );
|
181 |
+
$offset_in_sec = date_offset_get( $off_time );
|
182 |
+
$post_start -= $offset_in_sec;
|
183 |
+
}
|
184 |
|
185 |
if ( $post_start > time() ) {
|
186 |
$line_output .= '<br />' . sprintf( __( 'starts %s', 'advanced-ads' ), date( $expiry_date_format, $post_start ) );
|
188 |
if ( isset( $ad->expiry_date ) && $ad->expiry_date ) {
|
189 |
$expiry = $ad->expiry_date;
|
190 |
$expiry_date = date_create( '@' . $expiry );
|
|
|
191 |
|
192 |
if ( $tz_option ) {
|
193 |
$expiry_date->setTimezone( Advanced_Ads_Admin::get_wp_timezone() );
|
194 |
} else {
|
|
|
|
|
|
|
|
|
195 |
$expiry_date = date_create( '@' . ( $expiry + $offset_in_sec ) );
|
196 |
}
|
197 |
+
|
198 |
$TZ = ' ( ' . Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() ) . ' )';
|
199 |
+
|
200 |
if ( $expiry > time() ) {
|
201 |
$line_output .= '<br />' . sprintf( __( 'expires %s', 'advanced-ads' ), $expiry_date->format( $expiry_date_format ) ) . $TZ;
|
202 |
} elseif ( $expiry <= time() ) {
|
admin/includes/class-menu.php
CHANGED
@@ -81,7 +81,7 @@ class Advanced_Ads_Admin_Menu {
|
|
81 |
}
|
82 |
|
83 |
$this->ad_group_hook_suffix = add_submenu_page(
|
84 |
-
$this->plugin_slug, __( 'Ad Groups', 'advanced-ads' ), __( 'Groups', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads'), $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
|
85 |
);
|
86 |
|
87 |
// add placements page
|
81 |
}
|
82 |
|
83 |
$this->ad_group_hook_suffix = add_submenu_page(
|
84 |
+
$this->plugin_slug, __( 'Ad Groups & Rotations', 'advanced-ads' ), __( 'Groups & Rotation', 'advanced-ads' ), Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads'), $this->plugin_slug . '-groups', array($this, 'ad_group_admin_page')
|
85 |
);
|
86 |
|
87 |
// add placements page
|
admin/includes/class-overview-widgets.php
CHANGED
@@ -339,7 +339,7 @@ class Advanced_Ads_Overview_Widgets_Callbacks {
|
|
339 |
// allow add-ons to manipulate the output
|
340 |
$add_ons = apply_filters( 'advanced-ads-overview-add-ons', $add_ons );
|
341 |
|
342 |
-
uasort( $add_ons, 'self
|
343 |
|
344 |
?><table class="widefat striped"><?php
|
345 |
foreach( $add_ons as $_addon ) :
|
339 |
// allow add-ons to manipulate the output
|
340 |
$add_ons = apply_filters( 'advanced-ads-overview-add-ons', $add_ons );
|
341 |
|
342 |
+
uasort( $add_ons, array( 'self', 'sort_by_order' ) );
|
343 |
|
344 |
?><table class="widefat striped"><?php
|
345 |
foreach( $add_ons as $_addon ) :
|
admin/views/ad-list-no-ads.php
CHANGED
@@ -3,6 +3,6 @@
|
|
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/
|
7 |
});
|
8 |
</script>
|
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&showinfo=0" frameborder="0" allowfullscreen></iframe>' ).appendTo('#advads-first-ad-links');
|
7 |
});
|
8 |
</script>
|
admin/views/ad-list-timing-column.php
CHANGED
@@ -6,21 +6,28 @@
|
|
6 |
<?php if ( $expiry ) : ?>
|
7 |
<?php
|
8 |
$tz_option = get_option( 'timezone_string' );
|
9 |
-
$expiry_date = date_create( '@' . $expiry );
|
|
|
10 |
if ( $tz_option ) {
|
|
|
11 |
$expiry_date->setTimezone( Advanced_Ads_Admin::get_wp_timezone() );
|
|
|
|
|
12 |
} else {
|
|
|
13 |
$tz_name = Advanced_Ads_Admin::timezone_get_name( Advanced_Ads_Admin::get_wp_timezone() );
|
14 |
$tz_offset = substr( $tz_name, 3 );
|
15 |
$off_time = date_create( $expiry_date->format( 'Y-m-d\TH:i:s' ) . $tz_offset );
|
16 |
$offset_in_sec = date_offset_get( $off_time );
|
17 |
$expiry_date = date_create( '@' . ( $expiry + $offset_in_sec ) );
|
|
|
|
|
18 |
}
|
19 |
?>
|
20 |
<?php if ( $expiry > time() ) :?>
|
21 |
-
<p><?php printf( __( 'expires %s', 'advanced-ads' ),
|
22 |
<?php else : ?>
|
23 |
-
<p><?php printf( __( '<strong>expired</strong> %s', 'advanced-ads' ),
|
24 |
<?php endif; ?>
|
25 |
<?php endif; ?>
|
26 |
<?php echo $content_after; ?>
|
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; ?>
|
admin/views/feedback-disable.php
CHANGED
@@ -22,9 +22,9 @@
|
|
22 |
<?php if ($from) : ?>
|
23 |
<input type="hidden" name="advanced_ads_disable_from" value="<?php echo $from; ?>"/>
|
24 |
<?php endif; ?>
|
25 |
-
<input
|
26 |
-
<
|
27 |
-
<a class="advanced-ads-feedback-
|
28 |
</form>
|
29 |
</div>
|
30 |
</div>
|
22 |
<?php if ($from) : ?>
|
23 |
<input type="hidden" name="advanced_ads_disable_from" value="<?php echo $from; ?>"/>
|
24 |
<?php endif; ?>
|
25 |
+
<input class="advanced-ads-feedback-submit button button-primary" type="submit" name="advanced_ads_disable_submit" value="<?php _e('Submit & Deactivate', 'advanced-ads'); ?>"/>
|
26 |
+
<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'); ?>">
|
27 |
+
<a class="advanced-ads-feedback-only-deactivate" href="#"><?php _e('Only Deactivate', 'advanced-ads'); ?></a>
|
28 |
</form>
|
29 |
</div>
|
30 |
</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.8.
|
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.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.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.8.7' );
|
43 |
|
44 |
/*----------------------------------------------------------------------------*
|
45 |
* Autoloading, modules and functions
|
classes/ad.php
CHANGED
@@ -321,6 +321,11 @@ class Advanced_Ads_Ad {
|
|
321 |
return false;
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
324 |
// force ad display if debug mode is enabled
|
325 |
if( isset( $this->output['debugmode'] ) && ! $check_options['ignore_debugmode'] ) {
|
326 |
return true;
|
@@ -448,10 +453,10 @@ class Advanced_Ads_Ad {
|
|
448 |
global $wpdb;
|
449 |
|
450 |
// remove slashes from content
|
451 |
-
$content = $this->prepare_content_to_save();
|
452 |
|
453 |
$where = array('ID' => $this->id);
|
454 |
-
$wpdb->update( $wpdb->posts, array( 'post_content' => $content ), $where );
|
455 |
|
456 |
// clean post from object cache
|
457 |
clean_post_cache( $this->id );
|
@@ -662,6 +667,7 @@ class Advanced_Ads_Ad {
|
|
662 |
// print_r($this->output);
|
663 |
|
664 |
$position = ! empty( $this->output['position'] ) ? $this->output['position'] : '';
|
|
|
665 |
|
666 |
if ( ! isset( $this->args['previous_method'] ) || 'group' !== $this->args['previous_method'] ) {
|
667 |
if ( isset($this->output['class'] ) && is_array( $this->output['class'] ) ) {
|
@@ -669,6 +675,7 @@ class Advanced_Ads_Ad {
|
|
669 |
}
|
670 |
|
671 |
if ( ! empty( $this->args['placement_position'] ) ) {
|
|
|
672 |
$position = $this->args['placement_position'];
|
673 |
}
|
674 |
}
|
@@ -681,7 +688,13 @@ class Advanced_Ads_Ad {
|
|
681 |
$wrapper['style']['float'] = 'right';
|
682 |
break;
|
683 |
case 'center' :
|
684 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
// add css rule after wrapper to center the ad
|
686 |
// add_filter( 'advanced-ads-output-wrapper-after-content', array( $this, 'center_ad_content' ), 10, 2 );
|
687 |
break;
|
321 |
return false;
|
322 |
}
|
323 |
|
324 |
+
// Check If the current ad is requested using a shortcode placed in the content of the current ad.
|
325 |
+
if ( isset( $this->options['shortcode_ad_id'] ) && (int) $this->options['shortcode_ad_id'] === $this->id ) {
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
// force ad display if debug mode is enabled
|
330 |
if( isset( $this->output['debugmode'] ) && ! $check_options['ignore_debugmode'] ) {
|
331 |
return true;
|
453 |
global $wpdb;
|
454 |
|
455 |
// remove slashes from content
|
456 |
+
$this->content = $this->prepare_content_to_save();
|
457 |
|
458 |
$where = array('ID' => $this->id);
|
459 |
+
$wpdb->update( $wpdb->posts, array( 'post_content' => $this->content ), $where );
|
460 |
|
461 |
// clean post from object cache
|
462 |
clean_post_cache( $this->id );
|
667 |
// print_r($this->output);
|
668 |
|
669 |
$position = ! empty( $this->output['position'] ) ? $this->output['position'] : '';
|
670 |
+
$use_placement_pos = false;
|
671 |
|
672 |
if ( ! isset( $this->args['previous_method'] ) || 'group' !== $this->args['previous_method'] ) {
|
673 |
if ( isset($this->output['class'] ) && is_array( $this->output['class'] ) ) {
|
675 |
}
|
676 |
|
677 |
if ( ! empty( $this->args['placement_position'] ) ) {
|
678 |
+
$use_placement_pos = true;
|
679 |
$position = $this->args['placement_position'];
|
680 |
}
|
681 |
}
|
688 |
$wrapper['style']['float'] = 'right';
|
689 |
break;
|
690 |
case 'center' :
|
691 |
+
if ( ! empty ( $this->output['add_wrapper_sizes'] ) && ! $use_placement_pos ) {
|
692 |
+
$wrapper['style']['margin-left'] = 'auto';
|
693 |
+
$wrapper['style']['margin-right'] = 'auto';
|
694 |
+
} else {
|
695 |
+
$wrapper['style']['text-align'] = 'center';
|
696 |
+
}
|
697 |
+
|
698 |
// add css rule after wrapper to center the ad
|
699 |
// add_filter( 'advanced-ads-output-wrapper-after-content', array( $this, 'center_ad_content' ), 10, 2 );
|
700 |
break;
|
classes/ad_placements.php
CHANGED
@@ -31,7 +31,7 @@ class Advanced_Ads_Placements {
|
|
31 |
'title' => __( 'Manual Placement', 'advanced-ads' ),
|
32 |
'description' => __( 'Manual placement to use as function or shortcode.', 'advanced-ads' ),
|
33 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png',
|
34 |
-
'options' => array( 'show_position' => true )
|
35 |
),
|
36 |
'header' => array(
|
37 |
'title' => __( 'Header Code', 'advanced-ads' ),
|
@@ -47,24 +47,25 @@ class Advanced_Ads_Placements {
|
|
47 |
'title' => __( 'Before Content', 'advanced-ads' ),
|
48 |
'description' => __( 'Injected before the post content.', 'advanced-ads' ),
|
49 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-before.png',
|
50 |
-
'options' => array( 'show_position' => true )
|
51 |
),
|
52 |
'post_bottom' => array(
|
53 |
'title' => __( 'After Content', 'advanced-ads' ),
|
54 |
'description' => __( 'Injected after the post content.', 'advanced-ads' ),
|
55 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-after.png',
|
56 |
-
'options' => array( 'show_position' => true )
|
57 |
),
|
58 |
'post_content' => array(
|
59 |
'title' => __( 'Content', 'advanced-ads' ),
|
60 |
'description' => __( 'Injected into the content. You can choose the paragraph after which the ad content is displayed.', 'advanced-ads' ),
|
61 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-within.png',
|
62 |
-
'options' => array( 'show_position' => true )
|
63 |
),
|
64 |
'sidebar_widget' => array(
|
65 |
'title' => __( 'Sidebar Widget', 'advanced-ads' ),
|
66 |
'description' => __( 'Create a sidebar widget with an ad. Can be placed and used like any other widget.', 'advanced-ads' ),
|
67 |
-
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/widget.png'
|
|
|
68 |
),
|
69 |
);
|
70 |
return apply_filters( 'advanced-ads-placement-types', $types );
|
@@ -312,7 +313,8 @@ class Advanced_Ads_Placements {
|
|
312 |
|
313 |
// add the placement to the global output array
|
314 |
$advads = Advanced_Ads::get_instance();
|
315 |
-
$
|
|
|
316 |
|
317 |
$result = Advanced_Ads_Select::get_instance()->get_ad_by_method( (int) $_item[1], $_item[0], $args );
|
318 |
|
31 |
'title' => __( 'Manual Placement', 'advanced-ads' ),
|
32 |
'description' => __( 'Manual placement to use as function or shortcode.', 'advanced-ads' ),
|
33 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/manual.png',
|
34 |
+
'options' => array( 'show_position' => true, 'show_lazy_load' => true )
|
35 |
),
|
36 |
'header' => array(
|
37 |
'title' => __( 'Header Code', 'advanced-ads' ),
|
47 |
'title' => __( 'Before Content', 'advanced-ads' ),
|
48 |
'description' => __( 'Injected before the post content.', 'advanced-ads' ),
|
49 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-before.png',
|
50 |
+
'options' => array( 'show_position' => true, 'show_lazy_load' => true )
|
51 |
),
|
52 |
'post_bottom' => array(
|
53 |
'title' => __( 'After Content', 'advanced-ads' ),
|
54 |
'description' => __( 'Injected after the post content.', 'advanced-ads' ),
|
55 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-after.png',
|
56 |
+
'options' => array( 'show_position' => true, 'show_lazy_load' => true )
|
57 |
),
|
58 |
'post_content' => array(
|
59 |
'title' => __( 'Content', 'advanced-ads' ),
|
60 |
'description' => __( 'Injected into the content. You can choose the paragraph after which the ad content is displayed.', 'advanced-ads' ),
|
61 |
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/content-within.png',
|
62 |
+
'options' => array( 'show_position' => true, 'show_lazy_load' => true )
|
63 |
),
|
64 |
'sidebar_widget' => array(
|
65 |
'title' => __( 'Sidebar Widget', 'advanced-ads' ),
|
66 |
'description' => __( 'Create a sidebar widget with an ad. Can be placed and used like any other widget.', 'advanced-ads' ),
|
67 |
+
'image' => ADVADS_BASE_URL . 'admin/assets/img/placements/widget.png',
|
68 |
+
'options' => array( 'show_lazy_load' => true )
|
69 |
),
|
70 |
);
|
71 |
return apply_filters( 'advanced-ads-placement-types', $types );
|
313 |
|
314 |
// add the placement to the global output array
|
315 |
$advads = Advanced_Ads::get_instance();
|
316 |
+
$name = isset( $placement['name'] ) ? $placement['name'] : $id;
|
317 |
+
$advads->current_ads[] = array( 'type' => 'placement', 'id' => $id, 'title' => $name );
|
318 |
|
319 |
$result = Advanced_Ads_Select::get_instance()->get_ad_by_method( (int) $_item[1], $_item[0], $args );
|
320 |
|
classes/ad_type_content.php
CHANGED
@@ -37,8 +37,11 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
37 |
$this->parameters = array(
|
38 |
'content' => ''
|
39 |
);
|
|
|
|
|
40 |
}
|
41 |
|
|
|
42 |
/**
|
43 |
* output for the ad parameters metabox
|
44 |
*
|
@@ -125,7 +128,7 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
125 |
$output = convert_chars( $output );
|
126 |
$output = wpautop( $output );
|
127 |
$output = shortcode_unautop( $output );
|
128 |
-
$output = do_shortcode( $output );
|
129 |
$output = prepend_attachment( $output );
|
130 |
// make included images responsive, since WordPress 4.4
|
131 |
if( ! defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' ) && function_exists( 'wp_make_content_images_responsive' ) ){
|
@@ -135,4 +138,41 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
135 |
return $output;
|
136 |
}
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
37 |
$this->parameters = array(
|
38 |
'content' => ''
|
39 |
);
|
40 |
+
|
41 |
+
add_filter( 'advanced-ads-save-options', array( $this, 'save_ad_options' ), 10, 2);
|
42 |
}
|
43 |
|
44 |
+
|
45 |
/**
|
46 |
* output for the ad parameters metabox
|
47 |
*
|
128 |
$output = convert_chars( $output );
|
129 |
$output = wpautop( $output );
|
130 |
$output = shortcode_unautop( $output );
|
131 |
+
$output = $this->do_shortcode( $output, $ad );
|
132 |
$output = prepend_attachment( $output );
|
133 |
// make included images responsive, since WordPress 4.4
|
134 |
if( ! defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' ) && function_exists( 'wp_make_content_images_responsive' ) ){
|
138 |
return $output;
|
139 |
}
|
140 |
|
141 |
+
/**
|
142 |
+
* Add ad options.
|
143 |
+
*
|
144 |
+
* @param array $options Ad options.
|
145 |
+
* @param obj $ad Advanced_Ads_Ad.
|
146 |
+
* @retutn array $options Ad options.
|
147 |
+
*/
|
148 |
+
public function save_ad_options( $options, $ad ) {
|
149 |
+
if ( $ad->type === $this->ID ) {
|
150 |
+
$pattern = get_shortcode_regex( array( 'the_ad', 'the_ad_group', 'the_ad_placement' ) );
|
151 |
+
if ( preg_match( '/' . $pattern . '/s', $ad->content, $matches ) ) {
|
152 |
+
$options['output']['has_shortcode'] = true;
|
153 |
+
};
|
154 |
+
}
|
155 |
+
return $options;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Process shortcodes.
|
160 |
+
*
|
161 |
+
* @param str $output Ad content.
|
162 |
+
* @return obj Advanced_Ads_Ad
|
163 |
+
*/
|
164 |
+
private function do_shortcode( $output, Advanced_Ads_Ad $ad ) {
|
165 |
+
$ad_options = $ad->options();
|
166 |
+
|
167 |
+
if ( ! empty( $ad_options['output']['has_shortcode'] ) ) {
|
168 |
+
// Store arguments so that shortcode hooks can access it.
|
169 |
+
$ad_args = $ad->args;
|
170 |
+
$ad_args['shortcode_ad_id'] = $ad->id;
|
171 |
+
$output = preg_replace( '/\[(the_ad_group|the_ad_placement|the_ad)/', '[$1 ad_args="' . urlencode( json_encode( $ad_args ) ) . '"', $output );
|
172 |
+
}
|
173 |
+
|
174 |
+
$output = do_shortcode( $output );
|
175 |
+
return $output;
|
176 |
+
}
|
177 |
+
|
178 |
}
|
classes/ad_type_dummy.php
CHANGED
@@ -41,12 +41,12 @@ class Advanced_Ads_Ad_Type_Dummy extends Advanced_Ads_Ad_Type_Abstract{
|
|
41 |
|
42 |
// don’t show url field if tracking plugin enabled
|
43 |
if( ! defined( 'AAT_VERSION' )) :
|
44 |
-
$url = ( ! empty( $ad->url ) ) ? esc_url( $ad->url ) :
|
45 |
?><span class="label"><?php _e( 'URL', 'advanced-ads' ); ?></span>
|
46 |
<div><input type="url" name="advanced_ad[url]" id="advads-url" class="advads-ad-url" value="<?php echo $url; ?>"/></div><hr/>
|
47 |
<?php endif;
|
48 |
|
49 |
-
?><img src="<?php echo ADVADS_BASE_URL ?>/public/assets/img/dummy.
|
50 |
|
51 |
?><input type="hidden" name="advanced_ad[width]" value="300"/>
|
52 |
<input type="hidden" name="advanced_ad[height]" value="250"/><?php
|
@@ -67,7 +67,7 @@ class Advanced_Ads_Ad_Type_Dummy extends Advanced_Ads_Ad_Type_Abstract{
|
|
67 |
|
68 |
ob_start();
|
69 |
if( ! defined( 'AAT_VERSION' ) && $url ){ echo '<a href="'. $url .'"'.$target_blank.'>'; }
|
70 |
-
echo '<img src="' . ADVADS_BASE_URL . '/public/assets/img/dummy.
|
71 |
if( ! defined( 'AAT_VERSION' ) && $url ){ echo '</a>'; }
|
72 |
|
73 |
return ob_get_clean();
|
41 |
|
42 |
// don’t show url field if tracking plugin enabled
|
43 |
if( ! defined( 'AAT_VERSION' )) :
|
44 |
+
$url = ( ! empty( $ad->url ) ) ? esc_url( $ad->url ) : home_url();
|
45 |
?><span class="label"><?php _e( 'URL', 'advanced-ads' ); ?></span>
|
46 |
<div><input type="url" name="advanced_ad[url]" id="advads-url" class="advads-ad-url" value="<?php echo $url; ?>"/></div><hr/>
|
47 |
<?php endif;
|
48 |
|
49 |
+
?><img src="<?php echo ADVADS_BASE_URL ?>/public/assets/img/dummy.jpg" width="300" height="250"/><?php
|
50 |
|
51 |
?><input type="hidden" name="advanced_ad[width]" value="300"/>
|
52 |
<input type="hidden" name="advanced_ad[height]" value="250"/><?php
|
67 |
|
68 |
ob_start();
|
69 |
if( ! defined( 'AAT_VERSION' ) && $url ){ echo '<a href="'. $url .'"'.$target_blank.'>'; }
|
70 |
+
echo '<img src="' . ADVADS_BASE_URL . '/public/assets/img/dummy.jpg" width="300" height="250"/>';
|
71 |
if( ! defined( 'AAT_VERSION' ) && $url ){ echo '</a>'; }
|
72 |
|
73 |
return ob_get_clean();
|
classes/frontend_checks.php
CHANGED
@@ -74,12 +74,11 @@ class Advanced_Ads_Frontend_Checks {
|
|
74 |
|
75 |
// check if AdSense loads QuickStart ads
|
76 |
// Hidden, will be shown using js.
|
77 |
-
$utm_source = isset( $_SERVER['HTTP_HOST'] ) ? urlencode( $_SERVER['HTTP_HOST'] ) : 'advanced-ads';
|
78 |
$wp_admin_bar->add_node( array(
|
79 |
'parent' => 'advanced_ads_ad_health',
|
80 |
'id' => 'advanced_ads_quickstart_displayed',
|
81 |
'title' => __( 'Random AdSense ads', 'advanced-ads' ),
|
82 |
-
'href' => ADVADS_URL . 'adsense-in-random-positions-quickstart/#utm_source=
|
83 |
'meta' => array(
|
84 |
'class' => 'hidden advanced_ads_ad_health_warning',
|
85 |
'target' => '_blank'
|
@@ -205,7 +204,10 @@ class Advanced_Ads_Frontend_Checks {
|
|
205 |
$wp_admin_bar->add_node( array(
|
206 |
'parent' => 'advanced_ads_ad_health',
|
207 |
'id' => 'advanced_ads_ad_health_has_http',
|
208 |
-
'title' =>
|
|
|
|
|
|
|
209 |
'href' => 'https://wpadvancedads.com/manual/ad-health/#https-ads',
|
210 |
'meta' => array(
|
211 |
'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_has_http',
|
@@ -391,12 +393,19 @@ class Advanced_Ads_Frontend_Checks {
|
|
391 |
$content .= ob_get_clean();
|
392 |
}
|
393 |
|
|
|
394 |
if ( Advanced_Ads_Ad_Debug::is_https_and_http( $ad ) ) {
|
395 |
ob_start(); ?>
|
396 |
<!--noptimize--><script>window.jQuery && jQuery( document ).ready( function() {
|
397 |
-
var advads_has_http_link = document.querySelector( '.advanced_ads_ad_health_has_http
|
398 |
if ( advads_has_http_link ) {
|
399 |
advads_has_http_link.className = advads_has_http_link.className.replace( 'hidden', '' );
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
advanced_ads_frontend_checks.showCount();
|
401 |
}
|
402 |
});</script><!--/noptimize-->
|
74 |
|
75 |
// check if AdSense loads QuickStart ads
|
76 |
// Hidden, will be shown using js.
|
|
|
77 |
$wp_admin_bar->add_node( array(
|
78 |
'parent' => 'advanced_ads_ad_health',
|
79 |
'id' => 'advanced_ads_quickstart_displayed',
|
80 |
'title' => __( 'Random AdSense ads', 'advanced-ads' ),
|
81 |
+
'href' => ADVADS_URL . 'adsense-in-random-positions-quickstart/#utm_source=advancedads&utm_medium=link&utm_campaign=frontend-quickstart-ads',
|
82 |
'meta' => array(
|
83 |
'class' => 'hidden advanced_ads_ad_health_warning',
|
84 |
'target' => '_blank'
|
204 |
$wp_admin_bar->add_node( array(
|
205 |
'parent' => 'advanced_ads_ad_health',
|
206 |
'id' => 'advanced_ads_ad_health_has_http',
|
207 |
+
'title' => sprintf( '%s %s',
|
208 |
+
__( 'Your website is using HTTPS, but the ad code contains HTTP and might not work.', 'advanced-ads' ),
|
209 |
+
sprintf( __( 'Ad IDs: %s', 'advanced-ads' ), '<i></i>' )
|
210 |
+
),
|
211 |
'href' => 'https://wpadvancedads.com/manual/ad-health/#https-ads',
|
212 |
'meta' => array(
|
213 |
'class' => 'hidden advanced_ads_ad_health_warning advanced_ads_ad_health_has_http',
|
393 |
$content .= ob_get_clean();
|
394 |
}
|
395 |
|
396 |
+
|
397 |
if ( Advanced_Ads_Ad_Debug::is_https_and_http( $ad ) ) {
|
398 |
ob_start(); ?>
|
399 |
<!--noptimize--><script>window.jQuery && jQuery( document ).ready( function() {
|
400 |
+
var advads_has_http_link = document.querySelector( '.advanced_ads_ad_health_has_http' );
|
401 |
if ( advads_has_http_link ) {
|
402 |
advads_has_http_link.className = advads_has_http_link.className.replace( 'hidden', '' );
|
403 |
+
advads_has_http_link.innerHTML = advads_has_http_link.innerHTML.replace( /(<i>)(.*?)(<\/i>)/, function( match, p1, p2, p3 ) {
|
404 |
+
var ad_id = '<?php echo $ad->id; ?>';
|
405 |
+
p2 = ( p2 ) ? p2.split( ', ' ) : [];
|
406 |
+
if ( p2.indexOf( ad_id ) === -1 ) p2.push( ad_id );
|
407 |
+
return p1 + p2.join( ', ' ) + p3;
|
408 |
+
} );
|
409 |
advanced_ads_frontend_checks.showCount();
|
410 |
}
|
411 |
});</script><!--/noptimize-->
|
classes/plugin.php
CHANGED
@@ -337,37 +337,44 @@ class Advanced_Ads_Plugin {
|
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
-
* Prepare attributes
|
341 |
-
* Example: [ 'output__margin__top' => 1 ] => ['output']['margin']['top'] = 1
|
342 |
*
|
343 |
* @param array $atts array with strings
|
344 |
* @return array
|
345 |
*/
|
346 |
private function prepare_shortcode_atts( $atts ) {
|
347 |
-
if ( defined( 'ADVANCED_ADS_DISABLE_CHANGE' ) && ADVANCED_ADS_DISABLE_CHANGE ) {
|
348 |
-
return array();
|
349 |
-
}
|
350 |
-
|
351 |
$result = array();
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
-
|
358 |
|
359 |
-
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
362 |
}
|
363 |
|
364 |
-
$cur_lvl
|
365 |
}
|
366 |
|
367 |
-
$
|
368 |
}
|
369 |
|
370 |
-
|
|
|
|
|
|
|
|
|
371 |
|
372 |
return $result;
|
373 |
}
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
+
* Prepare shortcode attributes.
|
|
|
341 |
*
|
342 |
* @param array $atts array with strings
|
343 |
* @return array
|
344 |
*/
|
345 |
private function prepare_shortcode_atts( $atts ) {
|
|
|
|
|
|
|
|
|
346 |
$result = array();
|
347 |
|
348 |
+
/**
|
349 |
+
* Prepare attributes by converting strings to multi-dimensional array
|
350 |
+
* Example: [ 'output__margin__top' => 1 ] => ['output']['margin']['top'] = 1
|
351 |
+
*/
|
352 |
+
if ( ! defined( 'ADVANCED_ADS_DISABLE_CHANGE' ) || ! ADVANCED_ADS_DISABLE_CHANGE ) {
|
353 |
+
foreach ( $atts as $attr => $data ) {
|
354 |
+
$levels = explode( '__', $attr );
|
355 |
+
$last = array_pop( $levels );
|
356 |
|
357 |
+
$cur_lvl = &$result;
|
358 |
|
359 |
+
foreach ( $levels as $lvl ) {
|
360 |
+
if ( ! isset( $cur_lvl[ $lvl ] ) ) {
|
361 |
+
$cur_lvl[ $lvl ] = array();
|
362 |
+
}
|
363 |
+
|
364 |
+
$cur_lvl = &$cur_lvl[ $lvl ];
|
365 |
}
|
366 |
|
367 |
+
$cur_lvl[ $last ] = $data;
|
368 |
}
|
369 |
|
370 |
+
$result = array_diff_key( $result, array( 'id' => false, 'blog_id' => false, 'ad_args' => false ) );
|
371 |
}
|
372 |
|
373 |
+
// Ad type: 'content' and a shortcode inside.
|
374 |
+
if ( isset( $atts['ad_args'] ) ) {
|
375 |
+
$result = array_merge( $result, json_decode( urldecode( $atts['ad_args'] ) ,true) );
|
376 |
+
|
377 |
+
}
|
378 |
|
379 |
return $result;
|
380 |
}
|
modules/ad-blocker/admin/admin.php
CHANGED
@@ -96,7 +96,7 @@ class Advanced_Ads_Ad_Blocker_Admin
|
|
96 |
__( 'Ad blocker fix', 'advanced-ads' ),
|
97 |
array( $this, 'render_settings_use_adblocker' ),
|
98 |
$hook,
|
99 |
-
'
|
100 |
);
|
101 |
}
|
102 |
|
96 |
__( 'Ad blocker fix', 'advanced-ads' ),
|
97 |
array( $this, 'render_settings_use_adblocker' ),
|
98 |
$hook,
|
99 |
+
'advanced_ads_adblocker_setting_section'
|
100 |
);
|
101 |
}
|
102 |
|
modules/adblock-finder/admin/admin.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Advanced_Ads_Adblock_Finder_Admin {
|
3 |
+
public function __construct() {
|
4 |
+
// Add module settings to Advanced Ads settings page.
|
5 |
+
add_action( 'advanced-ads-settings-init', array( $this, 'settings_init' ), 9, 1 );
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Add settings to settings page.
|
10 |
+
*
|
11 |
+
* @param string $hook Settings page hook.
|
12 |
+
*/
|
13 |
+
public function settings_init( $hook ) {
|
14 |
+
add_settings_section(
|
15 |
+
'advanced_ads_adblocker_setting_section',
|
16 |
+
__( 'Ad Blocker', 'advanced-ads' ),
|
17 |
+
array( $this, 'render_settings_section_callback' ),
|
18 |
+
$hook
|
19 |
+
);
|
20 |
+
|
21 |
+
add_settings_field(
|
22 |
+
'GA-tracking-id',
|
23 |
+
__( 'Ad Block counter', 'advanced-ads' ),
|
24 |
+
array( $this, 'render_settings_ga' ),
|
25 |
+
$hook,
|
26 |
+
'advanced_ads_adblocker_setting_section'
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function render_settings_section_callback() {}
|
31 |
+
|
32 |
+
public function render_settings_ga() {
|
33 |
+
$options = Advanced_Ads::get_instance()->options();
|
34 |
+
$UID = isset( $options['ga-UID'] ) ? $options['ga-UID'] : '';
|
35 |
+
|
36 |
+
include dirname( __FILE__ ) . '/views/setting-ga.php';
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
modules/adblock-finder/admin/views/setting-ga.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<input type="text" name="<?php echo ADVADS_SLUG ?>[ga-UID]" value="<?php echo esc_attr( $UID ); ?>" />
|
2 |
+
<p class="description"><?php _e( 'Want to know how many of your visitors are using an ad blocker? Enter your Google Analytics property ID above to count them.', 'advanced-ads' ); ?> <code>(UA-123456-1)</code></p>
|
modules/adblock-finder/config.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Module configuration.
|
4 |
+
|
5 |
+
$path = dirname( __FILE__ );
|
6 |
+
|
7 |
+
return array(
|
8 |
+
'classmap' => array(
|
9 |
+
'Advanced_Ads_Adblock_Finder' => $path . '/public/public.php',
|
10 |
+
'Advanced_Ads_Adblock_Finder_Admin' => $path . '/admin/admin.php',
|
11 |
+
),
|
12 |
+
'textdomain' => null,
|
13 |
+
);
|
modules/adblock-finder/main.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class_exists( 'Advanced_Ads', false ) || exit();
|
4 |
+
|
5 |
+
$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
6 |
+
|
7 |
+
if ( ! is_admin() ) {
|
8 |
+
new Advanced_Ads_Adblock_Finder;
|
9 |
+
} elseif ( ! $is_ajax ) {
|
10 |
+
new Advanced_Ads_Adblock_Finder_Admin;
|
11 |
+
}
|
modules/adblock-finder/public/public.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Advanced_Ads_Adblock_Finder {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
add_action( 'wp_footer', array( $this, 'print_adblock_check_js' ), 9 );
|
7 |
+
}
|
8 |
+
|
9 |
+
public function print_adblock_check_js() {
|
10 |
+
$options = Advanced_Ads::get_instance()->options();
|
11 |
+
|
12 |
+
?><script>
|
13 |
+
var advanced_ads_adsense_UID = <?php echo isset( $options['ga-UID'] ) ? "'" . esc_js( $options['ga-UID'] ). "'" : 'false' ?>;
|
14 |
+
<?php readfile( dirname( __FILE__ ) . '/script.js' ); ?>
|
15 |
+
</script><?php
|
16 |
+
}
|
17 |
+
}
|
modules/adblock-finder/public/script.js
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Check if an ad block is enabled.
|
3 |
+
*
|
4 |
+
* @param {function} callback A callback function that is executed after the check has been done.
|
5 |
+
* The 'is_enabled' (bool) variable is passed as the callback's first argument.
|
6 |
+
*/
|
7 |
+
;advanced_ads_check_adblocker = ( function( callback ) {
|
8 |
+
var pending_callbacks = [];
|
9 |
+
var is_enabled = null;
|
10 |
+
|
11 |
+
function RAF( RAF_callback ) {
|
12 |
+
var fn = window.requestAnimationFrame
|
13 |
+
|| window.mozRequestAnimationFrame
|
14 |
+
|| window.webkitRequestAnimationFrame
|
15 |
+
|| function( RAF_callback ) { return setTimeout( RAF_callback, 16 ); };
|
16 |
+
|
17 |
+
fn.call( window, RAF_callback );
|
18 |
+
}
|
19 |
+
|
20 |
+
RAF( function() {
|
21 |
+
// Create a bait.
|
22 |
+
var ad = document.createElement( 'div' );
|
23 |
+
ad.innerHTML = ' ';
|
24 |
+
ad.setAttribute( 'class', 'ad_unit ad-unit text-ad text_ad pub_300x250' );
|
25 |
+
ad.setAttribute( 'style', 'width: 1px !important; height: 1px !important; position: absolute !important; left: -1000px !important; top: -1000px !important;' );
|
26 |
+
document.body.appendChild( ad );
|
27 |
+
|
28 |
+
RAF( function() {
|
29 |
+
var styles = window.getComputedStyle( ad );
|
30 |
+
|
31 |
+
is_enabled = styles.getPropertyValue( 'display' ) === 'none'
|
32 |
+
|| styles.getPropertyValue( '-moz-binding' ).indexOf( 'about:' ) !== -1;
|
33 |
+
|
34 |
+
// Call pending callbacks.
|
35 |
+
for ( var i = 0; i < pending_callbacks.length; i++ ) {
|
36 |
+
pending_callbacks[ i ]( is_enabled );
|
37 |
+
}
|
38 |
+
pending_callbacks = [];
|
39 |
+
} );
|
40 |
+
} );
|
41 |
+
|
42 |
+
return function( callback ) {
|
43 |
+
if ( is_enabled === null ) {
|
44 |
+
pending_callbacks.push( callback );
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
// Run the callback immediately
|
48 |
+
callback( is_enabled );
|
49 |
+
}
|
50 |
+
}());
|
51 |
+
|
52 |
+
(function() {
|
53 |
+
var advadsTracker = function( name, UID ) {
|
54 |
+
this.name = name;
|
55 |
+
this.UID = UID;
|
56 |
+
this.analyticsObject = null;
|
57 |
+
var that = this;
|
58 |
+
var data = {
|
59 |
+
hitType: 'event',
|
60 |
+
eventCategory: 'Advanced Ads',
|
61 |
+
eventAction: 'AdBlock',
|
62 |
+
eventLabel: 'Yes',
|
63 |
+
nonInteraction: true,
|
64 |
+
transport: 'beacon'
|
65 |
+
};
|
66 |
+
|
67 |
+
/**
|
68 |
+
* check if someone has already requested the analytics.js and created a GoogleAnalyticsObject
|
69 |
+
*/
|
70 |
+
this.analyticsObject = ( 'string' == typeof( GoogleAnalyticsObject ) && 'function' == typeof( window[GoogleAnalyticsObject] ) )? window[GoogleAnalyticsObject] : false;
|
71 |
+
|
72 |
+
if ( false === this.analyticsObject ) {
|
73 |
+
// No one has requested analytics.js at this point. Require it
|
74 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
75 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
76 |
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
77 |
+
})(window,document,'script','https://www.google-analytics.com/analytics.js','_advads_ga');
|
78 |
+
|
79 |
+
_advads_ga( 'create', that.UID, 'auto', this.name );
|
80 |
+
_advads_ga( that.name + '.send', data );
|
81 |
+
} else {
|
82 |
+
// someone has already created a variable, use it to avoid conflicts.
|
83 |
+
window.console && window.console.log( "Advanced Ads Analytics >> using other's variable named `" + GoogleAnalyticsObject + "`" );
|
84 |
+
window[GoogleAnalyticsObject]( 'create', that.UID, 'auto', this.name );
|
85 |
+
window[GoogleAnalyticsObject]( that.name + '.send', data );
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
advanced_ads_check_adblocker( function( is_enabled ) {
|
90 |
+
// Send data to Google Analytics if an ad blocker was detected.
|
91 |
+
if ( is_enabled && 'string' === typeof advanced_ads_adsense_UID && advanced_ads_adsense_UID ) {
|
92 |
+
new advadsTracker( 'advadsTracker', advanced_ads_adsense_UID );
|
93 |
+
}
|
94 |
+
} );
|
95 |
+
}());
|
96 |
+
|
public/assets/img/dummy.jpg
ADDED
Binary file
|
public/assets/img/dummy.png
DELETED
Binary file
|
public/class-advanced-ads.php
CHANGED
@@ -577,7 +577,7 @@ class Advanced_Ads {
|
|
577 |
*/
|
578 |
protected function get_group_taxonomy_params(){
|
579 |
$labels = array(
|
580 |
-
'name' => _x( 'Ad Groups', 'ad group general name', 'advanced-ads' ),
|
581 |
'singular_name' => _x( 'Ad Group', 'ad group singular name', 'advanced-ads' ),
|
582 |
'search_items' => __( 'Search Ad Groups', 'advanced-ads' ),
|
583 |
'all_items' => __( 'All Ad Groups', 'advanced-ads' ),
|
577 |
*/
|
578 |
protected function get_group_taxonomy_params(){
|
579 |
$labels = array(
|
580 |
+
'name' => _x( 'Ad Groups & Rotations', 'ad group general name', 'advanced-ads' ),
|
581 |
'singular_name' => _x( 'Ad Group', 'ad group singular name', 'advanced-ads' ),
|
582 |
'search_items' => __( 'Search Ad Groups', 'advanced-ads' ),
|
583 |
'all_items' => __( 'All Ad Groups', 'advanced-ads' ),
|
readme.txt
CHANGED
@@ -2,9 +2,10 @@
|
|
2 |
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: 4.
|
6 |
Tested up to: 4.8.1
|
7 |
-
|
|
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -211,6 +212,18 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
211 |
|
212 |
== Changelog ==
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
= 1.8.6 =
|
215 |
|
216 |
* hotfix for PHP below 5.4
|
@@ -238,6 +251,7 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
238 |
= 1.8.3 =
|
239 |
|
240 |
* introduced `advads_is_amp` function to fix ad injections on AMP pages
|
|
|
241 |
|
242 |
= 1.8.2 =
|
243 |
|
2 |
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: 4.6
|
6 |
Tested up to: 4.8.1
|
7 |
+
Requires PHP: 5.2
|
8 |
+
Stable tag: 1.8.7
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
212 |
|
213 |
== Changelog ==
|
214 |
|
215 |
+
= 1.8.7 =
|
216 |
+
|
217 |
+
* added option to analyze the number of visitors using an ad blocker
|
218 |
+
* exchanged Dummy ad image and URL to something more neutral
|
219 |
+
* compatibility with PHP 5.2
|
220 |
+
* use margin: auto to center reserved ad space
|
221 |
+
* renamed Groups menu item to also mention "Rotations"
|
222 |
+
* do not execute shortcodes of the current ad in its own content
|
223 |
+
* updated first-ad video tutorial link
|
224 |
+
* fixed wizard skipping a step after being stopped and reopened
|
225 |
+
* fixed wrong scheduled time displayed on ad overview list
|
226 |
+
|
227 |
= 1.8.6 =
|
228 |
|
229 |
* hotfix for PHP below 5.4
|
251 |
= 1.8.3 =
|
252 |
|
253 |
* introduced `advads_is_amp` function to fix ad injections on AMP pages
|
254 |
+
* implemented a simple ad block counter with Google Analytics
|
255 |
|
256 |
= 1.8.2 =
|
257 |
|