JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpUndefinedConstantInspection */
namespace WPForms\Providers\Provider\Settings;
use WPForms\Providers\Provider\Core;
/**
* Class PageIntegrations handles the WPForms -> Settings -> Integrations page.
*
* @since 1.4.7
*/
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() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
// Remove provider from Settings Integrations tab.
add_action( "wp_ajax_wpforms_settings_provider_disconnect_{$this->core->slug}", [ $this, 'ajax_disconnect' ] );
// Add new provider from Settings Integrations tab.
add_action( "wp_ajax_wpforms_settings_provider_add_{$this->core->slug}", [ $this, 'ajax_connect' ] );
}
/**
* @inheritdoc
*/
public function display( $active, $settings ) {
$accounts = ! empty( $settings[ $this->core->slug ] ) ? $settings[ $this->core->slug ] : [];
$classes = $this->get_provider_classes( $active, $settings );
$arrow = in_array( 'focus-in', $classes, true ) ? 'down' : 'right';
?>
<div id="wpforms-integration-<?php echo esc_attr( $this->core->slug ); ?>"
class="wpforms-settings-provider wpforms-clear <?php echo esc_attr( $this->core->slug ); ?> <?php echo wpforms_sanitize_classes( $classes, true ); ?>">
<div class="wpforms-settings-provider-header wpforms-clear" data-provider="<?php echo esc_attr( $this->core->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->core->icon ); ?>" alt="icon">
</div>
<div class="wpforms-settings-provider-info">
<h3><?php echo esc_html( $this->core->name ); ?></h3>
<p>
<?php
printf( /* translators: %s - provider name. */
esc_html__( 'Integrate %s with WPForms', 'wpforms-lite' ),
esc_html( $this->core->name )
);
?>
</p>
<span class="connected-indicator green">
<i class="fa fa-check-circle-o"></i>
<span><?php esc_html_e( 'Connected', 'wpforms-lite' ); ?></span>
</span>
</div>
</div>
<div class="wpforms-settings-provider-accounts" id="provider-<?php echo esc_attr( $this->core->slug ); ?>">
<div class="wpforms-settings-provider-accounts-list">
<ul>
<?php
if ( ! empty( $accounts ) ) {
foreach ( $accounts as $account_id => $account ) {
if ( empty( $account_id ) ) {
continue;
}
$this->display_connected_account( $account_id, $account );
}
}
?>
</ul>
</div>
<?php $this->display_add_new(); ?>
</div>
</div>
<?php
}
/**
* Get provider classes.
*
* @since 1.8.6
*
* @param array $active Array of activated providers addons.
* @param array $settings Providers options.
*/
protected function get_provider_classes( $active, $settings ) {
$connected = ! empty( $active[ $this->core->slug ] );
$accounts = ! empty( $settings[ $this->core->slug ] ) ? $settings[ $this->core->slug ] : [];
$classes = [];
if ( $connected && $accounts ) {
$classes[] = 'connected';
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( empty( $_GET['wpforms-integration'] ) ) {
return $classes;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$classes[] = $this->core->slug === $_GET['wpforms-integration'] ? 'focus-in' : 'focus-out';
return $classes;
}
/**
* Display a connected account.
*
* @since 1.7.5
*
* @param string $account_id Account ID.
* @param array $account Account data.
*/
protected function display_connected_account( $account_id, $account ) {
$account_connected = ! empty( $account['date'] )
? wpforms_date_format( $account['date'], '', true )
: esc_html__( 'N/A', 'wpforms-lite' );
echo '<li>';
/**
* Allow adding markup before connected account item.
*
* @since 1.7.5
*
* @param string $account_id Account ID.
* @param array $account Account data.
*/
do_action( 'wpforms_providers_provider_settings_page_integrations_display_connected_account_item_before', $account_id, $account );
echo '<span class="label">';
echo ! empty( $account['label'] ) ? esc_html( $account['label'] ) : '<em>' . esc_html__( 'No Label', 'wpforms-lite' ) . '</em>';
echo '</span>';
echo '<span class="date">';
echo esc_html(
sprintf( /* translators: %1$s - Connection date. */
__( 'Connected on: %1$s', 'wpforms-lite' ),
$account_connected
)
);
if ( defined( 'WPFORMS_DEBUG' ) && WPFORMS_DEBUG ) {
$this->display_account_id_debug( $account_id );
$this->display_expires_in_debug( $account );
}
echo '</span>';
echo(
'<span class="remove"><a href="#" data-provider="' . esc_attr( $this->core->slug ) . '" data-key="' .
esc_attr( $account_id ) . '">' . esc_html__( 'Disconnect', 'wpforms-lite' ) . '</a></span>'
);
/**
* Allow adding markup after connected account item.
*
* @since 1.7.5
*
* @param string $account_id Account ID.
* @param array $account Account data.
*/
do_action( 'wpforms_providers_provider_settings_page_integrations_display_connected_account_item_after', $account_id, $account );
echo '</li>';
}
/**
* Display the account ID for debugging purposes.
*
* @since 1.9.5
*
* @param mixed $account_id Account ID to display. If null, it displays 'no_id'.
*/
protected function display_account_id_debug( $account_id ): void {
echo ' <br />ID: ' . esc_html( $account_id ?? 'no_id' );
}
/**
* Display the expiration information in debug mode.
*
* @since 1.9.5
*
* @param array $account The account information containing the 'expires_in' timestamp.
*/
protected function display_expires_in_debug( array $account ): void {
if ( empty( $account['expires_in'] ) ) {
return;
}
$valid_until_timestamp = $account['expires_in'];
if ( $valid_until_timestamp > time() ) {
$format = sprintf( '%s \a\t %s', get_option( 'date_format' ), get_option( 'time_format' ) );
$valid_until = wpforms_datetime_format( $valid_until_timestamp, $format, true );
echo ' <br />Valid until: ' . esc_html( $valid_until ?? 'no_valid_until' );
}
}
/**
* Any new connection should be added.
* So display the content of that.
*
* @since 1.4.7
*/
protected function display_add_new() {
?>
<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->core->slug ); ?>">
<i class="fa fa-plus"></i> <?php esc_html_e( 'Add New Account', 'wpforms-lite' ); ?>
</a>
</p>
<div class="wpforms-settings-provider-accounts-connect">
<form>
<p class="wpforms-settings-provider-accounts-connect-general-description">
<?php esc_html_e( 'Please fill out all of the fields below to add your new provider account.', 'wpforms-lite' ); ?>
</p>
<div class="wpforms-settings-provider-accounts-connect-fields">
<?php $this->display_add_new_connection_fields(); ?>
</div>
<?php $this->display_add_new_connection_submit_button(); ?>
</form>
</div>
<?php
}
/**
* Some providers may or may not have fields.
*
* @since 1.4.7
*/
protected function display_add_new_connection_fields() {
}
/**
* Some providers may modify the form button and add their form handler.
*
* @since 1.7.4
*/
protected function display_add_new_connection_submit_button() {
/* translators: %s - provider name. */
$title = sprintf( __( 'Connect to %s', 'wpforms-lite' ), $this->core->name );
?>
<button type="submit" class="wpforms-btn wpforms-btn-md wpforms-btn-orange wpforms-settings-provider-connect"
data-provider="<?php echo esc_attr( $this->core->slug ); ?>" title="<?php echo esc_attr( $title ); ?>">
<?php echo esc_html( $title ); ?>
</button>
<?php
}
/**
* AJAX to disconnect a provider from the settings integrations tab.
*
* @since 1.4.7
*/
public function ajax_disconnect() {
// Run a security check.
if ( ! check_ajax_referer( 'wpforms-admin', 'nonce', false ) ) {
wp_send_json_error(
[
'error_msg' => esc_html__( 'Your session expired. Please reload the page.', 'wpforms-lite' ),
]
);
}
// Check for permissions.
if ( ! wpforms_current_user_can() ) {
wp_send_json_error(
[
'error_msg' => esc_html__( 'You do not have permission.', 'wpforms-lite' ),
]
);
}
if ( empty( $_POST['provider'] ) || empty( $_POST['key'] ) ) {
wp_send_json_error(
[
'error_msg' => 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(
[
'error_msg' => esc_html__( 'Connection missing.', 'wpforms-lite' ),
]
);
}
}
/**
* AJAX to add a provider from the settings integrations tab.
*
* @since 1.4.7
*/
public function ajax_connect() {
// Run a security check.
if ( ! check_ajax_referer( 'wpforms-admin', 'nonce', false ) ) {
wp_send_json_error(
[
'error_msg' => esc_html__( 'Your session expired. Please reload the page.', 'wpforms-lite' ),
]
);
}
// Check for permissions.
if ( ! wpforms_current_user_can() ) {
wp_send_json_error(
[
'error_msg' => esc_html__( 'You do not have permissions.', 'wpforms-lite' ),
]
);
}
if ( empty( $_POST['data'] ) ) {
wp_send_json_error(
[
'error_msg' => esc_html__( 'Missing required data in payload.', 'wpforms-lite' ),
]
);
}
}
}