mirror of
https://github.com/proelements/proelements.git
synced 2026-05-05 17:15:58 +00:00
v4.0.4
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\AtomicForm;
|
||||
|
||||
use ElementorPro\Base\Module_Base;
|
||||
use ElementorPro\Plugin;
|
||||
use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule;
|
||||
use Elementor\Core\Experiments\Manager as ExperimentsManager;
|
||||
use ElementorPro\Modules\AtomicForm\Widgets\Input;
|
||||
use ElementorPro\Modules\AtomicForm\Widgets\Label;
|
||||
use ElementorPro\Modules\AtomicForm\Widgets\Textarea;
|
||||
use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule;
|
||||
use Elementor\Widgets_Manager;
|
||||
use ElementorPro\Base\Module_Base;
|
||||
use ElementorPro\License\API;
|
||||
use ElementorPro\Modules\AtomicForm\Actions\Action_Runner;
|
||||
use ElementorPro\Modules\AtomicForm\Classes\Akismet;
|
||||
use ElementorPro\Modules\AtomicForm\Input\Input;
|
||||
use ElementorPro\Modules\AtomicForm\Label\Label;
|
||||
use ElementorPro\Modules\AtomicForm\Textarea\Textarea;
|
||||
use ElementorPro\Modules\AtomicForm\Submit_Button\Submit_Button;
|
||||
use ElementorPro\Modules\AtomicForm\Checkbox\Checkbox;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
@@ -17,6 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
class Module extends Module_Base {
|
||||
const MODULE_NAME = 'e-atomic-form';
|
||||
const EXPERIMENT_NAME = 'e_pro_atomic_form';
|
||||
const AKISMET_LICENSE_FEATURE_NAME = 'akismet';
|
||||
|
||||
public function get_name() {
|
||||
return self::MODULE_NAME;
|
||||
@@ -28,7 +34,7 @@ class Module extends Module_Base {
|
||||
'title' => esc_html__( 'Atomic Form', 'elementor-pro' ),
|
||||
'description' => esc_html__( 'Atomic form widgets. Note: This feature requires the "Atomic Widgets" experiment to be enabled.', 'elementor-pro' ),
|
||||
'hidden' => true,
|
||||
'default' => ExperimentsManager::STATE_INACTIVE,
|
||||
'default' => ExperimentsManager::STATE_ACTIVE,
|
||||
'release_status' => ExperimentsManager::RELEASE_STATUS_DEV,
|
||||
];
|
||||
}
|
||||
@@ -40,16 +46,28 @@ class Module extends Module_Base {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( class_exists( '\Akismet' ) && API::is_licence_has_feature( static::AKISMET_LICENSE_FEATURE_NAME, API::BC_VALIDATION_CALLBACK ) ) {
|
||||
$this->add_component( 'akismet', new Akismet() );
|
||||
}
|
||||
|
||||
add_filter(
|
||||
'elementor/widgets/register',
|
||||
fn( $widgets_manager ) => $this->register_widgets( $widgets_manager )
|
||||
);
|
||||
|
||||
add_action( 'elementor/frontend/after_enqueue_styles', fn () => $this->add_inline_styles() );
|
||||
|
||||
add_action( 'init', fn() => Action_Runner::init() );
|
||||
if ( Atomic_Form_Controller::is_form_submitted() ) {
|
||||
$this->add_component( 'atomic_ajax_handler', new Atomic_Form_Controller() );
|
||||
|
||||
do_action( 'elementor_pro/atomic_forms/form_submitted', $this );
|
||||
}
|
||||
}
|
||||
|
||||
private function is_experiment_active(): bool {
|
||||
return Plugin::elementor()->experiments->is_feature_active( self::EXPERIMENT_NAME )
|
||||
return version_compare( ELEMENTOR_VERSION, '4.0', '>=' )
|
||||
&& Plugin::elementor()->experiments->is_feature_active( self::EXPERIMENT_NAME )
|
||||
&& Plugin::elementor()->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME );
|
||||
}
|
||||
|
||||
@@ -57,12 +75,16 @@ class Module extends Module_Base {
|
||||
$widgets_manager->register( new Input() );
|
||||
$widgets_manager->register( new Label() );
|
||||
$widgets_manager->register( new Textarea() );
|
||||
$widgets_manager->register( new Submit_Button() );
|
||||
$widgets_manager->register( new Checkbox() );
|
||||
}
|
||||
|
||||
private function add_inline_styles() {
|
||||
// Default html textarea is resizable, but Elementor Atomic textarea is not resizable by default
|
||||
$inline_css = '.e-form-textarea-base:not([data-resizable]) { resize: none; }';
|
||||
wp_add_inline_style( 'elementor-frontend', $inline_css );
|
||||
$inline_styles = [
|
||||
Textarea::get_inline_styles(),
|
||||
Submit_Button::get_inline_styles(),
|
||||
];
|
||||
wp_add_inline_style( 'elementor-frontend', implode( ' ', $inline_styles ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user