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

Version Description

  • Code block styles moved to classes
  • Code block list moved to the sidebar
  • Added preview buttons in code block list
  • Fix for ad blocking detection when using https (Pro only)
  • Few minor bug fixes, cosmetic changes and code improvements
Download this release

Release Info

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

Code changes from version 2.2.10 to 2.2.11

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.2.10
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -12,6 +12,13 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
 
 
 
 
15
  Ad Inserter 2.2.10 - 2017-12-10
16
  - Fix for rotation editor code import/export
17
  - Fix for errors when using old |rotate| separator
@@ -576,7 +583,7 @@ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
576
  $adb_2_name = AI_ADB_2_DEFAULT_NAME;
577
  define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
578
 
579
- $script_path = AD_INSERTER_PLUGIN_DIR.'includes/js';
580
  $script = $script_path.'/sponsors.js';
581
 
582
  if (is_writable ($script_path) && is_writable ($script)) {
@@ -1461,12 +1468,25 @@ function ai_clean_url ( $url, $original_url){
1461
  function add_head_inline_styles_and_scripts () {
1462
  global $ai_wp_data;
1463
 
1464
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
 
 
 
1465
 
1466
  echo "<style type='text/css'>\n";
1467
 
1468
  if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
1469
 
 
 
 
 
 
 
 
 
 
 
1470
  if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
1471
 
1472
  if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
@@ -1652,9 +1672,9 @@ function add_footer_inline_scripts () {
1652
 
1653
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1654
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1655
- echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: - 1;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1656
- echo "<script type='text/javascript' src='", plugins_url ('includes/js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1657
- echo "<script type='text/javascript' src='", plugins_url ('includes/js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1658
  }
1659
  }
1660
 
@@ -1726,12 +1746,15 @@ function ai_admin_notice_hook () {
1726
 
1727
  $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]));
1728
 
1729
- if ((get_option ('ai-notice-review') === false && $used_blocks >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20) ||
 
 
 
1730
 
1731
- (get_option ('ai-notice-review') == 'later' && ($used_blocks >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 50 ||
1732
- $used_blocks >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 70))) {
1733
 
1734
- if (get_option ('ai-notice-review') == 'later') {
1735
  $message = "Hey, you are now using <strong>{$used_blocks} Ad Inserter</strong> code blocks.";
1736
  $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
1737
  } else {
@@ -3455,22 +3478,50 @@ function ai_ajax_backend () {
3455
  generate_code_preview (
3456
  $block,
3457
  // wp_unslash (urldecode ($_POST ["name"])),
3458
- base64_decode ($_POST ["name"]),
3459
  // urldecode ($_POST ["alignment"]),
3460
- base64_decode ($_POST ["alignment"]),
3461
  // wp_unslash (urldecode ($_POST ["alignment_css"])),
3462
- base64_decode ($_POST ["alignment_css"]),
3463
  // wp_unslash (urldecode ($_POST ["custom_css"])),
3464
- base64_decode ($_POST ["custom_css"]),
3465
  // wp_unslash (urldecode (base64_decode ($_POST ["code"]))), // base64_decode after wp_unslash / urldecode ?
3466
- base64_decode ($_POST ["code"]),
3467
  // urldecode ($_POST ["php"]) == 1);
3468
- $_POST ["php"]) == 1;
 
 
3469
  }
3470
  elseif ($block == 'adb') {
3471
  // generate_code_preview_adb (wp_unslash (urldecode (base64_decode ($_POST ["code"]))), urldecode ($_POST ["php"]) == 1);
3472
  generate_code_preview_adb (base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
3473
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3474
  }
3475
 
3476
  elseif (isset ($_POST ["edit"])) {
@@ -3535,7 +3586,6 @@ function ai_ajax_backend () {
3535
  }
3536
 
3537
  elseif (isset ($_POST ["notice"])) {
3538
- if (get_option ('ai-notice-review') == 'later') $_POST ["click"] = 'no';
3539
  update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
3540
  }
3541
 
@@ -3543,6 +3593,31 @@ function ai_ajax_backend () {
3543
  code_block_list ();
3544
  }
3545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3546
  elseif (isset ($_GET ["settings"])) {
3547
  generate_settings_form ();
3548
  }
@@ -3839,7 +3914,7 @@ function generate_alignment_css () {
3839
  global $ai_db_options_extract, $block_object;
3840
 
3841
  $block_class_name = get_block_class_name ();
3842
- if ($block_class_name == '') $block_class_name = 'ai-'; else $block_class_name .= '-';
3843
 
3844
  $styles = array ();
3845
 
@@ -4169,6 +4244,11 @@ function ai_settings () {
4169
  delete_site_option (AI_OPTION_NAME, $options);
4170
  }
4171
 
 
 
 
 
 
4172
  if (function_exists ('ai_load_globals')) {
4173
  delete_option (WP_AD_INSERTER_PRO_LICENSE);
4174
  $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.11
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
12
 
13
  Change Log
14
 
15
+ Ad Inserter 2.2.11 - 2017-12-25
16
+ - Code block styles moved to classes
17
+ - Code block list moved to the sidebar
18
+ - Added preview buttons in code block list
19
+ - Fix for ad blocking detection when using https (Pro only)
20
+ - Few minor bug fixes, cosmetic changes and code improvements
21
+
22
  Ad Inserter 2.2.10 - 2017-12-10
23
  - Fix for rotation editor code import/export
24
  - Fix for errors when using old |rotate| separator
583
  $adb_2_name = AI_ADB_2_DEFAULT_NAME;
584
  define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
585
 
586
+ $script_path = AD_INSERTER_PLUGIN_DIR.'js';
587
  $script = $script_path.'/sponsors.js';
588
 
589
  if (is_writable ($script_path) && is_writable ($script)) {
1468
  function add_head_inline_styles_and_scripts () {
1469
  global $ai_wp_data;
1470
 
1471
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
1472
+ get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1473
+ get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) ||
1474
+ $ai_wp_data [AI_WP_DEBUGGING] != 0) {
1475
 
1476
  echo "<style type='text/css'>\n";
1477
 
1478
  if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
1479
 
1480
+ if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1481
+ echo ".ai-rotate {position: relative;}\n";
1482
+ echo ".ai-rotate-option {visibility: hidden;}\n";
1483
+ echo ".ai-rotate-options {visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;}\n";
1484
+ echo ".ai-ip-data, .ai-ip-data-block {visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;}\n";
1485
+ }
1486
+
1487
+ // if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES)
1488
+ echo get_alignment_css ();
1489
+
1490
  if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
1491
 
1492
  if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1672
 
1673
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1674
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1675
+ echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: -1px;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1676
+ echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1677
+ echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1678
  }
1679
  }
1680
 
1746
 
1747
  $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]));
1748
 
1749
+ $notice_option = get_option ('ai-notice-review');
1750
+ if ($notice_option === false && $ai_wp_data [AI_DAYS_SINCE_INSTAL] >= 40) $notice_option = 'later';
1751
+
1752
+ if (($notice_option === false && $used_blocks >= 3 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] < 40) ||
1753
 
1754
+ ($notice_option == 'later' && ($used_blocks >= 5 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 50 ||
1755
+ $used_blocks >= 3 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 60))) {
1756
 
1757
+ if ($notice_option == 'later') {
1758
  $message = "Hey, you are now using <strong>{$used_blocks} Ad Inserter</strong> code blocks.";
1759
  $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
1760
  } else {
3478
  generate_code_preview (
3479
  $block,
3480
  // wp_unslash (urldecode ($_POST ["name"])),
3481
+ isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : null,
3482
  // urldecode ($_POST ["alignment"]),
3483
+ isset ($_POST ["alignment"]) ? base64_decode ($_POST ["alignment"]) : null,
3484
  // wp_unslash (urldecode ($_POST ["alignment_css"])),
3485
+ isset ($_POST ["alignment_css"]) ? base64_decode ($_POST ["alignment_css"]) : null,
3486
  // wp_unslash (urldecode ($_POST ["custom_css"])),
3487
+ isset ($_POST ["custom_css"]) ? base64_decode ($_POST ["custom_css"]) : null,
3488
  // wp_unslash (urldecode (base64_decode ($_POST ["code"]))), // base64_decode after wp_unslash / urldecode ?
3489
+ isset ($_POST ["code"]) ? base64_decode ($_POST ["code"]) : null,
3490
  // urldecode ($_POST ["php"]) == 1);
3491
+ isset ($_POST ["php"]) ? $_POST ["php"] == 1 : null,
3492
+ isset ($_POST ["read_only"]) ? true : false
3493
+ );
3494
  }
3495
  elseif ($block == 'adb') {
3496
  // generate_code_preview_adb (wp_unslash (urldecode (base64_decode ($_POST ["code"]))), urldecode ($_POST ["php"]) == 1);
3497
  generate_code_preview_adb (base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
3498
  }
3499
+ elseif ($block == 'adsense') {
3500
+
3501
+ if (defined ('AI_ADSENSE_API')) {
3502
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
3503
+
3504
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
3505
+
3506
+ $adsense = new adsense_api();
3507
+
3508
+ $adsense_code = $adsense->getAdCode (base64_decode ($_POST ["slot_id"]));
3509
+ $adsense_error = $adsense->getError ();
3510
+
3511
+ generate_code_preview (
3512
+ 0,
3513
+ isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : 'ADSENSE CODE',
3514
+ '',
3515
+ '',
3516
+ '',
3517
+ $adsense_error == '' ? $adsense_code : '<div style="color: red;">'.$adsense_error.'</div>',
3518
+ false,
3519
+ true
3520
+ );
3521
+
3522
+ }
3523
+ }
3524
+ }
3525
  }
3526
 
3527
  elseif (isset ($_POST ["edit"])) {
3586
  }
3587
 
3588
  elseif (isset ($_POST ["notice"])) {
 
3589
  update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
3590
  }
3591
 
3593
  code_block_list ();
3594
  }
3595
 
3596
+ elseif (isset ($_GET ["adsense-list"])) {
3597
+ if (defined ('AI_ADSENSE_API')) {
3598
+ adsense_list ();
3599
+ }
3600
+ }
3601
+
3602
+ elseif (isset ($_GET ["adsense-code"])) {
3603
+ if (defined ('AI_ADSENSE_API')) {
3604
+ adsense_code ($_GET ["adsense-code"]);
3605
+ }
3606
+ }
3607
+
3608
+ elseif (isset ($_GET ["adsense-authorization-code"])) {
3609
+ if (defined ('AI_ADSENSE_API')) {
3610
+ if ($_GET ['adsense-authorization-code'] == '') {
3611
+ delete_option (AI_ADSENSE_AUTH_CODE);
3612
+
3613
+ delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
3614
+ delete_transient (AI_TRANSIENT_ADSENSE_ADS);
3615
+
3616
+
3617
+ } else update_option (AI_ADSENSE_AUTH_CODE, base64_decode ($_GET ['adsense-authorization-code']));
3618
+ }
3619
+ }
3620
+
3621
  elseif (isset ($_GET ["settings"])) {
3622
  generate_settings_form ();
3623
  }
3914
  global $ai_db_options_extract, $block_object;
3915
 
3916
  $block_class_name = get_block_class_name ();
3917
+ if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME . '-'; else $block_class_name .= '-';
3918
 
3919
  $styles = array ();
3920
 
4244
  delete_site_option (AI_OPTION_NAME, $options);
4245
  }
4246
 
4247
+ delete_option (AI_ADSENSE_AUTH_CODE);
4248
+
4249
+ delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4250
+ delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4251
+
4252
  if (function_exists ('ai_load_globals')) {
4253
  delete_option (WP_AD_INSERTER_PRO_LICENSE);
4254
  $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
class.php CHANGED
@@ -1176,7 +1176,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1176
  break;
1177
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1178
  $this->code_version = '""';
 
 
 
 
1179
  $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
 
1180
  foreach ($ads as $index => $ad) {
1181
 
1182
  // If AMP separator use only code for normal pages
@@ -1189,9 +1194,15 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1189
 
1190
  switch ($index) {
1191
  case 0:
 
 
 
1192
  $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'".$version_name_data.">\n".trim ($ad, "\n")."\n</div>\n";
1193
  break;
1194
  default:
 
 
 
1195
  $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;'".$version_name_data.">".trim ($ad, "\n")."\n</div>\n";
1196
  break;
1197
  }
@@ -1268,7 +1279,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1268
  $this->client_side_ip_address_detection = true;
1269
  $this->needs_class = true;
1270
 
1271
- $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";
 
 
1272
  }
1273
  break;
1274
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
@@ -1331,6 +1344,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1331
 
1332
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1333
 
 
 
1334
  $hidden_viewports = '';
1335
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1336
 
@@ -1350,8 +1365,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1350
  $version_name = $this->version_name == '' ? '' : ' - ' . $this->version_name;
1351
  if ($this->get_detection_viewport ($viewport))
1352
  $visible_viewports .= '<section class="ai-viewport-' . $viewport .'"><section class="ai-debug-bar '.$this->color_class.'"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () . '<span class="ai-option-name">' . $version_name . '</span></a><a>&nbsp;'.$viewport_name.'&nbsp;</a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section></section>'; else
1353
- if (!$ai_wp_data [AI_WP_AMP_PAGE])
1354
- $hidden_viewports .= '<section class="ai-viewport-' . $viewport .' ai-debug-block ai-debug-viewport-invisible" style="' . $this->get_alignment_style() . '"><section class="ai-debug-bar ai-debug-viewport-invisible"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () . '<span class="ai-option-name">' . $version_name . '</span></a><a>&nbsp;'.$viewport_name.'&nbsp;</a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
 
 
 
1355
 
1356
  }
1357
  }
@@ -1365,18 +1383,33 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1365
  $block_class_name = get_block_class_name ();
1366
  if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1367
  $viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
1368
- $alignment_class = $this->get_alignment_class ();
1369
  if ($block_class_name != '' || $viewport_classes != '' || $alignment_class != '') {
1370
  if ($block_class_name != '') {
1371
- $class = " class='" . $block_class_name . ' ' . $alignment_class . ' ' . $block_class_name . "-" . $this->number . $viewport_classes ."'";
 
1372
  } else {
1373
- $class = " class='" . $alignment_class . $viewport_classes ."'";
 
1374
  }
1375
- } else $class = '';
1376
- $class = str_replace (' ', ' ', $class);
 
1377
 
1378
  if ($hidden_widgets) return $hidden_viewports; else {
1379
- if ($this->client_side_ip_address_detection && !$ai_wp_data [AI_WP_AMP_PAGE]) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
1380
 
1381
  $tracking_code_pre = '';
1382
  $tracking_code_data = '';
@@ -1689,28 +1722,30 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1689
  public function get_alignment_class (){
1690
  global $ai_wp_data;
1691
 
1692
- if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) {
1693
- if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1694
- $block_class_name = get_block_class_name ();
1695
- if ($block_class_name == '') $block_class_name = 'ai-'; else $block_class_name .= '-';
1696
-
1697
- switch ($this->get_alignment_type ()) {
1698
- case AI_ALIGNMENT_DEFAULT:
1699
- case AI_ALIGNMENT_LEFT:
1700
- case AI_ALIGNMENT_RIGHT:
1701
- case AI_ALIGNMENT_CENTER:
1702
- case AI_ALIGNMENT_FLOAT_LEFT:
1703
- case AI_ALIGNMENT_FLOAT_RIGHT:
1704
- case AI_ALIGNMENT_STICKY_LEFT:
1705
- case AI_ALIGNMENT_STICKY_RIGHT:
1706
- case AI_ALIGNMENT_STICKY_TOP:
1707
- case AI_ALIGNMENT_STICKY_BOTTOM:
1708
- return $block_class_name . str_replace (' ', '-', strtolower ($this->get_alignment_type_text ()));
1709
- break;
1710
- case AI_ALIGNMENT_CUSTOM_CSS:
1711
- return $block_class_name . str_replace (' ', '-', strtolower (md5 ($this->get_custom_css ())));
1712
- break;
1713
- }
 
 
1714
  }
1715
  }
1716
 
1176
  break;
1177
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1178
  $this->code_version = '""';
1179
+
1180
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1181
+ $processed_code = "\n<div class='ai-rotate'>\n";
1182
+ } else
1183
  $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
1184
+
1185
  foreach ($ads as $index => $ad) {
1186
 
1187
  // If AMP separator use only code for normal pages
1194
 
1195
  switch ($index) {
1196
  case 0:
1197
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1198
+ $processed_code .= "<div class='ai-rotate-option'".$version_name_data.">\n".trim ($ad, "\n")."\n</div>\n";
1199
+ } else
1200
  $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'".$version_name_data.">\n".trim ($ad, "\n")."\n</div>\n";
1201
  break;
1202
  default:
1203
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1204
+ $processed_code .= "<div class='ai-rotate-option ai-rotate-options'".$version_name_data.">".trim ($ad, "\n")."\n</div>\n";
1205
+ } else
1206
  $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;'".$version_name_data.">".trim ($ad, "\n")."\n</div>\n";
1207
  break;
1208
  }
1279
  $this->client_side_ip_address_detection = true;
1280
  $this->needs_class = true;
1281
 
1282
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1283
+ $processed_code = "\n<div class='ai-ip-data' $ip_address_attributes $country_attributes class-name='$block_class_name'>$processed_code</div>\n";
1284
+ } else $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";
1285
  }
1286
  break;
1287
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1344
 
1345
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1346
 
1347
+ $alignment_class = $this->get_alignment_class ();
1348
+
1349
  $hidden_viewports = '';
1350
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1351
 
1365
  $version_name = $this->version_name == '' ? '' : ' - ' . $this->version_name;
1366
  if ($this->get_detection_viewport ($viewport))
1367
  $visible_viewports .= '<section class="ai-viewport-' . $viewport .'"><section class="ai-debug-bar '.$this->color_class.'"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () . '<span class="ai-option-name">' . $version_name . '</span></a><a>&nbsp;'.$viewport_name.'&nbsp;</a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section></section>'; else
1368
+ if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
1369
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1370
+ $hidden_viewports .= '<section class="ai-viewport-' . $viewport .' ai-debug-block ai-debug-viewport-invisible '.$alignment_class.'"><section class="ai-debug-bar ai-debug-viewport-invisible"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () . '<span class="ai-option-name">' . $version_name . '</span></a><a>&nbsp;'.$viewport_name.'&nbsp;</a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1371
+ } else $hidden_viewports .= '<section class="ai-viewport-' . $viewport .' ai-debug-block ai-debug-viewport-invisible" style="' . $this->get_alignment_style() . '"><section class="ai-debug-bar ai-debug-viewport-invisible"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () . '<span class="ai-option-name">' . $version_name . '</span></a><a>&nbsp;'.$viewport_name.'&nbsp;</a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1372
+ }
1373
 
1374
  }
1375
  }
1383
  $block_class_name = get_block_class_name ();
1384
  if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1385
  $viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
 
1386
  if ($block_class_name != '' || $viewport_classes != '' || $alignment_class != '') {
1387
  if ($block_class_name != '') {
1388
+ // $class = " class='" . $block_class_name . ' ' . $alignment_class . ' ' . $block_class_name . "-" . $this->number . $viewport_classes ."'";
1389
+ $classes = array ($block_class_name, $alignment_class, $block_class_name . "-" . $this->number, trim ($viewport_classes));
1390
  } else {
1391
+ // $class = " class='" . $alignment_class . $viewport_classes ."'";
1392
+ $classes = array ($alignment_class, $viewport_classes);
1393
  }
1394
+ // } else $class = '';
1395
+ } else $classes = array ();
1396
+ // $class = str_replace (' ', ' ', $class);
1397
 
1398
  if ($hidden_widgets) return $hidden_viewports; else {
1399
+ if ($this->client_side_ip_address_detection && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1400
+ $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; ';
1401
+ if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES) {
1402
+ $classes [] = 'ai-ip-data-block';
1403
+ }
1404
+ } else {
1405
+ $additional_block_style = '';
1406
+ }
1407
+
1408
+ foreach ($classes as $index => $class_name) {
1409
+ if (trim ($class_name) == '') unset ($classes [$index]);
1410
+ }
1411
+ // $class = " class='" . str_replace (' ', ' ', implode (' ', $classes)) . "'";
1412
+ $class = " class='" . implode (' ', $classes) . "'";
1413
 
1414
  $tracking_code_pre = '';
1415
  $tracking_code_data = '';
1722
  public function get_alignment_class (){
1723
  global $ai_wp_data;
1724
 
1725
+ // if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES && $ai_wp_data [AI_WP_AMP_PAGE]) {
1726
+
1727
+ if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES && $ai_wp_data [AI_WP_AMP_PAGE] ||
1728
+ defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1729
+
1730
+ $block_class_name = get_block_class_name ();
1731
+ if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME . '-'; else $block_class_name .= '-';
1732
+
1733
+ switch ($this->get_alignment_type ()) {
1734
+ case AI_ALIGNMENT_DEFAULT:
1735
+ case AI_ALIGNMENT_LEFT:
1736
+ case AI_ALIGNMENT_RIGHT:
1737
+ case AI_ALIGNMENT_CENTER:
1738
+ case AI_ALIGNMENT_FLOAT_LEFT:
1739
+ case AI_ALIGNMENT_FLOAT_RIGHT:
1740
+ case AI_ALIGNMENT_STICKY_LEFT:
1741
+ case AI_ALIGNMENT_STICKY_RIGHT:
1742
+ case AI_ALIGNMENT_STICKY_TOP:
1743
+ case AI_ALIGNMENT_STICKY_BOTTOM:
1744
+ return $block_class_name . str_replace (' ', '-', strtolower ($this->get_alignment_type_text ()));
1745
+ break;
1746
+ case AI_ALIGNMENT_CUSTOM_CSS:
1747
+ return $block_class_name . str_replace (' ', '-', strtolower (md5 ($this->get_custom_css ())));
1748
+ break;
1749
  }
1750
  }
1751
 
constants.php CHANGED
@@ -7,6 +7,7 @@ define ('AI_OPTION_NAME', 'ad_inserter');
7
  define ('AI_INSTALL_NAME', 'ai-install');
8
  define ('AI_OPTION_GLOBAL', 'global');
9
  define ('AI_OPTION_EXTRACT', 'extract');
 
10
 
11
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
12
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
@@ -19,7 +20,7 @@ if (!defined( 'AD_INSERTER_NAME'))
19
  define ('AD_INSERTER_NAME', 'Ad Inserter');
20
 
21
  if (!defined( 'AD_INSERTER_VERSION'))
22
- define ('AD_INSERTER_VERSION', '2.2.10');
23
 
24
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
25
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -148,10 +149,10 @@ define ('AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE', 'adb-undismissible-message');
148
  define('AD_EMPTY_VALUE','');
149
 
150
  //define constant variable form
151
- define('AI_FORM_SAVE','ai_save');
152
  define('AI_FORM_CLEAR','ai_clear');
153
- define('AI_FORM_CLEAR_EXCEPTIONS','ai-clear-exceptions');
154
- define('AI_FORM_CLEAR_STATISTICS','ai-clear-statistics');
155
 
156
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
157
  define('AD_ROTATE_SEPARATOR', '|rotate|');
@@ -388,8 +389,6 @@ define('AI_TEXT_MULTIBYTE', 'Multibyte');
388
  define('AI_TRACKING_DISABLED', 0);
389
  define('AI_TRACKING_ENABLED', 1);
390
 
391
- define('AI_TRACKING_INTERNAL', 0);
392
-
393
  // Ad Blocking
394
  define ('AI_ADB_ACTION_NONE', 0);
395
  define ('AI_ADB_ACTION_MESSAGE', 1);
@@ -441,6 +440,11 @@ define ('AI_COOKIE_TIME', 3600);
441
  define ('AI_TRANSIENT_RATING', 'ai-rating');
442
  define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
443
 
 
 
 
 
 
444
  define ('AI_TRANSIENT_ADB_CLASS_1', 'ai-adb-class-1');
445
  define ('AI_TRANSIENT_ADB_CLASS_2', 'ai-adb-class-2');
446
  define ('AI_TRANSIENT_ADB_CLASS_3', 'ai-adb-class-3');
@@ -471,7 +475,8 @@ define ('DEFAULT_MULTISITE_PHP_PROCESSING', AI_ENABLED);
471
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
472
  define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
473
  define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
474
- define ('DEFAULT_TRACKING_MODE', AI_TRACKING_INTERNAL);
 
475
  define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
476
  define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
477
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
@@ -481,9 +486,11 @@ define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
481
  define ('DEFAULT_OUTPUT_BUFFERING', AI_OUTPUT_BUFFERING_DISABLED);
482
 
483
  define ('AI_ADBLOCKING_DETECTION', true);
 
484
  define ('AI_AMP_HEADER_STYLES', true);
485
  define ('AI_CODE_GENERATOR', true);
486
  define ('AI_BUFFERING', true);
 
487
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
488
  define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
489
  define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
7
  define ('AI_INSTALL_NAME', 'ai-install');
8
  define ('AI_OPTION_GLOBAL', 'global');
9
  define ('AI_OPTION_EXTRACT', 'extract');
10
+ define ('AI_ADSENSE_AUTH_CODE', 'ai-adsense-auth-code');
11
 
12
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
13
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
20
  define ('AD_INSERTER_NAME', 'Ad Inserter');
21
 
22
  if (!defined( 'AD_INSERTER_VERSION'))
23
+ define ('AD_INSERTER_VERSION', '2.2.11');
24
 
25
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
26
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
149
  define('AD_EMPTY_VALUE','');
150
 
151
  //define constant variable form
152
+ define('AI_FORM_SAVE', 'ai_save');
153
  define('AI_FORM_CLEAR','ai_clear');
154
+ define('AI_FORM_CLEAR_EXCEPTIONS', 'ai-clear-exceptions');
155
+ define('AI_FORM_CLEAR_STATISTICS', 'ai-clear-statistics');
156
 
157
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
158
  define('AD_ROTATE_SEPARATOR', '|rotate|');
389
  define('AI_TRACKING_DISABLED', 0);
390
  define('AI_TRACKING_ENABLED', 1);
391
 
 
 
392
  // Ad Blocking
393
  define ('AI_ADB_ACTION_NONE', 0);
394
  define ('AI_ADB_ACTION_MESSAGE', 1);
440
  define ('AI_TRANSIENT_RATING', 'ai-rating');
441
  define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
442
 
443
+ define ('AI_TRANSIENT_ADSENSE_TOKEN', 'ai-adsense');
444
+
445
+ define ('AI_TRANSIENT_ADSENSE_ADS', 'ai-adsense-ads');
446
+ define ('AI_TRANSIENT_ADSENSE_ADS_EXPIRATION', 24 * 3600);
447
+
448
  define ('AI_TRANSIENT_ADB_CLASS_1', 'ai-adb-class-1');
449
  define ('AI_TRANSIENT_ADB_CLASS_2', 'ai-adb-class-2');
450
  define ('AI_TRANSIENT_ADB_CLASS_3', 'ai-adb-class-3');
475
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
476
  define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
477
  define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
478
+ define ('DEFAULT_INTERNAL_TRACKING', AI_ENABLED);
479
+ define ('DEFAULT_EXTERNAL_TRACKING', AI_DISABLED);
480
  define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
481
  define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
482
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
486
  define ('DEFAULT_OUTPUT_BUFFERING', AI_OUTPUT_BUFFERING_DISABLED);
487
 
488
  define ('AI_ADBLOCKING_DETECTION', true);
489
+ define ('AI_NORMAL_HEADER_STYLES', true);
490
  define ('AI_AMP_HEADER_STYLES', true);
491
  define ('AI_CODE_GENERATOR', true);
492
  define ('AI_BUFFERING', true);
493
+ //define ('AI_ADSENSE_API', true);
494
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
495
  define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
496
  define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.2.10"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -47,6 +47,10 @@ button.ai-top-button {
47
  padding: .4em 0.6em;
48
  }
49
 
 
 
 
 
50
  .ace_editor {
51
  border: 1px solid #ddd;
52
  border-radius: 4px;
@@ -384,10 +388,20 @@ div.automatic-insertion img {
384
  padding: 0 0 0 10px;
385
  }
386
 
 
 
 
 
 
 
387
  .ai-toolbar-button.text {
388
  width: auto;
389
  }
390
 
 
 
 
 
391
  .ai-toolbar-button.ai-button-left {
392
  padding: 0 10px 0 0;
393
  }
@@ -397,9 +411,9 @@ div.automatic-insertion img {
397
  background-position: 50% 50%;
398
  background-color: #e3e3e3;
399
  border: solid 1px lightgrey;
400
- border-radius: 5px;
401
- -webkit-border-radius: 5px;
402
- -moz-border-radius: 5px;
403
  cursor: pointer;
404
  padding: 2px 2px;
405
  display: inline-block;
@@ -414,6 +428,18 @@ div.automatic-insertion img {
414
  box-sizing: border-box;
415
  }
416
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  .text .checkbox-button {
418
  font-size: 11px;
419
  padding: 0px 5px 0px 4px;
@@ -435,6 +461,49 @@ div.automatic-insertion img {
435
  vertical-align: middle;
436
  }
437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  img.automatic-insertion.disabled {
439
  background: url('images/insertions-alignmets.png') 0 0;
440
  }
@@ -750,7 +819,7 @@ img.automatic-insertion.preview {
750
  }
751
 
752
  .checkbox-icon.icon-paste-name {
753
- background: url('images/icons.png') -140px -40px;
754
  }
755
 
756
  .checkbox-icon.icon-paste-code {
@@ -758,17 +827,14 @@ img.automatic-insertion.preview {
758
  }
759
 
760
  .checkbox-icon.icon-paste-settings {
761
- background: url('images/icons.png') -180px -40px;
762
  }
763
 
764
  .checkbox-icon.icon-clear {
765
  background: url('images/icons.png') -160px -80px;
766
  }
767
 
768
-
769
  .checkbox-icon.icon-enabled-all {
770
- width: 16px;
771
- height: 16px;
772
  background: url('images/icons.png') -142px -22px;
773
  }
774
 
@@ -778,8 +844,6 @@ img.automatic-insertion.preview {
778
 
779
 
780
  .checkbox-icon.icon-rearrange {
781
- width: 16px;
782
- height: 16px;
783
  background: url('images/icons.png') -140px -80px;
784
  }
785
 
@@ -788,20 +852,22 @@ img.automatic-insertion.preview {
788
  }
789
 
790
  .checkbox-icon.icon-loading {
791
- width: 12px;
792
- height: 12px;
793
- margin: 3px 0;
794
- background: url('images/icons.png') -160px -20px;
795
  }
796
 
797
  .checkbox-icon.icon-loading.on {
798
- background: url('images/icons.png') -160px 0;
 
 
 
 
 
 
 
 
799
  }
800
 
801
  .checkbox-icon.icon-auto-refresh {
802
- width: 12px;
803
- height: 12px;
804
- margin: 3px 0;
805
  background: url('images/icons.png') -180px -20px;
806
  }
807
 
@@ -809,15 +875,30 @@ img.automatic-insertion.preview {
809
  background: url('images/icons.png') -180px 0;
810
  }
811
 
812
- .checkbox-icon.icon-none {
813
- width: 10px;
814
- height: 12px;
815
- margin-top: 6px;
816
  }
817
 
818
- .checkbox-icon.icon-none-small {
819
- width: 8px;
820
- height: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
821
  }
822
 
823
  .banner-preview {
@@ -873,6 +954,41 @@ img.automatic-insertion.preview {
873
  #wpwrap {
874
  width: 762px;
875
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
876
  }
877
 
878
  @media(max-width: 768px) {
@@ -900,15 +1016,15 @@ img.automatic-insertion.preview {
900
  font-size: 12px!important;
901
  line-height: 18px;
902
  }
903
- .checkbox-icon.icon-enabled-all {
904
- width: 20px;
905
- height: 20px;
906
- background: url('images/icons.png') -140px -20px;
907
- }
908
-
909
- .checkbox-icon.icon-enabled-all.on {
910
- background: url('images/icons.png') -140px -0px;
911
- }
912
 
913
  .banner-preview img {
914
  max-width: 160px;
1
  #ai-data {
2
+ font-family: "2.2.11"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
47
  padding: .4em 0.6em;
48
  }
49
 
50
+ .adsense-list .ui-button-text, .select-image .ui-button-text {
51
+ padding: 0.4em 0.5em;
52
+ }
53
+
54
  .ace_editor {
55
  border: 1px solid #ddd;
56
  border-radius: 4px;
388
  padding: 0 0 0 10px;
389
  }
390
 
391
+ .ai-list-button {
392
+ display: table-cell;
393
+ margin-right: 2px;
394
+ width: 20px;
395
+ }
396
+
397
  .ai-toolbar-button.text {
398
  width: auto;
399
  }
400
 
401
+ .ai-toolbar-button.small {
402
+ width: 20px;
403
+ }
404
+
405
  .ai-toolbar-button.ai-button-left {
406
  padding: 0 10px 0 0;
407
  }
411
  background-position: 50% 50%;
412
  background-color: #e3e3e3;
413
  border: solid 1px lightgrey;
414
+ border-radius: 4px;
415
+ -webkit-border-radius: 4px;
416
+ -moz-border-radius: 4px;
417
  cursor: pointer;
418
  padding: 2px 2px;
419
  display: inline-block;
428
  box-sizing: border-box;
429
  }
430
 
431
+ .custom-range-controls .checkbox-button {
432
+ border-radius: 3px;
433
+ -webkit-border-radius: 3px;
434
+ -moz-border-radius: 3px;
435
+ }
436
+
437
+ .ai-list-button .checkbox-button {
438
+ border-radius: 3px;
439
+ -webkit-border-radius: 3px;
440
+ -moz-border-radius: 3px;
441
+ }
442
+
443
  .text .checkbox-button {
444
  font-size: 11px;
445
  padding: 0px 5px 0px 4px;
461
  vertical-align: middle;
462
  }
463
 
464
+ .checkbox-icon.size-16 {
465
+ width: 16px;
466
+ height: 16px;
467
+ }
468
+
469
+ .checkbox-icon.size-img16 {
470
+ width: 16px;
471
+ height:16px;
472
+ background-size: 16px 16px;
473
+ }
474
+
475
+ .checkbox-icon.size-16w {
476
+ width: 17px;
477
+ height: 16px;
478
+ }
479
+
480
+ .checkbox-icon.size-12 {
481
+ width: 12px;
482
+ height: 12px;
483
+ margin: 3px 0;
484
+ }
485
+
486
+ .checkbox-icon.size-8 {
487
+ width: 8px;
488
+ height: 8px;
489
+ }
490
+
491
+ .checkbox-icon.icon-none {
492
+ width: 10px;
493
+ height: 12px;
494
+ margin-top: 6px;
495
+ }
496
+
497
+ .list-button.lb-size-16 {
498
+ width: 16px;
499
+ height: 16px;
500
+ }
501
+
502
+ .list-button {
503
+ margin: 0;
504
+ background-image: url(images/ui-icons_888888_256x240.png)
505
+ }
506
+
507
  img.automatic-insertion.disabled {
508
  background: url('images/insertions-alignmets.png') 0 0;
509
  }
819
  }
820
 
821
  .checkbox-icon.icon-paste-name {
822
+ background: url('images/icons.png') -180px -40px;
823
  }
824
 
825
  .checkbox-icon.icon-paste-code {
827
  }
828
 
829
  .checkbox-icon.icon-paste-settings {
830
+ background: url('images/icons.png') -140px -40px;
831
  }
832
 
833
  .checkbox-icon.icon-clear {
834
  background: url('images/icons.png') -160px -80px;
835
  }
836
 
 
837
  .checkbox-icon.icon-enabled-all {
 
 
838
  background: url('images/icons.png') -142px -22px;
839
  }
840
 
844
 
845
 
846
  .checkbox-icon.icon-rearrange {
 
 
847
  background: url('images/icons.png') -140px -80px;
848
  }
849
 
852
  }
853
 
854
  .checkbox-icon.icon-loading {
855
+ background: url('images/icons.png') -163px -23px;
 
 
 
856
  }
857
 
858
  .checkbox-icon.icon-loading.on {
859
+ background: url('images/icons.png') -163px -3px;
860
+ }
861
+
862
+ .checkbox-icon.icon-reload {
863
+ background: url('images/icons.png') -161px -22px;
864
+ }
865
+
866
+ .checkbox-icon.icon-reload.on {
867
+ background: url('images/icons.png') -161px -2px;
868
  }
869
 
870
  .checkbox-icon.icon-auto-refresh {
 
 
 
871
  background: url('images/icons.png') -180px -20px;
872
  }
873
 
875
  background: url('images/icons.png') -180px 0;
876
  }
877
 
878
+ .checkbox-icon.size-8.icon-stop {
879
+ background: #ddd;
 
 
880
  }
881
 
882
+ .checkbox-icon.size-8.icon-preview {
883
+ width: 0;
884
+ height: 0;
885
+ margin-left: 1px;
886
+ border-top: 4px solid transparent;
887
+ border-bottom: 4px solid transparent;
888
+ border-left: 7px solid #bbb;
889
+ }
890
+
891
+ .checkbox-icon.size-8.icon-get {
892
+ width: 0;
893
+ height: 0;
894
+ border-left: 4px solid transparent;
895
+ border-right: 4px solid transparent;
896
+ border-top: 8px solid #888;
897
+ }
898
+
899
+ .checkbox-icon.icon-adsense {
900
+ background: url('../images/ga-logo.png') 0px 0px;
901
+ background-size: 16px 16px;
902
  }
903
 
904
  .banner-preview {
954
  #wpwrap {
955
  width: 762px;
956
  }
957
+
958
+ .ai-toolbar-button.small {
959
+ width: 20px;
960
+ height: 20px;
961
+ margin-right: 10px;
962
+ }
963
+
964
+ .ai-toolbar-button.small .checkbox-icon {
965
+ margin: 4px 0px 0 4px;
966
+ }
967
+
968
+ .checkbox-icon.size-16 {
969
+ width: 20px;
970
+ height: 20px;
971
+ }
972
+
973
+ .checkbox-icon.size-img16 {
974
+ width: 24px;
975
+ height:24px;
976
+ background-size: 24px 24px;
977
+ }
978
+
979
+ .ai-toolbar-button.small .checkbox-icon.size-img16 {
980
+ margin: 0;
981
+ }
982
+
983
+ .checkbox-icon.size-16w {
984
+ width: 20px;
985
+ height: 20px;
986
+ }
987
+
988
+ .list-button.lb-size-16 {
989
+ margin: 6px 0 0 4px;
990
+ padding: 0px 4px 2px 0px;
991
+ }
992
  }
993
 
994
  @media(max-width: 768px) {
1016
  font-size: 12px!important;
1017
  line-height: 18px;
1018
  }
1019
+ /* .checkbox-icon.icon-enabled-all {*/
1020
+ /* width: 20px;*/
1021
+ /* height: 20px;*/
1022
+ /* background: url('images/icons.png') -140px -20px;*/
1023
+ /* }*/
1024
+
1025
+ /* .checkbox-icon.icon-enabled-all.on {*/
1026
+ /* background: url('images/icons.png') -140px -0px;*/
1027
+ /* }*/
1028
 
1029
  .banner-preview img {
1030
  max-width: 160px;
css/images/icons.png CHANGED
Binary file
images/ga-logo.png ADDED
Binary file
includes/js/ai-rotate.js CHANGED
@@ -10,8 +10,8 @@ jQuery (function ($) {
10
 
11
  rotate_options.hide ();
12
  var option = $(rotate_options [random_index]);
13
- option.css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
14
- $(this).css ({"position": ""});
15
 
16
  var wrapping_div = $(this).closest (wrapping_div_selector);
17
 
10
 
11
  rotate_options.hide ();
12
  var option = $(rotate_options [random_index]);
13
+ option.css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""}).removeClass ('ai-rotate-option').removeClass ('ai-rotate-options');
14
+ $(this).css ({"position": ""}).removeClass ('ai-rotate');
15
 
16
  var wrapping_div = $(this).closest (wrapping_div_selector);
17
 
includes/js/ai-rotate.min.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(function($){var wrapping_div_selector=".AI_BLOCK_CLASS_NAME";$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();if(n%2)random_index=rotate_options.length-random_index-1;rotate_options.hide();var option=$(rotate_options[random_index]);option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""});
2
- var wrapping_div=$(this).closest(wrapping_div_selector);if(typeof wrapping_div!="undefined")wrapping_div.find("span.ai-option-name").html(" - "+atob(option.data("name")));var tracking_updated=false;var adb_show_wrapping_div=$(this).closest(".ai-adb-show");if(typeof adb_show_wrapping_div!="undefined")if(typeof adb_show_wrapping_div.data("ai-tracking")!="undefined"){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+
3
- 1;adb_show_wrapping_div.data("ai-tracking",btoa(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated)if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}})});
1
+ jQuery(function($){var wrapping_div_selector=".AI_BLOCK_CLASS_NAME";$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();if(n%2)random_index=rotate_options.length-random_index-1;rotate_options.hide();var option=$(rotate_options[random_index]);option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""}).removeClass("ai-rotate-option").removeClass("ai-rotate-options");
2
+ $(this).css({"position":""}).removeClass("ai-rotate");var wrapping_div=$(this).closest(wrapping_div_selector);if(typeof wrapping_div!="undefined")wrapping_div.find("span.ai-option-name").html(" - "+atob(option.data("name")));var tracking_updated=false;var adb_show_wrapping_div=$(this).closest(".ai-adb-show");if(typeof adb_show_wrapping_div!="undefined")if(typeof adb_show_wrapping_div.data("ai-tracking")!="undefined"){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!==
3
+ "undefined"&&data.constructor===Array){data[1]=random_index+1;adb_show_wrapping_div.data("ai-tracking",btoa(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated)if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}})});
includes/js/sponsors.js DELETED
@@ -1 +0,0 @@
1
- window.ededdaeb=true;
 
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.2.10";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -16,7 +16,7 @@ var settings_page = "";
16
 
17
  var dateFormat = "yy-mm-dd";
18
 
19
- var search_reload = false;
20
 
21
  var AI_DISABLED = 0;
22
  var AI_BEFORE_POST = 1;
@@ -1372,7 +1372,7 @@ jQuery(document).ready(function($) {
1372
 
1373
  var window_width = 820;
1374
  var window_height = 870;
1375
- var window_left = 120;
1376
  var window_top = (screen.height / 2) - (870 / 2);
1377
  var nonce = $(this).attr ('nonce');
1378
  var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce, 'code': code, 'php': php};
@@ -1780,9 +1780,9 @@ jQuery(document).ready(function($) {
1780
 
1781
  var window_width = 820;
1782
  var window_height = 820;
1783
- var window_left = 120;
1784
  var window_top = (screen.height / 2) - (820 / 2);
1785
- var nonce = $(this).attr ('nonce');
1786
 
1787
  var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': btoa (name), 'alignment': btoa (alignment), 'alignment_css': btoa (alignment_css), 'custom_css': btoa (custom_css), 'code': code, 'php': php};
1788
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
@@ -1860,7 +1860,7 @@ jQuery(document).ready(function($) {
1860
 
1861
  var window_width = 820;
1862
  var window_height = 870;
1863
- var window_left = 120;
1864
  var window_top = (screen.height / 2) - (window_height / 2);
1865
  var nonce = $("#ai-form").attr ('nonce');
1866
  var param = {'action': 'ai_ajax_backend', 'edit': block, 'ai_check': nonce, 'code': code, 'php': php};
@@ -1868,6 +1868,8 @@ jQuery(document).ready(function($) {
1868
  });
1869
 
1870
  $("#open-image-button-"+tab).click (function (event) {
 
 
1871
  var block = $(this).attr('id').replace ("open-image-button-", "");
1872
  var frame;
1873
 
@@ -1887,34 +1889,50 @@ jQuery(document).ready(function($) {
1887
  });
1888
 
1889
  frame.on ('open', function(){
1890
- var selection = frame.state().get ('selection');
1891
- var selected = $('#banner-image-' + block).val();
1892
- if (selected) {
1893
- selection.add (wp.media.attachment (selected));
1894
- }
 
1895
  });
1896
 
1897
  frame.on ('select', function() {
1898
  var attachment = frame.state().get('selection').first().toJSON();
 
1899
  $('#banner-image-' + block).attr ('src', attachment.url);
1900
- $('#banner-image-url-' + block).val (attachment.url);
1901
-
1902
  });
1903
 
1904
  frame.open();
1905
  });
1906
 
1907
  $("#banner-image-url-" + tab).on ('input', function() {
 
1908
  var block = $(this).attr('id').replace ("banner-image-url-", "");
1909
  var image = $('#banner-image-' + block);
1910
- image.attr ('src', $(this).val ()).load (function() {
 
 
 
 
 
 
 
 
1911
  $(this).closest ('.ai-banner').removeClass ('ai-banner-top');
1912
  var width = this.naturalWidth;
1913
  var height = this.naturalHeight;
 
1914
  if (width / height > 2 && width > 300) {
1915
  $(this).closest ('.ai-banner').addClass ('ai-banner-top');
1916
  }
1917
- });
 
 
 
 
 
1918
 
1919
  });
1920
 
@@ -1943,8 +1961,8 @@ jQuery(document).ready(function($) {
1943
 
1944
  switch (code_type) {
1945
  case AI_CODE_BANNER:
1946
- $("#banner-image-url-" + block).val (code_data ['image']).trigger('input');
1947
- $("#banner-url-" + block).val (code_data ['link']).trigger('input');
1948
  $("#open-new-window-" + block).attr('checked', code_data ['target'] == '_blank');
1949
  break;
1950
  case AI_CODE_ADSENSE:
@@ -2090,6 +2108,19 @@ jQuery(document).ready(function($) {
2090
  var block = $(this).attr('id').replace ("remove-option-", "");
2091
  remove_rotate_option (block, $('#ai-rotation-container-' + block).tabs ("option", "active"));
2092
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
2093
  }
2094
 
2095
  function import_rotation_code (block) {
@@ -2681,10 +2712,10 @@ jQuery(document).ready(function($) {
2681
 
2682
 
2683
  function reload_list () {
2684
- search_reload = false;
2685
  var list = encodeURIComponent ($("#ai-list-search").val());
2686
  var all = + !$("#ai-load-all").parent ().find ('.checkbox-icon').hasClass ('on');
2687
- var nonce = $("#ai-list").attr ('nonce');
2688
 
2689
  var rearrange_controls = $('#list-rearrange-controls');
2690
  var rearrange = rearrange_controls.hasClass ('rearrange')
@@ -2718,12 +2749,26 @@ jQuery(document).ready(function($) {
2718
  $("#ai-tab-container").tabs ({active: tab});
2719
  });
2720
 
2721
- $("label.ai-load-settings").click (function () {
2722
  var block = $(this).closest ('tr').data ('block');
2723
 
2724
  load_saved_settings_to_clipboard (block, true);
2725
  });
2726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2727
  data_container.disableSelection();
2728
 
2729
  if (rearrange) reload_settings ();
@@ -2731,6 +2776,141 @@ jQuery(document).ready(function($) {
2731
  });
2732
  }
2733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2734
  function configure_tabs () {
2735
 
2736
  var tabs_array = new Array ();
@@ -2856,6 +3036,21 @@ jQuery(document).ready(function($) {
2856
  });
2857
  }
2858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2859
 
2860
 
2861
  if (debug) console.log ("READY");
@@ -2963,18 +3158,18 @@ jQuery(document).ready(function($) {
2963
 
2964
 
2965
  $("#ai-list").click (function () {
2966
- $('#ai-list-container').toggle ();
2967
-
2968
  var container = $("#ai-list-container");
2969
 
 
 
2970
  if (container.is(':visible')) {
2971
  reload_list ();
2972
  }
2973
  });
2974
 
2975
  $("#ai-list-search").keyup (function (event) {
2976
- if (!search_reload) {
2977
- search_reload = true;
2978
  setTimeout (reload_list, 200);
2979
  }
2980
  });
@@ -3010,6 +3205,30 @@ jQuery(document).ready(function($) {
3010
  reload_list ();
3011
  });
3012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3013
  setTimeout (update_rating, 1000);
3014
 
3015
  if (debug) console.log ("");
1
+ var javascript_version = "2.2.11";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
16
 
17
  var dateFormat = "yy-mm-dd";
18
 
19
+ var list_search_reload = false;
20
 
21
  var AI_DISABLED = 0;
22
  var AI_BEFORE_POST = 1;
1372
 
1373
  var window_width = 820;
1374
  var window_height = 870;
1375
+ var window_left = 100;
1376
  var window_top = (screen.height / 2) - (870 / 2);
1377
  var nonce = $(this).attr ('nonce');
1378
  var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce, 'code': code, 'php': php};
1780
 
1781
  var window_width = 820;
1782
  var window_height = 820;
1783
+ var window_left = 100;
1784
  var window_top = (screen.height / 2) - (820 / 2);
1785
+ var nonce = $("#ai-form").attr ('nonce');
1786
 
1787
  var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': btoa (name), 'alignment': btoa (alignment), 'alignment_css': btoa (alignment_css), 'custom_css': btoa (custom_css), 'code': code, 'php': php};
1788
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
1860
 
1861
  var window_width = 820;
1862
  var window_height = 870;
1863
+ var window_left = 100;
1864
  var window_top = (screen.height / 2) - (window_height / 2);
1865
  var nonce = $("#ai-form").attr ('nonce');
1866
  var param = {'action': 'ai_ajax_backend', 'edit': block, 'ai_check': nonce, 'code': code, 'php': php};
1868
  });
1869
 
1870
  $("#open-image-button-"+tab).click (function (event) {
1871
+ $(this).blur ();
1872
+
1873
  var block = $(this).attr('id').replace ("open-image-button-", "");
1874
  var frame;
1875
 
1889
  });
1890
 
1891
  frame.on ('open', function(){
1892
+ // var selected = $('#banner-image-' + block).attr ('src');
1893
+ // if (selected) {
1894
+ // var selection = frame.state().get ('selection');
1895
+ // var id = $('#banner-image-' + block).attr ('data-id');
1896
+ // selection.add (wp.media.attachment (id));
1897
+ // }
1898
  });
1899
 
1900
  frame.on ('select', function() {
1901
  var attachment = frame.state().get('selection').first().toJSON();
1902
+ console.log ('attachment', attachment);
1903
  $('#banner-image-' + block).attr ('src', attachment.url);
1904
+ $('#banner-image-url-' + block).val (attachment.url).trigger ("input");
 
1905
  });
1906
 
1907
  frame.open();
1908
  });
1909
 
1910
  $("#banner-image-url-" + tab).on ('input', function() {
1911
+
1912
  var block = $(this).attr('id').replace ("banner-image-url-", "");
1913
  var image = $('#banner-image-' + block);
1914
+
1915
+ var new_image_src = $(this).val ();
1916
+ if (new_image_src == '') {
1917
+ new_image_src = '//:0';
1918
+ image.hide ();
1919
+ }
1920
+
1921
+ image.attr ('src', new_image_src).load (function () {
1922
+ image.show ();
1923
  $(this).closest ('.ai-banner').removeClass ('ai-banner-top');
1924
  var width = this.naturalWidth;
1925
  var height = this.naturalHeight;
1926
+
1927
  if (width / height > 2 && width > 300) {
1928
  $(this).closest ('.ai-banner').addClass ('ai-banner-top');
1929
  }
1930
+ })
1931
+ .error (function() {
1932
+ if (image.is(':visible')) {
1933
+ image.hide ().attr ('src', '//:0');
1934
+ }
1935
+ });
1936
 
1937
  });
1938
 
1961
 
1962
  switch (code_type) {
1963
  case AI_CODE_BANNER:
1964
+ $("#banner-image-url-" + block).val (code_data ['image']).trigger ('input');
1965
+ $("#banner-url-" + block).val (code_data ['link']).trigger ('input');
1966
  $("#open-new-window-" + block).attr('checked', code_data ['target'] == '_blank');
1967
  break;
1968
  case AI_CODE_ADSENSE:
2108
  var block = $(this).attr('id').replace ("remove-option-", "");
2109
  remove_rotate_option (block, $('#ai-rotation-container-' + block).tabs ("option", "active"));
2110
  });
2111
+
2112
+ //
2113
+ $("#settings-" + tab + " .adsense-list").click (function () {
2114
+ $(this).blur ();
2115
+
2116
+ var container = $("#adsense-list-container");
2117
+
2118
+ container.toggle ();
2119
+
2120
+ if (container.is(':visible')) {
2121
+ reload_adsense_list (false);
2122
+ }
2123
+ });
2124
  }
2125
 
2126
  function import_rotation_code (block) {
2712
 
2713
 
2714
  function reload_list () {
2715
+ list_search_reload = false;
2716
  var list = encodeURIComponent ($("#ai-list-search").val());
2717
  var all = + !$("#ai-load-all").parent ().find ('.checkbox-icon').hasClass ('on');
2718
+ var nonce = $("#ai-form").attr ('nonce');
2719
 
2720
  var rearrange_controls = $('#list-rearrange-controls');
2721
  var rearrange = rearrange_controls.hasClass ('rearrange')
2749
  $("#ai-tab-container").tabs ({active: tab});
2750
  });
2751
 
2752
+ $("label.ai-copy-block").click (function () {
2753
  var block = $(this).closest ('tr').data ('block');
2754
 
2755
  load_saved_settings_to_clipboard (block, true);
2756
  });
2757
 
2758
+ $("label.ai-preview-block").click (function () {
2759
+ var block = $(this).closest ('tr').data ('block');
2760
+
2761
+ var window_width = 820;
2762
+ var window_height = 820;
2763
+ var window_left = 100;
2764
+ var window_top = (screen.height / 2) - (820 / 2);
2765
+ var nonce = $("#ai-form").attr ('nonce');
2766
+
2767
+ var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'read_only': 1};
2768
+ window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
2769
+ });
2770
+
2771
+
2772
  data_container.disableSelection();
2773
 
2774
  if (rearrange) reload_settings ();
2776
  });
2777
  }
2778
 
2779
+ function reload_adsense_list (update_ad_units) {
2780
+ adsense_search_reload = false;
2781
+ var list = encodeURIComponent ($("#adsense-list-search").val());
2782
+ var all = + !$("#adsense-load-all").parent ().find ('.checkbox-icon').hasClass ('on');
2783
+ var nonce = $("#ai-form").attr ('nonce');
2784
+
2785
+ var data_container = $("#adsense-list-data");
2786
+
2787
+ data_container.load (ajaxurl+"?action=ai_ajax_backend&adsense-list=" + list + "&all=" + all + "&update_ad_units=" + (update_ad_units ? 1 : 0) + "&ai_check=" + nonce, function (response, status, xhr) {
2788
+ $("#adsense-reload").parent ().find ('.checkbox-icon').removeClass ('on');
2789
+
2790
+ if (status == "error") {
2791
+ var message = "Error downloading AdSense data: " + xhr.status + " " + xhr.statusText;
2792
+ data_container.html (message);
2793
+ if (debug) console.log (message);
2794
+
2795
+
2796
+ } else {
2797
+ if (!$('#adsense-authorization-code', data_container).length) $('#adsense-list-controls').show (); else {
2798
+ $('#adsense-list-controls').hide ();
2799
+ $('button.ai-top-button', data_container).button().show ();
2800
+
2801
+ $("#authorize-adsense").click (function () {
2802
+
2803
+ var authorization_code = $("input#adsense-authorization-code").val ();
2804
+
2805
+ $('#adsense-list-controls').show ();
2806
+ data_container.text ('Loading...');
2807
+
2808
+ update_adsense_authorization (authorization_code);
2809
+ });
2810
+ }
2811
+
2812
+ var publisher_id = $('#adsense-data', data_container).data ('publisher-id');
2813
+ if (typeof publisher_id == 'undefined') publisher_id = '';
2814
+
2815
+ $('label#google-adsense-button').attr ('title', 'Google AdSense Home ' + publisher_id);
2816
+
2817
+ $("label.adsense-copy-code").click (function () {
2818
+ var ad_slot_id = $(this).closest ('tr').data ('id');
2819
+ var ad_name = atob ($(this).closest ('tr').data ('name'));
2820
+ var nonce = $("#ai-form").attr ('nonce');
2821
+
2822
+ if (debug) console.log ('ADSENSE CODE: ', ad_slot_id);
2823
+
2824
+ $('#ai-loading').show ();
2825
+ $.get (ajaxurl + '?action=ai_ajax_backend&adsense-code=' + ad_slot_id + '&ai_check=' + nonce, function (data) {
2826
+
2827
+ var code_data = JSON.parse (data);
2828
+ var error = code_data ['error-message'];
2829
+
2830
+ if (error == '') {
2831
+ var adsense_code = code_data ['code'];
2832
+
2833
+ if (debug) console.log (adsense_code);
2834
+
2835
+ var clipboard_template = $('#ai-clipboard-template');
2836
+ var clipboard = $('#ai-clipboard');
2837
+ clipboard.html (clipboard_template.html ());
2838
+ clipboard.find ('input#name-edit-999').attr ('value', ad_name).attr ('default', ad_name);
2839
+
2840
+ clipboard.find ('textarea.simple-editor').text (adsense_code);
2841
+
2842
+ $("#ai-container .ai-copy").each (function () {
2843
+ $(this).next ("label").find ('.checkbox-icon').addClass("on");
2844
+ });
2845
+
2846
+ var tools_button = $("#tools-button-" + active_tab);
2847
+ if (!tools_button.next ('label').find ('.checkbox-icon').hasClass ("on")) {
2848
+ tools_button.click ();
2849
+ }
2850
+ } else {
2851
+ console.log ('AdSense API error:', error);
2852
+ }
2853
+ }).fail (function (xhr, status, error) {
2854
+ var message = "Error downloading AdSense code: " + xhr.status + " " + xhr.statusText ;
2855
+ console.log (message);
2856
+ })
2857
+ .always (function () {
2858
+ $('#ai-loading').hide ();
2859
+ });
2860
+
2861
+ });
2862
+
2863
+ $("label.adsense-preview-code").click (function () {
2864
+ var ad_slot_id = $(this).closest ('tr').data ('id');
2865
+ var ad_name = $(this).closest ('tr').data ('name');
2866
+
2867
+ var window_width = 820;
2868
+ var window_height = 820;
2869
+ var window_left = 100;
2870
+ var window_top = (screen.height / 2) - (820 / 2);
2871
+ var nonce = $("#ai-form").attr ('nonce');
2872
+
2873
+ var param = {'action': 'ai_ajax_backend', 'preview': 'adsense', 'ai_check': nonce, 'read_only': 1, 'slot_id': btoa (ad_slot_id), 'name': ad_name};
2874
+ window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
2875
+ });
2876
+
2877
+ $("label.adsense-get-code").click (function () {
2878
+ var ad_slot_id = $(this).closest ('tr').data ('id');
2879
+ var ad_name = atob ($(this).closest ('tr').data ('name'));
2880
+ var nonce = $("#ai-form").attr ('nonce');
2881
+
2882
+ if (debug) console.log ('ADSENSE CODE: ', ad_slot_id);
2883
+
2884
+ $('#ai-loading').show ();
2885
+ $.get (ajaxurl + '?action=ai_ajax_backend&adsense-code=' + ad_slot_id + '&ai_check=' + nonce, function (data) {
2886
+
2887
+ var code_data = JSON.parse (data);
2888
+ var error = code_data ['error-message'];
2889
+
2890
+ if (error == '') {
2891
+ var adsense_code = code_data ['code'];
2892
+
2893
+ if (debug) console.log (adsense_code);
2894
+
2895
+ set_editor_text (active_tab, adsense_code);
2896
+ setTimeout (function() {$("#import-code-"+active_tab).click ();}, 10);
2897
+ } else {
2898
+ console.log ('AdSense API error:', error);
2899
+ }
2900
+ }).fail (function (xhr, status, error) {
2901
+ var message = "Error downloading AdSense code: " + xhr.status + " " + xhr.statusText ;
2902
+ console.log (message);
2903
+ })
2904
+ .always (function () {
2905
+ $('#ai-loading').hide ();
2906
+ });
2907
+ });
2908
+
2909
+ data_container.disableSelection();
2910
+ }
2911
+ });
2912
+ }
2913
+
2914
  function configure_tabs () {
2915
 
2916
  var tabs_array = new Array ();
3036
  });
3037
  }
3038
 
3039
+ function update_adsense_authorization (authorization_code) {
3040
+ var nonce = $("#ai-form").attr ('nonce');
3041
+
3042
+ $('#ai-loading').show ();
3043
+ $.get (ajaxurl + '?action=ai_ajax_backend&adsense-authorization-code=' + btoa (authorization_code) + '&ai_check=' + nonce, function (data) {
3044
+ reload_adsense_list (false);
3045
+ }).fail (function (xhr, status, error) {
3046
+ var message = "Error clearing AdSense authorization: " + xhr.status + " " + xhr.statusText ;
3047
+ console.log (message);
3048
+ })
3049
+ .always (function () {
3050
+ $('#ai-loading').hide ();
3051
+ });
3052
+ }
3053
+
3054
 
3055
 
3056
  if (debug) console.log ("READY");
3158
 
3159
 
3160
  $("#ai-list").click (function () {
 
 
3161
  var container = $("#ai-list-container");
3162
 
3163
+ container.toggle ();
3164
+
3165
  if (container.is(':visible')) {
3166
  reload_list ();
3167
  }
3168
  });
3169
 
3170
  $("#ai-list-search").keyup (function (event) {
3171
+ if (!list_search_reload) {
3172
+ list_search_reload = true;
3173
  setTimeout (reload_list, 200);
3174
  }
3175
  });
3205
  reload_list ();
3206
  });
3207
 
3208
+
3209
+ $("#adsense-load-all").click (function () {
3210
+ $(this).parent ().find ('.checkbox-icon').toggleClass ('on');
3211
+ reload_adsense_list (false);
3212
+ });
3213
+
3214
+ $("#adsense-list-search").keyup (function (event) {
3215
+ if (!adsense_search_reload) {
3216
+ adsense_search_reload = true;
3217
+ setTimeout (function() {reload_adsense_list (false);}, 200);
3218
+
3219
+ }
3220
+ });
3221
+
3222
+ $("#adsense-reload").click (function () {
3223
+ $(this).parent ().find ('.checkbox-icon').addClass ('on');
3224
+ setTimeout (function() {reload_adsense_list (true);}, 200);
3225
+ });
3226
+
3227
+ $("#clear-adsense-authorization").click (function () {
3228
+ $("#adsense-list-data").text ('Updating...');
3229
+ update_adsense_authorization ('');
3230
+ });
3231
+
3232
  setTimeout (update_rating, 1000);
3233
 
3234
  if (debug) console.log ("");
{includes/js → js}/ads.js RENAMED
File without changes
js/sponsors.js ADDED
@@ -0,0 +1 @@
 
1
+ window.lfoswyekaaslsd=true;
preview.php CHANGED
@@ -11,7 +11,7 @@ function alt_styles_data ($alt_styles_text) {
11
  }
12
  }
13
 
14
- function generate_code_preview ($block, $name = null, $alignment = null, $alignment_css = null, $custom_css = null, $client_code = null, $process_php = null) {
15
  global $block_object, $ai_wp_data;
16
 
17
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
@@ -314,7 +314,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $alignm
314
  style = $(id_css_alignment_sticky_bottom).text ();
315
  } else
316
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
317
- $("#css-code").show();
318
  $("#custom-css").show();
319
  style = $("#custom-css").val ();
320
  } else
@@ -631,7 +631,9 @@ function generate_code_preview ($block, $name = null, $alignment = null, $alignm
631
 
632
  update_width ();
633
 
 
634
  load_from_settings ();
 
635
 
636
  setTimeout (update_wrapper_size, 500);
637
 
@@ -887,6 +889,7 @@ div.automatic-insertion img {
887
  <div style="clear: both;"></div>
888
  </div>
889
 
 
890
  <div style="margin: 10px -8px">
891
  <table class="screen" cellspacing=0 cellspacing="0">
892
  <tr>
@@ -898,20 +901,33 @@ div.automatic-insertion img {
898
  </tr>
899
  </table>
900
  </div>
 
901
 
902
  <div style="float: right; width: 90px; margin-left: 20px;">
903
  <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
 
904
  <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Use current settings" >Use</button>
905
  <button id="reset-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Reset to the block settings" >Reset</button>
 
906
  <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Close preview window" >Cancel</button>
907
  </div>
908
 
 
909
  <div style="float: left; max-width: 300px; margin-right: 20px">
 
 
 
 
910
  <h1 style="margin: 0;">Preview</h1>
 
911
  <h2>Block <?php echo $block; ?></h2>
 
 
 
912
  <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
913
  </div>
914
 
 
915
  <div style="float: left; min-height: 200px; margin: 0 auto;">
916
  <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
917
  <tr>
@@ -973,10 +989,15 @@ div.automatic-insertion img {
973
  </tr>
974
  </table>
975
  </div>
 
976
 
977
  <div style="clear: both;"></div>
978
 
979
- <div id="css-code" style="margin: 20px 0;">
 
 
 
 
980
  <div style="margin: 20px 0 0 0;">
981
  Alignment and Style:&nbsp;&nbsp;&nbsp;
982
  <select id="block-alignment" style="border-radius: 5px; width:120px;">
@@ -1020,8 +1041,14 @@ div.automatic-insertion img {
1020
  </table>
1021
  </div>
1022
 
1023
- <p id="p1">This is a preview of the code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
 
1024
  or write CSS code directly and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.</p>
 
 
 
 
 
1025
 
1026
  <div id='padding-background'></div>
1027
  <div id='margin-background'></div>
@@ -1032,14 +1059,25 @@ div.automatic-insertion img {
1032
  <!-- IE bug: use inline CSS: position: absolute;-->
1033
  <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
1034
  <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
 
 
1035
  <p id="p2">You can resize the window (and refresh the page to reload ads) to check display with different screen widths.
1036
  Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.</p>
1037
- <p id="p3">Please note that the code displayed here is the code that is saved for this block, while block name, alignment and style are taken from the current block settings (may not be saved).
1038
- No Wrapping style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.</p>
1039
- <p id="p4">Few very important things you need to know in order to insert code and display some ad:
 
 
 
 
 
 
 
 
1040
  Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
1041
  Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
1042
- For Posts and static pages select default value On all Posts / On all Static pages unless you really know what are you doing.</p>
 
1043
  <?php ai_wp_footer_hook (); ?>
1044
  </body>
1045
  </html>
11
  }
12
  }
13
 
14
+ function generate_code_preview ($block, $name = null, $alignment = null, $alignment_css = null, $custom_css = null, $client_code = null, $process_php = null, $read_only = false) {
15
  global $block_object, $ai_wp_data;
16
 
17
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
314
  style = $(id_css_alignment_sticky_bottom).text ();
315
  } else
316
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
317
+ // $("#alignment-editor").show();
318
  $("#custom-css").show();
319
  style = $("#custom-css").val ();
320
  } else
631
 
632
  update_width ();
633
 
634
+ <?php if (!$read_only) : ?>
635
  load_from_settings ();
636
+ <?php endif; ?>
637
 
638
  setTimeout (update_wrapper_size, 500);
639
 
889
  <div style="clear: both;"></div>
890
  </div>
891
 
892
+ <?php if (!$read_only) : ?>
893
  <div style="margin: 10px -8px">
894
  <table class="screen" cellspacing=0 cellspacing="0">
895
  <tr>
901
  </tr>
902
  </table>
903
  </div>
904
+ <?php endif; ?>
905
 
906
  <div style="float: right; width: 90px; margin-left: 20px;">
907
  <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
908
+ <?php if (!$read_only) : ?>
909
  <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Use current settings" >Use</button>
910
  <button id="reset-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Reset to the block settings" >Reset</button>
911
+ <?php endif; ?>
912
  <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Close preview window" >Cancel</button>
913
  </div>
914
 
915
+ <?php if (!$read_only) : ?>
916
  <div style="float: left; max-width: 300px; margin-right: 20px">
917
+ <?php else : ?>
918
+ <div style="float: left; max-width: 600px; margin-right: 20px">
919
+ <?php endif; ?>
920
+
921
  <h1 style="margin: 0;">Preview</h1>
922
+ <?php if ($block != 0) : ?>
923
  <h2>Block <?php echo $block; ?></h2>
924
+ <?php else : ?>
925
+ <h2>AdSense ad unit</h2>
926
+ <?php endif; ?>
927
  <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
928
  </div>
929
 
930
+ <?php if (!$read_only) : ?>
931
  <div style="float: left; min-height: 200px; margin: 0 auto;">
932
  <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
933
  <tr>
989
  </tr>
990
  </table>
991
  </div>
992
+ <?php endif; ?>
993
 
994
  <div style="clear: both;"></div>
995
 
996
+ <?php if (!$read_only) : ?>
997
+ <div id="alignment-editor" style="margin: 20px 0;">
998
+ <?php else : ?>
999
+ <div id="alignment-editor" style="margin: 20px 0; display: none;">
1000
+ <?php endif; ?>
1001
  <div style="margin: 20px 0 0 0;">
1002
  Alignment and Style:&nbsp;&nbsp;&nbsp;
1003
  <select id="block-alignment" style="border-radius: 5px; width:120px;">
1041
  </table>
1042
  </div>
1043
 
1044
+ <?php if (!$read_only) : ?>
1045
+ <p id="p1">This is a preview of the code between dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
1046
  or write CSS code directly and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.</p>
1047
+ <?php elseif ($block != 0) : ?>
1048
+ <p id="p1">This is a preview of the saved code block between dummy paragraphs. It shows the code with the alignment and style as it is set for this code block. Highlight button highlights background, wrapping div margin and code area.</p>
1049
+ <?php else : ?>
1050
+ <p id="p1">This is a preview of AdSense ad between dummy paragraphs. AdSense ad code was loaded from your AdSense account.</p>
1051
+ <?php endif; ?>
1052
 
1053
  <div id='padding-background'></div>
1054
  <div id='margin-background'></div>
1059
  <!-- IE bug: use inline CSS: position: absolute;-->
1060
  <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
1061
  <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
1062
+
1063
+ <?php if (!$read_only) : ?>
1064
  <p id="p2">You can resize the window (and refresh the page to reload ads) to check display with different screen widths.
1065
  Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.</p>
1066
+ <p id="p3">Please note that the code, block name, alignment and style are taken from the current block settings (may not be saved).
1067
+ <strong>No Wrapping</strong> style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.</p>
1068
+ <?php else : ?>
1069
+ <?php endif; ?>
1070
+
1071
+ <p id="p4">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
1072
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
1073
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
1074
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
1075
+
1076
+ <p id="p5">Few very important things you need to know in order to insert code and display some ad:
1077
  Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
1078
  Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
1079
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
1080
+
1081
  <?php ai_wp_footer_hook (); ?>
1082
  </body>
1083
  </html>
readme.txt CHANGED
@@ -6,14 +6,14 @@ Tags: ads, adsense, ad management, advertising manager, advanced contextual ads,
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
- Stable tag: 2.2.9
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
13
 
14
  == Description ==
15
 
16
- Ad management plugin with many advanced advertising features. **Supports all kinds of WordPress ads including Google AdSense, contextual Amazon Native Shopping Ads and rotating banners.**
17
 
18
  Ad Inserter is more than just ad manager plugin. It provides many advanced options to insert any Javascript, CSS, HTML, PHP or advert code anywhere on the page.
19
 
@@ -23,7 +23,7 @@ Ad Inserter is more than just ad manager plugin. It provides many advanced optio
23
  > * Syntax highlighting editor
24
  > * Code preview with visual CSS editor
25
  > * Automatically inserts ads in posts and pages
26
- > * Insert above header (after `<body>` tag)
27
  > * Insert before or after post
28
  > * Insert before or after content
29
  > * Insert before or after paragraph
@@ -100,6 +100,8 @@ Ad Inserter Wordpress plugin is an advanced advertising manager - it has many fe
100
  Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
101
 
102
  * ad management and ad injection
 
 
103
  * to insert ads between paragraphs
104
  * to insert ads between posts
105
  * to insert ads between comments
@@ -117,7 +119,7 @@ Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding t
117
  * to insert header, footer or tracking code
118
  * to insert PHP, HTML, CSS, shortcodes
119
  * to insert Google analytics code
120
- * to insert various opt-in forms
121
 
122
  Maintaining several plugins (often from different vendors) is not easy. And each plugin is slowing down the speed of your website.
123
 
@@ -754,6 +756,13 @@ AD CODE RIGHT
754
 
755
  == Changelog ==
756
 
 
 
 
 
 
 
 
757
  = 2.2.10 =
758
  - Fix for rotation editor code import/export
759
  - Fix for errors when using old |rotate| separator
@@ -907,6 +916,12 @@ AD CODE RIGHT
907
 
908
  == Upgrade Notice ==
909
 
 
 
 
 
 
 
910
  = 2.2.10 =
911
  Fix for rotation editor code import/export;
912
  Fix for errors when using old |rotate| separator
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
+ Stable tag: 2.2.10
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
13
 
14
  == Description ==
15
 
16
+ Ad management plugin with many advanced advertising features. **Supports all kinds of WordPress ads including Google AdSense, contextual Amazon Native Shopping Ads, Media.net and rotating banners.**
17
 
18
  Ad Inserter is more than just ad manager plugin. It provides many advanced options to insert any Javascript, CSS, HTML, PHP or advert code anywhere on the page.
19
 
23
  > * Syntax highlighting editor
24
  > * Code preview with visual CSS editor
25
  > * Automatically inserts ads in posts and pages
26
+ > * Insert above header (after `<body>` tag, needs Output buffering)
27
  > * Insert before or after post
28
  > * Insert before or after content
29
  > * Insert before or after paragraph
100
  Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
101
 
102
  * ad management and ad injection
103
+ * to insert AdSense or Media.net ads
104
+ * to insert affiliate ads (CJ Affiliate by Conversant, ClickBank, ShareASale, Rakuten LinkShare, etc.)
105
  * to insert ads between paragraphs
106
  * to insert ads between posts
107
  * to insert ads between comments
119
  * to insert header, footer or tracking code
120
  * to insert PHP, HTML, CSS, shortcodes
121
  * to insert Google analytics code
122
+ * to insert various opt-in forms (MailChimp, AWeber, GetResponse, etc.)
123
 
124
  Maintaining several plugins (often from different vendors) is not easy. And each plugin is slowing down the speed of your website.
125
 
756
 
757
  == Changelog ==
758
 
759
+ = 2.2.11 =
760
+ - Code block styles moved to classes
761
+ - Code block list moved to the sidebar
762
+ - Added preview buttons in code block list
763
+ - Fix for ad blocking detection when using https (Pro only)
764
+ - Few minor bug fixes, cosmetic changes and code improvements
765
+
766
  = 2.2.10 =
767
  - Fix for rotation editor code import/export
768
  - Fix for errors when using old |rotate| separator
916
 
917
  == Upgrade Notice ==
918
 
919
+ = 2.2.11 =
920
+ Code block styles moved to classes;
921
+ Code block list moved to the sidebar;
922
+ Added preview buttons in code block list;
923
+ Fix for ad blocking detection when using https (Pro only)
924
+
925
  = 2.2.10 =
926
  Fix for rotation editor code import/export;
927
  Fix for errors when using old |rotate| separator
settings.php CHANGED
@@ -143,7 +143,7 @@ function generate_settings_form (){
143
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
144
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
145
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
146
- <button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>"><span>List</span></button>
147
  </div>
148
 
149
  <div style="clear: both;"></div>
@@ -282,41 +282,41 @@ function generate_settings_form (){
282
  elseif ($automatic) $style = "font-weight: bold; color: #e44;";
283
  elseif ($manual [$block]) $style = "font-weight: bold; color: #66f;";
284
 
285
- if (!wp_is_mobile ()) {
286
- $ad_name = $obj->get_ad_name();
287
 
288
- $ad_name_functions = false;
289
- if ($automatic) {
290
- $ad_name .= ": ".$obj->get_automatic_insertion_text ();
291
- $ad_name_functions = true;
292
- }
293
 
294
- if (!empty ($sidebars_with_widget [$block])) $sidebars [$block] = implode (", ", $sidebars_with_widget [$block]);
295
- if ($manual_widget [$block]) {
296
- if ($sidebars [$block] != "") {
297
- $ad_name .= $ad_name_functions ? ", " : ": ";
298
- $ad_name .= "Widget used in: [".$sidebars [$block]."]";
299
- $ad_name_functions = true;
300
- }
301
- } else {
302
- if (!empty ($sidebars_with_widget [$block])) {
303
- $ad_name .= $ad_name_functions ? ", " : ": ";
304
- $ad_name .= "Widget DISABLED but used in: [".$sidebars [$block]."]";
305
- $ad_name_functions = true;
306
- }
307
- }
308
 
309
- if ($manual_shortcode [$block]) {
310
- $ad_name .= $ad_name_functions ? ", " : ": ";
311
- $ad_name .= "Shortcode";
312
- $ad_name_functions = true;
313
- }
314
- if ($manual_php_function [$block]) {
315
- $ad_name .= $ad_name_functions ? ", " : ": ";
316
- $ad_name .= "PHP function";
317
- $ad_name_functions = true;
318
- }
319
- }
320
 
321
  echo "
322
  <li id=\"ai-tab$block\" class=\"ai-tab\" title=\"$ad_name\"><a href=\"#tab-$block\"><span style=\"", $style, "\">$block</span></a></li>";
@@ -567,7 +567,7 @@ function generate_settings_form (){
567
 
568
  <div id="tab-banner-<?php echo $block; ?>" class="ai-banner ai-banner-top responsive-table rounded">
569
  <div class="banner-preview">
570
- <a id="banner-link-<?php echo $block; ?>" href="" target="_blank"><img id="banner-image-<?php echo $block; ?>" src="" /></a>
571
  </div>
572
  <table class="ai-settings-table">
573
  <tr>
@@ -592,7 +592,7 @@ function generate_settings_form (){
592
  </td>
593
  <td>
594
  <label for="open-new-window-<?php echo $block; ?>" style="display: inline-block; margin-top: 6px;">Open link in a new tab</label>
595
- <button id="open-image-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; float: right; margin: 0;">Select Image</button>
596
  </td>
597
  </tr>
598
  </table>
@@ -676,11 +676,26 @@ function generate_settings_form (){
676
  <option value="<?php echo AI_ADSENSE_AMP_BELOW_THE_FOLD; ?>"><?php echo AI_TEXT_BELOW_THE_FOLD; ?></option>
677
  </select>
678
  </td>
 
 
 
 
 
 
 
679
  <td>
680
  </td>
681
  <td style="padding-left: 7px;">
682
  </td>
 
 
 
 
 
 
 
683
  </tr>
 
684
  </table>
685
  <div style="clear: both;"></div>
686
 
@@ -709,7 +724,7 @@ function generate_settings_form (){
709
  <button id="manual-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
710
  <button id="device-detection-button-<?php echo $block; ?>" class='ai-button' type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
711
  <button id="misc-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Check for user status, Limit insertions, [error 404 page, Ajax requests, RSS feeds], Filter, Scheduling, General tag"><span style="<?php echo $misc_style; ?>">Misc</span></button>
712
- <button id="preview-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
713
  </div>
714
  <div style="float: right;">
715
  <?php if (function_exists ('ai_settings_bottom_buttons')) ai_settings_bottom_buttons ($start, $end); else { ?>
@@ -793,7 +808,7 @@ function generate_settings_form (){
793
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
794
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $block; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
795
 
796
- <select style="margin: 0 0 0 10px;" id="enabled-on-which-posts-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
797
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
798
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
799
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
@@ -829,7 +844,7 @@ function generate_settings_form (){
829
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
830
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $block; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
831
 
832
- <select style="margin: 0 0 0 10px;" id="enabled-on-which-pages-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
833
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
834
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
835
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
@@ -1533,7 +1548,7 @@ function generate_settings_form (){
1533
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
1534
  <tr>
1535
  <td style="width: 34%;">
1536
- Syntax highlighter theme
1537
  </td>
1538
  <td>
1539
  <select
@@ -2104,8 +2119,6 @@ function generate_settings_form (){
2104
 
2105
  if (!function_exists ('ai_settings_side')) {
2106
 
2107
- code_block_list_container ();
2108
-
2109
  switch ($sidebar) {
2110
  case 0:
2111
  break;
@@ -2137,8 +2150,12 @@ function generate_settings_form (){
2137
 
2138
  <?php
2139
  if ($subpage == 'main') {
 
 
 
 
 
2140
  if (function_exists ('ai_settings_side')) {
2141
- code_block_list_container ();
2142
  ai_settings_side ();
2143
  } else {
2144
  switch ($sidebar) {
@@ -2183,7 +2200,7 @@ function generate_settings_form (){
2183
 
2184
  function replace_blocked_image (image_id, image_src, css_display) {
2185
  var image_selector = "#" + image_id;
2186
- if (!jQuery(image_selector + ":visible").length) {
2187
  blocking_counter ++;
2188
  var image = jQuery(image_selector);
2189
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
@@ -2206,7 +2223,6 @@ function generate_settings_form (){
2206
  replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
2207
  replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
2208
  replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
2209
- replace_blocked_image ('ai-loading', 'loading.gif', 'none');
2210
  if (blocking_counter > 5) {
2211
  var message = 'Ad blocking test: ' + blocking_counter + ' images not loaded';
2212
  console.log ('AD INSERTER:', message);
@@ -2260,19 +2276,19 @@ function get_sidebar_widgets () {
2260
  function code_block_list_container () {
2261
  ?>
2262
  <div id="ai-list-container" class="ai-form rounded" style="background: #fff; display: none;">
2263
- <div id='list-controls' class='ui-widget' style='margin: 8px auto;'>
2264
- <span class="ai-toolbar-button" style="vertical-align: middle; float: left;">
2265
- <input type="checkbox" value="0" id="ai-load-all" style="display: none;" />
2266
- <label class="checkbox-button" for="ai-load-all" title="Toggle active/all blocks"><span class="checkbox-icon icon-enabled-all on"></span></label>
2267
- </span>
2268
- <span class="ai-toolbar-button" style="vertical-align: middle; float: left;">
2269
  <input id="ai-list-search" type="text" value="" size="40" maxlength="40" />
2270
  </span>
2271
- <span class="ai-toolbar-button" style="vertical-align: middle; float: right;">
 
 
 
 
2272
  <input type="checkbox" value="0" id="ai-rearrange" style="display: none;" />
2273
- <label class="checkbox-button" for="ai-rearrange" title="Rearrange block order"><span class="checkbox-icon icon-rearrange"></span></label>
2274
  </span>
2275
- <span id='list-rearrange-controls' style='float: right; display: none;'>
2276
  <span id='list-save' class="ai-toolbar-button text" style="vertical-align: middle; display: none;">
2277
  <input type="checkbox" value="0" id="ai-save-changes" style="display: none;" />
2278
  <label class="checkbox-button" for="ai-save-changes" style="padding: 1px 5px 1px 4px; margin-top: 0px;" title="Save new block order">Save Changes</label>
@@ -2288,6 +2304,45 @@ function code_block_list_container () {
2288
  <?php
2289
  }
2290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2291
  function code_block_list () {
2292
  global $block_object, $wpdb;
2293
 
@@ -2298,7 +2353,7 @@ function code_block_list () {
2298
  if (!empty ($blocks_org) && count ($blocks_org) == count ($blocks_new)) {
2299
  // Uodate widgets
2300
  $current_options = get_option (AI_OPTION_NAME);
2301
- $new_options = $current_options;
2302
 
2303
  $error = false;
2304
  $block_indexes = array ();
@@ -2311,6 +2366,27 @@ function code_block_list () {
2311
  }
2312
 
2313
  if (!$error) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2314
  update_option (AI_OPTION_NAME, $new_options);
2315
  ai_load_settings ();
2316
 
@@ -2389,16 +2465,19 @@ function code_block_list () {
2389
 
2390
  ?>
2391
  <tr style="background: <?php echo $row_color; ?>" data-block="<?php echo $block; ?>">
2392
- <td style="min-width: 55px; text-align: right; color: <?php echo $block_used ? '#444' : '#ccc'; ?>">
2393
- <span class="ai-toolbar-button" style="float: left; margin-right: 2px;">
2394
- <label class="checkbox-button ai-load-settings" style="margin-top: -1px;" title="Copy block"><span class="checkbox-icon icon-none-small"></span></label>
 
 
 
2395
  </span>
2396
- <?php echo $block; ?>
2397
  </td>
2398
  <?php if ($visible_tab): ?>
2399
- <td class="ai-tab-link" data-tab="<?php echo $block; ?>" style=" min-width: 120px; color: #0073aa; cursor: pointer; text-align: left; padding-left: 10px; max-width: 220px; white-space: nowrap; overflow: hidden;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></td>
2400
  <?php else: ?>
2401
- <td style="min-width: 120px; text-align: left; padding-left: 10px; max-width: 280px; white-space: nowrap; overflow: hidden;"><a href="<?php echo $edit_url; ?>" style="text-decoration: none; box-shadow: 0 0 0;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></a></td>
2402
  <?php endif ?>
2403
  <td style="min-width: 180px; text-align: left; padding-left: 10px; max-width: 130px; white-space: nowrap; overflow: hidden; color: <?php echo $automatic_insertion ? '#666' : '#ccc'; ?>"><?php echo $obj->get_automatic_insertion_text(); ?></td>
2404
  <td style="min-width: 110px; text-align: left; padding-left: 10px; max-width: 80px; white-space: nowrap; overflow: hidden; color: <?php echo $block_used ? '#444' : '#ccc'; ?>"><?php echo $obj->get_alignment_type_text (); ?></td>
@@ -2415,8 +2494,8 @@ function code_block_list () {
2415
  <table id="ai-list-table" class="exceptions ai-sortable" cellspacing=0 cellpadding=0 style="width: 100%;" data-blocks="<?php echo json_encode ($blocks); ?>">
2416
  <thead>
2417
  <tr>
2418
- <th style="text-align: right;">Block</th>
2419
- <th style="text-align: left; padding-left: 10px;">Name</th>
2420
  <th style="text-align: left; padding-left: 10px;">Automatic Insertion</th>
2421
  <th style="text-align: left; padding-left: 10px;">Alignment</th>
2422
  <th style="text-align: center; padding-left: 10px;" title="PHP function call">P</th>
@@ -2435,6 +2514,162 @@ function code_block_list () {
2435
  }
2436
  }
2437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2438
  function sidebar_addense_alternative () { ?>
2439
 
2440
  <div class="ai-form header rounded">
@@ -2550,14 +2785,14 @@ function sidebar_pro () { ?>
2550
  <li>Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
2551
  <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
2552
  <li>Options to <a href="http://adinserter.pro/documentation#misc" class="simple-link" target="_blank">disable insertion</a> on Ajax calls, 404 error pages or in RSS feeds</li>
2553
- <li><a href="http://adinserter.pro/documentation#ad-rotation" class="simple-link" target="_blank">Ad rotation</a> (works also with caching)</li>
2554
  <li>Ad impression and click <a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">tracking</a> (works also with Javascript ads like AdSense)</li>
2555
  <li>Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
2556
  <li>Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
2557
  <li>Support for contextual <a href="https://adinserter.pro/settings#amazon" class="simple-link" target="_blank">Amazon Native Shopping Ads</a> (responsive)</li>
2558
  <li>Custom CSS class name for wrapping divs to avoid ad blockers</li>
2559
  <li>PHP code processing</li>
2560
- <li>Banner code generator</li>
2561
  <li>Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
2562
  <li>Support for Google Analytics, Piwik or any other web analytics code</li>
2563
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
@@ -2567,14 +2802,14 @@ function sidebar_pro () { ?>
2567
  <li><a href="http://adinserter.pro/lists" class="simple-link" target="_blank">Black/White-list </a>categories, tags, taxonomies, users, post IDs, urls, referers</li>
2568
  <li><a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">Black/White-list </a>IP addresses or countries (works also with caching)</li>
2569
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
2570
- <li>Import/Export block or plugin settings</li>
2571
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
2572
  <li>Country-level <a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
2573
  <li>Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
2574
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
2575
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
2576
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
2577
- <li>Clipboard support to easily copy code blocks or settings</li>
2578
  <li>Support via email</li>
2579
  </ul>
2580
 
143
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
144
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
145
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
146
+ <button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" title="Show list of all code blocks"><span>List</span></button>
147
  </div>
148
 
149
  <div style="clear: both;"></div>
282
  elseif ($automatic) $style = "font-weight: bold; color: #e44;";
283
  elseif ($manual [$block]) $style = "font-weight: bold; color: #66f;";
284
 
285
+ // if (!wp_is_mobile ()) {
286
+ // $ad_name = $obj->get_ad_name();
287
 
288
+ // $ad_name_functions = false;
289
+ // if ($automatic) {
290
+ // $ad_name .= ": ".$obj->get_automatic_insertion_text ();
291
+ // $ad_name_functions = true;
292
+ // }
293
 
294
+ // if (!empty ($sidebars_with_widget [$block])) $sidebars [$block] = implode (", ", $sidebars_with_widget [$block]);
295
+ // if ($manual_widget [$block]) {
296
+ // if ($sidebars [$block] != "") {
297
+ // $ad_name .= $ad_name_functions ? ", " : ": ";
298
+ // $ad_name .= "Widget used in: [".$sidebars [$block]."]";
299
+ // $ad_name_functions = true;
300
+ // }
301
+ // } else {
302
+ // if (!empty ($sidebars_with_widget [$block])) {
303
+ // $ad_name .= $ad_name_functions ? ", " : ": ";
304
+ // $ad_name .= "Widget DISABLED but used in: [".$sidebars [$block]."]";
305
+ // $ad_name_functions = true;
306
+ // }
307
+ // }
308
 
309
+ // if ($manual_shortcode [$block]) {
310
+ // $ad_name .= $ad_name_functions ? ", " : ": ";
311
+ // $ad_name .= "Shortcode";
312
+ // $ad_name_functions = true;
313
+ // }
314
+ // if ($manual_php_function [$block]) {
315
+ // $ad_name .= $ad_name_functions ? ", " : ": ";
316
+ // $ad_name .= "PHP function";
317
+ // $ad_name_functions = true;
318
+ // }
319
+ // }
320
 
321
  echo "
322
  <li id=\"ai-tab$block\" class=\"ai-tab\" title=\"$ad_name\"><a href=\"#tab-$block\"><span style=\"", $style, "\">$block</span></a></li>";
567
 
568
  <div id="tab-banner-<?php echo $block; ?>" class="ai-banner ai-banner-top responsive-table rounded">
569
  <div class="banner-preview">
570
+ <a id="banner-link-<?php echo $block; ?>" href="" target="_blank"><img id="banner-image-<?php echo $block; ?>" src="//:0" style="display: none;" /></a>
571
  </div>
572
  <table class="ai-settings-table">
573
  <tr>
592
  </td>
593
  <td>
594
  <label for="open-new-window-<?php echo $block; ?>" style="display: inline-block; margin-top: 6px;">Open link in a new tab</label>
595
+ <button id="open-image-button-<?php echo $block; ?>" type="button" class='ai-button select-image' style="display: none; float: right; margin: 7px 0 0 0;">Select Image</button>
596
  </td>
597
  </tr>
598
  </table>
676
  <option value="<?php echo AI_ADSENSE_AMP_BELOW_THE_FOLD; ?>"><?php echo AI_TEXT_BELOW_THE_FOLD; ?></option>
677
  </select>
678
  </td>
679
+ <td>
680
+ </td>
681
+ <td>
682
+ </td>
683
+ </tr>
684
+
685
+ <tr>
686
  <td>
687
  </td>
688
  <td style="padding-left: 7px;">
689
  </td>
690
+ <td>
691
+ </td>
692
+ <td>
693
+ <?php if (defined ('AI_ADSENSE_API')) { ?>
694
+ <button type="button" class='ai-button adsense-list' style="display: none; float: right; margin: -12px 0 0 0;" title="Show AdSense ad units from your account">AdSense ad units</button>
695
+ <?php } ?>
696
+ </td>
697
  </tr>
698
+
699
  </table>
700
  <div style="clear: both;"></div>
701
 
724
  <button id="manual-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
725
  <button id="device-detection-button-<?php echo $block; ?>" class='ai-button' type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
726
  <button id="misc-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Check for user status, Limit insertions, [error 404 page, Ajax requests, RSS feeds], Filter, Scheduling, General tag"><span style="<?php echo $misc_style; ?>">Misc</span></button>
727
+ <button id="preview-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="Preview saved code above" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
728
  </div>
729
  <div style="float: right;">
730
  <?php if (function_exists ('ai_settings_bottom_buttons')) ai_settings_bottom_buttons ($start, $end); else { ?>
808
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
809
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $block; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
810
 
811
+ <select style="margin: 0 0 0 10px;" id="enabled-on-which-posts-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions.">
812
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
813
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
814
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
844
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
845
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $block; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
846
 
847
+ <select style="margin: 0 0 0 10px;" id="enabled-on-which-pages-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions.">
848
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
849
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
850
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
1548
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
1549
  <tr>
1550
  <td style="width: 34%;">
1551
+ Syntax highlighting theme
1552
  </td>
1553
  <td>
1554
  <select
2119
 
2120
  if (!function_exists ('ai_settings_side')) {
2121
 
 
 
2122
  switch ($sidebar) {
2123
  case 0:
2124
  break;
2150
 
2151
  <?php
2152
  if ($subpage == 'main') {
2153
+ code_block_list_container ();
2154
+ if (defined ('AI_ADSENSE_API')) {
2155
+ adsense_list_container ();
2156
+ }
2157
+
2158
  if (function_exists ('ai_settings_side')) {
 
2159
  ai_settings_side ();
2160
  } else {
2161
  switch ($sidebar) {
2200
 
2201
  function replace_blocked_image (image_id, image_src, css_display) {
2202
  var image_selector = "#" + image_id;
2203
+ if (jQuery (image_selector).length && !jQuery(image_selector + ":visible").length) {
2204
  blocking_counter ++;
2205
  var image = jQuery(image_selector);
2206
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
2223
  replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
2224
  replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
2225
  replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
 
2226
  if (blocking_counter > 5) {
2227
  var message = 'Ad blocking test: ' + blocking_counter + ' images not loaded';
2228
  console.log ('AD INSERTER:', message);
2276
  function code_block_list_container () {
2277
  ?>
2278
  <div id="ai-list-container" class="ai-form rounded" style="background: #fff; display: none;">
2279
+ <div id='ai-list-controls' class='ui-widget' style='margin: 0 auto 8px;'>
2280
+ <span style="vertical-align: middle; float: left;">
 
 
 
 
2281
  <input id="ai-list-search" type="text" value="" size="40" maxlength="40" />
2282
  </span>
2283
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2284
+ <input type="checkbox" value="0" id="ai-load-all" style="display: none;" />
2285
+ <label class="checkbox-button" for="ai-load-all" title="Toggle active/all blocks"><span class="checkbox-icon size-16 icon-enabled-all on"></span></label>
2286
+ </span>
2287
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2288
  <input type="checkbox" value="0" id="ai-rearrange" style="display: none;" />
2289
+ <label class="checkbox-button" for="ai-rearrange" title="Rearrange block order"><span class="checkbox-icon size-16 icon-rearrange"></span></label>
2290
  </span>
2291
+ <span id='list-rearrange-controls' class="ai-toolbar-button text" style='float: right; display: none;'>
2292
  <span id='list-save' class="ai-toolbar-button text" style="vertical-align: middle; display: none;">
2293
  <input type="checkbox" value="0" id="ai-save-changes" style="display: none;" />
2294
  <label class="checkbox-button" for="ai-save-changes" style="padding: 1px 5px 1px 4px; margin-top: 0px;" title="Save new block order">Save Changes</label>
2304
  <?php
2305
  }
2306
 
2307
+ if (defined ('AI_ADSENSE_API')) {
2308
+
2309
+ function adsense_list_container () {
2310
+ ?>
2311
+ <div id="adsense-list-container" class="ai-form rounded" style="background: #fff; display: none;">
2312
+ <div id='adsense-list-controls' class='ui-widget' style='margin: 0 auto 8px; display: none;'>
2313
+ <span style="vertical-align: middle; float: left;">
2314
+ <input id="adsense-list-search" type="text" value="" size="40" maxlength="40" />
2315
+ </span>
2316
+
2317
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2318
+ <input type="checkbox" value="0" id="adsense-load-all" style="display: none;" />
2319
+ <label class="checkbox-button" for="adsense-load-all" title="Toggle active/all ad units"><span class="checkbox-icon size-16 icon-enabled-all on"></span></label>
2320
+ </span>
2321
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2322
+ <input type="checkbox" value="0" id="adsense-reload" style="display: none;" />
2323
+ <label class="checkbox-button" for="adsense-reload" title="Reload AdSense ad units"><span class="checkbox-icon size-16w icon-reload"></span></label>
2324
+ </span>
2325
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2326
+ <input type="checkbox" value="" id="clear-adsense-authorization" style="display: none;" />
2327
+ <label class="checkbox-button" for="clear-adsense-authorization" title="Clear authorization to access AdSense account"><span class="list-button lb-size-16 ui-icon ui-icon-power"></span></label>
2328
+ </span>
2329
+ <span class="ai-toolbar-button small" style="vertical-align: middle; float: right;">
2330
+ <input type="checkbox" value="0" id="google-adsense" style="display: none;" />
2331
+ <label class="checkbox-button" id="google-adsense-button" for="google-adsense" title="Google AdSense Home" onclick="window.open('https://www.google.com/adsense/login')" ><span class="checkbox-icon size-img16 icon-adsense"></span></label>
2332
+ </span>
2333
+ <div style="clear: both;"></div>
2334
+ </div>
2335
+
2336
+ <div id="adsense-list-data">
2337
+ Loading...
2338
+ </div>
2339
+ </div>
2340
+ <?php
2341
+ }
2342
+
2343
+ }
2344
+
2345
+
2346
  function code_block_list () {
2347
  global $block_object, $wpdb;
2348
 
2353
  if (!empty ($blocks_org) && count ($blocks_org) == count ($blocks_new)) {
2354
  // Uodate widgets
2355
  $current_options = get_option (AI_OPTION_NAME);
2356
+ $new_options = $current_options;
2357
 
2358
  $error = false;
2359
  $block_indexes = array ();
2366
  }
2367
 
2368
  if (!$error) {
2369
+ // Update AI_OPTION_FALLBACK and AI_OPTION_ADB_BLOCK_REPLACEMENT
2370
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2371
+ $ai_option_fallback = $new_options [$block][AI_OPTION_FALLBACK];
2372
+ if ($ai_option_fallback != '') {
2373
+ foreach ($blocks_org as $index => $org_block) {
2374
+ if ($ai_option_fallback == $org_block) {
2375
+ $new_options [$block][AI_OPTION_FALLBACK] = $blocks_new [$index];
2376
+ }
2377
+ }
2378
+ }
2379
+
2380
+ $ai_option_adb_block_replacement = $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT];
2381
+ if ($ai_option_adb_block_replacement != '') {
2382
+ foreach ($blocks_org as $index => $org_block) {
2383
+ if ($ai_option_adb_block_replacement == $org_block) {
2384
+ $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT] = $blocks_new [$index];
2385
+ }
2386
+ }
2387
+ }
2388
+ }
2389
+
2390
  update_option (AI_OPTION_NAME, $new_options);
2391
  ai_load_settings ();
2392
 
2465
 
2466
  ?>
2467
  <tr style="background: <?php echo $row_color; ?>" data-block="<?php echo $block; ?>">
2468
+ <td style="min-width: 55px; color: <?php echo $block_used ? '#444' : '#ccc'; ?>;">
2469
+ <span class="ai-list-button">
2470
+ <label class="checkbox-button ai-copy-block" style="margin-top: -1px;" title="Copy block"><span class="checkbox-icon size-8"></span></label>
2471
+ </span>
2472
+ <span class="ai-list-button">
2473
+ <label class="checkbox-button ai-preview-block" style="margin-top: -1px;" title="Preview block"><span class="checkbox-icon size-8 icon-preview"></span></label>
2474
  </span>
2475
+ <span class="ai-list-button" style="text-align: right; width: 16px;"><?php echo $block; ?></span>
2476
  </td>
2477
  <?php if ($visible_tab): ?>
2478
+ <td class="ai-tab-link" data-tab="<?php echo $block; ?>" style=" min-width: 120px; color: #0073aa; cursor: pointer; text-align: left; padding-left: 5px; max-width: 220px; white-space: nowrap; overflow: hidden;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></td>
2479
  <?php else: ?>
2480
+ <td style="min-width: 120px; text-align: left; padding-left: 5px; max-width: 280px; white-space: nowrap; overflow: hidden;"><a href="<?php echo $edit_url; ?>" style="text-decoration: none; box-shadow: 0 0 0;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></a></td>
2481
  <?php endif ?>
2482
  <td style="min-width: 180px; text-align: left; padding-left: 10px; max-width: 130px; white-space: nowrap; overflow: hidden; color: <?php echo $automatic_insertion ? '#666' : '#ccc'; ?>"><?php echo $obj->get_automatic_insertion_text(); ?></td>
2483
  <td style="min-width: 110px; text-align: left; padding-left: 10px; max-width: 80px; white-space: nowrap; overflow: hidden; color: <?php echo $block_used ? '#444' : '#ccc'; ?>"><?php echo $obj->get_alignment_type_text (); ?></td>
2494
  <table id="ai-list-table" class="exceptions ai-sortable" cellspacing=0 cellpadding=0 style="width: 100%;" data-blocks="<?php echo json_encode ($blocks); ?>">
2495
  <thead>
2496
  <tr>
2497
+ <th style="text-align: left;">Block</th>
2498
+ <th style="text-align: left; padding-left: 5px;">Name</th>
2499
  <th style="text-align: left; padding-left: 10px;">Automatic Insertion</th>
2500
  <th style="text-align: left; padding-left: 10px;">Alignment</th>
2501
  <th style="text-align: center; padding-left: 10px;" title="PHP function call">P</th>
2514
  }
2515
  }
2516
 
2517
+ if (defined ('AI_ADSENSE_API')) {
2518
+
2519
+ function adsense_list () {
2520
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
2521
+
2522
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
2523
+
2524
+ $publisher_id = '';
2525
+ $ad_units = array ();
2526
+ $error = '';
2527
+
2528
+ $update_ad_units = isset ($_GET ["update_ad_units"]) ? $_GET ["update_ad_units"] == 1 : false;
2529
+
2530
+ $adsense = new adsense_api();
2531
+
2532
+ $ad_data = get_transient (AI_TRANSIENT_ADSENSE_ADS);
2533
+
2534
+ if ($ad_data === false || $update_ad_units) {
2535
+ $ad_units = $adsense->getAdUnits();
2536
+ $error = $adsense->getError ();
2537
+ if ($error == '' && is_array ($ad_units)) {
2538
+ $ad_data = array ($adsense->getAdSensePublisherID (), $ad_units);
2539
+ set_transient (AI_TRANSIENT_ADSENSE_ADS, $ad_data, AI_TRANSIENT_ADSENSE_ADS_EXPIRATION);
2540
+ }
2541
+ }
2542
+
2543
+ if ($error == '') {
2544
+
2545
+ $publisher_id = $ad_data [0];
2546
+ $ad_units = $ad_data [1];
2547
+
2548
+ $show_all_ad_units = isset ($_GET ["all"]) && $_GET ["all"];
2549
+ ?>
2550
+
2551
+ <table id="ai-adsense-ad-units-table" class="exceptions" cellspacing=0 cellpadding=0 style="width: 100%;">
2552
+ <thead>
2553
+ <tr>
2554
+ <th style="text-align: left; width: 66px;">Ad unit</th>
2555
+ <th style="text-align: left;">Name</th>
2556
+ <th style="text-align: left;">Slot ID</th>
2557
+ <th style="text-align: left;">Type</th>
2558
+ <th style="text-align: left;">Size</th>
2559
+ </tr>
2560
+ </thead>
2561
+ <tbody>
2562
+ <?php
2563
+ $row_counter = 0;
2564
+ foreach ($ad_units as $ad_unit) {
2565
+
2566
+ if (!$show_all_ad_units && !$ad_unit ['active']) continue;
2567
+
2568
+ $search_text = trim ($_GET ["adsense-list"]);
2569
+ if ($search_text != '') $search_array = explode (' ', $search_text); else $search_array = array ();
2570
+ $block_text = $ad_unit ['name'] . ' ' . $ad_unit ['code'] . ' ' . $ad_unit ['type'] . ' ' . $ad_unit ['size'];
2571
+ foreach ($search_array as $search_item) {
2572
+ if (stripos ($block_text, trim ($search_item)) === false) continue 2;
2573
+ }
2574
+
2575
+ $row_counter ++;
2576
+ $row_color = $row_counter % 2 == 0 ? '#eee' : '#fff';
2577
+
2578
+ ?>
2579
+ <tr style="background: <?php echo $row_color; ?>" data-id="ca-<?php echo $publisher_id, ':', $ad_unit ['code']; ?>" data-name="<?php echo base64_encode ($ad_unit ['name']); ?>">
2580
+ <td>
2581
+ <span class="ai-list-button">
2582
+ <label class="checkbox-button adsense-copy-code" style="margin-top: -1px;" title="Copy AdSense code"><span class="checkbox-icon size-8"></span></label>
2583
+ </span>
2584
+ <span class="ai-list-button">
2585
+ <label class="checkbox-button adsense-preview-code" style="margin-top: -1px;" title="Preview AdSense ad"><span class="checkbox-icon size-8 icon-preview"></span></label>
2586
+ </span>
2587
+ <span class="ai-list-button">
2588
+ <label class="checkbox-button adsense-get-code" style="margin-top: -1px;" title="Get AdSense code"><span class="checkbox-icon size-8 icon-get"></span></label>
2589
+ </span>
2590
+ </td>
2591
+ <td style="color: <?php echo $ad_unit ['active'] ? '#444' : '#ccc'; ?>;">
2592
+ <?php echo $ad_unit ['name']; ?>
2593
+ </td>
2594
+ <td style="text-align: left; color: <?php echo $ad_unit ['active'] ? '#444' : '#ccc'; ?>;">
2595
+ <?php echo $ad_unit ['code']; ?>
2596
+ </td>
2597
+ <td style="color: <?php echo $ad_unit ['active'] ? '#444' : '#ccc'; ?>;">
2598
+ <?php echo ucwords (strtolower (str_replace ('_', ', ', $ad_unit ['type']))); ?>
2599
+ </td>
2600
+ <td style="color: <?php echo $ad_unit ['active'] ? '#444' : '#ccc'; ?>;">
2601
+ <?php echo ucwords (strtolower ($ad_unit ['size'])); ?>
2602
+ </td>
2603
+ </tr>
2604
+ <?php
2605
+ }
2606
+ ?>
2607
+ </tbody>
2608
+ </table>
2609
+
2610
+ <div id="adsense-data" style="display: none;" data-publisher-id="<?php echo $publisher_id; ?>"></div>
2611
+
2612
+ <?php
2613
+ } else echo "<div style='margin: 10px 0 0 20px;'>$error</div>";
2614
+
2615
+ } else {
2616
+ $adsense = new adsense_api();
2617
+ ?>
2618
+ <table class="responsive-table" cellspacing=0 cellpadding=0 style="width: 100%;">
2619
+ <tbody>
2620
+ <tr>
2621
+ <td colspan="2" style="white-space: inherit;">
2622
+ <div class="rounded" style="margin: 0;">
2623
+ <h2 style="margin: 5px 0; float: left;"><strong><?php echo AD_INSERTER_NAME; ?></strong> AdSense Integration</h2>
2624
+ <a href="https://www.google.com/adsense/login" class="simple-link" style="float: right;" target="_blank" title="Google AdSense Home"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>ga-logo.png" style="margin: 3px 0 -4px 0;"/></a>
2625
+ <div style="clear: both;"></div>
2626
+ </div>
2627
+ <p style="text-align: justify;">Here can <strong><?php echo AD_INSERTER_NAME; ?></strong> list configured AdSense ad units and get code for AdSense ads.
2628
+ To do this you need to authorize <?php echo AD_INSERTER_NAME; ?> to access your AdSense account. Click on the <strong>Get Authorization Code</strong> button to open a new window where you can allow access.
2629
+ When you get the code copy it to the field below and click on the button <strong>Authorize</strong>.</p>
2630
+ </td>
2631
+ </tr>
2632
+ <tr>
2633
+ <td style="padding-right: 10px;">
2634
+ <button type="button" class="ai-top-button" style="display: none; width: 162px; outline-color: transparent;" onclick="window.open('<?php echo $adsense->getAuthUrl (); ?>')">Get Authorization Code</button>
2635
+ </td>
2636
+ <td>
2637
+ <input id="adsense-authorization-code" style="width: 100%;" type="text" value="" size="100" maxlength="200" title="Enter Authorization Code"/>
2638
+ </td>
2639
+ </tr>
2640
+ <tr>
2641
+ <td>&nbsp;</td>
2642
+ <td>&nbsp;</td>
2643
+ </tr>
2644
+ <tr>
2645
+ <td></td>
2646
+ <td>
2647
+ <button type="button" id="authorize-adsense" class="ai-top-button" style="display: none; float: right; width: 162px; outline-color: transparent;">Authorize</button>
2648
+ </td>
2649
+ </tr>
2650
+ </tbody>
2651
+ </table>
2652
+
2653
+ <?php
2654
+ }
2655
+ }
2656
+
2657
+ }
2658
+
2659
+
2660
+ function adsense_code ($ad_slot_id) {
2661
+ if (defined ('AI_ADSENSE_API')) {
2662
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
2663
+
2664
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
2665
+ $adsense = new adsense_api();
2666
+ $code = $adsense->getAdCode ($ad_slot_id);
2667
+ echo json_encode (array ('code' => $code, 'error-message' => $adsense->getError ()));
2668
+ }
2669
+ }
2670
+ }
2671
+
2672
+
2673
  function sidebar_addense_alternative () { ?>
2674
 
2675
  <div class="ai-form header rounded">
2785
  <li>Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
2786
  <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
2787
  <li>Options to <a href="http://adinserter.pro/documentation#misc" class="simple-link" target="_blank">disable insertion</a> on Ajax calls, 404 error pages or in RSS feeds</li>
2788
+ <li><a href="https://adinserter.pro/code-editing#ad-rotation" class="simple-link" target="_blank">Ad rotation</a> (works also with caching)</li>
2789
  <li>Ad impression and click <a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">tracking</a> (works also with Javascript ads like AdSense)</li>
2790
  <li>Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
2791
  <li>Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
2792
  <li>Support for contextual <a href="https://adinserter.pro/settings#amazon" class="simple-link" target="_blank">Amazon Native Shopping Ads</a> (responsive)</li>
2793
  <li>Custom CSS class name for wrapping divs to avoid ad blockers</li>
2794
  <li>PHP code processing</li>
2795
+ <li><a href="https://adinserter.pro/code-editing#banners" class="simple-link" target="_blank">Banner</a> code generator</li>
2796
  <li>Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
2797
  <li>Support for Google Analytics, Piwik or any other web analytics code</li>
2798
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
2802
  <li><a href="http://adinserter.pro/lists" class="simple-link" target="_blank">Black/White-list </a>categories, tags, taxonomies, users, post IDs, urls, referers</li>
2803
  <li><a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">Black/White-list </a>IP addresses or countries (works also with caching)</li>
2804
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
2805
+ <li><a href="https://adinserter.pro/code-editing#export-import" class="simple-link" target="_blank">Import/Export</a> block or plugin settings</li>
2806
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
2807
  <li>Country-level <a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
2808
  <li>Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
2809
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
2810
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
2811
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
2812
+ <li><a href="https://adinserter.pro/code-editing#clipboard" class="simple-link" target="_blank">Clipboard support</a> to easily copy code blocks or settings</li>
2813
  <li>Support via email</li>
2814
  </ul>
2815