This commit is contained in:
Javier Casares 2026-08-24 10:47:37 +00:00
commit 5bb4d373fc
187 changed files with 8665 additions and 998 deletions

View file

@ -52,32 +52,34 @@ class Manager_Dependency {
/**
* Whether the ROBOTSTXT Manager plugin is installed and active.
*
* Matches any active plugin whose directory slug is "robotstxt-manager",
* so the main file name does not matter. On Multisite, network-activated
* plugins are matched as well.
* Uses the ecosystem presence constant ROBOTSTXT_MANAGER_NOTICED
* (Manager 1.6.2+) and falls back to a plugin-list scan for older
* Manager versions.
*
* @since 1.4.2
* @since 1.4.3 Switched to the ecosystem presence constant with a
* plugin-list scan fallback for older Manager versions.
*
* @return bool True when ROBOTSTXT Manager is active.
*/
public static function is_manager_active(): bool {
$active = get_option( 'active_plugins', array() );
if ( is_array( $active ) ) {
foreach ( $active as $basename ) {
if ( is_string( $basename ) && str_starts_with( $basename, 'robotstxt-manager/' ) ) {
return true;
}
}
if ( defined( 'ROBOTSTXT_MANAGER_NOTICED' ) && ROBOTSTXT_MANAGER_NOTICED ) {
return true;
}
if ( is_multisite() ) {
$network_active = get_site_option( 'active_sitewide_plugins', array() );
if ( is_array( $network_active ) ) {
foreach ( array_keys( $network_active ) as $basename ) {
if ( is_string( $basename ) && str_starts_with( $basename, 'robotstxt-manager/' ) ) {
return true;
}
}
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
foreach ( get_plugins() as $file => $data ) {
$slug = dirname( $file );
if ( '.' === $slug ) {
$slug = basename( $file, '.php' );
}
if ( 'robotstxt-manager' === $slug ) {
return is_plugin_active( $file );
}
}