More', 'wpforms-lite' ), 'more_link' => ! empty( $message['more_link'] ) ? $message['more_link'] : '', 'more_class' => ! empty( $message['more_class'] ) ? $message['more_class'] : '', 'cont_class' => ! empty( $message['cont_class'] ) ? $message['cont_class'] : '', 'enabled_title' => ! empty( $message['enabled']['title'] ) ? $message['enabled']['title'] : esc_html__( 'Did You Know?', 'wpforms-lite' ), 'enabled_desc' => ! empty( $message['enabled']['desc'] ) ? $message['enabled']['desc'] : '', 'enabled_more_title' => ! empty( $message['enabled']['more_title'] ) ? $message['enabled']['more_title'] : esc_html__( 'Learn More', 'wpforms-lite' ), 'enabled_more_link' => ! empty( $message['enabled']['more_link'] ) ? $message['enabled']['more_link'] : '', 'enabled_more_class' => ! empty( $message['enabled']['more_class'] ) ? $message['enabled']['more_class'] : '', 'enabled_cont_class' => ! empty( $message['enabled']['cont_class'] ) ? $message['enabled']['cont_class'] : '', ], true ); } /** * Generate Lite Connect entries information. * * @since 1.7.4 * * @return string */ private function get_lite_connect_entries_since_info() { $entries_count = LiteConnectIntegration::get_new_entries_count(); $enabled_since = LiteConnectIntegration::get_enabled_since(); $string = sprintf( esc_html( /* translators: %d - backed up entries count. */ _n( '%d entry backed up', '%d entries backed up', $entries_count, 'wpforms-lite' ) ), absint( $entries_count ) ); if ( ! empty( $enabled_since ) ) { $string .= ' '; $string .= esc_html( sprintf( /* translators: %1$s - time when Lite Connect was enabled. */ __( 'since %1$s', 'wpforms-lite' ), wpforms_date_format( $enabled_since, '', true ) ) ); } return $string; } } p_localize_script( 'wpforms-elementor', 'wpformsElementorVars', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'wpforms-elementor-integration' ), 'edit_form_url' => admin_url( 'admin.php?page=wpforms-builder&view=fields&form_id=' ), 'add_form_url' => admin_url( 'admin.php?page=wpforms-builder&view=setup' ), 'css_url' => WPFORMS_PLUGIN_URL . "assets/css/admin-integrations{$min}.css", 'debug' => wpforms_debug(), 'strings' => $strings, 'sizes' => [ 'field-size' => CSSVars::FIELD_SIZE, 'label-size' => CSSVars::LABEL_SIZE, 'button-size' => CSSVars::BUTTON_SIZE, ], ] ); } /** * Load an integration assets on the frontend. * * @since 1.6.2 */ public function frontend_assets() { if ( ElementorPlugin::$instance->preview->is_preview_mode() ) { return; } $min = wpforms_get_min_suffix(); wp_register_script( 'wpforms-elementor', WPFORMS_PLUGIN_URL . "assets/js/integrations/elementor/frontend{$min}.js", [ 'elementor-frontend', 'jquery', 'wp-util', 'wpforms' ], WPFORMS_VERSION, true ); wp_localize_script( 'wpforms-elementor', 'wpformsElementorVars', [ 'captcha_provider' => wpforms_setting( 'captcha-provider', 'recaptcha' ), 'recaptcha_type' => wpforms_setting( 'recaptcha-type', 'v2' ), ] ); } /** * Load assets in the elementor document. * * @since 1.6.2 */ public function editor_assets() { if ( empty( $_GET['action'] ) || $_GET['action'] !== 'elementor' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } $min = wpforms_get_min_suffix(); wp_enqueue_style( 'wpforms-integrations', WPFORMS_PLUGIN_URL . "assets/css/admin-integrations{$min}.css", null, WPFORMS_VERSION ); // Choices.js. wp_enqueue_script( 'choicesjs', WPFORMS_PLUGIN_URL . 'assets/lib/choices.min.js', [], '10.2.0', false ); } /** * Register WPForms Widget. * * @since 1.6.2 * @since 1.7.6 Added support for new registration method since 3.5.0. * @since 1.8.3 Added a condition for selecting the required widget instance. */ public function register_widget() { $widget_instance = $this->is_modern_widget() ? new WidgetModern() : new Widget(); version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ? ElementorPlugin::instance()->widgets_manager->register( $widget_instance ) : ElementorPlugin::instance()->widgets_manager->register_widget_type( $widget_instance ); } /** * Get form selector options. * * @since 1.6.2 */ public function ajax_get_form_selector_options() { check_ajax_referer( 'wpforms-elementor-integration', 'nonce' ); wp_send_json_success( ( new Widget() )->get_form_selector_options() ); } /** * Detect modern Widget. * * @since 1.8.3 */ protected function is_modern_widget() { return wpforms_get_render_engine() === 'modern' && (int) wpforms_setting( 'disable-css', '1' ) === 1; } /** * Disable the block render for pages built in Elementor. * * @since 1.8.8 * * @param bool $allow_render Whether to allow the block render. * * @return bool Whether to disable the block render. */ public function disable_gutenberg_block_render( $allow_render ): bool { $document = ElementorPlugin::$instance->documents->get( get_the_ID() ); if ( $document && $document->is_built_with_elementor() ) { return false; } return $allow_render; } /** * Disable honeypot on the preview panel. * * @since 1.9.0 * * @param bool|mixed $is_enabled True if the honeypot is enabled, false otherwise. * * @return bool Whether to disable the honeypot. * @noinspection PhpUndefinedFieldInspection */ public function filter_is_honeypot_enabled( $is_enabled ): bool { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $action = sanitize_key( $_REQUEST['action'] ?? '' ); if ( in_array( $action, [ 'elementor', 'elementor_ajax' ], true ) || ElementorPlugin::$instance->preview->is_preview_mode() ) { return false; } return (bool) $is_enabled; } }