JFIF    $         d d  7    * Z qn )ZP 0   !1 A "#a$2Qr   D8 a Ri [f  \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H  ~ , l s / 9  ć: [=/#f ; ) x { ٛE Q )~     = 𘙲r*2~  a _V = '  ku m F  D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq  1dđ #̩ ͑ 0  ; H ] u 搂 @:~ ו K L  N s h } O I R* 8 :2 ! lD JV o (  3 = M ( z Ȱ+i *N A  r6K n S l ) ! J J Ӂ* %  ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c  P A\IL Nj! J ۱+ O\ ͔ ] ޒ S߼ J ȧ c%A N ol  ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f  h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0  'G=i 2N +0 e 2 ]] 9 VT P  O׮ 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P  < 0 x <     !1AQ "Raq 02Br #S CTb  ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV׸ YT D I 6 2 '8Y2  7'\T P.6 d &˦ @V q i  |8 -O Ε  ] ʔ U=   T L 8= ;6c |  !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U# 6w +  +s &r+n ڐ   { @ 29 gL u " T Ù  M=6  (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 !  OS  r D  5 7 % | ?x> L |  / nD 6?/8 w # [ ) L 7 +6〼T A T g   !  %5  Mm Z /c  -{1_Je "| ^$ 'O  & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@  u6  BԒ  i YN * f 0 _ GhKW u  lT <nj- 0{  M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q  $ H8o Q˼EV ~ k 0 h' L  Pp M -M"  m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @񄞅~p   #   !1QAa q  ? AL0L  x LU 4 d ; x   " 16ad0 7.\ߋ 0  = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X  &Q  З non]я u ג./ ; gZ$ M QР 2M ]h ni 0  P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _  1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3  6 #Ik+ v  {ƒ v i ( ވ  ? a e)  X xy/*@Q Ǽ Ծ ) $ IWO l c G;  !i  k{ gOŀ L ('x  T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ)  X 5 c QɎMy W ?  Q *!R > 6=7)Xj 5`J ] e  8%t ! + ' ! 1Q 5   !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $  v , ,m   㵜5u bV  =sY+ @d { N ! dn O < .- B;  _w J t 6;Q  Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш  e黅X ۢ F :)[ F G X ƹ / w _c MeD   ,ʡc c .  W D  tA $ j@ : ) - # u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P  6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L !  ~ y5 g9T̅J kbM' +s :S +B) v @ M  j e C f j E 0  Y\Qn z G 1 д~ W o{T 9?`  Rm yhsy3 !HAD ] m  c1 ~ 2 L  S u7x T ;j$ `} 4-> L#  vzŏ I L S  ֭  T { r  jGK C ; b  pU= - ` Bs K. S F w4  M q] Z dH S 0 ) tLg Tiny File Manager | settings-api.php
  • File: settings-api.php
  • Full Path: /home/mata8712/public_html/on-me-trouve/wp-content/plugins/wpforms-lite/includes/admin/settings-api.php
  • File size: 22.99 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php
/**
 * Settings API.
 *
 * @since 1.3.7
 */

use WPForms\Admin\Education\Helpers as EducationHelpers;

/**
 * Settings output wrapper.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_output_field( array $args ): string {

	// Define default callback for this field type.
	$callback = ! empty( $args['type'] ) && function_exists( 'wpforms_settings_' . $args['type'] . '_callback' ) ? 'wpforms_settings_' . $args['type'] . '_callback' : 'wpforms_settings_missing_callback';

	// Allow custom callback to be provided via arg.
	if ( ! empty( $args['callback'] ) && function_exists( $args['callback'] ) ) {
		$callback = $args['callback'];
	}

	// Store returned markup from callback.
	$field = $callback( $args );

	// Allow arg to bypass standard field wrap for custom display.
	if ( ! empty( $args['wrap'] ) ) {
		return $field;
	}

	// Default class names.
	$class = [
		'wpforms-setting-row',
		"wpforms-setting-row-{$args['type']}",
		'wpforms-clear',
	];

	// Row attributes.
	$wrapper_attributes = wpforms_html_attributes(
		'wpforms-setting-row-' . wpforms_sanitize_key( $args['id'] ),
		! empty( $args['class'] ) ? array_merge( $class, (array) $args['class'] ) : $class,
		! empty( $args['data_attributes'] ) && is_array( $args['data_attributes'] ) ? $args['data_attributes'] : [],
		! empty( $args['is_hidden'] ) ? [ 'style' => 'display:none;' ] : []
	);

	// Build standard field markup and return.
	$output = "<div {$wrapper_attributes}>";

	if ( ! empty( $args['name'] ) && empty( $args['no_label'] ) ) {
		$output .= '<span class="wpforms-setting-label">';
		$output .= '<label for="wpforms-setting-' . wpforms_sanitize_key( $args['id'] ) . '">' . esc_html( $args['name'] );

		// Add education badge, if needed.
		// The badge should be added after the label text, but before the label closing tag.
		if ( ! empty( $args['education_badge'] ) ) {
			$output .= wp_kses( $args['education_badge'], [ 'span' => [ 'class' => [] ] ] );
		}

		$output .= '</label>';
		$output .= '</span>';
	}

	$output .= '<span class="wpforms-setting-field">';
	$output .= $field;

	if ( ! empty( $args['desc_after'] ) ) {
		$output .= '<div class="wpforms-clear">' . $args['desc_after'] . '</div>';
	}

	$output .= '</span>';
	$output .= '</div>';

	return $output;
}

/**
 * Missing Callback.
 *
 * If a function is missing for settings, callbacks alert the user.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments passed by the setting.
 *
 * @return string
 */
function wpforms_settings_missing_callback( array $args ): string {

	return sprintf(
		/* translators: %s - ID of a setting. */
		esc_html__( 'The callback function used for the %s setting is missing.', 'wpforms-lite' ),
		'<strong>' . wpforms_sanitize_key( $args['id'] ) . '</strong>'
	);
}

/**
 * Settings content field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_content_callback( array $args ): string {

	return ! empty( $args['content'] ) ? $args['content'] : '';
}

/**
 * Settings license field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Settings arguments.
 *
 * @return string
 * @noinspection HtmlUnknownTarget
 * @noinspection PhpUnusedParameterInspection
 */
function wpforms_settings_license_callback( array $args ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found

	$output  = '<p>' . esc_html__( 'You\'re using WPForms Lite - no license needed. Enjoy!', 'wpforms-lite' ) . ' 🙂</p>';
	$output .=
		'<p>' .
		sprintf(
			wp_kses( /* translators: %s - WPForms.com upgrade URL. */
				__( 'To unlock more features consider <strong><a href="%s" target="_blank" rel="noopener noreferrer" class="wpforms-upgrade-modal">upgrading to PRO</a></strong>.', 'wpforms-lite' ),
				[
					'a'      => [
						'href'   => [],
						'class'  => [],
						'target' => [],
						'rel'    => [],
					],
					'strong' => [],
				]
			),
			esc_url( wpforms_admin_upgrade_link( 'settings-license', 'Upgrade to WPForms Pro text Link' ) )
		) .
		'</p>';
	$output .=
		'<p class="discount-note">' .
			wp_kses(
				__( 'As a valued WPForms Lite user you receive <strong>50% off</strong>, automatically applied at checkout!', 'wpforms-lite' ),
				[
					'strong' => [],
				]
			) .
		'</p>';

	$output .= '<hr><p>' . esc_html__( 'Already purchased? Simply enter your license key below to enable WPForms PRO!', 'wpforms-lite' ) . '</p>';
	$output .= '<p>';
	$output .= '<input type="password" spellcheck="false" id="wpforms-settings-upgrade-license-key" placeholder="' . esc_attr__( 'Paste license key here', 'wpforms-lite' ) . '" value="">';
	$output .= '<button class="wpforms-btn wpforms-btn-md wpforms-btn-blue" id="wpforms-settings-connect-btn">' . esc_html__( 'Verify Key', 'wpforms-lite' ) . '</button>';
	$output .= '</p>';

	/**
	 * Filter license settings HTML output.
	 *
	 * @since 1.7.9
	 *
	 * @param string $output HTML markup to be rendered in place of license settings.
	 */
	return (string) apply_filters( 'wpforms_settings_license_output', $output );
}

/**
 * Settings text input field callback.
 *
 * @since 1.3.9
 * @since 1.10.0 Adds the ability to make text input readonly.
 *
 * @param array $args Settings arguments.
 *
 * @return string
 */
function wpforms_settings_text_callback( array $args ): string {

	if ( ! in_array( $args['type'], [ 'text', 'password' ], true ) ) {
		$args['type'] = 'text';
	}

	$default  = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value    = wpforms_setting( $args['id'], $default );
	$id       = wpforms_sanitize_key( $args['id'] );
	$readonly = ! empty( $args['readonly'] ) ? ' readonly' : '';

	$output = '<input type="' . esc_attr( $args['type'] ) . '" id="wpforms-setting-' . $id . '" name="' . $id . '" value="' . esc_attr( $value ) . '" ' . $readonly . ' />';

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings password input field callback.
 *
 * @since 1.8.4
 *
 * @param array $args Setting field arguments.
 *
 * @return string
 */
function wpforms_settings_password_callback( array $args ): string {

	return wpforms_settings_text_callback( $args );
}

/**
 * Settings masked text input field callback.
 *
 * Renders a masked display (dots + last 4 chars) for saved values.
 * The real value is never sent to the browser.
 *
 * @since 1.10.1
 *
 * @param array $args Setting field arguments.
 *
 * @return string
 */
function wpforms_settings_masked_text_callback( array $args ): string {

	$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value   = wpforms_setting( $args['id'], $default );
	$id      = wpforms_sanitize_key( $args['id'] );

	if ( ! empty( $value ) ) {
		// Generate masked display: 14 dots + last 4 characters.
		$visible_chars = mb_strlen( $value ) > 4 ? mb_substr( $value, -4 ) : '';
		$masked_value  = str_repeat( '•', 14 ) . $visible_chars;
		$placeholder   = ! empty( $args['masked_placeholder'] )
			? $args['masked_placeholder']
			: __( 'Paste new API key to replace', 'wpforms-lite' );

		// No `name` attribute — JS adds it on focus so the field can submit a new value.
		// `data-masked-value` stores the masked string so JS can restore it on blur.
		$output  = '<div class="wpforms-masked-input-wrap">';
		$output .= '<input type="text" id="wpforms-setting-' . $id . '" value="' . esc_attr( $masked_value ) . '" data-masked="1" data-masked-value="' . esc_attr( $masked_value ) . '" data-masked-placeholder="' . esc_attr( $placeholder ) . '" data-name="' . esc_attr( $id ) . '" readonly />';
		$output .= '<button type="button" class="wpforms-masked-input-clear" title="' . esc_attr__( 'Remove Key', 'wpforms-lite' ) . '" aria-label="' . esc_attr__( 'Remove Key', 'wpforms-lite' ) . '"><i class="fa fa-times-circle" aria-hidden="true"></i></button>';
		$output .= '<input type="hidden" name="' . $id . '-clear" value="0" class="wpforms-masked-input-clear-flag" />';
		$output .= '</div>';
	} else {
		$output = '<input type="text" id="wpforms-setting-' . $id . '" name="' . $id . '" value="" />';
	}

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings number input field callback.
 *
 * @since 1.5.3
 *
 * @param array $args Setting field arguments.
 *
 * @return string
 * @noinspection HtmlUnknownAttribute
 */
function wpforms_settings_number_callback( array $args ): string {

	$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$id      = 'wpforms-setting-' . wpforms_sanitize_key( $args['id'] );
	$attr    = [
		'value' => wpforms_setting( $args['id'], $default ),
		'name'  => wpforms_sanitize_key( $args['id'] ),
	];
	$data    = ! empty( $args['data'] ) ? $args['data'] : [];

	if ( ! empty( $args['attr'] ) ) {
		$attr = array_merge( $attr, $args['attr'] );
	}

	$output = sprintf(
		'<input type="number" %s>',
		wpforms_html_attributes( $id, [], $data, $attr )
	);

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings select field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_select_callback( array $args ): string { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

	$default     = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value       = wpforms_setting( $args['id'], $default );
	$id          = wpforms_sanitize_key( $args['id'] );
	$select_name = $id;
	$class       = ! empty( $args['choicesjs'] ) ? 'choicesjs-select' : '';
	$choices     = ! empty( $args['choicesjs'] );
	$data        = isset( $args['data'] ) ? (array) $args['data'] : [];
	$attr        = isset( $args['attr'] ) ? (array) $args['attr'] : [];

	if ( $choices && ! empty( $args['search'] ) ) {
		$data['search'] = 'true';
	}

	if ( ! empty( $args['placeholder'] ) ) {
		$data['placeholder'] = $args['placeholder'];
	}

	$size_attr = '';

	if ( $choices && ! empty( $args['multiple'] ) ) {
		$attr[]      = 'multiple';
		$select_name = $id . '[]';
		$size_attr   = ' size="1"';
	}

	foreach ( $data as $name => $val ) {
		$data[ $name ] = 'data-' . sanitize_html_class( $name ) . '="' . esc_attr( $val ) . '"';
	}

	$data = implode( ' ', $data );
	$attr = implode( ' ', array_map( 'sanitize_html_class', $attr ) );

	$output  = $choices ? '<span class="choicesjs-select-wrap">' : '';
	$output .= '<select id="wpforms-setting-' . $id . '" name="' . $select_name . '" class="' . $class . '"' . $data . $attr . $size_attr . '>';

	foreach ( $args['options'] as $option => $name ) {
		if ( empty( $args['selected'] ) ) {
			$selected = selected( $value, $option, false );
		} else {
			$selected = is_array( $args['selected'] ) && in_array( $option, $args['selected'], true ) ? 'selected' : '';
		}
		$output .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
	}

	$output .= '</select>';
	$output .= $choices ? '</span>' : '';

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings checkbox field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_checkbox_callback( array $args ): string {

	$value    = wpforms_setting( $args['id'] );
	$id       = wpforms_sanitize_key( $args['id'] );
	$checked  = ! empty( $value ) ? checked( 1, $value, false ) : '';
	$disabled = ! empty( $args['disabled'] ) ? ' disabled' : '';

	$output = '<input type="checkbox" id="wpforms-setting-' . $id . '" name="' . $id . '" ' . $checked . $disabled . '>';

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	if ( ! empty( $args['disabled_desc'] ) ) {
		$output .= '<p class="disabled-desc">' . wp_kses_post( $args['disabled_desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings radio field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_radio_callback( array $args ): string {

	$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value   = wpforms_setting( $args['id'], $default );
	$id      = wpforms_sanitize_key( $args['id'] );
	$output  = '';
	$x       = 1;

	foreach ( $args['options'] as $option => $name ) {

		$checked = checked( $value, $option, false );
		$output .= '<span class="wpforms-settings-field-radio-wrapper">';
		$output .= '<input type="radio" id="wpforms-setting-' . $id . '[' . $x . ']" name="' . $id . '" value="' . esc_attr( $option ) . '" ' . $checked . '>';
		$output .= '<label for="wpforms-setting-' . $id . '[' . $x . ']" class="option-' . sanitize_html_class( $option ) . '">';
		$output .= esc_html( $name );
		$output .= '</label>';
		$output .= '</span>';

		++$x;
	}

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Email template endpoint field callback.
 *
 * @since 1.8.5
 *
 * @param array $args Field arguments.
 *
 * @return string
 */
function wpforms_settings_email_template_callback( array $args ): string {

	$id             = wpforms_sanitize_key( $args['id'] );
	$is_pro         = wpforms()->is_pro();
	$output         = '';
	$x              = 1;
	$education_args = [
		'name'   => esc_html__( 'Email Templates', 'wpforms-lite' ),
		'plural' => '1',
		'action' => 'upgrade',
	];

	foreach ( $args['options'] as $option => $attrs ) {
		$checked       = checked( $args['value'], $option, false );
		$has_education = ! $is_pro && isset( $attrs['is_pro'] ) && $attrs['is_pro'];
		$class         = [ 'wpforms-settings-field-radio-wrapper', 'wpforms-card-image' ];
		$data          = [];

		// Add class and data attributes for education modal, if needed.
		if ( $has_education ) {
			$class[] = 'education-modal'; // This class is used for JS.
			$data    = $education_args; // This data is used for JS.
		}

		$output .= '<span ' . wpforms_html_attributes( '', $class, $data ) . '>';
		$output .= '<input type="radio" id="wpforms-setting-' . $id . '[' . $x . ']" name="' . $id . '" value="' . esc_attr( $option ) . '" ' . $checked . '>';
		$output .= '<label for="wpforms-setting-' . $id . '[' . $x . ']" class="option-' . sanitize_html_class( $option ) . '">';
		$output .= esc_html( $attrs['name'] );

		// Add class and data attributes for education modal, if needed.
		if ( $has_education ) {
			$output .= EducationHelpers::get_badge( 'Pro' );
		}

		$output .= '<span class="wpforms-card-image-overlay">';
		$output .= '<span class="wpforms-btn-choose wpforms-btn wpforms-btn-md wpforms-btn-orange">';
		$output .= esc_html__( 'Choose', 'wpforms-lite' ) . '</span>';

		// Only add the preview action button if provided.
		if ( ! empty( $attrs['preview'] ) ) {
			$output .= '<a href="' . esc_url( $attrs['preview'] ) . '" class="wpforms-btn-preview wpforms-btn wpforms-btn-md wpforms-btn-light-grey" target="_blank">';
			$output .= esc_html__( 'Preview', 'wpforms-lite' );
			$output .= '</a>';
		}

		$output .= '</span>';
		$output .= '</label>';
		$output .= '</span>';

		++$x;
	}

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings toggle field callback.
 *
 * @since 1.7.4
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_toggle_callback( array $args ): string { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

	$value      = ! empty( $args['value'] ) ? $args['value'] : wpforms_setting( $args['id'] );
	$id         = wpforms_sanitize_key( $args['id'] );
	$class      = ! empty( $args['control-class'] ) ? $args['control-class'] : '';
	$class     .= ! empty( $args['is-important'] ) ? ' wpforms-important' : '';
	$input_attr = ! empty( $args['input-attr'] ) ? $args['input-attr'] : '';

	$default_args = [
		'control-class' => $class,
	];

	$args = wp_parse_args( $args, $default_args );

	$output = wpforms_panel_field_toggle_control(
		$args,
		'wpforms-setting-' . $id,
		$id,
		! empty( $args['label'] ) ? $args['label'] : '',
		$value,
		$input_attr
	);

	$desc_on  = ! empty( $args['desc'] ) ? $args['desc'] : '';
	$desc_on  = ! empty( $args['desc-on'] ) ? $args['desc-on'] : $desc_on;
	$desc_off = ! empty( $args['desc-off'] ) ? $args['desc-off'] : '';

	$output .= sprintf(
		'<p class="desc desc-on wpforms-toggle-desc%1$s">%2$s</p>',
		empty( $value ) && ! empty( $desc_off ) ? ' wpforms-hidden' : '',
		wp_kses_post( $desc_on )
	);

	if ( ! empty( $desc_off ) ) {
		$output .= sprintf(
			'<p class="desc desc-off wpforms-toggle-desc%1$s">%2$s</p>',
			empty( $value ) ? '' : ' wpforms-hidden',
			wp_kses_post( $desc_off )
		);
	}

	if ( ! empty( $args['disabled_desc'] ) ) {
		$output .= '<p class="disabled-desc">' . wp_kses_post( $args['disabled_desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings image uploads field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_image_callback( array $args ): string {

	$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value   = wpforms_setting( $args['id'], $default );
	$id      = wpforms_sanitize_key( $args['id'] );
	$output  = '';

	if ( ! empty( $value ) ) {
		$output .= '<img src="' . esc_url_raw( $value ) . '">';
	}

	$output .= '<input type="text" id="wpforms-setting-' . $id . '" name="' . $id . '" value="' . esc_url_raw( $value ) . '">';

	// Show the remove button if specified.
	if ( isset( $args['show_remove'] ) && $args['show_remove'] ) {
		$output .= '<button class="wpforms-btn wpforms-btn-md wpforms-setting-remove-image">' . esc_html__( 'Remove Image', 'wpforms-lite' ) . '</button>';
	}

	$output .= '<button class="wpforms-btn wpforms-btn-md wpforms-btn-light-grey wpforms-setting-upload-image">' . esc_html__( 'Upload Image', 'wpforms-lite' ) . '</button>';

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings color picker field callback.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 */
function wpforms_settings_color_callback( array $args ): string {

	$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
	$value   = wpforms_setting( $args['id'], $default );
	$id      = wpforms_sanitize_key( $args['id'] );
	$data    = isset( $args['data'] ) ? (array) $args['data'] : [];

	foreach ( $data as $name => $val ) {
		$data[ $name ] = 'data-' . sanitize_html_class( $name ) . '="' . esc_attr( $val ) . '"';
	}

	$data = implode( ' ', $data );

	$output = '<input type="text" id="wpforms-setting-' . $id . '" class="wpforms-color-picker" name="' . $id . '" value="' . esc_attr( $value ) . '" ' . $data . '>';

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Color scheme endpoint fieldset callback.
 * This function will output a fieldset with color picker inputs.
 *
 * @since 1.8.5
 *
 * @param array $args Field arguments.
 *
 * @return string
 */
function wpforms_settings_color_scheme_callback( array $args ): string {

	$id     = wpforms_sanitize_key( $args['id'] );
	$value  = wpforms_setting( $args['id'], [] );
	$output = '';

	foreach ( $args['colors'] as $color => $attrs ) {
		$data             = isset( $attrs['data'] ) ? (array) $attrs['data'] : [];
		$default_value    = isset( $data['fallback-color'] ) ? wpforms_sanitize_hex_color( $data['fallback-color'] ) : '';
		$field_id         = "{$id}-{$color}";
		$field_value      = isset( $value[ $color ] ) ? wpforms_sanitize_hex_color( $value[ $color ] ) : $default_value;
		$input_attributes = wpforms_html_attributes(
			"wpforms-setting-{$field_id}",
			[ 'wpforms-color-picker' ],
			$data,
			[
				'type'  => 'text',
				'name'  => "{$id}[{$color}]",
				'value' => esc_attr( $field_value ),
			]
		);

		$output .= "<input {$input_attributes}>";
		$output .= '<label for="wpforms-setting-' . $field_id . '">';
		$output .= esc_html( $attrs['name'] );
		$output .= '</label>';
	}

	if ( ! empty( $args['desc'] ) ) {
		$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
	}

	return $output;
}

/**
 * Settings providers field callback - this is for the Integrations tab.
 *
 * @since 1.3.9
 *
 * @param array $args Arguments.
 *
 * @return string
 * @noinspection PhpUnusedParameterInspection
 */
function wpforms_settings_providers_callback( array $args ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found

	$active    = wpforms_get_providers_available();
	$providers = wpforms_get_providers_options();

	$output = '<div id="wpforms-settings-providers">';

	ob_start();

	/**
	 * Output settings providers.
	 *
	 * @since 1.3.9.1
	 *
	 * @param array $active    Active providers.
	 * @param array $providers Providers options.
	 */
	do_action( 'wpforms_settings_providers', $active, $providers );

	$output .= ob_get_clean();
	$output .= '</div>';

	return $output;
}

/**
 * Webhooks' endpoint field callback.
 *
 * @since 1.8.4
 *
 * @param array $args Field arguments.
 *
 * @return string
 */
function wpforms_settings_webhook_endpoint_callback( array $args ): string {

	if ( empty( $args['url'] ) ) {
		return ''; // Early return if no URL is provided.
	}

	$provider    = $args['provider'] ?? 'stripe';
	$input_id    = "wpforms-{$provider}-webhook-endpoint-url";
	$copy_btn    = '<a class="button button-secondary wpforms-copy-to-clipboard" data-clipboard-target="#' . esc_attr( $input_id ) . '" href="#" aria-label="' . esc_attr__( 'Copy webhook URL', 'wpforms-lite' ) . '"><span class="fa-regular fa-copy" aria-hidden="true"></span></a>';
	$input_field = '<input type="text" disabled id="' . esc_attr( $input_id ) . '" value="' . esc_url( $args['url'] ) . '" />';

	// No whitespace between the input and the button: inline elements would render it as an extra gap.
	$output = sprintf(
		'<div class="%1$s">%2$s%3$s</div>',
		esc_attr( "wpforms-{$provider}-webhook-endpoint-url" ),
		$input_field,
		$copy_btn
	);

	if ( ! empty( $args['desc'] ) ) {
		$output .= sprintf( '<p class="desc">%s</p>', wp_kses_post( $args['desc'] ) );
	}

	return $output;
}

/**
 * Settings field columns callback.
 *
 * @since 1.5.8
 *
 * @param array $args Arguments passed by the setting.
 *
 * @return string
 */
function wpforms_settings_columns_callback( array $args ): string {

	if ( empty( $args['columns'] ) || ! is_array( $args['columns'] ) ) {
		return '';
	}

	$output = '<div class="wpforms-setting-columns">';

	foreach ( $args['columns'] as $column ) {

		// Define default callback for this field type.
		$callback = ! empty( $column['type'] ) ? 'wpforms_settings_' . $column['type'] . '_callback' : '';

		// Allow custom callback to be provided via arg.
		if ( ! empty( $column['callback'] ) ) {
			$callback = $column['callback'];
		}

		$output .= '<div class="wpforms-setting-column">';

		if ( ! empty( $column['name'] ) ) {
			$output .= '<label><b>' . wp_kses_post( $column['name'] ) . '</b></label>';
		}

		if ( function_exists( $callback ) ) {
			$output .= $callback( $column );
		}

		$output .= '</div>';
	}

	$output .= '</div>';

	return $output;
}