Settings -> Integrations page. * * @package WPForms\Providers\Provider\Settings * @author WPForms * @since 1.4.7 * @license GPL-2.0+ * @copyright Copyright (c) 2018, WPForms LLC */ abstract class PageIntegrations implements PageIntegrationsInterface { /** * Get the Core loader class of a provider. * * @since 1.4.7 * * @var Core */ protected $core; /** * Integrations constructor. * * @since 1.4.7 * * @param Core $core Core provider object. */ public function __construct( Core $core ) { $this->core = $core; $this->ajax(); } /** * Process the default ajax functionality. * * @since 1.4.7 */ protected function ajax() { // Remove provider from Settings Integrations tab. \add_action( 'wp_ajax_wpforms_settings_provider_disconnect', array( $this, 'ajax_disconnect' ) ); // Add new provider from Settings Integrations tab. \add_action( 'wp_ajax_wpforms_settings_provider_add', array( $this, 'ajax_connect' ) ); } /** * @inheritdoc */ public function display( $active, $settings ) { $connected = ! empty( $active[ $this->core->slug ] ); $accounts = ! empty( $settings[ $this->core->slug ] ) ? $settings[ $this->core->slug ] : array(); $class = $connected && $accounts ? 'connected' : ''; $arrow = 'right'; // This lets us highlight a specific service by a special link. if ( ! empty( $_GET['wpforms-integration'] ) ) { //phpcs:ignore if ( $this->core->slug === $_GET['wpforms-integration'] ) { //phpcs:ignore $class .= ' focus-in'; $arrow = 'down'; } else { $class .= ' focus-out'; } } ?>

core->name ); ?>

core->name ) ); ?>

 
    $account ) { echo '
  • '; echo '' . \esc_html( $account['label'] ) . ''; /* translators: %s - Connection date. */ echo '' . \sprintf( \esc_html__( 'Connected on: %s', 'wpforms-lite' ), \date_i18n( \get_option( 'date_format' ), $account['date'] ) ) . ''; echo '' . \esc_html__( 'Disconnect', 'wpforms-lite' ) . ''; echo '
  • '; } } ?>
display_add_new(); ?>
core->name ); ?>

display_add_new_connection_fields(); ?>

\esc_html__( 'You do not have permission', 'wpforms-lite' ), ) ); } if ( empty( $_POST['provider'] ) || empty( $_POST['key'] ) ) { \wp_send_json_error( array( '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 ); \wp_send_json_success(); } else { \wp_send_json_error( array( 'error' => \esc_html__( 'Connection missing', 'wpforms-lite' ), ) ); } } /** * AJAX to add a provider from the settings integrations tab. * * @since 1.4.7 * * @return bool False when not own provider is processed. */ public function ajax_connect() { if ( $_POST['provider'] !== $this->core->slug ) { // phpcs:ignore return false; } // Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' ); // Check for permissions. if ( ! \wpforms_current_user_can() ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permissions.', 'wpforms-lite' ), ) ); } if ( empty( $_POST['data'] ) ) { \wp_send_json_error( array( 'error' => \esc_html__( 'Missing required data in payload.', 'wpforms-lite' ), ) ); } } }