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:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpUndefinedNamespaceInspection */
/** @noinspection PhpUndefinedClassInspection */
// phpcs:enable Generic.Commenting.DocComment.MissingShort
namespace WPForms\Integrations\Elementor;
use Elementor\Plugin;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
/**
* WPForms widget for Elementor page builder.
*
* @since 1.6.2
*/
class Widget extends Widget_Base {
/**
* Script dependencies.
*
* @since 1.9.1
*
* @return array
*/
public function get_script_depends(): array {
return [ 'wpforms-elementor' ];
}
/**
* Get widget name.
*
* Retrieve shortcode widget name.
*
* @since 1.6.2
*
* @return string Widget name.
*/
public function get_name() {
return 'wpforms';
}
/**
* Get widget title.
*
* Retrieve shortcode widget title.
*
* @since 1.6.2
*
* @return string Widget title.
*/
public function get_title() {
return __( 'WPForms', 'wpforms-lite' );
}
/**
* Get widget icon.
*
* Retrieve shortcode widget icon.
*
* @since 1.6.2
*
* @return string Widget icon.
*/
public function get_icon() {
return 'icon-wpforms';
}
/**
* Get widget keywords.
*
* Retrieve the list of keywords the widget belongs to.
*
* @since 1.6.2
*
* @return array Widget keywords.
*/
public function get_keywords() {
return [
'form',
'forms',
'wpforms',
'contact form',
'sullie',
'the dude',
];
}
/**
* Get widget categories.
*
* @since 1.6.2
*
* @return array Widget categories.
*/
public function get_categories() {
return [
'basic',
];
}
/**
* Register widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.6.2
*/
protected function register_controls() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
$this->content_controls();
}
/**
* Register content tab controls.
*
* @since 1.6.2
*
* @noinspection PhpUndefinedMethodInspection
* @noinspection HtmlUnknownTarget
*/
protected function content_controls() {
$this->start_controls_section(
'section_form',
[
'label' => esc_html__( 'Form', 'wpforms-lite' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$forms = $this->get_forms();
if ( empty( $forms ) ) {
$this->add_empty_forms_notice();
}
$this->add_control(
'form_id',
[
'label' => esc_html__( 'Form', 'wpforms-lite' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => $forms,
'default' => '0',
]
);
$this->add_control(
'edit_form',
[
'show_label' => false,
'type' => Controls_Manager::RAW_HTML,
'raw' => wp_kses( /* translators: %s - WPForms documentation link. */
__( 'Need to make changes? <a href="#">Edit the selected form.</a>', 'wpforms-lite' ),
[ 'a' => [] ]
),
'condition' => [
'form_id!' => '0',
],
]
);
$this->add_control(
'test_form_notice',
[
'show_label' => false,
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
wp_kses( /* translators: %s - WPForms documentation link. */
__( '<b>Heads up!</b> Don\'t forget to test your form. <a href="%s" target="_blank" rel="noopener noreferrer">Check out our complete guide!</a>', 'wpforms-lite' ),
[
'b' => [],
'br' => [],
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
'https://wpforms.com/docs/how-to-properly-test-your-wordpress-forms-before-launching-checklist/'
),
'condition' => [
'form_id!' => '0',
],
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
// The button opens the Form Builder, so it is only offered to users allowed to create forms.
if ( wpforms_current_user_can( 'create_forms' ) ) {
$this->add_control(
'add_form_btn',
[
'show_label' => false,
'label_block' => false,
'type' => Controls_Manager::BUTTON,
'button_type' => 'default',
'separator' => 'before',
'text' => '<b>+</b>' . esc_html__( 'New form', 'wpforms-lite' ),
'event' => 'elementorWPFormsAddFormBtnClick',
]
);
}
$this->add_legacy_styles_notice();
$this->end_controls_section();
$this->start_controls_section(
'section_display',
[
'label' => esc_html__( 'Display Options', 'wpforms-lite' ),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'form_id!' => '0',
],
]
);
$this->add_control(
'display_form_name',
[
'label' => esc_html__( 'Form Name', 'wpforms-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'wpforms-lite' ),
'label_off' => esc_html__( 'Hide', 'wpforms-lite' ),
'return_value' => 'yes',
'condition' => [
'form_id!' => '0',
],
]
);
$this->add_control(
'display_form_description',
[
'label' => esc_html__( 'Form Description', 'wpforms-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'wpforms-lite' ),
'label_off' => esc_html__( 'Hide', 'wpforms-lite' ),
'separator' => 'after',
'return_value' => 'yes',
'condition' => [
'form_id!' => '0',
],
]
);
$this->end_controls_section();
}
/**
* Add the notice explaining why the form selector has no options.
*
* A user who may not view forms gets an empty selector for a different reason than a user who
* has no forms yet, so the two states are worded differently.
*
* @since 2.0.1
*
* @noinspection PhpUndefinedMethodInspection
*/
private function add_empty_forms_notice() {
// The no-permission wording is composed of the two sentences the block editor already uses,
// so both surfaces read the same and share their translations.
$notice = $this->current_user_can_view_forms()
? __( '<b>You haven\'t created a form yet.</b><br> What are you waiting for?', 'wpforms-lite' )
: sprintf(
'<b>%1$s</b><br> %2$s',
__( 'You don’t have permission to use WPForms.', 'wpforms-lite' ),
__( 'Contact your site administrator for access.', 'wpforms-lite' )
);
$this->add_control(
'add_form_notice',
[
'show_label' => false,
'type' => Controls_Manager::RAW_HTML,
'raw' => wp_kses(
$notice,
[
'b' => [],
'br' => [],
]
),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info wpforms-elementor-no-forms-notice',
]
);
}
/**
* Add legacy styles notice.
*
* @since 1.9.6
*
* @noinspection PhpUndefinedMethodInspection
* @noinspection HtmlUnknownTarget
*/
private function add_legacy_styles_notice() {
$is_modern = wpforms_get_render_engine() === 'modern';
$is_full_styles = (int) wpforms_setting( 'disable-css', '1' ) === 1;
if ( ! $is_modern || ! $is_full_styles ) {
$notice_text = ! $is_modern
? __( 'Upgrade your forms to use our modern markup and unlock extensive style controls.', 'wpforms-lite' )
: __( 'Update your forms to use base and form theme styling and unlock extensive style controls.', 'wpforms-lite' );
$this->add_control(
'legacy_styling_notice',
[
'show_label' => false,
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
wp_kses( /* translators: %s - WPForms documentation link. */
__( '<b>Want to customize your form styles without editing CSS?</b> <p>%1$s</p> <a href="%2$s" target="_blank" rel="noopener noreferrer">Learn more</a>', 'wpforms-lite' ),
[
'b' => [],
'p' => [],
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
$notice_text,
wpforms_utm_link( 'https://wpforms.com/docs/styling-your-forms/', 'Elementor Widget Settings', 'Form Styles Documentation' )
),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning wpforms-legacy-styles-notice',
]
);
}
}
/**
* Render widget output.
*
* @since 1.6.2
*/
protected function render() {
if ( Plugin::$instance->editor->is_edit_mode() ) {
$this->render_edit_mode();
} else {
$this->render_frontend();
}
}
/**
* Render widget output in edit mode.
*
* @since 1.6.3.1
*
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
protected function render_edit_mode() {
$form_id = $this->get_settings_for_display( 'form_id' );
// Popup markup template.
echo wpforms_render( 'integrations/elementor/popup' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( count( $this->get_forms() ) < 2 ) {
// No forms block.
echo wpforms_render( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'integrations/elementor/no-forms',
[
'can_view_forms' => $this->current_user_can_view_forms(),
'can_create_forms' => wpforms_current_user_can( 'create_forms' ),
],
true
);
return;
}
if ( empty( $form_id ) ) {
// Render form selector.
echo wpforms_render( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'integrations/elementor/form-selector',
[
'forms' => $this->get_form_selector_options(),
],
true
);
return;
}
// Finally, render selected form.
$this->render_frontend();
}
/**
* Render widget output on the frontend.
*
* @since 1.6.3.1
*/
protected function render_frontend() {
// Render selected form.
$this->render_form();
}
/**
* Render widget as plain content.
*
* @since 1.6.2
*/
public function render_plain_content() {
$this->render_form();
}
/**
* Render a form.
*
* @since 1.8.3
*
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
public function render_form() {
wpforms_display(
$this->get_settings_for_display( 'form_id' ),
$this->get_settings_for_display( 'display_form_name' ) === 'yes',
$this->get_settings_for_display( 'display_form_description' ) === 'yes'
);
}
/**
* Determine whether the current user is entitled to view forms.
*
* Exposed on the widget because the form selector AJAX handler asks the same question before
* answering. See wpforms_current_user_can_view_forms() for the Lite and Pro difference.
*
* @since 2.0.1
*
* @return bool
*/
public function current_user_can_view_forms(): bool {
return wpforms_current_user_can_view_forms();
}
/**
* Get form list.
*
* @since 1.6.2
*
* @returns array Array of forms.
*/
public function get_forms() {
static $forms_list = [];
// This runs from the editor preview iframe and from admin-ajax, where the Pro owner-scoping
// filter ( wpforms_get_multiple_forms_args ) is not registered because the request's HTTP
// referer is not an admin one. Authorize and scope explicitly so the list never depends on
// a client-controlled header. The capability check precedes the memo because the memo is
// process-wide and not keyed by user.
if ( ! $this->current_user_can_view_forms() ) {
return [];
}
if ( ! empty( $forms_list ) ) {
return $forms_list;
}
// Reproduce the owner scoping the Pro filter would apply, since it is not registered here.
$args = wpforms_get_viewable_forms_args();
$forms_obj = wpforms()->obj( 'form' );
$forms = $forms_obj ? $forms_obj->get( '', $args ) : null;
if ( ! empty( $forms ) ) {
$forms_list[0] = esc_html__( 'Select a form', 'wpforms-lite' );
foreach ( $forms as $form ) {
$forms_list[ $form->ID ] = mb_strlen( $form->post_title ) > 100 ? mb_substr( $form->post_title, 0, 97 ) . '...' : $form->post_title;
}
}
return $forms_list;
}
/**
* Get form selector options.
*
* @since 1.6.2
*
* @returns string Rendered options for the select tag.
*/
public function get_form_selector_options() {
$forms = $this->get_forms();
$options = '';
foreach ( $forms as $form_id => $form ) {
$options .= sprintf(
'<option value="%d">%s</option>',
(int) $form_id,
esc_html( $form )
);
}
return $options;
}
}