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

Version Description

  • Added support for counting paragraphs with multibyte (unicode) characters
  • Fixed bug for class name not saved
  • Few minor bug fixes and cosmetic changes
Download this release

Release Info

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

Code changes from version 2.1.2 to 2.1.3

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.1.2
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,11 @@ Plugin URI: http://adinserter.pro/documentation
11
  /*
12
  Change Log
13
 
 
 
 
 
 
14
  Ad Inserter 2.1.2 - 1 March 2017
15
  - Fixed bug for disabled settings page on multisite blogs
16
 
@@ -1849,7 +1854,7 @@ function get_syntax_highlighter_theme () {
1849
  function get_block_class_name () {
1850
  global $ai_db_options;
1851
 
1852
- if (!isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAM!E'])) $ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
1853
 
1854
  return ($ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAME']);
1855
  }
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.1.3
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.1.3 - 11 March 2017
15
+ - Added support for counting paragraphs with multibyte (unicode) characters
16
+ - Fixed bug for class name not saved
17
+ - Few minor bug fixes and cosmetic changes
18
+
19
  Ad Inserter 2.1.2 - 1 March 2017
20
  - Fixed bug for disabled settings page on multisite blogs
21
 
1854
  function get_block_class_name () {
1855
  global $ai_db_options;
1856
 
1857
+ if (!isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAME'])) $ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
1858
 
1859
  return ($ai_db_options [AI_GLOBAL_OPTION_NAME]['BLOCK_CLASS_NAME']);
1860
  }
class.php CHANGED
@@ -1322,12 +1322,16 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1322
  if (!in_array (0, $paragraph_positions)) $paragraph_positions [] = 0;
1323
  } else $paragraph_start = '<' . $paragraph_start_string;
1324
 
1325
- $paragraph_start_len = strlen ($paragraph_start);
 
1326
 
1327
- while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
1328
- $last_position = stripos ($content, $paragraph_start, $last_position + 1);
 
 
1329
  if ($paragraph_start_string == "#") $paragraph_positions [] = $last_position + 4; else
1330
- if ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ")
 
1331
  $paragraph_positions [] = $last_position;
1332
  }
1333
  }
@@ -1345,7 +1349,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1345
  $blockquotes = $blockquotes [0];
1346
  foreach ($blockquotes as $index => $blockquote) {
1347
  if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
1348
- $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
 
1349
  }
1350
  }
1351
 
@@ -1370,7 +1375,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1370
  if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
1371
  $filtered_paragraph_positions = array ();
1372
  foreach ($paragraph_positions as $index => $paragraph_position) {
1373
- $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
 
1374
  if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
1375
  }
1376
  $paragraph_positions = $filtered_paragraph_positions;
@@ -1388,12 +1394,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1388
  $paragraph_text_type = $this->get_paragraph_text_type ();
1389
 
1390
  foreach ($paragraph_positions as $index => $paragraph_position) {
1391
- $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
 
1392
 
1393
  if ($paragraph_text_type == AD_CONTAIN) {
1394
  $found = true;
1395
  foreach ($paragraph_texts as $paragraph_text) {
1396
- if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
 
1397
  $found = false;
1398
  break;
1399
  }
@@ -1402,7 +1410,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1402
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
1403
  $found = false;
1404
  foreach ($paragraph_texts as $paragraph_text) {
1405
- if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
 
1406
  $found = true;
1407
  break;
1408
  }
@@ -1452,9 +1461,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1452
  if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1453
  $paragraph_position_above = $position - $avoid_paragraphs_above;
1454
  if ($paragraph_position_above < 0) $paragraph_position_above = 0;
1455
- $paragraph_code = substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
 
1456
  foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1457
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
 
1458
  $found_above = true;
1459
  break;
1460
  }
@@ -1465,11 +1476,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1465
  if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1466
  $paragraph_position_below = $position + $avoid_paragraphs_below;
1467
  if ($paragraph_position_below > count ($paragraph_positions) - 1)
1468
- $content_position_below = strlen ($content); else
 
1469
  $content_position_below = $paragraph_positions [$paragraph_position_below];
1470
- $paragraph_code = substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
 
1471
  foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1472
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
 
1473
  $found_below = true;
1474
  break;
1475
  }
@@ -1542,10 +1556,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1542
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1543
  $inserted_code = "[[AI_BP".($counter + 1)."]]";
1544
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1545
- $content = substr_replace ($content, $inserted_code, $paragraph_position, 0);
 
1546
  } else {
1547
- $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset, 0);
1548
- $offset += strlen ($inserted_code);
 
 
1549
  }
1550
  }
1551
  return $content;
@@ -1559,7 +1576,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1559
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
1560
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
1561
  $content_position = $paragraph_positions [$position];
1562
- $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position, 0);
 
1563
  $ai_last_check = AI_CHECK_INSERTED;
1564
  }
1565
  }
@@ -1572,7 +1590,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1572
  global $ai_wp_data, $ai_last_check;
1573
 
1574
  $paragraph_positions = array ();
1575
- $last_content_position = strlen ($content) - 1;
 
1576
 
1577
  $paragraph_tags = trim ($this->get_paragraph_tags());
1578
  if ($paragraph_tags == '') return $content;
@@ -1593,8 +1612,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1593
  if (!in_array ($last_content_position, $paragraph_positions)) $paragraph_positions [] = $last_content_position;
1594
  } else $paragraph_end = '</' . $paragraph_end_string . '>';
1595
 
1596
- while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
1597
- $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
 
 
1598
  if ($paragraph_end_string == "#") $paragraph_positions [] = $last_position - 4; else
1599
  $paragraph_positions [] = $last_position;
1600
  }
@@ -1613,7 +1634,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1613
  $blockquotes = $blockquotes [0];
1614
  foreach ($blockquotes as $index => $blockquote) {
1615
  if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
1616
- $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
 
1617
  }
1618
  }
1619
 
@@ -1638,7 +1660,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1638
  if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
1639
  $filtered_paragraph_positions = array ();
1640
  foreach ($paragraph_positions as $index => $paragraph_position) {
1641
- $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
 
1642
  if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
1643
  }
1644
  $paragraph_positions = $filtered_paragraph_positions;
@@ -1656,12 +1679,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1656
  $paragraph_text_type = $this->get_paragraph_text_type ();
1657
 
1658
  foreach ($paragraph_positions as $index => $paragraph_position) {
1659
- $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
 
1660
 
1661
  if ($paragraph_text_type == AD_CONTAIN) {
1662
  $found = true;
1663
  foreach ($paragraph_texts as $paragraph_text) {
1664
- if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
 
1665
  $found = false;
1666
  break;
1667
  }
@@ -1670,7 +1695,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1670
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
1671
  $found = false;
1672
  foreach ($paragraph_texts as $paragraph_text) {
1673
- if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
 
1674
  $found = true;
1675
  break;
1676
  }
@@ -1723,10 +1749,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1723
  $content_position_above = 0; else
1724
  $content_position_above = $paragraph_positions [$paragraph_position_above] + 1;
1725
 
1726
- $paragraph_code = substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
 
1727
 
1728
  foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1729
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
 
1730
  $found_above = true;
1731
  break;
1732
  }
@@ -1737,9 +1765,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1737
  if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1738
  $paragraph_position_below = $position + $avoid_paragraphs_below;
1739
  if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
1740
- $paragraph_code = substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
 
1741
  foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1742
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
 
1743
  $found_below = true;
1744
  break;
1745
  }
@@ -1813,10 +1843,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1813
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1814
  $inserted_code = "[[AI_AP".($counter + 1)."]]";
1815
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1816
- $content = substr_replace ($content, $inserted_code, $paragraph_position + 1, 0);
 
1817
  } else {
1818
- $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset + 1, 0);
1819
- $offset += strlen ($inserted_code);
 
 
1820
  }
1821
  }
1822
  return $content;
@@ -1830,9 +1863,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1830
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
1831
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
1832
  $content_position = $paragraph_positions [$position];
1833
- if ($content_position >= strlen ($content) - 1)
 
1834
  $content = $content . $this->get_code_for_insertion (); else
1835
- $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position + 1, 0);
 
 
1836
  $ai_last_check = AI_CHECK_INSERTED;
1837
  }
1838
  }
1322
  if (!in_array (0, $paragraph_positions)) $paragraph_positions [] = 0;
1323
  } else $paragraph_start = '<' . $paragraph_start_string;
1324
 
1325
+ // $paragraph_start_len = strlen ($paragraph_start);
1326
+ $paragraph_start_len = mb_strlen ($paragraph_start);
1327
 
1328
+ // while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
1329
+ // $last_position = stripos ($content, $paragraph_start, $last_position + 1);
1330
+ while (mb_stripos ($content, $paragraph_start, $last_position + 1) !== false) {
1331
+ $last_position = mb_stripos ($content, $paragraph_start, $last_position + 1);
1332
  if ($paragraph_start_string == "#") $paragraph_positions [] = $last_position + 4; else
1333
+ // if ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ")
1334
+ if (mb_substr ($content, $last_position + $paragraph_start_len, 1) == ">" || mb_substr ($content, $last_position + $paragraph_start_len, 1) == " ")
1335
  $paragraph_positions [] = $last_position;
1336
  }
1337
  }
1349
  $blockquotes = $blockquotes [0];
1350
  foreach ($blockquotes as $index => $blockquote) {
1351
  if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
1352
+ // $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
1353
+ $blockquote_offsets []= array (mb_strlen (substr ($content, 0, $blockquote [1] + 11)), mb_strlen (substr ($content, 0, $blockquotes [$index + 1][1])));
1354
  }
1355
  }
1356
 
1375
  if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
1376
  $filtered_paragraph_positions = array ();
1377
  foreach ($paragraph_positions as $index => $paragraph_position) {
1378
+ // $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
1379
+ $paragraph_code = $index == count ($paragraph_positions) - 1 ? mb_substr ($content, $paragraph_position) : mb_substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
1380
  if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
1381
  }
1382
  $paragraph_positions = $filtered_paragraph_positions;
1394
  $paragraph_text_type = $this->get_paragraph_text_type ();
1395
 
1396
  foreach ($paragraph_positions as $index => $paragraph_position) {
1397
+ // $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
1398
+ $paragraph_code = $index == count ($paragraph_positions) - 1 ? mb_substr ($content, $paragraph_position) : mb_substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
1399
 
1400
  if ($paragraph_text_type == AD_CONTAIN) {
1401
  $found = true;
1402
  foreach ($paragraph_texts as $paragraph_text) {
1403
+ // if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
1404
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text)) === false) {
1405
  $found = false;
1406
  break;
1407
  }
1410
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
1411
  $found = false;
1412
  foreach ($paragraph_texts as $paragraph_text) {
1413
+ // if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
1414
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
1415
  $found = true;
1416
  break;
1417
  }
1461
  if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1462
  $paragraph_position_above = $position - $avoid_paragraphs_above;
1463
  if ($paragraph_position_above < 0) $paragraph_position_above = 0;
1464
+ // $paragraph_code = substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
1465
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
1466
  foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1467
+ // if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1468
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1469
  $found_above = true;
1470
  break;
1471
  }
1476
  if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1477
  $paragraph_position_below = $position + $avoid_paragraphs_below;
1478
  if ($paragraph_position_below > count ($paragraph_positions) - 1)
1479
+ // $content_position_below = strlen ($content); else
1480
+ $content_position_below = mb_strlen ($content); else
1481
  $content_position_below = $paragraph_positions [$paragraph_position_below];
1482
+ // $paragraph_code = substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1483
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1484
  foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1485
+ // if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1486
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1487
  $found_below = true;
1488
  break;
1489
  }
1556
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1557
  $inserted_code = "[[AI_BP".($counter + 1)."]]";
1558
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1559
+ // $content = substr_replace ($content, $inserted_code, $paragraph_position, 0);
1560
+ $content = mb_substr ($content, 0, $paragraph_position) . $inserted_code . mb_substr ($content, $paragraph_position);
1561
  } else {
1562
+ // $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset, 0);
1563
+ $content = mb_substr ($content, 0, $paragraph_position + $offset) . $inserted_code . mb_substr ($content, $paragraph_position + $offset);
1564
+ // $offset += strlen ($inserted_code);
1565
+ $offset += mb_strlen ($inserted_code);
1566
  }
1567
  }
1568
  return $content;
1576
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
1577
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
1578
  $content_position = $paragraph_positions [$position];
1579
+ // $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position, 0);
1580
+ $content = mb_substr ($content, 0, $content_position) . $this->get_code_for_insertion () . mb_substr ($content, $content_position);
1581
  $ai_last_check = AI_CHECK_INSERTED;
1582
  }
1583
  }
1590
  global $ai_wp_data, $ai_last_check;
1591
 
1592
  $paragraph_positions = array ();
1593
+ // $last_content_position = strlen ($content) - 1;
1594
+ $last_content_position = mb_strlen ($content) - 1;
1595
 
1596
  $paragraph_tags = trim ($this->get_paragraph_tags());
1597
  if ($paragraph_tags == '') return $content;
1612
  if (!in_array ($last_content_position, $paragraph_positions)) $paragraph_positions [] = $last_content_position;
1613
  } else $paragraph_end = '</' . $paragraph_end_string . '>';
1614
 
1615
+ // while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
1616
+ // $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
1617
+ while (mb_stripos ($content, $paragraph_end, $last_position + 1) !== false) {
1618
+ $last_position = mb_stripos ($content, $paragraph_end, $last_position + 1) + mb_strlen ($paragraph_end) - 1;
1619
  if ($paragraph_end_string == "#") $paragraph_positions [] = $last_position - 4; else
1620
  $paragraph_positions [] = $last_position;
1621
  }
1634
  $blockquotes = $blockquotes [0];
1635
  foreach ($blockquotes as $index => $blockquote) {
1636
  if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
1637
+ // $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
1638
+ $blockquote_offsets []= array (mb_strlen (substr ($content, 0, $blockquote [1] + 11)), mb_strlen (substr ($content, 0, $blockquotes [$index + 1][1])));
1639
  }
1640
  }
1641
 
1660
  if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
1661
  $filtered_paragraph_positions = array ();
1662
  foreach ($paragraph_positions as $index => $paragraph_position) {
1663
+ // $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
1664
+ $paragraph_code = $index == 0 ? mb_substr ($content, 0, $paragraph_position + 1) : mb_substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
1665
  if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
1666
  }
1667
  $paragraph_positions = $filtered_paragraph_positions;
1679
  $paragraph_text_type = $this->get_paragraph_text_type ();
1680
 
1681
  foreach ($paragraph_positions as $index => $paragraph_position) {
1682
+ // $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
1683
+ $paragraph_code = $index == 0 ? mb_substr ($content, 0, $paragraph_position + 1) : mb_substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
1684
 
1685
  if ($paragraph_text_type == AD_CONTAIN) {
1686
  $found = true;
1687
  foreach ($paragraph_texts as $paragraph_text) {
1688
+ // if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
1689
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text)) === false) {
1690
  $found = false;
1691
  break;
1692
  }
1695
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
1696
  $found = false;
1697
  foreach ($paragraph_texts as $paragraph_text) {
1698
+ // if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
1699
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
1700
  $found = true;
1701
  break;
1702
  }
1749
  $content_position_above = 0; else
1750
  $content_position_above = $paragraph_positions [$paragraph_position_above] + 1;
1751
 
1752
+ // $paragraph_code = substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
1753
+ $paragraph_code = mb_substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
1754
 
1755
  foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1756
+ // if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1757
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1758
  $found_above = true;
1759
  break;
1760
  }
1765
  if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1766
  $paragraph_position_below = $position + $avoid_paragraphs_below;
1767
  if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
1768
+ // $paragraph_code = substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
1769
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
1770
  foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1771
+ // if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1772
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1773
  $found_below = true;
1774
  break;
1775
  }
1843
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1844
  $inserted_code = "[[AI_AP".($counter + 1)."]]";
1845
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1846
+ // $content = substr_replace ($content, $inserted_code, $paragraph_position + 1, 0);
1847
+ $content = mb_substr ($content, 0, $paragraph_position + 1) . $inserted_code . mb_substr ($content, $paragraph_position + 1);
1848
  } else {
1849
+ // $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset + 1, 0);
1850
+ $content = mb_substr ($content, 0, $paragraph_position + $offset + 1) . $inserted_code . mb_substr ($content, $paragraph_position + $offset + 1);
1851
+ // $offset += strlen ($inserted_code);
1852
+ $offset += mb_strlen ($inserted_code);
1853
  }
1854
  }
1855
  return $content;
1863
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
1864
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
1865
  $content_position = $paragraph_positions [$position];
1866
+ // if ($content_position >= strlen ($content) - 1)
1867
+ if ($content_position >= mb_strlen ($content) - 1)
1868
  $content = $content . $this->get_code_for_insertion (); else
1869
+ // $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position + 1, 0);
1870
+ $content = mb_substr ($content, 0, $content_position + 1) . $this->get_code_for_insertion () . mb_substr ($content, $content_position + 1);
1871
+
1872
  $ai_last_check = AI_CHECK_INSERTED;
1873
  }
1874
  }
constants.php CHANGED
@@ -14,7 +14,7 @@ if (!defined( 'AD_INSERTER_NAME'))
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
- define ('AD_INSERTER_VERSION', '2.1.2');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
+ define ('AD_INSERTER_VERSION', '2.1.3');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #data {
2
- font-family: "2.1.2"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #data {
2
+ font-family: "2.1.3"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
images/ad-inserter-pro.jpg ADDED
Binary file
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.1.2";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
1
+ var javascript_version = "2.1.3";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
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, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
5
  Requires at least: 4.0
6
- Tested up to: 4.7.2
7
- Stable tag: 2.1.1
8
  License: GPLv3
9
 
10
  Insert any advert or code into Wordpress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.
@@ -118,6 +118,7 @@ activate it and then click "Enter License Key" and enter license key you got in
118
  3. Select `ad-inserter-pro.zip` from your computer
119
  4. Click 'Install Now'
120
  5. Activate Ad Inserter Pro in the Plugin dashboard
 
121
 
122
  = Using FTP =
123
 
@@ -675,6 +676,11 @@ AD CODE RIGHT
675
 
676
  == Changelog ==
677
 
 
 
 
 
 
678
  = 2.1.2 =
679
  - Fixed bug for disabled settings page on multisite blogs
680
 
@@ -1007,6 +1013,11 @@ AD CODE RIGHT
1007
 
1008
  == Upgrade Notice ==
1009
 
 
 
 
 
 
1010
  = 2.1.2 =
1011
  Fixed bug for disabled settings page on multisite blogs
1012
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
5
  Requires at least: 4.0
6
+ Tested up to: 4.7.3
7
+ Stable tag: 2.1.2
8
  License: GPLv3
9
 
10
  Insert any advert or code into Wordpress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.
118
  3. Select `ad-inserter-pro.zip` from your computer
119
  4. Click 'Install Now'
120
  5. Activate Ad Inserter Pro in the Plugin dashboard
121
+ 5. Click "Enter License Key" or go to plugin Settings / tab * and enter license key you got in the email
122
 
123
  = Using FTP =
124
 
676
 
677
  == Changelog ==
678
 
679
+ = 2.1.3 =
680
+ - Added support for counting paragraphs with multibyte (unicode) characters
681
+ - Fixed bug for class name not saved
682
+ - Few minor bug fixes and cosmetic changes
683
+
684
  = 2.1.2 =
685
  - Fixed bug for disabled settings page on multisite blogs
686
 
1013
 
1014
  == Upgrade Notice ==
1015
 
1016
+ = 2.1.3 =
1017
+ Added support for counting paragraphs with multibyte (unicode) characters;
1018
+ Fixed bug for class name not saved;
1019
+ Few minor bug fixes and cosmetic changes
1020
+
1021
  = 2.1.2 =
1022
  Fixed bug for disabled settings page on multisite blogs
1023
 
settings.php CHANGED
@@ -1299,11 +1299,36 @@ function generate_settings_form (){
1299
  </div>
1300
 
1301
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
1302
- <a href="http://tinymonitor.com/" target="_blank"><img id="monitors-image" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>monitors.png" alt="Tiny Monitor" /></a>
1303
- <p style="text-align: justify;"><a href="http://tinymonitor.com/" target="_blank">Tiny Monitor</a> is a PHP application that can monitor your Google AdSense earnings,
1304
- CJ earnings and PayPal transactions. The purpose of Tiny Monitor is to download data from original sources and present them in a compact way on a single web page.
1305
- With Tiny Monitor you have all the data at one place so you dont have to log in to various pages just to check earnings.
1306
- Tiny Monitor 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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1307
  </div>
1308
  </div>
1309
  <?php
@@ -1321,9 +1346,9 @@ function generate_settings_form (){
1321
  jQuery("#blocked-warning.warning-enabled").show ();
1322
  jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
1323
 
1324
- var image = jQuery("#monitors-image");
1325
  if (image.height () < 100) {
1326
- image.hide ().after (image.clone ().attr ('class', '').attr ("id", 'monitors-image-ajax').attr ('src', '<?php echo wp_make_link_relative (get_site_url()); ?>/wp-admin/admin-ajax.php?action=ai_data&image=monitors.png&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').css ('display', 'block'));
1327
  }
1328
  }
1329
  </script>
1299
  </div>
1300
 
1301
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
1302
+ <p style="text-align: justify;">In addition to all the features of Ad Inserter, Ad Inserter Pro supports also the following:</p>
1303
+ <ul>
1304
+ <li>
1305
+ <strong>&squf;</strong> 64 code blocks
1306
+ </li>
1307
+ <li>
1308
+ <strong>&squf;</strong> 6 viewports
1309
+ </li>
1310
+ <li>
1311
+ <strong>&squf;</strong> GEO targeting (works also with caching)
1312
+ </li>
1313
+ <li>
1314
+ <strong>&squf;</strong> Black/White-list IP addresses or countries (works also with caching)
1315
+ </li>
1316
+ <li>
1317
+ <strong>&squf;</strong> Sticky positions (ads do not move when the page scrolls)
1318
+ </li>
1319
+ <li>
1320
+ <strong>&squf;</strong> Multisite options to limit settings on the sites
1321
+ </li>
1322
+ <li>
1323
+ <strong>&squf;</strong> Import/Export block or plugin settings
1324
+ </li>
1325
+ <li>
1326
+ <strong>&squf;</strong> Scheduling with fallback option
1327
+ </li>
1328
+ </ul>
1329
+ <p style="text-align: justify;">With Ad Inserter Pro you also get one year of free updates and support via email. If you find Ad Inserter useful and need more code blocks, GEO targeting or multisite support
1330
+ then you can simply upgrade to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> (existing settings will be preserved).</p>
1331
+ <a href="http://adinserter.pro/" target="_blank"><img id="pro-image" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>ad-inserter-pro.jpg" style="margin-left: -5px;" alt="Ad Inserter Pro" /></a>
1332
  </div>
1333
  </div>
1334
  <?php
1346
  jQuery("#blocked-warning.warning-enabled").show ();
1347
  jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
1348
 
1349
+ var image = jQuery("#pro-image");
1350
  if (image.height () < 100) {
1351
+ image.hide ().after (image.clone ().attr ('class', '').attr ("id", 'pro-image-ajax').attr ('src', '<?php echo wp_make_link_relative (get_site_url()); ?>/wp-admin/admin-ajax.php?action=ai_data&image=ad-inserter-pro.jpg&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').css ('display', 'block'));
1352
  }
1353
  }
1354
  </script>