Ad Inserter – WordPress Ads Management with AdSense Header Integration - Version 1.6.1

Version Description

  • Fixed bug: For shortcodes in posts the date was not checked
  • Fixed error with some templates "Call to undefined method is_main_query()"
  • Added support for minumum number of page/post words for Before/After content display option
  • Added support for {author} and {author_name} tags
Download this release

Release Info

Developer spacetime
Plugin Icon 128x128 Ad Inserter – WordPress Ads Management with AdSense Header Integration
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.1

Files changed (5) hide show
  1. ad-inserter.php +27 -4
  2. class.php +18 -0
  3. constants.php +1 -1
  4. readme.txt +15 -2
  5. settings.php +2 -4
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 1.6.0
5
  Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
6
  Author: Spacetime
7
  Author URI: http://igorfuna.com/
@@ -11,7 +11,13 @@ Plugin URI: http://igorfuna.com/software/web/ad-inserter-wordpress-plugin
11
  /*
12
  Change Log
13
 
14
- Ad Inserter 1.6.0 - 9 january 2016
 
 
 
 
 
 
15
  - Added support for client-side device detection
16
  - Many code improvements
17
  - Improved plugin processing speed
@@ -256,7 +262,7 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
256
  if ($hook_suffix == $ai_settings_page) {
257
  wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip'), AD_INSERTER_VERSION);
258
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
259
- wp_enqueue_style ('ad-inserter-css', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
260
 
261
  wp_enqueue_script ('ad-ace', plugins_url ('includes/ace/src-min-noconflict/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION);
262
  wp_enqueue_script ('ad-ace-ext-modelist', plugins_url ('includes/ace/src-min-noconflict/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION);
@@ -264,7 +270,7 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
264
  }
265
 
266
  function ai_enqueue_scripts_hook () {
267
- wp_enqueue_style ('ad-inserter-devices-css', plugins_url ( 'css/devices.css', __FILE__), false, AD_INSERTER_VERSION);
268
  }
269
 
270
  function ai_admin_notice_hook () {
@@ -309,6 +315,18 @@ function ai_current_user_role_ok () {
309
  $user_role = 0;
310
  $current_user = wp_get_current_user();
311
  $roles = $current_user->roles;
 
 
 
 
 
 
 
 
 
 
 
 
312
  foreach ($roles as $role) {
313
  $current_user_role = isset ($role_values [$role]) ? $role_values [$role] : 0;
314
  if ($current_user_role > $user_role) $user_role = $current_user_role;
@@ -1090,6 +1108,7 @@ function ai_excerpt_hook ($content = ''){
1090
  function ai_loop_start_hook ($query){
1091
  global $block_object;
1092
 
 
1093
  if (!$query->is_main_query()) return;
1094
  if (is_feed()) return;
1095
  if (strpos ($_SERVER ['REQUEST_URI'], '/wp-admin/') === 0) return;
@@ -1762,6 +1781,10 @@ function process_shortcodes ($atts) {
1762
 
1763
  if (!$obj->check_block_counter ()) return "";
1764
 
 
 
 
 
1765
  $block_class_name = get_block_class_name ();
1766
 
1767
  $device_class = "";
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 1.6.1
5
  Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
6
  Author: Spacetime
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 1.6.1 - 28 February 2016
15
+ - Fixed bug: For shortcodes in posts the date was not checked
16
+ - Fixed error with some templates "Call to undefined method is_main_query()"
17
+ - Added support for minumum number of page/post words for Before/After content display option
18
+ - Added support for {author} and {author_name} tags
19
+
20
+ Ad Inserter 1.6.0 - 9 January 2016
21
  - Added support for client-side device detection
22
  - Many code improvements
23
  - Improved plugin processing speed
262
  if ($hook_suffix == $ai_settings_page) {
263
  wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip'), AD_INSERTER_VERSION);
264
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
265
+ wp_enqueue_style ('ad-inserter', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
266
 
267
  wp_enqueue_script ('ad-ace', plugins_url ('includes/ace/src-min-noconflict/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION);
268
  wp_enqueue_script ('ad-ace-ext-modelist', plugins_url ('includes/ace/src-min-noconflict/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION);
270
  }
271
 
272
  function ai_enqueue_scripts_hook () {
273
+ wp_enqueue_style ('ad-inserter-devices', plugins_url ( 'css/devices.css', __FILE__), false, AD_INSERTER_VERSION);
274
  }
275
 
276
  function ai_admin_notice_hook () {
315
  $user_role = 0;
316
  $current_user = wp_get_current_user();
317
  $roles = $current_user->roles;
318
+
319
+ // Fix for empty roles
320
+ if (isset ($current_user->caps) && count ($current_user->caps) != 0) {
321
+ $caps = $current_user->caps;
322
+ if (isset ($caps ["super-admin"]) && $caps ["super-admin"]) $roles []= "super-admin";
323
+ if (isset ($caps ["administrator"]) && $caps ["administrator"]) $roles []= "administrator";
324
+ if (isset ($caps ["editor"]) && $caps ["editor"]) $roles []= "editor";
325
+ if (isset ($caps ["author"]) && $caps ["author"]) $roles []= "author";
326
+ if (isset ($caps ["contributor"]) && $caps ["contributor"]) $roles []= "contributor";
327
+ if (isset ($caps ["subscriber"]) && $caps ["subscriber"]) $roles []= "subscriber";
328
+ }
329
+
330
  foreach ($roles as $role) {
331
  $current_user_role = isset ($role_values [$role]) ? $role_values [$role] : 0;
332
  if ($current_user_role > $user_role) $user_role = $current_user_role;
1108
  function ai_loop_start_hook ($query){
1109
  global $block_object;
1110
 
1111
+ if (!method_exists ($query, 'is_main_query')) return;
1112
  if (!$query->is_main_query()) return;
1113
  if (is_feed()) return;
1114
  if (strpos ($_SERVER ['REQUEST_URI'], '/wp-admin/') === 0) return;
1781
 
1782
  if (!$obj->check_block_counter ()) return "";
1783
 
1784
+ if (is_page() || is_single()) {
1785
+ if (!$obj->check_date ()) return "";
1786
+ }
1787
+
1788
  $block_class_name = get_block_class_name ();
1789
 
1790
  $device_class = "";
class.php CHANGED
@@ -626,6 +626,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
626
  }
627
  if ($search_query == "") $search_query = $smart_tag;
628
 
 
 
 
 
629
  $ad_data = preg_replace ("/{title}/i", $title, parent::get_ad_data());
630
  $ad_data = preg_replace ("/{short_title}/i", $short_title, $ad_data);
631
  $ad_data = preg_replace ("/{category}/i", $category, $ad_data);
@@ -633,6 +637,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
633
  $ad_data = preg_replace ("/{tag}/i", $tag, $ad_data);
634
  $ad_data = preg_replace ("/{smart_tag}/i", $smart_tag, $ad_data);
635
  $ad_data = preg_replace ("/{search_query}/i", $search_query, $ad_data);
 
 
636
 
637
  return $ad_data;
638
  }
@@ -945,6 +951,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
945
  elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
946
  }
947
 
 
 
 
 
 
 
948
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return ai_getAdCode ($this) . $content; else
949
  return "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>" . $content;
950
  }
@@ -964,6 +976,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
964
  elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
965
  }
966
 
 
 
 
 
 
 
967
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return $content . ai_getAdCode ($this); else
968
  return $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
969
  }
626
  }
627
  if ($search_query == "") $search_query = $smart_tag;
628
 
629
+ $author = get_the_author_meta ('display_name');
630
+ $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name');
631
+ if ($author_name == '') $author_name = $author;
632
+
633
  $ad_data = preg_replace ("/{title}/i", $title, parent::get_ad_data());
634
  $ad_data = preg_replace ("/{short_title}/i", $short_title, $ad_data);
635
  $ad_data = preg_replace ("/{category}/i", $category, $ad_data);
637
  $ad_data = preg_replace ("/{tag}/i", $tag, $ad_data);
638
  $ad_data = preg_replace ("/{smart_tag}/i", $smart_tag, $ad_data);
639
  $ad_data = preg_replace ("/{search_query}/i", $search_query, $ad_data);
640
+ $ad_data = preg_replace ("/{author}/i", $author, $ad_data);
641
+ $ad_data = preg_replace ("/{author_name}/i", $author_name, $ad_data);
642
 
643
  return $ad_data;
644
  }
951
  elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
952
  }
953
 
954
+ $text = str_replace (array ("\n", " "), " ", $content);
955
+ $text = strip_tags ($text);
956
+ $number_of_words = sizeof (explode (" ", $text));
957
+
958
+ if ($number_of_words < $this->get_minimum_words()) return $content;
959
+
960
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return ai_getAdCode ($this) . $content; else
961
  return "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>" . $content;
962
  }
976
  elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
977
  }
978
 
979
+ $text = str_replace (array ("\n", " "), " ", $content);
980
+ $text = strip_tags ($text);
981
+ $number_of_words = sizeof (explode (" ", $text));
982
+
983
+ if ($number_of_words < $this->get_minimum_words()) return $content;
984
+
985
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return $content . ai_getAdCode ($this); else
986
  return $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
987
  }
constants.php CHANGED
@@ -11,7 +11,7 @@ if (!defined( 'AD_INSERTER_TITLE'))
11
  define ('AD_INSERTER_TITLE', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '1.6.0');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
11
  define ('AD_INSERTER_TITLE', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '1.6.1');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: adsense, amazon, clickbank, ad, ads, html, javascript, php, code, widget, sidebar, responsive, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 3.0
6
- Tested up to: 4.4.1
7
- Stable tag: 1.5.8
8
  License: GPLv3
9
 
10
  Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
@@ -42,6 +42,7 @@ Additional Display Options:
42
  Additional Options:
43
 
44
  * Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
 
45
  * To rotate different ad versions separate them with |rotate|
46
 
47
  Display Block to:
@@ -420,6 +421,12 @@ AD CODE RIGHT
420
 
421
  == Changelog ==
422
 
 
 
 
 
 
 
423
  = 1.6.0 =
424
  * Added support for client-side device detection
425
  * Many code improvements
@@ -575,6 +582,12 @@ AD CODE RIGHT
575
 
576
  == Upgrade Notice ==
577
 
 
 
 
 
 
 
578
  = 1.6.0 =
579
  Added support for client-side device detection;
580
  Many code improvements;
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: adsense, amazon, clickbank, ad, ads, html, javascript, php, code, widget, sidebar, responsive, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 3.0
6
+ Tested up to: 4.4.2
7
+ Stable tag: 1.6.0
8
  License: GPLv3
9
 
10
  Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
42
  Additional Options:
43
 
44
  * Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
45
+ * Use {author} for post author username or {author_name} for post author name to insert post author data into code blocks (**works only inside posts**)
46
  * To rotate different ad versions separate them with |rotate|
47
 
48
  Display Block to:
421
 
422
  == Changelog ==
423
 
424
+ = 1.6.1 =
425
+ * Fixed bug: For shortcodes in posts the date was not checked
426
+ * Fixed error with some templates "Call to undefined method is_main_query()"
427
+ * Added support for minumum number of page/post words for Before/After content display option
428
+ * Added support for {author} and {author_name} tags
429
+
430
  = 1.6.0 =
431
  * Added support for client-side device detection
432
  * Many code improvements
582
 
583
  == Upgrade Notice ==
584
 
585
+ = 1.6.1 =
586
+ Fixed bug: For shortcodes in posts the date was not checked;
587
+ Fixed error with some templates "Call to undefined method is_main_query()";
588
+ Added support for minumum number of page/post words for Before/After content display option;
589
+ Added support for {author} and {author_name} tags
590
+
591
  = 1.6.0 =
592
  Added support for client-side device detection;
593
  Many code improvements;
settings.php CHANGED
@@ -380,7 +380,8 @@ function print_settings_form (){
380
  </tbody>
381
  </table>
382
 
383
- <div id="after-published-<?php echo $ad_number; ?>" style="padding: 0px 38px 8px 16px; margin-top: 10px; float: right;">
 
384
  Display <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_after_day() ?>" size="2" maxlength="3" title="0 means publish immediately" /> days after post is published
385
  </div>
386
  <div style="padding:0px 0px 8px 16px; margin-top: 10px;">
@@ -400,9 +401,6 @@ function print_settings_form (){
400
  <option value="<?php echo AD_DIRECTION_FROM_BOTTOM; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_BOTTOM; ?></option>
401
  </select>&nbsp;&nbsp;&nbsp;
402
  Minimum number of paragraphs <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPHS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number_minimum() ?>" size="2" maxlength="3" />&nbsp;&nbsp;&nbsp;
403
- <div style="float: right;">
404
- Minimum page/post words <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_words() ?>" size="4" maxlength="6" />
405
- </div>
406
  </div>
407
  <div style="margin: 4px 0 4px 0; ">
408
  Count only paragraphs that
380
  </tbody>
381
  </table>
382
 
383
+ <div id="post_settings-<?php echo $ad_number; ?>" style="padding: 0px 38px 8px 16px; margin-top: 10px;">
384
+ Minimum page/post words <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_words() ?>" size="4" maxlength="6" /> &nbsp;&nbsp;&nbsp;
385
  Display <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_after_day() ?>" size="2" maxlength="3" title="0 means publish immediately" /> days after post is published
386
  </div>
387
  <div style="padding:0px 0px 8px 16px; margin-top: 10px;">
401
  <option value="<?php echo AD_DIRECTION_FROM_BOTTOM; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_BOTTOM; ?></option>
402
  </select>&nbsp;&nbsp;&nbsp;
403
  Minimum number of paragraphs <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPHS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number_minimum() ?>" size="2" maxlength="3" />&nbsp;&nbsp;&nbsp;
 
 
 
404
  </div>
405
  <div style="margin: 4px 0 4px 0; ">
406
  Count only paragraphs that