Version Description
- Fix for posts filter counter not counting
- Added list with short overview of all code blocks
- Added support for word count on blog pages
- Added support for client code preview (no need to save it for preview)
- Improved compatibility on AMP pages
- Few minor bug fixes, cosmetic changes and code improvements
Download this release
Release Info
Developer | spacetime |
Plugin | Ad Inserter – WordPress Ads Management with AdSense Header Integration |
Version | 2.2.6 |
Comparing to | |
See all releases |
Code changes from version 2.2.5 to 2.2.6
- ad-inserter.php +378 -168
- class.php +374 -50
- constants.php +30 -9
- css/ad-inserter.css +47 -4
- {images → css/images}/blank.png +0 -0
- css/images/icons.png +0 -0
- images/test.png +0 -0
- js/ad-inserter.js +265 -8
- preview.php +3 -2
- readme.txt +31 -9
- settings.php +341 -58
ad-inserter.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
-
Version: 2.2.
|
5 |
-
Description: Ad management plugin with advanced advertising options to automatically insert ad codes
|
6 |
Author: Igor Funa
|
7 |
Author URI: http://igorfuna.com/
|
8 |
Plugin URI: http://adinserter.pro/documentation
|
@@ -12,6 +12,14 @@ Plugin URI: http://adinserter.pro/documentation
|
|
12 |
|
13 |
Change Log
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
Ad Inserter 2.2.5 - 2017-10-15
|
16 |
- Fix for issue with Ajax requests
|
17 |
|
@@ -627,6 +635,8 @@ if (isset ($_POST [AI_FORM_SAVE]))
|
|
627 |
define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
|
628 |
|
629 |
|
|
|
|
|
630 |
add_action ('admin_menu', 'ai_admin_menu_hook');
|
631 |
|
632 |
add_action ('init', 'ai_init_hook');
|
@@ -660,6 +670,7 @@ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
|
660 |
}
|
661 |
|
662 |
|
|
|
663 |
function ai_toolbar ($wp_admin_bar) {
|
664 |
global $block_object, $ai_wp_data;
|
665 |
|
@@ -1002,6 +1013,24 @@ function ai_loop_check ($query, $action) {
|
|
1002 |
return false;
|
1003 |
}
|
1004 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1005 |
function ai_post_check ($post, $action) {
|
1006 |
global $ai_wp_data, $ad_inserter_globals;
|
1007 |
|
@@ -1021,7 +1050,7 @@ function ai_post_check ($post, $action) {
|
|
1021 |
|
1022 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
|
1023 |
|
1024 |
-
return true
|
1025 |
}
|
1026 |
|
1027 |
function ai_hook_function_loop_start ($hook_parameter) {
|
@@ -1100,7 +1129,6 @@ function ai_custom_hook_function_9 () {
|
|
1100 |
ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
|
1101 |
}
|
1102 |
|
1103 |
-
|
1104 |
function ai_wp_hook () {
|
1105 |
global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks;
|
1106 |
|
@@ -1204,69 +1232,14 @@ function ai_wp_hook () {
|
|
1204 |
$ai_walker = new ai_Walker_Comment;
|
1205 |
}
|
1206 |
|
1207 |
-
// Code for PHP VERSION >= 5.3.0
|
1208 |
-
// function ai_get_custom_hook_function ($action, $name) {
|
1209 |
-
// return function () use ($action, $name) {
|
1210 |
-
// ai_custom_hook ($action, $name);
|
1211 |
-
// };
|
1212 |
-
// }
|
1213 |
|
|
|
1214 |
// foreach ($ai_custom_hooks as $index => $custom_hook) {
|
1215 |
// if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
|
1216 |
// add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], $custom_hook ['name']), $custom_hook ['priority']);
|
1217 |
// }
|
1218 |
|
1219 |
// Code for PHP VERSION < 5.3.0
|
1220 |
-
// function ai_custom_hook_function_0 () {
|
1221 |
-
// global $ai_custom_hooks;
|
1222 |
-
// ai_custom_hook ($ai_custom_hooks [0]['action'], $ai_custom_hooks [0]['name']);
|
1223 |
-
// }
|
1224 |
-
|
1225 |
-
// function ai_custom_hook_function_1 () {
|
1226 |
-
// global $ai_custom_hooks;
|
1227 |
-
// ai_custom_hook ($ai_custom_hooks [1]['action'], $ai_custom_hooks [1]['name']);
|
1228 |
-
// }
|
1229 |
-
|
1230 |
-
// function ai_custom_hook_function_2 () {
|
1231 |
-
// global $ai_custom_hooks;
|
1232 |
-
// ai_custom_hook ($ai_custom_hooks [2]['action'], $ai_custom_hooks [2]['name']);
|
1233 |
-
// }
|
1234 |
-
|
1235 |
-
// function ai_custom_hook_function_3 () {
|
1236 |
-
// global $ai_custom_hooks;
|
1237 |
-
// ai_custom_hook ($ai_custom_hooks [3]['action'], $ai_custom_hooks [3]['name']);
|
1238 |
-
// }
|
1239 |
-
|
1240 |
-
// function ai_custom_hook_function_4 () {
|
1241 |
-
// global $ai_custom_hooks;
|
1242 |
-
// ai_custom_hook ($ai_custom_hooks [4]['action'], $ai_custom_hooks [4]['name']);
|
1243 |
-
// }
|
1244 |
-
|
1245 |
-
// function ai_custom_hook_function_5 () {
|
1246 |
-
// global $ai_custom_hooks;
|
1247 |
-
// ai_custom_hook ($ai_custom_hooks [5]['action'], $ai_custom_hooks [5]['name']);
|
1248 |
-
// }
|
1249 |
-
|
1250 |
-
// function ai_custom_hook_function_6 () {
|
1251 |
-
// global $ai_custom_hooks;
|
1252 |
-
// ai_custom_hook ($ai_custom_hooks [6]['action'], $ai_custom_hooks [6]['name']);
|
1253 |
-
// }
|
1254 |
-
|
1255 |
-
// function ai_custom_hook_function_7 () {
|
1256 |
-
// global $ai_custom_hooks;
|
1257 |
-
// ai_custom_hook ($ai_custom_hooks [7]['action'], $ai_custom_hooks [7]['name']);
|
1258 |
-
// }
|
1259 |
-
|
1260 |
-
// function ai_custom_hook_function_8 () {
|
1261 |
-
// global $ai_custom_hooks;
|
1262 |
-
// ai_custom_hook ($ai_custom_hooks [8]['action'], $ai_custom_hooks [8]['name']);
|
1263 |
-
// }
|
1264 |
-
|
1265 |
-
// function ai_custom_hook_function_9 () {
|
1266 |
-
// global $ai_custom_hooks;
|
1267 |
-
// ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
|
1268 |
-
// }
|
1269 |
-
|
1270 |
foreach ($ai_custom_hooks as $index => $custom_hook) {
|
1271 |
if ($index > 9) break;
|
1272 |
|
@@ -1275,7 +1248,6 @@ function ai_wp_hook () {
|
|
1275 |
}
|
1276 |
|
1277 |
|
1278 |
-
|
1279 |
if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
|
1280 |
// AMP, Accelerated Mobile Pages
|
1281 |
add_action ('amp_post_template_head', 'ai_amp_head_hook');
|
@@ -1340,6 +1312,21 @@ function ai_init_hook() {
|
|
1340 |
add_shortcode ('ADINSERTER', 'process_shortcodes_uc');
|
1341 |
}
|
1342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1343 |
function ai_admin_menu_hook () {
|
1344 |
global $ai_settings_page;
|
1345 |
|
@@ -1416,12 +1403,14 @@ function ai_clean_url ( $url, $original_url){
|
|
1416 |
function add_head_inline_styles_and_scripts () {
|
1417 |
global $ai_wp_data;
|
1418 |
|
1419 |
-
if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
|
1420 |
-
|
1421 |
echo "<style type='text/css'>\n";
|
1422 |
|
1423 |
if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
|
1424 |
|
|
|
|
|
1425 |
if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
|
1426 |
echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
|
1427 |
content: '\\f111';
|
@@ -1475,6 +1464,20 @@ function add_head_inline_styles_and_scripts () {
|
|
1475 |
}
|
1476 |
}
|
1477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1478 |
function ai_get_js ($js_name, $replace_js_data = true) {
|
1479 |
global $ai_wp_data;
|
1480 |
|
@@ -1598,7 +1601,7 @@ function ai_adb_code () {
|
|
1598 |
}
|
1599 |
|
1600 |
function add_footer_inline_scripts () {
|
1601 |
-
global $ai_wp_data, $
|
1602 |
|
1603 |
if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
|
1604 |
|
@@ -1614,6 +1617,11 @@ function add_footer_inline_scripts () {
|
|
1614 |
|
1615 |
$inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS] || (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
|
1616 |
|
|
|
|
|
|
|
|
|
|
|
1617 |
if ($ai_wp_data [AI_STICKY_WIDGETS] && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS) {
|
1618 |
// echo "<script type='text/javascript' src='", plugins_url ('includes/js/ResizeSensor.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
|
1619 |
echo "<script type='text/javascript' src='", plugins_url ('includes/js/theia-sticky-sidebar.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
|
@@ -1671,13 +1679,15 @@ function ai_admin_notice_hook () {
|
|
1671 |
if (function_exists ('ai_admin_notices')) ai_admin_notices (); else {
|
1672 |
if (is_super_admin () && !wp_is_mobile () && isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
|
1673 |
|
1674 |
-
|
|
|
|
|
1675 |
|
1676 |
-
(get_option ('ai-notice-review') == 'later' && ($
|
1677 |
-
$
|
1678 |
|
1679 |
if (get_option ('ai-notice-review') == 'later') {
|
1680 |
-
$message = "Hey, you are now using <strong>{$
|
1681 |
$option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
|
1682 |
} else {
|
1683 |
$message = "Hey, you've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.";
|
@@ -1964,9 +1974,9 @@ function get_page_type_debug_info ($text = '') {
|
|
1964 |
$page_type = 'UNKNOWN PAGE TYPE';
|
1965 |
break;
|
1966 |
}
|
1967 |
-
$
|
1968 |
|
1969 |
-
$page_type = "<section
|
1970 |
|
1971 |
return $page_type;
|
1972 |
}
|
@@ -1978,7 +1988,7 @@ function get_adb_status_debug_info () {
|
|
1978 |
|
1979 |
if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
|
1980 |
if ($ai_wp_data [AI_ADB_DETECTION]) {
|
1981 |
-
$page_type = "<section id='ai-adb-bar'
|
1982 |
}
|
1983 |
}
|
1984 |
|
@@ -2027,23 +2037,23 @@ function ai_wp_head_hook () {
|
|
2027 |
$obj = $block_object [AI_HEADER_OPTION_NAME];
|
2028 |
// $obj->clear_code_cache (); // cleared at ai_http_header
|
2029 |
|
2030 |
-
if (!$obj->check_server_side_detection ()) return;
|
2031 |
-
|
2032 |
if ($obj->get_enable_manual ()) {
|
2033 |
-
if ($
|
2034 |
-
$
|
|
|
2035 |
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
|
2046 |
-
|
|
|
2047 |
}
|
2048 |
}
|
2049 |
|
@@ -2069,6 +2079,12 @@ function ai_wp_head_hook () {
|
|
2069 |
</script>\n";
|
2070 |
}
|
2071 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2072 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
2073 |
$ai_total_plugin_time += microtime (true) - $start_time;
|
2074 |
ai_log ("HEAD HOOK END\n");
|
@@ -2083,28 +2099,28 @@ function ai_amp_head_hook () {
|
|
2083 |
$start_time = microtime (true);
|
2084 |
}
|
2085 |
|
2086 |
-
|
2087 |
|
2088 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
|
2089 |
|
2090 |
$obj = $block_object [AI_HEADER_OPTION_NAME];
|
2091 |
// $obj->clear_code_cache (); // cleared at ai_http_header
|
2092 |
|
2093 |
-
if (!$obj->check_server_side_detection ()) return;
|
2094 |
-
|
2095 |
if ($obj->get_enable_manual ()) {
|
2096 |
-
if ($
|
2097 |
-
$
|
|
|
2098 |
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
|
|
2108 |
}
|
2109 |
}
|
2110 |
}
|
@@ -2129,6 +2145,12 @@ function ai_amp_head_hook () {
|
|
2129 |
//</script>\n";
|
2130 |
// }
|
2131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2132 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
2133 |
$ai_total_plugin_time += microtime (true) - $start_time;
|
2134 |
ai_log ("HEAD HOOK END\n");
|
@@ -2144,13 +2166,19 @@ function ai_wp_footer_hook () {
|
|
2144 |
$start_time = microtime (true);
|
2145 |
}
|
2146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2147 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
|
2148 |
|
2149 |
$footer = $block_object [AI_FOOTER_OPTION_NAME];
|
2150 |
$footer->clear_code_cache ();
|
2151 |
|
2152 |
-
if ($footer->
|
2153 |
-
if ($footer->
|
2154 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
|
2155 |
$processed_code = do_shortcode ($footer->ai_getCode ());
|
2156 |
|
@@ -2186,6 +2214,12 @@ function ai_amp_footer_hook () {
|
|
2186 |
$start_time = microtime (true);
|
2187 |
}
|
2188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2189 |
// if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
|
2190 |
// add_footer_inline_scripts ();
|
2191 |
// }
|
@@ -2195,16 +2229,16 @@ function ai_amp_footer_hook () {
|
|
2195 |
$obj = $block_object [AI_FOOTER_OPTION_NAME];
|
2196 |
$obj->clear_code_cache ();
|
2197 |
|
2198 |
-
if (!$obj->check_server_side_detection ()) return;
|
2199 |
-
|
2200 |
if ($obj->get_enable_manual ()) {
|
2201 |
-
if ($
|
2202 |
-
$
|
|
|
2203 |
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
|
|
2208 |
}
|
2209 |
}
|
2210 |
}
|
@@ -2876,6 +2910,14 @@ function get_viewport_css () {
|
|
2876 |
return ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS']);
|
2877 |
}
|
2878 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2879 |
function get_syntax_highlighter_theme () {
|
2880 |
global $ai_db_options;
|
2881 |
|
@@ -3329,13 +3371,32 @@ function ai_ajax_backend () {
|
|
3329 |
if (isset ($_POST ["preview"])) {
|
3330 |
$block = urldecode ($_POST ["preview"]);
|
3331 |
if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
|
3332 |
-
generate_code_preview (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3333 |
}
|
3334 |
elseif ($block == 'adb') {
|
3335 |
generate_code_preview_adb ($block);
|
3336 |
}
|
3337 |
}
|
3338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3339 |
elseif (isset ($_GET ["image"])) {
|
3340 |
header ("Content-Type: image/png");
|
3341 |
header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
|
@@ -3371,6 +3432,10 @@ function ai_ajax_backend () {
|
|
3371 |
update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
|
3372 |
}
|
3373 |
|
|
|
|
|
|
|
|
|
3374 |
elseif (function_exists ('ai_ajax_backend_2')) {
|
3375 |
ai_ajax_backend_2 ();
|
3376 |
}
|
@@ -3381,12 +3446,17 @@ function ai_ajax_backend () {
|
|
3381 |
function ai_generate_extract (&$settings) {
|
3382 |
global $ai_custom_hooks;
|
3383 |
|
3384 |
-
|
|
|
3385 |
|
3386 |
$obj = new ai_Block (1);
|
3387 |
|
3388 |
$extract = array ();
|
3389 |
|
|
|
|
|
|
|
|
|
3390 |
$content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3391 |
$excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3392 |
$loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
@@ -3427,7 +3497,7 @@ function ai_generate_extract (&$settings) {
|
|
3427 |
$widget_blocks = array_unique ($widget_blocks);
|
3428 |
|
3429 |
// Generate extracted data
|
3430 |
-
$
|
3431 |
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
3432 |
|
3433 |
if (!isset ($settings [$block])) continue;
|
@@ -3449,6 +3519,12 @@ function ai_generate_extract (&$settings) {
|
|
3449 |
$automatic_insertion = $obj->get_automatic_insertion();
|
3450 |
if ($page_types) {
|
3451 |
switch ($automatic_insertion) {
|
|
|
|
|
|
|
|
|
|
|
|
|
3452 |
case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
|
3453 |
case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
|
3454 |
case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
|
@@ -3504,12 +3580,16 @@ function ai_generate_extract (&$settings) {
|
|
3504 |
$manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
|
3505 |
$manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
|
3506 |
if ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function) {
|
3507 |
-
$
|
3508 |
}
|
3509 |
}
|
3510 |
|
3511 |
-
$extract [AI_EXTRACT_USED_BLOCKS] = $
|
3512 |
|
|
|
|
|
|
|
|
|
3513 |
$extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
|
3514 |
$extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
|
3515 |
$extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
|
@@ -3531,7 +3611,8 @@ function ai_generate_extract (&$settings) {
|
|
3531 |
}
|
3532 |
|
3533 |
function ai_load_settings () {
|
3534 |
-
global $ai_db_options, $block_object, $
|
|
|
3535 |
|
3536 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
|
3537 |
|
@@ -3546,15 +3627,17 @@ function ai_load_settings () {
|
|
3546 |
}
|
3547 |
}
|
3548 |
|
3549 |
-
|
3550 |
-
|
3551 |
-
isset ($ai_db_options [
|
3552 |
-
isset ($ai_db_options [
|
3553 |
-
isset ($ai_db_options [
|
3554 |
-
isset ($ai_db_options [
|
3555 |
-
isset ($ai_db_options [
|
3556 |
-
|
3557 |
-
|
|
|
|
|
3558 |
|
3559 |
$obj = new ai_Block (0);
|
3560 |
$obj->wp_options [AI_OPTION_BLOCK_NAME] = 'Default';
|
@@ -3605,10 +3688,7 @@ function generate_viewport_css () {
|
|
3605 |
|
3606 |
$viewport_styles = '';
|
3607 |
if (count ($viewports) != 0) {
|
3608 |
-
// $viewport_styles .= "/* " . AD_INSERTER_NAME . " version " . AD_INSERTER_VERSION ." - viewport classes */\n\n";
|
3609 |
-
// $viewport_styles .= "/* DO NOT MODIFY - This file is automatically generated when you save ".AD_INSERTER_NAME." settings */\n";
|
3610 |
foreach ($viewports as $index => $viewport) {
|
3611 |
-
// $viewport_styles .= "\n/* " . $viewport ['name'] . " */\n\n";
|
3612 |
if ($viewport ['index'] == 1) {
|
3613 |
foreach (array_reverse ($viewports) as $index2 => $viewport2) {
|
3614 |
if ($viewport2 ['index'] != 1) {
|
@@ -3636,9 +3716,124 @@ function generate_viewport_css () {
|
|
3636 |
return ($viewport_styles);
|
3637 |
}
|
3638 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3639 |
|
3640 |
function ai_settings () {
|
3641 |
-
global $ai_db_options, $block_object, $wpdb;
|
3642 |
|
3643 |
if (isset ($_POST [AI_FORM_SAVE])) {
|
3644 |
|
@@ -3788,7 +3983,8 @@ function ai_settings () {
|
|
3788 |
if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-enabled-'.$hook]);
|
3789 |
}
|
3790 |
|
3791 |
-
$options ['VIEWPORT_CSS']
|
|
|
3792 |
|
3793 |
$ai_options [AI_OPTION_GLOBAL] = ai_check_plugin_options ($options);
|
3794 |
}
|
@@ -3800,7 +3996,15 @@ function ai_settings () {
|
|
3800 |
}
|
3801 |
|
3802 |
// Generate and save extract
|
3803 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3804 |
|
3805 |
$ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
|
3806 |
|
@@ -3890,6 +4094,10 @@ function ai_settings () {
|
|
3890 |
|
3891 |
ai_load_settings ();
|
3892 |
|
|
|
|
|
|
|
|
|
3893 |
if (function_exists ('ai_load_globals')) ai_load_globals ();
|
3894 |
|
3895 |
echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</strong></p></div>";
|
@@ -4147,29 +4355,29 @@ function ai_content_hook ($content = '') {
|
|
4147 |
if (function_exists ('ai_content')) ai_content ($content);
|
4148 |
|
4149 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
4150 |
-
$
|
4151 |
|
4152 |
-
$content = preg_replace ("/\r\n\r\n/", "\r\n\r\n<kbd
|
4153 |
|
4154 |
-
$content = preg_replace ("/<p>/i", "<p><kbd
|
4155 |
-
// $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd
|
4156 |
-
$content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd
|
4157 |
-
// $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd
|
4158 |
-
$content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd
|
4159 |
-
$content = preg_replace ("/<h([1-6])([^>]*?)>/i", "<h$1$2><kbd
|
4160 |
-
$content = preg_replace ("/<img([^>]*?)>/i", "<img$1><kbd
|
4161 |
-
$content = preg_replace ("/<pre([^>]*?)>/i", "<pre$1><kbd
|
4162 |
-
$content = preg_replace ("/<(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6]|img)([a-z0-9]+)([^>]*?)>/i", "<$1$2><kbd
|
4163 |
|
4164 |
-
$content = preg_replace ("/<\/p>/i", "<kbd
|
4165 |
-
$content = preg_replace ("/<\/div>/i", "<kbd
|
4166 |
-
$content = preg_replace ("/<\/h([1-6])>/i", "<kbd
|
4167 |
-
$content = preg_replace ("/<\/pre>/i", "<kbd
|
4168 |
-
$content = preg_replace ("/<\/(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6])([a-z0-9]+)>/i", "<kbd
|
4169 |
}
|
4170 |
|
4171 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4172 |
-
$
|
4173 |
|
4174 |
if (!$positions_inserted) {
|
4175 |
$preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
|
@@ -4177,19 +4385,19 @@ function ai_content_hook ($content = '') {
|
|
4177 |
$content = $preview->after_paragraph ($content, true);
|
4178 |
}
|
4179 |
|
4180 |
-
$content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section
|
4181 |
-
$content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section
|
4182 |
|
4183 |
$counter = $ad_inserter_globals [$globals_name];
|
4184 |
if ($counter == 1) $counter = '';
|
4185 |
|
4186 |
-
$content = "<section
|
4187 |
|
4188 |
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
4189 |
$content = get_page_type_debug_info ('AMP ') . $content;
|
4190 |
}
|
4191 |
|
4192 |
-
$content = $content . "<section
|
4193 |
|
4194 |
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
4195 |
$content = $content . get_page_type_debug_info ('AMP ');
|
@@ -4197,7 +4405,7 @@ function ai_content_hook ($content = '') {
|
|
4197 |
}
|
4198 |
|
4199 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
4200 |
-
$content = '<kbd
|
4201 |
}
|
4202 |
|
4203 |
if ($debug_processing) {
|
@@ -4271,12 +4479,12 @@ function ai_excerpt_hook ($content = '') {
|
|
4271 |
if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
|
4272 |
|
4273 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4274 |
-
$
|
4275 |
|
4276 |
-
$content = "<section
|
4277 |
|
4278 |
// Color positions from the content hook
|
4279 |
-
$content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span
|
4280 |
}
|
4281 |
|
4282 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
@@ -4284,7 +4492,7 @@ function ai_excerpt_hook ($content = '') {
|
|
4284 |
$content = preg_replace ("/<(.+?)>/", "", $content);
|
4285 |
|
4286 |
// Color text to mark removed HTML tags
|
4287 |
-
$content = str_replace ('[HTML TAGS REMOVED]', "<span
|
4288 |
}
|
4289 |
|
4290 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
|
@@ -4303,6 +4511,7 @@ function ai_excerpt_hook ($content = '') {
|
|
4303 |
|
4304 |
// Deprecated
|
4305 |
// Process Before / After Post postion
|
|
|
4306 |
function ai_before_after_post ($query, $automatic_insertion) {
|
4307 |
global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
|
4308 |
|
@@ -4329,10 +4538,10 @@ function ai_before_after_post ($query, $automatic_insertion) {
|
|
4329 |
$counter = $ad_inserter_globals [$globals_name];
|
4330 |
if ($counter == 1) $counter = '';
|
4331 |
|
4332 |
-
$
|
4333 |
|
4334 |
if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) echo get_page_type_debug_info ('AMP ');
|
4335 |
-
echo "<section
|
4336 |
if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) echo get_page_type_debug_info ('AMP ');
|
4337 |
}
|
4338 |
|
@@ -4448,9 +4657,9 @@ function ai_post_hook ($post) {
|
|
4448 |
|
4449 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4450 |
|
4451 |
-
$
|
4452 |
|
4453 |
-
echo "<section
|
4454 |
}
|
4455 |
|
4456 |
$ad_code = "";
|
@@ -4497,6 +4706,7 @@ function ai_post_hook ($post) {
|
|
4497 |
|
4498 |
return $post;
|
4499 |
}
|
|
|
4500 |
|
4501 |
function ai_comments_array ($comments , $post_id ){
|
4502 |
global $ai_wp_data;
|
@@ -4552,10 +4762,10 @@ function ai_comment_callback ($comment, $args, $depth) {
|
|
4552 |
|
4553 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4554 |
|
4555 |
-
$
|
4556 |
|
4557 |
echo "<$tag>\n";
|
4558 |
-
echo "<section
|
4559 |
echo "</$tag>\n";
|
4560 |
}
|
4561 |
|
@@ -4645,10 +4855,10 @@ function ai_comment_end_callback ($comment, $args, $depth) {
|
|
4645 |
|
4646 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4647 |
|
4648 |
-
$
|
4649 |
|
4650 |
echo "<$tag>\n";
|
4651 |
-
echo "<section
|
4652 |
echo "</$tag>\n";
|
4653 |
}
|
4654 |
|
@@ -4695,10 +4905,10 @@ function ai_comment_end_callback ($comment, $args, $depth) {
|
|
4695 |
|
4696 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4697 |
|
4698 |
-
$
|
4699 |
|
4700 |
echo "<$tag>\n";
|
4701 |
-
echo "<section
|
4702 |
echo "</$tag>\n";
|
4703 |
}
|
4704 |
|
@@ -4756,6 +4966,8 @@ function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = n
|
|
4756 |
|
4757 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
4758 |
|
|
|
|
|
4759 |
if (isset ($hook_check)) {
|
4760 |
if (!call_user_func ($hook_check, $hook_parameter, $action)) return;
|
4761 |
}
|
@@ -4773,16 +4985,14 @@ function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = n
|
|
4773 |
$ad_inserter_globals [$globals_name] = 1;
|
4774 |
} else $ad_inserter_globals [$globals_name] ++;
|
4775 |
|
4776 |
-
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
|
4777 |
-
|
4778 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4779 |
|
4780 |
$counter = $ad_inserter_globals [$globals_name];
|
4781 |
if ($counter == 1) $counter = '';
|
4782 |
|
4783 |
-
$
|
4784 |
|
4785 |
-
echo "<section
|
4786 |
}
|
4787 |
|
4788 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
+
Version: 2.2.6
|
5 |
+
Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
|
6 |
Author: Igor Funa
|
7 |
Author URI: http://igorfuna.com/
|
8 |
Plugin URI: http://adinserter.pro/documentation
|
12 |
|
13 |
Change Log
|
14 |
|
15 |
+
Ad Inserter 2.2.6 - 2017-11-07
|
16 |
+
- Fix for posts filter counter not counting
|
17 |
+
- Added list with short overview of all code blocks
|
18 |
+
- Added support for word count on blog pages
|
19 |
+
- Added support for client code preview (no need to save it for preview)
|
20 |
+
- Improved compatibility on AMP pages
|
21 |
+
- Few minor bug fixes, cosmetic changes and code improvements
|
22 |
+
|
23 |
Ad Inserter 2.2.5 - 2017-10-15
|
24 |
- Fix for issue with Ajax requests
|
25 |
|
635 |
define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
|
636 |
|
637 |
|
638 |
+
add_action ('wp_loaded', 'ai_wp_loaded_hook');
|
639 |
+
|
640 |
add_action ('admin_menu', 'ai_admin_menu_hook');
|
641 |
|
642 |
add_action ('init', 'ai_init_hook');
|
670 |
}
|
671 |
|
672 |
|
673 |
+
|
674 |
function ai_toolbar ($wp_admin_bar) {
|
675 |
global $block_object, $ai_wp_data;
|
676 |
|
1013 |
return false;
|
1014 |
}
|
1015 |
|
1016 |
+
|
1017 |
+
function ai_buffering_start () {
|
1018 |
+
ob_start ();
|
1019 |
+
define ('AI_BUFFERING_START', true);
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
function ai_buffering_end () {
|
1023 |
+
|
1024 |
+
if (!defined ('AI_BUFFERING_START')) return;
|
1025 |
+
|
1026 |
+
$page = ob_get_clean();
|
1027 |
+
$matches = preg_split ('/(<body.*?'.'>)/i', $page, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
1028 |
+
|
1029 |
+
echo $matches [0], $matches [1];
|
1030 |
+
ai_custom_hook ('above_header', 'Above Header');
|
1031 |
+
echo $matches [2];
|
1032 |
+
}
|
1033 |
+
|
1034 |
function ai_post_check ($post, $action) {
|
1035 |
global $ai_wp_data, $ad_inserter_globals;
|
1036 |
|
1050 |
|
1051 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
|
1052 |
|
1053 |
+
return true;
|
1054 |
}
|
1055 |
|
1056 |
function ai_hook_function_loop_start ($hook_parameter) {
|
1129 |
ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
|
1130 |
}
|
1131 |
|
|
|
1132 |
function ai_wp_hook () {
|
1133 |
global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks;
|
1134 |
|
1232 |
$ai_walker = new ai_Walker_Comment;
|
1233 |
}
|
1234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1235 |
|
1236 |
+
// Code for PHP VERSION >= 5.3.0
|
1237 |
// foreach ($ai_custom_hooks as $index => $custom_hook) {
|
1238 |
// if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
|
1239 |
// add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], $custom_hook ['name']), $custom_hook ['priority']);
|
1240 |
// }
|
1241 |
|
1242 |
// Code for PHP VERSION < 5.3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1243 |
foreach ($ai_custom_hooks as $index => $custom_hook) {
|
1244 |
if ($index > 9) break;
|
1245 |
|
1248 |
}
|
1249 |
|
1250 |
|
|
|
1251 |
if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
|
1252 |
// AMP, Accelerated Mobile Pages
|
1253 |
add_action ('amp_post_template_head', 'ai_amp_head_hook');
|
1312 |
add_shortcode ('ADINSERTER', 'process_shortcodes_uc');
|
1313 |
}
|
1314 |
|
1315 |
+
function ai_wp_loaded_hook () {
|
1316 |
+
global $ai_db_options, $ai_db_options_extract, $version_string;
|
1317 |
+
|
1318 |
+
if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
|
1319 |
+
isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
|
1320 |
+
isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
|
1321 |
+
isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
|
1322 |
+
isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
|
1323 |
+
isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
|
1324 |
+
@unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
|
1325 |
+
isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
|
1326 |
+
$ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
|
1327 |
+
$ai_db_options_extract = ai_generate_extract ($ai_db_options);
|
1328 |
+
}
|
1329 |
+
|
1330 |
function ai_admin_menu_hook () {
|
1331 |
global $ai_settings_page;
|
1332 |
|
1403 |
function add_head_inline_styles_and_scripts () {
|
1404 |
global $ai_wp_data;
|
1405 |
|
1406 |
+
if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
|
1407 |
+
|
1408 |
echo "<style type='text/css'>\n";
|
1409 |
|
1410 |
if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
|
1411 |
|
1412 |
+
if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
|
1413 |
+
|
1414 |
if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
|
1415 |
echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
|
1416 |
content: '\\f111';
|
1464 |
}
|
1465 |
}
|
1466 |
|
1467 |
+
function add_amp_head_inline_styles_and_scripts () {
|
1468 |
+
global $ai_wp_data;
|
1469 |
+
|
1470 |
+
if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
|
1471 |
+
echo "<style amp-custom>\n";
|
1472 |
+
|
1473 |
+
if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) echo get_alignment_css ();
|
1474 |
+
|
1475 |
+
if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
|
1476 |
+
|
1477 |
+
echo "</style>\n";
|
1478 |
+
}
|
1479 |
+
}
|
1480 |
+
|
1481 |
function ai_get_js ($js_name, $replace_js_data = true) {
|
1482 |
global $ai_wp_data;
|
1483 |
|
1601 |
}
|
1602 |
|
1603 |
function add_footer_inline_scripts () {
|
1604 |
+
global $ai_wp_data, $wp_version;
|
1605 |
|
1606 |
if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
|
1607 |
|
1617 |
|
1618 |
$inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS] || (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
|
1619 |
|
1620 |
+
if ($inline_scripts && !wp_script_is ('jquery', 'done')) {
|
1621 |
+
echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery.js'), "?ver=", $wp_version, "'></script>\n";
|
1622 |
+
echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery-migrate.min.js'), "?ver=", $wp_version, "'></script>\n";
|
1623 |
+
}
|
1624 |
+
|
1625 |
if ($ai_wp_data [AI_STICKY_WIDGETS] && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS) {
|
1626 |
// echo "<script type='text/javascript' src='", plugins_url ('includes/js/ResizeSensor.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
|
1627 |
echo "<script type='text/javascript' src='", plugins_url ('includes/js/theia-sticky-sidebar.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
|
1679 |
if (function_exists ('ai_admin_notices')) ai_admin_notices (); else {
|
1680 |
if (is_super_admin () && !wp_is_mobile () && isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
|
1681 |
|
1682 |
+
$used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]));
|
1683 |
+
|
1684 |
+
if ((get_option ('ai-notice-review') === false && $used_blocks >= 6 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10) ||
|
1685 |
|
1686 |
+
(get_option ('ai-notice-review') == 'later' && ($used_blocks >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 30 ||
|
1687 |
+
$used_blocks >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 60))) {
|
1688 |
|
1689 |
if (get_option ('ai-notice-review') == 'later') {
|
1690 |
+
$message = "Hey, you are now using <strong>{$used_blocks} Ad Inserter</strong> code blocks.";
|
1691 |
$option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
|
1692 |
} else {
|
1693 |
$message = "Hey, you've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.";
|
1974 |
$page_type = 'UNKNOWN PAGE TYPE';
|
1975 |
break;
|
1976 |
}
|
1977 |
+
$class = AI_DEBUG_PAGE_TYPE_CLASS;
|
1978 |
|
1979 |
+
$page_type = "<section class='$class'>".$text.$page_type."</section>";;
|
1980 |
|
1981 |
return $page_type;
|
1982 |
}
|
1988 |
|
1989 |
if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
|
1990 |
if ($ai_wp_data [AI_ADB_DETECTION]) {
|
1991 |
+
$page_type = "<section id='ai-adb-bar' class='".AI_DEBUG_ADB_CLASS."' title='Click to delete ad blocking detection cokies'>AD BLOCKING <span id='ai-adb-status'>STATUS UNKNOWN</span></section>";
|
1992 |
}
|
1993 |
}
|
1994 |
|
2037 |
$obj = $block_object [AI_HEADER_OPTION_NAME];
|
2038 |
// $obj->clear_code_cache (); // cleared at ai_http_header
|
2039 |
|
|
|
|
|
2040 |
if ($obj->get_enable_manual ()) {
|
2041 |
+
if ($obj->check_server_side_detection ()) {
|
2042 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
|
2043 |
+
$processed_code = do_shortcode ($obj->ai_getCode ());
|
2044 |
|
2045 |
+
if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
|
2046 |
+
$codes = explode (AD_HTTP_SEPARATOR, $processed_code);
|
2047 |
+
$processed_code = ltrim ($codes [1]);
|
2048 |
+
}
|
2049 |
|
2050 |
+
if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
|
2051 |
+
$codes = explode (AD_AMP_SEPARATOR, $processed_code);
|
2052 |
+
$processed_code = $codes [0];
|
2053 |
+
} elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
|
2054 |
|
2055 |
+
echo $processed_code;
|
2056 |
+
}
|
2057 |
}
|
2058 |
}
|
2059 |
|
2079 |
</script>\n";
|
2080 |
}
|
2081 |
|
2082 |
+
if (defined ('AI_BUFFERING')) {
|
2083 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
|
2084 |
+
ai_buffering_start ();
|
2085 |
+
}
|
2086 |
+
}
|
2087 |
+
|
2088 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
2089 |
$ai_total_plugin_time += microtime (true) - $start_time;
|
2090 |
ai_log ("HEAD HOOK END\n");
|
2099 |
$start_time = microtime (true);
|
2100 |
}
|
2101 |
|
2102 |
+
add_amp_head_inline_styles_and_scripts ();
|
2103 |
|
2104 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
|
2105 |
|
2106 |
$obj = $block_object [AI_HEADER_OPTION_NAME];
|
2107 |
// $obj->clear_code_cache (); // cleared at ai_http_header
|
2108 |
|
|
|
|
|
2109 |
if ($obj->get_enable_manual ()) {
|
2110 |
+
if ($obj->check_server_side_detection ()) {
|
2111 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
|
2112 |
+
$processed_code = do_shortcode ($obj->ai_getCode ());
|
2113 |
|
2114 |
+
if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
|
2115 |
+
$codes = explode (AD_HTTP_SEPARATOR, $processed_code);
|
2116 |
+
$processed_code = ltrim ($codes [1]);
|
2117 |
+
}
|
2118 |
|
2119 |
+
if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
|
2120 |
+
$codes = explode (AD_AMP_SEPARATOR, $processed_code);
|
2121 |
+
$processed_code = ltrim ($codes [1]);
|
2122 |
+
echo $processed_code;
|
2123 |
+
}
|
2124 |
}
|
2125 |
}
|
2126 |
}
|
2145 |
//</script>\n";
|
2146 |
// }
|
2147 |
|
2148 |
+
if (defined ('AI_BUFFERING')) {
|
2149 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
|
2150 |
+
ai_buffering_start ();
|
2151 |
+
}
|
2152 |
+
}
|
2153 |
+
|
2154 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
|
2155 |
$ai_total_plugin_time += microtime (true) - $start_time;
|
2156 |
ai_log ("HEAD HOOK END\n");
|
2166 |
$start_time = microtime (true);
|
2167 |
}
|
2168 |
|
2169 |
+
if (defined ('AI_BUFFERING')) {
|
2170 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
|
2171 |
+
ai_buffering_end ();
|
2172 |
+
}
|
2173 |
+
}
|
2174 |
+
|
2175 |
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
|
2176 |
|
2177 |
$footer = $block_object [AI_FOOTER_OPTION_NAME];
|
2178 |
$footer->clear_code_cache ();
|
2179 |
|
2180 |
+
if ($footer->get_enable_manual ()) {
|
2181 |
+
if ($footer->check_server_side_detection ()) {
|
2182 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
|
2183 |
$processed_code = do_shortcode ($footer->ai_getCode ());
|
2184 |
|
2214 |
$start_time = microtime (true);
|
2215 |
}
|
2216 |
|
2217 |
+
if (defined ('AI_BUFFERING')) {
|
2218 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
|
2219 |
+
ai_buffering_end ();
|
2220 |
+
}
|
2221 |
+
}
|
2222 |
+
|
2223 |
// if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
|
2224 |
// add_footer_inline_scripts ();
|
2225 |
// }
|
2229 |
$obj = $block_object [AI_FOOTER_OPTION_NAME];
|
2230 |
$obj->clear_code_cache ();
|
2231 |
|
|
|
|
|
2232 |
if ($obj->get_enable_manual ()) {
|
2233 |
+
if ($obj->check_server_side_detection ()) {
|
2234 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
|
2235 |
+
$processed_code = do_shortcode ($obj->ai_getCode ());
|
2236 |
|
2237 |
+
if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
|
2238 |
+
$codes = explode (AD_AMP_SEPARATOR, $processed_code);
|
2239 |
+
$processed_code = ltrim ($codes [1]);
|
2240 |
+
echo $processed_code;
|
2241 |
+
}
|
2242 |
}
|
2243 |
}
|
2244 |
}
|
2910 |
return ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS']);
|
2911 |
}
|
2912 |
|
2913 |
+
function get_alignment_css () {
|
2914 |
+
global $ai_db_options;
|
2915 |
+
|
2916 |
+
if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
|
2917 |
+
|
2918 |
+
return ($ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']);
|
2919 |
+
}
|
2920 |
+
|
2921 |
function get_syntax_highlighter_theme () {
|
2922 |
global $ai_db_options;
|
2923 |
|
3371 |
if (isset ($_POST ["preview"])) {
|
3372 |
$block = urldecode ($_POST ["preview"]);
|
3373 |
if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
|
3374 |
+
generate_code_preview (
|
3375 |
+
$block,
|
3376 |
+
wp_unslash (urldecode ($_POST ["name"])),
|
3377 |
+
urldecode ($_POST ["alignment"]),
|
3378 |
+
wp_unslash (urldecode ($_POST ["alignment_css"])),
|
3379 |
+
wp_unslash (urldecode ($_POST ["custom_css"])),
|
3380 |
+
wp_unslash (urldecode ($_POST ["code"])),
|
3381 |
+
urldecode ($_POST ["php"]) == 'true');
|
3382 |
}
|
3383 |
elseif ($block == 'adb') {
|
3384 |
generate_code_preview_adb ($block);
|
3385 |
}
|
3386 |
}
|
3387 |
|
3388 |
+
elseif (isset ($_GET ["generate-code"])) {
|
3389 |
+
$code_generator = new ai_code_generator ();
|
3390 |
+
|
3391 |
+
echo $code_generator->generate ($_GET);
|
3392 |
+
}
|
3393 |
+
|
3394 |
+
elseif (isset ($_GET ["import-code"])) {
|
3395 |
+
$code_generator = new ai_code_generator ();
|
3396 |
+
|
3397 |
+
echo json_encode ($code_generator->import (wp_unslash ($_GET ["import-code"])));
|
3398 |
+
}
|
3399 |
+
|
3400 |
elseif (isset ($_GET ["image"])) {
|
3401 |
header ("Content-Type: image/png");
|
3402 |
header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
|
3432 |
update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
|
3433 |
}
|
3434 |
|
3435 |
+
elseif (isset ($_GET ["list"])) {
|
3436 |
+
code_block_list ();
|
3437 |
+
}
|
3438 |
+
|
3439 |
elseif (function_exists ('ai_ajax_backend_2')) {
|
3440 |
ai_ajax_backend_2 ();
|
3441 |
}
|
3446 |
function ai_generate_extract (&$settings) {
|
3447 |
global $ai_custom_hooks;
|
3448 |
|
3449 |
+
if (!defined ('AI_GENERATE_EXTRACT'))
|
3450 |
+
define ('AI_GENERATE_EXTRACT', true);
|
3451 |
|
3452 |
$obj = new ai_Block (1);
|
3453 |
|
3454 |
$extract = array ();
|
3455 |
|
3456 |
+
if (defined ('AI_BUFFERING')) {
|
3457 |
+
$above_header_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3458 |
+
}
|
3459 |
+
|
3460 |
$content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3461 |
$excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3462 |
$loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
|
3497 |
$widget_blocks = array_unique ($widget_blocks);
|
3498 |
|
3499 |
// Generate extracted data
|
3500 |
+
$active_blocks = array ();
|
3501 |
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
3502 |
|
3503 |
if (!isset ($settings [$block])) continue;
|
3519 |
$automatic_insertion = $obj->get_automatic_insertion();
|
3520 |
if ($page_types) {
|
3521 |
switch ($automatic_insertion) {
|
3522 |
+
case AI_AUTOMATIC_INSERTION_ABOVE_HEADER:
|
3523 |
+
if (defined ('AI_BUFFERING')) {
|
3524 |
+
foreach ($page_types as $block_page_type) $above_header_hook_blocks [$block_page_type][]= $block;
|
3525 |
+
$above_header_hook_blocks [AI_PT_ANY][]= $block;
|
3526 |
+
}
|
3527 |
+
break;
|
3528 |
case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
|
3529 |
case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
|
3530 |
case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
|
3580 |
$manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
|
3581 |
$manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
|
3582 |
if ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function) {
|
3583 |
+
$active_blocks []= $block;
|
3584 |
}
|
3585 |
}
|
3586 |
|
3587 |
+
$extract [AI_EXTRACT_USED_BLOCKS] = serialize ($active_blocks);
|
3588 |
|
3589 |
+
|
3590 |
+
if (defined ('AI_BUFFERING')) {
|
3591 |
+
$extract [ABOVE_HEADER_HOOK_BLOCKS] = $above_header_hook_blocks;
|
3592 |
+
}
|
3593 |
$extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
|
3594 |
$extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
|
3595 |
$extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
|
3611 |
}
|
3612 |
|
3613 |
function ai_load_settings () {
|
3614 |
+
global $ai_db_options, $block_object, $ai_wp_data, $version_string, $ai_custom_hooks;
|
3615 |
+
// global $ai_db_options_extract;
|
3616 |
|
3617 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
|
3618 |
|
3627 |
}
|
3628 |
}
|
3629 |
|
3630 |
+
// Sidebars and widgets not loaded yet - moved to ai_wp_loaded_hook
|
3631 |
+
// if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
|
3632 |
+
// isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
|
3633 |
+
// isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
|
3634 |
+
// isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
|
3635 |
+
// isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
|
3636 |
+
// isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
|
3637 |
+
// @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
|
3638 |
+
// isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
|
3639 |
+
// $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
|
3640 |
+
// $ai_db_options_extract = ai_generate_extract ($ai_db_options);
|
3641 |
|
3642 |
$obj = new ai_Block (0);
|
3643 |
$obj->wp_options [AI_OPTION_BLOCK_NAME] = 'Default';
|
3688 |
|
3689 |
$viewport_styles = '';
|
3690 |
if (count ($viewports) != 0) {
|
|
|
|
|
3691 |
foreach ($viewports as $index => $viewport) {
|
|
|
3692 |
if ($viewport ['index'] == 1) {
|
3693 |
foreach (array_reverse ($viewports) as $index2 => $viewport2) {
|
3694 |
if ($viewport2 ['index'] != 1) {
|
3716 |
return ($viewport_styles);
|
3717 |
}
|
3718 |
|
3719 |
+
function get_main_alignment_css ($alt_styles_text) {
|
3720 |
+
if (strpos ($alt_styles_text, "||") !== false) {
|
3721 |
+
$styles = explode ("||", $alt_styles_text);
|
3722 |
+
return $styles [0];
|
3723 |
+
}
|
3724 |
+
return $alt_styles_text;
|
3725 |
+
}
|
3726 |
+
|
3727 |
+
function generate_alignment_css () {
|
3728 |
+
global $ai_db_options_extract, $block_object;
|
3729 |
+
|
3730 |
+
$block_class_name = get_block_class_name ();
|
3731 |
+
if ($block_class_name == '') $block_class_name = 'ai-'; else $block_class_name .= '-';
|
3732 |
+
|
3733 |
+
$styles = array ();
|
3734 |
+
|
3735 |
+
$styles [AI_ALIGNMENT_DEFAULT] = array (AI_TEXT_DEFAULT, get_main_alignment_css (AI_ALIGNMENT_CSS_DEFAULT));
|
3736 |
+
$styles [AI_ALIGNMENT_LEFT] = array (AI_TEXT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_LEFT));
|
3737 |
+
$styles [AI_ALIGNMENT_RIGHT] = array (AI_TEXT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_RIGHT));
|
3738 |
+
$styles [AI_ALIGNMENT_CENTER] = array (AI_TEXT_CENTER, get_main_alignment_css (AI_ALIGNMENT_CSS_CENTER));
|
3739 |
+
$styles [AI_ALIGNMENT_FLOAT_LEFT] = array (AI_TEXT_FLOAT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_LEFT));
|
3740 |
+
$styles [AI_ALIGNMENT_FLOAT_RIGHT] = array (AI_TEXT_FLOAT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_RIGHT));
|
3741 |
+
|
3742 |
+
if (function_exists ('generate_alignment_css_2')) $styles = array_replace ($styles, generate_alignment_css_2 ());
|
3743 |
+
|
3744 |
+
$alignment_css = '';
|
3745 |
+
$alignments = array ();
|
3746 |
+
$used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]);
|
3747 |
+
foreach ($used_blocks as $used_block) {
|
3748 |
+
$obj = $block_object [$used_block];
|
3749 |
+
$alignment_type = $obj->get_alignment_type ();
|
3750 |
+
|
3751 |
+
switch ($alignment_type) {
|
3752 |
+
case AI_ALIGNMENT_DEFAULT:
|
3753 |
+
case AI_ALIGNMENT_LEFT:
|
3754 |
+
case AI_ALIGNMENT_RIGHT:
|
3755 |
+
case AI_ALIGNMENT_CENTER:
|
3756 |
+
case AI_ALIGNMENT_FLOAT_LEFT:
|
3757 |
+
case AI_ALIGNMENT_FLOAT_RIGHT:
|
3758 |
+
case AI_ALIGNMENT_STICKY_LEFT:
|
3759 |
+
case AI_ALIGNMENT_STICKY_RIGHT:
|
3760 |
+
case AI_ALIGNMENT_STICKY_TOP:
|
3761 |
+
case AI_ALIGNMENT_STICKY_BOTTOM:
|
3762 |
+
$alignment_name = strtolower ($styles [$alignment_type][0]);
|
3763 |
+
if (in_array ($alignment_name, $alignments)) continue;
|
3764 |
+
$alignments []= $alignment_name;
|
3765 |
+
$alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $styles [$alignment_type][1] . "}\n";
|
3766 |
+
break;
|
3767 |
+
case AI_ALIGNMENT_CUSTOM_CSS:
|
3768 |
+
$custom_css = $obj->get_custom_css ();
|
3769 |
+
$alignment_name = strtolower (md5 ($custom_css));
|
3770 |
+
if (in_array ($alignment_name, $alignments)) continue;
|
3771 |
+
$alignments []= $alignment_name;
|
3772 |
+
$alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $custom_css . "}\n";
|
3773 |
+
break;
|
3774 |
+
}
|
3775 |
+
}
|
3776 |
+
|
3777 |
+
return $alignment_css;
|
3778 |
+
}
|
3779 |
+
|
3780 |
+
function generate_debug_css () {
|
3781 |
+
?>
|
3782 |
+
.ai-debug-tags {font-weight: bold; color: white; padding: 2px;}
|
3783 |
+
.ai-debug-positions {text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;}
|
3784 |
+
.ai-debug-page-type {text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;}
|
3785 |
+
.ai-debug-adb {text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid red; color: red; background: #fee; opacity: 0.85; cursor: pointer;}
|
3786 |
+
.ai-debug-widget {margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;}
|
3787 |
+
a.ai-debug-left {float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0; box-shadow: none;}
|
3788 |
+
a.ai-debug-right {float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0; box-shadow: none;}
|
3789 |
+
.ai-debug-invisible {display: none;}
|
3790 |
+
.ai-debug-content-hook-positions {color: blue;}
|
3791 |
+
.ai-debug-removed-html-tags {color: red;}
|
3792 |
+
.ai-debug-rnrn {background: #0ff; color: #000;}
|
3793 |
+
.ai-debug-p {background: #0a0;}
|
3794 |
+
.ai-debug-div {background: #46f;}
|
3795 |
+
.ai-debug-h {background: #d4e;}
|
3796 |
+
.ai-debug-img {background: #ee0; color: #000;}
|
3797 |
+
.ai-debug-pre {background: #222;}
|
3798 |
+
.ai-debug-special {background: #fb0; color: #000;}
|
3799 |
+
|
3800 |
+
.ai-debug-block {border: 1px solid;}
|
3801 |
+
|
3802 |
+
.ai-debug-block.ai-debug-default {border-color: #e00;}
|
3803 |
+
.ai-debug-bar.ai-debug-default {background: #e00;}
|
3804 |
+
|
3805 |
+
.ai-debug-block.ai-debug-viewport-invisible { border-color: #00f;}
|
3806 |
+
.ai-debug-bar.ai-debug-viewport-invisible {background: #00f;}
|
3807 |
+
|
3808 |
+
.ai-debug-block.ai-debug-amp {border-color: #0c0;}
|
3809 |
+
.ai-debug-bar.ai-debug-amp {background: #0c0;}
|
3810 |
+
|
3811 |
+
.ai-debug-block.ai-debug-normal {border-color: #222;}
|
3812 |
+
.ai-debug-bar.ai-debug-normal {background: #222;}
|
3813 |
+
|
3814 |
+
.ai-debug-block.ai-debug-default-amp {border-color: #0c0;}
|
3815 |
+
.ai-debug-bar.ai-debug-default-amp {background: #0c0;}
|
3816 |
+
|
3817 |
+
.ai-debug-block.ai-debug-fallback {border-color: #a0f;}
|
3818 |
+
.ai-debug-bar.ai-debug-fallback {background: #a0f;}
|
3819 |
+
|
3820 |
+
.ai-debug-bar {padding: 1px 0 1px 5px; color: white; font-size: 12px; line-height: 20px; text-align: center;}
|
3821 |
+
.ai-debug-bar-left {text-align: left;}
|
3822 |
+
.ai-debug-bar a {color: white;}
|
3823 |
+
|
3824 |
+
.ai-debug-bar a, .ai-debug-bar a:link, .ai-debug-bar a {text-decoration: none; color: white;}
|
3825 |
+
.ai-debug-bar a.ai-debug-text-left {float: left;}
|
3826 |
+
.ai-debug-bar a.ai-debug-text-right, .ai-debug-bar kbd.ai-debug-text-right {float: right; padding-right: 3px;}
|
3827 |
+
|
3828 |
+
.ai-debug-message {text-align: center; font-weight: bold;}
|
3829 |
+
|
3830 |
+
.ai-debug-bar kbd {padding: 0; color: #fff; font-size: inherit; background-color: transparent; box-shadow: none;}
|
3831 |
+
|
3832 |
+
<?php
|
3833 |
+
}
|
3834 |
|
3835 |
function ai_settings () {
|
3836 |
+
global $ai_db_options, $block_object, $wpdb, $ai_db_options_extract;
|
3837 |
|
3838 |
if (isset ($_POST [AI_FORM_SAVE])) {
|
3839 |
|
3983 |
if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-enabled-'.$hook]);
|
3984 |
}
|
3985 |
|
3986 |
+
// $options ['VIEWPORT_CSS'] = generate_viewport_css ();
|
3987 |
+
// $options ['ALIGNMENT_CSS'] = generate_alignment_css ();
|
3988 |
|
3989 |
$ai_options [AI_OPTION_GLOBAL] = ai_check_plugin_options ($options);
|
3990 |
}
|
3996 |
}
|
3997 |
|
3998 |
// Generate and save extract
|
3999 |
+
// Save new options as some function may need new settings
|
4000 |
+
update_option (AI_OPTION_NAME, $ai_options);
|
4001 |
+
ai_load_settings ();
|
4002 |
+
|
4003 |
+
$ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
|
4004 |
+
$ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
|
4005 |
+
|
4006 |
+
$ai_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css ();
|
4007 |
+
$ai_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
|
4008 |
|
4009 |
$ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
|
4010 |
|
4094 |
|
4095 |
ai_load_settings ();
|
4096 |
|
4097 |
+
// Generate extract
|
4098 |
+
$ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
|
4099 |
+
$ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
|
4100 |
+
|
4101 |
if (function_exists ('ai_load_globals')) ai_load_globals ();
|
4102 |
|
4103 |
echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</strong></p></div>";
|
4355 |
if (function_exists ('ai_content')) ai_content ($content);
|
4356 |
|
4357 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
4358 |
+
$class = AI_DEBUG_TAGS_CLASS;
|
4359 |
|
4360 |
+
$content = preg_replace ("/\r\n\r\n/", "\r\n\r\n<kbd class='$class ai-debug-rnrn'>\\r\\n\\r\\n</kbd>", $content);
|
4361 |
|
4362 |
+
$content = preg_replace ("/<p>/i", "<p><kbd class='$class ai-debug-p'><p></kbd>", $content);
|
4363 |
+
// $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'><p$1></kbd>", $content); // Full p tags
|
4364 |
+
$content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'><p></kbd>", $content);
|
4365 |
+
// $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'><div$1></kbd>", $content); // Full div tags
|
4366 |
+
$content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'><div></kbd>", $content);
|
4367 |
+
$content = preg_replace ("/<h([1-6])([^>]*?)>/i", "<h$1$2><kbd class='$class ai-debug-h'><h$1></kbd>", $content);
|
4368 |
+
$content = preg_replace ("/<img([^>]*?)>/i", "<img$1><kbd class='$class ai-debug-img'><img$1></kbd>", $content);
|
4369 |
+
$content = preg_replace ("/<pre([^>]*?)>/i", "<pre$1><kbd class='$class ai-debug-pre'><pre></kbd>", $content);
|
4370 |
+
$content = preg_replace ("/<(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6]|img)([a-z0-9]+)([^>]*?)>/i", "<$1$2><kbd class='$class ai-debug-special'><$1$2></kbd>", $content);
|
4371 |
|
4372 |
+
$content = preg_replace ("/<\/p>/i", "<kbd class='$class ai-debug-p'></p></kbd></p>", $content);
|
4373 |
+
$content = preg_replace ("/<\/div>/i", "<kbd class='$class ai-debug-div'></div></kbd></div>", $content);
|
4374 |
+
$content = preg_replace ("/<\/h([1-6])>/i", "<kbd class='$class ai-debug-h'></h$1></kbd></h$1>", $content);
|
4375 |
+
$content = preg_replace ("/<\/pre>/i", "<kbd class='$class ai-debug-pre'></pre></kbd></pre>", $content);
|
4376 |
+
$content = preg_replace ("/<\/(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6])([a-z0-9]+)>/i", "<kbd class='$class ai-debug-special'></$1></kbd></$1>", $content);
|
4377 |
}
|
4378 |
|
4379 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4380 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4381 |
|
4382 |
if (!$positions_inserted) {
|
4383 |
$preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
|
4385 |
$content = $preview->after_paragraph ($content, true);
|
4386 |
}
|
4387 |
|
4388 |
+
$content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section class='$class'>BEFORE PARAGRAPH $1</section>", $content);
|
4389 |
+
$content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section class='$class'>AFTER PARAGRAPH $1</section>", $content);
|
4390 |
|
4391 |
$counter = $ad_inserter_globals [$globals_name];
|
4392 |
if ($counter == 1) $counter = '';
|
4393 |
|
4394 |
+
$content = "<section class='$class'><a class='ai-debug-left'> </a> BEFORE CONTENT ".$counter."<a class='ai-debug-right'>".$content_words." words</a></section>". $content;
|
4395 |
|
4396 |
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
4397 |
$content = get_page_type_debug_info ('AMP ') . $content;
|
4398 |
}
|
4399 |
|
4400 |
+
$content = $content . "<section class='$class'>AFTER CONTENT ".$counter."</section>";
|
4401 |
|
4402 |
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
4403 |
$content = $content . get_page_type_debug_info ('AMP ');
|
4405 |
}
|
4406 |
|
4407 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
4408 |
+
$content = '<kbd class="ai-debug-invisible">[HTML TAGS REMOVED]</kbd>' . $content;
|
4409 |
}
|
4410 |
|
4411 |
if ($debug_processing) {
|
4479 |
if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
|
4480 |
|
4481 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4482 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4483 |
|
4484 |
+
$content = "<section class='$class'>BEFORE EXCERPT ".$ad_inserter_globals [$globals_name]."</section>". $content . "<section class='$class'>AFTER EXCERPT ".$ad_inserter_globals [$globals_name]."</section>";
|
4485 |
|
4486 |
// Color positions from the content hook
|
4487 |
+
$content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span class='ai-debug-content-hook-positions'> [$1] </span>", $content);
|
4488 |
}
|
4489 |
|
4490 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
|
4492 |
$content = preg_replace ("/<(.+?)>/", "", $content);
|
4493 |
|
4494 |
// Color text to mark removed HTML tags
|
4495 |
+
$content = str_replace ('[HTML TAGS REMOVED]', "<span class='ai-debug-removed-html-tags'>[HTML TAGS REMOVED]</span>", $content);
|
4496 |
}
|
4497 |
|
4498 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
|
4511 |
|
4512 |
// Deprecated
|
4513 |
// Process Before / After Post postion
|
4514 |
+
/*
|
4515 |
function ai_before_after_post ($query, $automatic_insertion) {
|
4516 |
global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
|
4517 |
|
4538 |
$counter = $ad_inserter_globals [$globals_name];
|
4539 |
if ($counter == 1) $counter = '';
|
4540 |
|
4541 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4542 |
|
4543 |
if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) echo get_page_type_debug_info ('AMP ');
|
4544 |
+
echo "<section class='$class'>".($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
|
4545 |
if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) echo get_page_type_debug_info ('AMP ');
|
4546 |
}
|
4547 |
|
4657 |
|
4658 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4659 |
|
4660 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4661 |
|
4662 |
+
echo "<section class='$class'>BETWEEN POSTS ".$ad_inserter_globals [AI_POST_COUNTER_NAME]."</section>";
|
4663 |
}
|
4664 |
|
4665 |
$ad_code = "";
|
4706 |
|
4707 |
return $post;
|
4708 |
}
|
4709 |
+
*/
|
4710 |
|
4711 |
function ai_comments_array ($comments , $post_id ){
|
4712 |
global $ai_wp_data;
|
4762 |
|
4763 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4764 |
|
4765 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4766 |
|
4767 |
echo "<$tag>\n";
|
4768 |
+
echo "<section class='$class'>BEFORE COMMENTS</section>";
|
4769 |
echo "</$tag>\n";
|
4770 |
}
|
4771 |
|
4855 |
|
4856 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4857 |
|
4858 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4859 |
|
4860 |
echo "<$tag>\n";
|
4861 |
+
echo "<section class='$class'>AFTER COMMENTS</section>";
|
4862 |
echo "</$tag>\n";
|
4863 |
}
|
4864 |
|
4905 |
|
4906 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4907 |
|
4908 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4909 |
|
4910 |
echo "<$tag>\n";
|
4911 |
+
echo "<section class='$class'>BETWEEN COMMENTS ".$ad_inserter_globals [AI_COMMENT_COUNTER_NAME]."</section>";
|
4912 |
echo "</$tag>\n";
|
4913 |
}
|
4914 |
|
4966 |
|
4967 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
|
4968 |
|
4969 |
+
$ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
|
4970 |
+
|
4971 |
if (isset ($hook_check)) {
|
4972 |
if (!call_user_func ($hook_check, $hook_parameter, $action)) return;
|
4973 |
}
|
4985 |
$ad_inserter_globals [$globals_name] = 1;
|
4986 |
} else $ad_inserter_globals [$globals_name] ++;
|
4987 |
|
|
|
|
|
4988 |
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
|
4989 |
|
4990 |
$counter = $ad_inserter_globals [$globals_name];
|
4991 |
if ($counter == 1) $counter = '';
|
4992 |
|
4993 |
+
$class = AI_DEBUG_POSITIONS_CLASS;
|
4994 |
|
4995 |
+
echo "<section class='$class'>".$hook_name." ".$counter."</section>";
|
4996 |
}
|
4997 |
|
4998 |
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
class.php
CHANGED
@@ -21,7 +21,7 @@ abstract class ai_BaseCodeBlock {
|
|
21 |
$this->w3tc_code = '';
|
22 |
$this->needs_class = false;
|
23 |
$this->code_version = 0;
|
24 |
-
$this->
|
25 |
|
26 |
$this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
|
27 |
$this->wp_options [AI_OPTION_PROCESS_PHP] = AI_DISABLED;
|
@@ -338,15 +338,16 @@ abstract class ai_BaseCodeBlock {
|
|
338 |
unset ($this->wp_options ['GENERATED_CODE']);
|
339 |
}
|
340 |
|
341 |
-
public function ai_getCode (){
|
342 |
global $block_object, $ai_total_php_time, $ai_wp_data;
|
343 |
|
344 |
if ($this->fallback != 0) return $block_object [$this->fallback]->ai_getCode ();
|
345 |
|
346 |
$obj = $this;
|
347 |
-
$code = $obj->get_ad_data();
|
|
|
348 |
|
349 |
-
if ($
|
350 |
|
351 |
$global_name = 'GENERATED_CODE';
|
352 |
if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
|
@@ -1112,10 +1113,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1112 |
return $counters;
|
1113 |
}
|
1114 |
|
1115 |
-
public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
|
1116 |
global $ai_wp_data, $ad_inserter_globals, $block_object;
|
1117 |
|
1118 |
-
$code = $this->ai_getCode ();
|
1119 |
|
1120 |
$processed_code = $this->replace_ai_tags (do_shortcode ($code));
|
1121 |
|
@@ -1134,10 +1135,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1134 |
$dynamic_blocks = get_dynamic_blocks ();
|
1135 |
if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1136 |
|
|
|
1137 |
if (strpos ($processed_code, AD_ROTATE_SEPARATOR) !== false) {
|
1138 |
$ads = explode (AD_ROTATE_SEPARATOR, $processed_code);
|
1139 |
|
1140 |
-
|
|
|
|
|
|
|
1141 |
case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
|
1142 |
$this->code_version = mt_rand (1, count ($ads));
|
1143 |
$processed_code = trim ($ads [$this->code_version - 1]);
|
@@ -1146,6 +1151,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1146 |
$this->code_version = '""';
|
1147 |
$processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
|
1148 |
foreach ($ads as $index => $ad) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1149 |
switch ($index) {
|
1150 |
case 0:
|
1151 |
$processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'>\n".trim ($ad, "\n")."\n</div>\n";
|
@@ -1166,24 +1178,46 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1166 |
}
|
1167 |
}
|
1168 |
|
1169 |
-
$this->color = '#e00';
|
1170 |
|
1171 |
-
|
1172 |
-
$codes = explode (AD_AMP_SEPARATOR, $processed_code);
|
1173 |
-
$code_index = $ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0;
|
1174 |
-
$this->color = $code_index ? '#0c0' : '#e00';
|
1175 |
-
$processed_code = trim ($codes [$code_index]);
|
1176 |
-
} else {
|
1177 |
-
// AMP page but No AMP separator - don't insert code unless enabled
|
1178 |
-
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
1179 |
-
if (!$this->get_enable_amp ()) {
|
1180 |
-
$processed_code = '';
|
1181 |
-
$this->color = '#222';
|
1182 |
-
} else $this->color = '#0c0';
|
1183 |
-
}
|
1184 |
-
}
|
1185 |
|
1186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1187 |
$countries = trim (str_replace (' ', '', strtoupper ($this->get_ad_country_list (true))));
|
1188 |
$country_list_type = $this->get_ad_country_list_type ();
|
1189 |
|
@@ -1239,12 +1273,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1239 |
$title = '';
|
1240 |
$fallback_code = '';
|
1241 |
if ($this->fallback != 0) {
|
1242 |
-
$this->
|
1243 |
$fallback_block = $block_object [$this->fallback];
|
1244 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_block->number); else $url_parameters = "";
|
1245 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_block->number;
|
1246 |
$fallback_code = ' ⇦ '.
|
1247 |
-
'<a
|
1248 |
}
|
1249 |
$counters = $this->ai_get_counters ($title);
|
1250 |
|
@@ -1252,8 +1286,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1252 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
|
1253 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
|
1254 |
|
1255 |
-
$processed_code = '<section
|
1256 |
-
. $url . '"><kbd
|
1257 |
}
|
1258 |
|
1259 |
return $processed_code;
|
@@ -1274,19 +1308,20 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1274 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
|
1275 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
|
1276 |
|
1277 |
-
$hidden_block_text = '<section
|
1278 |
|
1279 |
$visible_viewports = '';
|
1280 |
for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
|
1281 |
$viewport_name = get_viewport_name ($viewport);
|
1282 |
if ($viewport_name != '') {
|
1283 |
if ($this->get_detection_viewport ($viewport))
|
1284 |
-
$visible_viewports .= '<section class="ai-viewport-' . $viewport .'"
|
1285 |
-
|
|
|
1286 |
}
|
1287 |
}
|
1288 |
|
1289 |
-
$code = "<div
|
1290 |
} else $code = $this->ai_getProcessedCode ();
|
1291 |
|
1292 |
// Prevent empty wrapping div on AMP pages
|
@@ -1295,13 +1330,18 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1295 |
$block_class_name = get_block_class_name ();
|
1296 |
if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
|
1297 |
$viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
|
|
|
|
|
|
|
|
1301 |
} else $class = '';
|
|
|
1302 |
|
1303 |
if ($hidden_widgets) return $hidden_viewports; else {
|
1304 |
-
if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
|
1305 |
|
1306 |
$tracking_code_pre = '';
|
1307 |
$tracking_code_data = '';
|
@@ -1326,7 +1366,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1326 |
}
|
1327 |
}
|
1328 |
|
1329 |
-
|
|
|
|
|
|
|
|
|
1330 |
|
1331 |
$wrapper_after = "</div>\n";
|
1332 |
|
@@ -1334,7 +1378,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1334 |
|
1335 |
if ($this->get_tracking ()) $tracking_code_data = '[#AI_DATA#]';
|
1336 |
|
1337 |
-
|
|
|
|
|
|
|
|
|
1338 |
|
1339 |
$code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
|
1340 |
$code .= $this->w3tc_code.' if ($ai_enabled) echo str_replace (\'[#AI_DATA#]\', base64_encode ("[' . $this->number . ',$ai_index]"), unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_before)).'\'))), $ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_after)).'\'));';
|
@@ -1575,6 +1623,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1575 |
}
|
1576 |
|
1577 |
public function get_viewport_classes (){
|
|
|
|
|
|
|
|
|
1578 |
$viewport_classes = "";
|
1579 |
if ($this->get_detection_client_side ()) {
|
1580 |
$all_viewports = true;
|
@@ -1590,6 +1642,37 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1590 |
return ($viewport_classes);
|
1591 |
}
|
1592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1593 |
public function before_paragraph ($content, $position_preview = false) {
|
1594 |
global $ai_wp_data, $ai_last_check, $special_element_tags;
|
1595 |
|
@@ -2958,20 +3041,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
2958 |
|
2959 |
if ($minimum_words == 0 && $maximum_words == 0) return true;
|
2960 |
|
2961 |
-
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
} else $number_of_words = 0;
|
2974 |
-
|
|
|
|
|
|
|
2975 |
|
2976 |
$ai_last_check = AI_CHECK_MIN_NUMBER_OF_WORDS;
|
2977 |
if ($number_of_words < $minimum_words) return false;
|
@@ -3452,3 +3538,241 @@ class ai_Walker_Comment extends Walker_Comment {
|
|
3452 |
|
3453 |
}
|
3454 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
$this->w3tc_code = '';
|
22 |
$this->needs_class = false;
|
23 |
$this->code_version = 0;
|
24 |
+
$this->color_class = 'ai-debug-default';
|
25 |
|
26 |
$this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
|
27 |
$this->wp_options [AI_OPTION_PROCESS_PHP] = AI_DISABLED;
|
338 |
unset ($this->wp_options ['GENERATED_CODE']);
|
339 |
}
|
340 |
|
341 |
+
public function ai_getCode ($client_code = null, $process_php = null){
|
342 |
global $block_object, $ai_total_php_time, $ai_wp_data;
|
343 |
|
344 |
if ($this->fallback != 0) return $block_object [$this->fallback]->ai_getCode ();
|
345 |
|
346 |
$obj = $this;
|
347 |
+
$code = $client_code == null ? $obj->get_ad_data() : $client_code;
|
348 |
+
$php = $process_php == null ? $obj->get_process_php () : $process_php;
|
349 |
|
350 |
+
if ($php && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
|
351 |
|
352 |
$global_name = 'GENERATED_CODE';
|
353 |
if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
|
1113 |
return $counters;
|
1114 |
}
|
1115 |
|
1116 |
+
public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false, $client_code = null, $process_php = null){
|
1117 |
global $ai_wp_data, $ad_inserter_globals, $block_object;
|
1118 |
|
1119 |
+
$code = $this->ai_getCode ($client_code, $process_php);
|
1120 |
|
1121 |
$processed_code = $this->replace_ai_tags (do_shortcode ($code));
|
1122 |
|
1135 |
$dynamic_blocks = get_dynamic_blocks ();
|
1136 |
if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1137 |
|
1138 |
+
|
1139 |
if (strpos ($processed_code, AD_ROTATE_SEPARATOR) !== false) {
|
1140 |
$ads = explode (AD_ROTATE_SEPARATOR, $processed_code);
|
1141 |
|
1142 |
+
$amp_dynamic_blocks = $dynamic_blocks;
|
1143 |
+
if ($amp_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE && $ai_wp_data [AI_WP_AMP_PAGE]) $amp_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1144 |
+
|
1145 |
+
switch ($amp_dynamic_blocks) {
|
1146 |
case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
|
1147 |
$this->code_version = mt_rand (1, count ($ads));
|
1148 |
$processed_code = trim ($ads [$this->code_version - 1]);
|
1151 |
$this->code_version = '""';
|
1152 |
$processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
|
1153 |
foreach ($ads as $index => $ad) {
|
1154 |
+
|
1155 |
+
// If AMP separator use only code for normal pages
|
1156 |
+
if (strpos ($ad, AD_AMP_SEPARATOR) !== false) {
|
1157 |
+
$codes = explode (AD_AMP_SEPARATOR, $ad);
|
1158 |
+
$ad = trim ($codes [0]);
|
1159 |
+
}
|
1160 |
+
|
1161 |
switch ($index) {
|
1162 |
case 0:
|
1163 |
$processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'>\n".trim ($ad, "\n")."\n</div>\n";
|
1178 |
}
|
1179 |
}
|
1180 |
|
|
|
1181 |
|
1182 |
+
$this->color_class = 'ai-debug-default';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1183 |
|
1184 |
+
$amp_dynamic_blocks = $dynamic_blocks;
|
1185 |
+
if ($amp_dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && $this->w3tc_code == '') $amp_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1186 |
+
elseif ($amp_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE && $ai_wp_data [AI_WP_AMP_PAGE]) $amp_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1187 |
+
|
1188 |
+
switch ($amp_dynamic_blocks) {
|
1189 |
+
case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
|
1190 |
+
if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
|
1191 |
+
$codes = explode (AD_AMP_SEPARATOR, $processed_code);
|
1192 |
+
$code_index = $ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0;
|
1193 |
+
$this->color_class = $code_index ? 'ai-debug-amp' : 'ai-debug-default';
|
1194 |
+
$processed_code = trim ($codes [$code_index]);
|
1195 |
+
} else {
|
1196 |
+
// AMP page but No AMP separator - don't insert code unless enabled
|
1197 |
+
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
1198 |
+
if (!$this->get_enable_amp ()) {
|
1199 |
+
$processed_code = '';
|
1200 |
+
$this->color_class = 'ai-debug-normal';
|
1201 |
+
} else {
|
1202 |
+
$this->color_class = 'ai-debug-default-amp';
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
}
|
1206 |
+
break;
|
1207 |
+
case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
|
1208 |
+
$this->w3tc_code .= '$ai_amp_separator = \'' . AD_AMP_SEPARATOR . '\'; $ai_amp_page = ' . ($ai_wp_data [AI_WP_AMP_PAGE] ? 'true' : 'false') . '; $ai_amp_enabled = ' . $this->get_enable_amp () . ';';
|
1209 |
+
$this->w3tc_code .= 'if (strpos ($ai_code, $ai_amp_separator) !== false) {$codes = explode ($ai_amp_separator, $ai_code); $ai_code = trim ($codes [$ai_amp_page ? 1 : 0]); } else {if ($ai_amp_page && !$ai_amp_enabled) $ai_code = \'\';} $ai_enabled = true;';
|
1210 |
+
$processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
|
1211 |
+
$processed_code .= $this->w3tc_code.' echo $ai_code;';
|
1212 |
+
$processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
|
1213 |
+
break;
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
|
1217 |
+
$amp_dynamic_blocks = $dynamic_blocks;
|
1218 |
+
if ($amp_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE && $ai_wp_data [AI_WP_AMP_PAGE]) $amp_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
|
1219 |
+
|
1220 |
+
if ($amp_dynamic_blocks != AI_DYNAMIC_BLOCKS_SERVER_SIDE) {
|
1221 |
$countries = trim (str_replace (' ', '', strtoupper ($this->get_ad_country_list (true))));
|
1222 |
$country_list_type = $this->get_ad_country_list_type ();
|
1223 |
|
1273 |
$title = '';
|
1274 |
$fallback_code = '';
|
1275 |
if ($this->fallback != 0) {
|
1276 |
+
$this->color_class = 'ai-debug-fallback';
|
1277 |
$fallback_block = $block_object [$this->fallback];
|
1278 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_block->number); else $url_parameters = "";
|
1279 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_block->number;
|
1280 |
$fallback_code = ' ⇦ '.
|
1281 |
+
'<a title="Click to go to block settings" href="'. $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->fallback . ' ' . $fallback_block->get_ad_name () .'</a>';
|
1282 |
}
|
1283 |
$counters = $this->ai_get_counters ($title);
|
1284 |
|
1286 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
|
1287 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
|
1288 |
|
1289 |
+
$processed_code = '<section class="ai-debug-block '.$this->color_class.'"><section class="ai-debug-bar ai-debug-bar-left '.$this->color_class.'"><a title="Click to go to block settings" href="'
|
1290 |
+
. $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a> '.$fallback_code.'<a class="ai-debug-text-right"><kbd class="ai-debug-text-right" title="'.$title.'">'.$counters.'</kbd><kbd class="ai-debug-invisible">[/AI]</kbd></a></section>' . $processed_code . '</section>';
|
1291 |
}
|
1292 |
|
1293 |
return $processed_code;
|
1308 |
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
|
1309 |
$url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
|
1310 |
|
1311 |
+
$hidden_block_text = '<section class="ai-debug-message"> '.($hidden_widgets ? 'WIDGET':'BLOCK').' INSERTED BUT NOT VISIBLE </section>';
|
1312 |
|
1313 |
$visible_viewports = '';
|
1314 |
for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
|
1315 |
$viewport_name = get_viewport_name ($viewport);
|
1316 |
if ($viewport_name != '') {
|
1317 |
if ($this->get_detection_viewport ($viewport))
|
1318 |
+
$visible_viewports .= '<section class="ai-viewport-' . $viewport .'"><section class="ai-debug-bar '.$this->color_class.'"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a> '.$viewport_name.' </a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section></section>'; else
|
1319 |
+
if (!$ai_wp_data [AI_WP_AMP_PAGE])
|
1320 |
+
$hidden_viewports .= '<section class="ai-viewport-' . $viewport .' ai-debug-block ai-debug-viewport-invisible" style="' . $this->get_alignment_style() . '"><section class="ai-debug-bar ai-debug-viewport-invisible"><a class="ai-debug-text-left" title="Click to go to block settings" href="' . $url . '"><kbd class="ai-debug-invisible">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a> '.$viewport_name.' </a><a class="ai-debug-text-right" title="'.$title.'">'.$counters.'<kbd class="ai-debug-invisible">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
|
1321 |
}
|
1322 |
}
|
1323 |
|
1324 |
+
$code = "<div class='ai-debug-block " . $this->color_class . "'>".$visible_viewports . $processed_code.'</div>';
|
1325 |
} else $code = $this->ai_getProcessedCode ();
|
1326 |
|
1327 |
// Prevent empty wrapping div on AMP pages
|
1330 |
$block_class_name = get_block_class_name ();
|
1331 |
if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
|
1332 |
$viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
|
1333 |
+
$alignment_class = $this->get_alignment_class ();
|
1334 |
+
if ($block_class_name != '' || $viewport_classes != '' || $alignment_class != '') {
|
1335 |
+
if ($block_class_name != '') {
|
1336 |
+
$class = " class='" . $block_class_name . ' ' . $alignment_class . ' ' . $block_class_name . "-" . $this->number . $viewport_classes ."'";
|
1337 |
+
} else {
|
1338 |
+
$class = " class='" . $alignment_class . $viewport_classes ."'";
|
1339 |
+
}
|
1340 |
} else $class = '';
|
1341 |
+
$class = str_replace (' ', ' ', $class);
|
1342 |
|
1343 |
if ($hidden_widgets) return $hidden_viewports; else {
|
1344 |
+
if ($this->client_side_ip_address_detection && !$ai_wp_data [AI_WP_AMP_PAGE]) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
|
1345 |
|
1346 |
$tracking_code_pre = '';
|
1347 |
$tracking_code_data = '';
|
1366 |
}
|
1367 |
}
|
1368 |
|
1369 |
+
if ($alignment_class != '') {
|
1370 |
+
$wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code . ">\n";
|
1371 |
+
} else {
|
1372 |
+
$wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
|
1373 |
+
}
|
1374 |
|
1375 |
$wrapper_after = "</div>\n";
|
1376 |
|
1378 |
|
1379 |
if ($this->get_tracking ()) $tracking_code_data = '[#AI_DATA#]';
|
1380 |
|
1381 |
+
if ($alignment_class != '') {
|
1382 |
+
$wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code_pre . $tracking_code_data . $tracking_code_post . ">\n";
|
1383 |
+
} else {
|
1384 |
+
$wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code_pre . $tracking_code_data . $tracking_code_post . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
|
1385 |
+
}
|
1386 |
|
1387 |
$code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
|
1388 |
$code .= $this->w3tc_code.' if ($ai_enabled) echo str_replace (\'[#AI_DATA#]\', base64_encode ("[' . $this->number . ',$ai_index]"), unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_before)).'\'))), $ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_after)).'\'));';
|
1623 |
}
|
1624 |
|
1625 |
public function get_viewport_classes (){
|
1626 |
+
global $ai_wp_data;
|
1627 |
+
|
1628 |
+
if ($ai_wp_data [AI_WP_AMP_PAGE]) return '';
|
1629 |
+
|
1630 |
$viewport_classes = "";
|
1631 |
if ($this->get_detection_client_side ()) {
|
1632 |
$all_viewports = true;
|
1642 |
return ($viewport_classes);
|
1643 |
}
|
1644 |
|
1645 |
+
public function get_alignment_class (){
|
1646 |
+
global $ai_wp_data;
|
1647 |
+
|
1648 |
+
if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) {
|
1649 |
+
if ($ai_wp_data [AI_WP_AMP_PAGE]) {
|
1650 |
+
$block_class_name = get_block_class_name ();
|
1651 |
+
if ($block_class_name == '') $block_class_name = 'ai-'; else $block_class_name .= '-';
|
1652 |
+
|
1653 |
+
switch ($this->get_alignment_type ()) {
|
1654 |
+
case AI_ALIGNMENT_DEFAULT:
|
1655 |
+
case AI_ALIGNMENT_LEFT:
|
1656 |
+
case AI_ALIGNMENT_RIGHT:
|
1657 |
+
case AI_ALIGNMENT_CENTER:
|
1658 |
+
case AI_ALIGNMENT_FLOAT_LEFT:
|
1659 |
+
case AI_ALIGNMENT_FLOAT_RIGHT:
|
1660 |
+
case AI_ALIGNMENT_STICKY_LEFT:
|
1661 |
+
case AI_ALIGNMENT_STICKY_RIGHT:
|
1662 |
+
case AI_ALIGNMENT_STICKY_TOP:
|
1663 |
+
case AI_ALIGNMENT_STICKY_BOTTOM:
|
1664 |
+
return $block_class_name . str_replace (' ', '-', strtolower ($this->get_alignment_type_text ()));
|
1665 |
+
break;
|
1666 |
+
case AI_ALIGNMENT_CUSTOM_CSS:
|
1667 |
+
return $block_class_name . str_replace (' ', '-', strtolower (md5 ($this->get_custom_css ())));
|
1668 |
+
break;
|
1669 |
+
}
|
1670 |
+
}
|
1671 |
+
}
|
1672 |
+
|
1673 |
+
return '';
|
1674 |
+
}
|
1675 |
+
|
1676 |
public function before_paragraph ($content, $position_preview = false) {
|
1677 |
global $ai_wp_data, $ai_last_check, $special_element_tags;
|
1678 |
|
3041 |
|
3042 |
if ($minimum_words == 0 && $maximum_words == 0) return true;
|
3043 |
|
3044 |
+
// if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
|
3045 |
+
if ($number_of_words == 0) {
|
3046 |
+
if (!isset ($ai_wp_data [AI_WORD_COUNT])) {
|
3047 |
+
if ($content === null) {
|
3048 |
+
$content = '';
|
3049 |
+
$content_post = get_post ();
|
3050 |
+
if (isset ($content_post->post_content)) $content = $content_post->post_content;
|
3051 |
+
}
|
3052 |
|
3053 |
+
$number_of_words = number_of_words ($content);
|
3054 |
+
} else $number_of_words = $ai_wp_data [AI_WORD_COUNT];
|
3055 |
+
}
|
3056 |
+
// } else $number_of_words = 0;
|
3057 |
+
|
3058 |
+
// Cache word count only on single pages
|
3059 |
+
if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC)
|
3060 |
+
$ai_wp_data [AI_WORD_COUNT] = $number_of_words;
|
3061 |
|
3062 |
$ai_last_check = AI_CHECK_MIN_NUMBER_OF_WORDS;
|
3063 |
if ($number_of_words < $minimum_words) return false;
|
3538 |
|
3539 |
}
|
3540 |
|
3541 |
+
class ai_code_generator {
|
3542 |
+
|
3543 |
+
public function __construct () {
|
3544 |
+
}
|
3545 |
+
|
3546 |
+
public function generate ($data){
|
3547 |
+
|
3548 |
+
$code = '';
|
3549 |
+
switch ($data ['generate-code']) {
|
3550 |
+
case AI_CODE_BANNER:
|
3551 |
+
$code = '';
|
3552 |
+
if (isset ($data ['image']) && $data ['image'] != '') {
|
3553 |
+
$code = '<img src="' . $data ['image'] . '">';
|
3554 |
+
}
|
3555 |
+
if (isset ($data ['link']) && $data ['link'] != '') {
|
3556 |
+
$code = '<a href="' . $data ['link'] . '"' .(isset ($data ['target']) ? ' target="' . $data ['target'] . '"' : '') . '>' . $code . '</a>';
|
3557 |
+
}
|
3558 |
+
break;
|
3559 |
+
case AI_CODE_ADSENSE:
|
3560 |
+
if ($data ['adsense-width'] != '') $data ['adsense-width'] = ' width: '. $data ['adsense-width']. 'px;';
|
3561 |
+
if ($data ['adsense-height'] != '') $data ['adsense-height'] = ' height: '.$data ['adsense-height'].'px;';
|
3562 |
+
|
3563 |
+
switch ($data ['adsense-type']) {
|
3564 |
+
|
3565 |
+
case AI_ADSENSE_STANDARD:
|
3566 |
+
|
3567 |
+
switch ($data ['adsense-responsive']) {
|
3568 |
+
case 0:
|
3569 |
+
|
3570 |
+
// Normal
|
3571 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3572 |
+
<ins class="adsbygoogle"
|
3573 |
+
style="display: inline-block;'.$data ['adsense-width'].$data ['adsense-height'].'"
|
3574 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3575 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"></ins>
|
3576 |
+
<script>
|
3577 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3578 |
+
</script>';
|
3579 |
+
break;
|
3580 |
+
|
3581 |
+
case 1:
|
3582 |
+
|
3583 |
+
// Responsive
|
3584 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3585 |
+
<ins class="adsbygoogle"
|
3586 |
+
style="display: block;"
|
3587 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3588 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3589 |
+
data-ad-format="auto"></ins>
|
3590 |
+
<script>
|
3591 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3592 |
+
</script>';
|
3593 |
+
break;
|
3594 |
+
}
|
3595 |
+
break;
|
3596 |
+
|
3597 |
+
case AI_ADSENSE_LINK:
|
3598 |
+
switch ($data ['adsense-responsive']) {
|
3599 |
+
case 0:
|
3600 |
+
|
3601 |
+
// Normal
|
3602 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3603 |
+
<ins class="adsbygoogle"
|
3604 |
+
style="display: inline-block;'.$data ['adsense-width'].$data ['adsense-height'].'"
|
3605 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3606 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3607 |
+
data-ad-format="link"></ins>
|
3608 |
+
<script>
|
3609 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3610 |
+
</script>';
|
3611 |
+
break;
|
3612 |
+
|
3613 |
+
case 1:
|
3614 |
+
|
3615 |
+
// Responsive
|
3616 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3617 |
+
<ins class="adsbygoogle"
|
3618 |
+
style="display: block;"
|
3619 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3620 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3621 |
+
data-ad-format="link"></ins>
|
3622 |
+
<script>
|
3623 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3624 |
+
</script>';
|
3625 |
+
break;
|
3626 |
+
}
|
3627 |
+
break;
|
3628 |
+
|
3629 |
+
case AI_ADSENSE_IN_ARTICLE:
|
3630 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3631 |
+
<ins class="adsbygoogle"
|
3632 |
+
style="display: block; text-align: center;"
|
3633 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3634 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3635 |
+
data-ad-layout="in-article"
|
3636 |
+
data-ad-format="fluid"></ins>
|
3637 |
+
<script>
|
3638 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3639 |
+
</script>';
|
3640 |
+
break;
|
3641 |
+
|
3642 |
+
case AI_ADSENSE_IN_FEED:
|
3643 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3644 |
+
<ins class="adsbygoogle"
|
3645 |
+
style="display: block;"
|
3646 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3647 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3648 |
+
data-ad-layout="'.$data ['adsense-layout'].'"
|
3649 |
+
data-ad-layout-key="'.$data ['adsense-layout-key'].'"
|
3650 |
+
data-ad-format="fluid"></ins>
|
3651 |
+
<script>
|
3652 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3653 |
+
</script>';
|
3654 |
+
break;
|
3655 |
+
|
3656 |
+
case AI_ADSENSE_MATCHED_CONTENT:
|
3657 |
+
$code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
3658 |
+
<ins class="adsbygoogle"
|
3659 |
+
style="display: block;"
|
3660 |
+
data-ad-client="ca-'.$data ['adsense-publisher-id'].'"
|
3661 |
+
data-ad-slot="'.$data ['adsense-ad-slot-id'].'"
|
3662 |
+
data-ad-format="autorelaxed"></ins>
|
3663 |
+
<script>
|
3664 |
+
(adsbygoogle = window.adsbygoogle || []).push({});
|
3665 |
+
</script>';
|
3666 |
+
break;
|
3667 |
+
}
|
3668 |
+
break;
|
3669 |
+
}
|
3670 |
+
|
3671 |
+
return $code;
|
3672 |
+
}
|
3673 |
+
|
3674 |
+
public function import ($code){
|
3675 |
+
|
3676 |
+
$dom = new DOMDocument ();
|
3677 |
+
@$dom->loadHTML ($code);
|
3678 |
+
|
3679 |
+
// AdSense
|
3680 |
+
$adsense_code = $dom->getElementsByTagName ('ins');
|
3681 |
+
|
3682 |
+
if ($adsense_code->length == 0)
|
3683 |
+
$adsense_code = $dom->getElementsByTagName ('amp-ad');
|
3684 |
+
|
3685 |
+
if ($adsense_code->length != 0) {
|
3686 |
+
$data = array (
|
3687 |
+
'type' => AI_CODE_ADSENSE,
|
3688 |
+
'data-ad-client' => '',
|
3689 |
+
'data-ad-slot' => '',
|
3690 |
+
'adsense-type' => AI_ADSENSE_STANDARD,
|
3691 |
+
'adsense-responsive' => 0,
|
3692 |
+
'adsense-width' => '',
|
3693 |
+
'adsense-height' => '',
|
3694 |
+
'adsense-layout' => '',
|
3695 |
+
'adsense-layout-key' => '');
|
3696 |
+
|
3697 |
+
$data ['data-ad-client'] = str_replace ('ca-', '', $adsense_code [0]->getAttribute ('data-ad-client'));
|
3698 |
+
$data ['data-ad-slot'] = $adsense_code [0]->getAttribute ('data-ad-slot');
|
3699 |
+
|
3700 |
+
$adsense_style = $adsense_code [0]->getAttribute ('style');
|
3701 |
+
|
3702 |
+
$style_width = preg_match ("/width\s*:\s*(\d+)px/", $adsense_style, $width_match);
|
3703 |
+
if ($style_width) $data ['adsense-width'] = $width_match [1];
|
3704 |
+
|
3705 |
+
$style_height = preg_match ("/height\s*:\s*(\d+)px/", $adsense_style, $height_match);
|
3706 |
+
if ($style_height) $data ['adsense-height'] = $height_match [1];
|
3707 |
+
|
3708 |
+
$adsense_responsive = !$style_width && !$style_height;
|
3709 |
+
|
3710 |
+
$adsense_ad_format = $adsense_code [0]->getAttribute ('data-ad-format');
|
3711 |
+
switch ($adsense_ad_format) {
|
3712 |
+
case '':
|
3713 |
+
break;
|
3714 |
+
case 'auto':
|
3715 |
+
if ($adsense_responsive) $data ['adsense-responsive'] = 1;
|
3716 |
+
break;
|
3717 |
+
case 'autorelaxed':
|
3718 |
+
$data ['adsense-type'] = AI_ADSENSE_MATCHED_CONTENT;
|
3719 |
+
break;
|
3720 |
+
case 'link':
|
3721 |
+
$data ['adsense-type'] = AI_ADSENSE_LINK;
|
3722 |
+
if ($adsense_responsive) $data ['adsense-responsive'] = 1;
|
3723 |
+
break;
|
3724 |
+
case 'fluid':
|
3725 |
+
$adsense_ad_layout = $adsense_code [0]->getAttribute ('data-ad-layout');
|
3726 |
+
|
3727 |
+
switch ($adsense_ad_layout) {
|
3728 |
+
case 'in-article':
|
3729 |
+
$data ['adsense-type'] = AI_ADSENSE_IN_ARTICLE;
|
3730 |
+
break 2;
|
3731 |
+
}
|
3732 |
+
|
3733 |
+
$data ['adsense-type'] = AI_ADSENSE_IN_FEED;
|
3734 |
+
|
3735 |
+
$data ['adsense-layout'] = $adsense_ad_layout;
|
3736 |
+
$data ['adsense-layout-key'] = $adsense_code [0]->getAttribute ('data-ad-layout-key');
|
3737 |
+
|
3738 |
+
break;
|
3739 |
+
}
|
3740 |
+
|
3741 |
+
|
3742 |
+
return $data;
|
3743 |
+
}
|
3744 |
+
|
3745 |
+
// Old AdSense
|
3746 |
+
if (strpos ($code, 'google_ad_client') !== false) {
|
3747 |
+
if (preg_match ("/google_ad_client.+[\"\'](.+?)[\"\']/", $code, $match)) {
|
3748 |
+
$data = array ('type' => AI_CODE_ADSENSE, 'data-ad-client' => '', 'data-ad-slot' => '');
|
3749 |
+
|
3750 |
+
$data ['data-ad-client'] = str_replace ('ca-', '', $match [1]);
|
3751 |
+
|
3752 |
+
return $data;
|
3753 |
+
}
|
3754 |
+
}
|
3755 |
+
|
3756 |
+
|
3757 |
+
// Banner
|
3758 |
+
$links = $dom->getElementsByTagName ('a');
|
3759 |
+
$images = $dom->getElementsByTagName ('img');
|
3760 |
+
|
3761 |
+
if ($links->length != 0 || $images->length != 0) {
|
3762 |
+
$data = array ('type' => AI_CODE_BANNER, 'image' => '', 'link' => '', 'target' => '');
|
3763 |
+
|
3764 |
+
if ($images->length != 0) {
|
3765 |
+
$data ['image'] = $images [0]->getAttribute ('src');
|
3766 |
+
}
|
3767 |
+
|
3768 |
+
if ($links->length != 0) {
|
3769 |
+
$data ['link'] = $links [0]->getAttribute ('href');
|
3770 |
+
$data ['target'] = $links [0]->getAttribute ('target');
|
3771 |
+
}
|
3772 |
+
|
3773 |
+
return $data;
|
3774 |
+
}
|
3775 |
+
|
3776 |
+
return array ('type' => AI_CODE_UNKNOWN);
|
3777 |
+
}
|
3778 |
+
}
|
constants.php
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
define ('AI_OPTION_NAME', 'ad_inserter');
|
7 |
define ('AI_INSTALL_NAME', 'ai-install');
|
8 |
define ('AI_OPTION_GLOBAL', 'global');
|
|
|
9 |
|
10 |
if (!defined ('AD_INSERTER_PLUGIN_DIR'))
|
11 |
define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
|
@@ -18,7 +19,7 @@ if (!defined( 'AD_INSERTER_NAME'))
|
|
18 |
define ('AD_INSERTER_NAME', 'Ad Inserter');
|
19 |
|
20 |
if (!defined( 'AD_INSERTER_VERSION'))
|
21 |
-
define ('AD_INSERTER_VERSION', '2.2.
|
22 |
|
23 |
if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
|
24 |
define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
|
@@ -44,7 +45,6 @@ define ('AD_OPTIONS', 'AdInserterOptions'); // general plugin options
|
|
44 |
define ('AD_ADx_OPTIONS', 'AdInserter#Options');
|
45 |
|
46 |
// Options
|
47 |
-
define ('AI_EXTRACT_OPTION_NAME', 'extract');
|
48 |
define ('WP_FORM_FIELD_POSTFIX', '_block_');
|
49 |
define ('AI_HEADER_OPTION_NAME', 'h');
|
50 |
define ('AI_FOOTER_OPTION_NAME', 'f');
|
@@ -191,6 +191,7 @@ define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
|
|
191 |
define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
|
192 |
define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
|
193 |
define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
|
|
|
194 |
define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
|
195 |
|
196 |
define('AI_TEXT_DISABLED', 'Disabled');
|
@@ -206,6 +207,7 @@ define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
|
|
206 |
define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
|
207 |
define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
|
208 |
define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
|
|
|
209 |
define('AI_TEXT_FOOTER', 'Footer');
|
210 |
|
211 |
//Display options
|
@@ -337,10 +339,10 @@ define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
|
|
337 |
define ('AI_PHP_FUNCTION_CALL_COUNTER_NAME', 'AI_PHP_FUNCTION_CALL_COUNTER_');
|
338 |
define ('AI_CONTENT_COUNTER_NAME', 'AI_CONTENT_COUNTER');
|
339 |
define ('AI_EXCERPT_COUNTER_NAME', 'AI_EXCERPT_COUNTER');
|
340 |
-
define ('AI_LOOP_BEFORE_COUNTER_NAME', '
|
341 |
-
define ('AI_LOOP_AFTER_COUNTER_NAME', '
|
342 |
define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
|
343 |
-
define ('AI_POST_COUNTER_NAME', '
|
344 |
define ('AI_COMMENT_COUNTER_NAME', 'AI_COMMENT_COUNTER');
|
345 |
define ('AI_ADB_FALLBACK_DEPTH_NAME', 'AI_ADB_FALLBACK_DEPTH');
|
346 |
|
@@ -469,6 +471,9 @@ define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
|
|
469 |
define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
|
470 |
|
471 |
define ('AI_ADBLOCKING_DETECTION', true);
|
|
|
|
|
|
|
472 |
define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
|
473 |
define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
|
474 |
define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
|
@@ -508,6 +513,7 @@ define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
|
|
508 |
define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
|
509 |
define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
|
510 |
define ('FOOTER_HOOK_BLOCKS', 'wp_footer_hook');
|
|
|
511 |
define ('CUSTOM_HOOK_BLOCKS', '_hook');
|
512 |
define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
|
513 |
|
@@ -655,10 +661,25 @@ if (!defined ('AD_INSERTER_VIEWPORTS'))
|
|
655 |
if (!defined ('AD_INSERTER_HOOKS'))
|
656 |
define ('AD_INSERTER_HOOKS', 2);
|
657 |
|
658 |
-
define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
|
659 |
-
define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
|
660 |
-
define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
|
661 |
-
define ('AI_DEBUG_ADB_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid red; color: red; background: #fee; opacity: 0.85; cursor: pointer;');
|
662 |
define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
|
663 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
|
6 |
define ('AI_OPTION_NAME', 'ad_inserter');
|
7 |
define ('AI_INSTALL_NAME', 'ai-install');
|
8 |
define ('AI_OPTION_GLOBAL', 'global');
|
9 |
+
define ('AI_OPTION_EXTRACT', 'extract');
|
10 |
|
11 |
if (!defined ('AD_INSERTER_PLUGIN_DIR'))
|
12 |
define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
|
19 |
define ('AD_INSERTER_NAME', 'Ad Inserter');
|
20 |
|
21 |
if (!defined( 'AD_INSERTER_VERSION'))
|
22 |
+
define ('AD_INSERTER_VERSION', '2.2.6');
|
23 |
|
24 |
if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
|
25 |
define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
|
45 |
define ('AD_ADx_OPTIONS', 'AdInserter#Options');
|
46 |
|
47 |
// Options
|
|
|
48 |
define ('WP_FORM_FIELD_POSTFIX', '_block_');
|
49 |
define ('AI_HEADER_OPTION_NAME', 'h');
|
50 |
define ('AI_FOOTER_OPTION_NAME', 'f');
|
191 |
define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
|
192 |
define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
|
193 |
define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
|
194 |
+
define('AI_AUTOMATIC_INSERTION_ABOVE_HEADER', 14);
|
195 |
define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
|
196 |
|
197 |
define('AI_TEXT_DISABLED', 'Disabled');
|
207 |
define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
|
208 |
define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
|
209 |
define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
|
210 |
+
define('AI_TEXT_ABOVE_HEADER', 'Above Header');
|
211 |
define('AI_TEXT_FOOTER', 'Footer');
|
212 |
|
213 |
//Display options
|
339 |
define ('AI_PHP_FUNCTION_CALL_COUNTER_NAME', 'AI_PHP_FUNCTION_CALL_COUNTER_');
|
340 |
define ('AI_CONTENT_COUNTER_NAME', 'AI_CONTENT_COUNTER');
|
341 |
define ('AI_EXCERPT_COUNTER_NAME', 'AI_EXCERPT_COUNTER');
|
342 |
+
define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_START_COUNTER');
|
343 |
+
define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_END_COUNTER');
|
344 |
define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
|
345 |
+
define ('AI_POST_COUNTER_NAME', 'AI_THE_POST_COUNTER');
|
346 |
define ('AI_COMMENT_COUNTER_NAME', 'AI_COMMENT_COUNTER');
|
347 |
define ('AI_ADB_FALLBACK_DEPTH_NAME', 'AI_ADB_FALLBACK_DEPTH');
|
348 |
|
471 |
define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
|
472 |
|
473 |
define ('AI_ADBLOCKING_DETECTION', true);
|
474 |
+
define ('AI_AMP_HEADER_STYLES', true);
|
475 |
+
//define ('AI_CODE_GENERATOR', true);
|
476 |
+
//define ('AI_BUFFERING', true);
|
477 |
define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
|
478 |
define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
|
479 |
define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
|
513 |
define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
|
514 |
define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
|
515 |
define ('FOOTER_HOOK_BLOCKS', 'wp_footer_hook');
|
516 |
+
define ('ABOVE_HEADER_HOOK_BLOCKS', 'above_header_hook');
|
517 |
define ('CUSTOM_HOOK_BLOCKS', '_hook');
|
518 |
define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
|
519 |
|
661 |
if (!defined ('AD_INSERTER_HOOKS'))
|
662 |
define ('AD_INSERTER_HOOKS', 2);
|
663 |
|
|
|
|
|
|
|
|
|
664 |
define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
|
665 |
|
666 |
+
define ('AI_DEBUG_TAGS_CLASS', 'ai-debug-tags');
|
667 |
+
define ('AI_DEBUG_POSITIONS_CLASS', 'ai-debug-positions');
|
668 |
+
define ('AI_DEBUG_PAGE_TYPE_CLASS', 'ai-debug-page-type');
|
669 |
+
define ('AI_DEBUG_ADB_CLASS', 'ai-debug-adb');
|
670 |
+
|
671 |
+
define ('AI_CODE_UNKNOWN', 0);
|
672 |
+
define ('AI_CODE_BANNER', 1);
|
673 |
+
define ('AI_CODE_ADSENSE', 2);
|
674 |
+
|
675 |
+
define ('AI_ADSENSE_STANDARD', 0);
|
676 |
+
define ('AI_ADSENSE_LINK', 1);
|
677 |
+
define ('AI_ADSENSE_IN_ARTICLE', 2);
|
678 |
+
define ('AI_ADSENSE_IN_FEED', 3);
|
679 |
+
define ('AI_ADSENSE_MATCHED_CONTENT', 4);
|
680 |
+
|
681 |
+
define ('AI_TEXT_LINK', 'Link');
|
682 |
+
define ('AI_TEXT_IN_ARTICLE', 'In-article');
|
683 |
+
define ('AI_TEXT_IN_FEED', 'In-feed');
|
684 |
+
define ('AI_TEXT_MATCHED_CONTENT', 'Matched content');
|
685 |
|
css/ad-inserter.css
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
#ai-data {
|
2 |
-
font-family: "2.2.
|
3 |
}
|
4 |
|
5 |
#blocked-warning {
|
6 |
display: none;
|
7 |
}
|
8 |
|
9 |
-
.ui-widget,
|
10 |
font-family: sans-serif,Arial,Verdana;
|
11 |
font-size: 12px!important;
|
12 |
}
|
13 |
|
14 |
-
|
15 |
position: relative;
|
16 |
}
|
17 |
|
@@ -29,6 +29,16 @@
|
|
29 |
background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important;
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
.ace_editor {
|
33 |
border: 1px solid #ddd;
|
34 |
border-radius: 4px;
|
@@ -64,7 +74,7 @@ a.clear-link, a.clear-link:hover, a.clear-link:focus {
|
|
64 |
border-radius: 5px;
|
65 |
}
|
66 |
|
67 |
-
|
68 |
border-radius: 5px;
|
69 |
}
|
70 |
|
@@ -408,6 +418,11 @@ div.automatic-insertion img {
|
|
408 |
vertical-align: middle;
|
409 |
}
|
410 |
|
|
|
|
|
|
|
|
|
|
|
411 |
img.automatic-insertion.disabled {
|
412 |
background: url('images/insertions-alignmets.png') 0 0;
|
413 |
}
|
@@ -654,6 +669,16 @@ img.automatic-insertion.preview {
|
|
654 |
background: url('images/icons.png') -120px 0;
|
655 |
}
|
656 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
|
658 |
.checkbox-icon.icon-loading {
|
659 |
width: 12px;
|
@@ -705,6 +730,11 @@ img.automatic-insertion.preview {
|
|
705 |
background: 0 0!important;
|
706 |
}
|
707 |
|
|
|
|
|
|
|
|
|
|
|
708 |
@media (max-width: 782px) {
|
709 |
.auto-fold #wpcontent {
|
710 |
padding-left: 4px;
|
@@ -735,6 +765,19 @@ img.automatic-insertion.preview {
|
|
735 |
width: 90px;
|
736 |
padding: 3px 3px;
|
737 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
738 |
}
|
739 |
|
740 |
@media(min-width: 769px) {
|
1 |
#ai-data {
|
2 |
+
font-family: "2.2.6"; /* Used for version number of the file */
|
3 |
}
|
4 |
|
5 |
#blocked-warning {
|
6 |
display: none;
|
7 |
}
|
8 |
|
9 |
+
.ui-widget, .ai-form td {
|
10 |
font-family: sans-serif,Arial,Verdana;
|
11 |
font-size: 12px!important;
|
12 |
}
|
13 |
|
14 |
+
.ai-form .ui-widget {
|
15 |
position: relative;
|
16 |
}
|
17 |
|
29 |
background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important;
|
30 |
}
|
31 |
|
32 |
+
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover {
|
33 |
+
border: 1px solid #d3d3d3;
|
34 |
+
background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;
|
35 |
+
color: #555;
|
36 |
+
}
|
37 |
+
|
38 |
+
.ai-top-button.ui-button-text-only .ui-button-text {
|
39 |
+
padding: .4em 0.8em;
|
40 |
+
}
|
41 |
+
|
42 |
.ace_editor {
|
43 |
border: 1px solid #ddd;
|
44 |
border-radius: 4px;
|
74 |
border-radius: 5px;
|
75 |
}
|
76 |
|
77 |
+
.ai-form.rounded input, .ai-form.rounded select {
|
78 |
border-radius: 5px;
|
79 |
}
|
80 |
|
418 |
vertical-align: middle;
|
419 |
}
|
420 |
|
421 |
+
/* TEMP */
|
422 |
+
img.automatic-insertion.above-header {
|
423 |
+
background: url('images/insertions-alignmets.png') -56px 0;
|
424 |
+
}
|
425 |
+
|
426 |
img.automatic-insertion.disabled {
|
427 |
background: url('images/insertions-alignmets.png') 0 0;
|
428 |
}
|
669 |
background: url('images/icons.png') -120px 0;
|
670 |
}
|
671 |
|
672 |
+
.checkbox-icon.icon-enabled-all {
|
673 |
+
width: 16px;
|
674 |
+
height: 16px;
|
675 |
+
background: url('images/icons.png') -142px -22px;
|
676 |
+
}
|
677 |
+
|
678 |
+
.checkbox-icon.icon-enabled-all.on {
|
679 |
+
background: url('images/icons.png') -142px -2px;
|
680 |
+
}
|
681 |
+
|
682 |
|
683 |
.checkbox-icon.icon-loading {
|
684 |
width: 12px;
|
730 |
background: 0 0!important;
|
731 |
}
|
732 |
|
733 |
+
.ai-form .ai-dot {
|
734 |
+
font-size: 18px!important;
|
735 |
+
line-height: 16px;
|
736 |
+
}
|
737 |
+
|
738 |
@media (max-width: 782px) {
|
739 |
.auto-fold #wpcontent {
|
740 |
padding-left: 4px;
|
765 |
width: 90px;
|
766 |
padding: 3px 3px;
|
767 |
}
|
768 |
+
.ai-form .ai-dot {
|
769 |
+
font-size: 12px!important;
|
770 |
+
line-height: 18px;
|
771 |
+
}
|
772 |
+
.checkbox-icon.icon-enabled-all {
|
773 |
+
width: 20px;
|
774 |
+
height: 20px;
|
775 |
+
background: url('images/icons.png') -140px -20px;
|
776 |
+
}
|
777 |
+
|
778 |
+
.checkbox-icon.icon-enabled-all.on {
|
779 |
+
background: url('images/icons.png') -140px -0px;
|
780 |
+
}
|
781 |
}
|
782 |
|
783 |
@media(min-width: 769px) {
|
{images → css/images}/blank.png
RENAMED
File without changes
|
css/images/icons.png
CHANGED
Binary file
|
images/test.png
DELETED
Binary file
|
js/ad-inserter.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
var javascript_version = "2.2.
|
2 |
var ignore_key = true;
|
3 |
var start = 1;
|
4 |
var end = 16;
|
@@ -14,6 +14,8 @@ var settings_page = "";
|
|
14 |
|
15 |
var dateFormat = "yy-mm-dd";
|
16 |
|
|
|
|
|
17 |
var AI_DISABLED = 0;
|
18 |
var AI_BEFORE_POST = 1;
|
19 |
var AI_AFTER_POST = 2;
|
@@ -51,6 +53,16 @@ var AI_ADB_BLOCK_ACTION_REPLACE = 1;
|
|
51 |
var AI_ADB_BLOCK_ACTION_SHOW = 2;
|
52 |
var AI_ADB_BLOCK_ACTION_HIDE = 3;
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
var shSettings = {
|
56 |
"tab_size":"4",
|
@@ -138,6 +150,21 @@ function change_block_alignment (block) {
|
|
138 |
}(jQuery));
|
139 |
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
function get_editor_text (block) {
|
142 |
var editor = ace.edit ("editor-" + block);
|
143 |
var textarea = jQuery ("#block-" + block);
|
@@ -178,6 +205,7 @@ function window_open_post (url, windowoption, name, params) {
|
|
178 |
document.body.removeChild(form);
|
179 |
}
|
180 |
|
|
|
181 |
jQuery(document).ready(function($) {
|
182 |
|
183 |
var header = $('#ai-settings-' + 'header').length != 0;
|
@@ -811,6 +839,33 @@ jQuery(document).ready(function($) {
|
|
811 |
if (syntax_highlighting) configure_editor_language (block);
|
812 |
}
|
813 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
814 |
function configure_editor (block) {
|
815 |
|
816 |
if (debug) console.log ("configure_editor:", block);
|
@@ -1029,8 +1084,6 @@ jQuery(document).ready(function($) {
|
|
1029 |
|
1030 |
if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
|
1031 |
var nonce = $(this).attr ('nonce');
|
1032 |
-
// var site_url = $(this).attr ('site-url');
|
1033 |
-
// $("#export_settings_0").load (site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&export=0&ai_check=" + nonce, function() {
|
1034 |
$("#export_settings_0").load (ajaxurl+"?action=ai_ajax_backend&export=0&ai_check=" + nonce, function() {
|
1035 |
$("#export_settings_0").attr ("name", "export_settings_0");
|
1036 |
$("#export-switch-0").addClass ("loaded");
|
@@ -1491,17 +1544,16 @@ jQuery(document).ready(function($) {
|
|
1491 |
|
1492 |
var name = $("#name-label-"+block).text ();
|
1493 |
|
|
|
|
|
|
|
1494 |
var window_width = 820;
|
1495 |
var window_height = 820;
|
1496 |
var window_left = 120;
|
1497 |
var window_top = (screen.height / 2) - (820 / 2);
|
1498 |
var nonce = $(this).attr ('nonce');
|
1499 |
-
// var site_url = $(this).attr ('site-url');
|
1500 |
-
// var page = site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&preview=" + block + "&ai_check=" + nonce + "&alignment=" + alignment + "&css=" + encodeURI (alignment_css) + "&name=" + encodeURI (name);
|
1501 |
-
// var page = ajaxurl+"?action=ai_ajax_backend&preview=" + block + "&ai_check=" + nonce + "&alignment=" + alignment + "&css=" + encodeURI (alignment_css) + "&name=" + encodeURI (name);
|
1502 |
-
// var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
|
1503 |
|
1504 |
-
var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': name, 'alignment': alignment, 'alignment_css': alignment_css, 'custom_css': custom_css};
|
1505 |
window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
|
1506 |
});
|
1507 |
|
@@ -1516,6 +1568,167 @@ jQuery(document).ready(function($) {
|
|
1516 |
|
1517 |
$('#ai-devices-container-' + tab).tabs();
|
1518 |
$('#ai-devices-tabs-' + tab).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1519 |
}
|
1520 |
|
1521 |
function generate_country_list (element_name_prefix, index) {
|
@@ -1720,6 +1933,27 @@ jQuery(document).ready(function($) {
|
|
1720 |
});
|
1721 |
}
|
1722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1723 |
|
1724 |
if (debug) console.log ("READY");
|
1725 |
if (debug_title) $("#plugin_name").css ("color", "#f00");
|
@@ -1892,6 +2126,29 @@ jQuery(document).ready(function($) {
|
|
1892 |
$('#ai-stars').show ();
|
1893 |
});
|
1894 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1895 |
setTimeout (update_rating, 1000);
|
1896 |
|
1897 |
if (debug) console.log ("");
|
1 |
+
var javascript_version = "2.2.6";
|
2 |
var ignore_key = true;
|
3 |
var start = 1;
|
4 |
var end = 16;
|
14 |
|
15 |
var dateFormat = "yy-mm-dd";
|
16 |
|
17 |
+
var search_reload = false;
|
18 |
+
|
19 |
var AI_DISABLED = 0;
|
20 |
var AI_BEFORE_POST = 1;
|
21 |
var AI_AFTER_POST = 2;
|
53 |
var AI_ADB_BLOCK_ACTION_SHOW = 2;
|
54 |
var AI_ADB_BLOCK_ACTION_HIDE = 3;
|
55 |
|
56 |
+
var AI_CODE_UNKNOWN = 0;
|
57 |
+
var AI_CODE_BANNER = 1;
|
58 |
+
var AI_CODE_ADSENSE = 2;
|
59 |
+
|
60 |
+
var AI_ADSENSE_STANDARD = 0;
|
61 |
+
var AI_ADSENSE_LINK = 1;
|
62 |
+
var AI_ADSENSE_IN_ARTICLE = 2;
|
63 |
+
var AI_ADSENSE_IN_FEED = 3;
|
64 |
+
var AI_ADSENSE_MATCHED_CONTENT = 4;
|
65 |
+
|
66 |
|
67 |
var shSettings = {
|
68 |
"tab_size":"4",
|
150 |
}(jQuery));
|
151 |
|
152 |
|
153 |
+
serialize_object = function (obj) {
|
154 |
+
var str = [];
|
155 |
+
for(var p in obj)
|
156 |
+
if (obj.hasOwnProperty (p)) {
|
157 |
+
str.push(encodeURIComponent (p) + "=" + encodeURIComponent (obj[p]));
|
158 |
+
}
|
159 |
+
return str.join ("&");
|
160 |
+
}
|
161 |
+
|
162 |
+
Number.isInteger = Number.isInteger || function (value) {
|
163 |
+
return typeof value === "number" &&
|
164 |
+
isFinite (value) &&
|
165 |
+
Math.floor (value) === value;
|
166 |
+
};
|
167 |
+
|
168 |
function get_editor_text (block) {
|
169 |
var editor = ace.edit ("editor-" + block);
|
170 |
var textarea = jQuery ("#block-" + block);
|
205 |
document.body.removeChild(form);
|
206 |
}
|
207 |
|
208 |
+
|
209 |
jQuery(document).ready(function($) {
|
210 |
|
211 |
var header = $('#ai-settings-' + 'header').length != 0;
|
839 |
if (syntax_highlighting) configure_editor_language (block);
|
840 |
}
|
841 |
|
842 |
+
function process_adsense_elements (block) {
|
843 |
+
var adsense_type = parseInt ($("select#adsense-type-" + block +" option:selected").attr ('value'));
|
844 |
+
var adsense_responsive = $("#adsense-responsive-" + block).is(":checked");
|
845 |
+
|
846 |
+
$('#tab-adsense-' + block + ' .adsense-layout').css ('visibility', 'hidden');
|
847 |
+
$('#tab-adsense-' + block + ' .adsense-size').css ('visibility', 'hidden');
|
848 |
+
$('#tab-adsense-' + block + ' .adsense-responsive').css ('visibility', 'hidden');
|
849 |
+
|
850 |
+
switch (adsense_type) {
|
851 |
+
case AI_ADSENSE_STANDARD:
|
852 |
+
$('#tab-adsense-' + block + ' .adsense-responsive').css ('visibility', 'visible');
|
853 |
+
if (!adsense_responsive) $('#tab-adsense-' + block + ' .adsense-size').css ('visibility', 'visible');
|
854 |
+
break;
|
855 |
+
case AI_ADSENSE_LINK:
|
856 |
+
$('#tab-adsense-' + block + ' .adsense-responsive').css ('visibility', 'visible');
|
857 |
+
if (!adsense_responsive) $('#tab-adsense-' + block + ' .adsense-size').css ('visibility', 'visible');
|
858 |
+
break;
|
859 |
+
case AI_ADSENSE_IN_ARTICLE:
|
860 |
+
break;
|
861 |
+
case AI_ADSENSE_IN_FEED:
|
862 |
+
$('#tab-adsense-' + block + ' .adsense-layout').css ('visibility', 'visible');
|
863 |
+
break;
|
864 |
+
case AI_ADSENSE_MATCHED_CONTENT:
|
865 |
+
break;
|
866 |
+
}
|
867 |
+
}
|
868 |
+
|
869 |
function configure_editor (block) {
|
870 |
|
871 |
if (debug) console.log ("configure_editor:", block);
|
1084 |
|
1085 |
if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
|
1086 |
var nonce = $(this).attr ('nonce');
|
|
|
|
|
1087 |
$("#export_settings_0").load (ajaxurl+"?action=ai_ajax_backend&export=0&ai_check=" + nonce, function() {
|
1088 |
$("#export_settings_0").attr ("name", "export_settings_0");
|
1089 |
$("#export-switch-0").addClass ("loaded");
|
1544 |
|
1545 |
var name = $("#name-label-"+block).text ();
|
1546 |
|
1547 |
+
var code = get_editor_text (block);
|
1548 |
+
var php = $("input#process-php-"+block).is(":checked");
|
1549 |
+
|
1550 |
var window_width = 820;
|
1551 |
var window_height = 820;
|
1552 |
var window_left = 120;
|
1553 |
var window_top = (screen.height / 2) - (820 / 2);
|
1554 |
var nonce = $(this).attr ('nonce');
|
|
|
|
|
|
|
|
|
1555 |
|
1556 |
+
var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': name, 'alignment': alignment, 'alignment_css': alignment_css, 'custom_css': custom_css, 'code': code, 'php': php};
|
1557 |
window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
|
1558 |
});
|
1559 |
|
1568 |
|
1569 |
$('#ai-devices-container-' + tab).tabs();
|
1570 |
$('#ai-devices-tabs-' + tab).show();
|
1571 |
+
|
1572 |
+
|
1573 |
+
|
1574 |
+
$('#ai-code-generator-container-' + tab).tabs();
|
1575 |
+
$('#ai-code-generator-tabs-' + tab).show();
|
1576 |
+
|
1577 |
+
$("select#adsense-type-"+tab).change (function() {
|
1578 |
+
var block = $(this).attr('id').replace ("adsense-type-", "");
|
1579 |
+
process_adsense_elements (block);
|
1580 |
+
});
|
1581 |
+
|
1582 |
+
$("input#adsense-responsive-"+tab).change (function() {
|
1583 |
+
var block = $(this).attr('id').replace ("adsense-responsive-", "");
|
1584 |
+
process_adsense_elements (block);
|
1585 |
+
});
|
1586 |
+
|
1587 |
+
process_adsense_elements (tab);
|
1588 |
+
|
1589 |
+
$("#code-generator-"+tab).click (function () {
|
1590 |
+
var block = $(this).attr('id').replace ("code-generator-", "");
|
1591 |
+
$('#ai-code-generator-container-' + block).toggle();
|
1592 |
+
$(this).next ("label").find ('.checkbox-icon').toggleClass("on");
|
1593 |
+
});
|
1594 |
+
|
1595 |
+
$("#open-image-button-"+tab).click (function (event) {
|
1596 |
+
var block = $(this).attr('id').replace ("open-image-button-", "");
|
1597 |
+
var frame;
|
1598 |
+
|
1599 |
+
event.preventDefault();
|
1600 |
+
|
1601 |
+
if (frame) {
|
1602 |
+
frame.open();
|
1603 |
+
return;
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
frame = wp.media({
|
1607 |
+
title: 'Select or upload banner image',
|
1608 |
+
button: {
|
1609 |
+
text: 'Use this image'
|
1610 |
+
},
|
1611 |
+
multiple: false // Set to true to allow multiple files to be selected
|
1612 |
+
});
|
1613 |
+
|
1614 |
+
frame.on ('open', function(){
|
1615 |
+
var selection = frame.state().get ('selection');
|
1616 |
+
var selected = $('#banner-image-' + block).val();
|
1617 |
+
if (selected) {
|
1618 |
+
selection.add (wp.media.attachment (selected));
|
1619 |
+
}
|
1620 |
+
});
|
1621 |
+
|
1622 |
+
frame.on ('select', function() {
|
1623 |
+
var attachment = frame.state().get('selection').first().toJSON();
|
1624 |
+
$('#banner-image-' + block).attr ('src', attachment.url);
|
1625 |
+
$('#banner-image-url-' + block).val (attachment.url);
|
1626 |
+
|
1627 |
+
});
|
1628 |
+
|
1629 |
+
frame.open();
|
1630 |
+
});
|
1631 |
+
|
1632 |
+
$("#banner-image-url-" + tab).on ('input', function() {
|
1633 |
+
var block = $(this).attr('id').replace ("banner-image-url-", "");
|
1634 |
+
$('#banner-image-' + block).attr ('src', $(this).val ());
|
1635 |
+
});
|
1636 |
+
|
1637 |
+
$("#banner-url-" + tab).on ('input', function() {
|
1638 |
+
var block = $(this).attr('id').replace ("banner-url-", "");
|
1639 |
+
$('#banner-link-' + block).attr ('href', $(this).val ());
|
1640 |
+
});
|
1641 |
+
|
1642 |
+
$("#import-button-"+tab).click (function () {
|
1643 |
+
var block = $(this).attr('id').replace ("import-button-", "");
|
1644 |
+
|
1645 |
+
var nonce = $("#ai-form").attr ('nonce');
|
1646 |
+
var code_data = "&import-code=" + encodeURI (get_editor_text (block));
|
1647 |
+
|
1648 |
+
$.ajax ({
|
1649 |
+
url: ajaxurl + "?action=ai_ajax_backend&ai_check=" + nonce + code_data
|
1650 |
+
}).done (function (data) {
|
1651 |
+
if (data != '') {
|
1652 |
+
var code_data = JSON.parse (data);
|
1653 |
+
if (typeof code_data !== "undefined" && typeof code_data ['type'] !== "undefined") {
|
1654 |
+
|
1655 |
+
if (debug) console.log ("AI IMPORT CODE:", code_data);
|
1656 |
+
|
1657 |
+
var code_type = code_data ['type'];
|
1658 |
+
|
1659 |
+
$("#ai-code-generator-container-" + block).tabs ({active: code_type});
|
1660 |
+
|
1661 |
+
switch (code_type) {
|
1662 |
+
case AI_CODE_BANNER:
|
1663 |
+
$("#banner-image-url-" + block).val (code_data ['image']).trigger('input');
|
1664 |
+
$("#banner-url-" + block).val (code_data ['link']).trigger('input');
|
1665 |
+
$("#open-new-window-" + block).attr('checked', code_data ['target'] == '_blank');
|
1666 |
+
break;
|
1667 |
+
case AI_CODE_ADSENSE:
|
1668 |
+
$("#adsense-publisher-id-" + block).val (code_data ['data-ad-client']);
|
1669 |
+
$("#adsense-ad-slot-id-" + block).val (code_data ['data-ad-slot']);
|
1670 |
+
|
1671 |
+
$("#adsense-type-" + block).val (code_data ['adsense-type']);
|
1672 |
+
$("#adsense-responsive-" + block).prop ('checked', code_data ['adsense-responsive']);
|
1673 |
+
$("#adsense-width-" + block).val (code_data ['adsense-width']);
|
1674 |
+
$("#adsense-height-" + block).val (code_data ['adsense-height']);
|
1675 |
+
|
1676 |
+
$("#adsense-layout-" + block).val (code_data ['adsense-layout']);
|
1677 |
+
$("#adsense-layout-key-" + block).val (code_data ['adsense-layout-key']);
|
1678 |
+
|
1679 |
+
process_adsense_elements (block);
|
1680 |
+
break;
|
1681 |
+
case AI_CODE_UNKNOWN:
|
1682 |
+
break;
|
1683 |
+
}
|
1684 |
+
}
|
1685 |
+
}
|
1686 |
+
});
|
1687 |
+
});
|
1688 |
+
|
1689 |
+
$("#generate-button-"+tab).click (function () {
|
1690 |
+
var block = $(this).attr('id').replace ("generate-button-", "");
|
1691 |
+
|
1692 |
+
var nonce = $("#ai-form").attr ('nonce');
|
1693 |
+
var code_type = $("#ai-code-generator-container-" + block).tabs('option', 'active');
|
1694 |
+
var code_data = "&generate-code=" + code_type;
|
1695 |
+
|
1696 |
+
switch (code_type) {
|
1697 |
+
case AI_CODE_BANNER:
|
1698 |
+
code_data = code_data + "&" + serialize_object ({'image': $("#banner-image-url-" + block).val (), 'link': $("#banner-url-" + block).val ()});
|
1699 |
+
if ($("#open-new-window-" + block).is(":checked")) code_data = code_data + "&target=_blank";
|
1700 |
+
break;
|
1701 |
+
case AI_CODE_ADSENSE:
|
1702 |
+
code_data = code_data + "&" + serialize_object ({
|
1703 |
+
'adsense-publisher-id': $("#adsense-publisher-id-" + block).val (),
|
1704 |
+
'adsense-ad-slot-id': $("#adsense-ad-slot-id-" + block).val (),
|
1705 |
+
'adsense-type': parseInt ($("select#adsense-type-" + block +" option:selected").attr ('value')),
|
1706 |
+
'adsense-responsive': $("#adsense-responsive-" + block).is(":checked") ? 1 : 0,
|
1707 |
+
'adsense-width': $("#adsense-width-" + block).val (),
|
1708 |
+
'adsense-height': $("#adsense-height-" + block).val (),
|
1709 |
+
'adsense-layout': $("#adsense-layout-" + block).val (),
|
1710 |
+
'adsense-layout-key': $("#adsense-layout-key-" + block).val ()
|
1711 |
+
});
|
1712 |
+
break;
|
1713 |
+
case AI_CODE_UNKNOWN:
|
1714 |
+
break;
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
if (debug) {
|
1718 |
+
console.log ("AI GENERATE CODE:", code_type);
|
1719 |
+
code_data.split ("&").splice (1).forEach (function (element) {
|
1720 |
+
console.log (' ', decodeURIComponent (element));
|
1721 |
+
});
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
$.ajax ({
|
1725 |
+
url: ajaxurl + "?action=ai_ajax_backend&ai_check=" + nonce + code_data
|
1726 |
+
}).done (function (code) {
|
1727 |
+
if (code != '') {
|
1728 |
+
set_editor_text (block, code);
|
1729 |
+
}
|
1730 |
+
});
|
1731 |
+
});
|
1732 |
}
|
1733 |
|
1734 |
function generate_country_list (element_name_prefix, index) {
|
1933 |
});
|
1934 |
}
|
1935 |
|
1936 |
+
function reload_list () {
|
1937 |
+
search_reload = false;
|
1938 |
+
var list = encodeURIComponent ($("#ai-list-search").val());
|
1939 |
+
var all = + !$("#ai-load-all").parent ().find ('.checkbox-icon').hasClass ('on');
|
1940 |
+
var nonce = $("#ai-list").attr ('nonce');
|
1941 |
+
|
1942 |
+
var data_container = $("#ai-list-data");
|
1943 |
+
|
1944 |
+
data_container.load (ajaxurl+"?action=ai_ajax_backend&list=" + list + "&all=" + all + "&start=" + start + "&end=" + end + "&ai_check=" + nonce, function (response, status, xhr) {
|
1945 |
+
if (status == "error") {
|
1946 |
+
var message = "Error downloading list data: " + xhr.status + " " + xhr.statusText;
|
1947 |
+
data_container.html (message);
|
1948 |
+
if (debug) console.log (message);
|
1949 |
+
} else {
|
1950 |
+
$(".ai-tab-link").click (function () {
|
1951 |
+
var tab = $(this).data ('tab') - start;
|
1952 |
+
$("#ai-tab-container").tabs ({active: tab});
|
1953 |
+
});
|
1954 |
+
}
|
1955 |
+
});
|
1956 |
+
}
|
1957 |
|
1958 |
if (debug) console.log ("READY");
|
1959 |
if (debug_title) $("#plugin_name").css ("color", "#f00");
|
2126 |
$('#ai-stars').show ();
|
2127 |
});
|
2128 |
|
2129 |
+
|
2130 |
+
$("#ai-list").click (function () {
|
2131 |
+
$('#ai-list-container').toggle ();
|
2132 |
+
|
2133 |
+
var container = $("#ai-list-container");
|
2134 |
+
|
2135 |
+
if (container.is(':visible')) {
|
2136 |
+
reload_list ();
|
2137 |
+
}
|
2138 |
+
});
|
2139 |
+
|
2140 |
+
$("#ai-list-search").keyup (function (event) {
|
2141 |
+
if (!search_reload) {
|
2142 |
+
search_reload = true;
|
2143 |
+
setTimeout (reload_list, 200);
|
2144 |
+
}
|
2145 |
+
});
|
2146 |
+
|
2147 |
+
$("#ai-load-all").click (function () {
|
2148 |
+
$(this).parent ().find ('.checkbox-icon').toggleClass ('on');
|
2149 |
+
reload_list ();
|
2150 |
+
});
|
2151 |
+
|
2152 |
setTimeout (update_rating, 1000);
|
2153 |
|
2154 |
if (debug) console.log ("");
|
preview.php
CHANGED
@@ -11,7 +11,7 @@ function alt_styles_data ($alt_styles_text) {
|
|
11 |
}
|
12 |
}
|
13 |
|
14 |
-
function generate_code_preview ($block, $name = null, $alignment = null, $alignment_css = null, $custom_css = null) {
|
15 |
global $block_object, $ai_wp_data;
|
16 |
|
17 |
$ai_wp_data [AI_WP_DEBUGGING] = 0;
|
@@ -28,7 +28,8 @@ function generate_code_preview ($block, $name = null, $alignment = null, $alignm
|
|
28 |
ai_wp_head_hook ();
|
29 |
$head_code = ob_get_clean ();
|
30 |
|
31 |
-
$block_code = $obj->ai_getProcessedCode (true, true);
|
|
|
32 |
|
33 |
// Fix for relative urls
|
34 |
$block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
|
11 |
}
|
12 |
}
|
13 |
|
14 |
+
function generate_code_preview ($block, $name = null, $alignment = null, $alignment_css = null, $custom_css = null, $client_code = null, $process_php = null) {
|
15 |
global $block_object, $ai_wp_data;
|
16 |
|
17 |
$ai_wp_data [AI_WP_DEBUGGING] = 0;
|
28 |
ai_wp_head_hook ();
|
29 |
$head_code = ob_get_clean ();
|
30 |
|
31 |
+
// $block_code = $obj->ai_getProcessedCode (true, true);
|
32 |
+
$block_code = $obj->ai_getProcessedCode (true, true, $client_code, $process_php);
|
33 |
|
34 |
// Fix for relative urls
|
35 |
$block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
|
readme.txt
CHANGED
@@ -4,9 +4,9 @@ Contributors: spacetime
|
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
5 |
Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, ad injection, adverts, sticky widgets, sticky sidebar, hook, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, ad blocking, custom fields
|
6 |
Requires at least: 4.0
|
7 |
-
Tested up to: 4.
|
8 |
Requires PHP: 5.2.4
|
9 |
-
Stable tag: 2.2.
|
10 |
License: GPLv3
|
11 |
|
12 |
Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
|
@@ -35,7 +35,7 @@ Ad Inserter is more than just ad manager plugin. It provides many advanced optio
|
|
35 |
> * Insert between posts on blog pages (in-feed AdSense ads)
|
36 |
> * Insert between excerpts on blog pages
|
37 |
> * Insert between comments
|
38 |
-
> * Insert at custom hook positions
|
39 |
> * Clearance options to avoid insertion near images or headers
|
40 |
> * Insertion exceptions for posts and pages
|
41 |
> * Insert header and footer code
|
@@ -77,7 +77,7 @@ And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank
|
|
77 |
> * Export and import of settings
|
78 |
> * Support via email
|
79 |
|
80 |
-
Ad Inserter Wordpress plugin is
|
81 |
|
82 |
> * Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features and some <a href="http://adinserter.pro/settings" target="_blank">common settings</a> for quick start
|
83 |
> * Download **PDF user guide** for Ad Inserter: go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro plugin</a> page and below you can find button for free download of Ad Inserter User Guide
|
@@ -117,6 +117,14 @@ Maintaining several plugins (often from different vendors) is not easy. And each
|
|
117 |
|
118 |
**Speed Up Your WordPress: Replace them all with free Ad Inserter!**
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
**Quick Start**
|
121 |
|
122 |
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>:
|
@@ -267,18 +275,16 @@ Block Alignment and Style:
|
|
267 |
|
268 |
Ad Inserter has a very useful function that can help you to check if the ad code is working and to see how it will look like when it will be inserted. Click on the **Preview** button to open Preview window.
|
269 |
WARNING: Some adblockers may block code on the Ad Inserter preview window. If you see warning PAGE BLOCKED or you don't see your code and the widow elements are distorted, make sure you have disabled ad blockers.
|
270 |
-
On the top of the window there is visual CSS editor and four buttons and below there is CSS code of the wrapping div (which can be edited manually) and '
|
271 |
|
272 |
-
Below the settings there is a
|
273 |
and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.
|
274 |
You can resize the window (and refresh the page to reload ads) to check display with different screen widths. Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.
|
275 |
-
|
276 |
-
**Please note** that the code displayed here is the code that is saved for this block, while block name, alignment and style are taken from the current block settings (may not be saved).
|
277 |
No Wrapping style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.
|
278 |
|
279 |
**Please note** that Preview window uses also Header and Footer code.
|
280 |
|
281 |
-
Check <a href="https://
|
282 |
|
283 |
**CACHING**
|
284 |
|
@@ -741,6 +747,14 @@ AD CODE RIGHT
|
|
741 |
|
742 |
== Changelog ==
|
743 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
744 |
= 2.2.5 =
|
745 |
- Fix for issue with Ajax requests
|
746 |
|
@@ -861,6 +875,14 @@ AD CODE RIGHT
|
|
861 |
|
862 |
== Upgrade Notice ==
|
863 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
864 |
= 2.2.5 =
|
865 |
Fix for issue with Ajax requests
|
866 |
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
5 |
Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, ad injection, adverts, sticky widgets, sticky sidebar, hook, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, ad blocking, custom fields
|
6 |
Requires at least: 4.0
|
7 |
+
Tested up to: 4.9
|
8 |
Requires PHP: 5.2.4
|
9 |
+
Stable tag: 2.2.5
|
10 |
License: GPLv3
|
11 |
|
12 |
Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
|
35 |
> * Insert between posts on blog pages (in-feed AdSense ads)
|
36 |
> * Insert between excerpts on blog pages
|
37 |
> * Insert between comments
|
38 |
+
> * Insert at custom hook positions
|
39 |
> * Clearance options to avoid insertion near images or headers
|
40 |
> * Insertion exceptions for posts and pages
|
41 |
> * Insert header and footer code
|
77 |
> * Export and import of settings
|
78 |
> * Support via email
|
79 |
|
80 |
+
Ad Inserter Wordpress plugin is an advanced advertising manager - it has many features and options to automate ad insertion and to optimally monetize your website on desktop, tablet and phone displays. It provides many simple ways to insert any Javascript, HTML, PHP or advert code anywhere on the page. For best ad placement and to use optimal advertising positions please read the user manual to get the most of the plugin.
|
81 |
|
82 |
> * Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features and some <a href="http://adinserter.pro/settings" target="_blank">common settings</a> for quick start
|
83 |
> * Download **PDF user guide** for Ad Inserter: go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro plugin</a> page and below you can find button for free download of Ad Inserter User Guide
|
117 |
|
118 |
**Speed Up Your WordPress: Replace them all with free Ad Inserter!**
|
119 |
|
120 |
+
**Insert Any Code Anywhere on the Page**
|
121 |
+
|
122 |
+
* Automatic insertion using standard WP hooks (the_content, the_excerpt, loop_start, loop_end, the_post,...)
|
123 |
+
* Automatic insertion using custom WP hooks (e.g. using <a href="https://genesistutorials.com/visual-hook-guide/" target="_blank">Genesis Theme Framework Hook Guide</a>)
|
124 |
+
* Manual insertion with shortcodes
|
125 |
+
* Manual insertion with widgets
|
126 |
+
* Manual insertion by placing PHP function calls in your theme files
|
127 |
+
|
128 |
**Quick Start**
|
129 |
|
130 |
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>:
|
275 |
|
276 |
Ad Inserter has a very useful function that can help you to check if the ad code is working and to see how it will look like when it will be inserted. Click on the **Preview** button to open Preview window.
|
277 |
WARNING: Some adblockers may block code on the Ad Inserter preview window. If you see warning PAGE BLOCKED or you don't see your code and the widow elements are distorted, make sure you have disabled ad blockers.
|
278 |
+
On the top of the window there is visual CSS editor and four buttons and below there is CSS code of the wrapping div (which can be edited manually) and 'Alignment and Style' selection.
|
279 |
|
280 |
+
Below the settings there is a preview of the code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div or write CSS code directly
|
281 |
and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.
|
282 |
You can resize the window (and refresh the page to reload ads) to check display with different screen widths. Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.
|
|
|
|
|
283 |
No Wrapping style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.
|
284 |
|
285 |
**Please note** that Preview window uses also Header and Footer code.
|
286 |
|
287 |
+
Check <a href="https://adinserter.pro/alignments-and-styles">Ad Inserter Alignments and Styles</a> for explanation on available alignments and styles of code blocks.
|
288 |
|
289 |
**CACHING**
|
290 |
|
747 |
|
748 |
== Changelog ==
|
749 |
|
750 |
+
= 2.2.6 =
|
751 |
+
- Fix for posts filter counter not counting
|
752 |
+
- Added list with short overview of all code blocks
|
753 |
+
- Added support for word count on blog pages
|
754 |
+
- Added support for client code preview (no need to save it for preview)
|
755 |
+
- Improved compatibility on AMP pages
|
756 |
+
- Few minor bug fixes, cosmetic changes and code improvements
|
757 |
+
|
758 |
= 2.2.5 =
|
759 |
- Fix for issue with Ajax requests
|
760 |
|
875 |
|
876 |
== Upgrade Notice ==
|
877 |
|
878 |
+
= 2.2.6 =
|
879 |
+
Fix for posts filter counter not counting;
|
880 |
+
Added list with short overview of all code blocks;
|
881 |
+
Added support for word count on blog pages;
|
882 |
+
Added support for client code preview (no need to save it for preview);
|
883 |
+
Improved compatibility on AMP pages;
|
884 |
+
Few minor bug fixes, cosmetic changes and code improvements
|
885 |
+
|
886 |
= 2.2.5 =
|
887 |
Fix for issue with Ajax requests
|
888 |
|
settings.php
CHANGED
@@ -6,6 +6,8 @@ function generate_settings_form (){
|
|
6 |
global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
|
7 |
global $rating_value, $rating_string, $rating_css, $ai_custom_hooks;
|
8 |
|
|
|
|
|
9 |
$save_url = $_SERVER ['REQUEST_URI'];
|
10 |
if (isset ($_GET ['tab'])) {
|
11 |
$save_url = preg_replace ("/&tab=\d+/", "", $save_url);
|
@@ -98,6 +100,7 @@ function generate_settings_form (){
|
|
98 |
$rating_css = $rating_string == '' ? 'width: 100%;' : 'width: '.number_format ($rating_string * 20, 4).'%;';
|
99 |
$rating_value = $rating_string == '' ? '' : number_format ($rating_string, 1);
|
100 |
|
|
|
101 |
?>
|
102 |
|
103 |
<div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo $ai_wp_data [AI_JS_DEBUGGING] ? '1' : '0'; ?>" ></div>
|
@@ -109,7 +112,7 @@ function generate_settings_form (){
|
|
109 |
|
110 |
<div id="ai-settings" style="float: left;">
|
111 |
|
112 |
-
<form id="ai-form" class="no-select rounded" style="float: left;" action="<?php echo $save_url; ?>" method="post" name="ai_form" start="<?php echo $start; ?>" end="<?php echo $end; ?>">
|
113 |
|
114 |
<div id="header" class="ai-form header rounded">
|
115 |
<?php
|
@@ -119,11 +122,12 @@ function generate_settings_form (){
|
|
119 |
<h2 id="plugin_name" style="display: inline-block; margin: 5px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
|
120 |
</div>
|
121 |
<div id="header-buttons">
|
122 |
-
<button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('http://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button>
|
123 |
-
<button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button>
|
124 |
-
<button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
|
125 |
-
<button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
|
126 |
-
<button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go Pro</button>
|
|
|
127 |
</div>
|
128 |
|
129 |
<div style="clear: both;"></div>
|
@@ -163,7 +167,8 @@ function generate_settings_form (){
|
|
163 |
<div style="clear: both;"></div>
|
164 |
</div>
|
165 |
|
166 |
-
<div id="ai-
|
|
|
167 |
<div id="dummy-tabs" style="height: 30px; padding: .2em .2em 0;"></div>
|
168 |
|
169 |
<div id="ai-scroll-tabs" class="scroll_tabs_theme_light" style="display: none;">
|
@@ -179,31 +184,35 @@ function generate_settings_form (){
|
|
179 |
<ul id="ai-tabs" style="display: none;">
|
180 |
<?php
|
181 |
|
182 |
-
$
|
183 |
-
|
184 |
-
|
185 |
-
$
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
|
|
207 |
|
208 |
$manual_widget = array ();
|
209 |
$manual_shortcode = array ();
|
@@ -390,6 +399,14 @@ function generate_settings_form (){
|
|
390 |
</span>
|
391 |
<?php endif; ?>
|
392 |
<?php if (function_exists ('ai_settings_top_buttons_1')) ai_settings_top_buttons_1 ($ad_number, $obj, $default); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
<span class="ai-toolbar-button ai-settings">
|
394 |
<input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
|
395 |
<input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_process_php (); ?>" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
|
@@ -402,6 +419,130 @@ function generate_settings_form (){
|
|
402 |
|
403 |
<div id="settings-<?php echo $ad_number; ?>">
|
404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
<div style="margin: 8px 0;">
|
406 |
<textarea id="block-<?php echo $ad_number; ?>" class="simple-editor" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
|
407 |
</div>
|
@@ -427,6 +568,9 @@ function generate_settings_form (){
|
|
427 |
Automatic Insertion:
|
428 |
<select style="margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
|
429 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
|
|
|
|
|
|
|
430 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
|
431 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-content" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_CONTENT; ?></option>
|
432 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_PARAGRAPH; ?></option>
|
@@ -448,7 +592,7 @@ function generate_settings_form (){
|
|
448 |
|
449 |
<div style="float: right;">
|
450 |
Alignment and Style:
|
451 |
-
<select style="width:
|
452 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion default" value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
|
453 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion align-left" value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
|
454 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion center" value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
|
@@ -1054,7 +1198,7 @@ function generate_settings_form (){
|
|
1054 |
<div class="max-input">
|
1055 |
<span style="display: table-cell; width: 1px; white-space: nowrap;">
|
1056 |
Insert for
|
1057 |
-
<select id="display-for-users-<?php echo $ad_number; ?>" style="margin: 0 1px;" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_display_for_users(); ?>"
|
1058 |
<option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
|
1059 |
<option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
|
1060 |
<option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
|
@@ -1743,7 +1887,7 @@ function generate_settings_form (){
|
|
1743 |
Used blocks
|
1744 |
</td>
|
1745 |
<td>
|
1746 |
-
<?php if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) echo $
|
1747 |
</td>
|
1748 |
</tr>
|
1749 |
<?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
|
@@ -1751,36 +1895,42 @@ function generate_settings_form (){
|
|
1751 |
</div>
|
1752 |
|
1753 |
</div>
|
1754 |
-
</div>
|
1755 |
|
1756 |
-
</div>
|
|
|
|
|
|
|
1757 |
|
1758 |
<?php
|
1759 |
|
1760 |
$sidebar = 0;
|
|
|
1761 |
if (isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
|
1762 |
if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 2)
|
1763 |
$sidebar = 1;
|
1764 |
|
1765 |
-
if ($
|
1766 |
-
|
1767 |
$sidebar = 2;
|
1768 |
|
1769 |
-
if ($
|
1770 |
-
$
|
1771 |
-
|
1772 |
$sidebar = 3;
|
1773 |
|
1774 |
if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20)
|
1775 |
$sidebar = 4;
|
1776 |
|
1777 |
} else {
|
1778 |
-
if ($
|
1779 |
}
|
1780 |
|
1781 |
// $sidebar = 4;
|
1782 |
|
1783 |
-
if (!function_exists ('ai_settings_side')
|
|
|
|
|
1784 |
|
1785 |
switch ($sidebar) {
|
1786 |
case 0:
|
@@ -1809,15 +1959,14 @@ function generate_settings_form (){
|
|
1809 |
|
1810 |
</div>
|
1811 |
|
1812 |
-
|
1813 |
|
1814 |
<?php
|
1815 |
if ($subpage == 'main') {
|
1816 |
-
if (function_exists ('ai_settings_side'))
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
<?php
|
1821 |
switch ($sidebar) {
|
1822 |
case 0:
|
1823 |
sidebar_help ();
|
@@ -1845,14 +1994,12 @@ function generate_settings_form (){
|
|
1845 |
sidebar_pro ();
|
1846 |
break;
|
1847 |
}
|
1848 |
-
?>
|
1849 |
-
|
1850 |
-
</div>
|
1851 |
-
<?php
|
1852 |
}
|
1853 |
}
|
1854 |
?>
|
1855 |
-
|
|
|
|
|
1856 |
<script type="text/javascript">
|
1857 |
jQuery(document).ready(function($) {
|
1858 |
setTimeout (check_blocked_images, 400);
|
@@ -1897,8 +2044,147 @@ function generate_settings_form (){
|
|
1897 |
}
|
1898 |
</script>
|
1899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1900 |
<?php
|
1901 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1902 |
|
1903 |
function sidebar_addense_alternative () { ?>
|
1904 |
|
@@ -2106,6 +2392,3 @@ function sidebar_pro_small () { ?>
|
|
2106 |
<?php
|
2107 |
}
|
2108 |
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
6 |
global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
|
7 |
global $rating_value, $rating_string, $rating_css, $ai_custom_hooks;
|
8 |
|
9 |
+
wp_enqueue_media();
|
10 |
+
|
11 |
$save_url = $_SERVER ['REQUEST_URI'];
|
12 |
if (isset ($_GET ['tab'])) {
|
13 |
$save_url = preg_replace ("/&tab=\d+/", "", $save_url);
|
100 |
$rating_css = $rating_string == '' ? 'width: 100%;' : 'width: '.number_format ($rating_string * 20, 4).'%;';
|
101 |
$rating_value = $rating_string == '' ? '' : number_format ($rating_string, 1);
|
102 |
|
103 |
+
if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]); else $used_blocks = array ();
|
104 |
?>
|
105 |
|
106 |
<div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo $ai_wp_data [AI_JS_DEBUGGING] ? '1' : '0'; ?>" ></div>
|
112 |
|
113 |
<div id="ai-settings" style="float: left;">
|
114 |
|
115 |
+
<form id="ai-form" class="no-select rounded" style="float: left;" action="<?php echo $save_url; ?>" method="post" name="ai_form" start="<?php echo $start; ?>" end="<?php echo $end; ?>" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>">
|
116 |
|
117 |
<div id="header" class="ai-form header rounded">
|
118 |
<?php
|
122 |
<h2 id="plugin_name" style="display: inline-block; margin: 5px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
|
123 |
</div>
|
124 |
<div id="header-buttons">
|
125 |
+
<button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button>
|
126 |
+
<button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button>
|
127 |
+
<button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
|
128 |
+
<button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
|
129 |
+
<button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go Pro</button>
|
130 |
+
<button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>"><span>List</span></button>
|
131 |
</div>
|
132 |
|
133 |
<div style="clear: both;"></div>
|
167 |
<div style="clear: both;"></div>
|
168 |
</div>
|
169 |
|
170 |
+
<div id="ai-container">
|
171 |
+
<div id="ai-tab-container" class="ai-form rounded" style="padding-bottom: 1px;">
|
172 |
<div id="dummy-tabs" style="height: 30px; padding: .2em .2em 0;"></div>
|
173 |
|
174 |
<div id="ai-scroll-tabs" class="scroll_tabs_theme_light" style="display: none;">
|
184 |
<ul id="ai-tabs" style="display: none;">
|
185 |
<?php
|
186 |
|
187 |
+
$sidebars_with_widget = get_sidebar_widgets ();
|
188 |
+
|
189 |
+
// $sidebar_widgets = wp_get_sidebars_widgets();
|
190 |
+
// $widget_options = get_option ('widget_ai_widget');
|
191 |
+
|
192 |
+
// $sidebars_with_widgets = array ();
|
193 |
+
//// for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
|
194 |
+
// for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
|
195 |
+
// $sidebars_with_widget [$ad_number]= array ();
|
196 |
+
// }
|
197 |
+
// foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
|
198 |
+
// if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
|
199 |
+
// $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
|
200 |
+
// if ($sidebar_name != "") {
|
201 |
+
// foreach ($sidebar_widget as $widget) {
|
202 |
+
// if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
|
203 |
+
// if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
|
204 |
+
// $widget_option = $widget_options [$widget_id [1]];
|
205 |
+
// $widget_block = $widget_option ['block'];
|
206 |
+
//// if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
|
207 |
+
// if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
|
208 |
+
// $sidebars_with_widget [$widget_block] []= $sidebar_name;
|
209 |
+
// }
|
210 |
+
// }
|
211 |
+
// }
|
212 |
+
// }
|
213 |
+
// }
|
214 |
+
// }
|
215 |
+
// }
|
216 |
|
217 |
$manual_widget = array ();
|
218 |
$manual_shortcode = array ();
|
399 |
</span>
|
400 |
<?php endif; ?>
|
401 |
<?php if (function_exists ('ai_settings_top_buttons_1')) ai_settings_top_buttons_1 ($ad_number, $obj, $default); ?>
|
402 |
+
|
403 |
+
<?php if (defined ('AI_CODE_GENERATOR')) : ?>
|
404 |
+
<span class="ai-toolbar-button ai-settings">
|
405 |
+
<input type="checkbox" id="code-generator-<?php echo $ad_number; ?>" style="display: none;" />
|
406 |
+
<label class="checkbox-button" for="code-generator-<?php echo $ad_number; ?>" title="Open code generator"><span class="checkbox-icon icon-enabled"></span></label>
|
407 |
+
</span>
|
408 |
+
<?php endif; ?>
|
409 |
+
|
410 |
<span class="ai-toolbar-button ai-settings">
|
411 |
<input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
|
412 |
<input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_process_php (); ?>" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
|
419 |
|
420 |
<div id="settings-<?php echo $ad_number; ?>">
|
421 |
|
422 |
+
<?php if (defined ('AI_CODE_GENERATOR')) : ?>
|
423 |
+
|
424 |
+
<div id="ai-code-generator-container-<?php echo $ad_number; ?>" style="padding: 0; margin: 8px 0; border: 0; display: none;">
|
425 |
+
|
426 |
+
<ul id="ai-code-generator-tabs-<?php echo $ad_number; ?>" style="display: none;">
|
427 |
+
<li id="ai-visual-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-visual-<?php echo $ad_number; ?>">Visual Editor</a></li>
|
428 |
+
<li id="ai-banner-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-banner-<?php echo $ad_number; ?>">Banner</a></li>
|
429 |
+
<li id="ai-adsense-pub-id-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-adsense-<?php echo $ad_number; ?>">AdSense</a></li>
|
430 |
+
</ul>
|
431 |
+
|
432 |
+
<div id="tab-visual-<?php echo $ad_number; ?>" class="responsive-table rounded">
|
433 |
+
</div>
|
434 |
+
|
435 |
+
<div id="tab-banner-<?php echo $ad_number; ?>" class="responsive-table rounded">
|
436 |
+
<a id="banner-link-<?php echo $ad_number; ?>" href="" target="_blank"><img id="banner-image-<?php echo $ad_number; ?>" src="" style="float: left; max-width: 72px; max-height: 160px; margin: 0 10px 0 0;" /></a>
|
437 |
+
<table class="ai-settings-table" style="">
|
438 |
+
<tr>
|
439 |
+
<td style="padding-right: 7px;">
|
440 |
+
Image
|
441 |
+
</td>
|
442 |
+
<td style="width: 90%; padding-right: 7px;">
|
443 |
+
<input id="banner-image-url-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="50" maxlength="200" />
|
444 |
+
</td>
|
445 |
+
<td style="width: 130px;">
|
446 |
+
<button id="open-image-button-<?php echo $ad_number; ?>" type="button" style="display: none; float: right;">Select</button>
|
447 |
+
</td>
|
448 |
+
</tr>
|
449 |
+
<tr>
|
450 |
+
<td>
|
451 |
+
Link
|
452 |
+
</td>
|
453 |
+
<td style="padding-right: 7px;">
|
454 |
+
<input id="banner-url-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="50" maxlength="200" />
|
455 |
+
</td>
|
456 |
+
<td>
|
457 |
+
<input type="checkbox" id="open-new-window-<?php echo $ad_number; ?>" />
|
458 |
+
<label for="open-new-window-<?php echo $ad_number; ?>">Open in a new tab</label>
|
459 |
+
</td>
|
460 |
+
</tr>
|
461 |
+
</table>
|
462 |
+
<div style="clear: both;"></div>
|
463 |
+
</div>
|
464 |
+
|
465 |
+
<div id="tab-adsense-<?php echo $ad_number; ?>" class="responsive-table rounded">
|
466 |
+
<table class="ai-settings-table" style="">
|
467 |
+
<tr>
|
468 |
+
<td>
|
469 |
+
Publisher ID
|
470 |
+
</td>
|
471 |
+
<td style="width: 50%; padding-left: 7px;">
|
472 |
+
<input id="adsense-publisher-id-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="30" maxlength="30" />
|
473 |
+
</td>
|
474 |
+
<td class="adsense-layout" style="padding-left: 7px;">
|
475 |
+
Layout
|
476 |
+
</td>
|
477 |
+
<td class="adsense-layout" style="width: 50%; padding-left: 7px;">
|
478 |
+
<input id="adsense-layout-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="80" maxlength="100" />
|
479 |
+
</td>
|
480 |
+
</tr>
|
481 |
+
|
482 |
+
<tr>
|
483 |
+
<td>
|
484 |
+
Ad Slot ID
|
485 |
+
</td>
|
486 |
+
<td style="width: 50%; padding-left: 7px;">
|
487 |
+
<input id="adsense-ad-slot-id-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="30" maxlength="30" />
|
488 |
+
</td>
|
489 |
+
<td class="adsense-layout" style="padding-left: 7px;">
|
490 |
+
Layout Key
|
491 |
+
</td>
|
492 |
+
<td class="adsense-layout" style="width: 50%; padding-left: 7px;">
|
493 |
+
<input id="adsense-layout-key-<?php echo $ad_number; ?>" style="width: 100%;" type="text" size="80" maxlength="100" />
|
494 |
+
</td>
|
495 |
+
</tr>
|
496 |
+
|
497 |
+
<tr>
|
498 |
+
<td>
|
499 |
+
Ad Type
|
500 |
+
</td>
|
501 |
+
<td style="padding-left: 7px;">
|
502 |
+
<select id="adsense-type-<?php echo $ad_number; ?>">
|
503 |
+
<option value="<?php echo AI_ADSENSE_STANDARD; ?>" selected><?php echo AI_TEXT_STANDARD; ?></option>
|
504 |
+
<option value="<?php echo AI_ADSENSE_LINK; ?>"><?php echo AI_TEXT_LINK; ?></option>
|
505 |
+
<option value="<?php echo AI_ADSENSE_IN_ARTICLE; ?>"><?php echo AI_TEXT_IN_ARTICLE; ?></option>
|
506 |
+
<option value="<?php echo AI_ADSENSE_IN_FEED; ?>"><?php echo AI_TEXT_IN_FEED; ?></option>
|
507 |
+
<option value="<?php echo AI_ADSENSE_MATCHED_CONTENT; ?>"><?php echo AI_TEXT_MATCHED_CONTENT; ?></option>
|
508 |
+
</select>
|
509 |
+
<div class="adsense-responsive" style="float: right; margin-top: 3px;">
|
510 |
+
<input type="checkbox" id="adsense-responsive-<?php echo $ad_number; ?>" />
|
511 |
+
<label for="adsense-responsive-<?php echo $ad_number; ?>">Responsive</label>
|
512 |
+
</div>
|
513 |
+
</td>
|
514 |
+
<td>
|
515 |
+
|
516 |
+
</td>
|
517 |
+
<td class="adsense-size" style="padding-left: 7px;">
|
518 |
+
Width
|
519 |
+
<input id="adsense-width-<?php echo $ad_number; ?>" style="width: 50px;" type="text" size="5" maxlength="5" />
|
520 |
+
px
|
521 |
+
<div style="float: right;">
|
522 |
+
Height
|
523 |
+
<input id="adsense-height-<?php echo $ad_number; ?>" style="width: 50px;" type="text" size="5" maxlength="5" />
|
524 |
+
px
|
525 |
+
</div>
|
526 |
+
</td>
|
527 |
+
</tr>
|
528 |
+
</table>
|
529 |
+
<div style="clear: both;"></div>
|
530 |
+
|
531 |
+
</div>
|
532 |
+
|
533 |
+
<div style="padding: 0; min-height: 28px;">
|
534 |
+
<div style="float: left;">
|
535 |
+
<button id="import-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="">Import</button>
|
536 |
+
</div>
|
537 |
+
<div style="float: right;">
|
538 |
+
<button id="generate-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="">Generate</button>
|
539 |
+
</div>
|
540 |
+
<div style="clear: both;"></div>
|
541 |
+
</div>
|
542 |
+
|
543 |
+
</div>
|
544 |
+
<?php endif; ?>
|
545 |
+
|
546 |
<div style="margin: 8px 0;">
|
547 |
<textarea id="block-<?php echo $ad_number; ?>" class="simple-editor" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
|
548 |
</div>
|
568 |
Automatic Insertion:
|
569 |
<select style="margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
|
570 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
|
571 |
+
<?php if (defined ('AI_BUFFERING')) : ?>
|
572 |
+
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion above-header" value="<?php echo AI_AUTOMATIC_INSERTION_ABOVE_HEADER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_ABOVE_HEADER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ABOVE_HEADER; ?></option>
|
573 |
+
<?php endif; ?>
|
574 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
|
575 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-content" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_CONTENT; ?></option>
|
576 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_PARAGRAPH; ?></option>
|
592 |
|
593 |
<div style="float: right;">
|
594 |
Alignment and Style:
|
595 |
+
<select style="width:130px;" id="block-alignment-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_alignment_type(); ?>">
|
596 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion default" value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
|
597 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion align-left" value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
|
598 |
<option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion center" value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
|
1198 |
<div class="max-input">
|
1199 |
<span style="display: table-cell; width: 1px; white-space: nowrap;">
|
1200 |
Insert for
|
1201 |
+
<select id="display-for-users-<?php echo $ad_number; ?>" style="margin: 0 1px; width:160px" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_display_for_users(); ?>">
|
1202 |
<option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
|
1203 |
<option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
|
1204 |
<option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
|
1887 |
Used blocks
|
1888 |
</td>
|
1889 |
<td>
|
1890 |
+
<?php if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) echo count ($used_blocks), ' (', implode (', ', array_slice ($used_blocks, 0, 26)), count ($used_blocks) > 26 ? ',...' : '', ')'; ?>
|
1891 |
</td>
|
1892 |
</tr>
|
1893 |
<?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
|
1895 |
</div>
|
1896 |
|
1897 |
</div>
|
1898 |
+
</div> <!-- tab-0 -->
|
1899 |
|
1900 |
+
</div> <!-- ai-tab-container -->
|
1901 |
+
|
1902 |
+
|
1903 |
+
</div> <!-- ai-container -->
|
1904 |
|
1905 |
<?php
|
1906 |
|
1907 |
$sidebar = 0;
|
1908 |
+
$number_of_used_blocks = count ($used_blocks);
|
1909 |
if (isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
|
1910 |
if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 2)
|
1911 |
$sidebar = 1;
|
1912 |
|
1913 |
+
if ($number_of_used_blocks >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 5 ||
|
1914 |
+
$ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10)
|
1915 |
$sidebar = 2;
|
1916 |
|
1917 |
+
if ($number_of_used_blocks >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 7 ||
|
1918 |
+
$number_of_used_blocks >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10 ||
|
1919 |
+
$ai_wp_data [AI_DAYS_SINCE_INSTAL] > 15)
|
1920 |
$sidebar = 3;
|
1921 |
|
1922 |
if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20)
|
1923 |
$sidebar = 4;
|
1924 |
|
1925 |
} else {
|
1926 |
+
if ($number_of_used_blocks >= 3) $sidebar = 4;
|
1927 |
}
|
1928 |
|
1929 |
// $sidebar = 4;
|
1930 |
|
1931 |
+
if (!function_exists ('ai_settings_side')) {
|
1932 |
+
|
1933 |
+
code_block_list_container ();
|
1934 |
|
1935 |
switch ($sidebar) {
|
1936 |
case 0:
|
1959 |
|
1960 |
</div>
|
1961 |
|
1962 |
+
<div id="ai-sidebar" style="float: left;">
|
1963 |
|
1964 |
<?php
|
1965 |
if ($subpage == 'main') {
|
1966 |
+
if (function_exists ('ai_settings_side')) {
|
1967 |
+
code_block_list_container ();
|
1968 |
+
ai_settings_side ();
|
1969 |
+
} else {
|
|
|
1970 |
switch ($sidebar) {
|
1971 |
case 0:
|
1972 |
sidebar_help ();
|
1994 |
sidebar_pro ();
|
1995 |
break;
|
1996 |
}
|
|
|
|
|
|
|
|
|
1997 |
}
|
1998 |
}
|
1999 |
?>
|
2000 |
+
|
2001 |
+
</div>
|
2002 |
+
|
2003 |
<script type="text/javascript">
|
2004 |
jQuery(document).ready(function($) {
|
2005 |
setTimeout (check_blocked_images, 400);
|
2044 |
}
|
2045 |
</script>
|
2046 |
|
2047 |
+
<?php
|
2048 |
+
} // generate_settings_form ()
|
2049 |
+
|
2050 |
+
function get_sidebar_widgets () {
|
2051 |
+
$sidebar_widgets = wp_get_sidebars_widgets();
|
2052 |
+
$widget_options = get_option ('widget_ai_widget');
|
2053 |
+
|
2054 |
+
$sidebars_with_widgets = array ();
|
2055 |
+
// for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
|
2056 |
+
for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
|
2057 |
+
$sidebars_with_widget [$ad_number]= array ();
|
2058 |
+
}
|
2059 |
+
foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
|
2060 |
+
if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
|
2061 |
+
$sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
|
2062 |
+
if ($sidebar_name != "") {
|
2063 |
+
foreach ($sidebar_widget as $widget) {
|
2064 |
+
if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
|
2065 |
+
if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
|
2066 |
+
$widget_option = $widget_options [$widget_id [1]];
|
2067 |
+
$widget_block = $widget_option ['block'];
|
2068 |
+
// if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
|
2069 |
+
if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
|
2070 |
+
$sidebars_with_widget [$widget_block] []= $sidebar_name;
|
2071 |
+
}
|
2072 |
+
}
|
2073 |
+
}
|
2074 |
+
}
|
2075 |
+
}
|
2076 |
+
}
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
return $sidebars_with_widget;
|
2080 |
+
}
|
2081 |
+
|
2082 |
+
function code_block_list_container () {
|
2083 |
+
?>
|
2084 |
+
<div id="ai-list-container" class="ai-form rounded" style="background: #fff; display: none;">
|
2085 |
+
<div id='list-controls' class='ui-widget' style='margin: 8px auto;'>
|
2086 |
+
<span class="ai-toolbar-button" style="vertical-align: middle;">
|
2087 |
+
<input type="checkbox" value="0" id="ai-load-all" style="display: none;" />
|
2088 |
+
<label class="checkbox-button" for="ai-load-all" title="Toggle active/all blocks"><span class="checkbox-icon icon-enabled-all on"></span></label>
|
2089 |
+
</span>
|
2090 |
+
<span class="ai-toolbar-button" style="vertical-align: middle;">
|
2091 |
+
<input id="ai-list-search" type="text" value="" size="40" maxlength="40" />
|
2092 |
+
</span>
|
2093 |
+
</div>
|
2094 |
+
|
2095 |
+
<div id="ai-list-data">
|
2096 |
+
Loading...
|
2097 |
+
</div>
|
2098 |
+
</div>
|
2099 |
+
<?php
|
2100 |
+
}
|
2101 |
+
|
2102 |
+
function code_block_list () {
|
2103 |
+
global $block_object;
|
2104 |
+
|
2105 |
+
$sidebars_with_widget = get_sidebar_widgets (); ?>
|
2106 |
+
|
2107 |
+
<table class="exceptions" cellspacing=0 cellpadding=0 style="width: 100%;">
|
2108 |
+
<thead>
|
2109 |
+
<tr>
|
2110 |
+
<th style="text-align: right;">Block</th>
|
2111 |
+
<th style="text-align: left; padding-left: 10px;">Name</th>
|
2112 |
+
<th style="text-align: left; padding-left: 10px;">Automatic Insertion</th>
|
2113 |
+
<th style="text-align: left; padding-left: 10px;">Alignment</th>
|
2114 |
+
<th style="text-align: center; padding-left: 10px;" title="PHP function call">P</th>
|
2115 |
+
<th style="text-align: center; padding-left: 10px;" title="Shortcode">S</th>
|
2116 |
+
<th style="text-align: center; padding-left: 10px;" title="Widget">W</th>
|
2117 |
+
<th style="text-align: left; padding-left: 10px;">Widget Positions</th>
|
2118 |
+
</tr>
|
2119 |
+
</thead>
|
2120 |
+
<tbody>
|
2121 |
+
<?php
|
2122 |
+
|
2123 |
+
$search_text = trim ($_GET ["list"]);
|
2124 |
+
|
2125 |
+
$show_all_blocks = isset ($_GET ["all"]) && $_GET ["all"];
|
2126 |
+
|
2127 |
+
$start = trim ($_GET ["start"]);
|
2128 |
+
$end = trim ($_GET ["end"]);
|
2129 |
+
|
2130 |
+
if ($search_text != '') $search_array = explode (' ', $search_text); else $search_array = array ();
|
2131 |
+
|
2132 |
+
$row_counter = 0;
|
2133 |
+
for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
|
2134 |
+
$obj = $block_object [$block];
|
2135 |
+
|
2136 |
+
$automatic_insertion = $obj->get_automatic_insertion () != AI_AUTOMATIC_INSERTION_DISABLED;
|
2137 |
+
|
2138 |
+
$manual_widget = $obj->get_enable_widget() == AI_ENABLED;
|
2139 |
+
$manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
|
2140 |
+
$manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
|
2141 |
+
|
2142 |
+
$block_used = $automatic_insertion || $manual_php_function || $manual_shortcode || $manual_widget && !empty ($sidebars_with_widget [$block]);
|
2143 |
+
|
2144 |
+
if (!$show_all_blocks && !$block_used) continue;
|
2145 |
+
|
2146 |
+
$block_text = $block . ' '. $obj->wp_options [AI_OPTION_BLOCK_NAME] . ' ' . $obj->get_automatic_insertion_text() . ' ' . $obj->get_alignment_type_text () . ' ' . implode (', ', $sidebars_with_widget [$block]);
|
2147 |
+
if (!empty ($sidebars_with_widget [$block])) $block_text .= ' widget';
|
2148 |
+
if ($manual_shortcode) $block_text .= ' shortcode';
|
2149 |
+
if ($manual_php_function) $block_text .= ' php';
|
2150 |
+
|
2151 |
+
foreach ($search_array as $search_item) {
|
2152 |
+
if (stripos ($block_text, trim ($search_item)) === false) continue 2;
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
$row_counter ++;
|
2156 |
+
$row_color = $row_counter % 2 == 0 ? '#eee' : '#fff';
|
2157 |
+
|
2158 |
+
if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
|
2159 |
+
$edit_url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $block;
|
2160 |
+
|
2161 |
+
$visible_tab = $block >= $start && $block <= $end;
|
2162 |
+
|
2163 |
+
?>
|
2164 |
+
<tr style="background: <?php echo $row_color; ?>">
|
2165 |
+
<td style="text-align: right; color: <?php echo $block_used ? '#444' : '#ccc'; ?>"><?php echo $block; ?></td>
|
2166 |
+
<?php if ($visible_tab): ?>
|
2167 |
+
<td class="ai-tab-link" data-tab="<?php echo $block; ?>" style="color: #0073aa; cursor: pointer; text-align: left; padding-left: 10px; max-width: 280px; white-space: nowrap; overflow: hidden;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></td>
|
2168 |
+
<?php else: ?>
|
2169 |
+
<td style="text-align: left; padding-left: 10px; max-width: 280px; white-space: nowrap; overflow: hidden;"><a href="<?php echo $edit_url; ?>" style="text-decoration: none; box-shadow: 0 0 0;"><?php echo $obj->wp_options [AI_OPTION_BLOCK_NAME]; ?></a></td>
|
2170 |
+
<?php endif ?>
|
2171 |
+
<td style="text-align: left; padding-left: 10px; max-width: 130px; white-space: nowrap; overflow: hidden; color: <?php echo $automatic_insertion ? '#666' : '#ccc'; ?>"><?php echo $obj->get_automatic_insertion_text(); ?></td>
|
2172 |
+
<td style="text-align: left; padding-left: 10px; max-width: 80px; white-space: nowrap; overflow: hidden; color: <?php echo $block_used ? '#444' : '#ccc'; ?>"><?php echo $obj->get_alignment_type_text (); ?></td>
|
2173 |
+
<td class="ai-dot" style="text-align: center; padding-left: 10px; vertical-align: top; color: <?php echo $manual_php_function ? '#8080ff' : '#ddd'; ?>;">●</td>
|
2174 |
+
<td class="ai-dot" style="text-align: center; padding-left: 10px; vertical-align: top; color: <?php echo $manual_shortcode ? '#ff8b8b' : '#ddd'; ?>;">●</td>
|
2175 |
+
<td class="ai-dot" style="text-align: center; padding-left: 10px; vertical-align: top; color: <?php echo $manual_widget ? (count ($sidebars_with_widget [$block]) ? '#7cda7c' : '#666') : '#ddd'; ?>;">●</td>
|
2176 |
+
<td style="text-align: left; padding-left: 10px; max-width: 160px; white-space: nowrap; overflow: hidden; color: <?php echo $manual_widget ? '#666' : '#ccc'; ?>;"><?php echo implode (', ', $sidebars_with_widget [$block]); ?></td>
|
2177 |
+
</tr>
|
2178 |
<?php
|
2179 |
}
|
2180 |
+
?>
|
2181 |
+
</tbody>
|
2182 |
+
</table>
|
2183 |
+
<?php
|
2184 |
+
if ($row_counter == 0) {
|
2185 |
+
echo "<div style='margin: 10px 0 0 20px;'>No code block matches search keywords</div>";
|
2186 |
+
}
|
2187 |
+
}
|
2188 |
|
2189 |
function sidebar_addense_alternative () { ?>
|
2190 |
|
2392 |
<?php
|
2393 |
}
|
2394 |
|
|
|
|
|
|