Version Description
- fixed a bug that prevented removing placement conditions
- trim
inline-css
to remove duplicate spaces - check if
inline-css
index exists in ad options to prevent undefined index notice - move
Advanced_Ads_Inline_Css
class from singleton to one instance per ad, to fix issues withinline-css
not being added - fixed ad edit button visibility in frontend when ad label was activated
Download this release
Release Info
Developer | advancedads |
Plugin | Advanced Ads |
Version | 1.25.1 |
Comparing to | |
See all releases |
Code changes from version 1.25.0 to 1.25.1
- admin/assets/css/admin.css +7 -7
- admin/assets/js/admin.js +14 -25
- admin/assets/js/conditions.js +4 -3
- admin/views/frontend-picker-script.php +4 -1
- admin/views/placements.php +0 -12
- advanced-ads.php +2 -2
- classes/ad.php +15 -8
- classes/ad_group.php +7 -5
- classes/inline-css.php +32 -54
- languages/advanced-ads.pot +7 -7
- public/class-advanced-ads.php +4 -2
- readme.txt +9 -1
admin/assets/css/admin.css
CHANGED
@@ -291,7 +291,7 @@ fieldset.advads-group-add-ad { margin-top: 1em; }
|
|
291 |
.advads-placements-table th span { font-weight: normal; }
|
292 |
.advads-placements-table td { margin: 0; padding: 20px 10px; text-align: left; vertical-align: top; }
|
293 |
.advads-placements-table img { height: 70px; margin-bottom: 5px; }
|
294 |
-
.advads-placements-table .usage-
|
295 |
.advads-placements-table .advads-usage { margin-bottom: 20px; }
|
296 |
.advads-placements-table .advads-usage input { width: 100%; }
|
297 |
.advads-placements-table-options { text-align: right; }
|
@@ -697,8 +697,8 @@ tr.advads-clickable-row:hover{
|
|
697 |
/* table layout, mobile by default */
|
698 |
.advads-option-table { width:100%; }
|
699 |
.advads-option-table thead { display: none; }
|
700 |
-
.advads-option-table tbody td { display: block; }
|
701 |
-
.advads-option-table tbody td:before { /* display a label that is in the "data-th" attribute of the td tag */
|
702 |
content: attr( data-th );
|
703 |
display: inline-block;
|
704 |
width: 32%;
|
@@ -717,15 +717,15 @@ tr.advads-clickable-row:hover{
|
|
717 |
/* tables */
|
718 |
.advads-option-table { width:100%; }
|
719 |
.advads-option-table thead { display: table-header-group; }
|
720 |
-
.advads-option-table tbody td { display: table-cell; }
|
721 |
-
.advads-option-table tbody td:before { display: none; }
|
722 |
}
|
723 |
@media screen and (min-width: 1150px) {
|
724 |
/* tables */
|
725 |
.advads-option-table-responsive { width:100%; }
|
726 |
.advads-option-table-responsive thead { display: table-header-group; }
|
727 |
-
.advads-option-table-responsive tbody td { display: table-cell; }
|
728 |
-
.advads-option-table-responsive tbody td:before { display: none; }
|
729 |
}
|
730 |
@media (min-width: 1200px) {
|
731 |
.advads-placements-table .advads-placement-name {
|
291 |
.advads-placements-table th span { font-weight: normal; }
|
292 |
.advads-placements-table td { margin: 0; padding: 20px 10px; text-align: left; vertical-align: top; }
|
293 |
.advads-placements-table img { height: 70px; margin-bottom: 5px; }
|
294 |
+
.advads-placements-table .usage-modal-link { cursor: pointer; }
|
295 |
.advads-placements-table .advads-usage { margin-bottom: 20px; }
|
296 |
.advads-placements-table .advads-usage input { width: 100%; }
|
297 |
.advads-placements-table-options { text-align: right; }
|
697 |
/* table layout, mobile by default */
|
698 |
.advads-option-table { width:100%; }
|
699 |
.advads-option-table thead { display: none; }
|
700 |
+
.advads-option-table tbody td, .advads-option-table tfoot th { display: block; }
|
701 |
+
.advads-option-table tbody td:before, .advads-option-table tfoot th:before { /* display a label that is in the "data-th" attribute of the td tag */
|
702 |
content: attr( data-th );
|
703 |
display: inline-block;
|
704 |
width: 32%;
|
717 |
/* tables */
|
718 |
.advads-option-table { width:100%; }
|
719 |
.advads-option-table thead { display: table-header-group; }
|
720 |
+
.advads-option-table tbody td, .advads-option-table tfoot th { display: table-cell; }
|
721 |
+
.advads-option-table tbody td:before, .advads-option-table tfoot th:before { display: none; }
|
722 |
}
|
723 |
@media screen and (min-width: 1150px) {
|
724 |
/* tables */
|
725 |
.advads-option-table-responsive { width:100%; }
|
726 |
.advads-option-table-responsive thead { display: table-header-group; }
|
727 |
+
.advads-option-table-responsive tbody td, .advads-option-table-responsive tfoot th { display: table-cell; }
|
728 |
+
.advads-option-table-responsive tbody td:before, .advads-option-table-responsive tfoot th:before { display: none; }
|
729 |
}
|
730 |
@media (min-width: 1200px) {
|
731 |
.advads-placements-table .advads-placement-name {
|
admin/assets/js/admin.js
CHANGED
@@ -231,21 +231,6 @@ jQuery( document ).ready( function ( $ ) {
|
|
231 |
e.preventDefault();
|
232 |
} );
|
233 |
|
234 |
-
// display placement settings form
|
235 |
-
$( '.advads-placements-table a.advads-placement-options-link' ).on( 'click', function ( e ) {
|
236 |
-
e.preventDefault()
|
237 |
-
Advanced_Ads_Admin.toggle_placements_visibility( this )
|
238 |
-
} )
|
239 |
-
// display manual placement usage
|
240 |
-
$( '.advads-placements-table .usage-link' ).on( 'click', function ( e ) {
|
241 |
-
e.preventDefault()
|
242 |
-
var usagediv = $( this ).parents( 'tr' ).find( '.advads-usage' )
|
243 |
-
if ( usagediv.is( ':visible' ) ) {
|
244 |
-
usagediv.hide()
|
245 |
-
} else {
|
246 |
-
usagediv.show()
|
247 |
-
}
|
248 |
-
} )
|
249 |
// show warning if Container ID option contains invalid characters
|
250 |
$( '#advads-output-wrapper-id' ).on( 'keyup', function () {
|
251 |
var id_value = $( this ).val()
|
@@ -496,23 +481,21 @@ jQuery( document ).ready( function ( $ ) {
|
|
496 |
}
|
497 |
} )
|
498 |
|
499 |
-
|
500 |
-
$( 'form#advanced-ads-placements-form input, #advanced-ads-placements-form select' ).on( 'change', function () {
|
501 |
var tr = $( this ).closest( 'tr.advanced-ads-placement-row' )
|
502 |
if ( tr ) {
|
503 |
tr.data( 'touched', true )
|
504 |
}
|
505 |
-
}
|
|
|
|
|
|
|
|
|
506 |
|
507 |
// some special form elements overwrite the jquery listeners (or render them unusable in some strange way)
|
508 |
// to counter that and make it more robust in general, we now listen for mouseover events, that will
|
509 |
// only occur, when the settings of a placement are expanded (let's just assume this means editing)
|
510 |
-
$( 'form#advanced-ads-placements-form .advads-
|
511 |
-
var tr = $( this ).closest( 'tr.advanced-ads-placement-row' )
|
512 |
-
if ( tr ) {
|
513 |
-
tr.data( 'touched', true )
|
514 |
-
}
|
515 |
-
} )
|
516 |
|
517 |
// on submit remove placements that were untouched
|
518 |
$( 'form#advanced-ads-placements-form' ).on( 'submit', function () {
|
@@ -1103,6 +1086,12 @@ window.Advanced_Ads_Admin = window.Advanced_Ads_Admin || {
|
|
1103 |
jQuery( '#advads-parameters-shortcodes-warning' ).hide()
|
1104 |
}
|
1105 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
1106 |
toggle_placements_visibility: function ( elm, state ) {
|
1107 |
var advadsplacementformrow = jQuery( elm ).next( '.advads-placements-advanced-options' )
|
1108 |
|
@@ -1115,7 +1104,7 @@ window.Advanced_Ads_Admin = window.Advanced_Ads_Admin || {
|
|
1115 |
var placement_id = jQuery( elm ).parents( '.advads-placements-table-options' ).find( '.advads-placement-slug' ).val()
|
1116 |
advadsplacementformrow.show()
|
1117 |
jQuery( '#advads-last-edited-placement' ).val( placement_id )
|
1118 |
-
//
|
1119 |
var tr = jQuery( elm ).closest( 'tr.advanced-ads-placement-row' )
|
1120 |
if ( tr ) {
|
1121 |
tr.data( 'touched', true )
|
231 |
e.preventDefault();
|
232 |
} );
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
// show warning if Container ID option contains invalid characters
|
235 |
$( '#advads-output-wrapper-id' ).on( 'keyup', function () {
|
236 |
var id_value = $( this ).val()
|
481 |
}
|
482 |
} )
|
483 |
|
484 |
+
var set_touched_placement = function() {
|
|
|
485 |
var tr = $( this ).closest( 'tr.advanced-ads-placement-row' )
|
486 |
if ( tr ) {
|
487 |
tr.data( 'touched', true )
|
488 |
}
|
489 |
+
}
|
490 |
+
|
491 |
+
// keep track of placements that were changed
|
492 |
+
$( 'form#advanced-ads-placements-form input, #advanced-ads-placements-form select' ).on( 'change', set_touched_placement )
|
493 |
+
$( 'form#advanced-ads-placements-form button' ).on( 'click', set_touched_placement )
|
494 |
|
495 |
// some special form elements overwrite the jquery listeners (or render them unusable in some strange way)
|
496 |
// to counter that and make it more robust in general, we now listen for mouseover events, that will
|
497 |
// only occur, when the settings of a placement are expanded (let's just assume this means editing)
|
498 |
+
$( 'form#advanced-ads-placements-form .advads-modal' ).on( 'mouseover', set_touched_placement )
|
|
|
|
|
|
|
|
|
|
|
499 |
|
500 |
// on submit remove placements that were untouched
|
501 |
$( 'form#advanced-ads-placements-form' ).on( 'submit', function () {
|
1086 |
jQuery( '#advads-parameters-shortcodes-warning' ).hide()
|
1087 |
}
|
1088 |
},
|
1089 |
+
|
1090 |
+
/**
|
1091 |
+
* Toggle placement advanced options.
|
1092 |
+
*
|
1093 |
+
* @deprecated. Used only by add-ons when the base plugin version < 1.19.
|
1094 |
+
*/
|
1095 |
toggle_placements_visibility: function ( elm, state ) {
|
1096 |
var advadsplacementformrow = jQuery( elm ).next( '.advads-placements-advanced-options' )
|
1097 |
|
1104 |
var placement_id = jQuery( elm ).parents( '.advads-placements-table-options' ).find( '.advads-placement-slug' ).val()
|
1105 |
advadsplacementformrow.show()
|
1106 |
jQuery( '#advads-last-edited-placement' ).val( placement_id )
|
1107 |
+
// Some special elements (color picker) may not be detected with jquery.
|
1108 |
var tr = jQuery( elm ).closest( 'tr.advanced-ads-placement-row' )
|
1109 |
if ( tr ) {
|
1110 |
tr.data( 'touched', true )
|
admin/assets/js/conditions.js
CHANGED
@@ -53,7 +53,8 @@ jQuery( document ).ready(
|
|
53 |
condition_index++
|
54 |
condition_form_container.find( '.advads-conditions-index' ).val( condition_index )
|
55 |
// reset select.
|
56 |
-
condition_form_container.find( '.advads-conditions-new select' )[ 0 ].selectedIndex = 0
|
|
|
57 |
}
|
58 |
},
|
59 |
error: function ( MLHttpRequest, textStatus, errorThrown ) {
|
@@ -158,9 +159,9 @@ jQuery( document ).ready(
|
|
158 |
$( '.advads-conditions-not-selected' ).each(
|
159 |
function () {
|
160 |
if ( $( this ).siblings( 'input:checked' ).length ) {
|
161 |
-
$( this ).hide()
|
162 |
} else {
|
163 |
-
$( this ).show()
|
164 |
}
|
165 |
}
|
166 |
)
|
53 |
condition_index++
|
54 |
condition_form_container.find( '.advads-conditions-index' ).val( condition_index )
|
55 |
// reset select.
|
56 |
+
condition_form_container.find( '.advads-conditions-new select' )[ 0 ].selectedIndex = 0;
|
57 |
+
advads_display_condition_option_not_selected();
|
58 |
}
|
59 |
},
|
60 |
error: function ( MLHttpRequest, textStatus, errorThrown ) {
|
159 |
$( '.advads-conditions-not-selected' ).each(
|
160 |
function () {
|
161 |
if ( $( this ).siblings( 'input:checked' ).length ) {
|
162 |
+
$( this ).hide();
|
163 |
} else {
|
164 |
+
$( this ).show();
|
165 |
}
|
166 |
}
|
167 |
)
|
admin/views/frontend-picker-script.php
CHANGED
@@ -9,7 +9,10 @@ jQuery( document ).ready( function(){
|
|
9 |
var action = localStorage.getItem( 'advads_frontend_action' );
|
10 |
if (typeof(action) !== 'undefined'){
|
11 |
var show_all_link = jQuery( 'a[data-placement="' + placement + '"]');
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
// Auto-save the placement after selecting an element in the frontend.
|
15 |
var param = {
|
9 |
var action = localStorage.getItem( 'advads_frontend_action' );
|
10 |
if (typeof(action) !== 'undefined'){
|
11 |
var show_all_link = jQuery( 'a[data-placement="' + placement + '"]');
|
12 |
+
var tr = jQuery( show_all_link ).closest( 'tr.advanced-ads-placement-row' )
|
13 |
+
if ( tr ) {
|
14 |
+
tr.data( 'touched', true )
|
15 |
+
}
|
16 |
|
17 |
// Auto-save the placement after selecting an element in the frontend.
|
18 |
var param = {
|
admin/views/placements.php
CHANGED
@@ -436,18 +436,6 @@ $quick_actions['delete'] = '<a style="cursor: pointer;" class="advads-delete-tag
|
|
436 |
<?php if ( $advanced_options ) : ?>
|
437 |
<a href="#modal-<?php echo esc_attr( $_placement_slug ); ?>" style="cursor: pointer;"
|
438 |
data-placement="<?php echo esc_attr( $_placement_slug ); ?>" class="advads-mobile-hidden"><?php esc_html_e( 'edit conditions', 'advanced-ads' ); ?></a>
|
439 |
-
<?php
|
440 |
-
// phpcs:ignore
|
441 |
-
$hidden = ( isset( $_POST['advads-last-edited-placement'] ) && $_placement_slug === $_POST['advads-last-edited-placement'] ) ? '' : ' hidden';
|
442 |
-
// phpcs:ignore
|
443 |
-
?>
|
444 |
-
<div class="advads-placements-advanced-options advads-placements-advanced-options-
|
445 |
-
<?php
|
446 |
-
echo esc_attr( $_placement_slug );
|
447 |
-
echo esc_attr( $hidden );
|
448 |
-
?>
|
449 |
-
">
|
450 |
-
</div>
|
451 |
<?php endif; ?>
|
452 |
</td>
|
453 |
<?php do_action( 'advanced-ads-placements-list-column', $_placement_slug, $_placement ); ?>
|
436 |
<?php if ( $advanced_options ) : ?>
|
437 |
<a href="#modal-<?php echo esc_attr( $_placement_slug ); ?>" style="cursor: pointer;"
|
438 |
data-placement="<?php echo esc_attr( $_placement_slug ); ?>" class="advads-mobile-hidden"><?php esc_html_e( 'edit conditions', 'advanced-ads' ); ?></a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
<?php endif; ?>
|
440 |
</td>
|
441 |
<?php do_action( 'advanced-ads-placements-list-column', $_placement_slug, $_placement ); ?>
|
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.25.
|
16 |
* Author: Thomas Maier, Advanced Ads GmbH
|
17 |
* Author URI: https://wpadvancedads.com
|
18 |
* Text Domain: advanced-ads
|
@@ -39,7 +39,7 @@ define( 'ADVADS_BASE_DIR', dirname( ADVADS_BASE ) ); // directory of the plugin
|
|
39 |
// general and global slug, e.g. to store options in WP.
|
40 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
41 |
define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
|
42 |
-
define( 'ADVADS_VERSION', '1.25.
|
43 |
|
44 |
// Autoloading, modules and functions.
|
45 |
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: https://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
+
* Version: 1.25.1
|
16 |
* Author: Thomas Maier, Advanced Ads GmbH
|
17 |
* Author URI: https://wpadvancedads.com
|
18 |
* Text Domain: advanced-ads
|
39 |
// general and global slug, e.g. to store options in WP.
|
40 |
define( 'ADVADS_SLUG', 'advanced-ads' );
|
41 |
define( 'ADVADS_URL', 'https://wpadvancedads.com/' );
|
42 |
+
define( 'ADVADS_VERSION', '1.25.1' );
|
43 |
|
44 |
// Autoloading, modules and functions.
|
45 |
|
classes/ad.php
CHANGED
@@ -153,6 +153,13 @@ class Advanced_Ads_Ad {
|
|
153 |
*/
|
154 |
protected $label = '';
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
/**
|
157 |
* Init ad object
|
158 |
*
|
@@ -160,17 +167,17 @@ class Advanced_Ads_Ad {
|
|
160 |
* @param array $args additional arguments.
|
161 |
*/
|
162 |
public function __construct( $id, $args = array() ) {
|
163 |
-
$id
|
164 |
-
$this->id = $id;
|
165 |
$this->args = is_array( $args ) ? $args : array();
|
166 |
-
// Run constructor to check early if ajax cache busting already created inline css.
|
167 |
-
Advanced_Ads_Inline_Css::get_instance();
|
168 |
|
169 |
// whether the ad will be tracked.
|
170 |
$this->global_output = isset( $this->args['global_output'] ) ? (bool) $this->args['global_output'] : true;
|
171 |
|
172 |
-
if
|
173 |
-
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
// dynamically add sanitize filters for condition types.
|
@@ -929,8 +936,8 @@ class Advanced_Ads_Ad {
|
|
929 |
}
|
930 |
|
931 |
// Adds inline css to the wrapper.
|
932 |
-
if ( ! empty( $this->options['inline-css'] ) ) {
|
933 |
-
$wrapper_options =
|
934 |
}
|
935 |
|
936 |
if ( ( ! isset( $this->output['wrapper-id'] ) || '' === $this->output['wrapper-id'] )
|
153 |
*/
|
154 |
protected $label = '';
|
155 |
|
156 |
+
/**
|
157 |
+
* Inline CSS object, one instance per ad.
|
158 |
+
*
|
159 |
+
* @var Advanced_Ads_Inline_Css
|
160 |
+
*/
|
161 |
+
private $inline_css;
|
162 |
+
|
163 |
/**
|
164 |
* Init ad object
|
165 |
*
|
167 |
* @param array $args additional arguments.
|
168 |
*/
|
169 |
public function __construct( $id, $args = array() ) {
|
170 |
+
$this->id = (int) $id;
|
|
|
171 |
$this->args = is_array( $args ) ? $args : array();
|
|
|
|
|
172 |
|
173 |
// whether the ad will be tracked.
|
174 |
$this->global_output = isset( $this->args['global_output'] ) ? (bool) $this->args['global_output'] : true;
|
175 |
|
176 |
+
// Run constructor to check early if ajax cache busting already created inline css.
|
177 |
+
$this->inline_css = new Advanced_Ads_Inline_Css();
|
178 |
+
|
179 |
+
if ( ! empty( $this->id ) ) {
|
180 |
+
$this->load( $this->id );
|
181 |
}
|
182 |
|
183 |
// dynamically add sanitize filters for condition types.
|
936 |
}
|
937 |
|
938 |
// Adds inline css to the wrapper.
|
939 |
+
if ( ! empty( $this->options['inline-css'] ) && $this->args['is_top_level'] ) {
|
940 |
+
$wrapper_options = $this->inline_css->add_css( $wrapper_options, $this->options['inline-css'], $this->global_output );
|
941 |
}
|
942 |
|
943 |
if ( ( ! isset( $this->output['wrapper-id'] ) || '' === $this->output['wrapper-id'] )
|
classes/ad_group.php
CHANGED
@@ -188,13 +188,13 @@ class Advanced_Ads_Group {
|
|
188 |
*
|
189 |
* @since 1.4.8
|
190 |
* @param array/null $ordered_ad_ids Ordered ids of the ads that belong to the group.
|
191 |
-
* @return
|
192 |
*/
|
193 |
public function output( $ordered_ad_ids = false ) {
|
194 |
// if $ordered_ad_ids was not passed to the function, load it
|
195 |
$ordered_ad_ids = ( $ordered_ad_ids === false ) ? $this->get_ordered_ad_ids() : $ordered_ad_ids;
|
196 |
if ( $ordered_ad_ids === null ) {
|
197 |
-
return;
|
198 |
}
|
199 |
|
200 |
// load the ad output
|
@@ -231,7 +231,8 @@ class Advanced_Ads_Group {
|
|
231 |
}
|
232 |
}
|
233 |
|
234 |
-
|
|
|
235 |
// add the group to the global output array
|
236 |
$advads = Advanced_Ads::get_instance();
|
237 |
$advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
|
@@ -252,8 +253,9 @@ class Advanced_Ads_Group {
|
|
252 |
$output_string = implode( '', $output_array );
|
253 |
|
254 |
// Adds inline css to the wrapper.
|
255 |
-
if ( ! empty( $this->ad_args['inline-css'] ) ) {
|
256 |
-
$
|
|
|
257 |
}
|
258 |
|
259 |
if ( ! $this->is_head_placement && $this->wrapper !== array() ) {
|
188 |
*
|
189 |
* @since 1.4.8
|
190 |
* @param array/null $ordered_ad_ids Ordered ids of the ads that belong to the group.
|
191 |
+
* @return string $output output of ad(s) by ad
|
192 |
*/
|
193 |
public function output( $ordered_ad_ids = false ) {
|
194 |
// if $ordered_ad_ids was not passed to the function, load it
|
195 |
$ordered_ad_ids = ( $ordered_ad_ids === false ) ? $this->get_ordered_ad_ids() : $ordered_ad_ids;
|
196 |
if ( $ordered_ad_ids === null ) {
|
197 |
+
return '';
|
198 |
}
|
199 |
|
200 |
// load the ad output
|
231 |
}
|
232 |
}
|
233 |
|
234 |
+
$global_output = ! isset( $this->ad_args['global_output'] ) || $this->ad_args['global_output'];
|
235 |
+
if ( $global_output ) {
|
236 |
// add the group to the global output array
|
237 |
$advads = Advanced_Ads::get_instance();
|
238 |
$advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
|
253 |
$output_string = implode( '', $output_array );
|
254 |
|
255 |
// Adds inline css to the wrapper.
|
256 |
+
if ( ! empty( $this->ad_args['inline-css'] ) && $this->ad_args['is_top_level'] ) {
|
257 |
+
$inline_css = new Advanced_Ads_Inline_Css();
|
258 |
+
$this->wrapper = $inline_css->add_css( $this->wrapper, $this->ad_args['inline-css'], $global_output );
|
259 |
}
|
260 |
|
261 |
if ( ! $this->is_head_placement && $this->wrapper !== array() ) {
|
classes/inline-css.php
CHANGED
@@ -5,34 +5,19 @@
|
|
5 |
*/
|
6 |
class Advanced_Ads_Inline_Css {
|
7 |
/**
|
8 |
-
*
|
9 |
-
*
|
10 |
-
* @var self
|
11 |
-
*/
|
12 |
-
protected static $instance;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Module options
|
16 |
-
*
|
17 |
-
* @var array
|
18 |
-
*/
|
19 |
-
protected $options;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Holds the state if inline css should be outputted or not.
|
23 |
*
|
24 |
* @var bool
|
25 |
*/
|
26 |
protected $add_inline_css;
|
27 |
|
28 |
/**
|
29 |
-
* Initialize the module
|
30 |
*/
|
31 |
-
|
32 |
-
$this->options();
|
33 |
|
34 |
/**
|
35 |
-
* Filters the state if inline css should be
|
36 |
* Ajax CB container could have added inline css already.
|
37 |
*
|
38 |
* Set to false if an addon output inline css before the main plugin.
|
@@ -45,22 +30,20 @@ class Advanced_Ads_Inline_Css {
|
|
45 |
}
|
46 |
|
47 |
// Add inline css to the tcf container.
|
48 |
-
|
49 |
-
add_filter( 'advanced-ads-output-final', array( $this, 'add_tcf_container' ), 20, 2 );
|
50 |
-
$this->add_inline_css = false;
|
51 |
-
}
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
* Adds inline css.
|
56 |
*
|
57 |
-
* @param array
|
58 |
-
* @param string
|
|
|
59 |
*
|
60 |
* @return array
|
61 |
*/
|
62 |
-
public function add_css( $wrapper, $css ) {
|
63 |
-
$this->add_inline_css =
|
64 |
if ( ! $this->add_inline_css ) {
|
65 |
return $wrapper;
|
66 |
}
|
@@ -81,14 +64,23 @@ class Advanced_Ads_Inline_Css {
|
|
81 |
* @return string
|
82 |
*/
|
83 |
public function add_tcf_container( $output, Advanced_Ads_Ad $ad ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
return sprintf(
|
85 |
-
'<div class="tcf-container" style="' . $
|
86 |
$output
|
87 |
);
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
*
|
92 |
*
|
93 |
* @param string $string CSS-Style.
|
94 |
*
|
@@ -96,39 +88,25 @@ class Advanced_Ads_Inline_Css {
|
|
96 |
*/
|
97 |
private function get_styles_by_string( $string ) {
|
98 |
$chunks = array_chunk( preg_split( '/[:;]/', $string ), 2 );
|
|
|
|
|
|
|
99 |
|
100 |
return array_combine( array_filter( array_column( $chunks, 0 ) ), array_filter( array_column( $chunks, 1 ) ) );
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
*
|
105 |
-
*
|
106 |
-
* @return array
|
107 |
*/
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
111 |
}
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
$this->
|
116 |
-
}
|
117 |
-
|
118 |
-
return $this->options;
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Return an instance of Advanced_Ads_Inline_Css
|
123 |
-
*
|
124 |
-
* @return self
|
125 |
-
*/
|
126 |
-
public static function get_instance() {
|
127 |
-
// If the single instance hasn't been set, set it now.
|
128 |
-
if ( self::$instance === null ) {
|
129 |
-
self::$instance = new self();
|
130 |
}
|
131 |
-
|
132 |
-
return self::$instance;
|
133 |
}
|
134 |
}
|
5 |
*/
|
6 |
class Advanced_Ads_Inline_Css {
|
7 |
/**
|
8 |
+
* Holds the state if inline css should be output or not.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*
|
10 |
* @var bool
|
11 |
*/
|
12 |
protected $add_inline_css;
|
13 |
|
14 |
/**
|
15 |
+
* Initialize the module.
|
16 |
*/
|
17 |
+
public function __construct() {
|
|
|
18 |
|
19 |
/**
|
20 |
+
* Filters the state if inline css should be output or not.
|
21 |
* Ajax CB container could have added inline css already.
|
22 |
*
|
23 |
* Set to false if an addon output inline css before the main plugin.
|
30 |
}
|
31 |
|
32 |
// Add inline css to the tcf container.
|
33 |
+
$this->check_tcf_option();
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
* Adds inline css.
|
38 |
*
|
39 |
+
* @param array $wrapper Add wrapper array.
|
40 |
+
* @param string $css Custom inline css.
|
41 |
+
* @param bool|null $global_output Whether this ad is using cache-busting.
|
42 |
*
|
43 |
* @return array
|
44 |
*/
|
45 |
+
public function add_css( $wrapper, $css, $global_output ) {
|
46 |
+
$this->add_inline_css = $this->add_inline_css && $global_output !== false;
|
47 |
if ( ! $this->add_inline_css ) {
|
48 |
return $wrapper;
|
49 |
}
|
64 |
* @return string
|
65 |
*/
|
66 |
public function add_tcf_container( $output, Advanced_Ads_Ad $ad ) {
|
67 |
+
$inline_css = $ad->options( 'inline-css' );
|
68 |
+
|
69 |
+
if (
|
70 |
+
empty( $inline_css )
|
71 |
+
|| strpos( $output, '<div class="tcf-container"' ) === 0
|
72 |
+
) {
|
73 |
+
return $output;
|
74 |
+
}
|
75 |
+
|
76 |
return sprintf(
|
77 |
+
'<div class="tcf-container" style="' . $inline_css . '">%s</div>',
|
78 |
$output
|
79 |
);
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Reformat css styles string to array.
|
84 |
*
|
85 |
* @param string $string CSS-Style.
|
86 |
*
|
88 |
*/
|
89 |
private function get_styles_by_string( $string ) {
|
90 |
$chunks = array_chunk( preg_split( '/[:;]/', $string ), 2 );
|
91 |
+
array_walk_recursive( $chunks, function( &$value ) {
|
92 |
+
$value = trim( $value );
|
93 |
+
} );
|
94 |
|
95 |
return array_combine( array_filter( array_column( $chunks, 0 ) ), array_filter( array_column( $chunks, 1 ) ) );
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* If TCF is active, i.e. there is a TCF container, add the options to this container.
|
|
|
|
|
100 |
*/
|
101 |
+
private function check_tcf_option() {
|
102 |
+
static $privacy_options;
|
103 |
+
if ( $privacy_options === null ) {
|
104 |
+
$privacy_options = Advanced_Ads_Privacy::get_instance()->options();
|
105 |
}
|
106 |
|
107 |
+
if ( ! empty( $privacy_options['enabled'] ) && $privacy_options['enabled'] === 'on' && $privacy_options['consent-method'] === 'iab_tcf_20' ) {
|
108 |
+
add_filter( 'advanced-ads-output-final', array( $this, 'add_tcf_container' ), 20, 2 );
|
109 |
+
$this->add_inline_css = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
|
|
|
|
111 |
}
|
112 |
}
|
languages/advanced-ads.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Advanced Ads plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Advanced Ads 1.25.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
|
7 |
"Last-Translator: Thomas Maier <post@webzunft.de>\n"
|
8 |
"Language-Team: webgilde <support@wpadvancedads.com>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2021-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: advanced-ads\n"
|
@@ -1977,12 +1977,12 @@ msgid "Placements updated"
|
|
1977 |
msgstr ""
|
1978 |
|
1979 |
#: admin/views/placements.php:25
|
1980 |
-
#: admin/views/placements.php:
|
1981 |
msgid "Create a new placement"
|
1982 |
msgstr ""
|
1983 |
|
1984 |
#: admin/views/placements.php:26
|
1985 |
-
#: admin/views/placements.php:
|
1986 |
msgid "New Placement"
|
1987 |
msgstr ""
|
1988 |
|
@@ -2091,12 +2091,12 @@ msgstr ""
|
|
2091 |
msgid "edit conditions"
|
2092 |
msgstr ""
|
2093 |
|
2094 |
-
#: admin/views/placements.php:
|
2095 |
msgctxt "checkbox to remove placement"
|
2096 |
msgid "delete"
|
2097 |
msgstr ""
|
2098 |
|
2099 |
-
#: admin/views/placements.php:
|
2100 |
msgid "Save Placements"
|
2101 |
msgstr ""
|
2102 |
|
@@ -4211,7 +4211,7 @@ msgstr ""
|
|
4211 |
msgid "Parent Ad"
|
4212 |
msgstr ""
|
4213 |
|
4214 |
-
#: public/class-advanced-ads.php:
|
4215 |
msgctxt "label above ads"
|
4216 |
msgid "Advertisements"
|
4217 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Advanced Ads plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Advanced Ads 1.25.1\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
|
7 |
"Last-Translator: Thomas Maier <post@webzunft.de>\n"
|
8 |
"Language-Team: webgilde <support@wpadvancedads.com>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-07-01T14:50:38+02:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: advanced-ads\n"
|
1977 |
msgstr ""
|
1978 |
|
1979 |
#: admin/views/placements.php:25
|
1980 |
+
#: admin/views/placements.php:457
|
1981 |
msgid "Create a new placement"
|
1982 |
msgstr ""
|
1983 |
|
1984 |
#: admin/views/placements.php:26
|
1985 |
+
#: admin/views/placements.php:459
|
1986 |
msgid "New Placement"
|
1987 |
msgstr ""
|
1988 |
|
2091 |
msgid "edit conditions"
|
2092 |
msgstr ""
|
2093 |
|
2094 |
+
#: admin/views/placements.php:448
|
2095 |
msgctxt "checkbox to remove placement"
|
2096 |
msgid "delete"
|
2097 |
msgstr ""
|
2098 |
|
2099 |
+
#: admin/views/placements.php:455
|
2100 |
msgid "Save Placements"
|
2101 |
msgstr ""
|
2102 |
|
4211 |
msgid "Parent Ad"
|
4212 |
msgstr ""
|
4213 |
|
4214 |
+
#: public/class-advanced-ads.php:972
|
4215 |
msgctxt "label above ads"
|
4216 |
msgid "Advertisements"
|
4217 |
msgstr ""
|
public/class-advanced-ads.php
CHANGED
@@ -866,7 +866,7 @@ class Advanced_Ads {
|
|
866 |
* Show custom CSS in the header
|
867 |
*/
|
868 |
public function custom_header_code(){
|
869 |
-
if ( ! defined( 'ADVANCED_ADS_DISABLE_EDIT_BAR' ) && current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads') ) ){
|
870 |
?><style>
|
871 |
div.advads-edit-bar{position:relative;top:0;left:0;height:0;display:none;z-index:10000;animation:advads-edit-appear 2s linear 1;}
|
872 |
@keyframes advads-edit-appear {
|
@@ -876,7 +876,9 @@ class Advanced_Ads {
|
|
876 |
}
|
877 |
a.advads-edit-button{position:absolute;top:0;left:0;text-decoration:none !important;box-shadow:none;border-bottom:none;color:#0074a2;margin-top:-5px;}
|
878 |
a.advads-edit-button span{top:10px;line-height:25px;margin-left:-5px;width:26px;height:26px;border-radius:13px;border:solid 1px #0074a2;background:#fff}
|
879 |
-
|
|
|
|
|
880 |
}
|
881 |
}
|
882 |
|
866 |
* Show custom CSS in the header
|
867 |
*/
|
868 |
public function custom_header_code(){
|
869 |
+
if ( ! defined( 'ADVANCED_ADS_DISABLE_EDIT_BAR' ) && current_user_can( Advanced_Ads_Plugin::user_cap( 'advanced_ads_edit_ads' ) ) ) {
|
870 |
?><style>
|
871 |
div.advads-edit-bar{position:relative;top:0;left:0;height:0;display:none;z-index:10000;animation:advads-edit-appear 2s linear 1;}
|
872 |
@keyframes advads-edit-appear {
|
876 |
}
|
877 |
a.advads-edit-button{position:absolute;top:0;left:0;text-decoration:none !important;box-shadow:none;border-bottom:none;color:#0074a2;margin-top:-5px;}
|
878 |
a.advads-edit-button span{top:10px;line-height:25px;margin-left:-5px;width:26px;height:26px;border-radius:13px;border:solid 1px #0074a2;background:#fff}
|
879 |
+
:hover > div.advads-edit-bar {display: block;}
|
880 |
+
:hover > div.advads-edit-bar ~ div.advads-edit-bar {display: none;}</style>
|
881 |
+
<?php
|
882 |
}
|
883 |
}
|
884 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: ads, ad manager, ad rotation, adsense, banner
|
|
4 |
Requires at least: 4.9
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 1.25.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -317,6 +317,14 @@ Yes. You can use plenty of [hooks](https://wpadvancedads.com/codex/) to customiz
|
|
317 |
|
318 |
== Changelog ==
|
319 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
= 1.25.0 =
|
321 |
|
322 |
- show ad label event when ad wrapper is now shown
|
4 |
Requires at least: 4.9
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 1.25.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
317 |
|
318 |
== Changelog ==
|
319 |
|
320 |
+
= 1.25.1 =
|
321 |
+
|
322 |
+
- fixed a bug that prevented removing placement conditions
|
323 |
+
- trim `inline-css` to remove duplicate spaces
|
324 |
+
- check if `inline-css` index exists in ad options to prevent undefined index notice
|
325 |
+
- move `Advanced_Ads_Inline_Css` class from singleton to one instance per ad, to fix issues with `inline-css` not being added
|
326 |
+
- fixed ad edit button visibility in frontend when ad label was activated
|
327 |
+
|
328 |
= 1.25.0 =
|
329 |
|
330 |
- show ad label event when ad wrapper is now shown
|