*/ private $args; /** * Constructor. * * @since 0.6.0 * * @param Service_Entity $service_entity The service entity. * @param string $api_key The API key. * @param array $args { * Optional. Additional configuration arguments for the control. * * @type string $id_attr The input ID attribute. Default none. * @type string $name_attr The input name attribute. Default is the relevant option slug. * @type string $class_attr The input class attribute. Default none. * @type bool $omit_credentials_link Whether to omit the credentials link. Default false. * } */ public function __construct( Service_Entity $service_entity, string $api_key, array $args = array() ) { $this->service_entity = $service_entity; $this->api_key = $api_key; $this->args = wp_parse_args( $args, array( 'id_attr' => '', 'name_attr' => '', 'class_attr' => '', 'omit_credentials_link' => false, ) ); if ( ! $this->args['name_attr'] ) { $option_definitions = API_Key_Authentication::get_option_definitions( $this->service_entity->get_field_value( 'slug' ) ); if ( count( $option_definitions ) > 0 ) { $this->args['name_attr'] = key( $option_definitions ); } } } /** * Renders the entire API key input control, including wrapper element and label. * * @since 0.6.0 */ public function render(): void { ?>
render_label(); ?> render_input(); ?>
service_entity->get_field_value( 'name' ); $credentials_url = $this->service_entity->get_field_value( 'credentials_url' ); $has_forced_value = $this->service_entity->get_field_value( 'has_forced_api_key' ); ?> />

args['omit_credentials_link'] && $credentials_url ) { ?> api_key ) { /* translators: %s: service name */ $credentials_url_text = __( 'Manage %s API keys', 'ai-services' ); } else { /* translators: %s: service name */ $credentials_url_text = __( 'Get %s API key', 'ai-services' ); } $credentials_url_text .= ' ' . __( '(opens in a new tab)', 'ai-services' ) . ''; $credentials_url_text = str_replace( '', '', $credentials_url_text ); echo wp_kses( sprintf( $credentials_url_text, $service_name ), array( 'span' => array( 'class' => array() ), ) ); ?>