Version Description
- highlight ads in the frontend through the "Ad Health" options
- check if PHP DOM module is enabled and warn in "Ad Health" if not
- added DFP debug link to "Ad Health"
- added button to check Add-On license keys for changes
- extended ad debug mode with more information
- restructured support page to reach helper more quickly
- fixed header ad bug
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.7.10 |
Comparing to | |
See all releases |
Code changes from version 1.7.9.3 to 1.7.10
- admin/assets/css/admin.css +2 -1
- admin/class-advanced-ads-admin.php +4 -3
- admin/includes/class-ad-type.php +1 -1
- admin/includes/class-menu.php +0 -33
- admin/views/setting-license.php +1 -2
- admin/views/support.php +10 -36
- advanced-ads.php +2 -2
- classes/ad-debug.php +267 -0
- classes/ad.php +14 -97
- classes/ad_group.php +2 -0
- classes/ad_placements.php +3 -1
- classes/frontend_checks.php +84 -5
- modules/import-export/classes/XmlEncoder.php +7 -14
- public/views/ad-debug.php +20 -8
- readme.txt +12 -2
admin/assets/css/admin.css
CHANGED
@@ -252,7 +252,8 @@ tr:hover .on-hover { display: block; }
|
|
252 |
/**
|
253 |
- SUPPORT PAGE
|
254 |
-*/
|
255 |
-
.advads-support-form
|
|
|
256 |
|
257 |
/**
|
258 |
- GENERAL
|
252 |
/**
|
253 |
- SUPPORT PAGE
|
254 |
-*/
|
255 |
+
.advads-support-form input { width: 300px; height: 1.5em; line-height: 1.5em; font-size: 1.5em; border: 1px solid #0085ba; border-radius: 5px; }
|
256 |
+
.advads-support-form input.button { width: 100px; height: 1.5em; line-height: 1.5em; font-size: 1.5em; border: 1px solid #0085ba; border-radius: 5px; }
|
257 |
|
258 |
/**
|
259 |
- GENERAL
|
admin/class-advanced-ads-admin.php
CHANGED
@@ -354,6 +354,9 @@ class Advanced_Ads_Admin {
|
|
354 |
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
355 |
// save license status
|
356 |
update_option($options_slug . '-license-status', $license_data->license, false);
|
|
|
|
|
|
|
357 |
|
358 |
// display activation problem
|
359 |
if( !empty( $license_data->error )) {
|
@@ -374,8 +377,6 @@ class Advanced_Ads_Admin {
|
|
374 |
}
|
375 |
}
|
376 |
} else {
|
377 |
-
// save license value time
|
378 |
-
update_option($options_slug . '-license-expires', $license_data->expires, false);
|
379 |
// reset license_expires admin notification
|
380 |
Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expires' );
|
381 |
Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expired' );
|
@@ -575,7 +576,7 @@ class Advanced_Ads_Admin {
|
|
575 |
public function add_on_updater(){
|
576 |
|
577 |
// ignore, if not main blog or is ajax
|
578 |
-
if( ( is_multisite() && ! is_main_site() )
|
579 |
return;
|
580 |
}
|
581 |
|
354 |
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
355 |
// save license status
|
356 |
update_option($options_slug . '-license-status', $license_data->license, false);
|
357 |
+
if( !empty( $license_data->expires ) ){
|
358 |
+
update_option($options_slug . '-license-expires', $license_data->expires, false);
|
359 |
+
}
|
360 |
|
361 |
// display activation problem
|
362 |
if( !empty( $license_data->error )) {
|
377 |
}
|
378 |
}
|
379 |
} else {
|
|
|
|
|
380 |
// reset license_expires admin notification
|
381 |
Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expires' );
|
382 |
Advanced_Ads_Admin_Notices::get_instance()->remove_from_queue( 'license_expired' );
|
576 |
public function add_on_updater(){
|
577 |
|
578 |
// ignore, if not main blog or is ajax
|
579 |
+
if( ( is_multisite() && ! is_main_site() ) ){
|
580 |
return;
|
581 |
}
|
582 |
|
admin/includes/class-ad-type.php
CHANGED
@@ -546,7 +546,7 @@ class Advanced_Ads_Admin_Ad_Type {
|
|
546 |
*/
|
547 |
public static function check_ad_dom_is_not_valid( Advanced_Ads_Ad $ad ) {
|
548 |
$adContent = ( isset( $ad->content ) ) ? $ad->content : '';
|
549 |
-
if ( ! $adContent ) {
|
550 |
return false;
|
551 |
}
|
552 |
|
546 |
*/
|
547 |
public static function check_ad_dom_is_not_valid( Advanced_Ads_Ad $ad ) {
|
548 |
$adContent = ( isset( $ad->content ) ) ? $ad->content : '';
|
549 |
+
if ( ! extension_loaded( 'dom' ) || ! $adContent ) {
|
550 |
return false;
|
551 |
}
|
552 |
|
admin/includes/class-menu.php
CHANGED
@@ -179,39 +179,6 @@ class Advanced_Ads_Admin_Menu {
|
|
179 |
* @since 1.6.8.1
|
180 |
*/
|
181 |
public function display_support_page() {
|
182 |
-
// process email
|
183 |
-
|
184 |
-
$mail_sent = false;
|
185 |
-
$sent_errors = array();
|
186 |
-
global $current_user;
|
187 |
-
$user = wp_get_current_user();
|
188 |
-
|
189 |
-
$email = $user->user_email !== '' ? $user->user_email : '';
|
190 |
-
$name = $user->first_name !== '' ? $user->first_name . ' ' . $user->last_name : $user->user_login;
|
191 |
-
$message = '';
|
192 |
-
|
193 |
-
if( isset( $_POST['advads_support']['email'] ) ){
|
194 |
-
|
195 |
-
$email = trim( $_POST['advads_support']['email'] );
|
196 |
-
$name = trim( $_POST['advads_support']['name'] );
|
197 |
-
$message = trim( $_POST['advads_support']['message'] );
|
198 |
-
if( '' === $message ){
|
199 |
-
$sent_errors[] = __('Please enter a message', 'advanced-ads');
|
200 |
-
}
|
201 |
-
if( is_email( $email ) ){
|
202 |
-
$headers = 'From: '. $name .' <' . $email . '>' . "\r\n";
|
203 |
-
$content = $message;
|
204 |
-
$content .= "\r\n\r\n Name: " . $name;
|
205 |
-
$content .= "\r\n URL: " . home_url();
|
206 |
-
|
207 |
-
$mail_sent = wp_mail( 'support@wpadvancedads.com', 'Support for ' . home_url(), $content, $headers );
|
208 |
-
if( ! $mail_sent ){
|
209 |
-
$sent_errors[] = sprintf(__('Email could NOT be sent. Please contact us directly at %s.', 'advanced-ads'), '<a href="mailto:support@wpadvancedads.com">support@wpadvancedads.com</a>');
|
210 |
-
}
|
211 |
-
} else {
|
212 |
-
$sent_errors[] = __('Please enter a valid email address', 'advanced-ads');
|
213 |
-
}
|
214 |
-
}
|
215 |
|
216 |
include ADVADS_BASE_PATH . 'admin/views/support.php';
|
217 |
}
|
179 |
* @since 1.6.8.1
|
180 |
*/
|
181 |
public function display_support_page() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
include ADVADS_BASE_PATH . 'admin/views/support.php';
|
184 |
}
|
admin/views/setting-license.php
CHANGED
@@ -32,11 +32,10 @@ $show_active = ( $license_status !== false && $license_status == 'valid' && ! $e
|
|
32 |
name="advads_license_activate"><?php _e('Deactivate License'); ?></button>
|
33 |
|
34 |
<button type="button" class="button-primary advads-license-activate"
|
35 |
-
<?php if( $license_status === 'valid' && ! $expired ) echo ' style="display: none;" '; ?>
|
36 |
data-addon="<?php echo $index; ?>"
|
37 |
data-pluginname="<?php echo $plugin_name; ?>"
|
38 |
data-optionslug="<?php echo $options_slug; ?>"
|
39 |
-
name="advads_license_activate"><?php
|
40 |
if( '' === trim( $license_key ) ){
|
41 |
$errortext = __('Please enter a valid license key', 'advanced-ads');
|
42 |
} elseif( ! $expired && ! $errortext ){
|
32 |
name="advads_license_activate"><?php _e('Deactivate License'); ?></button>
|
33 |
|
34 |
<button type="button" class="button-primary advads-license-activate"
|
|
|
35 |
data-addon="<?php echo $index; ?>"
|
36 |
data-pluginname="<?php echo $plugin_name; ?>"
|
37 |
data-optionslug="<?php echo $options_slug; ?>"
|
38 |
+
name="advads_license_activate"><?php echo ( $license_status === 'valid' && ! $expired ) ? __('Update License') : __('Activate License'); ?></button><?php
|
39 |
if( '' === trim( $license_key ) ){
|
40 |
$errortext = __('Please enter a valid license key', 'advanced-ads');
|
41 |
} elseif( ! $expired && ! $errortext ){
|
admin/views/support.php
CHANGED
@@ -5,7 +5,6 @@
|
|
5 |
?><div class="wrap">
|
6 |
<?php screen_icon(); ?>
|
7 |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
8 |
-
<h2>1. <?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
|
9 |
<p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
|
10 |
|
11 |
<?php $messages = array();
|
@@ -45,41 +44,16 @@
|
|
45 |
?><div class="message error"><p><?php echo $_message; ?></p></div><?php
|
46 |
endforeach;
|
47 |
endif; ?>
|
48 |
-
<h2
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
<p><?php _e( 'Use the following form to search for solutions in the manual on wpadvancedads.com', 'advanced-ads' ); ?></p>
|
50 |
-
<form action="https://wpadvancedads.com/" method="get">
|
51 |
<input type="search" name="s"/>
|
52 |
-
<input type="submit" value="<?php _e( 'search', 'advanced-ads' ); ?>">
|
53 |
-
</form>
|
54 |
-
<h2>3. <?php _e( 'Contact', 'advanced-ads' ); ?></h2>
|
55 |
-
<p><?php printf(__( 'Please search the manual for a solution and take a look at <a href="%s" target="_blank">Ads not showing up?</a> before contacting me for help.', 'advanced-ads' ), ADVADS_URL . 'manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' ); ?></p>
|
56 |
-
<?php if( isset( $_POST['advads_support']['email'] ) && array() === $sent_errors ) : ?>
|
57 |
-
<p class="advads-success-message"><?php _e( 'Email was successfully sent.', 'advanced-ads' ); ?></p>
|
58 |
-
<?php else : ?>
|
59 |
-
<?php if( isset( $_POST['advads_support']['email'] ) && count( $sent_errors ) ) : ?>
|
60 |
-
<p class="advads-error-message"><?php echo implode( $sent_errors, '</p><p class="advads-error-message">' ); ?></p>
|
61 |
-
<?php endif; ?>
|
62 |
-
<form action="" method="post">
|
63 |
-
<table class="form-table advads-support-form">
|
64 |
-
<tbody>
|
65 |
-
<tr>
|
66 |
-
<th scope="row"><label for="advads-support-email"><?php _e( 'your email', 'advanced-ads' ); ?></label></th>
|
67 |
-
<td scope="row"><input id="advads-support-email" class="regular-text" type="email" name="advads_support[email]" value="<?php echo $email; ?>"/></td>
|
68 |
-
</tr>
|
69 |
-
<tr>
|
70 |
-
<th scope="row"><label for="advads-support-name"><?php _e( 'your name', 'advanced-ads' ); ?></label></th>
|
71 |
-
<td scope="row"><input type="text" class="regular-text" name="advads_support[name]" value="<?php echo $name; ?>"/></td>
|
72 |
-
</tr>
|
73 |
-
<tr>
|
74 |
-
<th scope="row"><label for="advads-support-text"><?php _e( 'your message', 'advanced-ads' ); ?></label></th>
|
75 |
-
<td scope="row"><textarea name="advads_support[message]"><?php echo $message; ?></textarea></td>
|
76 |
-
</tr>
|
77 |
-
<tr>
|
78 |
-
<td></td>
|
79 |
-
<td><input type="submit" class="button button-primary" value="<?php _e( 'send', 'advanced-ads' ); ?>"></td>
|
80 |
-
</tr>
|
81 |
-
</tbody>
|
82 |
-
</table>
|
83 |
</form>
|
84 |
-
|
85 |
-
</div>
|
5 |
?><div class="wrap">
|
6 |
<?php screen_icon(); ?>
|
7 |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
|
|
8 |
<p><?php _e( 'Please fix the red highlighted issues on this page or try to understand their consequences before contacting support.', 'advanced-ads' ); ?></p>
|
9 |
|
10 |
<?php $messages = array();
|
44 |
?><div class="message error"><p><?php echo $_message; ?></p></div><?php
|
45 |
endforeach;
|
46 |
endif; ?>
|
47 |
+
<h2><?php _e( 'Possible Issues', 'advanced-ads' ); ?></h2>
|
48 |
+
<ul>
|
49 |
+
<li><a href="<?php echo ADVADS_URL; ?>manual/ads-not-showing-up/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Ads not showing up', 'advanced-ads' ); ?></a></li>
|
50 |
+
<li><a href="<?php echo ADVADS_URL; ?>manual-category/purchase-licenses/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Purchase & Licenses', 'advanced-ads' ); ?></a></li>
|
51 |
+
<li><a href="<?php echo ADVADS_URL; ?>manual-category/troubleshooting/support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'General Issues', 'advanced-ads' ); ?></a></li>
|
52 |
+
<li><a href="<?php echo ADVADS_URL; ?>manual-category/add-on-issues/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support"><?php _e( 'Issues with Add-Ons', 'advanced-ads' ); ?></a></li>
|
53 |
+
</ul>
|
54 |
<p><?php _e( 'Use the following form to search for solutions in the manual on wpadvancedads.com', 'advanced-ads' ); ?></p>
|
55 |
+
<form action="https://wpadvancedads.com/" method="get" class="advads-support-form">
|
56 |
<input type="search" name="s"/>
|
57 |
+
<input type="submit" class="button button-primary" value="<?php _e( 'search', 'advanced-ads' ); ?>">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
</form>
|
59 |
+
<p><?php printf(__( 'Take a look at more common issues or contact us directly through the <a href="%s" target="_blank">support page</a>.', 'advanced-ads' ), ADVADS_URL . 'support/#utm_source=advanced-ads&utm_medium=link&utm_campaign=support' ); ?></p>
|
|
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.
|
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.
|
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.10
|
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.10' );
|
43 |
|
44 |
/*----------------------------------------------------------------------------*
|
45 |
* Autoloading, modules and functions
|
classes/ad-debug.php
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Advanced_Ads_Ad_Debug {
|
3 |
+
/**
|
4 |
+
* Prepare debug mode output.
|
5 |
+
*
|
6 |
+
* @param obj Advanced_Ads_Ad
|
7 |
+
*/
|
8 |
+
public function prepare_debug_output( Advanced_Ads_Ad $ad ) {
|
9 |
+
global $post, $wp_query;
|
10 |
+
|
11 |
+
// set size
|
12 |
+
if ( $ad->width > 100 && $ad->height > 100 ){
|
13 |
+
$width = $ad->width;
|
14 |
+
$height = $ad->height;
|
15 |
+
} else {
|
16 |
+
$width = 300;
|
17 |
+
$height = 250;
|
18 |
+
}
|
19 |
+
|
20 |
+
$style = "width:{$width}px;height:{$height}px;background-color:#ddd;overflow:scroll;";
|
21 |
+
$style_full = 'width: 100%; height: 100vh; background-color: #ddd; overflow: scroll; position: fixed; top: 0; left: 0; min-width: 600px; z-index: 99999;';
|
22 |
+
|
23 |
+
if ( ! empty( $ad->wrapper['id']) ) {
|
24 |
+
$wrapper_id = $ad->wrapper['id'];
|
25 |
+
} else {
|
26 |
+
$wrapper_id = Advanced_Ads_Plugin::get_instance()->get_frontend_prefix() . mt_rand();
|
27 |
+
}
|
28 |
+
|
29 |
+
$content = array();
|
30 |
+
|
31 |
+
// compare current wp_query with global wp_main_query
|
32 |
+
if ( ! $wp_query->is_main_query() ) {
|
33 |
+
$content[] = sprintf( '<span style="color: red;">%s</span>', __( 'Current query is not identical to main query.', 'advanced-ads' ) );
|
34 |
+
// output differences
|
35 |
+
$content[] = $this->build_query_diff_table();
|
36 |
+
}
|
37 |
+
|
38 |
+
// compare current post with global post
|
39 |
+
if ( $wp_query->post !== $post ){
|
40 |
+
$error = sprintf( '<span style="color: red;">%s</span>', __( 'Current post is not identical to main post.', 'advanced-ads' ) );
|
41 |
+
// output differences
|
42 |
+
if ( isset( $post->post_title ) && $post->ID ) {
|
43 |
+
$error .= sprintf( '<br />%s: %s, %s: %s', __( 'current post', 'advanced-ads' ), $post->post_title, 'ID', $post->ID );
|
44 |
+
}
|
45 |
+
if ( isset( $wp_query->post->post_title ) && $wp_query->post->ID ) {
|
46 |
+
$error .= sprintf( '<br />%s: %s, %s: %s', __( 'main post', 'advanced-ads' ), $wp_query->post->post_title, 'ID', $wp_query->post->ID );
|
47 |
+
}
|
48 |
+
$content[] = $error;
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( $ad->can_display( array( 'ignore_debugmode' => true ) ) ) {
|
52 |
+
$content[] = __( 'The ad is displayed on the page', 'advanced-ads' );
|
53 |
+
} else {
|
54 |
+
$content[] = __( 'The ad is not displayed on the page', 'advanced-ads' );
|
55 |
+
}
|
56 |
+
|
57 |
+
$content[] = $this->build_call_chain( $ad );
|
58 |
+
$content[] = $this->build_display_conditions_table( $ad );
|
59 |
+
$content[] = $this->build_visitor_conditions_table( $ad );
|
60 |
+
|
61 |
+
if ( $this->check_http( $ad ) ) {
|
62 |
+
$content[] = sprintf( '<span style="color: red;">%s</span>', __( 'The current URL is HTTPS, but the ad code contains HTTP', 'advanced-ads' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
$content = apply_filters( 'advanced-ads-ad-output-debug-content', $content, $ad );
|
66 |
+
|
67 |
+
ob_start();
|
68 |
+
|
69 |
+
include( ADVADS_BASE_PATH . '/public/views/ad-debug.php' );
|
70 |
+
|
71 |
+
$output = ob_get_clean();
|
72 |
+
|
73 |
+
// apply a custom filter by ad type
|
74 |
+
$output = apply_filters( 'advanced-ads-ad-output-debug', $output, $ad );
|
75 |
+
$output = apply_filters( 'advanced-ads-ad-output', $output, $ad );
|
76 |
+
|
77 |
+
return $output;
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* build table with differences between current and main query
|
83 |
+
*
|
84 |
+
* @since 1.7.0.3
|
85 |
+
*/
|
86 |
+
private function build_query_diff_table(){
|
87 |
+
|
88 |
+
global $wp_query, $wp_the_query;
|
89 |
+
|
90 |
+
$diff_current = array_diff_assoc( $wp_query->query_vars, $wp_the_query->query_vars );
|
91 |
+
$diff_main = array_diff_assoc( $wp_the_query->query_vars, $wp_query->query_vars );
|
92 |
+
|
93 |
+
if( ! is_array( $diff_current ) || ! is_array( $diff_main ) ){
|
94 |
+
return '';
|
95 |
+
}
|
96 |
+
|
97 |
+
ob_start();
|
98 |
+
|
99 |
+
?><table><thead><tr><th></th><th><?php _e( 'current query', 'advanced-ads'); ?></th><th><?php _e( 'main query', 'advanced-ads'); ?></th></tr></thead><?php
|
100 |
+
foreach( $diff_current as $_key => $_value ){
|
101 |
+
?><tr><td><?php echo $_key; ?></td><td><?php echo $_value; ?></td><td><?php if( isset( $diff_main[$_key] ) ) echo $diff_main[$_key]; ?></td></tr><?php
|
102 |
+
}
|
103 |
+
?></table><?php
|
104 |
+
|
105 |
+
return ob_get_clean();
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Build call chain (placement->group->ad)
|
110 |
+
*
|
111 |
+
* @param obj Advanced_Ads_Ad
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function build_call_chain( Advanced_Ads_Ad $ad ) {
|
115 |
+
ob_start();
|
116 |
+
|
117 |
+
$options = $ad->options();
|
118 |
+
|
119 |
+
printf( '%s: %s (%s)', __( 'Ad', 'advanced-ads' ), esc_html( $ad->title ), $ad->id );
|
120 |
+
|
121 |
+
if ( isset( $options['group'] ) && $options['group'] instanceof Advanced_Ads_Group ) {
|
122 |
+
$group = $ad->options( 'group' );
|
123 |
+
printf( '<br />%s: %s (%s)', _x( 'Ad Group', 'ad group singular name', 'advanced-ads' ), esc_html( $group->name ), $group->id );
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( isset( $options['output']['placement_id'] ) ) {
|
127 |
+
$placements = Advanced_Ads::get_ad_placements_array();
|
128 |
+
$placement_id = $options['output']['placement_id'];
|
129 |
+
$placement_name = isset( $placements[ $placement_id ]['name'] ) ? $placements[ $placement_id ]['name'] : '';
|
130 |
+
printf( '<br />%s: %s (%s)', __( 'Placement', 'advanced-ads' ), esc_html( $placement_name ), esc_html( $placement_id ) );
|
131 |
+
}
|
132 |
+
|
133 |
+
return ob_get_clean();
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Build display conditions table.
|
138 |
+
*
|
139 |
+
* @param obj Advanced_Ads_Ad
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
protected function build_display_conditions_table( Advanced_Ads_Ad $ad ) {
|
143 |
+
$options = $ad->options();
|
144 |
+
|
145 |
+
if ( ! isset( $options['conditions'] )
|
146 |
+
|| ! is_array( $options['conditions'] )
|
147 |
+
|| ! count( $options['conditions'] ) ) { return; }
|
148 |
+
|
149 |
+
$conditions = array_values( $options['conditions'] );
|
150 |
+
$display_conditions = Advanced_Ads_Display_Conditions::get_instance()->conditions;
|
151 |
+
$the_query = Advanced_Ads_Display_Conditions::get_instance()->ad_select_args_callback( array() );
|
152 |
+
|
153 |
+
ob_start();
|
154 |
+
_e( 'Display Conditions', 'advanced-ads' ); ?>
|
155 |
+
<?php
|
156 |
+
foreach ( $conditions as $_condition ) {
|
157 |
+
if ( ! is_array( $_condition )
|
158 |
+
|| ! isset( $_condition['type'] )
|
159 |
+
|| ! isset( $display_conditions[ $_condition['type'] ]['check'][1] )
|
160 |
+
) { continue; }
|
161 |
+
|
162 |
+
|
163 |
+
printf( '<div style="margin-bottom: 20px; white-space: pre-wrap; font-family: monospace; width: 100%%; background: %s;"><strong>%s</strong>',
|
164 |
+
Advanced_Ads_Display_Conditions::frontend_check( $_condition, $ad ) ? '#e9ffe9' : '#ffe9e9',
|
165 |
+
$display_conditions[ $_condition['type'] ]['label'] );
|
166 |
+
|
167 |
+
$check = $display_conditions[ $_condition['type'] ]['check'][1];
|
168 |
+
if ( $check === 'check_general' ) {
|
169 |
+
printf( '<table border="1"><thead><tr><th></th><th>%s</th><th>%s</th></tr></thead>', __( 'Ad', 'advanced-ads' ), 'wp_the_query' );
|
170 |
+
} else {
|
171 |
+
printf( '<table border="1"><thead><tr><th>%s</th><th>%s</th></tr></thead>', __( 'Ad', 'advanced-ads' ), 'wp_the_query' );
|
172 |
+
}
|
173 |
+
|
174 |
+
switch( $check ) {
|
175 |
+
case 'check_post_type':
|
176 |
+
printf( '<tr><td>%s</td><td>%s</td></tr>',
|
177 |
+
( isset( $_condition['value'] ) && is_array( $_condition['value'] ) ) ? esc_html( implode( ',', $_condition['value'] ) ) : '',
|
178 |
+
isset( $the_query['post']['post_type'] ) ? $the_query['post']['post_type'] : '' );
|
179 |
+
break;
|
180 |
+
case 'check_general':
|
181 |
+
if ( isset( $the_query['wp_the_query'] ) && is_array( $the_query['wp_the_query'] ) ) {
|
182 |
+
$ad_vars = ( isset( $_condition['value'] ) && is_array( $_condition['value'] ) ) ? $_condition['value'] : array();
|
183 |
+
|
184 |
+
foreach ( $the_query['wp_the_query'] as $_var => $_flag ) {
|
185 |
+
printf( '<tr><td>%s</td><td>%s</td><td>%s</td></tr>',
|
186 |
+
$_var,
|
187 |
+
in_array( $_var, $ad_vars ) ? 1 : 0,
|
188 |
+
$_flag );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
break;
|
192 |
+
case 'check_author':
|
193 |
+
printf( '<tr><td>%s</td><td>%s</td></tr>',
|
194 |
+
( isset( $_condition['value'] ) && is_array( $_condition['value'] ) ) ? esc_html( implode( ',', $_condition['value'] ) ) : '',
|
195 |
+
isset( $the_query['post']['author'] ) ? $the_query['post']['author'] : '' );
|
196 |
+
break;
|
197 |
+
case 'check_post_ids':
|
198 |
+
case 'check_taxonomies':
|
199 |
+
printf( '<tr><td>%s</td><td>post_id: %s<br />is_singular: %s</td></tr>',
|
200 |
+
( isset( $_condition['value'] ) && is_array( $_condition['value'] ) ) ? esc_html( implode( ',', $_condition['value'] ) ) : '',
|
201 |
+
isset( $the_query['post']['id']) ? $the_query['post']['id'] : '',
|
202 |
+
! empty( $the_query['wp_the_query']['is_singular'] ) );
|
203 |
+
break;
|
204 |
+
case 'check_taxonomy_archive':
|
205 |
+
printf( '<tr><td>%s</td><td>term_id: %s<br />is_archive: %s</td></tr>',
|
206 |
+
( isset( $_condition['value'] ) && is_array( $_condition['value'] ) ) ? esc_html( implode( ',', $_condition['value'] ) ) : '',
|
207 |
+
isset( $the_query['wp_the_query']['term_id'] ) ? $the_query['wp_the_query']['term_id'] : '',
|
208 |
+
! empty( $the_query['wp_the_query']['is_archive'] ) );
|
209 |
+
break;
|
210 |
+
default:
|
211 |
+
printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( print_r( $_condition, true ) ), print_r( $the_query, true ) );
|
212 |
+
break;
|
213 |
+
}
|
214 |
+
|
215 |
+
echo '</table></div>';
|
216 |
+
}
|
217 |
+
|
218 |
+
return ob_get_clean();
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Build visitor conditions table.
|
223 |
+
*
|
224 |
+
* @param obj Advanced_Ads_Ad
|
225 |
+
* @return string
|
226 |
+
*/
|
227 |
+
protected function build_visitor_conditions_table( Advanced_Ads_Ad $ad ) {
|
228 |
+
$options = $ad->options();
|
229 |
+
|
230 |
+
if ( ! isset( $options['visitors'] )
|
231 |
+
|| ! is_array( $options['visitors'] )
|
232 |
+
|| ! count( $options['visitors'] ) ) { return; }
|
233 |
+
|
234 |
+
ob_start();
|
235 |
+
|
236 |
+
$visitor_conditions = Advanced_Ads_Visitor_Conditions::get_instance()->conditions;
|
237 |
+
?><?php _e( 'Visitor Conditions', 'advanced-ads' );
|
238 |
+
|
239 |
+
foreach ( $options['visitors'] as $_condition ) {
|
240 |
+
if ( ! is_array( $_condition )
|
241 |
+
|| ! isset( $_condition['type'] )
|
242 |
+
|| ! isset( $visitor_conditions[ $_condition['type'] ]['check'][1] )
|
243 |
+
) { continue; }
|
244 |
+
|
245 |
+
$content = '';
|
246 |
+
foreach ( $_condition as $_k => $_v ) {
|
247 |
+
$content .= esc_html( $_k ) . ': ' . esc_html( $_v ) . '<br>';
|
248 |
+
}
|
249 |
+
|
250 |
+
printf( '<div style="margin-bottom: 20px; white-space: pre-wrap; font-family: monospace; width: 100%%; background: %s;">%s</div>',
|
251 |
+
Advanced_Ads_Visitor_Conditions::frontend_check( $_condition, $ad ) ? '#e9ffe9' : '#ffe9e9',
|
252 |
+
$content );
|
253 |
+
}
|
254 |
+
|
255 |
+
return ob_get_clean();
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Check if the current URL is HTTPS, but the ad code contains HTTP.
|
260 |
+
*
|
261 |
+
* @param obj Advanced_Ads_Ad
|
262 |
+
* @return bool
|
263 |
+
*/
|
264 |
+
protected function check_http( Advanced_Ads_Ad $ad ) {
|
265 |
+
is_ssl() && $ad->type === 'plain' && preg_match( '/http:\/\//i', $ad->prepare_frontend_output() );
|
266 |
+
}
|
267 |
+
}
|
classes/ad.php
CHANGED
@@ -172,8 +172,8 @@ class Advanced_Ads_Ad {
|
|
172 |
$this->type_obj = new Advanced_Ads_Ad_Type_Abstract;
|
173 |
}
|
174 |
$this->url = $this->options( 'url' );
|
175 |
-
$this->width = $this->options( 'width' );
|
176 |
-
$this->height = $this->options( 'height' );
|
177 |
$this->conditions = $this->options( 'conditions' );
|
178 |
$this->description = $this->options( 'description' );
|
179 |
$this->output = $this->options( 'output' );
|
@@ -264,7 +264,9 @@ class Advanced_Ads_Ad {
|
|
264 |
|
265 |
// switch between normal and debug mode
|
266 |
if( isset( $this->output['debugmode'] ) ){
|
267 |
-
|
|
|
|
|
268 |
} else {
|
269 |
$output = $this->prepare_frontend_output();
|
270 |
}
|
@@ -272,7 +274,11 @@ class Advanced_Ads_Ad {
|
|
272 |
// add the ad to the global output array
|
273 |
$advads = Advanced_Ads::get_instance();
|
274 |
if ( $output_options['global_output'] ) {
|
275 |
-
$
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
|
278 |
// action when output is created
|
@@ -289,10 +295,10 @@ class Advanced_Ads_Ad {
|
|
289 |
* @return bool $can_display true if can be displayed in frontend
|
290 |
*/
|
291 |
public function can_display( $check_options = array() ) {
|
292 |
-
$check_options = wp_parse_args( $check_options, array( 'passive_cache_busting' => false ) );
|
293 |
-
|
294 |
// force ad display if debug mode is enabled
|
295 |
-
if( isset( $this->output['debugmode'] )){
|
296 |
return true;
|
297 |
}
|
298 |
|
@@ -519,95 +525,6 @@ class Advanced_Ads_Ad {
|
|
519 |
|
520 |
return $output;
|
521 |
}
|
522 |
-
|
523 |
-
/**
|
524 |
-
* prepare debug mode output
|
525 |
-
*
|
526 |
-
* @since 1.7.0.3
|
527 |
-
*/
|
528 |
-
public function prepare_debug_output() {
|
529 |
-
|
530 |
-
global $post, $wp_query;
|
531 |
-
|
532 |
-
// set size
|
533 |
-
if( $this->width && $this->height ){
|
534 |
-
$width = $this->width;
|
535 |
-
$height = $this->height;
|
536 |
-
} else {
|
537 |
-
$width = 300;
|
538 |
-
$height = 250;
|
539 |
-
}
|
540 |
-
|
541 |
-
$style = "width:{$width}px;height:{$height}px;background-color:#ddd;overflow:scroll;";
|
542 |
-
|
543 |
-
$prefix = Advanced_Ads_Plugin::get_instance()->get_frontend_prefix();
|
544 |
-
|
545 |
-
$content = array();
|
546 |
-
|
547 |
-
// display notice that debug doesn’t work with cache-busting
|
548 |
-
if( class_exists( 'Advanced_Ads_Pro_Module_Cache_Busting', false ) && isset ( $this->args['cache-busting'] ) && 'off' !== $this->args['cache-busting'] ){
|
549 |
-
$content[] = '<span style="color: red;">Debug mode does not work properly with cache-busting enabled for this ad.</span>';
|
550 |
-
}
|
551 |
-
|
552 |
-
// compare current wp_query with global wp_main_query
|
553 |
-
if( ! $wp_query->is_main_query() ){
|
554 |
-
$content[] = '<span style="color: red;">Current query is not identical to main query.</span>';
|
555 |
-
// output differences
|
556 |
-
$content[] = $this->build_query_diff_table();
|
557 |
-
}
|
558 |
-
|
559 |
-
// compare current post with global post
|
560 |
-
if( $wp_query->post !== $post ){
|
561 |
-
$error = '<span style="color: red;">Current post is not identical to main post.</span>';
|
562 |
-
// output differences
|
563 |
-
if( isset( $post->post_title ) && $post->ID ){
|
564 |
-
$error .= '<br/>current post: ' . $post->post_title . ', ID: ' . $post->ID;
|
565 |
-
}
|
566 |
-
if( isset( $wp_query->post->post_title ) && $wp_query->post->ID ){
|
567 |
-
$error .= '<br/>main post: ' . $wp_query->post->post_title . ', ID: ' . $wp_query->post->ID;
|
568 |
-
}
|
569 |
-
$content[] = $error;
|
570 |
-
}
|
571 |
-
|
572 |
-
ob_start();
|
573 |
-
|
574 |
-
include( ADVADS_BASE_PATH . '/public/views/ad-debug.php' );
|
575 |
-
|
576 |
-
$output = ob_get_clean();
|
577 |
-
|
578 |
-
// apply a custom filter by ad type
|
579 |
-
$output = apply_filters( 'advanced-ads-ad-output-debug', $output, $this );
|
580 |
-
|
581 |
-
return $output;
|
582 |
-
|
583 |
-
}
|
584 |
-
|
585 |
-
/**
|
586 |
-
* build table with differences between current and main query
|
587 |
-
*
|
588 |
-
* @since 1.7.0.3
|
589 |
-
*/
|
590 |
-
private function build_query_diff_table(){
|
591 |
-
|
592 |
-
global $wp_query, $wp_the_query;
|
593 |
-
|
594 |
-
$diff_current = array_diff_assoc( $wp_query->query_vars, $wp_the_query->query_vars );
|
595 |
-
$diff_main = array_diff_assoc( $wp_the_query->query_vars, $wp_query->query_vars );
|
596 |
-
|
597 |
-
if( ! is_array( $diff_current ) || ! is_array( $diff_main ) ){
|
598 |
-
return '';
|
599 |
-
}
|
600 |
-
|
601 |
-
ob_start();
|
602 |
-
|
603 |
-
?><table><thead><tr><th></th><th>current query</th><th>main query</th></tr></thead><?php
|
604 |
-
foreach( $diff_current as $_key => $_value ){
|
605 |
-
?><tr><td><?php echo $_key; ?></td><td><?php echo $_value; ?></td><td><?php if( isset( $diff_main[$_key] ) ) echo $diff_main[$_key]; ?></td></tr><?php
|
606 |
-
}
|
607 |
-
?></table><?php
|
608 |
-
|
609 |
-
return ob_get_clean();
|
610 |
-
}
|
611 |
|
612 |
/**
|
613 |
* sanitize ad display conditions when saving the ad
|
@@ -767,7 +684,7 @@ class Advanced_Ads_Ad {
|
|
767 |
}
|
768 |
|
769 |
// exclude the 'Header Code' placement type
|
770 |
-
if ( ! isset( $this->args['placement_type'] ) ||
|
771 |
$wrapper['data-id'] = $this->id;
|
772 |
}
|
773 |
|
172 |
$this->type_obj = new Advanced_Ads_Ad_Type_Abstract;
|
173 |
}
|
174 |
$this->url = $this->options( 'url' );
|
175 |
+
$this->width = absint( $this->options( 'width' ) );
|
176 |
+
$this->height = absint( $this->options( 'height' ) );
|
177 |
$this->conditions = $this->options( 'conditions' );
|
178 |
$this->description = $this->options( 'description' );
|
179 |
$this->output = $this->options( 'output' );
|
264 |
|
265 |
// switch between normal and debug mode
|
266 |
if( isset( $this->output['debugmode'] ) ){
|
267 |
+
require_once __DIR__ . '/ad-debug.php';
|
268 |
+
$debug = new Advanced_Ads_Ad_Debug;
|
269 |
+
return $debug->prepare_debug_output( $this );
|
270 |
} else {
|
271 |
$output = $this->prepare_frontend_output();
|
272 |
}
|
274 |
// add the ad to the global output array
|
275 |
$advads = Advanced_Ads::get_instance();
|
276 |
if ( $output_options['global_output'] ) {
|
277 |
+
$new_ad = array('type' => 'ad', 'id' => $this->id, 'title' => $this->title, 'output' => $output);
|
278 |
+
if ( class_exists( 'Advanced_ads_Tracking_Plugin', false ) ) {
|
279 |
+
$new_ad['tracking_enabled'] = Advanced_ads_Tracking_Plugin::get_instance()->check_ad_tracking_enabled( $this );
|
280 |
+
}
|
281 |
+
$advads->current_ads[] = $new_ad;
|
282 |
}
|
283 |
|
284 |
// action when output is created
|
295 |
* @return bool $can_display true if can be displayed in frontend
|
296 |
*/
|
297 |
public function can_display( $check_options = array() ) {
|
298 |
+
$check_options = wp_parse_args( $check_options, array( 'passive_cache_busting' => false, 'ignore_debugmode' => false ) );
|
299 |
+
|
300 |
// force ad display if debug mode is enabled
|
301 |
+
if( isset( $this->output['debugmode'] ) && ! $check_options['ignore_debugmode'] ) {
|
302 |
return true;
|
303 |
}
|
304 |
|
525 |
|
526 |
return $output;
|
527 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
|
529 |
/**
|
530 |
* sanitize ad display conditions when saving the ad
|
684 |
}
|
685 |
|
686 |
// exclude the 'Header Code' placement type
|
687 |
+
if ( ! isset( $this->args['placement_type'] ) || 'header' !== $this->args['placement_type'] ) {
|
688 |
$wrapper['data-id'] = $this->id;
|
689 |
}
|
690 |
|
classes/ad_group.php
CHANGED
@@ -128,6 +128,8 @@ class Advanced_Ads_Group {
|
|
128 |
$this->description = $group->description;
|
129 |
$this->post_type = Advanced_Ads::POST_TYPE_SLUG;
|
130 |
$this->ad_args = $ad_args;
|
|
|
|
|
131 |
|
132 |
$this->load_additional_attributes();
|
133 |
}
|
128 |
$this->description = $group->description;
|
129 |
$this->post_type = Advanced_Ads::POST_TYPE_SLUG;
|
130 |
$this->ad_args = $ad_args;
|
131 |
+
// allow access to the group from ads
|
132 |
+
$this->ad_args['group'] = $this;
|
133 |
|
134 |
$this->load_additional_attributes();
|
135 |
}
|
classes/ad_placements.php
CHANGED
@@ -326,7 +326,9 @@ class Advanced_Ads_Placements {
|
|
326 |
// test ad is emtpy
|
327 |
$whitespaces = json_decode('"\t\n\r \u00A0"');
|
328 |
$adContent = Advanced_Ads_Select::get_instance()->get_ad_by_method( $placement_id, 'placement', $options );
|
329 |
-
if (
|
|
|
|
|
330 |
return $content;
|
331 |
}
|
332 |
|
326 |
// test ad is emtpy
|
327 |
$whitespaces = json_decode('"\t\n\r \u00A0"');
|
328 |
$adContent = Advanced_Ads_Select::get_instance()->get_ad_by_method( $placement_id, 'placement', $options );
|
329 |
+
if ( ! extension_loaded( 'dom' )
|
330 |
+
|| trim( $adContent, $whitespaces ) === ''
|
331 |
+
) {
|
332 |
return $content;
|
333 |
}
|
334 |
|
classes/frontend_checks.php
CHANGED
@@ -20,6 +20,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
20 |
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 1000 );
|
21 |
add_filter( 'the_content', array( $this, 'set_did_the_content' ) );
|
22 |
add_filter( 'wp_footer', array( $this, 'check_adblocker' ), -101 );
|
|
|
23 |
}
|
24 |
}
|
25 |
|
@@ -46,7 +47,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
46 |
'title' => __( 'jQuery not in header', 'advanced-ads' ),
|
47 |
'href' => 'https://wpadvancedads.com/manual/common-issues#frontend-issues-javascript',
|
48 |
'meta' => array(
|
49 |
-
'class' => 'hidden',
|
50 |
'target' => '_blank'
|
51 |
)
|
52 |
) );
|
@@ -58,7 +59,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
58 |
'title' => __( 'Ad blocker enabled', 'advanced-ads' ),
|
59 |
// 'href' => 'https://wpadvancedads.com/support',
|
60 |
'meta' => array(
|
61 |
-
'class' => 'hidden',
|
62 |
'target' => '_blank'
|
63 |
)
|
64 |
) );
|
@@ -72,6 +73,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
72 |
'title' => sprintf( __( '<em>%s</em> filter does not exist', 'advanced-ads' ), 'the_content' ),
|
73 |
'href' => 'https://wpadvancedads.com/manual/ads-not-showing-up/#frontend-issues-the-content-filter',
|
74 |
'meta' => array(
|
|
|
75 |
'target' => '_blank'
|
76 |
)
|
77 |
) );
|
@@ -88,6 +90,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
88 |
'title' => __( 'Ads are disabled on this page', 'advanced-ads' ),
|
89 |
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
|
90 |
'meta' => array(
|
|
|
91 |
'target' => '_blank'
|
92 |
)
|
93 |
) );
|
@@ -101,6 +104,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
101 |
'title' => __( 'Ads are disabled in the content of this page', 'advanced-ads' ),
|
102 |
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
|
103 |
'meta' => array(
|
|
|
104 |
'target' => '_blank'
|
105 |
)
|
106 |
) );
|
@@ -113,6 +117,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
113 |
'title' => __( 'the current post ID is 0 ', 'advanced-ads' ),
|
114 |
'href' => 'https://wpadvancedads.com/manual/known-plugin-conflicts/#frontend-issue-post-id-empty',
|
115 |
'meta' => array(
|
|
|
116 |
'target' => '_blank'
|
117 |
)
|
118 |
) );
|
@@ -127,6 +132,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
127 |
'title' => __( 'Ads are disabled on 404 pages', 'advanced-ads' ),
|
128 |
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
|
129 |
'meta' => array(
|
|
|
130 |
'target' => '_blank'
|
131 |
)
|
132 |
) );
|
@@ -140,6 +146,21 @@ class Advanced_Ads_Frontend_Checks {
|
|
140 |
'title' => __( 'Ads are disabled on non singular pages', 'advanced-ads' ),
|
141 |
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
|
142 |
'meta' => array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
'target' => '_blank'
|
144 |
)
|
145 |
) );
|
@@ -157,6 +178,23 @@ class Advanced_Ads_Frontend_Checks {
|
|
157 |
)
|
158 |
) );
|
159 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -176,7 +214,8 @@ class Advanced_Ads_Frontend_Checks {
|
|
176 |
* Check conditions and display warning. Conditions: AdBlocker enabled, jQuery is included in header
|
177 |
*/
|
178 |
public function check_adblocker() { ?>
|
179 |
-
<!--noptimize--><style>.hidden { display: none; } .advads-adminbar-is-warnings { background: #a54811 ! important; color: #fff !important; }
|
|
|
180 |
<script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
|
181 |
<script>
|
182 |
(function(d, w) {
|
@@ -189,12 +228,30 @@ class Advanced_Ads_Frontend_Checks {
|
|
189 |
obj.attachEvent( 'on' + type, function() { return fn.call( obj, window.event ); } );
|
190 |
};
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
addEvent( w, 'load', function() {
|
193 |
var adblock_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_adblocker_enabled' ),
|
194 |
jQuery_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_jquery' ),
|
195 |
fine_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_fine' ),
|
196 |
hide_fine = false;
|
197 |
|
|
|
|
|
|
|
|
|
|
|
198 |
if ( adblock_item && typeof advanced_ads_adblocker_test === 'undefined' ) {
|
199 |
// show hidden item
|
200 |
adblock_item.className = adblock_item.className.replace( /hidden/, '' );
|
@@ -216,8 +273,8 @@ class Advanced_Ads_Frontend_Checks {
|
|
216 |
|
217 |
var showCount = function() {
|
218 |
try {
|
219 |
-
// select not hidden items, exclude the 'fine_item'
|
220 |
-
var warning_count = document.querySelectorAll( '
|
221 |
} catch ( e ) { return; }
|
222 |
|
223 |
if ( warning_count ) {
|
@@ -234,4 +291,26 @@ class Advanced_Ads_Frontend_Checks {
|
|
234 |
<?php
|
235 |
}
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
20 |
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 1000 );
|
21 |
add_filter( 'the_content', array( $this, 'set_did_the_content' ) );
|
22 |
add_filter( 'wp_footer', array( $this, 'check_adblocker' ), -101 );
|
23 |
+
add_filter( 'advanced-ads-ad-output', array( $this, 'after_ad_output' ), 10, 2 );
|
24 |
}
|
25 |
}
|
26 |
|
47 |
'title' => __( 'jQuery not in header', 'advanced-ads' ),
|
48 |
'href' => 'https://wpadvancedads.com/manual/common-issues#frontend-issues-javascript',
|
49 |
'meta' => array(
|
50 |
+
'class' => 'hidden advanced_ads_ad_health_warning',
|
51 |
'target' => '_blank'
|
52 |
)
|
53 |
) );
|
59 |
'title' => __( 'Ad blocker enabled', 'advanced-ads' ),
|
60 |
// 'href' => 'https://wpadvancedads.com/support',
|
61 |
'meta' => array(
|
62 |
+
'class' => 'hidden advanced_ads_ad_health_warning',
|
63 |
'target' => '_blank'
|
64 |
)
|
65 |
) );
|
73 |
'title' => sprintf( __( '<em>%s</em> filter does not exist', 'advanced-ads' ), 'the_content' ),
|
74 |
'href' => 'https://wpadvancedads.com/manual/ads-not-showing-up/#frontend-issues-the-content-filter',
|
75 |
'meta' => array(
|
76 |
+
'class' => 'advanced_ads_ad_health_warning',
|
77 |
'target' => '_blank'
|
78 |
)
|
79 |
) );
|
90 |
'title' => __( 'Ads are disabled on this page', 'advanced-ads' ),
|
91 |
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
|
92 |
'meta' => array(
|
93 |
+
'class' => 'advanced_ads_ad_health_warning',
|
94 |
'target' => '_blank'
|
95 |
)
|
96 |
) );
|
104 |
'title' => __( 'Ads are disabled in the content of this page', 'advanced-ads' ),
|
105 |
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
|
106 |
'meta' => array(
|
107 |
+
'class' => 'advanced_ads_ad_health_warning',
|
108 |
'target' => '_blank'
|
109 |
)
|
110 |
) );
|
117 |
'title' => __( 'the current post ID is 0 ', 'advanced-ads' ),
|
118 |
'href' => 'https://wpadvancedads.com/manual/known-plugin-conflicts/#frontend-issue-post-id-empty',
|
119 |
'meta' => array(
|
120 |
+
'class' => 'advanced_ads_ad_health_warning',
|
121 |
'target' => '_blank'
|
122 |
)
|
123 |
) );
|
132 |
'title' => __( 'Ads are disabled on 404 pages', 'advanced-ads' ),
|
133 |
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
|
134 |
'meta' => array(
|
135 |
+
'class' => 'advanced_ads_ad_health_warning',
|
136 |
'target' => '_blank'
|
137 |
)
|
138 |
) );
|
146 |
'title' => __( 'Ads are disabled on non singular pages', 'advanced-ads' ),
|
147 |
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
|
148 |
'meta' => array(
|
149 |
+
'class' => 'advanced_ads_ad_health_warning',
|
150 |
+
'target' => '_blank'
|
151 |
+
)
|
152 |
+
) );
|
153 |
+
$display_fine = false;
|
154 |
+
}
|
155 |
+
|
156 |
+
if ( ! extension_loaded( 'dom' ) ) {
|
157 |
+
$wp_admin_bar->add_node( array(
|
158 |
+
'parent' => 'advanced_ads_ad_health',
|
159 |
+
'id' => 'advanced_ads_ad_health_no_dom_document',
|
160 |
+
'title' => sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'dom' ),
|
161 |
+
'href' => 'http://php.net/manual/en/book.dom.php',
|
162 |
+
'meta' => array(
|
163 |
+
'class' => 'advanced_ads_ad_health_warning',
|
164 |
'target' => '_blank'
|
165 |
)
|
166 |
) );
|
178 |
)
|
179 |
) );
|
180 |
}
|
181 |
+
|
182 |
+
$wp_admin_bar->add_node( array(
|
183 |
+
'parent' => 'advanced_ads_ad_health',
|
184 |
+
'id' => 'advanced_ads_ad_health_debug_dfp',
|
185 |
+
'title' => __( 'debug DFP ads', 'advanced-ads' ),
|
186 |
+
'href' => esc_url( add_query_arg( 'googfc', '' ) ),
|
187 |
+
'meta' => array(
|
188 |
+
'class' => 'hidden advanced_ads_ad_health_debug_dfp_link',
|
189 |
+
'target' => '_blank',
|
190 |
+
)
|
191 |
+
) );
|
192 |
+
|
193 |
+
$wp_admin_bar->add_node( array(
|
194 |
+
'parent' => 'advanced_ads_ad_health',
|
195 |
+
'id' => 'advanced_ads_ad_health_highlight_ads',
|
196 |
+
'title' => sprintf( '<label><input id="advanced_ads_highlight_ads_checkbox" type="checkbox"> %s</label>', __( 'highlight ads', 'advanced-ads' ) )
|
197 |
+
) );
|
198 |
}
|
199 |
|
200 |
/**
|
214 |
* Check conditions and display warning. Conditions: AdBlocker enabled, jQuery is included in header
|
215 |
*/
|
216 |
public function check_adblocker() { ?>
|
217 |
+
<!--noptimize--><style>.hidden { display: none; } .advads-adminbar-is-warnings { background: #a54811 ! important; color: #fff !important; }
|
218 |
+
.advanced-ads-highlight-ads { outline:4px solid blue !important; }</style>
|
219 |
<script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
|
220 |
<script>
|
221 |
(function(d, w) {
|
228 |
obj.attachEvent( 'on' + type, function() { return fn.call( obj, window.event ); } );
|
229 |
};
|
230 |
|
231 |
+
function highlight_ads() {
|
232 |
+
try {
|
233 |
+
var ad_wrappers = document.querySelectorAll('div[id^="<?php echo Advanced_Ads_Plugin::get_instance()->get_frontend_prefix();?>"]')
|
234 |
+
} catch ( e ) { return; }
|
235 |
+
for ( i = 0; i < ad_wrappers.length; i++ ) {
|
236 |
+
if ( this.checked ) {
|
237 |
+
ad_wrappers[i].className += ' advanced-ads-highlight-ads';
|
238 |
+
} else {
|
239 |
+
ad_wrappers[i].className = ad_wrappers[i].className.replace( 'advanced-ads-highlight-ads', '' );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
addEvent( w, 'load', function() {
|
245 |
var adblock_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_adblocker_enabled' ),
|
246 |
jQuery_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_jquery' ),
|
247 |
fine_item = d.getElementById( 'wp-admin-bar-advanced_ads_ad_health_fine' ),
|
248 |
hide_fine = false;
|
249 |
|
250 |
+
var highlight_checkbox = d.getElementById( 'advanced_ads_highlight_ads_checkbox' );
|
251 |
+
if ( highlight_checkbox ) {
|
252 |
+
addEvent( highlight_checkbox, 'change', highlight_ads );
|
253 |
+
}
|
254 |
+
|
255 |
if ( adblock_item && typeof advanced_ads_adblocker_test === 'undefined' ) {
|
256 |
// show hidden item
|
257 |
adblock_item.className = adblock_item.className.replace( /hidden/, '' );
|
273 |
|
274 |
var showCount = function() {
|
275 |
try {
|
276 |
+
// select not hidden warning items, exclude the 'fine_item'
|
277 |
+
var warning_count = document.querySelectorAll( '.advanced_ads_ad_health_warning:not(.hidden)' ).length;
|
278 |
} catch ( e ) { return; }
|
279 |
|
280 |
if ( warning_count ) {
|
291 |
<?php
|
292 |
}
|
293 |
|
294 |
+
/**
|
295 |
+
* Allow DFP debugging by showing a link that points to the current URL with the 'googfc' parameter.
|
296 |
+
*
|
297 |
+
* @param str $content ad content
|
298 |
+
* @param obj $ad Advanced_Ads_Ad
|
299 |
+
* @return str $content ad content
|
300 |
+
*/
|
301 |
+
public function after_ad_output( $content = '', Advanced_Ads_Ad $ad ) {
|
302 |
+
if ( $ad->type === 'plain' && preg_match( '/gpt\.js/', $content ) ) {
|
303 |
+
ob_start(); ?>
|
304 |
+
<!--noptimize--><script>
|
305 |
+
var advads_dfp_link = document.querySelector( '.advanced_ads_ad_health_debug_dfp_link.hidden' );
|
306 |
+
if ( advads_dfp_link ) {
|
307 |
+
advads_dfp_link.className = advads_dfp_link.className.replace( 'hidden', '' );
|
308 |
+
}
|
309 |
+
</script><!--/noptimize-->
|
310 |
+
<?php
|
311 |
+
$content .= ob_get_clean();
|
312 |
+
}
|
313 |
+
return $content;
|
314 |
+
}
|
315 |
+
|
316 |
}
|
modules/import-export/classes/XmlEncoder.php
CHANGED
@@ -60,6 +60,9 @@ class Advanced_Ads_XmlEncoder
|
|
60 |
if ( ! extension_loaded( 'simplexml' ) ) {
|
61 |
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'simplexml' ) );
|
62 |
}
|
|
|
|
|
|
|
63 |
|
64 |
$this->dom = new DOMDocument();
|
65 |
$this->dom->preserveWhiteSpace = false;
|
@@ -189,6 +192,10 @@ class Advanced_Ads_XmlEncoder
|
|
189 |
if ( ! extension_loaded( 'simplexml' ) ) {
|
190 |
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'simplexml' ) );
|
191 |
}
|
|
|
|
|
|
|
|
|
192 |
|
193 |
if ('' === trim($data)) {
|
194 |
throw new UnexpectedValueException( _x( 'Invalid XML data, it can not be empty', 'import_export', 'advanced-ads' ) );
|
@@ -315,18 +322,4 @@ class Advanced_Ads_XmlEncoder
|
|
315 |
return $text;
|
316 |
}
|
317 |
|
318 |
-
/**
|
319 |
-
* check if simplexml is loaded
|
320 |
-
*
|
321 |
-
* @return bool true if simplexml can be used
|
322 |
-
*/
|
323 |
-
private function check_simplexml_exists(){
|
324 |
-
if ( extension_loaded( 'simplexml' ) ) {
|
325 |
-
return true;
|
326 |
-
}
|
327 |
-
return false;
|
328 |
-
}
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
}
|
60 |
if ( ! extension_loaded( 'simplexml' ) ) {
|
61 |
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'simplexml' ) );
|
62 |
}
|
63 |
+
if ( ! extension_loaded( 'dom' ) ) {
|
64 |
+
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'dom' ) );
|
65 |
+
}
|
66 |
|
67 |
$this->dom = new DOMDocument();
|
68 |
$this->dom->preserveWhiteSpace = false;
|
192 |
if ( ! extension_loaded( 'simplexml' ) ) {
|
193 |
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'simplexml' ) );
|
194 |
}
|
195 |
+
if ( ! extension_loaded( 'dom' ) ) {
|
196 |
+
throw new Exception( sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'dom' ) );
|
197 |
+
}
|
198 |
+
|
199 |
|
200 |
if ('' === trim($data)) {
|
201 |
throw new UnexpectedValueException( _x( 'Invalid XML data, it can not be empty', 'import_export', 'advanced-ads' ) );
|
322 |
return $text;
|
323 |
}
|
324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
}
|
public/views/ad-debug.php
CHANGED
@@ -1,9 +1,21 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</div>
|
1 |
+
<!--noptimize--><script>
|
2 |
+
// Output script that makes full-screen mode.
|
3 |
+
if ( typeof advanced_ads_full_screen_debug !== 'function' ) {
|
4 |
+
function advanced_ads_full_screen_debug( ad ) {
|
5 |
+
if ( ! ad || ! document.body ) { return; }
|
6 |
+
|
7 |
+
var ad_full = document.createElement( 'div' );
|
8 |
+
ad_full.style.cssText = '<?php echo $style_full; ?>';
|
9 |
+
ad_full.ondblclick = function() {
|
10 |
+
this.parentNode.removeChild( this );
|
11 |
+
}
|
12 |
+
ad_full.innerHTML = ad.innerHTML;
|
13 |
+
document.body.appendChild( ad_full );
|
14 |
+
}
|
15 |
+
}
|
16 |
+
</script><!--/noptimize-->
|
17 |
+
<div id="<?php echo $wrapper_id; ?>" style="<?php echo $style; ?>" ondblclick="advanced_ads_full_screen_debug( this );">
|
18 |
+
<strong><?php _e( 'Ad debug output', 'advanced-ads' ); ?></strong>
|
19 |
+
<?php echo '<br /><br />' . implode( '<br /><br />', $content ); ?>
|
20 |
+
<br /><br /><a style="color: green;" href="<?php echo ADVADS_URL; ?>manual/ad-debug-mode/#utm_source=advanced-ads&utm_medium=link&utm_campaign=ad-debug-mode" target="_blank"><?php _e( 'Find solutions in the manual', 'advanced-ads' ); ?></a>
|
21 |
</div>
|
readme.txt
CHANGED
@@ -4,11 +4,11 @@ Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id
|
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Manage and optimize your ads
|
12 |
|
13 |
== Description ==
|
14 |
|
@@ -206,6 +206,16 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
206 |
|
207 |
== Changelog ==
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
= 1.7.9.3 =
|
210 |
|
211 |
* added Selling Ads widget on overview page
|
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.10
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Manage and optimize your ads and ads performance with support for AdSense, ad injection, ad widget, and ad rotation.
|
12 |
|
13 |
== Description ==
|
14 |
|
206 |
|
207 |
== Changelog ==
|
208 |
|
209 |
+
= 1.7.10 =
|
210 |
+
|
211 |
+
* highlight ads in the frontend through the "Ad Health" options
|
212 |
+
* check if PHP DOM module is enabled and warn in "Ad Health" if not
|
213 |
+
* added DFP debug link to "Ad Health"
|
214 |
+
* added button to check Add-On license keys for changes
|
215 |
+
* extended ad debug mode with more information
|
216 |
+
* restructured support page to reach helper more quickly
|
217 |
+
* fixed header ad bug
|
218 |
+
|
219 |
= 1.7.9.3 =
|
220 |
|
221 |
* added Selling Ads widget on overview page
|