all(); $mybot_stats = $plugin->logger->stats(); $mybot_queue = $plugin->queue->stats(); $mybot_progress = $plugin->indexer->get_progress(); $mybot_crypto_ok = MYBOT_Crypto::is_available(); $mybot_has_react = file_exists( MYBOT_PLUGIN_DIR . 'admin/build/index.js' ); $mybot_languages = $plugin->languages; $mybot_enabled = $mybot_languages->enabled(); $mybot_default = $mybot_languages->default_code(); /** * Renders a text input row. * * @param string $key Field name. * @param string $label Label. * @param string $description Description. * @param array $options Current options. * @return void */ function mybot_field_text( $key, $label, $description, $options ) { printf( '

%5$s

', esc_attr( $key ), esc_html( $label ), esc_attr( MYBOT_OPTION_KEY ), esc_attr( isset( $options[ $key ] ) ? $options[ $key ] : '' ), esc_html( $description ) ); } /** * Renders a number input row. * * @param string $key Field name. * @param string $label Label. * @param string $description Description. * @param array $options Current options. * @param int $min Minimum. * @param int $max Maximum. * @return void */ function mybot_field_number( $key, $label, $description, $options, $min, $max ) { printf( '

%7$s

', esc_attr( $key ), esc_html( $label ), esc_attr( MYBOT_OPTION_KEY ), esc_attr( isset( $options[ $key ] ) ? $options[ $key ] : '' ), (int) $min, (int) $max, esc_html( $description ) ); } /** * Renders a decimal input row. * * The plain number helper casts its bounds to int, which cannot express a score between * 0 and 1, so the score fields get their own renderer with a 0.01 step. * * @param string $key Field name. * @param string $label Label. * @param string $description Description. * @param array $options Current options. * @param float $min Minimum. * @param float $max Maximum. * @return void */ function mybot_field_decimal( $key, $label, $description, $options, $min, $max ) { printf( '

%7$s

', esc_attr( $key ), esc_html( $label ), esc_attr( MYBOT_OPTION_KEY ), esc_attr( isset( $options[ $key ] ) ? $options[ $key ] : '' ), esc_attr( $min ), esc_attr( $max ), esc_html( $description ) ); } /** * Renders a select row. * * @param string $key Field name. * @param string $label Label. * @param string $description Description. * @param array $options Current options. * @param array $choices List of choices. * @return void */ function mybot_field_select( $key, $label, $description, $options, $choices ) { $current = isset( $options[ $key ] ) ? (string) $options[ $key ] : ''; printf( '

%s

', esc_html( $description ) ); } /** * Renders a masked secret input row. * * @param string $key Field name. * @param string $label Label. * @param string $description Description. * @param MYBOT_Settings $settings The settings. * @return void */ function mybot_field_secret( $key, $label, $description, $settings ) { $stored = (string) $settings->get( $key, '' ); $masked = ( '' === $stored ) ? '' : MYBOT_Crypto::mask( MYBOT_Crypto::decrypt( $stored ) ); $placeholder = ( '' === $masked ) ? __( 'Not configured', 'aihouse' ) : $masked; /* * Leaving the embedding key empty is the documented way to reuse the key of the embedding * provider, so printing "Not configured" there contradicts the label right above it and * reads like a fault — which is exactly how it was read. */ if ( '' === $masked && 'embedding_api_key' === $key ) { $provider = sanitize_key( (string) $settings->get( 'embedding_provider', 'openai' ) ); if ( '' !== $settings->provider_key( $provider ) ) { $labels = MYBOT_LLM_Factory::options(); $placeholder = sprintf( /* translators: %s: provider name */ __( 'Using the %s key', 'aihouse' ), isset( $labels[ $provider ] ) ? $labels[ $provider ] : $provider ); } } printf( '

%5$s

', esc_attr( $key ), esc_html( $label ), esc_attr( MYBOT_OPTION_KEY ), esc_attr( $placeholder ), esc_html( $description ) ); } ?>