Version Description
- Fixed bug: For shortcodes in posts the url was not checked
- Optimizations for device detection
Download this release
Release Info
Developer | spacetime |
Plugin | Ad Inserter – WordPress Ads Management with AdSense Header Integration |
Version | 1.6.4 |
Comparing to | |
See all releases |
Code changes from version 1.6.3 to 1.6.4
- ad-inserter.php +54 -630
- class.php +5 -5
- constants.php +1 -1
- index.php +8 -8
- readme.txt +11 -3
- settings.php +1 -1
ad-inserter.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
-
Version: 1.6.
|
5 |
Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
|
6 |
Author: Spacetime
|
7 |
Author URI: http://igorfuna.com/
|
@@ -11,6 +11,10 @@ Plugin URI: http://igorfuna.com/software/web/ad-inserter-wordpress-plugin
|
|
11 |
/*
|
12 |
Change Log
|
13 |
|
|
|
|
|
|
|
|
|
14 |
Ad Inserter 1.6.3 - 6 April 2016
|
15 |
- Removed deprecated code (fixes PHP 7 deprecated warnings)
|
16 |
- Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
|
@@ -198,27 +202,43 @@ if (version_compare ($wp_version, "3.0", "<")) {
|
|
198 |
require_once AD_INSERTER_PLUGIN_DIR.'class.php';
|
199 |
require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
|
200 |
require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
|
201 |
-
require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
|
202 |
|
203 |
$ad_interter_globals = array ();
|
204 |
|
205 |
-
$detect = new ai_Mobile_Detect;
|
206 |
-
|
207 |
-
define ('AI_MOBILE', $detect->isMobile ());
|
208 |
-
define ('AI_TABLET', $detect->isTablet ());
|
209 |
-
define ('AI_PHONE', AI_MOBILE && !AI_TABLET);
|
210 |
-
define ('AI_DESKTOP', !AI_MOBILE);
|
211 |
-
|
212 |
// Load options
|
213 |
ai_load_options ();
|
214 |
|
|
|
|
|
|
|
215 |
$block_object = array ();
|
216 |
for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
|
217 |
$obj = new ai_Block ($counter);
|
218 |
$obj->load_options ($counter);
|
219 |
$block_object [$counter] = $obj;
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
$plugin_priority = get_plugin_priority ();
|
223 |
|
224 |
// Set hooks
|
@@ -227,13 +247,16 @@ add_filter ('the_content', 'ai_content_hook', $plugin_priority);
|
|
227 |
add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
|
228 |
add_action ('loop_start', 'ai_loop_start_hook');
|
229 |
add_action ('init', 'ai_init_hook');
|
230 |
-
add_action ('admin_notices', 'ai_admin_notice_hook');
|
231 |
add_action ('wp_head', 'ai_wp_head_hook');
|
232 |
add_action ('wp_footer', 'ai_wp_footer_hook');
|
233 |
add_action ('widgets_init', 'ai_widgets_init_hook');
|
234 |
add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
|
235 |
add_action ('save_post', 'ai_save_meta_box_data_hook');
|
236 |
-
|
|
|
|
|
|
|
237 |
|
238 |
add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
|
239 |
|
@@ -241,26 +264,12 @@ add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action
|
|
241 |
function ai_init_hook() {
|
242 |
global $block_object;
|
243 |
|
244 |
-
// OLD WIDGETS - DEPRECATED
|
245 |
-
// for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
|
246 |
-
// $obj = $block_object [$counter];
|
247 |
-
// if($obj->get_display_type() == AD_SELECT_WIDGET){
|
248 |
-
// // register widget
|
249 |
-
// $widget_options = array ('classname' => 'ad-inserter-widget', 'description' => "DEPRECATED - Use 'Ad Inserter' widget instead.");
|
250 |
-
// $widget_parameters = array ('block' => $counter);
|
251 |
-
// // Different callback functions because widgets that share callback functions don't get displayed
|
252 |
-
// if ($counter <= 16)
|
253 |
-
// wp_register_sidebar_widget ('ai_widget'.$counter, $obj->get_ad_name().' - DEPRECATED', 'ai_widget'.$counter, $widget_options, $widget_parameters);
|
254 |
-
// }
|
255 |
-
// }
|
256 |
-
|
257 |
add_shortcode ('adinserter', 'process_shortcodes');
|
258 |
}
|
259 |
|
260 |
function ai_admin_menu_hook () {
|
261 |
global $ai_settings_page;
|
262 |
|
263 |
-
// $ai_settings_page = add_submenu_page ('options-general.php', 'Ad Inserter Options', 'Ad Inserter', 8, basename(__FILE__), 'ai_settings');
|
264 |
$ai_settings_page = add_submenu_page ('options-general.php', 'Ad Inserter Options', 'Ad Inserter', 'manage_options', basename(__FILE__), 'ai_settings');
|
265 |
add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
|
266 |
}
|
@@ -680,21 +689,6 @@ function filter_option_hf ($option, $value){
|
|
680 |
return $value;
|
681 |
}
|
682 |
|
683 |
-
/*
|
684 |
-
function ai_block_counter_check (&$obj) {
|
685 |
-
global $ad_interter_globals;
|
686 |
-
|
687 |
-
$global_name = 'BLOCK_' . $obj->number . '_COUNTER';
|
688 |
-
$max_insertions = $obj->get_maximum_insertions ();
|
689 |
-
if (!isset ($ad_interter_globals [$global_name])) {
|
690 |
-
$ad_interter_globals [$global_name] = 0;
|
691 |
-
}
|
692 |
-
if ($max_insertions != 0 && $ad_interter_globals [$global_name] >= $max_insertions) return false;
|
693 |
-
$ad_interter_globals [$global_name] ++;
|
694 |
-
return true;
|
695 |
-
}
|
696 |
-
*/
|
697 |
-
|
698 |
function ai_settings () {
|
699 |
global $ai_db_options, $block_object;
|
700 |
|
@@ -862,7 +856,7 @@ function adinserter ($ad_number = ""){
|
|
862 |
|
863 |
$display_for_devices = $obj->get_display_for_devices ();
|
864 |
|
865 |
-
if ($obj->get_detection_server_side ()) {
|
866 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
|
867 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
|
868 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
|
@@ -926,7 +920,7 @@ function adinserter ($ad_number = ""){
|
|
926 |
$block_class_name = get_block_class_name ();
|
927 |
|
928 |
$device_class = "";
|
929 |
-
if ($obj->get_detection_client_side ()) {
|
930 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
931 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
932 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -964,7 +958,7 @@ function ai_content_hook ($content = ''){
|
|
964 |
|
965 |
$display_for_devices = $obj->get_display_for_devices ();
|
966 |
|
967 |
-
if ($obj->get_detection_server_side ()) {
|
968 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
969 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
970 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
@@ -1032,9 +1026,6 @@ function ai_content_hook ($content = ''){
|
|
1032 |
}
|
1033 |
}
|
1034 |
|
1035 |
-
// Clean remaining deprecated tags
|
1036 |
-
// $content = preg_replace ("/{adinserter (.*)}/", "", $content);
|
1037 |
-
|
1038 |
return $content;
|
1039 |
}
|
1040 |
|
@@ -1061,7 +1052,7 @@ function ai_excerpt_hook ($content = ''){
|
|
1061 |
|
1062 |
$display_for_devices = $obj->get_display_for_devices ();
|
1063 |
|
1064 |
-
if ($obj->get_detection_server_side ()) {
|
1065 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
1066 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
1067 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
@@ -1112,7 +1103,7 @@ function ai_excerpt_hook ($content = ''){
|
|
1112 |
$block_class_name = get_block_class_name ();
|
1113 |
|
1114 |
$device_class = "";
|
1115 |
-
if ($obj->get_detection_client_side ()) {
|
1116 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1117 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1118 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -1158,7 +1149,7 @@ function ai_loop_start_hook ($query){
|
|
1158 |
|
1159 |
$display_for_devices = $obj->get_display_for_devices ();
|
1160 |
|
1161 |
-
if ($obj->get_detection_server_side ()) {
|
1162 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
1163 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
1164 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
@@ -1220,7 +1211,7 @@ function ai_loop_start_hook ($query){
|
|
1220 |
$block_class_name = get_block_class_name ();
|
1221 |
|
1222 |
$device_class = "";
|
1223 |
-
if ($obj->get_detection_client_side ()) {
|
1224 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1225 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1226 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -1236,218 +1227,6 @@ function ai_loop_start_hook ($query){
|
|
1236 |
echo $ad_code;
|
1237 |
}
|
1238 |
|
1239 |
-
/*
|
1240 |
-
function ai_isCategoryAllowed ($categories, $cat_type) {
|
1241 |
-
|
1242 |
-
$categories = trim (strtolower ($categories));
|
1243 |
-
|
1244 |
-
// echo ' listed categories: ' . $categories, "<br />\n";
|
1245 |
-
|
1246 |
-
if ($cat_type == AD_BLACK_LIST) {
|
1247 |
-
|
1248 |
-
if($categories == AD_EMPTY_DATA) {
|
1249 |
-
return true;
|
1250 |
-
}
|
1251 |
-
|
1252 |
-
$cats_listed = explode (",", $categories);
|
1253 |
-
|
1254 |
-
foreach((get_the_category()) as $post_category) {
|
1255 |
-
|
1256 |
-
//echo '<br/> post category name : ' . $post_category->cat_name;
|
1257 |
-
|
1258 |
-
foreach($cats_listed as $cat_disabled){
|
1259 |
-
|
1260 |
-
$cat_disabled = trim ($cat_disabled);
|
1261 |
-
|
1262 |
-
$post_category_name = strtolower ($post_category->cat_name);
|
1263 |
-
$post_category_slug = strtolower ($post_category->slug);
|
1264 |
-
|
1265 |
-
//echo '<br/>Category disabled loop : ' . $cat_disabled . '<br/> category name : ' . $post_category_name;
|
1266 |
-
|
1267 |
-
if ($post_category_name == $cat_disabled || $post_category_slug == $cat_disabled) {
|
1268 |
-
//echo ' match';
|
1269 |
-
return false;
|
1270 |
-
}else{
|
1271 |
-
//echo ' not match';
|
1272 |
-
}
|
1273 |
-
}
|
1274 |
-
}
|
1275 |
-
return true;
|
1276 |
-
|
1277 |
-
} else {
|
1278 |
-
|
1279 |
-
if ($categories == AD_EMPTY_DATA){
|
1280 |
-
return false;
|
1281 |
-
}
|
1282 |
-
|
1283 |
-
$cats_listed = explode (",", $categories);
|
1284 |
-
|
1285 |
-
foreach((get_the_category()) as $post_category) {
|
1286 |
-
|
1287 |
-
//echo '<br/> post category name : ' . $post_category->cat_name;
|
1288 |
-
|
1289 |
-
foreach($cats_listed as $cat_enabled){
|
1290 |
-
|
1291 |
-
$cat_enabled = trim ($cat_enabled);
|
1292 |
-
|
1293 |
-
$post_category_name = strtolower ($post_category->cat_name);
|
1294 |
-
$post_category_slug = strtolower ($post_category->slug);
|
1295 |
-
|
1296 |
-
// echo '<br/>Category enabled loop : ' . $cat_enabled . '<br/> category name : ' . $post_category_name . '<br/> category slug: ' . $post_category_slug;
|
1297 |
-
|
1298 |
-
if ($post_category_name == $cat_enabled || $post_category_slug == $cat_enabled) {
|
1299 |
-
// echo '#match';
|
1300 |
-
return true;
|
1301 |
-
}else{
|
1302 |
-
// echo '#no match';
|
1303 |
-
}
|
1304 |
-
}
|
1305 |
-
}
|
1306 |
-
return false;
|
1307 |
-
}
|
1308 |
-
}
|
1309 |
-
|
1310 |
-
function ai_isTagAllowed ($tags, $tag_type){
|
1311 |
-
|
1312 |
-
$tags = trim (strtolower ($tags));
|
1313 |
-
$tags_listed = explode (",", $tags);
|
1314 |
-
foreach ($tags_listed as $index => $tag_listed) {
|
1315 |
-
$tags_listed [$index] = trim ($tag_listed);
|
1316 |
-
}
|
1317 |
-
$has_any_of_the_given_tags = has_tag ($tags_listed);
|
1318 |
-
|
1319 |
-
// echo ' listed tags: ' . $tags, "\n";
|
1320 |
-
|
1321 |
-
if ($tag_type == AD_BLACK_LIST) {
|
1322 |
-
|
1323 |
-
if ($tags == AD_EMPTY_DATA) {
|
1324 |
-
return true;
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
if (is_tag()) {
|
1328 |
-
foreach ($tags_listed as $tag_listed) {
|
1329 |
-
if (is_tag ($tag_listed)) return false;
|
1330 |
-
}
|
1331 |
-
return true;
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
return !$has_any_of_the_given_tags;
|
1335 |
-
|
1336 |
-
} else {
|
1337 |
-
|
1338 |
-
if ($tags == AD_EMPTY_DATA){
|
1339 |
-
return false;
|
1340 |
-
}
|
1341 |
-
|
1342 |
-
if (is_tag()) {
|
1343 |
-
foreach ($tags_listed as $tag_listed) {
|
1344 |
-
if (is_tag ($tag_listed)) return true;
|
1345 |
-
}
|
1346 |
-
return false;
|
1347 |
-
}
|
1348 |
-
|
1349 |
-
return $has_any_of_the_given_tags;
|
1350 |
-
}
|
1351 |
-
}
|
1352 |
-
|
1353 |
-
function ai_isUrlAllowed ($urls, $url_type){
|
1354 |
-
|
1355 |
-
$page_url = $_SERVER ['REQUEST_URI'];
|
1356 |
-
|
1357 |
-
$urls = trim ($urls);
|
1358 |
-
$urls_listed = explode (" ", $urls);
|
1359 |
-
foreach ($urls_listed as $index => $url_listed) {
|
1360 |
-
if ($url_listed == "") unset ($urls_listed [$index]); else
|
1361 |
-
$urls_listed [$index] = trim ($url_listed);
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
// print_r ($urls_listed);
|
1365 |
-
// echo "<br />\n";
|
1366 |
-
// echo ' page url: ' . $page_url, "<br />\n";
|
1367 |
-
// echo ' listed urls: ' . $urls, "\n";
|
1368 |
-
// echo "<br />\n";
|
1369 |
-
|
1370 |
-
if ($url_type == AD_BLACK_LIST) $return = false; else $return = true;
|
1371 |
-
|
1372 |
-
if ($urls == AD_EMPTY_DATA) {
|
1373 |
-
return !$return;
|
1374 |
-
}
|
1375 |
-
|
1376 |
-
foreach ($urls_listed as $url_listed) {
|
1377 |
-
if ($url_listed [0] == '') continue;
|
1378 |
-
if ($url_listed == '*') return $return;
|
1379 |
-
|
1380 |
-
if ($url_listed [0] == '*') {
|
1381 |
-
if ($url_listed [strlen ($url_listed) - 1] == '*') {
|
1382 |
-
$url_listed = substr ($url_listed, 1, strlen ($url_listed) - 2);
|
1383 |
-
if (strpos ($page_url, $url_listed) !== false) return $return;
|
1384 |
-
} else {
|
1385 |
-
$url_listed = substr ($url_listed, 1);
|
1386 |
-
if (substr ($page_url, - strlen ($url_listed)) == $url_listed) return $return;
|
1387 |
-
}
|
1388 |
-
}
|
1389 |
-
elseif ($url_listed [strlen ($url_listed) - 1] == '*') {
|
1390 |
-
$url_listed = substr ($url_listed, 0, strlen ($url_listed) - 1);
|
1391 |
-
if (strpos ($page_url, $url_listed) === 0) return $return;
|
1392 |
-
}
|
1393 |
-
else if ($url_listed == $page_url) return $return;
|
1394 |
-
}
|
1395 |
-
return !$return;
|
1396 |
-
}
|
1397 |
-
|
1398 |
-
function ai_isDisplayDisabled ($obj, $content){
|
1399 |
-
|
1400 |
-
$ad_name = $obj->get_ad_name();
|
1401 |
-
|
1402 |
-
if (preg_match ("/<!-- +Ad +Inserter +Ad +".($obj->number)." +Disabled +-->/i", $content)) return true;
|
1403 |
-
|
1404 |
-
if (preg_match ("/<!-- +disable +adinserter +\* +-->/i", $content)) return true;
|
1405 |
-
|
1406 |
-
if (preg_match ("/<!-- +disable +adinserter +".($obj->number)." +-->/i", $content)) return true;
|
1407 |
-
|
1408 |
-
// if (preg_match ("/<!-- +disable +adinserter +".(trim ($obj->get_ad_name()))." +-->/i", $content)) return true;
|
1409 |
-
if (strpos ($content, "<!-- disable adinserter " . $ad_name . " -->") != false) return true;
|
1410 |
-
|
1411 |
-
return false;
|
1412 |
-
}
|
1413 |
-
|
1414 |
-
function ai_isDisplayDateAllowed ($obj, $publish_date){
|
1415 |
-
|
1416 |
-
$after_days = trim ($obj->get_ad_after_day());
|
1417 |
-
|
1418 |
-
// If 0 display immediately
|
1419 |
-
if($after_days == AD_ZERO || $after_days == AD_EMPTY_DATA){
|
1420 |
-
return true;
|
1421 |
-
}
|
1422 |
-
|
1423 |
-
return (date ('U', time ()) >= $publish_date + $after_days * 86400);
|
1424 |
-
}
|
1425 |
-
|
1426 |
-
function ai_isRefererAllowed ($obj) {
|
1427 |
-
|
1428 |
-
$domain_list_type = $obj->get_ad_domain_list_type ();
|
1429 |
-
|
1430 |
-
if (isset ($_SERVER['HTTP_REFERER'])) {
|
1431 |
-
$http_referer = $_SERVER['HTTP_REFERER'];
|
1432 |
-
} else $http_referer = '';
|
1433 |
-
|
1434 |
-
if ($domain_list_type == AD_BLACK_LIST) $return = false; else $return = true;
|
1435 |
-
|
1436 |
-
$domains = trim ($obj->get_ad_domain_list ());
|
1437 |
-
if ($domains == "") return !$return;
|
1438 |
-
$domains = explode (",", $domains);
|
1439 |
-
|
1440 |
-
foreach ($domains as $domain) {
|
1441 |
-
$domain = trim ($domain);
|
1442 |
-
if ($domain == "") continue;
|
1443 |
-
|
1444 |
-
if ($domain == "#") {
|
1445 |
-
if ($http_referer == "") return $return;
|
1446 |
-
} elseif (preg_match ("/" . $domain . "/i", $http_referer)) return $return;
|
1447 |
-
}
|
1448 |
-
return !$return;
|
1449 |
-
}
|
1450 |
-
*/
|
1451 |
|
1452 |
function ai_getCode ($obj){
|
1453 |
$code = $obj->get_ad_data();
|
@@ -1477,293 +1256,9 @@ function ai_getAdCode ($obj){
|
|
1477 |
$ad_code = $ads [rand (0, sizeof ($ads) - 1)];
|
1478 |
}
|
1479 |
|
1480 |
-
// No shortcode processing if recursion is detected
|
1481 |
-
// if (preg_match ("/\[adinserter block=\"".$obj->number."\"[^\]]*\]/", $ad_code, $adinserter_shortcodes)) return $ad_code;
|
1482 |
-
// if (preg_match ("/\[adinserter name=\"".$obj->get_ad_name()."\"[^\]]*\]/", $ad_code, $adinserter_shortcodes)) return $ad_code;
|
1483 |
-
|
1484 |
return do_shortcode ($ad_code);
|
1485 |
}
|
1486 |
|
1487 |
-
/*
|
1488 |
-
|
1489 |
-
function ai_generateBeforeParagraph ($block, $content, $obj){
|
1490 |
-
|
1491 |
-
$paragraph_positions = array ();
|
1492 |
-
$last_position = - 1;
|
1493 |
-
|
1494 |
-
$paragraph_start = "<p";
|
1495 |
-
|
1496 |
-
while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
|
1497 |
-
$last_position = stripos ($content, $paragraph_start, $last_position + 1);
|
1498 |
-
if ($content [$last_position + 2] == ">" || $content [$last_position + 2] == " ")
|
1499 |
-
$paragraph_positions [] = $last_position;
|
1500 |
-
}
|
1501 |
-
|
1502 |
-
$paragraph_min_words = $obj->get_minimum_paragraph_words();
|
1503 |
-
if ($paragraph_min_words != 0) {
|
1504 |
-
$filtered_paragraph_positions = array ();
|
1505 |
-
foreach ($paragraph_positions as $index => $paragraph_position) {
|
1506 |
-
$paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
|
1507 |
-
$number_of_words = sizeof (explode (" ", strip_tags ($paragraph_code)));
|
1508 |
-
if ($number_of_words >= $paragraph_min_words) $filtered_paragraph_positions [] = $paragraph_position;
|
1509 |
-
}
|
1510 |
-
$paragraph_positions = $filtered_paragraph_positions;
|
1511 |
-
}
|
1512 |
-
|
1513 |
-
$paragraph_texts = explode (",", html_entity_decode ($obj->get_paragraph_text()));
|
1514 |
-
if ($obj->get_paragraph_text() != "" && count ($paragraph_texts != 0)) {
|
1515 |
-
|
1516 |
-
$filtered_paragraph_positions = array ();
|
1517 |
-
$paragraph_text_type = $obj->get_paragraph_text_type ();
|
1518 |
-
|
1519 |
-
foreach ($paragraph_positions as $index => $paragraph_position) {
|
1520 |
-
$paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
|
1521 |
-
|
1522 |
-
if ($paragraph_text_type == AD_CONTAIN) {
|
1523 |
-
$found = true;
|
1524 |
-
foreach ($paragraph_texts as $paragraph_text) {
|
1525 |
-
if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
|
1526 |
-
$found = false;
|
1527 |
-
break;
|
1528 |
-
}
|
1529 |
-
}
|
1530 |
-
if ($found) $filtered_paragraph_positions [] = $paragraph_position;
|
1531 |
-
} elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
|
1532 |
-
$found = false;
|
1533 |
-
foreach ($paragraph_texts as $paragraph_text) {
|
1534 |
-
if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
|
1535 |
-
$found = true;
|
1536 |
-
break;
|
1537 |
-
}
|
1538 |
-
}
|
1539 |
-
if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
|
1540 |
-
}
|
1541 |
-
}
|
1542 |
-
|
1543 |
-
$paragraph_positions = $filtered_paragraph_positions;
|
1544 |
-
}
|
1545 |
-
|
1546 |
-
// Nothing to do
|
1547 |
-
if (sizeof ($paragraph_positions) == 0) return $content;
|
1548 |
-
|
1549 |
-
$position = $obj->get_paragraph_number();
|
1550 |
-
|
1551 |
-
if ($position > 0 && $position < 1) {
|
1552 |
-
$position = intval ($position * (sizeof ($paragraph_positions) - 1) + 0.5);
|
1553 |
-
}
|
1554 |
-
elseif ($position <= 0) {
|
1555 |
-
$position = rand (0, sizeof ($paragraph_positions) - 1);
|
1556 |
-
} else $position --;
|
1557 |
-
|
1558 |
-
if ($obj->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
|
1559 |
-
$paragraph_positions = array_reverse ($paragraph_positions);
|
1560 |
-
}
|
1561 |
-
|
1562 |
-
$text = str_replace (array ("\n", " "), " ", $content);
|
1563 |
-
$text = strip_tags ($text);
|
1564 |
-
$number_of_words = sizeof (explode (" ", $text));
|
1565 |
-
|
1566 |
-
if (sizeof ($paragraph_positions) > $position && sizeof ($paragraph_positions) >= $obj->get_paragraph_number_minimum() && $number_of_words >= $obj->get_minimum_words()) {
|
1567 |
-
$content_position = $paragraph_positions [$position];
|
1568 |
-
|
1569 |
-
$block_class_name = get_block_class_name ();
|
1570 |
-
|
1571 |
-
$display_for_devices = $obj->get_display_for_devices ();
|
1572 |
-
|
1573 |
-
$device_class = "";
|
1574 |
-
if ($obj->get_detection_client_side ()) {
|
1575 |
-
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1576 |
-
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1577 |
-
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1578 |
-
elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
|
1579 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
|
1580 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
|
1581 |
-
}
|
1582 |
-
|
1583 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($obj), $content_position, 0); else
|
1584 |
-
$content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>", $content_position, 0);
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
return $content;
|
1588 |
-
}
|
1589 |
-
|
1590 |
-
function ai_generateAfterParagraph ($block, $content, $obj){
|
1591 |
-
|
1592 |
-
$paragraph_positions = array ();
|
1593 |
-
$last_position = - 1;
|
1594 |
-
|
1595 |
-
$paragraph_end = "</p>";
|
1596 |
-
|
1597 |
-
while (stripos ($content, $paragraph_end, $last_position + 1) !== false){
|
1598 |
-
$last_position = stripos ($content, $paragraph_end, $last_position + 1) + 3;
|
1599 |
-
$paragraph_positions [] = $last_position;
|
1600 |
-
}
|
1601 |
-
|
1602 |
-
$paragraph_min_words = $obj->get_minimum_paragraph_words();
|
1603 |
-
if ($paragraph_min_words != 0) {
|
1604 |
-
$filtered_paragraph_positions = array ();
|
1605 |
-
foreach ($paragraph_positions as $index => $paragraph_position) {
|
1606 |
-
$paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
|
1607 |
-
$number_of_words = sizeof (explode (" ", strip_tags ($paragraph_code)));
|
1608 |
-
if ($number_of_words >= $paragraph_min_words) $filtered_paragraph_positions [] = $paragraph_position;
|
1609 |
-
}
|
1610 |
-
$paragraph_positions = $filtered_paragraph_positions;
|
1611 |
-
}
|
1612 |
-
|
1613 |
-
$paragraph_texts = explode (",", html_entity_decode ($obj->get_paragraph_text()));
|
1614 |
-
if ($obj->get_paragraph_text() != "" && count ($paragraph_texts != 0)) {
|
1615 |
-
|
1616 |
-
$filtered_paragraph_positions = array ();
|
1617 |
-
$paragraph_text_type = $obj->get_paragraph_text_type ();
|
1618 |
-
|
1619 |
-
foreach ($paragraph_positions as $index => $paragraph_position) {
|
1620 |
-
$paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
|
1621 |
-
|
1622 |
-
if ($paragraph_text_type == AD_CONTAIN) {
|
1623 |
-
$found = true;
|
1624 |
-
foreach ($paragraph_texts as $paragraph_text) {
|
1625 |
-
if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
|
1626 |
-
$found = false;
|
1627 |
-
break;
|
1628 |
-
}
|
1629 |
-
}
|
1630 |
-
if ($found) $filtered_paragraph_positions [] = $paragraph_position;
|
1631 |
-
} elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
|
1632 |
-
$found = false;
|
1633 |
-
foreach ($paragraph_texts as $paragraph_text) {
|
1634 |
-
if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
|
1635 |
-
$found = true;
|
1636 |
-
break;
|
1637 |
-
}
|
1638 |
-
}
|
1639 |
-
if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
|
1640 |
-
}
|
1641 |
-
}
|
1642 |
-
|
1643 |
-
$paragraph_positions = $filtered_paragraph_positions;
|
1644 |
-
}
|
1645 |
-
|
1646 |
-
// Nothing to do
|
1647 |
-
if (sizeof ($paragraph_positions) == 0) return $content;
|
1648 |
-
|
1649 |
-
$position = $obj->get_paragraph_number();
|
1650 |
-
|
1651 |
-
if ($position > 0 && $position < 1) {
|
1652 |
-
$position = intval ($position * (sizeof ($paragraph_positions) - 1) + 0.5);
|
1653 |
-
}
|
1654 |
-
elseif ($position <= 0) {
|
1655 |
-
$position = rand (0, sizeof ($paragraph_positions) - 1);
|
1656 |
-
} else $position --;
|
1657 |
-
|
1658 |
-
if ($obj->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
|
1659 |
-
$paragraph_positions = array_reverse ($paragraph_positions);
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
$text = str_replace (array ("\n", " "), " ", $content);
|
1663 |
-
$text = strip_tags ($text);
|
1664 |
-
$number_of_words = sizeof (explode (" ", $text));
|
1665 |
-
|
1666 |
-
if (sizeof ($paragraph_positions) > $position && sizeof ($paragraph_positions) >= $obj->get_paragraph_number_minimum() && $number_of_words >= $obj->get_minimum_words()) {
|
1667 |
-
$content_position = $paragraph_positions [$position];
|
1668 |
-
|
1669 |
-
$block_class_name = get_block_class_name ();
|
1670 |
-
|
1671 |
-
$display_for_devices = $obj->get_display_for_devices ();
|
1672 |
-
|
1673 |
-
$device_class = "";
|
1674 |
-
if ($obj->get_detection_client_side ()) {
|
1675 |
-
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1676 |
-
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1677 |
-
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1678 |
-
elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
|
1679 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
|
1680 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
|
1681 |
-
}
|
1682 |
-
|
1683 |
-
if ($content_position >= strlen ($content) - 1) {
|
1684 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = $content = $content . ai_getAdCode ($obj); else
|
1685 |
-
$content = $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
|
1686 |
-
} else {
|
1687 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($obj), $content_position + 1, 0); else
|
1688 |
-
$content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>", $content_position + 1, 0);
|
1689 |
-
}
|
1690 |
-
}
|
1691 |
-
|
1692 |
-
return $content;
|
1693 |
-
}
|
1694 |
-
|
1695 |
-
function ai_generateDivBefore ($block, $content, $obj){
|
1696 |
-
$block_class_name = get_block_class_name ();
|
1697 |
-
|
1698 |
-
$display_for_devices = $obj->get_display_for_devices ();
|
1699 |
-
|
1700 |
-
$device_class = "";
|
1701 |
-
if ($obj->get_detection_client_side ()) {
|
1702 |
-
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1703 |
-
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1704 |
-
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1705 |
-
elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
|
1706 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
|
1707 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
|
1708 |
-
}
|
1709 |
-
|
1710 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return ai_getAdCode ($obj) . $content; else
|
1711 |
-
return "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>" . $content;
|
1712 |
-
}
|
1713 |
-
|
1714 |
-
function ai_generateDivAfter ($block, $content, $obj){
|
1715 |
-
$block_class_name = get_block_class_name ();
|
1716 |
-
|
1717 |
-
$display_for_devices = $obj->get_display_for_devices ();
|
1718 |
-
|
1719 |
-
$device_class = "";
|
1720 |
-
if ($obj->get_detection_client_side ()) {
|
1721 |
-
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1722 |
-
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1723 |
-
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1724 |
-
elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
|
1725 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
|
1726 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
|
1727 |
-
}
|
1728 |
-
|
1729 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return $content . ai_getAdCode ($obj); else
|
1730 |
-
return $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
|
1731 |
-
}
|
1732 |
-
|
1733 |
-
function ai_generateDivManual ($block, $content, $obj, $ad_number){
|
1734 |
-
|
1735 |
-
if (preg_match_all("/{adinserter (.+?)}/", $content, $tags)){
|
1736 |
-
|
1737 |
-
$block_class_name = get_block_class_name ();
|
1738 |
-
|
1739 |
-
$display_for_devices = $obj->get_display_for_devices ();
|
1740 |
-
|
1741 |
-
$device_class = "";
|
1742 |
-
if ($obj->get_detection_client_side ()) {
|
1743 |
-
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1744 |
-
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1745 |
-
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1746 |
-
elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
|
1747 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
|
1748 |
-
elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
|
1749 |
-
}
|
1750 |
-
|
1751 |
-
foreach ($tags [1] as $tag) {
|
1752 |
-
$ad_tag = strtolower (trim ($tag));
|
1753 |
-
$ad_name = strtolower (trim ($obj->get_ad_name()));
|
1754 |
-
if ($ad_tag == $ad_name || $ad_tag == $ad_number) {
|
1755 |
-
if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
|
1756 |
-
$ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
|
1757 |
-
$content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content);
|
1758 |
-
}
|
1759 |
-
}
|
1760 |
-
}
|
1761 |
-
|
1762 |
-
return $content;
|
1763 |
-
}
|
1764 |
-
|
1765 |
-
*/
|
1766 |
-
|
1767 |
|
1768 |
function process_shortcodes ($atts) {
|
1769 |
global $block_object;
|
@@ -1798,7 +1293,7 @@ function process_shortcodes ($atts) {
|
|
1798 |
|
1799 |
$display_for_devices = $obj->get_display_for_devices ();
|
1800 |
|
1801 |
-
if ($obj->get_detection_server_side ()) {
|
1802 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
|
1803 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
|
1804 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
|
@@ -1813,10 +1308,18 @@ function process_shortcodes ($atts) {
|
|
1813 |
if (!$obj->check_date ()) return "";
|
1814 |
}
|
1815 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1816 |
$block_class_name = get_block_class_name ();
|
1817 |
|
1818 |
$device_class = "";
|
1819 |
-
if ($obj->get_detection_client_side ()) {
|
1820 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1821 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1822 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -1839,7 +1342,7 @@ class ai_widget extends WP_Widget {
|
|
1839 |
function __construct () {
|
1840 |
parent::__construct (
|
1841 |
false, // Base ID
|
1842 |
-
'Ad Inserter',
|
1843 |
array ( // Args
|
1844 |
'classname' => 'ai_widget',
|
1845 |
'description' => 'Ad Inserter code block widget.')
|
@@ -1906,85 +1409,6 @@ class ai_widget extends WP_Widget {
|
|
1906 |
}
|
1907 |
|
1908 |
|
1909 |
-
// OLD WIDGETS - DEPRECATED
|
1910 |
-
|
1911 |
-
//function ai_widget ($args, $parameters) {
|
1912 |
-
// global $block_object;
|
1913 |
-
|
1914 |
-
// $block = $parameters ['block'];
|
1915 |
-
// $ad = $block_object [$block];
|
1916 |
-
// ai_widget_draw ($block, $ad, $args);
|
1917 |
-
//}
|
1918 |
-
|
1919 |
-
|
1920 |
-
// Fix because widgets that share callback functions don't get displayed
|
1921 |
-
|
1922 |
-
function ai_widget1 ($args, $parameters) {
|
1923 |
-
ai_widget ($args, $parameters);
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
function ai_widget2 ($args, $parameters) {
|
1927 |
-
ai_widget ($args, $parameters);
|
1928 |
-
}
|
1929 |
-
|
1930 |
-
function ai_widget3 ($args, $parameters) {
|
1931 |
-
ai_widget ($args, $parameters);
|
1932 |
-
}
|
1933 |
-
|
1934 |
-
function ai_widget4 ($args, $parameters) {
|
1935 |
-
ai_widget ($args, $parameters);
|
1936 |
-
}
|
1937 |
-
|
1938 |
-
function ai_widget5 ($args, $parameters) {
|
1939 |
-
ai_widget ($args, $parameters);
|
1940 |
-
}
|
1941 |
-
|
1942 |
-
function ai_widget6 ($args, $parameters) {
|
1943 |
-
ai_widget ($args, $parameters);
|
1944 |
-
}
|
1945 |
-
|
1946 |
-
function ai_widget7 ($args, $parameters) {
|
1947 |
-
ai_widget ($args, $parameters);
|
1948 |
-
}
|
1949 |
-
|
1950 |
-
function ai_widget8 ($args, $parameters) {
|
1951 |
-
ai_widget ($args, $parameters);
|
1952 |
-
}
|
1953 |
-
|
1954 |
-
function ai_widget9 ($args, $parameters) {
|
1955 |
-
ai_widget ($args, $parameters);
|
1956 |
-
}
|
1957 |
-
|
1958 |
-
function ai_widget10 ($args, $parameters) {
|
1959 |
-
ai_widget ($args, $parameters);
|
1960 |
-
}
|
1961 |
-
|
1962 |
-
function ai_widget11 ($args, $parameters) {
|
1963 |
-
ai_widget ($args, $parameters);
|
1964 |
-
}
|
1965 |
-
|
1966 |
-
function ai_widget12 ($args, $parameters) {
|
1967 |
-
ai_widget ($args, $parameters);
|
1968 |
-
}
|
1969 |
-
|
1970 |
-
function ai_widget13 ($args, $parameters) {
|
1971 |
-
ai_widget ($args, $parameters);
|
1972 |
-
}
|
1973 |
-
|
1974 |
-
function ai_widget14 ($args, $parameters) {
|
1975 |
-
ai_widget ($args, $parameters);
|
1976 |
-
}
|
1977 |
-
|
1978 |
-
function ai_widget15 ($args, $parameters) {
|
1979 |
-
ai_widget ($args, $parameters);
|
1980 |
-
}
|
1981 |
-
|
1982 |
-
function ai_widget16 ($args, $parameters) {
|
1983 |
-
ai_widget ($args, $parameters);
|
1984 |
-
}
|
1985 |
-
// OLD WIDGETS END
|
1986 |
-
|
1987 |
-
|
1988 |
function ai_widget_draw ($block, $obj, $args, $title = '') {
|
1989 |
|
1990 |
$display_for_users = $obj->get_display_for_users ();
|
@@ -1994,7 +1418,7 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
|
|
1994 |
|
1995 |
$display_for_devices = $obj->get_display_for_devices ();
|
1996 |
|
1997 |
-
if ($obj->get_detection_server_side ()) {
|
1998 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
|
1999 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
|
2000 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
|
@@ -2064,7 +1488,7 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
|
|
2064 |
$block_class_name = get_block_class_name ();
|
2065 |
|
2066 |
$device_class = "";
|
2067 |
-
if ($obj->get_detection_client_side ()) {
|
2068 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = "ai-desktop";
|
2069 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = "ai-tablet-phone";
|
2070 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = "ai-tablet";
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Ad Inserter
|
4 |
+
Version: 1.6.4
|
5 |
Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
|
6 |
Author: Spacetime
|
7 |
Author URI: http://igorfuna.com/
|
11 |
/*
|
12 |
Change Log
|
13 |
|
14 |
+
Ad Inserter 1.6.4 - 15 May 2016
|
15 |
+
- Fixed bug: For shortcodes in posts the url was not checked
|
16 |
+
- Optimizations for device detection
|
17 |
+
|
18 |
Ad Inserter 1.6.3 - 6 April 2016
|
19 |
- Removed deprecated code (fixes PHP 7 deprecated warnings)
|
20 |
- Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
|
202 |
require_once AD_INSERTER_PLUGIN_DIR.'class.php';
|
203 |
require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
|
204 |
require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
|
|
|
205 |
|
206 |
$ad_interter_globals = array ();
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
// Load options
|
209 |
ai_load_options ();
|
210 |
|
211 |
+
$device_detection = false;
|
212 |
+
$client_side_detection = false;
|
213 |
+
|
214 |
$block_object = array ();
|
215 |
for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
|
216 |
$obj = new ai_Block ($counter);
|
217 |
$obj->load_options ($counter);
|
218 |
$block_object [$counter] = $obj;
|
219 |
+
|
220 |
+
if ($obj->get_display_for_devices() != AD_DISPLAY_ALL_DEVICES) {
|
221 |
+
$device_detection = true;
|
222 |
+
if ($obj->get_detection_client_side ()) $client_side_detection = true;
|
223 |
+
}
|
224 |
}
|
225 |
|
226 |
+
if ($device_detection) {
|
227 |
+
require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
|
228 |
+
|
229 |
+
$detect = new ai_Mobile_Detect;
|
230 |
+
|
231 |
+
define ('AI_MOBILE', $detect->isMobile ());
|
232 |
+
define ('AI_TABLET', $detect->isTablet ());
|
233 |
+
define ('AI_PHONE', AI_MOBILE && !AI_TABLET);
|
234 |
+
define ('AI_DESKTOP', !AI_MOBILE);
|
235 |
+
} else {
|
236 |
+
define ('AI_MOBILE', true);
|
237 |
+
define ('AI_TABLET', true);
|
238 |
+
define ('AI_PHONE', true);
|
239 |
+
define ('AI_DESKTOP', true);
|
240 |
+
}
|
241 |
+
|
242 |
$plugin_priority = get_plugin_priority ();
|
243 |
|
244 |
// Set hooks
|
247 |
add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
|
248 |
add_action ('loop_start', 'ai_loop_start_hook');
|
249 |
add_action ('init', 'ai_init_hook');
|
250 |
+
//add_action ('admin_notices', 'ai_admin_notice_hook');
|
251 |
add_action ('wp_head', 'ai_wp_head_hook');
|
252 |
add_action ('wp_footer', 'ai_wp_footer_hook');
|
253 |
add_action ('widgets_init', 'ai_widgets_init_hook');
|
254 |
add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
|
255 |
add_action ('save_post', 'ai_save_meta_box_data_hook');
|
256 |
+
|
257 |
+
if ($client_side_detection) {
|
258 |
+
add_action ('wp_enqueue_scripts', 'ai_enqueue_scripts_hook');
|
259 |
+
}
|
260 |
|
261 |
add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
|
262 |
|
264 |
function ai_init_hook() {
|
265 |
global $block_object;
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
add_shortcode ('adinserter', 'process_shortcodes');
|
268 |
}
|
269 |
|
270 |
function ai_admin_menu_hook () {
|
271 |
global $ai_settings_page;
|
272 |
|
|
|
273 |
$ai_settings_page = add_submenu_page ('options-general.php', 'Ad Inserter Options', 'Ad Inserter', 'manage_options', basename(__FILE__), 'ai_settings');
|
274 |
add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
|
275 |
}
|
689 |
return $value;
|
690 |
}
|
691 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
692 |
function ai_settings () {
|
693 |
global $ai_db_options, $block_object;
|
694 |
|
856 |
|
857 |
$display_for_devices = $obj->get_display_for_devices ();
|
858 |
|
859 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
860 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
|
861 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
|
862 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
|
920 |
$block_class_name = get_block_class_name ();
|
921 |
|
922 |
$device_class = "";
|
923 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
|
924 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
925 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
926 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
958 |
|
959 |
$display_for_devices = $obj->get_display_for_devices ();
|
960 |
|
961 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
962 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
963 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
964 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
1026 |
}
|
1027 |
}
|
1028 |
|
|
|
|
|
|
|
1029 |
return $content;
|
1030 |
}
|
1031 |
|
1052 |
|
1053 |
$display_for_devices = $obj->get_display_for_devices ();
|
1054 |
|
1055 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
1056 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
1057 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
1058 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
1103 |
$block_class_name = get_block_class_name ();
|
1104 |
|
1105 |
$device_class = "";
|
1106 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
|
1107 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1108 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1109 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1149 |
|
1150 |
$display_for_devices = $obj->get_display_for_devices ();
|
1151 |
|
1152 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
1153 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
|
1154 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
|
1155 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
|
1211 |
$block_class_name = get_block_class_name ();
|
1212 |
|
1213 |
$device_class = "";
|
1214 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
|
1215 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1216 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1217 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1227 |
echo $ad_code;
|
1228 |
}
|
1229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1230 |
|
1231 |
function ai_getCode ($obj){
|
1232 |
$code = $obj->get_ad_data();
|
1256 |
$ad_code = $ads [rand (0, sizeof ($ads) - 1)];
|
1257 |
}
|
1258 |
|
|
|
|
|
|
|
|
|
1259 |
return do_shortcode ($ad_code);
|
1260 |
}
|
1261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1262 |
|
1263 |
function process_shortcodes ($atts) {
|
1264 |
global $block_object;
|
1293 |
|
1294 |
$display_for_devices = $obj->get_display_for_devices ();
|
1295 |
|
1296 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
1297 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
|
1298 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
|
1299 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
|
1308 |
if (!$obj->check_date ()) return "";
|
1309 |
}
|
1310 |
|
1311 |
+
if (!$obj->check_url ()) return "";
|
1312 |
+
|
1313 |
+
if (!$obj->check_referer ()) return "";
|
1314 |
+
|
1315 |
+
if (!$obj->check_category ()) return "";
|
1316 |
+
|
1317 |
+
if (!$obj->check_tag ()) return "";
|
1318 |
+
|
1319 |
$block_class_name = get_block_class_name ();
|
1320 |
|
1321 |
$device_class = "";
|
1322 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
|
1323 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1324 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1325 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1342 |
function __construct () {
|
1343 |
parent::__construct (
|
1344 |
false, // Base ID
|
1345 |
+
'Ad Inserter', // Name
|
1346 |
array ( // Args
|
1347 |
'classname' => 'ai_widget',
|
1348 |
'description' => 'Ad Inserter code block widget.')
|
1409 |
}
|
1410 |
|
1411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1412 |
function ai_widget_draw ($block, $obj, $args, $title = '') {
|
1413 |
|
1414 |
$display_for_users = $obj->get_display_for_users ();
|
1418 |
|
1419 |
$display_for_devices = $obj->get_display_for_devices ();
|
1420 |
|
1421 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
|
1422 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
|
1423 |
if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
|
1424 |
if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
|
1488 |
$block_class_name = get_block_class_name ();
|
1489 |
|
1490 |
$device_class = "";
|
1491 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
|
1492 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = "ai-desktop";
|
1493 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = "ai-tablet-phone";
|
1494 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = "ai-tablet";
|
class.php
CHANGED
@@ -842,7 +842,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
842 |
$display_for_devices = $this->get_display_for_devices ();
|
843 |
|
844 |
$device_class = "";
|
845 |
-
if ($this->get_detection_client_side ()) {
|
846 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
847 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
848 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -958,7 +958,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
958 |
$display_for_devices = $this->get_display_for_devices ();
|
959 |
|
960 |
$device_class = "";
|
961 |
-
if ($this->get_detection_client_side ()) {
|
962 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
963 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
964 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -985,7 +985,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
985 |
$display_for_devices = $this->get_display_for_devices ();
|
986 |
|
987 |
$device_class = "";
|
988 |
-
if ($this->get_detection_client_side ()) {
|
989 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
990 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
991 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -1010,7 +1010,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1010 |
$display_for_devices = $this->get_display_for_devices ();
|
1011 |
|
1012 |
$device_class = "";
|
1013 |
-
if ($this->get_detection_client_side ()) {
|
1014 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1015 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1016 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
@@ -1039,7 +1039,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
|
|
1039 |
$display_for_devices = $this->get_display_for_devices ();
|
1040 |
|
1041 |
$device_class = "";
|
1042 |
-
if ($this->get_detection_client_side ()) {
|
1043 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1044 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1045 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
842 |
$display_for_devices = $this->get_display_for_devices ();
|
843 |
|
844 |
$device_class = "";
|
845 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
|
846 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
847 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
848 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
958 |
$display_for_devices = $this->get_display_for_devices ();
|
959 |
|
960 |
$device_class = "";
|
961 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
|
962 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
963 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
964 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
985 |
$display_for_devices = $this->get_display_for_devices ();
|
986 |
|
987 |
$device_class = "";
|
988 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
|
989 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
990 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
991 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1010 |
$display_for_devices = $this->get_display_for_devices ();
|
1011 |
|
1012 |
$device_class = "";
|
1013 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
|
1014 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1015 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1016 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
1039 |
$display_for_devices = $this->get_display_for_devices ();
|
1040 |
|
1041 |
$device_class = "";
|
1042 |
+
if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
|
1043 |
if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
|
1044 |
elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
|
1045 |
elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
|
constants.php
CHANGED
@@ -11,7 +11,7 @@ if (!defined( 'AD_INSERTER_TITLE'))
|
|
11 |
define ('AD_INSERTER_TITLE', 'Ad Inserter');
|
12 |
|
13 |
if (!defined( 'AD_INSERTER_VERSION'))
|
14 |
-
define ('AD_INSERTER_VERSION', '1.6.
|
15 |
|
16 |
if (!defined ('AD_INSERTER_BLOCKS'))
|
17 |
define ('AD_INSERTER_BLOCKS', 16);
|
11 |
define ('AD_INSERTER_TITLE', 'Ad Inserter');
|
12 |
|
13 |
if (!defined( 'AD_INSERTER_VERSION'))
|
14 |
+
define ('AD_INSERTER_VERSION', '1.6.4');
|
15 |
|
16 |
if (!defined ('AD_INSERTER_BLOCKS'))
|
17 |
define ('AD_INSERTER_BLOCKS', 16);
|
index.php
CHANGED
@@ -59,23 +59,23 @@
|
|
59 |
<h2 style="text-align: center;">Monitor Google AdSense and Amazon Associates earnings</h2>
|
60 |
<p style="text-align: justify;">
|
61 |
Tiny Monitor for
|
62 |
-
<a href="http://tinymonitor.com/adsense-monitor-documentation" target="_blank">AdSense</a>,
|
63 |
-
<a href="http://tinymonitor.com/amazon-monitor-documentation" target="_blank">Amazon</a> and
|
64 |
-
<a href="http://tinymonitor.com/paypal-monitor-documentation" target="_blank">PayPal</a> is a perfect solution to track your online earnings.
|
65 |
-
This is a small PHP script that can be installed on any <a href="http://tinymonitor.com/installing-web-server" target="_blank">home web server</a> or commercial web hosting.
|
66 |
If you already have some website (very likely as you are using Ad Inserter plugin) then you can simply put it into a folder.
|
67 |
</p>
|
68 |
<p style="text-align: justify;">
|
69 |
Tiny Monitor automatically downloads data from Google, Amazon or PayPal and presents it in a simple single-page form.
|
70 |
This way you can have all the data easily accessible without the need to log into many websites just to check today's earnings.
|
71 |
</p>
|
72 |
-
<a href="http://tinymonitor.com/" target="_blank"><img style="display: block;margin: 0 auto;" src="images/tinymonitor-logo.png" alt="Tiny Monitor"></a>
|
73 |
-
<a href="http://tinymonitor.com/" target="_blank"><img style="display: block;margin: 0 auto;" src="images/tiny-monitor.png" alt="Amazon Associates"></a>
|
74 |
<p style="text-align: justify;">
|
75 |
-
And if you have more than one domain then you can monitor them with <a href="http://tinymonitor.com/domain-monitor-documentation" target="_blank">Tiny Domain Monitor</a>.
|
76 |
This PHP script is a simple yet effective solution to track expiration dates of your own domains or any other domains you would like to register as soon as they expire.
|
77 |
</p>
|
78 |
-
<a href="http://tinymonitor.com/domainmonitor/" target="_blank"><img style="display: block;margin: 0 auto;" src="images/domain-monitor.png" alt="Domain Monitor Script"></a>
|
79 |
</div>
|
80 |
</div>
|
81 |
<body>
|
59 |
<h2 style="text-align: center;">Monitor Google AdSense and Amazon Associates earnings</h2>
|
60 |
<p style="text-align: justify;">
|
61 |
Tiny Monitor for
|
62 |
+
<a href="http://tinymonitor.com/adsense-monitor-documentation" target="_blank" rel="nofollow">AdSense</a>,
|
63 |
+
<a href="http://tinymonitor.com/amazon-monitor-documentation" target="_blank" rel="nofollow">Amazon</a> and
|
64 |
+
<a href="http://tinymonitor.com/paypal-monitor-documentation" target="_blank" rel="nofollow">PayPal</a> is a perfect solution to track your online earnings.
|
65 |
+
This is a small PHP script that can be installed on any <a href="http://tinymonitor.com/installing-web-server" target="_blank" rel="nofollow">home web server</a> or commercial web hosting.
|
66 |
If you already have some website (very likely as you are using Ad Inserter plugin) then you can simply put it into a folder.
|
67 |
</p>
|
68 |
<p style="text-align: justify;">
|
69 |
Tiny Monitor automatically downloads data from Google, Amazon or PayPal and presents it in a simple single-page form.
|
70 |
This way you can have all the data easily accessible without the need to log into many websites just to check today's earnings.
|
71 |
</p>
|
72 |
+
<a href="http://tinymonitor.com/" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="images/tinymonitor-logo.png" alt="Tiny Monitor"></a>
|
73 |
+
<a href="http://tinymonitor.com/" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="images/tiny-monitor.png" alt="Amazon Associates"></a>
|
74 |
<p style="text-align: justify;">
|
75 |
+
And if you have more than one domain then you can monitor them with <a href="http://tinymonitor.com/domain-monitor-documentation" target="_blank" rel="nofollow">Tiny Domain Monitor</a>.
|
76 |
This PHP script is a simple yet effective solution to track expiration dates of your own domains or any other domains you would like to register as soon as they expire.
|
77 |
</p>
|
78 |
+
<a href="http://tinymonitor.com/domainmonitor/" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="images/domain-monitor.png" alt="Domain Monitor Script"></a>
|
79 |
</div>
|
80 |
</div>
|
81 |
<body>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: spacetime
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
4 |
Tags: adsense, amazon, clickbank, ad, ads, html, javascript, php, code, widget, sidebar, responsive, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv3
|
9 |
|
10 |
Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
|
@@ -35,7 +35,7 @@ Paragraphs can be counted from top or from bottom. It is also possible to count
|
|
35 |
|
36 |
You can also define paragraph tags. Normally only `<p>` tags are used. If you post contains also `<div>` or header tags you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
|
37 |
**WARNING:** Each code block you insert on post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
|
38 |
-
**After Paragraph**
|
39 |
|
40 |
Additional Display Options:
|
41 |
|
@@ -427,6 +427,10 @@ AD CODE RIGHT
|
|
427 |
|
428 |
== Changelog ==
|
429 |
|
|
|
|
|
|
|
|
|
430 |
= 1.6.3 =
|
431 |
- Removed deprecated code (fixes PHP 7 deprecated warnings)
|
432 |
- Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
|
@@ -596,6 +600,10 @@ AD CODE RIGHT
|
|
596 |
|
597 |
== Upgrade Notice ==
|
598 |
|
|
|
|
|
|
|
|
|
599 |
= 1.6.3 =
|
600 |
Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type);
|
601 |
Added support to change plugin processing priority
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
|
4 |
Tags: adsense, amazon, clickbank, ad, ads, html, javascript, php, code, widget, sidebar, responsive, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.5.2
|
7 |
+
Stable tag: 1.6.3
|
8 |
License: GPLv3
|
9 |
|
10 |
Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
|
35 |
|
36 |
You can also define paragraph tags. Normally only `<p>` tags are used. If you post contains also `<div>` or header tags you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
|
37 |
**WARNING:** Each code block you insert on post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
|
38 |
+
**After Paragraph** will not work if you specify tag names that have no closing tags!
|
39 |
|
40 |
Additional Display Options:
|
41 |
|
427 |
|
428 |
== Changelog ==
|
429 |
|
430 |
+
= 1.6.4 =
|
431 |
+
- Fixed bug: For shortcodes in posts the url was not checked
|
432 |
+
- Optimizations for device detection
|
433 |
+
|
434 |
= 1.6.3 =
|
435 |
- Removed deprecated code (fixes PHP 7 deprecated warnings)
|
436 |
- Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
|
600 |
|
601 |
== Upgrade Notice ==
|
602 |
|
603 |
+
= 1.6.4 =
|
604 |
+
Fixed bug: For shortcodes in posts the url was not checked;
|
605 |
+
Optimizations for device detection
|
606 |
+
|
607 |
= 1.6.3 =
|
608 |
Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type);
|
609 |
Added support to change plugin processing priority
|
settings.php
CHANGED
@@ -637,7 +637,7 @@ function print_settings_form (){
|
|
637 |
<h2>Monitor Google AdSense and Amazon Associates earnings with <a href="http://tinymonitor.com/" target="_blank">Tiny Monitor</a></h2>
|
638 |
<a href="http://tinymonitor.com/" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>tinymonitor-logo.png" alt="Tiny Monitor" /></a>
|
639 |
<a href="http://tinymonitor.com/" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>tiny-monitor.png" alt="Amazon Associates" /></a>
|
640 |
-
<p style="text-align: justify;">TinyMonitor is a PHP application that can
|
641 |
The purpose of TinyMonitor is to download data from original sources and present them in a compact way on a single web page.
|
642 |
With TinyMonitor you have all the data at one place so you dont have to log in to various pages just to check earnings.
|
643 |
TinyMonitor displays some data also in the page title and favicon so you still have simple access to current monitor status while you work with other applications.</p>
|
637 |
<h2>Monitor Google AdSense and Amazon Associates earnings with <a href="http://tinymonitor.com/" target="_blank">Tiny Monitor</a></h2>
|
638 |
<a href="http://tinymonitor.com/" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>tinymonitor-logo.png" alt="Tiny Monitor" /></a>
|
639 |
<a href="http://tinymonitor.com/" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>tiny-monitor.png" alt="Amazon Associates" /></a>
|
640 |
+
<p style="text-align: justify;">TinyMonitor is a PHP application that can monitor your Google AdSense earnings, Amazon Associates earnings and PayPal transactions.
|
641 |
The purpose of TinyMonitor is to download data from original sources and present them in a compact way on a single web page.
|
642 |
With TinyMonitor you have all the data at one place so you dont have to log in to various pages just to check earnings.
|
643 |
TinyMonitor displays some data also in the page title and favicon so you still have simple access to current monitor status while you work with other applications.</p>
|