95 lines
2.8 KiB
PHP
95 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Media Audit (by ROBOTSTXT)
|
|
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-mediaaudit
|
|
* Description: Internal media library usage auditing and external reverse image search to detect potential copyright issues.
|
|
* Version: 1.8.1
|
|
* Requires at least: 5.3
|
|
* Tested up to: 7.0
|
|
* Requires PHP: 8.0
|
|
* Requires Plugins: action-scheduler
|
|
* Network: true
|
|
* Author: ROBOTSTXT
|
|
* Author URI: https://www.robotstxt.es/
|
|
* Contributors: javiercasares, robotstxt
|
|
* License: GPL-3.0-or-later
|
|
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
|
* Text Domain: robotstxt-mediaaudit
|
|
* Domain Path: /languages
|
|
*
|
|
* @package MediaRightsAudit
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
define( 'ROBOTSTXT_MEDIAAUDIT_VERSION', '1.8.1' );
|
|
define( 'ROBOTSTXT_MEDIAAUDIT_DB_VERSION', '1.3.0' );
|
|
define( 'ROBOTSTXT_MEDIAAUDIT_PLUGIN_FILE', __FILE__ );
|
|
define( 'ROBOTSTXT_MEDIAAUDIT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'ROBOTSTXT_MEDIAAUDIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
|
|
|
require_once ROBOTSTXT_MEDIAAUDIT_PLUGIN_DIR . 'vendor/autoload.php';
|
|
|
|
use MediaRightsAudit\Core\Activator;
|
|
use MediaRightsAudit\Core\Deactivator;
|
|
use MediaRightsAudit\Core\NetworkActivator;
|
|
use MediaRightsAudit\Core\Plugin;
|
|
use MediaRightsAudit\Network\Plugin as NetworkPlugin;
|
|
|
|
/**
|
|
* Handles activation for both single-site and network-wide contexts.
|
|
*
|
|
* @param bool $network_wide True when activated network-wide in Multisite.
|
|
*
|
|
* @return void
|
|
*/
|
|
function robotstxt_mediaaudit_activate( bool $network_wide ): void {
|
|
if ( is_multisite() && $network_wide ) {
|
|
NetworkActivator::network_activate();
|
|
} else {
|
|
Activator::activate();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles deactivation for both single-site and network-wide contexts.
|
|
*
|
|
* @param bool $network_wide True when deactivated network-wide in Multisite.
|
|
*
|
|
* @return void
|
|
*/
|
|
function robotstxt_mediaaudit_deactivate( bool $network_wide ): void {
|
|
if ( is_multisite() && $network_wide ) {
|
|
NetworkActivator::network_deactivate();
|
|
} else {
|
|
Deactivator::deactivate();
|
|
}
|
|
}
|
|
|
|
register_activation_hook( __FILE__, 'robotstxt_mediaaudit_activate' );
|
|
register_deactivation_hook( __FILE__, 'robotstxt_mediaaudit_deactivate' );
|
|
|
|
// Provision tables for newly created sites when the plugin is network-active.
|
|
add_action( 'wp_initialize_site', array( NetworkActivator::class, 'on_new_site' ) );
|
|
|
|
/**
|
|
* Bootstraps the site-level plugin.
|
|
*
|
|
* In Multisite central mode, registers a placeholder notice instead of the full admin UI
|
|
* so all management happens from the network admin panel.
|
|
*
|
|
* @return void
|
|
*/
|
|
function robotstxt_mediaaudit_run(): void {
|
|
$plugin = new Plugin();
|
|
$plugin->run();
|
|
|
|
if ( is_multisite() ) {
|
|
$network_plugin = new NetworkPlugin();
|
|
$network_plugin->run();
|
|
}
|
|
}
|
|
|
|
add_action( 'plugins_loaded', 'robotstxt_mediaaudit_run' );
|