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

Version Description

  • Debugging functions in admin toolbar available only for administrators
  • Added option to hide debugging functions in admin toolbar
  • Added shortcode for debugger
  • Few minor bug fixes
Download this release

Release Info

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

Code changes from version 2.0.2 to 2.0.3

Files changed (6) hide show
  1. ad-inserter.php +99 -23
  2. constants.php +2 -1
  3. css/ad-inserter.css +1 -1
  4. js/ad-inserter.js +1 -1
  5. readme.txt +19 -5
  6. settings.php +14 -6
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.0.2
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,12 @@ Plugin URI: http://tinymonitor.com/ad-inserter
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
14
  Ad Inserter 2.0.2 - 25 September 2016
15
  - Changed javascript version check to get plugin version from the HTML page
16
  - Added warning if old cached version of CSS file is loaded on the settings page
@@ -289,12 +295,18 @@ $ai_wp_data [AI_WP_URL] = remove_parameters_from_url ($_SERVER ['REQUEST_URI']);
289
 
290
  if (!session_id()) session_start();
291
 
 
292
  if (!isset ($_GET [AI_URL_DEBUG]))
293
- if ((isset ($_GET [AI_URL_DEBUG_PROCESSING]) && $_GET [AI_URL_DEBUG_PROCESSING] == 1) || (isset ($_SESSION ['AI_WP_DEBUGGING']) && ($_SESSION ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING) != 0)) {
294
- $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
295
- $ai_last_time = microtime ();
296
- $ai_processing_log = array ();
297
- ai_log ("INITIALIZATION START");
 
 
 
 
 
298
  }
299
 
300
  $ad_interter_globals = array ();
@@ -506,8 +518,11 @@ function set_user () {
506
  if ($ai_wp_data [AI_WP_USER] != AI_USER_NOT_SET) return;
507
 
508
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
 
509
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
510
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
 
 
511
  }
512
 
513
  function set_page_type () {
@@ -534,17 +549,19 @@ function ai_log_message ($message) {
534
  function ai_log_filter_content ($content_string) {
535
 
536
  $content_string = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $content_string);
537
- return str_replace (array ("<!--", "-->", "\n", "\r"), "", $content_string);
538
  }
539
 
540
  function ai_log_content (&$content) {
541
- if (strlen ($content) < 100) ai_log (ai_log_filter_content ($content) . ' ['.strlen ($content).']');
542
- ai_log (ai_log_filter_content (substr ($content, 0, 60)) . ' ... ' . ai_log_filter_content (substr ($content, - 60)) . ' ['.number_of_words ($content).']');
543
  }
544
 
545
  function ai_log_block_status ($block, $ai_last_check) {
546
  global $block_object;
547
 
 
 
548
  if ($ai_last_check == AI_CHECK_INSERTED) return "BLOCK $block INSERTED";
549
  $status = "BLOCK $block FAILED CHECK: ";
550
  $obj = $block_object [$block];
@@ -676,12 +693,10 @@ function ai_wp_hook () {
676
  set_page_type ();
677
  set_user ();
678
 
679
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN)
680
- add_action( 'admin_bar_menu', 'ai_toolbar', 20);
681
-
682
- if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
683
 
684
- $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0;
685
 
686
  if (!session_id()) session_start();
687
 
@@ -1195,7 +1210,9 @@ function ai_write_debug_info ($write_processing_log = false) {
1195
  case AI_OPTION_PARAGRAPH_TEXT:
1196
  case AI_OPTION_AVOID_TEXT_ABOVE:
1197
  case AI_OPTION_AVOID_TEXT_BELOW:
1198
- $settings .= " " . $key . ": " . html_entity_decode ($obj->wp_options [$key]);
 
 
1199
  break;
1200
  default:
1201
  $settings .= " " . $key . ": " . $obj->wp_options [$key];
@@ -1260,6 +1277,26 @@ function ai_write_debug_info ($write_processing_log = false) {
1260
  foreach ($ai_processing_log as $log_line) {
1261
  echo $log_line, "\n";
1262
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  }
1264
  }
1265
 
@@ -1304,6 +1341,7 @@ function ai_check_plugin_options ($plugin_options = array ()) {
1304
  }
1305
  $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
1306
 
 
1307
  if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
1308
  if (!isset ($plugin_options ['JAVASCRIPT_DEBUGGING'])) $plugin_options ['JAVASCRIPT_DEBUGGING'] = DEFAULT_JAVASCRIPT_DEBUGGING;
1309
 
@@ -1448,6 +1486,18 @@ function get_plugin_priority () {
1448
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
1449
  }
1450
 
 
 
 
 
 
 
 
 
 
 
 
 
1451
  function get_remote_debugging () {
1452
  global $ai_db_options;
1453
 
@@ -1895,6 +1945,7 @@ function ai_settings () {
1895
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
1896
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
1897
  $options ['PLUGIN_PRIORITY'] = filter_option ('plugin_priority', $_POST ['plugin_priority']);
 
1898
  $options ['REMOTE_DEBUGGING'] = filter_option ('remote_debugging', $_POST ['remote_debugging']);
1899
  $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('javascript_debugging', $_POST ['javascript_debugging']);
1900
 
@@ -2073,6 +2124,8 @@ function ai_content_hook ($content = ''){
2073
  foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2074
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2075
 
 
 
2076
  $current_block = $block;
2077
 
2078
  $obj = $block_object [$block];
@@ -2204,6 +2257,8 @@ function ai_excerpt_hook ($content = ''){
2204
  foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2205
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2206
 
 
 
2207
  $current_block = $block;
2208
  $obj = $block_object [$block];
2209
  $obj->clear_code_cache ();
@@ -2302,6 +2357,8 @@ function ai_before_after_post ($query, $display_type){
2302
  foreach ($ai_db_options_extract [$display_type == AD_SELECT_BEFORE_POST ? LOOP_START_HOOK_BLOCKS : LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2303
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2304
 
 
 
2305
  $current_block = $block;
2306
 
2307
  $obj = $block_object [$block];
@@ -2359,16 +2416,29 @@ function process_shortcode (&$block, $atts) {
2359
  $block = intval ($parameters ['block']);
2360
  } elseif ($parameters ['name'] != '') {
2361
  $shortcode_name = strtolower ($parameters ['name']);
2362
- for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
2363
- $obj = $block_object [$counter];
2364
- $ad_name = strtolower (trim ($obj->get_ad_name()));
2365
- if ($shortcode_name == $ad_name) {
2366
- $block = $counter;
2367
- break;
 
 
2368
  }
2369
  }
2370
  }
2371
 
 
 
 
 
 
 
 
 
 
 
 
2372
  $ai_last_check = AI_CHECK_SHORTCODE_ATTRIBUTES;
2373
  if ($block < 1 || $block > AD_INSERTER_BLOCKS) return "";
2374
 
@@ -2409,7 +2479,13 @@ function process_shortcodes ($atts) {
2409
  global $ai_last_check, $ai_wp_data;
2410
 
2411
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2412
- if ($debug_processing) ai_log ("PROCESS SHORTCODES ".serialize ($atts));
 
 
 
 
 
 
2413
  $ai_last_check = AI_CHECK_NONE;
2414
  $block = - 1;
2415
  $shortcode = process_shortcode ($block, $atts);
@@ -2508,7 +2584,7 @@ function ai_widget_draw ($args, $instance, &$block) {
2508
  $block = isset ($instance ['block']) ? $instance ['block'] : 1;
2509
 
2510
  if ($block == 0) {
2511
- if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
2512
  ai_widget_draw_debugger ($args, $instance, $block);
2513
  return;
2514
  }
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.0.3
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.0.3 - 26 September 2016
15
+ - Debugging functions in admin toolbar available only for administrators
16
+ - Added option to hide debugging functions in admin toolbar
17
+ - Added shortcode for debugger
18
+ - Few minor bug fixes
19
+
20
  Ad Inserter 2.0.2 - 25 September 2016
21
  - Changed javascript version check to get plugin version from the HTML page
22
  - Added warning if old cached version of CSS file is loaded on the settings page
295
 
296
  if (!session_id()) session_start();
297
 
298
+
299
  if (!isset ($_GET [AI_URL_DEBUG]))
300
+ if (isset ($_GET [AI_URL_DEBUG_PROCESSING]) || (isset ($_SESSION ['AI_WP_DEBUGGING']) && ($_SESSION ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING) != 0)) {
301
+ if (isset ($_GET [AI_URL_DEBUG_PROCESSING]) && $_GET [AI_URL_DEBUG_PROCESSING] == 0) {
302
+ $_SESSION ['AI_WP_DEBUGGING'] &= ~AI_DEBUG_PROCESSING;
303
+ } else {
304
+ $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
305
+ $_SESSION ['AI_WP_DEBUGGING'] |= AI_DEBUG_PROCESSING;
306
+ $ai_last_time = microtime ();
307
+ $ai_processing_log = array ();
308
+ ai_log ("INITIALIZATION START");
309
+ }
310
  }
311
 
312
  $ad_interter_globals = array ();
518
  if ($ai_wp_data [AI_WP_USER] != AI_USER_NOT_SET) return;
519
 
520
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
521
+
522
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
523
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
524
+
525
+ if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
526
  }
527
 
528
  function set_page_type () {
549
  function ai_log_filter_content ($content_string) {
550
 
551
  $content_string = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $content_string);
552
+ return str_replace (array ("<!--", "-->", "\n", "\r"), array ("[!--", "--]", "*n", "*r"), $content_string);
553
  }
554
 
555
  function ai_log_content (&$content) {
556
+ if (strlen ($content) < 100) ai_log (ai_log_filter_content ($content) . ' ['.number_of_words ($content).']'); else
557
+ ai_log (ai_log_filter_content (substr ($content, 0, 60)) . ' ... ' . ai_log_filter_content (substr ($content, - 60)) . ' ['.number_of_words ($content).']');
558
  }
559
 
560
  function ai_log_block_status ($block, $ai_last_check) {
561
  global $block_object;
562
 
563
+ if ($block < 1 || $block > AD_INSERTER_BLOCKS) $block = 0;
564
+
565
  if ($ai_last_check == AI_CHECK_INSERTED) return "BLOCK $block INSERTED";
566
  $status = "BLOCK $block FAILED CHECK: ";
567
  $obj = $block_object [$block];
693
  set_page_type ();
694
  set_user ();
695
 
696
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_admin_toolbar_debugging ())
697
+ add_action ('admin_bar_menu', 'ai_toolbar', 20);
 
 
698
 
699
+ $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
700
 
701
  if (!session_id()) session_start();
702
 
1210
  case AI_OPTION_PARAGRAPH_TEXT:
1211
  case AI_OPTION_AVOID_TEXT_ABOVE:
1212
  case AI_OPTION_AVOID_TEXT_BELOW:
1213
+ if ($write_processing_log)
1214
+ $settings .= " " . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])); else
1215
+ $settings .= " " . $key . ": " . $obj->wp_options [$key];
1216
  break;
1217
  default:
1218
  $settings .= " " . $key . ": " . $obj->wp_options [$key];
1277
  foreach ($ai_processing_log as $log_line) {
1278
  echo $log_line, "\n";
1279
  }
1280
+
1281
+ echo "PHP: ", phpversion(), "\n";
1282
+ global $wp_version;
1283
+ echo "Wordpress: ", $wp_version, "\n";
1284
+ $current_theme = wp_get_theme();
1285
+
1286
+ echo "Current Theme: ", $current_theme->get ('Name') . " " . $current_theme->get ('Version'), "\n";
1287
+ echo "\n";
1288
+ echo "A INSTALLED PLUGINS\n";
1289
+ echo "======================================\n";
1290
+
1291
+ if ( ! function_exists( 'get_plugins' ) ) {
1292
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1293
+ }
1294
+ $all_plugins = get_plugins();
1295
+ $active_plugins = get_option ('active_plugins');
1296
+ foreach ($all_plugins as $plugin_path => $plugin) {
1297
+ // echo sprintf ("%s %-40s %s\n", in_array ($plugin_path, $active_plugins) ? '*' : ' ', $plugin ["Name"], $plugin ["Version"]);
1298
+ echo in_array ($plugin_path, $active_plugins) ? '* ' : ' ', $plugin ["Name"], ' ', $plugin ["Version"], "\n";
1299
+ }
1300
  }
1301
  }
1302
 
1341
  }
1342
  $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
1343
 
1344
+ if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
1345
  if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
1346
  if (!isset ($plugin_options ['JAVASCRIPT_DEBUGGING'])) $plugin_options ['JAVASCRIPT_DEBUGGING'] = DEFAULT_JAVASCRIPT_DEBUGGING;
1347
 
1486
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
1487
  }
1488
 
1489
+ function get_admin_toolbar_debugging () {
1490
+ global $ai_db_options;
1491
+
1492
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1493
+
1494
+ if (!isset ($plugin_db_options ['ADMIN_TOOLBAR_DEBUGGING']) || $plugin_db_options ['ADMIN_TOOLBAR_DEBUGGING'] == '') {
1495
+ $plugin_db_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
1496
+ }
1497
+
1498
+ return ($plugin_db_options ['ADMIN_TOOLBAR_DEBUGGING']);
1499
+ }
1500
+
1501
  function get_remote_debugging () {
1502
  global $ai_db_options;
1503
 
1945
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
1946
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
1947
  $options ['PLUGIN_PRIORITY'] = filter_option ('plugin_priority', $_POST ['plugin_priority']);
1948
+ $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('admin_toolbar_debugging', $_POST ['admin_toolbar_debugging']);
1949
  $options ['REMOTE_DEBUGGING'] = filter_option ('remote_debugging', $_POST ['remote_debugging']);
1950
  $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('javascript_debugging', $_POST ['javascript_debugging']);
1951
 
2124
  foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2125
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2126
 
2127
+ if (!isset ($block_object [$block])) continue;
2128
+
2129
  $current_block = $block;
2130
 
2131
  $obj = $block_object [$block];
2257
  foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2258
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2259
 
2260
+ if (!isset ($block_object [$block])) continue;
2261
+
2262
  $current_block = $block;
2263
  $obj = $block_object [$block];
2264
  $obj->clear_code_cache ();
2357
  foreach ($ai_db_options_extract [$display_type == AD_SELECT_BEFORE_POST ? LOOP_START_HOOK_BLOCKS : LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2358
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2359
 
2360
+ if (!isset ($block_object [$block])) continue;
2361
+
2362
  $current_block = $block;
2363
 
2364
  $obj = $block_object [$block];
2416
  $block = intval ($parameters ['block']);
2417
  } elseif ($parameters ['name'] != '') {
2418
  $shortcode_name = strtolower ($parameters ['name']);
2419
+ if ($shortcode_name == 'debugger') $block = 0; else {
2420
+ for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
2421
+ $obj = $block_object [$counter];
2422
+ $ad_name = strtolower (trim ($obj->get_ad_name()));
2423
+ if ($shortcode_name == $ad_name) {
2424
+ $block = $counter;
2425
+ break;
2426
+ }
2427
  }
2428
  }
2429
  }
2430
 
2431
+ if ($block == 0) {
2432
+ if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
2433
+ ob_start ();
2434
+ echo "<pre style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
2435
+ ai_write_debug_info ();
2436
+ echo "</pre>";
2437
+ return ob_get_clean ();
2438
+ }
2439
+ return "";
2440
+ }
2441
+
2442
  $ai_last_check = AI_CHECK_SHORTCODE_ATTRIBUTES;
2443
  if ($block < 1 || $block > AD_INSERTER_BLOCKS) return "";
2444
 
2479
  global $ai_last_check, $ai_wp_data;
2480
 
2481
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2482
+ if ($debug_processing) {
2483
+ $atts_string = '';
2484
+ foreach ($atts as $index => $att) {
2485
+ $atts_string .= $index . '="'.$att.'" ';
2486
+ }
2487
+ ai_log ("PROCESS SHORTCODES [adinserter ".trim ($atts_string).']');
2488
+ }
2489
  $ai_last_check = AI_CHECK_NONE;
2490
  $block = - 1;
2491
  $shortcode = process_shortcode ($block, $atts);
2584
  $block = isset ($instance ['block']) ? $instance ['block'] : 1;
2585
 
2586
  if ($block == 0) {
2587
+ if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0)
2588
  ai_widget_draw_debugger ($args, $instance, $block);
2589
  return;
2590
  }
constants.php CHANGED
@@ -11,7 +11,7 @@ if (!defined( 'AD_INSERTER_NAME'))
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '2.0.2');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
@@ -236,6 +236,7 @@ define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
236
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
237
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
238
  define ('DEFAULT_PARAGRAPH_TAGS', 'p');
 
239
  define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
240
  define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
241
  define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '2.0.3');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
236
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
237
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
238
  define ('DEFAULT_PARAGRAPH_TAGS', 'p');
239
+ define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AD_SETTINGS_CHECKED);
240
  define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
241
  define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
242
  define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #data {
2
- font-family: "2.0.2"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #data {
2
+ font-family: "2.0.3"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.0.2";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
1
+ var javascript_version = "2.0.3";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, banner rotation, multisite, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
- Stable tag: 2.0.1
8
  License: GPLv3
9
 
10
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
@@ -327,7 +327,7 @@ Some security plugins like WP Security or Wordfence may also detect Ad Inserter
327
 
328
  Caching on the frontend side (what visitors see) does speed up page loading but may cause some unwanted behavior.
329
  When you are using caching, Wordpress creates page, Ad Inseter is called to do the job and the created page is saved for quicker serving.
330
- The next time **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions do not work properly because Ad Inserter is not called when the page is cached:
331
 
332
  * Block rotation with `|rotate|`
333
  * User check
@@ -338,7 +338,7 @@ The next time **the visitor gets cached (saved) page **. Because of this some Ad
338
  When you need the functions listed above you have to switch off caching.
339
 
340
  Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
341
- The problem can occur when the plugin is updated since it also provides new javascript and CSS files.
342
  In order to prevent browsers from loading old js/css files the plugin appends version info as query parameter to js and css files needed.
343
 
344
  For example, in the source code of the settings page it should be like this:
@@ -369,8 +369,9 @@ Ad Inserter has many debugging functions that can help you to diagnose the probl
369
 
370
  * Code preview: click on the Preview button for each code block to see how the ad or code will look like. On the Preview window click on the Highlight button to highlight code. If you don't see display of the code here it is very likely that the code is not working properly.
371
  * Debugger Widget: Place Debugger widget in some widget area to see basic Wordpress page and Ad Inserter data (User status, Page Type, Post ID, Url, Referer, etc). With this widget you can also check saved block settings and client-side viewport name.
 
372
 
373
- Each post/page has a Wordpress toolbar on the top. Ad Inserter menu item has the following debugging functions:
374
 
375
  * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the broswer to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
376
  * Show Positions: Enable this function to show available positions for automatic display. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
@@ -390,7 +391,7 @@ When browsing other pages on the website debuggins settings are temporarily save
390
 
391
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
392
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
393
- Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging is always enabled.
394
 
395
  **MULTISITE**
396
 
@@ -803,6 +804,13 @@ AD CODE RIGHT
803
 
804
  == Changelog ==
805
 
 
 
 
 
 
 
 
806
  = 2.0.2 =
807
  - Changed javascript version check to get plugin version from the HTML page
808
  - Added warning if old cached version of CSS file is loaded on the settings page
@@ -1046,6 +1054,12 @@ AD CODE RIGHT
1046
 
1047
  == Upgrade Notice ==
1048
 
 
 
 
 
 
 
1049
  = 2.0.2 =
1050
  Changed javascript version check to get plugin version from the HTML page;
1051
  Added warning if old cached version of CSS file is loaded on the settings page;
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, banner rotation, multisite, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
+ Stable tag: 2.0.2
8
  License: GPLv3
9
 
10
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
327
 
328
  Caching on the frontend side (what visitors see) does speed up page loading but may cause some unwanted behavior.
329
  When you are using caching, Wordpress creates page, Ad Inseter is called to do the job and the created page is saved for quicker serving.
330
+ The next time the page is visited **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
331
 
332
  * Block rotation with `|rotate|`
333
  * User check
338
  When you need the functions listed above you have to switch off caching.
339
 
340
  Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
341
+ The problem can occur when the plugin is updated since the new plugin also provides new javascript and CSS files.
342
  In order to prevent browsers from loading old js/css files the plugin appends version info as query parameter to js and css files needed.
343
 
344
  For example, in the source code of the settings page it should be like this:
369
 
370
  * Code preview: click on the Preview button for each code block to see how the ad or code will look like. On the Preview window click on the Highlight button to highlight code. If you don't see display of the code here it is very likely that the code is not working properly.
371
  * Debugger Widget: Place Debugger widget in some widget area to see basic Wordpress page and Ad Inserter data (User status, Page Type, Post ID, Url, Referer, etc). With this widget you can also check saved block settings and client-side viewport name.
372
+ * Debugger Shortcode: Place shortcode [adinserter block="0"] or [adinserter name="Debugger"] into post or static page to see basic Wordpress page and Ad Inserter data
373
 
374
+ Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:
375
 
376
  * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the broswer to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
377
  * Show Positions: Enable this function to show available positions for automatic display. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
391
 
392
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
393
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
394
+ Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging via url is always enabled.
395
 
396
  **MULTISITE**
397
 
804
 
805
  == Changelog ==
806
 
807
+
808
+ = 2.0.3 =
809
+ - Debugging functions in admin toolbar available only for administrators
810
+ - Added option to hide debugging functions in admin toolbar
811
+ - Added shortcode for debugger
812
+ - Few minor bug fixes
813
+
814
  = 2.0.2 =
815
  - Changed javascript version check to get plugin version from the HTML page
816
  - Added warning if old cached version of CSS file is loaded on the settings page
1054
 
1055
  == Upgrade Notice ==
1056
 
1057
+ = 2.0.3 =
1058
+ Debugging functions in admin toolbar available only for administrators;
1059
+ Added option to hide debugging functions in admin toolbar;
1060
+ Added shortcode for debugger;
1061
+ Few minor bug fixes
1062
+
1063
  = 2.0.2 =
1064
  Changed javascript version check to get plugin version from the HTML page;
1065
  Added warning if old cached version of CSS file is loaded on the settings page;
settings.php CHANGED
@@ -1167,16 +1167,24 @@ function generate_settings_form (){
1167
  <?php if (function_exists ('ai_multisite_settings')) ai_multisite_settings (); ?>
1168
 
1169
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
 
 
 
 
 
 
1170
  <div style="margin: 8px;">
1171
  <input style="border-radius: 5px;" type="hidden" name="remote_debugging" value="0" />
1172
- <input style="border-radius: 5px;" type="checkbox" name="remote_debugging"id="remote-debugging" value="1" default="<?php echo DEFAULT_REMOTE_DEBUGGING; ?>" <?php if (get_remote_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1173
- <label for="remote-debugging" title="Enable Debugger widget and code insertion debugging (blocks, positions, tags, processing) by url parameters for non-logged in users. Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging is always enabled.">Remote debugging</label>
1174
  </div>
1175
 
1176
- <div id="system-debugging" style="margin: 8px; display: none;">
1177
- <input style="border-radius: 5px;" type="hidden" name="javascript_debugging" value="0" />
1178
- <input style="border-radius: 5px;" type="checkbox" name="javascript_debugging"id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1179
- <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
 
 
1180
  </div>
1181
  </div>
1182
 
1167
  <?php if (function_exists ('ai_multisite_settings')) ai_multisite_settings (); ?>
1168
 
1169
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1170
+ <div style="margin: 8px;">
1171
+ <input style="border-radius: 5px;" type="hidden" name="admin_toolbar_debugging" value="0" />
1172
+ <input style="border-radius: 5px;" type="checkbox" name="admin_toolbar_debugging" id="admin-toolbar-debugging" value="1" default="<?php echo DEFAULT_ADMIN_TOOLBAR_DEBUGGING; ?>" <?php if (get_admin_toolbar_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1173
+ <label for="admin-toolbar-debugging" title="Enable or disable debugging functions in admin toolbar">Debugging functions in admin toolbar</label>
1174
+ </div>
1175
+
1176
  <div style="margin: 8px;">
1177
  <input style="border-radius: 5px;" type="hidden" name="remote_debugging" value="0" />
1178
+ <input style="border-radius: 5px;" type="checkbox" name="remote_debugging" id="remote-debugging" value="1" default="<?php echo DEFAULT_REMOTE_DEBUGGING; ?>" <?php if (get_remote_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1179
+ <label for="remote-debugging" title="Enable Debugger widget and code insertion debugging (blocks, positions, tags, processing) by url parameters for non-logged in users. Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in administrators debugging is always enabled.">Remote debugging</label>
1180
  </div>
1181
 
1182
+ <div id="system-debugging" style="display: none;">
1183
+ <div style="margin: 8px;">
1184
+ <input style="border-radius: 5px;" type="hidden" name="javascript_debugging" value="0" />
1185
+ <input style="border-radius: 5px;" type="checkbox" name="javascript_debugging"id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1186
+ <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
1187
+ </div>
1188
  </div>
1189
  </div>
1190