Version Description
- Added option to insert ads between posts on blog pages
- Added option to check and manage post/page exceptions for each block
- Added option to check and manage all post/page exceptions (Pro only)
- Added option for multisite installations to disable PHP processing on sub-sites (Pro only)
- Added license status notifications (Pro only)
Download this release
Release Info
Developer | spacetime |
Plugin | Ad Inserter – WordPress Ads Management with AdSense Header Integration |
Version | 2.0.10 |
Comparing to | |
See all releases |
Code changes from version 2.0.9 to 2.0.10
- ad-inserter.php +233 -63
- class.php +51 -47
- constants.php +9 -1
- css/ad-inserter.css +19 -4
- js/ad-inserter.js +9 -1
- readme.txt +45 -13
- settings.php +80 -72
ad-inserter.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
-
Version: 2.0.
|
5 |
Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
|
6 |
Author: Igor Funa
|
7 |
Author URI: http://igorfuna.com/
|
@@ -11,8 +11,15 @@ Plugin URI: http://adinserter.pro/documentation
|
|
11 |
/*
|
12 |
Change Log
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
Ad Inserter 2.0.9 - 8 January 2017
|
15 |
-
- Added support for uppercase and lowercase {country_iso2} tag (Pro only)
|
16 |
- Removed inclusion of dummy css and js file
|
17 |
- Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache
|
18 |
|
@@ -311,7 +318,7 @@ if (version_compare ($wp_version, "4.0", "<")) {
|
|
311 |
exit ($exit_msg);
|
312 |
}
|
313 |
|
314 |
-
global $block_object, $ai_wp_data, $
|
315 |
|
316 |
//include required files
|
317 |
require_once AD_INSERTER_PLUGIN_DIR.'class.php';
|
@@ -351,7 +358,7 @@ if (!is_admin()) {
|
|
351 |
}
|
352 |
}
|
353 |
|
354 |
-
$
|
355 |
$block_object = array ();
|
356 |
|
357 |
ai_load_settings ();
|
@@ -421,7 +428,7 @@ if (isset ($_POST [AI_FORM_SAVE]))
|
|
421 |
add_action ('admin_menu', 'ai_admin_menu_hook');
|
422 |
|
423 |
add_action ('init', 'ai_init_hook');
|
424 |
-
|
425 |
|
426 |
add_action( 'wp', 'ai_wp_hook');
|
427 |
|
@@ -434,7 +441,9 @@ if ($adH->get_enable_manual () ||
|
|
434 |
if ($adF->get_enable_manual () || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE)
|
435 |
add_action ('wp_footer', 'ai_wp_footer_hook');
|
436 |
|
437 |
-
if (($
|
|
|
|
|
438 |
add_action ('shutdown', 'ai_shutdown_hook');
|
439 |
|
440 |
add_action ('widgets_init', 'ai_widgets_init_hook');
|
@@ -453,8 +462,6 @@ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
|
453 |
ai_log ("INITIALIZATION END\n");
|
454 |
}
|
455 |
|
456 |
-
|
457 |
-
|
458 |
function ai_toolbar ($wp_admin_bar) {
|
459 |
global $block_object, $ai_wp_data;
|
460 |
|
@@ -832,6 +839,9 @@ function ai_wp_hook () {
|
|
832 |
if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
|
833 |
add_action ('loop_end', 'ai_loop_end_hook');
|
834 |
|
|
|
|
|
|
|
835 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
836 |
$ai_total_plugin_time += microtime () - $start_time;
|
837 |
ai_log ("WP HOOK END\n");
|
@@ -871,7 +881,7 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
|
|
871 |
|
872 |
wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
|
873 |
|
874 |
-
|
875 |
|
876 |
if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
|
877 |
|
@@ -1112,10 +1122,12 @@ function ai_admin_notice_hook () {
|
|
1112 |
// }
|
1113 |
|
1114 |
// if (!empty ($sidebars_with_deprecated_widgets)) {
|
1115 |
-
// echo "<div class='
|
1116 |
// implode (", ", $sidebars_with_deprecated_widgets),
|
1117 |
-
// ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</div>";
|
1118 |
// }
|
|
|
|
|
1119 |
}
|
1120 |
|
1121 |
function ai_plugin_action_links ($links) {
|
@@ -1271,18 +1283,20 @@ function ai_meta_box_callback ($post) {
|
|
1271 |
echo 'Disabled on all ', $post_type, 's';
|
1272 |
}
|
1273 |
echo ' </td>';
|
1274 |
-
|
1275 |
echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
|
1276 |
-
|
1277 |
-
echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
|
1278 |
-
// else echo 'No exceptions';
|
1279 |
-
echo '<label for="ai-selected-block-', $block, '">';
|
1280 |
if ($individual_option_enabled) {
|
|
|
|
|
1281 |
if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
|
|
|
|
|
|
1285 |
|
|
|
1286 |
echo '</tr>';
|
1287 |
$rows ++;
|
1288 |
}
|
@@ -1391,7 +1405,9 @@ function ai_wp_footer_hook () {
|
|
1391 |
function ai_write_debug_info ($write_processing_log = false) {
|
1392 |
global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options;
|
1393 |
|
1394 |
-
echo sprintf ("%-25s%s
|
|
|
|
|
1395 |
echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
|
1396 |
echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
|
1397 |
echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2) , " ms\n";
|
@@ -1544,6 +1560,8 @@ function ai_write_debug_info ($write_processing_log = false) {
|
|
1544 |
echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
|
1545 |
if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
|
1546 |
echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
|
|
|
|
|
1547 |
|
1548 |
|
1549 |
echo "\nPAGE TYPE BLOCKS\n";
|
@@ -1555,6 +1573,8 @@ function ai_write_debug_info ($write_processing_log = false) {
|
|
1555 |
echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
|
1556 |
if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
|
1557 |
echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
|
|
|
|
|
1558 |
|
1559 |
if ($write_processing_log) {
|
1560 |
echo "\nTIME EVENT\n";
|
@@ -1588,15 +1608,26 @@ function ai_write_debug_info ($write_processing_log = false) {
|
|
1588 |
function ai_shutdown_hook () {
|
1589 |
global $ai_wp_data;
|
1590 |
|
1591 |
-
if (
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1595 |
}
|
1596 |
|
1597 |
function ai_check_multisite_options (&$multisite_options) {
|
1598 |
if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
|
1599 |
if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
|
|
|
1600 |
if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
|
1601 |
if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
|
1602 |
}
|
@@ -1861,6 +1892,20 @@ function multisite_widgets_enabled () {
|
|
1861 |
return DEFAULT_MULTISITE_WIDGETS;
|
1862 |
}
|
1863 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1864 |
function multisite_exceptions_enabled () {
|
1865 |
global $ai_db_options_multisite;
|
1866 |
|
@@ -2083,11 +2128,13 @@ function ai_generate_extract (&$settings) {
|
|
2083 |
$excerpt_hook_blocks = array ();
|
2084 |
$loop_start_hook_blocks = array ();
|
2085 |
$loop_end_hook_blocks = array ();
|
|
|
2086 |
|
2087 |
$content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2088 |
$excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2089 |
$loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2090 |
$loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
|
|
2091 |
|
2092 |
// Generate extracted data
|
2093 |
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
@@ -2129,6 +2176,10 @@ function ai_generate_extract (&$settings) {
|
|
2129 |
foreach ($page_types as $block_page_type) $loop_end_hook_blocks [$block_page_type][]= $block;
|
2130 |
$loop_end_hook_blocks [AI_PT_ANY][]= $block;
|
2131 |
break;
|
|
|
|
|
|
|
|
|
2132 |
}
|
2133 |
}
|
2134 |
}
|
@@ -2137,6 +2188,7 @@ function ai_generate_extract (&$settings) {
|
|
2137 |
$extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
|
2138 |
$extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
|
2139 |
$extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
|
|
|
2140 |
|
2141 |
return ($extract);
|
2142 |
}
|
@@ -2148,7 +2200,7 @@ function ai_load_settings () {
|
|
2148 |
|
2149 |
ai_load_options ();
|
2150 |
|
2151 |
-
if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) && $ai_db_options ['global']['VERSION'] == $version_string)
|
2152 |
$ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
|
2153 |
$ai_db_options_extract = ai_generate_extract ($ai_db_options);
|
2154 |
|
@@ -2360,6 +2412,7 @@ function ai_settings () {
|
|
2360 |
$options = array ();
|
2361 |
$options ['MULTISITE_SETTINGS_PAGE'] = filter_option ('multisite_settings_page', $_POST ['multisite_settings_page']);
|
2362 |
$options ['MULTISITE_WIDGETS'] = filter_option ('multisite_widgets', $_POST ['multisite_widgets']);
|
|
|
2363 |
$options ['MULTISITE_EXCEPTIONS'] = filter_option ('multisite_exceptions', $_POST ['multisite_exceptions']);
|
2364 |
$options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = filter_option ('multisite_main_for_all_blogs', $_POST ['multisite_main_for_all_blogs']);
|
2365 |
|
@@ -2375,7 +2428,7 @@ function ai_settings () {
|
|
2375 |
delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
|
2376 |
delete_option (AD_OPTIONS);
|
2377 |
|
2378 |
-
echo "<div class='
|
2379 |
|
2380 |
} elseif (isset ($_POST [AI_FORM_CLEAR])) {
|
2381 |
|
@@ -2395,9 +2448,41 @@ function ai_settings () {
|
|
2395 |
delete_site_option (WP_OPTION_NAME, $options);
|
2396 |
}
|
2397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2398 |
ai_load_settings ();
|
2399 |
|
2400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2401 |
}
|
2402 |
|
2403 |
generate_settings_form ();
|
@@ -2405,7 +2490,7 @@ function ai_settings () {
|
|
2405 |
|
2406 |
|
2407 |
function ai_adinserter ($ad_number = '', $ignore = ''){
|
2408 |
-
global $block_object, $
|
2409 |
|
2410 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2411 |
|
@@ -2416,11 +2501,11 @@ function ai_adinserter ($ad_number = '', $ignore = ''){
|
|
2416 |
|
2417 |
$globals_name = AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ad_number;
|
2418 |
|
2419 |
-
if (!isset ($
|
2420 |
-
$
|
2421 |
-
} else $
|
2422 |
|
2423 |
-
if ($debug_processing) ai_log ("PHP FUNCTION CALL adinserter ($ad_number".($ignore == '' ? '' : ', \''.$ignore)."') [" . $
|
2424 |
|
2425 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_PHP_FUNCTION;
|
2426 |
|
@@ -2436,7 +2521,7 @@ function ai_adinserter ($ad_number = '', $ignore = ''){
|
|
2436 |
if (!$obj->get_enable_php_call ()) return "";
|
2437 |
if (!$obj->check_server_side_detection ()) return "";
|
2438 |
if (!$obj->check_page_types_lists_users (in_array ("page_type", $ignore_array))) return "";
|
2439 |
-
if (!$obj->check_filter ($
|
2440 |
|
2441 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2442 |
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
@@ -2476,19 +2561,19 @@ function adinserter ($block = '', $ignore = '') {
|
|
2476 |
|
2477 |
|
2478 |
function ai_content_hook ($content = '') {
|
2479 |
-
global $block_object, $
|
2480 |
|
2481 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
2482 |
|
2483 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2484 |
$globals_name = AI_CONTENT_COUNTER_NAME;
|
2485 |
|
2486 |
-
if (!isset ($
|
2487 |
-
$
|
2488 |
-
} else $
|
2489 |
|
2490 |
if ($debug_processing) {
|
2491 |
-
ai_log ("CONTENT HOOK START [" . $
|
2492 |
$start_time = microtime ();
|
2493 |
}
|
2494 |
|
@@ -2509,8 +2594,11 @@ function ai_content_hook ($content = '') {
|
|
2509 |
if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
|
2510 |
if ($debug_processing) ai_log_content ($content);
|
2511 |
|
2512 |
-
|
2513 |
-
$
|
|
|
|
|
|
|
2514 |
|
2515 |
$ai_last_check = AI_CHECK_NONE;
|
2516 |
$current_block = 0;
|
@@ -2535,7 +2623,7 @@ function ai_content_hook ($content = '') {
|
|
2535 |
if (!$obj->check_server_side_detection ()) continue;
|
2536 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2537 |
if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
|
2538 |
-
if (!$obj->check_filter ($
|
2539 |
if (!$obj->check_number_of_words ($content)) continue;
|
2540 |
|
2541 |
// Deprecated
|
@@ -2611,7 +2699,7 @@ function ai_content_hook ($content = '') {
|
|
2611 |
$content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section style='$style'>BEFORE PARAGRAPH $1</section>", $content);
|
2612 |
$content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section style='$style'>AFTER PARAGRAPH $1</section>", $content);
|
2613 |
|
2614 |
-
$counter = $
|
2615 |
if ($counter == 1) $counter = '';
|
2616 |
|
2617 |
$content = "<section style='$style'><a style='float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0;'>".$content_words." words</a>BEFORE CONTENT ".$counter."<a style='float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0;'>".$content_words." words</a></section>". $content;
|
@@ -2633,19 +2721,19 @@ function ai_content_hook ($content = '') {
|
|
2633 |
|
2634 |
// Process Before/After Excerpt postion
|
2635 |
function ai_excerpt_hook ($content = '') {
|
2636 |
-
global $
|
2637 |
|
2638 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
2639 |
|
2640 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2641 |
$globals_name = AI_EXCERPT_COUNTER_NAME;
|
2642 |
|
2643 |
-
if (!isset ($
|
2644 |
-
$
|
2645 |
-
} else $
|
2646 |
|
2647 |
if ($debug_processing) {
|
2648 |
-
ai_log ("EXCERPT HOOK START [" . $
|
2649 |
$start_time = microtime ();
|
2650 |
}
|
2651 |
|
@@ -2665,7 +2753,7 @@ function ai_excerpt_hook ($content = '') {
|
|
2665 |
|
2666 |
if (!$obj->check_server_side_detection ()) continue;
|
2667 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2668 |
-
if (!$obj->check_filter ($
|
2669 |
|
2670 |
// Deprecated
|
2671 |
$ai_last_check = AI_CHECK_DISABLED_MANUALLY;
|
@@ -2691,7 +2779,7 @@ function ai_excerpt_hook ($content = '') {
|
|
2691 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
2692 |
$style = AI_DEBUG_POSITIONS_STYLE;
|
2693 |
|
2694 |
-
$content = "<section style='$style'>BEFORE EXCERPT ".$
|
2695 |
|
2696 |
// Color positions from the content hook
|
2697 |
$content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span style='color: blue;'> [$1] </span>", $content);
|
@@ -2722,7 +2810,7 @@ function ai_excerpt_hook ($content = '') {
|
|
2722 |
// Process Before / After Post postion
|
2723 |
|
2724 |
function ai_before_after_post ($query, $display_type) {
|
2725 |
-
global $block_object, $
|
2726 |
|
2727 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2728 |
|
@@ -2733,9 +2821,9 @@ function ai_before_after_post ($query, $display_type) {
|
|
2733 |
|
2734 |
$globals_name = $display_type == AD_SELECT_BEFORE_POST ? AI_LOOP_BEFORE_COUNTER_NAME : AI_LOOP_AFTER_COUNTER_NAME;
|
2735 |
|
2736 |
-
if (!isset ($
|
2737 |
-
$
|
2738 |
-
} else $
|
2739 |
|
2740 |
$ai_wp_data [AI_CONTEXT] = $display_type == AD_SELECT_BEFORE_POST ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST;
|
2741 |
|
@@ -2743,14 +2831,16 @@ function ai_before_after_post ($query, $display_type) {
|
|
2743 |
|
2744 |
$style = AI_DEBUG_POSITIONS_STYLE;
|
2745 |
|
2746 |
-
$counter = $
|
2747 |
if ($counter == 1) $counter = '';
|
2748 |
|
2749 |
echo "<section style='$style'>".($display_type == AD_SELECT_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
|
2750 |
}
|
2751 |
|
2752 |
-
$
|
2753 |
-
|
|
|
|
|
2754 |
|
2755 |
$ad_code = "";
|
2756 |
|
@@ -2770,7 +2860,7 @@ function ai_before_after_post ($query, $display_type) {
|
|
2770 |
if (!$obj->check_server_side_detection ()) continue;
|
2771 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2772 |
if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
|
2773 |
-
if (!$obj->check_filter ($
|
2774 |
|
2775 |
// Last check before insertion
|
2776 |
if (!$obj->check_and_increment_block_counter ()) continue;
|
@@ -2817,6 +2907,86 @@ function ai_loop_end_hook ($query){
|
|
2817 |
}
|
2818 |
}
|
2819 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2820 |
function process_shortcode (&$block, $atts) {
|
2821 |
global $block_object, $ai_last_check, $ai_wp_data;
|
2822 |
|
@@ -3005,7 +3175,7 @@ class ai_widget extends WP_Widget {
|
|
3005 |
|
3006 |
|
3007 |
function ai_widget_draw ($args, $instance, &$block) {
|
3008 |
-
global $block_object, $
|
3009 |
|
3010 |
$block = isset ($instance ['block']) ? $instance ['block'] : 1;
|
3011 |
|
@@ -3024,11 +3194,11 @@ function ai_widget_draw ($args, $instance, &$block) {
|
|
3024 |
|
3025 |
$globals_name = AI_WIDGET_COUNTER_NAME . $block;
|
3026 |
|
3027 |
-
if (!isset ($
|
3028 |
-
$
|
3029 |
-
} else $
|
3030 |
|
3031 |
-
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WIDGET (". $obj->number . ') ['.$
|
3032 |
|
3033 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
|
3034 |
|
@@ -3036,7 +3206,7 @@ function ai_widget_draw ($args, $instance, &$block) {
|
|
3036 |
if (!$obj->get_enable_widget ()) return;
|
3037 |
if (!$obj->check_server_side_detection ()) return;
|
3038 |
if (!$obj->check_page_types_lists_users ()) return;
|
3039 |
-
if (!$obj->check_filter ($
|
3040 |
|
3041 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
3042 |
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
+
Version: 2.0.10
|
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.10 - 26 January 2017
|
15 |
+
- Added option to insert ads between posts on blog pages
|
16 |
+
- Added option to check and manage post/page exceptions for each block
|
17 |
+
- Added option to check and manage all post/page exceptions (Pro only)
|
18 |
+
- Added option for multisite installations to disable PHP processing on sub-sites (Pro only)
|
19 |
+
- Added license status notifications (Pro only)
|
20 |
+
|
21 |
Ad Inserter 2.0.9 - 8 January 2017
|
22 |
+
- Added support for uppercase {country_ISO2} and lowercase {country_iso2} tag (Pro only)
|
23 |
- Removed inclusion of dummy css and js file
|
24 |
- Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache
|
25 |
|
318 |
exit ($exit_msg);
|
319 |
}
|
320 |
|
321 |
+
global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options;
|
322 |
|
323 |
//include required files
|
324 |
require_once AD_INSERTER_PLUGIN_DIR.'class.php';
|
358 |
}
|
359 |
}
|
360 |
|
361 |
+
$ad_inserter_globals = array ();
|
362 |
$block_object = array ();
|
363 |
|
364 |
ai_load_settings ();
|
428 |
add_action ('admin_menu', 'ai_admin_menu_hook');
|
429 |
|
430 |
add_action ('init', 'ai_init_hook');
|
431 |
+
add_action ('admin_notices', 'ai_admin_notice_hook');
|
432 |
|
433 |
add_action( 'wp', 'ai_wp_hook');
|
434 |
|
441 |
if ($adF->get_enable_manual () || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE)
|
442 |
add_action ('wp_footer', 'ai_wp_footer_hook');
|
443 |
|
444 |
+
if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
|
445 |
+
|
446 |
+
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
|
447 |
add_action ('shutdown', 'ai_shutdown_hook');
|
448 |
|
449 |
add_action ('widgets_init', 'ai_widgets_init_hook');
|
462 |
ai_log ("INITIALIZATION END\n");
|
463 |
}
|
464 |
|
|
|
|
|
465 |
function ai_toolbar ($wp_admin_bar) {
|
466 |
global $block_object, $ai_wp_data;
|
467 |
|
839 |
if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
|
840 |
add_action ('loop_end', 'ai_loop_end_hook');
|
841 |
|
842 |
+
if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
|
843 |
+
add_action ('the_post', 'ai_post_hook');
|
844 |
+
|
845 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
846 |
$ai_total_plugin_time += microtime () - $start_time;
|
847 |
ai_log ("WP HOOK END\n");
|
881 |
|
882 |
wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
|
883 |
|
884 |
+
wp_add_inline_style ('ai-admin', '.notice { margin: 5px 0 15px;}');
|
885 |
|
886 |
if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
|
887 |
|
1122 |
// }
|
1123 |
|
1124 |
// if (!empty ($sidebars_with_deprecated_widgets)) {
|
1125 |
+
// echo "<div class='notice notice-warning'><p><strong>Warning</strong>: You are using deprecated Ad Inserter widgets in the following sidebars: ",
|
1126 |
// implode (", ", $sidebars_with_deprecated_widgets),
|
1127 |
+
// ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</p></div>";
|
1128 |
// }
|
1129 |
+
|
1130 |
+
if (function_exists ('ai_admin_notices')) ai_admin_notices ();
|
1131 |
}
|
1132 |
|
1133 |
function ai_plugin_action_links ($links) {
|
1283 |
echo 'Disabled on all ', $post_type, 's';
|
1284 |
}
|
1285 |
echo ' </td>';
|
|
|
1286 |
echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
|
1287 |
+
|
|
|
|
|
|
|
1288 |
if ($individual_option_enabled) {
|
1289 |
+
echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
|
1290 |
+
echo '<label for="ai-selected-block-', $block, '">';
|
1291 |
if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
|
1292 |
+
echo '</label>';
|
1293 |
+
} else {
|
1294 |
+
if (in_array ($block, $selected_blocks)) {
|
1295 |
+
echo '<span style="margin-left: 6px;">•</span>';
|
1296 |
+
}
|
1297 |
+
}
|
1298 |
|
1299 |
+
echo ' </td>';
|
1300 |
echo '</tr>';
|
1301 |
$rows ++;
|
1302 |
}
|
1405 |
function ai_write_debug_info ($write_processing_log = false) {
|
1406 |
global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options;
|
1407 |
|
1408 |
+
echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
|
1409 |
+
if (function_exists ('ai_debug_header')) ai_debug_header ();
|
1410 |
+
echo "\n\n";
|
1411 |
echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
|
1412 |
echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
|
1413 |
echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2) , " ms\n";
|
1560 |
echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
|
1561 |
if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
|
1562 |
echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
|
1563 |
+
if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
|
1564 |
+
echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
|
1565 |
|
1566 |
|
1567 |
echo "\nPAGE TYPE BLOCKS\n";
|
1573 |
echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
|
1574 |
if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
|
1575 |
echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
|
1576 |
+
if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
|
1577 |
+
echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
|
1578 |
|
1579 |
if ($write_processing_log) {
|
1580 |
echo "\nTIME EVENT\n";
|
1608 |
function ai_shutdown_hook () {
|
1609 |
global $ai_wp_data;
|
1610 |
|
1611 |
+
if (function_exists ('ai_system_output')) ai_system_output ();
|
1612 |
+
|
1613 |
+
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
|
1614 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_HOMEPAGE ||
|
1615 |
+
$ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC ||
|
1616 |
+
$ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST ||
|
1617 |
+
$ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY ||
|
1618 |
+
$ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH ||
|
1619 |
+
$ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE) {
|
1620 |
+
echo "\n<!--\n\n";
|
1621 |
+
ai_write_debug_info (true);
|
1622 |
+
echo "\n-->\n";
|
1623 |
+
}
|
1624 |
+
}
|
1625 |
}
|
1626 |
|
1627 |
function ai_check_multisite_options (&$multisite_options) {
|
1628 |
if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
|
1629 |
if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
|
1630 |
+
if (!isset ($multisite_options ['MULTISITE_PHP_PROCESSING'])) $multisite_options ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
|
1631 |
if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
|
1632 |
if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
|
1633 |
}
|
1892 |
return DEFAULT_MULTISITE_WIDGETS;
|
1893 |
}
|
1894 |
|
1895 |
+
function multisite_php_processing () {
|
1896 |
+
global $ai_db_options_multisite;
|
1897 |
+
|
1898 |
+
if (is_multisite()) {
|
1899 |
+
if (!isset ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING']) || $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] == '') {
|
1900 |
+
$ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
|
1901 |
+
}
|
1902 |
+
|
1903 |
+
return ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING']);
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
return DEFAULT_MULTISITE_WIDGETS;
|
1907 |
+
}
|
1908 |
+
|
1909 |
function multisite_exceptions_enabled () {
|
1910 |
global $ai_db_options_multisite;
|
1911 |
|
2128 |
$excerpt_hook_blocks = array ();
|
2129 |
$loop_start_hook_blocks = array ();
|
2130 |
$loop_end_hook_blocks = array ();
|
2131 |
+
$post_hook_blocks = array ();
|
2132 |
|
2133 |
$content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2134 |
$excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2135 |
$loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2136 |
$loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2137 |
+
$post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array());
|
2138 |
|
2139 |
// Generate extracted data
|
2140 |
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
2176 |
foreach ($page_types as $block_page_type) $loop_end_hook_blocks [$block_page_type][]= $block;
|
2177 |
$loop_end_hook_blocks [AI_PT_ANY][]= $block;
|
2178 |
break;
|
2179 |
+
case AD_SELECT_BETWEEN_POSTS:
|
2180 |
+
foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block;
|
2181 |
+
$post_hook_blocks [AI_PT_ANY][]= $block;
|
2182 |
+
break;
|
2183 |
}
|
2184 |
}
|
2185 |
}
|
2188 |
$extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
|
2189 |
$extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
|
2190 |
$extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
|
2191 |
+
$extract [POST_HOOK_BLOCKS] = $post_hook_blocks;
|
2192 |
|
2193 |
return ($extract);
|
2194 |
}
|
2200 |
|
2201 |
ai_load_options ();
|
2202 |
|
2203 |
+
if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) && $ai_db_options ['global']['VERSION'] == $version_string && isset ($ai_db_options_extract [POST_HOOK_BLOCKS]))
|
2204 |
$ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
|
2205 |
$ai_db_options_extract = ai_generate_extract ($ai_db_options);
|
2206 |
|
2412 |
$options = array ();
|
2413 |
$options ['MULTISITE_SETTINGS_PAGE'] = filter_option ('multisite_settings_page', $_POST ['multisite_settings_page']);
|
2414 |
$options ['MULTISITE_WIDGETS'] = filter_option ('multisite_widgets', $_POST ['multisite_widgets']);
|
2415 |
+
$options ['MULTISITE_PHP_PROCESSING'] = filter_option ('multisite_php_processing', $_POST ['multisite_php_processing']);
|
2416 |
$options ['MULTISITE_EXCEPTIONS'] = filter_option ('multisite_exceptions', $_POST ['multisite_exceptions']);
|
2417 |
$options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = filter_option ('multisite_main_for_all_blogs', $_POST ['multisite_main_for_all_blogs']);
|
2418 |
|
2428 |
delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
|
2429 |
delete_option (AD_OPTIONS);
|
2430 |
|
2431 |
+
echo "<div class='notice notice-success is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings saved.</strong></p></div>";
|
2432 |
|
2433 |
} elseif (isset ($_POST [AI_FORM_CLEAR])) {
|
2434 |
|
2448 |
delete_site_option (WP_OPTION_NAME, $options);
|
2449 |
}
|
2450 |
|
2451 |
+
$args = array ( 'posts_per_page' => - 1);
|
2452 |
+
$pages = array_merge (get_pages (), get_posts ($args));
|
2453 |
+
foreach ($pages as $page) {
|
2454 |
+
delete_post_meta ($page->ID, '_adinserter_block_exceptions');
|
2455 |
+
}
|
2456 |
+
|
2457 |
ai_load_settings ();
|
2458 |
|
2459 |
+
if (function_exists ('ai_load_globals')) ai_load_globals ();
|
2460 |
+
|
2461 |
+
echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</p></div>";
|
2462 |
+
} elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
|
2463 |
+
$args = array ( 'posts_per_page' => - 1);
|
2464 |
+
$pages = array_merge (get_pages (), get_posts ($args));
|
2465 |
+
if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c") {
|
2466 |
+
foreach ($pages as $page) {
|
2467 |
+
delete_post_meta ($page->ID, '_adinserter_block_exceptions');
|
2468 |
+
}
|
2469 |
+
}
|
2470 |
+
elseif (strpos ($_POST [AI_FORM_CLEAR_EXCEPTIONS], 'id=') === 0) {
|
2471 |
+
$id = str_replace ('id=', '', $_POST [AI_FORM_CLEAR_EXCEPTIONS]);
|
2472 |
+
if (is_numeric ($id)) {
|
2473 |
+
delete_post_meta ($id, '_adinserter_block_exceptions');
|
2474 |
+
}
|
2475 |
+
}
|
2476 |
+
elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
|
2477 |
+
foreach ($pages as $page) {
|
2478 |
+
$post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
|
2479 |
+
$selected_blocks = explode (",", $post_meta);
|
2480 |
+
if (($key = array_search ($_POST [AI_FORM_CLEAR_EXCEPTIONS], $selected_blocks)) !== false) {
|
2481 |
+
unset ($selected_blocks [$key]);
|
2482 |
+
update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks));
|
2483 |
+
}
|
2484 |
+
}
|
2485 |
+
}
|
2486 |
}
|
2487 |
|
2488 |
generate_settings_form ();
|
2490 |
|
2491 |
|
2492 |
function ai_adinserter ($ad_number = '', $ignore = ''){
|
2493 |
+
global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
|
2494 |
|
2495 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2496 |
|
2501 |
|
2502 |
$globals_name = AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ad_number;
|
2503 |
|
2504 |
+
if (!isset ($ad_inserter_globals [$globals_name])) {
|
2505 |
+
$ad_inserter_globals [$globals_name] = 1;
|
2506 |
+
} else $ad_inserter_globals [$globals_name] ++;
|
2507 |
|
2508 |
+
if ($debug_processing) ai_log ("PHP FUNCTION CALL adinserter ($ad_number".($ignore == '' ? '' : ', \''.$ignore)."') [" . $ad_inserter_globals [$globals_name] . ']');
|
2509 |
|
2510 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_PHP_FUNCTION;
|
2511 |
|
2521 |
if (!$obj->get_enable_php_call ()) return "";
|
2522 |
if (!$obj->check_server_side_detection ()) return "";
|
2523 |
if (!$obj->check_page_types_lists_users (in_array ("page_type", $ignore_array))) return "";
|
2524 |
+
if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return "";
|
2525 |
|
2526 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2527 |
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2561 |
|
2562 |
|
2563 |
function ai_content_hook ($content = '') {
|
2564 |
+
global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
|
2565 |
|
2566 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
2567 |
|
2568 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2569 |
$globals_name = AI_CONTENT_COUNTER_NAME;
|
2570 |
|
2571 |
+
if (!isset ($ad_inserter_globals [$globals_name])) {
|
2572 |
+
$ad_inserter_globals [$globals_name] = 1;
|
2573 |
+
} else $ad_inserter_globals [$globals_name] ++;
|
2574 |
|
2575 |
if ($debug_processing) {
|
2576 |
+
ai_log ("CONTENT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
|
2577 |
$start_time = microtime ();
|
2578 |
}
|
2579 |
|
2594 |
if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
|
2595 |
if ($debug_processing) ai_log_content ($content);
|
2596 |
|
2597 |
+
|
2598 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2599 |
+
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2600 |
+
$selected_blocks = explode (",", $meta_value);
|
2601 |
+
} else $selected_blocks = array ();
|
2602 |
|
2603 |
$ai_last_check = AI_CHECK_NONE;
|
2604 |
$current_block = 0;
|
2623 |
if (!$obj->check_server_side_detection ()) continue;
|
2624 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2625 |
if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
|
2626 |
+
if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
|
2627 |
if (!$obj->check_number_of_words ($content)) continue;
|
2628 |
|
2629 |
// Deprecated
|
2699 |
$content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section style='$style'>BEFORE PARAGRAPH $1</section>", $content);
|
2700 |
$content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section style='$style'>AFTER PARAGRAPH $1</section>", $content);
|
2701 |
|
2702 |
+
$counter = $ad_inserter_globals [$globals_name];
|
2703 |
if ($counter == 1) $counter = '';
|
2704 |
|
2705 |
$content = "<section style='$style'><a style='float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0;'>".$content_words." words</a>BEFORE CONTENT ".$counter."<a style='float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0;'>".$content_words." words</a></section>". $content;
|
2721 |
|
2722 |
// Process Before/After Excerpt postion
|
2723 |
function ai_excerpt_hook ($content = '') {
|
2724 |
+
global $ad_inserter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
|
2725 |
|
2726 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
2727 |
|
2728 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2729 |
$globals_name = AI_EXCERPT_COUNTER_NAME;
|
2730 |
|
2731 |
+
if (!isset ($ad_inserter_globals [$globals_name])) {
|
2732 |
+
$ad_inserter_globals [$globals_name] = 1;
|
2733 |
+
} else $ad_inserter_globals [$globals_name] ++;
|
2734 |
|
2735 |
if ($debug_processing) {
|
2736 |
+
ai_log ("EXCERPT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
|
2737 |
$start_time = microtime ();
|
2738 |
}
|
2739 |
|
2753 |
|
2754 |
if (!$obj->check_server_side_detection ()) continue;
|
2755 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2756 |
+
if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
|
2757 |
|
2758 |
// Deprecated
|
2759 |
$ai_last_check = AI_CHECK_DISABLED_MANUALLY;
|
2779 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
2780 |
$style = AI_DEBUG_POSITIONS_STYLE;
|
2781 |
|
2782 |
+
$content = "<section style='$style'>BEFORE EXCERPT ".$ad_inserter_globals [$globals_name]."</section>". $content . "<section style='$style'>AFTER EXCERPT ".$ad_inserter_globals [$globals_name]."</section>";
|
2783 |
|
2784 |
// Color positions from the content hook
|
2785 |
$content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span style='color: blue;'> [$1] </span>", $content);
|
2810 |
// Process Before / After Post postion
|
2811 |
|
2812 |
function ai_before_after_post ($query, $display_type) {
|
2813 |
+
global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
|
2814 |
|
2815 |
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2816 |
|
2821 |
|
2822 |
$globals_name = $display_type == AD_SELECT_BEFORE_POST ? AI_LOOP_BEFORE_COUNTER_NAME : AI_LOOP_AFTER_COUNTER_NAME;
|
2823 |
|
2824 |
+
if (!isset ($ad_inserter_globals [$globals_name])) {
|
2825 |
+
$ad_inserter_globals [$globals_name] = 1;
|
2826 |
+
} else $ad_inserter_globals [$globals_name] ++;
|
2827 |
|
2828 |
$ai_wp_data [AI_CONTEXT] = $display_type == AD_SELECT_BEFORE_POST ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST;
|
2829 |
|
2831 |
|
2832 |
$style = AI_DEBUG_POSITIONS_STYLE;
|
2833 |
|
2834 |
+
$counter = $ad_inserter_globals [$globals_name];
|
2835 |
if ($counter == 1) $counter = '';
|
2836 |
|
2837 |
echo "<section style='$style'>".($display_type == AD_SELECT_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
|
2838 |
}
|
2839 |
|
2840 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2841 |
+
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2842 |
+
$selected_blocks = explode (",", $meta_value);
|
2843 |
+
} else $selected_blocks = array ();
|
2844 |
|
2845 |
$ad_code = "";
|
2846 |
|
2860 |
if (!$obj->check_server_side_detection ()) continue;
|
2861 |
if (!$obj->check_page_types_lists_users ()) continue;
|
2862 |
if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
|
2863 |
+
if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
|
2864 |
|
2865 |
// Last check before insertion
|
2866 |
if (!$obj->check_and_increment_block_counter ()) continue;
|
2907 |
}
|
2908 |
}
|
2909 |
|
2910 |
+
|
2911 |
+
// Process Between Posts postion
|
2912 |
+
function ai_post_hook ($post) {
|
2913 |
+
global $ai_wp_data, $ai_total_plugin_time;
|
2914 |
+
global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
|
2915 |
+
|
2916 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
2917 |
+
|
2918 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return;
|
2919 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return;
|
2920 |
+
|
2921 |
+
if (!in_the_loop()) return;
|
2922 |
+
|
2923 |
+
if (!isset ($ad_inserter_globals [AI_POST_COUNTER_NAME])) {
|
2924 |
+
$ad_inserter_globals [AI_POST_COUNTER_NAME] = 0;
|
2925 |
+
} else $ad_inserter_globals [AI_POST_COUNTER_NAME] ++;
|
2926 |
+
|
2927 |
+
if ($ad_inserter_globals [AI_POST_COUNTER_NAME] == 0) return;
|
2928 |
+
|
2929 |
+
$debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
|
2930 |
+
if ($debug_processing) {
|
2931 |
+
ai_log ('POST HOOK START [' . $ad_inserter_globals [AI_POST_COUNTER_NAME] . ']');
|
2932 |
+
$start_time = microtime ();
|
2933 |
+
}
|
2934 |
+
|
2935 |
+
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
|
2936 |
+
|
2937 |
+
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
2938 |
+
|
2939 |
+
$style = AI_DEBUG_POSITIONS_STYLE;
|
2940 |
+
|
2941 |
+
echo "<section style='$style'>BETWEEN POSTS ".$ad_inserter_globals [AI_POST_COUNTER_NAME]."</section>";
|
2942 |
+
}
|
2943 |
+
|
2944 |
+
// if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2945 |
+
// $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2946 |
+
// $selected_blocks = explode (",", $meta_value);
|
2947 |
+
// } else $selected_blocks = array ();
|
2948 |
+
|
2949 |
+
$ad_code = "";
|
2950 |
+
|
2951 |
+
$ai_last_check = AI_CHECK_NONE;
|
2952 |
+
$current_block = 0;
|
2953 |
+
|
2954 |
+
foreach ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
|
2955 |
+
if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
|
2956 |
+
|
2957 |
+
if (!isset ($block_object [$block])) continue;
|
2958 |
+
|
2959 |
+
$current_block = $block;
|
2960 |
+
|
2961 |
+
$obj = $block_object [$block];
|
2962 |
+
$obj->clear_code_cache ();
|
2963 |
+
|
2964 |
+
if (!$obj->check_server_side_detection ()) continue;
|
2965 |
+
if (!$obj->check_page_types_lists_users ()) continue;
|
2966 |
+
// if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
|
2967 |
+
if (!$obj->check_filter ($ad_inserter_globals [AI_POST_COUNTER_NAME])) continue;
|
2968 |
+
|
2969 |
+
// Last check before insertion
|
2970 |
+
if (!$obj->check_and_increment_block_counter ()) continue;
|
2971 |
+
|
2972 |
+
$ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
|
2973 |
+
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
|
2974 |
+
$ad_code .= $obj->get_code_for_insertion ();
|
2975 |
+
$ai_last_check = AI_CHECK_INSERTED;
|
2976 |
+
}
|
2977 |
+
}
|
2978 |
+
if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
|
2979 |
+
|
2980 |
+
echo $ad_code;
|
2981 |
+
|
2982 |
+
if ($debug_processing) {
|
2983 |
+
$ai_total_plugin_time += microtime () - $start_time;
|
2984 |
+
ai_log ("POST HOOK END\n");
|
2985 |
+
}
|
2986 |
+
|
2987 |
+
return $post;
|
2988 |
+
}
|
2989 |
+
|
2990 |
function process_shortcode (&$block, $atts) {
|
2991 |
global $block_object, $ai_last_check, $ai_wp_data;
|
2992 |
|
3175 |
|
3176 |
|
3177 |
function ai_widget_draw ($args, $instance, &$block) {
|
3178 |
+
global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
|
3179 |
|
3180 |
$block = isset ($instance ['block']) ? $instance ['block'] : 1;
|
3181 |
|
3194 |
|
3195 |
$globals_name = AI_WIDGET_COUNTER_NAME . $block;
|
3196 |
|
3197 |
+
if (!isset ($ad_inserter_globals [$globals_name])) {
|
3198 |
+
$ad_inserter_globals [$globals_name] = 1;
|
3199 |
+
} else $ad_inserter_globals [$globals_name] ++;
|
3200 |
|
3201 |
+
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']');
|
3202 |
|
3203 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
|
3204 |
|
3206 |
if (!$obj->get_enable_widget ()) return;
|
3207 |
if (!$obj->check_server_side_detection ()) return;
|
3208 |
if (!$obj->check_page_types_lists_users ()) return;
|
3209 |
+
if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return;
|
3210 |
|
3211 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
3212 |
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
class.php
CHANGED
@@ -315,7 +315,7 @@ abstract class ai_BaseCodeBlock {
|
|
315 |
|
316 |
$code = $obj->get_ad_data();
|
317 |
|
318 |
-
if ($obj->get_process_php ()) {
|
319 |
$start_time = microtime ();
|
320 |
|
321 |
$global_name = 'GENERATED_CODE';
|
@@ -801,43 +801,43 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
801 |
}
|
802 |
|
803 |
public function ai_get_counters (&$title){
|
804 |
-
global $ai_wp_data, $
|
805 |
|
806 |
$counters = '';
|
807 |
$title = 'Counters:';
|
808 |
|
809 |
-
if (isset ($
|
810 |
-
$counters .= ' C='.$
|
811 |
$title .= ' C= Content, ';
|
812 |
}
|
813 |
|
814 |
-
if (isset ($
|
815 |
-
$counters .= ' X='.$
|
816 |
$title .= ' X = Excerpt, ';
|
817 |
}
|
818 |
|
819 |
-
if (isset ($
|
820 |
-
$counters .= ' B='.$
|
821 |
$title .= ' B = Before post, ';
|
822 |
}
|
823 |
|
824 |
-
if (isset ($
|
825 |
-
$counters .= ' A='.$
|
826 |
$title .= ' A = After post, ';
|
827 |
}
|
828 |
|
829 |
-
if (isset ($
|
830 |
-
$counters .= ' W='.$
|
831 |
$title .= ' W = Widget, ';
|
832 |
}
|
833 |
|
834 |
-
if (isset ($
|
835 |
-
$counters .= ' P='.$
|
836 |
$title .= ' P = PHP function call, ';
|
837 |
}
|
838 |
|
839 |
-
if (isset ($
|
840 |
-
$counters .= ' N='.$
|
841 |
$title .= ' N = Block';
|
842 |
}
|
843 |
|
@@ -845,7 +845,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
845 |
}
|
846 |
|
847 |
public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
|
848 |
-
global $ai_wp_data, $
|
849 |
|
850 |
$processed_code = do_shortcode ($this->replace_ai_tags ($this->ai_getCode ()));
|
851 |
$dynamic_blocks = get_dynamic_blocks ();
|
@@ -2122,8 +2122,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2122 |
global $ai_last_check, $ai_wp_data;
|
2123 |
|
2124 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
|
2125 |
-
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2126 |
-
$selected_blocks = explode (",", $meta_value);
|
2127 |
|
2128 |
$enabled_on_text = $this->get_ad_enabled_on_which_posts ();
|
2129 |
if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
|
@@ -2135,8 +2135,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2135 |
if (!in_array ($this->number, $selected_blocks)) return false;
|
2136 |
}
|
2137 |
} elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2138 |
-
$meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2139 |
-
$selected_blocks = explode (",", $meta_value);
|
2140 |
|
2141 |
$enabled_on_text = $this->get_ad_enabled_on_which_pages ();
|
2142 |
if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
|
@@ -2152,7 +2152,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2152 |
}
|
2153 |
|
2154 |
function check_filter ($counter_for_filter) {
|
2155 |
-
global $ai_last_check, $
|
2156 |
|
2157 |
$ai_last_check = AI_CHECK_FILTER;
|
2158 |
$filter_settings = trim ($this->get_call_filter());
|
@@ -2160,33 +2160,37 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2160 |
|
2161 |
switch ($this->get_filter_type ()) {
|
2162 |
case AI_OPTION_FILTER_PHP_FUNCTION_CALLS:
|
2163 |
-
if (isset ($
|
2164 |
-
$counter_for_filter = $
|
2165 |
break;
|
2166 |
case AI_OPTION_FILTER_CONTENT_PROCESSING:
|
2167 |
-
if (isset ($
|
2168 |
-
$counter_for_filter = $
|
2169 |
break;
|
2170 |
case AI_OPTION_FILTER_EXCERPT_PROCESSING:
|
2171 |
-
if (isset ($
|
2172 |
-
$counter_for_filter = $
|
2173 |
break;
|
2174 |
case AI_OPTION_FILTER_BEFORE_POST_PROCESSING:
|
2175 |
-
if (isset ($
|
2176 |
-
$counter_for_filter = $
|
2177 |
break;
|
2178 |
case AI_OPTION_FILTER_AFTER_POST_PROCESSING:
|
2179 |
-
if (isset ($
|
2180 |
-
$counter_for_filter = $
|
2181 |
break;
|
2182 |
case AI_OPTION_FILTER_WIDGET_DRAWING:
|
2183 |
-
if (isset ($
|
2184 |
-
$counter_for_filter = $
|
2185 |
break;
|
2186 |
case AI_OPTION_FILTER_SUBPAGES:
|
2187 |
if (isset ($page))
|
2188 |
$counter_for_filter = $page; else return false;
|
2189 |
break;
|
|
|
|
|
|
|
|
|
2190 |
}
|
2191 |
|
2192 |
$filter_values = array ();
|
@@ -2198,43 +2202,43 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2198 |
}
|
2199 |
|
2200 |
function check_and_increment_block_counter () {
|
2201 |
-
global $
|
2202 |
|
2203 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2204 |
$max_insertions = intval ($this->get_maximum_insertions ());
|
2205 |
-
if (!isset ($
|
2206 |
-
$
|
2207 |
}
|
2208 |
$ai_last_check = AI_CHECK_MAX_INSERTIONS;
|
2209 |
-
if ($max_insertions != 0 && $
|
2210 |
-
$
|
2211 |
|
2212 |
return true;
|
2213 |
}
|
2214 |
|
2215 |
function check_block_counter () {
|
2216 |
-
global $
|
2217 |
|
2218 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2219 |
$max_insertions = intval ($this->get_maximum_insertions ());
|
2220 |
-
if (!isset ($
|
2221 |
-
$
|
2222 |
}
|
2223 |
$ai_last_check = AI_CHECK_MAX_INSERTIONS;
|
2224 |
-
if ($max_insertions != 0 && $
|
2225 |
return true;
|
2226 |
}
|
2227 |
|
2228 |
function increment_block_counter () {
|
2229 |
-
global $
|
2230 |
|
2231 |
if ($this->number == 0) return;
|
2232 |
|
2233 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2234 |
-
if (!isset ($
|
2235 |
-
$
|
2236 |
}
|
2237 |
-
$
|
2238 |
return;
|
2239 |
}
|
2240 |
|
315 |
|
316 |
$code = $obj->get_ad_data();
|
317 |
|
318 |
+
if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
|
319 |
$start_time = microtime ();
|
320 |
|
321 |
$global_name = 'GENERATED_CODE';
|
801 |
}
|
802 |
|
803 |
public function ai_get_counters (&$title){
|
804 |
+
global $ai_wp_data, $ad_inserter_globals;
|
805 |
|
806 |
$counters = '';
|
807 |
$title = 'Counters:';
|
808 |
|
809 |
+
if (isset ($ad_inserter_globals [AI_CONTENT_COUNTER_NAME]) && ($ai_wp_data [AI_CONTEXT] == AI_CONTEXT_CONTENT || $ai_wp_data [AI_CONTEXT] == AI_CONTEXT_SHORTCODE)) {
|
810 |
+
$counters .= ' C='.$ad_inserter_globals [AI_CONTENT_COUNTER_NAME];
|
811 |
$title .= ' C= Content, ';
|
812 |
}
|
813 |
|
814 |
+
if (isset ($ad_inserter_globals [AI_EXCERPT_COUNTER_NAME]) && $ai_wp_data [AI_CONTEXT] == AI_CONTEXT_EXCERPT) {
|
815 |
+
$counters .= ' X='.$ad_inserter_globals [AI_EXCERPT_COUNTER_NAME];
|
816 |
$title .= ' X = Excerpt, ';
|
817 |
}
|
818 |
|
819 |
+
if (isset ($ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME]) && $ai_wp_data [AI_CONTEXT] == AI_CONTEXT_BEFORE_POST) {
|
820 |
+
$counters .= ' B='.$ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME];
|
821 |
$title .= ' B = Before post, ';
|
822 |
}
|
823 |
|
824 |
+
if (isset ($ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME]) && $ai_wp_data [AI_CONTEXT] == AI_CONTEXT_AFTER_POST) {
|
825 |
+
$counters .= ' A='.$ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME];
|
826 |
$title .= ' A = After post, ';
|
827 |
}
|
828 |
|
829 |
+
if (isset ($ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number]) && $ai_wp_data [AI_CONTEXT] == AI_CONTEXT_WIDGET) {
|
830 |
+
$counters .= ' W='.$ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number];
|
831 |
$title .= ' W = Widget, ';
|
832 |
}
|
833 |
|
834 |
+
if (isset ($ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number])) {
|
835 |
+
$counters .= ' P='.$ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number];
|
836 |
$title .= ' P = PHP function call, ';
|
837 |
}
|
838 |
|
839 |
+
if (isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number])) {
|
840 |
+
$counters .= ' N='.$ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number];
|
841 |
$title .= ' N = Block';
|
842 |
}
|
843 |
|
845 |
}
|
846 |
|
847 |
public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
|
848 |
+
global $ai_wp_data, $ad_inserter_globals, $block_object;
|
849 |
|
850 |
$processed_code = do_shortcode ($this->replace_ai_tags ($this->ai_getCode ()));
|
851 |
$dynamic_blocks = get_dynamic_blocks ();
|
2122 |
global $ai_last_check, $ai_wp_data;
|
2123 |
|
2124 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
|
2125 |
+
// $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2126 |
+
// $selected_blocks = explode (",", $meta_value);
|
2127 |
|
2128 |
$enabled_on_text = $this->get_ad_enabled_on_which_posts ();
|
2129 |
if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
|
2135 |
if (!in_array ($this->number, $selected_blocks)) return false;
|
2136 |
}
|
2137 |
} elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2138 |
+
// $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
|
2139 |
+
// $selected_blocks = explode (",", $meta_value);
|
2140 |
|
2141 |
$enabled_on_text = $this->get_ad_enabled_on_which_pages ();
|
2142 |
if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
|
2152 |
}
|
2153 |
|
2154 |
function check_filter ($counter_for_filter) {
|
2155 |
+
global $ai_last_check, $ad_inserter_globals, $page;
|
2156 |
|
2157 |
$ai_last_check = AI_CHECK_FILTER;
|
2158 |
$filter_settings = trim ($this->get_call_filter());
|
2160 |
|
2161 |
switch ($this->get_filter_type ()) {
|
2162 |
case AI_OPTION_FILTER_PHP_FUNCTION_CALLS:
|
2163 |
+
if (isset ($ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number]))
|
2164 |
+
$counter_for_filter = $ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number]; else return false;
|
2165 |
break;
|
2166 |
case AI_OPTION_FILTER_CONTENT_PROCESSING:
|
2167 |
+
if (isset ($ad_inserter_globals [AI_CONTENT_COUNTER_NAME]))
|
2168 |
+
$counter_for_filter = $ad_inserter_globals [AI_CONTENT_COUNTER_NAME]; else return false;
|
2169 |
break;
|
2170 |
case AI_OPTION_FILTER_EXCERPT_PROCESSING:
|
2171 |
+
if (isset ($ad_inserter_globals [AI_EXCERPT_COUNTER_NAME]))
|
2172 |
+
$counter_for_filter = $ad_inserter_globals [AI_EXCERPT_COUNTER_NAME]; else return false;
|
2173 |
break;
|
2174 |
case AI_OPTION_FILTER_BEFORE_POST_PROCESSING:
|
2175 |
+
if (isset ($ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME]))
|
2176 |
+
$counter_for_filter = $ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME]; else return false;
|
2177 |
break;
|
2178 |
case AI_OPTION_FILTER_AFTER_POST_PROCESSING:
|
2179 |
+
if (isset ($ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME]))
|
2180 |
+
$counter_for_filter = $ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME]; else return false;
|
2181 |
break;
|
2182 |
case AI_OPTION_FILTER_WIDGET_DRAWING:
|
2183 |
+
if (isset ($ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number]))
|
2184 |
+
$counter_for_filter = $ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number]; else return false;
|
2185 |
break;
|
2186 |
case AI_OPTION_FILTER_SUBPAGES:
|
2187 |
if (isset ($page))
|
2188 |
$counter_for_filter = $page; else return false;
|
2189 |
break;
|
2190 |
+
case AI_OPTION_FILTER_POSTS:
|
2191 |
+
if (isset ($ad_inserter_globals [AI_POST_COUNTER_NAME]))
|
2192 |
+
$counter_for_filter = $ad_inserter_globals [AI_POST_COUNTER_NAME]; else return false;
|
2193 |
+
break;
|
2194 |
}
|
2195 |
|
2196 |
$filter_values = array ();
|
2202 |
}
|
2203 |
|
2204 |
function check_and_increment_block_counter () {
|
2205 |
+
global $ad_inserter_globals, $ai_last_check;
|
2206 |
|
2207 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2208 |
$max_insertions = intval ($this->get_maximum_insertions ());
|
2209 |
+
if (!isset ($ad_inserter_globals [$global_name])) {
|
2210 |
+
$ad_inserter_globals [$global_name] = 0;
|
2211 |
}
|
2212 |
$ai_last_check = AI_CHECK_MAX_INSERTIONS;
|
2213 |
+
if ($max_insertions != 0 && $ad_inserter_globals [$global_name] >= $max_insertions) return false;
|
2214 |
+
$ad_inserter_globals [$global_name] ++;
|
2215 |
|
2216 |
return true;
|
2217 |
}
|
2218 |
|
2219 |
function check_block_counter () {
|
2220 |
+
global $ad_inserter_globals;
|
2221 |
|
2222 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2223 |
$max_insertions = intval ($this->get_maximum_insertions ());
|
2224 |
+
if (!isset ($ad_inserter_globals [$global_name])) {
|
2225 |
+
$ad_inserter_globals [$global_name] = 0;
|
2226 |
}
|
2227 |
$ai_last_check = AI_CHECK_MAX_INSERTIONS;
|
2228 |
+
if ($max_insertions != 0 && $ad_inserter_globals [$global_name] >= $max_insertions) return false;
|
2229 |
return true;
|
2230 |
}
|
2231 |
|
2232 |
function increment_block_counter () {
|
2233 |
+
global $ad_inserter_globals;
|
2234 |
|
2235 |
if ($this->number == 0) return;
|
2236 |
|
2237 |
$global_name = AI_BLOCK_COUNTER_NAME . $this->number;
|
2238 |
+
if (!isset ($ad_inserter_globals [$global_name])) {
|
2239 |
+
$ad_inserter_globals [$global_name] = 0;
|
2240 |
}
|
2241 |
+
$ad_inserter_globals [$global_name] ++;
|
2242 |
return;
|
2243 |
}
|
2244 |
|
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.
|
15 |
|
16 |
if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
|
17 |
define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
|
@@ -115,6 +115,7 @@ define ('AI_OPTION_DISABLED', 'disabled');
|
|
115 |
|
116 |
define ('AI_OPTION_IMPORT', 'import');
|
117 |
define ('AI_OPTION_IMPORT_NAME', 'import_name');
|
|
|
118 |
|
119 |
//misc
|
120 |
define('AD_EMPTY_VALUE','');
|
@@ -122,6 +123,7 @@ define('AD_EMPTY_VALUE','');
|
|
122 |
//define constant variable form
|
123 |
define('AI_FORM_SAVE','ai_save');
|
124 |
define('AI_FORM_CLEAR','ai_clear');
|
|
|
125 |
|
126 |
define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
|
127 |
define('AD_ROTATE_SEPARATOR', '|rotate|');
|
@@ -139,6 +141,7 @@ define('AD_SELECT_BEFORE_CONTENT','Before Content');
|
|
139 |
define('AD_SELECT_AFTER_CONTENT','After Content');
|
140 |
define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
|
141 |
define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
|
|
|
142 |
|
143 |
define('AD_SELECT_WIDGET','Widget'); // Deprecated
|
144 |
define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
|
@@ -190,6 +193,7 @@ define ('AI_OPTION_FILTER_BEFORE_POST_PROCESSING', 'Before post processing');
|
|
190 |
define ('AI_OPTION_FILTER_AFTER_POST_PROCESSING', 'After post processing');
|
191 |
define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
|
192 |
define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
|
|
|
193 |
|
194 |
//Counter names
|
195 |
define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
|
@@ -199,6 +203,7 @@ define ('AI_EXCERPT_COUNTER_NAME', 'AI_EXCERPT_COUNTER');
|
|
199 |
define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_BEFORE_COUNTER');
|
200 |
define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_AFTER_COUNTER');
|
201 |
define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
|
|
|
202 |
|
203 |
//Text List Type
|
204 |
define('AD_CONTAIN','contain');
|
@@ -249,6 +254,7 @@ define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
|
|
249 |
define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
|
250 |
define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
|
251 |
define ('DEFAULT_MULTISITE_WIDGETS', AD_SETTINGS_CHECKED);
|
|
|
252 |
define ('DEFAULT_MULTISITE_EXCEPTIONS', AD_SETTINGS_CHECKED);
|
253 |
define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AD_SETTINGS_NOT_CHECKED);
|
254 |
|
@@ -266,6 +272,7 @@ define ('CONTENT_HOOK_BLOCKS', 'content_hook');
|
|
266 |
define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
|
267 |
define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
|
268 |
define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
|
|
|
269 |
|
270 |
define ('AI_CHECK_NONE', - 1);
|
271 |
define ('AI_CHECK_INSERTED', 0);
|
@@ -357,6 +364,7 @@ define ('AI_CONTEXT_PHP_FUNCTION', 6);
|
|
357 |
define ('AI_CONTEXT_SHORTCODE', 7);
|
358 |
define ('AI_CONTEXT_HEADER', 8);
|
359 |
define ('AI_CONTEXT_FOOTER', 9);
|
|
|
360 |
|
361 |
define ('AI_URL_DEBUG', 'ai-debug');
|
362 |
define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing');
|
11 |
define ('AD_INSERTER_NAME', 'Ad Inserter');
|
12 |
|
13 |
if (!defined( 'AD_INSERTER_VERSION'))
|
14 |
+
define ('AD_INSERTER_VERSION', '2.0.10');
|
15 |
|
16 |
if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
|
17 |
define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
|
115 |
|
116 |
define ('AI_OPTION_IMPORT', 'import');
|
117 |
define ('AI_OPTION_IMPORT_NAME', 'import_name');
|
118 |
+
define ('AI_OPTION_PLUGIN_STATUS', 'plugin_status');
|
119 |
|
120 |
//misc
|
121 |
define('AD_EMPTY_VALUE','');
|
123 |
//define constant variable form
|
124 |
define('AI_FORM_SAVE','ai_save');
|
125 |
define('AI_FORM_CLEAR','ai_clear');
|
126 |
+
define('AI_FORM_CLEAR_EXCEPTIONS','ai_clear_exceptions');
|
127 |
|
128 |
define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
|
129 |
define('AD_ROTATE_SEPARATOR', '|rotate|');
|
141 |
define('AD_SELECT_AFTER_CONTENT','After Content');
|
142 |
define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
|
143 |
define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
|
144 |
+
define('AD_SELECT_BETWEEN_POSTS','Between Posts');
|
145 |
|
146 |
define('AD_SELECT_WIDGET','Widget'); // Deprecated
|
147 |
define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
|
193 |
define ('AI_OPTION_FILTER_AFTER_POST_PROCESSING', 'After post processing');
|
194 |
define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
|
195 |
define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
|
196 |
+
define ('AI_OPTION_FILTER_POSTS', 'Posts');
|
197 |
|
198 |
//Counter names
|
199 |
define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
|
203 |
define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_BEFORE_COUNTER');
|
204 |
define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_AFTER_COUNTER');
|
205 |
define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
|
206 |
+
define ('AI_POST_COUNTER_NAME', 'AI_POST_COUNTER');
|
207 |
|
208 |
//Text List Type
|
209 |
define('AD_CONTAIN','contain');
|
254 |
define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
|
255 |
define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
|
256 |
define ('DEFAULT_MULTISITE_WIDGETS', AD_SETTINGS_CHECKED);
|
257 |
+
define ('DEFAULT_MULTISITE_PHP_PROCESSING', AD_SETTINGS_CHECKED);
|
258 |
define ('DEFAULT_MULTISITE_EXCEPTIONS', AD_SETTINGS_CHECKED);
|
259 |
define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AD_SETTINGS_NOT_CHECKED);
|
260 |
|
272 |
define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
|
273 |
define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
|
274 |
define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
|
275 |
+
define ('POST_HOOK_BLOCKS', 'post_hook');
|
276 |
|
277 |
define ('AI_CHECK_NONE', - 1);
|
278 |
define ('AI_CHECK_INSERTED', 0);
|
364 |
define ('AI_CONTEXT_SHORTCODE', 7);
|
365 |
define ('AI_CONTEXT_HEADER', 8);
|
366 |
define ('AI_CONTEXT_FOOTER', 9);
|
367 |
+
define ('AI_CONTEXT_BETWEEN_POSTS', 10);
|
368 |
|
369 |
define ('AI_URL_DEBUG', 'ai-debug');
|
370 |
define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing');
|
css/ad-inserter.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
#data {
|
2 |
-
font-family: "2.0.
|
3 |
}
|
4 |
|
5 |
#blocked-warning {
|
@@ -45,24 +45,39 @@
|
|
45 |
.nav-tab-active, .nav-tab-active:hover {
|
46 |
background: #fff;
|
47 |
}
|
|
|
48 |
.exceptions a {
|
49 |
text-decoration: none;
|
50 |
}
|
51 |
.exceptions th.page {
|
52 |
text-align: left;
|
53 |
}
|
|
|
|
|
|
|
54 |
.exceptions td.page {
|
55 |
padding-right: 20px;
|
56 |
}
|
57 |
-
.exceptions td.id {
|
58 |
padding-right: 10px;
|
59 |
text-align: right;
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
.exceptions th.block, .exceptions td.block {
|
62 |
text-align: center;
|
63 |
-
width:
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
-
|
66 |
.small-button .ui-button-text-only .ui-button-text {
|
67 |
padding: 0px;
|
68 |
}
|
1 |
#data {
|
2 |
+
font-family: "2.0.10"; /* Used for version number of the file */
|
3 |
}
|
4 |
|
5 |
#blocked-warning {
|
45 |
.nav-tab-active, .nav-tab-active:hover {
|
46 |
background: #fff;
|
47 |
}
|
48 |
+
|
49 |
.exceptions a {
|
50 |
text-decoration: none;
|
51 |
}
|
52 |
.exceptions th.page {
|
53 |
text-align: left;
|
54 |
}
|
55 |
+
.exceptions tr.even {
|
56 |
+
background: #f0f0f0;
|
57 |
+
}
|
58 |
.exceptions td.page {
|
59 |
padding-right: 20px;
|
60 |
}
|
61 |
+
.exceptions th.id, .exceptions td.id {
|
62 |
padding-right: 10px;
|
63 |
text-align: right;
|
64 |
}
|
65 |
+
.exceptions th.page, .exceptions td.page {
|
66 |
+
width: 90%;
|
67 |
+
overflow: hidden;
|
68 |
+
max-width: 280px;
|
69 |
+
}
|
70 |
+
.exceptions th.page-only, .exceptions td.page-only {
|
71 |
+
width: 100%;
|
72 |
+
}
|
73 |
.exceptions th.block, .exceptions td.block {
|
74 |
text-align: center;
|
75 |
+
min-width: 22px;
|
76 |
+
cursor: pointer;
|
77 |
+
}
|
78 |
+
.exceptions td.button-delete {
|
79 |
+
cursor: pointer;
|
80 |
}
|
|
|
81 |
.small-button .ui-button-text-only .ui-button-text {
|
82 |
padding: 0px;
|
83 |
}
|
js/ad-inserter.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
var javascript_version = "2.0.
|
2 |
var ignore_key = true;
|
3 |
var start = 1;
|
4 |
var end = 16;
|
@@ -518,6 +518,12 @@ jQuery(document).ready(function($) {
|
|
518 |
window.location.href = "widgets.php";
|
519 |
});
|
520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
$("#show-css-button-"+tab).button ({
|
522 |
}).show ().click (function () {
|
523 |
var block = $(this).attr ("id").replace ("show-css-button-","");
|
@@ -937,6 +943,8 @@ jQuery(document).ready(function($) {
|
|
937 |
tab_block = tab_block.replace ("ai-tab","");
|
938 |
active_tab = tab_block;
|
939 |
|
|
|
|
|
940 |
if (!$("#tab-" + tab_block).hasClass ('configured')) {
|
941 |
if (debug) console.log ("");
|
942 |
if (debug) console.log ("Empty tab: " + tab_block);
|
1 |
+
var javascript_version = "2.0.10";
|
2 |
var ignore_key = true;
|
3 |
var start = 1;
|
4 |
var end = 16;
|
518 |
window.location.href = "widgets.php";
|
519 |
});
|
520 |
|
521 |
+
$("#exceptions-button-"+tab).button ({
|
522 |
+
}).click (function () {
|
523 |
+
var block = $(this).attr ("id").replace ("exceptions-button-","");
|
524 |
+
$("#block-exceptions-" + block).toggle ();
|
525 |
+
});
|
526 |
+
|
527 |
$("#show-css-button-"+tab).button ({
|
528 |
}).show ().click (function () {
|
529 |
var block = $(this).attr ("id").replace ("show-css-button-","");
|
943 |
tab_block = tab_block.replace ("ai-tab","");
|
944 |
active_tab = tab_block;
|
945 |
|
946 |
+
if (debug) console.log ("active_tab: " + active_tab);
|
947 |
+
|
948 |
if (!$("#tab-" + tab_block).hasClass ('configured')) {
|
949 |
if (debug) console.log ("");
|
950 |
if (debug) console.log ("Empty tab: " + tab_block);
|
readme.txt
CHANGED
@@ -3,26 +3,32 @@ Contributors: spacetime
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
4 |
Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.7
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv3
|
9 |
|
10 |
-
Insert any advert or
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect for all kinds of ads
|
15 |
|
16 |
> **Features**
|
17 |
>
|
18 |
> * 16 code blocks
|
19 |
> * Syntax highlighting editor
|
20 |
> * Code preview with visual CSS editor
|
21 |
-
> * Automatic insertion: before/after post, content, paragraph or excerpt
|
|
|
|
|
|
|
|
|
|
|
22 |
> * Insertion exceptions for posts and pages
|
23 |
> * Manual insertion: widgets, shortcodes, PHP function call
|
24 |
> * Custom block alignment and style
|
25 |
-
> *
|
|
|
26 |
> * PHP code processing
|
27 |
> * Ad rotation (server-side and client-side - works with caching)
|
28 |
> * Device detection (server-side and client-side, 3 custom viewports)
|
@@ -76,14 +82,27 @@ Please *support the plugin* if you like it:
|
|
76 |
|
77 |
== Installation ==
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
|
88 |
**Ad Inserter Pro Installation**
|
89 |
|
@@ -93,12 +112,13 @@ activate it and then click "Enter License Key" and enter license key you got in
|
|
93 |
|
94 |
**Uninstall**
|
95 |
|
96 |
-
If you deactivate and delete Ad Inserter the settings will stay in the database. To completely remove the plugin and settings do the following:
|
97 |
|
98 |
1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
|
99 |
2. Deactivate Ad Inserter
|
100 |
3. Delete Ad Inserter plugin
|
101 |
|
|
|
102 |
**Quick Start**
|
103 |
|
104 |
Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
|
@@ -139,6 +159,7 @@ Automatic Insertion Options:
|
|
139 |
* Insert After Post (after post or posts on blog pages)
|
140 |
* Insert Before Excerpt (on blog pages)
|
141 |
* Insert After Excerpt (on blog pages)
|
|
|
142 |
|
143 |
For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
|
144 |
|
@@ -634,6 +655,13 @@ AD CODE RIGHT
|
|
634 |
|
635 |
== Changelog ==
|
636 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
= 2.0.9 =
|
638 |
- Added support for uppercase {country_ISO2} and lowercase {country_iso2} tag (Pro only)
|
639 |
- Removed inclusion of dummy css and js file
|
@@ -923,6 +951,10 @@ AD CODE RIGHT
|
|
923 |
|
924 |
== Upgrade Notice ==
|
925 |
|
|
|
|
|
|
|
|
|
926 |
= 2.0.9 =
|
927 |
Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache;
|
928 |
Added support for uppercase and lowercase {country_iso2} tag (Pro only); Removed inclusion of dummy css and js file
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
4 |
Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 2.0.9
|
8 |
License: GPLv3
|
9 |
|
10 |
+
Insert any advert or code into Wordpress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect for all kinds of ads including AdSense and Amazon.** Insert anything anywhere on the page.
|
15 |
|
16 |
> **Features**
|
17 |
>
|
18 |
> * 16 code blocks
|
19 |
> * Syntax highlighting editor
|
20 |
> * Code preview with visual CSS editor
|
21 |
+
> * Automatic insertion: before / after post, content, paragraph or excerpt
|
22 |
+
> * Automatic insertion before or after random paragraph
|
23 |
+
> * Automatic insertion before or after any HTML element in post
|
24 |
+
> * Automatic insertion at relative position in posts
|
25 |
+
> * Clearance options to avoid insertion near images or headers
|
26 |
+
> * Automatic insertion between posts on blog pages
|
27 |
> * Insertion exceptions for posts and pages
|
28 |
> * Manual insertion: widgets, shortcodes, PHP function call
|
29 |
> * Custom block alignment and style
|
30 |
+
> * Custom CSS class name for wrapping divs to avoid ad blockers
|
31 |
+
> * Insertion of shortcodes from other plugins
|
32 |
> * PHP code processing
|
33 |
> * Ad rotation (server-side and client-side - works with caching)
|
34 |
> * Device detection (server-side and client-side, 3 custom viewports)
|
82 |
|
83 |
== Installation ==
|
84 |
|
85 |
+
= Using The WordPress Dashboard =
|
86 |
+
|
87 |
+
1. Go to Wordpress Plugins menu, click Add New button
|
88 |
+
2. Search for `ad inserter`
|
89 |
+
3. Click 'Install Now'
|
90 |
+
4. Activate Ad Inserter on the Plugin dashboard
|
91 |
+
|
92 |
+
= Uploading plugin file =
|
93 |
|
94 |
+
1. Go to Wordpress Plugins menu, click Add New button
|
95 |
+
2. Click Upload Plugin
|
96 |
+
3. Select `ad-inserter.zip` from your computer
|
97 |
+
4. Click 'Install Now'
|
98 |
+
5. Activate Ad Inserter in the Plugin dashboard
|
99 |
|
100 |
+
= Using FTP =
|
101 |
+
|
102 |
+
1. Download `ad-inserter.zip`
|
103 |
+
2. Extract the `ad-inserter.zip` directory to your computer
|
104 |
+
3. Upload the `ad-inserter` directory to the `/wp-content/plugins/` directory
|
105 |
+
4. Activate Ad Inserter in the Plugin dashboard
|
106 |
|
107 |
**Ad Inserter Pro Installation**
|
108 |
|
112 |
|
113 |
**Uninstall**
|
114 |
|
115 |
+
If you deactivate and delete Ad Inserter, the settings will stay in the database. To completely remove the plugin and settings do the following:
|
116 |
|
117 |
1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
|
118 |
2. Deactivate Ad Inserter
|
119 |
3. Delete Ad Inserter plugin
|
120 |
|
121 |
+
|
122 |
**Quick Start**
|
123 |
|
124 |
Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
|
159 |
* Insert After Post (after post or posts on blog pages)
|
160 |
* Insert Before Excerpt (on blog pages)
|
161 |
* Insert After Excerpt (on blog pages)
|
162 |
+
* Insert Between Posts (on blog pages)
|
163 |
|
164 |
For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
|
165 |
|
655 |
|
656 |
== Changelog ==
|
657 |
|
658 |
+
= 2.0.10 =
|
659 |
+
- Added option to insert ads between posts on blog pages
|
660 |
+
- Added option to check and manage post/page exceptions for each block
|
661 |
+
- Added option to check and manage all post/page exceptions (Pro only)
|
662 |
+
- Added option for multisite installations to disable PHP processing on sub-sites (Pro only)
|
663 |
+
- Added license status notifications (Pro only)
|
664 |
+
|
665 |
= 2.0.9 =
|
666 |
- Added support for uppercase {country_ISO2} and lowercase {country_iso2} tag (Pro only)
|
667 |
- Removed inclusion of dummy css and js file
|
951 |
|
952 |
== Upgrade Notice ==
|
953 |
|
954 |
+
= 2.0.10 =
|
955 |
+
Option to insert ads between posts on blog pages;
|
956 |
+
Option to check and manage post/page exceptions for each block;
|
957 |
+
|
958 |
= 2.0.9 =
|
959 |
Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache;
|
960 |
Added support for uppercase and lowercase {country_iso2} tag (Pro only); Removed inclusion of dummy css and js file
|
settings.php
CHANGED
@@ -34,10 +34,32 @@ function generate_settings_form (){
|
|
34 |
|
35 |
$default = $block_object [0];
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
?>
|
38 |
|
39 |
<div id="data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
|
40 |
|
|
|
|
|
41 |
<div id="ai-settings" style="float: left;">
|
42 |
|
43 |
<form id="ai-form" class="ai-form no-select" action="<?php echo $save_url; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" start="<?php echo $start; ?>" end="<?php echo $end; ?>">
|
@@ -93,69 +115,6 @@ function generate_settings_form (){
|
|
93 |
<div style="clear: both;"></div>
|
94 |
</div>
|
95 |
|
96 |
-
<?php
|
97 |
-
if ($subpage == 'exceptions') {
|
98 |
-
?>
|
99 |
-
<div id="ai-exceptions" style="padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
100 |
-
|
101 |
-
<table class="exceptions">
|
102 |
-
<tbody>
|
103 |
-
<?php
|
104 |
-
|
105 |
-
$pages = get_pages ();
|
106 |
-
$posts_pages = array ('pages' => $pages);
|
107 |
-
|
108 |
-
$args = array( 'posts_per_page' => -1);
|
109 |
-
$posts_pages ['posts'] = get_posts ($args);
|
110 |
-
|
111 |
-
$table_header = '<tr><th class="id">ID</th><th class="page">Page / Post</th>';
|
112 |
-
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
113 |
-
$table_header .= '<th class="block">' . $block . '</th>';
|
114 |
-
}
|
115 |
-
$table_header .= '</tr>';
|
116 |
-
|
117 |
-
$header_written = false;
|
118 |
-
foreach ($posts_pages as $type => $post_page) {
|
119 |
-
foreach ($post_page as $page) {
|
120 |
-
$post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
|
121 |
-
if ($post_meta == '') continue;
|
122 |
-
$selected_blocks = explode (",", $post_meta);
|
123 |
-
|
124 |
-
if (!$header_written) {
|
125 |
-
echo $table_header;
|
126 |
-
$header_written = true;
|
127 |
-
}
|
128 |
-
echo '<tr><td class="id"><a href="', get_edit_post_link ($page->ID), '" target="_blank" title="Edit">', $page->ID, '</a></td>
|
129 |
-
<td class="page"><a href="', get_permalink ($page->ID), '" target="_blank" title="View">', $page->post_title, '</a></td>';
|
130 |
-
|
131 |
-
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
132 |
-
|
133 |
-
$obj = $block_object [$block];
|
134 |
-
if ($type == 'posts') {
|
135 |
-
$enabled_on_text = $obj->get_ad_enabled_on_which_posts ();
|
136 |
-
$general_enabled = $obj->get_display_settings_post();
|
137 |
-
} else {
|
138 |
-
$enabled_on_text = $obj->get_ad_enabled_on_which_pages ();
|
139 |
-
$general_enabled = $obj->get_display_settings_page();
|
140 |
-
}
|
141 |
-
|
142 |
-
$individual_option_enabled = $general_enabled && ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED || $enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED);
|
143 |
-
$individual_text_enabled = $enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED;
|
144 |
-
|
145 |
-
echo '<td class="block">', /*$individual_option_enabled && */in_array ($block, $selected_blocks) ? ($individual_text_enabled? '✗' : '✓') : '', '</td>';
|
146 |
-
}
|
147 |
-
|
148 |
-
echo '<tr>';
|
149 |
-
}
|
150 |
-
}
|
151 |
-
?>
|
152 |
-
</tbody>
|
153 |
-
</table>
|
154 |
-
|
155 |
-
</div>
|
156 |
-
<?php
|
157 |
-
} else {
|
158 |
-
?>
|
159 |
<div id="ai-tab-container" class="ai-form" style="padding: 8px 8px 1px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
160 |
<div id="dummy-tabs" style="height: 29px; padding: .2em .2em 0;"></div>
|
161 |
|
@@ -375,6 +334,7 @@ function generate_settings_form (){
|
|
375 |
<option value="<?php echo AD_SELECT_AFTER_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_POST; ?></option>
|
376 |
<option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
|
377 |
<option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
|
|
|
378 |
</select>
|
379 |
</div>
|
380 |
|
@@ -413,7 +373,7 @@ function generate_settings_form (){
|
|
413 |
</div>
|
414 |
</div>
|
415 |
|
416 |
-
<div class="responsive-table" style="padding: 7px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
|
417 |
<table>
|
418 |
<tr>
|
419 |
<td style="width: 70%">
|
@@ -427,6 +387,15 @@ function generate_settings_form (){
|
|
427 |
</select>
|
428 |
|
429 |
<label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
</td>
|
431 |
<td style="padding-left: 8px;">
|
432 |
</td>
|
@@ -471,6 +440,43 @@ function generate_settings_form (){
|
|
471 |
</table>
|
472 |
</div>
|
473 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
<div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:4px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;<?php echo $paragraph_settings ? "" : " display: none;" ?>">
|
475 |
<div style="margin: 4px 0; height: 26px;">
|
476 |
<div style="float: left; margin-top: 1px;">
|
@@ -853,6 +859,7 @@ function generate_settings_form (){
|
|
853 |
<option value="<?php echo AI_OPTION_FILTER_AFTER_POST_PROCESSING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_AFTER_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_AFTER_POST_PROCESSING; ?></option>
|
854 |
<option value="<?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?></option>
|
855 |
<option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
|
|
|
856 |
</select>
|
857 |
</span>
|
858 |
<span style="display: table-cell;">
|
@@ -942,10 +949,10 @@ function generate_settings_form (){
|
|
942 |
?>
|
943 |
<div id="tab-0" style="padding: 0;<?php echo $tab_visible ? "" : " display: none;" ?>">
|
944 |
<div style="margin: 16px 0 16px 4px;">
|
945 |
-
<h3 style="margin: 0; float: left;"><?php echo AD_INSERTER_NAME ?> Settings <?php if (isset ($ai_db_options [
|
946 |
-
(int) ($ai_db_options [
|
947 |
-
(int) ($ai_db_options [
|
948 |
-
<h4 style="margin: 0px; float: right;" title="Settings timestamp"><?php echo isset ($ai_db_options [
|
949 |
<div style="clear: both;"></div>
|
950 |
</div>
|
951 |
|
@@ -976,13 +983,13 @@ function generate_settings_form (){
|
|
976 |
<li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
|
977 |
<li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
|
978 |
<li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
|
979 |
-
<?php if (function_exists ('ai_plugin_settings_tab')) ai_plugin_settings_tab (); ?>
|
980 |
<li id="ai-d" class="ai-plugin-tab"><a href="#tab-debugging"><span style="<?php echo $style_d ?>">Debugging</span></a></li>
|
981 |
</ul>
|
982 |
|
983 |
<div id="tab-general" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
984 |
|
985 |
-
<table>
|
986 |
<?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
|
987 |
<tr>
|
988 |
<td style="padding-left: 10px;">
|
@@ -1205,7 +1212,7 @@ function generate_settings_form (){
|
|
1205 |
</div>
|
1206 |
</div>
|
1207 |
|
1208 |
-
<?php if (function_exists ('ai_plugin_settings')) ai_plugin_settings (); ?>
|
1209 |
|
1210 |
<div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
1211 |
<div style="margin: 8px;">
|
@@ -1226,6 +1233,8 @@ function generate_settings_form (){
|
|
1226 |
<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 '; ?> />
|
1227 |
<label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
|
1228 |
</div>
|
|
|
|
|
1229 |
</div>
|
1230 |
</div>
|
1231 |
|
@@ -1237,7 +1246,6 @@ function generate_settings_form (){
|
|
1237 |
<input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
|
1238 |
|
1239 |
<?php
|
1240 |
-
} // Main subpage
|
1241 |
wp_nonce_field ('save_adinserter_settings');
|
1242 |
?>
|
1243 |
</form>
|
34 |
|
35 |
$default = $block_object [0];
|
36 |
|
37 |
+
$pages = get_pages ();
|
38 |
+
$posts_pages = array ('pages' => $pages);
|
39 |
+
|
40 |
+
$args = array( 'posts_per_page' => -1);
|
41 |
+
$posts_pages ['posts'] = get_posts ($args);
|
42 |
+
|
43 |
+
$exceptions = array ();
|
44 |
+
foreach ($posts_pages as $type => $post_page) {
|
45 |
+
foreach ($post_page as $page) {
|
46 |
+
$post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
|
47 |
+
if ($post_meta == '') continue;
|
48 |
+
$exceptions [$page->ID] = array ('post' => $type == 'posts', 'title' => $page->post_title, 'blocks' => $post_meta);
|
49 |
+
|
50 |
+
$selected_blocks = explode (",", $post_meta);
|
51 |
+
foreach ($selected_blocks as $selected_block) {
|
52 |
+
$block_exceptions [$selected_block][$page->ID] = array ('post' => $type == 'posts', 'title' => $page->post_title);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
ksort ($exceptions);
|
57 |
?>
|
58 |
|
59 |
<div id="data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
|
60 |
|
61 |
+
<div style="clear: both;"></div>
|
62 |
+
|
63 |
<div id="ai-settings" style="float: left;">
|
64 |
|
65 |
<form id="ai-form" class="ai-form no-select" action="<?php echo $save_url; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" start="<?php echo $start; ?>" end="<?php echo $end; ?>">
|
115 |
<div style="clear: both;"></div>
|
116 |
</div>
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
<div id="ai-tab-container" class="ai-form" style="padding: 8px 8px 1px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
119 |
<div id="dummy-tabs" style="height: 29px; padding: .2em .2em 0;"></div>
|
120 |
|
334 |
<option value="<?php echo AD_SELECT_AFTER_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_POST; ?></option>
|
335 |
<option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
|
336 |
<option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
|
337 |
+
<option value="<?php echo AD_SELECT_BETWEEN_POSTS; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BETWEEN_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BETWEEN_POSTS; ?></option>
|
338 |
</select>
|
339 |
</div>
|
340 |
|
373 |
</div>
|
374 |
</div>
|
375 |
|
376 |
+
<div class="responsive-table small-button" style="padding: 7px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
|
377 |
<table>
|
378 |
<tr>
|
379 |
<td style="width: 70%">
|
387 |
</select>
|
388 |
|
389 |
<label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
|
390 |
+
|
391 |
+
<?php
|
392 |
+
if (!empty ($block_exceptions [$ad_number])) {
|
393 |
+
?>
|
394 |
+
<button id="exceptions-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px; margin-left: 20px;" title="Toggle Exceptions"></button>
|
395 |
+
<?php
|
396 |
+
}
|
397 |
+
?>
|
398 |
+
|
399 |
</td>
|
400 |
<td style="padding-left: 8px;">
|
401 |
</td>
|
440 |
</table>
|
441 |
</div>
|
442 |
|
443 |
+
<div id="block-exceptions-<?php echo $ad_number; ?>" class="responsive-table" style="padding: 7px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px; display: none;">
|
444 |
+
<?php
|
445 |
+
|
446 |
+
if (!empty ($block_exceptions [$ad_number])) {
|
447 |
+
ksort ($block_exceptions [$ad_number])
|
448 |
+
?>
|
449 |
+
<table class="exceptions" cellspacing=0 cellpadding=0><tbody>
|
450 |
+
<tr>
|
451 |
+
<th class="id">ID</th><th class="page page-only"> Page / Post</th><th>
|
452 |
+
<input id="clear-block-exceptions-<?php echo $ad_number; ?>"
|
453 |
+
onclick="if (confirm('Are you sure you want to clear all exceptions for block <?php echo $ad_number; ?>?')) {document.getElementById ('clear-block-exceptions-<?php echo $ad_number; ?>').style.visibility = 'hidden'; document.getElementById ('clear-block-exceptions-<?php echo $ad_number; ?>').style.fontSize = '1px'; document.getElementById ('clear-block-exceptions-<?php echo $ad_number; ?>').value = '<?php echo $ad_number; ?>'; return true;} return false"
|
454 |
+
title="Clear all exceptions for block <?php echo $ad_number; ?>"
|
455 |
+
name="<?php echo AI_FORM_CLEAR_EXCEPTIONS; ?>"
|
456 |
+
value="❌"
|
457 |
+
type="submit"
|
458 |
+
style="padding: 1px 3px; border: 0; background: transparent; font-size: 8px; color: #e44;" /></th>
|
459 |
+
</tr>
|
460 |
+
<?php
|
461 |
+
foreach ($block_exceptions [$ad_number] as $id => $exception) {
|
462 |
+
?>
|
463 |
+
<tr>
|
464 |
+
<td class="id"><a href="<?php
|
465 |
+
get_permalink ($id); ?>" target="_blank" title="View" style="color: #222;"><?php
|
466 |
+
echo $id; ?></a></td><td class="page page-only"><a href="<?php
|
467 |
+
get_edit_post_link ($id); ?>" target="_blank" title="Edit" style="margin-left: 2px; color: #222;"><?php
|
468 |
+
echo $exception ['title']; ?></a></td><td></td>
|
469 |
+
</tr>
|
470 |
+
<?php
|
471 |
+
}
|
472 |
+
?>
|
473 |
+
|
474 |
+
</tbody></table>
|
475 |
+
<?php
|
476 |
+
} else echo 'No exceptions';
|
477 |
+
?>
|
478 |
+
</div>
|
479 |
+
|
480 |
<div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:4px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;<?php echo $paragraph_settings ? "" : " display: none;" ?>">
|
481 |
<div style="margin: 4px 0; height: 26px;">
|
482 |
<div style="float: left; margin-top: 1px;">
|
859 |
<option value="<?php echo AI_OPTION_FILTER_AFTER_POST_PROCESSING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_AFTER_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_AFTER_POST_PROCESSING; ?></option>
|
860 |
<option value="<?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?></option>
|
861 |
<option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
|
862 |
+
<option value="<?php echo AI_OPTION_FILTER_POSTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_POSTS; ?></option>
|
863 |
</select>
|
864 |
</span>
|
865 |
<span style="display: table-cell;">
|
949 |
?>
|
950 |
<div id="tab-0" style="padding: 0;<?php echo $tab_visible ? "" : " display: none;" ?>">
|
951 |
<div style="margin: 16px 0 16px 4px;">
|
952 |
+
<h3 style="margin: 0; float: left;"><?php echo AD_INSERTER_NAME ?> Settings <?php if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'])) echo (int) ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][0].$ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][1]), '.',
|
953 |
+
(int) ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][2].$ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][3]), '.',
|
954 |
+
(int) ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][4].$ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'][5]); ?></h3>
|
955 |
+
<h4 style="margin: 0px; float: right;" title="Settings timestamp"><?php echo isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_GLOBAL_OPTION_NAME]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : ""; ?></h4>
|
956 |
<div style="clear: both;"></div>
|
957 |
</div>
|
958 |
|
983 |
<li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
|
984 |
<li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
|
985 |
<li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
|
986 |
+
<?php if (function_exists ('ai_plugin_settings_tab')) ai_plugin_settings_tab ($exceptions); ?>
|
987 |
<li id="ai-d" class="ai-plugin-tab"><a href="#tab-debugging"><span style="<?php echo $style_d ?>">Debugging</span></a></li>
|
988 |
</ul>
|
989 |
|
990 |
<div id="tab-general" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
991 |
|
992 |
+
<table style="width: 100%;">
|
993 |
<?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
|
994 |
<tr>
|
995 |
<td style="padding-left: 10px;">
|
1212 |
</div>
|
1213 |
</div>
|
1214 |
|
1215 |
+
<?php if (function_exists ('ai_plugin_settings')) ai_plugin_settings ($start, $end, $exceptions); ?>
|
1216 |
|
1217 |
<div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
|
1218 |
<div style="margin: 8px;">
|
1233 |
<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 '; ?> />
|
1234 |
<label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
|
1235 |
</div>
|
1236 |
+
|
1237 |
+
<?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
|
1238 |
</div>
|
1239 |
</div>
|
1240 |
|
1246 |
<input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
|
1247 |
|
1248 |
<?php
|
|
|
1249 |
wp_nonce_field ('save_adinserter_settings');
|
1250 |
?>
|
1251 |
</form>
|