| 1 |
<?php |
| 2 |
|
| 3 |
namespace HT_Builder\Elementor; |
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 5 |
|
| 6 |
/** |
| 7 |
* Scripts Manager |
| 8 |
*/ |
| 9 |
class HTBuilder_Scripts{ |
| 10 |
|
| 11 |
private static $instance = null; |
| 12 |
|
| 13 |
public static function instance() { |
| 14 |
if ( is_null( self::$instance ) ) { |
| 15 |
self::$instance = new self(); |
| 16 |
} |
| 17 |
return self::$instance; |
| 18 |
} |
| 19 |
|
| 20 |
function __construct(){ |
| 21 |
$this->init(); |
| 22 |
} |
| 23 |
|
| 24 |
public function init() { |
| 25 |
|
| 26 |
// Register Scripts |
| 27 |
add_action( 'init', [ $this, 'register_scripts' ] ); |
| 28 |
|
| 29 |
// Frontend Scripts |
| 30 |
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_frontend_scripts' ] ); |
| 31 |
|
| 32 |
// Editor Scripts |
| 33 |
add_action( 'elementor/editor/before_enqueue_scripts', [$this, 'enqueue_editor_scripts'] ); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Register Scripts |
| 38 |
*/ |
| 39 |
|
| 40 |
public function register_scripts(){ |
| 41 |
wp_register_script( |
| 42 |
'goodshare', |
| 43 |
HTBUILDER_PL_URL . 'assets/js/goodshare.min.js', |
| 44 |
array('jquery'), |
| 45 |
HTBUILDER_VERSION, |
| 46 |
TRUE |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Enqueue frontend scripts |
| 52 |
*/ |
| 53 |
public function enqueue_frontend_scripts() { |
| 54 |
|
| 55 |
// CSS |
| 56 |
wp_enqueue_style( |
| 57 |
'htbuilder-main', |
| 58 |
HTBUILDER_PL_URL . 'assets/css/htbuilder.css', |
| 59 |
NULL, |
| 60 |
HTBUILDER_VERSION |
| 61 |
); |
| 62 |
|
| 63 |
// JS |
| 64 |
wp_enqueue_script( 'masonry' ); |
| 65 |
wp_enqueue_script( |
| 66 |
'htbuilder-main', |
| 67 |
HTBUILDER_PL_URL . 'assets/js/htbuilder.js', |
| 68 |
array('jquery'), |
| 69 |
HTBUILDER_VERSION, |
| 70 |
TRUE |
| 71 |
); |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Enqueue Editor scripts |
| 77 |
*/ |
| 78 |
public function enqueue_editor_scripts(){} |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
HTBuilder_Scripts::instance(); |