| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Widgets; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class RegisterBitFormElementorWidget |
| 10 |
{ |
| 11 |
public function __construct() |
| 12 |
{ |
| 13 |
add_action('elementor/widgets/register', [$this, 'register_widgets']); |
| 14 |
add_action('elementor/editor/after_save', [$this, 'clearElementorCache']); |
| 15 |
add_action('update_option_elementor_css', [$this, 'clearElementorCache']); |
| 16 |
} |
| 17 |
|
| 18 |
public function register_widgets() |
| 19 |
{ |
| 20 |
$this->enqueueAssets(); |
| 21 |
|
| 22 |
if (file_exists(BITFORMS_PLUGIN_DIR_PATH . 'includes/Widgets/BitFormElementorWidget.php')) { |
| 23 |
require_once BITFORMS_PLUGIN_DIR_PATH . 'includes/Widgets/BitFormElementorWidget.php'; |
| 24 |
\Elementor\Plugin::instance()->widgets_manager->register(new BitFormElementorWidget()); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
private function enqueueAssets() |
| 29 |
{ |
| 30 |
// add_action('elementor/frontend/after_enqueue_styles', function () { |
| 31 |
// wp_enqueue_style('bitform-elementor-widget', BITFORMS_ASSET_URI . '/css/bitform-elementor-widget.css', [], '1.0.0'); |
| 32 |
// }); |
| 33 |
} |
| 34 |
|
| 35 |
public function clearElementorCache() |
| 36 |
{ |
| 37 |
if (class_exists('\Elementor\Plugin')) { |
| 38 |
\Elementor\Plugin::$instance->files_manager->clear_cache(); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|