| @@ -12,11 +12,20 @@ | ||
| 12 | 12 | |
| 13 | 13 | public function __construct() { |
| 14 | 14 | add_action( 'elementor/init', array( $this, 'setup_widgets' ) ); |
| 15 | 15 | add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) ); |
| 16 | - add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ), 11 ); | |
| 17 | 16 | add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_form_assets' ) ); |
| 18 | 17 | add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) ); |
| 18 | + | |
| 19 | + // compatibility with 3.7 | |
| 20 | + if ( | |
| 21 | + defined( 'ELEMENTOR_VERSION' ) && | |
| 22 | + version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) | |
| 23 | + ) { | |
| 24 | + add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); | |
| 25 | + } else { | |
| 26 | + add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) ); | |
| 27 | + } | |
| 19 | 28 | } |
| 20 | 29 | |
| 21 | 30 | public function enqueue_form_assets() { |
| 22 | 31 | wp_enqueue_style( 'jet-form-builder-frontend' ); |
| @@ -73,9 +82,14 @@ | ||
| 73 | 82 | } |
| 74 | 83 | |
| 75 | 84 | public function register_widgets( $manager ) { |
| 76 | 85 | foreach ( $this->_types as $widget ) { |
| 77 | - $manager->register_widget_type( $widget ); | |
| 86 | + // compatibility with 3.7 | |
| 87 | + if ( method_exists( $manager, 'register' ) ) { | |
| 88 | + $manager->register( $widget ); | |
| 89 | + } else { | |
| 90 | + $manager->register_widget_type( $widget ); | |
| 91 | + } | |
| 78 | 92 | } |
| 79 | 93 | } |
| 80 | 94 | |
| 81 | 95 | } |