v1.2.6
This commit is contained in:
parent
0c4fda16c0
commit
6385b02633
1 changed files with 79 additions and 22 deletions
|
|
@ -276,24 +276,35 @@ if ( ! class_exists( 'Robotstxt_Hello_Plugin' ) ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether the Manager (by ROBOTSTXT) plugin is active.
|
||||
* Returns whether Manager (by ROBOTSTXT) is installed and active.
|
||||
*
|
||||
* Detection covers both single-site and network-wide activation.
|
||||
* Uses the ecosystem presence constant (Manager 1.6.2+) and falls back
|
||||
* to a plugin-list scan for older Manager versions.
|
||||
*
|
||||
* @since 1.2.4
|
||||
* @since 1.2.6 Switched to the ROBOTSTXT_MANAGER_NOTICED presence
|
||||
* constant with a plugin-list scan fallback.
|
||||
*
|
||||
* @return bool True when any active plugin basename starts with 'robotstxt-manager/'.
|
||||
* @return bool True when Manager is present and activated.
|
||||
*/
|
||||
private function is_manager_active() {
|
||||
$active = (array) get_option( 'active_plugins', array() );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$active = array_merge( $active, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) );
|
||||
public function is_manager_active(): bool {
|
||||
if ( defined( 'ROBOTSTXT_MANAGER_NOTICED' ) && ROBOTSTXT_MANAGER_NOTICED ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ( $active as $basename ) {
|
||||
if ( is_string( $basename ) && 0 === strpos( $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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue