Version Description
- order ads in widgets and placements by ad title
- set OR as default connector in Display Conditions
- force OR on Display Conditions where conditions with AND never show the ad
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.7.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.7.4 to 1.7.4.1
- admin/assets/css/admin.css +1 -1
- admin/views/ad-display-metabox.php +29 -2
- advanced-ads.php +2 -2
- classes/ad_placements.php +1 -1
- classes/display-conditions.php +25 -5
- classes/widget.php +1 -1
- readme.txt +7 -1
admin/assets/css/admin.css
CHANGED
@@ -97,7 +97,7 @@ select + .advads-conditions-single { display: inline-block; }
|
|
97 |
.advads-conditions-table td, .advads-conditions-table td * { vertical-align: top; }
|
98 |
.advads-conditions-table > tbody > tr td { border-bottom: 1px solid #ddd; }
|
99 |
.advads-conditions-table select { vertical-align: inherit; margin: 0; }
|
100 |
-
.advads-conditions-connector label { text-transform: uppercase; background: #fff; border:
|
101 |
.advads-conditions-type { text-transform: capitalize; }
|
102 |
.advads-conditions-table tr:first-child .advads-conditions-connector * { display: none; }
|
103 |
|
97 |
.advads-conditions-table td, .advads-conditions-table td * { vertical-align: top; }
|
98 |
.advads-conditions-table > tbody > tr td { border-bottom: 1px solid #ddd; }
|
99 |
.advads-conditions-table select { vertical-align: inherit; margin: 0; }
|
100 |
+
.advads-conditions-connector label { text-transform: uppercase; background: #fff; border: 1px solid #aaa; color: #555; }
|
101 |
.advads-conditions-type { text-transform: capitalize; }
|
102 |
.advads-conditions-table tr:first-child .advads-conditions-connector * { display: none; }
|
103 |
|
admin/views/ad-display-metabox.php
CHANGED
@@ -14,9 +14,11 @@ $options = $ad->options('conditions');
|
|
14 |
);
|
15 |
}
|
16 |
|
|
|
17 |
$i = 0;
|
18 |
if (is_array($options)) :
|
19 |
foreach ($options as $_index => $_options) :
|
|
|
20 |
// get type attribute from previous option format
|
21 |
$_options['type'] = isset($_options['type']) ? $_options['type'] : $_index;
|
22 |
$connector = ( ! isset($_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
|
@@ -26,10 +28,35 @@ $options = $ad->options('conditions');
|
|
26 |
continue;
|
27 |
}
|
28 |
if (method_exists($metabox[0], $metabox[1])) {
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
call_user_func(array($metabox[0], $metabox[1]), $_options, $i++);
|
31 |
?></td><td><button type="button" class="advads-display-conditions-remove button">x</button></td></tr><?php
|
32 |
}
|
|
|
33 |
endforeach;
|
34 |
endif;
|
35 |
?></tbody></table>
|
@@ -73,7 +100,7 @@ endif;
|
|
73 |
success: function (r, textStatus, XMLHttpRequest) {
|
74 |
// add
|
75 |
if (r) {
|
76 |
-
var connector = '<input type="checkbox" name="<?php echo Advanced_Ads_Display_Conditions::FORM_NAME; ?>[' + display_condition_index + '][connector]" value="or" id="advads-conditions-'+ display_condition_index +'-connector"><label for="advads-conditions-'+ display_condition_index +'-connector"><?php _e( '
|
77 |
var newline = '<tr><td class="advads-conditions-connector">'+connector+'</td><td class="advads-conditions-type" data-condition-type="'+ display_condition_type +'">' + display_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-display-conditions-remove button">x</button></td></tr>';
|
78 |
$('#advads-display-conditions table tbody').append(newline);
|
79 |
$('#advads-display-conditions table tbody .advads-conditions-single.advads-buttonset').buttonset();
|
14 |
);
|
15 |
}
|
16 |
|
17 |
+
$last_index = -1;
|
18 |
$i = 0;
|
19 |
if (is_array($options)) :
|
20 |
foreach ($options as $_index => $_options) :
|
21 |
+
$show_or_force_warning = false;
|
22 |
// get type attribute from previous option format
|
23 |
$_options['type'] = isset($_options['type']) ? $_options['type'] : $_index;
|
24 |
$connector = ( ! isset($_options['connector'] ) || 'or' !== $_options['connector'] ) ? 'and' : 'or';
|
28 |
continue;
|
29 |
}
|
30 |
if (method_exists($metabox[0], $metabox[1])) {
|
31 |
+
/**
|
32 |
+
* show warning for connector when
|
33 |
+
* not set to OR already
|
34 |
+
* this condition and the previous are on page level and not from the identical type
|
35 |
+
* they are both set to SHOW
|
36 |
+
*/
|
37 |
+
$tax = ( isset( $_options['type'] ) && isset( $display_conditions[ $_options['type'] ]['taxonomy'] ) ) ? $display_conditions[ $_options['type'] ]['taxonomy'] : false;
|
38 |
+
$last_tax = ( isset( $options[$last_index]['type'] ) && isset( $display_conditions[ $options[$last_index]['type'] ]['taxonomy'] ) ) ? $display_conditions[ $options[$last_index]['type'] ]['taxonomy'] : false;
|
39 |
+
if( $tax && $last_tax && $last_tax === $tax
|
40 |
+
&& ( ! isset( $_options['connector'] ) || $_options['connector'] !== 'or' )
|
41 |
+
&& 'is' === $_options['operator'] && 'is' === $options[$last_index]['operator']
|
42 |
+
&& $_options['type'] !== $options[$last_index]['type'] ){
|
43 |
+
|
44 |
+
$show_or_force_warning = true;
|
45 |
+
}
|
46 |
+
|
47 |
+
?><tr><td class="advads-conditions-connector"><?php echo Advanced_Ads_Display_Conditions::render_connector_option( $i, $connector );
|
48 |
+
if( $show_or_force_warning ){
|
49 |
+
?><p class="advads-error-message"><?php
|
50 |
+
_e( 'Forced to OR.', 'advanced-ads');
|
51 |
+
echo ' <a target="_blank" href="' . ADVADS_URL . 'manual/display-conditions#manual-combining-multiple-conditions' . '">' . __( 'manual', 'advanced-ads' ) . '</a>';
|
52 |
+
?></p><?php
|
53 |
+
|
54 |
+
}
|
55 |
+
?></td><td class="advads-conditions-type" data-condition-type="<?php echo $_options['type']; ?>"><?php echo $display_conditions[$_options['type']]['label']; ?></td><td><?php
|
56 |
call_user_func(array($metabox[0], $metabox[1]), $_options, $i++);
|
57 |
?></td><td><button type="button" class="advads-display-conditions-remove button">x</button></td></tr><?php
|
58 |
}
|
59 |
+
$last_index = $_index;
|
60 |
endforeach;
|
61 |
endif;
|
62 |
?></tbody></table>
|
100 |
success: function (r, textStatus, XMLHttpRequest) {
|
101 |
// add
|
102 |
if (r) {
|
103 |
+
var connector = '<input type="checkbox" name="<?php echo Advanced_Ads_Display_Conditions::FORM_NAME; ?>[' + display_condition_index + '][connector]" checked="checked" value="or" id="advads-conditions-'+ display_condition_index +'-connector"><label for="advads-conditions-'+ display_condition_index +'-connector"><?php _e( 'or', 'advanced-ads' ); ?></label>';
|
104 |
var newline = '<tr><td class="advads-conditions-connector">'+connector+'</td><td class="advads-conditions-type" data-condition-type="'+ display_condition_type +'">' + display_condition_title + '</td><td>' + r + '</td><td><button type="button" class="advads-display-conditions-remove button">x</button></td></tr>';
|
105 |
$('#advads-display-conditions table tbody').append(newline);
|
106 |
$('#advads-display-conditions table tbody .advads-conditions-single.advads-buttonset').buttonset();
|
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.4
|
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.4' );
|
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.4.1
|
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.4.1' );
|
43 |
|
44 |
/*----------------------------------------------------------------------------*
|
45 |
* Autoloading, modules and functions
|
classes/ad_placements.php
CHANGED
@@ -191,7 +191,7 @@ class Advanced_Ads_Placements {
|
|
191 |
}
|
192 |
|
193 |
// load all ads
|
194 |
-
$ads = $model->get_ads( array('orderby' => '
|
195 |
foreach ( $ads as $_ad ) {
|
196 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
197 |
}
|
191 |
}
|
192 |
|
193 |
// load all ads
|
194 |
+
$ads = $model->get_ads( array('orderby' => 'title', 'order' => 'ASC') );
|
195 |
foreach ( $ads as $_ad ) {
|
196 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
197 |
}
|
classes/display-conditions.php
CHANGED
@@ -768,7 +768,8 @@ class Advanced_Ads_Display_Conditions {
|
|
768 |
) {
|
769 |
return true;
|
770 |
}
|
771 |
-
|
|
|
772 |
$query = $options['wp_the_query'];
|
773 |
$post = isset($options['post']) ? $options['post'] : null;
|
774 |
|
@@ -777,20 +778,39 @@ class Advanced_Ads_Display_Conditions {
|
|
777 |
|
778 |
for($i = 0; $i < $length; ++$i) {
|
779 |
$_condition = current( $conditions );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
780 |
// ignore OR if last result was true
|
781 |
if( $last_result && isset( $_condition['connector'] ) && 'or' === $_condition['connector'] ){
|
782 |
-
next( $conditions );
|
783 |
continue;
|
784 |
}
|
|
|
785 |
$last_result = $result = self::frontend_check($_condition, $ad);
|
786 |
if( ! $result ) {
|
787 |
// return false only, if the next condition doesn’t have an OR operator
|
788 |
-
$next = next( $conditions );
|
789 |
if( ! isset( $next['connector'] ) || $next['connector'] !== 'or' ) {
|
790 |
return false;
|
791 |
}
|
792 |
-
} else {
|
793 |
-
next( $conditions );
|
794 |
}
|
795 |
}
|
796 |
|
768 |
) {
|
769 |
return true;
|
770 |
}
|
771 |
+
// get conditions with rebased index keys
|
772 |
+
$conditions = array_values( $options['conditions'] );
|
773 |
$query = $options['wp_the_query'];
|
774 |
$post = isset($options['post']) ? $options['post'] : null;
|
775 |
|
778 |
|
779 |
for($i = 0; $i < $length; ++$i) {
|
780 |
$_condition = current( $conditions );
|
781 |
+
$next = next( $conditions );
|
782 |
+
$next_key = key( $conditions );
|
783 |
+
|
784 |
+
/**
|
785 |
+
* force next condition’s connector to OR if
|
786 |
+
* not set to OR already
|
787 |
+
* this condition and the next are from the same taxonomy
|
788 |
+
* the conditions don’t have the same condition type
|
789 |
+
* they are both set to SHOW
|
790 |
+
*/
|
791 |
+
$tax = ( isset( $_condition['type'] ) && isset( $this->conditions[ $_condition['type'] ]['taxonomy'] ) ) ? $this->conditions[ $_condition['type'] ]['taxonomy'] : false;
|
792 |
+
$next_tax = ( isset( $next['type'] ) && isset( $this->conditions[ $next['type'] ]['taxonomy'] ) ) ? $this->conditions[ $next['type'] ]['taxonomy'] : false;
|
793 |
+
if( $tax && $next_tax && $next_key
|
794 |
+
&& $next_tax === $tax
|
795 |
+
&& ( ! isset( $next['connector'] ) || $next['connector'] !== 'or' )
|
796 |
+
&& 'is' === $_condition['operator'] && 'is' === $next['operator']
|
797 |
+
&& $_condition['type'] !== $next['type'] ){
|
798 |
+
// error_log(print_r('force_or', true));
|
799 |
+
$next['connector'] = 'or';
|
800 |
+
$conditions[ $next_key ]['connector'] = 'or';
|
801 |
+
}
|
802 |
+
|
803 |
// ignore OR if last result was true
|
804 |
if( $last_result && isset( $_condition['connector'] ) && 'or' === $_condition['connector'] ){
|
|
|
805 |
continue;
|
806 |
}
|
807 |
+
|
808 |
$last_result = $result = self::frontend_check($_condition, $ad);
|
809 |
if( ! $result ) {
|
810 |
// return false only, if the next condition doesn’t have an OR operator
|
|
|
811 |
if( ! isset( $next['connector'] ) || $next['connector'] !== 'or' ) {
|
812 |
return false;
|
813 |
}
|
|
|
|
|
814 |
}
|
815 |
}
|
816 |
|
classes/widget.php
CHANGED
@@ -106,7 +106,7 @@ class Advanced_Ads_Widget extends WP_Widget {
|
|
106 |
$model = Advanced_Ads::get_instance()->get_model();
|
107 |
|
108 |
// load all ads
|
109 |
-
$ads = $model->get_ads( array('orderby' => '
|
110 |
foreach ( $ads as $_ad ){
|
111 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
112 |
}
|
106 |
$model = Advanced_Ads::get_instance()->get_model();
|
107 |
|
108 |
// load all ads
|
109 |
+
$ads = $model->get_ads( array('orderby' => 'title', 'order' => 'ASC') );
|
110 |
foreach ( $ads as $_ad ){
|
111 |
$select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
|
112 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.5.2
|
7 |
-
Stable tag: 1.7.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -203,6 +203,12 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
203 |
|
204 |
== Changelog ==
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
= 1.7.4 =
|
207 |
|
208 |
* added Wizard to quickly create new ads, [manual](https://wpadvancedads.com/manual/wizard/)
|
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.5.2
|
7 |
+
Stable tag: 1.7.4.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
203 |
|
204 |
== Changelog ==
|
205 |
|
206 |
+
= 1.7.4.1 =
|
207 |
+
|
208 |
+
* order ads in widgets and placements by ad title
|
209 |
+
* set OR as default connector in Display Conditions
|
210 |
+
* force OR on Display Conditions where conditions with AND never show the ad
|
211 |
+
|
212 |
= 1.7.4 =
|
213 |
|
214 |
* added Wizard to quickly create new ads, [manual](https://wpadvancedads.com/manual/wizard/)
|