: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
wpforms_sanitize_classes( $input_class ),
wpforms_sanitize_classes( $control_class ),
! empty( $args['disabled'] ) ? 'disabled' : ''
* Get settings block state, whether it's opened or closed.
* @param int $form_id Form ID.
* @param int $block_id Block ID.
* @param string $block_type Block type.
function wpforms_builder_settings_block_get_state( $form_id, $block_id, $block_type ): string {
$form_id = absint( $form_id );
$block_id = absint( $block_id );
$block_type = sanitize_key( $block_type );
$all_states = get_user_meta( get_current_user_id(), 'wpforms_builder_settings_collapsable_block_states', true );
if ( empty( $all_states ) ) {
is_array( $all_states ) &&
! empty( $all_states[ $form_id ][ $block_type ][ $block_id ] ) &&
$all_states[ $form_id ][ $block_type ][ $block_id ] === 'closed'
// Backward compatibility for notifications.
if ( $block_type === 'notification' && $state !== 'closed' ) {
$notification_states = get_user_meta( get_current_user_id(), 'wpforms_builder_notification_states', true );
! empty( $notification_states[ $form_id ][ $block_id ] ) &&
$notification_states[ $form_id ][ $block_id ] === 'closed'
if ( $block_type === 'notification' ) {
// Backward compatibility for notifications.
* Filters notification get state.
* @param string $state Notification get state.
* @param int $form_id Form ID.
* @param int $block_id Block ID.
return (string) apply_filters( 'wpforms_builder_notification_get_state', $state, $form_id, $block_id ); // phpcs:ignore WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement
* Filters settings block state.
* @param string $state Settings block state.
* @param int $form_id Form ID.
* @param int $block_id Block ID.
* @param string $block_type Block type.
return apply_filters( 'wpforms_builder_settings_block_get_state', $state, $form_id, $block_id, $block_type );
* Get the list of allowed tags, used in a pair with wp_kses() function.
* This allows getting rid of all potentially harmful HTML tags and attributes.
* @return array Allowed Tags.
function wpforms_builder_preview_get_allowed_tags(): array {
if ( ! empty( $allowed_tags ) ) {
$atts = [ 'align', 'class', 'type', 'id', 'for', 'style', 'src', 'rel', 'href', 'target', 'value', 'width', 'height' ];
$tags = [ 'label', 'iframe', 'style', 'button', 'strong', 'small', 'table', 'span', 'abbr', 'code', 'pre', 'div', 'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'li', 'em', 'hr', 'br', 'th', 'tr', 'td', 'p', 'a', 'b', 'i' ];
$allowed_atts = array_fill_keys( $atts, [] );
$allowed_tags = array_fill_keys( $tags, $allowed_atts );
* Output builder panel fields group wrapper.
* @param string $inner Inner HTML to wrap.
* @param array $args Array of arguments.
* @param bool $do_echo Flag to display.
* @noinspection HtmlUnknownAttribute
function wpforms_panel_fields_group( $inner, $args = [], $do_echo = true ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded
$group = ! empty( $args['group'] ) ? $args['group'] : '';
$unfoldable = ! empty( $args['unfoldable'] );
$default = ( ! empty( $args['default'] ) && $args['default'] === 'opened' ) ? ' opened' : '';
$opened = ! empty( $_COOKIE[ 'wpforms_fields_group_' . $group ] ) && $_COOKIE[ 'wpforms_fields_group_' . $group ] === 'true' ? ' opened' : $default;
$class = ! empty( $args['class'] ) ? wpforms_sanitize_classes( $args['class'] ) : '';
'<div class="wpforms-panel-fields-group %1$s%2$s" %3$s>',
$unfoldable ? ' unfoldable' . $opened : '',
$unfoldable ? ' data-group="' . $group . '"' : ''
if ( ! empty( $args['borders'] ) && in_array( 'top', $args['borders'], true ) ) {
$output .= '<div class="wpforms-panel-fields-group-border-top"></div>';
if ( ! empty( $args['title'] ) ) {
$chevron = $unfoldable ? '<i class="fa fa-chevron-circle-right"></i>' : '';
$output .= '<div class="wpforms-panel-fields-group-title">' . esc_html( $args['title'] ) . $chevron . '</div>';
if ( ! empty( $args['description'] ) ) {
$output .= '<div class="wpforms-panel-fields-group-description">' . wp_kses_post( $args['description'] ) . '</div>';
'<div class="wpforms-panel-fields-group-inner" %s>%s</div>',
empty( $opened ) && $unfoldable ? ' style="display: none;"' : '',
if ( ! empty( $args['borders'] ) && in_array( 'bottom', $args['borders'], true ) ) {
$output .= '<div class="wpforms-panel-fields-group-border-bottom"></div>';
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
* Get the pages for the "Show Page" dropdown selection in Confirmations Settings in Builder.
* @param array $form_data Form data.
* @param int $confirmation_id Confirmation ID.
function wpforms_builder_form_settings_confirmation_get_pages( $form_data, $confirmation_id ): array {
$pre_selected_page_id = empty( $form_data['settings']['confirmations'][ $confirmation_id ]['page'] ) ? 0 : absint( $form_data['settings']['confirmations'][ $confirmation_id ]['page'] );
$pages = wp_list_pluck( wpforms_search_posts(), 'post_title', 'ID' );
if ( empty( $pre_selected_page_id ) || isset( $pages[ $pre_selected_page_id ] ) ) {
// If the pre-selected page isn't in `$pages`, we manually fetch it include it in `$pages`.
$pre_selected_page = get_post( $pre_selected_page_id );
if ( empty( $pre_selected_page ) ) {
$pages[ $pre_selected_page->ID ] = wpforms_get_post_title( $pre_selected_page );