' . 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 '