: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$value = ! empty( $field['input_columns'] ) ? esc_attr( $field['input_columns'] ) : '';
$tooltip = esc_html__( 'Select the layout for displaying field choices.', 'wpforms-lite' );
'' => esc_html__( 'One Column', 'wpforms-lite' ),
'2' => esc_html__( 'Two Columns', 'wpforms-lite' ),
'3' => esc_html__( 'Three Columns', 'wpforms-lite' ),
'inline' => esc_html__( 'Inline', 'wpforms-lite' ),
$output = $this->field_element(
'slug' => 'input_columns',
'value' => esc_html__( 'Choice Layout', 'wpforms-lite' ),
$output .= $this->field_element(
'slug' => 'input_columns',
$output = $this->field_element(
'slug' => 'input_columns',
$value = ! empty( $field['dynamic_choices'] ) ? esc_attr( $field['dynamic_choices'] ) : '';
$tooltip = esc_html__( 'Select auto-populate method to use.', 'wpforms-lite' );
'' => esc_html__( 'Off', 'wpforms-lite' ),
'post_type' => esc_html__( 'Post Type', 'wpforms-lite' ),
'taxonomy' => esc_html__( 'Taxonomy', 'wpforms-lite' ),
$output = $this->field_element(
'slug' => 'dynamic_choices',
'value' => esc_html__( 'Dynamic Choices', 'wpforms-lite' ),
$output .= $this->field_element(
'slug' => 'dynamic_choices',
$output = $this->field_element(
'slug' => 'dynamic_choices',
'class' => ! empty( $field['choices_images'] ) || ! empty( $field['choices_icons'] ) ? 'wpforms-hidden' : '',
* Dynamic Choices Source.
case 'dynamic_choices_source':
$type = ! empty( $field['dynamic_choices'] ) ? esc_attr( $field['dynamic_choices'] ) : '';
if ( ! empty( $type ) ) {
if ( $type === 'post_type' ) {
$type_name = esc_html__( 'Post Type', 'wpforms-lite' );
unset( $items['attachment'] );
} elseif ( $type === 'taxonomy' ) {
$type_name = esc_html__( 'Taxonomy', 'wpforms-lite' );
'publicly_queryable' => true,
unset( $items['post_format'] );
/* translators: %s - dynamic source type name. */
$tooltip = sprintf( esc_html__( 'Select %s to use for auto-populating field choices.', 'wpforms-lite' ), esc_html( $type_name ) );
/* translators: %s - dynamic source type name. */
$label = sprintf( esc_html__( 'Dynamic %s Source', 'wpforms-lite' ), esc_html( $type_name ) );
$source = ! empty( $field[ 'dynamic_' . $type ] ) ? esc_attr( $field[ 'dynamic_' . $type ] ) : '';
static function ( $prev_item, $item ) {
return strcmp( $prev_item->name, $item->name );
foreach ( $items as $key => $item ) {
$options[ $key ] = esc_html( $item->labels->name );
$option_label = $this->field_element(
'slug' => 'dynamic_' . $type,
// Field option select input.
$option_input = $this->field_element(
'slug' => 'dynamic_' . $type,
// Field option row (markup) including label and input.
$output = $this->field_element(
'slug' => 'dynamic_' . $type,
'content' => $option_label . $option_input,
$is_allowed = RequirementsAlerts::is_product_quantities_allowed();
$enable_quantity = $this->is_payment_quantities_enabled( $field );
$min_quantity = isset( $field['min_quantity'] ) ? (int) $field['min_quantity'] : 0;
$max_quantity = isset( $field['max_quantity'] ) ? (int) $field['max_quantity'] : 10;
$toggle_tooltip = esc_html__( 'Enable quantity for this product to allow customers to purchase more than one.', 'wpforms-lite' );
$range_tooltip = esc_html__( 'Set the minimum and maximum quantity for this product.', 'wpforms-lite' );
$hidden_class = ! empty( $args['hidden'] ) ? 'wpforms-hidden' : '';
'slug' => 'enable_quantity',
'value' => $enable_quantity,
'desc' => esc_html__( 'Enable Quantity', 'wpforms-lite' ),
'tooltip' => $toggle_tooltip,
$toggle_data['attrs'] = [ 'disabled' => 'disabled' ];
$toggle_data['control-class'] = 'wpforms-toggle-control-disabled';
$toggle = $this->field_element(
$output = $this->field_element(
'slug' => 'enable_quantity',
'class' => $hidden_class,
$min_has_error = $min_quantity > $max_quantity ? 'wpforms-error' : '';
$content = $this->field_element(
'value' => esc_html__( 'Range', 'wpforms-lite' ),
'tooltip' => $range_tooltip,
$content .= '<div class="wpforms-field-options-quantity-columns">';
$content .= '<div class="wpforms-field-options-quantity-column">';
$content .= $this->field_element(
'slug' => 'min_quantity',
'value' => $min_quantity,
'after' => esc_html__( 'Minimum', 'wpforms-lite' ),
'class' => [ 'wpforms-field-options-column', 'min-quantity-input', $min_has_error ],
$content .= '<div class="wpforms-field-options-quantity-column">';
$content .= $this->field_element(
'slug' => 'max_quantity',
'value' => $max_quantity,
'after' => esc_html__( 'Maximum', 'wpforms-lite' ),
'class' => [ 'wpforms-field-options-column', 'max-quantity-input' ],
$range_hidden_class = $enable_quantity && empty( $args['hidden'] ) ? '' : 'wpforms-hidden';
$output .= $this->field_element(
'class' => [ $range_hidden_class, 'wpforms-field-quantity-option' ],
$output .= $this->field_element(
'slug' => 'quantities_alert',
'content' => RequirementsAlerts::get_product_quantities_alert(),
'class' => $hidden_class,
if ( ! in_array( $option, [ 'basic-options', 'advanced-options' ], true ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( $markup === 'open' ) {
do_action( "wpforms_field_options_before_{$option}", $field, $this );
if ( $markup === 'close' ) {
do_action( "wpforms_field_options_bottom_{$option}", $field, $this );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( $markup === 'open' ) {
do_action( "wpforms_field_options_top_{$option}", $field, $this );
if ( $markup === 'close' ) {
do_action( "wpforms_field_options_after_{$option}", $field, $this );
* Helper function to create common field options that are used frequently
* @since 1.5.0 Added support for <select> HTML tag for choices.
* @since 1.6.1 Added multiple select support.
* @param string $option Field option to render.
* @param array $field Field data and settings.
* @param array $args Field preview arguments.
* @param bool $echo Print or return the value. Print by default.
* @return mixed Print or return a string.
public function field_preview_option( $option, $field, $args = [], $echo = true ) {
$class = ! empty( $args['class'] ) ? wpforms_sanitize_classes( $args['class'] ) : '';
$allowed_tags = wpforms_builder_preview_get_allowed_tags();
$label = isset( $field['label'] ) && ! empty( $field['label'] ) ? esc_html( $field['label'] ) : esc_html__( 'Empty Label', 'wpforms-lite' );
$label_hidden = esc_html__( 'Label Hidden', 'wpforms-lite' );
$label_empty = esc_html__( 'To ensure your form is accessible, every field should have a descriptive label. If you\'d like to hide the label, you can do so by enabling Hide Label in the Advanced Field Options tab.', 'wpforms-lite' );
'<label class="label-title %s"><span class="hidden_text" title="%s"><i class="fa fa-eye-slash"></i></span><span class="empty_text" title="%s"><i class="fa fa-exclamation-triangle"></i></span><span class="text">%s</span><span class="required">*</span></label>',
$description = isset( $field['description'] ) && ! empty( $field['description'] ) ? wp_kses( $field['description'], $allowed_tags ) : '';
$description = strpos( $class, 'nl2br' ) !== false ? nl2br( $description ) : $description;
$output = sprintf( '<div class="description %s">%s</div>', $class, $description );
$fields_w_choices = [ 'checkbox', 'gdpr-checkbox', 'select', 'payment-select', 'radio', 'payment-multiple', 'payment-checkbox' ];
$slice_size = in_array( $field['type'], [ 'payment-select', 'select' ], true ) ? 250 : 20;
$values = ! empty( $field['choices'] ) ? $field['choices'] : $this->defaults;
$dynamic = ! empty( $field['dynamic_choices'] ) ? $field['dynamic_choices'] : false;
$total = count( $values );
$values = array_slice( $values, 0, $slice_size );
* Check to see if this field is configured for Dynamic Choices,
* either auto populating from a post type or a taxonomy.
if ( ! empty( $field['dynamic_post_type'] ) || ! empty( $field['dynamic_taxonomy'] ) ) {
// Post type dynamic populating.
$total_obj = wp_count_posts( $field['dynamic_post_type'] );
$total = isset( $total_obj->publish ) ? (int) $total_obj->publish : 0;
$posts = wpforms_get_hierarchical_object(
'wpforms_dynamic_choice_post_type_args',
'post_type' => $field['dynamic_post_type'],
foreach ( $posts as $post ) {
'label' => esc_html( wpforms_get_post_title( $post ) ),
// Taxonomy dynamic populating.
$total = (int) wp_count_terms( $field['dynamic_taxonomy'] );
$terms = wpforms_get_hierarchical_object(
'wpforms_dynamic_choice_taxonomy_args',
'taxonomy' => $field['dynamic_taxonomy'],
foreach ( $terms as $term ) {
'label' => esc_html( wpforms_get_term_name( $term ) ),
if ( ! in_array( $field['type'], $fields_w_choices, true ) ) {
switch ( $field['type'] ) {
$list_class = [ 'primary-input' ];
$with_images = empty( $field['dynamic_choices'] ) && empty( $field['choices_icons'] ) && ! empty( $field['choices_images'] );
$with_icons = empty( $field['dynamic_choices'] ) && empty( $field['choices_images'] ) && ! empty( $field['choices_icons'] );
$list_class[] = 'wpforms-image-choices';
$list_class[] = 'wpforms-image-choices-' . sanitize_html_class( $field['choices_images_style'] );
$list_class[] = 'wpforms-icon-choices';
$list_class[] = sanitize_html_class( 'wpforms-icon-choices-' . $field['choices_icons_style'] );
$list_class[] = sanitize_html_class( 'wpforms-icon-choices-' . $field['choices_icons_size'] );
$icon_color = isset( $field['choices_icons_color'] ) ? wpforms_sanitize_hex_color( $field['choices_icons_color'] ) : '';
$icon_color = empty( $icon_color ) ? IconChoices::get_default_color() : $icon_color;
$inline_style = "--wpforms-icon-choices-color: {$icon_color};";
if ( ! empty( $class ) ) {
// Special rules for <select>-based fields.
if ( $type === 'select' ) {
if ( empty( $values ) ) {
$list_class[] = 'wpforms-hidden';