Plugin Directory

Changeset 3307894


Ignore:
Timestamp:
06/07/2025 03:42:44 PM (10 months ago)
Author:
creativform
Message:

2.3.3

  • Fixed domain was triggered too early
  • Fixed admin transliteration
  • Improved debugging
  • Added transliteration for js-composer
  • Improved plugin speed
  • Improved PHP code
  • Improved transliterations
Location:
serbian-transliteration
Files:
142 added
32 edited

Legend:

Unmodified
Added
Removed
  • serbian-transliteration/trunk/CHANGELOG.txt

    r3288639 r3307894  
     1= 2.3.3 =
     2* Fixed domain was triggered too early
     3* Fixed admin transliteration
     4* Improved debugging
     5* Added transliteration for js-composer
     6* Improved plugin speed
     7* Improved PHP code
     8* Improved transliterations
     9
    110= 2.3.2 =
    211* Fixed Wp Admin transliteration
  • serbian-transliteration/trunk/classes/cache-db.php

    r3269990 r3307894  
    260260    /*
    261261     * Check is database table exists
    262      * @verson    1.0.0
     262     * @version   1.0.0
    263263     */
    264264    public static function table_exists($dry = false)
     
    296296    /*
    297297     * Install missing tables
    298      * @verson    1.0.0
     298     * @version   1.0.0
    299299     */
    300300    public static function table_install(): void
     
    326326    /*
    327327     * Instance
    328      * @verson    1.0.0
     328     * @version   1.0.0
    329329     */
    330330    public static function instance()
  • serbian-transliteration/trunk/classes/debug.php

    r3269990 r3307894  
    5656
    5757    /*
    58      * Check if PHP is 64 bit vesion
     58     * Check if PHP is 64 bit version
    5959     *
    6060     * @return boolean true or false
     
    8080
    8181    /*
    82      * Check if any OS is 64 bit vesion
     82     * Check if any OS is 64 bit version
    8383     *
    8484     * @return boolean true or false
     
    8686    public static function is_os64()
    8787    {
    88         // Let's ask system directly
    89         if (function_exists('shell_exec')) {
    90             if (self::is_win()) {
    91                 // Is Windows OS
    92                 $shell = shell_exec('wmic os get osarchitecture');
    93                 if (!($shell === '' || $shell === '0' || $shell === false || $shell === null) && strpos($shell ?? '', '64') !== false) {
    94                     return true;
    95                 }
    96             } else {
    97                 // Let's check some UNIX approach if is possible
    98                 $shell = shell_exec('uname -m');
    99                 if (!($shell === '' || $shell === '0' || $shell === false || $shell === null) && strpos($shell ?? '', '64') !== false) {
    100                     return true;
    101                 }
    102             }
    103         }
    104 
    105         // Check if PHP is 64 bit vesion (PHP 64bit only running on 64bit OS version)
    106         $is_php64 = self::is_php64();
    107         if ($is_php64) {
    108             return true;
    109         }
    110         // bit-shifting can help also
    111         return (bool) (1 << 32) - 1;
     88        // Check machine architecture using PHP
     89        if (function_exists('php_uname')) {
     90            $machine = php_uname('m');
     91            if ($machine && strpos($machine, '64') !== false) {
     92                return true;
     93            }
     94        }
     95
     96        // Fallback to PHP architecture detection
     97        return self::is_php64();
    11298    }
    11399
  • serbian-transliteration/trunk/classes/init.php

    r3269990 r3307894  
    1111        // Register the textdomain for the plugin
    1212        $this->set_admin_cookie_based_on_url();
    13         $this->add_action('plugins_loaded', 'load_textdomain');
    14         $this->add_action('load_textdomain_mofile', 'load_textdomain_mofile', 10, 2);
     13        // Load translations after plugins are fully loaded
     14       
     15        $this->add_action('plugins_loaded', 'hook_init');
    1516        $this->add_action('template_redirect', 'set_transliteration');
    1617
     
    4950    }
    5051
     52    public function hook_init(): void
     53    {
     54        $this->add_action('init', 'load_textdomain');
     55        $this->add_filter('load_textdomain_mofile', 'load_textdomain_mofile', 10, 2);
     56    }
     57
     58    /**
     59     * Set an admin detection cookie based on the requested URL.
     60     *
     61     * This allows other plugin components to know whether the current
     62     * request is in the admin area without relying solely on is_admin().
     63     */
    5164    public function set_admin_cookie_based_on_url(): void
    5265    {
  • serbian-transliteration/trunk/classes/maps/ar.php

    r3269990 r3307894  
    3535    ];
    3636
     37    /**
     38     * Transliterate text between Cyrillic and Latin.
     39     *
     40     * @param mixed $content String to transliterate.
     41     * @param string $translation Conversion direction.
     42     * @return mixed
     43     */
    3744    public static function transliterate($content, $translation = 'cyr_to_lat')
    3845    {
  • serbian-transliteration/trunk/classes/maps/ba.php

    r3269990 r3307894  
    6060    ];
    6161
     62    /**
     63     * Transliterate text between Cyrillic and Latin.
     64     *
     65     * @param mixed $content String to transliterate.
     66     * @param string $translation Conversion direction.
     67     * @return mixed
     68     */
    6269    public static function transliterate($content, $translation = 'cyr_to_lat')
    6370    {
  • serbian-transliteration/trunk/classes/maps/bel.php

    r3269990 r3307894  
    4040    ];
    4141
     42    /**
     43     * Transliterate text between Cyrillic and Latin.
     44     *
     45     * @param mixed $content String to transliterate.
     46     * @param string $translation Conversion direction.
     47     * @return mixed
     48     */
    4249    public static function transliterate($content, $translation = 'cyr_to_lat')
    4350    {
  • serbian-transliteration/trunk/classes/maps/bg_BG.php

    r3269990 r3307894  
    3535    ];
    3636
     37    /**
     38     * Transliterate text between Cyrillic and Latin.
     39     *
     40     * @param mixed $content String to transliterate.
     41     * @param string $translation Conversion direction.
     42     * @return mixed
     43     */
    3744    public static function transliterate($content, $translation = 'cyr_to_lat')
    3845    {
  • serbian-transliteration/trunk/classes/maps/bs_BA.php

    r3269990 r3307894  
    4545    ];
    4646
     47    /**
     48     * Transliterate text between Cyrillic and Latin.
     49     *
     50     * @param mixed $content String to transliterate.
     51     * @param string $translation Conversion direction.
     52     * @return mixed
     53     */
    4754    public static function transliterate($content, $translation = 'cyr_to_lat')
    4855    {
  • serbian-transliteration/trunk/classes/maps/cnr.php

    r3269990 r3307894  
    4747    ];
    4848
     49    /**
     50     * Transliterate text between Cyrillic and Latin.
     51     *
     52     * @param mixed $content String to transliterate.
     53     * @param string $translation Conversion direction.
     54     * @return mixed
     55     */
    4956    public static function transliterate($content, $translation = 'cyr_to_lat')
    5057    {
  • serbian-transliteration/trunk/classes/maps/el.php

    r3269990 r3307894  
    3939    ];
    4040
     41    /**
     42     * Transliterate text between Cyrillic and Latin.
     43     *
     44     * @param mixed $content String to transliterate.
     45     * @param string $translation Conversion direction.
     46     * @return mixed
     47     */
    4148    public static function transliterate($content, $translation = 'cyr_to_lat')
    4249    {
  • serbian-transliteration/trunk/classes/maps/hy.php

    r3269990 r3307894  
    3434    ];
    3535
     36    /**
     37     * Transliterate text between Cyrillic and Latin.
     38     *
     39     * @param mixed $content String to transliterate.
     40     * @param string $translation Conversion direction.
     41     * @return mixed
     42     */
    3643    public static function transliterate($content, $translation = 'cyr_to_lat')
    3744    {
  • serbian-transliteration/trunk/classes/maps/ka_GE.php

    r3269990 r3307894  
    3131    ];
    3232
     33    /**
     34     * Transliterate text between Cyrillic and Latin.
     35     *
     36     * @param mixed $content String to transliterate.
     37     * @param string $translation Conversion direction.
     38     * @return mixed
     39     */
    3340    public static function transliterate($content, $translation = 'cyr_to_lat')
    3441    {
  • serbian-transliteration/trunk/classes/maps/kir.php

    r3269990 r3307894  
    5454    ];
    5555
     56    /**
     57     * Transliterate text between Cyrillic and Latin.
     58     *
     59     * @param mixed $content String to transliterate.
     60     * @param string $translation Conversion direction.
     61     * @return mixed
     62     */
    5663    public static function transliterate($content, $translation = 'cyr_to_lat')
    5764    {
  • serbian-transliteration/trunk/classes/maps/kk.php

    r3269990 r3307894  
    3939    ];
    4040
     41    /**
     42     * Transliterate text between Cyrillic and Latin.
     43     *
     44     * @param mixed $content String to transliterate.
     45     * @param string $translation Conversion direction.
     46     * @return mixed
     47     */
    4148    public static function transliterate($content, $translation = 'cyr_to_lat')
    4249    {
  • serbian-transliteration/trunk/classes/maps/mk_MK.php

    r3269990 r3307894  
    2727        'в' => 'v',     'Г' => 'G',     'г' => 'g',     'Д' => 'D',     'д' => 'd',
    2828        'Е' => 'E',     'е' => 'e',     'З' => 'Z',     'з' => 'z',     'И' => 'I',
    29         'и' => 'i',     'J' => 'J',     'j' => 'j',     'К' => 'K',     'к' => 'k',
     29        'и' => 'i',     'Ј' => 'J',             'ј' => 'j',     'К' => 'K',     'к' => 'k',
    3030        'Л' => 'L',     'л' => 'l',     'М' => 'M',     'м' => 'm',     'Н' => 'N',
    3131        'н' => 'n',     'О' => 'O',     'о' => 'o',     'П' => 'P',     'п' => 'p',
     
    3535    ];
    3636
     37    /**
     38     * Transliterate text between Cyrillic and Latin.
     39     *
     40     * @param mixed $content String to transliterate.
     41     * @param string $translation Conversion direction.
     42     * @return mixed
     43     */
    3744    public static function transliterate($content, $translation = 'cyr_to_lat')
    3845    {
  • serbian-transliteration/trunk/classes/maps/mn.php

    r3269990 r3307894  
    5454    ];
    5555
     56    /**
     57     * Transliterate text between Cyrillic and Latin.
     58     *
     59     * @param mixed $content String to transliterate.
     60     * @param string $translation Conversion direction.
     61     * @return mixed
     62     */
    5663    public static function transliterate($content, $translation = 'cyr_to_lat')
    5764    {
  • serbian-transliteration/trunk/classes/maps/ru_RU.php

    r3269990 r3307894  
    3535    ];
    3636
     37    /**
     38     * Transliterate text between Cyrillic and Latin.
     39     *
     40     * @param mixed $content String to transliterate.
     41     * @param string $translation Conversion direction.
     42     * @return mixed
     43     */
    3744    public static function transliterate($content, $translation = 'cyr_to_lat')
    3845    {
  • serbian-transliteration/trunk/classes/maps/sr_RS.php

    r3269990 r3307894  
    4444    ];
    4545
     46    /**
     47     * Transliterate text between Cyrillic and Latin.
     48     *
     49     * @param mixed $content String to transliterate.
     50     * @param string $translation Conversion direction.
     51     * @return mixed
     52     */
    4653    public static function transliterate($content, $translation = 'cyr_to_lat')
    4754    {
  • serbian-transliteration/trunk/classes/maps/tg.php

    r3269990 r3307894  
    5252    ];
    5353
     54    /**
     55     * Transliterate text between Cyrillic and Latin.
     56     *
     57     * @param mixed $content String to transliterate.
     58     * @param string $translation Conversion direction.
     59     * @return mixed
     60     */
    5461    public static function transliterate($content, $translation = 'cyr_to_lat')
    5562    {
  • serbian-transliteration/trunk/classes/maps/uk.php

    r3269990 r3307894  
    4242    ];
    4343
     44    /**
     45     * Transliterate text between Cyrillic and Latin.
     46     *
     47     * @param mixed $content String to transliterate.
     48     * @param string $translation Conversion direction.
     49     * @return mixed
     50     */
    4451    public static function transliterate($content, $translation = 'cyr_to_lat')
    4552    {
  • serbian-transliteration/trunk/classes/maps/uz_UZ.php

    r3269990 r3307894  
    5454    ];
    5555
     56    /**
     57     * Transliterate text between Cyrillic and Latin.
     58     *
     59     * @param mixed $content String to transliterate.
     60     * @param string $translation Conversion direction.
     61     * @return mixed
     62     */
    5663    public static function transliterate($content, $translation = 'cyr_to_lat')
    5764    {
  • serbian-transliteration/trunk/classes/mode.php

    r3288639 r3307894  
    104104        }
    105105
    106         if (in_array($this->mode::MODE, ['forced'])) {
    107             return;
    108         }
    109 
    110106        $filters = null;
    111107
     
    118114        // On the frontend enable modes
    119115        else {
     116            if (in_array($this->mode::MODE, ['forced'])) {
     117                return;
     118            }
     119       
    120120            $filters = $this->filters();
    121121        }
  • serbian-transliteration/trunk/classes/plugins.php

    r3269990 r3307894  
    77class Transliteration_Plugins
    88{
     9    /**
     10     * Cached list of active plugin integration classes.
     11     *
     12     * @var array|null
     13     */
     14    private static ?array $cached_classes = null;
     15
    916    public function __construct()
    1017    {
     
    1219    }
    1320
     21    /**
     22     * Discover active plugin integration classes.
     23     * Results are cached for subsequent calls within the request.
     24     */
    1425    public function plugin_classes()
    1526    {
     27        if (self::$cached_classes !== null) {
     28            return self::$cached_classes;
     29        }
     30
    1631        // Get the list of active plugins
    1732        $active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
     
    3752        }
    3853
    39         // FIlter all classes
     54        // Filter all classes
    4055        $found_classes = apply_filters('rstr_active_plugin_classes', $found_classes, $active_plugins);
    4156
    42         return $found_classes;
     57        return self::$cached_classes = $found_classes;
    4358    }
    4459
     
    5974        }
    6075    }
     76
     77    /**
     78     * Reset cached plugin classes.
     79     */
     80    public static function clear_cache(): void
     81    {
     82        self::$cached_classes = null;
     83    }
    6184}
  • serbian-transliteration/trunk/classes/settings-fields.php

    r3269990 r3307894  
    329329
    330330        add_settings_field(
    331             'parameter-url-selector', // ID
     331            'url-selector', // ID
    332332            __('Parameter URL selector', 'serbian-transliteration'), // Title
    333333            [$this, 'parameter_url_selector_callback'], // Callback
     
    366366
    367367            add_settings_field(
    368                 'enable-body-class-' . $locale, // ID
     368                'disable-by-language-' . $locale, // ID
    369369                $language_name, // Title
    370370                [$this, 'exclude_language_callback'], // Callback
     
    10441044    }
    10451045
    1046     public function exclude_language_callback(array $attr): void
     1046    public function exclude_language_callback(array $attr=[]): void
    10471047    {
    10481048        foreach ([
  • serbian-transliteration/trunk/classes/settings.php

    r3269990 r3307894  
    321321        <div class="inner-sidebar">
    322322            <div id="side-sortables" class="meta-box-sortables">
    323                 <?php
    324                     do_action('transliteration-settings-before-sidebar', 'general', $this);
    325         do_meta_boxes('transliteration-settings', 'side', null);
    326         do_action('transliteration-settings-after-sidebar', 'general', $this);
    327         ?>
     323            <?php
     324                // Hook triggered before settings sidebar
     325                do_action('transliteration-settings-before-sidebar', 'general', $this);
     326                do_meta_boxes('transliteration-settings', 'side', null);
     327                // Hook triggered after settings sidebar
     328                do_action('transliteration-settings-after-sidebar', 'general', $this);
     329            ?>
    328330            </div>
    329331        </div>
     
    332334                <form method="post" action="options.php">
    333335                    <?php
    334             settings_fields('transliteration-group');
    335         do_settings_sections('serbian-transliteration');
    336         submit_button(
    337             __('Save Changes'),
    338             'primary',
    339             'trasnliteration_settings_save_changes_1',
    340             false,
    341             ['id' => 'trasnliteration_settings_submit_button_1']
    342         ); ?>
     336                        settings_fields('transliteration-group');
     337                        do_settings_sections('serbian-transliteration');
     338                        submit_button(
     339                            __('Save Changes'),
     340                            'primary',
     341                            'trasnliteration_settings_save_changes_1',
     342                            false,
     343                            ['id' => 'trasnliteration_settings_submit_button_1']
     344                        );
     345                    ?>
    343346                    <div id="trasnliteration_settings_submit_button_float">
    344347                        <?php submit_button(
     
    395398            <div id="side-sortables" class="meta-box-sortables">
    396399                <?php
     400// Hook triggered before settings sidebar
    397401                    do_action('transliteration-settings-before-sidebar', 'shortcodes', $this);
    398402        do_meta_boxes('transliteration-settings', 'side', null);
     403// Hook triggered after settings sidebar
    399404        do_action('transliteration-settings-after-sidebar', 'shortcodes', $this);
    400405        ?>
     
    431436            <div id="side-sortables" class="meta-box-sortables">
    432437                <?php
     438// Hook triggered before settings sidebar
    433439                    do_action('transliteration-settings-before-sidebar', 'functions', $this);
    434440        do_meta_boxes('transliteration-settings', 'side', null);
     441// Hook triggered after settings sidebar
    435442        do_action('transliteration-settings-after-sidebar', 'functions', $this);
    436443        ?>
     
    467474            <div id="side-sortables" class="meta-box-sortables">
    468475                <?php
     476// Hook triggered before settings sidebar
    469477                    do_action('transliteration-settings-before-sidebar', 'tags', $this);
    470478        do_meta_boxes('transliteration-settings', 'side', null);
     479// Hook triggered after settings sidebar
    471480        do_action('transliteration-settings-after-sidebar', 'tags', $this);
    472481        ?>
     
    512521            <div id="side-sortables" class="meta-box-sortables">
    513522                <?php
     523// Hook triggered before settings sidebar
    514524                    do_action('transliteration-settings-before-sidebar', 'transliteration', $this);
    515525        do_meta_boxes('transliteration-tools', 'side', null);
     526// Hook triggered after settings sidebar
    516527        do_action('transliteration-settings-after-sidebar', 'transliteration', $this);
    517528        ?>
     
    541552            <div id="side-sortables" class="meta-box-sortables">
    542553                <?php
     554// Hook triggered before settings sidebar
    543555                    do_action('transliteration-settings-before-sidebar', 'permalinks', $this);
    544556        do_meta_boxes('transliteration-tools', 'side', null);
     557// Hook triggered after settings sidebar
    545558        do_action('transliteration-settings-after-sidebar', 'permalinks', $this);
    546559        ?>
     
    577590            <div id="side-sortables" class="meta-box-sortables">
    578591                <?php
     592// Hook triggered before settings sidebar
    579593                    do_action('transliteration-settings-before-sidebar', 'debug', $this);
    580594        do_meta_boxes('transliteration-settings', 'side', null);
     595// Hook triggered after settings sidebar
    581596        do_action('transliteration-settings-after-sidebar', 'debug', $this);
    582597        ?>
     
    605620            <div id="side-sortables" class="meta-box-sortables">
    606621                <?php
     622// Hook triggered before settings sidebar
    607623                    do_action('transliteration-settings-before-sidebar', 'credits', $this);
    608624        do_meta_boxes('transliteration-credits', 'side', null);
     625// Hook triggered after settings sidebar
    609626        do_action('transliteration-settings-after-sidebar', 'credits', $this);
    610627        ?>
  • serbian-transliteration/trunk/classes/settings/page-debug.php

    r3269990 r3307894  
    33}
    44$activations = get_option(RSTR_NAME . '-activation');
    5 $options     = get_rstr_option();
    65?><br>
    76<table class="table table-sm table-striped w-100">
     7<?php // Hook to extend debug table header ?>
    88    <thead><?php do_action('rstr/settings/debug/table/thead'); ?></thead>
     9<?php // Hook before first debug table row ?>
    910    <tbody>
    1011        <?php do_action('rstr/settings/debug/table/tbody/start'); ?>
     
    111112        <tr>
    112113            <td><strong><?php esc_html_e('Plugin directory path', 'serbian-transliteration'); ?></strong></td>
     114<?php // Hook after last debug table row ?>
    113115            <td><?php echo RSTR_ROOT; ?></td>
     116<?php // Hook to extend debug table footer ?>
    114117        </tr>
    115118        <?php do_action('rstr/settings/debug/table/tbody/end'); ?>
     
    121124    <button class="accordion-link" type="button"><?php esc_html_e('Plugin settings', 'serbian-transliteration'); ?></button>
    122125    <div class="accordion-panel" style="padding:0;">
    123         <table class="rstr-debug-table" style="width:100%; max-width:100%; text-align:left; border-collapse: collapse">
    124             <tr>
    125                 <th style="width:35%;min-width: 165px;border: 1px solid #efefef; padding: 8px;"><?php esc_html_e('Option name', 'serbian-transliteration'); ?></th>
    126                 <th style="border: 1px solid #efefef; padding: 8px;"><?php esc_html_e('Value', 'serbian-transliteration'); ?></th>
    127             </tr>
    128             <?php foreach ($options as $key => $val) : ?>
    129             <tr>
    130                 <td style="font-weight: 600; border: 1px solid #efefef; padding: 8px;"><?php echo esc_html($key); ?></td>
    131                 <td style="border: 1px solid #efefef; padding: <?php echo esc_html(is_array($val) ? 0 : 8); ?>px;">
    132                 <?php if (is_array($val)) : ?>
    133                     <table class="rstr-debug-table-iner" style="width:100%; max-width:100%; text-align:left; padding:0; margin:0; border-collapse: collapse;">
    134                         <tr>
    135                             <th style="width:50%;border: 1px solid #efefef; padding: 8px;"><?php esc_html_e('Key', 'serbian-transliteration'); ?></th>
    136                             <th style="border: 1px solid #efefef; padding: 8px;"><?php esc_html_e('Value', 'serbian-transliteration'); ?></th>
    137                         </tr>
    138                         <?php foreach ($val as $i => $prop) : ?>
    139                         <tr>
    140                             <td style="border: 1px solid #efefef; padding: 8px;"><?php echo esc_html($i); ?></td>
    141                             <td style="border: 1px solid #efefef; padding: 8px;"><?php echo esc_html($prop); ?></td>
    142                         </tr>
    143                         <?php endforeach; ?>
    144                     </table>
    145                 <?php else: ?>
    146                     <?php echo esc_html($val); ?>
    147                 <?php endif; ?>
    148                 </td>
    149             </tr>
    150             <?php endforeach; ?>
    151         </table>
     126        <?php Transliteration_Utilities::debug_render_all_settings_fields('html'); ?>
    152127    </div>
    153128</div>
  • serbian-transliteration/trunk/classes/utilities.php

    r3288639 r3307894  
    1212     * Registered languages
    1313     * @since     1.4.3
    14      * @verson    1.0.0
     14     * @version   1.0.0
    1515     * @author    Ivijan-Stefan Stipic
    1616     */
     
    468468            $wpdb->query(sprintf("DELETE FROM `%s` WHERE `%s`.`option_name` REGEXP '^_transient_(.*)?%s(.*|\$)'", $wpdb->options, $wpdb->options, $RSTR_NAME));
    469469        }
     470
     471        if (class_exists('Transliteration_Plugins')) {
     472            Transliteration_Plugins::clear_cache();
     473        }
    470474    }
    471475
     
    473477     * Set cookie
    474478     * @since     1.0.10
    475      * @verson    1.0.0
     479     * @version   1.0.0
    476480    */
    477481    public static function setcookie($val, $expire = null): bool
     
    501505     * Get current script
    502506     * @since     1.0.10
    503      * @verson    1.0.0
     507     * @version   1.0.0
    504508     */
    505509    public static function get_current_script()
     
    524528    /*
    525529     * Flush Cache
    526      * @verson    1.0.1
     530     * @version   1.0.1
    527531     */
    528532    protected static $cache_flush = false;
     
    754758
    755759            // Check for specific editors and set the cache if true
    756             if (self::is_elementor_editor() || self::is_oxygen_editor()) {
     760            if (
     761                self::is_elementor_editor() ||
     762                self::is_oxygen_editor() ||
     763                self::is_wpbakery_editor()
     764            ) {
    757765                return true;
    758766            }
     
    781789    /*
    782790     * Check is in the Elementor editor mode
    783      * @verson    1.0.0
     791     * @version   1.0.0
    784792     */
    785793    public static function is_elementor_editor()
     
    806814    /*
    807815     * Check is in the Elementor preview mode
    808      * @verson    1.0.0
     816     * @version   1.0.0
    809817     */
    810818    public static function is_elementor_preview()
     
    833841    /*
    834842     * Check is in the Oxygen editor mode
    835      * @verson    1.0.0
     843     * @version   1.0.0
    836844     */
    837845    public static function is_oxygen_editor()
    838846    {
    839847        return self::cached_static('is_oxygen_editor', fn (): bool => self::is_plugin_active('oxygen/functions.php') && (($_REQUEST['ct_builder'] ?? null) == 'true' || ($_REQUEST['ct_inner'] ?? null) == 'true' || preg_match('/^((ct_|oxy_)(.*?))$/i', ($_REQUEST['action'] ?? ''))));
     848    }
     849
     850    /*
     851     * Check is in the WPBakery editor mode
     852     * @version   1.0.0
     853     */
     854    public static function is_wpbakery_editor()
     855    {
     856        return self::cached_static('is_wpbakery_editor', function (): bool {
     857            if (
     858                self::is_plugin_active('js_composer/js_composer.php') && (
     859                    (!empty($_GET['vc_editable']) && $_GET['vc_editable'] === 'true') ||
     860                    (!empty($_GET['vc_action']) && $_GET['vc_action'] === 'vc_inline') ||
     861                    (function_exists('vc_is_inline') && vc_is_inline())
     862                )
     863            ) {
     864                return true;
     865            }
     866
     867            return false;
     868        });
    840869    }
    841870
     
    895924     * PHP Wrapper for explode — Split a string by a string
    896925     * @since     1.0.9
    897      * @verson    1.0.0
     926     * @version   1.0.0
    898927     * @url       https://www.php.net/manual/en/function.explode.php
    899928     */
     
    10541083    */
    10551084    public static function normalize_latin_string($str)
    1056     {
    1057 
    1058         $map = apply_filters('rstr/utilities/normalize_latin_string', RSTR_NORMALIZE_LATIN_STRING_MAP, $str);
    1059 
    1060         $str = strtr($str, $map);
    1061 
    1062         if (function_exists('remove_accents')) {
    1063             return remove_accents($str);
    1064         }
    1065 
    1066         return $str;
    1067     }
     1085    {
     1086        // Step 1: Transliterate using WP native
     1087        if (function_exists('remove_accents')) {
     1088            $str = remove_accents($str);
     1089        }
     1090
     1091        // Step 2: Apply custom Unicode symbol map
     1092        $map = apply_filters('rstr/utilities/normalize_latin_string', RSTR_NORMALIZE_LATIN_STRING_MAP, $str);
     1093
     1094        // Step 3: Lazy translations
     1095        $placeholders = [
     1096            '%%degrees%%'         => __(' degrees ', 'serbian-transliteration'),
     1097            '%%divided_by%%'      => __(' divided by ', 'serbian-transliteration'),
     1098            '%%times%%'           => __(' times ', 'serbian-transliteration'),
     1099            '%%plus_minus%%'      => __(' plus-minus ', 'serbian-transliteration'),
     1100            '%%square_root%%'     => __(' square root ', 'serbian-transliteration'),
     1101            '%%infinity%%'        => __(' infinity ', 'serbian-transliteration'),
     1102            '%%almost_equal%%'    => __(' almost equal to ', 'serbian-transliteration'),
     1103            '%%not_equal%%'       => __(' not equal to ', 'serbian-transliteration'),
     1104            '%%identical%%'       => __(' identical to ', 'serbian-transliteration'),
     1105            '%%less_equal%%'      => __(' less than or equal to ', 'serbian-transliteration'),
     1106            '%%greater_equal%%'   => __(' greater than or equal to ', 'serbian-transliteration'),
     1107            '%%left%%'            => __(' left ', 'serbian-transliteration'),
     1108            '%%right%%'           => __(' right ', 'serbian-transliteration'),
     1109            '%%up%%'              => __(' up ', 'serbian-transliteration'),
     1110            '%%down%%'            => __(' down ', 'serbian-transliteration'),
     1111            '%%left_right%%'      => __(' left and right ', 'serbian-transliteration'),
     1112            '%%up_down%%'         => __(' up and down ', 'serbian-transliteration'),
     1113            '%%care_of%%'         => __(' care of ', 'serbian-transliteration'),
     1114            '%%estimated%%'       => __(' estimated ', 'serbian-transliteration'),
     1115            '%%ohm%%'             => __(' ohm ', 'serbian-transliteration'),
     1116            '%%female%%'          => __(' female ', 'serbian-transliteration'),
     1117            '%%male%%'            => __(' male ', 'serbian-transliteration'),
     1118            '%%copyright%%'       => __(' Copyright ', 'serbian-transliteration'),
     1119            '%%registered%%'      => __(' Registered ', 'serbian-transliteration'),
     1120            '%%trademark%%'       => __(' Trademark ', 'serbian-transliteration'),
     1121            '%%latin%%'           => __('Latin', 'serbian-transliteration'),
     1122            '%%cyrillic%%'        => __('Cyrillic', 'serbian-transliteration'),
     1123        ];
     1124
     1125        // Replace placeholders with translated strings
     1126        $map = array_map(function ($value) use ($placeholders) {
     1127            return $placeholders[$value] ?? $value;
     1128        }, $map);
     1129
     1130        // Final string replacement
     1131        return strtr($str, $map);
     1132    }
    10681133
    10691134    /*
     
    13221387        return self::cached_static('litespeed_is_cachable', fn (): bool => defined('LSCACHE_ENABLED') && LSCACHE_ENABLED && function_exists('litespeed_is_cachable') && litespeed_is_cachable());
    13231388    }
     1389   
     1390    /*
     1391     * Return plugin settings in debug format
     1392     */
     1393    public static function debug_render_all_settings_fields($format = 'html')
     1394    {
     1395        $page = 'serbian-transliteration';
     1396
     1397        global $wp_settings_fields;
     1398
     1399        if (!isset($wp_settings_fields[$page])) {
     1400            if ($format === 'html') {
     1401                echo '<p>No settings fields registered on this page.</p>';
     1402            } else {
     1403                return ($format === 'json') ? json_encode([]) : serialize([]);
     1404            }
     1405            return;
     1406        }
     1407
     1408        $disable_by_language = [];
     1409        foreach ($wp_settings_fields[$page] as $section => $fields) {
     1410            foreach ($fields as $id => $field) {
     1411                if (strpos($id, 'disable-by-language-') !== false) {
     1412                    $disable_by_language = get_rstr_option('disable-by-language');
     1413                    break;
     1414                }
     1415            }
     1416        }
     1417
     1418        $data = [];
     1419        $e = 0;
     1420
     1421        foreach ($wp_settings_fields[$page] as $section => $fields) {
     1422            foreach ($fields as $id => $field) {
     1423                if (strpos($id, 'disable-by-language-') !== false) {
     1424                    if ($e === 1) {
     1425                        continue;
     1426                    }
     1427                    $label = __('Exclusion', 'serbian-transliteration');
     1428                    $val = $disable_by_language;
     1429                    ++$e;
     1430                } else {
     1431                    $label = $field['title'] ?? $id;
     1432                    $val = get_rstr_option($id);
     1433                }
     1434                $data[] = ['label' => $label, 'value' => $val];
     1435            }
     1436        }
     1437
     1438        if ($format === 'json') {
     1439            return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
     1440        }
     1441
     1442        if ($format === 'serialize') {
     1443            return serialize($data);
     1444        }
     1445
     1446        // Default: HTML table output
     1447        echo '<table class="rstr-debug-table" style="width:100%; max-width:100%; text-align:left; border-collapse: collapse">';
     1448        echo '<tr>
     1449            <th style="width:35%;min-width:165px;border:1px solid #efefef;padding:8px;">' . esc_html__('Option name', 'serbian-transliteration') . '</th>
     1450            <th style="border:1px solid #efefef;padding:8px;">' . esc_html__('Value', 'serbian-transliteration') . '</th>
     1451        </tr>';
     1452
     1453        foreach ($data as $row) {
     1454            $label = $row['label'];
     1455            $val = $row['value'];
     1456
     1457            echo '<tr>';
     1458            echo '<td style="font-weight:600;border:1px solid #efefef;padding:8px;">' . esc_html($label) . '</td>';
     1459            echo '<td style="border:1px solid #efefef;padding:' . esc_html(is_array($val) ? 0 : 8) . 'px;">';
     1460
     1461            if (is_array($val)) {
     1462                echo '<table class="rstr-debug-table-iner" style="width:100%;text-align:left;border-collapse:collapse;">';
     1463                echo '<tr><th style="width:50%;border:1px solid #efefef;padding:8px;">' . esc_html__('Key', 'serbian-transliteration') . '</th>';
     1464                echo '<th style="border:1px solid #efefef;padding:8px;">' . esc_html__('Value', 'serbian-transliteration') . '</th></tr>';
     1465                foreach ($val as $i => $prop) {
     1466                    echo '<tr>';
     1467                    echo '<td style="border:1px solid #efefef;padding:8px;">' . esc_html($i) . '</td>';
     1468                    echo '<td style="border:1px solid #efefef;padding:8px;">' . esc_html($prop) . '</td>';
     1469                    echo '</tr>';
     1470                }
     1471                echo '</table>';
     1472            } else {
     1473                echo esc_html($val);
     1474            }
     1475
     1476            echo '</td>';
     1477            echo '</tr>';
     1478        }
     1479
     1480        echo '</table>';
     1481    }
     1482
    13241483}
  • serbian-transliteration/trunk/classes/wp-cli.php

    r3269990 r3307894  
    88 * WP-CLI Helpers
    99 * @since     1.4.3
    10  * @verson    1.0.1
     10 * @version   1.0.1
    1111 * @author    Ivijan-Stefan Stipic
    1212 */
  • serbian-transliteration/trunk/constants.php

    r3252345 r3307894  
    11<?php if ( !defined('WPINC') ) die();
    22
    3 // Find wp-admin file path
     3/**
     4 * Absolute path to the wp-admin directory.
     5 */
    46if (!defined('WP_ADMIN_DIR')) {
    57    // Default wp-admin directory
     
    1618}
    1719
    18 // Include Dependency
     20/**
     21 * Include plugin dependencies when plugin.php is accessible.
     22 */
    1923$include_dependency = false;
    2024if (!function_exists('is_plugin_active_for_network') || !function_exists('is_plugin_active')) {
     
    2832 * Main plugin constants
    2933 * @since     1.0.0
    30  * @verson    1.0.0
     34 * @version   1.0.0
    3135*/
    3236
    33 // Plugin basename
     37/** Plugin basename used for activation checks. */
    3438if (!defined('RSTR_BASENAME')) {
    3539    define('RSTR_BASENAME', plugin_basename(RSTR_FILE));
    3640}
    37 // Plugin root
     41/** Absolute path to the plugin root directory. */
    3842if (!defined('RSTR_ROOT')) {
    3943    define('RSTR_ROOT', rtrim(plugin_dir_path(RSTR_FILE) , '/'));
    4044}
    41 // Plugin URL root
     45/** Base URL to the plugin directory. */
    4246if (!defined('RSTR_URL')) {
    4347    define('RSTR_URL', rtrim(plugin_dir_url(RSTR_FILE) , '/'));
    4448}
    45 // Assets URL
     49/** URL to plugin assets directory. */
    4650if (!defined('RSTR_ASSETS')) {
    4751    define('RSTR_ASSETS', RSTR_URL . '/assets');
    4852}
    49 // Classes
     53/** Directory containing plugin classes. */
    5054if (!defined('RSTR_CLASSES')) {
    5155    define('RSTR_CLASSES', RSTR_ROOT . '/classes');
    5256}
    53 // Plugin name
     57/** Option name used for storing plugin settings. */
    5458if (!defined('RSTR_NAME')) {
    5559    define('RSTR_NAME', 'serbian-transliteration');
    5660}
    57 // Plugin table
     61/** Database table slug for plugin tables. */
    5862if (!defined('RSTR_TABLE')) {
    5963    define('RSTR_TABLE', 'serbian_transliteration');
    6064}
    6165
    62 // Current plugin version ( if change, clear also session cache )
     66/** Plugin version derived from the header comment. */
    6367if (function_exists('get_file_data') && $plugin_data = get_file_data(RSTR_FILE, array(
    6468    'Version' => 'Version'
     
    7478    define('RSTR_VERSION', $rstr_version);
    7579}
    76 // Plugin session prefix (controlled by version)
     80/** Prefix used for transients and cache entries. */
    7781if (!defined('RSTR_PREFIX')) {
    7882    define('RSTR_PREFIX', RSTR_TABLE . '_' . preg_replace("~[^0-9]~Ui", '', RSTR_VERSION) . '_');
    7983}
    80 // Is multisite
     84/** True when plugin is network activated. */
    8185if (!defined('RSTR_MULTISITE')) {
    8286    define('RSTR_MULTISITE', function_exists('is_plugin_active_for_network') ? is_plugin_active_for_network(RSTR_BASENAME) : false);
    8387}
    84 if (!defined('RSTR_MULTISITE')) {
    85     define('RSTR_MULTISITE', false);
    86 }
    8788
    88 // Is Woocommerce exists
     89/** Indicates whether WooCommerce is active. */
    8990if (!defined('RSTR_WOOCOMMERCE')) {
    9091    define('RSTR_WOOCOMMERCE', (function_exists('is_plugin_active') ? is_plugin_active('woocommerce/woocommerce.php') : false));
    9192}
    9293
    93 // Normalize Latin String map
     94/** Mapping of Unicode characters to ASCII equivalents. */
    9495if (!defined('RSTR_NORMALIZE_LATIN_STRING_MAP')) {
    9596    define('RSTR_NORMALIZE_LATIN_STRING_MAP', array(
     
    165166        'ხ' => 'kh', 'Ხ' => 'Kh', 'ჯ' => 'j', 'Ჯ' => 'J', 'ჰ' => 'h', 'Ჰ' => 'H',
    166167
    167         '“'=>'"', '”'=>'"', '‘'=>"'", '’'=>"'", '•'=>'-', '…'=>'...', '—'=>'-', '–'=>'-', '¿'=>'?', '¡'=>'!', '°'=>__(' degrees ', 'serbian-transliteration'),
     168        '“'=>'"', '”'=>'"', '‘'=>"'", '’'=>"'", '•'=>'-', '…'=>'...', '—'=>'-', '–'=>'-', '¿'=>'?', '¡'=>'!',
     169        '°'=>'%%degrees%%',
    168170        '¼'=>' 1/4 ', '½'=>' 1/2 ', '¾'=>' 3/4 ', '⅓'=>' 1/3 ', '⅔'=>' 2/3 ', '⅛'=>' 1/8 ', '⅜'=>' 3/8 ', '⅝'=>' 5/8 ', '⅞'=>' 7/8 ',
    169         '÷'=>__(' divided by ', 'serbian-transliteration'), '×'=>__(' times ', 'serbian-transliteration'), '±'=>__(' plus-minus ', 'serbian-transliteration'), '√'=>__(' square root ', 'serbian-transliteration'),
    170         '∞'=>__(' infinity ', 'serbian-transliteration'), '≈'=>__(' almost equal to ', 'serbian-transliteration'), '≠'=>__(' not equal to ', 'serbian-transliteration'),
    171         '≡'=>__(' identical to ', 'serbian-transliteration'), '≤'=>__(' less than or equal to ', 'serbian-transliteration'), '≥'=>__(' greater than or equal to ', 'serbian-transliteration'),
    172         '←'=>__(' left ', 'serbian-transliteration'), '→'=>__(' right ', 'serbian-transliteration'), '↑'=>__(' up ', 'serbian-transliteration'), '↓'=>__(' down ', 'serbian-transliteration'),
    173         '↔'=>__(' left and right ', 'serbian-transliteration'), '↕'=>__(' up and down ', 'serbian-transliteration'), '℅'=>__(' care of ', 'serbian-transliteration'),
    174         '℮' => __(' estimated ', 'serbian-transliteration'), 'Ω'=>__(' ohm ', 'serbian-transliteration'), '♀'=>__(' female ', 'serbian-transliteration'), '♂'=>__(' male ', 'serbian-transliteration'),
    175         '©'=>__(' Copyright ', 'serbian-transliteration'), '®'=>__(' Registered ', 'serbian-transliteration'), '™' =>__(' Trademark ', 'serbian-transliteration'),
     171        '÷'=>'%%divided_by%%', '×'=>'%%times%%', '±'=>'%%plus_minus%%', '√'=>'%%square_root%%',
     172        '∞'=>'%%infinity%%', '≈'=>'%%almost_equal%%', '≠'=>'%%not_equal%%',
     173        '≡'=>'%%identical%%', '≤'=>'%%less_equal%%', '≥'=>'%%greater_equal%%',
     174        '←'=>'%%left%%', '→'=>'%%right%%', '↑'=>'%%up%%', '↓'=>'%%down%%',
     175        '↔'=>'%%left_right%%', '↕'=>'%%up_down%%', '℅'=>'%%care_of%%',
     176        '℮'=>'%%estimated%%', 'Ω'=>'%%ohm%%', '♀'=>'%%female%%', '♂'=>'%%male%%',
     177        '©'=>'%%copyright%%', '®'=>'%%registered%%', '™'=>'%%trademark%%',
    176178    ));
    177179}
  • serbian-transliteration/trunk/readme.txt

    r3304466 r3307894  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.3.2
     7Stable tag: 2.3.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    109109
    110110== Changelog ==
     111
     112= 2.3.3 =
     113* Fixed domain was triggered too early
     114* Fixed admin transliteration
     115* Improved debugging
     116* Added transliteration for js-composer
     117* Improved plugin speed
     118* Improved PHP code
     119* Improved transliterations
    111120
    112121= 2.3.2 =
     
    248257
    249258== Upgrade Notice ==
     259
     260= 2.3.3 =
     261* Fixed domain was triggered too early
     262* Fixed admin transliteration
     263* Improved debugging
     264* Added transliteration for js-composer
     265* Improved plugin speed
     266* Improved PHP code
     267* Improved transliterations
    250268
    251269= 2.3.2 =
  • serbian-transliteration/trunk/serbian-transliteration.php

    r3288639 r3307894  
    66 * Plugin URI:        https://wordpress.org/plugins/serbian-transliteration/
    77 * Description:       All-in-one Cyrillic to Latin transliteration plugin for WordPress that actually works.
    8  * Version:           2.3.2
     8 * Version:           2.3.3
    99 * Requires at least: 5.4
    1010 * Tested up to:      6.8
     
    8181 * Main plugin constants
    8282 * @since     1.1.0
    83  * @verson    1.0.0
     83 * @version   1.0.0
    8484 */
    8585// Main plugin file
     
    112112 * Get plugin options
    113113 * @since     1.1.3
    114  * @verson    1.0.0
     114 * @version   1.0.0
    115115 */
    116116if (!function_exists('get_rstr_option')) {
Note: See TracChangeset for help on using the changeset viewer.