: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPForms\Integrations\Stripe\Admin\Builder\Traits;
use WPForms\Integrations\Stripe\Helpers;
use WPForms\Integrations\Stripe\Admin\Notices;
* Payment builder settings content trait.
* Display content inside the panel content area.
public function builder_content() {
if ( $this->builder_alerts() ) {
$hide_class = ! Helpers::has_stripe_field( $this->form_data ) ? 'wpforms-hidden' : '';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo Notices::get_fee_notice( $hide_class );
if ( Helpers::is_legacy_payment_settings( $this->form_data ) ) {
$this->legacy_builder_content();
$this->maybe_convert_legacy_settings();
echo '<div id="wpforms-panel-content-section-payment-stripe" class="' . esc_attr( $hide_class ) . '">';
if ( ! Helpers::is_pro() ) {
$this->builder_content_one_time();
$this->builder_content_recurring();
parent::builder_content();
* Convert legacy settings if they exist.
private function maybe_convert_legacy_settings() {
// Enable one-time payments if they were active.
if ( ! empty( $this->form_data['payments']['stripe']['enable'] ) ) {
unset( $this->form_data['payments']['stripe']['enable'] );
$this->form_data['payments']['stripe']['enable_one_time'] = 1;
// Convert subscription settings if they exist and disabled to new default plan.
empty( $this->form_data['payments']['stripe']['recurring'] ) ||
! empty( $this->form_data['payments']['stripe']['enable_recurring'] )
$stripe_recurring_settings = $this->form_data['payments']['stripe']['recurring'];
unset( $this->form_data['payments']['stripe']['recurring'] );
! empty( $stripe_recurring_settings['enable'] ) ||
array_filter( $stripe_recurring_settings, 'is_array' ) === $stripe_recurring_settings
// Preserve all settings (name, period, email, and CL).
$this->form_data['payments']['stripe']['recurring'][] = $stripe_recurring_settings;
* Display legacy content inside the panel content area.
private function legacy_builder_content() {
$this->enable_payments_toggle();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->content_section_body();
* Builder content for one time payments.
private function builder_content_one_time() {
<div class="wpforms-panel-content-section-payment">
<h2 class="wpforms-panel-content-section-payment-subtitle">
<?php esc_html_e( 'One-Time Payments', 'wpforms-lite' ); ?>
esc_html__( 'Enable one-time payments', 'wpforms-lite' ),
'tooltip' => esc_html__( 'Allow your customers to one-time pay via the form.', 'wpforms-lite' ),
'class' => 'wpforms-panel-content-section-payment-toggle wpforms-panel-content-section-payment-toggle-one-time',
<div class="wpforms-panel-content-section-payment-one-time wpforms-panel-content-section-payment-toggled-body">
<?php echo $this->get_builder_content_one_time_content(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
* Builder content for recurring payments.
private function builder_content_recurring() {
<div class="wpforms-panel-content-section-payment">
<h2 class="wpforms-panel-content-section-payment-subtitle">
<?php esc_html_e( 'Recurring Payments ', 'wpforms-lite' ); ?>
$this->add_plan_education();
esc_html__( 'Enable recurring subscription payments', 'wpforms-lite' ),
'tooltip' => esc_html__( 'Allow your customer to pay recurringly via the form.', 'wpforms-lite' ),
'class' => 'wpforms-panel-content-section-payment-toggle wpforms-panel-content-section-payment-toggle-recurring',
<div class="wpforms-panel-content-section-payment-recurring wpforms-panel-content-section-payment-toggled-body">
if ( empty( $this->form_data['payments'][ $this->slug ]['recurring'] ) ) {
$this->form_data['payments'][ $this->slug ]['recurring'][] = [];
foreach ( $this->form_data['payments'][ $this->slug ]['recurring'] as $plan_id => $plan_settings ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'builder/payment/recurring/item',
'content' => $this->get_builder_content_recurring_payment_content( $plan_id ),
// Limit plans if Stripe addon is NOT active.
* Add new plan education modals.
private function add_plan_education() {
$label = __( 'Add New Plan', 'wpforms-lite' );
if ( Helpers::is_allowed_license_type() ) {
$addon = wpforms()->get( 'addons' )->get_addon( 'wpforms-stripe' );
class="wpforms-panel-content-section-payment-button wpforms-panel-content-section-payment-button-add-plan education-modal"
data-action="' . esc_attr( $addon['action'] ) . '"
data-path="' . esc_attr( $addon['path'] ) . '"
data-slug="' . esc_attr( $addon['slug'] ) . '"
data-url="' . esc_url( $addon['url'] ) . '"
data-nonce="' . esc_attr( wp_create_nonce( 'wpforms-admin' ) ) . '"
data-name="' . esc_attr__( 'Stripe Pro', 'wpforms-lite' ) . '"
>' . esc_html( $label ) . '</a>';
class="wpforms-panel-content-section-payment-button wpforms-panel-content-section-payment-button-add-plan education-modal"
data-name="' . esc_attr__( 'Multiple Stripe Subscription Plans', 'wpforms-lite' ) . '"
>' . esc_html( $label ) . '</a>';
* Display alert if Stripe keys are not set.
private function builder_alerts() {
if ( Helpers::has_stripe_keys() ) {
if ( Helpers::is_legacy_payment_settings( $this->form_data ) ) {
Notices::prompt_new_interface();
$this->stripe_credit_card_alert();
echo '<div class="wpforms-builder-payment-settings-default-content"><p>';
esc_html_e( 'Heads up! Stripe payments can\'t be enabled yet.', 'wpforms-lite' );
wp_kses( /* translators: %1$s - admin area Payments settings page URL. */
__( 'First, please connect to your Stripe account on the <a href="%1$s" class="secondary-text">WPForms Settings</a> page.', 'wpforms-lite' ),
esc_url( admin_url( 'admin.php?page=wpforms-settings&view=payments' ) )
echo '</p><p class="wpforms-builder-payment-settings-learn-more">';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->learn_more_link();
* Display alert if Stripe Credit Card field is not added to the form.
private function stripe_credit_card_alert() {
$hide_class = Helpers::has_stripe_field( $this->form_data ) ? 'wpforms-hidden' : '';
<div id="wpforms-stripe-credit-card-alert" class="wpforms-alert wpforms-alert-info <?php echo esc_attr( $hide_class ); ?>">
<?php $this->alert_icon(); ?>
<div class="wpforms-builder-payment-settings-default-content">
<p><?php esc_html_e( 'To use Stripe, first add the Stripe payment field to your form.', 'wpforms-lite' ); ?></p>
<p class="wpforms-builder-payment-settings-learn-more"><?php echo $this->learn_more_link(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
* Display toggle to enable Stripe payments.
private function enable_payments_toggle() {
esc_html__( 'Enable Stripe payments', 'wpforms-lite' ),
* Display content inside the panel content section.
* @return string Stripe settings builder content section.
private function content_section_body() {
$content = '<div class="wpforms-panel-content-section-stripe-body">';
$content .= $this->get_builder_content_one_time_content();
$content .= sprintf( '<h2>%1$s</h2>', esc_html__( 'Subscriptions', 'wpforms-lite' ) );
$content .= wpforms_panel_field(
esc_html__( 'Enable recurring subscription payments', 'wpforms-lite' ),
'subsection' => 'recurring',
$content .= $this->get_builder_content_recurring_payment_content( '' );
* Get content inside the one time payment area.
protected function get_builder_content_one_time_content() {
$content = wpforms_panel_field(
esc_html__( 'Payment Description', 'wpforms-lite' ),
'tooltip' => esc_html__( 'Enter your payment description. Eg: Donation for the soccer team. Only used for standard one-time payments.', 'wpforms-lite' ),
$content .= wpforms_panel_field(
esc_html__( 'Stripe Payment Receipt', 'wpforms-lite' ),
'field_map' => [ 'email' ],
'placeholder' => esc_html__( '--- Select Email ---', 'wpforms-lite' ),
'tooltip' => esc_html__( 'If you would like to have Stripe send a receipt after payment, select the email field to use. This is optional but recommended. Only used for standard one-time payments.', 'wpforms-lite' ),
$content .= wpforms_panel_field(
esc_html__( 'Customer Email', 'wpforms-lite' ),
'field_map' => [ 'email' ],
'placeholder' => esc_html__( '--- Select Email ---', 'wpforms-lite' ),
'tooltip' => esc_html__( 'Select the field that contains the customer\'s email address. This is optional but recommended.', 'wpforms-lite' ),
$content .= $this->get_customer_name_panel_field();
$content .= $this->get_address_panel_fields();
$content .= $this->single_payments_conditional_logic_section();
* Get content inside the recurring payment area.
* @param string $plan_id Plan id.
protected function get_builder_content_recurring_payment_content( $plan_id ) {
$content = wpforms_panel_field(
esc_html__( 'Plan Name', 'wpforms-lite' ),
'subsection' => 'recurring',
'tooltip' => esc_html__( 'Enter the subscription name. Eg: Email Newsletter. Subscription period and price are automatically appended. If left empty the form name will be used.', 'wpforms-lite' ),
'class' => 'wpforms-panel-content-section-payment-plan-name',
$content .= wpforms_panel_field(
esc_html__( 'Recurring Period', 'wpforms-lite' ),
'subsection' => 'recurring',
'daily' => esc_html__( 'Daily', 'wpforms-lite' ),
'weekly' => esc_html__( 'Weekly', 'wpforms-lite' ),
'monthly' => esc_html__( 'Monthly', 'wpforms-lite' ),
'quarterly' => esc_html__( 'Quarterly', 'wpforms-lite' ),
'semiyearly' => esc_html__( 'Semi-Yearly', 'wpforms-lite' ),
'yearly' => esc_html__( 'Yearly', 'wpforms-lite' ),
'tooltip' => esc_html__( 'How often you would like the charge to recur.', 'wpforms-lite' ),
$content .= wpforms_panel_field(
esc_html__( 'Customer Email', 'wpforms-lite' ),
'subsection' => 'recurring',
'field_map' => [ 'email' ],
'placeholder' => esc_html__( '--- Select Email ---', 'wpforms-lite' ),
'tooltip' => esc_html__( "Select the field that contains the customer's email address. This field is required.", 'wpforms-lite' ),
$content .= $this->get_customer_name_panel_field( $plan_id );
$content .= $this->get_address_panel_fields( $plan_id );
$content .= $this->recurring_payments_conditional_logic_section( $plan_id );
private function alert_icon() {
'<img src="%1$s" class="wpforms-builder-payment-settings-alert-icon" alt="%2$s">',
esc_url( WPFORMS_PLUGIN_URL . 'assets/images/addon-icon-stripe.png' ),
esc_attr__( 'Connect WPForms to Stripe.', 'wpforms-lite' )