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

Version Description

  • Added support to insert ads in Ajax requests (e.g. in infinite scroll)
  • Added support to not include block classes when class name is empty
  • Added sticky positions (Pro only)
  • Bug fix for minimum user role not taken into account for exceptions list
  • Bug fix for IP database update cron event (Pro only)
Download this release

Release Info

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

Code changes from version 2.0.14 to 2.1.0

Files changed (8) hide show
  1. ad-inserter.php +94 -83
  2. class.php +114 -42
  3. constants.php +22 -2
  4. css/ad-inserter.css +1 -1
  5. js/ad-inserter.js +63 -1
  6. preview.php +262 -93
  7. readme.txt +15 -4
  8. settings.php +55 -42
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.0.14
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/
@@ -11,6 +11,13 @@ Plugin URI: http://adinserter.pro/documentation
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
 
14
  Ad Inserter 2.0.14 - 2 February 2017
15
  - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
16
 
@@ -450,7 +457,7 @@ add_action ('admin_menu', 'ai_admin_menu_hook');
450
  add_action ('init', 'ai_init_hook');
451
  add_action ('admin_notices', 'ai_admin_notice_hook');
452
 
453
- add_action( 'wp', 'ai_wp_hook');
454
 
455
  if ($adH->get_enable_manual () ||
456
  $ai_wp_data [CLIENT_SIDE_DETECTION] ||
@@ -482,6 +489,8 @@ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
482
  ai_log ("INITIALIZATION END\n");
483
  }
484
 
 
 
485
  function ai_toolbar ($wp_admin_bar) {
486
  global $block_object, $ai_wp_data;
487
 
@@ -626,7 +635,7 @@ function set_page_type () {
626
 
627
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
628
 
629
- if (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
630
  elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
631
  elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
632
  elseif (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
@@ -803,7 +812,7 @@ function ai_wp_hook () {
803
 
804
  $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
805
 
806
- if (!is_admin()) {
807
  if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
808
  if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
809
  unset ($_COOKIE ['AI_WP_DEBUGGING']);
@@ -869,7 +878,12 @@ function ai_wp_hook () {
869
  };
870
 
871
  function ai_init_hook() {
872
- global $block_object, $ai_wp_data;
 
 
 
 
 
873
 
874
  add_shortcode ('adinserter', 'process_shortcodes');
875
  }
@@ -1120,7 +1134,6 @@ list_ip_address){found=true;return false}}else if(list_ip_address.charAt(list_ip
1120
  $(this).attr("countries");if(typeof countries_list!="undefined"){var country_array=countries_list.split(",");var country_list_type=$(this).attr("country-list");var found=false;$.each(country_array,function(index,list_country){if(list_country==country){found=true;return false}});switch(country_list_type){case "B":if(found)enable_block=false;break;case "W":if(!found)enable_block=false;break}}}$(this).css({"visibility":"","position":"","width":"","height":"","z-index":""});block_div.css({"visibility":"",
1121
  "position":"","z-index":""});if(!enable_block){$(this).hide();block_div.hide()}})}).fail(function(){$("div.ai-ip-data").each(function(){$(this).css({"display":"none","visibility":"","position":"","width":"","height":"","z-index":""})})})});';
1122
 
1123
-
1124
  echo "\n</script>\n";
1125
  }
1126
  }
@@ -1693,8 +1706,7 @@ function ai_check_plugin_options ($plugin_options = array ()) {
1693
 
1694
  if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
1695
 
1696
- if (!isset ($plugin_options ['BLOCK_CLASS_NAME']) ||
1697
- $plugin_options ['BLOCK_CLASS_NAME'] == '') $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
1698
 
1699
  if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
1700
 
@@ -1833,7 +1845,7 @@ function get_block_class_name () {
1833
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1834
  if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
1835
 
1836
- if (!isset ($plugin_db_options ['BLOCK_CLASS_NAME']) || $plugin_db_options ['BLOCK_CLASS_NAME'] == '') {
1837
  $plugin_db_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
1838
  }
1839
 
@@ -2183,11 +2195,11 @@ function ai_generate_extract (&$settings) {
2183
  $loop_end_hook_blocks = array ();
2184
  $post_hook_blocks = array ();
2185
 
2186
- $content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
2187
- $excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
2188
- $loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
2189
- $loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
2190
- $post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
2191
 
2192
  // Generate extracted data
2193
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
@@ -2204,6 +2216,7 @@ function ai_generate_extract (&$settings) {
2204
  if ($obj->get_display_settings_category()) $page_types []= AI_PT_CATEGORY;
2205
  if ($obj->get_display_settings_search()) $page_types []= AI_PT_SEARCH;
2206
  if ($obj->get_display_settings_archive()) $page_types []= AI_PT_ARCHIVE;
 
2207
  if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
2208
  if ($obj->get_enable_404()) $page_types []= AI_PT_404;
2209
 
@@ -2253,7 +2266,9 @@ function ai_load_settings () {
2253
 
2254
  ai_load_options ();
2255
 
2256
- if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) && $ai_db_options ['global']['VERSION'] == $version_string && isset ($ai_db_options_extract [POST_HOOK_BLOCKS]))
 
 
2257
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
2258
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
2259
 
@@ -2501,29 +2516,31 @@ function ai_settings () {
2501
  delete_site_option (WP_OPTION_NAME, $options);
2502
  }
2503
 
2504
- $args = array (
2505
- 'posts_per_page' => 100,
2506
- 'offset' => 0,
2507
- 'category' => '',
2508
- 'category_name' => '',
2509
- 'orderby' => 'type',
2510
- 'order' => 'ASC',
2511
- 'include' => '',
2512
- 'exclude' => '',
2513
- 'meta_key' => '_adinserter_block_exceptions',
2514
- 'meta_value' => '',
2515
- 'post_type' => array ('post', 'page'),
2516
- 'post_mime_type' => '',
2517
- 'post_parent' => '',
2518
- 'author' => '',
2519
- 'author_name' => '',
2520
- 'post_status' => '',
2521
- 'suppress_filters' => true
2522
- );
2523
- $posts_pages = get_posts ($args);
2524
-
2525
- foreach ($posts_pages as $page) {
2526
- delete_post_meta ($page->ID, '_adinserter_block_exceptions');
 
 
2527
  }
2528
 
2529
  ai_load_settings ();
@@ -2532,46 +2549,47 @@ function ai_settings () {
2532
 
2533
  echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</p></div>";
2534
  } elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
2535
-
2536
- $args = array (
2537
- 'posts_per_page' => 100,
2538
- 'offset' => 0,
2539
- 'category' => '',
2540
- 'category_name' => '',
2541
- 'orderby' => 'type',
2542
- 'order' => 'ASC',
2543
- 'include' => '',
2544
- 'exclude' => '',
2545
- 'meta_key' => '_adinserter_block_exceptions',
2546
- 'meta_value' => '',
2547
- 'post_type' => array ('post', 'page'),
2548
- 'post_mime_type' => '',
2549
- 'post_parent' => '',
2550
- 'author' => '',
2551
- 'author_name' => '',
2552
- 'post_status' => '',
2553
- 'suppress_filters' => true
2554
- );
2555
- $posts_pages = get_posts ($args);
2556
-
2557
- if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c") {
2558
- foreach ($posts_pages as $page) {
2559
- delete_post_meta ($page->ID, '_adinserter_block_exceptions');
 
2560
  }
2561
- }
2562
- elseif (strpos ($_POST [AI_FORM_CLEAR_EXCEPTIONS], 'id=') === 0) {
2563
- $id = str_replace ('id=', '', $_POST [AI_FORM_CLEAR_EXCEPTIONS]);
2564
- if (is_numeric ($id)) {
2565
- delete_post_meta ($id, '_adinserter_block_exceptions');
2566
  }
2567
- }
2568
- elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
2569
- foreach ($posts_pages as $page) {
2570
- $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
2571
- $selected_blocks = explode (",", $post_meta);
2572
- if (($key = array_search ($_POST [AI_FORM_CLEAR_EXCEPTIONS], $selected_blocks)) !== false) {
2573
- unset ($selected_blocks [$key]);
2574
- update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks));
2575
  }
2576
  }
2577
  }
@@ -2686,7 +2704,6 @@ function ai_content_hook ($content = '') {
2686
  if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
2687
  if ($debug_processing) ai_log_content ($content);
2688
 
2689
-
2690
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
2691
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
2692
  $selected_blocks = explode (",", $meta_value);
@@ -3033,11 +3050,6 @@ function ai_post_hook ($post) {
3033
  echo "<section style='$style'>BETWEEN POSTS ".$ad_inserter_globals [AI_POST_COUNTER_NAME]."</section>";
3034
  }
3035
 
3036
- // if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3037
- // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3038
- // $selected_blocks = explode (",", $meta_value);
3039
- // } else $selected_blocks = array ();
3040
-
3041
  $ad_code = "";
3042
 
3043
  $ai_last_check = AI_CHECK_NONE;
@@ -3055,7 +3067,6 @@ function ai_post_hook ($post) {
3055
 
3056
  if (!$obj->check_server_side_detection ()) continue;
3057
  if (!$obj->check_page_types_lists_users ()) continue;
3058
- // if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
3059
  if (!$obj->check_filter ($ad_inserter_globals [AI_POST_COUNTER_NAME])) continue;
3060
 
3061
  // Last check before insertion
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.1.0
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/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.1.0 - 10 February 2017
15
+ - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
16
+ - Added support to not include block classes when class name is empty
17
+ - Added sticky positions (Pro only)
18
+ - Bug fix for minimum user role not taken into account for exceptions list
19
+ - Bug fix for IP database update cron event (Pro only)
20
+
21
  Ad Inserter 2.0.14 - 2 February 2017
22
  - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
23
 
457
  add_action ('init', 'ai_init_hook');
458
  add_action ('admin_notices', 'ai_admin_notice_hook');
459
 
460
+ add_action ('wp', 'ai_wp_hook');
461
 
462
  if ($adH->get_enable_manual () ||
463
  $ai_wp_data [CLIENT_SIDE_DETECTION] ||
489
  ai_log ("INITIALIZATION END\n");
490
  }
491
 
492
+
493
+
494
  function ai_toolbar ($wp_admin_bar) {
495
  global $block_object, $ai_wp_data;
496
 
635
 
636
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
637
 
638
+ if (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
639
  elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
640
  elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
641
  elseif (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
812
 
813
  $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
814
 
815
+ if (!is_admin() || defined ('DOING_AJAX')) {
816
  if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
817
  if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
818
  unset ($_COOKIE ['AI_WP_DEBUGGING']);
878
  };
879
 
880
  function ai_init_hook() {
881
+ global $block_object, $ai_wp_data, $ai_db_options_extract;
882
+
883
+ if (defined ('DOING_AJAX') && DOING_AJAX) {
884
+ $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_AJAX;
885
+ ai_wp_hook ();
886
+ }
887
 
888
  add_shortcode ('adinserter', 'process_shortcodes');
889
  }
1134
  $(this).attr("countries");if(typeof countries_list!="undefined"){var country_array=countries_list.split(",");var country_list_type=$(this).attr("country-list");var found=false;$.each(country_array,function(index,list_country){if(list_country==country){found=true;return false}});switch(country_list_type){case "B":if(found)enable_block=false;break;case "W":if(!found)enable_block=false;break}}}$(this).css({"visibility":"","position":"","width":"","height":"","z-index":""});block_div.css({"visibility":"",
1135
  "position":"","z-index":""});if(!enable_block){$(this).hide();block_div.hide()}})}).fail(function(){$("div.ai-ip-data").each(function(){$(this).css({"display":"none","visibility":"","position":"","width":"","height":"","z-index":""})})})});';
1136
 
 
1137
  echo "\n</script>\n";
1138
  }
1139
  }
1706
 
1707
  if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
1708
 
1709
+ if (!isset ($plugin_options ['BLOCK_CLASS_NAME'])) $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
 
1710
 
1711
  if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
1712
 
1845
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1846
  if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
1847
 
1848
+ if (!isset ($plugin_db_options ['BLOCK_CLASS_NAME'])) {
1849
  $plugin_db_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
1850
  }
1851
 
2195
  $loop_end_hook_blocks = array ();
2196
  $post_hook_blocks = array ();
2197
 
2198
+ $content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2199
+ $excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2200
+ $loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2201
+ $loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2202
+ $post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2203
 
2204
  // Generate extracted data
2205
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2216
  if ($obj->get_display_settings_category()) $page_types []= AI_PT_CATEGORY;
2217
  if ($obj->get_display_settings_search()) $page_types []= AI_PT_SEARCH;
2218
  if ($obj->get_display_settings_archive()) $page_types []= AI_PT_ARCHIVE;
2219
+ if ($obj->get_enable_ajax()) $page_types []= AI_PT_AJAX;
2220
  if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
2221
  if ($obj->get_enable_404()) $page_types []= AI_PT_404;
2222
 
2266
 
2267
  ai_load_options ();
2268
 
2269
+ if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) && $ai_db_options ['global']['VERSION'] == $version_string &&
2270
+ isset ($ai_db_options_extract [POST_HOOK_BLOCKS]) &&
2271
+ isset ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_AJAX]))
2272
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
2273
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
2274
 
2516
  delete_site_option (WP_OPTION_NAME, $options);
2517
  }
2518
 
2519
+ if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
2520
+ $args = array (
2521
+ 'posts_per_page' => 100,
2522
+ 'offset' => 0,
2523
+ 'category' => '',
2524
+ 'category_name' => '',
2525
+ 'orderby' => 'type',
2526
+ 'order' => 'ASC',
2527
+ 'include' => '',
2528
+ 'exclude' => '',
2529
+ 'meta_key' => '_adinserter_block_exceptions',
2530
+ 'meta_value' => '',
2531
+ 'post_type' => array ('post', 'page'),
2532
+ 'post_mime_type' => '',
2533
+ 'post_parent' => '',
2534
+ 'author' => '',
2535
+ 'author_name' => '',
2536
+ 'post_status' => '',
2537
+ 'suppress_filters' => true
2538
+ );
2539
+ $posts_pages = get_posts ($args);
2540
+
2541
+ foreach ($posts_pages as $page) {
2542
+ delete_post_meta ($page->ID, '_adinserter_block_exceptions');
2543
+ }
2544
  }
2545
 
2546
  ai_load_settings ();
2549
 
2550
  echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</p></div>";
2551
  } elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
2552
+ if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
2553
+ $args = array (
2554
+ 'posts_per_page' => 100,
2555
+ 'offset' => 0,
2556
+ 'category' => '',
2557
+ 'category_name' => '',
2558
+ 'orderby' => 'type',
2559
+ 'order' => 'ASC',
2560
+ 'include' => '',
2561
+ 'exclude' => '',
2562
+ 'meta_key' => '_adinserter_block_exceptions',
2563
+ 'meta_value' => '',
2564
+ 'post_type' => array ('post', 'page'),
2565
+ 'post_mime_type' => '',
2566
+ 'post_parent' => '',
2567
+ 'author' => '',
2568
+ 'author_name' => '',
2569
+ 'post_status' => '',
2570
+ 'suppress_filters' => true
2571
+ );
2572
+ $posts_pages = get_posts ($args);
2573
+
2574
+ if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c") {
2575
+ foreach ($posts_pages as $page) {
2576
+ delete_post_meta ($page->ID, '_adinserter_block_exceptions');
2577
+ }
2578
  }
2579
+ elseif (strpos ($_POST [AI_FORM_CLEAR_EXCEPTIONS], 'id=') === 0) {
2580
+ $id = str_replace ('id=', '', $_POST [AI_FORM_CLEAR_EXCEPTIONS]);
2581
+ if (is_numeric ($id)) {
2582
+ delete_post_meta ($id, '_adinserter_block_exceptions');
2583
+ }
2584
  }
2585
+ elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
2586
+ foreach ($posts_pages as $page) {
2587
+ $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
2588
+ $selected_blocks = explode (",", $post_meta);
2589
+ if (($key = array_search ($_POST [AI_FORM_CLEAR_EXCEPTIONS], $selected_blocks)) !== false) {
2590
+ unset ($selected_blocks [$key]);
2591
+ update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks));
2592
+ }
2593
  }
2594
  }
2595
  }
2704
  if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
2705
  if ($debug_processing) ai_log_content ($content);
2706
 
 
2707
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
2708
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
2709
  $selected_blocks = explode (",", $meta_value);
3050
  echo "<section style='$style'>BETWEEN POSTS ".$ad_inserter_globals [AI_POST_COUNTER_NAME]."</section>";
3051
  }
3052
 
 
 
 
 
 
3053
  $ad_code = "";
3054
 
3055
  $ai_last_check = AI_CHECK_NONE;
3067
 
3068
  if (!$obj->check_server_side_detection ()) continue;
3069
  if (!$obj->check_page_types_lists_users ()) continue;
 
3070
  if (!$obj->check_filter ($ad_inserter_globals [AI_POST_COUNTER_NAME])) continue;
3071
 
3072
  // Last check before insertion
class.php CHANGED
@@ -7,6 +7,7 @@ abstract class ai_BaseCodeBlock {
7
  var $fallback;
8
  var $client_side_ip_address_detection;
9
  var $w3tc_code;
 
10
 
11
  function __construct () {
12
 
@@ -14,6 +15,7 @@ abstract class ai_BaseCodeBlock {
14
  $this->fallback = 0;
15
  $this->client_side_ip_address_detection = false;
16
  $this->w3tc_code = '';
 
17
 
18
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
19
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
@@ -399,6 +401,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
399
  $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
400
  $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
401
  $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
 
402
  $this->wp_options [AI_OPTION_ENABLE_FEED] = AD_SETTINGS_NOT_CHECKED;
403
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
404
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
@@ -477,7 +480,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
477
  }
478
 
479
  public function get_alignment_type (){
480
- // Update old field names
481
  $option = isset ($this->wp_options [AI_OPTION_ALIGNMENT_TYPE]) ? $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] : AI_ALIGNMENT_DEFAULT;
482
 
483
  if ($option == '') $option = AI_ALIGNMENT_DEFAULT;
@@ -514,6 +516,18 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
514
  case AI_ALIGNMENT_FLOAT_RIGHT:
515
  return AI_TEXT_FLOAT_RIGHT;
516
  break;
 
 
 
 
 
 
 
 
 
 
 
 
517
  case AI_ALIGNMENT_NO_WRAPPING:
518
  return AI_TEXT_NO_WRAPPING;
519
  break;
@@ -526,45 +540,83 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
526
  }
527
  }
528
 
529
- public function alignmet_style ($alignment_type, $margin = DEFAULT_MARGIN) {
530
- if ($margin < 0) $margin = 0;
531
 
532
- if ($alignment_type == AI_ALIGNMENT_DEFAULT) {
533
- $style = "margin: ".$margin."px 0px;";
534
- }
535
- elseif ($alignment_type == AI_ALIGNMENT_LEFT) {
536
- $style = "text-align: left; margin: ".$margin."px 0px;";
537
- // $style = "text-align: left; display: table; margin: ".$margin."px auto ".$margin."px 0; width: 100%;";
538
- // $style = "text-align: left; display: flex; justify-content: flex-start; margin: ".$margin."px 0;";
539
- }
540
- elseif ($alignment_type == AI_ALIGNMENT_RIGHT) {
541
- $style = "text-align: right; margin: ".$margin."px 0px;";
542
- // $style = "text-align: right; display: table; margin: ".$margin."px 0 ".$margin."px auto; width: 100%;";
543
- // $style = "text-align: right; display: flex; justify-content: flex-end; margin: ".$margin."px 0;";
544
- }
545
- elseif ($alignment_type == AI_ALIGNMENT_CENTER) {
546
- $style = "text-align: center; margin: ".$margin."px auto;";
547
- // $style = "text-align: center; display: table; margin: ".$margin."px auto; width: 100%;";
548
- // $style = "text-align: center; display: flex; justify-content: center; margin: ".$margin."px 0;";
549
- }
550
- elseif ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) {
551
- $style = "float: left; margin: ".$margin."px ".$margin."px ".$margin."px 0;";
552
- }
553
- elseif ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) {
554
- $style = "float: right; margin: ".$margin."px 0px ".$margin."px ".$margin."px;";
555
- }
556
- elseif ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) {
557
- $style = $this->get_custom_css ();
 
 
 
 
 
 
 
 
 
558
  }
559
- else {
560
- $style = "";
 
 
 
 
561
  }
562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  return $style;
564
  }
565
 
566
- public function get_alignmet_style ($margin = DEFAULT_MARGIN){
567
- return $this->alignmet_style ($this->get_alignment_type(), $margin);
568
  }
569
 
570
  public function get_paragraph_number(){
@@ -766,6 +818,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
766
  return $enable_feed;
767
  }
768
 
 
 
 
 
 
 
769
  public function get_enable_manual (){
770
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
771
  if ($option == '') {
@@ -991,8 +1049,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
991
  if ($countries != '') $country_attributes = "countries='$countries' country-list='$country_list_type'"; else $country_attributes = '';
992
  if ($ip_addresses != '') $ip_address_attributes = "ip-addresses='$ip_addresses' ip-address-list='$ip_address_list_type'"; else $ip_address_attributes = '';
993
 
994
- $block_class_name = get_block_class_name ().'-'.$this->number;
 
 
995
  $this->client_side_ip_address_detection = true;
 
996
 
997
  $processed_code = "\n<div class='ai-ip-data' $ip_address_attributes $country_attributes class-name='$block_class_name' style='visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;'>$processed_code</div>\n";
998
  }
@@ -1215,13 +1276,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1215
  return ($viewport_classes);
1216
  }
1217
 
1218
- public function get_code_for_insertion ($viewport_classes = true, $hidden_widgets = false) {
1219
  global $ai_wp_data;
1220
 
1221
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1222
 
1223
- $block_class_name = get_block_class_name ();
1224
-
1225
  $hidden_blocks = '';
1226
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1227
 
@@ -1239,17 +1298,25 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1239
  if ($viewport_name != '') {
1240
  if ($this->get_detection_viewport ($viewport))
1241
  $visible_blocks .= '<section class="ai-viewport-' . $viewport .'" style=""><section style="padding: 1px 0 1px 5px; text-align: center; background: red; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section><section>'; else
1242
- $hidden_blocks .= '<section class="ai-viewport-' . $viewport .'" style="' . $this->get_alignmet_style() . '; border: 1px solid blue;"><section style="padding: 1px 0 1px 5px; text-align: center; background: blue; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1243
  }
1244
  }
1245
 
1246
  $code = "<div style='border: 1px solid red;'>".$visible_blocks.$this->ai_getProcessedCode (true).'</div>';
1247
  } else $code = $this->ai_getProcessedCode ();
1248
 
 
 
 
 
 
 
 
 
1249
  if ($hidden_widgets) return $hidden_blocks; else {
1250
  if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
1251
- $wrapper_before = $hidden_blocks . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . ($viewport_classes ? $this->get_viewport_classes () : "") . "' style='" . $additional_block_style . $this->get_alignmet_style() . "'>";
1252
- $wrapper_after = "</div>";
1253
 
1254
  if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
1255
  $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
@@ -1803,15 +1870,20 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1803
  if (preg_match_all("/{adinserter (.+?)}/", $content, $tags)){
1804
 
1805
  $block_class_name = get_block_class_name ();
 
 
 
 
 
1806
 
1807
- $display_for_devices = $this->get_display_for_devices ();
1808
 
1809
  foreach ($tags [1] as $tag) {
1810
  $ad_tag = strtolower (trim ($tag));
1811
  $ad_name = strtolower (trim ($this->get_ad_name()));
1812
  if ($ad_tag == $ad_name || $ad_tag == $this->number) {
1813
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) $ad_code = $this->ai_getProcessedCode (); else
1814
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . $this->ai_getProcessedCode () . "</div>";
1815
  $content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content);
1816
  }
1817
  }
7
  var $fallback;
8
  var $client_side_ip_address_detection;
9
  var $w3tc_code;
10
+ var $needs_class;
11
 
12
  function __construct () {
13
 
15
  $this->fallback = 0;
16
  $this->client_side_ip_address_detection = false;
17
  $this->w3tc_code = '';
18
+ $this->needs_class = false;
19
 
20
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
21
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
401
  $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
402
  $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
403
  $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
404
+ $this->wp_options [AI_OPTION_ENABLE_AJAX] = AD_SETTINGS_CHECKED;
405
  $this->wp_options [AI_OPTION_ENABLE_FEED] = AD_SETTINGS_NOT_CHECKED;
406
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
407
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
480
  }
481
 
482
  public function get_alignment_type (){
 
483
  $option = isset ($this->wp_options [AI_OPTION_ALIGNMENT_TYPE]) ? $this->wp_options [AI_OPTION_ALIGNMENT_TYPE] : AI_ALIGNMENT_DEFAULT;
484
 
485
  if ($option == '') $option = AI_ALIGNMENT_DEFAULT;
516
  case AI_ALIGNMENT_FLOAT_RIGHT:
517
  return AI_TEXT_FLOAT_RIGHT;
518
  break;
519
+ case AI_ALIGNMENT_STICKY_LEFT:
520
+ return AI_TEXT_STICKY_LEFT;
521
+ break;
522
+ case AI_ALIGNMENT_STICKY_RIGHT:
523
+ return AI_TEXT_STICKY_RIGHT;
524
+ break;
525
+ case AI_ALIGNMENT_STICKY_TOP:
526
+ return AI_TEXT_STICKY_TOP;
527
+ break;
528
+ case AI_ALIGNMENT_STICKY_BOTTOM:
529
+ return AI_TEXT_STICKY_BOTTOM;
530
+ break;
531
  case AI_ALIGNMENT_NO_WRAPPING:
532
  return AI_TEXT_NO_WRAPPING;
533
  break;
540
  }
541
  }
542
 
543
+ public function alignment_style ($alignment_type, $all_styles = false) {
 
544
 
545
+ $style = "";
546
+ switch ($alignment_type) {
547
+ case AI_ALIGNMENT_DEFAULT:
548
+ $style = AI_ALIGNMENT_CSS_DEFAULT;
549
+ break;
550
+ case AI_ALIGNMENT_LEFT:
551
+ $style = AI_ALIGNMENT_CSS_LEFT;
552
+ break;
553
+ case AI_ALIGNMENT_RIGHT:
554
+ $style = AI_ALIGNMENT_CSS_RIGHT;
555
+ break;
556
+ case AI_ALIGNMENT_CENTER:
557
+ $style = AI_ALIGNMENT_CSS_CENTER;
558
+ break;
559
+ case AI_ALIGNMENT_FLOAT_LEFT:
560
+ $style = AI_ALIGNMENT_CSS_FLOAT_LEFT;
561
+ break;
562
+ case AI_ALIGNMENT_FLOAT_RIGHT:
563
+ $style = AI_ALIGNMENT_CSS_FLOAT_RIGHT;
564
+ break;
565
+ case AI_ALIGNMENT_STICKY_LEFT:
566
+ $style = AI_ALIGNMENT_CSS_STICKY_LEFT;
567
+ break;
568
+ case AI_ALIGNMENT_STICKY_RIGHT:
569
+ $style = AI_ALIGNMENT_CSS_STICKY_RIGHT;
570
+ break;
571
+ case AI_ALIGNMENT_STICKY_TOP:
572
+ $style = AI_ALIGNMENT_CSS_STICKY_TOP;
573
+ break;
574
+ case AI_ALIGNMENT_STICKY_BOTTOM:
575
+ $style = AI_ALIGNMENT_CSS_STICKY_BOTTOM;
576
+ break;
577
+ case AI_ALIGNMENT_CUSTOM_CSS:
578
+ $style = $this->get_custom_css ();
579
+ break;
580
  }
581
+
582
+ if (!$all_styles && strpos ($style, "||") !== false) {
583
+ $styles = explode ("||", $style);
584
+ if (isset ($styles [0])) {
585
+ $style = trim ($styles [0]);
586
+ }
587
  }
588
 
589
+
590
+ // if ($alignment_type == AI_ALIGNMENT_DEFAULT) {
591
+ // $style = "margin: 8px 0px;";
592
+ // }
593
+ // elseif ($alignment_type == AI_ALIGNMENT_LEFT) {
594
+ // $style = "text-align: left; margin: 8px 0px;";
595
+ // }
596
+ // elseif ($alignment_type == AI_ALIGNMENT_RIGHT) {
597
+ // $style = "text-align: right; margin: 8px 0px;";
598
+ // }
599
+ // elseif ($alignment_type == AI_ALIGNMENT_CENTER) {
600
+ // $style = "text-align: center; margin: 8px auto;";
601
+ // }
602
+ // elseif ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) {
603
+ // $style = "float: left; margin: 8px 8px 8px 0;";
604
+ // }
605
+ // elseif ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) {
606
+ // $style = "float: right; margin: 8px 0px 8px 8px;";
607
+ // }
608
+ // elseif ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) {
609
+ // $style = $this->get_custom_css ();
610
+ // }
611
+ // else {
612
+ // $style = "";
613
+ // }
614
+
615
  return $style;
616
  }
617
 
618
+ public function get_alignment_style (){
619
+ return $this->alignment_style ($this->get_alignment_type());
620
  }
621
 
622
  public function get_paragraph_number(){
818
  return $enable_feed;
819
  }
820
 
821
+ public function get_enable_ajax (){
822
+ $enable_ajax = isset ($this->wp_options [AI_OPTION_ENABLE_AJAX]) ? $this->wp_options [AI_OPTION_ENABLE_AJAX] : "";
823
+ if ($enable_ajax == '') $enable_ajax = AD_SETTINGS_CHECKED;
824
+ return $enable_ajax;
825
+ }
826
+
827
  public function get_enable_manual (){
828
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
829
  if ($option == '') {
1049
  if ($countries != '') $country_attributes = "countries='$countries' country-list='$country_list_type'"; else $country_attributes = '';
1050
  if ($ip_addresses != '') $ip_address_attributes = "ip-addresses='$ip_addresses' ip-address-list='$ip_address_list_type'"; else $ip_address_attributes = '';
1051
 
1052
+ $block_class_name = get_block_class_name ();
1053
+ if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1054
+ $block_class_name = $block_class_name.'-'.$this->number;
1055
  $this->client_side_ip_address_detection = true;
1056
+ $this->needs_class = true;
1057
 
1058
  $processed_code = "\n<div class='ai-ip-data' $ip_address_attributes $country_attributes class-name='$block_class_name' style='visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;'>$processed_code</div>\n";
1059
  }
1276
  return ($viewport_classes);
1277
  }
1278
 
1279
+ public function get_code_for_insertion ($include_viewport_classes = true, $hidden_widgets = false) {
1280
  global $ai_wp_data;
1281
 
1282
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1283
 
 
 
1284
  $hidden_blocks = '';
1285
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1286
 
1298
  if ($viewport_name != '') {
1299
  if ($this->get_detection_viewport ($viewport))
1300
  $visible_blocks .= '<section class="ai-viewport-' . $viewport .'" style=""><section style="padding: 1px 0 1px 5px; text-align: center; background: red; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section><section>'; else
1301
+ $hidden_blocks .= '<section class="ai-viewport-' . $viewport .'" style="' . $this->get_alignment_style() . '; border: 1px solid blue;"><section style="padding: 1px 0 1px 5px; text-align: center; background: blue; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1302
  }
1303
  }
1304
 
1305
  $code = "<div style='border: 1px solid red;'>".$visible_blocks.$this->ai_getProcessedCode (true).'</div>';
1306
  } else $code = $this->ai_getProcessedCode ();
1307
 
1308
+ $block_class_name = get_block_class_name ();
1309
+ if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1310
+ $viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
1311
+ if ($block_class_name != '' || $viewport_classes != '') {
1312
+ if ($block_class_name == '') $viewport_classes = trim ($viewport_classes);
1313
+ $class = " class='" . ($block_class_name != '' ? $block_class_name . " " . $block_class_name . "-" . $this->number : '') . $viewport_classes ."'";
1314
+ } else $class = '';
1315
+
1316
  if ($hidden_widgets) return $hidden_blocks; else {
1317
  if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
1318
+ $wrapper_before = $hidden_blocks . "<div" . $class . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1319
+ $wrapper_after = "</div>\n";
1320
 
1321
  if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
1322
  $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1870
  if (preg_match_all("/{adinserter (.+?)}/", $content, $tags)){
1871
 
1872
  $block_class_name = get_block_class_name ();
1873
+ $viewport_classes = $this->get_viewport_classes ();
1874
+ if ($block_class_name != '' || $viewport_classes != '') {
1875
+ if ($block_class_name =='') $viewport_classes = trim ($viewport_classes);
1876
+ $class = " class='" . ($block_class_name != '' ? $block_class_name . " " . $block_class_name . "-" . $this->number : '') . $viewport_classes ."'";
1877
+ } else $class = '';
1878
 
1879
+ // $display_for_devices = $this->get_display_for_devices ();
1880
 
1881
  foreach ($tags [1] as $tag) {
1882
  $ad_tag = strtolower (trim ($tag));
1883
  $ad_name = strtolower (trim ($this->get_ad_name()));
1884
  if ($ad_tag == $ad_name || $ad_tag == $this->number) {
1885
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) $ad_code = $this->ai_getProcessedCode (); else
1886
+ $ad_code = "<div" . $class . " style='" . $this->get_alignment_style() . "'>" . $this->ai_getProcessedCode () . "</div>";
1887
  $content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content);
1888
  }
1889
  }
constants.php CHANGED
@@ -11,7 +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.14');
15
 
16
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
17
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -48,6 +48,7 @@ define ('AI_OPTION_CODE', 'code');
48
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
49
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
50
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
 
51
  define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
52
  define ('AI_OPTION_ENABLE_404', 'enable_404');
53
  define ('AI_OPTION_NAME', 'name');
@@ -209,6 +210,10 @@ define('AI_ALIGNMENT_FLOAT_LEFT', 4);
209
  define('AI_ALIGNMENT_FLOAT_RIGHT', 5);
210
  define('AI_ALIGNMENT_NO_WRAPPING', 6);
211
  define('AI_ALIGNMENT_CUSTOM_CSS', 7);
 
 
 
 
212
 
213
  define('AI_TEXT_DEFAULT', 'Default');
214
  define('AI_TEXT_LEFT', 'Align Left');
@@ -218,6 +223,21 @@ define('AI_TEXT_FLOAT_LEFT', 'Float Left');
218
  define('AI_TEXT_FLOAT_RIGHT', 'Float Right');
219
  define('AI_TEXT_NO_WRAPPING', 'No Wrapping');
220
  define('AI_TEXT_CUSTOM_CSS', 'Custom CSS');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
222
  //List Type
223
  define('AD_BLACK_LIST','Black List');
@@ -279,7 +299,6 @@ define('AI_TEXT_SERVER_SIDE_W3TC', 'Server-side using W3 Total Cache');
279
  define('AD_SETTINGS_CHECKED', '1');
280
  define('AD_SETTINGS_NOT_CHECKED', '0');
281
 
282
- define('DEFAULT_MARGIN', 8);
283
  define('AI_COOKIE_TIME', 3600);
284
 
285
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
@@ -378,6 +397,7 @@ define ('AI_PT_SEARCH', 6);
378
  define ('AI_PT_404', 7);
379
  define ('AI_PT_FEED', 8);
380
  define ('AI_PT_ADMIN', 9);
 
381
 
382
  define ('AI_USER_NOT_SET', - 1);
383
  define ('AI_USER_NOT_LOGGED_IN', 0);
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '2.1.0');
15
 
16
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
17
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
48
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
49
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
50
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
51
+ define ('AI_OPTION_ENABLE_AJAX', 'enable_ajax');
52
  define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
53
  define ('AI_OPTION_ENABLE_404', 'enable_404');
54
  define ('AI_OPTION_NAME', 'name');
210
  define('AI_ALIGNMENT_FLOAT_RIGHT', 5);
211
  define('AI_ALIGNMENT_NO_WRAPPING', 6);
212
  define('AI_ALIGNMENT_CUSTOM_CSS', 7);
213
+ define('AI_ALIGNMENT_STICKY_LEFT', 8);
214
+ define('AI_ALIGNMENT_STICKY_RIGHT', 9);
215
+ define('AI_ALIGNMENT_STICKY_TOP', 10);
216
+ define('AI_ALIGNMENT_STICKY_BOTTOM', 11);
217
 
218
  define('AI_TEXT_DEFAULT', 'Default');
219
  define('AI_TEXT_LEFT', 'Align Left');
223
  define('AI_TEXT_FLOAT_RIGHT', 'Float Right');
224
  define('AI_TEXT_NO_WRAPPING', 'No Wrapping');
225
  define('AI_TEXT_CUSTOM_CSS', 'Custom CSS');
226
+ define('AI_TEXT_STICKY_LEFT', 'Sticky Left');
227
+ define('AI_TEXT_STICKY_RIGHT', 'Sticky Right');
228
+ define('AI_TEXT_STICKY_TOP', 'Sticky Top');
229
+ define('AI_TEXT_STICKY_BOTTOM', 'Sticky Bottom');
230
+
231
+ define('AI_ALIGNMENT_CSS_DEFAULT', 'margin: 8px 0;');
232
+ define('AI_ALIGNMENT_CSS_LEFT', 'margin: 8px 0; text-align: left;||margin: 8px 0; text-align: left; display: flex; justify-content: flex-start;');
233
+ define('AI_ALIGNMENT_CSS_RIGHT', 'margin: 8px 0; text-align: right;||margin: 8px 0; text-align: right; display: flex; justify-content: flex-end;');
234
+ define('AI_ALIGNMENT_CSS_CENTER', 'margin: 8px auto; text-align: center;||margin: 8px 0; text-align: center; display: flex; justify-content: center;');
235
+ define('AI_ALIGNMENT_CSS_FLOAT_LEFT', 'margin: 8px 8px 8px 0; float: left;');
236
+ define('AI_ALIGNMENT_CSS_FLOAT_RIGHT', 'margin: 8px 0 8px 8px; float: right;');
237
+ define('AI_ALIGNMENT_CSS_STICKY_LEFT', 'position: fixed; left: 0px; top: 100px; z-index: 9999;');
238
+ define('AI_ALIGNMENT_CSS_STICKY_RIGHT', 'position: fixed; right: 0px; top: 100px; z-index: 9999;');
239
+ define('AI_ALIGNMENT_CSS_STICKY_TOP', 'position: fixed; top: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; top: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
240
+ define('AI_ALIGNMENT_CSS_STICKY_BOTTOM', 'position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
241
 
242
  //List Type
243
  define('AD_BLACK_LIST','Black List');
299
  define('AD_SETTINGS_CHECKED', '1');
300
  define('AD_SETTINGS_NOT_CHECKED', '0');
301
 
 
302
  define('AI_COOKIE_TIME', 3600);
303
 
304
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
397
  define ('AI_PT_404', 7);
398
  define ('AI_PT_FEED', 8);
399
  define ('AI_PT_ADMIN', 9);
400
+ define ('AI_PT_AJAX', 10);
401
 
402
  define ('AI_USER_NOT_SET', - 1);
403
  define ('AI_USER_NOT_LOGGED_IN', 0);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #data {
2
- font-family: "2.0.14"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #data {
2
+ font-family: "2.1.0"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.0.14";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -32,6 +32,10 @@ var AI_ALIGNMENT_FLOAT_LEFT = 4;
32
  var AI_ALIGNMENT_FLOAT_RIGHT = 5;
33
  var AI_ALIGNMENT_NO_WRAPPING = 6;
34
  var AI_ALIGNMENT_CUSTOM_CSS = 7;
 
 
 
 
35
 
36
  var shSettings = {
37
  "tab_size":"4",
@@ -296,6 +300,10 @@ jQuery(document).ready(function($) {
296
  $("#css-center-"+block).hide();
297
  $("#css-float-left-"+block).hide();
298
  $("#css-float-right-"+block).hide();
 
 
 
 
299
  $("#css-no-wrapping-"+block).hide();
300
 
301
  $("#no-wrapping-warning-"+block).hide();
@@ -331,7 +339,20 @@ jQuery(document).ready(function($) {
331
  } else
332
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
333
  $("#css-float-right-"+block).css('display', 'table-cell');
 
 
 
 
 
 
334
  }
 
 
 
 
 
 
 
335
 
336
  if ($('#css-code-'+block).is(':visible')) {
337
  $("#show-css-button-"+block+" span").text ("Hide");
@@ -478,6 +499,10 @@ jQuery(document).ready(function($) {
478
  });
479
  $("select#block-alignment-"+tab).change (function() {
480
  var block = $(this).attr('id').replace ("block-alignment-", "");
 
 
 
 
481
  process_display_elements (block);
482
  });
483
  $("input#process-php-"+tab).change (function() {
@@ -594,6 +619,10 @@ jQuery(document).ready(function($) {
594
  $("#css-center-"+block).hide();
595
  $("#css-float-left-"+block).hide();
596
  $("#css-float-right-"+block).hide();
 
 
 
 
597
 
598
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
599
 
@@ -626,9 +655,30 @@ jQuery(document).ready(function($) {
626
  $("#css-float-right-"+block).hide();
627
  $("#custom-css-"+block).show().val ($("#css-float-right-"+block).text ());
628
  $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  }
630
  });
631
 
 
632
  $("#name-label-"+tab).click (function () {
633
  var block = $(this).attr('id').replace ("name-label-", "");
634
  if (!$('#name-edit-'+block).is(':visible')) {
@@ -756,6 +806,18 @@ jQuery(document).ready(function($) {
756
  } else
757
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
758
  css = $("#css-float-right-"+block).text ();
 
 
 
 
 
 
 
 
 
 
 
 
759
  }
760
 
761
  var name = $("#name-label-"+block).text ();
1
+ var javascript_version = "2.1.0";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
32
  var AI_ALIGNMENT_FLOAT_RIGHT = 5;
33
  var AI_ALIGNMENT_NO_WRAPPING = 6;
34
  var AI_ALIGNMENT_CUSTOM_CSS = 7;
35
+ var AI_ALIGNMENT_STICKY_LEFT = 8;
36
+ var AI_ALIGNMENT_STICKY_RIGHT = 9;
37
+ var AI_ALIGNMENT_STICKY_TOP = 10;
38
+ var AI_ALIGNMENT_STICKY_BOTTOM = 11;
39
 
40
  var shSettings = {
41
  "tab_size":"4",
300
  $("#css-center-"+block).hide();
301
  $("#css-float-left-"+block).hide();
302
  $("#css-float-right-"+block).hide();
303
+ $("#css-sticky-left-"+block).hide();
304
+ $("#css-sticky-right-"+block).hide();
305
+ $("#css-sticky-top-"+block).hide();
306
+ $("#css-sticky-bottom-"+block).hide();
307
  $("#css-no-wrapping-"+block).hide();
308
 
309
  $("#no-wrapping-warning-"+block).hide();
339
  } else
340
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
341
  $("#css-float-right-"+block).css('display', 'table-cell');
342
+ } else
343
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
344
+ $("#css-sticky-left-"+block).css('display', 'table-cell');
345
+ } else
346
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
347
+ $("#css-sticky-right-"+block).css('display', 'table-cell');
348
  }
349
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
350
+ $("#css-sticky-top-"+block).css('display', 'table-cell');
351
+ } else
352
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
353
+ $("#css-sticky-bottom-"+block).css('display', 'table-cell');
354
+ }
355
+
356
 
357
  if ($('#css-code-'+block).is(':visible')) {
358
  $("#show-css-button-"+block+" span").text ("Hide");
499
  });
500
  $("select#block-alignment-"+tab).change (function() {
501
  var block = $(this).attr('id').replace ("block-alignment-", "");
502
+ var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
503
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT || alignment == AI_ALIGNMENT_STICKY_RIGHT || alignment == AI_ALIGNMENT_STICKY_TOP || alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
504
+ $("select#display-type-"+block).val (AI_AFTER_POST).change ();
505
+ }
506
  process_display_elements (block);
507
  });
508
  $("input#process-php-"+tab).change (function() {
619
  $("#css-center-"+block).hide();
620
  $("#css-float-left-"+block).hide();
621
  $("#css-float-right-"+block).hide();
622
+ $("#css-sticky-left-"+block).hide();
623
+ $("#css-sticky-right-"+block).hide();
624
+ $("#css-sticky-top-"+block).hide();
625
+ $("#css-sticky-bottom-"+block).hide();
626
 
627
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
628
 
655
  $("#css-float-right-"+block).hide();
656
  $("#custom-css-"+block).show().val ($("#css-float-right-"+block).text ());
657
  $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
658
+ } else
659
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
660
+ $("#css-sticky-left-"+block).hide();
661
+ $("#custom-css-"+block).show().val ($("#css-sticky-left-"+block).text ());
662
+ $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
663
+ } else
664
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
665
+ $("#css-sticky-right-"+block).hide();
666
+ $("#custom-css-"+block).show().val ($("#css-sticky-right-"+block).text ());
667
+ $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
668
+ }
669
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
670
+ $("#css-sticky-top-"+block).hide();
671
+ $("#custom-css-"+block).show().val ($("#css-sticky-top-"+block).text ());
672
+ $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
673
+ } else
674
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
675
+ $("#css-sticky-bottom-"+block).hide();
676
+ $("#custom-css-"+block).show().val ($("#css-sticky-bottom-"+block).text ());
677
+ $("select#block-alignment-"+block).val (AI_ALIGNMENT_CUSTOM_CSS).change();
678
  }
679
  });
680
 
681
+
682
  $("#name-label-"+tab).click (function () {
683
  var block = $(this).attr('id').replace ("name-label-", "");
684
  if (!$('#name-edit-'+block).is(':visible')) {
806
  } else
807
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
808
  css = $("#css-float-right-"+block).text ();
809
+ } else
810
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
811
+ css = $("#css-sticky-left-"+block).text ();
812
+ } else
813
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
814
+ css = $("#css-sticky-right-"+block).text ();
815
+ }
816
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
817
+ css = $("#css-sticky-top-"+block).text ();
818
+ } else
819
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
820
+ css = $("#css-sticky-bottom-"+block).text ();
821
  }
822
 
823
  var name = $("#name-label-"+block).text ();
preview.php CHANGED
@@ -1,5 +1,16 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
3
  function generate_code_preview ($block) {
4
 
5
  global $block_object;
@@ -9,20 +20,22 @@ function generate_code_preview ($block) {
9
  $block_name = isset ($_GET ["name"]) ? $_GET ["name"] : $obj->get_ad_name();
10
  $custom_css = $obj->get_custom_css();
11
  $alignment_type = isset ($_GET ["alignment"]) ? $_GET ["alignment"] : $obj->get_alignment_type();
12
- $wrapper_css = isset ($_GET ["css"]) ? $_GET ["css"] : $obj->get_alignmet_style ();
13
  $block_code = $obj->ai_getProcessedCode (true, true);
14
 
15
  ?><html>
16
  <head>
17
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
18
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
19
- <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
20
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
21
  <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
22
  <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
23
  <script src='<?php echo plugins_url ('includes/js/jquery.mousewheel.min.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
24
  <script src='<?php echo plugins_url ('includes/js/jquery.ui.spinner.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
25
  <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
 
 
 
26
  <script>
27
 
28
  // initialize_preview ();
@@ -60,6 +73,21 @@ function generate_code_preview ($block) {
60
  var AI_ALIGNMENT_FLOAT_RIGHT = 5;
61
  var AI_ALIGNMENT_NO_WRAPPING = 6;
62
  var AI_ALIGNMENT_CUSTOM_CSS = 7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  function update_highlighting () {
65
  if ($('body').hasClass ("highlighted")) {
@@ -114,8 +142,8 @@ function generate_code_preview ($block) {
114
  // document.write = oldDocumentWrite
115
  // }, 1000);
116
 
117
-
118
  $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
 
119
  $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
120
  $("#block-name").text (settings.find ("#name-label-" + block).text ());
121
 
@@ -127,8 +155,24 @@ function generate_code_preview ($block) {
127
  if (window.opener != null && !window.opener.closed) {
128
  var settings = $(window.opener.document).contents ();
129
 
130
- settings.find ("select#block-alignment-" + block).val ($("select#block-alignment option:selected").attr('value')).change ();
131
- settings.find ("#custom-css-" + block).val ($("#custom-css").val ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  window.opener.change_block_alignment (block);
133
  }
134
  }
@@ -179,61 +223,95 @@ function generate_code_preview ($block) {
179
  $("#css-label").css('display', 'inline-block');
180
  $("#edit-css-button").css('display', 'inline-block');
181
 
182
- $("#css-none").hide();
 
 
 
 
 
 
 
 
 
183
  $("#custom-css").hide();
184
- $("#css-left").hide();
185
- $("#css-right").hide();
186
- $("#css-center").hide();
187
- $("#css-float-left").hide();
188
- $("#css-float-right").hide();
189
  $("#css-no-wrapping").hide();
190
 
191
  $("#demo-box").show ();
192
  $("#demo-box-no-wrapping").hide ();
193
  wrapping = true;
194
 
195
- var alignment = $("select#block-alignment option:selected").attr('value');
196
 
197
- if (alignment == AI_ALIGNMENT_NO_WRAPPING) {
198
- $("#css-no-wrapping").css('display', 'inline-block');
199
- $("#css-label").hide();
200
- $("#edit-css-button").hide();
201
-
202
- wrapping = false;
203
- style = "";
204
-
205
- $("#demo-box").hide ();
206
- $("#demo-box-no-wrapping").show ();
 
 
 
 
207
 
208
- } else
209
  if (alignment == AI_ALIGNMENT_DEFAULT) {
210
- $("#css-none").css('display', 'inline-block');
211
- style = $("#css-none").text ();
212
- } else
213
- if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
214
- $("#css-code").show();
215
- $("#custom-css").show();
216
- style = $("#custom-css").val ();
217
  } else
218
  if (alignment == AI_ALIGNMENT_LEFT) {
219
- $("#css-left").css('display', 'inline-block');
220
- style = $("#css-left").text ();
221
  } else
222
  if (alignment == AI_ALIGNMENT_RIGHT) {
223
- $("#css-right").css('display', 'inline-block');
224
- style = $("#css-right").text ();
225
  } else
226
  if (alignment == AI_ALIGNMENT_CENTER) {
227
- $("#css-center").css('display', 'inline-block');
228
- style = $("#css-center").text ();
229
  } else
230
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
231
- $("#css-float-left").css('display', 'inline-block');
232
- style = $("#css-float-left").text ();
233
  } else
234
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
235
- $("#css-float-right").css('display', 'inline-block');
236
- style = $("#css-float-right").text ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
238
 
239
  $("#wrapper").attr ("style", style);
@@ -285,42 +363,57 @@ function generate_code_preview ($block) {
285
  $("#edit-css-button").button ({
286
  }).click (function () {
287
 
288
- $("#css-left").hide();
289
- $("#css-right").hide();
290
- $("#css-center").hide();
291
- $("#css-float-left").hide();
292
- $("#css-float-right").hide();
 
 
 
 
 
293
 
294
  var alignment = $("select#block-alignment"+" option:selected").attr('value');
295
 
296
  if (alignment == AI_ALIGNMENT_DEFAULT) {
297
- $("#css-none").hide();
298
- $("#custom-css").show().val ($("#css-none").text ());
299
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
300
  } else
301
  if (alignment == AI_ALIGNMENT_LEFT) {
302
- $("#css-left").hide();
303
- $("#custom-css").show().val ($("#css-left").text ());
304
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
305
  } else
306
  if (alignment == AI_ALIGNMENT_RIGHT) {
307
- $("#css-right").hide();
308
- $("#custom-css").show().val ($("#css-right").text ());
309
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
310
  } else
311
  if (alignment == AI_ALIGNMENT_CENTER) {
312
- $("#css-center").hide();
313
- $("#custom-css").show().val ($("#css-center").text ());
314
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
315
  } else
316
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
317
- $("#css-float-left").hide();
318
- $("#custom-css").show().val ($("#css-float-left").text ());
319
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
320
  } else
321
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
322
- $("#css-float-right").hide();
323
- $("#custom-css").show().val ($("#css-float-right").text ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
325
  }
326
  });
@@ -330,7 +423,7 @@ function generate_code_preview ($block) {
330
  update_margin_padding ();
331
  update_highlighting ();
332
  update_wrapper_size ();
333
- });;
334
 
335
  $("#highlight-button").button ({
336
  }).click (function () {
@@ -342,6 +435,13 @@ function generate_code_preview ($block) {
342
  }
343
 
344
  if (wrapping) {
 
 
 
 
 
 
 
345
  var wrapper_offset = wrapper.offset ();
346
  var wrapper_left = wrapper_offset.left;
347
  var wrapper_top = wrapper_offset.top;
@@ -368,7 +468,12 @@ function generate_code_preview ($block) {
368
  console.log ("wrapper_top: " + wrapper_top);
369
  console.log ("wrapper_width: " + wrapper_width);
370
  console.log ("wrapper_height: " + wrapper_height);
 
 
 
 
371
  console.log ("wrapper_outer_width: " + wrapper_outer_width);
 
372
  console.log ("wrapper_margin_height: " + wrapper_margin_height);
373
  console.log ("wrapper_margin_width: " + wrapper_margin_width);
374
  console.log ("wrapper_margin_height: " + wrapper_margin_height);
@@ -383,22 +488,22 @@ function generate_code_preview ($block) {
383
  $('#margin-background').show ();
384
  $("#padding-background-white").show ();
385
 
386
- $("#margin-background").offset ({top: wrapper_top - wrapper_margin_top, left: wrapper_left - wrapper_margin_left});
387
  $('#margin-background').css ('width', wrapper_width).css ('height', wrapper_height);
 
388
 
389
- $("#padding-background").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
390
  $('#padding-background').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
 
391
 
392
- $("#padding-background-white").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
393
  $('#padding-background-white').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
 
394
 
395
  code_blocks = wrapper.children ();
396
  } else {
397
  $('#margin-background').hide ();
398
  $("#padding-background-white").hide ();
399
 
400
- $("#padding-background").offset ({top: $('#wrapper').offset ().top, left: $('#wrapper').offset ().left});
401
  $('#padding-background').css ('width', $('#wrapper').outerWidth ()).css ('height', $('#wrapper').outerHeight ());
 
402
 
403
  code_blocks = wrapper.children ();
404
  }
@@ -432,12 +537,35 @@ function generate_code_preview ($block) {
432
  console.log ("element_outer_height: " + element_outer_height);
433
  }
434
 
 
 
 
 
 
 
 
 
 
 
 
435
  var new_id = "code-" + code_index;
436
- $("#" + last_code_div).after (overlay_div.clone ().offset ({top: element_top, left: element_left}).css ('width', element_outer_width).css ('height', element_outer_height).attr ("id", new_id).addClass ("highlighting"));
 
 
 
 
 
 
437
  last_code_div = new_id;
438
 
439
  var new_bkg_id = "code-background-" + code_index;
440
- $("#" + last_bkg_div).after (overlay_background_div.clone ().offset ({top: element_top, left: element_left}).css ('width', element_outer_width).css ('height', element_outer_height).attr ("id", new_bkg_id).addClass ("highlighting"));
 
 
 
 
 
 
441
  last_bkg_div = new_bkg_id;
442
  }
443
  });
@@ -478,6 +606,23 @@ function generate_code_preview ($block) {
478
 
479
  var current_time = new Date().getTime();
480
  if (debug) console.log ("TIME: " + ((current_time - start_time) / 1000).toFixed (3));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  }
482
 
483
  jQuery(document).ready(function($) {
@@ -491,7 +636,6 @@ function generate_code_preview ($block) {
491
  jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
492
  }
493
 
494
-
495
  </script>
496
  <style>
497
  .responsive-table td {
@@ -546,7 +690,7 @@ function generate_code_preview ($block) {
546
  display: block;
547
  }
548
  .code-overlay {
549
- z-index: 7;
550
  position: absolute;
551
  display: none;
552
  }
@@ -637,6 +781,25 @@ td.demo-wrapper-background {
637
  font-size: 11px;
638
  }
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  </style>
641
  <?php ai_wp_head_hook (); ?>
642
 
@@ -660,6 +823,7 @@ td.demo-wrapper-background {
660
  $previous_width = $viewport_width;
661
  }
662
  echo "<td style='background: #eee; text-align: left; border: 1px solid #888; border-left-width: 0; min-width: 2000px'><span style='margin-left: 30px;'>", get_viewport_name (1), "</span><span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
 
663
  ?>
664
  </tr>
665
  </table>
@@ -687,12 +851,6 @@ td.demo-wrapper-background {
687
  </table>
688
  </div>
689
 
690
- <div style="float: left; max-width: 300px; margin-right: 20px">
691
- <h1 style="margin: 0;">Preview</h1>
692
- <h2>Block <?php echo $block; ?></h2>
693
- <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
694
- </div>
695
-
696
  <div style="float: right; width: 90px; margin-left: 20px;">
697
  <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
698
  <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Use</button>
@@ -700,6 +858,12 @@ td.demo-wrapper-background {
700
  <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Cancel</button>
701
  </div>
702
 
 
 
 
 
 
 
703
  <div style="float: left; min-height: 200px; margin: 0 auto;">
704
  <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
705
  <tr>
@@ -765,21 +929,40 @@ td.demo-wrapper-background {
765
  <div style="clear: both;"></div>
766
 
767
  <div id="css-code" style="margin: 20px 0;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
  <table class="responsive-table">
769
  <tr>
770
  <td style="vertical-align: middle; padding:0;">
771
- <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0; font-size: 12px; display: none;">CSS &nbsp;</span>
772
  </td>
773
  <td style="width: 100%; height: 32px; padding:0;">
774
  <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 0; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css; ?>" size="70" maxlength="160" title="Custom CSS code for wrapping div" />
775
  <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
776
  <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
777
- <span id="css-none" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_DEFAULT); ?></span>
778
- <span id="css-left" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_LEFT); ?></span>
779
- <span id="css-right" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_RIGHT); ?></span>
780
- <span id="css-center" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_CENTER); ?></span>
781
- <span id="css-float-left" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
782
- <span id="css-float-right" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
 
783
  </span>
784
  </td>
785
  <td padding:0;>
@@ -787,20 +970,6 @@ td.demo-wrapper-background {
787
  </td>
788
  </tr>
789
  </table>
790
-
791
- <div style="margin: 20px 0;">
792
- Block Alignment and Style:&nbsp;&nbsp;&nbsp;
793
- <select style="border-radius: 5px; width:120px; height: 25px;" id="block-alignment">
794
- <option value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
795
- <option value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
796
- <option value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
797
- <option value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
798
- <option value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
799
- <option value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
800
- <option value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
801
- <option value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
802
- </select>
803
- </div>
804
  </div>
805
 
806
  <p id="p1">This is a preview of the saved code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
1
  <?php
2
 
3
+ function alt_styles_data ($alt_styles_text) {
4
+ if (strpos ($alt_styles_text, "||") !== false) {
5
+ $styles = explode ("||", $alt_styles_text);
6
+ $alt_styles = array ();
7
+ foreach ($styles as $index => $style) {
8
+ $alt_styles ['css' . ($index + 1)] = str_replace ("'", '"', str_replace (array ("\"", "<", ">", "[", "]"), "", trim ($style)));
9
+ }
10
+ echo "data-alt-style='1' data-alt-styles='", json_encode ($alt_styles), "'";
11
+ }
12
+ }
13
+
14
  function generate_code_preview ($block) {
15
 
16
  global $block_object;
20
  $block_name = isset ($_GET ["name"]) ? $_GET ["name"] : $obj->get_ad_name();
21
  $custom_css = $obj->get_custom_css();
22
  $alignment_type = isset ($_GET ["alignment"]) ? $_GET ["alignment"] : $obj->get_alignment_type();
23
+ $wrapper_css = isset ($_GET ["css"]) ? $_GET ["css"] : $obj->get_alignment_style ();
24
  $block_code = $obj->ai_getProcessedCode (true, true);
25
 
26
  ?><html>
27
  <head>
28
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
29
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
 
30
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
31
  <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
32
  <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
33
  <script src='<?php echo plugins_url ('includes/js/jquery.mousewheel.min.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
34
  <script src='<?php echo plugins_url ('includes/js/jquery.ui.spinner.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
35
  <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
36
+ <link rel='stylesheet' href='<?php echo plugins_url ('css/image-picker.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
37
+ <script src='<?php echo plugins_url ('includes/js/image-picker.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
38
+ <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
39
  <script>
40
 
41
  // initialize_preview ();
73
  var AI_ALIGNMENT_FLOAT_RIGHT = 5;
74
  var AI_ALIGNMENT_NO_WRAPPING = 6;
75
  var AI_ALIGNMENT_CUSTOM_CSS = 7;
76
+ var AI_ALIGNMENT_STICKY_LEFT = 8;
77
+ var AI_ALIGNMENT_STICKY_RIGHT = 9;
78
+ var AI_ALIGNMENT_STICKY_TOP = 10;
79
+ var AI_ALIGNMENT_STICKY_BOTTOM = 11;
80
+
81
+ var id_css_alignment_default = "#css-" + AI_ALIGNMENT_DEFAULT;
82
+ var id_css_alignment_left = "#css-" + AI_ALIGNMENT_LEFT;
83
+ var id_css_alignment_right = "#css-" + AI_ALIGNMENT_RIGHT;
84
+ var id_css_alignment_center = "#css-" + AI_ALIGNMENT_CENTER;
85
+ var id_css_alignment_float_left = "#css-" + AI_ALIGNMENT_FLOAT_LEFT;
86
+ var id_css_alignment_float_right = "#css-" + AI_ALIGNMENT_FLOAT_RIGHT;
87
+ var id_css_alignment_sticky_left = "#css-" + AI_ALIGNMENT_STICKY_LEFT;
88
+ var id_css_alignment_sticky_right = "#css-" + AI_ALIGNMENT_STICKY_RIGHT;
89
+ var id_css_alignment_sticky_top = "#css-" + AI_ALIGNMENT_STICKY_TOP;
90
+ var id_css_alignment_sticky_bottom = "#css-" + AI_ALIGNMENT_STICKY_BOTTOM;
91
 
92
  function update_highlighting () {
93
  if ($('body').hasClass ("highlighted")) {
142
  // document.write = oldDocumentWrite
143
  // }, 1000);
144
 
 
145
  $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
146
+ $("select#block-alignment option:selected").data ('alt-style', '1');
147
  $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
148
  $("#block-name").text (settings.find ("#name-label-" + block).text ());
149
 
155
  if (window.opener != null && !window.opener.closed) {
156
  var settings = $(window.opener.document).contents ();
157
 
158
+ var selected_alignment = $("select#block-alignment option:selected");
159
+ var new_alignment = selected_alignment.attr('value');
160
+ var new_custom_css = $("#custom-css").val ();
161
+
162
+ var alt_styles = selected_alignment.data ('alt-styles');
163
+ if (typeof alt_styles != 'undefined') {
164
+ css_index = selected_alignment.data ('alt-style')
165
+ if (css_index != 1) {
166
+ new_alignment = AI_ALIGNMENT_CUSTOM_CSS;
167
+ new_custom_css = alt_styles ['css' + css_index].replace (/\"/g, "'");
168
+ }
169
+ }
170
+
171
+ settings.find ("select#block-alignment-" + block).val (new_alignment).change ();
172
+ if (new_alignment == AI_ALIGNMENT_CUSTOM_CSS) {
173
+ settings.find ("#custom-css-" + block).val (new_custom_css);
174
+ }
175
+
176
  window.opener.change_block_alignment (block);
177
  }
178
  }
223
  $("#css-label").css('display', 'inline-block');
224
  $("#edit-css-button").css('display', 'inline-block');
225
 
226
+ $(id_css_alignment_default).hide();
227
+ $(id_css_alignment_left).hide();
228
+ $("#css-" + AI_ALIGNMENT_RIGHT).hide();
229
+ $("#css-" + AI_ALIGNMENT_CENTER).hide();
230
+ $("#css-" + AI_ALIGNMENT_FLOAT_LEFT).hide();
231
+ $("#css-" + AI_ALIGNMENT_FLOAT_RIGHT).hide();
232
+ $("#css-" + AI_ALIGNMENT_STICKY_LEFT).hide();
233
+ $("#css-" + AI_ALIGNMENT_STICKY_RIGHT).hide();
234
+ $("#css-" + AI_ALIGNMENT_STICKY_TOP).hide();
235
+ $("#css-" + AI_ALIGNMENT_STICKY_BOTTOM).hide();
236
  $("#custom-css").hide();
 
 
 
 
 
237
  $("#css-no-wrapping").hide();
238
 
239
  $("#demo-box").show ();
240
  $("#demo-box-no-wrapping").hide ();
241
  wrapping = true;
242
 
243
+ $("#css-index").text ('');
244
 
245
+ var selected_alignment = $("select#block-alignment option:selected");
246
+ var alignment = selected_alignment.attr ('value');
247
+ var alt_styles = selected_alignment.data ('alt-styles');
248
+ if (typeof alt_styles != 'undefined') {
249
+ var alt_style_index = selected_alignment.data ('alt-style');
250
+ var num_styles = Object.keys(alt_styles).length;
251
+ if (alt_style_index > num_styles) {
252
+ alt_style_index = 1;
253
+ }
254
+ $('#css-' + alignment).text (alt_styles ['css' + alt_style_index].replace (/\"/g, "'"));
255
+ if (num_styles > 1) {
256
+ $("#css-index").text (alt_style_index);
257
+ }
258
+ }
259
 
 
260
  if (alignment == AI_ALIGNMENT_DEFAULT) {
261
+ $(id_css_alignment_default).css('display', 'inline-block');
262
+ style = $(id_css_alignment_default).text ();
 
 
 
 
 
263
  } else
264
  if (alignment == AI_ALIGNMENT_LEFT) {
265
+ $(id_css_alignment_left).css('display', 'inline-block');
266
+ style = $(id_css_alignment_left).text ();
267
  } else
268
  if (alignment == AI_ALIGNMENT_RIGHT) {
269
+ $(id_css_alignment_right).css('display', 'inline-block');
270
+ style = $(id_css_alignment_right).text ();
271
  } else
272
  if (alignment == AI_ALIGNMENT_CENTER) {
273
+ $(id_css_alignment_center).css('display', 'inline-block');
274
+ style = $(id_css_alignment_center).text ();
275
  } else
276
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
277
+ $(id_css_alignment_float_left).css('display', 'inline-block');
278
+ style = $(id_css_alignment_float_left).text ();
279
  } else
280
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
281
+ $(id_css_alignment_float_right).css('display', 'inline-block');
282
+ style = $(id_css_alignment_float_right).text ();
283
+ } else
284
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
285
+ $(id_css_alignment_sticky_left).css('display', 'inline-block');
286
+ style = $(id_css_alignment_sticky_left).text ();
287
+ } else
288
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
289
+ $(id_css_alignment_sticky_right).css('display', 'inline-block');
290
+ style = $(id_css_alignment_sticky_right).text ();
291
+ } else
292
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
293
+ $(id_css_alignment_sticky_top).css('display', 'inline-block');
294
+ style = $(id_css_alignment_sticky_top).text ();
295
+ } else
296
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
297
+ $(id_css_alignment_sticky_bottom).css('display', 'inline-block');
298
+ style = $(id_css_alignment_sticky_bottom).text ();
299
+ } else
300
+ if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
301
+ $("#css-code").show();
302
+ $("#custom-css").show();
303
+ style = $("#custom-css").val ();
304
+ } else
305
+ if (alignment == AI_ALIGNMENT_NO_WRAPPING) {
306
+ $("#css-no-wrapping").css('display', 'inline-block');
307
+ $("#css-label").hide();
308
+ $("#edit-css-button").hide();
309
+
310
+ wrapping = false;
311
+ style = "";
312
+
313
+ $("#demo-box").hide ();
314
+ $("#demo-box-no-wrapping").show ();
315
  }
316
 
317
  $("#wrapper").attr ("style", style);
363
  $("#edit-css-button").button ({
364
  }).click (function () {
365
 
366
+ $(id_css_alignment_default).hide();
367
+ $(id_css_alignment_left).hide();
368
+ $(id_css_alignment_right).hide();
369
+ $(id_css_alignment_center).hide();
370
+ $(id_css_alignment_float_left).hide();
371
+ $(id_css_alignment_float_right).hide();
372
+ $(id_css_alignment_sticky_left).hide();
373
+ $(id_css_alignment_sticky_right).hide();
374
+ $(id_css_alignment_sticky_top).hide();
375
+ $(id_css_alignment_sticky_bottom).hide();
376
 
377
  var alignment = $("select#block-alignment"+" option:selected").attr('value');
378
 
379
  if (alignment == AI_ALIGNMENT_DEFAULT) {
380
+ $("#custom-css").show().val ($(id_css_alignment_default).text ());
 
381
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
382
  } else
383
  if (alignment == AI_ALIGNMENT_LEFT) {
384
+ $("#custom-css").show().val ($(id_css_alignment_left).text ());
 
385
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
386
  } else
387
  if (alignment == AI_ALIGNMENT_RIGHT) {
388
+ $("#custom-css").show().val ($(id_css_alignment_right).text ());
 
389
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
390
  } else
391
  if (alignment == AI_ALIGNMENT_CENTER) {
392
+ $("#custom-css").show().val ($(id_css_alignment_center).text ());
 
393
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
394
  } else
395
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
396
+ $("#custom-css").show().val ($(id_css_alignment_float_left).text ());
 
397
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
398
  } else
399
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
400
+ $("#custom-css").show().val ($(id_css_alignment_float_right).text ());
401
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
402
+ } else
403
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
404
+ $("#custom-css").show().val ($(id_css_alignment_sticky_left).text ());
405
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
406
+ } else
407
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
408
+ $("#custom-css").show().val ($(id_css_alignment_sticky_right).text ());
409
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
410
+ }
411
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
412
+ $("#custom-css").show().val ($(id_css_alignment_sticky_top).text ());
413
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
414
+ } else
415
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
416
+ $("#custom-css").show().val ($(id_css_alignment_sticky_bottom).text ());
417
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
418
  }
419
  });
423
  update_margin_padding ();
424
  update_highlighting ();
425
  update_wrapper_size ();
426
+ });
427
 
428
  $("#highlight-button").button ({
429
  }).click (function () {
435
  }
436
 
437
  if (wrapping) {
438
+
439
+ var overlay_position = '';
440
+ if (wrapper.css ('position') == 'fixed') overlay_position = 'fixed';
441
+ $('#margin-background').css ('position', overlay_position);
442
+ $('#padding-background').css ('position', overlay_position);
443
+ $('#padding-background-white').css ('position', overlay_position);
444
+
445
  var wrapper_offset = wrapper.offset ();
446
  var wrapper_left = wrapper_offset.left;
447
  var wrapper_top = wrapper_offset.top;
468
  console.log ("wrapper_top: " + wrapper_top);
469
  console.log ("wrapper_width: " + wrapper_width);
470
  console.log ("wrapper_height: " + wrapper_height);
471
+ console.log ("wrapper_margin_top: " + wrapper_margin_top);
472
+ console.log ("wrapper_margin_left: " + wrapper_margin_left);
473
+ console.log ("wrapper_border_top: " + wrapper_border_top);
474
+ console.log ("wrapper_border_left: " + wrapper_border_left);
475
  console.log ("wrapper_outer_width: " + wrapper_outer_width);
476
+ console.log ("wrapper_outer_height: " + wrapper_outer_height);
477
  console.log ("wrapper_margin_height: " + wrapper_margin_height);
478
  console.log ("wrapper_margin_width: " + wrapper_margin_width);
479
  console.log ("wrapper_margin_height: " + wrapper_margin_height);
488
  $('#margin-background').show ();
489
  $("#padding-background-white").show ();
490
 
 
491
  $('#margin-background').css ('width', wrapper_width).css ('height', wrapper_height);
492
+ $("#margin-background").offset ({top: wrapper_top - wrapper_margin_top, left: wrapper_left - wrapper_margin_left});
493
 
 
494
  $('#padding-background').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
495
+ $("#padding-background").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
496
 
 
497
  $('#padding-background-white').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
498
+ $("#padding-background-white").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
499
 
500
  code_blocks = wrapper.children ();
501
  } else {
502
  $('#margin-background').hide ();
503
  $("#padding-background-white").hide ();
504
 
 
505
  $('#padding-background').css ('width', $('#wrapper').outerWidth ()).css ('height', $('#wrapper').outerHeight ());
506
+ $("#padding-background").offset ({top: $('#wrapper').offset ().top, left: $('#wrapper').offset ().left});
507
 
508
  code_blocks = wrapper.children ();
509
  }
537
  console.log ("element_outer_height: " + element_outer_height);
538
  }
539
 
540
+ var overlay_div_position = overlay_div.css ('position');
541
+ var overlay_background_div_position = overlay_background_div.css ('position');
542
+ var fixed_offset_top = 0;
543
+ var fixed_offset_left = 0;
544
+ if (wrapper.css ('position') == 'fixed') {
545
+ overlay_div_position = 'fixed';
546
+ overlay_background_div_position = 'fixed';
547
+ fixed_offset_top = $(document).scrollTop();
548
+ fixed_offset_left = $(document).scrollLeft();
549
+ }
550
+
551
  var new_id = "code-" + code_index;
552
+ $("#" + last_code_div).after (overlay_div.clone ().
553
+ css ('position', overlay_div_position).
554
+ css ('width', element_outer_width).
555
+ css ('height', element_outer_height).
556
+ offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
557
+ attr ("id", new_id).
558
+ addClass ("highlighting"));
559
  last_code_div = new_id;
560
 
561
  var new_bkg_id = "code-background-" + code_index;
562
+ $("#" + last_bkg_div).after (overlay_background_div.clone ().
563
+ css ('position', overlay_background_div_position).
564
+ css ('width', element_outer_width).
565
+ css ('height', element_outer_height).
566
+ offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
567
+ attr ("id", new_bkg_id).
568
+ addClass ("highlighting"));
569
  last_bkg_div = new_bkg_id;
570
  }
571
  });
606
 
607
  var current_time = new Date().getTime();
608
  if (debug) console.log ("TIME: " + ((current_time - start_time) / 1000).toFixed (3));
609
+
610
+ $("select#block-alignment").imagepicker({hide_select: false});
611
+ $("select#block-alignment + ul").appendTo("#alignment-style").css ('padding-top', '10px');
612
+
613
+ $("div.automatic-insertion").dblclick (function () {
614
+ var selected_alignment = $("select#block-alignment option:selected");
615
+ var alignment_value = selected_alignment.val ();
616
+ var alt_styles = selected_alignment.data ('alt-styles');
617
+ if (typeof alt_styles != 'undefined') {
618
+ var alt_style_index = selected_alignment.data ('alt-style');
619
+ var num_styles = Object.keys(alt_styles).length;
620
+ alt_style_index ++;
621
+ if (alt_style_index > num_styles) alt_style_index = 1;
622
+ selected_alignment.data ('alt-style', alt_style_index)
623
+ process_display_elements ();
624
+ }
625
+ });
626
  }
627
 
628
  jQuery(document).ready(function($) {
636
  jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
637
  }
638
 
 
639
  </script>
640
  <style>
641
  .responsive-table td {
690
  display: block;
691
  }
692
  .code-overlay {
693
+ z-index: 99999;
694
  position: absolute;
695
  display: none;
696
  }
781
  font-size: 11px;
782
  }
783
 
784
+ .thumbnail {
785
+ border-radius: 6px;
786
+ }
787
+ ul.image_picker_selector {
788
+ overflow: hidden!important;
789
+ }
790
+
791
+ div.automatic-insertion {
792
+ width: 50px;
793
+ height: 50px;
794
+ }
795
+
796
+ li.automatic-insertion p {
797
+ width: 50px;
798
+ }
799
+
800
+ div.automatic-insertion img {
801
+ width: 50px;
802
+ }
803
  </style>
804
  <?php ai_wp_head_hook (); ?>
805
 
823
  $previous_width = $viewport_width;
824
  }
825
  echo "<td style='background: #eee; text-align: left; border: 1px solid #888; border-left-width: 0; min-width: 2000px'><span style='margin-left: 30px;'>", get_viewport_name (1), "</span><span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
826
+
827
  ?>
828
  </tr>
829
  </table>
851
  </table>
852
  </div>
853
 
 
 
 
 
 
 
854
  <div style="float: right; width: 90px; margin-left: 20px;">
855
  <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
856
  <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Use</button>
858
  <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90; height: 35px; float: right;" title="Highlight inserted code" >Cancel</button>
859
  </div>
860
 
861
+ <div style="float: left; max-width: 300px; margin-right: 20px">
862
+ <h1 style="margin: 0;">Preview</h1>
863
+ <h2>Block <?php echo $block; ?></h2>
864
+ <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
865
+ </div>
866
+
867
  <div style="float: left; min-height: 200px; margin: 0 auto;">
868
  <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
869
  <tr>
929
  <div style="clear: both;"></div>
930
 
931
  <div id="css-code" style="margin: 20px 0;">
932
+ <div style="margin: 20px 0 0 0;">
933
+ Alignment and Style:&nbsp;&nbsp;&nbsp;
934
+ <select style="border-radius: 5px; width:120px; height: 25px;" id="block-alignment">
935
+ <option data-img-src="<?php echo plugins_url ('images/default.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
936
+ <option data-img-src="<?php echo plugins_url ('images/align-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
937
+ <option data-img-src="<?php echo plugins_url ('images/center.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
938
+ <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
939
+ <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
940
+ <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
941
+ <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type); ?>
942
+ <option data-img-src="<?php echo plugins_url ('images/custom-css.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
943
+ <option data-img-src="<?php echo plugins_url ('images/no-wrapping.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
944
+ </select>
945
+ <span id="css-index" style="margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
946
+ </div>
947
+
948
+ <div id="alignment-style" style="margin: 4px 0;"></div>
949
+
950
  <table class="responsive-table">
951
  <tr>
952
  <td style="vertical-align: middle; padding:0;">
953
+ <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0 0; width: 36px; font-size: 14px; font-weight: bold; display: none;">CSS</span>
954
  </td>
955
  <td style="width: 100%; height: 32px; padding:0;">
956
  <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 0; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css; ?>" size="70" maxlength="160" title="Custom CSS code for wrapping div" />
957
  <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
958
  <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
959
+ <span id="css-<?php echo AI_ALIGNMENT_DEFAULT; ?>" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
960
+ <span id="css-<?php echo AI_ALIGNMENT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_LEFT); ?></span>
961
+ <span id="css-<?php echo AI_ALIGNMENT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_RIGHT); ?></span>
962
+ <span id="css-<?php echo AI_ALIGNMENT_CENTER; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_CENTER); ?></span>
963
+ <span id="css-<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
964
+ <span id="css-<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
965
+ <?php if (function_exists ('ai_preview_style_css')) ai_preview_style_css ($obj); ?>
966
  </span>
967
  </td>
968
  <td padding:0;>
970
  </td>
971
  </tr>
972
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  </div>
974
 
975
  <p id="p1">This is a preview of the saved code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
5
  Requires at least: 4.0
6
  Tested up to: 4.7.2
7
- Stable tag: 2.0.13
8
  License: GPLv3
9
 
10
  Insert any advert or code into Wordpress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.
@@ -187,7 +187,7 @@ Block Alignment and Style:
187
 
188
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
189
  * Custom CSS (You can enter custom CSS code for wrapping div)
190
- * None (simple div with thin margin)
191
  * Align Left
192
  * Align Right
193
  * Center
@@ -428,7 +428,7 @@ Use your own tracking id! Please note `{smart_tag}` as default search phrase. Th
428
 
429
  Configure block 1 and 2 with ads using:
430
 
431
- * Automatic Insertion: None
432
  * Block Alignment and Style: No Wrapping
433
  * Enable shortcode: checked
434
 
@@ -659,7 +659,7 @@ AD CODE RIGHT
659
  7. Visualization of HTML tags in post
660
  8. Visualization of positions for automatic insertion in post
661
  9. Visualization of inserted block in post
662
- 10. Alignment **Left**, **None** - None means default (usually left) aligned ad block with thin margin around
663
  11. Alignment **Right** - Right aligned ad block with thin margin around
664
  12. Alignment **Center** - Center aligned ad block with thin margin around
665
  13. Alignment **No Wrapping** - Default (usually left) aligned ad block **with no margin around**
@@ -671,6 +671,13 @@ AD CODE RIGHT
671
 
672
  == Changelog ==
673
 
 
 
 
 
 
 
 
674
  = 2.0.14 =
675
  - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
676
 
@@ -987,6 +994,10 @@ AD CODE RIGHT
987
 
988
  == Upgrade Notice ==
989
 
 
 
 
 
990
  = 2.0.14 =
991
  Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
992
 
4
  Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
5
  Requires at least: 4.0
6
  Tested up to: 4.7.2
7
+ Stable tag: 2.0.14
8
  License: GPLv3
9
 
10
  Insert any advert or code into Wordpress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.
187
 
188
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
189
  * Custom CSS (You can enter custom CSS code for wrapping div)
190
+ * Default (simple div with thin margin)
191
  * Align Left
192
  * Align Right
193
  * Center
428
 
429
  Configure block 1 and 2 with ads using:
430
 
431
+ * Automatic Insertion: Disabled
432
  * Block Alignment and Style: No Wrapping
433
  * Enable shortcode: checked
434
 
659
  7. Visualization of HTML tags in post
660
  8. Visualization of positions for automatic insertion in post
661
  9. Visualization of inserted block in post
662
+ 10. Alignment **Left**, **Default** - Default means default (usually left) aligned ad block with thin margin around
663
  11. Alignment **Right** - Right aligned ad block with thin margin around
664
  12. Alignment **Center** - Center aligned ad block with thin margin around
665
  13. Alignment **No Wrapping** - Default (usually left) aligned ad block **with no margin around**
671
 
672
  == Changelog ==
673
 
674
+ = 2.1.0 =
675
+ - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
676
+ - Added support to not include block classes when class name is empty
677
+ - Added sticky positions (Pro only)
678
+ - Bug fix for minimum user role not taken into account for exceptions list
679
+ - Bug fix for IP database update cron event (Pro only)
680
+
681
  = 2.0.14 =
682
  - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
683
 
994
 
995
  == Upgrade Notice ==
996
 
997
+ = 2.1.0 =
998
+ Support for ads in Ajax requests (e.g. in infinite scroll); Added sticky positions (Pro only);
999
+ Bug fix for minimum user role for exceptions list; Bug fix for IP database update cron event (Pro only)
1000
+
1001
  = 2.0.14 =
1002
  Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
1003
 
settings.php CHANGED
@@ -34,36 +34,41 @@ function generate_settings_form (){
34
 
35
  $default = $block_object [0];
36
 
37
- $args = array (
38
- 'posts_per_page' => 100,
39
- 'offset' => 0,
40
- 'category' => '',
41
- 'category_name' => '',
42
- 'orderby' => 'type',
43
- 'order' => 'ASC',
44
- 'include' => '',
45
- 'exclude' => '',
46
- 'meta_key' => '_adinserter_block_exceptions',
47
- 'meta_value' => '',
48
- 'post_type' => array ('post', 'page'),
49
- 'post_mime_type' => '',
50
- 'post_parent' => '',
51
- 'author' => '',
52
- 'author_name' => '',
53
- 'post_status' => '',
54
- 'suppress_filters' => true
55
- );
56
- $posts_pages = get_posts ($args);
57
-
58
- $exceptions = array ();
59
- foreach ($posts_pages as $page) {
60
- $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
61
- if ($post_meta == '') continue;
62
- $exceptions [$page->ID] = array ('type' => $page->post_type, 'title' => $page->post_title, 'blocks' => $post_meta);
63
-
64
- $selected_blocks = explode (",", $post_meta);
65
- foreach ($selected_blocks as $selected_block) {
66
- $block_exceptions [$selected_block][$page->ID] = array ('type' => $page->post_type, 'title' => $page->post_title);
 
 
 
 
 
67
  }
68
  }
69
  ?>
@@ -359,6 +364,7 @@ function generate_settings_form (){
359
  <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
360
  <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
361
  <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
 
362
  <option data-img-src="<?php echo plugins_url ('images/custom-css.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
363
  <option data-img-src="<?php echo plugins_url ('images/no-wrapping.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
364
  </select>
@@ -367,20 +373,21 @@ function generate_settings_form (){
367
  </div>
368
  <div style="clear: both;"></div>
369
 
370
- <div id="css-code-<?php echo $ad_number; ?>" style="height: 190px; margin: 4px 0 2px; display: none;">
371
  <div id="automatic-insertion-<?php echo $ad_number; ?>"></div>
372
  <div id="alignment-style-<?php echo $ad_number; ?>" style="margin-bottom: 4px;"></div>
373
  <div class="max-input">
374
- <span id="css-label-<?php echo $ad_number; ?>" style="display: table-cell; width: 34px; padding: 0; height: 26px; vertical-align: middle; margin: 4px 0 0 0;">CSS &nbsp;</span>
375
  <input id="custom-css-<?php echo $ad_number; ?>" style="width: 100%; border-radius: 4px; display: none; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_custom_css(); ?>" value="<?php echo $obj->get_custom_css(); ?>" maxlength="160" title="Custom CSS code for wrapping div" />
376
  <span style="display: table-cell; vertical-align: middle; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
377
  <span id="css-no-wrapping-<?php echo $ad_number; ?>" class='css-code' style="height: 18px; padding-left: 7px; display: none;"></span>
378
- <span id="css-none-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_DEFAULT); ?></span>
379
- <span id="css-left-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_LEFT); ?></span>
380
- <span id="css-right-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_RIGHT); ?></span>
381
- <span id="css-center-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_CENTER); ?></span>
382
- <span id="css-float-left-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
383
- <span id="css-float-right-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-right: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignmet_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
 
384
  </span>
385
  <span style="display:table-cell; width: 46px;" ><button id="edit-css-button-<?php echo $ad_number; ?>" type="button" style="display: table-cell; padding: 0; margin: 0 0 0 8px;">Edit</button></span>
386
  </div>
@@ -487,7 +494,7 @@ function generate_settings_form (){
487
 
488
  </tbody></table>
489
  <?php
490
- } else echo 'No exceptions';
491
  ?>
492
  </div>
493
 
@@ -860,10 +867,10 @@ function generate_settings_form (){
860
  Filter insertions
861
  </span>
862
  <span style="display: table-cell;">
863
- <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 means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="16" maxlength="20" />
864
  </span>
865
  <span style="display: table-cell;">
866
- &nbsp;&nbsp;&nbsp;Counter for filter
867
  <select style="border-radius: 5px; margin-bottom: 3px;" id="filter-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_FILTER_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_filter_type(); ?>" style="width:160px">
868
  <option value="<?php echo AI_OPTION_FILTER_AUTO; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_AUTO) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_AUTO; ?></option>
869
  <option value="<?php echo AI_OPTION_FILTER_PHP_FUNCTION_CALLS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_PHP_FUNCTION_CALLS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_PHP_FUNCTION_CALLS; ?></option>
@@ -875,6 +882,12 @@ function generate_settings_form (){
875
  <option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
876
  <option value="<?php echo AI_OPTION_FILTER_POSTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_POSTS; ?></option>
877
  </select>
 
 
 
 
 
 
878
  </span>
879
  <span style="display: table-cell;">
880
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
@@ -884,7 +897,7 @@ function generate_settings_form (){
884
  <span style="display: table-cell;">
885
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
886
  <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 '; ?> />
887
- <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable insertion on page for Error 404: Page not found">404 page</label>
888
  </span>
889
  </div>
890
  </div>
34
 
35
  $default = $block_object [0];
36
 
37
+
38
+ $exceptions = false;
39
+ $block_exceptions = array ();
40
+ if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
41
+ $args = array (
42
+ 'posts_per_page' => 100,
43
+ 'offset' => 0,
44
+ 'category' => '',
45
+ 'category_name' => '',
46
+ 'orderby' => 'type',
47
+ 'order' => 'ASC',
48
+ 'include' => '',
49
+ 'exclude' => '',
50
+ 'meta_key' => '_adinserter_block_exceptions',
51
+ 'meta_value' => '',
52
+ 'post_type' => array ('post', 'page'),
53
+ 'post_mime_type' => '',
54
+ 'post_parent' => '',
55
+ 'author' => '',
56
+ 'author_name' => '',
57
+ 'post_status' => '',
58
+ 'suppress_filters' => true
59
+ );
60
+ $posts_pages = get_posts ($args);
61
+
62
+ $exceptions = array ();
63
+ foreach ($posts_pages as $page) {
64
+ $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
65
+ if ($post_meta == '') continue;
66
+ $exceptions [$page->ID] = array ('type' => $page->post_type, 'title' => $page->post_title, 'blocks' => $post_meta);
67
+
68
+ $selected_blocks = explode (",", $post_meta);
69
+ foreach ($selected_blocks as $selected_block) {
70
+ $block_exceptions [$selected_block][$page->ID] = array ('type' => $page->post_type, 'title' => $page->post_title);
71
+ }
72
  }
73
  }
74
  ?>
364
  <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
365
  <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
366
  <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
367
+ <?php $css_code_height = 190; if (function_exists ('ai_style_options')) $css_code_height = ai_style_options ($obj); ?>
368
  <option data-img-src="<?php echo plugins_url ('images/custom-css.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
369
  <option data-img-src="<?php echo plugins_url ('images/no-wrapping.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
370
  </select>
373
  </div>
374
  <div style="clear: both;"></div>
375
 
376
+ <div id="css-code-<?php echo $ad_number; ?>" style="height: <?php echo $css_code_height; ?>px; margin: 4px 0 2px; display: none;">
377
  <div id="automatic-insertion-<?php echo $ad_number; ?>"></div>
378
  <div id="alignment-style-<?php echo $ad_number; ?>" style="margin-bottom: 4px;"></div>
379
  <div class="max-input">
380
+ <span id="css-label-<?php echo $ad_number; ?>" style="display: table-cell; width: 36px; padding: 0; height: 26px; vertical-align: middle; margin: 4px 0 0 0; font-size: 14px; font-weight: bold;">CSS</span>
381
  <input id="custom-css-<?php echo $ad_number; ?>" style="width: 100%; border-radius: 4px; display: none; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_custom_css(); ?>" value="<?php echo $obj->get_custom_css(); ?>" maxlength="160" title="Custom CSS code for wrapping div" />
382
  <span style="display: table-cell; vertical-align: middle; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
383
  <span id="css-no-wrapping-<?php echo $ad_number; ?>" class='css-code' style="height: 18px; padding-left: 7px; display: none;"></span>
384
+ <span id="css-none-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
385
+ <span id="css-left-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_LEFT); ?></span>
386
+ <span id="css-right-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_RIGHT); ?></span>
387
+ <span id="css-center-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_CENTER); ?></span>
388
+ <span id="css-float-left-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
389
+ <span id="css-float-right-<?php echo $ad_number; ?>" class='css-code-<?php echo $ad_number; ?>' style="height: 18px; padding-right: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
390
+ <?php if (function_exists ('ai_style_css')) ai_style_css ($ad_number, $obj); ?>
391
  </span>
392
  <span style="display:table-cell; width: 46px;" ><button id="edit-css-button-<?php echo $ad_number; ?>" type="button" style="display: table-cell; padding: 0; margin: 0 0 0 8px;">Edit</button></span>
393
  </div>
494
 
495
  </tbody></table>
496
  <?php
497
+ };
498
  ?>
499
  </div>
500
 
867
  Filter insertions
868
  </span>
869
  <span style="display: table-cell;">
870
+ <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 means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="12" maxlength="24" />
871
  </span>
872
  <span style="display: table-cell;">
873
+ &nbsp;&nbsp;&nbsp;using
874
  <select style="border-radius: 5px; margin-bottom: 3px;" id="filter-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_FILTER_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_filter_type(); ?>" style="width:160px">
875
  <option value="<?php echo AI_OPTION_FILTER_AUTO; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_AUTO) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_AUTO; ?></option>
876
  <option value="<?php echo AI_OPTION_FILTER_PHP_FUNCTION_CALLS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_PHP_FUNCTION_CALLS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_PHP_FUNCTION_CALLS; ?></option>
882
  <option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
883
  <option value="<?php echo AI_OPTION_FILTER_POSTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_POSTS; ?></option>
884
  </select>
885
+ counter
886
+ </span>
887
+ <span style="display: table-cell;">
888
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
889
+ <input style="border-radius: 5px; margin-left: 10px;" id="enable-ajax-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_ajax(); ?>" <?php if ($obj->get_enable_ajax () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
890
+ <label for="enable-ajax-<?php echo $ad_number; ?>" title="Enable or disable insertion in Ajax requests">Ajax</label>
891
  </span>
892
  <span style="display: table-cell;">
893
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
897
  <span style="display: table-cell;">
898
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
899
  <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 '; ?> />
900
+ <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable insertion on page for Error 404: Page not found">404</label>
901
  </span>
902
  </div>
903
  </div>