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

Version Description

  • Delayed display moved to Misc group
  • Added option for scheduling to insert code only between specified dates (Pro only)
  • Added option for Geo targeting (Pro only)
  • Few minor bug fixes and cosmetic changes
Download this release

Release Info

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

Code changes from version 2.0.6 to 2.0.7

Files changed (8) hide show
  1. ad-inserter.php +65 -11
  2. class.php +75 -10
  3. constants.php +25 -9
  4. css/ad-inserter.css +23 -1
  5. includes/js/index.html +4 -0
  6. js/ad-inserter.js +168 -2
  7. readme.txt +86 -53
  8. settings.php +43 -28
ad-inserter.php CHANGED
@@ -1,16 +1,22 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.0.6
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
8
- Plugin URI: http://tinymonitor.com/ad-inserter
9
  */
10
 
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
14
  Ad Inserter 2.0.6 - 25 November 2016
15
  - Added support to filter subpages created by the <!--nextpage--> tag
16
  - Added option to import block name (Pro only)
@@ -326,6 +332,8 @@ $block_object = array ();
326
 
327
  ai_load_settings ();
328
 
 
 
329
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
330
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
331
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
@@ -534,7 +542,7 @@ function set_user () {
534
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
535
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
536
 
537
- if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
538
  }
539
 
540
  function set_page_type () {
@@ -600,8 +608,9 @@ function ai_log_block_status ($block, $ai_last_check) {
600
  case AI_CHECK_ID: $status .= "ID"; break;
601
  case AI_CHECK_URL: $status .= "URL"; break;
602
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
603
- case AI_CHECK_REFERER: $status .= "REFERER"; break;
604
- case AI_CHECK_DATE: $status .= "DATE"; break;
 
605
  case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
606
  case AI_CHECK_LOGGED_IN_USER: $status .= "LOGGED-IN USER"; break;
607
  case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
@@ -794,12 +803,18 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
794
  'jquery-ui-tabs',
795
  'jquery-ui-button',
796
  'jquery-ui-tooltip',
 
797
  ), AD_INSERTER_VERSION);
798
- wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
799
- wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
 
 
 
800
 
801
  // wp_add_inline_style ('ai-admin', AI_SETTINGS_STYLE);
802
 
 
 
803
  if (AI_SYNTAX_HIGHLIGHTING) {
804
  wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/src-min-noconflict/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
805
  wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/src-min-noconflict/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
@@ -982,7 +997,7 @@ function ai_meta_box_callback ($post) {
982
  echo '<thead style="font-weight: bold;">';
983
  echo ' <td>Block</td>';
984
  echo ' <td style="padding: 0 10px 0 10px;">Name</td>';
985
- echo ' <td style="padding: 0 10px 0 10px;">Automatic Display Type</td>';
986
  echo ' <td style="padding: 0 5px 0 5px;">Posts</td>';
987
  echo ' <td style="padding: 0 5px 0 5px;">Pages</td>';
988
  echo ' <td style="padding: 0 5px 0 5px;">Widget</td>';
@@ -1179,6 +1194,7 @@ function ai_write_debug_info ($write_processing_log = false) {
1179
  echo 'ID: ', get_the_ID(), "\n";
1180
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1181
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? remove_parameters_from_url ($_SERVER['HTTP_REFERER']) : "", "\n";
 
1182
  echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1183
  echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1184
  if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
@@ -1411,6 +1427,8 @@ function ai_check_plugin_options ($plugin_options = array ()) {
1411
  } else $plugin_options [$viewport_width_option_name] = '';
1412
  }
1413
 
 
 
1414
  return ($plugin_options);
1415
  }
1416
 
@@ -1616,6 +1634,36 @@ function get_viewport_width ($viewport_number) {
1616
  return ($plugin_db_options [$viewport_settins_name]);
1617
  }
1618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1619
  function filter_html_class ($str){
1620
 
1621
  $str = str_replace (array ("\\\""), array ("\""), $str);
@@ -1637,7 +1685,8 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1637
  if ($delete_escaped_backslashes)
1638
  $value = str_replace (array ("\\\""), array ("\""), $value);
1639
 
1640
- if ($option == AI_OPTION_DOMAIN_LIST) {
 
1641
  $value = str_replace (array ("\\", "/", "?", "\"", "<", ">", "[", "]"), "", $value);
1642
  $value = esc_html ($value);
1643
  }
@@ -1651,6 +1700,7 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1651
  elseif ($option == AI_OPTION_NAME ||
1652
  $option == AI_OPTION_GENERAL_TAG ||
1653
  $option == AI_OPTION_DOMAIN_LIST ||
 
1654
  $option == AI_OPTION_CATEGORY_LIST ||
1655
  $option == AI_OPTION_TAG_LIST ||
1656
  $option == AI_OPTION_ID_LIST ||
@@ -1668,6 +1718,8 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1668
  $option == AI_OPTION_MAX_PARAGRAPH_WORDS ||
1669
  $option == AI_OPTION_MAXIMUM_INSERTIONS ||
1670
  $option == AI_OPTION_AFTER_DAYS ||
 
 
1671
  $option == AI_OPTION_EXCERPT_NUMBER ||
1672
  $option == AI_OPTION_CUSTOM_CSS) {
1673
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
@@ -1703,7 +1755,7 @@ function ai_preview () {
1703
  }
1704
  }
1705
 
1706
- if (isset ($_GET ["export"])) {
1707
  $block = $_GET ["export"];
1708
  if (is_numeric ($block)) {
1709
  if ($block == 0) echo base64_encode (serialize ($ai_db_options));
@@ -1714,7 +1766,7 @@ function ai_preview () {
1714
  }
1715
  }
1716
 
1717
- if (isset ($_GET ["image"])) {
1718
  header ("Content-Type: image/png");
1719
  header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
1720
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
@@ -2015,6 +2067,8 @@ function ai_settings () {
2015
 
2016
  ai_load_settings ();
2017
 
 
 
2018
  delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
2019
  delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
2020
  delete_option (AD_OPTIONS);
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.0.7
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
8
+ Plugin URI: http://adinserter.pro/documentation
9
  */
10
 
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.0.7 - 23 December 2016
15
+ - Delayed display moved to Misc group
16
+ - Added option for scheduling to insert code only between specified dates (Pro only)
17
+ - Added option for Geo targeting (Pro only)
18
+ - Few minor bug fixes and cosmetic changes
19
+
20
  Ad Inserter 2.0.6 - 25 November 2016
21
  - Added support to filter subpages created by the <!--nextpage--> tag
22
  - Added option to import block name (Pro only)
332
 
333
  ai_load_settings ();
334
 
335
+ if (function_exists ('ai_load_globals')) ai_load_globals ();
336
+
337
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
338
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
339
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
542
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
543
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
544
 
545
+ // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
546
  }
547
 
548
  function set_page_type () {
608
  case AI_CHECK_ID: $status .= "ID"; break;
609
  case AI_CHECK_URL: $status .= "URL"; break;
610
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
611
+ case AI_CHECK_REFERER: $status .= "REFERER ". $obj->get_ad_domain_list(); break;
612
+ case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break;
613
+ case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break;
614
  case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
615
  case AI_CHECK_LOGGED_IN_USER: $status .= "LOGGED-IN USER"; break;
616
  case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
803
  'jquery-ui-tabs',
804
  'jquery-ui-button',
805
  'jquery-ui-tooltip',
806
+ 'jquery-ui-datepicker',
807
  ), AD_INSERTER_VERSION);
808
+ wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
809
+
810
+ if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
811
+
812
+ wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
813
 
814
  // wp_add_inline_style ('ai-admin', AI_SETTINGS_STYLE);
815
 
816
+ if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
817
+
818
  if (AI_SYNTAX_HIGHLIGHTING) {
819
  wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/src-min-noconflict/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
820
  wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/src-min-noconflict/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
997
  echo '<thead style="font-weight: bold;">';
998
  echo ' <td>Block</td>';
999
  echo ' <td style="padding: 0 10px 0 10px;">Name</td>';
1000
+ echo ' <td style="padding: 0 10px 0 10px;">Automatic Insertion</td>';
1001
  echo ' <td style="padding: 0 5px 0 5px;">Posts</td>';
1002
  echo ' <td style="padding: 0 5px 0 5px;">Pages</td>';
1003
  echo ' <td style="padding: 0 5px 0 5px;">Widget</td>';
1194
  echo 'ID: ', get_the_ID(), "\n";
1195
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1196
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? remove_parameters_from_url ($_SERVER['HTTP_REFERER']) : "", "\n";
1197
+ if (function_exists ('ai_debug')) ai_debug ();
1198
  echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1199
  echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1200
  if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
1427
  } else $plugin_options [$viewport_width_option_name] = '';
1428
  }
1429
 
1430
+ if (function_exists ('ai_check_options')) ai_check_options ($plugin_options);
1431
+
1432
  return ($plugin_options);
1433
  }
1434
 
1634
  return ($plugin_db_options [$viewport_settins_name]);
1635
  }
1636
 
1637
+ function get_country_group_name ($group_number) {
1638
+ global $ai_db_options;
1639
+
1640
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1641
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
1642
+
1643
+ $country_group_settins_name = 'COUNTRY_GROUP_NAME_' . $group_number;
1644
+
1645
+ if (!isset ($plugin_db_options [$country_group_settins_name])) {
1646
+ $plugin_db_options [$country_group_settins_name] = DEFAULT_COUNTRY_GROUP_NAME . ' ' . $group_number;
1647
+ }
1648
+
1649
+ return ($plugin_db_options [$country_group_settins_name]);
1650
+ }
1651
+
1652
+ function get_group_country_list ($group_number) {
1653
+ global $ai_db_options;
1654
+
1655
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1656
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
1657
+
1658
+ $group_countries_settins_name = 'GROUP_COUNTRIES_' . $group_number;
1659
+
1660
+ if (!isset ($plugin_db_options [$group_countries_settins_name])) {
1661
+ $plugin_db_options [$group_countries_settins_name] = '';
1662
+ }
1663
+
1664
+ return ($plugin_db_options [$group_countries_settins_name]);
1665
+ }
1666
+
1667
  function filter_html_class ($str){
1668
 
1669
  $str = str_replace (array ("\\\""), array ("\""), $str);
1685
  if ($delete_escaped_backslashes)
1686
  $value = str_replace (array ("\\\""), array ("\""), $value);
1687
 
1688
+ if ($option == AI_OPTION_DOMAIN_LIST ||
1689
+ $option == AI_OPTION_COUNTRY_LIST) {
1690
  $value = str_replace (array ("\\", "/", "?", "\"", "<", ">", "[", "]"), "", $value);
1691
  $value = esc_html ($value);
1692
  }
1700
  elseif ($option == AI_OPTION_NAME ||
1701
  $option == AI_OPTION_GENERAL_TAG ||
1702
  $option == AI_OPTION_DOMAIN_LIST ||
1703
+ $option == AI_OPTION_COUNTRY_LIST ||
1704
  $option == AI_OPTION_CATEGORY_LIST ||
1705
  $option == AI_OPTION_TAG_LIST ||
1706
  $option == AI_OPTION_ID_LIST ||
1718
  $option == AI_OPTION_MAX_PARAGRAPH_WORDS ||
1719
  $option == AI_OPTION_MAXIMUM_INSERTIONS ||
1720
  $option == AI_OPTION_AFTER_DAYS ||
1721
+ $option == AI_OPTION_START_DATE ||
1722
+ $option == AI_OPTION_END_DATE ||
1723
  $option == AI_OPTION_EXCERPT_NUMBER ||
1724
  $option == AI_OPTION_CUSTOM_CSS) {
1725
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
1755
  }
1756
  }
1757
 
1758
+ elseif (isset ($_GET ["export"])) {
1759
  $block = $_GET ["export"];
1760
  if (is_numeric ($block)) {
1761
  if ($block == 0) echo base64_encode (serialize ($ai_db_options));
1766
  }
1767
  }
1768
 
1769
+ elseif (isset ($_GET ["image"])) {
1770
  header ("Content-Type: image/png");
1771
  header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
1772
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2067
 
2068
  ai_load_settings ();
2069
 
2070
+ if (function_exists ('ai_load_globals')) ai_load_globals ();
2071
+
2072
  delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
2073
  delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
2074
  delete_option (AD_OPTIONS);
class.php CHANGED
@@ -354,7 +354,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
354
  $this->wp_options [AI_OPTION_DIRECTION_TYPE] = AD_DIRECTION_FROM_TOP;
355
  $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] = AD_ALIGNMENT_NONE;
356
  $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
357
- $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_ZERO;
 
 
 
358
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
359
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
360
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
@@ -364,6 +367,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
364
  $this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE] = AD_BLACK_LIST;
365
  $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
366
  $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
 
 
367
  $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
368
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
369
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
@@ -851,9 +856,30 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
851
  return $option;
852
  }
853
 
 
 
 
 
 
 
 
 
 
 
 
854
  public function get_ad_after_day(){
855
  $option = isset ($this->wp_options [AI_OPTION_AFTER_DAYS]) ? $this->wp_options [AI_OPTION_AFTER_DAYS] : "";
856
- if ($option == '') $option = AD_ZERO;
 
 
 
 
 
 
 
 
 
 
857
  return $option;
858
  }
859
 
@@ -906,6 +932,18 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
906
  return $option;
907
  }
908
 
 
 
 
 
 
 
 
 
 
 
 
 
909
  public function get_ad_name(){
910
  $option = isset ($this->wp_options [AI_OPTION_NAME]) ? $this->wp_options [AI_OPTION_NAME] : "";
911
  if ($option == '') $option = AD_NAME. " " . $this->number;
@@ -1786,15 +1824,36 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1786
  return !$return;
1787
  }
1788
 
1789
- function check_date () {
1790
 
1791
- $after_days = intval ($this->get_ad_after_day());
1792
- if ($after_days == AD_ZERO) return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
1793
 
1794
- $post_date = get_the_date ('U');
1795
- if ($post_date === false) return true;
 
 
1796
 
1797
- return (date ('U', time ()) >= $post_date + $after_days * 86400);
 
 
 
 
 
 
1798
  }
1799
 
1800
  function check_referer () {
@@ -1902,8 +1961,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1902
  $ai_last_check = AI_CHECK_REFERER;
1903
  if (!$this->check_referer ()) return false;
1904
 
1905
- $ai_last_check = AI_CHECK_DATE;
1906
- if (!$this->check_date ()) return false;
 
 
 
 
1907
 
1908
  $ai_last_check = AI_CHECK_CODE;
1909
  if ($this->ai_getCode () == '') return false;
@@ -2205,6 +2268,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2205
  $ad_data = preg_replace ("/{author}/i", $author, $ad_data);
2206
  $ad_data = preg_replace ("/{author_name}/i", $author_name, $ad_data);
2207
 
 
 
2208
  return $ad_data;
2209
  }
2210
  }
354
  $this->wp_options [AI_OPTION_DIRECTION_TYPE] = AD_DIRECTION_FROM_TOP;
355
  $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] = AD_ALIGNMENT_NONE;
356
  $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
357
+ $this->wp_options [AI_OPTION_SCHEDULING] = AI_SCHEDULING_OFF;
358
+ $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_EMPTY_DATA;
359
+ $this->wp_options [AI_OPTION_START_DATE] = AD_EMPTY_DATA;
360
+ $this->wp_options [AI_OPTION_END_DATE] = AD_EMPTY_DATA;
361
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
362
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
363
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
367
  $this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE] = AD_BLACK_LIST;
368
  $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
369
  $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
370
+ $this->wp_options [AI_OPTION_COUNTRY_LIST] = AD_EMPTY_DATA;
371
+ $this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE] = AD_BLACK_LIST;
372
  $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
373
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
374
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
856
  return $option;
857
  }
858
 
859
+ public function get_scheduling(){
860
+ $option = isset ($this->wp_options [AI_OPTION_SCHEDULING]) ? $this->wp_options [AI_OPTION_SCHEDULING] : "";
861
+
862
+ // Convert old option
863
+ if ($option == '' && intval ($this->get_ad_after_day()) != 0) $option = AI_SCHEDULING_DELAY;
864
+
865
+ if ($option == '') $option = AI_SCHEDULING_OFF;
866
+
867
+ return $option;
868
+ }
869
+
870
  public function get_ad_after_day(){
871
  $option = isset ($this->wp_options [AI_OPTION_AFTER_DAYS]) ? $this->wp_options [AI_OPTION_AFTER_DAYS] : "";
872
+ // if ($option == '') $option = AD_ZERO;
873
+ return $option;
874
+ }
875
+
876
+ public function get_schedule_start_date(){
877
+ $option = isset ($this->wp_options [AI_OPTION_START_DATE]) ? $this->wp_options [AI_OPTION_START_DATE] : "";
878
+ return $option;
879
+ }
880
+
881
+ public function get_schedule_end_date(){
882
+ $option = isset ($this->wp_options [AI_OPTION_END_DATE]) ? $this->wp_options [AI_OPTION_END_DATE] : "";
883
  return $option;
884
  }
885
 
932
  return $option;
933
  }
934
 
935
+ public function get_ad_country_list ($expand = false){
936
+ $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST] : "";
937
+ if ($expand && function_exists ('expanded_country_list')) return expanded_country_list ($option);
938
+ return $option;
939
+ }
940
+
941
+ public function get_ad_country_list_type (){
942
+ $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE] : "";
943
+ if ($option == '') $option = AD_BLACK_LIST;
944
+ return $option;
945
+ }
946
+
947
  public function get_ad_name(){
948
  $option = isset ($this->wp_options [AI_OPTION_NAME]) ? $this->wp_options [AI_OPTION_NAME] : "";
949
  if ($option == '') $option = AD_NAME. " " . $this->number;
1824
  return !$return;
1825
  }
1826
 
1827
+ function check_scheduling () {
1828
 
1829
+ switch ($this->get_scheduling()) {
1830
+ case AI_SCHEDULING_OFF:
1831
+ return true;
1832
+ break;
1833
+
1834
+ case AI_SCHEDULING_DELAY:
1835
+ $after_days = trim ($this->get_ad_after_day());
1836
+ if ($after_days == '') return true;
1837
+ if (intval ($after_days) == AD_ZERO) return true;
1838
+
1839
+ $post_date = get_the_date ('U');
1840
+ if ($post_date === false) return true;
1841
+
1842
+ return (date ('U', current_time ('timestamp')) >= $post_date + $after_days * 86400);
1843
+ break;
1844
 
1845
+ case AI_SCHEDULING_BETWEEN_DATES:
1846
+ $current_time = current_time ('timestamp');
1847
+ $start_date = strtotime ($this->get_schedule_start_date(), $current_time);
1848
+ $end_date = strtotime ($this->get_schedule_end_date(), $current_time);
1849
 
1850
+ return ($current_time >= $start_date && $current_time < $end_date);
1851
+ break;
1852
+
1853
+ default:
1854
+ return true;
1855
+ break;
1856
+ }
1857
  }
1858
 
1859
  function check_referer () {
1961
  $ai_last_check = AI_CHECK_REFERER;
1962
  if (!$this->check_referer ()) return false;
1963
 
1964
+ if (function_exists ('ai_check_lists')) {
1965
+ if (!ai_check_lists ($this)) return false;
1966
+ }
1967
+
1968
+ $ai_last_check = AI_CHECK_SCHEDULING;
1969
+ if (!$this->check_scheduling ()) return false;
1970
 
1971
  $ai_last_check = AI_CHECK_CODE;
1972
  if ($this->ai_getCode () == '') return false;
2268
  $ad_data = preg_replace ("/{author}/i", $author, $ad_data);
2269
  $ad_data = preg_replace ("/{author_name}/i", $author_name, $ad_data);
2270
 
2271
+ if (function_exists ('ai_tags')) ai_tags ($ad_data);
2272
+
2273
  return $ad_data;
2274
  }
2275
  }
constants.php CHANGED
@@ -11,13 +11,7 @@ if (!defined( 'AD_INSERTER_NAME'))
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '2.0.6');
15
-
16
- if (!defined ('AD_INSERTER_BLOCKS'))
17
- define ('AD_INSERTER_BLOCKS', 16);
18
-
19
- if (!defined ('AD_INSERTER_VIEWPORTS'))
20
- define ('AD_INSERTER_VIEWPORTS', 3);
21
 
22
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
23
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -93,7 +87,10 @@ define ('AI_OPTION_FILTER_TYPE', 'filter_type');
93
  define ('AI_OPTION_DIRECTION_TYPE', 'direction_type');
94
  define ('AI_OPTION_ALIGNMENT_TYPE', 'alignment_type');
95
  define ('AI_OPTION_GENERAL_TAG', 'general_tag');
 
96
  define ('AI_OPTION_AFTER_DAYS', 'after_days');
 
 
97
  define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
98
  define ('AI_OPTION_ID_LIST', 'id_list');
99
  define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
@@ -103,6 +100,8 @@ define ('AI_OPTION_URL_PARAMETER_LIST', 'url_parameter_list');
103
  define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
104
  define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
105
  define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
 
 
106
  define ('AI_OPTION_CATEGORY_LIST', 'category_list');
107
  define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
108
  define ('AI_OPTION_TAG_LIST', 'tag_list');
@@ -129,7 +128,6 @@ define ('AI_OPTION_DISABLED', 'disabled');
129
  define ('AI_OPTION_IMPORT', 'import');
130
  define ('AI_OPTION_IMPORT_NAME', 'import_name');
131
 
132
-
133
  //misc
134
  define('AD_EMPTY_VALUE','');
135
 
@@ -227,6 +225,15 @@ define('AD_BELOW','below');
227
  define('AD_ABOVE_AND_THEN_BELOW','above and then below');
228
  define('AD_BELOW_AND_THEN_ABOVE','below and then above');
229
 
 
 
 
 
 
 
 
 
 
230
  //Settings
231
  define('AD_SETTINGS_CHECKED', '1');
232
  define('AD_SETTINGS_NOT_CHECKED', '0');
@@ -254,6 +261,8 @@ define ('DEFAULT_VIEWPORT_WIDTH_1', 980);
254
  define ('DEFAULT_VIEWPORT_WIDTH_2', 768);
255
  define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
256
 
 
 
257
  define ('CONTENT_HOOK_BLOCKS', 'content_hook');
258
  define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
259
  define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
@@ -282,7 +291,7 @@ define ('AI_CHECK_CATEGORY', 15);
282
  define ('AI_CHECK_TAG', 16);
283
  define ('AI_CHECK_URL', 17);
284
  define ('AI_CHECK_REFERER', 18);
285
- define ('AI_CHECK_DATE', 19);
286
  define ('AI_CHECK_CODE', 20);
287
  define ('AI_CHECK_LOGGED_IN_USER', 21);
288
  define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
@@ -310,6 +319,7 @@ define ('AI_CHECK_DO_NOT_INSERT', 42);
310
  define ('AI_CHECK_AD_ABOVE', 43);
311
  define ('AI_CHECK_AD_BELOW', 44);
312
  define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
 
313
 
314
  define ('AI_PT_NONE', - 1);
315
  define ('AI_PT_ANY', 0);
@@ -363,6 +373,12 @@ define ('AI_DEBUG_TAGS', 0x04);
363
  define ('AI_DEBUG_POSITIONS', 0x08);
364
  define ('AI_DEBUG_NO_INSERTION', 0x10);
365
 
 
 
 
 
 
 
366
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
367
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
368
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '2.0.7');
 
 
 
 
 
 
15
 
16
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
17
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
87
  define ('AI_OPTION_DIRECTION_TYPE', 'direction_type');
88
  define ('AI_OPTION_ALIGNMENT_TYPE', 'alignment_type');
89
  define ('AI_OPTION_GENERAL_TAG', 'general_tag');
90
+ define ('AI_OPTION_SCHEDULING', 'scheduling');
91
  define ('AI_OPTION_AFTER_DAYS', 'after_days');
92
+ define ('AI_OPTION_START_DATE', 'start_date');
93
+ define ('AI_OPTION_END_DATE', 'end_date');
94
  define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
95
  define ('AI_OPTION_ID_LIST', 'id_list');
96
  define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
100
  define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
101
  define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
102
  define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
103
+ define ('AI_OPTION_COUNTRY_LIST', 'country_list');
104
+ define ('AI_OPTION_COUNTRY_LIST_TYPE', 'country_list_type');
105
  define ('AI_OPTION_CATEGORY_LIST', 'category_list');
106
  define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
107
  define ('AI_OPTION_TAG_LIST', 'tag_list');
128
  define ('AI_OPTION_IMPORT', 'import');
129
  define ('AI_OPTION_IMPORT_NAME', 'import_name');
130
 
 
131
  //misc
132
  define('AD_EMPTY_VALUE','');
133
 
225
  define('AD_ABOVE_AND_THEN_BELOW','above and then below');
226
  define('AD_BELOW_AND_THEN_ABOVE','below and then above');
227
 
228
+ // Scheduling
229
+ define('AI_SCHEDULING_OFF', 0);
230
+ define('AI_SCHEDULING_DELAY', 1);
231
+ define('AI_SCHEDULING_BETWEEN_DATES', 2);
232
+
233
+ define('AI_TEXT_OFF', 'Insert immediately');
234
+ define('AI_TEXT_DELAY_DISPLAY', 'Delay insertion');
235
+ define('AI_TEXT_DISPLAY_BETWEEN_DATES', 'Insert between dates');
236
+
237
  //Settings
238
  define('AD_SETTINGS_CHECKED', '1');
239
  define('AD_SETTINGS_NOT_CHECKED', '0');
261
  define ('DEFAULT_VIEWPORT_WIDTH_2', 768);
262
  define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
263
 
264
+ define ('DEFAULT_COUNTRY_GROUP_NAME', "Group");
265
+
266
  define ('CONTENT_HOOK_BLOCKS', 'content_hook');
267
  define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
268
  define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
291
  define ('AI_CHECK_TAG', 16);
292
  define ('AI_CHECK_URL', 17);
293
  define ('AI_CHECK_REFERER', 18);
294
+ define ('AI_CHECK_SCHEDULING', 19);
295
  define ('AI_CHECK_CODE', 20);
296
  define ('AI_CHECK_LOGGED_IN_USER', 21);
297
  define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
319
  define ('AI_CHECK_AD_ABOVE', 43);
320
  define ('AI_CHECK_AD_BELOW', 44);
321
  define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
322
+ define ('AI_CHECK_COUNTRY', 46);
323
 
324
  define ('AI_PT_NONE', - 1);
325
  define ('AI_PT_ANY', 0);
373
  define ('AI_DEBUG_POSITIONS', 0x08);
374
  define ('AI_DEBUG_NO_INSERTION', 0x10);
375
 
376
+ if (!defined ('AD_INSERTER_BLOCKS'))
377
+ define ('AD_INSERTER_BLOCKS', 16);
378
+
379
+ if (!defined ('AD_INSERTER_VIEWPORTS'))
380
+ define ('AD_INSERTER_VIEWPORTS', 3);
381
+
382
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
383
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
384
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #data {
2
- font-family: "2.0.6"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -70,6 +70,7 @@
70
  white-space: nowrap;
71
  padding: 0;
72
  }
 
73
  .no-select {
74
  -webkit-user-select: none; /* Chrome all / Safari all */
75
  -moz-user-select: none; /* Firefox all */
@@ -153,3 +154,24 @@
153
  }
154
  }
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #data {
2
+ font-family: "2.0.7"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
70
  white-space: nowrap;
71
  padding: 0;
72
  }
73
+
74
  .no-select {
75
  -webkit-user-select: none; /* Chrome all / Safari all */
76
  -moz-user-select: none; /* Firefox all */
154
  }
155
  }
156
 
157
+ .ms-container {
158
+ width: 100%;
159
+ font-size: 12px;
160
+ }
161
+
162
+ .ms-container .ms-selectable li.ms-elem-selectable, .ms-container .ms-selection li.ms-elem-selection {
163
+ padding: 1px 10px;
164
+ font-size: 12px;
165
+ }
166
+
167
+ .ms-container dd, li {
168
+ margin-bottom: 4px;
169
+ }
170
+ .ms-container .search-input {
171
+ width: 100%;
172
+ border-radius: 4px;
173
+ }
174
+
175
+ .ms-container div.ms-selection {
176
+ margin-top: 24px;
177
+ }
includes/js/index.html ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <html>
2
+ <body bgcolor="#FFFFFF">
3
+ </body>
4
+ </html>
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.0.6";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -11,6 +11,8 @@ var next_tab = 0;
11
  var syntax_highlighting = false;
12
  var settings_page = "";
13
 
 
 
14
  var shSettings = {
15
  "tab_size":"4",
16
  "use_soft_tabs":"1",
@@ -196,6 +198,53 @@ jQuery(document).ready(function($) {
196
  } else editor.getSession ().setMode ("ace/mode/html");
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  function process_display_elements (block) {
200
 
201
  $("#paragraph-settings-"+block).hide();
@@ -214,7 +263,8 @@ jQuery(document).ready(function($) {
214
  $("#paragraph-clearance-"+block).hide();
215
  }
216
 
217
- if (display_type == "Before Paragraph" || display_type == "After Paragraph" || display_type == "Before Content" || display_type == "After Content") {
 
218
  $("#content-settings-"+block).show();
219
  }
220
 
@@ -277,6 +327,25 @@ jQuery(document).ready(function($) {
277
  $("#check-up-to-"+block).hide (); else
278
  $("#check-up-to-"+block).show ();
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  if (syntax_highlighting) configure_editor_language (block);
281
  }
282
 
@@ -364,6 +433,10 @@ jQuery(document).ready(function($) {
364
 
365
  if (syntax_highlighting) configure_editor_language ('h');
366
  if (syntax_highlighting) configure_editor_language ('f');
 
 
 
 
367
  }
368
 
369
  function configure_tab (tab) {
@@ -398,6 +471,10 @@ jQuery(document).ready(function($) {
398
  var block = $(this).attr('id').replace ("display-for-devices-", "");
399
  process_display_elements (block);
400
  });
 
 
 
 
401
 
402
  $("#display-homepage-"+tab).change (function() {
403
  var block = $(this).attr('id').replace ("display-homepage-", "");
@@ -421,6 +498,16 @@ jQuery(document).ready(function($) {
421
  process_display_elements (block);
422
  });
423
 
 
 
 
 
 
 
 
 
 
 
424
  $("select#avoid-action-"+tab).change (function() {
425
  var block = $(this).attr('id').replace ("avoid-action-", "");
426
  process_display_elements (block);
@@ -457,6 +544,9 @@ jQuery(document).ready(function($) {
457
  $("#paragraph-clearance-" + block).toggle ();
458
  });
459
 
 
 
 
460
  $("#edit-css-button-"+tab).button ({
461
  }).click (function () {
462
  var block = $(this).attr('id').replace ("edit-css-button-", "");
@@ -589,6 +679,13 @@ jQuery(document).ready(function($) {
589
  $("#misc-settings-" + block).toggle ();
590
  });
591
 
 
 
 
 
 
 
 
592
  $("#preview-button-"+tab).button ({
593
  }).show ().click (function () {
594
  var block = $(this).attr ("id");
@@ -632,6 +729,75 @@ jQuery(document).ready(function($) {
632
  var window_top = (screen.height / 2) - (820 / 2);
633
  var preview_window = window.open (page, 'preview','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');
634
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  }
636
 
637
  function configure_hidden_tab () {
1
+ var javascript_version = "2.0.7";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
11
  var syntax_highlighting = false;
12
  var settings_page = "";
13
 
14
+ var dateFormat = "yy-mm-dd";
15
+
16
  var shSettings = {
17
  "tab_size":"4",
18
  "use_soft_tabs":"1",
198
  } else editor.getSession ().setMode ("ace/mode/html");
199
  }
200
 
201
+ function getDate (element) {
202
+ var date;
203
+ try {
204
+ date = $.datepicker.parseDate (dateFormat, element.val ());
205
+ } catch (error) {
206
+ date = null;
207
+ }
208
+
209
+ return date;
210
+ }
211
+
212
+ function process_scheduling_dates (block) {
213
+ var start_date_picker = $("#scheduling-on-"+block);
214
+ var end_date_picker = $("#scheduling-off-"+block);
215
+ var start_date = getDate (start_date_picker);
216
+ var end_date = getDate (end_date_picker);
217
+ var date_text = $("#scheduling-text-"+block);
218
+
219
+ date_text.text ("");
220
+ date_text.css ("color", "#222");
221
+ end_date_picker.css ("border-color", "#ddd");
222
+
223
+ if (start_date == null) {
224
+ date_text.text ("");
225
+ } else
226
+ if (end_date == null) {
227
+ date_text.text ("");
228
+ } else
229
+ if (end_date > start_date) {
230
+ var now = new Date();
231
+ var today_date = new Date (now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
232
+ if (end_date <= today_date) {
233
+ var expiration = Math.round ((today_date - end_date) / 1000 / 3600 / 24);
234
+ date_text.text ("Invalid end date - insertion already expired ");
235
+ date_text.css ("color", "#d00");
236
+ end_date_picker.css ("border-color", "#d00");
237
+ } else {
238
+ var duration = Math.round ((end_date - start_date) / 1000 / 3600 / 24);
239
+ date_text.text (" Duration: " + duration + " day" + (duration == 1 ? "" : "s"));
240
+ }
241
+ } else {
242
+ date_text.text ("Invalid end date - must be after start date");
243
+ date_text.css ("color", "#d00");
244
+ end_date_picker.css ("border-color", "#d00");
245
+ }
246
+ }
247
+
248
  function process_display_elements (block) {
249
 
250
  $("#paragraph-settings-"+block).hide();
263
  $("#paragraph-clearance-"+block).hide();
264
  }
265
 
266
+ var content_settings = display_type == "Before Paragraph" || display_type == "After Paragraph" || display_type == "Before Content" || display_type == "After Content";
267
+ if (content_settings) {
268
  $("#content-settings-"+block).show();
269
  }
270
 
327
  $("#check-up-to-"+block).hide (); else
328
  $("#check-up-to-"+block).show ();
329
 
330
+
331
+ $("#scheduling-delay-"+block).hide();
332
+ $("#scheduling-between-dates-"+block).hide();
333
+ $("#scheduling-delay-warning-"+block).hide();
334
+
335
+ var scheduling = $("select#scheduling-"+block).val();
336
+
337
+ if (scheduling == "1") {
338
+ if (content_settings) {
339
+ $("#scheduling-delay-"+block).show();
340
+ } else {
341
+ $("#scheduling-delay-warning-"+block).show();
342
+ }
343
+ } else
344
+ if (scheduling == "2") {
345
+ $("#scheduling-between-dates-"+block).show();
346
+ process_scheduling_dates (block);
347
+ }
348
+
349
  if (syntax_highlighting) configure_editor_language (block);
350
  }
351
 
433
 
434
  if (syntax_highlighting) configure_editor_language ('h');
435
  if (syntax_highlighting) configure_editor_language ('f');
436
+
437
+ for (var index = 1; index <= 6; index ++) {
438
+ generate_country_list ('group-country', index);
439
+ }
440
  }
441
 
442
  function configure_tab (tab) {
471
  var block = $(this).attr('id').replace ("display-for-devices-", "");
472
  process_display_elements (block);
473
  });
474
+ $("select#scheduling-"+tab).change (function() {
475
+ var block = $(this).attr('id').replace ("scheduling-", "");
476
+ process_display_elements (block);
477
+ });
478
 
479
  $("#display-homepage-"+tab).change (function() {
480
  var block = $(this).attr('id').replace ("display-homepage-", "");
498
  process_display_elements (block);
499
  });
500
 
501
+ $("#scheduling-on-"+tab).change (function() {
502
+ var block = $(this).attr('id').replace ("scheduling-on-", "");
503
+ process_scheduling_dates (block);
504
+ });
505
+
506
+ $("#scheduling-off-"+tab).change (function() {
507
+ var block = $(this).attr('id').replace ("scheduling-off-", "");
508
+ process_scheduling_dates (block);
509
+ });
510
+
511
  $("select#avoid-action-"+tab).change (function() {
512
  var block = $(this).attr('id').replace ("avoid-action-", "");
513
  process_display_elements (block);
544
  $("#paragraph-clearance-" + block).toggle ();
545
  });
546
 
547
+ $("#scheduling-on-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
548
+ $("#scheduling-off-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
549
+
550
  $("#edit-css-button-"+tab).button ({
551
  }).click (function () {
552
  var block = $(this).attr('id').replace ("edit-css-button-", "");
679
  $("#misc-settings-" + block).toggle ();
680
  });
681
 
682
+ $("#scheduling-button-"+tab).button ({
683
+ }).show ().click (function () {
684
+ var block = $(this).attr ("id");
685
+ block = block.replace ("scheduling-button-","");
686
+ $("#scheduling-settings-" + block).toggle ();
687
+ });
688
+
689
  $("#preview-button-"+tab).button ({
690
  }).show ().click (function () {
691
  var block = $(this).attr ("id");
729
  var window_top = (screen.height / 2) - (820 / 2);
730
  var preview_window = window.open (page, 'preview','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');
731
  });
732
+
733
+ generate_country_list ('country', tab);
734
+ }
735
+
736
+ function generate_country_list (element_name_prefix, index) {
737
+ if ($('#'+element_name_prefix+'-select-'+index).length !== 0) {
738
+
739
+ $('#'+element_name_prefix+'-list-'+index).click (function () {
740
+ if (!$('#'+element_name_prefix+'-select-'+index).hasClass ('multi-select')) {
741
+ $('#'+element_name_prefix+'-select-'+index).addClass ('multi-select');
742
+ $('#'+element_name_prefix+'-select-'+index).multiSelect({
743
+ selectableHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='Search...'>",
744
+ selectedHeader: "Selected Countries",
745
+ afterInit: function(ms){
746
+ var that = this,
747
+ $selectableSearch = that.$selectableUl.prev(),
748
+ $selectionSearch = that.$selectionUl.prev(),
749
+ selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
750
+ selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
751
+
752
+ that.qs1 = $selectableSearch.quicksearch (selectableSearchString)
753
+ .on('keydown', function(e){
754
+ if (e.which === 40){
755
+ that.$selectableUl.focus();
756
+ return false;
757
+ }
758
+ });
759
+
760
+ that.qs2 = $selectionSearch.quicksearch (selectionSearchString)
761
+ .on('keydown', function(e){
762
+ if (e.which == 40){
763
+ that.$selectionUl.focus();
764
+ return false;
765
+ }
766
+ });
767
+ },
768
+ afterSelect: function(values){
769
+ update_country_list (this, element_name_prefix);
770
+ },
771
+ afterDeselect: function(values){
772
+ update_country_list (this, element_name_prefix);
773
+ }
774
+ });
775
+ $('#ms-'+element_name_prefix+'-select-'+index).hide();
776
+ }
777
+ update_country_selection ($(this), element_name_prefix, true)
778
+ }).focusout (function () {
779
+ update_country_selection ($(this), element_name_prefix)
780
+ });
781
+ }
782
+ }
783
+
784
+ function update_country_list (select_element, element_name_prefix) {
785
+ var ms = select_element.$element;
786
+ var ms_val = ms.val();
787
+ var index = ms.attr ('id').replace (element_name_prefix+'-select-','');
788
+ $('#'+element_name_prefix+'-list-'+index).attr ('value', ms_val);
789
+ select_element.qs1.cache();
790
+ select_element.qs2.cache();
791
+ }
792
+
793
+ function update_country_selection (select_element, element_name_prefix, toggle = false) {
794
+ var index = select_element.attr ('id');
795
+ var index = index.replace (element_name_prefix+'-list-','');
796
+ if (toggle) $('#ms-'+element_name_prefix+'-select-'+index).toggle();
797
+ if ($('#ms-'+element_name_prefix+'-select-'+index).is(':visible')) {
798
+ var country_array = $('#'+element_name_prefix+'-list-'+index).attr ('value').replace(/ /g , '').toUpperCase().split (',');
799
+ $('#'+element_name_prefix+'-select-'+index).multiSelect ('deselect_all').multiSelect ('select', country_array).multiSelect('refresh');
800
+ }
801
  }
802
 
803
  function configure_hidden_tab () {
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
- Tags: adsense, amazon, clickbank, advertising, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, rotation, multisite, 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.7
7
  Stable tag: 2.0.6
@@ -28,6 +28,7 @@ A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect
28
  > * Simple troubleshooting with many debugging functions to visualize inserted code blocks, available insertion positions, HTML tags, etc.
29
  >
30
  > Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features.
 
31
 
32
  Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress.
33
 
@@ -44,45 +45,45 @@ There is also <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</
44
 
45
  **Quick Start**
46
 
47
- Few very important things you need to know in order to <a href="http://tinymonitor.com/ad-inserter#quick-start">insert code and display some ad</a>:
48
 
49
- * **Enable and use at least one display option** (Automatic Display, Widget, Shortcode, PHP function call)
50
- * **Enable display on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
51
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
52
- * If you don't see inserted code block turn on **debuging functions**: Label inserted blocks, Show available positions for automatic display (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
53
 
54
  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 and instructions for **Debugging**.
55
 
56
  **Settings**
57
 
58
- Each code block has 4 display options:
59
 
60
- * Automatic Display
61
  * Widget
62
  * Shortcode
63
  * PHP function call
64
 
65
- Normally for each code block you use only one display option.
66
- Of course, you can use all 4 options simultaneously taking into account that all display options use the same block settings (with some exceptions mentioned below).
67
 
68
- To rename code block click on the block name. To display code block (ad) at some position **you need to enable and use at least one display option**.
69
 
70
- Automatic Display Options:
71
 
72
- * Display Before Post (before post or posts on blog pages, previously named Before Title)
73
- * Display Before Content (before post or static page text)
74
- * Display Before Paragraph (on posts, static pages and blog pages)
75
- * Display After Paragraph (on posts, static pages and blog pages)
76
- * Display After Content (after post or static page text)
77
- * Display After Post (after post or posts on blog pages)
78
- * Display Before Excerpt (on blog pages)
79
- * Display After Excerpt (on blog pages)
80
 
81
- 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.
82
 
83
- 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.
84
 
85
- Order of display positions in a typical post is the following:
86
 
87
  * [Before Post]
88
  * Post Title
@@ -99,7 +100,7 @@ Order of display positions in a typical post is the following:
99
 
100
  Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab *).
101
 
102
- Please use **Show positions** function to see available positions for automatic display (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page).
103
 
104
  Block Alignment and Style:
105
 
@@ -132,7 +133,7 @@ Check <a href="https://wordpress.org/plugins/ad-inserter/screenshots/">screensho
132
  **PLEASE NOTE:** If you are using **No Wrapping** style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-viewport-1, ai-viewport-2, ai-viewport-3).
133
  This doesn't apply to widgets as they always contain a wrapping div.
134
 
135
- For all display positions you can also define Wordpress page types where the ads can be displayed. **PLEASE NOTE:** Regardles of other settings you need to enable display on AT LEAST ONE PAGE TYPE:
136
 
137
  Single pages:
138
 
@@ -153,11 +154,14 @@ Insertion (located in the Misc section) is possible also for:
153
 
154
  **Please Note** For shortcodes and PHP function calls it is possible to ignore enabled page types and use them on any page. See down for details.
155
 
156
- 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).
 
 
 
157
 
158
  **PARAGRAPHS**
159
 
160
- Paragraph number for Automatic Display options Before and After Paragraph:
161
 
162
  * 0 means random paragraph position
163
  * value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
@@ -171,14 +175,15 @@ If more than one text is defined (comma separated) and "contain" is selected the
171
  Paragraphs are not counted inside `<blockquote>` elements. Of course, there is an option to enable counting also inside `<blockquote>`.
172
 
173
  **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,
174
- 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) empty (means all posts on the blog page) and define maximum number of insertions.
 
175
 
176
  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**).
177
 
178
  **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>`.
179
  **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.
180
 
181
- Minimum number of paragraphs / Minimum/Maximum page/post words: do not display ad if the number of paragraphs or the number of words is below or above limit (used only for position Before or After selected paragraph).
182
 
183
  **[ Clearance ]**
184
 
@@ -193,7 +198,7 @@ On every post/page there is a toolbar on the top. Ad Inserter menu item has few
193
 
194
  **Additional Post/Static Page Options**
195
 
196
- You can define post/page minimum and maximum word length. Display after N days checks the date when the post was published and delays publishing.
197
 
198
  Additional Options for code blocks:
199
 
@@ -201,6 +206,7 @@ PHP processing: Enabled or Disabled - Enable processing of PHP code. If there is
201
 
202
  * Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
203
  * Use {author} for post author username or {author_name} for post author name to insert post author data into code blocks (**works only inside posts**)
 
204
  * To rotate different ad versions separate them with `|rotate|` - Ad Inserter will randomly select one of the ads
205
 
206
  WARNING: If you are using caching ad rotation may not work as expected. It works only when the page is generated and Ad Inserter is called. In such cases please make sure you have disabled caching when you are using |rotate|.
@@ -238,30 +244,42 @@ Display Block to:
238
 
239
  **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.
240
 
 
 
 
 
 
 
 
 
241
  **[ Lists ]**
242
 
243
- Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list):
244
  leave category list empty and set it to Black list to show ads in all categories.
245
 
246
  **WARNING:** If category name contains commas or spaces, use category slug instead. Also make sure you have enabled display on **Category pages**.
247
 
248
- 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**.
249
 
250
- Do not display ads in posts/pages with certain post IDs (black list) or display ads only in posts with certain IDs (white list). Leave Post ID list empty and set it to Black list to show ads for all IDs.
251
 
252
- Do not display ads on pages with certain urls (black list) or display ads only on pages with certain urls (white list): leave url list empty and set it to Black list to show ads for all urls.
253
  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`
254
  You can also use partial urls with *. To filter all urls starting with /url-start use `/url-start*`, to filter all urls that contain url-pattern use `*url-pattern*`, to filter all urls ending with url-end use `*url-end`.
255
  **WARNING:** Separate urls with SPACES.
256
 
257
- Do not display ads on pages with certain url query parameters (black list) or display ads only on pages with certain url parameters (white list): leave url parameter list empty and set it to Black list to show ads for all url.
258
  You can specifiy either parameters or parameters with values. For example for url `http://example.com?data=2&customer-id=22&device=0` you can define url parameters '`data, customer-id=22`' to display ad only for urls where there is `data` paramteter and `customer-id` parameter with value 22.
259
  Separate parameters with comma.
260
 
261
- Do not display ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or display ads only for certain referrers (white list): use # for no referer (direct visit),
262
  leave referrers list empty and set it to Black list to show ads for all referrers.
263
 
264
- **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.
 
 
 
 
265
 
266
  **[ Devices ]**
267
 
@@ -279,7 +297,7 @@ leave referrers list empty and set it to Black list to show ads for all referrer
279
 
280
  **BUT BE CAREFUL:** Some ad networks (like AdSense) limit ads per page. The ads are still inserted (loaded and counted) for all devices, but for unwanted devices they are hidden by the browser using CSS media queries based on viewport widths.
281
 
282
- Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab * (<a href="http://tinymonitor.com/ad-inserter-pro" target="_blank">Ad Inserter Pro</a> supports up to 6 viewports). Default values are:
283
 
284
  * Desktop: 980 pixels or more
285
  * Tablet: from 768 pixels to 979 pixels
@@ -299,7 +317,7 @@ Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab
299
  In such cases **the user might get (saved) page for wrong device** (used by some previous visitor who triggered page caching). To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin.
300
  Server-side detection uses User-Agent string combined with specific HTTP headers to detect the environment.
301
 
302
- **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.
303
 
304
  **[ Manual ]**
305
 
@@ -311,7 +329,7 @@ There are 3 independent types of manual insertion of code block:
311
 
312
  **OTHER NOTES**
313
 
314
- By default code blocks will not be inserted on Error 404 page (Page Not Found) and in feeds. Check '404 Page' or 'Feed' checkbox to enable code block on error 404 page or in feed.
315
 
316
  **Ad Inserter general Settings - last tab**
317
 
@@ -336,8 +354,11 @@ Some security plugins like WP Security or Wordfence may also detect Ad Inserter
336
 
337
  **CACHING**
338
 
339
- Caching on the frontend side (what visitors see) does speed up page loading but may cause some unwanted behavior.
340
- When you are using caching, Wordpress creates page, Ad Inseter is called to do the job and the created page is saved for quicker serving.
 
 
 
341
  The next time the page is visited **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
342
 
343
  * Block rotation with `|rotate|`
@@ -345,8 +366,9 @@ The next time the page is visited **the visitor gets cached (saved) page **. Bec
345
  * Server-side device detection
346
  * Referer check
347
  * Debugging functions
 
348
 
349
- When you need the functions listed above you have to switch off caching.
350
 
351
  Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
352
  The problem can occur when the plugin is updated since the new plugin also provides new javascript and CSS files.
@@ -371,7 +393,7 @@ If you are using caching make sure the caching software **DOES NOT REMOVE VERSIO
371
  **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
372
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
373
 
374
- **PLEASE DO NOT FORGET:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check and server-side detection work only when the page is generated and Ad Inserter is called.
375
  In such cases please make sure you have disabled caching.
376
 
377
  **DEBUGGING**
@@ -385,7 +407,7 @@ Ad Inserter has many debugging functions that can help you to diagnose the probl
385
  Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:
386
 
387
  * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the broswer to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
388
- * Show Positions: Enable this function to show available positions for automatic display. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
389
  * Show HTML tags: Enable this function to see HTML tags used in the post. Use this function to determine post structure in order to configure paragraph counting.
390
  * Disable insertion: Use this function to temporarily disable insertion of code blocks - everything else on the page will look like the code blocks were processed and inserted.
391
  * Log Processing: Use this function to log insertion process in order to determine why some code block was not inserted. The log is added as HTML comment at the end of the page - check page source
@@ -398,16 +420,16 @@ Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible onl
398
  * Disable insertion: `ai-debug-no-insertion=1` (use `ai-debug-no-insertion=0` to turn it off)
399
  * Log Processing: `ai-debug-processing=1` (use `ai-debug-processing=0` to turn it off)
400
 
401
- When browsing other pages on the website debuggins settings are temporarily saved (for the session). To disable all debugging functions click on the 'Ad Inserter' top menu item in the toolbar (or use `ai-debug=0`)
402
 
403
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
404
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
405
- Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging via url is always enabled.
406
 
407
  **MULTISITE**
408
 
409
  Ad Inserter supports multisite Wordpress installations. Normally, the plugin is available with settings and widgets to all the sites on the network.
410
- <a href="http://tinymonitor.com/ad-inserter-pro" target="_blank">Ad Inserter Pro</a> supports options to disable Setings page, widgets and post/page exceptions for sites (except the main one).
411
 
412
  **SUPPORT**
413
 
@@ -416,7 +438,7 @@ However, before you ask please use debugging functions described above. In almos
416
  Check also source code of the page. Some code for ads may not display anything, either because of errors in the ad code or because of ad network issues.
417
  In order to be able to diagnose the problem and suggest actions or fix a bug, please do the following:
418
 
419
- 1. Enable Remote debugging (located on the Ad Inserter Settings tab - Debugging).
420
 
421
  2. Clearly describe the problem. Describe what does not work as expected.
422
 
@@ -424,7 +446,7 @@ In order to be able to diagnose the problem and suggest actions or fix a bug, pl
424
 
425
  4. Provide web addresses (links) of the pages where the code from the settings above is not inserted properly.
426
 
427
- Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help. Once the problem is fixed you can disable Remote debugging.
428
  Thank you very much for understanding.
429
 
430
  Please **support the plugin** if you like it:
@@ -449,10 +471,10 @@ make sure you have whitelisted Ad Inserter settings page (select "Disable on thi
449
  However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
450
  Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
451
 
452
- **WARNING:** If you are using caching the inserted code may not appear imemdiately on the page. Make sure you have disabled caching when you are testing or debugging.
453
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
454
 
455
- **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check and server-side detection work only when the page is generated and Ad Inserter is called.
456
  In such cases please make sure you have disabled caching when you are using such settings.
457
 
458
  **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
@@ -461,7 +483,7 @@ The code may be inserted properly but you won't see anything. Try to add some te
461
 
462
  **Ad Inserter Pro Installation**
463
 
464
- <a href="http://tinymonitor.com/ad-inserter-pro" target="_blank">Ad Inserter Pro</a> is an upgraded version of the freely available Ad Inserter.
465
  In addition to all the features in the free version it offers 64 code blocks, 6 custom viewports, export and import of settings, additional multisite options and support via email.
466
 
467
  If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
@@ -798,7 +820,7 @@ AD CODE RIGHT
798
 
799
  == Screenshots ==
800
 
801
- 1. Settings for one code block (Before post). Up to 16 blocks can be configured (up to 64 in <a href="http://tinymonitor.com/ad-inserter-pro" target="_blank">Ad Inserter Pro</a>)
802
  2. Complete settings for one code block (Before Paragraph)
803
  3. Alignment **Left**, **None** - None means default (usually left) aligned ad block with thin margin around
804
  4. Alignment **Right** - Right aligned ad block with thin margin around
@@ -815,6 +837,11 @@ AD CODE RIGHT
815
 
816
  == Changelog ==
817
 
 
 
 
 
 
818
 
819
  = 2.0.6 =
820
  - Added support to filter subpages created by the `<!--nextpage-->` tag
@@ -1080,6 +1107,12 @@ AD CODE RIGHT
1080
 
1081
  == Upgrade Notice ==
1082
 
 
 
 
 
 
 
1083
  = 2.0.6 =
1084
  Added support to filter subpages created by the `<!--nextpage-->` tag;
1085
  Added option to import block name (Pro only);
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
+ Tags: adsense, amazon, clickbank, advertising, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, rotation, geo targeting, countries, multisite, contextual, shortcodes, widgets, header, footer, users, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
  Stable tag: 2.0.6
28
  > * Simple troubleshooting with many debugging functions to visualize inserted code blocks, available insertion positions, HTML tags, etc.
29
  >
30
  > Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features.
31
+ You can also download PDF user guide for Ad Inserter. Go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> page and below you can find button for free download of Ad Inserter User Guide.
32
 
33
  Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress.
34
 
45
 
46
  **Quick Start**
47
 
48
+ Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
49
 
50
+ * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
51
+ * **Enable insertion on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
52
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
53
+ * If you don't see inserted code block turn on **debuging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
54
 
55
  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 and instructions for **Debugging**.
56
 
57
  **Settings**
58
 
59
+ Each code block has 4 insertion options:
60
 
61
+ * Automatic Insertion
62
  * Widget
63
  * Shortcode
64
  * PHP function call
65
 
66
+ Normally for each code block you use only one insertion option.
67
+ Of course, you can use all 4 options simultaneously taking into account that all insertion options use the same block settings (with some exceptions mentioned below).
68
 
69
+ To rename code block click on the block name. To display code block (ad) at some position **you need to enable and use at least one insertion option**.
70
 
71
+ Automatic Insertion Options:
72
 
73
+ * Insert Before Post (before post or posts on blog pages, previously named Before Title)
74
+ * Insert Before Content (before post or static page text)
75
+ * Insert Before Paragraph (on posts, static pages and blog pages)
76
+ * Insert After Paragraph (on posts, static pages and blog pages)
77
+ * Insert After Content (after post or static page text)
78
+ * Insert After Post (after post or posts on blog pages)
79
+ * Insert Before Excerpt (on blog pages)
80
+ * Insert After Excerpt (on blog pages)
81
 
82
+ For single posts or static pages insertion 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.
83
 
84
+ For single posts or static pages insertion 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.
85
 
86
+ Order of insertion positions in a typical post is the following:
87
 
88
  * [Before Post]
89
  * Post Title
100
 
101
  Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab *).
102
 
103
+ Please use **Show positions** function to see available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page).
104
 
105
  Block Alignment and Style:
106
 
133
  **PLEASE NOTE:** If you are using **No Wrapping** style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-viewport-1, ai-viewport-2, ai-viewport-3).
134
  This doesn't apply to widgets as they always contain a wrapping div.
135
 
136
+ For all display positions you can also define Wordpress page types where the ads will be inserted. **PLEASE NOTE:** Regardles of other settings you need to enable insertion on AT LEAST ONE PAGE TYPE:
137
 
138
  Single pages:
139
 
154
 
155
  **Please Note** For shortcodes and PHP function calls it is possible to ignore enabled page types and use them on any page. See down for details.
156
 
157
+ You can also disable insertion of ads on certain posts or static pages. For each code block on posts or static pages you first define default insertion settings for posts/pages page type.
158
+ Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below).
159
+ Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content).
160
+ 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).
161
 
162
  **PARAGRAPHS**
163
 
164
+ Paragraph number for Automatic Insertion options Before and After Paragraph:
165
 
166
  * 0 means random paragraph position
167
  * value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
175
  Paragraphs are not counted inside `<blockquote>` elements. Of course, there is an option to enable counting also inside `<blockquote>`.
176
 
177
  **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,
178
+ 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.
179
+ You can also leave Filter (click Misc button) empty (means all posts on the blog page) and define maximum number of insertions.
180
 
181
  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**).
182
 
183
  **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>`.
184
  **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.
185
 
186
+ Minimum number of paragraphs / Minimum/Maximum page/post words: do not insert ad if the number of paragraphs or the number of words is below or above limit (used only for position Before or After selected paragraph).
187
 
188
  **[ Clearance ]**
189
 
198
 
199
  **Additional Post/Static Page Options**
200
 
201
+ You can define post/page minimum and maximum word length.
202
 
203
  Additional Options for code blocks:
204
 
206
 
207
  * Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
208
  * Use {author} for post author username or {author_name} for post author name to insert post author data into code blocks (**works only inside posts**)
209
+ * Use {country_iso2} to insert country ISO Alpha-2 code into code blocks
210
  * To rotate different ad versions separate them with `|rotate|` - Ad Inserter will randomly select one of the ads
211
 
212
  WARNING: If you are using caching ad rotation may not work as expected. It works only when the page is generated and Ad Inserter is called. In such cases please make sure you have disabled caching when you are using |rotate|.
244
 
245
  **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.
246
 
247
+ **Scheduling**
248
+
249
+ You can define when the code block will be inserted:
250
+
251
+ * Insert immedaitely: no scheduling
252
+ * Delay insertion for N days after publishing: waits for N days after the time when the post was published (available only for before/after content and before/after paragraph)
253
+ * Insert between dates START_DATE and END_DATE (Pro only): inserts code only between START_DATE (including) and END_DATE (excluding) - on START_DATE it starts inserting, on END_DATE it ends inserting
254
+
255
  **[ Lists ]**
256
 
257
+ Do not insert ads in certain caregories e.g sport, news, science,... (black list) or insert ads only in certain categories (white list):
258
  leave category list empty and set it to Black list to show ads in all categories.
259
 
260
  **WARNING:** If category name contains commas or spaces, use category slug instead. Also make sure you have enabled display on **Category pages**.
261
 
262
+ Do not insert ads in posts with certain tags (black list) or insert 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**.
263
 
264
+ Do not insert ads in posts/pages with certain post IDs (black list) or insert ads only in posts with certain IDs (white list). Leave Post ID list empty and set it to Black list to show ads for all IDs.
265
 
266
+ Do not insert ads on pages with certain urls (black list) or insert ads only on pages with certain urls (white list): leave url list empty and set it to Black list to show ads for all urls.
267
  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`
268
  You can also use partial urls with *. To filter all urls starting with /url-start use `/url-start*`, to filter all urls that contain url-pattern use `*url-pattern*`, to filter all urls ending with url-end use `*url-end`.
269
  **WARNING:** Separate urls with SPACES.
270
 
271
+ Do not insert ads on pages with certain url query parameters (black list) or insert ads only on pages with certain url parameters (white list): leave url parameter list empty and set it to Black list to show ads for all url.
272
  You can specifiy either parameters or parameters with values. For example for url `http://example.com?data=2&customer-id=22&device=0` you can define url parameters '`data, customer-id=22`' to display ad only for urls where there is `data` paramteter and `customer-id` parameter with value 22.
273
  Separate parameters with comma.
274
 
275
+ Do not insert ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or insert ads only for certain referrers (white list): use # for no referer (direct visit),
276
  leave referrers list empty and set it to Black list to show ads for all referrers.
277
 
278
+ GEO targeting (Pro only): Do not insert ads for certain countries (black list) or insert ads only for certain countries (white list). Leave country list empty and set it to Black list to show ads for all countries.
279
+ Country list should contain comma separated country ISO Alpha-2 codes. Click list to toggle country selection and then click on the countries on the left list to select countries - country codes will automatically be added to the list.
280
+ You can also use 6 country groups which you can define on the Ad Inserter settings page (tab *, GEO targeting).
281
+
282
+ **WARNING:** If you are using caching, referer check and GEO targeting 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.
283
 
284
  **[ Devices ]**
285
 
297
 
298
  **BUT BE CAREFUL:** Some ad networks (like AdSense) limit ads per page. The ads are still inserted (loaded and counted) for all devices, but for unwanted devices they are hidden by the browser using CSS media queries based on viewport widths.
299
 
300
+ Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab * (<a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> supports up to 6 viewports). Default values are:
301
 
302
  * Desktop: 980 pixels or more
303
  * Tablet: from 768 pixels to 979 pixels
317
  In such cases **the user might get (saved) page for wrong device** (used by some previous visitor who triggered page caching). To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin.
318
  Server-side detection uses User-Agent string combined with specific HTTP headers to detect the environment.
319
 
320
+ **PLEASE NOTE:** Use server-side device type detection only when you need to insert (display and count) ONLY code blocks for specific device type. In all other cases switch it off.
321
 
322
  **[ Manual ]**
323
 
329
 
330
  **OTHER NOTES**
331
 
332
+ By default code blocks will not be inserted on Error 404 page (Page Not Found) and in feeds. Check '404 Page' or 'Feed' checkbox to enable code block insertion on error 404 page or in feed.
333
 
334
  **Ad Inserter general Settings - last tab**
335
 
354
 
355
  **CACHING**
356
 
357
+ Keep in mind that just installing a caching plugin does not necessarily make your site faster. Doing a bit of optimization will get you a lot of speed increase without caching plugins.
358
+ To further combat slowness you may want to re-evaluate the performance of your hosting package. Maybe you've outgrown it. In that case, upgrade to a better hosting solution.
359
+
360
+ Caching on the frontend side (what visitors see) in some cases does speed up page loading but may also cause some unwanted behavior.
361
+ When you are using caching and visitor visits some page, Wordpress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later.
362
  The next time the page is visited **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
363
 
364
  * Block rotation with `|rotate|`
366
  * Server-side device detection
367
  * Referer check
368
  * Debugging functions
369
+ * GEO targeting (Pro only)
370
 
371
+ When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed).
372
 
373
  Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
374
  The problem can occur when the plugin is updated since the new plugin also provides new javascript and CSS files.
393
  **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
394
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
395
 
396
+ **PLEASE DO NOT FORGET:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check, GEO targeting and server-side detection work only when the page is generated and Ad Inserter is called.
397
  In such cases please make sure you have disabled caching.
398
 
399
  **DEBUGGING**
407
  Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:
408
 
409
  * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the broswer to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
410
+ * Show Positions: Enable this function to show available positions for automatic insertion. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
411
  * Show HTML tags: Enable this function to see HTML tags used in the post. Use this function to determine post structure in order to configure paragraph counting.
412
  * Disable insertion: Use this function to temporarily disable insertion of code blocks - everything else on the page will look like the code blocks were processed and inserted.
413
  * Log Processing: Use this function to log insertion process in order to determine why some code block was not inserted. The log is added as HTML comment at the end of the page - check page source
420
  * Disable insertion: `ai-debug-no-insertion=1` (use `ai-debug-no-insertion=0` to turn it off)
421
  * Log Processing: `ai-debug-processing=1` (use `ai-debug-processing=0` to turn it off)
422
 
423
+ When browsing other pages on the website debuggins settings are temporarily saved (in a cookie). To disable all debugging functions click on the 'Ad Inserter' top menu item in the toolbar (or use `ai-debug=0`)
424
 
425
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
426
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
427
+ Enable this option (and disable caching) to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging via url is always enabled.
428
 
429
  **MULTISITE**
430
 
431
  Ad Inserter supports multisite Wordpress installations. Normally, the plugin is available with settings and widgets to all the sites on the network.
432
+ <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> supports options to disable Setings page, widgets and post/page exceptions for sites (except the main one).
433
 
434
  **SUPPORT**
435
 
438
  Check also source code of the page. Some code for ads may not display anything, either because of errors in the ad code or because of ad network issues.
439
  In order to be able to diagnose the problem and suggest actions or fix a bug, please do the following:
440
 
441
+ 1. Enable Remote debugging (located on the Ad Inserter Settings tab - Debugging) and disable caching.
442
 
443
  2. Clearly describe the problem. Describe what does not work as expected.
444
 
446
 
447
  4. Provide web addresses (links) of the pages where the code from the settings above is not inserted properly.
448
 
449
+ Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help. Once the problem is fixed you can disable Remote debugging and enable caching.
450
  Thank you very much for understanding.
451
 
452
  Please **support the plugin** if you like it:
471
  However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
472
  Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
473
 
474
+ **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
475
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
476
 
477
+ **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check, country and server-side detection work only when the page is generated and Ad Inserter is called.
478
  In such cases please make sure you have disabled caching when you are using such settings.
479
 
480
  **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
483
 
484
  **Ad Inserter Pro Installation**
485
 
486
+ <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> is an upgraded version of the freely available Ad Inserter.
487
  In addition to all the features in the free version it offers 64 code blocks, 6 custom viewports, export and import of settings, additional multisite options and support via email.
488
 
489
  If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
820
 
821
  == Screenshots ==
822
 
823
+ 1. Settings for one code block (Before post). Up to 16 blocks can be configured (up to 64 in <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>)
824
  2. Complete settings for one code block (Before Paragraph)
825
  3. Alignment **Left**, **None** - None means default (usually left) aligned ad block with thin margin around
826
  4. Alignment **Right** - Right aligned ad block with thin margin around
837
 
838
  == Changelog ==
839
 
840
+ = 2.0.7 =
841
+ - Delayed display moved to Misc group
842
+ - Added option for scheduling to insert code only between specified dates (Pro only)
843
+ - Added option for Geo targeting (Pro only)
844
+ - Few minor bug fixes and cosmetic changes
845
 
846
  = 2.0.6 =
847
  - Added support to filter subpages created by the `<!--nextpage-->` tag
1107
 
1108
  == Upgrade Notice ==
1109
 
1110
+ = 2.0.7 =
1111
+ Delayed display moved to Misc group
1112
+ Added option for scheduling to insert code only between specified dates (Pro only);
1113
+ Added option for Geo targeting (Pro only);
1114
+ Few minor bug fixes and cosmetic changes
1115
+
1116
  = 2.0.6 =
1117
  Added support to filter subpages created by the `<!--nextpage-->` tag;
1118
  Added option to import block name (Pro only);
settings.php CHANGED
@@ -50,9 +50,9 @@ function generate_settings_form (){
50
  <h2 id="plugin_name" style="display: inline-block; margin: 13px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
51
  </div>
52
  <div id="header-buttons">
53
- <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Doc</button></a>
54
  <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Donate</button></a>
55
- <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter-pro" target="_blank"><button type="button" title="If you need more than 16 blocks, more viewports, import/export settings, multisite support" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
56
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter please write a nice review" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
57
  </div>
58
 
@@ -288,13 +288,16 @@ function generate_settings_form (){
288
  $url_list = $obj->get_ad_url_list();
289
  $url_parameter_list = $obj->get_url_parameter_list();
290
  $domain_list = $obj->get_ad_domain_list();
291
- $show_lists = $cat_list != '' || $tag_list != '' || $id_list != '' || $url_list != '' || $url_parameter_list != '' || $domain_list != '';
 
292
  if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
293
 
294
  $show_manual = $manual [$ad_number];
295
  if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$ad_number] || empty ($sidebars_with_widget [$ad_number]) ? "#66f;" : "#e44;"); else $manual_style = "";
296
 
297
- $show_misc = intval ($obj->get_maximum_insertions ()) != 0 || intval ($obj->get_call_filter()) != 0 || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_404 () == AD_SETTINGS_CHECKED || $obj->get_enable_feed () == AD_SETTINGS_CHECKED;
 
 
298
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
299
 
300
  $get_display_type = $obj->get_display_type();
@@ -345,9 +348,9 @@ function generate_settings_form (){
345
 
346
  <div style="padding: 0; min-height: 28px;">
347
  <div style="float: left;">
348
- <button id="misc-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Limit / filter insertions, general tag, check for users, display on error 404 page or in feeds"><span style="<?php echo $misc_style; ?>">Misc</span></button>
349
  <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
350
- <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url or Referer (domain)"><span style="<?php echo $lists_style; ?>">Lists</span></button>
351
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
352
  <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>">Preview</button>
353
  </div>
@@ -361,7 +364,7 @@ function generate_settings_form (){
361
 
362
  <div style="padding:8px 8px 6px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
363
  <div style="float: left;">
364
- Automatic Display:
365
  <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; ?>" default="<?php echo $default->get_display_type(); ?>" style="width:200px;">
366
  <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>
367
  <option value="<?php echo AD_SELECT_BEFORE_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_POST; ?></option>
@@ -415,9 +418,9 @@ function generate_settings_form (){
415
  <tr>
416
  <td style="width: 70%">
417
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
418
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" 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 '; ?> />
419
 
420
- <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; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
421
  <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>
422
  <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>
423
  <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>
@@ -430,21 +433,21 @@ function generate_settings_form (){
430
  <td style="padding-left: 8px;">
431
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
432
  <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" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
433
- <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>
434
  </td>
435
  <td style="padding-left: 8px;">
436
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
437
  <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" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
438
- <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable display on category blog pages (including sub-pages)">Category pages</label>
439
  </td>
440
  </tr>
441
 
442
  <tr>
443
  <td style="width: 70%">
444
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
445
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" 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 '; ?> />
446
 
447
- <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; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
448
  <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>
449
  <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>
450
  <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>
@@ -457,12 +460,12 @@ function generate_settings_form (){
457
  <td style="padding-left: 8px;">
458
  <input style="border-radius: 5px;;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
459
  <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" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
460
- <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable display on search blog pages">Search pages</label>
461
  </td>
462
  <td style="padding-left: 8px;">
463
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
464
  <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" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
465
- <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable display on tag or archive blog pages">Tag / Archive pages</label>
466
  </td>
467
  </tr>
468
  </table>
@@ -660,10 +663,6 @@ function generate_settings_form (){
660
  and
661
  <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAX_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Maximum number of post/static page words, leave empty for no limit" default="<?php echo $default->get_maximum_words(); ?>" value="<?php echo $obj->get_maximum_words() ?>" size="4" maxlength="6" />
662
  words
663
-
664
- <div style="float: right;">
665
- Display <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_after_day(); ?>" value="<?php echo $obj->get_ad_after_day(); ?>" size="2" maxlength="3" title="0 means publish immediately" /> days after publishing
666
- </div>
667
  </div>
668
 
669
  <div class="responsive-table" id="list-settings-<?php echo $ad_number; ?>" style="margin: 8px 0; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_lists) echo 'display: none;'; ?>">
@@ -765,6 +764,7 @@ function generate_settings_form (){
765
  <label for="referer-whitelist-<?php echo $ad_number; ?>" title="Whitelist referers"><?php echo AD_WHITE_LIST; ?></label>
766
  </td>
767
  </tr>
 
768
  </tbody>
769
  </table>
770
  </div>
@@ -815,7 +815,7 @@ function generate_settings_form (){
815
  <div id="misc-settings-<?php echo $ad_number; ?>" style="margin: 8px 0; padding: 0 8px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_misc) echo 'display: none;'; ?>">
816
  <div class="max-input" style="margin: 8px 0;">
817
  <span style="display: table-cell;">
818
- Display for
819
  <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; ?>" default="<?php echo $default->get_display_for_users(); ?>" style="width:160px">
820
  <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>
821
  <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>
@@ -840,7 +840,7 @@ function generate_settings_form (){
840
  Filter insertions
841
  </span>
842
  <span style="display: table-cell;">
843
- <input style="border-radius: 5px; width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty 0 means all / no limits. Set Counter for filter to Auto if you are using only one display type." size="16" maxlength="20" />
844
  </span>
845
  <span style="display: table-cell;">
846
  &nbsp;&nbsp;&nbsp;Counter for filter
@@ -863,11 +863,26 @@ function generate_settings_form (){
863
  <span style="display: table-cell;">
864
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
865
  <input style="border-radius: 5px; margin-left: 10px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_404(); ?>" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
866
- <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable display on page for Error 404: Page not found">404 page</label>
867
  </span>
868
  </div>
869
  </div>
870
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
871
  </div>
872
 
873
  <div id="device-detection-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_devices) echo 'display: none;'; ?>">
@@ -877,7 +892,7 @@ function generate_settings_form (){
877
  <div style="margin-bottom: 5px;">
878
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
879
  <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" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
880
- <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to display only on:</label>
881
  </div>
882
 
883
  <div style="margin: 5px 0 0 40px;">
@@ -961,7 +976,7 @@ function generate_settings_form (){
961
  <li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
962
  <li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
963
  <li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
964
- <?php if (function_exists ('ai_multisite_settings_tab')) ai_multisite_settings_tab (); ?>
965
  <li id="ai-d" class="ai-plugin-tab"><a href="#tab-debugging"><span style="<?php echo $style_d ?>">Debugging</span></a></li>
966
  </ul>
967
 
@@ -1045,7 +1060,7 @@ function generate_settings_form (){
1045
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1046
  ?>
1047
  <div style="margin: 8px;">
1048
- Viewport <?php echo $viewport; ?> name:&nbsp;&nbsp;&nbsp;
1049
  <input style="border-radius: 5px; margin-left: 0px;" type="text" id="option-name-<?php echo $viewport; ?>" name="viewport-name-<?php echo $viewport; ?>" value="<?php echo get_viewport_name ($viewport); ?>" size="15" maxlength="40" />
1050
  <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '<span style="display: none;">' ?>
1051
  &nbsp;&nbsp; min width
@@ -1165,7 +1180,7 @@ function generate_settings_form (){
1165
  </div>
1166
  </div>
1167
 
1168
- <?php if (function_exists ('ai_multisite_settings')) ai_multisite_settings (); ?>
1169
 
1170
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1171
  <div style="margin: 8px;">
@@ -1210,11 +1225,11 @@ function generate_settings_form (){
1210
  <div style="float: left;">
1211
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1212
  <div style="float: left;">
1213
- <h2 style="display: inline-block; margin: 13px 0;">Ad Inserter Pro - 64 blocks, 6 viewports, import/export settings, multisite support</h2>
1214
  </div>
1215
 
1216
  <div id="header-buttons">
1217
- <a style="text-decoration: none;" href="http://tinymonitor.com/ad-inserter-pro" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
1218
  </div>
1219
 
1220
  <div style="clear: both;"></div>
50
  <h2 id="plugin_name" style="display: inline-block; margin: 13px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
51
  </div>
52
  <div id="header-buttons">
53
+ <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Doc</button></a>
54
  <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Donate</button></a>
55
+ <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="If you need more than 16 blocks, more viewports, GEO targeting, scheduling, import/export settings, multisite support" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
56
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter please write a nice review" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
57
  </div>
58
 
288
  $url_list = $obj->get_ad_url_list();
289
  $url_parameter_list = $obj->get_url_parameter_list();
290
  $domain_list = $obj->get_ad_domain_list();
291
+ if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false;
292
+ $show_lists = $cat_list != '' || $tag_list != '' || $id_list != '' || $url_list != '' || $url_parameter_list != '' || $domain_list != '' || $lists;
293
  if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
294
 
295
  $show_manual = $manual [$ad_number];
296
  if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$ad_number] || empty ($sidebars_with_widget [$ad_number]) ? "#66f;" : "#e44;"); else $manual_style = "";
297
 
298
+ $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
299
+
300
+ $show_misc = $scheduling_active || intval ($obj->get_maximum_insertions ()) != 0 || intval ($obj->get_call_filter()) != 0 || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_404 () == AD_SETTINGS_CHECKED || $obj->get_enable_feed () == AD_SETTINGS_CHECKED;
301
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
302
 
303
  $get_display_type = $obj->get_display_type();
348
 
349
  <div style="padding: 0; min-height: 28px;">
350
  <div style="float: left;">
351
+ <button id="misc-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Limit / Filter / Delay insertions, general tag, check for users, insert on error 404 page or in feeds"><span style="<?php echo $misc_style; ?>">Misc</span></button>
352
  <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
353
+ <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
354
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
355
  <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>">Preview</button>
356
  </div>
364
 
365
  <div style="padding:8px 8px 6px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
366
  <div style="float: left;">
367
+ Automatic Insertion:
368
  <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; ?>" default="<?php echo $default->get_display_type(); ?>" style="width:200px;">
369
  <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>
370
  <option value="<?php echo AD_SELECT_BEFORE_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_POST; ?></option>
418
  <tr>
419
  <td style="width: 70%">
420
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
421
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
422
 
423
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
424
  <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>
425
  <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>
426
  <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>
433
  <td style="padding-left: 8px;">
434
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
435
  <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" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
436
+ <label for="display-homepage-<?php echo $ad_number; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage">Homepage</label>
437
  </td>
438
  <td style="padding-left: 8px;">
439
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
440
  <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" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
441
+ <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
442
  </td>
443
  </tr>
444
 
445
  <tr>
446
  <td style="width: 70%">
447
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
448
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
449
 
450
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
451
  <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>
452
  <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>
453
  <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>
460
  <td style="padding-left: 8px;">
461
  <input style="border-radius: 5px;;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
462
  <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" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
463
+ <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
464
  </td>
465
  <td style="padding-left: 8px;">
466
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
467
  <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" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
468
+ <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
469
  </td>
470
  </tr>
471
  </table>
663
  and
664
  <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAX_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Maximum number of post/static page words, leave empty for no limit" default="<?php echo $default->get_maximum_words(); ?>" value="<?php echo $obj->get_maximum_words() ?>" size="4" maxlength="6" />
665
  words
 
 
 
 
666
  </div>
667
 
668
  <div class="responsive-table" id="list-settings-<?php echo $ad_number; ?>" style="margin: 8px 0; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_lists) echo 'display: none;'; ?>">
764
  <label for="referer-whitelist-<?php echo $ad_number; ?>" title="Whitelist referers"><?php echo AD_WHITE_LIST; ?></label>
765
  </td>
766
  </tr>
767
+ <?php if (function_exists ('ai_list_rows')) ai_list_rows ($ad_number, $default, $obj); ?>
768
  </tbody>
769
  </table>
770
  </div>
815
  <div id="misc-settings-<?php echo $ad_number; ?>" style="margin: 8px 0; padding: 0 8px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_misc) echo 'display: none;'; ?>">
816
  <div class="max-input" style="margin: 8px 0;">
817
  <span style="display: table-cell;">
818
+ Insert for
819
  <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; ?>" default="<?php echo $default->get_display_for_users(); ?>" style="width:160px">
820
  <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>
821
  <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>
840
  Filter insertions
841
  </span>
842
  <span style="display: table-cell;">
843
+ <input style="border-radius: 5px; width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty 0 means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="16" maxlength="20" />
844
  </span>
845
  <span style="display: table-cell;">
846
  &nbsp;&nbsp;&nbsp;Counter for filter
863
  <span style="display: table-cell;">
864
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
865
  <input style="border-radius: 5px; margin-left: 10px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_404(); ?>" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
866
+ <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable insertion on page for Error 404: Page not found">404 page</label>
867
  </span>
868
  </div>
869
  </div>
870
 
871
+ <div style="margin: 8px 0;">
872
+ <select style="border-radius: 5px; margin-bottom: 0px;" id="scheduling-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_SCHEDULING, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_scheduling(); ?>">
873
+ <option value="<?php echo AI_SCHEDULING_OFF; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_OFF) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_OFF; ?></option>
874
+ <option value="<?php echo AI_SCHEDULING_DELAY; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_DELAY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DELAY_DISPLAY; ?></option>
875
+ <?php if (function_exists ('ai_scheduling_options')) ai_scheduling_options ($obj); ?>
876
+ </select>
877
+
878
+ <span id="scheduling-delay-<?php echo $ad_number; ?>">
879
+ for <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_after_day(); ?>" value="<?php echo $obj->get_ad_after_day(); ?>" size="2" maxlength="3" /> days after publishing
880
+ </span>
881
+ <span id="scheduling-delay-warning-<?php echo $ad_number; ?>" style="color: #d00; display: none;">&nbsp;&nbsp; Not available</span>
882
+
883
+ <?php if (function_exists ('ai_scheduling_data')) ai_scheduling_data ($ad_number, $obj, $default); ?>
884
+ </div>
885
+
886
  </div>
887
 
888
  <div id="device-detection-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_devices) echo 'display: none;'; ?>">
892
  <div style="margin-bottom: 5px;">
893
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
894
  <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" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
895
+ <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to show only on:</label>
896
  </div>
897
 
898
  <div style="margin: 5px 0 0 40px;">
976
  <li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
977
  <li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
978
  <li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
979
+ <?php if (function_exists ('ai_plugin_settings_tab')) ai_plugin_settings_tab (); ?>
980
  <li id="ai-d" class="ai-plugin-tab"><a href="#tab-debugging"><span style="<?php echo $style_d ?>">Debugging</span></a></li>
981
  </ul>
982
 
1060
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1061
  ?>
1062
  <div style="margin: 8px;">
1063
+ Viewport <?php echo $viewport; ?> name&nbsp;&nbsp;&nbsp;
1064
  <input style="border-radius: 5px; margin-left: 0px;" type="text" id="option-name-<?php echo $viewport; ?>" name="viewport-name-<?php echo $viewport; ?>" value="<?php echo get_viewport_name ($viewport); ?>" size="15" maxlength="40" />
1065
  <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '<span style="display: none;">' ?>
1066
  &nbsp;&nbsp; min width
1180
  </div>
1181
  </div>
1182
 
1183
+ <?php if (function_exists ('ai_plugin_settings')) ai_plugin_settings (); ?>
1184
 
1185
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1186
  <div style="margin: 8px;">
1225
  <div style="float: left;">
1226
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1227
  <div style="float: left;">
1228
+ <h2 style="display: inline-block; margin: 13px 0;">Ad Inserter Pro - 64 blocks, 6 viewports, GEO targeting, scheduling, import/export</h2>
1229
  </div>
1230
 
1231
  <div id="header-buttons">
1232
+ <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
1233
  </div>
1234
 
1235
  <div style="clear: both;"></div>