: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( empty( $_GET['form_id'] ) || ! empty( $this->form_data ) ) {
$revisions = wpforms()->get( 'revisions' );
$revision = $revisions ? $revisions->get_revision() : null;
// Setup form data based on the revision_id.
$this->form_data = wpforms_decode( $revision->post_content );
// Setup form data based on the ID.
$form = wpforms()->get( 'form' );
$this->form_data = $form->get(
absint( $_GET['form_id'] ),
[ 'content_only' => true ]
// phpcs:enable WordPress.Security.NonceVerification.Recommended
* Display content inside the panel content area.
public function builder_content() {
$form_data = $this->form_data;
$providers = wpforms_get_providers_options();
if ( ! empty( $form_data['providers'][ $this->slug ] ) && ! empty( $providers[ $this->slug ] ) ) {
foreach ( $form_data['providers'][ $this->slug ] as $connection_id => $connection ) {
foreach ( $providers[ $this->slug ] as $account_id => $connections ) {
! empty( $connection['account_id'] ) &&
$connection['account_id'] === $account_id
echo $this->output_connection( $connection_id, $connection, $form_data );
* Get provider configured status.
private function get_configured() {
return ! empty( $this->form_data['id'] ) && Status::init( $this->slug )->is_ready( $this->form_data['id'] )
* Display content inside the panel sidebar area.
public function builder_sidebar() {
$configured = $this->get_configured();
echo '<a href="#" class="wpforms-panel-sidebar-section icon ' . esc_attr( $configured ) . ' wpforms-panel-sidebar-section-' . esc_attr( $this->slug ) . '" data-section="' . esc_attr( $this->slug ) . '">';
echo '<img src="' . esc_url( $this->icon ) . '">';
echo esc_html( $this->name );
echo '<i class="fa fa-angle-right wpforms-toggle-arrow"></i>';
if ( ! empty( $configured ) ) {
echo '<i class="fa fa-check-circle-o"></i>';
* Wrap the builder content with the required markup.
public function builder_output() {
$form_id = ! empty( $this->form_data['id'] ) ? $this->form_data['id'] : '';
<div class="wpforms-panel-content-section wpforms-panel-content-section-<?php echo esc_attr( $this->slug ); ?>"
id="<?php echo esc_attr( $this->slug ); ?>-provider">
<?php $this->builder_output_before(); ?>
<div class="wpforms-panel-content-section-title">
<?php echo esc_html( $this->name ); ?>
<button class="wpforms-provider-connections-add" data-form_id="<?php echo absint( $form_id ); ?>"
data-provider="<?php echo esc_attr( $this->slug ); ?>"
data-type="<?php echo esc_attr( strtolower( $this->type ) ); ?>">
printf( /* translators: %s - provider type. */
esc_html__( 'Add New %s', 'wpforms-lite' ),
FormBuilder::display_content_default_screen(
Status::init( $this->slug )->is_ready( $form_id ),
<div class="wpforms-provider-connections-wrap wpforms-clear">
<div class="wpforms-provider-connections">
<?php $this->builder_content(); ?>
<?php $this->builder_output_after(); ?>
* Optionally output content before the main builder output.
public function builder_output_before() {
* Optionally output content after the main builder output.
public function builder_output_after() {
/*************************************************************************
* Integrations tab methods - these methods relate to the settings page. *
*************************************************************************/
* Form fields to add a new provider account.
public function integrations_tab_new_form() {
* AJAX to disconnect a provider from the settings integrations tab.
public function integrations_tab_disconnect() {
check_ajax_referer( 'wpforms-admin', 'nonce' );
// Check for permissions.
if ( ! wpforms_current_user_can() ) {
'error' => esc_html__( 'You do not have permission', 'wpforms-lite' ),
if ( empty( $_POST['provider'] ) || empty( $_POST['key'] ) ) {
'error' => esc_html__( 'Missing data', 'wpforms-lite' ),
$providers = wpforms_get_providers_options();
if ( ! empty( $providers[ $_POST['provider'] ][ $_POST['key'] ] ) ) {
unset( $providers[ $_POST['provider'] ][ $_POST['key'] ] );
update_option( 'wpforms_providers', $providers );
'error' => esc_html__( 'Connection missing', 'wpforms-lite' ),
* AJAX to add a provider from the settings integrations tab.
public function integrations_tab_add() {
if ( $_POST['provider'] !== $this->slug ) { //phpcs:ignore
check_ajax_referer( 'wpforms-admin', 'nonce' );
// Check for permissions.
if ( ! wpforms_current_user_can() ) {
'error' => esc_html__( 'You do not have permission', 'wpforms-lite' ),
if ( empty( $_POST['data'] ) ) {
'error' => esc_html__( 'Missing data', 'wpforms-lite' ),
$data = wp_parse_args( $_POST['data'], [] );
$auth = $this->api_auth( $data, '' );
if ( is_wp_error( $auth ) ) {
'error' => esc_html__( 'Could not connect to the provider.', 'wpforms-lite' ),
'error_msg' => $auth->get_error_message(),
$account = '<li class="wpforms-clear">';
$account .= '<span class="label">' . sanitize_text_field( $data['label'] ) . '</span>';
$account .= '<span class="date">';
sprintf( /* translators: %1$s - Connection date. */
__( 'Connected on: %1$s', 'wpforms-lite' ),
wpforms_date_format( time(), '', true )
$account .= '<span class="remove"><a href="#" data-provider="' . $this->slug . '" data-key="' . esc_attr( $auth ) . '">' . esc_html__( 'Disconnect', 'wpforms-lite' ) . '</a></span>';
* Add provider to the Settings Integrations tab.
* @param array $active Array of active connections.
* @param array $settings Array of all connections settings.
public function integrations_tab_options( $active, $settings ) {
$connected = ! empty( $active[ $this->slug ] );
$accounts = ! empty( $settings[ $this->slug ] ) ? $settings[ $this->slug ] : [];
$class = $connected && $accounts ? 'connected' : '';
/* translators: %s - provider name. */
$title_connect_to = sprintf( esc_html__( 'Connect to %s', 'wpforms-lite' ), esc_html( $this->name ) );
// This lets us highlight a specific service by a special link.
if ( ! empty( $_GET['wpforms-integration'] ) ) { //phpcs:ignore
if ( $this->slug === $_GET['wpforms-integration'] ) { //phpcs:ignore
<div id="wpforms-integration-<?php echo esc_attr( $this->slug ); ?>" class="wpforms-settings-provider wpforms-clear <?php echo esc_attr( $this->slug ); ?> <?php echo esc_attr( $class ); ?>">
<div class="wpforms-settings-provider-header wpforms-clear" data-provider="<?php echo esc_attr( $this->slug ); ?>">
<div class="wpforms-settings-provider-logo">
<i title="<?php esc_attr_e( 'Show Accounts', 'wpforms-lite' ); ?>" class="fa fa-chevron-<?php echo esc_attr( $arrow ); ?>"></i>
<img src="<?php echo esc_url( $this->icon ); ?>">
<div class="wpforms-settings-provider-info">
<h3><?php echo esc_html( $this->name ); ?></h3>
printf( /* translators: %s - provider name. */
esc_html__( 'Integrate %s with WPForms', 'wpforms-lite' ),
<span class="connected-indicator green"><i class="fa fa-check-circle-o"></i> <?php esc_html_e( 'Connected', 'wpforms-lite' ); ?></span>
<div class="wpforms-settings-provider-accounts" id="provider-<?php echo esc_attr( $this->slug ); ?>">
<div class="wpforms-settings-provider-accounts-list">
if ( ! empty( $accounts ) ) {
foreach ( $accounts as $key => $account ) {
echo '<li class="wpforms-clear">';
echo '<span class="label">' . esc_html( $account['label'] ) . '</span>';
echo '<span class="date">';
sprintf( /* translators: %1$s - Connection date. */
__( 'Connected on: %1$s', 'wpforms-lite' ),
wpforms_date_format( (int) $account['date'], '', true )
echo '<span class="remove"><a href="#" data-provider="' . esc_attr( $this->slug ) . '" data-key="' . esc_attr( $key ) . '">' . esc_html__( 'Disconnect', 'wpforms-lite' ) . '</a></span>';
<p class="wpforms-settings-provider-accounts-toggle">
<a class="wpforms-btn wpforms-btn-md wpforms-btn-light-grey" href="#" data-provider="<?php echo esc_attr( $this->slug ); ?>">
<i class="fa fa-plus"></i> <?php esc_html_e( 'Add New Account', 'wpforms-lite' ); ?>
<div class="wpforms-settings-provider-accounts-connect">
<p><?php esc_html_e( 'Please fill out all of the fields below to add your new provider account.', 'wpforms-lite' ); ?></span></p>
<p class="wpforms-settings-provider-accounts-connect-fields">
<?php $this->integrations_tab_new_form(); ?>
<button type="submit" class="wpforms-btn wpforms-btn-md wpforms-btn-orange wpforms-settings-provider-connect"
data-provider="<?php echo esc_attr( $this->slug ); ?>" title="<?php echo esc_attr( $title_connect_to ); ?>">
<?php echo esc_html( $title_connect_to ); ?>
* Error wrapper for WP_Error.
public function error( $message = '', $parent = '0' ) {
return new WP_Error( $this->slug . '-error', $message );