v1.5.0
This commit is contained in:
parent
672d0f295f
commit
83d629568a
20 changed files with 1321 additions and 15 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace MediaRightsAudit\Core;
|
||||
|
||||
use MediaRightsAudit\Admin\AttachmentDetailPage;
|
||||
use MediaRightsAudit\Admin\AuditPage;
|
||||
use MediaRightsAudit\Admin\Settings;
|
||||
use MediaRightsAudit\Admin\ToolsPage;
|
||||
|
|
@ -14,6 +15,7 @@ use MediaRightsAudit\CLI\Command;
|
|||
use MediaRightsAudit\External\AbstractProvider;
|
||||
use MediaRightsAudit\External\ExternalScanner;
|
||||
use MediaRightsAudit\External\GoogleVisionProvider;
|
||||
use MediaRightsAudit\External\PicDefenseProvider;
|
||||
use MediaRightsAudit\External\TinEyeProvider;
|
||||
use MediaRightsAudit\Internal\AttachmentIndexer;
|
||||
use MediaRightsAudit\Internal\UsageScanner;
|
||||
|
|
@ -46,13 +48,21 @@ class Plugin {
|
|||
*/
|
||||
private ToolsPage $tools_page;
|
||||
|
||||
/**
|
||||
* Attachment detail page controller.
|
||||
*
|
||||
* @var AttachmentDetailPage
|
||||
*/
|
||||
private AttachmentDetailPage $detail_page;
|
||||
|
||||
/**
|
||||
* Initialises dependencies.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->settings = new Settings();
|
||||
$this->audit_page = new AuditPage();
|
||||
$this->tools_page = new ToolsPage();
|
||||
$this->settings = new Settings();
|
||||
$this->audit_page = new AuditPage();
|
||||
$this->tools_page = new ToolsPage();
|
||||
$this->detail_page = new AttachmentDetailPage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,6 +148,15 @@ class Plugin {
|
|||
'robotstxt-mediaaudit-settings',
|
||||
array( $this->settings, 'render' )
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'', // hidden from menu.
|
||||
__( 'Attachment Report', 'robotstxt-mediaaudit' ),
|
||||
'',
|
||||
'edit_posts',
|
||||
'robotstxt-mediaaudit-detail',
|
||||
array( $this->detail_page, 'render' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -172,9 +191,34 @@ class Plugin {
|
|||
}
|
||||
$list[] = new GoogleVisionProvider();
|
||||
$list[] = new TinEyeProvider();
|
||||
if ( $this->is_provider_configured( 'picdefense' ) ) {
|
||||
$list[] = new PicDefenseProvider();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a provider has its credentials configured.
|
||||
*
|
||||
* Checks provider-specific option keys in the plugin settings.
|
||||
*
|
||||
* @param string $slug Provider slug (e.g. 'picdefense').
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_provider_configured( string $slug ): bool {
|
||||
$raw = get_option( Settings::OPTION_NAME, array() );
|
||||
$opts = is_array( $raw ) ? $raw : array();
|
||||
|
||||
if ( 'picdefense' === $slug ) {
|
||||
$uid = $opts['picdefense_user_id'] ?? '';
|
||||
$key = $opts['picdefense_api_key'] ?? '';
|
||||
return is_string( $uid ) && '' !== trim( $uid ) && is_string( $key ) && '' !== trim( $key );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers WP-CLI commands when running in CLI context.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue