Changeset 3252345
- Timestamp:
- 03/07/2025 08:44:33 PM (13 months ago)
- Location:
- serbian-transliteration
- Files:
-
- 138 added
- 6 edited
-
tags/2.2.1 (added)
-
tags/2.2.1/CHANGELOG.txt (added)
-
tags/2.2.1/LICENSE.txt (added)
-
tags/2.2.1/assets (added)
-
tags/2.2.1/assets/css (added)
-
tags/2.2.1/assets/css/admin.css (added)
-
tags/2.2.1/assets/css/admin.min.css (added)
-
tags/2.2.1/assets/css/highlight.min.css (added)
-
tags/2.2.1/assets/css/index.php (added)
-
tags/2.2.1/assets/css/tools.css (added)
-
tags/2.2.1/assets/css/tools.min.css (added)
-
tags/2.2.1/assets/img (added)
-
tags/2.2.1/assets/img/fp-icon-80x80.png (added)
-
tags/2.2.1/assets/img/icon-animated-24x24.gif (added)
-
tags/2.2.1/assets/img/icon-animated-32x32.gif (added)
-
tags/2.2.1/assets/img/index.php (added)
-
tags/2.2.1/assets/img/logo-contra-team.jpg (added)
-
tags/2.2.1/assets/img/logo-freelance-poslovi-sr_RS.jpg (added)
-
tags/2.2.1/assets/img/logo-freelance-poslovi.jpg (added)
-
tags/2.2.1/assets/index.php (added)
-
tags/2.2.1/assets/js (added)
-
tags/2.2.1/assets/js/admin.js (added)
-
tags/2.2.1/assets/js/admin.min.js (added)
-
tags/2.2.1/assets/js/highlight.min.js (added)
-
tags/2.2.1/assets/js/index.php (added)
-
tags/2.2.1/assets/js/tools-block.js (added)
-
tags/2.2.1/assets/js/tools-block.min.js (added)
-
tags/2.2.1/assets/js/tools-tinymce.js (added)
-
tags/2.2.1/assets/js/tools-tinymce.min.js (added)
-
tags/2.2.1/assets/js/tools.js (added)
-
tags/2.2.1/assets/js/tools.min.js (added)
-
tags/2.2.1/classes (added)
-
tags/2.2.1/classes/ajax.php (added)
-
tags/2.2.1/classes/autoloader.php (added)
-
tags/2.2.1/classes/cache-db.php (added)
-
tags/2.2.1/classes/controller.php (added)
-
tags/2.2.1/classes/debug.php (added)
-
tags/2.2.1/classes/email.php (added)
-
tags/2.2.1/classes/filters.php (added)
-
tags/2.2.1/classes/index.php (added)
-
tags/2.2.1/classes/init.php (added)
-
tags/2.2.1/classes/map.php (added)
-
tags/2.2.1/classes/maps (added)
-
tags/2.2.1/classes/maps/ar.php (added)
-
tags/2.2.1/classes/maps/ba.php (added)
-
tags/2.2.1/classes/maps/bel.php (added)
-
tags/2.2.1/classes/maps/bg_BG.php (added)
-
tags/2.2.1/classes/maps/bs_BA.php (added)
-
tags/2.2.1/classes/maps/cnr.php (added)
-
tags/2.2.1/classes/maps/el.php (added)
-
tags/2.2.1/classes/maps/hy.php (added)
-
tags/2.2.1/classes/maps/index.php (added)
-
tags/2.2.1/classes/maps/ka_GE.php (added)
-
tags/2.2.1/classes/maps/kir.php (added)
-
tags/2.2.1/classes/maps/kk.php (added)
-
tags/2.2.1/classes/maps/mk_MK.php (added)
-
tags/2.2.1/classes/maps/mn.php (added)
-
tags/2.2.1/classes/maps/ru_RU.php (added)
-
tags/2.2.1/classes/maps/sr_RS.php (added)
-
tags/2.2.1/classes/maps/tg.php (added)
-
tags/2.2.1/classes/maps/uk.php (added)
-
tags/2.2.1/classes/maps/uz_UZ.php (added)
-
tags/2.2.1/classes/menus.php (added)
-
tags/2.2.1/classes/mode.php (added)
-
tags/2.2.1/classes/model.php (added)
-
tags/2.2.1/classes/modes (added)
-
tags/2.2.1/classes/modes/admin.php (added)
-
tags/2.2.1/classes/modes/advanced.php (added)
-
tags/2.2.1/classes/modes/dev.php (added)
-
tags/2.2.1/classes/modes/forced.php (added)
-
tags/2.2.1/classes/modes/index.php (added)
-
tags/2.2.1/classes/modes/light.php (added)
-
tags/2.2.1/classes/modes/phantom.php (added)
-
tags/2.2.1/classes/modes/standard.php (added)
-
tags/2.2.1/classes/modes/woocommerce.php (added)
-
tags/2.2.1/classes/notifications.php (added)
-
tags/2.2.1/classes/plugins (added)
-
tags/2.2.1/classes/plugins.php (added)
-
tags/2.2.1/classes/plugins/advanced-custom-fields-pro.php (added)
-
tags/2.2.1/classes/plugins/advanced-custom-fields.php (added)
-
tags/2.2.1/classes/plugins/contact-form-7.php (added)
-
tags/2.2.1/classes/plugins/data-tables-generator-by-supsystic.php (added)
-
tags/2.2.1/classes/plugins/elementor.php (added)
-
tags/2.2.1/classes/plugins/index.php (added)
-
tags/2.2.1/classes/plugins/polylang.php (added)
-
tags/2.2.1/classes/plugins/revslider.php (added)
-
tags/2.2.1/classes/plugins/woocommerce.php (added)
-
tags/2.2.1/classes/plugins/wordpress-seo.php (added)
-
tags/2.2.1/classes/requirements.php (added)
-
tags/2.2.1/classes/rest.php (added)
-
tags/2.2.1/classes/sanitization.php (added)
-
tags/2.2.1/classes/search.php (added)
-
tags/2.2.1/classes/settings (added)
-
tags/2.2.1/classes/settings-fields.php (added)
-
tags/2.2.1/classes/settings-sidebars.php (added)
-
tags/2.2.1/classes/settings.php (added)
-
tags/2.2.1/classes/settings/index.php (added)
-
tags/2.2.1/classes/settings/page-credits.php (added)
-
tags/2.2.1/classes/settings/page-debug.php (added)
-
tags/2.2.1/classes/settings/page-functions.php (added)
-
tags/2.2.1/classes/settings/page-permalinks.php (added)
-
tags/2.2.1/classes/settings/page-shortcodes.php (added)
-
tags/2.2.1/classes/settings/page-tags.php (added)
-
tags/2.2.1/classes/settings/page-transliteration.php (added)
-
tags/2.2.1/classes/shortcodes.php (added)
-
tags/2.2.1/classes/themes (added)
-
tags/2.2.1/classes/themes.php (added)
-
tags/2.2.1/classes/themes/avada.php (added)
-
tags/2.2.1/classes/themes/divi.php (added)
-
tags/2.2.1/classes/themes/index.php (added)
-
tags/2.2.1/classes/themes/themify.php (added)
-
tags/2.2.1/classes/tools.php (added)
-
tags/2.2.1/classes/traits (added)
-
tags/2.2.1/classes/traits/cache-controlled.php (added)
-
tags/2.2.1/classes/traits/cache.php (added)
-
tags/2.2.1/classes/traits/index.php (added)
-
tags/2.2.1/classes/utilities.php (added)
-
tags/2.2.1/classes/wordpress.php (added)
-
tags/2.2.1/classes/wp-cli.php (added)
-
tags/2.2.1/constants.php (added)
-
tags/2.2.1/functions.php (added)
-
tags/2.2.1/index.php (added)
-
tags/2.2.1/languages (added)
-
tags/2.2.1/languages/index.php (added)
-
tags/2.2.1/languages/serbian-transliteration-hr.mo (added)
-
tags/2.2.1/languages/serbian-transliteration-hr.po (added)
-
tags/2.2.1/languages/serbian-transliteration-sr_RS.mo (added)
-
tags/2.2.1/languages/serbian-transliteration-sr_RS.po (added)
-
tags/2.2.1/languages/serbian-transliteration.pot (added)
-
tags/2.2.1/libraries (added)
-
tags/2.2.1/libraries/.htaccess (added)
-
tags/2.2.1/libraries/index.php (added)
-
tags/2.2.1/libraries/locale.lib (added)
-
tags/2.2.1/libraries/sr_RS.diacritical.words.lib (added)
-
tags/2.2.1/libraries/sr_RS.skip.words.lib (added)
-
tags/2.2.1/readme.txt (added)
-
tags/2.2.1/serbian-transliteration.php (added)
-
tags/2.2.1/uninstall.php (added)
-
trunk/CHANGELOG.txt (modified) (1 diff)
-
trunk/classes/controller.php (modified) (12 diffs)
-
trunk/classes/wordpress.php (modified) (4 diffs)
-
trunk/constants.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/serbian-transliteration.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
serbian-transliteration/trunk/CHANGELOG.txt
r3244095 r3252345 1 = 2.2.1 = 2 * Fixed PHP errors from the previous version 3 * Improved UTF-8 encoding 4 * Optimized transliteration scripts 5 * Added support for the special HTML attributes 6 1 7 = 2.2.0 = 2 8 * NEW: Phantom Mode - ultra fast DOM-based transliteration (experimental) -
serbian-transliteration/trunk/classes/controller.php
r3244095 r3252345 239 239 return $placeholder; 240 240 }, $content); 241 242 // Extract <head> contents and replace them with placeholders 243 $head_placeholders = []; 244 $content = preg_replace_callback('/<head\b[^>]*>(.*?)<\/head>/is', function($matches) use (&$head_placeholders) { 245 $placeholder = '@=[3-' . count($head_placeholders) . ']=@'; 246 $head_placeholders[$placeholder] = $matches[0]; 247 return $placeholder; 248 }, $content); 241 249 242 250 // Handle percentage format specifiers by replacing them with placeholders 243 251 $formatSpecifiers = []; 244 252 $content = preg_replace_callback('/(\b\d+(?:\.\d+)?%)/', function($matches) use (&$formatSpecifiers) { 245 $placeholder = '@=[ 3-' . count($formatSpecifiers) . ']=@';253 $placeholder = '@=[4-' . count($formatSpecifiers) . ']=@'; 246 254 $formatSpecifiers[$placeholder] = $matches[0]; 247 255 return $placeholder; … … 288 296 $content = strtr($content, $style_placeholders); 289 297 unset($style_placeholders); 298 } 299 300 // Restore <head> contents back to their original form 301 if ($head_placeholders) { 302 $content = strtr($content, $head_placeholders); 303 unset($head_placeholders); 290 304 } 291 305 … … 405 419 }, $content); 406 420 421 // Extract <head> contents and replace them with placeholders 422 $head_placeholders = []; 423 $content = preg_replace_callback('/<head\b[^>]*>(.*?)<\/head>/is', function($matches) use (&$head_placeholders) { 424 $placeholder = '@=[5-' . count($head_placeholders) . ']=@'; 425 $head_placeholders[$placeholder] = $matches[0]; 426 return $placeholder; 427 }, $content); 428 407 429 // Extract special shortcode contents and replace them with placeholders 408 430 $special_shortcodes = []; 409 431 $content = preg_replace_callback('/\{\{([\w+_-]+)\s?([^\}]*)\}\}(.*?)\{\{\/\1\}\}/is', function($matches) use (&$special_shortcodes) { 410 $placeholder = '@=[ 5-' . count($special_shortcodes) . ']=@';432 $placeholder = '@=[6-' . count($special_shortcodes) . ']=@'; 411 433 $special_shortcodes[$placeholder] = $matches[0]; 412 434 return $placeholder; … … 414 436 415 437 $content = preg_replace_callback('/\{([\w+_-]+)\s?([^\}]*)\}(.*?)\{\/\1\}/is', function($matches) use (&$special_shortcodes) { 416 $placeholder = '@=[ 6-' . count($special_shortcodes) . ']=@';438 $placeholder = '@=[7-' . count($special_shortcodes) . ']=@'; 417 439 $special_shortcodes[$placeholder] = $matches[0]; 418 440 return $placeholder; … … 427 449 ); 428 450 $content = preg_replace_callback($regex, function($matches) use (&$formatSpecifiers) { 429 $placeholder = '@=[ 7-' . count($formatSpecifiers) . ']=@';451 $placeholder = '@=[8-' . count($formatSpecifiers) . ']=@'; 430 452 $formatSpecifiers[$placeholder] = $matches[0]; 431 453 return $placeholder; … … 496 518 $content = strtr($content, $style_placeholders); 497 519 unset($style_placeholders); 520 } 521 522 // Restore <head> contents back to their original form 523 if ($head_placeholders) { 524 $content = strtr($content, $head_placeholders); 525 unset($head_placeholders); 498 526 } 499 527 … … 620 648 } 621 649 622 $dom = new DOMDocument( );650 $dom = new DOMDocument('1.0', 'UTF-8'); 623 651 624 652 libxml_use_internal_errors(true); 625 $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); 653 $html = '<?xml encoding="UTF-8">' . $html; // UTF-8 deklaracija OBAVEZNA! 654 $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); 626 655 libxml_clear_errors(); 627 656 … … 639 668 'img', 640 669 'svg', 641 'image' 642 ]); 670 'image', 671 'head', 672 'meta' 673 ], 'dom'); 643 674 644 675 // Atributi na koje se primenjuje transliteracija 645 $attributesToTransliterate = apply_filters('transliteration_html_attributes', [ 646 'title', 647 'data-title', 648 'alt', 649 'placeholder', 650 'data-placeholder', 651 'aria-label', 652 'data-label', 653 'data-description' 654 ], 'inherit'); 676 $attributesToTransliterate = $this->private__html_atributes('dom', true); 655 677 656 678 // Transliteracija teksta unutar tagova, osim onih koji su na listi za izbegavanje 657 679 foreach ($xpath->query('//text()') as $textNode) { 658 680 if (!in_array($textNode->parentNode->nodeName, $skipTags)) { 659 $textNode->nodeValue = mb_convert_encoding( 660 $this->transliterate_no_html($textNode->nodeValue), 661 'HTML-ENTITIES', 662 'UTF-8' 663 ); 681 $textNode->nodeValue = $this->transliterate_no_html($textNode->nodeValue); 664 682 } 665 683 } 666 684 667 685 // Transliteracija određenih atributa 668 669 686 foreach ($xpath->query('//*[@' . implode(' or @', $attributesToTransliterate) . ']') as $node) { 670 687 foreach ($attributesToTransliterate as $attr) { 671 688 if ($node->hasAttribute($attr)) { 672 $node->setAttribute($attr, mb_convert_encoding( 673 $this->transliterate_no_html($node->getAttribute($attr)), 674 'HTML-ENTITIES', 675 'UTF-8' 676 )); 689 $node->setAttribute($attr, $this->transliterate($node->getAttribute($attr))); 677 690 } 678 691 } … … 680 693 681 694 // Vraćamo HTML sa pravilnim enkodingom 682 return mb_convert_encoding($dom->saveHTML(), 'UTF-8', 'HTML-ENTITIES'); 683 } 695 return $dom->saveHTML(); 696 } 697 684 698 685 699 … … 687 701 * PRIVATE: Allowed HTML attributes for transliteration 688 702 */ 689 private function private__html_atributes($type = 'inherit' ) {690 return self::cached_static('private__html_atributes', function() use ($type ) {703 private function private__html_atributes($type = 'inherit', $return_array = false) { 704 return self::cached_static('private__html_atributes', function() use ($type, $return_array) { 691 705 $html_attributes_match = [ 692 706 'title', … … 697 711 'aria-label', 698 712 'data-label', 699 'data-description' 713 'data-description', 714 'data-text', 715 'data-content', 716 'data-tooltip', 717 'data-success_message', 718 'data-qm-component', 719 'data-qm-subject' 700 720 ]; 701 721 … … 704 724 $html_attributes_match = is_array($html_attributes_match) ? array_map('trim', $html_attributes_match) : []; 705 725 726 if($return_array) { 727 return $html_attributes_match; 728 } 729 706 730 return join('|', $html_attributes_match); 707 }, $type);731 }, [$type, $return_array]); 708 732 } 709 733 -
serbian-transliteration/trunk/classes/wordpress.php
r3224920 r3252345 5 5 public function __construct() { 6 6 $this->add_filter('sanitize_user', 'allow_cyrillic_usernames', 10, 3); 7 $this->add_filter('body_class', 'add_body_class', 10, 1); 7 $this->add_filter('body_class', 'add_body_class', 10, 2); 8 8 9 $this->transliterate_rss_atom(); 9 10 $this->transliterate_widgets(); … … 43 44 } 44 45 45 public function add_body_class($classes ){46 public function add_body_class($classes, $css_class){ 46 47 if(get_rstr_option('enable-body-class', 'no') == 'no') { 47 return ;48 return $classes; 48 49 } 50 49 51 $script = Transliteration_Utilities::get_current_script(); 52 50 53 //body class based on the current script - cyr, lat 51 54 $classes[] = 'rstr-' . $script; 52 55 $classes[] = 'transliteration-' . $script; 53 56 $classes[] = $script; 57 54 58 return $classes; 55 59 } … … 61 65 62 66 $priority = PHP_INT_MAX - 100; 67 63 68 $actions = [ 64 69 'rss_head', 'rss_footer', … … 67 72 'atom_head', 'atom_footer', 68 73 ]; 74 69 75 foreach ($actions as $action) { 70 76 $this->add_action($action, 'rss_output_buffer_' . (strpos($action??'', '_head') ? 'start' : 'end'), $priority); 71 } 77 } 72 78 } 73 79 -
serbian-transliteration/trunk/constants.php
r3239677 r3252345 30 30 * @verson 1.0.0 31 31 */ 32 33 // This is need for plugin debugging.34 if (defined('WP_DEBUG')) {35 if (WP_DEBUG === true || WP_DEBUG === 1) {36 if (!defined('RSTR_DEBUG')) define('RSTR_DEBUG', true);37 }38 }39 32 40 33 // Plugin basename -
serbian-transliteration/trunk/readme.txt
r3244095 r3252345 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.0 7 Stable tag: 2.2. 07 Stable tag: 2.2.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 108 108 109 109 == Changelog == 110 111 = 2.2.1 = 112 * Fixed PHP errors from the previous version 113 * Improved UTF-8 encoding 114 * Optimized transliteration scripts 115 * Added support for the special HTML attributes 110 116 111 117 = 2.2.0 = … … 216 222 217 223 == Upgrade Notice == 224 225 = 2.2.1 = 226 * Fixed PHP errors from the previous version 227 * Improved UTF-8 encoding 228 * Optimized transliteration scripts 229 * Added support for the special HTML attributes 218 230 219 231 = 2.2.0 = -
serbian-transliteration/trunk/serbian-transliteration.php
r3244095 r3252345 6 6 * Description: All in one Cyrillic to Latin transliteration plugin for WordPress that actually works. 7 7 * Donate link: https://www.buymeacoffee.com/ivijanstefan 8 * Version: 2.2. 08 * Version: 2.2.1 9 9 * Requires at least: 5.4 10 10 * Tested up to: 6.7 … … 100 100 include_once __DIR__ . '/constants.php'; 101 101 102 // Developers need good debug103 if( (defined('RSTR_DEV_MODE') && RSTR_DEV_MODE) || (defined('RSTR_DEBUG') && RSTR_DEBUG) ) {104 error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);105 add_action('doing_it_wrong_run', '__return_false');106 ini_set('display_errors', true);107 ini_set('log_errors', true);108 }109 110 102 // Set database tables 111 103 global $wpdb, $rstr_is_admin;
Note: See TracChangeset
for help on using the changeset viewer.