assets
3 weeks ago
theme-hooks
4 years ago
views
1 year ago
activator.php
2 years ago
cpt-api.php
4 years ago
cpt-hooks.php
2 years ago
cpt.php
1 year ago
init.php
3 weeks ago
init.php
70 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Modules\Header_Footer; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | class Init { |
| 7 | |
| 8 | public $dir; |
| 9 | |
| 10 | public $url; |
| 11 | |
| 12 | public function __construct() { |
| 13 | |
| 14 | // get current directory path |
| 15 | $this->dir = dirname( __FILE__ ) . '/'; |
| 16 | |
| 17 | // get current module's url |
| 18 | $this->url = \ElementsKit_Lite::plugin_url() . 'modules/header-footer/'; |
| 19 | |
| 20 | // enqueue scripts |
| 21 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
| 22 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 23 | |
| 24 | // include all necessary files |
| 25 | $this->include_files(); |
| 26 | |
| 27 | add_action( 'admin_footer', array( $this, 'modal_view' ) ); |
| 28 | |
| 29 | Cpt_Hooks::instance(); |
| 30 | Activator::instance(); |
| 31 | } |
| 32 | |
| 33 | public function include_files() { |
| 34 | include_once $this->dir . 'cpt.php'; |
| 35 | include_once $this->dir . 'cpt-api.php'; |
| 36 | } |
| 37 | |
| 38 | public function modal_view() { |
| 39 | $screen = get_current_screen(); |
| 40 | if ( $screen->id == 'edit-elementskit_template' ) { |
| 41 | include_once $this->dir . 'views/modal-editor.php'; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public function enqueue_styles() { |
| 46 | $screen = get_current_screen(); |
| 47 | if ( $screen->id == 'edit-elementskit_template' ) { |
| 48 | wp_enqueue_style( 'select2', \ElementsKit_Lite::plugin_url() . 'assets/libs/select2/select2.min.css', [], \ElementsKit_Lite::version() ); |
| 49 | wp_enqueue_style( 'elementskit-menu-admin-style', $this->url . 'assets/css/admin-style.css', false, \ElementsKit_Lite::version() ); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | public function enqueue_scripts() { |
| 54 | $screen = get_current_screen(); |
| 55 | if ( $screen->id == 'edit-elementskit_template' ) { |
| 56 | wp_enqueue_script( 'select2', \ElementsKit_Lite::plugin_url() . 'assets/libs/select2/select2.min.js', array( 'jquery' ), true, \ElementsKit_Lite::version() ); |
| 57 | wp_enqueue_script( 'elementskit-menu-admin-script', $this->url . 'assets/js/admin-script.js', array( 'jquery' ), true, \ElementsKit_Lite::version() ); |
| 58 | wp_localize_script( |
| 59 | 'elementskit-menu-admin-script', |
| 60 | 'ekit_headerfooter_i18n', |
| 61 | array( |
| 62 | 'all' => esc_html__( 'All', 'elementskit-lite' ), |
| 63 | 'header' => esc_html__( 'Header', 'elementskit-lite' ), |
| 64 | 'footer' => esc_html__( 'Footer', 'elementskit-lite' ), |
| 65 | ) |
| 66 | ); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 |