: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
/* global wpforms_builder, wpforms_builder_stripe */
* Stripe builder function.
const WPFormsStripeModernBuilder = window.WPFormsStripeModernBuilder || ( function( document, window, $ ) {
* Public functions and properties.
* Initialized once the DOM is fully loaded.
if ( app.isLegacySettings() ) {
$alert: $( '#wpforms-stripe-credit-card-alert' ),
$panelContent: $( '#wpforms-panel-content-section-payment-stripe' ),
$feeNotice: $( '.wpforms-stripe-notice-info' ),
if ( ! wpforms_builder_stripe.is_pro ) {
const toggleInput = '.wpforms-panel-content-section-payment-toggle input',
planNameInput = '.wpforms-panel-content-section-payment-plan-name input';
$( toggleInput ).each( app.toggleContent );
$( planNameInput ).each( app.checkPlanName );
$( '#wpforms-panel-payments' )
.on( 'click', toggleInput, app.toggleContent )
.on( 'click', '.wpforms-panel-content-section-payment-plan-head-buttons-toggle', app.togglePlan )
.on( 'click', '.wpforms-panel-content-section-stripe .wpforms-panel-content-section-payment-plan-head-buttons-delete', app.deletePlan )
.on( 'input', planNameInput, app.renamePlan )
.on( 'focusout', planNameInput, app.checkPlanName );
* Process various events as a response to UI interactions.
const $builder = $( '#wpforms-builder' );
$builder.on( 'wpformsFieldDelete', app.disableNotifications )
.on( 'wpformsSaved', app.requiredFieldsCheck )
.on( 'wpformsFieldAdd', app.fieldAdded )
.on( 'wpformsFieldDelete', app.fieldDeleted )
.on( 'wpformsPaymentsPlanCreated', app.toggleMultiplePlansWarning )
.on( 'wpformsPaymentsPlanDeleted', app.toggleMultiplePlansWarning );
* On form save notify users about required fields.
if ( ! $( '#wpforms-panel-field-stripe-enable_recurring' ).is( ':checked' ) || el.$panelContent.hasClass( 'wpforms-hidden' ) ) {
el.$panelContent.find( '.wpforms-panel-content-section-payment-plan' ).each( function() {
planId = $plan.data( 'plan-id' );
if ( ! $plan.find( `#wpforms-panel-field-stripe-recurring-${ planId }-email` ).val() ) {
app.recurringEmailAlert();
* Show alert for required recurring email field.
title: wpforms_builder.heads_up,
content: wpforms_builder.stripe_recurring_email,
icon: 'fa fa-exclamation-circle',
text: wpforms_builder.ok,
* @param {Object} e Event object.
* @param {number} id Field ID.
* @param {string} type Field type.
disableNotifications( e, id, type ) {
if ( ! app.isStripeField( type ) ) {
const $notificationWrap = $( '.wpforms-panel-content-section-notifications [id*="-stripe-wrap"]' );
$notificationWrap.find( 'input[id*="-stripe"]' ).prop( 'checked', false );
$notificationWrap.addClass( 'wpforms-hidden' );
* Determine is legacy settings is loaded.
* @return {boolean} True is legacy settings loaded.
return $( '#wpforms-panel-field-stripe-enable' ).length;
* We have to do several actions when the "Stripe" field is added.
* @param {Object} e Event object.
* @param {number} id Field ID.
* @param {string} type Field type.
fieldAdded( e, id, type ) {
if ( ! app.isStripeField( type ) ) {
app.settingsToggle( true );
el.$feeNotice.toggleClass( 'wpforms-hidden' );
* We have to do several actions when the "Stripe" field is deleted.
* @param {Object} e Event object.
* @param {number} id Field ID.
* @param {string} type Field type.
fieldDeleted( e, id, type ) {
if ( ! app.isStripeField( type ) ) {
app.settingsToggle( false );
el.$feeNotice.toggleClass( 'wpforms-hidden' );
* Determine if field type is Stripe credit card.
* @param {string} type Field type.
* @return {boolean} True if Stripe field.
return wpforms_builder_stripe.field_slugs.includes( type );
* Toggles visibility of multiple plans warning.
toggleMultiplePlansWarning() {
el.$panelContent.find( '.wpforms-stripe-multiple-plans-warning' ).toggleClass( 'wpforms-hidden', el.$panelContent.find( '.wpforms-panel-content-section-payment-plan' ).length === 1 );
* Toggles visibility of the Stripe addon settings.
* @param {boolean} display Show or hide settings.
settingsToggle( display ) {
! el.$panelContent.length
el.$alert.toggleClass( 'wpforms-hidden', display );
el.$panelContent.toggleClass( 'wpforms-hidden', ! display );
* Toggle payments content.
const $input = $( this );
$( '#wpforms-panel-field-stripe-enable_recurring' ).is( ':checked' ) &&
$( '#wpforms-panel-field-stripe-enable_one_time' ).is( ':checked' )
$input.prop( 'checked', false );
title: wpforms_builder.heads_up,
content: $input.attr( 'id' ) === 'wpforms-panel-field-stripe-enable_recurring' ? wpforms_builder_stripe.disabled_recurring : wpforms_builder_stripe.disabled_one_time,
icon: 'fa fa-exclamation-circle',
text: wpforms_builder.ok,
$input.prop( 'checked', false );
const $wrapper = $input.closest( '.wpforms-panel-content-section-payment' ),
isChecked = $input.prop( 'checked' ) && ! $( '#wpforms-panel-field-settings-disable_entries' ).prop( 'checked' );
$wrapper.find( '.wpforms-panel-content-section-payment-toggled-body' ).toggle( isChecked );
$wrapper.toggleClass( 'wpforms-panel-content-section-payment-open', isChecked );
const $plan = $( this ).closest( '.wpforms-panel-content-section-payment-plan' ),
$icon = $plan.find( '.wpforms-panel-content-section-payment-plan-head-buttons-toggle' );
$icon.toggleClass( 'fa-chevron-circle-up fa-chevron-circle-down' );
$plan.find( '.wpforms-panel-content-section-payment-plan-body' ).toggle( $icon.hasClass( 'fa-chevron-circle-down' ) );
// Trigger a warning modal when trying to delete single plan without pro addon.
$( '.wpforms-panel-content-section-stripe .wpforms-panel-content-section-payment-button-add-plan' ).click();
* Check a plan name on empty value.
const $input = $( this ),
$plan = $input.closest( '.wpforms-panel-content-section-payment-plan' ),
$planName = $plan.find( '.wpforms-panel-content-section-payment-plan-head-title' );
$planName.html( $input.val() );
const defaultValue = wpforms_builder_stripe.plan_placeholder;
$planName.html( defaultValue );
$input.val( defaultValue );
const $input = $( this ),
$plan = $input.closest( '.wpforms-panel-content-section-payment-plan' ),
$planName = $plan.find( '.wpforms-panel-content-section-payment-plan-head-title' );
$planName.html( $input.val() );
// Provide access to public functions/properties.
}( document, window, jQuery ) );
WPFormsStripeModernBuilder.init();