feat:3.0.0版初次提交,新版将完全推倒重写

This commit is contained in:
sunxiyuan 2020-07-13 18:44:03 +08:00
parent e556c4b6d9
commit 39735249ee
293 changed files with 26908 additions and 475 deletions

View file

@ -0,0 +1,102 @@
<?php
/**
* API keys/settings screen
*/
$this->extend('../layout');
/* @var Loco_mvc_ViewParams[] $apis */
/* @var Loco_mvc_ViewParams $nonce */
$help = apply_filters('loco_external','https://localise.biz/wordpress/plugin/manual/providers');
?>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="<?php $nonce->e('name')?>" value="<?php $nonce->e('value')?>" />
<table class="form-table">
<tbody><?php
// GOOGLE
$api = $apis['google']?>
<tr>
<th scope="row"><?php $api->e('name')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e(__('API key','loco-translate'))?></span>
</legend>
<p>
<label for="loco--google_api_key">
<?php esc_html_e(__('API key','loco-translate'))?>:
</label>
<input type="text" size="50" name="api[google][key]" id="loco--google_api_key" value="<?php $api->e('key')?>" spellcheck="false" />
</p>
<p>
<span class="description"><a href="https://cloud.google.com/translate/" target="_blank" tabindex="-1">https://cloud.google.com/translate</a></span>
</p>
</fieldset>
</td>
</tr><?php
// MICROSOFT
$api = $apis['microsoft']?>
<tr>
<th scope="row"><?php $api->e('name')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e(__('API key','loco-translate'))?></span>
</legend>
<p>
<label for="loco--microsoft_api_key">
<?php esc_html_e(__('API key','loco-translate'))?>:
</label>
<input type="text" size="50" name="api[microsoft][key]" id="loco--microsoft_api_key" value="<?php $api->e('key')?>" spellcheck="false" />
</p>
<p>
<label for="loco--microsoft_api_region">
<?php esc_html_e(__('API region','loco-translate'))?>:
</label>
<input type="text" size="20" name="api[microsoft][region]" id="loco--microsoft_api_region" value="<?php $api->e('region')?>" spellcheck="false" placeholder="global" />
</p>
<p>
<span class="description"><a href="https://aka.ms/MicrosoftTranslator" target="_blank" tabindex="-1">https://aka.ms/MicrosoftTranslator</a></span>
</p>
</fieldset>
</td>
</tr><?php
// YANDEX
$api = $apis['yandex']?>
<tr>
<th scope="row"><?php $api->e('name')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e(__('API key','loco-translate'))?></span>
</legend>
<p>
<label for="loco--yandex_api_key">
<?php esc_html_e(__('API key','loco-translate'))?>:
</label>
<input type="text" size="90" name="api[yandex][key]" id="loco--yandex_api_key" value="<?php $api->e('key')?>" spellcheck="false" />
</p>
<p>
<span class="description"><a href="https://tech.yandex.com/translate/" target="_blank" tabindex="-1">https://tech.yandex.com/translate/</a></span>
</p>
</fieldset>
</td>
</tr>
</tbody>
</table>
<div class="notice inline">
<p>
<strong class="has-icon"><?php esc_html_e('Important','loco-translate')?>:</strong>
<span>
<?php esc_html_e('Third party services are subject to their own terms of use and may incur costs from the provider','loco-translate')?>.
<a href="<?php self::e($help)?>#legal" target="_blank" tabindex="-1"><?php esc_html_e('See full disclaimer','loco-translate')?></a>.
</span>
</p>
</div>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_html_e('Save settings','loco-translate')?>" />
<a class="button button-link" href="<?php self::e($help)?>" target="_blank"><?php esc_html_e('Documentation','loco-translate')?></a>
</p>
</form>

View file

@ -0,0 +1,123 @@
<?php
/**
* System diagnostics
*/
$this->extend('../layout');
?>
<div class="panel" id="loco-versions">
<h3>
Versions
<a href="#loco-versions" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl><?php
foreach( $versions as $key => $value ): if( $value ):?>
<dt>
<?php echo $versions->escape($key)?>:
</dt>
<dd>
<code class="path"><?php $versions->e($key)?></code>
</dd><?php
endif; endforeach?>
</dl>
</div>
<div class="panel" id="loco-unicode">
<h3>
Unicode
<a href="#loco-unicode" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl>
<dt>UTF-8 rendering:</dt>
<dd><?php echo $encoding->OK?> <span id="loco-utf8-check"><?php echo $encoding->tick?></span></dd>
<dt>Multibyte support:</dt>
<dd><?php echo $encoding->mbstring?></dd>
</dl>
</div>
<div class="panel" id="loco-ajax">
<h3>
Ajax
<a href="#loco-ajax" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl>
<dt>Endpoint:</dt>
<dd><code id="loco-ajax-url" class="path">/wp-admin/admin-ajax.php</code></dd>
<dt>JSON decoding:</dt>
<dd><?php echo $encoding->json?></dd>
<dt class="jsonly">Ajax test result:</dt>
<dd class="jsonly" id="loco-ajax-check"><span class="inline-spinner"> </span></dd>
</dl>
</div>
<div class="panel" id="loco-apis">
<h3>
Translation APIs
<a href="#loco-apis" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl><?php
/* @var Loco_mvc_ViewParams[] $apis */
foreach( $apis as $api ):?>
<dt><?php $api->e('name')?>:</dt>
<dd class="jsonly" id="loco-api-<?php $api->e('id')?>"><span class="inline-spinner"> </span></dd><?php
endforeach?>
</dl>
</div>
<div class="panel" id="loco-sizes">
<h3>
Limits
<a href="#loco-sizes" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl><?php
foreach( $memory as $key => $value ):?>
<dt>
<?php echo $memory->escape($key)?>:
</dt>
<dd>
<?php $memory->e($key)?>
</dd><?php
endforeach?>
</dl>
</div>
<div class="panel" id="loco-files">
<h3>
Filesystem
<a href="#loco-files" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl>
<dt>Custom languages directory:</dt>
<dd><code class="path"><?php $fs->e('langdir')?></code></dd>
<dt>Directory writable:</dt>
<dd><?php echo $fs->writable?'Yes':'No'?></dd>
<dt>File mods disallowed:</dt>
<dd><?php echo $fs->disabled?'Yes':'No'?></dd>
<dt>File mod safety level:</dt>
<dd><?php $fs->e('fs_protect')?></dd>
</dl>
</div>
<div class="panel" id="loco-debug">
<h3>
Debug settings
<a href="#loco-debug" class="loco-anchor" aria-hidden="true"></a>
</h3>
<dl><?php
foreach( $debug as $key => $value ):?>
<dt>
<?php echo $debug->escape($key)?>:
</dt>
<dd>
<?php $debug->e($key)?>
</dd><?php
endforeach?>
</dl>
</div>

View file

@ -0,0 +1,34 @@
<?php
/**
* User preferences screen
*/
$this->extend('../layout');
/* @var Loco_data_Preferences $opts */
$help = apply_filters('loco_external','https://localise.biz/wordpress/plugin/manual/settings');
?>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="<?php $nonce->e('name')?>" value="<?php $nonce->e('value')?>" />
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php esc_html_e('Translator credit','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Translator credit','loco-translate')?></span>
</legend>
<p>
<input type="text" size="64" name="opts[credit]" id="loco--credit" value="<?php echo esc_attr($opts->credit)?>" placeholder="<?php echo esc_attr($opts->default_credit())?>" />
</p>
</fieldset>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_html_e('Save settings','loco-translate')?>" />
<a class="button button-link" href="<?php self::e($help)?>#user" target="_blank"><?php esc_html_e('Documentation','loco-translate')?></a>
</p>
</form>

View file

@ -0,0 +1,179 @@
<?php
/**
* Global settings screen. (plugin options)
*/
$this->extend('../layout');
$help = apply_filters('loco_external','https://localise.biz/wordpress/plugin/manual/settings');
$fs_help = apply_filters('loco_external','https://localise.biz/wordpress/plugin/manual/filesystem');
/* @var Loco_data_Settings $opts */
/* @var Loco_data_Settings $dflt */
?>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="<?php $nonce->e('name')?>" value="<?php $nonce->e('value')?>" />
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php esc_html_e('Compiling MO files','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Compiling MO files','loco-translate')?></span>
</legend>
<p>
<label for="loco--gen-hash">
<input type="checkbox" name="opts[gen_hash]" value="1" id="loco--gen-hash"<?php echo $opts->gen_hash?' checked':''?> />
<?php esc_html_e('Generate hash tables','loco-translate')?>
</label>
</p>
<p>
<label for="loco--use-fuzzy">
<input type="checkbox" name="opts[use_fuzzy]" value="1" id="loco--use-fuzzy"<?php echo $opts->use_fuzzy?' checked':''?> />
<?php esc_html_e('Include Fuzzy strings','loco-translate')?>
</label>
</p>
</fieldset>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Extracting strings','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Extracting strings','loco-translate')?></span>
</legend>
<p>
<label for="loco--max_php_size">
<?php esc_html_e('Skip PHP files larger than:','loco-translate')?>
</label>
<input type="text" size="5" name="opts[max_php_size]" id="loco--max_php_size" value="<?php echo esc_attr( $opts->max_php_size)?>" placeholder="<?php echo esc_attr($dflt->max_php_size)?>" />
</p>
<p>
<label for="loco--php_alias">
<?php esc_html_e('Scan PHP files with extensions:','loco-translate')?>
</label>
<input type="text" size="15" name="opts[php_alias]" id="loco--php_alias" value="<?php echo esc_attr( implode(' ',$opts->php_alias) )?>" placeholder="<?php echo esc_attr(implode(' ',$dflt->php_alias))?>" />
</p>
<p>
<label for="loco--jsx_alias">
<?php esc_html_e('Scan JavaScript files with extensions:','loco-translate')?>
</label>
<input type="text" size="15" name="opts[jsx_alias]" id="loco--jsx_alias" value="<?php echo esc_attr( implode(' ',$opts->jsx_alias) )?>" placeholder="<?php echo esc_attr(implode(' ',$dflt->jsx_alias))?>" />
</p>
</fieldset>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Saving PO/POT files','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Saving PO/POT files','loco-translate')?></span>
</legend>
<p>
<label for="loco--num-backups">
<?php esc_html_e('Number of backups to keep of each file:','loco-translate')?>
</label>
<input type="number" min="0" max="99" size="2" name="opts[num_backups]" id="loco--num_backups" value="<?php printf('%u',$opts->num_backups)?>" />
</p>
<p>
<label for="loco--po-width">
<?php esc_html_e('Maximum line length (zero disables wrapping)','loco-translate')?>
</label>
<input type="number" min="0" max="999" size="2" name="opts[po_width]" id="loco--po-width" value="<?php printf('%u',$opts->po_width)?>" />
</p>
<p>
<label for="loco--po-utf8-bom">
<input type="checkbox" name="opts[po_utf8_bom]" value="1" id="loco--po-utf8-bom"<?php echo $opts->po_utf8_bom?' checked':''?> />
<?php esc_html_e('Add UTF-8 byte order mark','loco-translate')?> (<?php esc_html_e('Not recommended','loco-translate')?>)
</label>
</p>
<p>
<label for="loco--ajax-files">
<input type="checkbox" name="opts[ajax_files]" value="1" id="loco--ajax-files"<?php echo $opts->ajax_files?' checked':''?> />
<?php esc_html_e('Enable Ajax file uploads','loco-translate')?> (<?php esc_html_e('Recommended','loco-translate')?>)
</label>
</p>
</fieldset>
</td>
</tr>
<!--tr>
<th scope="row"><?php esc_html_e('POT template files','loco-translate')?></th>
<td>
<fieldset>
<p>
<label for="loco--pot_alias">
< ?php esc_html_e('Look for non-standard names:','loco-translate')? >
</label>
<input type="text" size="40" name="opts[pot_alias]" id="loco--pot_alias" value="< ?php echo esc_attr( implode(' ',$opts->pot_alias) )? >" />
</p>
</fieldset>
</td>
</tr-->
<tr>
<th scope="row"><?php esc_html_e('File system access','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('File system access','loco-translate')?></span>
</legend>
<p>
<label for="loco--fs-persist">
<input type="checkbox" name="opts[fs_persist]" value="1" id="loco--fs-persist"<?php echo $opts->fs_persist?' checked':''?> />
<?php esc_html_e('Save credentials in session','loco-translate')?>
(<?php esc_html_e('Not recommended','loco-translate')?>)
</label>
</p>
<p><?php
/* @var Loco_mvc_ViewParams $verbose */
esc_html_e('Modification of installed files','loco-translate');?>:
<select name="opts[fs_protect]" id="loco--fs-protect">
<option value="0"><?php $verbose->e(0)?></option>
<option value="1"<?php echo 1 === $opts->fs_protect?' selected':''?>><?php $verbose->e(1)?></option>
<option value="2"<?php echo 2 === $opts->fs_protect?' selected':''?>><?php $verbose->e(2)?></option>
</select>
</p>
<p><?php
esc_html_e('Editing of POT (template) files','loco-translate');?>:
<select name="opts[pot_protect]" id="loco--pot-protect">
<option value="0"><?php $verbose->e(0)?></option>
<option value="1"<?php echo 1 === $opts->pot_protect?' selected':''?>><?php $verbose->e(1)?></option>
<option value="2"<?php echo 2 === $opts->pot_protect?' selected':''?>><?php $verbose->e(2)?></option>
</select>
</p>
<p>
<span class="description">
<a href="<?php self::e($fs_help)?>" target="_blank"><?php
esc_html_e('About file system access','loco-translate')?></a>
</span>
</p>
</fieldset>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Grant access to roles','loco-translate')?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Allow full access to these roles','loco-translate')?></span>
</legend><?php
/* @var Loco_mvc_ViewParams[] $caps */
foreach( $caps as $cap ):?>
<p>
<label>
<input type="checkbox" name="<?php $cap->e('name')?>" value="<?php $cap->e('label')?>" <?php echo $cap->attrs?> />
<?php $cap->e('label')?>
</label>
</p><?php
endforeach;?>
</fieldset>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_html_e('Save settings','loco-translate')?>" />
<a class="button button-link" href="<?php self::e($help)?>" target="_blank"><?php esc_html_e('Documentation','loco-translate')?></a>
</p>
</form>

View file

@ -0,0 +1,41 @@
<?php
/**
* Plugin version information
*/
$this->extend('../layout');
if( $params->has('update') ):?>
<div class="notice inline notice-warning">
<h3 class="has-icon">
<?php self::e( __('Version %s','loco-translate'), $version )?>
</h3>
<p>
<?php esc_html_e( __('A newer version of Loco Translate is available for download','loco-translate') )?>.
</p>
<p class="submit">
<a class="button button-primary" href="<?php echo $update_href?>"><?php self::e(__('Upgrade to %s','loco-translate'), $update )?></a>
<a class="button button-link has-icon icon-ext" href="https://wordpress.org/plugins/loco-translate/installation/" target="_blank"><?php esc_html_e( __('Install manually','loco-translate') )?></a>
</p>
</div><?php
elseif( $params->has('devel') ):?>
<div class="notice inline notice-debug">
<h3 class="has-icon">
<?php self::e( __('Version %s','loco-translate'), $version )?>
</h3>
<p>
<?php esc_html_e("You're running a development snapshot of Loco Translate",'loco-translate')?>
</p>
</div><?php
else:?>
<div class="notice inline notice-success">
<h3 class="has-icon">
<?php self::e( __('Version %s','loco-translate'), $version)?>
</h3>
<p>
<?php esc_html_e("You're running the latest version of Loco Translate",'loco-translate')?>
</p>
</div><?php
endif;