v1.5.0
This commit is contained in:
parent
672d0f295f
commit
83d629568a
20 changed files with 1321 additions and 15 deletions
|
|
@ -80,6 +80,22 @@ class Settings {
|
|||
'mra_api_credentials'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'picdefense_user_id',
|
||||
__( 'PicDefense User ID', 'robotstxt-mediaaudit' ),
|
||||
array( $this, 'field_picdefense_user_id' ),
|
||||
'robotstxt-mediaaudit-settings',
|
||||
'mra_api_credentials'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'picdefense_api_key',
|
||||
__( 'PicDefense API Key', 'robotstxt-mediaaudit' ),
|
||||
array( $this, 'field_picdefense_api_key' ),
|
||||
'robotstxt-mediaaudit-settings',
|
||||
'mra_api_credentials'
|
||||
);
|
||||
|
||||
add_settings_section(
|
||||
'mra_external_scanning',
|
||||
__( 'External Scanning', 'robotstxt-mediaaudit' ),
|
||||
|
|
@ -126,6 +142,12 @@ class Settings {
|
|||
$tineye_val = $input['tineye_api_key'] ?? null;
|
||||
$output['tineye_api_key'] = is_string( $tineye_val ) ? sanitize_text_field( $tineye_val ) : '';
|
||||
|
||||
$pd_uid_val = $input['picdefense_user_id'] ?? null;
|
||||
$output['picdefense_user_id'] = is_string( $pd_uid_val ) ? sanitize_text_field( $pd_uid_val ) : '';
|
||||
|
||||
$pd_key_val = $input['picdefense_api_key'] ?? null;
|
||||
$output['picdefense_api_key'] = is_string( $pd_key_val ) ? sanitize_text_field( $pd_key_val ) : '';
|
||||
|
||||
$batch_val = $input['external_batch_size'] ?? null;
|
||||
$batch = is_numeric( $batch_val ) ? (int) $batch_val : 10;
|
||||
$output['external_batch_size'] = max( 1, min( 100, $batch ) );
|
||||
|
|
@ -265,6 +287,58 @@ class Settings {
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the PicDefense User ID field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_picdefense_user_id(): void {
|
||||
$options = (array) get_option( self::OPTION_NAME, array() );
|
||||
$val = $options['picdefense_user_id'] ?? '';
|
||||
$value = is_string( $val ) ? $val : '';
|
||||
?>
|
||||
<input
|
||||
type="text"
|
||||
id="picdefense_user_id"
|
||||
name="<?php echo esc_attr( self::OPTION_NAME ); ?>[picdefense_user_id]"
|
||||
value="<?php echo esc_attr( $value ); ?>"
|
||||
class="regular-text"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Required for PicDefense copyright risk analysis. Your PicDefense account user ID.', 'robotstxt-mediaaudit' ); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the PicDefense API key field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_picdefense_api_key(): void {
|
||||
$options = (array) get_option( self::OPTION_NAME, array() );
|
||||
$val = $options['picdefense_api_key'] ?? '';
|
||||
$value = is_string( $val ) ? $val : '';
|
||||
?>
|
||||
<input
|
||||
type="password"
|
||||
id="picdefense_api_key"
|
||||
name="<?php echo esc_attr( self::OPTION_NAME ); ?>[picdefense_api_key]"
|
||||
value="<?php echo esc_attr( $value ); ?>"
|
||||
class="regular-text"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Required for PicDefense copyright risk analysis. Your PicDefense API key.', 'robotstxt-mediaaudit' ); ?>
|
||||
—
|
||||
<a href="https://picdefense.io" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e( 'View pricing', 'robotstxt-mediaaudit' ); ?>
|
||||
</a>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the external batch size field.
|
||||
*
|
||||
|
|
@ -315,6 +389,43 @@ class Settings {
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether Google Cloud Vision is configured.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_google_vision_configured(): bool {
|
||||
$raw = get_option( self::OPTION_NAME, array() );
|
||||
$opts = is_array( $raw ) ? $raw : array();
|
||||
$key = $opts['google_vision_api_key'] ?? '';
|
||||
return is_string( $key ) && '' !== trim( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether TinEye is configured.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_tineye_configured(): bool {
|
||||
$raw = get_option( self::OPTION_NAME, array() );
|
||||
$opts = is_array( $raw ) ? $raw : array();
|
||||
$key = $opts['tineye_api_key'] ?? '';
|
||||
return is_string( $key ) && '' !== trim( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether PicDefense is configured.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_picdefense_configured(): bool {
|
||||
$raw = get_option( self::OPTION_NAME, array() );
|
||||
$opts = is_array( $raw ) ? $raw : array();
|
||||
$uid = $opts['picdefense_user_id'] ?? '';
|
||||
$key = $opts['picdefense_api_key'] ?? '';
|
||||
return is_string( $uid ) && '' !== trim( $uid ) && is_string( $key ) && '' !== trim( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Settings admin page.
|
||||
*
|
||||
|
|
@ -324,9 +435,44 @@ class Settings {
|
|||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to access this page.', 'robotstxt-mediaaudit' ) );
|
||||
}
|
||||
|
||||
$gv_ok = $this->is_google_vision_configured();
|
||||
$te_ok = $this->is_tineye_configured();
|
||||
$pd_ok = $this->is_picdefense_configured();
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||
|
||||
<div class="mra-provider-status">
|
||||
<strong><?php esc_html_e( 'API Credentials Status', 'robotstxt-mediaaudit' ); ?></strong>
|
||||
<ul>
|
||||
<li>
|
||||
<?php if ( $gv_ok ) : ?>
|
||||
<span class="dashicons dashicons-yes-alt" style="color:green;"></span>
|
||||
<?php else : ?>
|
||||
<span class="dashicons dashicons-warning" style="color:orange;"></span>
|
||||
<?php endif; ?>
|
||||
<?php esc_html_e( 'Google Cloud Vision', 'robotstxt-mediaaudit' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<?php if ( $te_ok ) : ?>
|
||||
<span class="dashicons dashicons-yes-alt" style="color:green;"></span>
|
||||
<?php else : ?>
|
||||
<span class="dashicons dashicons-warning" style="color:orange;"></span>
|
||||
<?php endif; ?>
|
||||
<?php esc_html_e( 'TinEye', 'robotstxt-mediaaudit' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<?php if ( $pd_ok ) : ?>
|
||||
<span class="dashicons dashicons-yes-alt" style="color:green;"></span>
|
||||
<?php else : ?>
|
||||
<span class="dashicons dashicons-warning" style="color:orange;"></span>
|
||||
<?php endif; ?>
|
||||
PicDefense
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields( self::OPTION_GROUP );
|
||||
|
|
|
|||
Loading…
Reference in a new issue