label. */ defined( 'ABSPATH' ) || exit; function avc_ais_render_field( $id, $label, $type = 'text', $value = '', $description = '', $name = '', $options = array() ) { $field_id = sanitize_key( $id ); if ( '' === $name ) { $name = $field_id; } // Ensure value is never null to avoid PHP 8 deprecation warnings. $value = $value ?? ''; echo '
'; echo ''; switch ( $type ) { case 'textarea': printf( '', esc_attr( $field_id ), esc_attr( $name ), esc_textarea( (string) $value ) ); break; case 'select': echo ''; break; case 'checkbox': printf( '', esc_attr( $field_id ), esc_attr( $name ), checked( (bool) $value, true, false ) ); break; default: printf( '', esc_attr( $type ), esc_attr( $field_id ), esc_attr( $name ), esc_attr( (string) $value ) ); break; } if ( '' !== $description ) { echo '

' . esc_html( $description ) . '

'; } echo '
'; } /** * Render a tooltip help icon with hover text. * * @param string $text The tooltip text to display on hover. * @return string HTML for the tooltip. */ defined( 'ABSPATH' ) || exit; function avc_ais_render_tooltip( $text ) { if ( empty( $text ) ) { return ''; } return sprintf( '' . '?' . '%2$s' . '', esc_attr__( 'Help', 'aivec-ai-search-schema' ), esc_html( $text ) ); } /** * Echo a tooltip help icon with hover text. * * @param string $text The tooltip text to display on hover. */ defined( 'ABSPATH' ) || exit; function avc_ais_tooltip( $text ) { echo wp_kses_post( avc_ais_render_tooltip( $text ) ); }