Version Description
- dynamically adjust available ad weight in a group depending on the number of ads
- added option to interpret shortcodes in plain text ad type
- specified some of the warnings on settings page
- fixed 'Display only once' feature when used together with Content placement
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.8.22 |
Comparing to | |
See all releases |
Code changes from version 1.8.21 to 1.8.22
- admin/includes/class-ad-groups-list.php +5 -4
- admin/includes/class-ad-type.php +12 -5
- advanced-ads.php +1 -1
- classes/ad_group.php +21 -4
- classes/ad_placements.php +10 -9
- classes/ad_type_abstract.php +22 -1
- classes/ad_type_content.php +1 -39
- classes/ad_type_plain.php +22 -1
- classes/checks.php +4 -6
- classes/frontend_checks.php +7 -6
- classes/plugin.php +5 -3
- classes/utils.php +13 -2
- modules/import-export/classes/import.php +1 -1
- public/views/ad-debug.php +5 -3
- readme.txt +8 -1
admin/includes/class-ad-groups-list.php
CHANGED
@@ -108,6 +108,7 @@ class Advanced_Ads_Groups_List {
|
|
108 |
$weights = $group->get_ad_weights();
|
109 |
$ad_form_rows = $weights;
|
110 |
arsort( $ad_form_rows );
|
|
|
111 |
|
112 |
// The Loop
|
113 |
if ( $ads->post_count ) {
|
@@ -116,8 +117,8 @@ class Advanced_Ads_Groups_List {
|
|
116 |
$ad_id = $_ad->ID;
|
117 |
$row .= '<tr data-ad-id="'. $ad_id . '"><td>' . $_ad->post_title . '</td><td>';
|
118 |
$row .= '<select name="advads-groups['. $group->id . '][ads]['.$_ad->ID.']">';
|
119 |
-
$ad_weight = (isset($weights[$ad_id])) ? $weights[$ad_id] : Advanced_Ads_Group::
|
120 |
-
for ( $i = 0; $i <=
|
121 |
$row .= '<option ' . selected( $ad_weight, $i, false ) . '>' . $i . '</option>';
|
122 |
}
|
123 |
$row .= '</select</td><td><button type="button" class="advads-remove-ad-from-group button">x</button></td></tr>';
|
@@ -130,7 +131,7 @@ class Advanced_Ads_Groups_List {
|
|
130 |
|
131 |
$ads_for_select = $this->ads_for_select();
|
132 |
$new_ad_weights = '<select class="advads-group-add-ad-list-weights">';
|
133 |
-
for ( $i = 0; $i <=
|
134 |
$new_ad_weights .= '<option ' . selected( 10, $i, false ) . '>' . $i . '</option>';
|
135 |
}
|
136 |
$new_ad_weights .= '</select>';
|
@@ -159,7 +160,7 @@ class Advanced_Ads_Groups_List {
|
|
159 |
$ads->the_post();
|
160 |
$line_output = '<li><a href="' . get_edit_post_link( get_the_ID() ) . '">' . get_the_title() . '</a>';
|
161 |
|
162 |
-
$_weight = (isset($weights[get_the_ID()])) ? $weights[get_the_ID()] : Advanced_Ads_Group::
|
163 |
if ( $group->type == 'default' && $weight_sum ) {
|
164 |
$line_output .= '<span class="ad-weight" title="'.__( 'Ad weight', 'advanced-ads' ).'">' . number_format( ($_weight / $weight_sum) * 100 ) .'%</span>';
|
165 |
}
|
108 |
$weights = $group->get_ad_weights();
|
109 |
$ad_form_rows = $weights;
|
110 |
arsort( $ad_form_rows );
|
111 |
+
$max_weight = Advanced_Ads_Group::get_max_ad_weight( $ads->post_count );
|
112 |
|
113 |
// The Loop
|
114 |
if ( $ads->post_count ) {
|
117 |
$ad_id = $_ad->ID;
|
118 |
$row .= '<tr data-ad-id="'. $ad_id . '"><td>' . $_ad->post_title . '</td><td>';
|
119 |
$row .= '<select name="advads-groups['. $group->id . '][ads]['.$_ad->ID.']">';
|
120 |
+
$ad_weight = (isset($weights[$ad_id])) ? $weights[$ad_id] : Advanced_Ads_Group::MAX_AD_GROUP_DEFAULT_WEIGHT;
|
121 |
+
for ( $i = 0; $i <= $max_weight; $i++ ) {
|
122 |
$row .= '<option ' . selected( $ad_weight, $i, false ) . '>' . $i . '</option>';
|
123 |
}
|
124 |
$row .= '</select</td><td><button type="button" class="advads-remove-ad-from-group button">x</button></td></tr>';
|
131 |
|
132 |
$ads_for_select = $this->ads_for_select();
|
133 |
$new_ad_weights = '<select class="advads-group-add-ad-list-weights">';
|
134 |
+
for ( $i = 0; $i <= $max_weight; $i++ ) {
|
135 |
$new_ad_weights .= '<option ' . selected( 10, $i, false ) . '>' . $i . '</option>';
|
136 |
}
|
137 |
$new_ad_weights .= '</select>';
|
160 |
$ads->the_post();
|
161 |
$line_output = '<li><a href="' . get_edit_post_link( get_the_ID() ) . '">' . get_the_title() . '</a>';
|
162 |
|
163 |
+
$_weight = (isset($weights[get_the_ID()])) ? $weights[get_the_ID()] : Advanced_Ads_Group::MAX_AD_GROUP_DEFAULT_WEIGHT;
|
164 |
if ( $group->type == 'default' && $weight_sum ) {
|
165 |
$line_output .= '<span class="ad-weight" title="'.__( 'Ad weight', 'advanced-ads' ).'">' . number_format( ($_weight / $weight_sum) * 100 ) .'%</span>';
|
166 |
}
|
admin/includes/class-ad-type.php
CHANGED
@@ -283,11 +283,7 @@ class Advanced_Ads_Admin_Ad_Type {
|
|
283 |
$_POST['advanced_ad'] = apply_filters( 'advanced-ads-ad-settings-pre-save', $_POST['advanced_ad'] );
|
284 |
|
285 |
$ad->type = $_POST['advanced_ad']['type'];
|
286 |
-
|
287 |
-
$ad->set_option( 'output', $_POST['advanced_ad']['output'] );
|
288 |
-
} else {
|
289 |
-
$ad->set_option( 'output', array() );
|
290 |
-
}
|
291 |
/**
|
292 |
* deprecated since introduction of "visitors" in 1.5.4
|
293 |
*/
|
@@ -324,6 +320,17 @@ class Advanced_Ads_Admin_Ad_Type {
|
|
324 |
$ad->content = $_POST['advanced_ad']['content']; }
|
325 |
else { $ad->content = ''; }
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
if ( ! empty($_POST['advanced_ad']['conditions']) ){
|
328 |
$ad->conditions = $_POST['advanced_ad']['conditions'];
|
329 |
} else {
|
283 |
$_POST['advanced_ad'] = apply_filters( 'advanced-ads-ad-settings-pre-save', $_POST['advanced_ad'] );
|
284 |
|
285 |
$ad->type = $_POST['advanced_ad']['type'];
|
286 |
+
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* deprecated since introduction of "visitors" in 1.5.4
|
289 |
*/
|
320 |
$ad->content = $_POST['advanced_ad']['content']; }
|
321 |
else { $ad->content = ''; }
|
322 |
|
323 |
+
$output = isset( $_POST['advanced_ad']['output'] ) ? $_POST['advanced_ad']['output'] : array();
|
324 |
+
|
325 |
+
// Find Advanced Ads shortcodes.
|
326 |
+
if ( ! empty( $output['allow_shortcodes'] ) ) {
|
327 |
+
$shortcode_pattern = get_shortcode_regex( array( 'the_ad', 'the_ad_group', 'the_ad_placement' ) );
|
328 |
+
$output['has_shortcode'] = preg_match( '/' . $shortcode_pattern . '/s', $ad->content );
|
329 |
+
}
|
330 |
+
|
331 |
+
// Set output.
|
332 |
+
$ad->set_option( 'output', $output );
|
333 |
+
|
334 |
if ( ! empty($_POST['advanced_ad']['conditions']) ){
|
335 |
$ad->conditions = $_POST['advanced_ad']['conditions'];
|
336 |
} else {
|
advanced-ads.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: https://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
-
* Version: 1.8.
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: https://wpadvancedads.com
|
18 |
* Text Domain: advanced-ads
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: https://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
+
* Version: 1.8.22
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: https://wpadvancedads.com
|
18 |
* Text Domain: advanced-ads
|
classes/ad_group.php
CHANGED
@@ -20,8 +20,9 @@ class Advanced_Ads_Group {
|
|
20 |
|
21 |
/**
|
22 |
* default ad group weight
|
|
|
23 |
*/
|
24 |
-
const
|
25 |
|
26 |
/**
|
27 |
* term id of this ad group
|
@@ -526,15 +527,15 @@ class Advanced_Ads_Group {
|
|
526 |
private function update_ad_weights(){
|
527 |
$ads = $this->get_all_ads();
|
528 |
$weights = $this->get_ad_weights();
|
529 |
-
|
530 |
$new_weights = array();
|
531 |
// use only ads assigned to the group
|
532 |
foreach ( $ads as $_ad ){
|
533 |
if ( isset($weights[$_ad->ID]) ){
|
534 |
$new_weights[$_ad->ID] = $weights[$_ad->ID];
|
535 |
} else {
|
536 |
-
// if no weight is given, use
|
537 |
-
$new_weights[$_ad->ID] = self::
|
538 |
}
|
539 |
}
|
540 |
|
@@ -598,5 +599,21 @@ class Advanced_Ads_Group {
|
|
598 |
$this->wrapper['id'] = $prefix . mt_rand();
|
599 |
}
|
600 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
|
602 |
}
|
20 |
|
21 |
/**
|
22 |
* default ad group weight
|
23 |
+
* previously called MAX_AD_GROUP_WEIGHT
|
24 |
*/
|
25 |
+
const MAX_AD_GROUP_DEFAULT_WEIGHT = 10;
|
26 |
|
27 |
/**
|
28 |
* term id of this ad group
|
527 |
private function update_ad_weights(){
|
528 |
$ads = $this->get_all_ads();
|
529 |
$weights = $this->get_ad_weights();
|
530 |
+
|
531 |
$new_weights = array();
|
532 |
// use only ads assigned to the group
|
533 |
foreach ( $ads as $_ad ){
|
534 |
if ( isset($weights[$_ad->ID]) ){
|
535 |
$new_weights[$_ad->ID] = $weights[$_ad->ID];
|
536 |
} else {
|
537 |
+
// if no weight is given, use default value
|
538 |
+
$new_weights[$_ad->ID] = self::MAX_AD_GROUP_DEFAULT_WEIGHT;
|
539 |
}
|
540 |
}
|
541 |
|
599 |
$this->wrapper['id'] = $prefix . mt_rand();
|
600 |
}
|
601 |
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* calculate the number of available weights for a group depending on
|
605 |
+
* number of ads and default value
|
606 |
+
*
|
607 |
+
* @param int $num_ads number of ads in the group
|
608 |
+
* @since 1.8.22
|
609 |
+
*/
|
610 |
+
public static function get_max_ad_weight( $num_ads = 1 ){
|
611 |
+
|
612 |
+
// use default if lower than default
|
613 |
+
$num_ads = absint( $num_ads );
|
614 |
+
|
615 |
+
return $num_ads < self::MAX_AD_GROUP_DEFAULT_WEIGHT ? self::MAX_AD_GROUP_DEFAULT_WEIGHT : $num_ads;
|
616 |
+
}
|
617 |
+
|
618 |
|
619 |
}
|
classes/ad_placements.php
CHANGED
@@ -343,18 +343,12 @@ class Advanced_Ads_Placements {
|
|
343 |
* @link inspired by http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
|
344 |
*/
|
345 |
public static function &inject_in_content($placement_id, $options, &$content) {
|
|
|
|
|
|
|
346 |
|
347 |
// get plugin options
|
348 |
$plugin_options = Advanced_Ads::get_instance()->options();
|
349 |
-
|
350 |
-
// test ad is emtpy
|
351 |
-
$whitespaces = json_decode('"\t\n\r \u00A0"');
|
352 |
-
$adContent = Advanced_Ads_Select::get_instance()->get_ad_by_method( $placement_id, 'placement', $options );
|
353 |
-
if ( ! extension_loaded( 'dom' )
|
354 |
-
|| trim( $adContent, $whitespaces ) === ''
|
355 |
-
) {
|
356 |
-
return $content;
|
357 |
-
}
|
358 |
|
359 |
// parse document as DOM (fragment - having only a part of an actual post given)
|
360 |
// -TODO may want to verify the wpcharset is supported by server (mb_list_encodings)
|
@@ -442,6 +436,7 @@ class Advanced_Ads_Placements {
|
|
442 |
$items = apply_filters( 'advanced-ads-placement-content-injection-items', $items, $xpath, $tag );
|
443 |
|
444 |
// filter empty tags from items
|
|
|
445 |
$paragraphs = array();
|
446 |
foreach ($items as $item) {
|
447 |
if ( $options['allowEmpty'] || ( isset($item->textContent) && trim($item->textContent, $whitespaces) !== '' ) ) {
|
@@ -453,6 +448,12 @@ class Advanced_Ads_Placements {
|
|
453 |
if ($paragraph_count >= $paragraph_id) {
|
454 |
$offset = $paragraph_select_from_bottom ? $paragraph_count - $paragraph_id : $paragraph_id - 1;
|
455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
// convert HTML to XML!
|
457 |
$adDom = new DOMDocument('1.0', $wpCharset);
|
458 |
libxml_use_internal_errors(true);
|
343 |
* @link inspired by http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
|
344 |
*/
|
345 |
public static function &inject_in_content($placement_id, $options, &$content) {
|
346 |
+
if ( ! extension_loaded( 'dom' ) ) {
|
347 |
+
return $content;
|
348 |
+
}
|
349 |
|
350 |
// get plugin options
|
351 |
$plugin_options = Advanced_Ads::get_instance()->options();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
|
353 |
// parse document as DOM (fragment - having only a part of an actual post given)
|
354 |
// -TODO may want to verify the wpcharset is supported by server (mb_list_encodings)
|
436 |
$items = apply_filters( 'advanced-ads-placement-content-injection-items', $items, $xpath, $tag );
|
437 |
|
438 |
// filter empty tags from items
|
439 |
+
$whitespaces = json_decode('"\t\n\r \u00A0"');
|
440 |
$paragraphs = array();
|
441 |
foreach ($items as $item) {
|
442 |
if ( $options['allowEmpty'] || ( isset($item->textContent) && trim($item->textContent, $whitespaces) !== '' ) ) {
|
448 |
if ($paragraph_count >= $paragraph_id) {
|
449 |
$offset = $paragraph_select_from_bottom ? $paragraph_count - $paragraph_id : $paragraph_id - 1;
|
450 |
|
451 |
+
// test ad is emtpy
|
452 |
+
$adContent = Advanced_Ads_Select::get_instance()->get_ad_by_method( $placement_id, 'placement', $options );
|
453 |
+
if ( trim( $adContent, $whitespaces ) === '' ) {
|
454 |
+
return $content;
|
455 |
+
}
|
456 |
+
|
457 |
// convert HTML to XML!
|
458 |
$adDom = new DOMDocument('1.0', $wpCharset);
|
459 |
libxml_use_internal_errors(true);
|
classes/ad_type_abstract.php
CHANGED
@@ -121,4 +121,25 @@ class Advanced_Ads_Ad_Type_Abstract {
|
|
121 |
return $ad->content;
|
122 |
}
|
123 |
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
return $ad->content;
|
122 |
}
|
123 |
|
124 |
+
/**
|
125 |
+
* Process shortcodes.
|
126 |
+
*
|
127 |
+
* @param str $output Ad content.
|
128 |
+
* @return obj Advanced_Ads_Ad
|
129 |
+
* @return bool force_aa Whether to force Advanced ads shortcodes processing.
|
130 |
+
*/
|
131 |
+
protected function do_shortcode( $output, Advanced_Ads_Ad $ad ) {
|
132 |
+
$ad_options = $ad->options();
|
133 |
+
|
134 |
+
if ( ! isset( $ad_options['output']['has_shortcode'] ) || $ad_options['output']['has_shortcode'] ) {
|
135 |
+
// Store arguments so that shortcode hooks can access it.
|
136 |
+
$ad_args = $ad->args;
|
137 |
+
$ad_args['shortcode_ad_id'] = $ad->id;
|
138 |
+
$output = preg_replace( '/\[(the_ad_group|the_ad_placement|the_ad)/', '[$1 ad_args="' . urlencode( json_encode( $ad_args ) ) . '"', $output );
|
139 |
+
}
|
140 |
+
|
141 |
+
$output = do_shortcode( $output );
|
142 |
+
return $output;
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
classes/ad_type_content.php
CHANGED
@@ -37,8 +37,6 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
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 |
|
@@ -75,7 +73,7 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
75 |
'drag_drop_upload' => true
|
76 |
);
|
77 |
wp_editor( $content, 'advanced-ad-parameters-content', $args );
|
78 |
-
} ?><br class="clear"/><?php
|
79 |
include ADVADS_BASE_PATH . 'admin/views/ad-info-after-textarea.php';
|
80 |
}
|
81 |
|
@@ -137,40 +135,4 @@ class Advanced_Ads_Ad_Type_Content extends Advanced_Ads_Ad_Type_Abstract{
|
|
137 |
|
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 |
-
$options['output']['has_shortcode'] = preg_match( '/' . $pattern . '/s', $ad->content );
|
152 |
-
}
|
153 |
-
return $options;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Process shortcodes.
|
158 |
-
*
|
159 |
-
* @param str $output Ad content.
|
160 |
-
* @return obj Advanced_Ads_Ad
|
161 |
-
*/
|
162 |
-
private function do_shortcode( $output, Advanced_Ads_Ad $ad ) {
|
163 |
-
$ad_options = $ad->options();
|
164 |
-
|
165 |
-
if ( ! isset( $ad_options['output']['has_shortcode'] ) || $ad_options['output']['has_shortcode'] ) {
|
166 |
-
// Store arguments so that shortcode hooks can access it.
|
167 |
-
$ad_args = $ad->args;
|
168 |
-
$ad_args['shortcode_ad_id'] = $ad->id;
|
169 |
-
$output = preg_replace( '/\[(the_ad_group|the_ad_placement|the_ad)/', '[$1 ad_args="' . urlencode( json_encode( $ad_args ) ) . '"', $output );
|
170 |
-
}
|
171 |
-
|
172 |
-
$output = do_shortcode( $output );
|
173 |
-
return $output;
|
174 |
-
}
|
175 |
-
|
176 |
}
|
37 |
$this->parameters = array(
|
38 |
'content' => ''
|
39 |
);
|
|
|
|
|
40 |
}
|
41 |
|
42 |
|
73 |
'drag_drop_upload' => true
|
74 |
);
|
75 |
wp_editor( $content, 'advanced-ad-parameters-content', $args );
|
76 |
+
} ?><br class="clear"/> <input type="hidden" name="advanced_ad[output][allow_shortcodes]" value="1" /><?php
|
77 |
include ADVADS_BASE_PATH . 'admin/views/ad-info-after-textarea.php';
|
78 |
}
|
79 |
|
135 |
|
136 |
return $output;
|
137 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
classes/ad_type_plain.php
CHANGED
@@ -54,6 +54,7 @@ class Advanced_Ads_Ad_Type_Plain extends Advanced_Ads_Ad_Type_Abstract{
|
|
54 |
<?php include ADVADS_BASE_PATH . 'admin/views/ad-info-after-textarea.php'; ?>
|
55 |
<input type="hidden" name="advanced_ad[output][allow_php]" value="0"/>
|
56 |
<?php $this->render_php_allow($ad);
|
|
|
57 |
}
|
58 |
|
59 |
/**
|
@@ -91,6 +92,21 @@ class Advanced_Ads_Ad_Type_Plain extends Advanced_Ads_Ad_Type_Abstract{
|
|
91 |
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/**
|
95 |
* prepare the ads frontend output
|
96 |
*
|
@@ -108,7 +124,12 @@ class Advanced_Ads_Ad_Type_Plain extends Advanced_Ads_Ad_Type_Abstract{
|
|
108 |
} else {
|
109 |
$content = $ad->content;
|
110 |
}
|
|
|
|
|
|
|
|
|
|
|
111 |
return $content;
|
112 |
}
|
113 |
|
114 |
-
}
|
54 |
<?php include ADVADS_BASE_PATH . 'admin/views/ad-info-after-textarea.php'; ?>
|
55 |
<input type="hidden" name="advanced_ad[output][allow_php]" value="0"/>
|
56 |
<?php $this->render_php_allow($ad);
|
57 |
+
$this->render_shortcodes_allow( $ad );
|
58 |
}
|
59 |
|
60 |
/**
|
92 |
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* Render allow shortcodes field.
|
97 |
+
*
|
98 |
+
* @param $ad Advanced_Ads_Ad object
|
99 |
+
*/
|
100 |
+
public function render_shortcodes_allow( $ad ){
|
101 |
+
$allow_shortcodes = ! empty( $ad->output['allow_shortcodes'] );
|
102 |
+
?>
|
103 |
+
<label class="label" for="advads-parameters-shortcodes"><?php _e( 'Allow shortcodes', 'advanced-ads' ); ?></label>
|
104 |
+
<div>
|
105 |
+
<input id="advads-parameters-shortcodes" type="checkbox" name="advanced_ad[output][allow_shortcodes]" value="1" <?php
|
106 |
+
checked( 1, $allow_shortcodes ); ?>/><?php _e( 'Execute shortcodes', 'advanced-ads' );
|
107 |
+
?></div><hr/><?php
|
108 |
+
}
|
109 |
+
|
110 |
/**
|
111 |
* prepare the ads frontend output
|
112 |
*
|
124 |
} else {
|
125 |
$content = $ad->content;
|
126 |
}
|
127 |
+
|
128 |
+
if ( ! empty( $ad->output['allow_shortcodes'] ) ) {
|
129 |
+
$content = $this->do_shortcode( $content, $ad );
|
130 |
+
}
|
131 |
+
|
132 |
return $content;
|
133 |
}
|
134 |
|
135 |
+
}
|
classes/checks.php
CHANGED
@@ -151,9 +151,6 @@ class Advanced_Ads_Checks {
|
|
151 |
|
152 |
$conflicting_plugins = array();
|
153 |
|
154 |
-
if( defined( 'AALB_PLUGIN_CURRENT_VERSION' ) ){ // Amazon Associates Link Builder
|
155 |
-
$conflicting_plugins[] = 'Amazon Associates Link Builder';
|
156 |
-
}
|
157 |
if( defined( 'Publicize_Base' ) ){ // JetPack Publicize module
|
158 |
$conflicting_plugins[] = 'Jetpack – Publicize';
|
159 |
}
|
@@ -163,7 +160,7 @@ class Advanced_Ads_Checks {
|
|
163 |
if( defined( 'GT_VERSION' ) ){ // GT ShortCodes
|
164 |
$conflicting_plugins[] = 'GT ShortCodes';
|
165 |
}
|
166 |
-
if( class_exists( 'ITSEC_Core', false ) ){ // iThemes Security
|
167 |
$conflicting_plugins[] = 'iThemes Security';
|
168 |
}
|
169 |
if( class_exists('q2w3_fixed_widget', false) ){ // Q2W3 Fixed Widget
|
@@ -175,6 +172,7 @@ class Advanced_Ads_Checks {
|
|
175 |
|
176 |
/**
|
177 |
* check if any of the global hide ads options is set
|
|
|
178 |
*
|
179 |
* @since 1.7.10
|
180 |
* @return bool
|
@@ -182,8 +180,8 @@ class Advanced_Ads_Checks {
|
|
182 |
public static function ads_disabled(){
|
183 |
$options = Advanced_Ads::get_instance()->options();
|
184 |
if( isset( $options['disabled-ads'] ) && is_array( $options['disabled-ads'] ) ){
|
185 |
-
foreach( $options['disabled-ads'] as $_value ){
|
186 |
-
if( !empty( $_value ) ){
|
187 |
return true;
|
188 |
}
|
189 |
}
|
151 |
|
152 |
$conflicting_plugins = array();
|
153 |
|
|
|
|
|
|
|
154 |
if( defined( 'Publicize_Base' ) ){ // JetPack Publicize module
|
155 |
$conflicting_plugins[] = 'Jetpack – Publicize';
|
156 |
}
|
160 |
if( defined( 'GT_VERSION' ) ){ // GT ShortCodes
|
161 |
$conflicting_plugins[] = 'GT ShortCodes';
|
162 |
}
|
163 |
+
if( class_exists( 'ITSEC_Core', false ) && defined ( 'AAP_VERSION' ) ){ // iThemes Security, but only if Pro is enabled
|
164 |
$conflicting_plugins[] = 'iThemes Security';
|
165 |
}
|
166 |
if( class_exists('q2w3_fixed_widget', false) ){ // Q2W3 Fixed Widget
|
172 |
|
173 |
/**
|
174 |
* check if any of the global hide ads options is set
|
175 |
+
* ignore feed setting, because it is standard
|
176 |
*
|
177 |
* @since 1.7.10
|
178 |
* @return bool
|
180 |
public static function ads_disabled(){
|
181 |
$options = Advanced_Ads::get_instance()->options();
|
182 |
if( isset( $options['disabled-ads'] ) && is_array( $options['disabled-ads'] ) ){
|
183 |
+
foreach( $options['disabled-ads'] as $_key => $_value ){
|
184 |
+
if( !empty( $_value ) && 'feed' !== $_key ){
|
185 |
return true;
|
186 |
}
|
187 |
}
|
classes/frontend_checks.php
CHANGED
@@ -350,8 +350,9 @@ class Advanced_Ads_Frontend_Checks {
|
|
350 |
*/
|
351 |
public function footer_checks() {
|
352 |
$adsense_options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
|
|
|
353 |
?><!-- Advanced Ads: <?php _e( 'the following code is used for automatic error detection and only visible to admins', 'advanced-ads' ); ?>-->
|
354 |
-
|
355 |
#wp-admin-bar-advanced_ads_ad_health-default a:after { content: "\25BA"; margin-left: .5em; font-size: smaller; }
|
356 |
.advanced-ads-highlight-ads { outline:4px solid blue !important; }</style>
|
357 |
<script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
|
@@ -465,7 +466,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
465 |
}
|
466 |
var quickstart_ads = jQuery(document).find('.google-auto-placed');
|
467 |
jQuery( '<p class="advads-quickstart-hint" style="background-color:#0085ba;color:#fff;font-size:0.8em;padding:5px;"><?php
|
468 |
-
printf(__( 'This
|
469 |
?></p>' ).prependTo( quickstart_ads );
|
470 |
// show quickstart warning in Adhealth Bar if relevant
|
471 |
if( quickstart_ads.length ){
|
@@ -480,8 +481,8 @@ class Advanced_Ads_Frontend_Checks {
|
|
480 |
}
|
481 |
<?php endif; ?>
|
482 |
})(document, window);
|
483 |
-
</script
|
484 |
-
<?php
|
485 |
}
|
486 |
|
487 |
/**
|
@@ -505,7 +506,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
505 |
}
|
506 |
});</script><!--/noptimize-->
|
507 |
<?php
|
508 |
-
$content .= ob_get_clean();
|
509 |
}
|
510 |
|
511 |
|
@@ -525,7 +526,7 @@ class Advanced_Ads_Frontend_Checks {
|
|
525 |
}
|
526 |
});</script><!--/noptimize-->
|
527 |
<?php
|
528 |
-
$content .= ob_get_clean();
|
529 |
}
|
530 |
|
531 |
return $content;
|
350 |
*/
|
351 |
public function footer_checks() {
|
352 |
$adsense_options = Advanced_Ads_AdSense_Data::get_instance()->get_options();
|
353 |
+
ob_start();
|
354 |
?><!-- Advanced Ads: <?php _e( 'the following code is used for automatic error detection and only visible to admins', 'advanced-ads' ); ?>-->
|
355 |
+
<style>.hidden { display: none; } .advads-adminbar-is-warnings { background: #a54811 ! important; color: #fff !important; }
|
356 |
#wp-admin-bar-advanced_ads_ad_health-default a:after { content: "\25BA"; margin-left: .5em; font-size: smaller; }
|
357 |
.advanced-ads-highlight-ads { outline:4px solid blue !important; }</style>
|
358 |
<script type="text/javascript" src="<?php echo ADVADS_BASE_URL . 'admin/assets/js/advertisement.js' ?>"></script>
|
466 |
}
|
467 |
var quickstart_ads = jQuery(document).find('.google-auto-placed');
|
468 |
jQuery( '<p class="advads-quickstart-hint" style="background-color:#0085ba;color:#fff;font-size:0.8em;padding:5px;"><?php
|
469 |
+
printf(__( 'This ad was automatically placed here by AdSense. <a href="%s" target="_blank" style="color:#fff;border-color:#fff;">Click here to learn more</a>.', 'advanced-ads' ), ADVADS_URL . 'adsense-in-random-positions/#utm_source=advanced-ads&utm_medium=link&utm_campaign=frontend-quickstart-ads' );
|
470 |
?></p>' ).prependTo( quickstart_ads );
|
471 |
// show quickstart warning in Adhealth Bar if relevant
|
472 |
if( quickstart_ads.length ){
|
481 |
}
|
482 |
<?php endif; ?>
|
483 |
})(document, window);
|
484 |
+
</script>
|
485 |
+
<?php echo Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
|
486 |
}
|
487 |
|
488 |
/**
|
506 |
}
|
507 |
});</script><!--/noptimize-->
|
508 |
<?php
|
509 |
+
$content .= Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
|
510 |
}
|
511 |
|
512 |
|
526 |
}
|
527 |
});</script><!--/noptimize-->
|
528 |
<?php
|
529 |
+
$content .= Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
|
530 |
}
|
531 |
|
532 |
return $content;
|
classes/plugin.php
CHANGED
@@ -165,15 +165,17 @@ class Advanced_Ads_Plugin {
|
|
165 |
*/
|
166 |
|
167 |
echo apply_filters( 'advanced-ads-attribution', '<!-- managing ads with Advanced Ads -->' );
|
168 |
-
|
|
|
|
|
169 |
<?php if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
170 |
readfile( ADVADS_BASE_PATH . 'public/assets/js/ready.js' );
|
171 |
} else { ?>
|
172 |
advanced_ads_ready=function(){var fns=[],listener,doc=typeof document==="object"&&document,hack=doc&&doc.documentElement.doScroll,domContentLoaded="DOMContentLoaded",loaded=doc&&(hack?/^loaded|^c/:/^loaded|^i|^c/).test(doc.readyState);if(!loaded&&doc){listener=function(){doc.removeEventListener(domContentLoaded,listener);window.removeEventListener("load",listener);loaded=1;while(listener=fns.shift())listener()};doc.addEventListener(domContentLoaded,listener);window.addEventListener("load",listener)}return function(fn){loaded?setTimeout(fn,0):fns.push(fn)}}();
|
173 |
<?php
|
174 |
}
|
175 |
-
?></script
|
176 |
-
|
177 |
}
|
178 |
|
179 |
public function widget_init() {
|
165 |
*/
|
166 |
|
167 |
echo apply_filters( 'advanced-ads-attribution', '<!-- managing ads with Advanced Ads -->' );
|
168 |
+
|
169 |
+
ob_start();
|
170 |
+
?><script>
|
171 |
<?php if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
172 |
readfile( ADVADS_BASE_PATH . 'public/assets/js/ready.js' );
|
173 |
} else { ?>
|
174 |
advanced_ads_ready=function(){var fns=[],listener,doc=typeof document==="object"&&document,hack=doc&&doc.documentElement.doScroll,domContentLoaded="DOMContentLoaded",loaded=doc&&(hack?/^loaded|^c/:/^loaded|^i|^c/).test(doc.readyState);if(!loaded&&doc){listener=function(){doc.removeEventListener(domContentLoaded,listener);window.removeEventListener("load",listener);loaded=1;while(listener=fns.shift())listener()};doc.addEventListener(domContentLoaded,listener);window.addEventListener("load",listener)}return function(fn){loaded?setTimeout(fn,0):fns.push(fn)}}();
|
175 |
<?php
|
176 |
}
|
177 |
+
?></script><?php
|
178 |
+
echo Advanced_Ads_Utils::get_inline_asset( ob_get_clean() );
|
179 |
}
|
180 |
|
181 |
public function widget_init() {
|
classes/utils.php
CHANGED
@@ -72,6 +72,17 @@ class Advanced_Ads_Utils {
|
|
72 |
return $result;
|
73 |
}
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
?>
|
72 |
return $result;
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
+
* Get inline asset.
|
77 |
+
*
|
78 |
+
* @param str $content
|
79 |
+
* @return str $content
|
80 |
+
*/
|
81 |
+
public static function get_inline_asset( $content ) {
|
82 |
+
if ( Advanced_Ads_Checks::active_autoptimize() ) {
|
83 |
+
return '<!--noptimize-->' . $content . '<!--/noptimize-->';
|
84 |
+
}
|
85 |
+
return $content;
|
86 |
+
}
|
87 |
}
|
88 |
+
?>
|
modules/import-export/classes/import.php
CHANGED
@@ -221,7 +221,7 @@ class Advanced_Ads_Import {
|
|
221 |
update_option( 'advads-ad-groups', $advads_ad_groups );
|
222 |
}
|
223 |
|
224 |
-
$ad_weight = isset( $_group['weight'] ) ? absint( $_group['weight'] ) : Advanced_Ads_Group::
|
225 |
$advads_ad_weights[ $group_id ][ $post_id ] = $ad_weight;
|
226 |
}
|
227 |
|
221 |
update_option( 'advads-ad-groups', $advads_ad_groups );
|
222 |
}
|
223 |
|
224 |
+
$ad_weight = isset( $_group['weight'] ) ? absint( $_group['weight'] ) : Advanced_Ads_Group::MAX_AD_GROUP_DEFAULT_WEIGHT;
|
225 |
$advads_ad_weights[ $group_id ][ $post_id ] = $ad_weight;
|
226 |
}
|
227 |
|
public/views/ad-debug.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
|
|
|
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 ) {
|
@@ -13,9 +14,10 @@ if ( typeof advanced_ads_full_screen_debug !== 'function' ) {
|
|
13 |
document.body.appendChild( ad_full );
|
14 |
}
|
15 |
}
|
16 |
-
</script
|
|
|
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>
|
1 |
+
<?php ob_start(); ?>
|
2 |
+
<script>
|
3 |
// Output script that makes full-screen mode.
|
4 |
if ( typeof advanced_ads_full_screen_debug !== 'function' ) {
|
5 |
function advanced_ads_full_screen_debug( ad ) {
|
14 |
document.body.appendChild( ad_full );
|
15 |
}
|
16 |
}
|
17 |
+
</script>
|
18 |
+
<?php echo Advanced_Ads_Utils::get_inline_asset( ob_get_clean() ); ?>
|
19 |
<div id="<?php echo $wrapper_id; ?>" style="<?php echo $style; ?>" ondblclick="advanced_ads_full_screen_debug( this );">
|
20 |
<strong><?php _e( 'Ad debug output', 'advanced-ads' ); ?></strong>
|
21 |
<?php echo '<br /><br />' . implode( '<br /><br />', $content ); ?>
|
22 |
<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>
|
23 |
+
</div>
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: ads, ad, ad inserter, ad injection, ad manager, ads manager, ad widget, ad
|
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.2
|
8 |
-
Stable tag: 1.8.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -233,6 +233,13 @@ Yes. Advanced Ads is based on WordPress standards and therefore easily customiza
|
|
233 |
|
234 |
== Changelog ==
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
= 1.8.21 =
|
237 |
|
238 |
* added more checks for conflicting plugins
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.2
|
8 |
+
Stable tag: 1.8.22
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
233 |
|
234 |
== Changelog ==
|
235 |
|
236 |
+
= 1.8.22 =
|
237 |
+
|
238 |
+
* dynamically adjust available ad weight in a group depending on the number of ads
|
239 |
+
* added option to interpret shortcodes in plain text ad type
|
240 |
+
* specified some of the warnings on settings page
|
241 |
+
* fixed 'Display only once' feature when used together with Content placement
|
242 |
+
|
243 |
= 1.8.21 =
|
244 |
|
245 |
* added more checks for conflicting plugins
|