Plugin Directory

Changeset 3470689


Ignore:
Timestamp:
02/26/2026 09:11:43 PM (4 weeks ago)
Author:
timwhitlock
Message:

Added code_view setting with x3 levels

Location:
loco-translate/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • loco-translate/trunk/languages/loco-translate.pot

    r3457848 r3470689  
    44"Project-Id-Version: Loco Translate 2.8.2-dev\n"
    55"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/loco-translate/\n"
    6 "POT-Creation-Date: 2026-02-10 10:05+0000\n"
     6"POT-Creation-Date: 2026-02-26 21:11+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    276276msgstr ""
    277277
     278#: tpl/admin/config/settings.php:211
     279msgid "Admins only"
     280msgstr ""
     281
    278282#: src/admin/bundle/BaseController.php:102 tpl/admin/file/conf.php:58
    279283#: tpl/admin/file/move.php:26
     
    300304msgstr ""
    301305
    302 #: src/admin/config/SettingsController.php:66
     306#: src/admin/config/SettingsController.php:66 tpl/admin/config/settings.php:212
    303307msgid "Allow"
    304308msgstr ""
     
    308312msgstr ""
    309313
    310 #: tpl/admin/config/settings.php:216
     314#: tpl/admin/config/settings.php:226
    311315msgid "Allow full access to these roles"
    312316msgstr ""
     
    577581msgstr ""
    578582
    579 #: src/admin/config/SettingsController.php:68
     583#: src/admin/config/SettingsController.php:68 tpl/admin/config/settings.php:210
    580584msgid "Disallow"
    581585msgstr ""
    582586
    583587#: src/admin/file/EditController.php:132 src/admin/file/EditController.php:183
    584 #: src/admin/bundle/LocaleController.php:138 tpl/admin/config/settings.php:234
     588#: src/admin/bundle/LocaleController.php:138 tpl/admin/config/settings.php:244
    585589#: tpl/admin/config/apis.php:167 tpl/admin/config/prefs.php:45
    586590#: tpl/admin/common/inc-fsconn.php:16 tpl/admin/common/inc-fsconn.php:41
     
    10091013msgstr ""
    10101014
    1011 #: tpl/admin/config/settings.php:210
     1015#: tpl/admin/config/settings.php:220
    10121016msgid "Grant access to roles"
    10131017msgstr ""
     
    16281632msgstr ""
    16291633
    1630 #: tpl/admin/config/settings.php:233 tpl/admin/config/apis.php:166
     1634#: tpl/admin/config/settings.php:243 tpl/admin/config/apis.php:166
    16311635#: tpl/admin/config/prefs.php:44
    16321636msgid "Save settings"
     
    17241728#: src/admin/file/BaseController.php:118
    17251729msgid "Source"
     1730msgstr ""
     1731
     1732#: tpl/admin/config/settings.php:207
     1733msgid "Source code viewer access"
    17261734msgstr ""
    17271735
  • loco-translate/trunk/readme.txt

    r3457848 r3470689  
    103103
    104104= 2.8.2 =
     105* Fix for LLMs retaining escaped forward slashes
    105106* Bumped WordPress compatibility to 6.9.1
    106107
  • loco-translate/trunk/src/ajax/FsReferenceController.php

    r3229260 r3470689  
    7878    public function render(){
    7979        $post = $this->validate();
    80        
     80
     81        // enforce code_view access setting before doing anything else
     82        $conf = Loco_data_Settings::get();
     83        $code_view = (int) $conf->code_view;
     84        if( 0 === $code_view ){
     85            throw new Loco_error_Exception('Source code viewer is disabled');
     86        }
     87        if( 1 === $code_view && ! current_user_can('manage_options') ){
     88            throw new Loco_error_Exception('Source code viewer requires administrator privileges');
     89        }
     90
    8191        // at the very least we need a reference to examine
    8292        if( ! $post->has('ref') ){
     
    103113       
    104114        // validate allowed source file types, including custom aliases
    105         $conf = Loco_data_Settings::get();
    106115        $ext = strtolower( $srcfile->extension() );
    107116        $type = $conf->ext2type($ext,'none');
  • loco-translate/trunk/src/data/Settings.php

    r3256049 r3470689  
    2121 * @property bool $jed_clean Whether to clean up redundant JSON files during compilation
    2222 * @property bool $ajax_files Whether to submit PO data as concrete files (requires Blob support in Ajax)
    23  *
     23 * @property int $code_view Access level for source code snippet viewer (0:disabled, 1:admins only, 2:all users)
     24 *
    2425 * @property string $deepl_api_key API key for DeepL Translator
    2526 * @property string $google_api_key API key for Google Translate
     
    3738    /**
    3839     * Global instance of this plugin's settings
    39      * @var Loco_data_Settings
    40      */
    41     private static $current;
     40     */
     41    private static ?Loco_data_Settings $current = null;
    4242
    4343
    4444    /**
    4545     * Available options and their defaults
    46      * @var array
    47      */
    48     private static $defaults =  [
     46     */
     47    private static array $defaults =  [
    4948        'version' => '',
    5049        'gen_hash' => false,
     
    6564        'jed_clean' => false,
    6665        'ajax_files' => true,
     66        'code_view' => 1,
    6767        'deepl_api_key' => '',
    6868        'google_api_key' => '',
  • loco-translate/trunk/tpl/admin/config/settings.php

    r3050582 r3470689  
    203203                                </select>
    204204                            </p>
     205                            <p>
     206                                <label for="loco--code-view">
     207                                    <?php esc_html_e('Source code viewer access','loco-translate');?>:
     208                                </label>
     209                                <select name="opts[code_view]" id="loco--code-view">
     210                                    <option value="0"><?php esc_html_e('Disallow','loco-translate')?></option>
     211                                    <option value="1"<?php echo 1 === $opts->code_view?' selected':''?>><?php esc_html_e('Admins only','loco-translate')?></option>
     212                                    <option value="2"<?php echo 2 === $opts->code_view?' selected':''?>><?php esc_html_e('Allow','loco-translate')?></option>
     213                                </select>
     214                            </p>
    205215                        </fieldset>
    206216                    </td>
Note: See TracChangeset for help on using the changeset viewer.