: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPForms\Integrations\Stripe\Admin\Builder;
use WPForms\Integrations\Stripe\Helpers;
* Settings panel for Stripe in the Builder.
* Slug of the integration.
private $slug = 'stripe';
* Name of the integration.
private $name = 'Stripe';
* Marker means the payment integration is recommended.
private $recommended = true;
$this->icon = WPFORMS_PLUGIN_URL . 'assets/images/addon-icon-stripe.png';
$this->form_data = $this->get_form_data();
private function hooks() {
add_filter( 'wpforms_payments_available', [ $this, 'register_payment' ] );
add_action( 'wpforms_payments_panel_content', [ $this, 'builder_output' ], 0 );
add_action( 'wpforms_payments_panel_sidebar', [ $this, 'builder_sidebar' ], 0 );
add_filter( 'wpforms_admin_education_addons_item_base_display_single_addon_hide', [ $this, 'should_hide_educational_menu_item' ], 10, 2 );
* Register the payment gateway.
* @param array $payments_available List of available payment gateways.
public function register_payment( $payments_available ) {
$payments_available[ $this->slug ] = $this->name;
return $payments_available;
* Output the gateway menu item.
public function builder_sidebar() {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'builder/payment/sidebar',
'configured' => $this->is_payments_enabled() ? 'configured' : '',
'recommended' => $this->recommended,
* Output the gateway settings.
public function builder_output() {
<div class="wpforms-panel-content-section wpforms-panel-content-section-<?php echo esc_attr( $this->slug ); ?>"
id="<?php echo esc_attr( $this->slug ); ?>-provider" data-provider="<?php echo esc_attr( $this->slug ); ?>">
<div class="wpforms-panel-content-section-title">
<?php echo esc_html( $this->name ); ?>
<div class="wpforms-payment-settings wpforms-clear">
<?php $this->builder_content(); ?>
* Check if it is going to be displayed Stripe educational menu item and hide it.
* @param bool $hide Whether to hide the menu item.
* @param array $addon Addon data.
public function should_hide_educational_menu_item( $hide, $addon ) {
return isset( $addon['clear_slug'] ) && $this->slug === $addon['clear_slug'] ? true : $hide;
* Check if payments enabled.
private function is_payments_enabled() {
return ! empty( $this->form_data['payments'][ $this->slug ]['enable'] );
private function get_form_data() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
$form_data = wpforms()->get( 'form' )->get(
return is_array( $form_data ) ? $form_data : [];
* Get single payments conditional logic for the Stripe settings panel.
private function single_payments_conditional_logic_section() {
return $this->get_conditional_logic_toggle();
* Get recurring payments conditional logic for the Stripe settings panel.
* @since 1.8.4 Added Plan ID parameter.
* @param string $plan_id Plan ID.
private function recurring_payments_conditional_logic_section( $plan_id ) {
return $this->get_conditional_logic_toggle( true );
* Get education toggle for the conditional logic.
* @param bool $is_recurring Is recurring section.
private function get_conditional_logic_toggle( $is_recurring = false ) {
return wpforms_panel_field(
$this->maybe_reset_conditional_logic( $this->form_data ),
esc_html__( 'Enable Conditional Logic', 'wpforms-lite' ),
'input_class' => 'education-modal',
'subsection' => $is_recurring ? 'recurring' : '',
'pro_badge' => ! Helpers::is_allowed_license_type(),
'data' => $this->get_conditional_logic_section_data(),
'disabled' => 'disabled',
* Get conditional logic section data.
private function get_conditional_logic_section_data() {
$addon = wpforms()->get( 'addons' )->get_addon( 'stripe' );
empty( $addon['action'] ) ||
empty( $addon['status'] ) || (
$addon['status'] === 'active' &&
$addon['action'] !== 'upgrade'
if ( $addon['plugin_allow'] && $addon['action'] === 'install' ) {
'message' => esc_html__( 'The Stripe Pro addon is required to enable conditional logic for payments. Would you like to install and activate it?', 'wpforms-lite' ),
'nonce' => wp_create_nonce( 'wpforms-admin' ),
if ( $addon['plugin_allow'] && $addon['action'] === 'activate' ) {
'message' => esc_html__( 'The Stripe Pro addon is required to enable conditional logic for payments. Would you like to activate it?', 'wpforms-lite' ),
'path' => $addon['path'],
'nonce' => wp_create_nonce( 'wpforms-admin' ),
'name' => esc_html__( 'Smart Conditional Logic', 'wpforms-lite' ),
'utm-content' => 'Builder Stripe Conditional Logic',
* Maybe reset conditional logic.
* If Stripe Pro is disabled, reset conditional logic for Stripe settings.
* @param array $form_data Form data.
private function maybe_reset_conditional_logic( $form_data ) {
if ( Helpers::is_pro() ) {
! isset( $form_data['payments']['stripe']['conditional_logic'] ) &&
! isset( $form_data['payments']['stripe']['recurring']['conditional_logic'] )
$form_data['payments']['stripe']['conditional_logic'],
$form_data['payments']['stripe']['recurring']['conditional_logic']