field['value'] ) ) { return; } if ( ! empty( $this->field['multiple'] ) ) { if ( in_array( $value, (array) $this->field['value'] ) ) { echo esc_attr( 'selected' ) . '="' . esc_attr( 'selected' ) . '"'; } } else { selected( $value, is_array( $this->field['value'] ) ? $this->field['value'][ array_key_first( $this->field['value'] ) ] : $this->field['value'] ); } } /** * Set Select Search attributes. * * @return void */ private function search_attrs() { echo wp_kses_post( ! empty( $this->field['search_data'] ) ? esc_attr( 'data-search_params' ) . '="' . esc_attr( wp_json_encode( $this->field['search_data'] ) ) . '"' : '' ); } /** * Set Select2 args attributes. * * @return void */ private function select_args() { echo wp_kses_post( ! empty( $this->field['select_args'] ) ? esc_attr( 'data-select_args' ) . '="' . esc_attr( wp_json_encode( $this->field['select_args'] ) ) . '"' : '' ); } /** * Get Empty Value. * * @return string */ public function get_empty_value() { return ! empty( $this->field['multiple'] ) ? array() : $this->field['value']; } /** * Sanitize Field. * * @param mixed $value * @return string */ public function sanitize_field( $value ) { if ( ! empty( $this->field['multiple'] ) ) { $value = (array) $value; } return is_array( $value ) ? map_deep( $value, 'sanitize_text_field' ) : sanitize_text_field( $value ); } }