Version Description
- fixed empty content placements still being parsed
- fixed missing or double tags created by content placements
Download this release
Release Info
Developer | webzunft |
Plugin | Advanced Ads |
Version | 1.3.8 |
Comparing to | |
See all releases |
Code changes from version 1.3.7 to 1.3.8
- advanced-ads.php +1 -1
- classes/ad_placements.php +22 -5
- public/class-advanced-ads.php +2 -0
- readme.txt +6 -1
advanced-ads.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: http://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
-
* Version: 1.3.
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: http://webgilde.com
|
18 |
* Text Domain: advanced-ads
|
12 |
* Plugin Name: Advanced Ads
|
13 |
* Plugin URI: http://wpadvancedads.com
|
14 |
* Description: Manage and optimize your ads in WordPress
|
15 |
+
* Version: 1.3.8
|
16 |
* Author: Thomas Maier
|
17 |
* Author URI: http://webgilde.com
|
18 |
* Text Domain: advanced-ads
|
classes/ad_placements.php
CHANGED
@@ -222,6 +222,7 @@ class Advads_Ad_Placements {
|
|
222 |
* @link inspired by http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
|
223 |
*/
|
224 |
static function inject_in_content($placement_id, $options, $content) {
|
|
|
225 |
$tag = (isset($options['tag'])) ? $options['tag'] : 'p';
|
226 |
$position = (isset($options['position'])) ? $options['position'] : 'after';
|
227 |
|
@@ -233,26 +234,42 @@ class Advads_Ad_Placements {
|
|
233 |
|
234 |
$paragraph_id = isset($options['index']) ? $options['index'] : 1;
|
235 |
$ad_content = Advads_Ad_Placements::output($placement_id);
|
236 |
-
|
237 |
$paragraphs = explode($tag, $content);
|
|
|
238 |
$offset = 0;
|
239 |
$running = true;
|
240 |
foreach ($paragraphs as $index => $paragraph) {
|
241 |
|
242 |
// check if current paragraph is empty and if so, create offset
|
243 |
-
if($running && $index > 0 && trim(str_replace(array($tag, ' '), '', $paragraph)) == '')
|
244 |
$offset++;
|
|
|
|
|
|
|
|
|
245 |
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
|
|
|
250 |
if ($paragraph_id + $offset == $index + 1) {
|
251 |
$paragraphs[$index] .= $ad_content;
|
252 |
$running = false;
|
253 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
return implode('', $paragraphs);
|
256 |
}
|
257 |
|
258 |
-
}
|
222 |
* @link inspired by http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
|
223 |
*/
|
224 |
static function inject_in_content($placement_id, $options, $content) {
|
225 |
+
|
226 |
$tag = (isset($options['tag'])) ? $options['tag'] : 'p';
|
227 |
$position = (isset($options['position'])) ? $options['position'] : 'after';
|
228 |
|
234 |
|
235 |
$paragraph_id = isset($options['index']) ? $options['index'] : 1;
|
236 |
$ad_content = Advads_Ad_Placements::output($placement_id);
|
|
|
237 |
$paragraphs = explode($tag, $content);
|
238 |
+
|
239 |
$offset = 0;
|
240 |
$running = true;
|
241 |
foreach ($paragraphs as $index => $paragraph) {
|
242 |
|
243 |
// check if current paragraph is empty and if so, create offset
|
244 |
+
if($running && $index > 0 && trim(str_replace(array($tag, ' '), '', $paragraph)) == ''){
|
245 |
$offset++;
|
246 |
+
} elseif($index == 0 && trim(str_replace(array($tag, ' '), '', $paragraph)) == ''){
|
247 |
+
// if the current paragraph is empty (because the tag was the first one in the content) attach the tag
|
248 |
+
$paragraphs[$index] = $tag;
|
249 |
+
}
|
250 |
|
251 |
+
|
252 |
+
// insert tag in case the ads position is after it
|
253 |
+
if (trim($paragraph) && $position == 'after'){
|
254 |
+
// not on the last paragraph
|
255 |
+
if($index+1 != count($paragraphs))
|
256 |
+
$paragraphs[$index] .= $tag;
|
257 |
}
|
258 |
|
259 |
+
// insert ad content
|
260 |
if ($paragraph_id + $offset == $index + 1) {
|
261 |
$paragraphs[$index] .= $ad_content;
|
262 |
$running = false;
|
263 |
}
|
264 |
+
|
265 |
+
// insert tag in case the ads position is before it
|
266 |
+
if (trim($paragraph) && $position == 'before'){
|
267 |
+
// not on the last paragraph
|
268 |
+
if($index+1 != count($paragraphs))
|
269 |
+
$paragraphs[$index] = $paragraphs[$index] . $tag;
|
270 |
+
}
|
271 |
}
|
272 |
return implode('', $paragraphs);
|
273 |
}
|
274 |
|
275 |
+
}
|
public/class-advanced-ads.php
CHANGED
@@ -684,6 +684,8 @@ class Advanced_Ads {
|
|
684 |
|
685 |
$placements = get_option('advads-ads-placements', array());
|
686 |
foreach($placements as $_placement_id => $_placement){
|
|
|
|
|
687 |
if(isset($_placement['type']) && $_placement['type'] == 'post_top'){
|
688 |
$content = Advads_Ad_Placements::output($_placement_id) . $content;
|
689 |
}
|
684 |
|
685 |
$placements = get_option('advads-ads-placements', array());
|
686 |
foreach($placements as $_placement_id => $_placement){
|
687 |
+
if(empty($_placement['item'])) continue;
|
688 |
+
|
689 |
if(isset($_placement['type']) && $_placement['type'] == 'post_top'){
|
690 |
$content = Advads_Ad_Placements::output($_placement_id) . $content;
|
691 |
}
|
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, adsense, display, banner, advertisements, adverts, advert, monetization
|
5 |
Requires at least: WP 3.5, PHP 5.3
|
6 |
Tested up to: 4.1.
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -147,6 +147,11 @@ There is no revenue share. Advanced Ads doesn’t alter your ad codes in a way t
|
|
147 |
|
148 |
== Changelog ==
|
149 |
|
|
|
|
|
|
|
|
|
|
|
150 |
= 1.3.7 =
|
151 |
|
152 |
* fixed bug with display conditions not working for custom post types and taxonomies
|
4 |
Tags: ads, ad, adsense, display, banner, advertisements, adverts, advert, monetization
|
5 |
Requires at least: WP 3.5, PHP 5.3
|
6 |
Tested up to: 4.1.
|
7 |
+
Stable tag: 1.3.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
147 |
|
148 |
== Changelog ==
|
149 |
|
150 |
+
= 1.3.8 =
|
151 |
+
|
152 |
+
* fixed empty content placements still being parsed
|
153 |
+
* fixed missing or double tags created by content placements
|
154 |
+
|
155 |
= 1.3.7 =
|
156 |
|
157 |
* fixed bug with display conditions not working for custom post types and taxonomies
|