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

Version Description

  • Bug fix: Shortcodes did not ignore post/static page exceptions
  • Slightly redesigned user interface
  • Excerpt/Post number(s) renamed to Filter as it now works on all display positions
  • Widget setting removed from Automatic display to Manual display section
  • Added support to disable widgets (standalone checkbox in Manual display)
  • Added call counter/filter for widgets
  • Added support to edit CSS for predefined styles
  • Few other minor bug fixes, code improvements and cosmetic changes
Download this release

Release Info

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

Code changes from version 1.6.7 to 1.7.0

Files changed (7) hide show
  1. ad-inserter.php +143 -78
  2. class.php +114 -78
  3. constants.php +7 -4
  4. js/ad-inserter.js +134 -31
  5. preview.php +319 -0
  6. readme.txt +115 -55
  7. settings.php +368 -188
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 1.6.7
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: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,16 @@ Plugin URI: http://tinymonitor.com/ad-inserter
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
 
 
 
 
14
  Ad Inserter 1.6.7 - 9 August 2016
15
  - Bug fix: Block code textarea was not escaped
16
  - Added checks for page types for shortcodes
@@ -225,6 +235,7 @@ if (version_compare ($wp_version, "4.0", "<")) {
225
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
226
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
227
  require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
 
228
 
229
  $ad_interter_globals = array ();
230
 
@@ -289,7 +300,9 @@ if ($client_side_detection) {
289
  }
290
 
291
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
292
- add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
 
 
293
 
294
  function ai_init_hook() {
295
  global $block_object;
@@ -309,7 +322,7 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
309
  global $ai_settings_page;
310
 
311
  if ($hook_suffix == $ai_settings_page) {
312
- wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip'), filemtime (plugin_dir_path (__FILE__ ).'js/ad-inserter.js'));
313
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
314
  wp_enqueue_style ('ad-inserter', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
315
 
@@ -492,9 +505,9 @@ function ai_meta_box_callback ($post) {
492
 
493
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
494
  if ($individual_option_enabled)
495
- echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
496
 
497
- echo '<label for="adinserter_selected_block_', $block, '">';
498
  if ($individual_option_enabled) {
499
  if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
500
  }
@@ -830,6 +843,20 @@ function filter_option_hf ($option, $value){
830
  return $value;
831
  }
832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
  function ai_settings () {
834
  global $ai_db_options, $block_object;
835
 
@@ -940,6 +967,8 @@ function ai_settings () {
940
  } 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>";
941
  }
942
 
 
 
943
  update_option (WP_OPTION_NAME, $ai_options);
944
 
945
  // Reload options
@@ -1128,7 +1157,7 @@ function adinserter ($ad_number = ""){
1128
 
1129
  if (!$obj->check_referer ()) return "";
1130
 
1131
- $counter_settings = $obj->get_excerpt_number();
1132
  $numbers = array ();
1133
  if (strpos ($counter_settings, ",") !== false) {
1134
  $numbers = explode (",", $counter_settings);
@@ -1237,7 +1266,7 @@ function ai_content_hook ($content = ''){
1237
  }
1238
 
1239
  if ($blog_page) {
1240
- $counter_settings = $obj->get_excerpt_number();
1241
  $numbers = array ();
1242
  if (strpos ($counter_settings, ",") !== false) {
1243
  $numbers = explode (",", $counter_settings);
@@ -1299,6 +1328,8 @@ function ai_content_hook ($content = ''){
1299
  function ai_excerpt_hook ($content = ''){
1300
  global $ad_interter_globals, $block_object;
1301
 
 
 
1302
  if (!isset ($ad_interter_globals ['EXCERPT'])) {
1303
  $ad_interter_globals ['EXCERPT'] = 1;
1304
  } else $ad_interter_globals ['EXCERPT'] ++;
@@ -1327,7 +1358,7 @@ function ai_excerpt_hook ($content = ''){
1327
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
1328
  }
1329
 
1330
- $counter_settings = $obj->get_excerpt_number();
1331
  $numbers = array ();
1332
  if (strpos ($counter_settings, ",") !== false) {
1333
  $numbers = explode (",", $counter_settings);
@@ -1475,15 +1506,15 @@ function ai_before_after_post ($query, $display_type){
1475
 
1476
  if (!$obj->check_referer ()) continue;
1477
 
1478
- if (!$obj->check_and_increment_block_counter ()) continue;
1479
-
1480
- $counter_settings = $obj->get_excerpt_number();
1481
  $numbers = array ();
1482
  if (strpos ($counter_settings, ",") !== false) {
1483
  $numbers = explode (",", $counter_settings);
1484
  } else $numbers []= $counter_settings;
1485
  if ($counter_settings != 0 && !in_array ($ad_interter_globals [$globals_name], $numbers)) continue;
1486
 
 
 
1487
  $block_class_name = get_block_class_name ();
1488
 
1489
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code .= ai_getAdCode ($obj); else
@@ -1543,6 +1574,7 @@ function process_shortcodes ($atts) {
1543
  $parameters = shortcode_atts (array (
1544
  "block" => "",
1545
  "name" => "",
 
1546
  ), $atts);
1547
  if (is_numeric ($parameters ['block'])) $block = intval ($parameters ['block']); else $block = 0;
1548
  if ($block < 1 && $block > AD_INSERTER_BLOCKS) {
@@ -1559,84 +1591,98 @@ function process_shortcodes ($atts) {
1559
  }
1560
  }
1561
 
1562
- if ($block != 0) {
1563
- $obj = $block_object [$block];
1564
-
1565
- if ($obj->get_enable_manual ()) {
1566
- $display_for_users = $obj->get_display_for_users ();
1567
 
1568
- if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1569
- if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
 
1570
 
1571
- if ($obj->get_detection_server_side ()) {
1572
- $display_for_devices = $obj->get_display_for_devices ();
 
 
1573
 
1574
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1575
- if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1576
- if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1577
- if ($display_for_devices == AD_DISPLAY_PHONE_DEVICES && !AI_PHONE) return "";
1578
- if ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES && !(AI_DESKTOP || AI_TABLET)) return "";
1579
- if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return "";
1580
- }
1581
 
1582
- if (is_front_page ()){
1583
- if (!$obj->get_display_settings_home()) return "";
1584
- if (!$obj->check_date ()) return "";
1585
- } else if (is_single ()) {
1586
- if (!$obj->get_display_settings_post ()) return "";
1587
- if (!$obj->check_date ()) return "";
1588
 
1589
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
1590
- $selected_blocks = explode (",", $meta_value);
1591
 
1592
- $enabled_on_text = $obj->get_ad_enabled_on_which_posts ();
1593
- if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
1594
- if (in_array ($obj->number, $selected_blocks)) return "";
1595
- }
1596
- elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
1597
- if (!in_array ($obj->number, $selected_blocks)) return "";
1598
- }
1599
- } elseif (is_page ()) {
1600
- if (!$obj->get_display_settings_page ()) return "";
1601
 
1602
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
1603
- $selected_blocks = explode (",", $meta_value);
1604
 
1605
- $enabled_on_text = $obj->get_ad_enabled_on_which_pages ();
1606
- if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
1607
- if (in_array ($obj->number, $selected_blocks)) return "";
1608
- }
1609
- elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
1610
- if (!in_array ($obj->number, $selected_blocks)) return "";
1611
- }
1612
- } elseif (is_category()){
1613
- if (!$obj->get_display_settings_category()) return "";
1614
- } elseif (is_search()){
1615
- if (!$obj->get_display_settings_search()) return "";
1616
- } elseif (is_archive()){
1617
- if (!$obj->get_display_settings_archive()) return "";
1618
- } elseif (is_404()){
1619
- if (!$obj->get_enable_404()) return "";
1620
- }
1621
 
1622
- if (!$obj->check_url ()) return "";
 
 
 
 
1623
 
1624
- if (!$obj->check_referer ()) return "";
 
 
1625
 
1626
- if (!$obj->check_category ()) return "";
 
 
 
 
 
 
 
1627
 
1628
- if (!$obj->check_tag ()) return "";
 
 
1629
 
1630
- if (!$obj->check_and_increment_block_counter ()) return "";
 
 
1631
 
1632
- $block_class_name = get_block_class_name ();
 
 
 
 
 
 
 
1633
 
1634
- if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1635
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1636
- return ($ad_code);
1637
- }
 
 
 
 
1638
  }
1639
- return "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1640
  }
1641
 
1642
 
@@ -1675,7 +1721,9 @@ class ai_widget extends WP_Widget {
1675
  $obj = $block_object [$block];
1676
 
1677
  $title = '[' . $block . '] ' . $obj->get_ad_name();
1678
- if (!empty ($widget_title)) $title .= ' - ' . $widget_title
 
 
1679
 
1680
  ?>
1681
  <input id="<?php echo $this->get_field_id ('title'); ?>" name="<?php echo $this->get_field_name ('title'); ?>" type="hidden" value="<?php echo esc_attr ($title); ?>">
@@ -1692,11 +1740,16 @@ class ai_widget extends WP_Widget {
1692
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
1693
  $obj = $block_object [$block_index];
1694
  ?>
1695
- <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $obj->get_ad_name(); ?></option>
1696
  <?php } ?>
1697
  </select>
1698
  </p>
 
1699
  <?php
 
 
 
 
1700
  }
1701
 
1702
  function update ($new_instance, $old_instance) {
@@ -1713,6 +1766,13 @@ class ai_widget extends WP_Widget {
1713
 
1714
 
1715
  function ai_widget_draw ($block, $obj, $args, $title = '') {
 
 
 
 
 
 
 
1716
 
1717
  $display_for_users = $obj->get_display_for_users ();
1718
 
@@ -1730,8 +1790,6 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1730
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return;
1731
  }
1732
 
1733
- // if ($obj->get_display_type () != AD_SELECT_WIDGET) return;
1734
-
1735
  //if empty data, continue next
1736
  if($obj->get_ad_data()==AD_EMPTY_DATA){
1737
  return;
@@ -1789,6 +1847,13 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1789
 
1790
  if (!$obj->check_referer ()) return;
1791
 
 
 
 
 
 
 
 
1792
  if (!$obj->check_and_increment_block_counter ()) return;
1793
 
1794
  $block_class_name = get_block_class_name ();
@@ -1802,7 +1867,7 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1802
  }
1803
 
1804
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) echo ai_getAdCode ($obj); else
1805
- echo "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . "' style='" . $obj->get_alignmet_style (false) . "'>" . ai_getAdCode ($obj) . "</div>";
1806
 
1807
  echo $args ['after_widget'];
1808
  if ($viewport_classes != "") echo "</div>";
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 1.7.0
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: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 1.7.0 - 16 August 2016
15
+ - Bug fix: Shortcodes did not ignore post/static page exceptions
16
+ - Slightly redesigned user interface
17
+ - Excerpt/Post number(s) renamed to Filter as it now works on all display positions
18
+ - Widget setting removed from Automatic display to Manual display section
19
+ - Added support to disable widgets (standalone checkbox in Manual display)
20
+ - Added call counter/filter for widgets
21
+ - Added support to edit CSS for predefined styles
22
+ - Few other minor bug fixes, code improvements and cosmetic changes
23
+
24
  Ad Inserter 1.6.7 - 9 August 2016
25
  - Bug fix: Block code textarea was not escaped
26
  - Added checks for page types for shortcodes
235
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
236
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
237
  require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
238
+ require_once AD_INSERTER_PLUGIN_DIR.'preview.php';
239
 
240
  $ad_interter_globals = array ();
241
 
300
  }
301
 
302
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
303
+ add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
304
+ add_action ('wp_ajax_ai_preview', 'ai_preview');
305
+ add_action ('wp_ajax_nopriv_ai_preview', 'ai_preview');
306
 
307
  function ai_init_hook() {
308
  global $block_object;
322
  global $ai_settings_page;
323
 
324
  if ($hook_suffix == $ai_settings_page) {
325
+ wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip', 'jquery-ui-dialog'), AD_INSERTER_VERSION);
326
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
327
  wp_enqueue_style ('ad-inserter', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
328
 
505
 
506
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
507
  if ($individual_option_enabled)
508
+ echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
509
 
510
+ echo '<label for="ai-selected-block-', $block, '">';
511
  if ($individual_option_enabled) {
512
  if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
513
  }
843
  return $value;
844
  }
845
 
846
+ function ai_preview () {
847
+
848
+ check_admin_referer ("adinserter_preview", "ai_check");
849
+
850
+ if (isset ($_GET ["ai_code"])) {
851
+ $block = $_GET ["ai_code"];
852
+ if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
853
+ generate_code_preview ($block);
854
+ }
855
+ }
856
+
857
+ die ();
858
+ }
859
+
860
  function ai_settings () {
861
  global $ai_db_options, $block_object;
862
 
967
  } 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>";
968
  }
969
 
970
+ $ai_options [AI_GLOBAL_OPTION_NAME]['TIMESTAMP'] = time ();
971
+
972
  update_option (WP_OPTION_NAME, $ai_options);
973
 
974
  // Reload options
1157
 
1158
  if (!$obj->check_referer ()) return "";
1159
 
1160
+ $counter_settings = $obj->get_call_filter();
1161
  $numbers = array ();
1162
  if (strpos ($counter_settings, ",") !== false) {
1163
  $numbers = explode (",", $counter_settings);
1266
  }
1267
 
1268
  if ($blog_page) {
1269
+ $counter_settings = $obj->get_call_filter();
1270
  $numbers = array ();
1271
  if (strpos ($counter_settings, ",") !== false) {
1272
  $numbers = explode (",", $counter_settings);
1328
  function ai_excerpt_hook ($content = ''){
1329
  global $ad_interter_globals, $block_object;
1330
 
1331
+ if (strpos ($_SERVER ['REQUEST_URI'], '/wp-admin/') === 0) return;
1332
+
1333
  if (!isset ($ad_interter_globals ['EXCERPT'])) {
1334
  $ad_interter_globals ['EXCERPT'] = 1;
1335
  } else $ad_interter_globals ['EXCERPT'] ++;
1358
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
1359
  }
1360
 
1361
+ $counter_settings = $obj->get_call_filter();
1362
  $numbers = array ();
1363
  if (strpos ($counter_settings, ",") !== false) {
1364
  $numbers = explode (",", $counter_settings);
1506
 
1507
  if (!$obj->check_referer ()) continue;
1508
 
1509
+ $counter_settings = $obj->get_call_filter();
 
 
1510
  $numbers = array ();
1511
  if (strpos ($counter_settings, ",") !== false) {
1512
  $numbers = explode (",", $counter_settings);
1513
  } else $numbers []= $counter_settings;
1514
  if ($counter_settings != 0 && !in_array ($ad_interter_globals [$globals_name], $numbers)) continue;
1515
 
1516
+ if (!$obj->check_and_increment_block_counter ()) continue;
1517
+
1518
  $block_class_name = get_block_class_name ();
1519
 
1520
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code .= ai_getAdCode ($obj); else
1574
  $parameters = shortcode_atts (array (
1575
  "block" => "",
1576
  "name" => "",
1577
+ "ignore" => "",
1578
  ), $atts);
1579
  if (is_numeric ($parameters ['block'])) $block = intval ($parameters ['block']); else $block = 0;
1580
  if ($block < 1 && $block > AD_INSERTER_BLOCKS) {
1591
  }
1592
  }
1593
 
1594
+ if ($block == 0) return "";
 
 
 
 
1595
 
1596
+ // IGNORE SETTINGS
1597
+ // page_type
1598
+ // *block_counter
1599
 
1600
+ $ignore_array = array ();
1601
+ if (trim ($parameters ['ignore']) != '') {
1602
+ $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore']));
1603
+ }
1604
 
1605
+ $obj = $block_object [$block];
 
 
 
 
 
 
1606
 
1607
+ if (!$obj->get_enable_manual ()) return "";
 
 
 
 
 
1608
 
1609
+ $display_for_users = $obj->get_display_for_users ();
 
1610
 
1611
+ if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1612
+ if ($display_for_users == AD_DISPLAY_NOT_LOGGED_IN_USERS && is_user_logged_in ()) return "";
 
 
 
 
 
 
 
1613
 
1614
+ if ($obj->get_detection_server_side ()) {
1615
+ $display_for_devices = $obj->get_display_for_devices ();
1616
 
1617
+ if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1618
+ if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1619
+ if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1620
+ if ($display_for_devices == AD_DISPLAY_PHONE_DEVICES && !AI_PHONE) return "";
1621
+ if ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES && !(AI_DESKTOP || AI_TABLET)) return "";
1622
+ if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return "";
1623
+ }
 
 
 
 
 
 
 
 
 
1624
 
1625
+ if (is_front_page ()){
1626
+ if (!$obj->get_display_settings_home() && !in_array ("page_type", $ignore_array)) return "";
1627
+ } else if (is_single ()) {
1628
+ if (!$obj->get_display_settings_post () && !in_array ("page_type", $ignore_array)) return "";
1629
+ if (!$obj->check_date ()) return "";
1630
 
1631
+ //// Exceptions are only for automatic insertion
1632
+ // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
1633
+ // $selected_blocks = explode (",", $meta_value);
1634
 
1635
+ // $enabled_on_text = $obj->get_ad_enabled_on_which_posts ();
1636
+ // if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
1637
+ // if (in_array ($obj->number, $selected_blocks)) return "";
1638
+ // }
1639
+ // elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
1640
+ // if (!in_array ($obj->number, $selected_blocks)) return "";
1641
+ // }
1642
+ ////
1643
 
1644
+ } elseif (is_page ()) {
1645
+ if (!$obj->get_display_settings_page () && !in_array ("page_type", $ignore_array)) return "";
1646
+ if (!$obj->check_date ()) return "";
1647
 
1648
+ //// Exceptions are only for automatic insertion
1649
+ // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
1650
+ // $selected_blocks = explode (",", $meta_value);
1651
 
1652
+ // $enabled_on_text = $obj->get_ad_enabled_on_which_pages ();
1653
+ // if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
1654
+ // if (in_array ($obj->number, $selected_blocks)) return "";
1655
+ // }
1656
+ // elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
1657
+ // if (!in_array ($obj->number, $selected_blocks)) return "";
1658
+ // }
1659
+ ////
1660
 
1661
+ } elseif (is_category()){
1662
+ if (!$obj->get_display_settings_category() && !in_array ("page_type", $ignore_array)) return "";
1663
+ } elseif (is_search()){
1664
+ if (!$obj->get_display_settings_search() && !in_array ("page_type", $ignore_array)) return "";
1665
+ } elseif (is_archive()){
1666
+ if (!$obj->get_display_settings_archive() && !in_array ("page_type", $ignore_array)) return "";
1667
+ } elseif (is_404()){
1668
+ if (!$obj->get_enable_404() && !in_array ("page_type", $ignore_array)) return "";
1669
  }
1670
+
1671
+ if (!$obj->check_url ()) return "";
1672
+
1673
+ if (!$obj->check_referer ()) return "";
1674
+
1675
+ if (!$obj->check_category ()) return "";
1676
+
1677
+ if (!$obj->check_tag ()) return "";
1678
+
1679
+ if (!$obj->check_and_increment_block_counter ()) return "";
1680
+
1681
+ $block_class_name = get_block_class_name ();
1682
+
1683
+ if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1684
+ $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1685
+ return ($ad_code);
1686
  }
1687
 
1688
 
1721
  $obj = $block_object [$block];
1722
 
1723
  $title = '[' . $block . '] ' . $obj->get_ad_name();
1724
+ if (!empty ($widget_title)) $title .= ' - ' . $widget_title;
1725
+
1726
+ if (!$obj->get_enable_widget ()) $title .= ' - DISABLED'
1727
 
1728
  ?>
1729
  <input id="<?php echo $this->get_field_id ('title'); ?>" name="<?php echo $this->get_field_name ('title'); ?>" type="hidden" value="<?php echo esc_attr ($title); ?>">
1740
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
1741
  $obj = $block_object [$block_index];
1742
  ?>
1743
+ <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $obj->get_ad_name(), !$obj->get_enable_widget ()? ' - DISABLED' : ''; ?></option>
1744
  <?php } ?>
1745
  </select>
1746
  </p>
1747
+
1748
  <?php
1749
+ $url_parameters = "";
1750
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block);
1751
+
1752
+ echo "<p><a href='", admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, "&tab=", $block, "'>Settings</a></p>";
1753
  }
1754
 
1755
  function update ($new_instance, $old_instance) {
1766
 
1767
 
1768
  function ai_widget_draw ($block, $obj, $args, $title = '') {
1769
+ global $ad_interter_globals;
1770
+
1771
+ if (!isset ($ad_interter_globals ['WIDGET_COUNTER_'.$block])) {
1772
+ $ad_interter_globals ['WIDGET_COUNTER_'.$block] = 1;
1773
+ } else $ad_interter_globals ['WIDGET_COUNTER_'.$block] ++;
1774
+
1775
+ if (!$obj->get_enable_widget ()) return;
1776
 
1777
  $display_for_users = $obj->get_display_for_users ();
1778
 
1790
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return;
1791
  }
1792
 
 
 
1793
  //if empty data, continue next
1794
  if($obj->get_ad_data()==AD_EMPTY_DATA){
1795
  return;
1847
 
1848
  if (!$obj->check_referer ()) return;
1849
 
1850
+ $counter_settings = $obj->get_call_filter();
1851
+ $numbers = array ();
1852
+ if (strpos ($counter_settings, ",") !== false) {
1853
+ $numbers = explode (",", $counter_settings);
1854
+ } else $numbers []= $counter_settings;
1855
+ if ($counter_settings != 0 && !in_array ($ad_interter_globals ['WIDGET_COUNTER_'.$block], $numbers)) return;
1856
+
1857
  if (!$obj->check_and_increment_block_counter ()) return;
1858
 
1859
  $block_class_name = get_block_class_name ();
1867
  }
1868
 
1869
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) echo ai_getAdCode ($obj); else
1870
+ echo "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . "' style='" . $obj->get_alignmet_style (0) . "'>" . ai_getAdCode ($obj) . "</div>";
1871
 
1872
  echo $args ['after_widget'];
1873
  if ($viewport_classes != "") echo "</div>";
class.php CHANGED
@@ -254,63 +254,65 @@ abstract class ai_BaseCodeBlock {
254
 
255
  abstract class ai_CodeBlock extends ai_BaseCodeBlock {
256
 
257
- var $number;
258
 
259
- function __construct () {
260
 
261
- $this->number = 0;
262
 
263
- parent::__construct();
264
 
265
- $this->wp_options [AI_OPTION_NAME] = AD_NAME;
266
- $this->wp_options [AI_OPTION_DISPLAY_TYPE] = AD_SELECT_NONE;
267
- $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
268
- $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_ZERO;
269
- $this->wp_options [AI_OPTION_MIN_WORDS] = AD_ZERO;
270
- $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] = AD_ZERO;
271
- $this->wp_options [AI_OPTION_PARAGRAPH_TAGS] = DEFAULT_PARAGRAPH_TAGS;
272
- $this->wp_options [AI_OPTION_EXCERPT_NUMBER] = AD_ZERO;
273
- $this->wp_options [AI_OPTION_DIRECTION_TYPE] = AD_DIRECTION_FROM_TOP;
274
- $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] = AD_ALIGNMENT_NONE;
275
- $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
276
- $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_ZERO;
277
- $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_ZERO;
278
- $this->wp_options [AI_OPTION_URL_LIST] = AD_EMPTY_DATA;
279
- $this->wp_options [AI_OPTION_URL_LIST_TYPE] = AD_BLACK_LIST;
280
- $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
281
- $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
282
- $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
283
- $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
284
- $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
285
- $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
286
- $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AD_SETTINGS_CHECKED;
287
- $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AD_SETTINGS_NOT_CHECKED;
288
- $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AD_SETTINGS_NOT_CHECKED;
289
- $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
290
- $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
291
- $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
292
- $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
293
- $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
294
- $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AD_SETTINGS_NOT_CHECKED;
295
- $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
296
- $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
297
- $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
298
- $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
299
- $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
300
- $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AD_SETTINGS_NOT_CHECKED;
301
- $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AD_SETTINGS_NOT_CHECKED;
302
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
303
- $this->wp_options [AI_OPTION_DETECT_VIEWPORT . '_' . $viewport] = AD_SETTINGS_NOT_CHECKED;
304
- }
305
  }
 
306
 
307
- public function get_display_type(){
308
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE]) ? $this->wp_options [AI_OPTION_DISPLAY_TYPE] : "";
309
- if ($option == '') $option = AD_SELECT_NONE;
310
- elseif ($option == AD_SELECT_MANUAL) $option = AD_SELECT_NONE;
311
- elseif ($option == AD_SELECT_BEFORE_TITLE) $option = AD_SELECT_BEFORE_POST;
312
- return $option;
313
- }
 
314
 
315
  public function get_paragraph_number(){
316
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
@@ -341,7 +343,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
341
  return $option;
342
  }
343
 
344
- public function get_excerpt_number(){
345
  $option = isset ($this->wp_options [AI_OPTION_EXCERPT_NUMBER]) ? $this->wp_options [AI_OPTION_EXCERPT_NUMBER] : "";
346
  if ($option == '') $option = AD_ZERO;
347
  return $option;
@@ -368,43 +370,37 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
368
  return $option;
369
  }
370
 
371
- public function get_alignmet_style ($margin = true){
372
- if ($this->get_alignment_type() == AD_ALIGNMENT_LEFT) {
373
- if ($margin)
374
- $style = "text-align:left;margin:8px 0px;"; else
375
- $style = "text-align:left;";
376
  }
377
- elseif ($this->get_alignment_type() == AD_ALIGNMENT_RIGHT) {
378
- if ($margin)
379
- $style = "text-align:right;margin:8px 0px;"; else
380
- $style = "text-align:right;";
381
  }
382
- elseif ($this->get_alignment_type() == AD_ALIGNMENT_CENTER) {
383
- if ($margin)
384
- $style = "text-align:center;margin-left:auto;margin-right:auto;margin-top:8px;margin-bottom:8px;"; else
385
- $style = "text-align:center;margin-left:auto;margin-right:auto;";
386
  }
387
- elseif ($this->get_alignment_type() == AD_ALIGNMENT_FLOAT_LEFT) {
388
- if ($margin)
389
- $style = "float:left;margin:8px 8px 8px 0px;"; else
390
- $style = "float:left;";
391
  }
392
- elseif ($this->get_alignment_type() == AD_ALIGNMENT_FLOAT_RIGHT) {
393
- if ($margin)
394
- $style = "float:right;margin:8px 0px 8px 8px;"; else
395
- $style = "float:right;";
396
  }
397
- elseif ($this->get_alignment_type() == AD_ALIGNMENT_CUSTOM_CSS) {
398
  $style = $this->get_custom_css ();
399
  }
400
  else {
401
- if ($margin)
402
- $style = "margin:8px 0px;"; else
403
- $style = "margin:0;";
404
  }
405
 
406
  return $style;
407
- }
 
 
 
 
408
 
409
  public function get_display_settings_post(){
410
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
@@ -513,6 +509,46 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
513
  return $option;
514
  }
515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  public function get_enable_php_call (){
517
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_PHP_CALL]) ? $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] : "";
518
  if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
254
 
255
  abstract class ai_CodeBlock extends ai_BaseCodeBlock {
256
 
257
+ var $number;
258
 
259
+ function __construct () {
260
 
261
+ $this->number = 0;
262
 
263
+ parent::__construct();
264
 
265
+ $this->wp_options [AI_OPTION_NAME] = AD_NAME;
266
+ $this->wp_options [AI_OPTION_DISPLAY_TYPE] = AD_SELECT_NONE;
267
+ $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
268
+ $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_ZERO;
269
+ $this->wp_options [AI_OPTION_MIN_WORDS] = AD_ZERO;
270
+ $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] = AD_ZERO;
271
+ $this->wp_options [AI_OPTION_PARAGRAPH_TAGS] = DEFAULT_PARAGRAPH_TAGS;
272
+ $this->wp_options [AI_OPTION_EXCERPT_NUMBER] = AD_ZERO;
273
+ $this->wp_options [AI_OPTION_DIRECTION_TYPE] = AD_DIRECTION_FROM_TOP;
274
+ $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] = AD_ALIGNMENT_NONE;
275
+ $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
276
+ $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_ZERO;
277
+ $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_ZERO;
278
+ $this->wp_options [AI_OPTION_URL_LIST] = AD_EMPTY_DATA;
279
+ $this->wp_options [AI_OPTION_URL_LIST_TYPE] = AD_BLACK_LIST;
280
+ $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
281
+ $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
282
+ $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
283
+ $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
284
+ $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
285
+ $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
286
+ $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AD_SETTINGS_CHECKED;
287
+ $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AD_SETTINGS_NOT_CHECKED;
288
+ $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AD_SETTINGS_NOT_CHECKED;
289
+ $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
290
+ $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
291
+ $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
292
+ $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
293
+ $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
294
+ $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AD_SETTINGS_NOT_CHECKED;
295
+ $this->wp_options [AI_OPTION_ENABLE_WIDGET] = AD_SETTINGS_CHECKED;
296
+ $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
297
+ $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
298
+ $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
299
+ $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
300
+ $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
301
+ $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AD_SETTINGS_NOT_CHECKED;
302
+ $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AD_SETTINGS_NOT_CHECKED;
303
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
304
+ $this->wp_options [AI_OPTION_DETECT_VIEWPORT . '_' . $viewport] = AD_SETTINGS_NOT_CHECKED;
305
  }
306
+ }
307
 
308
+ public function get_display_type(){
309
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE]) ? $this->wp_options [AI_OPTION_DISPLAY_TYPE] : "";
310
+ if ($option == '') $option = AD_SELECT_NONE;
311
+ elseif ($option == AD_SELECT_MANUAL) $option = AD_SELECT_NONE;
312
+ elseif ($option == AD_SELECT_BEFORE_TITLE) $option = AD_SELECT_BEFORE_POST;
313
+ elseif ($option == AD_SELECT_WIDGET) $option = AD_SELECT_NONE;
314
+ return $option;
315
+ }
316
 
317
  public function get_paragraph_number(){
318
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
343
  return $option;
344
  }
345
 
346
+ public function get_call_filter(){
347
  $option = isset ($this->wp_options [AI_OPTION_EXCERPT_NUMBER]) ? $this->wp_options [AI_OPTION_EXCERPT_NUMBER] : "";
348
  if ($option == '') $option = AD_ZERO;
349
  return $option;
370
  return $option;
371
  }
372
 
373
+ public function alignmet_style ($alignment_type, $margin = DEFAULT_MARGIN){
374
+ if ($margin < 0) $margin = 0;
375
+
376
+ if ($alignment_type == AD_ALIGNMENT_LEFT) {
377
+ $style = "text-align: left; margin: ".$margin."px 0px;";
378
  }
379
+ elseif ($alignment_type == AD_ALIGNMENT_RIGHT) {
380
+ $style = "text-align: right; margin: ".$margin."px 0px;";
 
 
381
  }
382
+ elseif ($alignment_type == AD_ALIGNMENT_CENTER) {
383
+ $style = "text-align: center; margin: ".$margin."px auto;";
 
 
384
  }
385
+ elseif ($alignment_type == AD_ALIGNMENT_FLOAT_LEFT) {
386
+ $style = "float: left; margin: ".$margin."px ".$margin."px ".$margin."px 0px;";
 
 
387
  }
388
+ elseif ($alignment_type == AD_ALIGNMENT_FLOAT_RIGHT) {
389
+ $style = "float: right; margin: ".$margin."px 0px ".$margin."px ".$margin."px;";
 
 
390
  }
391
+ elseif ($alignment_type == AD_ALIGNMENT_CUSTOM_CSS) {
392
  $style = $this->get_custom_css ();
393
  }
394
  else {
395
+ $style = "margin: ".$margin."px 0px;";
 
 
396
  }
397
 
398
  return $style;
399
+ }
400
+
401
+ public function get_alignmet_style ($margin = DEFAULT_MARGIN){
402
+ return $this->alignmet_style ($this->get_alignment_type(), $margin);
403
+ }
404
 
405
  public function get_display_settings_post(){
406
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
509
  return $option;
510
  }
511
 
512
+ public function get_enable_widget (){
513
+ global $ai_db_options;
514
+
515
+ $enable_widget = isset ($this->wp_options [AI_OPTION_ENABLE_WIDGET]) ? $this->wp_options [AI_OPTION_ENABLE_WIDGET] : "";
516
+
517
+ // if ($ai_db_options ['global']['VERSION'] < '010608') {
518
+ // if (isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE]) && $this->wp_options [AI_OPTION_DISPLAY_TYPE] == AD_SELECT_WIDGET) $enable_widget = AD_SETTINGS_CHECKED;
519
+ // else {
520
+ // // Check for block not set for Widgets but at least one Ad Inserter widget is used
521
+ // $sidebar_widgets = wp_get_sidebars_widgets();
522
+ // $widget_options = get_option ('widget_ai_widget');
523
+ // foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
524
+ // if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
525
+ // $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
526
+ // if ($sidebar_name != "") {
527
+ // foreach ($sidebar_widget as $widget) {
528
+ // if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
529
+ // if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
530
+ // $widget_option = $widget_options [$widget_id [1]];
531
+ // $widget_block = $widget_option ['block'];
532
+ // if ($widget_block == $this->number) {
533
+ // $enable_widget = AD_SETTINGS_CHECKED;
534
+ // break 2;
535
+ // }
536
+ // }
537
+ // }
538
+ // }
539
+ // }
540
+ // }
541
+ // }
542
+ // }
543
+ // }
544
+
545
+ // if ($enable_widget == '') $enable_widget = AD_SETTINGS_NOT_CHECKED;
546
+
547
+ if ($enable_widget == '') $enable_widget = AD_SETTINGS_CHECKED;
548
+
549
+ return $enable_widget;
550
+ }
551
+
552
  public function get_enable_php_call (){
553
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_PHP_CALL]) ? $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] : "";
554
  if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
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.7');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
@@ -49,7 +49,7 @@ if (!defined ('WP_PLUGIN_DIR'))
49
  define ('AD_EMPTY_DATA', '');
50
  define ('AD_ZERO', '0');
51
  define ('AD_ONE', '1');
52
- define ('AD_GENERAL_TAG', 'gadgets');
53
  define ('AD_NAME', 'Block');
54
 
55
  // Old options
@@ -65,6 +65,7 @@ define ('AI_FOOTER_OPTION_NAME', 'f');
65
 
66
  define ('AI_OPTION_CODE', 'code');
67
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
 
68
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
69
  define ('AI_OPTION_ENABLE_404', 'enable_404');
70
 
@@ -135,10 +136,10 @@ define('AD_SELECT_BEFORE_CONTENT','Before Content');
135
  define('AD_SELECT_AFTER_CONTENT','After Content');
136
  define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
137
  define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
138
- define('AD_SELECT_WIDGET','Widget');
139
 
 
140
  define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
141
- define('AD_SELECT_MANUAL','Manual'); // Deprecated
142
 
143
  //Display options
144
  define('AD_DISPLAY_ALL_USERS','all');
@@ -184,6 +185,8 @@ define('AD_DO_NOT_CONTAIN','do not contain');
184
  define('AD_SETTINGS_CHECKED', '1');
185
  define('AD_SETTINGS_NOT_CHECKED', '0');
186
 
 
 
187
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
188
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
189
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
11
  define ('AD_INSERTER_TITLE', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '1.7.0');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
49
  define ('AD_EMPTY_DATA', '');
50
  define ('AD_ZERO', '0');
51
  define ('AD_ONE', '1');
52
+ define ('AD_GENERAL_TAG', 'wordpress');
53
  define ('AD_NAME', 'Block');
54
 
55
  // Old options
65
 
66
  define ('AI_OPTION_CODE', 'code');
67
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
68
+ define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
69
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
70
  define ('AI_OPTION_ENABLE_404', 'enable_404');
71
 
136
  define('AD_SELECT_AFTER_CONTENT','After Content');
137
  define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
138
  define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
 
139
 
140
+ define('AD_SELECT_WIDGET','Widget'); // Deprecated
141
  define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
142
+ define('AD_SELECT_MANUAL','Manual'); // Deprecated
143
 
144
  //Display options
145
  define('AD_DISPLAY_ALL_USERS','all');
185
  define('AD_SETTINGS_CHECKED', '1');
186
  define('AD_SETTINGS_NOT_CHECKED', '0');
187
 
188
+ define('DEFAULT_MARGIN', 8);
189
+
190
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
191
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
192
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
js/ad-inserter.js CHANGED
@@ -81,44 +81,62 @@ jQuery(document).ready(function($) {
81
 
82
  $("#paragraph-settings-"+block).hide();
83
 
84
- $("#blog-page-settings-"+block).hide();
85
-
86
  var display_type = '';
87
  $("select#display-type-"+block+" option:selected").each(function() {
88
  display_type += $(this).text();
89
  });
 
90
  if (display_type == "Before Paragraph" || display_type == "After Paragraph") {
91
  $("#paragraph-settings-"+block).show();
92
- if ($("#display-homepage-"+block).is(":checked") ||
93
- $("#display-category-"+block).is(":checked") ||
94
- $("#display-search-"+block).is(":checked") ||
95
- $("#display-archive-"+block).is(":checked"))
96
- $("#blog-page-settings-"+block).show();
97
- } else
98
- if (display_type == "Before Excerpt" || display_type == "After Excerpt") {
99
- $("#paragraph-settings-"+block).hide();
100
- $("#blog-page-settings-"+block).show();
101
- } else
102
- if (display_type == "Before Post" || display_type == "After Post") {
103
- $("#blog-page-settings-"+block).show();
104
  }
105
 
106
- if ($("#enable-php-call-"+block).is(":checked")) {
107
- $("#blog-page-settings-"+block).show();
108
- }
109
 
110
- $("#no-wrapping-warning").hide();
111
  $("#custom-css-"+block).hide();
 
 
 
 
 
 
 
 
112
 
113
  var alignment = '';
114
  $("select#block-alignment-"+block+" option:selected").each(function() {
115
  alignment += $(this).text();
116
  });
 
 
 
 
 
 
 
 
 
 
 
117
  if (alignment == "Custom CSS") {
 
118
  $("#custom-css-"+block).show();
119
  } else
120
- if (alignment == "No Wrapping" && $("#client-side-detection-"+block).is(":checked")) {
121
- $("#no-wrapping-warning").show();
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
 
124
  configure_editor_language (block);
@@ -218,8 +236,8 @@ jQuery(document).ready(function($) {
218
  block = $(this).attr('id').replace ("process-php-", "");
219
  process_display_elements (block);
220
  });
221
- $("#enable-manual-"+ad_block).change (function() {
222
- block = $(this).attr('id').replace ("enable-manual-", "");
223
  process_display_elements (block);
224
  });
225
  $("#enable-php-call-"+ad_block).change (function() {
@@ -255,6 +273,64 @@ jQuery(document).ready(function($) {
255
 
256
  process_display_elements (ad_block);
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  $("#export-switch-"+ad_block).button ({
259
  icons: {
260
  primary: "ui-icon-gear",
@@ -262,25 +338,52 @@ jQuery(document).ready(function($) {
262
  },
263
  text: false
264
  }).show ().click (function () {
265
- tab_block = $(this).attr ("id");
266
- tab_block = tab_block.replace ("export-switch-","");
267
- $("#export-container-" + tab_block).toggle ();
268
  });
269
 
270
  $("#device-detection-button-"+ad_block).button ({
271
  }).show ().click (function () {
272
- tab_block = $(this).attr ("id");
273
- tab_block = tab_block.replace ("device-detection-button-","");
274
- $("#device-detection-container-" + tab_block).toggle ();
275
  });
276
 
277
  $("#lists-button-"+ad_block).button ({
278
  }).show ().click (function () {
279
- tab_block = $(this).attr ("id");
280
- tab_block = tab_block.replace ("lists-button-","");
281
- $("#lists-container-" + tab_block).toggle ();
282
  });
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  }
285
 
286
  $("#export-switch-0").button ({
81
 
82
  $("#paragraph-settings-"+block).hide();
83
 
 
 
84
  var display_type = '';
85
  $("select#display-type-"+block+" option:selected").each(function() {
86
  display_type += $(this).text();
87
  });
88
+
89
  if (display_type == "Before Paragraph" || display_type == "After Paragraph") {
90
  $("#paragraph-settings-"+block).show();
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
+ $("#css-label-"+block).css('display', 'inline-block');
94
+ $("#edit-css-button-"+block).css('display', 'inline-block');
 
95
 
96
+ $("#css-none-"+block).hide();
97
  $("#custom-css-"+block).hide();
98
+ $("#css-left-"+block).hide();
99
+ $("#css-right-"+block).hide();
100
+ $("#css-center-"+block).hide();
101
+ $("#css-float-left-"+block).hide();
102
+ $("#css-float-right-"+block).hide();
103
+ $("#css-no-wrapping-"+block).hide();
104
+
105
+ $("#no-wrapping-warning-"+block).hide();
106
 
107
  var alignment = '';
108
  $("select#block-alignment-"+block+" option:selected").each(function() {
109
  alignment += $(this).text();
110
  });
111
+ if (alignment == "No Wrapping") {
112
+ $("#css-no-wrapping-"+block).css('display', 'inline-block');
113
+ $("#css-label-"+block).hide();
114
+ $("#edit-css-button-"+block).hide();
115
+ if ($("#client-side-detection-"+block).is(":checked")) {
116
+ $("#no-wrapping-warning-"+block).show();
117
+ }
118
+ } else
119
+ if (alignment == "None") {
120
+ $("#css-none-"+block).css('display', 'inline-block');
121
+ } else
122
  if (alignment == "Custom CSS") {
123
+ $("#css-code-" + block).show();
124
  $("#custom-css-"+block).show();
125
  } else
126
+ if (alignment == "Align Left") {
127
+ $("#css-left-"+block).css('display', 'inline-block');
128
+ } else
129
+ if (alignment == "Align Right") {
130
+ $("#css-right-"+block).css('display', 'inline-block');
131
+ } else
132
+ if (alignment == "Center") {
133
+ $("#css-center-"+block).css('display', 'inline-block');
134
+ } else
135
+ if (alignment == "Float Left") {
136
+ $("#css-float-left-"+block).css('display', 'inline-block');
137
+ } else
138
+ if (alignment == "Float Right") {
139
+ $("#css-float-right-"+block).css('display', 'inline-block');
140
  }
141
 
142
  configure_editor_language (block);
236
  block = $(this).attr('id').replace ("process-php-", "");
237
  process_display_elements (block);
238
  });
239
+ $("#enable-shortcode-"+ad_block).change (function() {
240
+ block = $(this).attr('id').replace ("enable-shortcode-", "");
241
  process_display_elements (block);
242
  });
243
  $("#enable-php-call-"+ad_block).change (function() {
273
 
274
  process_display_elements (ad_block);
275
 
276
+ $("#widgets-button-"+ad_block).button ({
277
+ }).click (function () {
278
+ window.location.href = "widgets.php";
279
+ });
280
+
281
+ $("#show-css-button-"+ad_block).button ({
282
+ }).show ().click (function () {
283
+ block = $(this).attr ("id");
284
+ block = block.replace ("show-css-button-","");
285
+ $("#css-code-" + block).toggle ();
286
+ });
287
+
288
+ $("#edit-css-button-"+ad_block).button ({
289
+ }).click (function () {
290
+ block = $(this).attr('id').replace ("edit-css-button-", "");
291
+
292
+ $("#css-left-"+block).hide();
293
+ $("#css-right-"+block).hide();
294
+ $("#css-center-"+block).hide();
295
+ $("#css-float-left-"+block).hide();
296
+ $("#css-float-right-"+block).hide();
297
+
298
+ var alignment = '';
299
+ $("select#block-alignment-"+block+" option:selected").each(function() {
300
+ alignment += $(this).text();
301
+ });
302
+ if (alignment == "None") {
303
+ $("#css-none-"+block).hide();
304
+ $("#custom-css-"+block).show().val ($("#css-none-"+block).text ());
305
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
306
+ } else
307
+ if (alignment == "Align Left") {
308
+ $("#css-left-"+block).hide();
309
+ $("#custom-css-"+block).show().val ($("#css-left-"+block).text ());
310
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
311
+ } else
312
+ if (alignment == "Align Right") {
313
+ $("#css-right-"+block).hide();
314
+ $("#custom-css-"+block).show().val ($("#css-right-"+block).text ());
315
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
316
+ } else
317
+ if (alignment == "Center") {
318
+ $("#css-center-"+block).hide();
319
+ $("#custom-css-"+block).show().val ($("#css-center-"+block).text ());
320
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
321
+ } else
322
+ if (alignment == "Float Left") {
323
+ $("#css-float-left-"+block).hide();
324
+ $("#custom-css-"+block).show().val ($("#css-float-left-"+block).text ());
325
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
326
+ } else
327
+ if (alignment == "Float Right") {
328
+ $("#css-float-right-"+block).hide();
329
+ $("#custom-css-"+block).show().val ($("#css-float-right-"+block).text ());
330
+ $("select#block-alignment-"+block+"").val ("Custom CSS").change();
331
+ }
332
+ });
333
+
334
  $("#export-switch-"+ad_block).button ({
335
  icons: {
336
  primary: "ui-icon-gear",
338
  },
339
  text: false
340
  }).show ().click (function () {
341
+ block = $(this).attr ("id");
342
+ block = block.replace ("export-switch-","");
343
+ $("#export-container-" + block).toggle ();
344
  });
345
 
346
  $("#device-detection-button-"+ad_block).button ({
347
  }).show ().click (function () {
348
+ block = $(this).attr ("id");
349
+ block = block.replace ("device-detection-button-","");
350
+ $("#device-detection-settings-" + block).toggle ();
351
  });
352
 
353
  $("#lists-button-"+ad_block).button ({
354
  }).show ().click (function () {
355
+ block = $(this).attr ("id");
356
+ block = block.replace ("lists-button-","");
357
+ $("#list-settings-" + block).toggle ();
358
  });
359
 
360
+ $("#manual-button-"+ad_block).button ({
361
+ }).show ().click (function () {
362
+ block = $(this).attr ("id");
363
+ block = block.replace ("manual-button-","");
364
+ $("#manual-settings-" + block).toggle ();
365
+ });
366
+
367
+ $("#misc-button-"+ad_block).button ({
368
+ }).show ().click (function () {
369
+ block = $(this).attr ("id");
370
+ block = block.replace ("misc-button-","");
371
+ $("#misc-settings-" + block).toggle ();
372
+ });
373
+
374
+ $("#preview-button-"+ad_block).button ({
375
+ }).show ().click (function () {
376
+ block = $(this).attr ("id");
377
+ block = block.replace ("preview-button-","");
378
+
379
+ var window_width = 820;
380
+ var window_height = 820;
381
+ var nonce = $(this).attr ('nonce');
382
+ var page = "/wp-admin/admin-ajax.php?action=ai_preview&ai_code=" + block + "&ai_check=" + nonce;
383
+ var window_left = (screen.width / 3) - (820 / 2);
384
+ var window_top = (screen.height / 2) - (820 / 2);
385
+ var preview_window = window.open (page, 'toswindow','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
386
+ });
387
  }
388
 
389
  $("#export-switch-0").button ({
preview.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function generate_code_preview ($block) {
4
+
5
+ global $block_object;
6
+
7
+ function margin_css ($style) {
8
+ $style .= ";";
9
+ $clean_style = "border-width: 0; ";
10
+ if (preg_match_all ("/(margin|float)([^;]+)/", strtolower ($style).";", $css)) {
11
+ $clean_style .= implode ("; ", $css [0]) .";";
12
+ }
13
+ $clean_style = str_replace (array ("margin", "auto"), array ("border-width", "0"), $clean_style);
14
+ $clean_style = str_replace (array ("border-width-top", "border-width-right", "border-width-bottom", "border-width-left"),
15
+ array ("border-top-width", "border-right-width", "border-bottom-width", "border-left-width"), $clean_style);
16
+ return trim ($clean_style);
17
+ }
18
+
19
+ function no_margin_css ($style) {
20
+ $clean_style = preg_replace ("/margin([^;]+;?)/", "", $style);
21
+ return trim ($clean_style);
22
+ }
23
+
24
+
25
+
26
+ // $style = "padding-top: 15px; margin-bottom: 25px; margin-top: 10px;";
27
+ // echo $style, "\n";
28
+ // echo no_margin_css ($style), "\n";
29
+
30
+ $obj = $block_object [$block];
31
+
32
+ ?><html>
33
+ <head>
34
+ <title><?php echo AD_INSERTER_TITLE; ?> Code Preview</title>
35
+ <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
36
+ <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
37
+ <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
38
+ <script>
39
+ window.onkeydown = function( event ) {
40
+ if (event.keyCode === 27 ) {
41
+ window.close();
42
+ }
43
+ }
44
+
45
+ jQuery(document).ready(function($) {
46
+
47
+ $("#highlight-button").button ({
48
+ }).click (function () {
49
+
50
+ // $('#margin').toggleClass ("highlighted");
51
+ // $('#code-overlay-background').toggleClass ("highlighted");
52
+ // $('#code-overlay').toggleClass ("highlighted");
53
+ // $('#demo-box').toggle ();
54
+
55
+ $('body').toggleClass ("highlighted");
56
+ $('#demo-box').toggle ();
57
+
58
+ if (!$('body').hasClass ("highlighted")) return;
59
+
60
+ console.log ("highlighting");
61
+
62
+
63
+ var code_overlay_left = 100000;
64
+ var code_overlay_top = 100000;
65
+ var code_overlay_right = 0;
66
+ var code_overlay_bottom = 0;
67
+
68
+ var code_overlay_width = 0;
69
+ var code_overlay_height = 0;
70
+
71
+ // var wrapper = $("#wrapper");
72
+ // var wrapper_offset = {top: 0, left: 0};
73
+ // var wrapper_margin_top = 0;
74
+ // var wrapper_margin_left = 0;
75
+ // var wrapper_border_top = 0;
76
+ // var wrapper_border_left = 0;
77
+ // if (wrapper.length) {
78
+ // wrapper_offset = wrapper.offset ();
79
+ // wrapper_margin_top = parseInt (wrapper.css ('marginTop'));
80
+ // wrapper_margin_left = parseInt (wrapper.css ('marginLeft'));
81
+ // wrapper_border_top = parseInt (wrapper.css ('borderTop'));
82
+ // wrapper_border_left = parseInt (wrapper.css ('borderLeft'));
83
+ // }
84
+
85
+ var code_offset = $('#code').offset ();
86
+
87
+ var code_left = code_offset.left;
88
+ var code_top = code_offset.top;
89
+ var code_width = $('#code').outerWidth (true);
90
+ var code_height = $('#code').outerHeight (true);
91
+
92
+
93
+ // console.log ("wrapper_offset: top: " + wrapper_offset.top + ", left: " + wrapper_offset.left);
94
+ console.log ("code_left: " + code_left);
95
+ console.log ("code_top: " + code_top);
96
+ console.log ("code_width: " + code_width);
97
+ console.log ("code_height: " + code_height);
98
+
99
+ $('#code').children ().each (function () {
100
+
101
+ var element_tag = $(this).prop("tagName").toLowerCase();
102
+
103
+ if (element_tag != 'script') {
104
+
105
+ var element_offset = $(this).offset ();
106
+
107
+ console.log ("");
108
+ console.log ("tag: " + $(this).prop("tagName"));
109
+ console.log ("top: " + element_offset.top);
110
+ console.log ("marginTop: " + $(this).css ('marginTop'));
111
+ console.log ("left: " + element_offset.left);
112
+ console.log ("marginLeft: " + $(this).css ('marginLeft'));
113
+ console.log ("outerWidth: " + $(this).outerWidth (true));
114
+ console.log ("outerHeight: " + $(this).outerHeight (true));
115
+
116
+ var element_left = element_offset.left - parseInt ($(this).css ('marginLeft'));
117
+ var element_width = $(this).outerWidth (true);
118
+ var element_right = element_left + element_width;
119
+
120
+ if (element_left < code_overlay_left) {
121
+ code_overlay_left = element_left;
122
+ }
123
+
124
+ if (element_right > code_overlay_right) {
125
+ code_overlay_right = element_right;
126
+ }
127
+
128
+ var element_top = element_offset.top - parseInt ($(this).css ('marginTop'));
129
+ var element_height = $(this).outerHeight (true);
130
+ var element_bottom = element_top + element_height;
131
+
132
+ if (element_top < code_overlay_top) {
133
+ code_overlay_top = element_top;
134
+ }
135
+
136
+ if (element_bottom > code_overlay_bottom) {
137
+ code_overlay_bottom = element_bottom;
138
+ }
139
+
140
+ console.log ("==============");
141
+ console.log ("code_overlay_top: " + code_overlay_top);
142
+ console.log ("code_overlay_left: " + code_overlay_left);
143
+ console.log ("code_overlay_right: " + code_overlay_right);
144
+ console.log ("code_overlay_bottom: " + code_overlay_bottom);
145
+ }
146
+ });
147
+
148
+ if (code_overlay_left < code_left) code_overlay_left = code_left;
149
+ if (code_overlay_top < code_top) code_overlay_top = code_top;
150
+
151
+ code_overlay_width = code_overlay_right - code_overlay_left;
152
+ code_overlay_height = code_overlay_bottom - code_overlay_top;
153
+
154
+ if (code_overlay_width > code_width) code_overlay_width = code_width;
155
+ if (code_overlay_height > code_height) code_overlay_height = code_height;
156
+
157
+ $('#code-overlay').offset ({top: code_overlay_top, left: code_overlay_left});
158
+ $('#code-overlay').css ('width', code_overlay_width);
159
+ $('#code-overlay').css ('height', code_overlay_height);
160
+
161
+ console.log ("");
162
+ console.log ("==============");
163
+ console.log ('code-overlay: top: ' + $('#code-overlay').offset ().top + ", left: " + $('#code-overlay').offset ().left);
164
+ console.log ("code_overlay_width: " + code_overlay_width);
165
+ console.log ("code_overlay_height: " + code_overlay_height);
166
+
167
+ // $('#code-overlay-background').offset ({top: code_overlay_top - wrapper_offset.top - wrapper_border_top - wrapper_margin_top, left: code_overlay_left - wrapper_offset.left - wrapper_border_left - wrapper_margin_left});
168
+ $('#code-overlay-background').offset ({top: code_overlay_top, left: code_overlay_left});
169
+ $('#code-overlay-background').css ('width', code_overlay_width);
170
+ $('#code-overlay-background').css ('height', code_overlay_height);
171
+
172
+ console.log ("");
173
+ console.log ("--------------");
174
+ console.log ("code-overlay-background: top: " + $('#code-overlay-background').offset ().top + ", left: " + $('#code-overlay-background').offset ().left);
175
+ console.log ("code-overlay-background width: " + code_overlay_width);
176
+ console.log ("code-overlay-background height: " + code_overlay_height);
177
+ });
178
+
179
+ });
180
+
181
+ $(window).resize(function() {
182
+ if ($('body').hasClass ("highlighted"))
183
+ $("#highlight-button").click ();
184
+ });
185
+ </script>
186
+ <style>
187
+ .small-button .ui-button-text-only .ui-button-text {
188
+ padding: 0;
189
+ }
190
+ #margin {
191
+ z-index: 1;
192
+ position: relative;
193
+ border-style: solid;
194
+ border-color: transparent;
195
+ }
196
+ .highlighted #margin {
197
+ border-color: rgba(255, 145, 0, 0.5);
198
+ }
199
+ #wrapper {
200
+ z-index: 1;
201
+ position: relative;
202
+ }
203
+ .highlighted #wrapper {
204
+ background: rgba(50, 220, 140, 0.5);
205
+ }
206
+ #code-overlay-background {
207
+ z-index: 2;
208
+ position: absolute;
209
+ background: #fff;
210
+ display: none;
211
+ }
212
+ .highlighted #code-overlay-background {
213
+ display: inline-block;
214
+ }
215
+ #code {
216
+ z-index: 3;
217
+ display: inline-block;
218
+ width: 100%;
219
+ position: relative;
220
+ }
221
+ #code-overlay {
222
+ z-index: 999999;
223
+ display: inline-block;
224
+ position: absolute;
225
+ }
226
+ .highlighted #code-overlay {
227
+ /* background: rgba(255, 0, 0, 0.5);*/
228
+ background: rgba(50, 140, 220, 0.5);
229
+ }
230
+ table#demo-box {
231
+ width: 180px;
232
+ display: none;
233
+ }
234
+ #demo-box td {
235
+ font-size: 10px;
236
+ }
237
+ td.demo-wrapper-margin {
238
+ width: 100%;
239
+ height: 12px;
240
+ text-align: center;
241
+ background: rgba(255, 145, 0, 0.5);
242
+ }
243
+ td.demo-code {
244
+ width: 60%;
245
+ height: 70px;
246
+ text-align: center;
247
+ background: rgba(50, 140, 220, 0.5);
248
+ }
249
+ td.demo-wrapper-background {
250
+ text-align: center;
251
+ background: rgba(50, 220, 140, 0.5);
252
+ }
253
+ </style>
254
+ <?php echo ai_wp_head_hook (); ?>
255
+ </head>
256
+ <body style='font-family: arial; text-align: justify;'>
257
+ <div style="float: right;">
258
+ <button id="highlight-button" type="button" style="margin-left: 20px; font-size: 12px;" title="Highlight inserted code" >Highlight</button>
259
+ </div>
260
+ <div style="float: right;">
261
+ <table id="demo-box" cellspacing=0 cellspacing="0">
262
+ <tr>
263
+ <td class="demo-wrapper-margin" colspan="2">wrapper margin</td>
264
+ </tr>
265
+ <td class="demo-code">Code block</td>
266
+ <td class="demo-wrapper-background">wrapper background</td>
267
+ <tr>
268
+ </tr>
269
+ <td class="demo-wrapper-margin" colspan="2">wrapper margin</td>
270
+ <tr>
271
+ </tr>
272
+ </table>
273
+ </div>
274
+ <h1><?php echo AD_INSERTER_TITLE; ?> Code Preview</h1>
275
+ <h2>Block <?php echo $block; ?></h2>
276
+ <h3><?php echo $obj->get_ad_name(); ?></h3>
277
+ <p>Need to install ads or widgets on Wordpress website? Ad Inserter is a simple yet powerful solution to insert any code into Wordpress.
278
+ You can install it from Wordpress (Plugins / Add New / search for Ad Inserter). <strong>Perfect for AdSense or contextual Amazon ads</strong>.
279
+ Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.
280
+ Ad Inserter supports up to 16 code blocks. Code block is any code (for example AdSense ad) that has to be inserted (displayed) at some position.
281
+ Each code block can be configured to insert code at almost any position supported by Wordpress. It Features 16 code blocks; Syntax highlighting editor;
282
+ Automatic positions: before/after post, content, paragraph or excerpt; Manual positions: widgets, shortcodes, PHP function call; Block alignment and style:
283
+ left, center, right, float left, float right, custom CSS, no wrapping; PHP code processing: Server-side and client-side device detection (3 custom viewports);
284
+ Black/White-list categories, tags, urls, referers.</p>
285
+ <?php if ($obj->get_alignment_type() != AD_ALIGNMENT_NO_WRAPPING) : ?>
286
+ <div id='margin' style='<?php echo margin_css ($obj->get_alignmet_style ()); ?>'>
287
+ <div id='wrapper' style='<?php echo no_margin_css ($obj->get_alignmet_style (0)); ?>'>
288
+ <div id='code-overlay-background'></div>
289
+ <?php endif; ?>
290
+ <span id='code'>
291
+ <?php echo $obj->get_ad_data(); ?>
292
+ </span>
293
+ <?php if ($obj->get_alignment_type() != AD_ALIGNMENT_NO_WRAPPING) : ?>
294
+ </div>
295
+ <?php endif; ?>
296
+ </div>
297
+ <div id='code-overlay'></div>
298
+ <p>Few very important things you need to know in order to insert code and display some ad:
299
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call)
300
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
301
+ For Posts and static pages select default value On all Posts / On all Static pages unless you really know what are you doing
302
+ Each code block has 4 independent display options: Automatic Display, Widget, Shortcode and PHP function call.
303
+ To display code block (ad) at some position you need to enable and use at least one display option.
304
+ For single posts or static pages display position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
305
+ For single posts or static pages display position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
306
+ <a href='http://tinymonitor.com/ad-inserter-pro' style='text-decoration: none;' target='_blank'><strong>Ad Inserter Pro</strong></a> is an upgraded version of the freely available Ad Inserter.
307
+ In addition to all the features in the free version it offers 64 code blocks, 6 custom viewports, export and import of settings and support via email.
308
+ For a complete description of features, screenshots and FAQ please check Ad Inserter page.
309
+ If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
310
+ After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to Wordpress Plugins, Add New, Upload Plugin,
311
+ Choose file, click on Install Now, activate it and then click 'Enter License Key' and enter license key you got in the email.</p>
312
+ <?php echo ai_wp_footer_hook (); ?>
313
+ </body>
314
+ </html>
315
+ <?php
316
+
317
+ }
318
+
319
+
readme.txt CHANGED
@@ -3,17 +3,19 @@ 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.6
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.
11
 
12
  == Description ==
13
 
 
 
14
  Need to install ads or widgets on Wordpress website?
15
 
16
- Ad Inserter is a simple yet powerful solution to insert any code into Wordpress. **Perfect for AdSense or contextual Amazon ads.** Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.
17
 
18
  Ad Inserter supports up to 16 code blocks. Code block is any code (for example AdSense ad) that has to be inserted (displayed) at some position.
19
  Each code block can be configured to insert code at almost any position supported by Wordpress.
@@ -33,10 +35,11 @@ And there is also <a href="http://tinymonitor.com/ad-inserter-pro" target="_blan
33
 
34
  **Quick Start**
35
 
36
- You need to know two very important things in order to insert code and display some ad:
37
 
38
- * You need to **enable and use at least one display option** (Automatic Display, Widget, Shortcode, PHP function call)
39
- * You need to **enable display on at least one Wordpress page type** (Posts, Pages, Blog pages, Homepage, Category pages, Search Pages, Archive pages)
 
40
 
41
  Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page!
42
 
@@ -54,26 +57,17 @@ To display code block (ad) at some position **you need to enable and use at leas
54
  Automatic Display Options:
55
 
56
  * Display Before Post (before post or posts on blog pages, previously named Before Title)
57
- * Display Before Content (before post or page text)
58
- * Display Before Paragraph (on posts, pages and blog pages)
59
- * Display After Paragraph (on posts, pages and blog pages)
60
- * Display After Content (after post or page text)
61
  * Display After Post (after post or posts on blog pages)
62
  * Display Before Excerpt (on blog pages)
63
  * Display After Excerpt (on blog pages)
64
- * As a Widget - Simply drag **Ad Inserter** widget to any widget postition (e.g. Sidebar), select code block, save and you're done.
65
-
66
- For single posts or pages display position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
67
 
68
- For single posts or pages display position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
69
-
70
- Display Block to:
71
 
72
- * All users (default)
73
- * Logged in users
74
- * Not logged in users
75
-
76
- **WARNING:** If you are using caching this may not work as expected. The check works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
77
 
78
  Order of display positions in a typical post is the following:
79
 
@@ -95,7 +89,7 @@ Of course, the final order of items depends also on other plugins. Ad Inserter i
95
  Block Alignment and Style:
96
 
97
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
98
- * Custom CSS (You can define custom CSS code for wrapping div)
99
  * None (simple div with thin margin)
100
  * Align Left
101
  * Align Right
@@ -113,21 +107,17 @@ For all display positions you can also define Wordpress page types where the ads
113
  Single pages:
114
 
115
  * Posts
116
- * Pages
 
117
 
118
  Blog pages:
119
 
120
  * Homepage
121
  * Category pages
122
  * Search Pages
123
- * Archive pages
124
-
125
- You can also disable ads on certain posts or pages. For each code block on posts or pages you first define default display settings for posts/pages page type. Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below). Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content). For one or few exceptions it is easier to first enable ads on All Posts/Pages page types and then either white or black-list single url or few space-separated urls (click on the Lists button).
126
 
127
- For blog pages and display positions Before Excerpt / After Excerpt and Before Content / After Content you can also specify excerpt/post number or comma separated list of excerpt/post numbers (1 - 9). For Before Post / After Post positions this setting is a filter to limit/filter insertions before or after post if the theme inserts code block more than once. You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.
128
-
129
- **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,
130
- 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.
131
 
132
  Paragraph number for Automatic Display options Before and After Paragraph:
133
 
@@ -137,6 +127,9 @@ Paragraph number for Automatic Display options Before and After Paragraph:
137
 
138
  Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum number of words. If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.
139
 
 
 
 
140
  You can also define paragraph HTML tags. Normally only `<p>` tags are used. If your post contains also `<div>` or header tags, you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
141
  **WARNING:** Each code block you insert in post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
142
  **After Paragraph** will not work if you specify tag names that have no closing tags! Use # as tag if paragraphs have no tags and are separated with the `\r\n\r\n` characters.
@@ -147,12 +140,6 @@ Display only for posts published after N days checks the date when the post was
147
 
148
  On the Ad Inserter settings page (tab #) you also have option Tag Debugging. If enabled, it displays paragraph tags surrounded with a border. This way you can check where your code will be inserted. You can select to show paragraph tags before or after plugin processing. If Before Processing is selected Ad Inserter WILL NOT insert any code!
149
 
150
- Additional Display Options:
151
-
152
- * Manual - Insert shortcode `[adinserter block="BLOCK_NUMBER"]` or `[adinserter name="BLOCK_NAME"]` into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position.
153
- * PHP function call `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER); ?>` - Insert code block BLOCK_NUMBER at any position in template file. With PHP function call counter (Excerpt/Post number) you can also define which call(s) to the function will actually insert code.
154
- This is useful if you put a call to the `adinserter` function inside a loop in a template file (e.g. for homepage) and you need to insert ads only few times between posts.
155
-
156
  Additional Options for code blocks:
157
 
158
  PHP processing: Enabled or Disabled - Enable processing of PHP code. If there is an error in the PHP code, it will not break the website.
@@ -165,13 +152,42 @@ WARNING: If you are using caching ad rotation may not work as expected. It works
165
 
166
  Ad Inserter is perfect for displaying any kind of ads. It can also be used to display various versions of ad, for example <a href="https://support.google.com/adsense/answer/65083?ctx=as2&rd=2&ref_topic=23389" target="_blank">AdSense ads using channels</a> to test which format or color combination performs best.
167
 
168
- **Lists**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list):
171
  leave category list empty and set it to Black list to show ads in all categories.
172
  **WARNING:** If category name contains commas use category slug instead. Also make sure you have enabled display on **Category pages**.
173
 
174
- Do not display ads in posts with certain tags (black list) or display ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on **Archive pages**.
175
 
176
  Do not display ads on pages with certain urls (black list) or display ads only pages with certain urls (white list): leave url list empty and set it to Black list to show ads on all urls.
177
  Url used here is everything starting form the `/` after the domain name. For example: if web address is `http://domain.com/lorem-ipsum`, url to white/black-list is `/lorem-ipsum`
@@ -183,7 +199,7 @@ leave referrers list empty and set it to Black list to show ads for all referrer
183
 
184
  **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.
185
 
186
- **Devices**
187
 
188
  **IMPORTANT:** There are two types of device detection: **server side** and **client-side**.
189
 
@@ -221,7 +237,17 @@ Server-side detection uses User-Agent string combined with specific HTTP headers
221
 
222
  **PLEASE NOTE:** Use server-side device type detection only when you need to generate (display and count) ONLY code blocks for specific device type. In all other cases switch it off.
223
 
224
- By default code blocks will not be inserted on Error 404 page (Page Not Found). Check Error '404 Page checkbox' to enable code block on error 404 page.
 
 
 
 
 
 
 
 
 
 
225
 
226
  **Ad Inserter Settings - Tab #**
227
 
@@ -229,7 +255,7 @@ Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which
229
 
230
  You can choose between many syntax highlighting themes.
231
 
232
- 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 #).
233
 
234
  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.
235
 
@@ -240,7 +266,6 @@ Support for Special Code Blocks:
240
  * Header scripts (scripts in the `<header>` section)
241
  * Footer scripts (scripts before the `</body>` tag)
242
 
243
-
244
  **WARNING:** Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to **Simple editor** using the checkbox above the code box.
245
 
246
  **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.
@@ -269,6 +294,12 @@ Try to add some text after the ad code to check if it appears at the expected ad
269
  Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help.
270
  Thank you very much for understanding.
271
 
 
 
 
 
 
 
272
  == Installation ==
273
 
274
  **Automatic installation**: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
@@ -311,25 +342,31 @@ activate it and then click "Enter License Key" and enter license key you got in
311
  4. Save settings.
312
 
313
 
 
 
 
 
 
 
314
  = Settings for ad before the first paragraph on all posts =
315
 
316
  * Automatic Display: Before Paragraph
317
- * On all Posts checked, other pages unchecked
318
  * Paragraph number: 1
319
 
320
 
321
  = Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post =
322
 
323
  * Automatic Display: Before Paragraph
324
- * On all Posts checked, Homepage checked, other pages unchecked
325
  * Paragraph number: 2
326
- * Excerpt/Post number(s): 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)
327
 
328
 
329
  = Settings for ad wrapped with text of the third paragraph on all posts =
330
 
331
  * Automatic Display: Before Paragraph
332
- * On all Posts checked, other pages unchecked
333
  * Block Alignment and Style: Float Left
334
  * Paragraph number: 3
335
 
@@ -337,7 +374,7 @@ activate it and then click "Enter License Key" and enter license key you got in
337
  = Settings for centered ad in the middle of post paragraphs =
338
 
339
  * Automatic Display: Before Paragraph
340
- * On all Posts checked, other pages unchecked
341
  * Block Alignment and Style: Center
342
  * Paragraph number: 0.5
343
 
@@ -345,7 +382,7 @@ activate it and then click "Enter License Key" and enter license key you got in
345
  = Settings for ad above post excerpts on the Insurance category page =
346
 
347
  * Automatic Display: Before Post
348
- * Category pages checked, other pages unchecked
349
  * Click Lists button to display lists
350
  * Categories: Insurance, White List checked
351
 
@@ -353,14 +390,14 @@ activate it and then click "Enter License Key" and enter license key you got in
353
  = Settings for ad above the first and third post excerpts on the homepage =
354
 
355
  * Automatic Display: Before Excerpt
356
- * Homepage checked, other pages unchecked
357
- * Excerpt/Post number(s): 1, 3
358
 
359
 
360
  = Settings for ad above the post excerpts on the Cars tag page =
361
 
362
  * Automatic Display: Before Post
363
- * Archive pages checked, other pages unchecked
364
  * Click Lists button to display lists
365
  * Tags: Cars, White List checked
366
 
@@ -388,9 +425,7 @@ Use <a href="https://wordpress.org/plugins/search-regex/" target="_blank">Search
388
 
389
  = How can I add some text or title (e.g. Advertisement) above the ad? =
390
 
391
- If this is a sidebar widget then you can simply name the widget.
392
-
393
- In other cases you can add title HTML code above ad code. For example:
394
 
395
  `<h3>Advertisement</h3>
396
 
@@ -399,6 +434,12 @@ AD_CODE`
399
  Change title tag according to the theme style.
400
 
401
 
 
 
 
 
 
 
402
  = How can I enable/disable ads on specific posts/pages? =
403
 
404
  There are two possible approaches.
@@ -620,6 +661,16 @@ AD CODE RIGHT
620
 
621
  == Changelog ==
622
 
 
 
 
 
 
 
 
 
 
 
623
  = 1.6.7 =
624
  - Bug fix: Block code textarea was not escaped
625
  - Added checks for page types for shortcodes
@@ -816,6 +867,16 @@ AD CODE RIGHT
816
 
817
  == Upgrade Notice ==
818
 
 
 
 
 
 
 
 
 
 
 
819
  = 1.6.7 =
820
  Bug fix: Block code textarea was not escaped;
821
  Added checks for page types for shortcodes;
@@ -1004,4 +1065,3 @@ Support for different sidebar implementations in various themes
1004
  = 1.0.0 =
1005
  Initial release
1006
 
1007
-
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.6.0
7
+ Stable tag: 1.6.7
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.
11
 
12
  == Description ==
13
 
14
+ **Ad Inserter**
15
+
16
  Need to install ads or widgets on Wordpress website?
17
 
18
+ Ad Inserter is a simple yet powerful plugin to insert any code into Wordpress. **Perfect for AdSense or contextual Amazon ads.** Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.
19
 
20
  Ad Inserter supports up to 16 code blocks. Code block is any code (for example AdSense ad) that has to be inserted (displayed) at some position.
21
  Each code block can be configured to insert code at almost any position supported by Wordpress.
35
 
36
  **Quick Start**
37
 
38
+ Few very important things you need to know in order to insert code and display some ad:
39
 
40
+ * **Enable and use at least one display option** (Automatic Display, Widget, Shortcode, PHP function call)
41
+ * **Enable display on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
42
+ * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
43
 
44
  Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page!
45
 
57
  Automatic Display Options:
58
 
59
  * Display Before Post (before post or posts on blog pages, previously named Before Title)
60
+ * Display Before Content (before post or static page text)
61
+ * Display Before Paragraph (on posts, static pages and blog pages)
62
+ * Display After Paragraph (on posts, static pages and blog pages)
63
+ * Display After Content (after post or static page text)
64
  * Display After Post (after post or posts on blog pages)
65
  * Display Before Excerpt (on blog pages)
66
  * Display After Excerpt (on blog pages)
 
 
 
67
 
68
+ For single posts or static pages display position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
 
 
69
 
70
+ For single posts or static pages display position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
 
 
 
 
71
 
72
  Order of display positions in a typical post is the following:
73
 
89
  Block Alignment and Style:
90
 
91
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
92
+ * Custom CSS (You can enter custom CSS code for wrapping div)
93
  * None (simple div with thin margin)
94
  * Align Left
95
  * Align Right
107
  Single pages:
108
 
109
  * Posts
110
+ * Static pages
111
+ * 404 page (Error 404: Page not found)
112
 
113
  Blog pages:
114
 
115
  * Homepage
116
  * Category pages
117
  * Search Pages
118
+ * Tag / Archive pages
 
 
119
 
120
+ You can also disable ads on certain posts or static pages. For each code block on posts or static pages you first define default display settings for posts/pages page type. Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below). Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content). For one or few exceptions it is easier to first enable ads on All Posts/Static pages page types and then either white or black-list single url or few space-separated urls (click on the Lists button).
 
 
 
121
 
122
  Paragraph number for Automatic Display options Before and After Paragraph:
123
 
127
 
128
  Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum number of words. If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.
129
 
130
+ **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,
131
+ 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 Filter. You can also leave Filter (click Misc button) to 0 (means all posts on the blog page) and define maximum number of insertions.
132
+
133
  You can also define paragraph HTML tags. Normally only `<p>` tags are used. If your post contains also `<div>` or header tags, you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
134
  **WARNING:** Each code block you insert in post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
135
  **After Paragraph** will not work if you specify tag names that have no closing tags! Use # as tag if paragraphs have no tags and are separated with the `\r\n\r\n` characters.
140
 
141
  On the Ad Inserter settings page (tab #) you also have option Tag Debugging. If enabled, it displays paragraph tags surrounded with a border. This way you can check where your code will be inserted. You can select to show paragraph tags before or after plugin processing. If Before Processing is selected Ad Inserter WILL NOT insert any code!
142
 
 
 
 
 
 
 
143
  Additional Options for code blocks:
144
 
145
  PHP processing: Enabled or Disabled - Enable processing of PHP code. If there is an error in the PHP code, it will not break the website.
152
 
153
  Ad Inserter is perfect for displaying any kind of ads. It can also be used to display various versions of ad, for example <a href="https://support.google.com/adsense/answer/65083?ctx=as2&rd=2&ref_topic=23389" target="_blank">AdSense ads using channels</a> to test which format or color combination performs best.
154
 
155
+ **BUTTONS**
156
+
157
+ **[ Misc ]**
158
+
159
+ For each code block you can also limit how many times on the page the code (or ad) will be inserted. There are two settings for this:
160
+
161
+ * **Max N insertions**: simple limit for the first N calls for the block
162
+ * **Filter**: define which cals are wanted - single number or comma separated numbers
163
+
164
+ This is **useful in many cases where you can't remove unwanted insertions** of the code with other settings:
165
+
166
+ * If you need to insert ad before the first, third and fith excerpt on the homepage you simply specify `1, 3, 5` for the filter.
167
+ * In some WP themes hooks (that call Ad Inserter insertion functions) are called more than once. In such case you might get unwanted insertions. Simply set the filter to the number of the wanted call(s).
168
+ * If you use adinserter PHP function and you don't want that for each time the functon is called on the page the code is inserted, you can simply filter calls.
169
+ * If you oly need the first N calls (insertions) then leave filter to 0 and use Max N insertions instead.
170
+
171
+ **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,
172
+ 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 Filter. You can also leave Filter to 0 (means all posts on the blog page) and define maximum number of insertions.
173
+
174
+ General tag: text used for {tag} and {smart_tag} if the post has no tags - useful for contextual ads - **works only inside posts!**
175
+
176
+ Display Block to:
177
+
178
+ * All users (default)
179
+ * Logged in users
180
+ * Not logged in users
181
+
182
+ **WARNING:** If you are using caching this may not work as expected. The check works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
183
+
184
+ **[ Lists ]**
185
 
186
  Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list):
187
  leave category list empty and set it to Black list to show ads in all categories.
188
  **WARNING:** If category name contains commas use category slug instead. Also make sure you have enabled display on **Category pages**.
189
 
190
+ Do not display ads in posts with certain tags (black list) or display ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on **Tag / Archive pages**.
191
 
192
  Do not display ads on pages with certain urls (black list) or display ads only pages with certain urls (white list): leave url list empty and set it to Black list to show ads on all urls.
193
  Url used here is everything starting form the `/` after the domain name. For example: if web address is `http://domain.com/lorem-ipsum`, url to white/black-list is `/lorem-ipsum`
199
 
200
  **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.
201
 
202
+ **[ Devices ]**
203
 
204
  **IMPORTANT:** There are two types of device detection: **server side** and **client-side**.
205
 
237
 
238
  **PLEASE NOTE:** Use server-side device type detection only when you need to generate (display and count) ONLY code blocks for specific device type. In all other cases switch it off.
239
 
240
+ **[ Manual ]**
241
+
242
+ There are 3 independent types of manual insertion of code block:
243
+
244
+ * Widget - Widgets for all code blocks are enabled by default - simply drag **Ad Inserter** widget to any widget postition (e.g. Sidebar), select code block, save and you're done.
245
+ * Shortcode - Insert shortcode `[adinserter block="BLOCK_NUMBER"]` or `[adinserter name="BLOCK_NAME"]` into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position. **PLEASE NOTE:** Shortcodes IGNORE post/static page exception settings!
246
+ * PHP function call `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER); ?>` - Insert code block BLOCK_NUMBER at any position in template file. You can also define Filter for PHP function - define which call(s) to the function will actually insert code. This is useful if you put a call to the `adinserter` function inside a loop in a template file (e.g. for homepage) and you need to insert ads only few times between posts.
247
+
248
+ **OTHER NOTES**
249
+
250
+ By default code blocks will not be inserted on Error 404 page (Page Not Found). Check '404 Page' checkbox to enable code block on error 404 page.
251
 
252
  **Ad Inserter Settings - Tab #**
253
 
255
 
256
  You can choose between many syntax highlighting themes.
257
 
258
+ By default Ad Inserter exceptions on posts/static pages are enabled only for administrators. You can define minimum user role for page/post Ad Inserter exceptions editing in Ad Inserter Settings (tab #).
259
 
260
  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.
261
 
266
  * Header scripts (scripts in the `<header>` section)
267
  * Footer scripts (scripts before the `</body>` tag)
268
 
 
269
  **WARNING:** Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to **Simple editor** using the checkbox above the code box.
270
 
271
  **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.
294
  Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help.
295
  Thank you very much for understanding.
296
 
297
+ Please **support the plugin** if you like it:
298
+
299
+ * Write a nice <a href="http://wordpress.org/support/view/plugin-reviews/ad-inserter">review</a>
300
+ * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
301
+
302
+
303
  == Installation ==
304
 
305
  **Automatic installation**: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
342
  4. Save settings.
343
 
344
 
345
+ = Settings for **widget** =
346
+
347
+ * Nothing needed, just enter the code and save settings - widget is enabled by default
348
+ * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
349
+
350
+
351
  = Settings for ad before the first paragraph on all posts =
352
 
353
  * Automatic Display: Before Paragraph
354
+ * On all Posts checked, other page types unchecked
355
  * Paragraph number: 1
356
 
357
 
358
  = Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post =
359
 
360
  * Automatic Display: Before Paragraph
361
+ * On all Posts checked, Homepage checked, other page types unchecked
362
  * Paragraph number: 2
363
+ * Filter: 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)
364
 
365
 
366
  = Settings for ad wrapped with text of the third paragraph on all posts =
367
 
368
  * Automatic Display: Before Paragraph
369
+ * On all Posts checked, other page types unchecked
370
  * Block Alignment and Style: Float Left
371
  * Paragraph number: 3
372
 
374
  = Settings for centered ad in the middle of post paragraphs =
375
 
376
  * Automatic Display: Before Paragraph
377
+ * On all Posts checked, other page types unchecked
378
  * Block Alignment and Style: Center
379
  * Paragraph number: 0.5
380
 
382
  = Settings for ad above post excerpts on the Insurance category page =
383
 
384
  * Automatic Display: Before Post
385
+ * Category pages checked, other page types unchecked
386
  * Click Lists button to display lists
387
  * Categories: Insurance, White List checked
388
 
390
  = Settings for ad above the first and third post excerpts on the homepage =
391
 
392
  * Automatic Display: Before Excerpt
393
+ * Homepage checked, other page types unchecked
394
+ * Filter: 1, 3
395
 
396
 
397
  = Settings for ad above the post excerpts on the Cars tag page =
398
 
399
  * Automatic Display: Before Post
400
+ * Archive pages checked, other page types unchecked
401
  * Click Lists button to display lists
402
  * Tags: Cars, White List checked
403
 
425
 
426
  = How can I add some text or title (e.g. Advertisement) above the ad? =
427
 
428
+ If this is a sidebar widget then you can simply name the widget. In other cases you can add title HTML code above ad code. For example:
 
 
429
 
430
  `<h3>Advertisement</h3>
431
 
434
  Change title tag according to the theme style.
435
 
436
 
437
+ = I like the plugin. How can I support it? =
438
+
439
+ * Write a nice <a href="http://wordpress.org/support/view/plugin-reviews/ad-inserter">review</a>
440
+ * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
441
+
442
+
443
  = How can I enable/disable ads on specific posts/pages? =
444
 
445
  There are two possible approaches.
661
 
662
  == Changelog ==
663
 
664
+ = 1.7.0 =
665
+ - Bug fix: Shortcodes did not ignore post/static page exceptions
666
+ - Slightly redesigned user interface
667
+ - Excerpt/Post number(s) renamed to Filter as it now works on all display positions
668
+ - Widget setting removed from Automatic display to Manual display section
669
+ - Added support to disable widgets (standalone checkbox in Manual display)
670
+ - Added call counter/filter for widgets
671
+ - Added support to edit CSS for predefined styles
672
+ - Few other minor bug fixes, code improvements and cosmetic changes
673
+
674
  = 1.6.7 =
675
  - Bug fix: Block code textarea was not escaped
676
  - Added checks for page types for shortcodes
867
 
868
  == Upgrade Notice ==
869
 
870
+ = 1.7.0 =
871
+ Bug fix: Shortcodes did not ignore post/static page exceptions;
872
+ Slightly redesigned user interface;
873
+ Excerpt/Post number(s) renamed to Filter as it now works on all display positions;
874
+ Widget setting removed from Automatic display to Manual display section;
875
+ Added support to disable widgets (standalone checkbox in Manual display);
876
+ Added call counter/filter for widgets;
877
+ Added support to edit CSS for predefined styles;
878
+ Few other minor bug fixes, code improvements and cosmetic changes;
879
+
880
  = 1.6.7 =
881
  Bug fix: Block code textarea was not escaped;
882
  Added checks for page types for shortcodes;
1065
  = 1.0.0 =
1066
  Initial release
1067
 
 
settings.php CHANGED
@@ -5,6 +5,11 @@ require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
5
  function generate_settings_form (){
6
  global $ai_db_options, $block_object;
7
 
 
 
 
 
 
8
  $subpage = 'main';
9
  $start = 1;
10
  $end = 16;
@@ -52,6 +57,13 @@ function generate_settings_form (){
52
  text-align: center;
53
  width: 20px;
54
  }
 
 
 
 
 
 
 
55
  </style>
56
 
57
  <div id="ai-settings" style="margin-right: 16px; float: left; ">
@@ -60,11 +72,11 @@ function generate_settings_form (){
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 Ad Inserter 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
- <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter-pro" target="_blank">Go Pro</a> if you need more than 16 blocks
67
- or <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 free Ad Inserter development.
68
  </div>
69
  <h2><?php echo AD_INSERTER_TITLE . ' ' . AD_INSERTER_VERSION ?></h2>
70
  <?php
@@ -75,7 +87,7 @@ function generate_settings_form (){
75
  <?php
76
  if ($subpage == 'exceptions') {
77
  ?>
78
- <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
79
  <div id="ai-exceptions" style="padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
80
 
81
  <table class="exceptions">
@@ -137,33 +149,109 @@ function generate_settings_form (){
137
  </form>
138
  <?php
139
  } else {
140
- if (function_exists ('ai_settings_ranges')) ai_settings_ranges ($start, $active_tab);
141
  ?>
142
- <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; ?>">
143
  <div id="ai-tab-container" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
144
- <div id="dummy-tabs" style="height: <?php echo 29;//intval ((AD_INSERTER_BLOCKS + 1) / 17 + 0.9) * 29; ?>px; padding: .2em .2em 0;"></div>
145
  <ul id="ai-tabs" style="display: none;">
146
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
148
  $obj = $block_object [$ad_number];
149
 
 
 
 
 
 
150
  $ad_name = $obj->get_ad_name();
151
- if ($obj->get_display_type() != AD_SELECT_NONE) $ad_name .= ": ".$obj->get_display_type();
 
 
 
 
 
 
152
 
153
  $style = "";
154
- if ($obj->get_display_type() != AD_SELECT_NONE) $style = "font-weight: bold; color: #e44;";
155
- elseif ($obj->get_enable_manual()) $style = "font-weight: bold; color: #66e;";
156
- elseif ($obj->get_enable_php_call()) $style = "font-weight: bold; color: #66e;";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  echo "
159
  <li id=\"ai-tab$ad_number\" class=\"ai-tab\" title=\"$ad_name\"><a href=\"#tab-$ad_number\"><span style=\"", $style, "\">$ad_number</span></a></li>";
160
 
161
  }
162
 
163
- if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $style_h = "font-weight: bold; color: #66e;"; else $style_h = "";
164
- if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $style_f = "font-weight: bold; color: #66e;"; else $style_f = "";
 
 
 
 
 
165
  ?>
166
- <li id="ai-tab0" class="ai-tab" title="Ad Inserter Settings"><a href="#tab-0"><span style="<?php echo $style_f ?>">#</span></a></li>
167
  </ul>
168
 
169
  <?php
@@ -171,15 +259,22 @@ function generate_settings_form (){
171
  $obj = $block_object [$ad_number];
172
 
173
  $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
174
- if ($show_devices) $devices_style = "font-weight: bold; color: #e44;"; else $devices_style = "";
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
- if ($show_lists) $lists_style = "font-weight: bold; color: #e44;"; else $lists_style = "";
182
 
 
 
 
 
 
 
 
183
  ?>
184
 
185
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
@@ -188,8 +283,8 @@ function generate_settings_form (){
188
  </div>
189
 
190
  <div style="float: right; padding: 1px 5px;">
191
- <?php if (function_exists ('ai_settings_buttons')) ai_settings_buttons ($ad_number); ?>
192
- <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
193
  </div>
194
 
195
  <div style="padding:0px 8px 16px 16px;">
@@ -200,12 +295,13 @@ function generate_settings_form (){
200
 
201
  <div style="display: inline-block; padding: 1px 10px; float: right;">
202
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
203
- <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Process PHP code in block">Process PHP</label>
 
204
  </div>
205
 
206
  <div style="display: inline-block; padding: 1px 10px; float: right;">
207
  <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-<?php echo $ad_number; ?>" />
208
- <label for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor">Simple editor</label>
209
  </div>
210
 
211
  <div style="padding-left:16px;">
@@ -216,8 +312,21 @@ function generate_settings_form (){
216
  <textarea id="block-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
217
  </div>
218
 
219
- <div style="padding:8px 8px 8px 16px;">
220
- <div style="padding: 0 0 0 0;">
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  Automatic Display:
222
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:200px">
223
  <option value="<?php echo AD_SELECT_NONE; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_NONE; ?></option>
@@ -229,87 +338,111 @@ function generate_settings_form (){
229
  <option value="<?php echo AD_SELECT_AFTER_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_POST; ?></option>
230
  <option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
231
  <option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
232
- <option value="<?php echo AD_SELECT_WIDGET; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_WIDGET) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_WIDGET; ?></option>
233
- </select>
234
-
235
- &nbsp;for&nbsp;
236
- <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-users-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
237
- <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
238
- <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
239
- <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
240
  </select>
241
- users
242
-
243
- <div style="float: right;">
244
- <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>
245
- <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>
246
- </div>
247
  </div>
248
 
249
- <div style="padding: 8px 0 0 0;">
250
- Block Alignment and Style:&nbsp;&nbsp;&nbsp;
251
- <select style="border-radius: 5px;" id="block-alignment-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:120px">
252
- <option value="<?php echo AD_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_NO_WRAPPING; ?></option>
253
- <option value="<?php echo AD_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CUSTOM_CSS; ?></option>
254
- <option value="<?php echo AD_ALIGNMENT_NONE; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_NONE; ?></option>
255
- <option value="<?php echo AD_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_LEFT; ?></option>
256
- <option value="<?php echo AD_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_RIGHT; ?></option>
257
- <option value="<?php echo AD_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CENTER; ?></option>
258
- <option value="<?php echo AD_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_LEFT; ?></option>
259
- <option value="<?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?></option>
260
- </select> &nbsp;&nbsp;&nbsp;
261
- <span id="custom-css-<?php echo $ad_number; ?>" style="display: none;">CSS: <input style="border-radius: 7px;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_custom_css(); ?>" size="48" maxlength="160" title="Custom CSS code for wrapping div" /></span>
262
- <span id="no-wrapping-warning" style="margin-top: 5px; display: none;"><span style="color: red;">WARNING:</span> <strong>No Wrapping</strong> style has no HTML code for client-side detection</span>
263
  </div>
 
264
  </div>
265
 
266
- <div style="padding:8px 8px 8px 8px; margin: 8px 0 0 5px; border: 1px solid #ddd; border-radius: 5px;">
267
- <div id="blog-pages-<?php echo $ad_number; ?>" style="display: inline-block; vertical-align: top; float: right;">
268
- <div style="display: inline-block; margin-right: 20px; margin-top: 4px;">
269
- <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
270
- <input id= "display-homepage-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Homepage</label>
271
-
272
- <input style="border-radius: 5px; margin-left: 25px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
273
- <input id= "display-category-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 25px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Category pages</label>
274
-
275
- <br /><br />
276
-
277
- <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
278
- <input id= "display-search-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Search pages</label>
279
-
280
- <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
281
- <input id= "display-archive-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Archive pages</label>
282
- </div>
283
- </div>
284
-
285
- <div id="single-page-<?php echo $ad_number; ?>" style="display: inline-block; vertical-align: top; margin-right: 10px;">
286
-
287
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
288
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
289
-
290
- <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
291
- <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
292
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
293
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
294
- </select>
295
-
296
- &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Posts</label>
297
- <br />
298
-
299
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
300
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
301
-
302
- <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
303
- <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
304
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
305
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
306
- </select>
307
-
308
- &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Pages</label>
309
 
310
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
 
312
- <div style="clear: both;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  </div>
314
 
315
  <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 0 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px;">
@@ -341,108 +474,146 @@ function generate_settings_form (){
341
  </div>
342
  </div>
343
 
344
- <div id="lists-container-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_lists) echo 'display: none;'; ?>">
345
- <table style="padding:8px 8px 10px 8px;">
346
- <tbody>
347
- <tr>
348
- <td style="padding-right: 7px;">
349
- Categories:
350
- </td>
351
- <td style="padding-right: 7px;">
352
- <input style="border-radius: 5px;" title="Comma separated category names - if category name contains commas use category slug instead" type="text" name="<?php echo AI_OPTION_CATEGORY_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $cat_list; ?>" size="54" maxlength="500" />
353
- </td>
354
- <td style="padding-right: 7px;">
355
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
356
- </td>
357
- <td>
358
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_WHITE_LIST) echo 'checked '; ?> /> <?php echo AD_WHITE_LIST; ?>
359
- </td>
360
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  <tr>
362
- <td style="padding-right: 7px;">
363
- Tags:
364
- </td>
365
- <td style="padding-right: 7px;">
366
- <input style="border-radius: 5px;" title="Comma separated tags" type="text" name="<?php echo AI_OPTION_TAG_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $tag_list; ?>" size="54" maxlength="500"/>
367
- </td>
368
- <td style="padding-right: 7px;">
369
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
370
  </td>
371
  <td>
372
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_WHITE_LIST) echo 'checked '; ?> /> <?php echo AD_WHITE_LIST; ?>
 
373
  </td>
374
  </tr>
375
  <tr>
376
- <td style="padding-right: 7px;">
377
- Urls:
378
- </td>
379
- <td style="padding-right: 7px;">
380
- <input style="border-radius: 5px;" title="SPACE separated urls starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500"/>
381
- </td>
382
- <td style="padding-right: 7px;">
383
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
384
  </td>
385
  <td>
386
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_WHITE_LIST) echo 'checked '; ?> /> <?php echo AD_WHITE_LIST; ?>
 
387
  </td>
388
  </tr>
389
  <tr>
390
- <td style="padding-right: 7px;">
391
- Referers:
392
- </td>
393
- <td style="padding-right: 7px;">
394
- <input style="border-radius: 5px;" title="Comma separated domains, use # for no referer" type="text" name="<?php echo AI_OPTION_DOMAIN_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $domain_list; ?>" size="54" maxlength="500"/>
395
- </td>
396
- <td style="padding-right: 7px;">
397
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
398
  </td>
399
  <td>
400
- <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_WHITE_LIST) echo 'checked '; ?> /> <?php echo AD_WHITE_LIST; ?>
401
  </td>
402
  </tr>
403
- </tbody>
404
- </table>
405
  </div>
406
 
407
- <div style="padding:7px; margin: 8px 0 8px 5px; text-align: left; border: 1px solid #ddd; border-radius: 5px;">
408
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
409
- <input style="border-radius: 5px;" id="enable-manual-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
410
- <label for="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable manual insertion of this code block in posts and pages">
411
- Enable shortcode
412
- </label>
413
- &nbsp;&nbsp;
414
- <pre style= "margin: 0; display: inline; color: blue;">[adinserter block="<?php echo $ad_number; ?>"]</pre> or
415
- <pre style= "margin: 0; display: inline; color: blue;">[adinserter name="<?php echo $obj->get_ad_name(); ?>"]</pre>.
416
- <hr />
417
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
418
- <input style="border-radius: 5px;" id="enable-php-call-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_php_call () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
419
- <label for="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable PHP function call to insert this code block at any position in template file. If function is disabled for block it will return empty string.">
420
- Enable PHP function
421
- </label>
422
- &nbsp;&nbsp;
423
- <pre style= "margin: 0; display: inline; color: blue;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
424
- </div>
425
 
426
- <div id="blog-page-settings-<?php echo $ad_number; ?>" style="padding: 8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px;">
427
- Excerpt/Post number(s) <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_excerpt_number() ?>" title= "Filter insertions by specifying calls for this position - single number or comma separated numbers, 0 means all / no limits" size="10" maxlength="20" /> on blog pages (also filter for Before/After Post and PHP function calls)
428
- </div>
 
 
 
 
 
 
429
 
430
- <div style="margin: 8px 0 8px 5px; padding:8px; border: 1px solid #ddd; border-radius: 5px;">
431
- General tag: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_general_tag() ?>" size="16" maxlength="40" title="Used for {tags} when no page data is found" /> &nbsp;&nbsp;&nbsp;
432
- Max <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_maximum_insertions () ?>" size="2" maxlength="3" title="0 means unlimited" /> insertions &nbsp;&nbsp;&nbsp;
433
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
434
- <input style="border-radius: 5px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
435
- <label for="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable display of this code block on error 404 (Not Found) page">Display on Error 404 Page</label>
436
  </div>
437
 
438
- <div id="device-detection-container-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 5px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_devices) echo 'display: none;'; ?>">
439
  <table>
440
  <tr>
441
  <td>
442
  <div style="margin-bottom: 5px;">
443
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
444
- <input id="client-side-detection-<?php echo $ad_number; ?>" style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection in visitor's browser - uses CSS media queries to hide or show code blocks. Usually this is what you need." <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
445
- <label for="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Use client-side detection to display only on:</label>
446
  </div>
447
 
448
  <div style="margin: 5px 0 0 40px;">
@@ -454,8 +625,8 @@ function generate_settings_form (){
454
  ?>
455
  <div style="margin: 8px 0;">
456
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
457
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device min width <?php echo get_viewport_width ($viewport); ?> px" <?php if ($obj->get_detection_viewport ($viewport)==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
458
- <label for="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo $viewport_name; ?></label>
459
  </div>
460
  <?php
461
  }
@@ -464,9 +635,9 @@ function generate_settings_form (){
464
  </div>
465
  </td><td style="padding-left: 40px; vertical-align: top;">
466
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
467
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection when the page is created (and cached) - turn it off unless you know what you are doing." <?php if ($obj->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
 
468
 
469
- <label for="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Use server-side detection to display only on </label>
470
  <div style="margin: 0 0 10px 40px;">
471
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
472
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
@@ -483,6 +654,10 @@ function generate_settings_form (){
483
  </table>
484
  </div>
485
 
 
 
 
 
486
  </div>
487
 
488
  <?php
@@ -491,12 +666,15 @@ function generate_settings_form (){
491
 
492
  <div id="tab-0" style="padding: 0 0 30px 0;">
493
  <div style="padding: 10px 0 0 4px;">
494
- <h3>Ad Inserter Settings</h3>
 
 
 
495
  </div>
496
 
497
  <div style="float: right; padding: 1px 5px;">
498
  <?php if (function_exists ('ai_settings_global_buttons')) ai_settings_global_buttons (); ?>
499
- <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;" />
500
  </div>
501
 
502
  <div style="clear: both;"></div>
@@ -618,11 +796,12 @@ function generate_settings_form (){
618
  <div style="padding: 0;">
619
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
620
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
621
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="1" <?php if ($adH->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
622
- <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" title="Enable or disable insertion of this code into HTML page header">Enable</label> &nbsp;&nbsp;
 
623
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="0" />
624
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="1" <?php if ($adH->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
625
- <label for="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" title="Enable or disable display of this code block into HTML page header of error 404 (Not Found) page">Error 404 Page</label>
626
  </div>
627
 
628
  <div style="padding-left:4px;">
@@ -636,7 +815,7 @@ function generate_settings_form (){
636
  <div style="display: inline-block; padding: 1px 10px; float: right;">
637
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="0" />
638
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="1" id="process-php-h" <?php if ($adH->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
639
- <label for="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" title="Process PHP code">Process PHP</label>
640
  </div>
641
 
642
  <div style="display: inline-block; padding: 1px 10px; float: right;">
@@ -657,11 +836,12 @@ function generate_settings_form (){
657
  <div style="padding: 0;">
658
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
659
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
660
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="1" <?php if ($adF->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
661
- <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" title="Enable or disable insertion of this code into HTML page footer">Enable</label> &nbsp;&nbsp;
 
662
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="0" />
663
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="1" <?php if ($adF->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
664
- <label for="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" title="Enable or disable display of this code block into HTML page footer on error 404 (Not Found) page">Error 404 Page</label>
665
  </div>
666
 
667
  <div style="padding-left:4px;">
@@ -675,7 +855,7 @@ function generate_settings_form (){
675
  <div style="display: inline-block; padding: 1px 10px; float: right;">
676
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="0" />
677
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="1" id="process-php-f" <?php if ($adF->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
678
- <label for="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" title="Process PHP code">Process PHP</label>
679
  </div>
680
 
681
  <div style="display: inline-block; padding: 1px 10px; float: right;">
@@ -701,7 +881,7 @@ function generate_settings_form (){
701
  <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false" name="<?php echo AI_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:120px; font-weight: bold; color: #e44;" />
702
  </div>
703
  <div style="float: right; padding: 1px 1px;">
704
- <input name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="display: none; border-radius: 5px; width:120px; font-weight: bold;" />
705
  </div>
706
  </div>
707
 
5
  function generate_settings_form (){
6
  global $ai_db_options, $block_object;
7
 
8
+ $save_url = $_SERVER ['REQUEST_URI'];
9
+ if (isset ($_GET ['tab'])) {
10
+ $save_url = preg_replace ("/&tab=\d+/", "", $save_url);
11
+ }
12
+
13
  $subpage = 'main';
14
  $start = 1;
15
  $end = 16;
57
  text-align: center;
58
  width: 20px;
59
  }
60
+
61
+ .small-button .ui-button-text-only .ui-button-text {
62
+ padding: 0;
63
+ }
64
+ .responsive-table td {
65
+ white-space: nowrap;
66
+ }
67
  </style>
68
 
69
  <div id="ai-settings" style="margin-right: 16px; float: left; ">
72
  <?php
73
  if (function_exists ('ai_settings_header')) ai_settings_header (); else { ?>
74
  <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
75
+ <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 free Ad Inserter development
76
+ or <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter-pro" target="_blank"><span style="font-weight: bold; color: #80f;">Go Pro</span></a> to get more than 16 blocks.
77
  </div>
78
  <div style="float: right; text-align: right; margin: 0px 18px 0px 0;">
79
+ <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter" target="_blank">Documentation</a> :: If you like Ad Inserter please write a nice review on the <a style="text-decoration: none;" href="https://wordpress.org/support/view/plugin-reviews/ad-inserter" target="_blank">Reviews</a> page.
 
80
  </div>
81
  <h2><?php echo AD_INSERTER_TITLE . ' ' . AD_INSERTER_VERSION ?></h2>
82
  <?php
87
  <?php
88
  if ($subpage == 'exceptions') {
89
  ?>
90
+ <form action="<?php echo $save_url; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
91
  <div id="ai-exceptions" style="padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
92
 
93
  <table class="exceptions">
149
  </form>
150
  <?php
151
  } else {
152
+ if (function_exists ('ai_settings_ranges')) ai_settings_ranges ($active_tab);
153
  ?>
154
+ <form action="<?php echo $save_url; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" start="<?php echo $start; ?>" end="<?php echo $end; ?>">
155
  <div id="ai-tab-container" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
156
+ <div id="dummy-tabs" style="height: <?php echo 29; ?>px; padding: .2em .2em 0;"></div>
157
  <ul id="ai-tabs" style="display: none;">
158
  <?php
159
+
160
+ $sidebar_widgets = wp_get_sidebars_widgets();
161
+ $widget_options = get_option ('widget_ai_widget');
162
+
163
+ $sidebars_with_widgets = array ();
164
+ for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
165
+ $sidebars_with_widget [$ad_number]= array ();
166
+ }
167
+ foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
168
+ if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
169
+ $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
170
+ if ($sidebar_name != "") {
171
+ foreach ($sidebar_widget as $widget) {
172
+ if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
173
+ if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
174
+ $widget_option = $widget_options [$widget_id [1]];
175
+ $widget_block = $widget_option ['block'];
176
+ if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
177
+ $sidebars_with_widget [$widget_block] []= $sidebar_name;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+
186
+ $manual_widget = array ();
187
+ $manual_shortcode = array ();
188
+ $manual_php_function = array ();
189
+ $manual = array ();
190
+ $sidebars = array ();
191
+
192
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
193
  $obj = $block_object [$ad_number];
194
 
195
+ $manual_widget [$ad_number] = $obj->get_enable_widget() == AD_SETTINGS_CHECKED;
196
+ $manual_shortcode [$ad_number] = $obj->get_enable_manual() == AD_SETTINGS_CHECKED;
197
+ $manual_php_function [$ad_number] = $obj->get_enable_php_call() == AD_SETTINGS_CHECKED;
198
+ $manual [$ad_number] = ($manual_widget [$ad_number] && !empty ($sidebars_with_widget [$ad_number])) || $manual_shortcode [$ad_number] || $manual_php_function [$ad_number];
199
+
200
  $ad_name = $obj->get_ad_name();
201
+ $automatic = $obj->get_display_type() != AD_SELECT_NONE;
202
+
203
+ $ad_name_functions = false;
204
+ if ($automatic) {
205
+ $ad_name .= ": ".$obj->get_display_type();
206
+ $ad_name_functions = true;
207
+ }
208
 
209
  $style = "";
210
+
211
+ if ($automatic && $manual [$ad_number]) $style = "font-weight: bold; color: #c4f;";
212
+ elseif ($automatic) $style = "font-weight: bold; color: #e44;";
213
+ elseif ($manual [$ad_number]) $style = "font-weight: bold; color: #66f;";
214
+
215
+ if (!empty ($sidebars_with_widget [$ad_number])) $sidebars [$ad_number] = implode (", ", $sidebars_with_widget [$ad_number]); else $sidebars [$ad_number] = "";
216
+ if ($manual_widget [$ad_number]) {
217
+ if ($sidebars [$ad_number] != "") {
218
+ $ad_name .= $ad_name_functions ? ", " : ": ";
219
+ $ad_name .= "Widget used in: [".$sidebars [$ad_number]."]";
220
+ $ad_name_functions = true;
221
+ }
222
+ } else {
223
+ if (!empty ($sidebars_with_widget [$ad_number])) {
224
+ $ad_name .= $ad_name_functions ? ", " : ": ";
225
+ $ad_name .= "Widget DISABLED but used in: [".$sidebars [$ad_number]."]";
226
+ $ad_name_functions = true;
227
+ }
228
+ }
229
+
230
+ if ($manual_shortcode [$ad_number]) {
231
+ $ad_name .= $ad_name_functions ? ", " : ": ";
232
+ $ad_name .= "Shortcode";
233
+ $ad_name_functions = true;
234
+ }
235
+ if ($manual_php_function [$ad_number]) {
236
+ $ad_name .= $ad_name_functions ? ", " : ": ";
237
+ $ad_name .= "PHP function";
238
+ $ad_name_functions = true;
239
+ }
240
 
241
  echo "
242
  <li id=\"ai-tab$ad_number\" class=\"ai-tab\" title=\"$ad_name\"><a href=\"#tab-$ad_number\"><span style=\"", $style, "\">$ad_number</span></a></li>";
243
 
244
  }
245
 
246
+ $title_hf = "";
247
+ if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hf .= ", Header code";
248
+ if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hf .= ", Footer code";
249
+
250
+ if (($adH->get_enable_manual () && $adH->get_ad_data() != "") ||
251
+ ($adF->get_enable_manual () && $adF->get_ad_data() != ""))
252
+ $style_hf = "font-weight: bold; color: #e44;"; else $style_hf = "";
253
  ?>
254
+ <li id="ai-tab0" class="ai-tab" title="Ad Inserter Settings<?php echo $title_hf ?>"><a href="#tab-0"><span style="<?php echo $style_hf ?>">#</span></a></li>
255
  </ul>
256
 
257
  <?php
259
  $obj = $block_object [$ad_number];
260
 
261
  $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
262
+ if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
263
 
264
  $cat_list = $obj->get_ad_block_cat();
265
  $tag_list = $obj->get_ad_block_tag();
266
  $url_list = $obj->get_ad_url_list();
267
  $domain_list = $obj->get_ad_domain_list();
268
  $show_lists = $cat_list != '' || $tag_list != '' || $url_list != '' || $domain_list != '';
269
+ if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
270
 
271
+ $show_manual = $manual [$ad_number];
272
+ if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$ad_number] || empty ($sidebars_with_widget [$ad_number]) ? "#66f;" : "#e44;"); else $manual_style = "";
273
+
274
+ $show_misc = $obj->get_maximum_insertions () != 0 || $obj->get_call_filter() != 0 || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS;
275
+ if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
276
+
277
+ $save_button_text = "Save All Settings";
278
  ?>
279
 
280
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
283
  </div>
284
 
285
  <div style="float: right; padding: 1px 5px;">
286
+ <?php if (function_exists ('ai_settings_buttons')) ai_settings_buttons ($ad_number, $save_button_text, $start, $end); ?>
287
+ <input style="display: none; border-radius: 5px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="<?php echo $save_button_text; ?>" type="submit" />
288
  </div>
289
 
290
  <div style="padding:0px 8px 16px 16px;">
295
 
296
  <div style="display: inline-block; padding: 1px 10px; float: right;">
297
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
298
+ <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
299
+ <label for="process-php-<?php echo $ad_number; ?>" title="Process PHP code in block">Process PHP</label>
300
  </div>
301
 
302
  <div style="display: inline-block; padding: 1px 10px; float: right;">
303
  <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-<?php echo $ad_number; ?>" />
304
+ <label for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor for mobile devices">Simple editor</label>
305
  </div>
306
 
307
  <div style="padding-left:16px;">
312
  <textarea id="block-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
313
  </div>
314
 
315
+ <div style="padding:8px 8px 8px 8px;">
316
+ <!-- <div style="float: left;">-->
317
+ <!-- <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_preview"); ?>">Preview</button>-->
318
+ <!-- </div>-->
319
+ <div style="float: right;">
320
+ <button id="misc-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Limit / filter insertions, general tag, check for logged-in users"><span style="<?php echo $misc_style; ?>">Misc</span></button>
321
+ <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>
322
+ <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>
323
+ <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual Display</span></button>
324
+ </div>
325
+ <div style="clear: both;"></div>
326
+ </div>
327
+
328
+ <div style="padding:8px 8px 8px 8px;">
329
+ <div style="float: left;">
330
  Automatic Display:
331
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:200px">
332
  <option value="<?php echo AD_SELECT_NONE; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_NONE; ?></option>
338
  <option value="<?php echo AD_SELECT_AFTER_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_POST; ?></option>
339
  <option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
340
  <option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
 
 
 
 
 
 
 
 
341
  </select>
 
 
 
 
 
 
342
  </div>
343
 
344
+ <div style="float: right;">
345
+ Block Alignment and Style:&nbsp;&nbsp;&nbsp;
346
+ <select style="border-radius: 5px;" id="block-alignment-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:120px">
347
+ <option value="<?php echo AD_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_NO_WRAPPING; ?></option>
348
+ <option value="<?php echo AD_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CUSTOM_CSS; ?></option>
349
+ <option value="<?php echo AD_ALIGNMENT_NONE; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_NONE; ?></option>
350
+ <option value="<?php echo AD_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_LEFT; ?></option>
351
+ <option value="<?php echo AD_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_RIGHT; ?></option>
352
+ <option value="<?php echo AD_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CENTER; ?></option>
353
+ <option value="<?php echo AD_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_LEFT; ?></option>
354
+ <option value="<?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?></option>
355
+ </select>
356
+ &nbsp;
357
+ <button id="show-css-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Show CSS code">Show CSS</button>
358
  </div>
359
+ <div style="clear: both;"></div>
360
  </div>
361
 
362
+ <div class="responsive-table" id="css-code-<?php echo $ad_number; ?>" style="min-height: 31px; padding:8px 8px 8px 8px; margin: 8px 0 0 5px; height: 24px; display: none;">
363
+ <table>
364
+ <tr>
365
+ <td style="vertical-align: middle;">
366
+ <span id="css-label-<?php echo $ad_number; ?>" style="height: 22px; vertical-align: middle; margin: 4px 0 0 0;">CSS &nbsp;</span>
367
+ </td>
368
+ <td style="width: 100%;">
369
+ <input id="custom-css-<?php echo $ad_number; ?>" style="width: 100%; vertical-align: middle; border-radius: 4px; display: none; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_custom_css(); ?>" size="70" maxlength="160" title="Custom CSS code for wrapping div" />
370
+ <span style="width: 100%; vertical-align: middle; margin: 3px 0 0 7px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold;">
371
+ <span id="css-no-wrapping-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle; display: none;"></span>
372
+ <span id="css-none-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle; display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_NONE); ?></span>
373
+ <span id="css-left-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle;display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_LEFT); ?></span>
374
+ <span id="css-right-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle;display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_RIGHT); ?></span>
375
+ <span id="css-center-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle;display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_CENTER); ?></span>
376
+ <span id="css-float-left-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle;display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_FLOAT_LEFT); ?></span>
377
+ <span id="css-float-right-<?php echo $ad_number; ?>" style="height: 18px; vertical-align: middle;display: none;" title="CSS code for wrapping div"><?php echo $obj->alignmet_style (AD_ALIGNMENT_FLOAT_RIGHT); ?></span>
378
+ </span>
379
+ </td>
380
+ <td>
381
+ <button id="edit-css-button-<?php echo $ad_number; ?>" type="button" style="float: right; margin-left: 7px;" title="Edit CSS code">Edit</button>
382
+ </td>
383
+ </tr>
384
+ </table>
385
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
 
387
+ <div class="responsive-table" style="padding:8px 8px 8px 8px; margin: 8px 0 0 5px; border: 1px solid #ddd; border-radius: 5px;">
388
+ <table>
389
+ <tr>
390
+ <td style="width: 70%">
391
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
392
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable display on posts" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
393
+
394
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts - exceptions can be configured on individual post editor pages" id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
395
+ <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
396
+ <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
397
+ <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
398
+ </select>
399
+ &nbsp;
400
+ <label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
401
+ </td>
402
+ <td style="padding-left: 8px;">
403
+ </td>
404
+ <td style="padding-left: 8px;">
405
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
406
+ <input id= "display-homepage-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
407
+ <label for="display-homepage-<?php echo $ad_number; ?>" title="Enable or disable display on homepage: latest posts (including sub-pages), static page or theme homepage">Homepage</label>
408
+ </td>
409
+ <td style="padding-left: 8px;">
410
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
411
+ <input id= "display-category-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
412
+ <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable display on category blog pages (including sub-pages)">Category pages</label>
413
+ </td>
414
+ </tr>
415
 
416
+ <tr>
417
+ <td style="width: 70%">
418
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
419
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable display on static pages" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
420
+
421
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for pages - exceptions can be configured on individual page editor pages" id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
422
+ <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
423
+ <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
424
+ <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
425
+ </select>
426
+ &nbsp;
427
+ <label for="display-pages-<?php echo $ad_number; ?>">Static pages</label>
428
+ </td>
429
+ <td style="padding-left: 8px;">
430
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
431
+ <input style="border-radius: 5px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
432
+ <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable display on page for Error 404: Page not found">404 page</label>
433
+ </td>
434
+ <td style="padding-left: 8px;">
435
+ <input style="border-radius: 5px;;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
436
+ <input id= "display-search-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
437
+ <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable display on search blog pages">Search pages</label>
438
+ </td>
439
+ <td style="padding-left: 8px;">
440
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
441
+ <input id= "display-archive-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
442
+ <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable display on tag or archive blog pages">Tag / Archive pages</label>
443
+ </td>
444
+ </tr>
445
+ </table>
446
  </div>
447
 
448
  <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 0 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px;">
474
  </div>
475
  </div>
476
 
477
+ <div class="responsive-table" id="list-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_lists) echo 'display: none;'; ?>">
478
+ <table style="padding:8px 8px 10px 8px;">
479
+ <tbody>
480
+ <tr>
481
+ <td style="padding-right: 7px;">
482
+ Categories
483
+ </td>
484
+ <td style="padding-right: 7px; width: 70%;">
485
+ <input style="border-radius: 5px; width: 100%;" title="Comma separated category names - if category name contains commas use category slug instead" type="text" name="<?php echo AI_OPTION_CATEGORY_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $cat_list; ?>" size="54" maxlength="500" />
486
+ </td>
487
+ <td style="padding-right: 7px;">
488
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="category-blacklist-<?php echo $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> />
489
+ <label for="category-blacklist-<?php echo $ad_number; ?>" title="Blacklist categories"><?php echo AD_BLACK_LIST; ?></label>
490
+ </td>
491
+ <td>
492
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="category-whitelist-<?php echo $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_WHITE_LIST) echo 'checked '; ?> />
493
+ <label for="category-whitelist-<?php echo $ad_number; ?>" title="Whitelist categories"><?php echo AD_WHITE_LIST; ?></label>
494
+ </td>
495
+ </tr>
496
+ <tr>
497
+ <td style="padding-right: 7px;">
498
+ Tags
499
+ </td>
500
+ <td style="padding-right: 7px; width: 70%;">
501
+ <input style="border-radius: 5px; width: 100%;" title="Comma separated tags" type="text" name="<?php echo AI_OPTION_TAG_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $tag_list; ?>" size="54" maxlength="500"/>
502
+ </td>
503
+ <td style="padding-right: 7px;">
504
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="tag-blacklist-<?php echo $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> />
505
+ <label for="tag-blacklist-<?php echo $ad_number; ?>" title="Blacklist tags"><?php echo AD_BLACK_LIST; ?></label>
506
+ </td>
507
+ <td>
508
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="tag-whitelist-<?php echo $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_WHITE_LIST) echo 'checked '; ?> />
509
+ <label for="tag-whitelist-<?php echo $ad_number; ?>" title="Whitelist tags"><?php echo AD_WHITE_LIST; ?></label>
510
+ </td>
511
+ </tr>
512
+ <tr>
513
+ <td style="padding-right: 7px;">
514
+ Urls
515
+ </td>
516
+ <td style="padding-right: 7px;" width: 70%;>
517
+ <input style="border-radius: 5px; width: 100%;" title="SPACE separated urls (page addresses) starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500"/>
518
+ </td>
519
+ <td style="padding-right: 7px;">
520
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-blacklist-<?php echo $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
521
+ <label for="url-blacklist-<?php echo $ad_number; ?>" title="Blacklist urls"><?php echo AD_BLACK_LIST; ?></label>
522
+ </td>
523
+ <td>
524
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-whitelist-<?php echo $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
525
+ <label for="url-whitelist-<?php echo $ad_number; ?>" title="Whitelist urls"><?php echo AD_WHITE_LIST; ?></label>
526
+ </td>
527
+ </tr>
528
+ <tr>
529
+ <td style="padding-right: 7px;">
530
+ Referers
531
+ </td>
532
+ <td style="padding-right: 7px;" width: 70%;>
533
+ <input style="border-radius: 5px; width: 100%;" title="Comma separated domains, use # for no referer" type="text" name="<?php echo AI_OPTION_DOMAIN_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $domain_list; ?>" size="54" maxlength="500"/>
534
+ </td>
535
+ <td style="padding-right: 7px;">
536
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="referer-blacklist-<?php echo $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
537
+ <label for="referer-blacklist-<?php echo $ad_number; ?>" title="Blacklist referers"><?php echo AD_BLACK_LIST; ?></label>
538
+ </td>
539
+ <td>
540
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="referer-whitelist-<?php echo $ad_number; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
541
+ <label for="referer-whitelist-<?php echo $ad_number; ?>" title="Whitelist referers"><?php echo AD_WHITE_LIST; ?></label>
542
+ </td>
543
+ </tr>
544
+ </tbody>
545
+ </table>
546
+ </div>
547
+
548
+ <div id="manual-settings-<?php echo $ad_number; ?>" class="small-button" style="padding:7px; margin: 8px 0 8px 5px; text-align: left; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_manual) echo 'display: none;'; ?>">
549
+ <table>
550
  <tr>
551
+ <td style="padding: 4px 10px 4px 0;">
552
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
553
+ <input style="border-radius: 5px;" id="enable-widget-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_widget () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
554
+ <label for="enable-widget-<?php echo $ad_number; ?>" title="Enable or disable widget for this code block">
555
+ Widget
556
+ </label>
 
 
557
  </td>
558
  <td>
559
+ <pre style= "margin: 0; display: inline; color: blue;" title="Sidebars (or widget positions) where this widged is used"><?php echo $sidebars [$ad_number], !empty ($sidebars [$ad_number]) ? " &nbsp;" : ""; ?></pre>
560
+ <button id="widgets-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px;" title="Manage Widgets"></button>
561
  </td>
562
  </tr>
563
  <tr>
564
+ <td style="padding: 4px 10px 4px 0;">
565
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
566
+ <input style="border-radius: 5px;" type="checkbox" id="enable-shortcode-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
567
+ <label for="enable-shortcode-<?php echo $ad_number; ?>" title="Enable or disable shortcode for manual insertion of this code block in posts and pages">
568
+ Shortcode
569
+ </label>
 
 
570
  </td>
571
  <td>
572
+ <pre style= "margin: 0; display: inline; color: blue; font-size: 11px;">[adinserter block="<?php echo $ad_number; ?>"]</pre>
573
+ or <pre style= "margin: 0; display: inline; color: blue;">[adinserter name="<?php echo $obj->get_ad_name(); ?>"]</pre>
574
  </td>
575
  </tr>
576
  <tr>
577
+ <td style="padding: 4px 10px 4px 0;">
578
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
579
+ <input style="border-radius: 5px;" id="enable-php-call-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_php_call () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
580
+ <label for="enable-php-call-<?php echo $ad_number; ?>" title="Enable or disable PHP function call to insert this code block at any position in template file. If function is disabled for block it will return empty string.">
581
+ PHP function
582
+ </label>
 
 
583
  </td>
584
  <td>
585
+ <pre style= "margin: 0; display: inline; color: blue; font-size: 11px;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
586
  </td>
587
  </tr>
588
+ </table>
 
589
  </div>
590
 
591
+ <div id="misc-settings-<?php echo $ad_number; ?>" style="margin: 8px 0 8px 5px; padding:8px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_misc) echo 'display: none;'; ?>">
592
+ Max <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_maximum_insertions () ?>" size="2" maxlength="3" title="0 means no limit" /> insertions &nbsp;&nbsp;
593
+ Filter <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_call_filter() ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, 0 means all / no limits" size="6" maxlength="20" /> &nbsp;&nbsp;
594
+ General tag <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_general_tag() ?>" size="10" maxlength="40" title="Used for {tags} when no page data is found" /> &nbsp;&nbsp;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
 
596
+ <div style="float: right;">
597
+ Display for
598
+ <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-users-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
599
+ <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
600
+ <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
601
+ <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
602
+ </select>
603
+ users
604
+ </div>
605
 
606
+ <div style="clear: both;"></div>
 
 
 
 
 
607
  </div>
608
 
609
+ <div id="device-detection-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_devices) echo 'display: none;'; ?>">
610
  <table>
611
  <tr>
612
  <td>
613
  <div style="margin-bottom: 5px;">
614
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
615
+ <input id="client-side-detection-<?php echo $ad_number; ?>" style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
616
+ <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to display only on:</label>
617
  </div>
618
 
619
  <div style="margin: 5px 0 0 40px;">
625
  ?>
626
  <div style="margin: 8px 0;">
627
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
628
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="viewport-<?php echo $viewport, "-", $ad_number; ?>" value="1" <?php if ($obj->get_detection_viewport ($viewport)==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
629
+ <label for="viewport-<?php echo $viewport, "-", $ad_number; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
630
  </div>
631
  <?php
632
  }
635
  </div>
636
  </td><td style="padding-left: 40px; vertical-align: top;">
637
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
638
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="server-side-detection-<?php echo $viewport_name; ?>" value="1" <?php if ($obj->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
639
+ <label for="server-side-detection-<?php echo $viewport_name; ?>">Use server-side detection to display only on </label>
640
 
 
641
  <div style="margin: 0 0 10px 40px;">
642
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
643
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
654
  </table>
655
  </div>
656
 
657
+ <div id="no-wrapping-warning-<?php echo $ad_number; ?>" style="padding:8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; display: none;">
658
+ <span id="" style="margin-top: 5px;"><strong><span style="color: red;">WARNING:</span> No Wrapping</strong> style has no HTML code for client-side device detection!</span>
659
+ </div>
660
+
661
  </div>
662
 
663
  <?php
666
 
667
  <div id="tab-0" style="padding: 0 0 30px 0;">
668
  <div style="padding: 10px 0 0 4px;">
669
+ <h3>Ad Inserter Settings <?php echo (int) ($ai_db_options ['global']['VERSION'][0].$ai_db_options ['global']['VERSION'][1]), '.',
670
+ (int) ($ai_db_options ['global']['VERSION'][2].$ai_db_options ['global']['VERSION'][3]), '.',
671
+ (int) ($ai_db_options ['global']['VERSION'][4].$ai_db_options ['global']['VERSION'][5]);
672
+ echo isset ($ai_db_options ['global']['TIMESTAMP']) ? " saved on ".date ("Y-m-d H:i:s", $ai_db_options ['global']['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : ""; ?></h3>
673
  </div>
674
 
675
  <div style="float: right; padding: 1px 5px;">
676
  <?php if (function_exists ('ai_settings_global_buttons')) ai_settings_global_buttons (); ?>
677
+ <input style="display: none; border-radius: 5px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save Settings" type="submit" style="width:120px; font-weight: bold;" />
678
  </div>
679
 
680
  <div style="clear: both;"></div>
796
  <div style="padding: 0;">
797
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
798
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
799
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" id="enable-header" value="1" <?php if ($adH->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
800
+ <label for="enable-header" title="Enable or disable insertion of this code into HTML page header">Enable</label> &nbsp;&nbsp;
801
+
802
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="0" />
803
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" id="enable-header-404" value="1" <?php if ($adH->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
804
+ <label for="enable-header-404" title="Enable or disable insertion of this code into HTML page header on page for Error 404: Page not found">Error 404 Page</label>
805
  </div>
806
 
807
  <div style="padding-left:4px;">
815
  <div style="display: inline-block; padding: 1px 10px; float: right;">
816
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="0" />
817
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="1" id="process-php-h" <?php if ($adH->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
818
+ <label for="process-php-h" title="Process PHP code">Process PHP</label>
819
  </div>
820
 
821
  <div style="display: inline-block; padding: 1px 10px; float: right;">
836
  <div style="padding: 0;">
837
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
838
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
839
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" id="enable-footer" value="1" <?php if ($adF->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
840
+ <label for="enable-footer" title="Enable or disable insertion of this code into HTML page footer">Enable</label> &nbsp;&nbsp;
841
+
842
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="0" />
843
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" id="enable-footer-404" value="1" <?php if ($adF->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
844
+ <label for="enable-footer-404" title="Enable or disable insertion of this code into HTML page footer on page for Error 404: Page not found">Error 404 Page</label>
845
  </div>
846
 
847
  <div style="padding-left:4px;">
855
  <div style="display: inline-block; padding: 1px 10px; float: right;">
856
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="0" />
857
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="1" id="process-php-f" <?php if ($adF->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
858
+ <label for="process-php-f" title="Process PHP code">Process PHP</label>
859
  </div>
860
 
861
  <div style="display: inline-block; padding: 1px 10px; float: right;">
881
  <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false" name="<?php echo AI_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:120px; font-weight: bold; color: #e44;" />
882
  </div>
883
  <div style="float: right; padding: 1px 1px;">
884
+ <input name="<?php echo AI_FORM_SAVE; ?>" value="<?php echo $save_button_text; ?>" type="submit" style="display: none; border-radius: 5px; font-weight: bold;" />
885
  </div>
886
  </div>
887