Renders a single input for the field.
Description
See also
Parameters
- $current_value
-
(mixed) (Required) Current field value.
Source
File: src/modules/access-controls/autocomplete-with-button.php
protected function render_single_input( $current_value ) { $current_label = ''; if ( ! empty( $current_value ) && ! empty( $this->autocomplete['rest_placeholder_label_route'] ) ) { $rest_url = rest_url( str_replace( '%value%', $current_value, $this->autocomplete['rest_placeholder_label_route'] ) ); $request = WP_REST_Request::from_url( $rest_url ); if ( $request ) { $response = rest_do_request( $request ); if ( ! is_wp_error( $response ) ) { $current_label = $this->replace_placeholders_with_data( $this->autocomplete['label_generator'], $response->get_data() ); } } } $input_attrs = array( 'type' => $this->type, 'value' => $current_label, ); $hidden_attrs = array( 'type' => 'hidden', 'name' => $this->get_name_attribute(), 'value' => $current_value, ); ?> <input<?php echo $this->get_input_attrs( $input_attrs ); ?>> <input<?php echo $this->attrs( $hidden_attrs ); ?>> <?php if ( ! empty( $this->button_label ) ) : ?> <button type="button" <?php echo $this->attrs( $this->button_attrs ); ?>><?php echo esc_html( $this->button_label ); ?></button> <?php endif; ?> <?php $this->render_repeatable_remove_button(); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |