v1.2.0
This commit is contained in:
parent
02cd01e862
commit
1ccc13da01
14 changed files with 845 additions and 197 deletions
|
|
@ -245,6 +245,40 @@ if ( ! class_exists( 'AI_Translator_Admin' ) ) {
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="ai-translator-request-timeout"><?php echo esc_html__( 'Request timeout', 'robotstxt-ai-translator' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="number"
|
||||
id="ai-translator-request-timeout"
|
||||
name="ai_translator_settings[request_timeout]"
|
||||
value="<?php echo esc_attr( (string) $current['request_timeout'] ); ?>"
|
||||
min="30"
|
||||
max="300"
|
||||
step="1"
|
||||
class="small-text"
|
||||
/>
|
||||
<span class="description"><?php echo esc_html__( 'seconds', 'robotstxt-ai-translator' ); ?></span>
|
||||
<p class="description">
|
||||
<?php
|
||||
$ini_raw = ini_get( 'max_execution_time' );
|
||||
$php_limit = is_string( $ini_raw ) ? (int) $ini_raw : 0;
|
||||
if ( $php_limit > 0 ) {
|
||||
printf(
|
||||
/* translators: %d: PHP max_execution_time in seconds. */
|
||||
esc_html__( 'Maximum time the server waits for an AI response. PHP max_execution_time is %d s — values above this have no effect.', 'robotstxt-ai-translator' ),
|
||||
absint( $php_limit )
|
||||
);
|
||||
} else {
|
||||
esc_html_e( 'Maximum time the server waits for an AI response. PHP max_execution_time is unlimited.', 'robotstxt-ai-translator' );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ( class_exists( '\Inpsyde\MultilingualPress\TranslationUi\Post\MetaboxAction' ) ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php echo esc_html__( 'MultilingualPress', 'robotstxt-ai-translator' ); ?></th>
|
||||
|
|
@ -355,6 +389,40 @@ if ( ! class_exists( 'AI_Translator_Admin' ) ) {
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="ai-translator-net-request-timeout"><?php echo esc_html__( 'Request timeout', 'robotstxt-ai-translator' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="number"
|
||||
id="ai-translator-net-request-timeout"
|
||||
name="ai_translator_settings[request_timeout]"
|
||||
value="<?php echo esc_attr( (string) $network['request_timeout'] ); ?>"
|
||||
min="30"
|
||||
max="300"
|
||||
step="1"
|
||||
class="small-text"
|
||||
/>
|
||||
<span class="description"><?php echo esc_html__( 'seconds', 'robotstxt-ai-translator' ); ?></span>
|
||||
<p class="description">
|
||||
<?php
|
||||
$ini_raw_net = ini_get( 'max_execution_time' );
|
||||
$php_limit_net = is_string( $ini_raw_net ) ? (int) $ini_raw_net : 0;
|
||||
if ( $php_limit_net > 0 ) {
|
||||
printf(
|
||||
/* translators: %d: PHP max_execution_time in seconds. */
|
||||
esc_html__( 'Maximum time the server waits for an AI response. PHP max_execution_time is %d s — values above this have no effect.', 'robotstxt-ai-translator' ),
|
||||
absint( $php_limit_net )
|
||||
);
|
||||
} else {
|
||||
esc_html_e( 'Maximum time the server waits for an AI response. PHP max_execution_time is unlimited.', 'robotstxt-ai-translator' );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ( class_exists( '\Inpsyde\MultilingualPress\TranslationUi\Post\MetaboxAction' ) ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php echo esc_html__( 'MultilingualPress', 'robotstxt-ai-translator' ); ?></th>
|
||||
|
|
@ -563,18 +631,18 @@ if ( ! class_exists( 'AI_Translator_Admin' ) ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sanitises a raw settings array into a strict boolean schema.
|
||||
* Sanitises a raw settings array into a typed schema.
|
||||
*
|
||||
* This is the single sanitisation boundary for all form input from both the
|
||||
* site and network settings pages. Raw POST values arrive via wp_unslash()
|
||||
* and are converted here to strict booleans. Any new field added to this
|
||||
* schema MUST be sanitised in this method before being stored.
|
||||
* and are converted here to strict types. Any new field added to this schema
|
||||
* MUST be sanitised in this method before being stored.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param array<string,mixed> $raw Raw input from the form.
|
||||
*
|
||||
* @return array<string,bool>
|
||||
* @return array<string,bool|int>
|
||||
*/
|
||||
private function sanitize_settings( array $raw ) {
|
||||
return array(
|
||||
|
|
@ -582,6 +650,7 @@ if ( ! class_exists( 'AI_Translator_Admin' ) ) {
|
|||
'translate_content' => ! empty( $raw['translate_content'] ),
|
||||
'translate_excerpt' => ! empty( $raw['translate_excerpt'] ),
|
||||
'auto_translate_on_mlp_create' => ! empty( $raw['auto_translate_on_mlp_create'] ),
|
||||
'request_timeout' => max( 30, min( 300, isset( $raw['request_timeout'] ) && is_numeric( $raw['request_timeout'] ) ? (int) $raw['request_timeout'] : 60 ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue