' . esc_html( $error ) . '

'; } add_action( 'admin_notices', 'adct_llms_install_path_admin_notice' ); /** * Return active ADCT plugin basenames (including duplicates/nested copies). * * @return string[] */ function adct_llms_get_active_copies() { $active = (array) get_option( 'active_plugins', array() ); $copies = array(); foreach ( $active as $basename ) { $basename = (string) $basename; if ( preg_match( '#/(adct-llm-index|adct-llms-index)\.php$#', $basename ) ) { $copies[] = $basename; } } return array_values( array_unique( $copies ) ); } /** * Determine which active copy should be the only bootstrapped instance. * * @param string[] $copies Active plugin basenames. * @return string */ function adct_llms_primary_active_copy( array $copies ) { $priority = array( 'adct-llm-index/adct-llm-index.php', 'adct-llms-index/adct-llms-index.php', ); foreach ( $priority as $preferred ) { if ( in_array( $preferred, $copies, true ) ) { return $preferred; } } sort( $copies ); return (string) reset( $copies ); } /** * Whether the current file should bootstrap plugin internals. * * @return bool */ function adct_llms_should_bootstrap_this_copy() { $copies = adct_llms_get_active_copies(); if ( count( $copies ) <= 1 ) { return true; } return ADCT_LLMS_BASENAME === adct_llms_primary_active_copy( $copies ); } /** * Warn admins when duplicate active copies are detected. */ function adct_llms_duplicate_copy_admin_notice() { if ( ! is_admin() || ! current_user_can( 'activate_plugins' ) ) { return; } $copies = adct_llms_get_active_copies(); if ( count( $copies ) <= 1 ) { return; } $primary = adct_llms_primary_active_copy( $copies ); echo '

'; echo esc_html__( 'Multiple active copies of ADCT LLM Index were detected. Keep only one active copy and delete the others.', 'adct-llm-index' ); echo '

'; echo esc_html__( 'Keep active:', 'adct-llm-index' ) . ' ' . esc_html( $primary ) . '
'; echo esc_html__( 'Detected active copies:', 'adct-llm-index' ) . ' ' . esc_html( implode( ', ', $copies ) ) . ''; echo '

'; } add_action( 'admin_notices', 'adct_llms_duplicate_copy_admin_notice' ); if ( ! adct_llms_should_bootstrap_this_copy() ) { return; } if ( file_exists( ADCT_LLMS_DIR . 'commercial/bootstrap.php' ) ) { require_once ADCT_LLMS_DIR . 'commercial/bootstrap.php'; } else { if ( ! defined( 'ADCT_LLMS_COMMERCIAL' ) ) { define( 'ADCT_LLMS_COMMERCIAL', false ); } require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-license.php'; } require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-yoast.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-activator.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-settings.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-sold-detector.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-scanner.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-generator.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-file-writer.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-cron.php'; require_once ADCT_LLMS_DIR . 'includes/class-adct-llms-admin.php'; /** * Bootstrap plugin. */ function adct_llms_index_init() { ADCT_LLMS_License::init(); if ( class_exists( 'ADCT_LLMS_Updater' ) ) { ADCT_LLMS_Updater::init(); } ADCT_LLMS_Settings::init(); ADCT_LLMS_Cron::init(); ADCT_LLMS_Admin::init(); } add_action( 'plugins_loaded', 'adct_llms_index_init' ); register_activation_hook( __FILE__, array( 'ADCT_LLMS_Activator', 'activate' ) ); register_deactivation_hook( __FILE__, array( 'ADCT_LLMS_Cron', 'deactivate' ) );