| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit; |
| 3 |
|
| 4 |
final class Elementor_ULTP_Extension { |
| 5 |
|
| 6 |
private static $_instance = null; |
| 7 |
|
| 8 |
public static function instance() { |
| 9 |
if (is_null( self::$_instance ) ) { |
| 10 |
self::$_instance = new self(); |
| 11 |
} |
| 12 |
return self::$_instance; |
| 13 |
} |
| 14 |
|
| 15 |
public function __construct() { |
| 16 |
$this->init(); |
| 17 |
} |
| 18 |
|
| 19 |
public function init() { |
| 20 |
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] ); |
| 21 |
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'widget_scripts' ] ); |
| 22 |
add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'widget_styles' ] ); |
| 23 |
} |
| 24 |
|
| 25 |
public function widget_styles() { |
| 26 |
wp_register_style('ultp-style', ULTP_URL.'assets/css/style.min.css', array(), ultimate_post()->get_setting('save_version') ); |
| 27 |
wp_enqueue_style('ultp-style'); |
| 28 |
} |
| 29 |
|
| 30 |
public function widget_scripts() { |
| 31 |
wp_register_script('ultp-script', ULTP_URL.'assets/js/ultp.min.js', array('jquery'), ultimate_post()->get_setting('save_version'), true); |
| 32 |
wp_enqueue_script('ultp-script'); |
| 33 |
wp_localize_script('ultp-script', 'ultp_data_frontend', array( |
| 34 |
'url' => ULTP_URL, |
| 35 |
'ajax' => admin_url('admin-ajax.php'), |
| 36 |
'security' => wp_create_nonce('ultp-nonce') |
| 37 |
)); |
| 38 |
} |
| 39 |
|
| 40 |
public function includes() { |
| 41 |
require_once ULTP_PATH.'addons/elementor/Elementor_Widget.php'; |
| 42 |
} |
| 43 |
|
| 44 |
public function register_widgets() { |
| 45 |
$this->includes(); |
| 46 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Gutenberg_Post_Blocks_Widget() ); |
| 47 |
} |
| 48 |
} |