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

Version Description

  • Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
  • Few minor cosmetic changes
  • Requirements changed to WordPress 4.0 or newer
  • Added initial support for Pro version
Download this release

Release Info

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

Code changes from version 1.6.5 to 1.6.6

Files changed (6) hide show
  1. ad-inserter.php +63 -42
  2. class.php +4 -8
  3. constants.php +1 -1
  4. js/ad-inserter.js +23 -19
  5. readme.txt +57 -15
  6. settings.php +33 -51
ad-inserter.php CHANGED
@@ -1,16 +1,21 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 1.6.5
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/
8
- Plugin URI: http://igorfuna.com/software/web/ad-inserter-wordpress-plugin
9
  */
10
 
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
14
  Ad Inserter 1.6.5 - 1 August 2016
15
  - Fixed bug: Wrong counting of max insertions
16
  - Change: display position Before Title was renamed to Before Post
@@ -203,9 +208,9 @@ if (!defined ('AD_INSERTER_PLUGIN_DIR'))
203
 
204
  /* Version check */
205
  global $wp_version, $version_string;
206
- $exit_msg = 'Ad Inserter requires WordPress 3.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
207
 
208
- if (version_compare ($wp_version, "3.0", "<")) {
209
  exit ($exit_msg);
210
  }
211
 
@@ -270,12 +275,14 @@ add_action ('widgets_init', 'ai_widgets_init_hook');
270
  add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
271
  add_action ('save_post', 'ai_save_meta_box_data_hook');
272
 
 
 
273
  if ($client_side_detection) {
274
  add_action ('wp_enqueue_scripts', 'ai_enqueue_scripts_hook');
275
  }
276
 
277
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
278
-
279
 
280
  function ai_init_hook() {
281
  global $block_object;
@@ -286,7 +293,7 @@ function ai_init_hook() {
286
  function ai_admin_menu_hook () {
287
  global $ai_settings_page;
288
 
289
- $ai_settings_page = add_submenu_page ('options-general.php', 'Ad Inserter Options', 'Ad Inserter', 'manage_options', basename(__FILE__), 'ai_settings');
290
  add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
291
  }
292
 
@@ -342,6 +349,21 @@ function ai_plugin_action_links ($links) {
342
  return $links;
343
  }
344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  function ai_current_user_role_ok () {
346
  $role_values = array ("super-admin" => 6, "administrator" => 5, "editor" => 4, "author" => 3, "contributor" => 2, "subscriber" => 1);
347
  global $wp_roles;
@@ -381,7 +403,7 @@ function ai_add_meta_box_hook() {
381
  foreach ($screens as $screen) {
382
  add_meta_box (
383
  'adinserter_sectionid',
384
- 'Ad Inserter Exceptions',
385
  'ai_meta_box_callback',
386
  $screen
387
  );
@@ -479,7 +501,7 @@ function ai_meta_box_callback ($post) {
479
  echo '</tbody>';
480
  echo '</table>';
481
 
482
- echo '<p>Default behavior for all code blocks for ', $post_type, 's (enabled or disabled) can be configured on <a href="/wp-admin/options-general.php?page=ad-inserter.php" target="_blank">Ad Inserter Settings page</a>. Here you can configure exceptions for this ', $post_type, '.</p>';
483
  }
484
 
485
  function ai_save_meta_box_data_hook ($post_id) {
@@ -536,7 +558,7 @@ function ai_wp_footer_hook () {
536
  }
537
  }
538
 
539
- function ai_plugin_options ($plugin_options = array ()) {
540
 
541
  $version_array = explode (".", AD_INSERTER_VERSION);
542
  $version_string = "";
@@ -574,7 +596,7 @@ function ai_plugin_options ($plugin_options = array ()) {
574
  $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport;
575
 
576
  if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] =
577
- defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : "VIEWPORT_" . $viewport;
578
 
579
  if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '')
580
  $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1");
@@ -718,7 +740,7 @@ function get_viewport_name ($viewport_number) {
718
  $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number;
719
 
720
  if (!isset ($plugin_db_options [$viewport_settins_name])) {
721
- $plugin_db_options [$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : "VIEWPORT_" . $viewport_number;
722
  }
723
 
724
  return ($plugin_db_options [$viewport_settins_name]);
@@ -825,9 +847,11 @@ function ai_settings () {
825
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
826
  $ad = new ai_Block ($block);
827
 
 
 
 
828
  $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . $block;
829
  if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
830
- $saved_settings = $ai_db_options [$block];
831
 
832
  $exported_settings = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_" . $block])));
833
  if ($exported_settings !== false) {
@@ -856,7 +880,9 @@ function ai_settings () {
856
  }
857
  }
858
 
859
- $ai_options [$block] = $ad->wp_options;
 
 
860
 
861
  delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
862
  }
@@ -883,6 +909,8 @@ function ai_settings () {
883
 
884
  $options = array ();
885
 
 
 
886
  $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
887
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
888
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
@@ -896,12 +924,12 @@ function ai_settings () {
896
  $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
897
  }
898
 
899
- $ai_options [AI_GLOBAL_OPTION_NAME] = ai_plugin_options ($options);
900
  }
901
 
902
  if (!empty ($invalid_blocks)) {
903
  if ($invalid_blocks [0] == 0) {
904
- echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing Ad Inserter settings.</div>";
905
  } else echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing settings for block", count ($invalid_blocks) == 1 ? "" : "s:", " ", implode (", ", $invalid_blocks), ".</div>";
906
  }
907
 
@@ -923,7 +951,7 @@ function ai_settings () {
923
  $style = '';
924
  if (count ($viewports) != 0) {
925
  $style .= "/* " . AD_INSERTER_TITLE . " version " . AD_INSERTER_VERSION ." - viewport classes */\n\n";
926
- $style .= "/* DO NOT MODIFY - This file is automatically generated when you save Ad Inserter settings */\n";
927
  foreach ($viewports as $index => $viewport) {
928
  $style .= "\n/* " . $viewport ['name'] . " */\n\n";
929
  if ($viewport ['index'] == 1) {
@@ -982,7 +1010,7 @@ function ai_settings () {
982
 
983
  $ai_options [AI_HEADER_OPTION_NAME] = $adH->wp_options;
984
  $ai_options [AI_FOOTER_OPTION_NAME] = $adF->wp_options;
985
- $ai_options [AI_GLOBAL_OPTION_NAME] = ai_plugin_options ();
986
  update_option (WP_OPTION_NAME, $ai_options);
987
 
988
  // Reload options
@@ -1001,7 +1029,7 @@ function ai_settings () {
1001
  echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Settings cleared.</div>";
1002
  }
1003
 
1004
- print_settings_form ();
1005
  }
1006
 
1007
 
@@ -1030,9 +1058,9 @@ function adinserter ($ad_number = ""){
1030
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1031
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
1032
 
1033
- $display_for_devices = $obj->get_display_for_devices ();
1034
-
1035
  if ($obj->get_detection_server_side ()) {
 
 
1036
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1037
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1038
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
@@ -1125,13 +1153,6 @@ function ai_content_hook ($content = ''){
1125
  $obj = $block_object [$counter];
1126
 
1127
  $display_type = $obj->get_display_type();
1128
- // $manual_insert = $obj->get_enable_manual ();
1129
-
1130
- // if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
1131
- // $display_type != AD_SELECT_AFTER_PARAGRAPH &&
1132
- // $display_type != AD_SELECT_BEFORE_CONTENT &&
1133
- // $display_type != AD_SELECT_AFTER_CONTENT &&
1134
- // !$manual_insert) continue;
1135
 
1136
  if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
1137
  $display_type != AD_SELECT_AFTER_PARAGRAPH &&
@@ -1143,9 +1164,9 @@ function ai_content_hook ($content = ''){
1143
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1144
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1145
 
1146
- $display_for_devices = $obj->get_display_for_devices ();
1147
-
1148
  if ($obj->get_detection_server_side ()) {
 
 
1149
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1150
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1151
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -1288,9 +1309,9 @@ function ai_excerpt_hook ($content = ''){
1288
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1289
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1290
 
1291
- $display_for_devices = $obj->get_display_for_devices ();
1292
-
1293
  if ($obj->get_detection_server_side ()) {
 
 
1294
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1295
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1296
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -1379,9 +1400,9 @@ function ai_before_after_post ($query, $display_type){
1379
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1380
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1381
 
1382
- $display_for_devices = $obj->get_display_for_devices ();
1383
-
1384
  if ($obj->get_detection_server_side ()) {
 
 
1385
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1386
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1387
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -1527,9 +1548,9 @@ function process_shortcodes ($atts) {
1527
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1528
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
1529
 
1530
- $display_for_devices = $obj->get_display_for_devices ();
1531
-
1532
  if ($obj->get_detection_server_side ()) {
 
 
1533
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1534
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1535
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
@@ -1571,10 +1592,10 @@ class ai_widget extends WP_Widget {
1571
  function __construct () {
1572
  parent::__construct (
1573
  false, // Base ID
1574
- 'Ad Inserter', // Name
1575
  array ( // Args
1576
  'classname' => 'ai_widget',
1577
- 'description' => 'Ad Inserter code block widget.')
1578
  );
1579
  }
1580
 
@@ -1645,9 +1666,9 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1645
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return;
1646
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return;
1647
 
1648
- $display_for_devices = $obj->get_display_for_devices ();
1649
-
1650
  if ($obj->get_detection_server_side ()) {
 
 
1651
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
1652
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
1653
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 1.6.6
5
+ Description: Insert any ad code into Wordpress. Perfect for AdSense or Amazon ads. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
6
+ Author: Tiny Monitor
7
+ Author URI: http://tinymonitor.com/
 
8
  */
9
 
10
  /*
11
  Change Log
12
 
13
+ Ad Inserter 1.6.6 - 5 August 2016
14
+ - Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
15
+ - Few minor cosmetic changes
16
+ - Requirements changed to WordPress 4.0 or newer
17
+ - Added initial support for Pro version
18
+
19
  Ad Inserter 1.6.5 - 1 August 2016
20
  - Fixed bug: Wrong counting of max insertions
21
  - Change: display position Before Title was renamed to Before Post
208
 
209
  /* Version check */
210
  global $wp_version, $version_string;
211
+ $exit_msg = 'Ad Inserter requires WordPress 4.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
212
 
213
+ if (version_compare ($wp_version, "4.0", "<")) {
214
  exit ($exit_msg);
215
  }
216
 
275
  add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
276
  add_action ('save_post', 'ai_save_meta_box_data_hook');
277
 
278
+ if (function_exists ('ai_hooks')) ai_hooks ();
279
+
280
  if ($client_side_detection) {
281
  add_action ('wp_enqueue_scripts', 'ai_enqueue_scripts_hook');
282
  }
283
 
284
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
285
+ add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
286
 
287
  function ai_init_hook() {
288
  global $block_object;
293
  function ai_admin_menu_hook () {
294
  global $ai_settings_page;
295
 
296
+ $ai_settings_page = add_submenu_page ('options-general.php', AD_INSERTER_TITLE.' Options', AD_INSERTER_TITLE, 'manage_options', basename(__FILE__), 'ai_settings');
297
  add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
298
  }
299
 
349
  return $links;
350
  }
351
 
352
+ function ai_set_plugin_meta ($links, $file) {
353
+ if ($file == plugin_basename (__FILE__)) {
354
+ if (is_multisite() && !is_main_site ()) {
355
+ foreach ($links as $index => $link) {
356
+ if (stripos ($link, "update") !== false) unset ($links [$index]);
357
+ }
358
+ }
359
+ // if (stripos (AD_INSERTER_TITLE, "pro") === false) {
360
+ // $new_links = array ('donate' => '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank">Donate</a>');
361
+ // $links = array_merge ($links, $new_links);
362
+ // }
363
+ }
364
+ return $links;
365
+ }
366
+
367
  function ai_current_user_role_ok () {
368
  $role_values = array ("super-admin" => 6, "administrator" => 5, "editor" => 4, "author" => 3, "contributor" => 2, "subscriber" => 1);
369
  global $wp_roles;
403
  foreach ($screens as $screen) {
404
  add_meta_box (
405
  'adinserter_sectionid',
406
+ AD_INSERTER_TITLE.' Exceptions',
407
  'ai_meta_box_callback',
408
  $screen
409
  );
501
  echo '</tbody>';
502
  echo '</table>';
503
 
504
+ echo '<p>Default behavior for all code blocks for ', $post_type, 's (enabled or disabled) can be configured on <a href="/wp-admin/options-general.php?page=ad-inserter.php" target="_blank">', AD_INSERTER_TITLE, ' Settings page</a>. Here you can configure exceptions for this ', $post_type, '.</p>';
505
  }
506
 
507
  function ai_save_meta_box_data_hook ($post_id) {
558
  }
559
  }
560
 
561
+ function ai_check_plugin_options ($plugin_options = array ()) {
562
 
563
  $version_array = explode (".", AD_INSERTER_VERSION);
564
  $version_string = "";
596
  $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport;
597
 
598
  if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] =
599
+ defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : "";
600
 
601
  if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '')
602
  $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1");
740
  $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number;
741
 
742
  if (!isset ($plugin_db_options [$viewport_settins_name])) {
743
+ $plugin_db_options [$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : "";
744
  }
745
 
746
  return ($plugin_db_options [$viewport_settins_name]);
847
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
848
  $ad = new ai_Block ($block);
849
 
850
+ if (isset ($ai_db_options [$block])) $saved_settings = $ai_db_options [$block]; else
851
+ $saved_settings = $ad->wp_options;
852
+
853
  $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . $block;
854
  if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
 
855
 
856
  $exported_settings = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_" . $block])));
857
  if ($exported_settings !== false) {
880
  }
881
  }
882
 
883
+ if (isset ($_POST [AI_OPTION_NAME . WP_FORM_FIELD_POSTFIX . $block]))
884
+ $ai_options [$block] = $ad->wp_options; else
885
+ $ai_options [$block] = $saved_settings;
886
 
887
  delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
888
  }
909
 
910
  $options = array ();
911
 
912
+ if (function_exists ('ai_filter_global_settings')) ai_filter_global_settings ($options);
913
+
914
  $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
915
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
916
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
924
  $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
925
  }
926
 
927
+ $ai_options [AI_GLOBAL_OPTION_NAME] = ai_check_plugin_options ($options);
928
  }
929
 
930
  if (!empty ($invalid_blocks)) {
931
  if ($invalid_blocks [0] == 0) {
932
+ echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing ", AD_INSERTER_TITLE, " settings.</div>";
933
  } else echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing settings for block", count ($invalid_blocks) == 1 ? "" : "s:", " ", implode (", ", $invalid_blocks), ".</div>";
934
  }
935
 
951
  $style = '';
952
  if (count ($viewports) != 0) {
953
  $style .= "/* " . AD_INSERTER_TITLE . " version " . AD_INSERTER_VERSION ." - viewport classes */\n\n";
954
+ $style .= "/* DO NOT MODIFY - This file is automatically generated when you save ".AD_INSERTER_TITLE." settings */\n";
955
  foreach ($viewports as $index => $viewport) {
956
  $style .= "\n/* " . $viewport ['name'] . " */\n\n";
957
  if ($viewport ['index'] == 1) {
1010
 
1011
  $ai_options [AI_HEADER_OPTION_NAME] = $adH->wp_options;
1012
  $ai_options [AI_FOOTER_OPTION_NAME] = $adF->wp_options;
1013
+ $ai_options [AI_GLOBAL_OPTION_NAME] = ai_check_plugin_options ();
1014
  update_option (WP_OPTION_NAME, $ai_options);
1015
 
1016
  // Reload options
1029
  echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Settings cleared.</div>";
1030
  }
1031
 
1032
+ generate_settings_form ();
1033
  }
1034
 
1035
 
1058
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1059
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
1060
 
 
 
1061
  if ($obj->get_detection_server_side ()) {
1062
+ $display_for_devices = $obj->get_display_for_devices ();
1063
+
1064
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1065
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1066
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1153
  $obj = $block_object [$counter];
1154
 
1155
  $display_type = $obj->get_display_type();
 
 
 
 
 
 
 
1156
 
1157
  if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
1158
  $display_type != AD_SELECT_AFTER_PARAGRAPH &&
1164
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1165
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1166
 
 
 
1167
  if ($obj->get_detection_server_side ()) {
1168
+ $display_for_devices = $obj->get_display_for_devices ();
1169
+
1170
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1171
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1172
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1309
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1310
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1311
 
 
 
1312
  if ($obj->get_detection_server_side ()) {
1313
+ $display_for_devices = $obj->get_display_for_devices ();
1314
+
1315
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1316
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1317
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1400
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) continue;
1401
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) continue;
1402
 
 
 
1403
  if ($obj->get_detection_server_side ()) {
1404
+ $display_for_devices = $obj->get_display_for_devices ();
1405
+
1406
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1407
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1408
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1548
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1549
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
1550
 
 
 
1551
  if ($obj->get_detection_server_side ()) {
1552
+ $display_for_devices = $obj->get_display_for_devices ();
1553
+
1554
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1555
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1556
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1592
  function __construct () {
1593
  parent::__construct (
1594
  false, // Base ID
1595
+ AD_INSERTER_TITLE, // Name
1596
  array ( // Args
1597
  'classname' => 'ai_widget',
1598
+ 'description' => AD_INSERTER_TITLE.' code block widget.')
1599
  );
1600
  }
1601
 
1666
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return;
1667
  if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return;
1668
 
 
 
1669
  if ($obj->get_detection_server_side ()) {
1670
+ $display_for_devices = $obj->get_display_for_devices ();
1671
+
1672
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
1673
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
1674
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
class.php CHANGED
@@ -432,8 +432,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
432
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
433
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
434
  $display_type == AD_SELECT_BEFORE_CONTENT ||
435
- $display_type == AD_SELECT_AFTER_CONTENT ||
436
- $display_type == AD_SELECT_NONE)
437
  $option = AD_SETTINGS_NOT_CHECKED;
438
  }
439
 
@@ -454,8 +453,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
454
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
455
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
456
  $display_type == AD_SELECT_BEFORE_CONTENT ||
457
- $display_type == AD_SELECT_AFTER_CONTENT ||
458
- $display_type == AD_SELECT_NONE)
459
  $option = AD_SETTINGS_NOT_CHECKED;
460
  }
461
 
@@ -476,8 +474,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
476
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
477
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
478
  $display_type == AD_SELECT_BEFORE_CONTENT ||
479
- $display_type == AD_SELECT_AFTER_CONTENT ||
480
- $display_type == AD_SELECT_NONE)
481
  $option = AD_SETTINGS_NOT_CHECKED;
482
  }
483
 
@@ -498,8 +495,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
498
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
499
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
500
  $display_type == AD_SELECT_BEFORE_CONTENT ||
501
- $display_type == AD_SELECT_AFTER_CONTENT ||
502
- $display_type == AD_SELECT_NONE)
503
  $option = AD_SETTINGS_NOT_CHECKED;
504
  }
505
 
432
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
433
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
434
  $display_type == AD_SELECT_BEFORE_CONTENT ||
435
+ $display_type == AD_SELECT_AFTER_CONTENT)
 
436
  $option = AD_SETTINGS_NOT_CHECKED;
437
  }
438
 
453
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
454
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
455
  $display_type == AD_SELECT_BEFORE_CONTENT ||
456
+ $display_type == AD_SELECT_AFTER_CONTENT)
 
457
  $option = AD_SETTINGS_NOT_CHECKED;
458
  }
459
 
474
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
475
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
476
  $display_type == AD_SELECT_BEFORE_CONTENT ||
477
+ $display_type == AD_SELECT_AFTER_CONTENT)
 
478
  $option = AD_SETTINGS_NOT_CHECKED;
479
  }
480
 
495
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
496
  $display_type == AD_SELECT_AFTER_PARAGRAPH ||
497
  $display_type == AD_SELECT_BEFORE_CONTENT ||
498
+ $display_type == AD_SELECT_AFTER_CONTENT)
 
499
  $option = AD_SETTINGS_NOT_CHECKED;
500
  }
501
 
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.5');
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.6');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
js/ad-inserter.js CHANGED
@@ -65,7 +65,7 @@ SyntaxHighlight.prototype.applySettings = function () {
65
 
66
  jQuery(document).ready(function($) {
67
 
68
- var header = $('#ai_settings_header').length != 0;
69
  var header_id = 'name';
70
 
71
  function configure_editor_language (block) {
@@ -156,9 +156,10 @@ jQuery(document).ready(function($) {
156
  });
157
  }
158
 
159
- var blocks = $('#ai-form').attr('blocks');
 
160
 
161
- for (block = 1; block <= blocks; block ++) {
162
  configure_editor (block);
163
  }
164
 
@@ -170,17 +171,17 @@ jQuery(document).ready(function($) {
170
  $('#ai-tab-container a').css ("width", "14px").css ("text-align", "center");
171
  $('#ai-tabs').css ("padding", ".2em 0 0 .6em");
172
 
173
- var active_tab = $("#ai-active-tab").attr ("value");
174
  var tab_index = $('#ai-tab-container a[href="#tab-'+active_tab+'"]').parent().index();
175
  $("#ai-tab-container").tabs("option", "active", tab_index);
176
 
177
  $('.ai-tab').click (function () {
178
- tab_index = $(this).attr ("id");
179
- tab_index = tab_index.replace ("ai-tab","");
180
- $("#ai-active-tab").attr ("value", tab_index);
181
 
182
- if (tab_index != 0) {
183
- var editor = ace.edit ("editor-" + tab_index);
184
  editor.getSession ().highlightLines (10000000);
185
  }
186
  });
@@ -193,12 +194,15 @@ jQuery(document).ready(function($) {
193
 
194
  $('#ai-settings').tooltip();
195
 
 
 
 
196
  $('#dummy-tabs').hide();
197
  $('#ai-tabs').show();
198
 
199
  $('#ai-settings input[type=submit], #ai-settings button').button().show ();
200
 
201
- for (ad_block = 1; ad_block <= blocks; ad_block++) {
202
  $("select#display-type-"+ad_block).change (function() {
203
  block = $(this).attr('id').replace ("display-type-", "");
204
  process_display_elements (block);
@@ -255,23 +259,23 @@ jQuery(document).ready(function($) {
255
  },
256
  text: false
257
  }).show ().click (function () {
258
- tab_index = $(this).attr ("id");
259
- tab_index = tab_index.replace ("export-switch-","");
260
- $("#export-container-" + tab_index).toggle ();
261
  });
262
 
263
  $("#device-detection-button-"+ad_block).button ({
264
  }).show ().click (function () {
265
- tab_index = $(this).attr ("id");
266
- tab_index = tab_index.replace ("device-detection-button-","");
267
- $("#device-detection-container-" + tab_index).toggle ();
268
  });
269
 
270
  $("#lists-button-"+ad_block).button ({
271
  }).show ().click (function () {
272
- tab_index = $(this).attr ("id");
273
- tab_index = tab_index.replace ("lists-button-","");
274
- $("#lists-container-" + tab_index).toggle ();
275
  });
276
 
277
  }
65
 
66
  jQuery(document).ready(function($) {
67
 
68
+ var header = $('#ai-settings-' + 'header').length != 0;
69
  var header_id = 'name';
70
 
71
  function configure_editor_language (block) {
156
  });
157
  }
158
 
159
+ var start = parseInt ($('#ai-form').attr('start'));
160
+ var end = parseInt ($('#ai-form').attr('end'));
161
 
162
+ for (block = start; block <= end; block ++) {
163
  configure_editor (block);
164
  }
165
 
171
  $('#ai-tab-container a').css ("width", "14px").css ("text-align", "center");
172
  $('#ai-tabs').css ("padding", ".2em 0 0 .6em");
173
 
174
+ var active_tab = parseInt ($("#ai-active-tab").attr ("value"));
175
  var tab_index = $('#ai-tab-container a[href="#tab-'+active_tab+'"]').parent().index();
176
  $("#ai-tab-container").tabs("option", "active", tab_index);
177
 
178
  $('.ai-tab').click (function () {
179
+ tab_block = $(this).attr ("id");
180
+ tab_block = tab_block.replace ("ai-tab","");
181
+ $("#ai-active-tab").attr ("value", tab_block);
182
 
183
+ if (tab_block != 0) {
184
+ var editor = ace.edit ("editor-" + tab_block);
185
  editor.getSession ().highlightLines (10000000);
186
  }
187
  });
194
 
195
  $('#ai-settings').tooltip();
196
 
197
+ $('#dummy-ranges').hide();
198
+ $('#ai-ranges').show();
199
+
200
  $('#dummy-tabs').hide();
201
  $('#ai-tabs').show();
202
 
203
  $('#ai-settings input[type=submit], #ai-settings button').button().show ();
204
 
205
+ for (ad_block = start; ad_block <= end; ad_block++) {
206
  $("select#display-type-"+ad_block).change (function() {
207
  block = $(this).attr('id').replace ("display-type-", "");
208
  process_display_elements (block);
259
  },
260
  text: false
261
  }).show ().click (function () {
262
+ tab_block = $(this).attr ("id");
263
+ tab_block = tab_block.replace ("export-switch-","");
264
+ $("#export-container-" + tab_block).toggle ();
265
  });
266
 
267
  $("#device-detection-button-"+ad_block).button ({
268
  }).show ().click (function () {
269
+ tab_block = $(this).attr ("id");
270
+ tab_block = tab_block.replace ("device-detection-button-","");
271
+ $("#device-detection-container-" + tab_block).toggle ();
272
  });
273
 
274
  $("#lists-button-"+ad_block).button ({
275
  }).show ().click (function () {
276
+ tab_block = $(this).attr ("id");
277
+ tab_block = tab_block.replace ("lists-button-","");
278
+ $("#lists-container-" + tab_block).toggle ();
279
  });
280
 
281
  }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, 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.5.3
7
- Stable tag: 1.6.4
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.
@@ -49,6 +49,22 @@ Order of display positions in a typical post is the following:
49
 
50
  Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab #).
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  **Please Note** Paragraph processing works on **every** post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts,
53
  Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Excerpt/Post number(s). You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.
54
 
@@ -163,7 +179,7 @@ Leave referrers list empty and set it to Black list to show ads for all referrer
163
 
164
  **WARNING:** If you are using caching, referer check may not work as expected. It works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
165
 
166
- For all display positions you can also define Wordpress page types where the ads can be displayed:
167
 
168
  Single pages:
169
 
@@ -194,10 +210,6 @@ Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which
194
 
195
  To configure syntax highlighting go to Ad Inserter Settings (tab #) and choose theme.
196
 
197
- You can also easily copy settings from one block to another. Click on the Import/Export icon next to the Save button. Select encoded settings for the source block, copy them to the clipboard and paste them into the same field of the destination block. Check the **Import settings** checkbox for the destination block and save settings. Please note that the block name is not imported, what you put in the name field will be saved.
198
-
199
- You can also copy complete Ad Inserter settings from one website to another. Go to settings tab (#) and click on the Import/Export icon next to the Save button. Select encoded settings for the source website, copy them to the clipboard and then paste them into the same field of the destination website. Check the **Import settings** checkbox for the destination website and save settings.
200
-
201
  By default Ad Inserter exceptions on posts/pages are enabled only for administrators. You can define minimum user role for page/post Ad Inserter exceptions editing in Ad Inserter Settings (tab #).
202
 
203
  Default Ad Inserter plugin processing order is 99999. It is used to specify the order in which the plugin functions are executed. Lower numbers correspond with earlier execution. You can change this value if you have problems with the processing order of other plugins.
@@ -212,19 +224,38 @@ Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/
212
  **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check and server-side detection works only when the page is generated and Ad Inserter is called.
213
  In such cases please make sure you have disabled caching when you are using such settings.
214
 
215
- **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
216
- Before you report problem please check source code of the page and make sure the code is not inserted where it should be.
217
- The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position.
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  == Installation ==
220
 
221
- Automatic installation: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
222
 
223
- Manual installation:
224
 
225
- 1. Download and extract ad-inserter folder and copy it to the "/wp-content/plugins/" directory
226
- 2. Activate the plugin through the 'Plugins' menu in WordPress
227
- 3. Access Setting / Ad Inserter to configure it
 
 
 
 
 
 
 
228
 
229
  **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page.
230
 
@@ -518,6 +549,11 @@ AD CODE RIGHT
518
 
519
  == Changelog ==
520
 
 
 
 
 
 
521
 
522
  = 1.6.5 =
523
  - Fixed bug: Wrong counting of max insertions
@@ -703,6 +739,12 @@ AD CODE RIGHT
703
 
704
  == Upgrade Notice ==
705
 
 
 
 
 
 
 
706
  = 1.6.5 =
707
  Fixed bug: Wrong counting of max insertions;
708
  Change: display position Before Title was renamed to Before Post;
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, 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: 4.0
6
  Tested up to: 4.5.3
7
+ Stable tag: 1.6.5
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.
49
 
50
  Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab #).
51
 
52
+ For all display positions you can also define Wordpress page types where the ads can be displayed:
53
+
54
+ **PLEASE NOTE:** Regardles of other settings you need to enable display on AT LEAST ONE PAGE TYPE:
55
+
56
+ Single pages:
57
+
58
+ * Posts
59
+ * Pages
60
+
61
+ Blog pages:
62
+
63
+ * Homepage
64
+ * Category pages
65
+ * Search Pages
66
+ * Archive pages
67
+
68
  **Please Note** Paragraph processing works on **every** post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts,
69
  Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Excerpt/Post number(s). You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.
70
 
179
 
180
  **WARNING:** If you are using caching, referer check may not work as expected. It works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
181
 
182
+ **IMPORTANT:** For any display position you should also ENABLE AT LEAST ONE WORDPRESS PAGE TYPE where the ads can be displayed:
183
 
184
  Single pages:
185
 
210
 
211
  To configure syntax highlighting go to Ad Inserter Settings (tab #) and choose theme.
212
 
 
 
 
 
213
  By default Ad Inserter exceptions on posts/pages are enabled only for administrators. You can define minimum user role for page/post Ad Inserter exceptions editing in Ad Inserter Settings (tab #).
214
 
215
  Default Ad Inserter plugin processing order is 99999. It is used to specify the order in which the plugin functions are executed. Lower numbers correspond with earlier execution. You can change this value if you have problems with the processing order of other plugins.
224
  **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check and server-side detection works only when the page is generated and Ad Inserter is called.
225
  In such cases please make sure you have disabled caching when you are using such settings.
226
 
227
+ **SUPPORT**
228
+
229
+ If you experience problems with the Ad Inserter plugin you can ask for help on the <a href ="https://wordpress.org/support/plugin/ad-inserter">support forum</a>.
230
+ However, in order to be able to diagnose the problem and suggest actions or fix a bug, please do the following:
231
+
232
+ 0. Some code for ads may not display anything, either because of errors in the ad code or because of ad network issues. Before you report problem please check source code of the page and make sure the code is not inserted where it should be. The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position. If you are sure that there is something wrong ***you need to provide the following**:
233
+
234
+ 1. Clear description of the problem. Describe what does not work as expected.
235
+
236
+ 2. Screenshot(s) of the settings
237
+
238
+ 3. Web addresses (links) of the pages where the code from the settings above is not inserted properly.
239
+
240
+ Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help.
241
+ Thank you very much for understanding.
242
 
243
  == Installation ==
244
 
245
+ **Automatic installation**: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
246
 
247
+ **Manual installation**:
248
 
249
+ 1. Download the plugin,
250
+ 2. Go to Wordpress Plugins, Add New, Upload Plugin
251
+ 3. Choose file, click on Install Now, activate it
252
+ 3. Go to Setting / Ad Inserter to configure it
253
+
254
+ **Ad Inserter Pro Installation**
255
+
256
+ If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
257
+ After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to Wordpress Plugins, Add New, Upload Plugin, Choose file, click on Install Now,
258
+ activate it and then click "Enter License Key" and enter license key you got in the email. If you need to edit license key go to Ad Inserter settings (tab #).
259
 
260
  **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page.
261
 
549
 
550
  == Changelog ==
551
 
552
+ = 1.6.6 =
553
+ - Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
554
+ - Few minor cosmetic changes
555
+ - Requirements changed to WordPress 4.0 or newer
556
+ - Added initial support for Pro version
557
 
558
  = 1.6.5 =
559
  - Fixed bug: Wrong counting of max insertions
739
 
740
  == Upgrade Notice ==
741
 
742
+ = 1.6.6 =
743
+ Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
744
+ Few minor cosmetic changes;
745
+ Requirements changed to WordPress 4.0 or newer;
746
+ Added initial support for Pro version
747
+
748
  = 1.6.5 =
749
  Fixed bug: Wrong counting of max insertions;
750
  Change: display position Before Title was renamed to Before Post;
settings.php CHANGED
@@ -2,18 +2,19 @@
2
 
3
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
- if (file_exists (AD_INSERTER_PLUGIN_DIR.'functions.php')) {
6
- include_once AD_INSERTER_PLUGIN_DIR.'functions.php';
7
- }
8
-
9
- function print_settings_form (){
10
  global $ai_db_options, $block_object;
11
 
12
- if (isset ($_GET ['subpage'])) $subpage = $_GET ['subpage']; else $subpage = 'main';
 
 
 
13
 
14
- $active_tab = isset ($_POST ['ai-active-tab']) ? $_POST ['ai-active-tab'] : 1;
 
15
  if (!is_numeric ($active_tab)) $active_tab = 1;
16
- if ($active_tab < 0 || $active_tab > AD_INSERTER_BLOCKS) $active_tab = 1;
 
17
 
18
  $adH = new ai_AdH();
19
  $adF = new ai_AdF();
@@ -58,14 +59,11 @@ function print_settings_form (){
58
  <div style="width: 735px; padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
59
  <?php
60
  if (function_exists ('ai_settings_header')) ai_settings_header (); else { ?>
61
- <div style="float: right; margin: 7px 20px 0 0; text-decoration: none;">
62
- <a style="text-decoration: none;" href="http://igorfuna.com/contact/contact-igor-funa" target="_blank">Contact Author</a> #
63
- <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank">Donate</a> #
64
- <a style="text-decoration: none;" href="http://tinymonitor.com/" target="_blank">AdSense and Amazon Monitor</a> #
65
- <a style="text-decoration: none;" href="http://igorfuna.com/wordpress-hosting" target="_blank">Cool Wordpress Hosting</a>
66
  </div>
67
- <div style="float: right; text-align: right; margin: 2px 18px 2px 0;">
68
- If you find the <span style="font-weight: bold;"><?php echo AD_INSERTER_TITLE; ?></span> plugin useful, <span style="font-weight: bold;color: #0a0;">please rate it</span> on the <a style="text-decoration: none;" href="http://wordpress.org/plugins/ad-inserter/" target="_blank">plugin directory page</a>.
69
  </div>
70
  <h2><?php echo AD_INSERTER_TITLE . ' ' . AD_INSERTER_VERSION ?></h2>
71
  <?php
@@ -138,14 +136,14 @@ function print_settings_form (){
138
  </form>
139
  <?php
140
  } else {
 
141
  ?>
142
-
143
- <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
144
  <div id="ai-tab-container" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
145
- <div id="dummy-tabs" style="height: <?php echo intval ((AD_INSERTER_BLOCKS + 1) / 17 + 0.9) * 29; ?>px; padding: .2em .2em 0; border: 1px solid white;"></div>
146
  <ul id="ai-tabs" style="display: none;">
147
  <?php
148
- for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
149
  $obj = $block_object [$ad_number];
150
 
151
  $ad_name = $obj->get_ad_name();
@@ -168,16 +166,19 @@ function print_settings_form (){
168
  </ul>
169
 
170
  <?php
171
- for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
172
  $obj = $block_object [$ad_number];
173
 
174
  $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
 
175
 
176
  $cat_list = $obj->get_ad_block_cat();
177
  $tag_list = $obj->get_ad_block_tag();
178
  $url_list = $obj->get_ad_url_list();
179
  $domain_list = $obj->get_ad_domain_list();
180
  $show_lists = $cat_list != '' || $tag_list != '' || $url_list != '' || $domain_list != '';
 
 
181
  ?>
182
 
183
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
@@ -186,7 +187,7 @@ function print_settings_form (){
186
  </div>
187
 
188
  <div style="float: right; padding: 1px 5px;">
189
- <button id="export-switch-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
190
  <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
191
  </div>
192
 
@@ -194,18 +195,7 @@ function print_settings_form (){
194
  Block Name: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="100" />
195
  </div>
196
 
197
- <div id="export-container-<?php echo $ad_number; ?>" style="display: none; padding:8px;">
198
- <div style="display: inline-block; padding: 2px 10px; float: right;">
199
- <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
200
- <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="import-<?php echo $ad_number; ?>" />
201
- <label for="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Import settings when saving - if checked, the encoded settings below will be imported for this block">Import Settings for block <?php echo $ad_number; ?></label>
202
- </div>
203
-
204
- <div style="float: left; padding-left:10px;">
205
- Saved settings for block <?php echo $ad_number, " (", $obj->get_ad_name(); ?>)
206
- </div>
207
- <textarea id="export_settings_<?php echo $ad_number; ?>" name="export_settings_<?php echo $ad_number; ?>" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 324px;"><?php echo base64_encode (serialize ($obj->wp_options)); ?></textarea>
208
- </div>
209
 
210
  <div style="display: inline-block; padding: 1px 10px; float: right;">
211
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
@@ -213,7 +203,8 @@ function print_settings_form (){
213
  </div>
214
 
215
  <div style="display: inline-block; padding: 1px 10px; float: right;">
216
- <input type="checkbox" style="border-radius: 5px;" name="simple-editor-<?php echo $ad_number; ?>" value="0" id="simple-editor-<?php echo $ad_number; ?>" /> <label for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor">Simple editor</label>
 
217
  </div>
218
 
219
  <div style="padding-left:16px;">
@@ -249,8 +240,8 @@ function print_settings_form (){
249
  users
250
 
251
  <div style="float: right;">
252
- <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)">Devices</button>
253
- <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="White/Black-list Category, Tag, Url or Referer (domain)">Lists</button>
254
  </div>
255
  </div>
256
 
@@ -503,24 +494,13 @@ function print_settings_form (){
503
  </div>
504
 
505
  <div style="float: right; padding: 1px 5px;">
506
- <button id="export-switch-0" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
507
  <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="width:120px; font-weight: bold;" />
508
  </div>
509
 
510
  <div style="clear: both;"></div>
511
 
512
- <div id="export-container-0" style="display: none; padding: 8px;">
513
- <div style="display: inline-block; padding: 2px 10px; float: right;">
514
- <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="0" />
515
- <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="1" id="import-0" />
516
- <label for="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" title="Import Ad Inserter settings when saving - if checked, the encoded settings below will be imported for all blocks and settings">Import Settings for Ad Inserter</label>
517
- </div>
518
-
519
- <div style="float: left; padding-left:10px;">
520
- Saved settings for Ad Inserter
521
- </div>
522
- <textarea id="export_settings_0" name="export_settings_0" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 324px;"><?php echo base64_encode (serialize ($ai_db_options)); ?></textarea>
523
- </div>
524
 
525
  <div style="padding:0px 0px 8px 16px;">
526
  Syntax Highlighter Theme:&nbsp;&nbsp;&nbsp;
@@ -658,7 +638,8 @@ function print_settings_form (){
658
  </div>
659
 
660
  <div style="display: inline-block; padding: 1px 10px; float: right;">
661
- <input type="checkbox" style="border-radius: 5px;" name="simple-editor-h" value="0" id="simple-editor-h" /> <label for="simple-editor-h" title="Simple editor">Simple editor</label>
 
662
  </div>
663
 
664
  <div style="padding-left:16px;">
@@ -696,7 +677,8 @@ function print_settings_form (){
696
  </div>
697
 
698
  <div style="display: inline-block; padding: 1px 10px; float: right;">
699
- <input type="checkbox" style="border-radius: 5px;" name="simple-editor-f" value="0" id="simple-editor-f" /> <label for="simple-editor-f" title="Simple editor">Simple editor</label>
 
700
  </div>
701
 
702
  <div style="padding-left:16px;">
2
 
3
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
+ function generate_settings_form (){
 
 
 
 
6
  global $ai_db_options, $block_object;
7
 
8
+ $subpage = 'main';
9
+ $start = 1;
10
+ $end = 16;
11
+ if (function_exists ('ai_settings_parameters')) ai_settings_parameters ($subpage, $start, $end);
12
 
13
+ if (isset ($_GET ['tab'])) $active_tab = $_GET ['tab']; else
14
+ $active_tab = isset ($_POST ['ai-active-tab']) ? $_POST ['ai-active-tab'] : 1;
15
  if (!is_numeric ($active_tab)) $active_tab = 1;
16
+ if ($active_tab != 0)
17
+ if ($active_tab < $start || $active_tab > $end) $active_tab = $start;
18
 
19
  $adH = new ai_AdH();
20
  $adF = new ai_AdF();
59
  <div style="width: 735px; padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
60
  <?php
61
  if (function_exists ('ai_settings_header')) ai_settings_header (); else { ?>
62
+ <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
63
+ If you find this plugin useful, please write a nice review on the <a style="text-decoration: none;" href="https://wordpress.org/support/view/plugin-reviews/ad-inserter" target="_blank">Plugin Reviews</a> page.
 
 
 
64
  </div>
65
+ <div style="float: right; text-align: right; margin: 0px 18px 0px 0;">
66
+ You can also <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank">donate</a> to support plugin development.
67
  </div>
68
  <h2><?php echo AD_INSERTER_TITLE . ' ' . AD_INSERTER_VERSION ?></h2>
69
  <?php
136
  </form>
137
  <?php
138
  } else {
139
+ if (function_exists ('ai_settings_ranges')) ai_settings_ranges ($start, $active_tab);
140
  ?>
141
+ <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" start="<?php echo $start; ?>" end="<?php echo $end; ?>">
 
142
  <div id="ai-tab-container" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
143
+ <div id="dummy-tabs" style="height: <?php echo 29;//intval ((AD_INSERTER_BLOCKS + 1) / 17 + 0.9) * 29; ?>px; padding: .2em .2em 0;"></div>
144
  <ul id="ai-tabs" style="display: none;">
145
  <?php
146
+ for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
147
  $obj = $block_object [$ad_number];
148
 
149
  $ad_name = $obj->get_ad_name();
166
  </ul>
167
 
168
  <?php
169
+ for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
170
  $obj = $block_object [$ad_number];
171
 
172
  $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
173
+ if ($show_devices) $devices_style = "font-weight: bold; color: #e44;"; else $devices_style = "";
174
 
175
  $cat_list = $obj->get_ad_block_cat();
176
  $tag_list = $obj->get_ad_block_tag();
177
  $url_list = $obj->get_ad_url_list();
178
  $domain_list = $obj->get_ad_domain_list();
179
  $show_lists = $cat_list != '' || $tag_list != '' || $url_list != '' || $domain_list != '';
180
+ if ($show_lists) $lists_style = "font-weight: bold; color: #e44;"; else $lists_style = "";
181
+
182
  ?>
183
 
184
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
187
  </div>
188
 
189
  <div style="float: right; padding: 1px 5px;">
190
+ <?php if (function_exists ('ai_settings_buttons')) ai_settings_buttons ($ad_number); ?>
191
  <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
192
  </div>
193
 
195
  Block Name: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="100" />
196
  </div>
197
 
198
+ <?php if (function_exists ('ai_settings_container')) ai_settings_container ($ad_number, $obj); ?>
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  <div style="display: inline-block; padding: 1px 10px; float: right;">
201
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
203
  </div>
204
 
205
  <div style="display: inline-block; padding: 1px 10px; float: right;">
206
+ <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-<?php echo $ad_number; ?>" />
207
+ <label for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor">Simple editor</label>
208
  </div>
209
 
210
  <div style="padding-left:16px;">
240
  users
241
 
242
  <div style="float: right;">
243
+ <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
244
+ <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="White/Black-list Category, Tag, Url or Referer (domain)"><span style="<?php echo $lists_style; ?>">Lists</span></button>
245
  </div>
246
  </div>
247
 
494
  </div>
495
 
496
  <div style="float: right; padding: 1px 5px;">
497
+ <?php if (function_exists ('ai_settings_global_buttons')) ai_settings_global_buttons (); ?>
498
  <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="width:120px; font-weight: bold;" />
499
  </div>
500
 
501
  <div style="clear: both;"></div>
502
 
503
+ <?php if (function_exists ('ai_global_settings')) ai_global_settings (); ?>
 
 
 
 
 
 
 
 
 
 
 
504
 
505
  <div style="padding:0px 0px 8px 16px;">
506
  Syntax Highlighter Theme:&nbsp;&nbsp;&nbsp;
638
  </div>
639
 
640
  <div style="display: inline-block; padding: 1px 10px; float: right;">
641
+ <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-h" />
642
+ <label for="simple-editor-h" title="Simple editor">Simple editor</label>
643
  </div>
644
 
645
  <div style="padding-left:16px;">
677
  </div>
678
 
679
  <div style="display: inline-block; padding: 1px 10px; float: right;">
680
+ <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-f" />
681
+ <label for="simple-editor-f" title="Simple editor">Simple editor</label>
682
  </div>
683
 
684
  <div style="padding-left:16px;">